StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.cosmics.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 int nevent = 0;
21 
22 // ----------------------------------------------------------------------------
23 void geometry( TString tag, Bool_t agml=true )
24 {
25  TString cmd = "DETP GEOM "; cmd += tag;
26  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
27  geant_maker -> LoadGeometry(cmd);
28  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
29 }
30 // ----------------------------------------------------------------------------
31 void command( TString cmd )
32 {
33  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
34  geant_maker -> Do( cmd );
35 }
36 // ----------------------------------------------------------------------------
37 
38 const char* types[] = { "mu+", "mu-" };
39 void trig( Int_t n=1 )
40 {
41  for ( Int_t i=0; i<n; i++ ) {
42 
43  // Clear the chain from the previous event
44  chain->Clear();
45 
46  // Generate 1 mu minus at high pT
47  // kinematics->Kine( 1, "mu-", 10.0, 50.0, -2.0, 2.0 );
48 
49  // Generate 4 muons flat in pT and eta
50  // kinematics->Kine(4, "mu+", 0., 5., -2.0, +2.0 );
51 
52 
53  // Generate 4 neutral pions according to a PT and ETA distribution
54  // kinematics->Dist(4, "pi0", ptDist, etaDist );
55 
56  kinematics -> Cosmic( 1, types[i%2], 3.0, 10.0, 510.0, -10.0, +10.0, 5.0 );
57 
58  // Generate the event
59  chain->Make();
60 
61  // Print the event
62  _primary->event()->Print();
63 
64  command("gprint hits");
65 
66  }
67 }
68 // ----------------------------------------------------------------------------
69 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
71 void Kinematics()
72 {
73 
74  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
75  gSystem->Load( "libKinematics.so");
76  kinematics = new StarKinematics();
77 
78  _primary->AddGenerator(kinematics);
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 = "y2015a geant gstar usexgeom agml ";
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( "kinematics.starsim.root");
113  chain -> AddBefore( "geant", _primary );
114  }
115 
116  Kinematics();
117 
118  //
119  // Initialize primary event generator and all sub makers
120  //
121  _primary -> Init();
122 
123  //
124  // Setup geometry and set starsim to use agusread for input
125  //
126  geometry("y2015a");
127  command("gkine -4 0");
128  command("gfile o kinematics.starsim.fzd");
129 
130 
131  //
132  // Setup PT and ETA distributions
133  //
134 
135  Double_t pt0 = 3.0;
136  ptDist = new TF1("ptDist","(x/[0])/(1+(x/[0])^2)^6",0.0,10.0);
137  ptDist->SetParameter(0, pt0);
138  ptDist->Draw();
139 
140  etaDist = new TF1("etaDist","-TMath::Erf(x+2.6)*TMath::Erf(x-2.6)",-0.8,+0.8);
141 
142  //
143  // Trigger on nevents
144  //
145  trig( nevents );
146 
147  // command("call agexit"); // Make sure that STARSIM exits properly
148 
149 }
150 // ----------------------------------------------------------------------------
151 
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)
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.
void Cosmic(int ntrack, const char *type="mu+", double plow=3.0, double phigh=10.0, double radius=300.0, double zmin=-3.0, double zmax=+3.0, double dtheta=15.0)
Main steering class for event generation.
static void capture()
Capture gRandom random number generator.
Definition: StarRandom.cxx:57
Sparse class to hold track kinematics.