45 tree->Branch(
"event", &(this->
fFull),
46 "full/l:time/i:detector:type/s:guid/C");
55 tree->SetBranchAddress(
"event", &(this->
fFull));
70 const ULong64_t bcMask = (1 <<
kBCWidth) - 1;
73 ULong64_t ret = ((bc & bcMask) |
90 # include <AliESDEvent.h>
95 ULong64_t period = esd->GetPeriodNumber();
96 ULong64_t orbit = esd->GetOrbitNumber();
97 ULong64_t bc = esd->GetBunchCrossNumber();
98 fType = esd->GetEventType();
99 fTime = esd->GetTimeStamp();
103 for (i = 0; i < guid.Length() && i < 42; i++)
fGUID[i] = guid[i];
104 for (; i < 42; i++)
fGUID[i] =
'\0';
110 Warning(
"Fill",
"Calling empty method - shouldn't happen");
116 # include <AliAnalysisManager.h>
117 # include <AliVEventHandler.h>
118 # include <AliESDEvent.h>
122 # include <AliCDBManager.h>
123 # include <AliCDBEntry.h>
124 # include <AliTriggerConfiguration.h>
125 # include <AliTriggerClass.h>
126 # include <AliTriggerCluster.h>
128 # include <TObjArray.h>
129 # include <TDirectory.h>
138 # include <AliAnalysisTaskSE.h>
179 fBranchNames =
"ESD:AliESDRun.,AliESDHeader.";
188 Printf(
"Creating tree and histogram");
195 16, -.5, 15.5, 31, -.5, 30.5);
200 Printf(
"Histogram (%d,%f,%f)x(%d,%f,%f)",
211 Printf(
"Make tree and disassociate from file");
213 fTree->SetDirectory(0);
214 Printf(
"Create branch");
228 static Bool_t first =
true;
233 if (!esd->GetHeader())
return;
239 ULong64_t mask = esd->GetTriggerMask();
242 if ((1 << i) & mask) dets |=
fDets[i];
248 UInt_t type = esd->GetEventType();
250 for (
UInt_t i = 0; i < 31; i++) {
251 if ((1 << i) & detectors)
fDetVsType->Fill(type, i);
261 AliVEventHandler* inp = mgr->GetInputEventHandler();
263 Warning(
"UserNotify",
"No input handler");
266 TTree* tree = inp->GetTree();
268 Warning(
"UserNotify",
"No input tree");
271 TFile*
file = tree->GetCurrentFile();
273 Warning(
"UserNotify",
"No current file for tree");
276 const TUrl*
url = file->GetEndpointUrl();
278 Warning(
"UserNotify",
"No end point for file");
282 Printf(
"Got GUID=%s from %s",
fGUID.Data(), url->GetUrl());
288 Printf(
"Loading trigger configuration for run %d", runNo);
290 AliCDBManager* cdb = AliCDBManager::Instance();
291 cdb->SetDefaultStorageFromRun(runNo);
295 AliCDBEntry* entry = cdb->Get(
"GRP/CTP/Config");
296 if (!entry || !entry->GetObject()) {
297 Warning(
"LoadTriggerConfig",
"Couldn't get trigger configuration");
300 AliTriggerConfiguration* config =
301 static_cast<AliTriggerConfiguration*
>(entry->GetObject());
304 const TObjArray& clss = config->GetClasses();
305 fDets.resize(clss.GetEntries());
309 AliTriggerClass* cls = 0;
310 while ((cls = static_cast<AliTriggerClass*>(next()))) {
311 Int_t mask = cls->GetMask();
312 AliTriggerCluster* cluster = cls->GetCluster();
314 Warning(
"LoadTriggerConfig",
315 "Failed to get trigger cluster for %s", cls->GetName());
318 TString names = cluster->GetDetectorsInCluster();
319 if (names.IsNull()) {
320 Warning(
"LoadTriggerConfig",
"No detectors for cluster %s",
327 Printf(
"Trigger mask 0x%08x (%3d): 0x%08x (%s)",
328 mask,
id, dets, names.Data());
340 mgr->ConnectInput(
this, 0, mgr->GetCommonInputContainer());
341 AliAnalysisDataContainer* contTree =
342 mgr->CreateContainer(
"T", TTree::Class(),
343 AliAnalysisManager::kOutputContainer,
345 AliAnalysisDataContainer* contList =
346 mgr->CreateContainer(
"L", TList::Class(),
347 AliAnalysisManager::kOutputContainer,
349 mgr->ConnectOutput(
this,
kTreeSlot, contTree);
350 mgr->ConnectOutput(
this,
kListSlot, contList);
359 task->
Connect(AliAnalysisManager::GetAnalysisManager());
386 typedef std::map<ULong64_t,ULong64_t>
Map;
388 typedef Map::key_type
Key;
410 const char*
GetName()
const {
return "eventTimeMap"; }
518 # include <TArrayL64.h>
520 # include <TParameter.h>
521 # include <TCanvas.h>
554 if (cur == 0) old = 0;
558 std::cout <<
"\rLooping over " << total <<
" entries: ... "
559 << now <<
'%' << std::flush;
560 if (now >= 100) std::cout << std::endl;
577 chain->Add(inputName);
578 if (chain->GetListOfFiles()->GetEntries() < 1) {
579 Error(
"Run",
"Failed to add \"%s\" to chain", inputName);
596 if (file) file->Close();
608 Bool_t Run(
const char* inputName,
const char* outputName,
609 const char* treeName=
"T")
611 if (!
OpenInput(inputName, treeName))
return false;
616 ULong64_t* values =
new ULong64_t[nEnt];
620 for (
Long64_t iEnt = 0; iEnt < nEnt; iEnt++) {
623 fTree->GetEntry(iEnt);
630 Warning(
"Run",
"Non-PHYSICS event (%d) with FMD in it",
fData.
fType);
645 TMath::Sort(n, values, index.fArray,
false);
649 ULong64_t key = values[index[0]];
651 ULong64_t dt = key-prev;
652 ULong64_t min = 0xFFFFFFFFFFFFFFFF;
654 eventTimeMap[key] = dt;
662 Printf(
"0x%016llx==0x%016llx -> dt=%10llu [%10lld %10lld] "
663 "(det: 0x%08x 0x%08x type: 0x%04x 0x%04x time: %08d %08d)",
664 key, prev, dt, j, k, dets[j], dets[k],
665 types[j], types[k], times[j], times[k]);
668 eventTimeMap[key] = dt;
669 min = TMath::Min(dt, min);
670 max = TMath::Max(dt, max);
672 std::cout <<
"Range is [" << min <<
"," << max <<
']' << std::endl;
674 TFile* output = TFile::Open(outputName,
"RECREATE");
676 Error(
"Run",
"Failed to create output file \"%s\"", outputName);
681 eventTimeMap.Write();
692 const char* treeName=
"T")
694 if (!
OpenInput(inputName, treeName))
return false;
697 TFile* output = TFile::Open(outputName,
"UPDATE");
699 Error(
"Test",
"Failed to open \"%s\"", outputName);
704 static_cast<EventTimeMap*
>(output->Get(
"eventTimeMap"));
706 Error(
"Test",
"Failed to get \"%s\" from \"%s\"",
707 "eventTimeMap", outputName);
712 ULong64_t mmin = TMath::Min(25*
fMin, 900000ULL);
713 ULong64_t mmax = TMath::Min(25*
fMax, 110000000ULL);
714 TH1* diff =
new TH1D(
"diff",
"Time-to-last-event (10#mus bins w/FMD)",
715 (mmax-mmin)/10000, mmin, mmax);
717 diff->SetXTitle(
"#Deltat [ns]");
718 diff->SetFillColor(kRed+1);
719 diff->SetFillStyle(3001);
720 diff->SetDirectory(0);
723 TH1* ldiff =
new TH1D(
"ldiff",
"log(#Deltat) - Events w/FMD",
726 ldiff->SetXTitle(
"log_{10}(#Deltat) [ns]");
727 ldiff->SetFillColor(kGreen+1);
728 ldiff->SetFillStyle(3001);
729 ldiff->SetDirectory(0);
737 for (
Long64_t iEnt = 0; iEnt < nEnt; iEnt++) {
739 fTree->GetEntry(iEnt);
748 Warning(
"Run",
"Non-PHYSICS event (%d) with FMD in it",
fData.
fType);
754 ULong64_t dT = eventTimeMap->
Get(value);
756 Warning(
"Test",
"Value %llu not found", value);
763 Warning(
"Test",
"Impossible dt=%llu found for %llu (0x%0x %2d)",
777 Printf(
"missing: %llu, bad: %llu, good: %llu, no FMD: %llu, all: %llu",
778 nMiss,nZero,nGood,nNoFMD,nEnt);
781 TCanvas*
c =
new TCanvas(
"c",
"C");
782 c->SetTopMargin(0.01);
783 c->SetRightMargin(0.01);
785 TVirtualPad* p = c->cd(2);
810 # pragma link C++ class std::pair<ULong64_t,ULong64_t>+;
811 # pragma link C++ class std::map<ULong64_t,ULong64_t>+;
814 # pragma link C++ class std::vector<UInt_t>+;
void ReadBranch(TTree *tree)
std::vector< UInt_t > fDets
void CreateBranch(TTree *tree)
static ULong64_t EncodeFull(ULong64_t period, ULong64_t orbit, ULong64_t bc)
Bool_t OpenInput(const char *inputName, const char *treeName)
ConstIterator Begin() const
void Connect(AliAnalysisManager *mgr)
Bool_t Run(const char *inputName, const char *outputName, const char *treeName="T")
Bool_t Test(const char *inputName, const char *outputName, const char *treeName="T")
void LoadTriggerConfig(Int_t runNo)
Map::const_iterator ConstIterator
void Set(const Key ×tamp, const Value &diff)
std::map< ULong64_t, ULong64_t > Map
void UserCreateOutputObjects()
void Fill(AliESDEvent *esd, UInt_t dets, const TString &guid)
Iterator Find(const Key &k)
std::pair< ULong64_t, ULong64_t > EventTimeMapPair
ConstIterator Find(const Key &k) const
ConstIterator End() const
ClassDef(EventTimeTask, 3)
void Progress(Long64_t cur, Long64_t total) const
EventTimeTask(const char *name)
Value & operator[](const Key &k)
const char * GetName() const
Value Get(const Key ×tamp) const
void UserExec(Option_t *)