StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
starsim_nightly_test.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 StarHijing;
16 StarHijing *hijing = 0;
17 
18 class StarKinematics;
19 StarKinematics* kine = 0;
20 
21 //____________________________________________________________
22 void geometry( TString tag, bool 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 
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 bool accept( TString table ) {
38  if ( table.Contains("_hit") ) return true;
39  if ( table.Contains("g2t_track") ) return true;
40  if ( table.Contains("g2t_vertex") ) return true;
41 }
42 //____________________________________________________________
43 void trig( int n=0 )
44 {
45  int stat = 0;
46 
47  HiMain1_t& himain1 = hijing->himain1();
48 
49  // Histograms will be created in TObjArray for every found hit table
50  TObjArray hists;
51 
52  for ( int i=0; i<n+1; i++ ) {
53  chain->Clear();
54 
55 
56  stat = chain->Make();
57  if ( stat ) break; // EOF or...?
58 
59  int np = himain1.nwounded_yell;
60  int nt = himain1.nwounded_blue;
61  int npart = np+nt;
62 
63  // Embed muons in proportion to number of participants
64  kine->Kine( npart/10, "mu-,mu+", 1.0, 20.0, -0.625, 0.625 );
65 
66  TDataSet* gData = chain->GetDataSet("geant"); if (0==gData) continue;
67  TDataSetIter gIter(gData);
68 
69  TTable* table = (TTable*)gIter.Next();
70  while ( table ) {
71  TString name = table->GetName();
72  // Accumulate number of hits, vertexs and tracks
73  if ( accept(name) ) {
74  TH1F* h = hists.FindObject(Form("num_%s",name.Data()));
75  if ( 0==h ) {
76  h = new TH1F(Form("num_%s",name.Data()),Form("Size of table [%s] / n_participants ",name.Data()),100,0.,100.);
77  h->SetBit(TH1::kCanRebin);
78  hists.Add(h);
79  }
80  // Fill number of hits
81  h->Fill( table->GetNRows() / npart );
82  }
83  table = (TTable*)gIter.Next();
84  }
85 
86  }
87 
88  // Iterate over all histograms and dump average and RMS
89  const TObjArray* p = &hists;
90  TObjArrayIter Iter( p );
91 
92  TH1F* nhits = (TH1F*)Iter();
93  while ( nhits ) {
94 
95  std::cout << "STARSIM NIGHTLY QA: " << nhits->GetTitle() << " nhits = " << nhits->GetMean() << " rms = " << nhits->GetRMS() << std::endl;
96 
97  nhits= (TH1F*)Iter();
98 
99  }
100 
101 
102 
103 
104 }
105 //____________________________________________________________
106 void Kinematics()
107 {
108 
109  // gSystem->Load( "libStarGeneratorPoolPythia6_4_23.so" );
110  gSystem->Load( "libKinematics.so");
111  kine = new StarKinematics();
112 
113  _primary->AddGenerator(kine);
114 }
115 void Hijing()
116 {
117  hijing = new StarHijing();
118  hijing->SetTitle("Hijing 1.383");
119 
120  // Setup collision frame, energy and beam species
121  hijing->SetFrame("CMS",200.0);
122  hijing->SetBlue("Au");
123  hijing->SetYell("Au");
124 
125  // Fixed impact parameter of 20
126  // hijing->SetImpact(19.9999, 20.0001); // Impact parameter min/max (fm) 0. 30.
127  hijing->SetImpact(10.0, 11.0); // Impact parameter min/max (fm) 0. 30.
128 
129  _primary -> AddGenerator(hijing);
130 
131  // Keep it in the central region
132  _primary -> SetCuts( 1.0E-6 , -1., -4.25, +4.25 );
133 
134 }
135 //____________________________________________________________
136 //void starsim( int nevents=10,int rngSeed=1234, const char* tag="y2018" )
137 void starsim_nightly_test( const char* tag="y2012a", int nevents=5 )
138 {
139 
140  gROOT->ProcessLine(".L bfc.C");
141  {
142  TString simple = Form("%s geant gstar usexgeom agml ",tag);
143  bfc(0, simple );
144  }
145 
146  gSystem->Load( "libVMC.so");
147 
148  gSystem->Load( "StarGeneratorUtil.so" );
149  gSystem->Load( "StarGeneratorEvent.so" );
150  gSystem->Load( "StarGeneratorBase.so" );
151  gSystem->Load( "libMathMore.so" );
152  gSystem->Load( "libHijing1_383.so");
153  gSystem->Load( "xgeometry.so" );
154 
155  // Setup RNG seed and map all ROOT TRandom here
156  StarRandom::seed( 12345 ); // fixed seed for nightly tests
158 
159  //
160  // Create the primary event generator and insert it
161  // before the geant maker
162  //
163  _primary = new StarPrimaryMaker();
164  {
165  _primary -> SetFileName( "hijing.starsim.root");
166  chain -> AddBefore( "geant", _primary );
167  }
168 
169 
170  //
171  // Setup an event generator
172  //
173  Kinematics();
174  Hijing();
175 
176  //
177  // Initialize primary event generator and all sub makers
178  //
179  _primary -> Init();
180 
181  // Configure HIJING simulation
182  HiParnt_t &hiparnt = hijing->hiparnt();
183  {
184  hiparnt.ihpr2(4) = 0; // Jet quenching (1=yes/0=no) 0
185  hiparnt.ihpr2(3) = 0; // Hard scattering (1=yes/0=no)
186  //hiparnt.hipr1(10) = -2.5; // pT jet (negative indicates lower limit)
187  hiparnt.ihpr2(8) = 10; // Max number of jets / nucleon
188  hiparnt.ihpr2(11) = 1; // Set baryon production
189  hiparnt.ihpr2(12) = 1; // Turn on/off decay of particles [1=recommended]
190  hiparnt.ihpr2(18) = 0; // 1=B quark production. 0=C quark production.
191  hiparnt.hipr1(7) = 5.35; // Set B production ???? Not really used... Really ????
192 
193  // For more configuration options, see the HIJING manual
194  // http://ntc0.lbl.gov/~xnwang/hijing/doc.html
195  }
196  //
197  // Setup geometry and set starsim to use agusread for input
198  //
199  //geometry("y2012");
200  command("gkine -4 0");
201  // command("gfile o hijing.starsim.fzd");
202 
203 
204 
205  //
206  // Trigger on nevents
207  //
208  trig( nevents );
209 
210  // command("gprint kine");
211 
212  // command("call agexit"); // Make sure that STARSIM exits properly
213 
214 }
215 //____________________________________________________________
216 
HIJING /HIPARNT/ common block/.
Definition: Hijing.h:79
void SetFrame(const Char_t *frame, const Double_t val)
Star Simple Kinematics Generator.
void SetImpact(Double_t bmin, Double_t bmax)
Set the minimum and maximum impact parameters for the collision (HI generators)
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void AddGenerator(StarGenerator *gener)
void SetBlue(const Char_t *b)
Sets the particle species for the blue beam.
int & ihpr2(int i)
Definition: Hijing.h:94
Int_t Init()
Initialize generator.
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
HiParnt_t & hiparnt()
Returns a reference to the hijing parameters.
Definition: StarHijing.h:58
HiMain1_t & himain1()
Returns a reference to the hijing main1 block.
Definition: StarHijing.h:62
virtual TDataSet * Next() const
Definition: TDataSet.cxx:447
float & hipr1(int i)
Definition: Hijing.h:90
Interface to the HIJING event generator.
Definition: StarHijing.h:48
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
Main steering class for event generation.
void SetYell(const Char_t *y)
Sets the particle species for the yellow beam.
Definition: TTable.h:48
static void capture()
Capture gRandom random number generator.
Definition: StarRandom.cxx:57
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())