70 #include "TEntryList.h" 76 #include "AliRawReaderRoot.h" 77 #include "AliXRDPROOFtoolkit.h" 78 #include "AliRawVEvent.h" 79 #include "AliRawEventHeaderBase.h" 81 #include "AliSysInfo.h" 82 #include "TTimeStamp.h" 84 #include "TAlienCollection.h" 94 TNamed(triggerName,triggerName),
99 fCounterEventInput(0),
100 fCounterFileOutput(0),
101 fCounterEventOutput(0),
108 fDefaultTimeOut(timeOut),
109 fDefaultTreeCache(cacheSize),
110 fESDTriggerList(NULL)
113 gSystem->Setenv(
"XRDCLIENTMAXWAIT",Form(
"%d",timeOut));
114 gEnv->SetValue(
"XNet.RequestTimeout", timeOut);
115 gEnv->SetValue(
"XNet.ConnectTimeout", timeOut);
116 gEnv->SetValue(
"XNet.TransactionTimeout", timeOut);
117 gEnv->SetValue(
"XNet.FirstConnectMaxCnt", 2);
118 gEnv->SetValue(
"TFile.AsyncPrefetching", 1);
131 for (
Int_t i=0; i<entries; i++){
134 tree->SetAlias(
"trigger",trigger);
149 if (rawFile==NULL)
return;
150 if (TPRegexp(
"^alien").Match(rawFile) && gGrid==0) TGrid::Connect(
"alien");
152 TPRegexp reg0(
".*/");
153 reg0.Substitute(chunkName,
"");
154 TPRegexp reg1(
".root$");
155 reg1.Substitute(chunkName,
"");
157 std::ofstream file_out(
"gidrawReader.list");
159 file_out<<
"fname/C:eventCounter/i:gid/l:timeStamp/i:period/i:orbit/i:bcid/i:eventID/i"<<endl;
161 AliRawReaderRoot *preader =
new AliRawReaderRoot(rawFile);
163 ::Error(
"dumpRAWGIDTree",
"rawFile %s not accessible",rawFile);
167 while (preader->NextEvent()){
171 "\t"<<preader->GetEventIdAsLong()<<
172 "\t"<<preader->GetTimestamp()<<
173 "\t"<<preader->GetPeriod()<<
174 "\t"<<preader->GetOrbitID()<<
175 "\t"<<preader->GetBCID()<<
178 if (counter%100==0) printf(
"EventNumber\t%d\t%llu\n",counter,preader->GetEventIdAsLong());
201 if (rawFile==NULL)
return;
202 if (TPRegexp(
"^alien").Match(rawFile) && gGrid==0) TGrid::Connect(
"alien");
205 TPRegexp expRoot(
".root$");
206 TPRegexp expList(
".list$");
209 if (
TString(rawFile).Contains(expRoot)){
211 fileList->AddLast(
new TObjString(rawFile));
213 if (
TString(rawFile).Contains(expList)){
214 fileList =
gSystem->GetFromPipe(TString::Format(
"cat %s", rawFile)).Tokenize(
"\n");
217 ::Error(
"dumpRAWGIDTree",
"Invalid input r %s",rawFile);
219 std::ofstream file_out(
"gidrawTree.list");
222 file_out<<
"fname/C:eventCounter/i:gid/l:timeStamp/i:period/i:orbit/i:bcid/i:eventID/i"<<endl;
224 Int_t nFiles= fileList->GetEntries();
225 for (
Int_t iFile=0; iFile<nFiles; iFile++){
226 if (TPRegexp(
"^alien").Match(fileList->At(iFile)->GetName()) && gGrid==0) TGrid::Connect(
"alien");
227 finput =TFile::Open(fileList->At(iFile)->GetName());
229 ::Error(
"dumpRAWGIDTree",
"rawFile %s not accessible", fileList->At(iFile)->GetName());
232 tree = (
TTree*)finput->Get(
"RAW");
234 ::Error(
"dumpRAWGIDTree",
"rawFile %s does not contained requested tree",rawFile);
238 TString chunkName=fileList->At(iFile)->GetName();
239 TPRegexp yearExp(
"./20.*/");
240 Int_t indexShort=chunkName.Index(yearExp);
241 TString chunkShort(&(chunkName[indexShort+7]));
243 TPRegexp reg0(
".*/");
244 reg0.Substitute(chunkName,
"");
245 TPRegexp reg1(
".root$");
246 reg1.Substitute(chunkName,
"");
248 AliRawVEvent* fEvent=0;
249 tree->SetBranchStatus(
"TPC*",kFALSE);
250 tree->SetBranchStatus(
"TRD*",kFALSE);
251 tree->SetBranchStatus(
"rawevent",kTRUE);
252 TBranch *fBranch = tree->GetBranch(
"rawevent");
262 fBranch->SetAddress(&fEvent);
263 fBranch->GetEntry(ievent);
264 AliRawEventHeaderBase *header = fEvent->GetHeader();
265 Int_t run = header->Get(
"RunNb");
267 const UInt_t *
id = header->GetP(
"Id");
268 ULong64_t period =
id ? (((id)[0]>>4)&0x0fffffff): 0;
269 ULong64_t orbit =
id ? ((((id)[0]<<20)&0xf00000)|(((
id)[1]>>12)&0xfffff)) : 0;
270 ULong64_t bcID =
id ? ((id)[1]&0x00000fff) : 0;
271 ULong64_t gid = (((ULong64_t)period << 36) | ((ULong64_t)orbit << 12) |(ULong64_t)bcID);
272 UInt_t timeStamp=header->Get(
"Timestamp");
276 AliSysInfo::AddStamp(TString::Format(
"%s",chunkShort.Data()).
Data(), 2, iFile, ievent);
287 if (ievent%100==0) printf(
"EventNumber\t%d\t%llu\n",ievent,gid);
314 if (TPRegexp(
"^alien").Match(chinput) && gGrid==0) TGrid::Connect(
"alien");
315 TFile * finput = TFile::Open(chinput);
317 ::Error(
"dumpRAWGIDTree",
"rawFile %s not accessible",chinput);
320 TTree * esdTree= (
TTree*)finput->Get(
"esdTree");
322 ::Error(
"dumpRAWGIDTree",
"rawFile %s does not contained requested tree",chinput);
326 TPRegexp regE(
"/AliESDs.root$");
327 regE.Substitute(chunkName,
"");
328 TPRegexp reg0(
".*/");
329 reg0.Substitute(chunkName,
"");
338 Int_t entries=esdTree->GetEntries();
339 ::Info(
"dumpAndCompareGID::DumpGIDESD",
"Entries=%llu",esdTree->GetEntries());
340 esdTree->SetAlias(
"gid",
"((fPeriodNumber << 36) | (fOrbitNumber << 12) | fBunchCrossNumber)");
342 entries=esdTree->Draw(
"gid:Entry$:fPeriodNumber:fOrbitNumber:fBunchCrossNumber:fEventNumberInFile:fTimeStamp",trigger,
"goffpara");
344 std::ofstream file_out(choutput);
346 file_out<<
"fname/C:eventCounter/i:gid/l:timeStamp/i:period/i:orbit/i:bcid/i:eventID/i"<<endl;
348 if (entries>0)
for (
Int_t i=0;i<entries; i++){
351 "\t"<<
Long64_t(esdTree->GetVal(1)[i])<<
352 "\t"<<
Long64_t(esdTree->GetVal(0)[i])<<
353 "\t"<<
Long64_t(esdTree->GetVal(6)[i])<<
354 "\t"<<
Long64_t(esdTree->GetVal(2)[i])<<
355 "\t"<<
Long64_t(esdTree->GetVal(3)[i])<<
356 "\t"<<
Long64_t(esdTree->GetVal(4)[i])<<
357 "\t"<<
Long64_t(esdTree->GetVal(5)[i])<<
376 treeGIDRAWReader->ReadFile(
"gidrawReeader.list",
"",
'\t');
377 treeGIDRAWTree->ReadFile(
"gidrawTree.list",
"",
'\t');
378 treeGIDESD->ReadFile(
"gidesd.list",
"",
'\t');
380 treeGIDESD->BuildIndex(
"gid");
381 treeGIDRAWTree->BuildIndex(
"gid");
382 treeGIDRAWReader->BuildIndex(
"gid");
383 treeGIDESD->AddFriend(treeGIDRAWReader,
"RAW");
384 treeGIDESD->AddFriend(treeGIDRAWTree,
"RAWTree");
386 if ( treeGIDRAWReader->GetEntries()!= treeGIDESD->GetEntries()){
387 ::Error(
"dumpAndCompareGID::diffList",
"TestFailed. Mismatch in number of events RAW=%llu\tESD=%llu", treeGIDRAWReader->GetEntries(), treeGIDESD->GetEntries());
389 ::Info(
"dumpAndCompareGID::diffList",
"TestOK. Match in number of events RAW=%llu\tESD=%llu", treeGIDRAWReader->GetEntries(), treeGIDESD->GetEntries());
391 if ( treeGIDRAWTree->GetEntries()!= treeGIDESD->GetEntries()){
392 ::Error(
"dumpAndCompareGID::diffList",
"TestFailed. Mismatch in number of events RAWTree=%llu\tESD=%llu", treeGIDRAWTree->GetEntries(), treeGIDESD->GetEntries());
394 ::Info(
"dumpAndCompareGID::diffList",
"TestOK. Match in number of events RAWTree=%llu\tESD=%llu", treeGIDRAWTree->GetEntries(), treeGIDESD->GetEntries());
396 Int_t entriesMatch=treeGIDESD->Draw(
"event-RAW.event",
"1");
398 if (entriesMatch>0) diff= TMath::Mean(entriesMatch, treeGIDESD->GetV1());
399 if (entriesMatch!= treeGIDRAWReader->GetEntries() || diff!=0){
400 ::Error(
"dumpAndCompareGID::diffList",
"TestFailed. Mismatch in GID");
402 ::Info(
"dumpAndCompareGID::diffList",
"TestOK. Match in GID");
415 if (!friendTrees)
return NULL;
417 Int_t ntrees=array->GetEntries();
419 tree->ReadFile(refTree,
"",
'\t');
420 tree->BuildIndex(
"gid");
421 for (
Int_t jf=0; jf<ntrees; jf++){
423 ftree->ReadFile(array->At(jf)->GetName(),
"",
'\t');
424 ftree->BuildIndex(
"gid");
425 tree->AddFriend(ftree,TString::Format(
"T%d",jf));
443 tree->ReadFile(triggerList,
"",
'\t');
444 Int_t entries=tree->GetEntries();
446 ::Error(
"AliOfflineTrigger::LoadTriggerList",
"Invalid input trigger list\t%s", triggerList);
449 TBranch *chBranch=tree->GetBranch(
"fname");
450 TBranch *gidBranch=tree->GetBranch(
"gid");
451 TBranch *eventBranch=tree->GetBranch(
"eventID");
452 TBranch *timeBranch=tree->GetBranch(
"timeStamp");
453 TBranch *triggerBranch=tree->GetBranch(
"trigger");
454 Bool_t isOK=(chBranch!=NULL && gidBranch!=NULL &&eventBranch && timeBranch!=NULL);
456 ::Error(
"AliOfflineTrigger::LoadTriggerList",
"Missing information - in trigger list\t%s", triggerList);
461 char * chbuffer=
new char[10000];
462 char * chtrigger=
new char[10000];
463 chBranch->SetAddress(chbuffer);
464 gidBranch->SetAddress(&gid);
465 timeBranch->SetAddress(&timeStamp);
466 eventBranch->SetAddress(&eventNr);
467 if (triggerBranch) triggerBranch->SetAddress(chtrigger);
468 for (
Int_t i=0; i<entries; i++){
487 if (rawFile==NULL)
return 0;
488 if (TPRegexp(
"^alien").Match(rawFile) && gGrid==0) TGrid::Connect(
"alien");
489 TFile * finput =TFile::Open(rawFile);
491 ::Error(
"dumpRAWGIDTree",
"rawFile %s not accessible",rawFile);
496 ::Error(
"dumpRAWGIDTree",
"rawFile %s does not contained requested tree",rawFile);
500 TPRegexp reg0(
".*/");
501 reg0.Substitute(chunkName,
"");
502 TPRegexp reg1(
".root$");
503 reg1.Substitute(chunkName,
"");
505 AliRawVEvent* fEvent=0;
506 tree->SetBranchStatus(
"TPC*",kFALSE);
507 tree->SetBranchStatus(
"TRD*",kFALSE);
508 tree->SetBranchStatus(
"rawevent",kTRUE);
509 TBranch *fBranch = tree->GetBranch(
"rawevent");
510 fBranch->SetAddress(&fEvent);
519 fBranch->GetEntry(ievent);
520 Int_t run = fEvent->GetHeader()->Get(
"RunNb");
521 const UInt_t *
id = fEvent->GetHeader()->GetP(
"Id");
522 ULong64_t period =
id ? (((id)[0]>>4)&0x0fffffff): 0;
523 ULong64_t orbit =
id ? ((((id)[0]<<20)&0xf00000)|(((
id)[1]>>12)&0xfffff)) : 0;
524 ULong64_t bcID =
id ? ((id)[1]&0x00000fff) : 0;
525 ULong64_t gid = (((ULong64_t)period << 36) | ((ULong64_t)orbit << 12) |(ULong64_t)bcID);
526 UInt_t timeStamp=fEvent->GetHeader()->Get(
"Timestamp");
527 if (gid==gidOld && verbose>0){
528 ::Error(
"AliOfflineTrigger::LoadMapFromRawData)",
"Event %d not unique GID. GID %llu can not be used as unique ID. Time %d", ievent, gid, timeStamp);
535 if (verbose==1&&ievent%100==0) ::Info(
"AliOfflineTrigger::LoadMapFromRawData",
"Event # \t%d\t%llu",ievent,gid);
536 if ((verbose&2)>0) ::Info(
"AliOfflineTrigger::LoadMapFromRawData",
"Event # \t%d\t%llu",ievent,gid);
541 ::Info(
"AliOfflineTrigger::LoadMapFromRawData()",
"Trig.event=%d. GID=%llu\tTime=%d", ievent, gid, timeStamp);
542 if (trgTimeStamp!=timeStamp){
543 ::Error(
"AliOfflineTrigger::LoadMapFromRawData()",
"Inconsistent timestamp");
550 tree->SetCacheSize(0);
563 AliRawVEvent* fEvent=0;
564 TBranch *fEventBranch = 0;
567 ::Error(
"AliOfflineTrigger::ExtractSelected",
"Output file not intitialized");
572 ::Info(
"AliOfflineTrigger::LoadMapFromRawData",
"Trigger list is empty. Nothing to filter for file %s", rawFile);
576 ::Info(
" AliOfflineTrigger::ExtractSelected",
"%s:\t N_{trig}=%d", rawFile,nTriggered);
580 TFile * finput = TFile::Open(rawFile);
582 ::Info(
" AliOfflineTrigger::ExtractSelected",
"File %s not exist or not accessible within TimeOut %d", rawFile,
fDefaultTimeOut);
585 if (finput->IsOpen()==kFALSE || finput->IsZombie()){
586 ::Info(
" AliOfflineTrigger::ExtractSelected",
"File %s not accessible within TimeOut %d", rawFile,
fDefaultTimeOut);
589 TTree *itree=
dynamic_cast<TTree*
>(finput->Get(
"RAW"));
591 ::Info(
" AliOfflineTrigger::ExtractSelected",
"Tree in file %s not exist or not accessible within TimeOut %d", rawFile,
fDefaultTimeOut);
594 fEventBranch = itree->GetBranch(
"rawevent");
595 fEventBranch->SetAddress(&fEvent);
603 Int_t size= itree->GetEntry(0);
607 Bool_t isSelected = kFALSE;
610 if (!isSelected)
continue;
615 size= itree->GetEntry(iEvent);
617 Int_t readEntry=itree->GetReadEntry();
624 itree->ResetBranchAddresses();
643 if (TPRegexp(
".xml$").Match(rawList)){
645 TAlienCollection *coll = (TAlienCollection *)TAlienCollection::Open(rawList);
646 Int_t nFiles = coll->GetNofGroups();
648 while( coll->Next()){
649 rawArray->AddLast(
new TObjString(coll->GetTURL()));
653 rawArray =
gSystem->GetFromPipe(TString::Format(
"cat %s", rawList)).Tokenize(
"\n");
656 ::Fatal(
"AliOfflineTrigger::ExtractSelected",
"Unable to get list of RAW files");
658 Int_t nFiles=rawArray->GetEntries();
660 ::Error(
"AliOfflineTrigger::ExtractSelected",
"Empty input list");
663 for (
Int_t iFile=0; iFile<nFiles; iFile++){
void SetTriggerAlias(TTree *tree, const char *trigger)
std::map< ULong64_t, TString > fTrgGIDTrigger
GID -> ChunkName.
void DumpGIDESD(const char *chinput="AliESDs.root", const char *trigger="1", const char *choutput="gidesd.list")
TObjArray * fESDTriggerList
std::map< ULong64_t, UInt_t > fRAWGIDTimeStamp
EventNumber -> GID.
void LoadTriggerList(const char *triggerList)
TFile * fRawTriggerFile
name of the output file
TTree * fRawTriggerTree
! pointer to ouput raw trigger files
Int_t LoadMapFromRawData(const char *rawFile="raw.root", Int_t verbose=1)
void AddESDAlias(const char *aliasName, const char *aliasValue)
std::map< ULong64_t, TString > fTrgGIDChunkName
std::map< UInt_t, ULong64_t > fRAWEventNrGID
GID -> EventNumber.
Int_t fCounterFileInput
input event counter
Int_t fDefaultTimeOut
triger map GID -> TimeStamp map
std::map< ULong64_t, UInt_t > fRAWGIDEventNr
GID -> ChunkName.
Double_t nEvents
plot quality messages
static TTree * MakeDiffTree(const char *refTree, const char *friendTrees)
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
Int_t fCounterFileOutput
triger map GID -> TimeStamp map
std::map< ULong64_t, TString > fRAWGIDChunkName
! pointer to output raw trigger tree
void DumpGIDRAWTree(const char *rawFile="raw.root")
void DumpGIDRAWReader(const char *rawFile="raw.root")
std::map< ULong64_t, UInt_t > fTrgGIDEventNr
GID -> Trigger type.
std::map< ULong64_t, UInt_t > fTrgGIDTimeStamp
GID -> EventNumber.
void ExtractSelected(const char *rawList, const char *triggerList, const char *outputName, Long_t maxCounter, Int_t verbose=1)
This class provides fucntionality for OFFLINE Trigger raw data selection and consistency checks...