]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliForwardMCFlowTaskQC.cxx
Compatibility with ROOT trunk
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardMCFlowTaskQC.cxx
CommitLineData
2b556440 1//
2// Calculate flow on MC data in the forward and central regions using the Q cumulants method.
3//
4// Inputs:
5// - AliAODEvent
6//
7// Outputs:
8// - AnalysisResults.root
9//
10#include "AliForwardMCFlowTaskQC.h"
11#include "AliAODMCParticle.h"
12#include "AliAODMCHeader.h"
13#include "TGraph.h"
14#include "TF1.h"
15#include "TProfile2D.h"
16#include "AliAODEvent.h"
17#include "AliAODForwardMult.h"
18#include "AliAODCentralMult.h"
19
20ClassImp(AliForwardMCFlowTaskQC)
936b0a6c 21#if 0
22;
23#endif
2b556440 24//_____________________________________________________________________
936b0a6c 25AliForwardMCFlowTaskQC::AliForwardMCFlowTaskQC()
26 : AliForwardFlowTaskQC(),
27 fBinsFMDTR(), // List of FMDTR analysis objects
28 fBinsSPDTR(), // List of SPDTR analysis objects
29 fBinsMC(), // List of MC truth analysis objects
30 fdNdedpMC(), // MC truth d^2N/detadphi histogram
31 fWeights(), // Flow weights
32 fImpactParToCent(), // Impact parameter to centrality graph
33 fUseImpactPar(0), // Use impact par for centrality
34 fAddFlow(0), // Add flow to MC truth
35 fAddType(0), // Add type of flow to MC truth
36 fAddOrder(0) // Add order of flow to MC truth
37{}
2b556440 38 //
39 // Default Constructor
40 //
41//_____________________________________________________________________
936b0a6c 42AliForwardMCFlowTaskQC::AliForwardMCFlowTaskQC(const char* name)
43 : AliForwardFlowTaskQC(name),
44 fBinsFMDTR(), // List of FMDTR analysis objects
45 fBinsSPDTR(), // List of SPDTR analysis objects
46 fBinsMC(), // List of MC truth analysis objects
47 fdNdedpMC(), // MC truth d^2N/detadphi histogram
48 fWeights(), // Flow weights
49 fImpactParToCent(), // Impact parameter to centrality graph
50 fUseImpactPar(0), // Use impact par for centrality
51 fAddFlow(0), // Add flow to MC truth
52 fAddType(0), // Add type of flow to MC truth
53 fAddOrder(0) // Add order of flow to MC truth
2b556440 54{
55 //
56 // Constructor
57 // Parameters:
58 // name: Name of task
59 //
936b0a6c 60 fdNdedpMC = TH2D("fdNdedpMC", "fdNdedpMC",
61 48, -6., 6., 200, 0., 2.*TMath::Pi());
2b556440 62 fdNdedpMC.Sumw2();
63
936b0a6c 64 // Double_t impactParam[] = {0.,1.75,4.225,5.965,7.765,9.215,10.46,
65 // 11.565,12.575,13.515,16.679};
66 // Double_t centrality[] = {0.,2.5,7.5,15,25,35,45,55,65,75,90};
67 Double_t impactParam[] = { 0.00, 3.72, 5.23, 7.31, 8.88, 10.20,
68 11.38, 12.47, 13.50, 14.51, 16.679};
69 Double_t centrality[] = { 0., 5., 10., 20., 30., 40.,
70 50., 60., 70., 80., 100.};
2b556440 71
72 Int_t nPoints = sizeof(impactParam)/sizeof(Double_t);
73 fImpactParToCent = new TGraph(nPoints, impactParam, centrality);
74
75}
76//_____________________________________________________________________
936b0a6c 77AliForwardMCFlowTaskQC::AliForwardMCFlowTaskQC(const AliForwardMCFlowTaskQC& o)
78 : AliForwardFlowTaskQC(o),
79 fBinsFMDTR(), // List of FMDTR analysis objects
80 fBinsSPDTR(), // List of SPDTR analysis objects
81 fBinsMC(), // List of MC truth analysis objects
82 fdNdedpMC(o.fdNdedpMC), // MC truth d^2N/detadphi histogram
83 fWeights(o.fWeights), // Flow weights
84 fImpactParToCent(o.fImpactParToCent), // Impact parameter to centrality
85 fUseImpactPar(o.fUseImpactPar), // Use impact par for centrality
86 fAddFlow(o.fAddFlow), // Add flow to MC truth
87 fAddType(o.fAddType), // Add type of flow to MC truth
88 fAddOrder(o.fAddOrder) // Add order of flow to MC truth
89{
2b556440 90 //
91 // Copy Constructor
92 //
936b0a6c 93}
2b556440 94//_____________________________________________________________________
95AliForwardMCFlowTaskQC&
96AliForwardMCFlowTaskQC::operator=(const AliForwardMCFlowTaskQC& o)
97{
98 //
99 // Assignment operator
100 // Parameters:
101 // o Object to copy from
102 //
eeb6c967 103 if (&o == this) return *this;
2b556440 104 fdNdedpMC = o.fdNdedpMC;
936b0a6c 105 fWeights = o.fWeights;
2b556440 106 fImpactParToCent = o.fImpactParToCent;
4b5b52b7 107 fUseImpactPar = o.fUseImpactPar;
2b556440 108 fAddFlow = o.fAddFlow;
109 fAddType = o.fAddType;
110 fAddOrder = o.fAddOrder;
111 return *this;
112}
113//_____________________________________________________________________
114void AliForwardMCFlowTaskQC::InitVertexBins()
115{
116 //
117 // Initiate VertexBin lists
118 //
119 AliForwardFlowTaskQC::InitVertexBins();
120
d420e249 121 for(UShort_t n = 2; n <= 6; n++) {
2b556440 122 if (!fv[n]) continue;
d420e249 123 for (Int_t v = 1; v <= fVtxAxis->GetNbins(); v++) {
a7989168 124 Int_t vL = Int_t(fVtxAxis->GetBinLowEdge(v));
125 Int_t vH = Int_t(fVtxAxis->GetBinUpEdge(v));
126 fBinsFMDTR.Add(new VertexBin(vL, vH, n, "FMDTR", (fgDispVtx ? kFALSE : kTRUE), fFMDCut));
127 fBinsSPDTR.Add(new VertexBin(vL, vH, n, "SPDTR", kTRUE, fSPDCut));
128 fBinsMC.Add(new VertexBin(vL, vH, n, "MC"));
2b556440 129 }
130 }
2b556440 131}
132//_____________________________________________________________________
133void AliForwardMCFlowTaskQC::InitHists()
134{
135 //
136 // Initiate diagnostics hists and add to outputlist
137 //
138 AliForwardFlowTaskQC::InitHists();
139
140 TIter nextFMDTR(&fBinsFMDTR);
141 VertexBin* bin = 0;
142 while ((bin = static_cast<VertexBin*>(nextFMDTR()))) {
143 bin->AddOutput(fSumList);
144 }
145 TIter nextSPDTR(&fBinsSPDTR);
146 while ((bin = static_cast<VertexBin*>(nextSPDTR()))) {
147 bin->AddOutput(fSumList);
148 }
149 TIter nextMC(&fBinsMC);
150 while ((bin = static_cast<VertexBin*>(nextMC()))) {
151 bin->AddOutput(fSumList);
152 }
153
936b0a6c 154 fWeights.Init(fSumList);
2b556440 155}
156//_____________________________________________________________________
157Bool_t AliForwardMCFlowTaskQC::Analyze()
158{
159 //
160 // Load FMD and SPD MC objects from aod tree and call the cumulants
161 // calculation for the correct vertexbin
162 //
163 if (!AliForwardFlowTaskQC::Analyze()) return kFALSE;
164
165 // Run analysis on trackrefs from FMD and SPD
936b0a6c 166 const AliAODForwardMult* aodfmult =
167 static_cast<AliAODForwardMult*>(fAOD->FindListObject("ForwardMC"));
168 const AliAODCentralMult* aodcmult =
169 static_cast<AliAODCentralMult*>(fAOD->FindListObject("CentralClustersMC"));
d420e249 170 Int_t vtx = fVtxAxis->FindBin(fVtx)-1;
2b556440 171
4b5b52b7 172 // if objects are present, get histograms
d420e249 173 if (aodfmult) {
174 const TH2D& fmdTRdNdetadphi = aodfmult->GetHistogram();
175 FillVtxBinList(fBinsFMDTR, fmdTRdNdetadphi, vtx);
176 }
177 if (aodcmult) {
178 const TH2D& spdTRdNdetadphi = aodcmult->GetHistogram();
179 FillVtxBinList(fBinsSPDTR, spdTRdNdetadphi, vtx);
180 }
2b556440 181
182 // Run analysis on MC branch
183 if (!LoopAODMC()) return kFALSE;
d420e249 184 FillVtxBinList(fBinsMC, fdNdedpMC, vtx);
2b556440 185
186 return kTRUE;
187}
188//_____________________________________________________________________
189void AliForwardMCFlowTaskQC::Finalize()
190{
191 //
192 // Finalize command, called by Terminate()
193 //
194 AliForwardFlowTaskQC::Finalize();
195
4b5b52b7 196 EndVtxBinList(fBinsFMDTR);
197 EndVtxBinList(fBinsSPDTR);
198 EndVtxBinList(fBinsMC);
2b556440 199
4b5b52b7 200 return;
201}
202//_____________________________________________________________________
d420e249 203Bool_t AliForwardMCFlowTaskQC::CheckTrigger(const AliAODForwardMult* aodfm) const
204{
205 //
206 // Function to look for a trigger string in the event.
207 //
208 // Parameters:
209 // AliAODForwardMult: forward mult object with trigger and vertex info
210 //
211 // Returns true if B trigger is present - for some reason this is the one we use in MC
212 //
213 return aodfm->IsTriggerBits(AliAODForwardMult::kB);
214}
215// _____________________________________________________________________
4b5b52b7 216Bool_t AliForwardMCFlowTaskQC::GetCentrality(const AliAODForwardMult* aodfm)
217{
218 //
219 // Function to use centrality parametrization from impact parameter
220 // if flag is not set call AliForwardFlowTaskQC::GetCentrality
221 //
222 // Parameters:
223 // AliAODForwardMult: forward mult object with trigger and vertex info
224 //
225 // Returns true when centrality is set.
226 //
227 if (fUseImpactPar) {
228 fCent = GetCentFromB();
d420e249 229// if (fCent > 30) fCent = 42;
230 if (fCent != -1) return kTRUE;
2b556440 231 }
d420e249 232 return AliForwardFlowTaskQC::GetCentrality(aodfm);
2b556440 233}
234//_____________________________________________________________________
235Bool_t AliForwardMCFlowTaskQC::LoopAODMC()
236{
237 //
238 // Loop over AliAODParticle branch and fill d^2N/detadphi-histograms.
239 // Add flow if set to do so in AddTask function
240 fdNdedpMC.Reset();
241
242 //retreive MC particles from event
936b0a6c 243 TClonesArray* mcArray =
d420e249 244 static_cast<TClonesArray*>(fAOD->FindListObject(
245 AliAODMCParticle::StdBranchName()));
2b556440 246 if(!mcArray){
d420e249 247 AliWarning("No MC array found in AOD. Try making it again.");
2b556440 248 return kFALSE;
249 }
250
251 Double_t rp = 0;
936b0a6c 252 AliAODMCHeader* header =
d420e249 253 dynamic_cast<AliAODMCHeader*>(fAOD->FindListObject(
254 AliAODMCHeader::StdBranchName()));
936b0a6c 255 if (!header)
2b556440 256 AliWarning("No header file found.");
936b0a6c 257 else
2b556440 258 rp = header->GetReactionPlaneAngle();
2b556440 259
260 Int_t ntracks = mcArray->GetEntriesFast();
261
936b0a6c 262 UShort_t flowFlags = 0;
263 if (fAddFlow.Length() > 1) {
264 if (fAddFlow.Contains("pt")) flowFlags |= AliForwardFlowWeights::kPt;
265 if (fAddFlow.Contains("pid")) flowFlags |= AliForwardFlowWeights::kPt;
266 if (fAddFlow.Contains("eta")) flowFlags |= AliForwardFlowWeights::kEta;
267 if (fAddFlow.Contains("cent")) flowFlags |= AliForwardFlowWeights::kCent;
268 }
269
2b556440 270 // Track loop: chek how many particles will be accepted
271 Double_t weight = 0;
272 for (Int_t it = 0; it < ntracks; it++) {
273 weight = 1;
274 AliAODMCParticle* particle = (AliAODMCParticle*)mcArray->At(it);
275 if (!particle) {
276 AliError(Form("Could not receive track %d", it));
277 continue;
278 }
279 if (!particle->IsPhysicalPrimary()) continue;
280 if (particle->Charge() == 0) continue;
281 Double_t pT = particle->Pt();
282 Double_t eta = particle->Eta();
283 Double_t phi = particle->Phi();
4b5b52b7 284 if (eta > -4. && eta < 5.) {
2b556440 285 // Add flow if it is in the argument
936b0a6c 286 if (flowFlags != 0)
287 weight = fWeights.CalcWeight(eta, pT, phi, particle->PdgCode(),
288 rp, fCent, fAddType, fAddOrder,
289 flowFlags) + 1;
2b556440 290 fdNdedpMC.Fill(eta, phi, weight);
291 }
292 }
d420e249 293 Int_t sBin = fdNdedpMC.GetXaxis()->FindBin(-4.);
294 Int_t eBin = fdNdedpMC.GetXaxis()->FindBin(+5.);
295 for ( ; sBin < eBin; sBin++) fdNdedpMC.SetBinContent(sBin, 0, 1.);
2b556440 296
297 return kTRUE;
298}
299//_____________________________________________________________________
2b556440 300Double_t AliForwardMCFlowTaskQC::GetCentFromB() const
301{
302 //
303 // Get centrality from MC impact parameter.
2b556440 304 //
305 Double_t cent = -1.;
306 Double_t b = -1.;
936b0a6c 307 AliAODMCHeader* header =
308 static_cast<AliAODMCHeader*>(fAOD->FindListObject(AliAODMCHeader::
309 StdBranchName()));
2b556440 310 if (!header) return cent;
311 b = header->GetImpactParameter();
312
313 cent = fImpactParToCent->Eval(b);
314
315 return cent;
316}
317//_____________________________________________________________________
d420e249 318void AliForwardMCFlowTaskQC::PrintFlowSetup() const
319{
320 //
321 // Print the setup of the flow task
322 //
323 Printf("AliForwardMCFlowTaskQC::Print");
324 Printf("Number of bins in vertex axis:\t%d", fVtxAxis->GetNbins());
325 Printf("Range of vertex axis :\t[%3.1f,%3.1f]",
326 fVtxAxis->GetXmin(), fVtxAxis->GetXmax());
327 printf("Doing flow analysis for :\t");
328 for (Int_t n = 2; n <= 6; n++) if (fv[n]) printf("v%d ", n);
329 printf("\n");
330 Printf("Displaced vertex flag: :\t%s", (fgDispVtx ? "true" : "false"));
331 Printf("FMD sigma cut: :\t%f", fFMDCut);
332 Printf("SPD sigma cut: :\t%f", fSPDCut);
333}
334//_____________________________________________________________________
2b556440 335//
336//
337// EOF
338