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::Setup()
110 fEnergyFitter.Init();
114 //____________________________________________________________________
116 AliForwardQATask::Book()
119 // Create output objects
122 UInt_t what = AliForwardCorrectionManager::kAll;
123 what ^= AliForwardCorrectionManager::kDoubleHit;
124 what ^= AliForwardCorrectionManager::kVertexBias;
125 what ^= AliForwardCorrectionManager::kAcceptance;
126 what ^= AliForwardCorrectionManager::kMergingEfficiency;
127 what ^= AliForwardCorrectionManager::kELossFits;
128 fNeededCorrections = what;
129 fExtraCorrections = AliForwardCorrectionManager::kELossFits;
131 fEnergyFitter.CreateOutputObjects(fList);
132 fSharingFilter.CreateOutputObjects(fList);
133 fDensityCalculator.CreateOutputObjects(fList);
137 //____________________________________________________________________
139 AliForwardQATask::PreData(const TAxis& /*vertex*/, const TAxis& eta)
142 // Initialise the sub objects and stuff. Called on first event
145 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
146 // We allow fall-back queries so that we may proceed in case we have no
148 if (!fcm.GetELossFit()) {
149 AliWarning("No energy loss fits");
151 // Fall-back values if we do not have the energy loss fits
152 AliFMDMultCuts& sfLCuts = GetSharingFilter().GetLCuts();
153 if (sfLCuts.GetMethod() != AliFMDMultCuts::kFixed) {
155 AliWarningF("Using fixed cut @ %f for the lower bound "
156 "of the sharing filter", cut);
157 sfLCuts.SetMultCuts(cut);
159 AliFMDMultCuts& sfHCuts = GetSharingFilter().GetHCuts();
160 if (sfHCuts.GetMethod() != AliFMDMultCuts::kFixed) {
162 AliWarningF("Using fixed cut @ %f for the upper bound "
163 "of the sharing filter", cut);
164 sfHCuts.SetMultCuts(cut);
166 AliFMDMultCuts& dcCuts = GetDensityCalculator().GetCuts();
167 if (dcCuts.GetMethod() != AliFMDMultCuts::kFixed) {
169 AliWarningF("Using fixed cut @ %f for the lower bound "
170 "of the density calculator", cut);
171 dcCuts.SetMultCuts(cut);
175 fcm.GetELossFit()->CacheBins(GetDensityCalculator().GetMinQuality());
179 // GetEventInspector().SetupForData(vertex);
180 GetEnergyFitter() .SetupForData(eta);
181 GetSharingFilter() .SetupForData(eta);
182 GetDensityCalculator().SetupForData(eta);
187 //____________________________________________________________________
189 AliForwardQATask::PreEvent()
196 //____________________________________________________________________
198 AliForwardQATask::Event(AliESDEvent& esd)
201 // Process each event
206 DGUARD(fDebug,1,"Process the input event");
209 // If the first event flag wasn't cleared in the above call to
210 // GetESDEvent, we should not do anything, since nothing has been
211 // initialised yet, so we opt out here (with a warning)
212 AliWarning("Nothing has been initialized yet, opt'ing out");
216 Bool_t lowFlux = kFALSE;
221 UShort_t nClusters = 0;
222 UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
223 ivz, ip, cent, nClusters);
226 if (found & AliFMDEventInspector::kNoEvent) ok = false;
227 if (found & AliFMDEventInspector::kNoTriggers) ok = false;
228 if (found & AliFMDEventInspector::kNoSPD) ok = false;
229 if (found & AliFMDEventInspector::kNoFMD) ok = false;
230 if (found & AliFMDEventInspector::kNoVertex) ok = false;
231 if (triggers & AliAODForwardMult::kPileUp) ok = false;
232 if (triggers & AliAODForwardMult::kA) ok = false;
233 if (triggers & AliAODForwardMult::kC) ok = false;
234 if (triggers & AliAODForwardMult::kE) ok = false;
235 if (!(triggers & AliAODForwardMult::kOffline)) ok = false;
236 if (found & AliFMDEventInspector::kBadVertex) ok = false;
238 DMSG(fDebug,2,"Event failed selection: %s",
239 AliFMDEventInspector::CodeString(found));
242 DMSG(fDebug,2,"Event triggers: %s",
243 AliAODForwardMult::GetTriggerString(triggers));
245 // We we do not want to use low flux specific code, we disable it here.
246 if (!fEnableLowFlux) lowFlux = false;
249 AliESDFMD* esdFMD = esd.GetFMDData();
251 // Run the energy loss fitter
252 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
253 triggers & AliAODForwardMult::kEmpty)) {
254 AliWarning("Energy fitter failed");
258 // // Apply the sharing filter (or hit merging or clustering if you like)
259 if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
260 AliWarning("Sharing filter failed!");
264 // Calculate the inclusive charged particle density
265 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
266 // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
267 AliWarning("Density calculator failed!");
274 //____________________________________________________________________
276 AliForwardQATask::Finalize()
284 if (fDebug) AliInfo("In Forwards terminate");
288 // Get our histograms from the container
290 TH1I* hEventsTrVtx = 0;
291 TH1I* hEventsAcc = 0;
293 if (!fEventInspector.FetchHistograms(fList,
298 AliError(Form("Didn't get histograms from event selector "
299 "(hEventsTr=%p,hEventsTrVtx=%p,hEventsAcc=%p)",
300 hEventsTr, hEventsTrVtx,hEventsAcc));
306 fEnergyFitter.Fit(fResults);
308 AliInfoF("Fitting took %d real-time seconds, and %f CPU seconds",
309 Int_t(swf.RealTime()), swf.CpuTime());
311 fSharingFilter.Terminate(fList,fResults,Int_t(hEventsTr->Integral()));
312 fDensityCalculator.Terminate(fList,fResults,Int_t(hEventsTrVtx->Integral()));
314 if (fDebug) AliInfoF("Posting post processing results to %s",
315 fResults->GetName());
317 AliInfoF("Finalize took %d real-time seconds, and %f CPU seconds",
318 Int_t(swt.RealTime()), swt.CpuTime());
323 //____________________________________________________________________
325 AliForwardQATask::Print(Option_t* option) const
333 AliBaseESDTask::Print(option);
334 gROOT->IncreaseDirLevel();
335 GetEnergyFitter() .Print(option);
336 GetSharingFilter() .Print(option);
337 GetDensityCalculator().Print(option);
338 gROOT->DecreaseDirLevel();