2 // Calculate the multiplicity in the forward regions event-by-event
14 #include "AliForwardQATask.h"
15 #include "AliForwardUtil.h"
16 #include "AliTriggerAnalysis.h"
17 #include "AliPhysicsSelection.h"
19 #include "AliESDEvent.h"
20 #include "AliAODHandler.h"
21 #include "AliMultiplicity.h"
22 #include "AliInputEventHandler.h"
23 #include "AliForwardCorrectionManager.h"
24 #include "AliAnalysisManager.h"
25 #include "AliAODForwardMult.h"
27 #include <TDirectory.h>
30 #include <TStopwatch.h>
32 //====================================================================
33 AliForwardQATask::AliForwardQATask()
35 fEnableLowFlux(false),
50 //____________________________________________________________________
51 AliForwardQATask::AliForwardQATask(const char* name)
52 : AliBaseESDTask(name, "", &(AliForwardCorrectionManager::Instance())),
53 fEnableLowFlux(false),
56 fEventInspector("event"),
58 fEnergyFitter("energy"),
59 fSharingFilter("sharing"),
60 fDensityCalculator("density")
68 fEnergyFitter.SetNParticles(1); // Just find the 1st peak
69 fEnergyFitter.SetDoMakeObject(false);
70 fEnergyFitter.SetUseIncreasingBins(true);
71 fEnergyFitter.SetDoFits(kTRUE);
72 fEnergyFitter.SetLowCut(0.4);
73 fEnergyFitter.SetFitRangeBinWidth(4);
74 fEnergyFitter.SetMinEntries(1000);
77 // For the QA we always enable fall-back
78 AliForwardCorrectionManager::Instance().SetEnableFallBack(true);
80 //____________________________________________________________________
82 AliForwardQATask::SetDebug(Int_t dbg)
90 AliBaseESDTask:: SetDebug(dbg);
91 GetEnergyFitter() .SetDebug(dbg);
92 GetSharingFilter() .SetDebug(dbg);
93 GetDensityCalculator().SetDebug(dbg);
96 //____________________________________________________________________
98 AliForwardQATask::DefaultEtaAxis() const
100 static TAxis* a = new TAxis(240, -6, 6);
103 //____________________________________________________________________
105 AliForwardQATask::DefaultVertexAxis() const
107 static TAxis* a = new TAxis(10, -10, 10);
111 //____________________________________________________________________
113 AliForwardQATask::Setup()
115 fEnergyFitter.Init();
119 //____________________________________________________________________
121 AliForwardQATask::Book()
124 // Create output objects
127 UInt_t what = AliForwardCorrectionManager::kAll;
128 what ^= AliForwardCorrectionManager::kDoubleHit;
129 what ^= AliForwardCorrectionManager::kVertexBias;
130 what ^= AliForwardCorrectionManager::kAcceptance;
131 what ^= AliForwardCorrectionManager::kMergingEfficiency;
132 what ^= AliForwardCorrectionManager::kELossFits;
133 fNeededCorrections = what;
134 fExtraCorrections = AliForwardCorrectionManager::kELossFits;
136 fESDFixer .CreateOutputObjects(fList);
137 fEnergyFitter .CreateOutputObjects(fList);
138 fSharingFilter .CreateOutputObjects(fList);
139 fDensityCalculator.CreateOutputObjects(fList);
143 //____________________________________________________________________
145 AliForwardQATask::PreData(const TAxis& /*vertex*/, const TAxis& eta)
148 // Initialise the sub objects and stuff. Called on first event
151 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
152 // We allow fall-back queries so that we may proceed in case we have no
154 if (!fcm.GetELossFit()) {
155 AliWarning("No energy loss fits");
157 // Fall-back values if we do not have the energy loss fits
158 AliFMDMultCuts& sfLCuts = GetSharingFilter().GetLCuts();
159 if (sfLCuts.GetMethod() != AliFMDMultCuts::kFixed) {
161 AliWarningF("Using fixed cut @ %f for the lower bound "
162 "of the sharing filter", cut);
163 sfLCuts.SetMultCuts(cut);
165 AliFMDMultCuts& sfHCuts = GetSharingFilter().GetHCuts();
166 if (sfHCuts.GetMethod() != AliFMDMultCuts::kFixed) {
168 AliWarningF("Using fixed cut @ %f for the upper bound "
169 "of the sharing filter", cut);
170 sfHCuts.SetMultCuts(cut);
172 AliFMDMultCuts& dcCuts = GetDensityCalculator().GetCuts();
173 if (dcCuts.GetMethod() != AliFMDMultCuts::kFixed) {
175 AliWarningF("Using fixed cut @ %f for the lower bound "
176 "of the density calculator", cut);
177 dcCuts.SetMultCuts(cut);
181 fcm.GetELossFit()->CacheBins(GetDensityCalculator().GetMinQuality());
185 // GetEventInspector().SetupForData(vertex);
186 GetEnergyFitter() .SetupForData(eta);
187 GetSharingFilter() .SetupForData(eta);
188 GetDensityCalculator().SetupForData(eta);
193 //____________________________________________________________________
195 AliForwardQATask::PreEvent()
202 //____________________________________________________________________
204 AliForwardQATask::Event(AliESDEvent& esd)
207 // Process each event
212 DGUARD(fDebug,1,"Process the input event");
215 // If the first event flag wasn't cleared in the above call to
216 // GetESDEvent, we should not do anything, since nothing has been
217 // initialised yet, so we opt out here (with a warning)
218 AliWarning("Nothing has been initialized yet, opt'ing out");
222 Bool_t lowFlux = kFALSE;
227 UShort_t nClusters = 0;
228 UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
229 ivz, ip, cent, nClusters);
232 if (found & AliFMDEventInspector::kNoEvent) ok = false;
233 if (found & AliFMDEventInspector::kNoTriggers) ok = false;
234 if (found & AliFMDEventInspector::kNoSPD) ok = false;
235 if (found & AliFMDEventInspector::kNoFMD) ok = false;
236 if (found & AliFMDEventInspector::kNoVertex) ok = false;
237 if (triggers & AliAODForwardMult::kPileUp) ok = false;
238 if (triggers & AliAODForwardMult::kA) ok = false;
239 if (triggers & AliAODForwardMult::kC) ok = false;
240 if (triggers & AliAODForwardMult::kE) ok = false;
241 if (!(triggers & AliAODForwardMult::kOffline)) ok = false;
242 if (found & AliFMDEventInspector::kBadVertex) ok = false;
244 DMSG(fDebug,2,"Event failed selection: %s",
245 AliFMDEventInspector::CodeString(found));
248 DMSG(fDebug,2,"Event triggers: %s",
249 AliAODForwardMult::GetTriggerString(triggers));
251 // We we do not want to use low flux specific code, we disable it here.
252 if (!fEnableLowFlux) lowFlux = false;
255 AliESDFMD* esdFMD = esd.GetFMDData();
257 // Fix up the the ESD
258 GetESDFixer().Fix(*esdFMD, ip.Z());
260 // Run the energy loss fitter
261 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
262 triggers & AliAODForwardMult::kEmpty)) {
263 AliWarning("Energy fitter failed");
267 // // Apply the sharing filter (or hit merging or clustering if you like)
268 if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
269 AliWarning("Sharing filter failed!");
273 // Calculate the inclusive charged particle density
274 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
275 // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
276 AliWarning("Density calculator failed!");
283 //____________________________________________________________________
285 AliForwardQATask::Finalize()
293 if (fDebug) AliInfo("In Forwards terminate");
297 // Get our histograms from the container
299 TH1I* hEventsTrVtx = 0;
300 TH1I* hEventsAcc = 0;
302 if (!fEventInspector.FetchHistograms(fList,
307 AliErrorF("Didn't get histograms from event selector "
308 "(hEventsTr=%p,hEventsTrVtx=%p,hEventsAcc=%p)",
309 hEventsTr, hEventsTrVtx,hEventsAcc);
315 fEnergyFitter.Fit(fResults);
317 AliInfoF("Fitting took %d real-time seconds, and %f CPU seconds",
318 Int_t(swf.RealTime()), swf.CpuTime());
320 fSharingFilter.Terminate(fList,fResults,Int_t(hEventsTr->Integral()));
321 fDensityCalculator.Terminate(fList,fResults,Int_t(hEventsTrVtx->Integral()));
323 if (fDebug) AliInfoF("Posting post processing results to %s",
324 fResults->GetName());
326 AliInfoF("Finalize took %d real-time seconds, and %f CPU seconds",
327 Int_t(swt.RealTime()), swt.CpuTime());
332 //____________________________________________________________________
334 AliForwardQATask::Print(Option_t* option) const
342 AliBaseESDTask::Print(option);
343 gROOT->IncreaseDirLevel();
344 GetESDFixer() .Print(option);
345 GetEnergyFitter() .Print(option);
346 GetSharingFilter() .Print(option);
347 GetDensityCalculator().Print(option);
348 gROOT->DecreaseDirLevel();