StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.addparticle.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 
24 class St_geant_Maker;
25 St_geant_Maker *geant_maker = 0;
26 
27 class StarGenEvent;
28 StarGenEvent *event = 0;
29 
30 class StarPrimaryMaker;
31 StarPrimaryMaker *_primary = 0;
32 
33 class StarKinematics;
35 
36 TF1 *ptDist = 0;
37 TF1 *etaDist = 0;
38 
39 // ----------------------------------------------------------------------------
40 void geometry( TString tag, Bool_t agml=true )
41 {
42  TString cmd = "DETP GEOM "; cmd += tag;
43  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
44  geant_maker -> LoadGeometry(cmd);
45  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
46 }
47 // ----------------------------------------------------------------------------
48 void command( TString cmd )
49 {
50  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
51  geant_maker -> Do( cmd );
52 }
53 // ----------------------------------------------------------------------------
54 void Particles()
55 {
57  // TParticlePDG *myNewParticle = new TParticlePDG( "X(2430)", "Lambda-xi0",
58  // 2430.543, true, 2.5e-15, 0,
59  // "dibaryon", 700, 0,
60  // /* G3 ID */ 40009);
61 
62  //char* name; char* title;
63  //double mass(GeV); bool stable; dobule width(GeV); double charge;
64  //char* particleClass; int pdgCode; int anti; int tracking Code;
65 
66 
67  if ( 1 )
68  {
69  TString name = "lamXi0";
70  TString title = "Lambda Xi0 Dibaryon";
71  Double_t mass = 2.430543;
72  Bool_t stable = false;
73  Double_t width = 2.5E-15;
74  Double_t charg3 = 0;
75  TString _class = "dibaryon";
76  Int_t pdgCode = 2033223122;
77  Int_t g3Code = 60002; // must exist in gstar_part.g
78 
79  TParticlePDG *part = data.AddParticle(name, title, mass, stable, width, charg3, _class, pdgCode, 0, g3Code );
80  }
81 
82  if ( 1 )
83  {
84  // ! omega(782) --> e+ e- 100%
85  // Particle omega code=10150 TrkTyp=3 mass=.782 charge=0 tlife=7.79E-23,
86  // pdg=0 bratio = { 1.00, },
87  // mode = { 0203, }
88  TString name = "omega(782)";
89  TString title = "omgea(782)";
90  Double_t mass = 0.782;
91  Bool_t stable = false;
92  Double_t width = 0.;
93  Double_t charg3 = 0.;
94  TString _class = "meson";
95  Int_t pdgCode = 223;
96  Int_t g3Code = 10150; // must exist in gstar_part.g
97 
98  TParticlePDG *part = data.AddParticle(name, title, mass, stable, width, charg3, _class, pdgCode, 0, g3Code );
99  }
100 
101  // command("gexe $STAR_LIB/gstar.so");
102  // gSystem->Load(".$STAR_HOST_SYS/lib/gstar.so");
103  gSystem->Load("libgstar.so");
104  command("call gstar");
105 
106 }
107 
108 // ----------------------------------------------------------------------------
109 void trig( Int_t n=1 )
110 {
111  for ( Int_t i=0; i<n; i++ )
112  {
113  // Clear the chain from the previous event
114  chain->Clear();
115 
116  kinematics->Kine(1, "lamXi0", 0.0, 10.0, -1.0, +1.0 );// number; particle; pt low high; eta low high
117  // kinematics->Kine(5, "omega(782)", 0.0, 10.0, -1.0, +1.0 );// number; particle; pt low high; eta low high
118 
119  // Generate 4 muons flat in pT and eta
120  // kinematics->Kine(5, "proton", 0., 10., -1.0, +1.0 );
121 
122  // Generate 4 muons according to a PT and ETA distribution
123  // kinematics->Dist(4, "mu-", ptDist, etaDist );
124 
125  // Generate the event
126  chain->Make();
127 
128  // Print the event
129  _primary->event()->Print();
130  }
131 }
132 // ----------------------------------------------------------------------------
133 // ----------------------------------------------------------------------------
134 // ----------------------------------------------------------------------------
135 void Kinematics()
136 {
137  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
138  gSystem->Load( "libKinematics.so");
139  kinematics = new StarKinematics();
140 
141  _primary->AddGenerator(kinematics);
142 }
143 // ----------------------------------------------------------------------------
144 // ----------------------------------------------------------------------------
145 // ----------------------------------------------------------------------------
146 void starsim( Int_t nevents=1, Int_t rngSeed=1234 )
147 {
148  gROOT->ProcessLine(".L bfc.C");
149  {
150  TString simple = "y2012 geant gstar usexgeom agml ";
151  bfc(0, simple );
152  }
153 
154  gSystem->Load( "libVMC.so");
155 
156  gSystem->Load( "StarGeneratorUtil.so" );
157  gSystem->Load( "StarGeneratorEvent.so" );
158  gSystem->Load( "StarGeneratorBase.so" );
159 
160  gSystem->Load( "libMathMore.so" );
161  gSystem->Load( "xgeometry.so" );
162 
163  // Setup RNG seed and captuire ROOT TRandom
164  StarRandom::seed(rngSeed);
166 
167  //
168  // Create the primary event generator and insert it
169  // before the geant maker
170  //
171  // StarPrimaryMaker *
172  _primary = new StarPrimaryMaker();
173  {
174  _primary -> SetFileName( "kinematics.starsim.root");
175  chain -> AddBefore( "geant", _primary );
176  }
177 
178  Particles();
179  Kinematics();
180 
181  //
182  // Initialize primary event generator and all sub makers
183  //
184  _primary -> Init();
185 
186  //
187  // Setup geometry and set starsim to use agusread for input
188  //
189  geometry("y2012");
190  command("gkine -4 0");
191  command("gfile o pythia6.starsim.fzd");
192 
193  //
194  // Setup PT and ETA distributions
195  //
196 
197  Double_t pt0 = 3.0;
198  ptDist = new TF1("ptDist","(x/[0])/(1+(x/[0])^2)^6",0.0,10.0);
199  ptDist->SetParameter(0, pt0);
200  ptDist->Draw();
201 
202  etaDist = new TF1("etaDist","-TMath::Erf(x+2.6)*TMath::Erf(x-2.6)",-0.8,+0.8);
203 
204  //
205  // Trigger on nevents
206  //
207  trig( nevents );
208 
209  // command("call agexit"); // Make sure that STARSIM exits properly
210 }
211 // ----------------------------------------------------------------------------
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
static StarParticleData & instance()
Returns a reference to the single instance of this class.
Interface to PDG information.
void AddGenerator(StarGenerator *gener)
void AddParticle(const Char_t *name, TParticlePDG *particle)
Add a particle to the database.
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())