]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliForwardMCMultiplicityTask.cxx
Mega commit of many changes to PWGLFforward
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardMCMultiplicityTask.cxx
CommitLineData
7984e5f7 1//
2// Calculate the multiplicity in the forward regions event-by-event
3//
4// Inputs:
5// - AliESDEvent
6// - Kinematics
7// - Track references
8//
9// Outputs:
10// - AliAODForwardMult
11//
12// Histograms
13//
14// Corrections used
15//
285e7b27 16#include "AliForwardMCMultiplicityTask.h"
17#include "AliTriggerAnalysis.h"
18#include "AliPhysicsSelection.h"
19#include "AliLog.h"
285e7b27 20#include "AliESDEvent.h"
21#include "AliAODHandler.h"
22#include "AliMultiplicity.h"
23#include "AliInputEventHandler.h"
24#include "AliForwardCorrectionManager.h"
25#include "AliAnalysisManager.h"
26#include <TH1.h>
27#include <TDirectory.h>
28#include <TTree.h>
29#include <TROOT.h>
285e7b27 30
31//====================================================================
32AliForwardMCMultiplicityTask::AliForwardMCMultiplicityTask()
33 : AliForwardMultiplicityBase(),
285e7b27 34 fESDFMD(),
285e7b27 35 fMCESDFMD(),
36 fMCHistos(),
37 fMCAODFMD(),
5bb5d1f6 38 fMCRingSums(),
4cbdf467 39 fPrimary(0),
285e7b27 40 fEventInspector(),
285e7b27 41 fSharingFilter(),
42 fDensityCalculator(),
43 fCorrections(),
44 fHistCollector(),
8449e3e0 45 fEventPlaneFinder()
285e7b27 46{
7984e5f7 47 //
48 // Constructor
49 //
285e7b27 50}
51
52//____________________________________________________________________
53AliForwardMCMultiplicityTask::AliForwardMCMultiplicityTask(const char* name)
54 : AliForwardMultiplicityBase(name),
285e7b27 55 fESDFMD(),
285e7b27 56 fMCESDFMD(),
57 fMCHistos(),
58 fMCAODFMD(kTRUE),
5bb5d1f6 59 fMCRingSums(),
4cbdf467 60 fPrimary(0),
285e7b27 61 fEventInspector("event"),
285e7b27 62 fSharingFilter("sharing"),
63 fDensityCalculator("density"),
64 fCorrections("corrections"),
65 fHistCollector("collector"),
8449e3e0 66 fEventPlaneFinder("eventplane")
285e7b27 67{
7984e5f7 68 //
69 // Constructor
70 //
71 // Parameters:
72 // name Name of task
73 //
285e7b27 74}
75
76//____________________________________________________________________
77AliForwardMCMultiplicityTask::AliForwardMCMultiplicityTask(const AliForwardMCMultiplicityTask& o)
78 : AliForwardMultiplicityBase(o),
285e7b27 79 fESDFMD(o.fESDFMD),
285e7b27 80 fMCESDFMD(o.fMCESDFMD),
81 fMCHistos(o.fMCHistos),
82 fMCAODFMD(o.fMCAODFMD),
5bb5d1f6 83 fMCRingSums(o.fMCRingSums),
4cbdf467 84 fPrimary(o.fPrimary),
285e7b27 85 fEventInspector(o.fEventInspector),
4cbdf467 86 fSharingFilter(o.fSharingFilter),
285e7b27 87 fDensityCalculator(o.fDensityCalculator),
88 fCorrections(o.fCorrections),
89 fHistCollector(o.fHistCollector),
8449e3e0 90 fEventPlaneFinder(o.fEventPlaneFinder)
285e7b27 91{
7984e5f7 92 //
93 // Copy constructor
94 //
95 // Parameters:
96 // o Object to copy from
97 //
285e7b27 98}
99
100//____________________________________________________________________
101AliForwardMCMultiplicityTask&
102AliForwardMCMultiplicityTask::operator=(const AliForwardMCMultiplicityTask& o)
103{
7984e5f7 104 //
105 // Assignment operator
106 //
107 // Parameters:
108 // o Object to assign from
109 //
110 // Return:
111 // Reference to this object
112 //
d015ecfe 113 if (&o == this) return *this;
285e7b27 114 AliForwardMultiplicityBase::operator=(o);
115
285e7b27 116 fEventInspector = o.fEventInspector;
285e7b27 117 fSharingFilter = o.fSharingFilter;
118 fDensityCalculator = o.fDensityCalculator;
119 fCorrections = o.fCorrections;
120 fHistCollector = o.fHistCollector;
2b556440 121 fEventPlaneFinder = o.fEventPlaneFinder;
285e7b27 122 fMCHistos = o.fMCHistos;
123 fMCAODFMD = o.fMCAODFMD;
5bb5d1f6 124 fMCRingSums = o.fMCRingSums;
4cbdf467 125 fPrimary = o.fPrimary;
285e7b27 126 return *this;
127}
128
129//____________________________________________________________________
130void
8449e3e0 131AliForwardMCMultiplicityTask::SetOnlyPrimary(Bool_t use)
285e7b27 132{
8449e3e0 133 fSharingFilter.GetTrackDensity().SetUseOnlyPrimary(use);
134 fCorrections.SetSecondaryForMC(!use);
285e7b27 135}
8449e3e0 136
5bb5d1f6 137//____________________________________________________________________
138void
8449e3e0 139AliForwardMCMultiplicityTask::CreateBranches(AliAODHandler* ah)
5bb5d1f6 140{
8449e3e0 141 //
142 // Create output objects
143 //
144 //
145 AliForwardMultiplicityBase::CreateBranches(ah);
146
147 TObject* mcobj = &fMCAODFMD;
148 ah->AddBranch("AliAODForwardMult", &mcobj);
149
150 fPrimary = new TH2D("primary", "MC Primaries", 1,0,1,20,0,TMath::TwoPi());
151 fPrimary->SetXTitle("#eta");
152 fPrimary->SetYTitle("#varphi [radians]");
153 fPrimary->SetZTitle("d^{2}N_{ch}/d#etad#phi");
154 fPrimary->Sumw2();
155 fPrimary->SetStats(0);
156 fPrimary->SetDirectory(0);
157
158 ah->AddBranch("TH2D", &fPrimary);
5bb5d1f6 159}
160
8449e3e0 161
285e7b27 162//____________________________________________________________________
8449e3e0 163void
164AliForwardMCMultiplicityTask::InitMembers(const TAxis* pe, const TAxis* pv)
285e7b27 165{
7984e5f7 166 //
167 // Initialise the sub objects and stuff. Called on first event
168 //
169 //
8449e3e0 170 AliForwardMultiplicityBase::InitMembers(pe, pv);
1174780f 171
285e7b27 172 fMCHistos.Init(*pe);
173 fMCAODFMD.Init(*pe);
5bb5d1f6 174 fMCRingSums.Init(*pe);
285e7b27 175
8449e3e0 176 AliForwardUtil::Histos::RebinEta(fPrimary, *pe);
5bb5d1f6 177
178 TList* mcRings = new TList;
179 mcRings->SetName("mcRingSums");
180 mcRings->SetOwner();
181 fList->Add(mcRings);
182
183 mcRings->Add(fMCRingSums.Get(1, 'I'));
184 mcRings->Add(fMCRingSums.Get(2, 'I'));
185 mcRings->Add(fMCRingSums.Get(2, 'O'));
186 mcRings->Add(fMCRingSums.Get(3, 'I'));
187 mcRings->Add(fMCRingSums.Get(3, 'O'));
188 fMCRingSums.Get(1, 'I')->SetMarkerColor(AliForwardUtil::RingColor(1, 'I'));
189 fMCRingSums.Get(2, 'I')->SetMarkerColor(AliForwardUtil::RingColor(2, 'I'));
190 fMCRingSums.Get(2, 'O')->SetMarkerColor(AliForwardUtil::RingColor(2, 'O'));
191 fMCRingSums.Get(3, 'I')->SetMarkerColor(AliForwardUtil::RingColor(3, 'I'));
192 fMCRingSums.Get(3, 'O')->SetMarkerColor(AliForwardUtil::RingColor(3, 'O'));
285e7b27 193}
194
285e7b27 195//____________________________________________________________________
196void
197AliForwardMCMultiplicityTask::UserExec(Option_t*)
198{
7984e5f7 199 //
200 // Process each event
201 //
202 // Parameters:
203 // option Not used
204 //
205
f7cfc454 206 // Read production details
207 if (fFirstEvent)
208 fEventInspector.ReadProductionDetails(MCEvent());
209
285e7b27 210 // Get the input data
e1f47419 211 AliESDEvent* esd = GetESDEvent();
212 AliMCEvent* mcEvent = MCEvent();
6ff251d8 213 if (!esd || !mcEvent) return;
285e7b27 214
285e7b27 215 // Clear stuff
216 fHistos.Clear();
217 fESDFMD.Clear();
218 fAODFMD.Clear();
2b556440 219 fAODEP.Clear();
285e7b27 220 fMCHistos.Clear();
221 fMCESDFMD.Clear();
222 fMCAODFMD.Clear();
4cbdf467 223 fPrimary->Reset();
285e7b27 224
5bb5d1f6 225 Bool_t lowFlux = kFALSE;
226 UInt_t triggers = 0;
227 UShort_t ivz = 0;
5ca83fee 228 TVector3 ip(1024, 1024, 0);
21d778b1 229 Double_t cent = -1;
5bb5d1f6 230 UShort_t nClusters = 0;
231 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux,
5ca83fee 232 ivz, ip, cent, nClusters);
e1f47419 233 UShort_t ivzMC = 0;
234 Double_t vzMC = 0;
235 Double_t phiR = 0;
236 Double_t b = 0;
241cca4d 237 Double_t cMC = 0;
e308a636 238 Int_t npart = 0;
239 Int_t nbin = 0;
e1f47419 240 // UInt_t foundMC =
241cca4d 241 fEventInspector.ProcessMC(mcEvent, triggers, ivzMC, vzMC, b, cMC,
e308a636 242 npart, nbin, phiR);
73b32206 243 fEventInspector.CompareResults(ip.Z(), vzMC, cent, cMC, b, npart, nbin);
1dbfc345 244
e333578d 245 //Store all events
148c39de 246 MarkEventForStore();
e333578d 247
248 Bool_t isAccepted = true;
249 if (found & AliFMDEventInspector::kNoEvent) isAccepted = false; // return;
250 if (found & AliFMDEventInspector::kNoTriggers) isAccepted = false; // return;
148c39de 251 //MarkEventForStore();
b30dee70 252 // Always set the B trigger - each MC event _is_ a collision
253 triggers |= AliAODForwardMult::kB;
285e7b27 254 // Set trigger bits, and mark this event for storage
255 fAODFMD.SetTriggerBits(triggers);
e308a636 256 fAODFMD.SetSNN(fEventInspector.GetEnergy());
257 fAODFMD.SetSystem(fEventInspector.GetCollisionSystem());
e58000b7 258 fAODFMD.SetCentrality(cent);
5bb5d1f6 259 fAODFMD.SetNClusters(nClusters);
e308a636 260
261 fMCAODFMD.SetTriggerBits(triggers);
262 fMCAODFMD.SetSNN(fEventInspector.GetEnergy());
263 fMCAODFMD.SetSystem(fEventInspector.GetCollisionSystem());
264 fMCAODFMD.SetCentrality(cent);
5bb5d1f6 265 fMCAODFMD.SetNClusters(nClusters);
e58000b7 266
e333578d 267 //All events should be stored - HHD
148c39de 268 //if (isAccepted) MarkEventForStore();
285e7b27 269
e1f47419 270 // Disable this check on SPD - will bias data
271 // if (found & AliFMDEventInspector::kNoSPD) isAccepted = false; // return;
e333578d 272 if (found & AliFMDEventInspector::kNoFMD) isAccepted = false; // return;
273 if (found & AliFMDEventInspector::kNoVertex) isAccepted = false; // return;
274
275 if (isAccepted) {
5ca83fee 276 fAODFMD.SetIpZ(ip.Z());
277 fMCAODFMD.SetIpZ(ip.Z());
e333578d 278 }
279 if (found & AliFMDEventInspector::kBadVertex) isAccepted = false; // return;
285e7b27 280
281 // We we do not want to use low flux specific code, we disable it here.
282 if (!fEnableLowFlux) lowFlux = false;
148c39de 283
284
285e7b27 285
286 // Get FMD data
287 AliESDFMD* esdFMD = esd->GetFMDData();
e1f47419 288
285e7b27 289 // Apply the sharing filter (or hit merging or clustering if you like)
5ca83fee 290 if (isAccepted && !fSharingFilter.Filter(*esdFMD, lowFlux, fESDFMD,ip.Z())) {
285e7b27 291 AliWarning("Sharing filter failed!");
292 return;
293 }
5ca83fee 294 if (!fSharingFilter.FilterMC(*esdFMD, *mcEvent, ip.Z(),fMCESDFMD,fPrimary)) {
285e7b27 295 AliWarning("MC Sharing filter failed!");
296 return;
297 }
e333578d 298 if (!isAccepted) return; // Exit on MC event w/o trigger, vertex, data
148c39de 299 // HHD if (!isAccepted) return; // Exit on MC event w/o trigger, vertex, data
1dbfc345 300
148c39de 301 //MarkEventForStore();
285e7b27 302 fSharingFilter.CompareResults(fESDFMD, fMCESDFMD);
303
285e7b27 304 // Calculate the inclusive charged particle density
5934a3e3 305 if (!fDensityCalculator.Calculate(fESDFMD, fHistos, lowFlux, cent, ip)) {
285e7b27 306 AliWarning("Density calculator failed!");
307 return;
308 }
309 if (!fDensityCalculator.CalculateMC(fMCESDFMD, fMCHistos)) {
310 AliWarning("MC Density calculator failed!");
311 return;
312 }
313 fDensityCalculator.CompareResults(fHistos, fMCHistos);
314
2b556440 315 if (fEventInspector.GetCollisionSystem() == AliFMDEventInspector::kPbPb) {
8449e3e0 316 if (!fEventPlaneFinder.FindEventplane(esd, fAODEP,
317 &(fAODFMD.GetHistogram()) , &fHistos))
2b556440 318 AliWarning("Eventplane finder failed!");
319 }
320
285e7b27 321 // Do the secondary and other corrections.
322 if (!fCorrections.Correct(fHistos, ivz)) {
323 AliWarning("Corrections failed");
324 return;
325 }
326 if (!fCorrections.CorrectMC(fMCHistos, ivz)) {
327 AliWarning("MC Corrections failed");
328 return;
329 }
330 fCorrections.CompareResults(fHistos, fMCHistos);
331
5bb5d1f6 332 if (!fHistCollector.Collect(fHistos, fRingSums,
8449e3e0 333 ivz, fAODFMD.GetHistogram(),
334 fAODFMD.GetCentrality())) {
285e7b27 335 AliWarning("Histogram collector failed");
336 return;
337 }
5bb5d1f6 338 if (!fHistCollector.Collect(fMCHistos, fMCRingSums,
339 ivz, fMCAODFMD.GetHistogram())) {
285e7b27 340 AliWarning("MC Histogram collector failed");
341 return;
342 }
343
344 if (fAODFMD.IsTriggerBits(AliAODForwardMult::kInel))
345 fHData->Add(&(fAODFMD.GetHistogram()));
346
347 PostData(1, fList);
348}
349
350//____________________________________________________________________
351void
8449e3e0 352AliForwardMCMultiplicityTask::EstimatedNdeta(const TList* input,
353 TList* output) const
285e7b27 354{
8449e3e0 355 AliForwardMultiplicityBase::EstimatedNdeta(input, output);
356 MakeRingdNdeta(input, "mcRingSums", output, "mcRingResults", 24);
285e7b27 357}
358
285e7b27 359
8449e3e0 360
285e7b27 361//
362// EOF
363//