-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathPrimaryGenerator.h
More file actions
142 lines (111 loc) · 4.78 KB
/
PrimaryGenerator.h
File metadata and controls
142 lines (111 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \author R+Preghenella - June 2017
#ifndef ALICEO2_EVENTGEN_PRIMARYGENERATOR_H_
#define ALICEO2_EVENTGEN_PRIMARYGENERATOR_H_
#include "FairPrimaryGenerator.h"
#include "DataFormatsCalibration/MeanVertexObject.h"
#include "SimConfig/SimConfig.h"
class TFile;
class TTree;
class TString;
namespace o2
{
namespace dataformats
{
class MCEventHeader;
}
} // namespace o2
namespace o2
{
namespace eventgen
{
/**
** custom primary generator in order to be able to deal with
** specific O2 matters, like initialisation, generation, ...
**/
class PrimaryGenerator : public FairPrimaryGenerator
{
public:
/** default constructor **/
PrimaryGenerator() = default;
/** destructor **/
~PrimaryGenerator() override;
/** Public method GenerateEvent
To be called at the beginning of each event from FairMCApplication.
Generates an event vertex and calls the ReadEvent methods from the
registered generators.
*@param pStack The particle stack
*@return kTRUE if successful, kFALSE if not
**/
Bool_t GenerateEvent(FairGenericStack* pStack) override;
/** ALICE-o2 AddTrack with mother/daughter indices **/
void AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t pz,
Double_t vx, Double_t vy, Double_t vz,
Int_t mother1 = -1, Int_t mother2 = -1,
Int_t daughter1 = -1, Int_t daughter2 = -1,
Bool_t wanttracking = true,
Double_t e = -9e9, Double_t tof = 0.,
Double_t weight = 0., TMCProcess proc = kPPrimary, Int_t generatorStatus = 0);
/** override, to set encoded status code correctly **/
void AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t pz,
Double_t vx, Double_t vy, Double_t vz,
Int_t parent = -1, Bool_t wanttracking = true,
Double_t e = -9e9, Double_t tof = 0.,
Double_t weight = 0., TMCProcess proc = kPPrimary) override;
/** initialize the generator **/
Bool_t Init() override;
/** Public embedding methods **/
Bool_t embedInto(TString fname);
/// sets the embedding index
void setEmbedIndex(int idx) { mEmbedIndex = idx; }
void setExternalVertexForNextEvent(double x, double y, double z);
// sets the vertex mode; if mode is kCCDB, a valid MeanVertexObject pointer must be given at the same time
void setVertexMode(o2::conf::VertexMode const& mode, o2::dataformats::MeanVertexObject const* obj = nullptr);
// if we apply vertex smearing
void setApplyVertex(bool onoff) { mApplyVertex = onoff; }
// set identifier and description
void setGeneratorId(int id) { mGeneratorId = id; }
void setGeneratorDescription(std::string const& desc) { mGeneratorDescription = desc; }
protected:
/** copy constructor **/
// PrimaryGenerator(const PrimaryGenerator&) = default;
/** operator= **/
// PrimaryGenerator& operator=(const PrimaryGenerator&) = default;
/** set interaction diamond position **/
void setInteractionDiamond(const Double_t* xyz, const Double_t* sigmaxyz);
/** set interaction vertex position **/
void setInteractionVertex(const o2::dataformats::MCEventHeader* event);
/** generate and fix interaction vertex **/
void fixInteractionVertex();
float mExternalVertexX = 0, mExternalVertexY = 0, mExternalVertexZ = 0; // holding vertex fixed from outside
bool mHaveExternalVertex = false; // true of user fixed external vertex from outside for next event
/** embedding members **/
TFile* mEmbedFile = nullptr;
TTree* mEmbedTree = nullptr;
Int_t mEmbedEntries = 0;
Int_t mEmbedIndex = 0;
o2::dataformats::MCEventHeader* mEmbedEvent = nullptr;
bool mApplyVertex = true;
o2::conf::VertexMode mVertexMode = o2::conf::VertexMode::kDiamondParam; // !vertex mode
std::unique_ptr<o2::dataformats::MeanVertexObject> mMeanVertex;
private:
void setGeneratorInformation();
// generator identifier and description
int mGeneratorId = -1;
std::string mGeneratorDescription;
ClassDefOverride(PrimaryGenerator, 3);
}; /** class PrimaryGenerator **/
/*****************************************************************/
/*****************************************************************/
} /* namespace eventgen */
} /* namespace o2 */
#endif /* ALICEO2_EVENTGEN_PRIMARYGENERATOR_H_ */