StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
OnlineQaTpcRaw.C
1 // $Id: OnlineQaTpcRaw.C,v 1.8 2006/08/15 21:43:24 jeromel Exp $
2 // $Log: OnlineQaTpcRaw.C,v $
3 // Revision 1.8 2006/08/15 21:43:24 jeromel
4 // Fix rhic -> rhic.bnl.gov
5 //
6 // Revision 1.7 2000/06/20 19:57:38 kathy
7 // minor updates & cleanup
8 //
9 // Revision 1.6 2000/06/14 15:03:55 kathy
10 // changed default input daq file to be a current one
11 //
12 // Revision 1.5 2000/06/14 14:35:42 kathy
13 // comment out setdebug so zillions of daq messages aren't printed out
14 //
15 // Revision 1.4 2000/06/12 15:20:51 kathy
16 // put in Sergei's code to set output hist file name correctly
17 //
18 // Revision 1.2 2000/06/09 18:53:28 kathy
19 // update comments
20 //
21 // Revision 1.1 2000/06/09 16:27:30 kathy
22 // put new online QA tpc macro in
23 //
24 //======================================================================
25 // owner: Alex,Sergei
26 // what it does:
27 
28 // Inputs to macro:
29 // nevents - # events to process
30 // MainFile - input file
31 // nevHistOut - #events to write to each output .hist.root file
32 // - default is 0 which means it writes out all events
33 // present in input file
34 //
35 //
36 //
37 //======================================================================
38 
39 class StChain;
40 StChain *chain;
41 
42 
43 void OnlineQaTpcRaw(
44  Int_t nevents=2,
45  const char *MainFile=
46  "/afs/rhic.bnl.gov/star/data/samples/june_2000_st_physics_1164058_raw_0001.daq",
47  Int_t nevHistOut=0)
48 {
49 //
50  cout << " OnlineQaTpcRaw.C: #events to process = " << nevents << endl;
51  cout << " OnlineQaTpcRaw.C: input file name = " << MainFile << endl;
52  cout << " OnlineQaTpcRaw.C: #events to write to hist file (0=all) = " <<
53  nevHistOut << endl;
54 
55 // Generate a name for an outHistFile using input file name
56 //
57  fInFile = new TString(MainFile);
58  fFileOut = new TString(gSystem->BaseName(fInFile->Data()));
59  fFileOut->ReplaceAll(".daq",""); // remove old file extension
60  const char *histoDir = "./"; // directory for histos
61  fFileOut->Prepend(histoDir);
62  const Char_t *outHistFile= fFileOut->Data(); // done
63 
64 
65 // define other values needed:
66  const Char_t *topTree="OnlQaTpcTree";
67  const Char_t *makerName="RawTpcQa";
68 
69 
70  cout << " OnlineQaTpcRaw.C: output hist file name set to " <<
71  outHistFile << ".hist.root" << endl;
72  cout << " OnlineQaTpcRaw.C: top level Tree directory set to " <<
73  topTree << endl;
74  cout << " OnlineQaTpcRaw.C: maker name set to " <<
75  makerName << endl;
76 
77 // load libraries - basic ones needed
78  gSystem->Load("St_base");
79  gSystem->Load("StChain");
80  gSystem->Load("StIOMaker");
81  gSystem->Load("StTreeMaker");
82 
83 // these 2 are for using the StHistUtil class
84  gSystem->Load("StUtilities");
85  gSystem->Load("StAnalysisUtilities");
86 
87 // for raw tpc qa maker
88  gSystem->Load("StRawTpcQaMaker");
89 
90 
91 // Setup top part of chain
92  chain = new StChain("OnlineQaTpcRawChain");
93  // chain->SetDebug(0);
94 
95 // now any Maker that gets constructed will be added to the chain
96  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,topTree);
97  //IOMk->SetDebug();
98  IOMk->SetIOMode("r");
99 
100 // histogram utility class (this is not a Maker so not used in chain)
101  StHistUtil *HU = new StHistUtil;
102 // now must set pointer to any StMaker so HistUtil can find histograms
103 // with StHistUtil methods
104 // -- input any maker pointer but must cast as type StMaker
105  HU->SetPntrToMaker((StMaker *)IOMk);
106 
107 
108  StRawTpcQaMaker *RTQa = new StRawTpcQaMaker(makerName);
109 
110 // output hist.root file:
111  StTreeMaker* treeMk = new StTreeMaker("tree",outHistFile,topTree);
112  treeMk->SetIOMode("w");
113  treeMk->SetBranch("histBranch");
114 
115 
116 // --- now execute chain member functions
117  chain->Init();
118 
119 
120 // method to print out list of histograms -
121 //can do this anytime after they're booked
122  Int_t NoHist=0;
123  NoHist = HU->ListHists(makerName);
124  cout << " !!! OnlineQaTpcRaw.C, No. of Hist Booked = " << NoHist << endl;
125 
126  int istat=0;
127  int iev=0;
128  int countev=0;
129 
130 // Event loop
131 EventLoop: if (iev < nevents && !istat) {
132 
133  chain->Clear();
134  istat = chain->Make(iev);
135 
136 // count # times Make is called
137  iev++;
138 
139  cout << " Called Make # " << iev << endl;
140  cout << " istat value returned from chain Make = " << istat <<
141 
142 endl;
143 
144  if (!istat) {
145 
146  countev++;
147 
148  cout << " processed event # " << countev << endl;
149 
150  } // istat
151 
152  else // if (istat)
153  {
154  cout << "Last event processed. Status = " << istat << endl;
155  }
156 
157  goto EventLoop;
158 
159 } // EventLoop
160 
161  cout << endl;
162  cout << "QAInfo: End of Job " << endl;
163  cout << "QAInfo: # times Make called = " << iev << endl;
164  cout << "QAInfo: # events read = " << countev << endl;
165 
166  chain->Finish();
167 
168 }
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
virtual Int_t Make()
Definition: StChain.cxx:110