CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtGen Class Reference

#include <EvtGen.hh>

Public Member Functions

 EvtGen (const char *const decayName, const char *const pdtTableName, EvtRandomEngine *randomEngine=0, EvtAbsRadCorr *isrEngine=0)
 
 ~EvtGen ()
 
void readUDecay (const char *const udecay_name)
 
void generateDecay (int stdhepid, EvtVector4R P, EvtVector4R D, EvtStdHep *evtStdHep, EvtSpinDensity *spinDensity=0)
 
void generateDecay (EvtParticle *p)
 
void generateEvent (int stdhepid, HepLorentzVector P, HepLorentzVector D)
 
void generateEvent (EvtParticle *p, HepLorentzVector D)
 

Detailed Description

Definition at line 46 of file EvtGen.hh.

Constructor & Destructor Documentation

◆ EvtGen()

EvtGen::EvtGen ( const char *const  decayName,
const char *const  pdtTableName,
EvtRandomEngine randomEngine = 0,
EvtAbsRadCorr isrEngine = 0 
)

Definition at line 77 of file EvtGen.cc.

80 {
81
82
83 report(INFO,"EvtGen") << "Initializing EvtGen"<<endl;
84
85 report(INFO,"EvtGen") << "Storing known decay models"<<endl;
86 EvtModelReg dummy;
87
88 report(INFO,"EvtGen") << "Main decay file name :"<<decayName<<endl;
89 report(INFO,"EvtGen") << "PDT table file name :"<<pdtTableName<<endl;
90
91 report(INFO,"EvtGen") << "Initializing RadCorr=PHOTOS"<<endl;
92 if (isrEngine==0){
93 static EvtPHOTOS defaultRadCorrEngine;
94 EvtRadCorr::setRadCorrEngine(&defaultRadCorrEngine);
95 report(INFO,"EvtGen") <<"No RadCorr engine given in "
96 <<"EvtGen::EvtGen constructor, "
97 <<"will use default EvtPHOTOS."<<endl;
98 }
99 else{
101 }
102
103 _pdl.readPDT(pdtTableName);
104
105
106 ifstream indec;
107
109
110 if (randomEngine==0){
111 static EvtRandomEngine defaultRandomEngine;
112 EvtRandom::setRandomEngine(&defaultRandomEngine);
113 report(INFO,"EvtGen") <<"No random engine given in "
114 <<"EvtGen::EvtGen constructor, "
115 <<"will use default EvtRandomEngine."<<endl;
116 }
117 else{
118 EvtRandom::setRandomEngine(randomEngine);
119 }
120
121 report(INFO,"EvtGen") << "Done initializing EvtGen"<<endl;
122
123}
ostream & report(Severity severity, const char *facility)
Definition: EvtReport.cc:36
@ INFO
Definition: EvtReport.hh:52
static void readDecayFile(const std::string dec_name)
void readPDT(const std::string fname)
Definition: EvtPDL.cc:63
static void setRadCorrEngine(EvtAbsRadCorr *isrEngine)
Definition: EvtRadCorr.cc:47
static void setRandomEngine(EvtRandomEngine *randomEngine)
Definition: EvtRandom.cc:36
std::ifstream ifstream
Definition: bpkt_streams.h:44

◆ ~EvtGen()

EvtGen::~EvtGen ( )

Definition at line 64 of file EvtGen.cc.

64 {
65
66 //This is a bit uggly, should not do anything
67 //in a destructor. This will fail if EvtGen is made a static
68 //because then this destructor might be called _after_
69 //the destructoin of objects that it depends on, e.g., EvtPDL.
70
71 if (getenv("EVTINFO")){
73 }
74
75}
static void printSummary()

Member Function Documentation

◆ generateDecay() [1/2]

void EvtGen::generateDecay ( EvtParticle p)

Definition at line 183 of file EvtGen.cc.

183 {
184
185 int times=0;
186 do{
187 times+=1;
189 p->decay();
190
191 //ok then finish.
192 if ( EvtStatus::getRejectFlag()==0 ) {
193 times=0;
194 }
195 else{
196
197 int ii;
198 for (ii=0;ii<p->getNDaug();ii++){
199 EvtParticle *temp=p->getDaug(ii);
200 temp->deleteTree();
201 }
202 p->resetFirstOrNot();
203 p->resetNDaug();
204
205 }
206
207 if ( times==10000) {
208 report(ERROR,"EvtGen") << "Your event has been rejected 10000 times!"<<endl;
209 report(ERROR,"EvtGen") << "Will now abort."<<endl;
210 ::abort();
211 times=0;
212 }
213 } while (times);
214
215}
@ ERROR
Definition: EvtReport.hh:49
void resetNDaug()
Definition: EvtParticle.hh:255
void decay()
Definition: EvtParticle.cc:404
void resetFirstOrNot()
Definition: EvtParticle.cc:77
int getNDaug() const
Definition: EvtParticle.cc:125
EvtParticle * getDaug(int i)
Definition: EvtParticle.cc:85
void deleteTree()
Definition: EvtParticle.cc:555
static void initRejectFlag()
Definition: EvtStatus.hh:40
static int getRejectFlag()
Definition: EvtStatus.hh:42

◆ generateDecay() [2/2]

void EvtGen::generateDecay ( int  stdhepid,
EvtVector4R  P,
EvtVector4R  D,
EvtStdHep evtStdHep,
EvtSpinDensity spinDensity = 0 
)

Definition at line 152 of file EvtGen.cc.

156 {
157
158
159 EvtParticle *p;
160
161 if(spinDensity==0){
163 }
164 else{
166 P,*spinDensity);
167 }
168
169 generateDecay(p);
170 // p->Decay();
171
172 evtStdHep->init();
173
174 p->makeStdHep(*evtStdHep);
175
176 evtStdHep->translate(D);
177
178 p->deleteTree();
179
180
181}
double P(RecMdcKalTrack *trk)
void generateDecay(int stdhepid, EvtVector4R P, EvtVector4R D, EvtStdHep *evtStdHep, EvtSpinDensity *spinDensity=0)
Definition: EvtGen.cc:152
static EvtId evtIdFromStdHep(int stdhep)
Definition: EvtPDL.cc:244
static EvtParticle * particleFactory(EvtSpinType::spintype spinType)
void makeStdHep(EvtStdHep &stdhep, EvtSecondary &secondary, EvtId *stable_parent_ihep)
Definition: EvtParticle.cc:757
void translate(EvtVector4R d)
Definition: EvtStdHep.cc:69
void init()
Definition: EvtStdHep.cc:33

Referenced by generateDecay(), and generateEvent().

◆ generateEvent() [1/2]

void EvtGen::generateEvent ( EvtParticle p,
HepLorentzVector  D 
)

Definition at line 241 of file EvtGen.cc.

241 {
242 int i;
243 static int nevent=0;
244 nevent++;
245
246 static EvtStdHep evtstdhep;
247 // static EvtSecondary evtsecondary;
248
249 int j;
250 int istat;
251 int partnum;
252 double px,py,pz,e,m;
253 double x,y,z,t;
254
255 EvtVector4R p4,x4;
256 generateDecay(root_part);
257 // root_part->Decay();
258 int npart=0;
259 EvtId list_of_stable[10];
260 EvtParticle* stable_parent[10];
261
262
263 list_of_stable[0]=EvtId(-1,-1);
264 stable_parent[0]=0;
265
266 evtstdhep.init();
267 // evtsecondary.init();
268 // root_part->makeStdHep(evtstdhep,evtsecondary,list_of_stable);
269 root_part->makeStdHep(evtstdhep);
270
271 //report(INFO,"EvtGen") << evtstdhep;
272 //report(INFO,"EvtGen") << evtsecondary;
273
274 npart=evtstdhep.getNPart();
275 for(i=0;i<evtstdhep.getNPart();i++){
276
277 j=i+1;
278
279 int jmotherfirst=evtstdhep.getFirstMother(i)+1;
280 int jmotherlast=evtstdhep.getLastMother(i)+1;
281 int jdaugfirst=evtstdhep.getFirstDaughter(i)+1;
282 int jdauglast=evtstdhep.getLastDaughter(i)+1;
283
284 partnum=evtstdhep.getStdHepID(i);
285
286 istat=evtstdhep.getIStat(i);
287
288 p4=evtstdhep.getP4(i);
289 x4=evtstdhep.getX4(i);
290 px=p4.get(1);
291 py=p4.get(2);
292 pz=p4.get(3);
293 e=p4.get(0);
294
295 x=x4.get(1)+D.x();
296 y=x4.get(2)+D.y();
297 z=x4.get(3)+D.z();
298 t=x4.get(0)+D.t();
299
300 m=p4.mass();
301
302 begevtgenstore_(&j,&nevent,&npart,&istat,
303 &partnum,&jmotherfirst,&jmotherlast,
304 &jdaugfirst,&jdauglast,
305 &px,&py,&pz,&e,
306 &m,&x,&y,&z,&t);
307 }
308
309}
Double_t x[10]
void begevtgenstore_(int *, int *, int *, int *, int *, int *, int *, int *, int *, double *, double *, double *, double *, double *, double *, double *, double *, double *)
Definition: EvtId.hh:27
int getIStat(int i)
Definition: EvtStdHep.hh:45
int getFirstMother(int i)
Definition: EvtStdHep.hh:39
int getLastMother(int i)
Definition: EvtStdHep.hh:40
int getLastDaughter(int i)
Definition: EvtStdHep.hh:42
int getStdHepID(int i)
Definition: EvtStdHep.hh:44
int getFirstDaughter(int i)
Definition: EvtStdHep.hh:41
int getNPart()
Definition: EvtStdHep.cc:37
EvtVector4R getP4(int i)
Definition: EvtStdHep.hh:47
EvtVector4R getX4(int i)
Definition: EvtStdHep.hh:48
double mass() const
Definition: EvtVector4R.cc:39
double get(int i) const
Definition: EvtVector4R.hh:179
int t()
Definition: t.c:1

◆ generateEvent() [2/2]

void EvtGen::generateEvent ( int  stdhepid,
HepLorentzVector  P,
HepLorentzVector  D 
)

Definition at line 219 of file EvtGen.cc.

219 {
220
221 EvtParticle *root_part;
222 EvtVectorParticle *vector_part;
223
224 vector_part=new EvtVectorParticle;
225 EvtVector4R p_init;
226
227 p_init.set(P.t(),P.x(),P.y(),P.z());
228
229 vector_part->init(EvtPDL::evtIdFromStdHep(stdhepid),p_init);
230
231 root_part=(EvtParticle *)vector_part;
232
233 root_part->setVectorSpinDensity();
234
235 generateEvent(root_part,D);
236
237 root_part->deleteTree();
238
239}
void generateEvent(int stdhepid, HepLorentzVector P, HepLorentzVector D)
Definition: EvtGen.cc:219
void setVectorSpinDensity()
Definition: EvtParticle.cc:138
void set(int i, double d)
Definition: EvtVector4R.hh:183
void init(EvtId part_n, double e, double px, double py, double pz)

Referenced by generateEvent().

◆ readUDecay()

void EvtGen::readUDecay ( const char *const  udecay_name)

Definition at line 126 of file EvtGen.cc.

126 {
127
128 ifstream indec;
129
130 if ( uDecayName[0] == 0) {
131 report(INFO,"EvtGen") << "Is not reading a user decay file!"<<endl;
132 }
133 else{
134 indec.open(uDecayName);
135 if (indec) {
137
138 report(INFO,"EvtGen") << "Reading "<<uDecayName
139 <<" to override decay table."<<endl;
140 }
141 else{
142
143 report(INFO,"EvtGen") << "Can not find UDECAY file '"
144 <<uDecayName<<"'. Stopping"<<endl;
145 ::abort();
146 }
147 }
148
149}

Referenced by EvtDecay::initialize().


The documentation for this class was generated from the following files: