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 //____________________________________________________________________
79 AliForwardQATask::SetDebug(Int_t dbg)
87 AliBaseESDTask:: SetDebug(dbg);
88 GetEnergyFitter() .SetDebug(dbg);
89 GetSharingFilter() .SetDebug(dbg);
90 GetDensityCalculator().SetDebug(dbg);
93 //____________________________________________________________________
95 AliForwardQATask::DefaultEtaAxis() const
97 static TAxis* a = new TAxis(240, -6, 6);
100 //____________________________________________________________________
102 AliForwardQATask::DefaultVertexAxis() const
104 static TAxis* a = new TAxis(10, -10, 10);
108 //____________________________________________________________________
110 AliForwardQATask::Setup()
112 fEnergyFitter.Init();
116 //____________________________________________________________________
118 AliForwardQATask::Book()
121 // Create output objects
124 UInt_t what = AliForwardCorrectionManager::kAll;
125 what ^= AliForwardCorrectionManager::kDoubleHit;
126 what ^= AliForwardCorrectionManager::kVertexBias;
127 what ^= AliForwardCorrectionManager::kAcceptance;
128 what ^= AliForwardCorrectionManager::kMergingEfficiency;
129 what ^= AliForwardCorrectionManager::kELossFits;
130 fNeededCorrections = what;
131 fExtraCorrections = AliForwardCorrectionManager::kELossFits;
133 fESDFixer .CreateOutputObjects(fList);
134 fEnergyFitter .CreateOutputObjects(fList);
135 fSharingFilter .CreateOutputObjects(fList);
136 fDensityCalculator.CreateOutputObjects(fList);
140 //____________________________________________________________________
142 AliForwardQATask::PreData(const TAxis& /*vertex*/, const TAxis& eta)
145 // Initialise the sub objects and stuff. Called on first event
148 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
149 // We allow fall-back queries so that we may proceed in case we have no
151 if (!fcm.GetELossFit()) {
152 AliWarning("No energy loss fits");
154 // Fall-back values if we do not have the energy loss fits
155 AliFMDMultCuts& sfLCuts = GetSharingFilter().GetLCuts();
156 if (sfLCuts.GetMethod() != AliFMDMultCuts::kFixed) {
158 AliWarningF("Using fixed cut @ %f for the lower bound "
159 "of the sharing filter", cut);
160 sfLCuts.SetMultCuts(cut);
162 AliFMDMultCuts& sfHCuts = GetSharingFilter().GetHCuts();
163 if (sfHCuts.GetMethod() != AliFMDMultCuts::kFixed) {
165 AliWarningF("Using fixed cut @ %f for the upper bound "
166 "of the sharing filter", cut);
167 sfHCuts.SetMultCuts(cut);
169 AliFMDMultCuts& dcCuts = GetDensityCalculator().GetCuts();
170 if (dcCuts.GetMethod() != AliFMDMultCuts::kFixed) {
172 AliWarningF("Using fixed cut @ %f for the lower bound "
173 "of the density calculator", cut);
174 dcCuts.SetMultCuts(cut);
178 fcm.GetELossFit()->CacheBins(GetDensityCalculator().GetMinQuality());
182 // GetEventInspector().SetupForData(vertex);
183 GetEnergyFitter() .SetupForData(eta);
184 GetSharingFilter() .SetupForData(eta);
185 GetDensityCalculator().SetupForData(eta);
190 //____________________________________________________________________
192 AliForwardQATask::PreEvent()
199 //____________________________________________________________________
201 AliForwardQATask::Event(AliESDEvent& esd)
204 // Process each event
209 DGUARD(fDebug,1,"Process the input event");
212 // If the first event flag wasn't cleared in the above call to
213 // GetESDEvent, we should not do anything, since nothing has been
214 // initialised yet, so we opt out here (with a warning)
215 AliWarning("Nothing has been initialized yet, opt'ing out");
219 Bool_t lowFlux = kFALSE;
224 UShort_t nClusters = 0;
225 UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
226 ivz, ip, cent, nClusters);
229 if (found & AliFMDEventInspector::kNoEvent) ok = false;
230 if (found & AliFMDEventInspector::kNoTriggers) ok = false;
231 if (found & AliFMDEventInspector::kNoSPD) ok = false;
232 if (found & AliFMDEventInspector::kNoFMD) ok = false;
233 if (found & AliFMDEventInspector::kNoVertex) ok = false;
234 if (triggers & AliAODForwardMult::kPileUp) ok = false;
235 if (triggers & AliAODForwardMult::kA) ok = false;
236 if (triggers & AliAODForwardMult::kC) ok = false;
237 if (triggers & AliAODForwardMult::kE) ok = false;
238 if (!(triggers & AliAODForwardMult::kOffline)) ok = false;
239 if (found & AliFMDEventInspector::kBadVertex) ok = false;
241 DMSG(fDebug,2,"Event failed selection: %s",
242 AliFMDEventInspector::CodeString(found));
245 DMSG(fDebug,2,"Event triggers: %s",
246 AliAODForwardMult::GetTriggerString(triggers));
248 // We we do not want to use low flux specific code, we disable it here.
249 if (!fEnableLowFlux) lowFlux = false;
252 AliESDFMD* esdFMD = esd.GetFMDData();
254 // Fix up the the ESD
255 GetESDFixer().Fix(*esdFMD, ip.Z());
257 // Run the energy loss fitter
258 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
259 triggers & AliAODForwardMult::kEmpty)) {
260 AliWarning("Energy fitter failed");
264 // // Apply the sharing filter (or hit merging or clustering if you like)
265 if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
266 AliWarning("Sharing filter failed!");
270 // Calculate the inclusive charged particle density
271 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
272 // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
273 AliWarning("Density calculator failed!");
280 //____________________________________________________________________
282 AliForwardQATask::Finalize()
290 if (fDebug) AliInfo("In Forwards terminate");
294 // Get our histograms from the container
296 TH1I* hEventsTrVtx = 0;
297 TH1I* hEventsAcc = 0;
299 if (!fEventInspector.FetchHistograms(fList,
304 AliErrorF("Didn't get histograms from event selector "
305 "(hEventsTr=%p,hEventsTrVtx=%p,hEventsAcc=%p)",
306 hEventsTr, hEventsTrVtx,hEventsAcc);
312 fEnergyFitter.Fit(fResults);
314 AliInfoF("Fitting took %d real-time seconds, and %f CPU seconds",
315 Int_t(swf.RealTime()), swf.CpuTime());
317 fSharingFilter.Terminate(fList,fResults,Int_t(hEventsTr->Integral()));
318 fDensityCalculator.Terminate(fList,fResults,Int_t(hEventsTrVtx->Integral()));
320 if (fDebug) AliInfoF("Posting post processing results to %s",
321 fResults->GetName());
323 AliInfoF("Finalize took %d real-time seconds, and %f CPU seconds",
324 Int_t(swt.RealTime()), swt.CpuTime());
329 //____________________________________________________________________
331 AliForwardQATask::Print(Option_t* option) const
339 AliBaseESDTask::Print(option);
340 gROOT->IncreaseDirLevel();
341 GetESDFixer() .Print(option);
342 GetEnergyFitter() .Print(option);
343 GetSharingFilter() .Print(option);
344 GetDensityCalculator().Print(option);
345 gROOT->DecreaseDirLevel();