AliPhysics  e34b7ac (e34b7ac)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliForwardMultiplicityTask.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 //
15 #include "AliTriggerAnalysis.h"
16 #include "AliPhysicsSelection.h"
17 #include "AliLog.h"
18 #include "AliESDEvent.h"
19 #include "AliAODHandler.h"
20 #include "AliMultiplicity.h"
21 #include "AliInputEventHandler.h"
23 #include "AliAnalysisManager.h"
24 #include <TH1.h>
25 #include <TH3D.h>
26 #include <TDirectory.h>
27 #include <TTree.h>
28 #include <TROOT.h>
29 #include <TStopwatch.h>
30 #include <TProfile.h>
31 // #define ENABLE_TIMING
32 #ifndef ENABLE_TIMING
33 # define MAKE_SW(NAME) do {} while(false)
34 # define START_SW(NAME) do {} while(false)
35 # define FILL_SW(NAME,WHICH) do {} while(false)
36 #else
37 # define MAKE_SW(NAME) TStopwatch NAME
38 # define START_SW(NAME) if (fDoTiming) NAME.Start(true)
39 # define FILL_SW(NAME,WHICH) \
40  if (fDoTiming) fHTiming->Fill(WHICH,NAME.CpuTime())
41 #endif
42 
43 //====================================================================
46  fESDFMD(),
47  fEventInspector(),
48  // fMultEventClassifier(),
49  fESDFixer(),
50  fSharingFilter(),
51  fDensityCalculator(),
52  fCorrections(),
53  fHistCollector(),
54  fEventPlaneFinder()
55 {
56  //
57  // Constructor
58  //
59  DGUARD(fDebug, 3,"Default CTOR of AliForwardMultiplicityTask");
60 }
61 
62 //____________________________________________________________________
65  fESDFMD(),
66  fEventInspector("event"),
67  // fMultEventClassifier("multClass"),
68  fESDFixer("esdFizer"),
69  fSharingFilter("sharing"),
70  fDensityCalculator("density"),
71  fCorrections("corrections"),
72  fHistCollector("collector"),
73  fEventPlaneFinder("eventplane")
74 {
75  //
76  // Constructor
77  //
78  // Parameters:
79  // name Name of task
80  //
81  DGUARD(fDebug, 3,"named CTOR of AliForwardMultiplicityTask: %s", name);
82 }
83 
84 
85 //____________________________________________________________________
86 void
88 {
89 #ifndef ENABLE_TIMING
90  if (enable)
91  AliWarning("Timing of task explicitly disabled in compilation");
92 #else
93  fDoTiming = enable;
94 #endif
95 }
96 
97 //____________________________________________________________________
98 void
100 {
101  if (!esd) return;
102 
103  AliESDFMD* esdFMD = esd->GetFMDData();
104  if (!esdFMD) return;
105 
106  Int_t tgt = GetESDFixer().FindTargetNoiseFactor(*esdFMD, false);
107  if (tgt <= 0) {
108  // If the target noise factor is 0 or less, disable the noise/gain
109  // correction.
112  }
113  else
114  AliWarning("The noise corrector has been enabled!");
115 }
116 //____________________________________________________________________
117 Bool_t
119 {
120  // Clear stuff
121  fHistos.Clear();
122  fESDFMD.Clear();
123  fAODFMD.Clear();
124  fAODEP.Clear();
125  // fAODRef.Clear();
126  return true;
127 }
128 //____________________________________________________________________
129 Bool_t
131 {
132  //
133  // Process each event
134  //
135  // Parameters:
136  // option Not used
137  //
138  MAKE_SW(total);
139  MAKE_SW(individual);
140  START_SW(total);
141 
142  DGUARD(fDebug,1,"Process the input event");
143 
144  // Inspect the event
145  START_SW(individual);
146  Bool_t lowFlux = kFALSE;
147  UInt_t triggers = 0;
148  UShort_t ivz = 0;
149  TVector3 ip;
150  Double_t cent = -1;
151  UShort_t nClusters = 0;
152  UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
153  ivz, ip, cent, nClusters);
154  // fMultEventClassifier.Process(&esd,&fAODRef);
155  FILL_SW(individual,kTimingEventInspector);
156 
157  if (found & AliFMDEventInspector::kNoEvent) {
158  fHStatus->Fill(kStatusNoEvent);
159  return false;
160  }
161  if (found & AliFMDEventInspector::kNoTriggers) {
162  fHStatus->Fill(kStatusNoTrigger);
163  return false;
164  }
165 
166  // Set trigger bits, and mark this event for storage
167  fAODFMD.SetTriggerBits(triggers);
170  fAODFMD.SetCentrality(cent);
171  fAODFMD.SetNClusters(nClusters);
173 
174  // Do not check if SPD data is there - potential bias
175  // if (found & AliFMDEventInspector::kNoSPD) {
176  // fHStatus->Fill(3);
177  // return false;
178  // }
179  if (found & AliFMDEventInspector::kNoFMD) {
180  fHStatus->Fill(kStatusNoFMD);
181  return false;
182  }
183  if (found & AliFMDEventInspector::kNoVertex) {
184  fHStatus->Fill(kStatusNoVertex);
185  return false;
186  }
187  // Also analyse pile-up events - we'll remove them in later steps.
188  if (triggers & AliAODForwardMult::kPileUp) {
189  fHStatus->Fill(kStatusPileup);
190  // return false;
191  }
192  // Also analyse SPD outliers events - we'll remove them in later steps.
193  if (triggers & AliAODForwardMult::kSPDOutlier) {
195  // return false;
196  }
197  fAODFMD.SetIpZ(ip.Z());
198  if (found & AliFMDEventInspector::kBadVertex) {
200  return false;
201  }
202 
203  // We we do not want to use low flux specific code, we disable it here.
204  if (!fEnableLowFlux) lowFlux = false;
205 
206  // Get FMD data
207  AliESDFMD* esdFMD = esd.GetFMDData();
208 
209  // Fix up the the ESD
210  GetESDFixer().Fix(*esdFMD, ip);
211 
212  // Apply the sharing filter (or hit merging or clustering if you like)
213  START_SW(individual);
214  if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
215  AliWarning("Sharing filter failed!");
217  return false;
218  }
219  FILL_SW(individual,kTimingSharingFilter);
220 
221  // Calculate the inclusive charged particle density
222  START_SW(individual);
223  if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
224  // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
225  AliWarning("Density calculator failed!");
227  return false;
228  }
229  FILL_SW(individual,kTimingDensityCalculator);
230 
231  // Check if we should do the event plane finder
233  START_SW(individual);
235  &(fAODFMD.GetHistogram()), &fHistos)){
236  AliWarning("Eventplane finder failed!");
238  }
239  FILL_SW(individual,kTimingEventPlaneFinder);
240  }
241 
242  // Check how many rings have been marked for skipping
243  Int_t nSkip = 0;
244  for (UShort_t d=1; d<=3; d++) {
245  for (UShort_t q=0; q<=(d/2); q++) {
246  TH2D* h = fHistos.Get(d,q == 0 ? 'I' : 'O');
247  if (h && h->TestBit(AliForwardUtil::kSkipRing)) nSkip++;
248  }
249  }
250  if (nSkip > 0) {
251  // Skip the rest if we have too many outliers
252  fHStatus->Fill(kStatusOutlier);
253  return false;
254  }
255 
256  // Do the secondary and other corrections.
257  START_SW(individual);
258  if (!fCorrections.Correct(fHistos, ivz)) {
259  AliWarning("Corrections failed");
261  return false;
262  }
263  FILL_SW(individual,kTimingCorrections);
264 
265  // Check if we should add to internal caches
266  Bool_t add = (fAODFMD.IsTriggerBits(fAddMask) && nSkip < 1);
267 
268  // Collect our `super' histogram
269  START_SW(individual);
271  fRingSums,
272  ivz,
275  false,
276  add)) {
277  AliWarning("Histogram collector failed");
279  return false;
280  }
281  FILL_SW(individual,kTimingHistCollector);
282 
283  if (!add) {
284  fHStatus->Fill(kStatusNotAdded);
285  }
286  else {
287  // Collect rough Min. Bias result
288  fHData->Add(&(fAODFMD.GetHistogram()));
290  }
291  FILL_SW(total,kTimingTotal);
292 
293  return true;
294 }
295 
296 
297 //
298 // EOF
299 //
void SetIpZ(Float_t ipZ)
void Clear(Option_t *option="")
double Double_t
Definition: External.C:58
void SetTriggerBits(UInt_t bits)
void SetNClusters(UShort_t n)
void SetSNN(UShort_t sNN)
void Clear(Option_t *option="")
AliFMDEventPlaneFinder fEventPlaneFinder
void SetCentrality(Float_t c)
virtual void MarkEventForStore() const
void Clear(Option_t *option="")
#define START_SW(NAME)
Int_t FindTargetNoiseFactor(const AliESDFMD &esd, Bool_t check=true) const
virtual Bool_t Correct(AliForwardUtil::Histos &hists, UShort_t vtxBin)
UInt_t Process(const AliESDEvent *event, UInt_t &triggers, Bool_t &lowFlux, UShort_t &ivz, TVector3 &ip, Double_t &cent, UShort_t &nClusters)
AliFMDDensityCalculator fDensityCalculator
int Int_t
Definition: External.C:63
UShort_t GetCollisionSystem() const
unsigned int UInt_t
Definition: External.C:33
static Bool_t IsTriggerBits(UInt_t bits, UInt_t trg)
Bool_t Filter(const AliESDFMD &input, Bool_t lowFlux, AliESDFMD &output, Double_t zvtx)
virtual Bool_t Collect(const AliForwardUtil::Histos &hists, AliForwardUtil::Histos &sums, UShort_t vtxBin, TH2D &out, Double_t cent=-1.0, Bool_t eta2phi=false, Bool_t add=true)
Definition: External.C:228
void SetSystem(UShort_t sys)
virtual void PreCorrections(const AliESDEvent *esd)
#define DGUARD(L, N, F,...)
virtual void SetDoTiming(Bool_t enable=true)
void SetRecoNoiseFactor(Int_t f)
virtual Bool_t Calculate(const AliESDFMD &fmd, AliForwardUtil::Histos &hists, Bool_t lowFlux, Double_t cent=-1, const TVector3 &ip=TVector3(1024, 1024, 0))
TH2D * Get(UShort_t d, Char_t r) const
#define MAKE_SW(NAME)
virtual Bool_t Event(AliESDEvent &esd)
UShort_t GetEnergy() const
unsigned short UShort_t
Definition: External.C:28
Float_t GetCentrality() const
UInt_t fNeededCorrections
bool Bool_t
Definition: External.C:53
Bool_t FindEventplane(AliVEvent *esd, AliAODForwardEP &aodEp, TH2D *h, AliForwardUtil::Histos *hists)
#define FILL_SW(NAME, WHICH)
void Fix(AliESDFMD &esd, const TVector3 &ip)
const TH2D & GetHistogram() const