2 # include <AliFMDEventInspector.h>
3 # include <AliForwardCorrectionManager.h>
5 # include <AliESDFMD.h>
6 # include <AliAODForwardMult.h>
7 # include <AliESDEvent.h>
11 class AliFMDEventInspector;
15 #include <AliBaseESDTask.h>
16 #include <AliForwardUtil.h>
19 #include "EventTimeTask.C"
22 * @defgroup pwglf_forward_eventtime Investigation of time-between-events
23 * @ingroup pwglf_forward_trains_specific
26 * Task to analyse the energy loss in the FMD rings as function of the
27 * time to previous event.
29 * @ingroup pwglf_forward_eventtime
31 struct ELossTimeTask : public AliBaseESDTask
34 * Constructor - for I/O only
50 * @param name Name of task
52 ELossTimeTask(const char* name)
53 : AliBaseESDTask(name, "ELossTimeTask",
54 &(AliForwardCorrectionManager::Instance())),
55 fEventInspector("fmdEventInspector"),
66 * Book output objects. Derived class should define this to book
67 * output objects on the processing output list @c fList before the
68 * actual event processing. This is called on the master and on
71 * If this member function returns false, the execution is stopped
72 * with a fatal signal.
74 * @return true on success.
78 fNeededCorrections = 0;
79 fExtraCorrections = 0;
81 fDt = new TH1D("dt", "Time-to-last event (PS-triggered)", 60, 0, 15);
82 fDt->SetXTitle("log_{10}(#Deltat)");
83 fDt->SetFillColor(kYellow+2);
84 fDt->SetLineColor(kYellow+2);
85 fDt->SetFillStyle(3001);
89 fFMD1i.Book(fList, fDt);
90 fFMD2i.Book(fList, fDt);
91 fFMD2o.Book(fList, fDt);
92 fFMD3i.Book(fList, fDt);
93 fFMD3o.Book(fList, fDt);
95 // Possibly re-read map
101 * Process a single event
103 * @param esd Input event
105 * @return true on success
107 virtual Bool_t Event(AliESDEvent& esd)
109 Bool_t lowFlux = kFALSE;
114 UShort_t nClusters = 0;
115 UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
116 ivz, ip, cent, nClusters);
117 if (found & AliFMDEventInspector::kNoEvent) return false;
118 if (found & AliFMDEventInspector::kNoTriggers) return false;
119 if (found & AliFMDEventInspector::kNoSPD) return false;
120 if (found & AliFMDEventInspector::kNoFMD) return false;
121 if (found & AliFMDEventInspector::kNoVertex) return false;
122 if (found & AliFMDEventInspector::kBadVertex) return false;
124 // do not process pile-up, A, C, and E events
125 if (triggers & AliAODForwardMult::kPileUp) return false;
126 if (triggers & AliAODForwardMult::kA) return false;
127 if (triggers & AliAODForwardMult::kC) return false;
128 if (triggers & AliAODForwardMult::kE) return false;
130 // We want only the events found by off-line
131 if (!(triggers & AliAODForwardMult::kOffline)) return false;
133 // Perhaps we should also insist on MB only
134 // if (fOnlyMB && (!(triggers & AliAODForwardMult::kInel))) return false;
137 AliESDFMD* esdFMD = esd.GetFMDData();
138 ULong64_t period = esd.GetPeriodNumber();
139 ULong64_t orbit = esd.GetOrbitNumber();
140 ULong64_t bc = esd.GetBunchCrossNumber();
141 ULong64_t full = EventTimeData::EncodeFull(period, orbit, bc);
142 ULong64_t dt = fMap->Get(full);
143 Double_t logDt = TMath::Log10(25. * dt);
144 if (dt == EventTimeMap::kInvalidTime) {
146 Printf("!!! Failed to find dT for 0x%016llu", full);
149 // Printf("=== 0x%016llu -> 0x%016llu", full, dt);
152 for (UShort_t d = 1; d <= 3; d++) {
153 UShort_t nQ = d == 1 ? 1 : 2;
154 for (UShort_t q = 0; q < nQ; q++) {
157 case 1: r = &fFMD1i; break;
158 case 2: r = (q == 0 ? &fFMD2i : &fFMD2o); break;
159 case 3: r = (q == 0 ? &fFMD3i : &fFMD3o); break;
161 r->Event(*esdFMD, logDt);
167 * Do the final analysis on the merged output.
169 * @return true on success
171 virtual Bool_t Finalize()
173 fDt = static_cast<TH1*>(fList->FindObject("dt"));
175 fFMD1i.Finalize(fList, fResults, fDt);
176 fFMD2i.Finalize(fList, fResults, fDt);
177 fFMD2o.Finalize(fList, fResults, fDt);
178 fFMD3i.Finalize(fList, fResults, fDt);
179 fFMD3o.Finalize(fList, fResults, fDt);
183 * Get a reference to the event inspector. User must override this
184 * to return proper object
186 * @return Reference to the event inspector
188 virtual AliFMDEventInspector& GetEventInspector() { return fEventInspector; }
190 * Get a reference to the event inspector. User must override this
191 * to return proper object
193 * @return Reference to the event inspector
195 virtual const AliFMDEventInspector& GetEventInspector() const
197 return fEventInspector;
200 * Read the map from timestamp to time-to-previous event
202 * @param filename File to read the map from
204 * @return true on success, false otherwise
206 Bool_t ReadMap(const char* filename)
208 if (gSystem->AccessPathName(filename, kReadPermission)) {
209 // TSystem::AccessPathName returns false if file can be accessed!
210 Error("ReadMap", "File \"%s\" cannot be open for reading", filename);
213 Printf("Opening \"%s\" ...", filename);
214 TFile* file = TFile::Open(filename, "READ");
216 Error("ReadMap", "Failed to open file \"%s\"", filename);
219 Printf("Opened \"%s\" ...", filename);
220 TObject* o = file->Get("eventTimeMap");
222 Error("ReadMap", "Failed to get \"eventTimeMap\" from %s", filename);
225 Printf("Got object \"eventTimeMap\" from \"%s\" ...", filename);
226 if (!o->IsA()->InheritsFrom(EventTimeMap::Class())) {
227 Error("ReadMap", "Object \"%s\" is not an EventTimeMap, but a %s",
228 o->GetName(), o->ClassName());
231 Printf("Set the \"eventTimeMap\" to use");
236 fMap = static_cast<EventTimeMap*>(o);
241 * Create and connect the task
243 * @param mapfile File name of file containing timestamp map
245 * @return true on connect
247 static Bool_t Create(const char* mapfile)
249 ELossTimeTask* task = new ELossTimeTask("elossTime");
250 if (!task->ReadMap(mapfile)) return false;
256 * Dummy copy constructor
258 * @param o Object to copy from
260 ELossTimeTask(const ELossTimeTask& o) : AliBaseESDTask(o) {}
261 /** Our event inspector */
262 AliFMDEventInspector fEventInspector;
264 * Structure to hold per-ring histograms
266 struct RingHistos : public AliForwardUtil::RingHistos
269 * Constructor - for I/O only
272 : AliForwardUtil::RingHistos(),
278 * @param d detector number
279 * @param r ring identifier
281 RingHistos(UShort_t d, Char_t r)
282 : AliForwardUtil::RingHistos(d,r),
288 * @param dir Parent list to add our list to
289 * @param dt Histogram of time differences
291 * @return true on success
293 Bool_t Book(TList* dir, TH1* dt)
295 TList* l = DefineOutputList(dir);
296 // Double_t dtBins[] = { 0, 1, 2e3, 5e5, 1.1e6, 5e6, 1e12, 1e20 };
297 fDtVsELoss = new TH2D("dtVsELoss",
298 Form("#Deltat vs #Delta/#Delta_{mip} - %s",
299 GetName()), 450, 0, 15,
300 dt->GetXaxis()->GetNbins(),
301 dt->GetXaxis()->GetXmin(),
302 dt->GetXaxis()->GetXmax());
303 fDtVsELoss->SetXTitle("#Delta/#Delta_{mip}");
304 fDtVsELoss->SetYTitle("log_{10}(#Deltat) [ns]");
305 fDtVsELoss->SetMarkerColor(Color());
306 fDtVsELoss->SetDirectory(0);
312 * Process a single event
314 * @param fmd FMD ESD data
315 * @param logDt Logarithm (base 10) of Time-to-previous event
317 void Event(AliESDFMD& fmd, Double_t logDt)
319 const UShort_t nSec = NSector();
320 const UShort_t nStr = NStrip();
321 for (UShort_t s = 0; s < nSec; s++) {
322 for (UShort_t t = 0; t < nStr; t++) {
323 Float_t mult = fmd.Multiplicity(fDet,fRing,s,t);
324 if(mult == AliESDFMD::kInvalidMult || mult <= 0)
326 fDtVsELoss->Fill(mult, logDt);
330 void Finalize(const TList* input, TList* output, TH1* dt)
332 TList* in = GetOutputList(input);
333 TList* out = DefineOutputList(output);
335 fDtVsELoss = static_cast<TH2*>(in->FindObject("dtVsELoss"));
337 TH2* dtVsELoss = static_cast<TH2*>(fDtVsELoss->Clone());
338 dtVsELoss->SetDirectory(0);
339 dtVsELoss->SetZTitle("1/N_{events}");
341 for (UShort_t j = 1; j <= dt->GetNbinsX(); j++) {
342 Double_t norm = dt->GetBinContent(j);
344 // Warning("Finalize", "Bin %d empty in dT", j);
347 for (UShort_t i = 1; i <= fDtVsELoss->GetNbinsX(); i++) {
348 Double_t c = fDtVsELoss->GetBinContent(i, j);
349 Double_t e = fDtVsELoss->GetBinError(i, j);
350 dtVsELoss->SetBinContent(i,j,c/norm);
351 dtVsELoss->SetBinError(i,j,e/norm);
358 ClassDef(RingHistos,1)
360 /** Container of FMD1i histograms */
362 /** Container of FMD2i histograms */
364 /** Container of FMD2o histograms */
366 /** Container of FMD3i histograms */
368 /** Container of FMD3o histograms */
370 /** Map from timestamp to time-to-previous event*/
372 /** Distribution of log10(dt) */
374 ClassDef(ELossTimeTask,2)