StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.pythia8.hftune.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 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 // Example macro for loading a "tune" deck. It is based on work done by
17 // Thomas Ullrich http://www.star.bnl.gov/protected/heavy/ullrich/pythia8/
18 //
19 //
20 //
21 
22 
23 
24 //
25 // This is for testing only and should NOT be used in a production (i.e. batch
26 // system) run. It will spam the heck out of our AFS system, and bring the
27 // wrath of Jerome down upon you. We will install data files in appropriate
28 // path, and you should update when available.
29 //
30 TString LHAPDF_DATA_PATH="/afs/cern.ch/sw/lcg/external/lhapdfsets/current/";
31 
32 
33 // ----------------------------------------------------------------------------
34 void geometry( TString tag, Bool_t agml=true )
35 {
36  TString cmd = "DETP GEOM "; cmd += tag;
37  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
38  geant_maker -> LoadGeometry(cmd);
39  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
40 }
41 // ----------------------------------------------------------------------------
42 void command( TString cmd )
43 {
44  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
45  geant_maker -> Do( cmd );
46 }
47 // ----------------------------------------------------------------------------
48 // trig() -- generates one event
49 // trig(n) -- generates n+1 events.
50 //
51 // NOTE: last event generated will be corrupt in the FZD file
52 //
53 void trig( Int_t n=1 )
54 {
55  chain->EventLoop(n);
56  _primary->event()->Print();
57 
58 }
59 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
62 void Pythia8( TString config="pp:W" )
63 {
64 
65  //
66  // Create the pythia 8 event generator and add it to
67  // the primary generator
68  //
69  StarPythia8 *pythia8 = new StarPythia8();
70  if ( config=="pp:W" ) {
71  pythia8->SetFrame("CMS", 510.0);
72  pythia8->SetBlue("proton");
73  pythia8->SetYell("proton");
74 
75  pythia8->Set("WeakSingleBoson:all=off");
76  pythia8->Set("WeakSingleBoson:ffbar2W=on");
77  pythia8->Set("24:onMode=0"); // switch off all W+/- decaus
78  pythia8->Set("24:onIfAny 11 -11"); // switch on for decays to e+/-
79 
80  }
81  if ( config=="pp:510:minbias" ) {
82  pythia8->SetFrame("CMS", 510.0);
83  pythia8->SetBlue("proton");
84  pythia8->SetYell("proton");
85  pythia8->Set("SoftQCD:minBias = on");
86  }
87 
88  if ( config=="pp:200:charmonium" ) {
89  pythia8->SetFrame("CMS", 200.0);
90  pythia8->SetBlue("proton");
91  pythia8->SetYell("proton");
92  pythia8->ReadFile( "star_hf_tune_v1.1-1.cmnd" );
93  pythia8->Set( "HardQCD:all = off" );
94  pythia8->Set( "Charmonium:all=on" );
95  }
96  if ( config=="pp:200:bottomonium" ) {
97  pythia8->SetFrame("CMS", 200.0);
98  pythia8->SetBlue("proton");
99  pythia8->SetYell("proton");
100  pythia8->ReadFile( "star_hf_tune_v1.1-1.cmnd" );
101  pythia8->Set( "HardQCD:all = off" );
102  pythia8->Set( "Bottomonium:all=on" );
103  }
104  if ( config=="pp:200:drellyan" ) {
105  pythia8->SetFrame("CMS", 200.0);
106  pythia8->SetBlue("proton");
107  pythia8->SetYell("proton");
108  pythia8->ReadFile( "star_hf_tune_v1.1-1.cmnd" );
109  pythia8->Set( "HardQCD:all = off" );
110  pythia8->Set( "WeakSingleBoson:ffbar2gmZ=on" );
111  }
112  if ( config=="pp:200:minbias" ) {
113  pythia8->SetFrame("CMS", 200.0);
114  pythia8->SetBlue("proton");
115  pythia8->SetYell("proton");
116  pythia8->ReadFile( "star_hf_tune_v1.1-1.cmnd" );
117  pythia8->Set( "HardQCD:all = on" );
118  pythia8->Set( "SoftQCD:minbias = on" );
119  }
120 
121  // The TUNE deck may request too many events. We only need one event
122  // per run for simulation.
123  pythia8->Set("Main:numberOfEvents = 1 ");
124 
125  _primary -> AddGenerator( pythia8 );
126 
127 }
128 // ----------------------------------------------------------------------------
129 // ----------------------------------------------------------------------------
130 // ----------------------------------------------------------------------------
131 void starsim( Int_t nevents=10000, Int_t rngSeed=1234 )
132 {
133 
134  gROOT->ProcessLine(".L bfc.C");
135  {
136  TString simple = "y2012 geant gstar usexgeom agml -detdb -db";
137  bfc(0, simple );
138  }
139 
140  gSystem->Load( "libVMC.so");
141 
142  gSystem->Load( "StarGeneratorUtil.so");
143  gSystem->Load( "StarGeneratorEvent.so");
144  gSystem->Load( "StarGeneratorBase.so" );
145 
146 
147  if ( LHAPDF_DATA_PATH.Contains("afs") ) {
148  cout << endl << endl;
149  cout << "WARNING: LHAPDF_DATA_PATH points to an afs volume" << endl << endl;
150  cout << " You are advised to copy the PDF files you need into a local" << endl;
151  cout << " directory and set the LHAPDF_DATA_PATH to point to it." << endl;
152  cout << endl << endl;
153  }
154 
155  gSystem->Setenv("LHAPDF_DATA_PATH", LHAPDF_DATA_PATH.Data() );
156  gSystem->Load( "/opt/star/$STAR_HOST_SYS/lib/libLHAPDF.so");
157 
158  gSystem->Load( "Pythia8_1_62.so");
159 
160  gSystem->Load( "libMathMore.so" );
161 
162  // Force loading of xgeometry
163  gSystem->Load( "xgeometry.so" );
164 
165 // // And unloading of geometry
166 // TString geo = gSystem->DynamicPathName("geometry.so");
167 // if ( !geo.Contains("Error" ) ) {
168 // std::cout << "Unloading geometry.so" << endl;
169 // gSystem->Unload( gSystem->DynamicPathName("geometry.so") );
170 // }
171 
172  gSystem->Load( "Pythia8_1_62.so" );
173 
174  // Setup RNG seed and map all ROOT TRandom here
175  StarRandom::seed( rngSeed );
177 
178  //
179  // Create the primary event generator and insert it
180  // before the geant maker
181  //
182  // StarPrimaryMaker *
183  _primary = new Star_PrimaryMaker();
184  {
185  _primary -> SetFileName( "pythia8.starsim.root");
186  _primary -> SetVertex( 0.1, -0.1, 0.0 );
187  _primary -> SetSigma ( 0.1, 0.1, 30.0 );
188  chain -> AddBefore( "geant", _primary );
189  }
190 
191  //
192  // Setup an event generator
193  //
194  Pythia8("pp:200:bottomonium");
195 
196  //
197  // Setup cuts on which particles get passed to geant for
198  // simulation. (To run generator in standalone mode,
199  // set ptmin=1.0E9.)
200  // ptmin ptmax
201  _primary->SetPtRange (1.0E9, -1.0); // GeV
202  // _primary->SetPtRange (0.0, -1.0); // GeV
203  // etamin etamax
204  _primary->SetEtaRange ( -3.0, +3.0 );
205  // phimin phimax
206  _primary->SetPhiRange ( 0., TMath::TwoPi() );
207 
208 
209  //
210  // Setup a realistic z-vertex distribution:
211  // x = 0 gauss width = 1mm
212  // y = 0 gauss width = 1mm
213  // z = 0 gauss width = 30cm
214  //
215  _primary->SetVertex( 0., 0., 0. );
216  _primary->SetSigma( 0.1, 0.1, 30.0 );
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("y2012");
228  //* AGUSER/GKINE NTRACK ID [ PTLOW PTHIGH YLOW YHIGH PHILOW PHIHIGH ZLOW ZHIGH option ]
229 
230  command("gkine -4 0");
231  command("gfile o pythia8.starsim.fzd");
232 
233 
234  //
235  // Trigger on nevents
236  //
237  trig( nevents );
238 
239  //
240  // Finish the chain
241  //
242  chain->Finish();
243 
244  //
245  // EXIT starsim
246  //
247  command("call agexit"); // Make sure that STARSIM exits properly
248 
249 }
250 // ----------------------------------------------------------------------------
251 
void ReadFile(const char *f)
Read in a command file.
Definition: StarPythia8.h:93
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 Print(const Option_t *opts="head") const
void SetPhiRange(Double_t phimin, Double_t phimax)
Set phi range. Particles falling outside this range will be dropped from simulation.
virtual Int_t Finish()
Definition: StChain.cxx:85
void AddGenerator(StarGenerator *gener)
void SetBlue(const Char_t *b)
Sets the particle species for the blue beam.
static void seed(UInt_t s)
Definition: StarRandom.cxx:119
Base class for event records.
Definition: StarGenEvent.h:81
StarGenEvent * event()
Return a pointer to the event.
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 Set(const char *s)
Pass a string to Pythia8::Pythia::readString(), for user configuration.
Definition: StarPythia8.h:91
void SetVertex(Double_t x, Double_t y, Double_t z)
Set the x, y and z vertex position.