StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
trigCtb.C
1 //
4 
5 #include "iostream.h"
6 
7 class StChain;
8 StChain *chain=0;
9 
10 
11 void Help()
12 {
13  cout << "Usage: trigCtb.C(startEvent,nEvents,\"path/some_dst_file.xdf\")" << endl;
14  cout << " trigCtb.C(nEvents,\"path/*.event.root\")" << endl;
15  cout << " trigCtb.C(nEvents,\"path/file.dst.root\",\"evout\")" << endl;
16 }
17 // ProtoTypes
18 
19 void trigCtb(Int_t nEvents, const Char_t ** fileList, const Char_t *qaflag =0);
20 void trigCtb(Int_t startEvent, Int_t nEvents, const Char_t ** fileList, const Char_t *qaflag =0);
21 
22 void trigCtb(Int_t nEvents=2,
23  const Char_t *file="/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
24  const Char_t *qaflag = 0);
25 
26 void trigCtb(Int_t startEvent=1,Int_t nEvents=2,
27  const Char_t *file="/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
28  const Char_t *qaflag = 0);
29 
30 void trigCtb(const Int_t nEvents=2,
31  const Char_t *path,
32  const Char_t *file,
33  const Char_t *qaflag, int flag);
34 
35 
36 
37 
38 // ------------------ Here is the actual method -----------------------------------------
39 void trigCtb(Int_t startEvent, Int_t nEvents, const Char_t **fileList, const Char_t *qaflag)
40 {
41 
42  TString tflag = qaflag;
43  cout << endl << endl <<" trigCtb - input # events = " << nEvents << endl;
44  Int_t ilist=0;
45  while(fileList[ilist]){
46  cout << " trigCtb - input fileList = " << fileList[ilist] << endl;
47  ilist++;
48  }
49  cout << " trigCtb - input qaflag = " << qaflag << endl;
50 
51  //
52  // First load some shared libraries we need
53  //
54 
55  gSystem->Load("St_base");
56  gSystem->Load("StChain");
57 
58  gSystem->Load("libgen_Tables");
59  gSystem->Load("libsim_Tables");
60  gSystem->Load("libglobal_Tables");
61 
62  gSystem->Load("StUtilities");
63  gSystem->Load("StIOMaker");
64  gSystem->Load("StTreeMaker");
65  gSystem->Load("StarClassLibrary");
66  gSystem->Load("StEvent");
67  gSystem->Load("StMagF");
68  // gSystem->Load("StEventMaker");
69  gSystem->Load("StTrgMaker");
70 
71  //
72  // Handling depends on whether file is a ROOT file or XDF file
73  //
74  chain = new StChain("StChain");
75  StFileI *setFiles =0;
76  if (fileList) { //Normal case
77  setFiles= new StFile(fileList);
78  } else { //Grand Challenge
79  gSystem->Load("StChallenger");
80  setFiles = StChallenger::Challenge();
81  setFiles->SetDebug();
82  const char *Argv[]= {
83  "-s","dst runco", // list of components needed
84  "-q","numberOfPrimaryTracks>1500", // example of user query
85  "-c","/afs/rhic.bnl.gov/star/incoming/GCA/daq/stacs.rc" // pointer to GC servers for daq
86  };
87  Int_t Argc=sizeof(Argv)/4;
88  setFiles->Init(Argc,Argv);
89  }
90 
91  TString mainBranch;
92  if (fileList && fileList[0] && strstr(fileList[0],".root")) {
93  mainBranch = fileList[0];
94  mainBranch.ReplaceAll(".root","");
95  int idot = strrchr((char*)mainBranch,'.') - mainBranch.Data();
96  mainBranch.Replace(0,idot+1,"");
97  mainBranch+="Branch";
98  }
99 
100  StIOMaker *IOMk = new StIOMaker("IO","r",setFiles,"bfcTree");
101  IOMk->SetIOMode("r");
102  IOMk->SetBranch("*",0,"0"); //deactivate all branches
103  if(!mainBranch.IsNull()) IOMk->SetBranch(mainBranch,0,"r");
104 // IOMk->SetBranch("dstBranch",0,"r");
105 // IOMk->SetBranch("runcoBranch",0,"r");
106  IOMk->SetDebug();
107 
108  //
109  // Maker to read events from file or database into StEvent
110  //
111  // StEventMaker *readerMaker = new StEventMaker("events","title");
112 
113  //
114  // Sample analysis maker
115  //
116  StTrgMaker *analysisMaker = new StTrgMaker("analysis");
117 
118  // WriteOut StEvent
119  Int_t wrStEOut = tflag.Contains("evout",TString::kIgnoreCase);
120  if (wrStEOut) {
121  cout << "!!!! trigCtb: will write out .event.root file !!" << endl << endl;
122  StTreeMaker *outMk = new StTreeMaker("EvOut","","bfcTree");
123  outMk->SetIOMode("w");
124  outMk->SetBranch("eventBranch","test.event.root","w");
125  outMk->IntoBranch("eventBranch","StEvent");
126  }
127 
128  //
129  // Initialize chain
130  //
131  Int_t iInit = chain->Init();
132  if (iInit) chain->Fatal(iInit,"on init");
133  chain->PrintInfo();
134 
135 
136 //----- added 6/20/00 by Kathy
137  TTable *tabl=0;
138  TDataSet *obj=0;
139  TDataSet *ddb=0;
140  TDataSet *ddstBranch=0;
141 //------
142 
143  //
144  // Event loop
145  //
146  int istat=0,i=1;
147  EventLoop: if (i <= nEvents && istat!=2) {
148 
149  cout << endl << "============================ Event " << i
150  << " start ============================" << endl;
151 
152  chain->Clear();
153  istat = chain->Make(i);
154 
155  if (istat==2)
156  {cout << "Last event processed. Status = " << istat << endl;}
157  if (istat==3)
158  {cout << "Error event processed. Status = " << istat << endl;}
159 
160 //------------------ added 6/20/00 by Kathy to unpack BfcStatus table
161  if (!istat) {
162 
163  ddstBranch=chain->GetDataSet("dstBranch");
164 
165  TDataSetIter dstbranchIter(ddstBranch);
166 
167  if (ddstBranch) {
168 
169  cout << endl << " QAInfo: in dstBranch " << endl;
170 
171  while (ddb=dstbranchIter.Next()) {
172 
173  cout << endl <<
174  " QAInfo: found object: " << ddb->GetName() << endl;
175 
176  TString dsName = ddb->GetName();
177 
178  if (ddb->InheritsFrom("TTable")) {
179 
180  tabl = (TTable *)ddb;
181  cout << " QAInfo: it is a table with #rows = "
182  << tabl->GetNRows() << endl;
183 
184  if (dsName == "BfcStatus") {
185 // Now print out contents of BfcStatus for QA purposes
186  TDataSetIter bfcstatiter(ddb);
187  St_dst_bfc_status *bfcstat =
188  (St_dst_bfc_status *) bfcstatiter.Find("BfcStatus");
189  St_dst_bfc_status::iterator bth = bfcstat->begin();
190  St_dst_bfc_status::iterator bthEnd = bfcstat->end();
191 // loop over all rows in table BfcStatus:
192  for (; bth != bthEnd; bth++)
193  {
194  cout << " QAInfo: BfcStatus table -- row " << ij <<
195  ", Maker: " << (*bth).maker_name <<
196  " has istat = " << (*bth).status << endl;
197  } // for bfcstat
198  } // if dsName
199  } // if ddb
200  } // while obj Next
201  } // if dstBranch
202  } // if !istat
203 
204 //------------------
205 
206  i++;
207  goto EventLoop;
208  }
209 
210  i--;
211  cout << endl << "============================ Event " << i
212  << " finish ============================" << endl;
213 
214 }
215 
216 //--------------------------------------------------------------------------
217 
218 void trigCtb(const Int_t startEvent, const Int_t nEvents, const Char_t *file, const Char_t *qaflag)
219 {
220  printf("*file = %s\n",file);
221  if (nEvents==-1) { Help(); return;}
222  const char *fileListQQ[]={0,0};
223  if (strncmp(file,"GC",2)==0) {
224  fileListQQ=0;
225  } else {
226  fileListQQ[0]=file;
227  }
228  trigCtb(startEvent,nEvents,fileListQQ,qaflag);
229 }
230 //--------------------------------------------------------------------------
231 void trigCtb(const Int_t nEvents, const Char_t *file, const Char_t *qaflag)
232 {
233  trigCtb(1,nEvents,file,qaflag);
234 }
235 
236 //--------------------------------------------------------------------------
237 void trigCtb(const Int_t nEvents, const Char_t *path,const Char_t *file, const Char_t *qaflag, int flag)
238 {
239  TString F;
240  if (path && path[0] && path[0]!='-') F = path;
241  if (file && file[0] && file[0]!='-')
242  {
243  if (!F.IsNull()) F +="/";
244  F += file;
245  }
246  TString opt = qaflag;
247  if (flag) opt += " evout";
248 
249 
250  trigCtb(1,nEvents,F.Data(),opt.Data());
251 }
252 
253 //--------------------------------------------------------------------------
254 void trigCtb(Int_t nEvents, const Char_t **fileList, const Char_t *qaflag)
255 { trigCtb(1,nEvents,fileList,qaflag); }
256 
Definition: StTree.h:125
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 Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
virtual TDataSet * Next() const
Definition: TDataSet.cxx:447
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: TTable.h:48
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362