StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.pythia6reader.evtgen.C
1 // macro to instantiate the Geant3 from within
2 // STAR C++ framework and get the starsim prompt
3 // To use it do
4 // root4star starsim.C
5 //
6 // By Y. Zhang 07/29/2014
7 // Modified from Jason 's macro
8 // Added real distributions for pT, y
9 
10 
11 class St_geant_Maker;
12 St_geant_Maker *geant_maker = 0;
13 
14 class StarGenEvent;
15 StarGenEvent *event = 0;
16 
17 class StarPrimaryMaker;
18 StarPrimaryMaker *_primary = 0;
19 
20 //Initialize the settings:
21 Float_t vx = 0.;
22 Float_t vy = 0.;
23 Float_t vz = 0.;
24 Float_t vx_sig = 0.01;
25 Float_t vy_sig = 0.01;
26 Float_t vz_sig = 2.0;
27 //Float_t minVz = -5.0;
28 //Float_t maxVz = +5.0;
29 Float_t minPt = 0.0;
30 Float_t maxPt = +20;
31 Float_t minY = -1.0;
32 Float_t maxY = +1.0;
33 
34 //_____________________________________________________________________________
35 void geometry( TString tag, Bool_t agml=true )
36 {
37  TString cmd = "DETP GEOM "; cmd += tag;
38  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
39  geant_maker -> LoadGeometry(cmd);
40  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
41 }
42 //_____________________________________________________________________________
43 void command( TString cmd )
44 {
45  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
46  geant_maker -> Do( cmd );
47 }
48 //_____________________________________________________________________________
49 void trig( Int_t n=0 )
50 {
51  for ( Int_t i=0; i<n+1; i++ ) {
52  chain->Clear();
53  chain->Make();
54  // Print event generator
55  cout << "_____________________________________________________________________" << endl;
56  // _primary -> event() -> Print();
57  // command("gprint kine");
58  // command("gprint vert");
59  cout << "_____________________________________________________________________" << endl;
60 
61 
62  }
63 }
64 
65 void ExtendParticles()
66 {
67  // The Dalitz particle is defined in starsim in gstar_part.g --
68  //
69  // Particle Dalitz code=10007 TrkTyp=4 mass=0.135 charge=0 tlife=8.4e-17, | // pdg=100111 bratio= { 1.0,} mode= {10203,} | //
70  // The particle database does not know about this particle, so we have to add it. It is
71  // important that we do not overwrite PDG id = 111, the ID of the standard pi0. Otherwise,
72  // we will have all pi0's in the event decaying by dalitz.
73 
75 
76  data.AddParticleToG3("Jpsi", 3.096, 7.48e-21, 0., 4, 443, 160, 0, 0 );
77  data.AddParticleToG3("rho", 0.770, 4.35e-24, 0., 3, 113, 152, 0, 0 );
78  data.AddParticleToG3("rho_plus", 0.767, 4.35e-24, 1., 4, 213, 153, 0, 0 );
79  data.AddParticleToG3("rho_minus", 0.767, 4.35e-24,-1., 4, -213, 154, 0, 0 );
80  data.AddParticleToG3("D_star_plus", 2.01027,6.86e-22, 1., 4, 413, 60, 0, 0 );
81  data.AddParticleToG3("D_star_minus",2.01027,6.86e-22,-1., 4, -413, 61, 0, 0 );
82  data.AddParticleToG3("D_star_0", 2.007, 3.13e-22, 0., 4, 423, 62, 0, 0 );
83  data.AddParticleToG3("D_star_0_bar",2.007, 3.13e-22, 0., 4, -423, 63, 0, 0 );
84 
85  data.AddParticleToG3("B0", 5.2790, 1.536e-12, 0., 4, 511, 72, 0, 0 );
86  data.AddParticleToG3("B0_bar", 5.2790, 1.536e-12, 0., 4, -511, 73, 0, 0 );
87  data.AddParticleToG3("B_plus", 5.2790, 1.671e-12, 1., 4, 521, 70, 0, 0 );
88  data.AddParticleToG3("B_minus",5.2790, 1.671e-12, -1., 4, -521, 71, 0, 0 );
89  data.AddParticleToG3("D0", 1.86484,0.415e-12, 0., 3, 421, 37, 0, 0 );
90  data.AddParticleToG3("D0_bar", 1.86484,1.536e-12, 0., 3, -421, 38, 0, 0 );
91  data.AddParticleToG3("D_plus", 1.869, 1.057e-12, 1., 4, 411, 35, 0, 0 );
92  data.AddParticleToG3("D_minus",1.869, 1.057e-12, -1., 4, -411, 36, 0, 0 );
93 
94 }
95 
96 //_____________________________________________________________________________
97 
98 void Pythia6( TString filename )
99 {
100 
101  gSystem -> Load( "libStarGenEventReader.so" );
102  StarGenEventReader* eventreader = new StarGenEventReader();
103  eventreader->SetInputFile( filename, "genevents", "primaryEvent" );
104  _primary->AddGenerator( eventreader );
105 
106 
107 }
108 
109 //_____________________________________________________________________________
110 void reader( int nevents, int index, int rng )
111 {
112  starsim( nevents, index, rng );
113 }
114 void starsim( Int_t nevents=10, Int_t Index = 0, Int_t rngSeed=4321 )
115 {
116 
117  gROOT->ProcessLine(".L bfc.C");
118  {
119  TString simple = "y2013_1c geant gstar usexgeom agml ";
120  bfc(0, simple );
121  }
122 
123  gSystem->Load( "libVMC.so");
124 
125  gSystem->Load( "StarGeneratorUtil.so" );
126  gSystem->Load( "StarGeneratorEvent.so" );
127  gSystem->Load( "StarGeneratorBase.so" );
128  gSystem->Load( "StarGeneratorDecay.so" );
129  gSystem->Load( "libMathMore.so" );
130  gSystem->Load( "libHijing1_383.so");
131  gSystem->Load( "libKinematics.so");
132  gSystem->Load( "xgeometry.so" );
133 
134  gSystem->Load("libHepMC2_06_09.so");
135  gSystem->Load("libPythia8_1_86.so");
136  gSystem->Load("libPhotos3_61.so");
137  gSystem->Load("libTauola1_1_5.so");
138  gSystem->Load("libEvtGen1_06_00.so");
139 
140 
141  // Setup RNG seed and map all ROOT TRandom here
142  StarRandom::seed( rngSeed );
144 
145  char rootname[100],fzname[100];
146  sprintf(rootname,"st_pythiaevtgen_%d.starsim.root",Index);
147  sprintf(fzname,"gfile o st_pythiaevtgen_%d.starsim.fzd",Index);
148 
149  //
150  // Create the primary event generator and insert it
151  // before the geant maker
152  //
153  _primary = new StarPrimaryMaker();
154  {
155  _primary -> SetFileName(rootname);
156  chain -> AddBefore( "geant", _primary );
157  }
158 
159  //
160  // These should be adjusted to your best vertex estimates
161  //
162  _primary -> SetVertex( vx,vy,vz );
163  _primary -> SetSigma( vx_sig,vy_sig,vz_sig );
164 
165  //
166  // Setup an event generator
167  //
168  // Pythia6("pp:W");
169  Pythia6( "pythia6.starsim.root" );
170 
171  //
172  // Setup decay manager
173  //
174  StarDecayManager *decayMgr = AgUDecay::Manager();
175 
176  //
177  // Output a decay table for taus which specifies Tauola as the decay model
178  //
179  {
180  ofstream out("TAUS.DEC");
181  const char* cmds[] = {
182  "Decay tau-", // 1
183  "1.0 TAUOLA 0;", // 2
184  "Enddecay", // 3
185  "CDecay tau+", // 4
186  "End" // 5
187  };
188  for ( int i=0;i<5;i++ )
189  {
190  out << cmds[i] << endl;
191  }
192  }
193 
194  //
195  // Setup EvtGen to decay most particles in STAR
196  //
197  StarEvtGenDecayer *decayEvt = new StarEvtGenDecayer();
198  decayEvt->SetDecayTable("TAUS.DEC");
199  decayMgr->AddDecayer( 0, decayEvt ); // Handle any decay requested
200  decayEvt->SetDebug(0);
201 
202 
203  //
204  // Setup pythia8 to decay W+ and W- (and possibly others...)
205  //
206  StarPythia8Decayer *decayPy8 = new StarPythia8Decayer();
207  decayMgr->AddDecayer( +24, decayPy8 );
208  decayMgr->AddDecayer( -24, decayPy8 );
209  decayPy8->SetDebug(1);
210 
211 
212  // Allow W to e+ nu or e- nu only
213  decayPy8->Set("24:onMode = 0");
214  decayPy8->Set("24:onIfAny = 11 -11");
215 
216 
217  //
218  // Initialize primary event generator and all sub makers
219  //
220  _primary -> Init();
221 
222  //return;
223 
224  //
225  // Setup geometry and set starsim to use agusread for input
226  //
227  geometry("y2013_1c");
228  command("gkine -4 0");
229  command(fzname);
230 
231 
232  //
233  // Limits on eta, pt, ...
234  //
235  _primary->SetPtRange(0,-1.0); // no limits
236  _primary->SetEtaRange(-2.5,2.5);
237 
238  //
239  // Trigger on nevents
240  //
241  trig( nevents );
242 
243  // _primary->event()->Print();
244 
245  command("call agexit"); // Make sure that STARSIM exits properly
246  // command("gprint kine");
247 }
248 //_____________________________________________________________________________
249 
void SetSigma(Double_t sx, Double_t sy, Double_t sz, Double_t rho=0)
void SetFileName(const Char_t *name)
Set the filename of the output TTree.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void SetDecayTable(TString decayTable)
Modify EvtGen behavior.
static StarParticleData & instance()
Returns a reference to the single instance of this class.
Interface to PDG information.
void AddGenerator(StarGenerator *gener)
Connects VMC to class(es) which handle particle decays.
void SetDebug(Int_t dbg=1)
Set the debug level.
virtual Int_t Make()
Definition: StChain.cxx:110
static void seed(UInt_t s)
Definition: StarRandom.cxx:119
Base class for event records.
Definition: StarGenEvent.h:81
STAR wrapper for EvtGen Decayer.
Main steering class for event generation.
void AddDecayer(Int_t pdgid, TVirtualMCDecayer *decayer)
void SetPtRange(Double_t ptmin, Double_t ptmax=-1)
Set PT range. Particles falling outside this range will be dropped from simulation.
void SetDebug(int dbg=1)
Set the debug level.
static void capture()
Capture gRandom random number generator.
Definition: StarRandom.cxx:57
void SetEtaRange(Double_t etamin, Double_t etamax)
Set rapidity range. Particles falling outside this range will be dropped from simulation.
TParticlePDG * AddParticleToG3(const char *name, const double mass, const double lifetime, const double charge, const int tracktype, const int pdgcode, const int g3code, const double *bratio=0, const int *mode=0)
void Set(const char *cmd)
Modify pythia8 behavior.
void SetVertex(Double_t x, Double_t y, Double_t z)
Set the x, y and z vertex position.