AliPhysics  8d00e07 (8d00e07)
AliForwardQATask.cxx
Go to the documentation of this file.
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"
24 #include "AliAnalysisManager.h"
25 #include "AliAODForwardMult.h"
26 #include <TH1.h>
27 #include <TDirectory.h>
28 #include <TTree.h>
29 #include <TROOT.h>
30 #include <TStopwatch.h>
31 
32 //====================================================================
34  : AliBaseESDTask(),
35  fEnableLowFlux(false),
36  fESDFMD(),
37  fHistos(),
38  fEventInspector(),
39  fESDFixer(),
40  fEnergyFitter(),
41  fSharingFilter(),
42  fDensityCalculator()
43 {
44  //
45  // Constructor
46  //
47  fCloneList = true;
48 }
49 
50 //____________________________________________________________________
52  : AliBaseESDTask(name, "", &(AliForwardCorrectionManager::Instance())),
53  fEnableLowFlux(false),
54  fESDFMD(),
55  fHistos(),
56  fEventInspector("event"),
57  fESDFixer("fixer"),
58  fEnergyFitter("energy"),
59  fSharingFilter("sharing"),
60  fDensityCalculator("density")
61 {
62  //
63  // Constructor
64  //
65  // Parameters:
66  // name Name of task
67  //
68  fEnergyFitter.SetNParticles(1); // Just find the 1st peak
71  fEnergyFitter.SetDoFits(kTRUE);
75  fCloneList = true;
76 
77  // For the QA we always enable fall-back
79 }
80 //____________________________________________________________________
81 void
83 {
84  //
85  // Set debug level
86  //
87  // Parameters:
88  // dbg Debug level
89  //
91  GetEnergyFitter() .SetDebug(dbg);
92  GetSharingFilter() .SetDebug(dbg);
94 }
95 
96 //____________________________________________________________________
97 TAxis*
99 {
100  static TAxis* a = new TAxis(240, -6, 6);
101  return a;
102 }
103 //____________________________________________________________________
104 TAxis*
106 {
107  static TAxis* a = new TAxis(10, -10, 10);
108  return a;
109 }
110 
111 //____________________________________________________________________
112 Bool_t
114 {
116  return true;
117 }
118 
119 //____________________________________________________________________
120 Bool_t
122 {
123  //
124  // Create output objects
125  //
126  //
133  fNeededCorrections = what;
135 
140 
141  return true;
142 }
143 //____________________________________________________________________
144 Bool_t
145 AliForwardQATask::PreData(const TAxis& /*vertex*/, const TAxis& eta)
146 {
147  //
148  // Initialise the sub objects and stuff. Called on first event
149  //
150  //
152  // We allow fall-back queries so that we may proceed in case we have no
153  // valid corrections
154  if (!fcm.GetELossFit()) {
155  AliWarning("No energy loss fits");
156 
157  // Fall-back values if we do not have the energy loss fits
159  if (sfLCuts.GetMethod() != AliFMDMultCuts::kFixed) {
160  Double_t cut = 0.15;
161  AliWarningF("Using fixed cut @ %f for the lower bound "
162  "of the sharing filter", cut);
163  sfLCuts.SetMultCuts(cut);
164  }
166  if (sfHCuts.GetMethod() != AliFMDMultCuts::kFixed) {
167  Double_t cut = 0.45;
168  AliWarningF("Using fixed cut @ %f for the upper bound "
169  "of the sharing filter", cut);
170  sfHCuts.SetMultCuts(cut);
171  }
173  if (dcCuts.GetMethod() != AliFMDMultCuts::kFixed) {
174  Double_t cut = 0.45;
175  AliWarningF("Using fixed cut @ %f for the lower bound "
176  "of the density calculator", cut);
177  dcCuts.SetMultCuts(cut);
178  }
179  }
180  else
181  fcm.GetELossFit()->CacheBins(GetDensityCalculator().GetMinQuality());
182 
183  fHistos.Init(eta);
184 
185  // GetEventInspector().SetupForData(vertex);
187  GetEventInspector().GetCollisionSystem());
190 
191  return true;
192 }
193 
194 //____________________________________________________________________
195 Bool_t
197 {
198  // Clear stuff
199  fHistos.Clear();
200  fESDFMD.Clear();
201  return true;
202 }
203 //____________________________________________________________________
204 Bool_t
206 {
207  //
208  // Process each event
209  //
210  // Parameters:
211  // option Not used
212  //
213  DGUARD(fDebug,1,"Process the input event");
214 
215  if (fFirstEvent) {
216  // If the first event flag wasn't cleared in the above call to
217  // GetESDEvent, we should not do anything, since nothing has been
218  // initialised yet, so we opt out here (with a warning)
219  AliWarning("Nothing has been initialized yet, opt'ing out");
220  return false;
221  }
222 
223  Bool_t lowFlux = kFALSE;
224  UInt_t triggers = 0;
225  UShort_t ivz = 0;
226  TVector3 ip;
227  Double_t cent = -1;
228  UShort_t nClusters = 0;
229  UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
230  ivz, ip, cent, nClusters);
231 
232  Bool_t ok = true;
233  if (found & AliFMDEventInspector::kNoEvent) ok = false;
234  if (found & AliFMDEventInspector::kNoTriggers) ok = false;
235  if (found & AliFMDEventInspector::kNoSPD) ok = false;
236  if (found & AliFMDEventInspector::kNoFMD) ok = false;
237  if (found & AliFMDEventInspector::kNoVertex) ok = false;
238  if (triggers & AliAODForwardMult::kPileUp) ok = false;
239  if (triggers & AliAODForwardMult::kA) ok = false;
240  if (triggers & AliAODForwardMult::kC) ok = false;
241  if (triggers & AliAODForwardMult::kE) ok = false;
242  if (!(triggers & AliAODForwardMult::kOffline)) ok = false;
243  if (found & AliFMDEventInspector::kBadVertex) ok = false;
244  if (!ok) {
245  DMSG(fDebug,2,"Event failed selection: %s",
247  return false;
248  }
249  DMSG(fDebug,2,"Event triggers: %s",
251 
252  // We we do not want to use low flux specific code, we disable it here.
253  if (!fEnableLowFlux) lowFlux = false;
254 
255  // Get FMD data
256  AliESDFMD* esdFMD = esd.GetFMDData();
257 
258  // Fix up the the ESD
259  GetESDFixer().Fix(*esdFMD, ip);
260 
261  // Run the energy loss fitter
262  if (!fEnergyFitter.Accumulate(*esdFMD, cent,
263  triggers & AliAODForwardMult::kEmpty)) {
264  AliWarning("Energy fitter failed");
265  return false;
266  }
267 
268  // // Apply the sharing filter (or hit merging or clustering if you like)
269  if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
270  AliWarning("Sharing filter failed!");
271  return false;
272  }
273 
274  // Calculate the inclusive charged particle density
275  if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
276  // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
277  AliWarning("Density calculator failed!");
278  return false;
279  }
280 
281  return true;
282 }
283 
284 //____________________________________________________________________
285 Bool_t
287 {
288  //
289  // End of job
290  //
291  // Parameters:
292  // option Not used
293  //
294  if (fDebug) AliInfo("In Forwards terminate");
295  TStopwatch swt;
296  swt.Start();
297 
298  // Get our histograms from the container
299  TH1I* hEventsTr = 0;
300  TH1I* hEventsTrVtx = 0;
301  TH1I* hEventsAcc = 0;
302  TH1I* hTriggers = 0;
304  hEventsTr,
305  hEventsTrVtx,
306  hEventsAcc,
307  hTriggers)) {
308  AliErrorF("Didn't get histograms from event selector "
309  "(hEventsTr=%p,hEventsTrVtx=%p,hEventsAcc=%p)",
310  hEventsTr, hEventsTrVtx,hEventsAcc);
311  return false;
312  }
313 
314  TStopwatch swf;
315  swf.Start();
317  swf.Stop();
318  AliInfoF("Fitting took %d real-time seconds, and %f CPU seconds",
319  Int_t(swf.RealTime()), swf.CpuTime());
320 
321  fSharingFilter.Terminate(fList,fResults,Int_t(hEventsTr->Integral()));
322  fDensityCalculator.Terminate(fList,fResults,Int_t(hEventsTrVtx->Integral()));
323 
324  if (fDebug) AliInfoF("Posting post processing results to %s",
325  fResults->GetName());
326  swt.Stop();
327  AliInfoF("Finalize took %d real-time seconds, and %f CPU seconds",
328  Int_t(swt.RealTime()), swt.CpuTime());
329 
330  return true;
331 }
332 
333 //____________________________________________________________________
334 void
336 {
337  //
338  // Print information
339  //
340  // Parameters:
341  // option Not used
342  //
343  AliBaseESDTask::Print(option);
344  gROOT->IncreaseDirLevel();
345  GetESDFixer() .Print(option);
346  GetEnergyFitter() .Print(option);
347  GetSharingFilter() .Print(option);
348  GetDensityCalculator().Print(option);
349  gROOT->DecreaseDirLevel();
350 }
351 
352 //
353 // EOF
354 //
virtual Bool_t Finalize()
virtual void SetupForData(const TAxis &etaAxis)
AliFMDMultCuts & GetHCuts()
AliFMDMultCuts & GetLCuts()
void Clear(Option_t *option="")
double Double_t
Definition: External.C:58
virtual void Terminate(const TList *dir, TList *output, Int_t nEvents)
void Print(Option_t *option="") const
AliFMDEventInspector fEventInspector
virtual Bool_t Event(AliESDEvent &esd)
void SetDoFits(Bool_t doFit=kTRUE)
virtual Bool_t Accumulate(const AliESDFMD &input, Double_t cent, Bool_t empty)
void SetLowCut(Double_t lowCut=0.3)
virtual void Print(Option_t *option="") const
void SetupForData(const TAxis &axis)
#define DMSG(L, N, F,...)
virtual void Fit(const TList *dir)
virtual void Terminate(const TList *dir, TList *output, Int_t nEvents)
void CacheBins(UShort_t minQuality=kDefaultQuality) const
AliFMDSharingFilter & GetSharingFilter()
void SetFitRangeBinWidth(UShort_t n=4)
Bool_t FetchHistograms(const TList *d, TH1I *&hEventsTr, TH1I *&hEventsTrVtx, TH1I *&hEventsAcc, TH1I *&hTriggers) const
AliForwardUtil::Histos fHistos
virtual void CreateOutputObjects(TList *dir)
void SetNParticles(UShort_t n)
UInt_t Process(const AliESDEvent *event, UInt_t &triggers, Bool_t &lowFlux, UShort_t &ivz, TVector3 &ip, Double_t &cent, UShort_t &nClusters)
void Print(Option_t *option="") const
void SetDebug(Int_t dbg)
Per-event per bin.
EMethod GetMethod() const
int Int_t
Definition: External.C:63
Definition: External.C:204
unsigned int UInt_t
Definition: External.C:33
Bool_t Filter(const AliESDFMD &input, Bool_t lowFlux, AliESDFMD &output, Double_t zvtx)
void SetDoMakeObject(Bool_t doMake=kTRUE)
Various utilities used in PWGLF/FORWARD.
AliFMDESDFixer & GetESDFixer()
virtual Bool_t Book()
virtual void SetDebug(Int_t dbg)
void SetUseIncreasingBins(Bool_t x)
virtual void CreateOutputObjects(TList *dir)
AliFMDEnergyFitter fEnergyFitter
const AliFMDCorrELossFit * GetELossFit() const
void SetMinEntries(UShort_t n)
static const Char_t * GetTriggerString(UInt_t mask, const char *sep="&")
#define DGUARD(L, N, F,...)
AliFMDESDFixer fESDFixer
AliFMDSharingFilter fSharingFilter
void CreateOutputObjects(TList *l)
virtual void SetDebug(Int_t dbg=1)
virtual Bool_t Calculate(const AliESDFMD &fmd, AliForwardUtil::Histos &hists, Bool_t lowFlux, Double_t cent=-1, const TVector3 &ip=TVector3(1024, 1024, 0))
virtual void CreateOutputObjects(TList *dir)
UInt_t fExtraCorrections
virtual Bool_t Setup()
virtual Bool_t PreData(const TAxis &vertex, const TAxis &eta)
virtual void SetEnableFallBack(Bool_t use=true)
virtual void Print(Option_t *option="") const
void Init(const TAxis &etaAxis)
AliFMDEventInspector & GetEventInspector()
void SetMultCuts(Double_t fmd1i, Double_t fmd2i=-1, Double_t fmd2o=-1, Double_t fmd3i=-1, Double_t fmd3o=-1)
unsigned short UShort_t
Definition: External.C:28
void SetDebug(Int_t dbg=1)
const char Option_t
Definition: External.C:48
UInt_t fNeededCorrections
AliFMDDensityCalculator & GetDensityCalculator()
AliFMDEnergyFitter & GetEnergyFitter()
bool Bool_t
Definition: External.C:53
virtual TAxis * DefaultVertexAxis() const
void Fix(AliESDFMD &esd, const TVector3 &ip)
static const char * CodeString(UInt_t mask)
virtual Bool_t PreEvent()
void Print(Option_t *option="") const
void Print(Option_t *option="") const
AliFMDDensityCalculator fDensityCalculator
static AliForwardCorrectionManager & Instance()
virtual void SetupForData(const TAxis &etaAxis, UShort_t sys=0)
virtual TAxis * DefaultEtaAxis() const