AliPhysics  1168478 (1168478)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliFMDEnergyFitterTask.cxx
Go to the documentation of this file.
1 //
2 // Histogram and fit the energy loss distributions for the FMD
3 //
4 // Inputs:
5 // - AliESDEvent
6 //
7 // Outputs:
8 // - None
9 //
10 // Histograms:
11 //
12 // Corrections used:
13 // - None
14 //
15 //
16 //
17 #include "AliFMDEnergyFitterTask.h"
18 #include "AliLog.h"
19 #include "AliESDEvent.h"
20 #include "AliESDFMD.h"
21 #include "AliMCEvent.h"
22 #include "AliAODForwardMult.h"
23 #include "AliAnalysisManager.h"
25 #include <TH1.h>
26 #include <TDirectory.h>
27 #include <TTree.h>
28 #include <TFile.h>
29 #include <TROOT.h>
30 #include <iostream>
31 
32 //====================================================================
34  : AliBaseESDTask(),
35  fEventInspector(),
36  fESDFixer(),
37  fEnergyFitter(),
38  fOnlyMB(false)
39 {
40  //
41  // Constructor
42  //
43  DGUARD(fDebug, 3,"Default CTOR of AliFMDEnergyFitterTask");
44  fCloneList = true;
45 }
46 
47 //____________________________________________________________________
49  : AliBaseESDTask(name, "AliFMDEnergyFitterTask",
50  &(AliForwardCorrectionManager::Instance())),
51  fEventInspector("event"),
52  fESDFixer("esdFizer"),
53  fEnergyFitter("energy"),
54  fOnlyMB(false)
55 {
56  //
57  // Constructor
58  //
59  // Parameters:
60  // name Name of task
61  //
62  DGUARD(fDebug, 3,"Named CTOR of AliFMDEnergyFitterTask: %s", name);
63  fCloneList = true;
64 }
65 
66 
67 //____________________________________________________________________
68 void
70 {
71  //
72  // Set the debug level
73  //
74  // Parameters:
75  // dbg Debug level
76  //
79 }
80 //____________________________________________________________________
81 TAxis*
83 {
84  static TAxis* a = new TAxis(0, 0, 0);
85  return a;
86 }
87 //____________________________________________________________________
88 TAxis*
90 {
91  static TAxis* a = new TAxis(10, -10, 10);
92  return a;
93 }
94 
95 //____________________________________________________________________
96 Bool_t
98 {
100  return true;
101 }
102 
103 //____________________________________________________________________
104 Bool_t
106 {
107  //
108  // Create output objects
109  //
110  //
111  DGUARD(fDebug,1,"Create output objects of AliFMDEnergyFitterTask");
112 
113  // We don't need any corrections for this task
114  fNeededCorrections = 0;
115  fExtraCorrections = 0;
118 
121 
123  return true;
124 }
125 //____________________________________________________________________
126 void
128 {
129  if (!esd) return;
130 
131  AliESDFMD* esdFMD = esd->GetFMDData();
132  if (!esdFMD) return;
133 
134  // TODO: We should always disable this on MC!
135  Int_t tgt = fESDFixer.FindTargetNoiseFactor(*esdFMD, false);
136  if (tgt <= 0) {
137  // If the target noise factor is 0 or less, disable the noise/gain
138  // correction.
141  }
142  else
143  AliWarning("The noise corrector has been enabled!");
144 }
145 
146 //____________________________________________________________________
147 Bool_t
148 AliFMDEnergyFitterTask::PreData(const TAxis& /*vertex*/, const TAxis& eta)
149 {
150  //
151  // Initialise the sub objects and stuff. Called on first event
152  //
153  //
154  DGUARD(fDebug,1,"Initialize subs of AliFMDEnergyFitterTask");
155 
156  fEnergyFitter.SetupForData(eta,GetEventInspector().GetCollisionSystem());
157 
158  Print();
159  return true;
160 }
161 
162 //____________________________________________________________________
163 Bool_t
165 {
166  //
167  // Process each event
168  //
169  // Parameters:
170  // option Not used
171  //
172 
173  // static Int_t cnt = 0;
174  // cnt++;
175  // Get the input data
176  DGUARD(fDebug,3,"Analyse event of AliFMDEnergyFitterTask");
177  // --- Read in the data --------------------------------------------
178  LoadBranches();
179 
180  Bool_t lowFlux = kFALSE;
181  UInt_t triggers = 0;
182  UShort_t ivz = 0;
183  TVector3 ip;
184  Double_t cent = 0;
185  UShort_t nClusters = 0;
186  UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
187  ivz, ip, cent, nClusters);
188  if (found & AliFMDEventInspector::kNoEvent) return false;
189  if (found & AliFMDEventInspector::kNoTriggers) return false;
190  if (found & AliFMDEventInspector::kNoSPD) return false;
191  if (found & AliFMDEventInspector::kNoFMD) return false;
192  if (found & AliFMDEventInspector::kNoVertex) return false;
193  if (found & AliFMDEventInspector::kBadVertex) return false;
194 
195  // do not process pile-up, A, C, and E events
196  if (triggers & AliAODForwardMult::kPileUp) return false;
197  if (triggers & AliAODForwardMult::kA) return false;
198  if (triggers & AliAODForwardMult::kC) return false;
199  if (triggers & AliAODForwardMult::kE) return false;
200 
201  // We want only the events found by off-line
202  if (!(triggers & AliAODForwardMult::kOffline)) return false;
203 
204  // Perhaps we should also insist on MB only
205  if (fOnlyMB && (!(triggers & AliAODForwardMult::kInel))) return false;
206 
207  // if(cent > 0) {
208  // if( cent < 40 || cent >50 ) return;
209  // else std::cout<<"selecting event with cent "<<cent<<std::endl;
210  // }
211 
212  // Get FMD data
213  AliESDFMD* esdFMD = esd.GetFMDData();
214 
215  // Fix up ESD
216  fESDFixer.Fix(*esdFMD, ip);
217 
218  // Do the energy stuff
219  if (!fEnergyFitter.Accumulate(*esdFMD, cent,
220  triggers & AliAODForwardMult::kEmpty)){
221  AliWarning("Energy fitter failed");
222  return false;
223  }
224 
225  return true;
226 }
227 
228 //____________________________________________________________________
229 Bool_t
231 {
232  //
233  // End of job
234  //
235  // Parameters:
236  // option Not used
237  //
238  DGUARD(fDebug,1,"Processing merged output of AliFMDEnergyFitterTask");
239 
240  AliInfo("Fitting energy loss spectra");
242 
243  return true;
244 }
245 
246 #define PFB(N,FLAG) \
247  do { \
248  AliForwardUtil::PrintName(N); \
249  std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
250  } while(false)
251 //____________________________________________________________________
252 void
254 {
255  //
256  // Print information
257  //
258  // Parameters:
259  // option Not used
260  //
261  AliBaseESDTask::Print(option);
262  gROOT->IncreaseDirLevel();
263  PFB("Only MB", fOnlyMB);
264  fESDFixer .Print(option);
265  fEnergyFitter.Print(option);
266  gROOT->DecreaseDirLevel();
267 }
268 
269 //
270 // EOF
271 //
AliFMDEventInspector fEventInspector
double Double_t
Definition: External.C:58
void Print(Option_t *option="") const
virtual Bool_t Accumulate(const AliESDFMD &input, Double_t cent, Bool_t empty)
AliFMDEnergyFitter fEnergyFitter
virtual void Print(Option_t *option="") const
virtual void Fit(const TList *dir)
virtual Bool_t Event(AliESDEvent &esd)
#define PFB(N, FLAG)
virtual TAxis * DefaultVertexAxis() const
virtual void CreateOutputObjects(TList *dir)
Int_t FindTargetNoiseFactor(const AliESDFMD &esd, Bool_t check=true) const
UInt_t Process(const AliESDEvent *event, UInt_t &triggers, Bool_t &lowFlux, UShort_t &ivz, TVector3 &ip, Double_t &cent, UShort_t &nClusters)
AliFMDEventInspector & GetEventInspector()
Per-event per bin.
virtual Bool_t PreData(const TAxis &vertex, const TAxis &eta)
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
virtual void SetDebug(Int_t dbg)
#define DGUARD(L, N, F,...)
void SetRecoNoiseFactor(Int_t f)
void CreateOutputObjects(TList *l)
virtual void PreCorrections(const AliESDEvent *esd)
static TObject * MakeParameter(const char *name, UShort_t value)
UInt_t fExtraCorrections
void Print(Option_t *option="") const
virtual TAxis * DefaultEtaAxis() const
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
bool Bool_t
Definition: External.C:53
void Fix(AliESDFMD &esd, const TVector3 &ip)
void Print(Option_t *option="") const
Bool_t IsUseNoiseCorrection() const
virtual void SetupForData(const TAxis &etaAxis, UShort_t sys=0)