AliPhysics  556872f (556872f)
 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  DMSG(fDebug, 1, "Pre-event clearing of structures");
122  fHistos.Clear();
123  fESDFMD.Clear();
124  fAODFMD.Clear();
125  fAODEP.Clear();
126  // fAODRef.Clear();
127  return true;
128 }
129 //____________________________________________________________________
130 Bool_t
132 {
133  //
134  // Process each event
135  //
136  // Parameters:
137  // option Not used
138  //
139  MAKE_SW(total);
140  MAKE_SW(individual);
141  START_SW(total);
142 
143  DGUARD(fDebug,1,"Process the input event");
144 
145  // Inspect the event
146  START_SW(individual);
147  Bool_t lowFlux = kFALSE;
148  UInt_t triggers = 0;
149  UShort_t ivz = 0;
150  TVector3 ip;
151  Double_t cent = -1;
152  UShort_t nClusters = 0;
153  UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
154  ivz, ip, cent, nClusters);
155  // fMultEventClassifier.Process(&esd,&fAODRef);
156  FILL_SW(individual,kTimingEventInspector);
157 
158  if (found & AliFMDEventInspector::kNoEvent) {
159  fHStatus->Fill(kStatusNoEvent);
160  return false;
161  }
162  if (found & AliFMDEventInspector::kNoTriggers) {
163  fHStatus->Fill(kStatusNoTrigger);
164  return false;
165  }
166 
167  // Set trigger bits, and mark this event for storage
168  fAODFMD.SetTriggerBits(triggers);
171  fAODFMD.SetCentrality(cent);
172  fAODFMD.SetNClusters(nClusters);
174 
175  // Do not check if SPD data is there - potential bias
176  // if (found & AliFMDEventInspector::kNoSPD) {
177  // fHStatus->Fill(3);
178  // return false;
179  // }
180  if (found & AliFMDEventInspector::kNoFMD) {
181  fHStatus->Fill(kStatusNoFMD);
182  return false;
183  }
184  if (found & AliFMDEventInspector::kNoVertex) {
185  fHStatus->Fill(kStatusNoVertex);
186  return false;
187  }
188  // Also analyse pile-up events - we'll remove them in later steps.
189  if (triggers & AliAODForwardMult::kPileUp) {
190  fHStatus->Fill(kStatusPileup);
191  // return false;
192  }
193  // Also analyse SPD outliers events - we'll remove them in later steps.
194  if (triggers & AliAODForwardMult::kSPDOutlier) {
196  // return false;
197  }
198  fAODFMD.SetIpZ(ip.Z());
199  if (found & AliFMDEventInspector::kBadVertex) {
201  return false;
202  }
203 
204  // We we do not want to use low flux specific code, we disable it here.
205  if (!fEnableLowFlux) lowFlux = false;
206 
207  // Get FMD data
208  AliESDFMD* esdFMD = esd.GetFMDData();
209 
210  // Fix up the the ESD
211  GetESDFixer().Fix(*esdFMD, ip);
212 
213  // Apply the sharing filter (or hit merging or clustering if you like)
214  START_SW(individual);
215  if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
216  AliWarning("Sharing filter failed!");
218  return false;
219  }
220  FILL_SW(individual,kTimingSharingFilter);
221 
222  // Calculate the inclusive charged particle density
223  START_SW(individual);
224  if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
225  // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
226  AliWarning("Density calculator failed!");
228  return false;
229  }
230  FILL_SW(individual,kTimingDensityCalculator);
231 
232  // Check if we should do the event plane finder
234  START_SW(individual);
236  &(fAODFMD.GetHistogram()), &fHistos)){
237  AliWarning("Eventplane finder failed!");
239  }
240  FILL_SW(individual,kTimingEventPlaneFinder);
241  }
242 
243  // Check how many rings have been marked for skipping
244  Int_t nSkip = 0;
245  for (UShort_t d=1; d<=3; d++) {
246  for (UShort_t q=0; q<=(d/2); q++) {
247  TH2D* h = fHistos.Get(d,q == 0 ? 'I' : 'O');
248  if (h && h->TestBit(AliForwardUtil::kSkipRing)) nSkip++;
249  }
250  }
251  if (nSkip > 0) {
252  // Skip the rest if we have too many outliers
253  fHStatus->Fill(kStatusOutlier);
254  return false;
255  }
256 
257  // Do the secondary and other corrections.
258  START_SW(individual);
259  if (!fCorrections.Correct(fHistos, ivz)) {
260  AliWarning("Corrections failed");
262  return false;
263  }
264  FILL_SW(individual,kTimingCorrections);
265 
266  // Check if we should add to internal caches
267  Bool_t add = (fAODFMD.IsTriggerBits(fAddMask) && nSkip < 1);
268 
269  // Collect our `super' histogram
270  START_SW(individual);
272  fRingSums,
273  ivz,
276  false,
277  add)) {
278  AliWarning("Histogram collector failed");
280  return false;
281  }
282  FILL_SW(individual,kTimingHistCollector);
283 
284  if (!add) {
285  fHStatus->Fill(kStatusNotAdded);
286  }
287  else {
288  // Collect rough Min. Bias result
289  fHData->Add(&(fAODFMD.GetHistogram()));
291  }
292  FILL_SW(total,kTimingTotal);
293 
294  return true;
295 }
296 
297 
298 //
299 // EOF
300 //
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)
#define DMSG(L, N, F,...)
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