77 cout <<
"Usage: doEvents.C(2) // work with default event.root file" << endl;
78 cout <<
" doEvents.C(startEvent, nEvents,\"path/somefile.event.root\")" << endl;
79 cout <<
" doEvents.C(nEvents, \"path/*.event.root\")" << endl;
80 cout <<
" doEvents.C(nEvents, \"path/file.dst.root\", \"evout\") //Write out StEvent" << endl;
81 cout <<
" doEvents.C(nEvents, \"path/file.dst.root\", \"display\") //EventDispay" << endl;
82 cout <<
" doEvents.C(nEvents, \"path/file.dst.root\", \"dbon\") //DB on" << endl;
83 cout <<
" doEvents.C(nEvents, \"@file.lis\") //list of files in file.lis " << endl;
84 cout <<
" doEvents.C(nEvents, \"SELECT MuDST WHERE production=P04ih and zdc1Energy>50\", \"gc\") //GridCollector selects MuDST.root files " << endl;
85 cout <<
" doEvents.C(nEvents, \"SELECT event WHERE production=P04ih and zdc1Energy>50\", \"gc\") //GridCollector selects event.root files" << endl;
86 cout <<
" doEvents.C(nEvents, \"@GridCollector_commands.txt\", \"gc,evout\") //GridCollector commands in file" << endl;
92 void doEvents(Int_t nEvents,
const char ** fileList,
const char *qaflag =0);
93 void doEvents(Int_t startEvent, Int_t nEvents,
const char ** fileList,
const char *qaflag =0);
95 void doEvents(Int_t nEvents,
96 const char *file=
"/afs/rhic.bnl.gov/star/data/samples/example.event.root",
97 const char *qaflag = 0);
99 void doEvents(Int_t startEvent,Int_t nEvents,
100 const char *file=
"/afs/rhic.bnl.gov/star/data/samples/example.event.root",
101 const char *qaflag = 0);
103 void doEvents(Int_t nEvents,
106 const char *qaflag,
int flag);
108 void loadLibs(
const char *opt);
109 int gcInit (
const char *request);
113 void doEvents(Int_t startEvent, Int_t nEventsQQ,
const char **fileList,
const char *qaflag)
116 if (!qaflag) qaflag =
"";
117 int nEvents = nEventsQQ;
118 int eventNumber2Display = 0;
119 TString tflag = qaflag; tflag.ToLower();
120 int eventDisplay = tflag.Contains(
"disp");
122 if (gROOT->IsBatch() )
124 cout << endl << endl <<
" ** Warning ** You have started the EventDisplay version in a batch mode" << endl;
127 TObjArray *tokens = tflag.Tokenize(
":");
128 if ( tokens->GetEntries() >= 2 ) {
130 TString eventid = (tokens->At(tokens->GetEntries()-1))->GetName();
131 if ( eventid.IsDigit() )
132 eventNumber2Display = eventid.Atoi();
136 cout << endl << endl <<
" doEvents - input # events = " << nEvents << endl;
138 while(fileList[ilist]){
139 cout <<
" doEvents - input fileList = " << fileList[ilist] << endl;
142 cout <<
" doEvents - input qaflag = " << qaflag << endl;
150 if (tflag.Contains(
"dbon")) {
161 chain =
new StChain(
"StChain");
164 if (tflag.Contains(
"gc")) {
165 int nev = gcInit(fileList[0]);
167 if (nEvents <= 0) nEvents = nev;
169 setFiles =
new StFile(fileList);
170 char line[999]; strcpy(line,fileList[0]);
172 TString command(
"grep '.root' "); command += line+1;
173 FILE *pipe = gSystem->OpenPipe(command.Data(),
"r");
174 if (pipe) {fgets(line,999,pipe);line[strlen(line)-1] = 0;}
179 mainBranch.ReplaceAll(
".root",
"");
180 int idot = strrchr((
char*)mainBranch,
'.') - mainBranch.Data();
181 mainBranch.Replace(0,idot+1,
"");
182 mainBranch +=
"Branch";
187 int NwGeant=5000000, IwType=0, NwPaw=0;
194 if (!mainBranch.IsNull()) {
195 printf(
"*** mainBranch=%s ***\n",mainBranch.Data());
204 IOMk->SetBranch(
"*",0,
"0");
205 if(!mainBranch.IsNull()) IOMk->SetBranch(mainBranch,0,
"r");
206 IOMk->SetBranch(
"evtselBranch",0,
"r");
213 if (tflag.Contains(
"dbon")) {
214 dbMk =
new St_db_Maker(
"db",
"MySQL:StarDb",
"$STAR/StarDb",
"StarDb");
218 if (!mainBranch.Contains(
"mudstBranch") &&
219 mainBranch.Contains(
"dstBranch")) {
220 gSystem->Load(
"libStMagF");
221 gSystem->Load(
"StDetectorDbMaker");
222 gSystem->Load(
"StTpcDb");
223 gSystem->Load(
"StEventMaker");
242 Int_t wrStEOut = tflag.Contains(
"evout");
244 cout <<
"!!!! doEvents: will write out .event.root file !!" << endl << endl;
247 outMk->IntoBranch(
"evtselBranch",
"StEvent");
248 IOMk->SetNotify(
"CloseFile",outMk);
249 IOMk->SetNotify(
"OpenFile" ,outMk);
256 StEventDisplayMaker *displayMk =
new StEventDisplayMaker();
257 displayMk->SetEventIdToRender(eventNumber2Display);
258 if (eventNumber2Display)
259 printf(
"\n\n\n Display the Event %d only\n", eventNumber2Display);
261 displayMk->AddName(
"StEvent(Primary Tracks)");
267 displayMk->AddFilter(
new StFilterDef(
"MainFilter"));
271 if (!gSystem->Load(
"StCustomFilter")) {
278 cout <<
"----------------------------------------------------------" << endl;
279 cout <<
" doEvents - Initializing and Printing chain information " << endl;
280 Int_t iInit = chain->Init();
281 if (iInit) chain->Fatal(iInit,
"on init");
283 cout <<
"----------------------------------------------------------" << endl << endl;
287 if (startEvent > 1) IOMk->Skip(startEvent-1);
291 istat = chain->EventLoop(1,nEvents);
297 void doEvents(Int_t startEvent, Int_t nEvents,
const char *file,
const char *qaflag)
299 if (!qaflag) qaflag=
"";
300 printf(
"*file = %s\n",file);
301 const char *fileListQQ[]={0,0};
303 cout <<
"Calling (startEvent,nEvents,fileListQQ,qaflag)" << endl;
304 doEvents(startEvent,nEvents,fileListQQ,qaflag);
307 void doEvents(Int_t nEvents,
const char *file,
const char *qaflag)
309 if (!qaflag) qaflag=
"";
310 cout <<
"Calling (1,nEvents,file,qaflag)" << endl;
311 doEvents(1,nEvents,file,qaflag);
315 void doEvents(Int_t nEvents,
const char *path,
const char *file,
const char *qaflag,
int flag)
317 if (!qaflag) qaflag=
"";
319 if (path && path[0] && path[0]!=
'-') F = path;
320 if (file && file[0] && file[0]!=
'-') {
321 if (!F.IsNull()) F +=
"/";
324 TString opt = qaflag;
325 if (flag) opt +=
" evout";
327 cout <<
"Calling (1,nEvents,F.Data(),opt.Data())" << endl;
328 doEvents(1,nEvents,F.Data(),opt.Data());
332 void doEvents(Int_t nEvents,
const char **fileList,
const char *qaflag)
334 cout <<
"Calling (1,nEvents,fileList,qaflag)" << endl;
335 doEvents(1,nEvents,fileList,qaflag);
338 void loadLibs(
const char *opt)
344 gSystem->Load(
"libPhysics");
345 gSystem->Load(
"libTable");
346 gSystem->Load(
"libGeom");
349 gSystem->Load(
"St_base");
350 gSystem->Load(
"StChain");
351 gSystem->Load(
"St_Tables");
352 gSystem->Load(
"StUtilities");
353 gSystem->Load(
"StTreeMaker");
354 gSystem->Load(
"StIOMaker");
355 gSystem->Load(
"StarClassLibrary");
356 gSystem->Load(
"StTriggerDataMaker");
357 gSystem->Load(
"StBichsel");
358 gSystem->Load(
"StEvent");
359 gSystem->Load(
"StTpcDb");
360 gSystem->Load(
"StEventUtilities");
361 gSystem->Load(
"StEmcUtil");
362 gSystem->Load(
"StTofUtil");
363 gSystem->Load(
"StPmdUtil");
364 gSystem->Load(
"StPreEclMaker");
365 gSystem->Load(
"StStrangeMuDstMaker");
366 gSystem->Load(
"StMuDSTMaker");
367 gSystem->Load(
"StarMagField");
368 gSystem->Load(
"StMagF");
369 gSystem->Load(
"StAnalysisMaker");
370 gSystem->Load(
"StMuAnalysisMaker");
371 cout <<
" loading of shared libraries done" << endl;
374 if (strstr(opt,
"dbon")) {
375 gSystem->Load(
"StDbLib.so");
376 gSystem->Load(
"StDbBroker.so");
377 gSystem->Load(
"libStDb_Tables.so");
378 gSystem->Load(
"St_db_Maker.so");
379 gSystem->Load(
"StTpcDb");
380 gSystem->Load(
"StDetectorDbMaker");
383 if (strstr(opt,
"disp")) {
384 gSystem->Load(
"St_g2t");
385 gSystem->Load(
"geometry");
386 gSystem->Load(
"St_geant_Maker");
387 gSystem->Load(
"StTableUtilities");
388 gSystem->Load(
"StEventDisplayMaker");
394 int gcReadCommands(
const char *file, TString& cmds)
398 inp = fopen(file,
"r");
400 printf(
"doEvents: ERROR. File Not Found // %s\n",req+1);
404 char line[500], *comm, *fst;
405 while(fgets(line, 500, inp)) {
406 for (
int i=0; line[i]; i++)
407 if (line[i]==
'\t' || line[i]==
'\n') line[i]=
' ';
409 fst = line + strspn(line,
" \t");
410 if (fst[0] == 0 )
continue;
411 if (fst[0] ==
'#')
continue;
412 if (strncmp(fst,
"//",2)==0 )
continue;
414 comm = strstr(line,
" //");
if (comm) comm[0]=0;
425 int gcInit(
const char *request)
428 gSystem->Load(
"StGridCollector");
432 if (request == 0 || *request == 0) {
435 const char *argv[] = {
437 "-c",
"/afs/rhic.bnl.gov/star/incoming/GCA/gca.rc"
439 "-w",
"production=P04ih and zdc1Energy>50"
441 const Int_t argc =
sizeof(argv)/4;
442 ierr = req->Init(argc, argv);
444 std::cout <<
"doEvents.C can not initialize the Grid Collector "
445 <<
"with argument \"";
447 for (Int_t i = 1; i < argc; ++ i)
448 std::cout <<
" " << argv[i];
449 std::cout <<
"\"\nError code is " << ierr
453 else if (*request ==
'@') {
455 ierr = gcReadCommands(request+1, cmds);
456 if (!ierr) ierr = req->Init(cmds.Data());
458 std::cout <<
"doEvents.C can not initialize the Grid Collector "
459 <<
"with argument \"" << cmds.Data()
460 <<
"\"\nError code is " << ierr
465 ierr = req->Init(request);
467 std::cout <<
"doEvents.C can not initialize the Grid Collector "
468 <<
"with argument \"" << request
469 <<
"\"\nError code is " << ierr
478 int nEvents = req->GetNEvents();
479 std::cout <<
"INFO: actual number of events " << nEvents << std::endl;
481 mainBranch = req->GetCompName();
482 mainBranch +=
"Branch";
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
static void setLevel(unsigned int level)
sets the debug level
A typical Analysis Class.
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
virtual void LoadGeometry(const Char_t *option="detp geometry field_only")
Specifies GEANT3 geometry command.