StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.pythia8.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 class StarKinematics;
22 
23 //Initialize the settings:
24 Float_t vx = 0.;
25 Float_t vy = 0.;
26 Float_t vz = 0.;
27 Float_t vx_sig = 0.01;
28 Float_t vy_sig = 0.01;
29 Float_t vz_sig = 2.0;
30 //Float_t minVz = -5.0;
31 //Float_t maxVz = +5.0;
32 Float_t minPt = 0.0;
33 Float_t maxPt = +20;
34 Float_t minY = -1.0;
35 Float_t maxY = +1.0;
36 
37 // ----------------------------------------------------------------------------
38 void geometry( TString tag, Bool_t agml=true )
39 {
40  TString cmd = "DETP GEOM "; cmd += tag;
41  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
42  geant_maker -> LoadGeometry(cmd);
43  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
44 }
45 // ----------------------------------------------------------------------------
46 void command( TString cmd )
47 {
48  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
49  geant_maker -> Do( cmd );
50 }
51 // ----------------------------------------------------------------------------
52 void trig( Int_t n=0 )
53 {
54  for ( Int_t i=0; i<n+1; i++ ) {
55  chain->Clear();
56 
57  // Throw single tau-
58  if (kinematics) kinematics -> Kine( 1, "tau-", 10.0, 20.0, -1.0, 1.0 );
59 
60  chain->Make();
61  }
62 }
63 
64 void Kinematics()
65 {
66 
67  kinematics = new StarKinematics("EvtGen Decay");
68  _primary -> AddGenerator(kinematics);
69 }
70 
71 void Pythia6( TString mode="pp:W", Int_t tune=320 )
72 {
73 
74  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
75  gSystem->Load( "libPythia6_4_28.so");
76  // gSystem->Load( "StarPythia6.so" );
77 
78  StarPythia6 *pythia6 = new StarPythia6("pythia6");
79  if ( mode=="pp:W" )
80  {
81  pythia6->SetFrame("CMS", 510.0 );
82  pythia6->SetBlue("proton");
83  pythia6->SetYell("proton");
84  if ( tune ) pythia6->PyTune( tune );
85 
86  // Setup pythia process
87  PySubs_t &pysubs = pythia6->pysubs();
88  pysubs.msel = 12;
89  pysubs.ckin(3)=4.0;
90 
91  }
92  if ( mode == "pp:minbias" )
93  {
94  pythia6->SetFrame("CMS", 510.0 );
95  pythia6->SetBlue("proton");
96  pythia6->SetYell("proton");
97  if ( tune ) pythia6->PyTune( tune );
98  }
99  if ( mode == "ep" )
100  {
101  Double_t pblue[]={0.,0.,30.0};
102  Double_t pyell[]={0.,0.,-320.0};
103  pythia6->SetFrame("3MOM", pblue, pyell );
104  pythia6->SetBlue("e-");
105  pythia6->SetYell("proton");
106  if ( tune ) pythia6->PyTune( tune );
107  }
108 
109  _primary->AddGenerator(pythia6);
110 }
111 
112 void Pythia8( TString config="pp:W" )
113 {
114 
115  //
116  // Create the pythia 8 event generator and add it to
117  // the primary generator
118  //
119  StarPythia8 *pythia8 = new StarPythia8();
120  if ( config=="pp:W" )
121  {
122  pythia8->SetFrame("CMS", 510.0);
123  pythia8->SetBlue("proton");
124  pythia8->SetYell("proton");
125 
126  pythia8->Set("WeakSingleBoson:all=off");
127  pythia8->Set("WeakSingleBoson:ffbar2W=on");
128  pythia8->Set("24:onMode=0"); // switch off all W+/- decaus
129  pythia8->Set("24:onIfAny 11 -11"); // switch on for decays to e+/-
130 
131  }
132  if ( config=="pp:minbias" )
133  {
134  pythia8->SetFrame("CMS", 510.0);
135  pythia8->SetBlue("proton");
136  pythia8->SetYell("proton");
137 
138  pythia8->Set("SoftQCD:minBias = on");
139  }
140 
141  _primary -> AddGenerator( pythia8 );
142 
143 }
144 
145 //
146 void starsim( Int_t nevents=1, Int_t Index = 0, Int_t rngSeed=4321 )
147 {
148 
149  gROOT->ProcessLine(".L bfc.C");
150  {
151  TString simple = "y2014 geant gstar usexgeom agml ";
152  bfc(0, simple );
153  }
154 
155  gSystem->Load( "libVMC.so");
156 
157  gSystem->Load( "StarGeneratorUtil.so" );
158  gSystem->Load( "StarGeneratorEvent.so" );
159  gSystem->Load( "StarGeneratorBase.so" );
160  gSystem->Load( "StarGeneratorDecay.so" );
161  gSystem->Load( "libMathMore.so" );
162  gSystem->Load( "libHijing1_383.so");
163  gSystem->Load( "libKinematics.so");
164  gSystem->Load( "xgeometry.so" );
165 
166  gSystem->Load("libHepMC2_06_09.so");
167  gSystem->Load("libPythia8_1_86.so");
168  gSystem->Load("libPhotos3_61.so");
169  gSystem->Load("libTauola1_1_5.so");
170  gSystem->Load("libEvtGen1_06_00.so");
171 
172 
173  // force gstar load/call nope
174  // gSystem->Load( "gstar.so" );
175  // command("call gstar");
176 
177  // Setup RNG seed and map all ROOT TRandom here
178  StarRandom::seed( rngSeed );
180 
181  TString rootname = "tau.root";
182  TString fzname = "gfile o tau.fzd";
183 
184  //
185  // Create the primary event generator and insert it
186  // before the geant maker
187  //
188  _primary = new StarPrimaryMaker();
189  {
190  _primary -> SetFileName(rootname);
191  chain -> AddBefore( "geant", _primary );
192  }
193 
194  //
195  // These should be adjusted to your best vertex estimates
196  //
197  _primary -> SetVertex( vx,vy,vz );
198  _primary -> SetSigma( vx_sig,vy_sig,vz_sig );
199 
200 
201  //
202  // Setup single particle
203  //
204  // Kinematics();
205  Pythia8("pp:W");
206  // Pythia6("pp:W");
207 
208 
209  //
210  // Setup decay manager
211  //
212  StarDecayManager *decayMgr = AgUDecay::Manager();
213  StarEvtGenDecayer *decayEvt = new StarEvtGenDecayer();
214  //decayEvt->SetDecayTable("StRoot/StSimulationMaker/Decay_Table/Jpsi.DEC");
215  decayMgr->AddDecayer( 0, decayEvt ); // Handle any decay requested
216  // decayEvt->SetDebug(1);
217 
218 
219  //
220  // Initialize primary event generator and all sub makers
221  //
222  _primary -> Init();
223 
224  //
225  // Setup geometry and set starsim to use agusread for input
226  //
227  //geometry("y2014");
228  command("gkine -4 0");
229  command(fzname);
230 
231  //
232  // Trigger on nevents
233  //
234  trig( nevents );
235 
236  _primary->event()->Print();
237 
238  command("call agexit"); // Make sure that STARSIM exits properly
239 
240 }
241 // ----------------------------------------------------------------------------
242 
void PyTune(Int_t tune)
Calls the pytune function.
Definition: StarPythia6.cxx:44
void SetFrame(const Char_t *frame, const Double_t val)
void Print(const Option_t *opts="head") const
Star Simple Kinematics Generator.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void AddGenerator(StarGenerator *gener)
void SetBlue(const Char_t *b)
Sets the particle species for the blue beam.
Connects VMC to class(es) which handle particle decays.
Int_t Init()
Initialize generator.
PySubs_t & pysubs()
Returns a reference to the /PYSUBS/ common block.
Definition: StarPythia6.h:61
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
Interface to pythia 6.
Definition: StarPythia6.h:48
STAR wrapper for EvtGen Decayer.
StarGenEvent * event()
Return a pointer to the event.
Main steering class for event generation.
void AddDecayer(Int_t pdgid, TVirtualMCDecayer *decayer)
void SetYell(const Char_t *y)
Sets the particle species for the yellow beam.
static void capture()
Capture gRandom random number generator.
Definition: StarRandom.cxx:57
Sparse class to hold track kinematics.
void Kine(Int_t ntrack, const Char_t *type="pi+,pi-,K+,K-,proton,antiproton", Double_t ptlow=0.0, Double_t pthigh=500.0, Double_t ylow=-10.0, Double_t yhigh=+10.0, Double_t philow=0.0, Double_t phihigh=TMath::TwoPi())
void Set(const char *s)
Pass a string to Pythia8::Pythia::readString(), for user configuration.
Definition: StarPythia8.h:91