]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliForwardMultiplicityTask.cxx
Updates
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardMultiplicityTask.cxx
CommitLineData
7984e5f7 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//
0bd4b00f 14#include "AliForwardMultiplicityTask.h"
7e4038b5 15#include "AliTriggerAnalysis.h"
16#include "AliPhysicsSelection.h"
17#include "AliLog.h"
7e4038b5 18#include "AliESDEvent.h"
19#include "AliAODHandler.h"
20#include "AliMultiplicity.h"
21#include "AliInputEventHandler.h"
0bd4b00f 22#include "AliForwardCorrectionManager.h"
23#include "AliAnalysisManager.h"
7e4038b5 24#include <TH1.h>
4f9319f3 25#include <TH3D.h>
7e4038b5 26#include <TDirectory.h>
27#include <TTree.h>
0bd4b00f 28#include <TROOT.h>
1f7aa5c7 29#include <TStopwatch.h>
30#include <TProfile.h>
336ac2ac 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
7e4038b5 42
43//====================================================================
0bd4b00f 44AliForwardMultiplicityTask::AliForwardMultiplicityTask()
eb865a4f 45 : AliForwardMultiplicityBase(),
7e4038b5 46 fESDFMD(),
fffea31d 47 fEventInspector(),
0ccdab7b 48 fESDFixer(),
7e4038b5 49 fSharingFilter(),
50 fDensityCalculator(),
51 fCorrections(),
52 fHistCollector(),
8449e3e0 53 fEventPlaneFinder()
7e4038b5 54{
7984e5f7 55 //
56 // Constructor
57 //
5ca83fee 58 DGUARD(fDebug, 3,"Default CTOR of AliForwardMultiplicityTask");
7e4038b5 59}
60
61//____________________________________________________________________
0bd4b00f 62AliForwardMultiplicityTask::AliForwardMultiplicityTask(const char* name)
eb865a4f 63 : AliForwardMultiplicityBase(name),
7e4038b5 64 fESDFMD(),
fffea31d 65 fEventInspector("event"),
0ccdab7b 66 fESDFixer("esdFizer"),
7e4038b5 67 fSharingFilter("sharing"),
68 fDensityCalculator("density"),
69 fCorrections("corrections"),
70 fHistCollector("collector"),
8449e3e0 71 fEventPlaneFinder("eventplane")
7e4038b5 72{
7984e5f7 73 //
74 // Constructor
75 //
76 // Parameters:
77 // name Name of task
78 //
5ca83fee 79 DGUARD(fDebug, 3,"named CTOR of AliForwardMultiplicityTask: %s", name);
7e4038b5 80}
81
7e4038b5 82
336ac2ac 83//____________________________________________________________________
84void
85AliForwardMultiplicityTask::SetDoTiming(Bool_t enable)
86{
87#ifndef ENABLE_TIMING
88 if (enable)
89 AliWarning("Timing of task explicitly disabled in compilation");
90#else
91 fDoTiming = enable;
92#endif
93}
94
0ccdab7b 95//____________________________________________________________________
96void
97AliForwardMultiplicityTask::PreCorrections(const AliESDEvent* esd)
98{
99 if (!esd) return;
100
101 AliESDFMD* esdFMD = esd->GetFMDData();
102 if (!esdFMD) return;
103
104 Int_t tgt = GetESDFixer().FindTargetNoiseFactor(*esdFMD, false);
105 if (tgt <= 0) {
106 // If the target noise factor is 0 or less, disable the noise/gain
107 // correction.
108 GetESDFixer().SetRecoNoiseFactor(4);
109 fNeededCorrections ^= AliForwardCorrectionManager::kNoiseGain;
110 }
111 else
112 AliWarning("The noise corrector has been enabled!");
113}
7e4038b5 114//____________________________________________________________________
c8b1a7db 115Bool_t
116AliForwardMultiplicityTask::PreEvent()
7e4038b5 117{
c8b1a7db 118 // Clear stuff
119 fHistos.Clear();
120 fESDFMD.Clear();
121 fAODFMD.Clear();
122 fAODEP.Clear();
123 return true;
7e4038b5 124}
7e4038b5 125//____________________________________________________________________
c8b1a7db 126Bool_t
127AliForwardMultiplicityTask::Event(AliESDEvent& esd)
7e4038b5 128{
7984e5f7 129 //
130 // Process each event
131 //
132 // Parameters:
133 // option Not used
134 //
336ac2ac 135 MAKE_SW(total);
136 MAKE_SW(individual);
137 START_SW(total);
1f7aa5c7 138
f53fb4f6 139 DGUARD(fDebug,1,"Process the input event");
1f7aa5c7 140
141 // Inspect the event
336ac2ac 142 START_SW(individual);
5bb5d1f6 143 Bool_t lowFlux = kFALSE;
144 UInt_t triggers = 0;
145 UShort_t ivz = 0;
5ca83fee 146 TVector3 ip;
5bb5d1f6 147 Double_t cent = -1;
148 UShort_t nClusters = 0;
c8b1a7db 149 UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
5ca83fee 150 ivz, ip, cent, nClusters);
336ac2ac 151 FILL_SW(individual,kTimingEventInspector);
b399c3cb 152
153 if (found & AliFMDEventInspector::kNoEvent) {
154 fHStatus->Fill(1);
155 return false;
156 }
157 if (found & AliFMDEventInspector::kNoTriggers) {
158 fHStatus->Fill(2);
159 return false;
160 }
9bff843b 161
fffea31d 162 // Set trigger bits, and mark this event for storage
9d99b0dd 163 fAODFMD.SetTriggerBits(triggers);
b2e7f2d6 164 fAODFMD.SetSNN(fEventInspector.GetEnergy());
165 fAODFMD.SetSystem(fEventInspector.GetCollisionSystem());
e58000b7 166 fAODFMD.SetCentrality(cent);
5bb5d1f6 167 fAODFMD.SetNClusters(nClusters);
7e4038b5 168 MarkEventForStore();
2b556440 169
c8b1a7db 170 // Do not check if SPD data is there - potential bias
b399c3cb 171 // if (found & AliFMDEventInspector::kNoSPD) {
172 // fHStatus->Fill(3);
173 // return false;
174 // }
175 if (found & AliFMDEventInspector::kNoFMD) {
176 fHStatus->Fill(4);
177 return false;
178 }
179 if (found & AliFMDEventInspector::kNoVertex) {
180 fHStatus->Fill(5);
181 return false;
182 }
336ac2ac 183 // Also analyse pile-up events - we'll remove them in later steps.
b399c3cb 184 if (triggers & AliAODForwardMult::kPileUp) {
185 fHStatus->Fill(6);
186 return false;
187 }
5ca83fee 188 fAODFMD.SetIpZ(ip.Z());
b399c3cb 189 if (found & AliFMDEventInspector::kBadVertex) {
190 fHStatus->Fill(7);
191 return false;
192 }
7e4038b5 193
0bd4b00f 194 // We we do not want to use low flux specific code, we disable it here.
195 if (!fEnableLowFlux) lowFlux = false;
196
fffea31d 197 // Get FMD data
c8b1a7db 198 AliESDFMD* esdFMD = esd.GetFMDData();
1f7aa5c7 199
0ccdab7b 200 // Fix up the the ESD
201 GetESDFixer().Fix(*esdFMD, ip.Z());
202
1f7aa5c7 203 // Apply the sharing filter (or hit merging or clustering if you like)
336ac2ac 204 START_SW(individual);
5ca83fee 205 if (!fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD, ip.Z())) {
fffea31d 206 AliWarning("Sharing filter failed!");
b399c3cb 207 fHStatus->Fill(8);
c8b1a7db 208 return false;
7e4038b5 209 }
336ac2ac 210 FILL_SW(individual,kTimingSharingFilter);
2b556440 211
7e4038b5 212 // Calculate the inclusive charged particle density
336ac2ac 213 START_SW(individual);
5ca83fee 214 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
f7cfc454 215 // if (!fDensityCalculator.Calculate(*esdFMD, fHistos, ivz, lowFlux)) {
7e4038b5 216 AliWarning("Density calculator failed!");
b399c3cb 217 fHStatus->Fill(9);
c8b1a7db 218 return false;
7e4038b5 219 }
336ac2ac 220 FILL_SW(individual,kTimingDensityCalculator);
2b556440 221
1f7aa5c7 222 // Check if we should do the event plane finder
2b556440 223 if (fEventInspector.GetCollisionSystem() == AliFMDEventInspector::kPbPb) {
336ac2ac 224 START_SW(individual);
c8b1a7db 225 if (!fEventPlaneFinder.FindEventplane(&esd, fAODEP,
b399c3cb 226 &(fAODFMD.GetHistogram()), &fHistos)){
2b556440 227 AliWarning("Eventplane finder failed!");
b399c3cb 228 fHStatus->Fill(10);
229 }
336ac2ac 230 FILL_SW(individual,kTimingEventPlaneFinder);
2b556440 231 }
7e4038b5 232
77f97e3f
CHC
233 // Check how many rings have been marked for skipping
234 Int_t nSkip = 0;
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++;
239 }
240 }
b399c3cb 241 if (nSkip > 0) {
77f97e3f 242 // Skip the rest if we have too many outliers
b399c3cb 243 fHStatus->Fill(11);
77f97e3f 244 return false;
b399c3cb 245 }
77f97e3f 246
7e4038b5 247 // Do the secondary and other corrections.
336ac2ac 248 START_SW(individual);
7e4038b5 249 if (!fCorrections.Correct(fHistos, ivz)) {
250 AliWarning("Corrections failed");
b399c3cb 251 fHStatus->Fill(12);
c8b1a7db 252 return false;
7e4038b5 253 }
336ac2ac 254 FILL_SW(individual,kTimingCorrections);
7e4038b5 255
b399c3cb 256 // Check if we should add to internal caches
b0127559 257 Bool_t add = (fAODFMD.IsTriggerBits(fAddMask) && nSkip < 1);
b399c3cb 258
1f7aa5c7 259 // Collect our `super' histogram
336ac2ac 260 START_SW(individual);
b399c3cb 261 if (!fHistCollector.Collect(fHistos,
262 fRingSums,
263 ivz,
264 fAODFMD.GetHistogram(),
265 fAODFMD.GetCentrality(),
266 false,
267 add)) {
7e4038b5 268 AliWarning("Histogram collector failed");
b399c3cb 269 fHStatus->Fill(13);
c8b1a7db 270 return false;
7e4038b5 271 }
336ac2ac 272 FILL_SW(individual,kTimingHistCollector);
7e4038b5 273
b399c3cb 274 if (!add) {
275 fHStatus->Fill(14);
276 }
277 else {
336ac2ac 278 // Collect rough Min. Bias result
7e4038b5 279 fHData->Add(&(fAODFMD.GetHistogram()));
b399c3cb 280 fHStatus->Fill(15);
281 }
336ac2ac 282 FILL_SW(total,kTimingTotal);
c8b1a7db 283
284 return true;
36ffcf83 285}
286
7e4038b5 287
288//
289// EOF
290//