StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_event_QAhist.C
1 // $Id: bfcread_event_QAhist.C,v 1.21 2015/04/02 19:54:41 genevb Exp $
2 // $Log: bfcread_event_QAhist.C,v $
3 // Revision 1.21 2015/04/02 19:54:41 genevb
4 // Bichsel now needed for TPC dE/dx QA
5 //
6 // Revision 1.20 2013/03/14 17:28:31 genevb
7 // StTpcDb.so now depends on StEvent.so
8 //
9 // Revision 1.19 2011/03/09 22:17:10 genevb
10 // Update dependence on StEEmcUtil
11 //
12 // Revision 1.18 2011/01/19 20:03:03 fisyak
13 // switch order DbUtil and TpcDb shared libraries loading
14 //
15 // Revision 1.17 2010/02/22 20:05:16 genevb
16 // Using StTpcDbMaker now requires StMagFMaker
17 //
18 // Revision 1.16 2008/03/07 19:26:11 genevb
19 // Ye olde loading of StdetectorDbMaker library change
20 //
21 // Revision 1.15 2006/08/15 21:42:37 jeromel
22 // Fix rhic -> rhic.bnl.gov
23 //
24 // Revision 1.14 2006/05/18 16:38:04 genevb
25 // Introduce StHistUtil::GetRunYear()
26 //
27 // Revision 1.13 2005/08/31 15:03:09 fisyak
28 // Add dependence StMagF vs StarMagField
29 //
30 // Revision 1.12 2005/01/27 05:28:58 genevb
31 // open runcoBranch
32 //
33 // Revision 1.11 2005/01/05 21:57:02 genevb
34 // More lib loads, evtselBranch, remove date set on calib maker
35 //
36 // Revision 1.10 2003/01/28 23:52:14 genevb
37 // Allow for multiple zones per page
38 //
39 // Revision 1.9 2001/07/17 03:22:31 genevb
40 // Modify TPC DB info for year 2001
41 //
42 // Revision 1.8 2001/05/24 20:10:37 lansdell
43 // changed DB maker SetDateTime option to year_2b
44 //
45 // Revision 1.7 2001/05/16 20:53:37 lansdell
46 // added StMcEvent to chain
47 //
48 // Revision 1.6 2001/04/28 21:45:19 genevb
49 // include libs for EMC
50 //
51 // Revision 1.5 2000/07/26 19:53:45 lansdell
52 // made changes for creating new QA histograms
53 //
54 // Revision 1.4 2000/06/13 00:58:59 lansdell
55 // added libglobal_Tables to resolve crashes
56 //
57 // Revision 1.3 2000/06/02 20:26:10 lansdell
58 // added check on Make() return codes
59 //
60 // Revision 1.2 2000/05/15 20:24:01 kathy
61 // correct Log,Id so they get written out
62 //
63 //
64 //======================================================================
65 // owner: Curtis Lansdell
66 // what it does:
67 // - reads in *.event.root
68 // - sets event branch
69 // - runs StEventQAMaker
70 // - draws EventQA histograms and then sends them to a postscript file
71 //
72 //=======================================================================
73 //
74 // inputs: nevents - # events to process
75 // MainFile - input *.event.root file from bfc output
76 // psFile - output postscript filename
77 // PageTitle - title you want on each output page, default = "" is
78 // MainFile name
79 // PrintList - name of subset histogram list that you want printed
80 // - these are defined in StHistUtil, method SetDefaultPrintList
81 // - default = "", prints all histograms in directory
82 // MakerHistDir - this is the Maker name that you want to get histograms
83 // from - leave as "QA" for this macro since this
84 // macro is setup to run St_QA_Maker!
85 //
86 // standard Maker names in bfc,doEvents
87 // (but if you run your own Maker here, then use whatever name you give it)
88 // are listed at
89 // http://www.star.bnl.gov/STAR/html/comp_l/train/tut/bfc_maker_names.html
90 // doEvents_maker_names.html
91 //
92 // Documentation on StEventQAMaker class is at:
93 // http://duvall.star.bnl.gov/STARAFS/comp/pkg/dev/StRoot/St_QA_Maker/doc/
94 //
95 // Documentation on StHistUtil class is at:
96 // http://duvall.star.bnl.gov/STARAFS/comp/pkg/dev/StRoot/StAnalysisUtilities/doc/
97 //
98 //
99 //======================================================================
100 
101 class StChain;
102 StChain *chain;
103 
104 //TBrowser *brow=0;
105 
106 void bfcread_event_QAhist(
107  Int_t nevents=2,
108  const Char_t *MainFile=
109  //"/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
110 "/star/rcf/test/dev/trs_redhat61/Tue/year_2001/hc_standard/hc_standard.40_evts.event.root",
111  const Char_t *psFile="EventQAhist.ps",
112  const Char_t *PageTitle="",
113  const Char_t *PrintList="",
114  const Char_t *MakerHistDir="EventQA",
115  const Int_t ZoneH=2,
116  const Int_t ZoneV=3
117  )
118 {
119 //
120  cout << "bfcread_event_QAhist.C, num events to process " <<
121  nevents << endl;
122  cout << "bfcread_event_QAhist.C, input file name " <<
123  MainFile << endl;
124  cout << "bfcread_event_QAhist.C, output psfile name " <<
125  psFile << endl;
126  cout << "bfcread_event_QAhist.C, hist page title " <<
127  PageTitle << endl;
128  cout << "bfcread_event_QAhist.C, Maker directory containing histograms = "
129  << MakerHistDir << endl;
130  cout << "bfcread_event_QAhist.C, subset list name of which histograms to draw,print = "
131  << PrintList << endl;
132 
133  gSystem->Load("St_base");
134  gSystem->Load("StChain");
135  gSystem->Load("St_Tables");
136  gSystem->Load("libglobal_Tables");
137  gSystem->Load("libsim_Tables");
138  gSystem->Load("libgen_Tables");
139  gSystem->Load("libgeometry_Tables");
140 
141  gSystem->Load("StUtilities");
142  gSystem->Load("StAnalysisUtilities");
143  gSystem->Load("StIOMaker");
144  gSystem->Load("StarClassLibrary");
145  gSystem->Load("StBichsel");
146  gSystem->Load("StDetectorDbMaker");
147  gSystem->Load("StEvent");
148  gSystem->Load("StTpcDb");
149  gSystem->Load("StDbUtilities");
150  gSystem->Load("StDbLib");
151  gSystem->Load("StDbBroker");
152  gSystem->Load("St_db_Maker");
153  gSystem->Load("StEmcUtil");
154  gSystem->Load("StEEmcUtil");
155  gSystem->Load("StMcEvent");
156  gSystem->Load("StMcEventMaker");
157  gSystem->Load("StarMagField");
158  gSystem->Load("StMagF");
159  gSystem->Load("StPmdUtil");
160  gSystem->Load("St_QA_Maker");
161 
162 // Setup top part of chain
163  chain = new StChain("MyChain");
164  chain->SetDebug();
165 
166 // Input File Maker
167  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
168  IOMk->SetBranch("evtselBranch",0,"r");
169  IOMk->SetBranch("event",0,"r");
170  IOMk->SetBranch("geantBranch",0,"r");
171  IOMk->SetBranch("runcoBranch",0,"r");
172  IOMk->SetDebug();
173 
174 // database stuff
175  const char* calibDB = "MySQL:StarDb";
176  const char* calibDB2 = "$STAR/StarDb";
177  St_db_Maker* calibMk = new St_db_Maker("StarDb",calibDB,calibDB2);
178  StMagFMaker* magfMk = new StMagFMaker; // now required for StTpcDbMaker
179  //calibMk->SetDateTime("year_2b");
180  calibMk->SetDebug();
181  StTpcDbMaker *tpcDbMk = new StTpcDbMaker("tpcDb");
182 
183 // constructor for other maker (not used in chain)
184  StHistUtil *HU = new StHistUtil;
185 
186 // now must set pointer to StMaker so HistUtil can find histograms
187 // with StHistUtil methods
188 // -- input any maker pointer but must cast as type StMaker
189  HU->SetPntrToMaker((StMaker *)IOMk);
190 
191 // add other makers to chain:
192  StMcEventMaker *mcEvent = new StMcEventMaker;
193  StEventQAMaker *EventQA = new StEventQAMaker("EventQA","StEvent/QA");
194 
195 // --- now execute chain member functions --> Init
196  Int_t iInit = chain->Init();
197  if (iInit) chain->Fatal(iInit,"on init");
198  chain->PrintInfo();
199 
200 // method to print out list of histograms -
201 //can do this anytime after they're booked
202  Int_t NoHist=0;
203  NoHist = HU->ListHists(MakerHistDir);
204  cout << " !!! bfcread_event_QAhist.C, No. of Hist we have == " << NoHist << endl;
205 
206 // loop over events:
207  int iev=0,iret=0, evnum=0;
208  EventLoop: if (iev<nevents && iret!=2) { // goto loop code
209  evnum=iev+1;
210  cout << " !!! bfcread_event_QAhist.C, processing event !!! " << evnum << endl ;
211  chain->Clear();
212  switch (iret = chain->Make()) {
213  case 0: break;
214  case 2: { gMessMgr->Info("Last event from input."); break; }
215  case 3: { gMessMgr->Error() << "Event " << evnum << " had error " <<
216  iret << ". Now skipping event."; gMessMgr->Print(); break; }
217  default: { gMessMgr->Warning() << "Event " << evnum << " returned status "
218  << iret << ". Continuing."; gMessMgr->Print(); }
219  }
220  iev++; // goto loop code
221  goto EventLoop; // goto loop code
222  }
223 
224  cout << " !!! bfcread_event_QAhist.C, passed chain->Make !!!" << endl ;
225 
226 // brow = new TBrowser("BName","BTitle");
227 
228 // the following methods are already set to default values in St_QA_Maker::Init - now write over them
229 
230 // Set the default canvas style to plain (so it won't print out grey!)
231  gROOT->SetStyle("Plain");
232 // gStyle->SetOptStat(111111);
233 
234  HU->SetHistsNamesDraw("*","*");
235  HU->GetRunYear(MainFile);
236  HU->SetPostScriptFile(psFile);
237  HU->SetZones(ZoneH,ZoneV);
238  HU->SetPaperSize();
239  HU->SetDefaultLogXList(MakerHistDir);
240  HU->SetDefaultLogYList(MakerHistDir);
241  if (PageTitle=="") PageTitle=MainFile;
242  HU->SetGlobalTitle(PageTitle);
243 
244  HU->SetDefaultPrintList(MakerHistDir,PrintList);
245 
246  Int_t numLog = 0;
247  numLog = HU->ExamineLogYList();
248  cout << " bfcread_event_QAhist.C, Number hist to plot with log scale = " << numLog << endl;
249 
250  Int_t numPrint = 0;
251  numPrint = HU->ExaminePrintList();
252  cout << " bfcread_event_QAhist.C, Number hist to print = " << numPrint << endl;
253 
254 
255 // Now draw the actual histograms to canvas and to ps file
256  HU->DrawHists(MakerHistDir);
257 
258 // overlay two histograms and print to screen
259  Int_t result = HU->Overlay1D(MakerHistDir,"StEQaGtrkRT","StEQaPtrkRT");
260  if (result == kStErr)
261  cout << " !!! There was an error in Overlay1D !!!" << endl;
262 
263  result = HU->Overlay2D(MakerHistDir,"StEQaGtrkLengthVEtaT","StEQaPtrkLengthVEtaT");
264  if (result == kStErr)
265  cout << " !!! There was an error in Overlay2D !!!" << endl;
266 
267  //chain->Finish();
268  //cout << "bfcread_event_QAhist.C, passed chain->Finish" << endl ;
269 }
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
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
Definition: Stypes.h:44