StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMiniHijing.C
1 // $Id: StMiniHijing.C,v 1.7 2006/07/24 19:25:26 calderon Exp $
3 // owner: Manuel Calderon de la Barca Sanchez
4 //
5 // what it does: reads .geant.root file from hijing data, produces minimc.root file
6 // runs a chain with the makers:
7 // StMcEventMaker,StAssociationMaker,
8 // StMiniMcEventMaker
9 // $Log: StMiniHijing.C,v $
10 // Revision 1.7 2006/07/24 19:25:26 calderon
11 // Load EEmcUtil, needed by StMcEvent.
12 //
13 // Revision 1.6 2004/03/30 03:16:15 calderon
14 // Modifications for running in bfc.
15 // - Changed to use StiIOInterface (IOMaker in normal mode, TreeMaker in bfc)
16 // - Cleaned up Init(), InitRun() to handle the changing file names.
17 // - Initialize lots of variables and pointers in constructor.
18 // - Delete some pointers in Finish (deleting the TTree causes a seg fault, though.)
19 // - Note that currently the StHits in the ITTF chain don't have a usedInFit() flag,
20 // so there will be many messages complaining about this.
21 // - Removed the mDebug data member, every Maker already has one, so change
22 // to use that throughout the package.
23 //
24 // Revision 1.5 2003/07/09 01:07:23 calderon
25 // Addition of FTPC reference multiplicity
26 // Addition of other multiplicity values for StMiniMcEvent
27 // Changes to reflect the use of the setters and getters, no longer
28 // access the data members directly.
29 //
30 // Revision 1.4 2002/06/28 22:15:12 calderon
31 // Changes to deal with seg. faults in the file name handling:
32 // Conventions:
33 // StMiniMcMaker looks for the input file from the IO maker to figure out
34 // if the file has changed. This is done using TString::Contains() in Make().
35 // Usually we will run one file at a time, but in order not to break Bum's scheme of being
36 // able to process several files in one go, this is left as is. However, for
37 // embedding, the file name is not enough, in Eric's new scheme there are repeated
38 // file names. This is resolved by adding a prefix to the output file name. However,
39 // this prefix should not be overwritten, so the current code only replaces the
40 // string inside the output file name pertaining to the input file name, and leaves
41 // the prefix of the output file intact. This was done for embedding looking for
42 // st_physics, and here is where the problem arose: hijing files begin with a different
43 // prefix. To solve this problem, the input file name prefix is now an input parameter
44 // in the macro.
45 //
46 // StMiniEmbed.C and StMiniHijing.C now conform to this convention. StMiniEmbed.C
47 // did not change its prototype, because all embedding files have st_phyics as prefix.
48 // StMiniHijing.C changed its prototype, now it takes as an input argument the prefix,
49 // but in order not to break Jenn's scripts if she was already using this macro,
50 // this parameter was added at the end and defaults to "rcf", which is appropriate
51 // for hijing files reconstructed in rcf.
52 //
53 // Revision 1.3 2002/06/07 02:21:59 calderon
54 // Protection against empty vector in findFirstLastHit
55 // $Log: StMiniHijing.C,v $
56 // Revision 1.7 2006/07/24 19:25:26 calderon
57 // Load EEmcUtil, needed by StMcEvent.
58 //
59 // Revision 1.6 2004/03/30 03:16:15 calderon
60 // Modifications for running in bfc.
61 // - Changed to use StiIOInterface (IOMaker in normal mode, TreeMaker in bfc)
62 // - Cleaned up Init(), InitRun() to handle the changing file names.
63 // - Initialize lots of variables and pointers in constructor.
64 // - Delete some pointers in Finish (deleting the TTree causes a seg fault, though.)
65 // - Note that currently the StHits in the ITTF chain don't have a usedInFit() flag,
66 // so there will be many messages complaining about this.
67 // - Removed the mDebug data member, every Maker already has one, so change
68 // to use that throughout the package.
69 //
70 // Revision 1.5 2003/07/09 01:07:23 calderon
71 // Addition of FTPC reference multiplicity
72 // Addition of other multiplicity values for StMiniMcEvent
73 // Changes to reflect the use of the setters and getters, no longer
74 // access the data members directly.
75 //
76 // Revision 1.4 2002/06/28 22:15:12 calderon
77 // Changes to deal with seg. faults in the file name handling:
78 //
80 
81 class StChain;
82 StChain *chain=0;
83 
84 void StMiniHijing(Int_t nevents=3,
85  const char* MainFile=
86  "hijing_b0_3/rcf0147_01*geant.root",
87  const char* outDir = "./",
88  int commonHits=3,
89  TString filePrefix="rcf")
90 {
91 
92  // Dynamically link needed shared libs
93  //gSystem->Load("StarRoot");
94  gSystem->Load("St_base");
95  gSystem->Load("StChain");
96 
97  gSystem->Load("St_Tables");
98  gSystem->Load("StUtilities");
99  gSystem->Load("StIOMaker");
100  gSystem->Load("StarClassLibrary");
101 
102  gSystem->Load("StDetectorDbMaker");
103  gSystem->Load("StTpcDb");
104  gSystem->Load("StEvent");
105  gSystem->Load("StEventMaker");
106  gSystem->Load("StEmcUtil");
107  gSystem->Load("StEEmcUtil");
108  gSystem->Load("StMcEvent");
109  gSystem->Load("StMcEventMaker");
110  gSystem->Load("StAssociationMaker");
111  gSystem->Load("StMcAnalysisMaker");
112 
113  gSystem->Load("StMiniMcEvent");
114  gSystem->Load("StMiniMcMaker");
115 // gSystem->Load("Common");
116 
117  chain = new StChain("StChain");
118  chain->SetDebug();
119 
120  // Now we add Makers to the chain...
121 
122  StIOMaker* ioMaker = new StIOMaker("IO","r",MainFile,"bfcTree");
123  ioMaker->SetDebug();
124  ioMaker->SetIOMode("r");
125  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
126  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
127  ioMaker->SetBranch("eventBranch",0,"r"); //activate Event Branch
128  // ioMaker->SetBranch("runcoBranch",0,"r"); //activate runco Branch
129 
130  // const char *mainDB = "MySQL:Geometry_tpc";
131  // St_db_Maker *dbMk = new St_db_Maker("Geometry",mainDB);
132  // dbMk->SetDebug();
133 
134  // const char *calibDB = "MySQL:Calibrations_tpc";
135  // St_db_Maker *calibMk = new St_db_Maker("Calibrations",calibDB);
136  // calibMk->SetDebug();
137 
138  // StTpcDbMaker *tpcDbMk = new StTpcDbMaker("tpcDb");
139 
140  // Note, the title "events" is used in the Association Maker, so don't change it.
141 // StEventMaker* eventReader = new StEventMaker("events","title");
142 // eventReader->doPrintMemoryInfo = kFALSE;
143 
144  StMcEventMaker* mcEventReader = new StMcEventMaker; // Make an instance...
145  // mcEventReader->doPrintMemoryInfo = kFALSE;
146  // mcEventReader->doUseTpc = kTRUE;
147  // mcEventReader->doUseSvt = kTRUE;
148  // mcEventReader->doUseFtpc = kTRUE;
149  // mcEventReader->doUseRich = kTRUE;
150  StAssociationMaker* associator = new StAssociationMaker;
151  //associator->doPrintMemoryInfo = kTRUE;
152 
153  //
154  // mdst of association stuff
155  //
156 
157  TString filename = MainFile;
158  int fileBeginIndex = filename.Index(filePrefix,0);
159  filename.Remove(0,fileBeginIndex);
160 
161 
162  StMiniMcMaker *krap = new StMiniMcMaker;
163  krap->SetDebug(1);
164  krap->setGhost();
165  krap->setOutDir(outDir);
166  krap->setPtCut(0.);
167  krap->setFileName(filename);
168  krap->setFilePrefix(filePrefix);
169 
170  // Define the cuts for the Associations
171 
172  StMcParameterDB* parameterDB = StMcParameterDB::instance();
173  // TPC
174  parameterDB->setXCutTpc(.5); // 5 mm
175  parameterDB->setYCutTpc(.5); // 5 mm
176  parameterDB->setZCutTpc(.5); // 5 mm
177  parameterDB->setReqCommonHitsTpc(commonHits); // Require 3 hits in common for tracks to be associated
178  // FTPC
179  parameterDB->setRCutFtpc(.3); // 3 mm
180  parameterDB->setPhiCutFtpc(5*(3.1415927/180.0)); // 5 degrees
181  parameterDB->setReqCommonHitsFtpc(3); // Require 3 hits in common for tracks to be associated
182  // SVT
183  parameterDB->setXCutSvt(.08); // 800 um
184  parameterDB->setYCutSvt(.08); // 800 um
185  parameterDB->setZCutSvt(.08); // 800 um
186  parameterDB->setReqCommonHitsSvt(1); // Require 1 hits in common for tracks to be associated
187 
188 
189  // now execute the chain member functions
190 
191  //chain->PrintInfo();
192  Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers
193  if (initStat) chain->Fatal(initStat, "during Init()");
194 
195  int istat=0,iev=1;
196  EventLoop: if (iev<=nevents && istat!=2) {
197  chain->Clear();
198  cout << "---------------------- Processing Event : " << iev << " ----------------------" << endl;
199  istat = chain->Make(iev); // This should call the Make() method in ALL makers
200  if (istat == 2) { cout << "Last Event Processed. Status = " << istat << endl; }
201  if (istat == 3) { cout << "Error Event Processed. Status = " << istat << endl; }
202  iev++; goto EventLoop;
203  } // Event Loop
204 
205  chain->Finish();
206 
207 }
208 
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
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
virtual Int_t Make()
Definition: StChain.cxx:110