2 // Calculate the multiplicity in the forward regions event-by-event
14 #include "AliForwardMultiplicityTask.h"
15 #include "AliTriggerAnalysis.h"
16 #include "AliPhysicsSelection.h"
18 #include "AliESDEvent.h"
19 #include "AliAODHandler.h"
20 #include "AliMultiplicity.h"
21 #include "AliInputEventHandler.h"
22 #include "AliForwardCorrectionManager.h"
23 #include "AliAnalysisManager.h"
26 #include <TDirectory.h>
29 #include <TStopwatch.h>
31 // #define 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)
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())
43 //====================================================================
44 AliForwardMultiplicityTask::AliForwardMultiplicityTask()
45 : AliForwardMultiplicityBase(),
58 DGUARD(fDebug, 3,"Default CTOR of AliForwardMultiplicityTask");
61 //____________________________________________________________________
62 AliForwardMultiplicityTask::AliForwardMultiplicityTask(const char* name)
63 : AliForwardMultiplicityBase(name),
65 fEventInspector("event"),
66 fESDFixer("esdFizer"),
67 fSharingFilter("sharing"),
68 fDensityCalculator("density"),
69 fCorrections("corrections"),
70 fHistCollector("collector"),
71 fEventPlaneFinder("eventplane")
79 DGUARD(fDebug, 3,"named CTOR of AliForwardMultiplicityTask: %s", name);
83 //____________________________________________________________________
85 AliForwardMultiplicityTask::SetDoTiming(Bool_t enable)
89 AliWarning("Timing of task explicitly disabled in compilation");
95 //____________________________________________________________________
97 AliForwardMultiplicityTask::PreCorrections(const AliESDEvent* esd)
101 AliESDFMD* esdFMD = esd->GetFMDData();
104 Int_t tgt = GetESDFixer().FindTargetNoiseFactor(*esdFMD, false);
106 // If the target noise factor is 0 or less, disable the noise/gain
108 GetESDFixer().SetRecoNoiseFactor(4);
109 fNeededCorrections ^= AliForwardCorrectionManager::kNoiseGain;
112 AliWarning("The noise corrector has been enabled!");
114 //____________________________________________________________________
116 AliForwardMultiplicityTask::PreEvent()
125 //____________________________________________________________________
127 AliForwardMultiplicityTask::Event(AliESDEvent& esd)
130 // Process each event
139 DGUARD(fDebug,1,"Process the input event");
142 START_SW(individual);
143 Bool_t lowFlux = kFALSE;
148 UShort_t nClusters = 0;
149 UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
150 ivz, ip, cent, nClusters);
151 FILL_SW(individual,kTimingEventInspector);
153 if (found & AliFMDEventInspector::kNoEvent) {
157 if (found & AliFMDEventInspector::kNoTriggers) {
162 // Set trigger bits, and mark this event for storage
163 fAODFMD.SetTriggerBits(triggers);
164 fAODFMD.SetSNN(fEventInspector.GetEnergy());
165 fAODFMD.SetSystem(fEventInspector.GetCollisionSystem());
166 fAODFMD.SetCentrality(cent);
167 fAODFMD.SetNClusters(nClusters);
170 // Do not check if SPD data is there - potential bias
171 // if (found & AliFMDEventInspector::kNoSPD) {
172 // fHStatus->Fill(3);
175 if (found & AliFMDEventInspector::kNoFMD) {
179 if (found & AliFMDEventInspector::kNoVertex) {
183 // Also analyse pile-up events - we'll remove them in later steps.
184 if (triggers & AliAODForwardMult::kPileUp) {
188 fAODFMD.SetIpZ(ip.Z());
189 if (found & AliFMDEventInspector::kBadVertex) {
194 // We we do not want to use low flux specific code, we disable it here.
195 if (!fEnableLowFlux) lowFlux = false;
198 AliESDFMD* esdFMD = esd.GetFMDData();
200 // Fix up the the ESD
201 GetESDFixer().Fix(*esdFMD, ip.Z());
203 // Apply the sharing filter (or hit merging or clustering if you like)
204 START_SW(individual);
205 if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
206 AliWarning("Sharing filter failed!");
210 FILL_SW(individual,kTimingSharingFilter);
212 // Calculate the inclusive charged particle density
213 START_SW(individual);
214 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
215 // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
216 AliWarning("Density calculator failed!");
220 FILL_SW(individual,kTimingDensityCalculator);
222 // Check if we should do the event plane finder
223 if (fEventInspector.GetCollisionSystem() == AliFMDEventInspector::kPbPb) {
224 START_SW(individual);
225 if (!fEventPlaneFinder.FindEventplane(&esd, fAODEP,
226 &(fAODFMD.GetHistogram()), &fHistos)){
227 AliWarning("Eventplane finder failed!");
230 FILL_SW(individual,kTimingEventPlaneFinder);
233 // Check how many rings have been marked for skipping
235 for (UShort_t d=1; d<=3; d++) {
236 for (UShort_t q=0; q<=(d/2); q++) {
237 TH2D* h = fHistos.Get(d,q == 0 ? 'I' : 'O');
238 if (h && h->TestBit(AliForwardUtil::kSkipRing)) nSkip++;
242 // Skip the rest if we have too many outliers
247 // Do the secondary and other corrections.
248 START_SW(individual);
249 if (!fCorrections.Correct(fHistos, ivz)) {
250 AliWarning("Corrections failed");
254 FILL_SW(individual,kTimingCorrections);
256 // Check if we should add to internal caches
257 Bool_t add = (fAODFMD.IsTriggerBits(AliAODForwardMult::kInel) &&
258 !(triggers & AliAODForwardMult::kPileUp) && nSkip < 1);
260 // Collect our `super' histogram
261 START_SW(individual);
262 if (!fHistCollector.Collect(fHistos,
265 fAODFMD.GetHistogram(),
266 fAODFMD.GetCentrality(),
269 AliWarning("Histogram collector failed");
273 FILL_SW(individual,kTimingHistCollector);
279 // Collect rough Min. Bias result
280 fHData->Add(&(fAODFMD.GetHistogram()));
283 FILL_SW(total,kTimingTotal);