StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runSimFlat.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 class StarKinematics;
17 
18 // Set magnetic field (reversed full)
19 Float_t field = -5.0;
20 //Float_t field = 0.0;
21 
22 // ----------------------------------------------------------------------------
23 void geometry( TString tag, Bool_t agml=true ){
24  TString cmd = "DETP GEOM "; cmd += tag; cmd += Form(" field=%f", field);
25  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
26  geant_maker -> LoadGeometry(cmd);
27  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
28 }
29 // ----------------------------------------------------------------------------
30 void command( TString cmd ){
31  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
32  geant_maker -> Do( cmd );
33 }
34 // ----------------------------------------------------------------------------
35 void trig( Int_t n=1, const char* pid="mu-", int print=0){
36  for ( Int_t i=0; i<n; i++ ) {
37  cout << "==== Event="<<i<<"===="<<endl;
38  // Clear the chain from the previous event
39  chain->Clear();
40  // In kinematics, generates single particle before Make is called.
41  kinematics->Kine( 1, pid, 2.99, 3.01, 2.50, 4.60, 0.0, 3.141592654*2.0);
42  //kinematics->Kine( 1, pid, 2.99, 3.01, 2.50, 4.20, 0.0, 3.141592654/2.0);
43  // Generate the event
44  chain->Make();
45  // Print the event
46  if(print>0) primary->event()->Print();
47  if(print>1) {
48  TIter Iterator = primary->event()->IterAll();
49  StarGenParticle *p = 0;
50  while( ( p = (StarGenParticle*)Iterator.Next() ) ){
51  TLorentzVector v = p->momentum();
52  cout << Form(" ===> pt=%7.3f eta=%7.3f phi=%7.3f\n",v.Pt(),v.Eta(),v.Phi());
53  }
54  }
55  if(print>2) command("gpri hits");
56  }
57 }
58 // ----------------------------------------------------------------------------
59 void Kinematics(){
60  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
61  gSystem->Load( "libKinematics.so");
62  kinematics = new StarKinematics();
63  primary->AddGenerator(kinematics);
64 }
65 // ----------------------------------------------------------------------------
66 void runSimFlat( Int_t nevents=1000, Int_t run=1, const char* pid="muon", int print=0){
67  gROOT->ProcessLine(".L bfc.C");{
68  TString simple = "y2015 geant gstar agml usexgeom";
69  bfc(0, simple );
70  }
71  gSystem->Load( "libVMC.so");
72  gSystem->Load( "StarGeneratorUtil.so" );
73  gSystem->Load( "StarGeneratorEvent.so" );
74  gSystem->Load( "StarGeneratorBase.so" );
75  gSystem->Load( "libMathMore.so" );
76  // gSystem->Load( "xgeometry.so" );
77 
78  // Create the primary event generator and insert it
79  // before the geant maker
80  primary = new StarPrimaryMaker();
81  {
82  chain -> AddBefore( "geant", primary );
83  // Set the output filename for the event record
84  primary -> SetFileName(Form("test_%s_run%i.root",pid,run));
85  // Set the x,y,z vertex and distribution
86  primary -> SetVertex( 0., 0., 0. );
87  primary -> SetSigma ( 0., 0., 0. );
88  }
89 
90  // Initialize primary event generator and all sub makers
91  Kinematics();
92  primary -> Init();
93 
94  // Initialize random number generator
96  StarRandom::seed(run);
97 
98  // Setup geometry and set starsim to use agusread for input
99  geometry("y2015");
100  command("gkine -4 0");
101  command(Form("gfile o test_%s_run%i.fzd",pid,run));
102 
103  // Switch off some physics
104  const Char_t *cmds[] = {
105  "CKOV 0"
106  };
107  for ( UInt_t i=0;i<sizeof(cmds)/sizeof(Char_t*); i++ ){command( cmds[i] );}
108 
109  // Trigger on nevents
110  trig(nevents, pid, print);
111 
112  command("call agexit");
113 }
114 // ----------------------------------------------------------------------------
115 
void Print(const Option_t *opts="head") const
Star Simple Kinematics Generator.
Yet another particle class.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void AddGenerator(StarGenerator *gener)
Int_t Init()
Initialize generator.
TLorentzVector momentum()
Return the 4-momentum of the particle.
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
StarGenEvent * event()
Return a pointer to the event.
Main steering class for event generation.
TIter IterAll(Bool_t dir=kIterForward)
Definition: StarGenEvent.h:173
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())