StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.decayer.evtgen.tau.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 // By Y. Zhang 07/29/2014
7 // Modified from Jason 's macro
8 // Added real distributions for pT, y
9 
10 
11 class St_geant_Maker;
12 St_geant_Maker *geant_maker = 0;
13 
14 class StarGenEvent;
15 StarGenEvent *event = 0;
16 
17 class StarPrimaryMaker;
18 StarPrimaryMaker *_primary = 0;
19 
20 class StarKinematics;
22 
23 //Initialize the settings:
24 Float_t vx = 0.;
25 Float_t vy = 0.;
26 Float_t vz = 0.;
27 Float_t vx_sig = 0.01;
28 Float_t vy_sig = 0.01;
29 Float_t vz_sig = 2.0;
30 //Float_t minVz = -5.0;
31 //Float_t maxVz = +5.0;
32 Float_t minPt = 0.0;
33 Float_t maxPt = +20;
34 Float_t minY = -1.0;
35 Float_t maxY = +1.0;
36 
37 // ----------------------------------------------------------------------------
38 void geometry( TString tag, Bool_t agml=true )
39 {
40  TString cmd = "DETP GEOM "; cmd += tag;
41  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
42  geant_maker -> LoadGeometry(cmd);
43  // if ( agml ) command("gexec $STAR_LIB/libxgeometry.so");
44 }
45 // ----------------------------------------------------------------------------
46 void command( TString cmd )
47 {
48  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
49  geant_maker -> Do( cmd );
50 }
51 // ----------------------------------------------------------------------------
52 void trig( Int_t n=0 )
53 {
54  for ( Int_t i=0; i<n+1; i++ ) {
55  chain->Clear();
56 
57  // Throw single tau-
58  if (kinematics) kinematics -> Kine( 1, "tau-", 10.0, 20.0, -1.0, 1.0 );
59 
60  chain->Make();
61  }
62 }
63 
64 void Kinematics()
65 {
66 
67  kinematics = new StarKinematics("EvtGen Decay");
68  _primary -> AddGenerator(kinematics);
69 }
70 //
71 void starsim( Int_t nevents=1, Int_t Index = 0, Int_t rngSeed=4321 )
72 {
73 
74  gROOT->ProcessLine(".L bfc.C");
75  {
76  TString simple = "y2014 geant gstar usexgeom agml ";
77  bfc(0, simple );
78  }
79 
80  gSystem->Load( "libVMC.so");
81 
82  gSystem->Load( "StarGeneratorUtil.so" );
83  gSystem->Load( "StarGeneratorEvent.so" );
84  gSystem->Load( "StarGeneratorBase.so" );
85  gSystem->Load( "StarGeneratorDecay.so" );
86  gSystem->Load( "libMathMore.so" );
87  gSystem->Load( "libHijing1_383.so");
88  gSystem->Load( "libKinematics.so");
89  gSystem->Load( "xgeometry.so" );
90 
91  gSystem->Load("libHepMC2_06_09.so");
92  gSystem->Load("libPythia8_1_86.so");
93  gSystem->Load("libPhotos3_61.so");
94  gSystem->Load("libTauola1_1_5.so");
95  gSystem->Load("libEvtGen1_06_00.so");
96 
97 
98  // force gstar load/call nope
99  // gSystem->Load( "gstar.so" );
100  // command("call gstar");
101 
102  // Setup RNG seed and map all ROOT TRandom here
103  StarRandom::seed( rngSeed );
105 
106  TString rootname = "tau.root";
107  TString fzname = "gfile o tau.fzd";
108 
109  //
110  // Create the primary event generator and insert it
111  // before the geant maker
112  //
113  _primary = new StarPrimaryMaker();
114  {
115  _primary -> SetFileName(rootname);
116  chain -> AddBefore( "geant", _primary );
117  }
118 
119  //
120  // These should be adjusted to your best vertex estimates
121  //
122  _primary -> SetVertex( vx,vy,vz );
123  _primary -> SetSigma( vx_sig,vy_sig,vz_sig );
124 
125 
126  //
127  // Setup single particle
128  //
129  Kinematics();
130 
131 
132  //
133  // Setup decay manager
134  //
135  StarDecayManager *decayMgr = AgUDecay::Manager();
136  StarEvtGenDecayer *decayEvt = new StarEvtGenDecayer();
137  //decayEvt->SetDecayTable("StRoot/StSimulationMaker/Decay_Table/Jpsi.DEC");
138  decayMgr->AddDecayer( 0, decayEvt ); // Handle any decay requested
139  // decayEvt->SetDebug(1);
140 
141 
142  //
143  // Initialize primary event generator and all sub makers
144  //
145  _primary -> Init();
146 
147  //
148  // Setup geometry and set starsim to use agusread for input
149  //
150  //geometry("y2014");
151  command("gkine -4 0");
152  command(fzname);
153 
154  //
155  // Trigger on nevents
156  //
157  trig( nevents );
158 
159  _primary->event()->Print();
160 
161  command("call agexit"); // Make sure that STARSIM exits properly
162 
163 }
164 // ----------------------------------------------------------------------------
165 
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
Connects VMC to class(es) which handle particle decays.
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
STAR wrapper for EvtGen Decayer.
StarGenEvent * event()
Return a pointer to the event.
Main steering class for event generation.
void AddDecayer(Int_t pdgid, TVirtualMCDecayer *decayer)
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())