StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.pythia6reader.pythia8decayer.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=10, int index=1, int rng=31415 )
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  TString rootname = "pythia6.reader.root";
149  TString fzname = "gfile o pythia6.reader.fzd";
150 
151  //
152  // Create the primary event generator and insert it
153  // before the geant maker
154  //
155  _primary = new StarPrimaryMaker();
156  {
157  _primary -> SetFileName(rootname);
158  chain -> AddBefore( "geant", _primary );
159  }
160 
161  //
162  // These should be adjusted to your best vertex estimates
163  //
164  _primary -> SetVertex( vx,vy,vz );
165  _primary -> SetSigma( vx_sig,vy_sig,vz_sig );
166 
167  //
168  // Setup an event generator
169  //
170  // Pythia6("pp:W");
171  Pythia6( "pythia6.standalone.root" ); // input
172 
173  //
174  // Setup decay manager
175  //
176  StarDecayManager *decayMgr = AgUDecay::Manager();
177 
178  //
179  // Output a decay table for taus which specifies Tauola as the decay model
180  //
181  {
182  ofstream out("TAUS.DEC");
183  const char* cmds[] = {
184  "Decay tau-", // 1
185  "1.0 TAUOLA 0;", // 2
186  "Enddecay", // 3
187  "CDecay tau+", // 4
188  "End" // 5
189  };
190  for ( int i=0;i<5;i++ )
191  {
192  out << cmds[i] << endl;
193  }
194  }
195 
196  // //
197  // // Setup EvtGen to decay most particles in STAR
198  // //
199  // StarEvtGenDecayer *decayEvt = new StarEvtGenDecayer();
200  // decayEvt->SetDecayTable("TAUS.DEC");
201  // decayMgr->AddDecayer( 23, decayEvt ); // Handle any decay requested
202  // decayMgr->AddDecayer( +15, decayEvt ); // Handle any decay requested [tau+]
203  // decayMgr->AddDecayer( -15, decayEvt ); // Handle any decay requested [tau-]
204  // decayEvt->SetDebug(0);
205 
206 
207  //
208  // Setup pythia8 to decay W+ and W- (and possibly others...)
209  //
210  StarPythia8Decayer *decayPy8 = new StarPythia8Decayer();
211  decayMgr -> AddDecayer( 0, decayPy8 );
212  decayMgr->AddDecayer( +24, decayPy8 );
213  decayMgr->AddDecayer( -24, decayPy8 );
214  decayMgr->AddDecayer( +23, decayPy8 );
215  decayMgr->AddDecayer( -23, decayPy8 );
216  decayPy8->SetDebug(1);
217 
218 
219  // Allow W to e+ nu or e- nu only
220  decayPy8->Set("24:onMode = 0");
221  decayPy8->Set("24:onIfAny = 11 -11");
222  decayPy8->Set("23:onMode = 0");
223  decayPy8->Set("23:onIfAny = 15 -15");
224 
225 
226  //
227  // Initialize primary event generator and all sub makers
228  //
229  _primary -> Init();
230 
231  //return;
232 
233  //
234  // Setup geometry and set starsim to use agusread for input
235  //
236  geometry("y2013_1c");
237  command("gkine -4 0");
238  command(fzname);
239 
240 
241  //
242  // Limits on eta, pt, ...
243  //
244  _primary->SetPtRange(0,-1.0); // no limits
245  _primary->SetEtaRange(-2.5,2.5);
246 
247  //
248  // Trigger on nevents
249  //
250  trig( nevents );
251 
252  // _primary->event()->Print();
253 
254  command("call agexit"); // Make sure that STARSIM exits properly
255  // command("gprint kine");
256 }
257 //_____________________________________________________________________________
258 
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
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.
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
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.