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=10, 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 = "y2017 geant gstar agml usexgeom ";
124  bfc(0, simple );
125  }
126 
127  gSystem->Load( "libVMC.so");
128  gSystem->Load( "StarGeneratorUtil.so" );
129  gSystem->Load( "StarGeneratorEvent.so" );
130  gSystem->Load( "StarGeneratorBase.so" );
131  gSystem->Load( "StarGeneratorFilt.so");
132  gSystem->Load( "libMathMore.so" );
133  gSystem->Load( "xgeometry.so" );
134 
135 
136  db_maker = (St_db_Maker *)chain->GetMaker("db");
137  if(db_maker){
138  db_maker->SetAttr("blacklist", "tpc");
139  db_maker->SetAttr("blacklist", "svt");
140  db_maker->SetAttr("blacklist", "ssd");
141  db_maker->SetAttr("blacklist", "ist");
142  db_maker->SetAttr("blacklist", "pxl");
143  db_maker->SetAttr("blacklist", "pp2pp");
144  db_maker->SetAttr("blacklist", "ftpc");
145  db_maker->SetAttr("blacklist", "emc");
146  db_maker->SetAttr("blacklist", "eemc");
147  db_maker->SetAttr("blacklist", "mtd");
148  db_maker->SetAttr("blacklist", "pmd");
149  db_maker->SetAttr("blacklist", "tof");
150  }
151 
152  // Setup RNG seed and map all ROOT TRandom here
153  StarRandom::seed( run );
155 
156  //
157  // Create the primary event generator and insert it
158  // before the geant maker
159  //
160  // StarPrimaryMaker *
161  primaryMaker = new StarPrimaryMaker();
162  {
163  primaryMaker -> SetFileName( Form("pythia_%s_vz%d_run%d.root",particle,int(vz),run));
164  chain -> AddBefore( "geant", primaryMaker );
165  }
166 
167  //
168  // Setup an event generator
169  //
170  TString proc(particle);
171  if(proc.Contains("mb")){
172  Pythia6("pp:minbias", tune);
173  }else if(proc.Contains("jet")){ //JET
174  Pythia6("pp:qcd", tune);
175  jetfilter = (StarFilterMaker *)new FcsJetFilter();
176  primaryMaker->AddFilter(jetfilter);
177  }else if( proc.Contains("dy") && !proc.Contains("dybg") ){ // DY signal
178  Pythia6("pp:DY", tune);
179  dyfilter = (StarFilterMaker *)new FcsDYFilter();
180  primaryMaker->AddFilter(dyfilter);
181  }else if(proc.Contains("dybg") && !proc.Contains("dybgSingle") ){ //DY background via QCD
182  Pythia6("pp:qcd", tune);
183  dybgfilter = new FcsDYBGFilter();
184  primaryMaker->AddFilter(dybgfilter);
185  }else if(proc.Contains("dybgSingle")){ //DY background via QCD
186  Pythia6("pp:qcd", tune);
187  dybgSinglefilter = new FcsDYBGFilterSingle();
188  primaryMaker->AddFilter(dybgSinglefilter);
189  }else if( proc.Contains("JPsi")){ // Jpsi signal
190  Pythia6("pp:JPsi", tune);
191  jpsifilter = (StarFilterMaker *)new FcsJPsiFilter();
192  primaryMaker->AddFilter(jpsifilter);
193  }
194 
195  //
196  // Setup cuts on which particles get passed to geant for
197  // simulation.
198  //
199  // If ptmax < ptmin indicates an infinite ptmax.
200  // ptmin will always be the low pT cutoff.
201  //
202  // ptmin ptmax
203  primaryMaker->SetPtRange (0.0, -1.0); // GeV
204  //
205  // If etamax < etamin, there is no cut in eta.
206  // otherwise, particles outside of the specified range are cut.
207  //
208  // etamin etamax
209  primaryMaker->SetEtaRange ( 0.0, +10.0 );
210  //
211  // phirange will be mapped into 0 to 2 pi internally.
212  //
213  // phimin phimax
214  primaryMaker->SetPhiRange ( 0., TMath::TwoPi() );
215 
216  // Setup a realistic z-vertex distribution:
217  // x = 0 gauss width = 1mm
218  // y = 0 gauss width = 1mm
219  // z = 0 gauss width = 30cm
220  //
221  primaryMaker->SetVertex( 0., 0., vz );
222  //primaryMaker->SetSigma( 0.1, 0.1, 30.0 );
223  primaryMaker->SetSigma( 0., 0., 0. );
224 
225  //
226  // Initialize primary event generator and all sub makers
227  //
228  primaryMaker -> Init();
229 
230  //chenging pypars(90)
231  if(tune==370){
232  PyPars_t &pypars = pythia6->pypars();
233  printf("PARP(90) was %f, replacing it with 0.213\n",pypars.parp(90));
234  pypars.parp(90)=0.213;
235  }
236  //
237  // Setup geometry and set starsim to use agusread for input
238  //
239  //geometry("fwddev1a");
240  //geometry("ftsref6a");
241  geometry("dev2022");
242  //geometry("sitrver0");
243  command("gkine -4 0");
244  command(Form("gfile o pythia_%s_vz%d_run%d.fzd",particle,int(vz),run));
245 
246  //
247  // Trigger on nevents
248  //
249  trig( nevents );
250 
251  pythia6->PyStat(1);
252 
253  command("call agexit"); // Make sure that STARSIM exits properly
254 }
255 // ----------------------------------------------------------------------------
256 
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.