StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.pythia8standalone.C
1 
20 const bool GEANT_HANDLES_DECAYS = true;
21 
22 class St_geant_Maker;
23 St_geant_Maker *geant_maker = 0;
24 
25 class StarGenEvent;
26 StarGenEvent *event = 0;
27 
28 class StarPrimaryMaker;
29 StarPrimaryMaker *_primary = 0;
30 
31 class StarPythia8;
32 StarPythia8* _pythia8;
33 
34 // ----------------------------------------------------------------------------
35 void trig( Int_t n=1 )
36 {
37  for ( Int_t i=0; i<n; i++ ) {
38  chain->Clear();
39  chain->Make();
40  _primary -> event() -> Print();
41  }
42 }
43 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
46 void Pythia6( TString mode="pp:W", Int_t tune=320 )
47 {
48 
49  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
50  gSystem->Load( "libPythia6_4_28.so");
51 
52  StarPythia6 *pythia6 = new StarPythia6("pythia6");
53  if ( mode=="pp:W" )
54  {
55  pythia6->SetFrame("CMS", 510.0 );
56  pythia6->SetBlue("proton");
57  pythia6->SetYell("proton");
58  if ( tune ) pythia6->PyTune( tune );
59 
60  // Setup pythia process
61  PySubs_t &pysubs = pythia6->pysubs();
62  int& msel = pysubs.msel;
63  msel = 12;
64 
65  // Setup other common block variables / array elements
66  float& ckin3 = pysubs.ckin(3);
67  ckin3 = 4.0;
68 
69  //
70  // Set particles to be stable so that the decay manager
71  // can handle them in the starsim phase
72  //
73  pythia6 -> SetDecayFlag( +24, 0 ); // W+
74  pythia6 -> SetDecayFlag( -24, 0 ); // W-
75  pythia6 -> SetDecayFlag( +23, 0 ); // Z0
76  pythia6 -> SetDecayFlag( -23, 0 ); // Z0
77  pythia6 -> SetDecayFlag( +15, 0 ); // tau+
78  pythia6 -> SetDecayFlag( -15, 0 ); // tau-
79 
80 
81  }
82  if ( mode == "pp:minbias" )
83  {
84  pythia6->SetFrame("CMS", 510.0 );
85  pythia6->SetBlue("proton");
86  pythia6->SetYell("proton");
87  if ( tune ) pythia6->PyTune( tune );
88  }
89  if ( mode == "ep" )
90  {
91  Double_t pblue[]={0.,0.,30.0};
92  Double_t pyell[]={0.,0.,-320.0};
93  pythia6->SetFrame("3MOM", pblue, pyell );
94  pythia6->SetBlue("e-");
95  pythia6->SetYell("proton");
96  if ( tune ) pythia6->PyTune( tune );
97  }
98 
99  _primary->AddGenerator(pythia6);
100 }
101 // ----------------------------------------------------------------------------
102 // ----------------------------------------------------------------------------
103 // ----------------------------------------------------------------------------
104 void Pythia8( TString config="pp:W", const char* _library="libPythia8_1_62.so" )
105 {
106  gSystem->Load( _library );
107 
108  //
109  // Create the pythia 8 event generator and add it to
110  // the primary generator
111  //
112  StarPythia8 *pythia8 = new StarPythia8();
113  _pythia8=pythia8;
114  if ( config=="pp:W" )
115  {
116  pythia8->SetFrame("CMS", 510.0);
117  pythia8->SetBlue("proton");
118  pythia8->SetYell("proton");
119 
120  pythia8->Set("WeakSingleBoson:all=off");
121  pythia8->Set("WeakSingleBoson:ffbar2W=on");
122  pythia8->Set("24:onMode=0"); // switch off all W+/- decaus
123  pythia8->Set("24:onIfAny 11 -11"); // switch on for decays to e+/-
124 
125  }
126  if ( config=="pp:minbias" )
127  {
128  pythia8->SetFrame("CMS", 510.0);
129  pythia8->SetBlue("proton");
130  pythia8->SetYell("proton");
131 
132  pythia8->Set("SoftQCD:minBias = on");
133  }
134 
135  _primary -> AddGenerator( pythia8 );
136 
137 }
138 // ----------------------------------------------------------------------------
139 // ----------------------------------------------------------------------------
140 // ----------------------------------------------------------------------------
141 void starsim( Int_t nevents=1000, UInt_t rngSeed = 12345 )
142 {
143 
144  gROOT->ProcessLine(".L bfc.C");
145  {
146  TString simple = "tables nodefault";
147  bfc(0, simple );
148  }
149 
150  gSystem->Load( "libVMC.so");
151  gSystem->Load( "St_g2t.so" );
152  gSystem->Load( "St_geant_Maker.so" );
153 
154  gSystem->Load( "StarGeneratorUtil.so" );
155  gSystem->Load( "StarGeneratorEvent.so" );
156  gSystem->Load( "StarGeneratorBase.so" );
157 
158  gSystem->Load( "libMathMore.so" );
159 
160  //
161  // Create the primary event generator and insert it
162  // before the geant maker
163  //
164  // StarPrimaryMaker *
165  _primary = new StarPrimaryMaker();
166  {
167  _primary -> SetFileName( "pythia8.starsim.root");
168  // chain -> AddBefore( "geant", primary );
169  }
170 
171  //
172  // Setup an event generator
173  //
174  Pythia8( "pp:minbias" );
175 
176  //
177  // Initialize random number generator
178  //
179  StarRandom &random = StarRandom::Instance();
180  random.capture(); // maps all ROOT TRandoms to StarRandom
181  random.seed( rngSeed );
182 
183 
184  //
185  // Setup cuts on which particles get passed to geant for
186  // simulation. (To run generator in standalone mode,
187  // set ptmin=1.0E9.)
188  // ptmin ptmax
189  _primary->SetPtRange (1.0E9, -1.0); // GeV
190  // etamin etamax
191  _primary->SetEtaRange ( -5.0, +5.0 );
192  // phimin phimax
193  _primary->SetPhiRange ( 0., TMath::TwoPi() );
194 
195 
196  //
197  // Fixed x, y, z vertex
198  //
199  _primary->SetVertex( 0., 0., 0. );
200  _primary->SetSigma( 0., 0., 0. );
201 
202  //
203  // Initialize primary event generator and all sub makers
204  //
205  _primary -> Init();
206 
207 
208  //
209  // By default we have configured pythia8 such that the following
210  // particles are stable, so that geant is responsible for decaying
211  // them. If you need pythia to decay these for analysis, enable
212  // the following code block...
213  //
214  if ( GEANT_HANDLES_DECAYS ) {
215  _pythia8->Set("111:onMode=1"); // pi0
216  _pythia8->Set("211:onMode=1"); // pi+/-
217  _pythia8->Set("221:onMode=1"); // eta
218  _pythia8->Set("321:onMode=1"); // K+/-
219  _pythia8->Set("310:onMode=1"); // K short
220  _pythia8->Set("130:onMode=1"); // K long
221  _pythia8->Set("3122:onMode=1"); // Lambda 0
222  _pythia8->Set("3112:onMode=1"); // Sigma -
223  _pythia8->Set("3222:onMode=1"); // Sigma +
224  _pythia8->Set("3212:onMode=1"); // Sigma 0
225  _pythia8->Set("3312:onMode=1"); // Xi -
226  _pythia8->Set("3322:onMode=1"); // Xi 0
227  _pythia8->Set("3334:onMode=1"); // Omega -
228  }
229 
230 
231  //
232  // Trigger on nevents
233  //
234  trig( nevents );
235 
236 }
237 // ----------------------------------------------------------------------------
238 
void PyTune(Int_t tune)
Calls the pytune function.
Definition: StarPythia6.cxx:44
static StarRandom & Instance()
Obtain the single instance of the random number generator.
Definition: StarRandom.cxx:87
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 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.
A class for providing random number generation.
Definition: StarRandom.h:30
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
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.
int Init()
Initialize the event generator.
Definition: StarPythia8.cxx:51
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.