StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_event_QA_outhistfile.C
1 // $Id: bfcread_event_QA_outhistfile.C,v 1.19 2015/04/02 19:54:41 genevb Exp $
2 // $Log: bfcread_event_QA_outhistfile.C,v $
3 // Revision 1.19 2015/04/02 19:54:41 genevb
4 // Bichsel now needed for TPC dE/dx QA
5 //
6 // Revision 1.18 2013/11/22 16:31:20 genevb
7 // Restore parallelism with bfcread_event_QAhist.C
8 //
9 // Revision 1.17 2013/03/14 17:28:31 genevb
10 // StTpcDb.so now depends on StEvent.so
11 //
12 // Revision 1.16 2011/03/09 22:17:10 genevb
13 // Update dependence on StEEmcUtil
14 //
15 // Revision 1.15 2011/01/19 20:03:03 fisyak
16 // switch order DbUtil and TpcDb shared libraries loading
17 //
18 // Revision 1.14 2010/02/22 20:05:16 genevb
19 // Using StTpcDbMaker now requires StMagFMaker
20 //
21 // Revision 1.13 2008/03/07 19:26:11 genevb
22 // Ye olde loading of StdetectorDbMaker library change
23 //
24 // Revision 1.12 2006/08/15 21:42:36 jeromel
25 // Fix rhic -> rhic.bnl.gov
26 //
27 // Revision 1.11 2005/01/27 05:28:58 genevb
28 // open runcoBranch
29 //
30 // Revision 1.10 2001/07/17 03:26:51 genevb
31 // Modify input file for year 2001
32 //
33 // Revision 1.9 2001/07/17 03:24:45 genevb
34 // Modify TPC DB info for year 2001
35 //
36 // Revision 1.8 2001/05/24 20:10:37 lansdell
37 // changed DB maker SetDateTime option to year_2b
38 //
39 // Revision 1.7 2001/05/16 20:53:37 lansdell
40 // added StMcEvent to chain
41 //
42 // Revision 1.6 2001/04/28 21:45:19 genevb
43 // include libs for EMC
44 //
45 // Revision 1.5 2000/07/26 19:53:45 lansdell
46 // made changes for creating new QA histograms
47 //
48 // Revision 1.4 2000/06/13 00:58:59 lansdell
49 // added libglobal_Tables to resolve crashes
50 //
51 // Revision 1.3 2000/06/02 20:26:03 lansdell
52 // added check on Make() return codes
53 //
54 // Revision 1.2 2000/05/15 20:24:00 kathy
55 // correct Log,Id so they get written out
56 //
57 //
58 //======================================================================
59 // owner: Curtis Lansdell, Kathy Turner
60 // what it does:
61 // - reads a *.event.root file from bfc.C
62 // - sets event branch
63 // - runs StEventQAMaker (books & fills hist)
64 // - opens & writes histograms to output hist file
65 //
66 //=======================================================================
67 //
68 // inputs:
69 // nevents - # events to process
70 // MainFile - input event file from bfc output
71 // outHistFile - output hist file name --> outHistFile.hist.root
72 // TopDirTree - top level directory tree in your input hist file
73 // (this is 3rd argument of constructor for StTreeMaker that
74 // you probably used to write the *.hist.root file)
75 // NOTE: if you ran bfc, then the TopDirTree = bfcTree !!
76 // MakerHistDir - directory name of Maker that you want histograms
77 // from (this will be first input when you did constructor)
78 // -- see standard Maker names note below!
79 //
80 // standard Maker names in bfc,doEvents
81 // (but if you run your own Maker here, then use whatever name you give it)
82 // are listed at
83 // http://www.star.bnl.gov/STAR/html/comp_l/train/tut/bfc_maker_names.html
84 // doEvents_maker_names.html
85 //
86 // Documentation on StEventQAMaker class is at:
87 // http://duvall.star.bnl.gov/STARAFS/comp/pkg/dev/StRoot/St_QA_Maker/doc/
88 //
89 // Documentation on StHistUtil class is at:
90 // http://duvall.star.bnl.gov/STARAFS/comp/pkg/dev/StRoot/StAnalysisUtilities/doc/
91 //
92 //======================================================================
93 
94 class StChain;
95 StChain *chain;
96 
97 void bfcread_event_QA_outhistfile(
98  Int_t nevents=2,
99  const Char_t *MainFile=
100  //"/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
101 "/star/rcf/test/dev/trs_redhat61/Tue/year_2001/hc_standard/hc_standard.40_evts.event.root",
102  const Char_t *outHistFile="StEQAMaker",
103  const Char_t *TopDirTree="StEQAtree",
104  const Char_t *MakerHistDir="StEQA")
105 {
106 //
107  cout << "bfcread_event_QA_outhistfile.C, num events to process "
108  << nevents << endl;
109  cout << "bfcread_event_QA_outhistfile.C, input file name "
110  << MainFile << endl;
111  cout << "bfcread_event_QA_outhistfile.C, Maker directory name "
112  << MakerHistDir<< endl;
113  cout << "bfcread_event_QA_outhistfile.C, output hist name "
114  << outHistFile<< endl;
115  cout << "bfcread_event_QA_outhistfile.C, output top level directory name "
116  << TopDirTree<< endl;
117 
118  gSystem->Load("St_base");
119  gSystem->Load("StChain");
120  gSystem->Load("St_Tables");
121  gSystem->Load("libglobal_Tables");
122  gSystem->Load("libsim_Tables");
123  gSystem->Load("libgen_Tables");
124  gSystem->Load("libgeometry_Tables");
125 
126  gSystem->Load("StUtilities");
127  gSystem->Load("StAnalysisUtilities");
128  gSystem->Load("StIOMaker");
129  gSystem->Load("StarClassLibrary");
130  gSystem->Load("StBichsel");
131  gSystem->Load("StDetectorDbMaker");
132  gSystem->Load("StEvent");
133  gSystem->Load("StTpcDb");
134  gSystem->Load("StDbUtilities");
135  gSystem->Load("StDbLib");
136  gSystem->Load("StDbBroker");
137  gSystem->Load("St_db_Maker");
138  gSystem->Load("StEmcUtil");
139  gSystem->Load("StEEmcUtil");
140  gSystem->Load("StMcEvent");
141  gSystem->Load("StMcEventMaker");
142  gSystem->Load("StarMagField");
143  gSystem->Load("StMagF");
144  gSystem->Load("StPmdUtil");
145  gSystem->Load("St_QA_Maker");
146  gSystem->Load("StTreeMaker");
147 
148 // Setup top part of chain
149  chain = new StChain("MyChain");
150  chain->SetDebug();
151 
152 // Input File Maker
153  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
154  IOMk->SetIOMode("r");
155  IOMk->SetBranch("event",0,"r");
156  IOMk->SetBranch("geantBranch",0,"r");
157  IOMk->SetBranch("runcoBranch",0,"r");
158 
159 // database stuff
160  const char* calibDB = "MySQL:StarDb";
161  const char* calibDB2 = "$STAR/StarDb";
162  St_db_Maker* calibMk = new St_db_Maker("StarDb",calibDB,calibDB2);
163  StMagFMaker* magfMk = new StMagFMaker; // now required for StTpcDbMaker
164  //calibMk->SetDateTime("year_2b");
165  calibMk->SetDebug();
166  StTpcDbMaker *tpcDbMk = new StTpcDbMaker("tpcDb");
167 
168 // constructor for other maker (not used in chain)
169  StHistUtil *HU = new StHistUtil;
170 
171 // now must set pointer to StMaker so HistUtil can find histograms
172 // with StHistUtil methods
173 // -- input any maker pointer but must cast as type StMaker
174  HU->SetPntrToMaker((StMaker *)IOMk);
175 
176 // add other makers to chain:
177  StMcEventMaker *mcEvent = new StMcEventMaker;
178  StEventQAMaker *EventQA = new StEventQAMaker(MakerHistDir,"StEvent/QA-notused");
179 
180 // output hist.root file:
181  StTreeMaker* treeMk = new StTreeMaker("tree",outHistFile,TopDirTree);
182  treeMk->SetIOMode("w");
183  treeMk->SetBranch("histBranch");
184 
185 // --- now execute chain member functions --> Init
186  Int_t iInit = chain->Init();
187  if (iInit) chain->Fatal(iInit,"on init");
188  chain->PrintInfo();
189 
190 // method to print out list of histograms -
191 //can do this anytime after they're booked
192  Int_t NoHist=0;
193  NoHist = HU->ListHists(MakerHistDir);
194  cout << " !!! bfcread_dst_QAhist.C, No. of Hist we have == " << NoHist << endl;
195 
196 // loop over events:
197  int iev=0,iret=0, evnum=0;
198  EventLoop: if (iev<nevents && iret!=2) { // goto loop code
199  evnum=iev+1;
200  cout << " !!! bfcread_event_QA_outhistfile.C, processing event !!! " << evnum << endl ;
201  chain->Clear();
202  switch (iret = chain->Make()) {
203  case 0: break;
204  case 2: { gMessMgr->Info("Last event from input."); break; }
205  case 3: { gMessMgr->Error() << "Event " << evnum << " had error " <<
206  iret << ". Now skipping event."; gMessMgr->Print(); break; }
207  default: { gMessMgr->Warning() << "Event " << evnum << " returned status "
208  << iret << ". Continuing."; gMessMgr->Print(); }
209  }
210  iev++; // goto loop code
211  goto EventLoop; // goto loop code
212  }
213 
214  cout << " !!! bfcread_event_QA_outhistfile.C, passed chain->Make !!!" << endl ;
215 
216  chain->Finish();
217  cout << "bfcread_event_QA_outhistfile.C, passed chain->Finish" << endl ;
218 
219 }
220 
221 
222 
223 
224 
225 
226 
227 
228 
229 
230 
231 
232 
233 
234 
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