StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim.starlight.C
1 // macro to instantiate Grant3 from within the STAR C++ framework and get the starsim prompt
2 // To use it do:
3 // root4star
4 // [0] .L StarLight.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 // ----------------------------------------------------------------------------
16 void geometry( TString tag, Bool_t agm1=true )
17 {
18  TString cmd = "DETP GEOM "; cmd += tag;
19  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
20  geant_maker -> LoadGeometry(cmd);
21 }
22 // ----------------------------------------------------------------------------
23 void command( TString cmd )
24 {
25  if ( !geant_maker ) geant_maker = (St_geant_Maker *)chain->GetMaker("geant");
26  geant_maker -> Do( cmd );
27 }
28 // ----------------------------------------------------------------------------
29 void trig( Int_t n=1 )
30 {
31  for ( Int_t i=0; i<n; i++ )
32  {
33  chain->Clear();
34  chain->Make();
35  _primary->event()->Print();
36  }
37 }
38 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
41 void STARlight( TString mode="pp" )
42 {
43 
44  gSystem->Load( "libStarLight.so" );
45 
46  starlight = new StarLightGen( "STARlight" );
47  if ( mode = "pp" )
48  {
49  starlight->SetFrame("CMS",510);
50  starlight->SetBlue("proton");
51  starlight->SetYell("proton");
52  }
53 
54  _primary->AddGenerator(starlight);
55 }
56 // ----------------------------------------------------------------------------
57 // ----------------------------------------------------------------------------
58 // ----------------------------------------------------------------------------
59 void starsim( Int_t nevents=1, Int_t rngSeed=1234 )
60 {
61 
62  gROOT->ProcessLine( ".L bfc.C" );
63  {
64  TString simple = "y2012 geant gstar usexgeom agml ";
65  bfc( 0, simple );
66  }
67 
68  gSystem->Load( "libVMC.so" );
69 
70  gSystem->Load( "StarGeneratorUtil.so" );
71  gSystem->Load( "StarGeneratorEvent.so" );
72  gSystem->Load( "StarGeneratorBase.so" );
73 
74  gSystem->Load( "libMathMore.so" );
75  gSystem->Load( "xgeometry.so" );
76 
77  // Setup RNG seed and map all ROOT TRandom here
78  StarRandom::seed( rngSeed );
80 
81  //
82  _primary = new StarPrimaryMaker();
83  {
84  _primary->SetFileName( "StarLight.starsim.root" );
85  chain->AddBefore("geant",_primary);
86  }
87 
88  STARlight( "pp" );
89 
90  _primary->Init();
91 
92  geometry( "y2012" );
93  command( "gkine -4 0" );
94  command( "gfile o StarLight.starsim.fzd" );
95 
96  trig( nevents );
97 
98  command("call agexit"); // Make sure that STARSIM exits properly
99 
100 
101 }
102 // ----------------------------------------------------------------------------
void SetFileName(const Char_t *name)
Set the filename of the output TTree.
void Print(const Option_t *opts="head") const
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void AddGenerator(StarGenerator *gener)
Interface to the StarLightGen (c++ version) event generator.
Definition: StarLightGen.h:19
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