StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.stepper.C
1 
10 class St_geant_Maker;
11 St_geant_Maker *geant_maker = 0;
12 
13 class StarGenEvent;
14 StarGenEvent *event = 0;
15 
16 class StarPrimaryMaker;
17 StarPrimaryMaker *_primary = 0;
18 
19 class StarKinematics;
21 
22 TF1 *ptDist = 0;
23 TF1 *etaDist = 0;
24 
25 Double_t _zslice = 0;
26 Int_t _ntracks = 1;
27 Double_t _pt = 5.0; // GeV
28 Double_t _eta = 0.0;
29 const Char_t *_part = "pi-";
30 
31 
32 Int_t rngSeed = 12345;
33 
34 // ----------------------------------------------------------------------------
35 void geometry( TString tag, Bool_t agml=true )
36 {
37  TString cmd = "DETP GEOM "; cmd += tag; cmd+=" phys_off=1";
38 
39  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
40  geant_maker -> LoadGeometry(cmd);
41 
42  // make certain AgML loads
43  TString path = "$STAR/StarDb/AgMLGeometry";
44  Char_t *file = gSystem->Which( path.Data(), Form("Geometry.%s.C",tag.Data()), kReadPermission );
45  assert(file);
46 
47  TString cmdL = Form(".L %s",file);
48  TString cmdX = Form("CreateTable()");
49  TString cmdU = Form(".U %s",file);
50 
51  gInterpreter -> ProcessLine( cmdL );
52  gInterpreter -> Calc ( cmdX );
53  gInterpreter -> ProcessLine( cmdU );
54 
55 }
56 // ----------------------------------------------------------------------------
57 void command( TString cmd )
58 {
59  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
60  geant_maker -> Do( cmd );
61 }
62 // ----------------------------------------------------------------------------
63 void trig( Int_t n=1 )
64 {
65 
66  //
67  // Scan from zvertex
68  //
69  Double_t zvertex = _zslice;
70 
71  // Clear the chain from the previous event
72  chain->Clear();
73 
74  _primary->SetVertex( 0.0, 0.0, zvertex );
75  // kinematics->Kine( _ntracks, "pi-", 4.995, 5.005, -0.005, 0.005 );
76  // kinematics -> Kine( _ntracks, "pi-", 0.39995, 0.40005, -0.0005, 0.0005 );
77  kinematics -> Kine( _ntracks, _part, _pt - 0.005, _pt + 0.00t, _eta - 0.0005, _eta + 0.0005 );
78 
79  // Generate the event
80  chain->Make();
81 
82  // Print the event
83  //_primary->event()->Print();
84 
85 }
86 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
88 // ----------------------------------------------------------------------------
89 void Kinematics()
90 {
91 
92  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
93  gSystem->Load( "libKinematics.so");
94  kinematics = new StarKinematics();
95 
96  _primary->AddGenerator(kinematics);
97 }
98 
99 // ----------------------------------------------------------------------------
100 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
102 void LoadLibraries( const Char_t *chopts = "y2014a geant gstar usexgeom agml " )
103 {
104  gROOT->ProcessLine(".L bfc.C");
105  {
106  TString simple = chopts; //"y2012 geant gstar usexgeom agml ";
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  gSystem->Load( "StarGeneratorStep.so" );
116 
117  gSystem->Load( "libMathMore.so" );
118  gSystem->Load( "xgeometry.so" );
119 
120 }
121 // ----------------------------------------------------------------------------
122 // ----------------------------------------------------------------------------
123 // ----------------------------------------------------------------------------
124 //void starsim( Int_t nevents=1, Int_t rngSeed=1234 )
125 void starsim( Double_t zslice = 0.0,
126  Int_t nevents = 100,
127  Int_t ntracks = 50,
128  const Char_t *fzname = "stiscan_zslice.fz", // MC zebra file
129  const Char_t *roname = "stiscan_zslice.track_history.root", // Particle history file
130  const Char_t *rcname = "stiscan_zslice.evgen_record.root" // Event generator record
131  )
132 {
133 
134  LoadLibraries();
135 
136  _zslice = zslice;
137  _ntracks = ntracks;
138 
139  //
140  // Setup custom stepping
141  //
142  AgUStep *step = AgUStep::Instance();
143  {
144  step->Init( roname );
145  }
146 
147  // Setup RNG seed and map all ROOT TRandom here
148  StarRandom::seed( rngSeed );
150 
151  //
152  // Create the primary event generator and insert it
153  // before the geant maker
154  //
155  // StarPrimaryMaker *
156  _primary = new StarPrimaryMaker();
157  {
158  _primary -> SetFileName( rcname );
159  chain -> AddBefore( "geant", _primary );
160  }
161  _primary->SetSigma( 0.0, 0.0, 0.0 );
162 
163  Kinematics();
164 
165  //
166  // Initialize primary event generator and all sub makers
167  //
168  _primary -> Init();
169 
170 
171  //
172  // Setup geometry and agusread for particle input
173  //
174  geometry("y2014a");
175  command("gkine -4 0");
176 
177  command( "DCAY 0" );
178  command( "ANNI 0" );
179  command( "BREM 0" );
180  command( "COMP 0" );
181  command( "HADR 0" );
182  command( "MUNU 0" );
183  command( "PAIR 0" );
184  command( "PFIS 0" );
185  command( "PHOT 0" );
186  command( "RAYL 0" );
187  command( "LOSS 4" );
188  command( "DRAY 0" );
189  command( "MULS 0" );
190  command( "STRA 0" );
191  command( "physi" );
192 
193  //
194  // Setup output file
195  //
196  command( Form("gfile o %s",fzname ) );
197 
198 
199  //
200  // Trigger on events
201  //
202  for ( Int_t i=0;i<nevents;i++ ) trig();
203 
204  //
205  // Finish up the stepper
206  //
207  step->Finish();
208 
209  command("call agexit"); // Make sure that STARSIM exits properly
210 
211 }
212 // ----------------------------------------------------------------------------
213 
void SetSigma(Double_t sx, Double_t sy, Double_t sz, Double_t rho=0)
Star Simple Kinematics Generator.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void Init(const Char_t *filename="")
Initialize stepping routine. Opens TFile and creates TTree.
Definition: AgUStep.cxx:383
void AddGenerator(StarGenerator *gener)
Int_t Init()
Initialize generator.
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
Main steering class for event generation.
static void capture()
Capture gRandom random number generator.
Definition: StarRandom.cxx:57
Sparse class to hold track kinematics.
void Kine(Int_t ntrack, const Char_t *type="pi+,pi-,K+,K-,proton,antiproton", Double_t ptlow=0.0, Double_t pthigh=500.0, Double_t ylow=-10.0, Double_t yhigh=+10.0, Double_t philow=0.0, Double_t phihigh=TMath::TwoPi())
void SetVertex(Double_t x, Double_t y, Double_t z)
Set the x, y and z vertex position.