StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.pythia6.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 void geometry( TString tag, Bool_t agml=true )
17 {
18  TString cmd = "DETP GEOM "; cmd += tag;
19  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
20  geant_maker -> LoadGeometry(cmd);
21  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
22 }
23 // ----------------------------------------------------------------------------
24 void command( TString cmd )
25 {
26  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
27  geant_maker -> Do( cmd );
28 }
29 // ----------------------------------------------------------------------------
30 void trig( Int_t n=1 )
31 {
32  for ( Int_t i=0; i<n; i++ ) {
33  chain->Clear();
34  chain->Make();
35  }
36 }
37 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
40 void Pythia6( TString mode="pp:W", Int_t tune=320 )
41 {
42 
43  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
44  gSystem->Load( "libPythia6_4_28.so");
45  // gSystem->Load( "StarPythia6.so" );
46 
47  StarPythia6 *pythia6 = new StarPythia6("pythia6");
48  if ( mode=="pp:W" )
49  {
50  pythia6->SetFrame("CMS", 510.0 );
51  pythia6->SetBlue("proton");
52  pythia6->SetYell("proton");
53  if ( tune ) pythia6->PyTune( tune );
54 
55  // Setup pythia process
56  PySubs_t &pysubs = pythia6->pysubs();
57  pysubs.msel = 12;
58  pysubs.ckin(3)=4.0;
59 
60  }
61  if ( mode == "pp:minbias" )
62  {
63  pythia6->SetFrame("CMS", 510.0 );
64  pythia6->SetBlue("proton");
65  pythia6->SetYell("proton");
66  if ( tune ) pythia6->PyTune( tune );
67  }
68  if ( mode == "ep" )
69  {
70  Double_t pblue[]={0.,0.,30.0};
71  Double_t pyell[]={0.,0.,-320.0};
72  pythia6->SetFrame("3MOM", pblue, pyell );
73  pythia6->SetBlue("e-");
74  pythia6->SetYell("proton");
75  if ( tune ) pythia6->PyTune( tune );
76  }
77 
78  _primary->AddGenerator(pythia6);
79 }
80 // ----------------------------------------------------------------------------
81 // ----------------------------------------------------------------------------
82 // ----------------------------------------------------------------------------
83 void starsim( Int_t nevents=1, Int_t rngSeed=1234 )
84 {
85 
86  gROOT->ProcessLine(".L bfc.C");
87  {
88  TString simple = "y2012 geant gstar agml usexgeom ";
89  bfc(0, simple );
90  }
91 
92  gSystem->Load( "libVMC.so");
93 
94  gSystem->Load( "StarGeneratorUtil.so" );
95  gSystem->Load( "StarGeneratorEvent.so" );
96  gSystem->Load( "StarGeneratorBase.so" );
97 
98  gSystem->Load( "libMathMore.so" );
99  gSystem->Load( "xgeometry.so" );
100 
101  // Setup RNG seed and map all ROOT TRandom here
102  StarRandom::seed( rngSeed );
104 
105  //
106  // Create the primary event generator and insert it
107  // before the geant maker
108  //
109  // StarPrimaryMaker *
110  _primary = new StarPrimaryMaker();
111  {
112  _primary -> SetFileName( "pythia6.starsim.root");
113  chain -> AddBefore( "geant", _primary );
114  }
115 
116  //
117  // Setup an event generator
118  //
119  Pythia6( "pp:W" );
120 
121  //
122  // Setup cuts on which particles get passed to geant for
123  // simulation.
124  //
125  // If ptmax < ptmin indicates an infinite ptmax.
126  // ptmin will always be the low pT cutoff.
127  //
128  // ptmin ptmax
129  _primary->SetPtRange (0.0, -1.0); // GeV
130  //
131  // If etamax < etamin, there is no cut in eta.
132  // otherwise, particles outside of the specified range are cut.
133  //
134  // etamin etamax
135  // primary->SetEtaRange ( -3.0, +3.0 );
136  //
137  // phirange will be mapped into 0 to 2 pi internally.
138  //
139  // phimin phimax
140  _primary->SetPhiRange ( 0., TMath::TwoPi() );
141 
142 
143  //
144  // Setup a realistic z-vertex distribution:
145  // x = 0 gauss width = 1mm
146  // y = 0 gauss width = 1mm
147  // z = 0 gauss width = 30cm
148  //
149  _primary->SetVertex( 0., 0., 0. );
150  _primary->SetSigma( 0.1, 0.1, 30.0 );
151 
152  //
153  // Initialize primary event generator and all sub makers
154  //
155  _primary -> Init();
156 
157  //
158  // Setup geometry and set starsim to use agusread for input
159  //
160  geometry("y2012");
161  command("gkine -4 0");
162  command("gfile o pythia6.starsim.fzd");
163 
164 
165  //
166  // Trigger on nevents
167  //
168  trig( nevents );
169 
170  command("call agexit"); // Make sure that STARSIM exits properly
171 }
172 // ----------------------------------------------------------------------------
173 
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.
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 SetVertex(Double_t x, Double_t y, Double_t z)
Set the x, y and z vertex position.