StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runPythia.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_pythia6.C
5 
6 class St_geant_Maker;
7 St_geant_Maker *geant_maker = 0;
8 
9 class St_db_Maker;
10 St_db_Maker *db_maker = 0;
11 
12 class StarGenEvent;
13 StarGenEvent *event = 0;
14 
15 class StarPrimaryMaker;
16 StarPrimaryMaker *primaryMaker = 0;
17 
18 class StarPythia6;
19 StarPythia6 *pythia6 = 0;
20 
21 class StarFilterMaker;
22 class FcsDYFilter;
23 class FcsJetFilter;
24 StarFilterMaker *dyfilter =0;
25 StarFilterMaker *dybgfilter=0;
26 StarFilterMaker *jetfilter=0;
27 StarFilterMaker *jpsifilter=0;
28 
29 TString LHAPDF_DATA_PATH="/star/u/akio/lhapdf";
30 
31 // ----------------------------------------------------------------------------
32 void geometry( TString tag, Bool_t agml=true )
33 {
34  TString cmd = "DETP GEOM "; cmd += tag;
35  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
36  geant_maker -> LoadGeometry(cmd);
37  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
38 }
39 // ----------------------------------------------------------------------------
40 void command( TString cmd )
41 {
42  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
43  geant_maker -> Do( cmd );
44 }
45 // ----------------------------------------------------------------------------
46 void trig( Int_t n=1 )
47 {
48  for ( Int_t i=0; i<n; i++ ) {
49  chain->Clear();
50  chain->Make();
51  }
52 }
53 // ----------------------------------------------------------------------------
54 // ----------------------------------------------------------------------------
55 // ----------------------------------------------------------------------------
56 void Pythia6( TString mode="pp:DY", Int_t tune=370)
57 {
58 
59  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
60  if ( LHAPDF_DATA_PATH.Contains("afs") ) {
61  cout << "WARNING: LHAPDF_DATA_PATH points to an afs volume" << endl << endl;
62  cout << " You are advised to copy the PDF files you need into a local" << endl;
63  cout << " directory and set the LHAPDF_DATA_PATH to point to it." << endl;
64  }
65 
66  gSystem->Setenv("LHAPDF_DATA_PATH", LHAPDF_DATA_PATH.Data() );
67 
68  gSystem->Load( "/opt/star/$STAR_HOST_SYS/lib/libLHAPDF.so");
69  gSystem->Load( "libPythia6_4_28.so");
70 
71  pythia6 = new StarPythia6("pythia6");
72  pythia6->SetFrame("CMS", 510.0 );
73  pythia6->SetBlue("proton");
74  pythia6->SetYell("proton");
75  pythia6->PyTune(tune);
76  PySubs_t &pysubs = pythia6->pysubs();
77  if ( mode == "pp:minbias" ) {
78  pysubs.msel = 2;
79  }else if( mode == "pp:qcd" ) {
80  pysubs.msel = 1;
81  }else if( mode == "pp:DY" ) {
82  pysubs.msel = 0;
83  pysubs.msub(1)=1; //qq->ll & qq->Z
84  }else if( mode == "pp:JPsi" ) {
85  pysubs.msel = 0;
86  pysubs.msub(86)=1;
87  pysubs.msub(106)=1;
88  pysubs.msub(107)=1;
89  }
90 
91  pythia6->Init();
92  PyPars_t &pypars = pythia6->pypars();
93  printf("PARP(90) was %f, replacing it with 0.213\n",pypars.parp(90));
94  pypars.parp(90)=0.213;
95 
96  // Set pi0 (id=102), pi+ (id=106) and eta (id=109) stable
97  PyDat3_t &pydat3 = pythia6->pydat3();
98  printf("MDCY(102,1) was %f, replacing it with 0\n",pydat3.mdcy(102,1));
99 
100  pydat3.mdcy(102,1) = 0; //PI0
101  pydat3.mdcy(106,1) = 0; //PI+
102  pydat3.mdcy(109,1) = 0; // ETA
103  pydat3.mdcy(116,1) = 0; // K+
104  pydat3.mdcy(112,1) = 0; // K_SHORT
105  pydat3.mdcy(105,1) = 0; // K_LONG
106  pydat3.mdcy(164,1) = 0; // ! LAMBDA0 3122
107  pydat3.mdcy(167,1) = 0; // ! SIGMA0 3212
108  pydat3.mdcy(162,1) = 0; // ! SIGMA- 3112
109  pydat3.mdcy(169,1) = 0; // ! SIGMA+ 3222
110  pydat3.mdcy(172,1) = 0; // ! Xi- 3312
111  pydat3.mdcy(174,1) = 0; // ! Xi0 3322
112  pydat3.mdcy(176,1) = 0; // ! OMEGA- 3334
113 
114  primaryMaker->AddGenerator(pythia6);
115 }
116 // ----------------------------------------------------------------------------
117 // ----------------------------------------------------------------------------
118 // ----------------------------------------------------------------------------
119 void runPythia( Int_t nevents=100, Int_t run=1, char* particle="JPsi", float vz=0.0, Int_t tune=370){
120  cout<<"Random seed : "<<run<<endl;
121 
122  gROOT->ProcessLine(".L bfc.C");{
123  TString simple = "y2023 geant gstar agml usexgeom ";
124  bfc(0, simple );
125  }
126 
127  gSystem->Load("libfastjet.so");
128  gSystem->Load( "libVMC.so");
129  gSystem->Load( "StarGeneratorUtil.so" );
130  gSystem->Load( "StarGeneratorEvent.so" );
131  gSystem->Load( "StarGeneratorBase.so" );
132  gSystem->Load( "StarGeneratorFilt.so");
133  gSystem->Load( "libMathMore.so" );
134  gSystem->Load( "xgeometry.so" );
135 
136 
137  db_maker = (St_db_Maker *)chain->GetMaker("db");
138  if(db_maker){
139  db_maker->SetAttr("blacklist", "tpc");
140  db_maker->SetAttr("blacklist", "svt");
141  db_maker->SetAttr("blacklist", "ssd");
142  db_maker->SetAttr("blacklist", "ist");
143  db_maker->SetAttr("blacklist", "pxl");
144  db_maker->SetAttr("blacklist", "pp2pp");
145  db_maker->SetAttr("blacklist", "ftpc");
146  db_maker->SetAttr("blacklist", "emc");
147  db_maker->SetAttr("blacklist", "eemc");
148  db_maker->SetAttr("blacklist", "mtd");
149  db_maker->SetAttr("blacklist", "pmd");
150  db_maker->SetAttr("blacklist", "tof");
151  }
152 
153  // Setup RNG seed and map all ROOT TRandom here
154  StarRandom::seed( run );
156 
157  //
158  // Create the primary event generator and insert it
159  // before the geant maker
160  //
161  // StarPrimaryMaker *
162  primaryMaker = new StarPrimaryMaker();
163  {
164  primaryMaker -> SetFileName( Form("pythia_%s_vz%d_run%d.root",particle,int(vz),run));
165  chain -> AddBefore( "geant", primaryMaker );
166  }
167 
168  //
169  // Setup an event generator
170  //
171  TString proc(particle);
172  if(proc.Contains("mb")){
173  Pythia6("pp:minbias", tune);
174  }else if(proc.Contains("jet")){ //JET
175  Pythia6("pp:qcd", tune);
176  jetfilter = (StarFilterMaker *)new FcsJetFilter();
177  primaryMaker->AddFilter(jetfilter);
178  }else if( proc.Contains("dy") && !proc.Contains("dybg") ){ // DY signal
179  Pythia6("pp:DY", tune);
180  dyfilter = (StarFilterMaker *)new FcsDYFilter();
181  primaryMaker->AddFilter(dyfilter);
182  }else if(proc.Contains("dybg") && !proc.Contains("dybgSingle") ){ //DY background via QCD
183  Pythia6("pp:qcd", tune);
184  dybgfilter = new FcsDYBGFilter();
185  primaryMaker->AddFilter(dybgfilter);
186  }else if(proc.Contains("dybgSingle")){ //DY background via QCD
187  Pythia6("pp:qcd", tune);
188  dybgSinglefilter = new FcsDYBGFilterSingle();
189  primaryMaker->AddFilter(dybgSinglefilter);
190  }else if( proc.Contains("JPsi")){ // Jpsi signal
191  Pythia6("pp:JPsi", tune);
192  jpsifilter = (StarFilterMaker *)new FcsJPsiFilter();
193  primaryMaker->AddFilter(jpsifilter);
194  }
195 
196  //
197  // Setup cuts on which particles get passed to geant for
198  // simulation.
199  //
200  // If ptmax < ptmin indicates an infinite ptmax.
201  // ptmin will always be the low pT cutoff.
202  //
203  // ptmin ptmax
204  primaryMaker->SetPtRange (0.0, -1.0); // GeV
205  //
206  // If etamax < etamin, there is no cut in eta.
207  // otherwise, particles outside of the specified range are cut.
208  //
209  // etamin etamax
210  primaryMaker->SetEtaRange ( 0.0, +10.0 );
211  //
212  // phirange will be mapped into 0 to 2 pi internally.
213  //
214  // phimin phimax
215  primaryMaker->SetPhiRange ( 0., TMath::TwoPi() );
216 
217  // Setup a realistic z-vertex distribution:
218  // x = 0 gauss width = 1mm
219  // y = 0 gauss width = 1mm
220  // z = 0 gauss width = 30cm
221  //
222  primaryMaker->SetVertex( 0., 0., vz );
223  //primaryMaker->SetSigma( 0.1, 0.1, 30.0 );
224  primaryMaker->SetSigma( 0., 0., 0. );
225 
226  //
227  // Initialize primary event generator and all sub makers
228  //
229  primaryMaker -> Init();
230 
231  //chenging pypars(90)
232  if(tune==370){
233  PyPars_t &pypars = pythia6->pypars();
234  printf("PARP(90) was %f, replacing it with 0.213\n",pypars.parp(90));
235  pypars.parp(90)=0.213;
236  }
237  //
238  // Setup geometry and set starsim to use agusread for input
239  //
240  //geometry("fwddev1a");
241  //geometry("ftsref6a");
242  geometry("y2023");
243  //geometry("sitrver0");
244  command("gkine -4 0");
245  command(Form("gfile o pythia_%s_vz%d_run%d.fzd",particle,int(vz),run));
246 
247  //
248  // Trigger on nevents
249  //
250  trig( nevents );
251 
252  pythia6->PyStat(1);
253 
254  command("call agexit"); // Make sure that STARSIM exits properly
255 }
256 // ----------------------------------------------------------------------------
257 
void PyTune(Int_t tune)
Calls the pytune function.
Definition: StarPythia6.cxx:44
void SetSigma(Double_t sx, Double_t sy, Double_t sz, Double_t rho=0)
void SetFrame(const Char_t *frame, const Double_t val)
PyDat3_t & pydat3()
Returns a reference to the /PYDAT3/ common block.
Definition: StarPythia6.h:65
void SetPhiRange(Double_t phimin, Double_t phimax)
Set phi range. Particles falling outside this range will be dropped from simulation.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
Int_t Init()
Definition: StarPythia6.cxx:49
Main filter class. Goes anywhere in the chain, filters StarGenEvent objects.
void AddGenerator(StarGenerator *gener)
void SetBlue(const Char_t *b)
Sets the particle species for the blue beam.
void PyStat(Int_t stat)
Calls the pystat function.
Definition: StarPythia6.cxx:45
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
PyPars_t & pypars()
Returns a reference to the /PYPARS/ common block.
Definition: StarPythia6.h:67
Main steering class for event generation.
void SetYell(const Char_t *y)
Sets the particle species for the yellow beam.
void SetPtRange(Double_t ptmin, Double_t ptmax=-1)
Set PT range. Particles falling outside this range will be dropped from simulation.
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.
void AddFilter(StarFilterMaker *filt)
void SetVertex(Double_t x, Double_t y, Double_t z)
Set the x, y and z vertex position.