StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TDFReader.C
1 void TDFReader(int run, int file=1, int nEvents=1000000, int debug=0, const char* dir="trgdata"){
2  //void TDFReader(int run, const char* dir=".", int nEvents=10000){
3 
4  gROOT->Macro("Load.C");
5  gSystem->Load("StIOMaker");
6  gSystem->Load("StTriggerDataMaker");
7  gSystem->Load("StRccCounterMonitor");
8 
9  cout << "Setting up chain" << endl;
10  StChain* chain = new StChain;
11 
12  StIOMaker* iomaker = 0;
13  char name[200];
14  if(file>0){
15  sprintf(name,"trgdata/run%d.%d.dat",run,file);
16  cout << "Reading up to "<<nEvents<<" events from "<<name<<endl;
17  iomaker = new StIOMaker("IO","r", name);
18  }else if(file>-999){
19  StFile* files = new StFile();
20  int id=run/1000;
21  for(int i=0; i<-file; i++){
22  int f=i*20+1;
23  char* cmd[200];
24  sprintf(cmd,"mkdir -p %d; cd %d; ln -s ../trgdata/run%d.%d.dat run%d_%d.dat",id,id,run,f,run,f);
25  printf("%s\n",cmd);
26  system(cmd);
27  sprintf(name,"%d/run%d_%d.dat",id,run,f);
28  printf("Adding %s\n",name);
29  files->AddFile(name);
30  }
31  files->ls();
32  iomaker = new StIOMaker("IO","r",files);
33  }else{
34  StFile* files = new StFile();
35  int id=run/1000;
36  for(int i=0; i<2; i++){
37  int f=i+1;
38  char* cmd[200];
39  sprintf(cmd,"mkdir -p %d; cd %d; ln -s ../trgdata/run%d.%d.dat run%d_%d.dat",id,id,run,f,run,f);
40  printf("%s\n",cmd);
41  system(cmd);
42  sprintf(name,"%d/run%d_%d.dat",id,run,f);
43  printf("Adding %s\n",name);
44  files->AddFile(name);
45  }
46  files->ls();
47  iomaker = new StIOMaker("IO","r",files);
48  }
49 
50  StTriggerDataMaker* trgmaker = new StTriggerDataMaker();
51  StRccCounterMonitor* rccmaker = new StRccCounterMonitor(run);
52  rccmaker->setDebug(debug);
53 
54  cout << "Init Chain" << endl;
55  chain->Init();
56 
57  cout << "Event Loop nEvents=" << nEvents << endl;
58  chain->EventLoop(0,nEvents);
59 
60  cout << "Finish Chain" << endl;
61  chain->Finish();
62  delete chain;
63 }
Definition: StTree.h:125
virtual Int_t Finish()
Definition: StChain.cxx:85