StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdEz2histoExample.C
1 
2 rdEz2histoExample(int mxEve=5000,
3  char *runL="R5132028 R5132029 ",
4  TString iPath="/star/data04/sim/balewski/daq/ezTree/pp200/pp2/",
5  int firstSec=5,
6  int lastSec=5,
7  int oflTrigId=0
8  ) {
9 
10  char *libL[]={
11  "StRoot/StDbLib/StDbLib.so",
12  "StRoot/StEEmcUtil/EEfeeRaw/libEEfeeRaw.so",
13  "StRoot/StEEmcDbMaker/libEEmcDbMaker.so",
14  "StRoot/StEEmcPool/StEzExample/libEzEEtower.so",
15  "EEmcDb/libEEmcDb.so"
16  };
17 
18  int i;
19  for(i=0;i<sizeof(libL)/sizeof(char*);i++) {
20  printf(" load '%s' ...\n",libL[i]);
21  assert( !gSystem->Load(libL[i]));
22  }
23  printf("loaded %d libraries\n",i);
24 
25  // ......... input event file .........
26 
27  TChain *chain = new TChain("ezstar");
28 
29  char *run=strtok(runL," "); // init 'strtok'
30  int i=0;
31  do {
32  printf("add run %d '%s' \n",i++,run);
33  TString fullName=iPath+run+".ez.root";
34  chain->Add(fullName);
35  } while(run=strtok(0," ")); // advance by one nam
36 
37  int nEntries = (Int_t)chain->GetEntries();
38  printf("Sort %d of total Events %d\n",mxEve, nEntries);
39  int nEve=0;
40 
41 
42  Int_t nEntries = (Int_t)chain->GetEntries();
43  if(nEntries<=0) {
44  printf("\n\nSth is wrong, chain is empty nEntries=%d\n\n",nEntries);
45  assert(nEntries>0);
46  }
47 
48  EEfeeRawEvent *eFee=0;
49  EEmcEventHeader *eHead =0;
50  EEstarTrig *eTrig=0;
51  chain->SetBranchAddress("eemc",&eFee);
52  chain->SetBranchAddress("head",&eHead);
53  chain->SetBranchAddress("trig",&eTrig);
54 
55  chain->GetEntry(0);// read first event
56 
57  long timeStamp=eHead->getTimeStamp();
58 
59  printf("run timeStamp=%d=%s\n" ,timeStamp,ctime((const time_t *)&timeStamp));
60 
61  //............ DB-reader .................
62  EEmcDb *db=new EEmcDb() ;
63  db->setThreshold(3.0);
64  db->requestDataBase(timeStamp,firstSec,lastSec); // range of sectors
65 
66  TObjArray HList;
67  //........... sorters ..........
69  sorter->set(&HList,db,eFee,eHead,eTrig);
70  sorter->init();
71 
72  printf("Sort %d of total Events %d, use trigId=%d\n",mxEve, nEntries,oflTrigId);
73 
74  int nEve=0,nAcc=0,nOK=0;
75  int t1=time(0);
76  for(nEve=0; nEve<nEntries && nEve<mxEve; nEve++) {
77  chain->GetEntry(nEve);
78  if(nEve%1000==0)printf("in %d, acc %d ok=%d\n",nEve,nAcc,nOK);
79  if(oflTrigId>0 && ! eTrig->isTrigID(oflTrigId) ){ continue;}
80  nAcc++;
81  // verify data block consistency
82  int nCr=eFee->maskWrongCrates(timeStamp,eHead->getToken(),EEfeeRawEvent::headVer1);
83  if(nCr==22) nOK++;
84  sorter->make();
85  }
86  int t2=time(0);
87  if(t2==t1) t2=t1+1;
88  float rate=1.*nEve/(t2-t1);
89  printf("sorting done, nEve=%d, CPU event rate=%.1f Hz\n",nEve,rate);
90 
91  sorter->finish();
92 
93  // save output histograms
94 
95  HList.ls();
96  sorter->saveHisto("aaa");
97 
98  return;
99  h=(TH1F*)HList.FindObject("tE");
100  h->Draw(""); gPad->SetLogy();
101  }
102