StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.pythia6.lhapdf.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 StarGenEvent;
10 StarGenEvent *event = 0;
11 
12 class StarPrimaryMaker;
13 StarPrimaryMaker *_primary = 0;
14 
15 
16 //
17 // This is for testing only and should NOT be used in a production (i.e. batch
18 // system) run. It will spam the heck out of our AFS system, and bring the
19 // wrath of Jerome down upon you. We will install data files in appropriate
20 // path, and you should update when available.
21 //
22 TString LHAPDF_DATA_PATH="/afs/cern.ch/sw/lcg/external/lhapdfsets/current/";
23 
24 // ----------------------------------------------------------------------------
25 void geometry( TString tag, Bool_t agml=true )
26 {
27  TString cmd = "DETP GEOM "; cmd += tag;
28  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
29  geant_maker -> LoadGeometry(cmd);
30  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
31 }
32 // ----------------------------------------------------------------------------
33 void command( TString cmd )
34 {
35  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
36  geant_maker -> Do( cmd );
37 }
38 // ----------------------------------------------------------------------------
39 void trig( Int_t n=1 )
40 {
41  for ( Int_t i=0; i<n; i++ ) {
42  chain->Clear();
43  chain->Make();
44  }
45 }
46 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
49 void Pythia6( TString mode="pp:W", Int_t tune=370 )
50 {
51 
52  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
53  if ( LHAPDF_DATA_PATH.Contains("afs") ) {
54  cout << "WARNING: LHAPDF_DATA_PATH points to an afs volume" << endl << endl;
55  cout << " You are advised to copy the PDF files you need into a local" << endl;
56  cout << " directory and set the LHAPDF_DATA_PATH to point to it." << endl;
57  }
58 
59  gSystem->Setenv("LHAPDF_DATA_PATH", LHAPDF_DATA_PATH.Data() );
60 
61  gSystem->Load( "/opt/star/$STAR_HOST_SYS/lib/libLHAPDF.so");
62  gSystem->Load( "libPythia6_4_28.so");
63 
64  // gSystem->Load( "StarPythia6.so" );
65 
66  StarPythia6 *pythia6 = new StarPythia6("pythia6");
67  if ( mode == "pp:minbias" )
68  {
69  //pythia6->SetFrame("CMS", 510.0 );
70  pythia6->SetFrame("CMS", 200.0 );
71  pythia6->SetBlue("proton");
72  pythia6->SetYell("proton");
73  if ( tune ) pythia6->PyTune( tune );
74  //PyPars_t &pypars = pythia6->pypars();
75  //int& mstp5 = pypars.mstp(5); mstp5 = 370;
76  //float& parp90 = pypars.parp(90); parp90 = 0.213;
77  }
78  if ( mode == "ep" )
79  {
80  Double_t pblue[]={0.,0.,30.0};
81  Double_t pyell[]={0.,0.,-320.0};
82  pythia6->SetFrame("3MOM", pblue, pyell );
83  pythia6->SetBlue("e-");
84  pythia6->SetYell("proton");
85  if ( tune ) pythia6->PyTune( tune );
86  }
87 
88  _primary->AddGenerator(pythia6);
89 }
90 // ----------------------------------------------------------------------------
91 // ----------------------------------------------------------------------------
92 // ----------------------------------------------------------------------------
93 void starsim( Int_t nevents=1, Int_t rngSeed=0 , Int_t eventnameid=0)
94 {
95 
96  if(rngSeed==0)
97  {
98  Int_t currenttime=time(0);
99  cout<<"time : "<<currenttime<<endl;
100  rngSeed=abs((eventnameid +currenttime)*21474836) % (int)(pow(2,20)); // ly: just a simple random seed
101  }
102  cout<<"Random seed : "<<rngSeed<<endl;
103 
104  gROOT->ProcessLine(".L bfc.C");
105  {
106  TString simple = "y2012 geant gstar agml usexgeom ";
107  bfc(0, simple );
108  }
109 
110  gSystem->Load( "libVMC.so");
111 
112  gSystem->Load( "StarGeneratorUtil.so" );
113  gSystem->Load( "StarGeneratorEvent.so" );
114  gSystem->Load( "StarGeneratorBase.so" );
115 
116  gSystem->Load( "libMathMore.so" );
117  gSystem->Load( "xgeometry.so" );
118 
119  // Setup RNG seed and map all ROOT TRandom here
120  StarRandom::seed( rngSeed );
122 
123  //
124  // Create the primary event generator and insert it
125  // before the geant maker
126  //
127  // StarPrimaryMaker *
128  _primary = new StarPrimaryMaker();
129  {
130  _primary -> SetFileName( Form("pythia6.starsim_%d.root",eventnameid));
131  chain -> AddBefore( "geant", _primary );
132  }
133 
134  //
135  // Setup an event generator
136  //
137  Pythia6( "pp:minbias" ,370);
138 
139  //
140  // Setup cuts on which particles get passed to geant for
141  // simulation.
142  //
143  // If ptmax < ptmin indicates an infinite ptmax.
144  // ptmin will always be the low pT cutoff.
145  //
146  // ptmin ptmax
147  _primary->SetPtRange (0.0, -1.0); // GeV
148  //
149  // If etamax < etamin, there is no cut in eta.
150  // otherwise, particles outside of the specified range are cut.
151  //
152  // etamin etamax
153  // _primary->SetEtaRange ( -3.0, +3.0 );
154  //
155  // phirange will be mapped into 0 to 2 pi internally.
156  //
157  // phimin phimax
158  _primary->SetPhiRange ( 0., TMath::TwoPi() );
159 
160 
161  //
162  // Setup a realistic z-vertex distribution:
163  // x = 0 gauss width = 1mm
164  // y = 0 gauss width = 1mm
165  // z = 0 gauss width = 30cm
166  //
167  _primary->SetVertex( 0., 0., 0. );
168  //_primary->SetSigma( 0.1, 0.1, 30.0 );
169  _primary->SetSigma( 0., 0., 0. );
170 
171  //
172  // Initialize _primary event generator and all sub makers
173  //
174  _primary -> Init();
175 
176  //
177  // Setup geometry and set starsim to use agusread for input
178  //
179  geometry("y2012");
180  command("gkine -4 0");
181  command("gfile o pythia6.starsim.fzd");
182 
183 
184  //
185  // Trigger on nevents
186  //
187  trig( nevents );
188 
189  command("call agexit"); // Make sure that STARSIM exits properly
190 }
191 // ----------------------------------------------------------------------------
192 
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)
void SetFileName(const Char_t *name)
Set the filename of the output TTree.
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
void AddGenerator(StarGenerator *gener)
void SetBlue(const Char_t *b)
Sets the particle species for the blue beam.
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
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 SetVertex(Double_t x, Double_t y, Double_t z)
Set the x, y and z vertex position.