StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
simM2Maker.C
1 #ifndef __CINT__
2 #include "TSystem.h"
3 #include "TBrowser.h"
4 #include "TBenchmark.h"
5 #include "TClassTable.h"
6 #include "StBFChain.h"
7 #include "St_tcl_Maker/St_tcl_Maker.h"
8 #include "St_tpt_Maker/St_tpt_Maker.h"
9 #include "StEvent.h"
10 #include "St_geant_Maker/St_geant_Maker.h"
11 #include "StIOMaker/StIOMaker.h"
12 #include "StEventDisplayMaker/StEventDisplayMaker.h"
13 #include "StEventMaker/StEventMaker.h"
14 #include "StAssociationMaker/StMcParameterDB.h"
15 #include "St_dst_Maker/StV0Maker.h"
16 #include "xdf2root/St_XDFFile.h"
17 #include "StTpcT0Maker/StTpcT0Maker.h"
18 
19 gSystem->Load("StDetectorDbMaker");
20 
21 void Usage();
22 void Load();
23 
24 #else
25 
26 class StMaker;
27 class StBFChain;
28 class StEvent;
29 class St_geant_Maker;
30 class StIOMaker;
31 class St_XDFFile;
32 class StEventDisplayMaker;
33 class StEventMaker;
34 class StTpcT0Maker;
35 class StChain;
36 class StAssociationMaker;
37 class StMcAnalysisMaker;
38 
39 #endif
40 
41 #include <string>
42 class St_DataSet;
44 StChain *chain;
45 TBrowser *brow=0;
46 
47 
48 // The acual file to be used is passed as an argument to the macro, or a default can be set
49 
50 void simM2Maker (
51  const char *MainFile="/star/institutions/rice/geurts/sim/tof/pythia_0.geant.root",
52  Int_t nevents=10,
53  const char *outFileName="test.root"
54  )
55 {
56  // Load all the System libraries
57  gSystem->Load("StarRoot");
58  gSystem->Load("St_base");
59  gSystem->Load("StChain");
60  gSystem->Load("libglobal_Tables");
61  gSystem->Load("libgen_Tables");
62  gSystem->Load("libsim_Tables");
63  gSystem->Load("StUtilities");
64  gSystem->Load("StIOMaker");
65  gSystem->Load("StarClassLibrary");
66  gSystem->Load("StDbLib.so");
67  gSystem->Load("StDbBroker.so");
68  gSystem->Load("libStDb_Tables.so");
69  gSystem->Load("St_db_Maker.so");
70  gROOT->Macro("loadMuDst.C");
71  gSystem->Load("StTpcDb");
72  gSystem->Load("StDetectorDbMaker");
73  gSystem->Load("StDbUtilities");
74  gSystem->Load("StBFChain");
75  gSystem->Load("StChallenger");
76  gSystem->Load("StEvent");
77  gSystem->Load("StEventMaker");
78  gSystem->Load("StIOMaker");
79  gSystem->Load("StBTofUtil");
80  gSystem->Load("St_Tables");
81  gSystem->Load("StEmcUtil");
82  gSystem->Load("StAssociationMaker");
83  gSystem->Load("StMcAnalysisMaker");
84  gSystem->Load("StMcEvent");
85  gSystem->Load("StMcEventMaker");
86  gSystem->Load("St_g2t"); // is a part od St_Tables
87  gSystem->Load("geometry");
88  gSystem->Load("St_geant_Maker");
89  gSystem->Load("StTableUtilities");
90  gSystem->Load("StBTofSimMaker");
91  gSystem->Load("StBTofMatchMaker");
92  gSystem->Load("StTofCalibMaker");
93 
94  chain = new StChain("BTofSim");
95  //chain->SetDebug();
96 
97  St_geant_Maker *geantMk = new St_geant_Maker();
98  geantMk->LoadGeometry("detp geometry y2009");
99  //geantMk->LoadGeometry("detp geometry y2008");
100  geantMk->SetActive(kFALSE);
101 
102  StIOMaker *IOMk = new StIOMaker("bfc");
103  IOMk->SetFile(MainFile);
104  IOMk->SetIOMode("r");
105  IOMk->SetBranch("*",0,"0"); //deactivate all branches
106  IOMk->SetBranch("geantBranch",0,"r");
107  IOMk->SetBranch("eventBranch",0,"r");
108 
109  StMcEventMaker *mcEventReader = new StMcEventMaker; // Make an instance...
110  mcEventReader->doPrintEventInfo = false;
111  mcEventReader->doPrintMemoryInfo = false;
112  mcEventReader->doUseTpc = true;
113  mcEventReader->doUseBemc = false;
114  mcEventReader->doUseBsmd = false;
115  mcEventReader->doUseFtpc = false;
116  mcEventReader->doUseSvt = false;
117  mcEventReader->doUseRich = false;
118  mcEventReader->doUseEemc = false;
119  mcEventReader->doUseTof = true;
120  mcEventReader->SetDebug(1);
121 
122 
123  St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb", "MySQL:StarDb", "$STAR/StarDb");
124  dbMk->SetDateTime(20090401,214129); // for simulation
125  cout << " DbMaker loading done " << endl;
126 
127 
128  //geant to StEvent convertion code
129  string filename=outFileName;
130  StBTofSimMaker *simMaker = new StBTofSimMaker;
131  simMaker->setBookHist(kTRUE);
132  simMaker->setHistFileName(filename);
133  simMaker->writeStEvent(kTRUE);
134 
135  StBTofMatchMaker *matchMaker = new StBTofMatchMaker;
136  matchMaker->setIdealGeometry();
137  matchMaker->SetDebug(1);
138 
139  //StEvent to MuDst conversion
140  StMuDstMaker* makeMu=new StMuDstMaker("makeMu");
141 
142  //user analysis makers here
143  //M2Maker *mk = new M2Maker(makeMu);
144  //mk->SetRootFile(newOutName);
145 
146  int totalProcessedTofPoints=0;
147 
148  chain->Init();
149  chain->PrintInfo();
150  int total=0;
151  for (Int_t iev=0;iev<nevents; iev++) {
152  cout << "****************************************** " << endl;
153  cout << "Working on eventNumber " << iev << endl;
154  cout << "****************************************** " << endl;
155  chain->Clear();
156  int iret = chain->Make(iev);
157 
158  if (iret) { cout << "Bad return code!" << endl; break;}
159 
160  total++;
161 
162  StMuDst* temp=makeMu->muDst();
163  int nTofs=temp->numberOfBTofHit();
164  cout<<"MUDSTOUTPUT-- BTofHits "<<nTofs<<endl;
165 
166 
167  }
168 
169 
170  cout << "****************************************** " << endl;
171  cout << "Work done... now its time to close up shop!"<< endl;
172  cout << "****************************************** " << endl;
173  chain->Finish();
174  cout << "****************************************** " << endl;
175  cout << "total number of events " << total << endl;
176  cout << "****************************************** " << endl;
177 
178  cout<<endl<<endl;
179  cout<<"Total Tof Hits Processed in MuDst: "<<totalProcessedTofPoints<<endl;
180 // gApplication->Terminate();
181 
182 }
StMuDst * muDst()
Definition: StMuDstMaker.h:425
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
Barrel TOF Match Maker.
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
Bool_t doPrintMemoryInfo
lots of screen output
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: AgUStep.h:26
void setIdealGeometry(const Bool_t useIdealGeometry=kTRUE)
switch between standard and ideal MC geometry
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
Definition: StMaker.h:208
virtual void LoadGeometry(const Char_t *option="detp geometry field_only")
Specifies GEANT3 geometry command.