00001
00002
00004
00005 #include "iostream.h"
00006
00007 class StChain;
00008 StChain *chain=0;
00009
00010
00011 void Help()
00012 {
00013 cout << "Usage: trigCtb.C(startEvent,nEvents,\"path/some_dst_file.xdf\")" << endl;
00014 cout << " trigCtb.C(nEvents,\"path/*.event.root\")" << endl;
00015 cout << " trigCtb.C(nEvents,\"path/file.dst.root\",\"evout\")" << endl;
00016 }
00017
00018
00019 void trigCtb(Int_t nEvents, const Char_t ** fileList, const Char_t *qaflag =0);
00020 void trigCtb(Int_t startEvent, Int_t nEvents, const Char_t ** fileList, const Char_t *qaflag =0);
00021
00022 void trigCtb(Int_t nEvents=2,
00023 const Char_t *file="/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
00024 const Char_t *qaflag = 0);
00025
00026 void trigCtb(Int_t startEvent=1,Int_t nEvents=2,
00027 const Char_t *file="/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
00028 const Char_t *qaflag = 0);
00029
00030 void trigCtb(const Int_t nEvents=2,
00031 const Char_t *path,
00032 const Char_t *file,
00033 const Char_t *qaflag, int flag);
00034
00035
00036
00037
00038
00039 void trigCtb(Int_t startEvent, Int_t nEvents, const Char_t **fileList, const Char_t *qaflag)
00040 {
00041
00042 TString tflag = qaflag;
00043 cout << endl << endl <<" trigCtb - input # events = " << nEvents << endl;
00044 Int_t ilist=0;
00045 while(fileList[ilist]){
00046 cout << " trigCtb - input fileList = " << fileList[ilist] << endl;
00047 ilist++;
00048 }
00049 cout << " trigCtb - input qaflag = " << qaflag << endl;
00050
00051
00052
00053
00054
00055 gSystem->Load("St_base");
00056 gSystem->Load("StChain");
00057
00058 gSystem->Load("libgen_Tables");
00059 gSystem->Load("libsim_Tables");
00060 gSystem->Load("libglobal_Tables");
00061
00062 gSystem->Load("StUtilities");
00063 gSystem->Load("StIOMaker");
00064 gSystem->Load("StTreeMaker");
00065 gSystem->Load("StarClassLibrary");
00066 gSystem->Load("StEvent");
00067 gSystem->Load("StMagF");
00068
00069 gSystem->Load("StTrgMaker");
00070
00071
00072
00073
00074 chain = new StChain("StChain");
00075 StFileI *setFiles =0;
00076 if (fileList) {
00077 setFiles= new StFile(fileList);
00078 } else {
00079 gSystem->Load("StChallenger");
00080 setFiles = StChallenger::Challenge();
00081 setFiles->SetDebug();
00082 const char *Argv[]= {
00083 "-s","dst runco",
00084 "-q","numberOfPrimaryTracks>1500",
00085 "-c","/afs/rhic.bnl.gov/star/incoming/GCA/daq/stacs.rc"
00086 };
00087 Int_t Argc=sizeof(Argv)/4;
00088 setFiles->Init(Argc,Argv);
00089 }
00090
00091 TString mainBranch;
00092 if (fileList && fileList[0] && strstr(fileList[0],".root")) {
00093 mainBranch = fileList[0];
00094 mainBranch.ReplaceAll(".root","");
00095 int idot = strrchr((char*)mainBranch,'.') - mainBranch.Data();
00096 mainBranch.Replace(0,idot+1,"");
00097 mainBranch+="Branch";
00098 }
00099
00100 StIOMaker *IOMk = new StIOMaker("IO","r",setFiles,"bfcTree");
00101 IOMk->SetIOMode("r");
00102 IOMk->SetBranch("*",0,"0");
00103 if(!mainBranch.IsNull()) IOMk->SetBranch(mainBranch,0,"r");
00104
00105
00106 IOMk->SetDebug();
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 StTrgMaker *analysisMaker = new StTrgMaker("analysis");
00117
00118
00119 Int_t wrStEOut = tflag.Contains("evout",TString::kIgnoreCase);
00120 if (wrStEOut) {
00121 cout << "!!!! trigCtb: will write out .event.root file !!" << endl << endl;
00122 StTreeMaker *outMk = new StTreeMaker("EvOut","","bfcTree");
00123 outMk->SetIOMode("w");
00124 outMk->SetBranch("eventBranch","test.event.root","w");
00125 outMk->IntoBranch("eventBranch","StEvent");
00126 }
00127
00128
00129
00130
00131 Int_t iInit = chain->Init();
00132 if (iInit) chain->Fatal(iInit,"on init");
00133 chain->PrintInfo();
00134
00135
00136
00137 TTable *tabl=0;
00138 TDataSet *obj=0;
00139 TDataSet *ddb=0;
00140 TDataSet *ddstBranch=0;
00141
00142
00143
00144
00145
00146 int istat=0,i=1;
00147 EventLoop: if (i <= nEvents && istat!=2) {
00148
00149 cout << endl << "============================ Event " << i
00150 << " start ============================" << endl;
00151
00152 chain->Clear();
00153 istat = chain->Make(i);
00154
00155 if (istat==2)
00156 {cout << "Last event processed. Status = " << istat << endl;}
00157 if (istat==3)
00158 {cout << "Error event processed. Status = " << istat << endl;}
00159
00160
00161 if (!istat) {
00162
00163 ddstBranch=chain->GetDataSet("dstBranch");
00164
00165 TDataSetIter dstbranchIter(ddstBranch);
00166
00167 if (ddstBranch) {
00168
00169 cout << endl << " QAInfo: in dstBranch " << endl;
00170
00171 while (ddb=dstbranchIter.Next()) {
00172
00173 cout << endl <<
00174 " QAInfo: found object: " << ddb->GetName() << endl;
00175
00176 TString dsName = ddb->GetName();
00177
00178 if (ddb->InheritsFrom("TTable")) {
00179
00180 tabl = (TTable *)ddb;
00181 cout << " QAInfo: it is a table with #rows = "
00182 << tabl->GetNRows() << endl;
00183
00184 if (dsName == "BfcStatus") {
00185
00186 TDataSetIter bfcstatiter(ddb);
00187 St_dst_bfc_status *bfcstat =
00188 (St_dst_bfc_status *) bfcstatiter.Find("BfcStatus");
00189 St_dst_bfc_status::iterator bth = bfcstat->begin();
00190 St_dst_bfc_status::iterator bthEnd = bfcstat->end();
00191
00192 for (; bth != bthEnd; bth++)
00193 {
00194 cout << " QAInfo: BfcStatus table -- row " << ij <<
00195 ", Maker: " << (*bth).maker_name <<
00196 " has istat = " << (*bth).status << endl;
00197 }
00198 }
00199 }
00200 }
00201 }
00202 }
00203
00204
00205
00206 i++;
00207 goto EventLoop;
00208 }
00209
00210 i--;
00211 cout << endl << "============================ Event " << i
00212 << " finish ============================" << endl;
00213
00214 }
00215
00216
00217
00218 void trigCtb(const Int_t startEvent, const Int_t nEvents, const Char_t *file, const Char_t *qaflag)
00219 {
00220 printf("*file = %s\n",file);
00221 if (nEvents==-1) { Help(); return;}
00222 const char *fileListQQ[]={0,0};
00223 if (strncmp(file,"GC",2)==0) {
00224 fileListQQ=0;
00225 } else {
00226 fileListQQ[0]=file;
00227 }
00228 trigCtb(startEvent,nEvents,fileListQQ,qaflag);
00229 }
00230
00231 void trigCtb(const Int_t nEvents, const Char_t *file, const Char_t *qaflag)
00232 {
00233 trigCtb(1,nEvents,file,qaflag);
00234 }
00235
00236
00237 void trigCtb(const Int_t nEvents, const Char_t *path,const Char_t *file, const Char_t *qaflag, int flag)
00238 {
00239 TString F;
00240 if (path && path[0] && path[0]!='-') F = path;
00241 if (file && file[0] && file[0]!='-')
00242 {
00243 if (!F.IsNull()) F +="/";
00244 F += file;
00245 }
00246 TString opt = qaflag;
00247 if (flag) opt += " evout";
00248
00249
00250 trigCtb(1,nEvents,F.Data(),opt.Data());
00251 }
00252
00253
00254 void trigCtb(Int_t nEvents, const Char_t **fileList, const Char_t *qaflag)
00255 { trigCtb(1,nEvents,fileList,qaflag); }
00256