StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.kinematics.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 TF1 *ptDist = 0;
19 TF1 *etaDist = 0;
20 
21 // ----------------------------------------------------------------------------
22 void geometry( TString tag, Bool_t agml=true )
23 {
24  TString cmd = "DETP GEOM "; cmd += tag;
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 {
32  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
33  geant_maker -> Do( cmd );
34 }
35 // ----------------------------------------------------------------------------
36 void trig( Int_t n=1 )
37 {
38  for ( Int_t i=0; i<n; i++ ) {
39 
40  // Clear the chain from the previous event
41  chain->Clear();
42 
43  // Generate 1 mu minus at high pT
44  kinematics->Kine( 1, "mu-", 10.0, 50.0, -2.0, 2.0 );
45 
46  // Generate 4 muons flat in pT and eta
47  kinematics->Kine(4, "mu+", 0., 5., -2.0, +2.0 );
48 
49  // Generate 4 neutral pions according to a PT and ETA distribution
50  kinematics->Dist(4, "pi0", ptDist, etaDist );
51 
52  // Generate the event
53  chain->Make();
54 
55  // Print the event
56  _primary->event()->Print();
57  }
58 }
59 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
62 void Kinematics()
63 {
64 
65  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
66  gSystem->Load( "libKinematics.so");
67  kinematics = new StarKinematics();
68 
69  _primary->AddGenerator(kinematics);
70 }
71 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
74 void starsim( Int_t nevents=1, Int_t rngSeed=1234 )
75 {
76 
77  gROOT->ProcessLine(".L bfc.C");
78  {
79  TString simple = "y2018a geant gstar usexgeom agml ";
80  bfc(0, simple );
81  }
82 
83  gSystem->Load( "libVMC.so");
84 
85  gSystem->Load( "StarGeneratorUtil.so" );
86  gSystem->Load( "StarGeneratorEvent.so" );
87  gSystem->Load( "StarGeneratorBase.so" );
88 
89  gSystem->Load( "libMathMore.so" );
90  gSystem->Load( "xgeometry.so" );
91 
92  // Setup RNG seed and map all ROOT TRandom here
93  StarRandom::seed( rngSeed );
95 
96  //
97  // Create the primary event generator and insert it
98  // before the geant maker
99  //
100  // StarPrimaryMaker *
101  _primary = new StarPrimaryMaker();
102  {
103  _primary -> SetFileName( "kinematics.starsim.root");
104  chain -> AddBefore( "geant", _primary );
105  }
106 
107  Kinematics();
108 
109  //
110  // Initialize primary event generator and all sub makers
111  //
112  _primary -> Init();
113 
114  //
115  // Setup geometry and set starsim to use agusread for input
116  //
117  //geometry("y2012");
118  command("gkine -4 0");
119  command("gfile o kinematics.starsim.fzd");
120 
121 
122  //
123  // Setup PT and ETA distributions
124  //
125 
126  Double_t pt0 = 3.0;
127  ptDist = new TF1("ptDist","(x/[0])/(1+(x/[0])^2)^6",0.0,10.0);
128  ptDist->SetParameter(0, pt0);
129  ptDist->Draw();
130 
131  etaDist = new TF1("etaDist","-TMath::Erf(x+2.6)*TMath::Erf(x-2.6)",-0.8,+0.8);
132 
133  //
134  // Trigger on nevents
135  //
136  trig( nevents );
137 
138  command("call agexit"); // Make sure that STARSIM exits properly
139 
140 }
141 // ----------------------------------------------------------------------------
142 
void Print(const Option_t *opts="head") const
Star Simple Kinematics Generator.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void AddGenerator(StarGenerator *gener)
void Dist(Int_t ntrack, const Char_t *type, TF1 *pt, TF1 *y, TF1 *phi=0)
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
StarGenEvent * event()
Return a pointer to the event.
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())