StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
example1.cc
1 //
2 // Sample test program for running EvtGen
3 //
4 
5 #include "EvtGen/EvtGen.hh"
6 
7 #include "EvtGenBase/EvtParticle.hh"
8 #include "EvtGenBase/EvtParticleFactory.hh"
9 #include "EvtGenBase/EvtPatches.hh"
10 #include "EvtGenBase/EvtPDL.hh"
11 #include "EvtGenBase/EvtRandom.hh"
12 #include "EvtGenBase/EvtReport.hh"
13 #include "EvtGenBase/EvtHepMCEvent.hh"
14 #include "EvtGenBase/EvtSimpleRandomEngine.hh"
15 #include "EvtGenBase/EvtMTRandomEngine.hh"
16 #include "EvtGenBase/EvtAbsRadCorr.hh"
17 #include "EvtGenBase/EvtDecayBase.hh"
18 
19 #ifdef EVTGEN_EXTERNAL
20 #include "EvtGenExternal/EvtExternalGenList.hh"
21 #endif
22 
23 #include <iostream>
24 #include <string>
25 #include <list>
26 
27 int main(int argc, char** argv) {
28 
29  EvtParticle* parent(0);
30 
31  // Define the random number generator
32  EvtRandomEngine* eng = 0;
33 
34 #ifdef EVTGEN_CPP11
35  // Use the Mersenne-Twister generator (C++11 only)
36  eng = new EvtMTRandomEngine();
37 #else
38  eng = new EvtSimpleRandomEngine();
39 #endif
40 
41  EvtRandom::setRandomEngine(eng);
42 
43  EvtAbsRadCorr* radCorrEngine = 0;
44  std::list<EvtDecayBase*> extraModels;
45 
46 #ifdef EVTGEN_EXTERNAL
47  EvtExternalGenList genList;
48  radCorrEngine = genList.getPhotosModel();
49  extraModels = genList.getListOfModels();
50 #endif
51 
52  //Initialize the generator - read in the decay table and particle properties
53  EvtGen myGenerator("../DECAY_2010.DEC","../evt.pdl", eng,
54  radCorrEngine, &extraModels);
55 
56  //If I wanted a user decay file, I would read it in now.
57  //myGenerator.readUDecay("../user.dec");
58 
59  static EvtId UPS4 = EvtPDL::getId(std::string("Upsilon(4S)"));
60 
61  int nEvents(100);
62 
63  // Loop to create nEvents, starting from an Upsilon(4S)
64  int i;
65  for (i = 0; i < nEvents; i++) {
66 
67  std::cout<<"Event number "<<i<<std::endl;
68 
69  // Set up the parent particle
70  EvtVector4R pInit(EvtPDL::getMass(UPS4), 0.0, 0.0, 0.0);
71  parent = EvtParticleFactory::particleFactory(UPS4, pInit);
72  parent->setVectorSpinDensity();
73 
74  // Generate the event
75  myGenerator.generateDecay(parent);
76 
77  // Write out the results
78  EvtHepMCEvent theEvent;
79  theEvent.constructEvent(parent);
80  HepMC::GenEvent* genEvent = theEvent.getEvent();
81  genEvent->print(std::cout);
82 
83  parent->deleteTree();
84 
85  }
86 
87  delete eng;
88  return 0;
89 
90 }
The GenEvent class is the core of HepMC.
Definition: GenEvent.h:155
Definition: EvtId.hh:27
Definition: EvtGen.hh:46
void print(std::ostream &ostr=std::cout) const
dumps to ostr
Definition: GenEvent.cc:277