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),
49 //____________________________________________________________________
50 AliForwardQATask::AliForwardQATask(const char* name)
51 : AliBaseESDTask(name, "", &(AliForwardCorrectionManager::Instance())),
52 fEnableLowFlux(false),
55 fEventInspector("event"),
56 fEnergyFitter("energy"),
57 fSharingFilter("sharing"),
58 fDensityCalculator("density")
66 fEnergyFitter.SetNParticles(1); // Just find the 1st peak
67 fEnergyFitter.SetDoMakeObject(false);
68 fEnergyFitter.SetUseIncreasingBins(true);
69 fEnergyFitter.SetDoFits(kTRUE);
70 fEnergyFitter.SetLowCut(0.4);
71 fEnergyFitter.SetFitRangeBinWidth(4);
72 fEnergyFitter.SetMinEntries(1000);
75 //____________________________________________________________________
77 AliForwardQATask::SetDebug(Int_t dbg)
85 AliBaseESDTask:: SetDebug(dbg);
86 GetEnergyFitter() .SetDebug(dbg);
87 GetSharingFilter() .SetDebug(dbg);
88 GetDensityCalculator().SetDebug(dbg);
91 //____________________________________________________________________
93 AliForwardQATask::DefaultEtaAxis() const
95 static TAxis* a = new TAxis(240, -6, 6);
98 //____________________________________________________________________
100 AliForwardQATask::DefaultVertexAxis() const
102 static TAxis* a = new TAxis(10, -10, 10);
106 //____________________________________________________________________
108 AliForwardQATask::Book()
111 // Create output objects
114 UInt_t what = AliForwardCorrectionManager::kAll;
115 what ^= AliForwardCorrectionManager::kDoubleHit;
116 what ^= AliForwardCorrectionManager::kVertexBias;
117 what ^= AliForwardCorrectionManager::kAcceptance;
118 what ^= AliForwardCorrectionManager::kMergingEfficiency;
119 what ^= AliForwardCorrectionManager::kELossFits;
120 fNeededCorrections = what;
121 fExtraCorrections = AliForwardCorrectionManager::kELossFits;
123 fEnergyFitter.CreateOutputObjects(fList);
124 fSharingFilter.CreateOutputObjects(fList);
125 fDensityCalculator.CreateOutputObjects(fList);
129 //____________________________________________________________________
131 AliForwardQATask::PreData(const TAxis& /*vertex*/, const TAxis& eta)
134 // Initialise the sub objects and stuff. Called on first event
137 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
138 // We allow fall-back queries so that we may proceed in case we have no
140 if (!fcm.GetELossFit()) {
141 AliWarning("No energy loss fits");
143 // Fall-back values if we do not have the energy loss fits
144 AliFMDMultCuts& sfLCuts = GetSharingFilter().GetLCuts();
145 if (sfLCuts.GetMethod() != AliFMDMultCuts::kFixed) {
147 AliWarningF("Using fixed cut @ %f for the lower bound "
148 "of the sharing filter", cut);
149 sfLCuts.SetMultCuts(cut);
151 AliFMDMultCuts& sfHCuts = GetSharingFilter().GetHCuts();
152 if (sfHCuts.GetMethod() != AliFMDMultCuts::kFixed) {
154 AliWarningF("Using fixed cut @ %f for the upper bound "
155 "of the sharing filter", cut);
156 sfHCuts.SetMultCuts(cut);
158 AliFMDMultCuts& dcCuts = GetDensityCalculator().GetCuts();
159 if (dcCuts.GetMethod() != AliFMDMultCuts::kFixed) {
161 AliWarningF("Using fixed cut @ %f for the lower bound "
162 "of the density calculator", cut);
163 dcCuts.SetMultCuts(cut);
167 fcm.GetELossFit()->CacheBins(GetDensityCalculator().GetMinQuality());
171 // GetEventInspector().SetupForData(vertex);
172 GetEnergyFitter() .SetupForData(eta);
173 GetSharingFilter() .SetupForData(eta);
174 GetDensityCalculator().SetupForData(eta);
179 //____________________________________________________________________
181 AliForwardQATask::PreEvent()
188 //____________________________________________________________________
190 AliForwardQATask::Event(AliESDEvent& esd)
193 // Process each event
198 DGUARD(fDebug,1,"Process the input event");
201 // If the first event flag wasn't cleared in the above call to
202 // GetESDEvent, we should not do anything, since nothing has been
203 // initialised yet, so we opt out here (with a warning)
204 AliWarning("Nothing has been initialized yet, opt'ing out");
208 Bool_t lowFlux = kFALSE;
213 UShort_t nClusters = 0;
214 UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
215 ivz, ip, cent, nClusters);
218 if (found & AliFMDEventInspector::kNoEvent) ok = false;
219 if (found & AliFMDEventInspector::kNoTriggers) ok = false;
220 if (found & AliFMDEventInspector::kNoSPD) ok = false;
221 if (found & AliFMDEventInspector::kNoFMD) ok = false;
222 if (found & AliFMDEventInspector::kNoVertex) ok = false;
223 if (triggers & AliAODForwardMult::kPileUp) ok = false;
224 if (triggers & AliAODForwardMult::kA) ok = false;
225 if (triggers & AliAODForwardMult::kC) ok = false;
226 if (triggers & AliAODForwardMult::kE) ok = false;
227 if (!(triggers & AliAODForwardMult::kOffline)) ok = false;
228 if (found & AliFMDEventInspector::kBadVertex) ok = false;
230 DMSG(fDebug,2,"Event failed selection: %s",
231 AliFMDEventInspector::CodeString(found));
234 DMSG(fDebug,2,"Event triggers: %s",
235 AliAODForwardMult::GetTriggerString(triggers));
237 // We we do not want to use low flux specific code, we disable it here.
238 if (!fEnableLowFlux) lowFlux = false;
241 AliESDFMD* esdFMD = esd.GetFMDData();
243 // Run the energy loss fitter
244 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
245 triggers & AliAODForwardMult::kEmpty)) {
246 AliWarning("Energy fitter failed");
250 // // Apply the sharing filter (or hit merging or clustering if you like)
251 if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
252 AliWarning("Sharing filter failed!");
256 // Calculate the inclusive charged particle density
257 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
258 // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
259 AliWarning("Density calculator failed!");
266 //____________________________________________________________________
268 AliForwardQATask::Finalize()
276 if (fDebug) AliInfo("In Forwards terminate");
280 // Get our histograms from the container
282 TH1I* hEventsTrVtx = 0;
283 TH1I* hEventsAcc = 0;
285 if (!fEventInspector.FetchHistograms(fList,
290 AliError(Form("Didn't get histograms from event selector "
291 "(hEventsTr=%p,hEventsTrVtx=%p,hEventsAcc=%p)",
292 hEventsTr, hEventsTrVtx,hEventsAcc));
298 fEnergyFitter.Fit(fResults);
300 AliInfoF("Fitting took %d real-time seconds, and %f CPU seconds",
301 Int_t(swf.RealTime()), swf.CpuTime());
303 fSharingFilter.Terminate(fList,fResults,Int_t(hEventsTr->Integral()));
304 fDensityCalculator.Terminate(fList,fResults,Int_t(hEventsTrVtx->Integral()));
306 if (fDebug) AliInfoF("Posting post processing results to %s",
307 fResults->GetName());
309 AliInfoF("Finalize took %d real-time seconds, and %f CPU seconds",
310 Int_t(swt.RealTime()), swt.CpuTime());
315 //____________________________________________________________________
317 AliForwardQATask::Print(Option_t* option) const
325 AliBaseESDTask::Print(option);
326 gROOT->IncreaseDirLevel();
327 GetEnergyFitter() .Print(option);
328 GetSharingFilter() .Print(option);
329 GetDensityCalculator().Print(option);
330 gROOT->DecreaseDirLevel();