]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliForwardQATask.cxx
Took out L3 field from ELoss selector
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardQATask.cxx
CommitLineData
96624385 1//
2// Calculate the multiplicity in the forward regions event-by-event
3//
4// Inputs:
5// - AliESDEvent
6//
7// Outputs:
8// - AliAODForwardMult
9//
10// Histograms
11//
12// Corrections used
13//
14#include "AliForwardQATask.h"
15#include "AliForwardUtil.h"
16#include "AliTriggerAnalysis.h"
17#include "AliPhysicsSelection.h"
18#include "AliLog.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"
26#include <TH1.h>
27#include <TDirectory.h>
28#include <TTree.h>
29#include <TROOT.h>
e2213ed5 30#include <TStopwatch.h>
96624385 31
32//====================================================================
33AliForwardQATask::AliForwardQATask()
c8b1a7db 34 : AliBaseESDTask(),
96624385 35 fEnableLowFlux(false),
96624385 36 fESDFMD(),
37 fHistos(),
38 fEventInspector(),
e140afb9 39 fESDFixer(),
96624385 40 fEnergyFitter(),
41 fSharingFilter(),
c8b1a7db 42 fDensityCalculator()
96624385 43{
44 //
45 // Constructor
46 //
c8b1a7db 47 fCloneList = true;
96624385 48}
49
50//____________________________________________________________________
51AliForwardQATask::AliForwardQATask(const char* name)
c8b1a7db 52 : AliBaseESDTask(name, "", &(AliForwardCorrectionManager::Instance())),
96624385 53 fEnableLowFlux(false),
96624385 54 fESDFMD(),
55 fHistos(),
56 fEventInspector("event"),
e140afb9 57 fESDFixer("fixer"),
96624385 58 fEnergyFitter("energy"),
59 fSharingFilter("sharing"),
c8b1a7db 60 fDensityCalculator("density")
96624385 61{
62 //
63 // Constructor
64 //
65 // Parameters:
66 // name Name of task
67 //
96624385 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);
c8b1a7db 75 fCloneList = true;
96624385 76}
96624385 77//____________________________________________________________________
78void
79AliForwardQATask::SetDebug(Int_t dbg)
80{
81 //
82 // Set debug level
83 //
84 // Parameters:
85 // dbg Debug level
86 //
c8b1a7db 87 AliBaseESDTask:: SetDebug(dbg);
88 GetEnergyFitter() .SetDebug(dbg);
89 GetSharingFilter() .SetDebug(dbg);
90 GetDensityCalculator().SetDebug(dbg);
96624385 91}
92
93//____________________________________________________________________
c8b1a7db 94TAxis*
95AliForwardQATask::DefaultEtaAxis() const
96624385 96{
c8b1a7db 97 static TAxis* a = new TAxis(240, -6, 6);
98 return a;
99}
100//____________________________________________________________________
101TAxis*
102AliForwardQATask::DefaultVertexAxis() const
103{
104 static TAxis* a = new TAxis(10, -10, 10);
105 return a;
96624385 106}
107
0b7de667 108//____________________________________________________________________
109Bool_t
110AliForwardQATask::Setup()
111{
112 fEnergyFitter.Init();
113 return true;
114}
115
96624385 116//____________________________________________________________________
117Bool_t
c8b1a7db 118AliForwardQATask::Book()
96624385 119{
c8b1a7db 120 //
121 // Create output objects
122 //
96624385 123 //
124 UInt_t what = AliForwardCorrectionManager::kAll;
125 what ^= AliForwardCorrectionManager::kDoubleHit;
126 what ^= AliForwardCorrectionManager::kVertexBias;
127 what ^= AliForwardCorrectionManager::kAcceptance;
128 what ^= AliForwardCorrectionManager::kMergingEfficiency;
c8b1a7db 129 what ^= AliForwardCorrectionManager::kELossFits;
130 fNeededCorrections = what;
131 fExtraCorrections = AliForwardCorrectionManager::kELossFits;
132
e140afb9 133 fESDFixer .CreateOutputObjects(fList);
134 fEnergyFitter .CreateOutputObjects(fList);
135 fSharingFilter .CreateOutputObjects(fList);
c8b1a7db 136 fDensityCalculator.CreateOutputObjects(fList);
137
96624385 138 return true;
139}
96624385 140//____________________________________________________________________
422a78c8 141Bool_t
c8b1a7db 142AliForwardQATask::PreData(const TAxis& /*vertex*/, const TAxis& eta)
96624385 143{
144 //
145 // Initialise the sub objects and stuff. Called on first event
146 //
147 //
c8b1a7db 148 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
149 // We allow fall-back queries so that we may proceed in case we have no
150 // valid corrections
151 if (!fcm.GetELossFit()) {
152 AliWarning("No energy loss fits");
153
154 // Fall-back values if we do not have the energy loss fits
155 AliFMDMultCuts& sfLCuts = GetSharingFilter().GetLCuts();
156 if (sfLCuts.GetMethod() != AliFMDMultCuts::kFixed) {
e140afb9 157 Double_t cut = 0.15;
c8b1a7db 158 AliWarningF("Using fixed cut @ %f for the lower bound "
159 "of the sharing filter", cut);
160 sfLCuts.SetMultCuts(cut);
161 }
162 AliFMDMultCuts& sfHCuts = GetSharingFilter().GetHCuts();
163 if (sfHCuts.GetMethod() != AliFMDMultCuts::kFixed) {
e140afb9 164 Double_t cut = 0.45;
c8b1a7db 165 AliWarningF("Using fixed cut @ %f for the upper bound "
166 "of the sharing filter", cut);
167 sfHCuts.SetMultCuts(cut);
168 }
169 AliFMDMultCuts& dcCuts = GetDensityCalculator().GetCuts();
170 if (dcCuts.GetMethod() != AliFMDMultCuts::kFixed) {
e140afb9 171 Double_t cut = 0.45;
c8b1a7db 172 AliWarningF("Using fixed cut @ %f for the lower bound "
173 "of the density calculator", cut);
174 dcCuts.SetMultCuts(cut);
175 }
460a5c02 176 }
c8b1a7db 177 else
178 fcm.GetELossFit()->CacheBins(GetDensityCalculator().GetMinQuality());
96624385 179
c8b1a7db 180 fHistos.Init(eta);
96624385 181
c8b1a7db 182 // GetEventInspector().SetupForData(vertex);
183 GetEnergyFitter() .SetupForData(eta);
184 GetSharingFilter() .SetupForData(eta);
185 GetDensityCalculator().SetupForData(eta);
422a78c8 186
187 return true;
96624385 188}
189
190//____________________________________________________________________
c8b1a7db 191Bool_t
192AliForwardQATask::PreEvent()
96624385 193{
c8b1a7db 194 // Clear stuff
195 fHistos.Clear();
196 fESDFMD.Clear();
197 return true;
96624385 198}
199//____________________________________________________________________
c8b1a7db 200Bool_t
201AliForwardQATask::Event(AliESDEvent& esd)
96624385 202{
203 //
204 // Process each event
205 //
206 // Parameters:
207 // option Not used
208 //
241cca4d 209 DGUARD(fDebug,1,"Process the input event");
96624385 210
460a5c02 211 if (fFirstEvent) {
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");
c8b1a7db 216 return false;
460a5c02 217 }
96624385 218
96624385 219 Bool_t lowFlux = kFALSE;
220 UInt_t triggers = 0;
221 UShort_t ivz = 0;
5ca83fee 222 TVector3 ip;
96624385 223 Double_t cent = -1;
224 UShort_t nClusters = 0;
c8b1a7db 225 UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
5ca83fee 226 ivz, ip, cent, nClusters);
96624385 227
241cca4d 228 Bool_t ok = true;
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;
81775aba 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;
241cca4d 239 if (found & AliFMDEventInspector::kBadVertex) ok = false;
240 if (!ok) {
241 DMSG(fDebug,2,"Event failed selection: %s",
242 AliFMDEventInspector::CodeString(found));
c8b1a7db 243 return false;
241cca4d 244 }
5ca83fee 245 DMSG(fDebug,2,"Event triggers: %s",
246 AliAODForwardMult::GetTriggerString(triggers));
96624385 247
248 // We we do not want to use low flux specific code, we disable it here.
249 if (!fEnableLowFlux) lowFlux = false;
250
251 // Get FMD data
c8b1a7db 252 AliESDFMD* esdFMD = esd.GetFMDData();
e140afb9 253
254 // Fix up the the ESD
255 GetESDFixer().Fix(*esdFMD, ip.Z());
96624385 256
257 // Run the energy loss fitter
258 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
259 triggers & AliAODForwardMult::kEmpty)) {
260 AliWarning("Energy fitter failed");
c8b1a7db 261 return false;
96624385 262 }
4077f3e8 263
96624385 264 // // Apply the sharing filter (or hit merging or clustering if you like)
5ca83fee 265 if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
96624385 266 AliWarning("Sharing filter failed!");
c8b1a7db 267 return false;
96624385 268 }
4077f3e8 269
96624385 270 // Calculate the inclusive charged particle density
57522224 271 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
96624385 272 // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
273 AliWarning("Density calculator failed!");
c8b1a7db 274 return false;
96624385 275 }
4077f3e8 276
c8b1a7db 277 return true;
96624385 278}
279
280//____________________________________________________________________
c8b1a7db 281Bool_t
282AliForwardQATask::Finalize()
96624385 283{
284 //
285 // End of job
286 //
287 // Parameters:
288 // option Not used
289 //
9b2f2e39 290 if (fDebug) AliInfo("In Forwards terminate");
e2213ed5 291 TStopwatch swt;
292 swt.Start();
96624385 293
96624385 294 // Get our histograms from the container
c8b1a7db 295 TH1I* hEventsTr = 0;
296 TH1I* hEventsTrVtx = 0;
5ca83fee 297 TH1I* hEventsAcc = 0;
96624385 298 TH1I* hTriggers = 0;
c8b1a7db 299 if (!fEventInspector.FetchHistograms(fList,
5ca83fee 300 hEventsTr,
301 hEventsTrVtx,
302 hEventsAcc,
303 hTriggers)) {
71d536f4 304 AliErrorF("Didn't get histograms from event selector "
305 "(hEventsTr=%p,hEventsTrVtx=%p,hEventsAcc=%p)",
306 hEventsTr, hEventsTrVtx,hEventsAcc);
c8b1a7db 307 return false;
96624385 308 }
309
e2213ed5 310 TStopwatch swf;
311 swf.Start();
c8b1a7db 312 fEnergyFitter.Fit(fResults);
e2213ed5 313 swf.Stop();
314 AliInfoF("Fitting took %d real-time seconds, and %f CPU seconds",
315 Int_t(swf.RealTime()), swf.CpuTime());
96624385 316
c8b1a7db 317 fSharingFilter.Terminate(fList,fResults,Int_t(hEventsTr->Integral()));
318 fDensityCalculator.Terminate(fList,fResults,Int_t(hEventsTrVtx->Integral()));
96624385 319
9b2f2e39 320 if (fDebug) AliInfoF("Posting post processing results to %s",
c8b1a7db 321 fResults->GetName());
e2213ed5 322 swt.Stop();
c8b1a7db 323 AliInfoF("Finalize took %d real-time seconds, and %f CPU seconds",
e2213ed5 324 Int_t(swt.RealTime()), swt.CpuTime());
325
c8b1a7db 326 return true;
96624385 327}
328
329//____________________________________________________________________
330void
331AliForwardQATask::Print(Option_t* option) const
332{
333 //
334 // Print information
335 //
336 // Parameters:
337 // option Not used
338 //
c8b1a7db 339 AliBaseESDTask::Print(option);
96624385 340 gROOT->IncreaseDirLevel();
e140afb9 341 GetESDFixer() .Print(option);
96624385 342 GetEnergyFitter() .Print(option);
343 GetSharingFilter() .Print(option);
57522224 344 GetDensityCalculator().Print(option);
96624385 345 gROOT->DecreaseDirLevel();
346}
347
348//
349// EOF
350//