f5ec6c30 |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * |
6 | * * |
7 | * Permission to use, copy, modify and distribute this software and its * |
8 | * documentation strictly for non-commercial purposes is hereby granted * |
9 | * without fee, provided that the above copyright notice appears in all * |
10 | * copies and that both the copyright notice and this permission notice * |
11 | * appear in the supporting documentation. The authors make no claims * |
12 | * about the suitability of this software for any purpose. It is * |
13 | * provided "as is" without express or implied warranty. * |
14 | **************************************************************************/ |
15 | |
16 | //----------------------------------------------------------------------- |
17 | // Class for HF corrections as a function of many variables |
18 | // 6 Steps introduced: MC, MC Acc, Reco, Reco Acc, Reco Acc + ITS Cl, |
19 | // Reco Acc + ITS Cl + PPR cuts |
20 | // 11 variables used: pt, y, cosThetaStar, ptPi, ptK, ct, |
21 | // dca, d0Pi, d0K, d0Pixd0K, cosPointingAngle |
22 | // |
23 | //----------------------------------------------------------------------- |
24 | // Author : C. Zampolli, CERN |
25 | //----------------------------------------------------------------------- |
26 | |
27 | #include <TCanvas.h> |
28 | #include <TParticle.h> |
29 | #include <TH1I.h> |
30 | #include <TStyle.h> |
31 | |
32 | #include "AliCFHeavyFlavourTaskMultiVarMultiStep.h" |
33 | #include "AliStack.h" |
34 | #include "AliMCEvent.h" |
35 | #include "AliCFManager.h" |
36 | #include "AliCFContainer.h" |
37 | #include "AliLog.h" |
38 | #include "AliAODEvent.h" |
39 | #include "AliAODRecoDecay.h" |
40 | #include "AliAODRecoDecayHF.h" |
41 | #include "AliAODRecoDecayHF2Prong.h" |
42 | #include "AliAODMCParticle.h" |
43 | |
44 | //__________________________________________________________________________ |
45 | AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep() : |
46 | AliAnalysisTaskSE(), |
47 | fPDG(0), |
48 | fCFManager(0x0), |
49 | fHistEventsProcessed(0x0), |
50 | fCountMC(0), |
51 | fCountAcc(0), |
52 | fCountReco(0), |
53 | fCountRecoAcc(0), |
54 | fCountRecoITSClusters(0), |
55 | fCountRecoPPR(0), |
56 | fEvents(0), |
57 | fFillFromGenerated(kFALSE), |
58 | fMinITSClusters(5) |
59 | { |
60 | // |
61 | //Default ctor |
62 | // |
63 | } |
64 | //___________________________________________________________________________ |
65 | AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(const Char_t* name) : |
66 | AliAnalysisTaskSE(name), |
67 | fPDG(0), |
68 | fCFManager(0x0), |
69 | fHistEventsProcessed(0x0), |
70 | fCountMC(0), |
71 | fCountAcc(0), |
72 | fCountReco(0), |
73 | fCountRecoAcc(0), |
74 | fCountRecoITSClusters(0), |
75 | fCountRecoPPR(0), |
76 | fEvents(0), |
77 | fFillFromGenerated(kFALSE), |
78 | fMinITSClusters(5) |
79 | { |
80 | // |
81 | // Constructor. Initialization of Inputs and Outputs |
82 | // |
83 | Info("AliCFHeavyFlavourTaskMultiVarMultiStep","Calling Constructor"); |
84 | /* |
85 | DefineInput(0) and DefineOutput(0) |
86 | are taken care of by AliAnalysisTaskSE constructor |
87 | */ |
88 | DefineOutput(1,TH1I::Class()); |
89 | DefineOutput(2,AliCFContainer::Class()); |
90 | } |
91 | |
92 | //___________________________________________________________________________ |
93 | AliCFHeavyFlavourTaskMultiVarMultiStep& AliCFHeavyFlavourTaskMultiVarMultiStep::operator=(const AliCFHeavyFlavourTaskMultiVarMultiStep& c) |
94 | { |
95 | // |
96 | // Assignment operator |
97 | // |
98 | if (this!=&c) { |
99 | AliAnalysisTaskSE::operator=(c) ; |
100 | fPDG = c.fPDG; |
101 | fCFManager = c.fCFManager; |
102 | fHistEventsProcessed = c.fHistEventsProcessed; |
103 | } |
104 | return *this; |
105 | } |
106 | |
107 | //___________________________________________________________________________ |
108 | AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(const AliCFHeavyFlavourTaskMultiVarMultiStep& c) : |
109 | AliAnalysisTaskSE(c), |
110 | fPDG(c.fPDG), |
111 | fCFManager(c.fCFManager), |
112 | fHistEventsProcessed(c.fHistEventsProcessed), |
113 | fCountMC(c.fCountMC), |
114 | fCountAcc(c.fCountAcc), |
115 | fCountReco(c.fCountReco), |
116 | fCountRecoAcc(c.fCountRecoAcc), |
117 | fCountRecoITSClusters(c.fCountRecoITSClusters), |
118 | fCountRecoPPR(c.fCountRecoPPR), |
119 | fEvents(c.fEvents), |
120 | fFillFromGenerated(c.fFillFromGenerated), |
121 | fMinITSClusters(c.fMinITSClusters) |
122 | { |
123 | // |
124 | // Copy Constructor |
125 | // |
126 | } |
127 | |
128 | //___________________________________________________________________________ |
129 | AliCFHeavyFlavourTaskMultiVarMultiStep::~AliCFHeavyFlavourTaskMultiVarMultiStep() { |
130 | // |
131 | //destructor |
132 | // |
133 | if (fCFManager) delete fCFManager ; |
134 | if (fHistEventsProcessed) delete fHistEventsProcessed ; |
135 | } |
136 | |
137 | //_________________________________________________ |
138 | void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *) |
139 | { |
140 | // |
141 | // Main loop function |
142 | // |
143 | |
144 | if (fFillFromGenerated){ |
145 | AliWarning("Flag to fill container with generated value ON ---> dca, d0pi, d0K, d0xd0, cosPointingAngle will be set as dummy!"); |
146 | } |
147 | |
148 | if (!fInputEvent) { |
149 | Error("UserExec","NO EVENT FOUND!"); |
150 | return; |
151 | } |
152 | |
153 | fEvents++; |
154 | if (fEvents%10000 ==0) AliInfo(Form("Event %d",fEvents)); |
155 | AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent); |
156 | fCFManager->SetEventInfo(aodEvent); |
157 | |
158 | // MC-event selection |
159 | Double_t containerInput[11] ; |
160 | |
161 | //loop on the MC event |
162 | |
163 | TClonesArray* mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName())); |
164 | if (!mcArray) AliError("Could not find Monte-Carlo in AOD"); |
165 | Int_t icountMC = 0; |
166 | Int_t icountAcc = 0; |
167 | Int_t icountReco = 0; |
168 | Int_t icountRecoAcc = 0; |
169 | Int_t icountRecoITSClusters = 0; |
170 | Int_t icountRecoPPR = 0; |
171 | |
172 | for (Int_t iPart=0; iPart<mcArray->GetEntriesFast(); iPart++) { |
173 | AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart)); |
174 | if (!mcPart) { |
175 | AliWarning("Particle not found in tree, skipping"); |
176 | continue; |
177 | } |
178 | |
179 | // check the MC-level cuts |
180 | if (!fCFManager->CheckParticleCuts(0, mcPart)) continue; // 0 stands for MC level |
181 | |
182 | // fill the container for Gen-level selection |
183 | Double_t vectorMC[6] = {9999.,9999.,9999.,9999.,9999.,9999.}; |
184 | if (GetGeneratedValuesFromMCParticle(mcPart, mcArray, vectorMC)){ |
185 | containerInput[0] = vectorMC[0]; |
186 | containerInput[1] = vectorMC[1] ; |
187 | containerInput[2] = vectorMC[2] ; |
188 | containerInput[3] = vectorMC[3] ; |
189 | containerInput[4] = vectorMC[4] ; |
190 | containerInput[5] = vectorMC[5] ; // in micron |
191 | containerInput[6] = 0.; // dummy value, meaningless in MC, in micron |
192 | containerInput[7] = 0.; // dummy value, meaningless in MC, in micron |
193 | containerInput[8] = 0.; // dummy value, meaningless in MC, in micron |
194 | containerInput[9] = -100000.; // dummy value, meaningless in MC, in micron^2 |
195 | containerInput[10] = 1.01; // dummy value, meaningless in MC |
196 | fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated); |
197 | icountMC++; |
198 | |
199 | // check the MC-Acceptance level cuts |
200 | // since standard CF functions are not applicable, using Kine Cuts on daughters |
201 | |
202 | Int_t daughter0 = mcPart->GetDaughter(0); |
203 | Int_t daughter1 = mcPart->GetDaughter(1); |
204 | AliDebug(2, Form("daughter0 = %d and daughter1 = %d",daughter0,daughter1)); |
205 | if (daughter0 == 0 || daughter1 == 0) { |
206 | AliDebug(2, "Error! the D0 MC doesn't have correct daughters!! But it should have, this check was already done..."); |
207 | } |
208 | if (TMath::Abs(daughter1 - daughter0 != 1)) { |
209 | AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, but it should be, this check was already done..."); |
210 | } |
211 | AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter0)); |
212 | AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter1)); |
213 | if (!mcPartDaughter0 || !mcPartDaughter1) { |
214 | AliWarning("At least one Daughter Particle not found in tree, but it should be, this check was already done..."); |
215 | } |
216 | Double_t eta0 = mcPartDaughter0->Eta(); |
217 | Double_t eta1 = mcPartDaughter1->Eta(); |
218 | Double_t y0 = mcPartDaughter0->Y(); |
219 | Double_t y1 = mcPartDaughter1->Y(); |
220 | Double_t pt0 = mcPartDaughter0->Pt(); |
221 | Double_t pt1 = mcPartDaughter1->Pt(); |
222 | AliDebug(2, Form("Daughter 0: eta = %f, y = %f, pt = %f", eta0, y0, pt0)); |
223 | AliDebug(2, Form("Daughter 1: eta = %f, y = %f, pt = %f", eta1, y1, pt1)); |
224 | Bool_t daught0inAcceptance = (TMath::Abs(eta0) < 0.9 && pt0 > 0.1); |
225 | Bool_t daught1inAcceptance = (TMath::Abs(eta1) < 0.9 && pt1 > 0.1); |
226 | if (daught0inAcceptance && daught1inAcceptance) { |
227 | // checking whether the cuts implemented in the CF are equivalent - simply a cross-check |
228 | AliDebug(2, "Daughter particles in acceptance"); |
229 | if (!fCFManager->CheckParticleCuts(1, mcPartDaughter0)) { |
230 | AliInfo("Inconsistency with CF cut for daughter 0!"); |
231 | } |
232 | if (!fCFManager->CheckParticleCuts(1, mcPartDaughter1)) { |
233 | AliInfo("Inconsistency with CF cut for daughter 1!"); |
234 | } |
235 | fCFManager->GetParticleContainer()->Fill(containerInput,kStepAcceptance); |
236 | icountAcc++; |
237 | } |
238 | } |
239 | else { |
240 | AliDebug(3,"Problems in filling the container"); |
241 | continue; |
242 | } |
243 | } |
244 | |
245 | AliDebug(2, Form("Found %i MC particles that are D0!!",icountMC)); |
246 | AliDebug(2, Form("Found %i MC particles that are D0 and satisfy Acc cuts!!",icountAcc)); |
247 | |
248 | // Now go to rec level |
249 | fCountMC += icountMC; |
250 | fCountAcc += icountAcc; |
251 | |
1e090d47 |
252 | // AOD primary vertex |
253 | AliAODVertex *vtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex(); |
254 | |
f5ec6c30 |
255 | // load heavy flavour vertices |
1e090d47 |
256 | TClonesArray *arrayD0toKpi = (TClonesArray*)((aodEvent->GetList())->FindObject("D0toKpi")); |
257 | if (!arrayD0toKpi) AliError("Could not find array of HF vertices"); |
258 | AliDebug(2, Form("Found %d vertices",arrayD0toKpi->GetEntriesFast())); |
f5ec6c30 |
259 | |
1e090d47 |
260 | for (Int_t iD0toKpi = 0; iD0toKpi<arrayD0toKpi->GetEntriesFast(); iD0toKpi++) { |
f5ec6c30 |
261 | |
1e090d47 |
262 | AliAODRecoDecayHF2Prong* d0tokpi = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->At(iD0toKpi); |
263 | Bool_t unsetvtx=kFALSE; |
264 | if(!d0tokpi->GetOwnPrimaryVtx()) { |
265 | d0tokpi->SetOwnPrimaryVtx(vtx1); // needed to compute all variables |
266 | unsetvtx=kTRUE; |
267 | } |
268 | |
f5ec6c30 |
269 | // find associated MC particle |
1e090d47 |
270 | Int_t mcLabel = d0tokpi->MatchToMC(421, mcArray) ; |
f5ec6c30 |
271 | if (mcLabel == -1) |
272 | { |
273 | AliDebug(2,"No MC particle found"); |
274 | } |
275 | else { |
276 | AliAODMCParticle* mcVtxHF = (AliAODMCParticle*)mcArray->At(mcLabel); |
277 | if (!mcVtxHF) { |
278 | AliWarning("Could not find associated MC in AOD MC tree"); |
279 | continue; |
280 | } |
281 | |
282 | // check if associated MC v0 passes the cuts |
283 | if (!fCFManager->CheckParticleCuts(0 ,mcVtxHF)) { // 0 stands for MC |
284 | AliDebug(2, "Skipping the particles due to cuts"); |
285 | continue; |
286 | } |
287 | |
288 | |
289 | // fill the container... |
1e090d47 |
290 | Double_t pt = d0tokpi->Pt(); |
291 | Double_t rapidity = d0tokpi->YD0(); |
f5ec6c30 |
292 | |
293 | Double_t cosThetaStar = 9999.; |
294 | Double_t pTpi = 0.; |
295 | Double_t pTK = 0.; |
1e090d47 |
296 | Double_t dca = d0tokpi->GetDCA(); |
f5ec6c30 |
297 | Double_t d0pi = 0.; |
298 | Double_t d0K = 0.; |
1e090d47 |
299 | Double_t d0xd0 = d0tokpi->Prodd0d0(); |
300 | Double_t cosPointingAngle = d0tokpi->CosPointingAngle(); |
f5ec6c30 |
301 | Int_t pdgCode = mcVtxHF->GetPdgCode(); |
302 | if (pdgCode > 0){ |
1e090d47 |
303 | cosThetaStar = d0tokpi->CosThetaStarD0(); |
304 | pTpi = d0tokpi->PtProng(0); |
305 | pTK = d0tokpi->PtProng(1); |
306 | d0pi = d0tokpi->Getd0Prong(0); |
307 | d0K = d0tokpi->Getd0Prong(1); |
f5ec6c30 |
308 | } |
309 | else { |
1e090d47 |
310 | cosThetaStar = d0tokpi->CosThetaStarD0bar(); |
311 | pTpi = d0tokpi->PtProng(1); |
312 | pTK = d0tokpi->PtProng(0); |
313 | d0pi = d0tokpi->Getd0Prong(1); |
314 | d0K = d0tokpi->Getd0Prong(0); |
f5ec6c30 |
315 | } |
316 | |
1e090d47 |
317 | Double_t cT = d0tokpi->CtD0(); |
f5ec6c30 |
318 | |
319 | if (!fFillFromGenerated){ |
320 | // ...either with reconstructed values.... |
321 | containerInput[0] = pt; |
322 | containerInput[1] = rapidity; |
323 | containerInput[2] = cosThetaStar; |
324 | containerInput[3] = pTpi; |
325 | containerInput[4] = pTK; |
326 | containerInput[5] = cT*1.E4; // in micron |
327 | containerInput[6] = dca*1.E4; // in micron |
328 | containerInput[7] = d0pi*1.E4; // in micron |
329 | containerInput[8] = d0K*1.E4; // in micron |
330 | containerInput[9] = d0xd0*1.E8; // in micron^2 |
331 | containerInput[10] = cosPointingAngle; // in micron |
332 | } |
333 | else { |
334 | // ... or with generated values |
335 | Double_t vectorMC[6] = {9999.,9999.,9999.,9999.,9999.,9999.}; |
336 | if (GetGeneratedValuesFromMCParticle(mcVtxHF, mcArray, vectorMC)){ |
337 | containerInput[0] = vectorMC[0]; |
338 | containerInput[1] = vectorMC[1] ; |
339 | containerInput[2] = vectorMC[2] ; |
340 | containerInput[3] = vectorMC[3] ; |
341 | containerInput[4] = vectorMC[4] ; |
342 | containerInput[5] = vectorMC[5] ; // in micron |
343 | containerInput[6] = 0.; // dummy value, meaningless in MC, in micron |
344 | containerInput[7] = 0.; // dummy value, meaningless in MC, in micron |
345 | containerInput[8] = 0.; // dummy value, meaningless in MC, in micron |
346 | containerInput[9] = 100000.; // dummy value, meaningless in MC, in micron^2 |
347 | containerInput[10] = 1.01; // dummy value, meaningless in MC |
348 | } |
349 | else { |
350 | AliDebug(3,"Problems in filling the container"); |
351 | continue; |
352 | } |
353 | } |
354 | AliDebug(2, Form("Filling the container with pt = %f, rapidity = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, cT = %f", containerInput[0], containerInput[1], containerInput[2], containerInput[3], containerInput[4], containerInput[5])); |
355 | icountReco++; |
356 | fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ; |
357 | |
358 | // cut in acceptance |
1e090d47 |
359 | Bool_t acceptanceProng0 = (TMath::Abs(d0tokpi->EtaProng(0))< 0.9 && d0tokpi->PtProng(0) > 0.1); |
360 | Bool_t acceptanceProng1 = (TMath::Abs(d0tokpi->EtaProng(1))< 0.9 && d0tokpi->PtProng(1) > 0.1); |
f5ec6c30 |
361 | if (acceptanceProng0 && acceptanceProng1) { |
362 | AliDebug(2,"D0 reco daughters in acceptance"); |
363 | fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoAcceptance) ; |
364 | icountRecoAcc++; |
365 | |
366 | // cut on the min n. of clusters in ITS |
367 | Int_t ncls0=0; |
1e090d47 |
368 | for(Int_t l=0;l<6;l++) if(TESTBIT(d0tokpi->GetITSClusterMap(),l)) ncls0++; |
f5ec6c30 |
369 | AliDebug(2, Form("n clusters = %d", ncls0)); |
370 | if (ncls0 >= fMinITSClusters){ |
371 | fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoITSClusters) ; |
372 | icountRecoITSClusters++; |
373 | AliDebug(2,Form("pT = %f, dca = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, d0pi = %f, d0K = %f, d0xd0 = %f, cosPointingAngle = %f", pt, dca, cosThetaStar,pTpi, pTK, d0pi*1E4, d0K*1E4, d0xd0*1E8, cosPointingAngle)); |
374 | |
375 | // PPR cuts |
376 | Double_t cuts[6]; |
377 | if (pt <= 1){ |
378 | cuts[0] = 400; |
379 | cuts[1] = 0.8; |
380 | cuts[2] = 0.5; |
381 | cuts[3] = 500; |
382 | cuts[4] = -20000; |
383 | cuts[5] = 0.5; |
384 | } |
385 | else if (pt > 1 && pt <= 2){ |
386 | cuts[0] = 300; |
387 | cuts[1] = 0.8; |
388 | cuts[2] = 0.6; |
389 | cuts[3] = 500; |
390 | cuts[4] = -20000; |
391 | cuts[5] = 0.6; |
392 | } |
393 | else if (pt > 2 && pt <= 3){ |
394 | cuts[0] = 200; |
395 | cuts[1] = 0.8; |
396 | cuts[2] = 0.7; |
397 | cuts[3] = 500; |
398 | cuts[4] = -20000; |
399 | cuts[5] = 0.8; |
400 | } |
401 | else if (pt > 3 && pt <= 5){ |
402 | cuts[0] = 200; |
403 | cuts[1] = 0.8; |
404 | cuts[2] = 0.7; |
405 | cuts[3] = 500; |
406 | cuts[4] = -10000; |
407 | cuts[5] = 0.8; |
408 | } |
409 | else if (pt > 5){ |
410 | cuts[0] = 200; |
411 | cuts[1] = 0.8; |
412 | cuts[2] = 0.7; |
413 | cuts[3] = 500; |
414 | cuts[4] = -5000; |
415 | cuts[5] = 0.8; |
416 | } |
417 | if (dca*1E4 < cuts[0] |
418 | && TMath::Abs(cosThetaStar) < cuts[1] |
419 | && pTpi > cuts[2] |
420 | && pTK > cuts[2] |
421 | && TMath::Abs(d0pi*1E4) < cuts[3] |
422 | && TMath::Abs(d0K*1E4) < cuts[3] |
423 | && d0xd0*1E8 < cuts[4] |
424 | && cosPointingAngle > cuts[5] |
425 | ){ |
426 | |
427 | AliDebug(2,"Particle passed PPR cuts"); |
428 | fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoPPR) ; |
429 | icountRecoPPR++; |
430 | } |
431 | else{ |
432 | AliDebug(2,"Particle skipped due to PPR cuts"); |
433 | if (dca*1E4 > cuts[0]){ |
434 | AliDebug(2,"Problems with dca"); |
435 | } |
436 | if ( TMath::Abs(cosThetaStar) > cuts[1]){ |
437 | AliDebug(2,"Problems with cosThetaStar"); |
438 | } |
439 | if (pTpi < cuts[2]){ |
440 | AliDebug(2,"Problems with pTpi"); |
441 | } |
442 | if (pTK < cuts[2]){ |
443 | AliDebug(2,"Problems with pTK"); |
444 | } |
445 | if (TMath::Abs(d0pi*1E4) > cuts[3]){ |
446 | AliDebug(2,"Problems with d0pi"); |
447 | } |
448 | if (TMath::Abs(d0K*1E4) > cuts[3]){ |
449 | AliDebug(2,"Problems with d0K"); |
450 | } |
451 | if (d0xd0*1E8 > cuts[4]){ |
452 | AliDebug(2,"Problems with d0xd0"); |
453 | } |
454 | if (cosPointingAngle < cuts[5]){ |
455 | AliDebug(2,"Problems with cosPointingAngle"); |
456 | } |
457 | } |
458 | } |
459 | } |
460 | } |
1e090d47 |
461 | if(unsetvtx) d0tokpi->UnsetOwnPrimaryVtx(); |
462 | } // end loop on D0->Kpi |
f5ec6c30 |
463 | |
464 | AliDebug(2, Form("Found %i Reco particles that are D0!!",icountReco)); |
465 | |
466 | fCountReco+= icountReco; |
467 | fCountRecoAcc+= icountRecoAcc; |
468 | fCountRecoITSClusters+= icountRecoITSClusters; |
469 | fCountRecoPPR+= icountRecoPPR; |
470 | |
471 | fHistEventsProcessed->Fill(0); |
472 | /* PostData(0) is taken care of by AliAnalysisTaskSE */ |
473 | PostData(1,fHistEventsProcessed) ; |
474 | PostData(2,fCFManager->GetParticleContainer()) ; |
475 | } |
476 | |
477 | |
478 | //___________________________________________________________________________ |
479 | void AliCFHeavyFlavourTaskMultiVarMultiStep::Terminate(Option_t*) |
480 | { |
481 | // The Terminate() function is the last function to be called during |
482 | // a query. It always runs on the client, it can be used to present |
483 | // the results graphically or save the results to file. |
484 | |
485 | Info("Terminate",""); |
486 | AliAnalysisTaskSE::Terminate(); |
487 | |
488 | AliInfo(Form("Found %i MC particles that are D0 in MC, in %d events",fCountMC,fEvents)); |
489 | AliInfo(Form("Found %i MC particles that are D0 in MC and satisfy Acc cuts, in %d events",fCountAcc,fEvents)); |
490 | AliInfo(Form("Found %i reco D0 that are decaying in K+pi, in %d events",fCountReco,fEvents)); |
491 | AliInfo(Form("Among the above, found %i reco D0 that are decaying in K+pi and are in the requested acceptance, in %d events",fCountRecoAcc,fEvents)); |
492 | AliInfo(Form("Among the above, found %i reco D0 that are decaying in K+pi and have at least %d clusters in ITS, in %d events",fCountRecoITSClusters,fMinITSClusters,fEvents)); |
493 | AliInfo(Form("Among the above, found %i reco D0 that are decaying in K+pi and satisfy PPR cuts, in %d events",fCountRecoPPR,fEvents)); |
494 | |
495 | // draw some example plots.... |
496 | |
497 | AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2)); |
498 | |
499 | // projecting the containers to obtain histograms |
500 | // first argument = variable, second argument = step |
501 | |
502 | // MC-level |
503 | TH1D* h00 = cont->ShowProjection(0,0) ; // pt |
504 | TH1D* h10 = cont->ShowProjection(1,0) ; // rapidity |
505 | TH1D* h20 = cont->ShowProjection(2,0) ; // cosThetaStar |
506 | TH1D* h30 = cont->ShowProjection(3,0) ; // pTpi |
507 | TH1D* h40 = cont->ShowProjection(4,0) ; // pTK |
508 | TH1D* h50 = cont->ShowProjection(5,0) ; // cT |
509 | TH1D* h60 = cont->ShowProjection(6,0) ; // dca |
510 | TH1D* h70 = cont->ShowProjection(7,0) ; // d0pi |
511 | TH1D* h80 = cont->ShowProjection(8,0) ; // d0K |
512 | TH1D* h90 = cont->ShowProjection(9,0) ; // d0xd0 |
513 | TH1D* h100 = cont->ShowProjection(10,0) ; // cosPointingAngle |
514 | |
515 | // MC-Acceptance level |
516 | TH1D* h01 = cont->ShowProjection(0,1) ; // pt |
517 | TH1D* h11 = cont->ShowProjection(1,1) ; // rapidity |
518 | TH1D* h21 = cont->ShowProjection(2,1) ; // cosThetaStar |
519 | TH1D* h31 = cont->ShowProjection(3,1) ; // pTpi |
520 | TH1D* h41 = cont->ShowProjection(4,1) ; // pTK |
521 | TH1D* h51 = cont->ShowProjection(5,1) ; // cT |
522 | TH1D* h61 = cont->ShowProjection(6,1) ; // dca |
523 | TH1D* h71 = cont->ShowProjection(7,1) ; // d0pi |
524 | TH1D* h81 = cont->ShowProjection(8,1) ; // d0K |
525 | TH1D* h91 = cont->ShowProjection(9,1) ; // d0xd0 |
526 | TH1D* h101 = cont->ShowProjection(10,1) ; // cosPointingAngle |
527 | |
528 | // Reco-level |
529 | TH1D* h02 = cont->ShowProjection(0,2) ; // pt |
530 | TH1D* h12 = cont->ShowProjection(1,2) ; // rapidity |
531 | TH1D* h22 = cont->ShowProjection(2,2) ; // cosThetaStar |
532 | TH1D* h32 = cont->ShowProjection(3,2) ; // pTpi |
533 | TH1D* h42 = cont->ShowProjection(4,2) ; // pTK |
534 | TH1D* h52 = cont->ShowProjection(5,2) ; // cT |
535 | TH1D* h62 = cont->ShowProjection(6,2) ; // dca |
536 | TH1D* h72 = cont->ShowProjection(7,2) ; // d0pi |
537 | TH1D* h82 = cont->ShowProjection(8,2) ; // d0K |
538 | TH1D* h92 = cont->ShowProjection(9,2) ; // d0xd0 |
539 | TH1D* h102 = cont->ShowProjection(10,2) ; // cosPointingAngle |
540 | |
541 | h00->SetTitle("pT_D0 (GeV/c)"); |
542 | h10->SetTitle("rapidity"); |
543 | h20->SetTitle("cosThetaStar"); |
544 | h30->SetTitle("pT_pi (GeV/c)"); |
545 | h40->SetTitle("pT_K (Gev/c)"); |
546 | h50->SetTitle("cT (#mum)"); |
547 | h60->SetTitle("dca (#mum)"); |
548 | h70->SetTitle("d0_pi (#mum)"); |
549 | h80->SetTitle("d0_K (#mum)"); |
550 | h90->SetTitle("d0xd0 (#mum^2)"); |
551 | h100->SetTitle("cosPointingAngle"); |
552 | |
553 | h00->GetXaxis()->SetTitle("pT_D0 (GeV/c)"); |
554 | h10->GetXaxis()->SetTitle("rapidity"); |
555 | h20->GetXaxis()->SetTitle("cosThetaStar"); |
556 | h30->GetXaxis()->SetTitle("pT_pi (GeV/c)"); |
557 | h40->GetXaxis()->SetTitle("pT_K (Gev/c)"); |
558 | h50->GetXaxis()->SetTitle("cT (#mum)"); |
559 | h60->GetXaxis()->SetTitle("dca (#mum)"); |
560 | h70->GetXaxis()->SetTitle("d0_pi (#mum)"); |
561 | h80->GetXaxis()->SetTitle("d0_K (#mum)"); |
562 | h90->GetXaxis()->SetTitle("d0xd0 (#mum^2)"); |
563 | h100->GetXaxis()->SetTitle("cosPointingAngle"); |
564 | |
565 | h01->SetTitle("pT_D0 (GeV/c)"); |
566 | h11->SetTitle("rapidity"); |
567 | h21->SetTitle("cosThetaStar"); |
568 | h31->SetTitle("pT_pi (GeV/c)"); |
569 | h41->SetTitle("pT_K (Gev/c)"); |
570 | h51->SetTitle("cT (#mum)"); |
571 | h61->SetTitle("dca (#mum)"); |
572 | h71->SetTitle("d0_pi (#mum)"); |
573 | h81->SetTitle("d0_K (#mum)"); |
574 | h91->SetTitle("d0xd0 (#mum^2)"); |
575 | h101->SetTitle("cosPointingAngle"); |
576 | |
577 | h01->GetXaxis()->SetTitle("pT_D0 (GeV/c)"); |
578 | h11->GetXaxis()->SetTitle("rapidity"); |
579 | h21->GetXaxis()->SetTitle("cosThetaStar"); |
580 | h31->GetXaxis()->SetTitle("pT_pi (GeV/c)"); |
581 | h41->GetXaxis()->SetTitle("pT_K (Gev/c)"); |
582 | h51->GetXaxis()->SetTitle("cT (#mum)"); |
583 | h61->GetXaxis()->SetTitle("dca (#mum)"); |
584 | h71->GetXaxis()->SetTitle("d0_pi (#mum)"); |
585 | h81->GetXaxis()->SetTitle("d0_K (#mum)"); |
586 | h91->GetXaxis()->SetTitle("d0xd0 (#mum^2)"); |
587 | h101->GetXaxis()->SetTitle("cosPointingAngle"); |
588 | |
589 | h02->SetTitle("pT_D0 (GeV/c)"); |
590 | h12->SetTitle("rapidity"); |
591 | h22->SetTitle("cosThetaStar"); |
592 | h32->SetTitle("pT_pi (GeV/c)"); |
593 | h42->SetTitle("pT_K (Gev/c)"); |
594 | h52->SetTitle("cT (#mum)"); |
595 | h62->SetTitle("dca (#mum)"); |
596 | h72->SetTitle("d0_pi (#mum)"); |
597 | h82->SetTitle("d0_K (#mum)"); |
598 | h92->SetTitle("d0xd0 (#mum^2)"); |
599 | h102->SetTitle("cosPointingAngle"); |
600 | |
601 | h02->GetXaxis()->SetTitle("pT_D0 (GeV/c)"); |
602 | h12->GetXaxis()->SetTitle("rapidity"); |
603 | h22->GetXaxis()->SetTitle("cosThetaStar"); |
604 | h32->GetXaxis()->SetTitle("pT_pi (GeV/c)"); |
605 | h42->GetXaxis()->SetTitle("pT_K (Gev/c)"); |
606 | h52->GetXaxis()->SetTitle("cT (#mum)"); |
607 | h62->GetXaxis()->SetTitle("dca (#mum)"); |
608 | h72->GetXaxis()->SetTitle("d0_pi (#mum)"); |
609 | h82->GetXaxis()->SetTitle("d0_K (#mum)"); |
610 | h92->GetXaxis()->SetTitle("d0xd0 (#mum^2)"); |
611 | h102->GetXaxis()->SetTitle("cosPointingAngle"); |
612 | |
613 | Double_t max0 = h00->GetMaximum(); |
614 | Double_t max1 = h10->GetMaximum(); |
615 | Double_t max2 = h20->GetMaximum(); |
616 | Double_t max3 = h30->GetMaximum(); |
617 | Double_t max4 = h40->GetMaximum(); |
618 | Double_t max5 = h50->GetMaximum(); |
619 | Double_t max6 = h60->GetMaximum(); |
620 | Double_t max7 = h70->GetMaximum(); |
621 | Double_t max8 = h80->GetMaximum(); |
622 | Double_t max9 = h90->GetMaximum(); |
623 | Double_t max10 = h100->GetMaximum(); |
624 | |
625 | h00->GetYaxis()->SetRangeUser(0,max0*1.2); |
626 | h10->GetYaxis()->SetRangeUser(0,max1*1.2); |
627 | h20->GetYaxis()->SetRangeUser(0,max2*1.2); |
628 | h30->GetYaxis()->SetRangeUser(0,max3*1.2); |
629 | h40->GetYaxis()->SetRangeUser(0,max4*1.2); |
630 | h50->GetYaxis()->SetRangeUser(0,max5*1.2); |
631 | h60->GetYaxis()->SetRangeUser(0,max6*1.2); |
632 | h70->GetYaxis()->SetRangeUser(0,max7*1.2); |
633 | h80->GetYaxis()->SetRangeUser(0,max8*1.2); |
634 | h90->GetYaxis()->SetRangeUser(0,max9*1.2); |
635 | h100->GetYaxis()->SetRangeUser(0,max10*1.2); |
636 | |
637 | h01->GetYaxis()->SetRangeUser(0,max0*1.2); |
638 | h11->GetYaxis()->SetRangeUser(0,max1*1.2); |
639 | h21->GetYaxis()->SetRangeUser(0,max2*1.2); |
640 | h31->GetYaxis()->SetRangeUser(0,max3*1.2); |
641 | h41->GetYaxis()->SetRangeUser(0,max4*1.2); |
642 | h51->GetYaxis()->SetRangeUser(0,max5*1.2); |
643 | h61->GetYaxis()->SetRangeUser(0,max6*1.2); |
644 | h71->GetYaxis()->SetRangeUser(0,max7*1.2); |
645 | h81->GetYaxis()->SetRangeUser(0,max8*1.2); |
646 | h91->GetYaxis()->SetRangeUser(0,max9*1.2); |
647 | h101->GetYaxis()->SetRangeUser(0,max10*1.2); |
648 | |
649 | h00->SetMarkerStyle(20); |
650 | h10->SetMarkerStyle(24); |
651 | h20->SetMarkerStyle(21); |
652 | h30->SetMarkerStyle(25); |
653 | h40->SetMarkerStyle(27); |
654 | h50->SetMarkerStyle(28); |
655 | h60->SetMarkerStyle(20); |
656 | h70->SetMarkerStyle(24); |
657 | h80->SetMarkerStyle(21); |
658 | h90->SetMarkerStyle(25); |
659 | h100->SetMarkerStyle(27); |
660 | |
661 | h00->SetMarkerColor(2); |
662 | h10->SetMarkerColor(2); |
663 | h20->SetMarkerColor(2); |
664 | h30->SetMarkerColor(2); |
665 | h40->SetMarkerColor(2); |
666 | h50->SetMarkerColor(2); |
667 | h60->SetMarkerColor(2); |
668 | h70->SetMarkerColor(2); |
669 | h80->SetMarkerColor(2); |
670 | h90->SetMarkerColor(2); |
671 | h100->SetMarkerColor(2); |
672 | |
673 | h01->SetMarkerStyle(20) ; |
674 | h11->SetMarkerStyle(24) ; |
675 | h21->SetMarkerStyle(21) ; |
676 | h31->SetMarkerStyle(25) ; |
677 | h41->SetMarkerStyle(27) ; |
678 | h51->SetMarkerStyle(28) ; |
679 | h61->SetMarkerStyle(20); |
680 | h71->SetMarkerStyle(24); |
681 | h81->SetMarkerStyle(21); |
682 | h91->SetMarkerStyle(25); |
683 | h101->SetMarkerStyle(27); |
684 | |
685 | h01->SetMarkerColor(8); |
686 | h11->SetMarkerColor(8); |
687 | h21->SetMarkerColor(8); |
688 | h31->SetMarkerColor(8); |
689 | h41->SetMarkerColor(8); |
690 | h51->SetMarkerColor(8); |
691 | h61->SetMarkerColor(8); |
692 | h71->SetMarkerColor(8); |
693 | h81->SetMarkerColor(8); |
694 | h91->SetMarkerColor(8); |
695 | h101->SetMarkerColor(8); |
696 | |
697 | h02->SetMarkerStyle(20) ; |
698 | h12->SetMarkerStyle(24) ; |
699 | h22->SetMarkerStyle(21) ; |
700 | h32->SetMarkerStyle(25) ; |
701 | h42->SetMarkerStyle(27) ; |
702 | h52->SetMarkerStyle(28) ; |
703 | h62->SetMarkerStyle(20); |
704 | h72->SetMarkerStyle(24); |
705 | h82->SetMarkerStyle(21); |
706 | h92->SetMarkerStyle(25); |
707 | h102->SetMarkerStyle(27); |
708 | |
709 | h02->SetMarkerColor(4); |
710 | h12->SetMarkerColor(4); |
711 | h22->SetMarkerColor(4); |
712 | h32->SetMarkerColor(4); |
713 | h42->SetMarkerColor(4); |
714 | h52->SetMarkerColor(4); |
715 | h62->SetMarkerColor(4); |
716 | h72->SetMarkerColor(4); |
717 | h82->SetMarkerColor(4); |
718 | h92->SetMarkerColor(4); |
719 | h102->SetMarkerColor(4); |
720 | |
721 | gStyle->SetCanvasColor(0); |
722 | gStyle->SetFrameFillColor(0); |
723 | gStyle->SetTitleFillColor(0); |
724 | gStyle->SetStatColor(0); |
725 | |
726 | // drawing in 2 separate canvas for a matter of clearity |
727 | TCanvas * c1 =new TCanvas("c1","pT, rapidiy, cosThetaStar",1100,1600); |
728 | c1->Divide(3,3); |
729 | |
730 | c1->cd(1); |
731 | h00->Draw("p"); |
732 | c1->cd(1); |
733 | c1->cd(2); |
734 | h01->Draw("p"); |
735 | c1->cd(2); |
736 | c1->cd(3); |
737 | h02->Draw("p"); |
738 | c1->cd(3); |
739 | c1->cd(4); |
740 | h10->Draw("p"); |
741 | c1->cd(4); |
742 | c1->cd(5); |
743 | h11->Draw("p"); |
744 | c1->cd(5); |
745 | c1->cd(6); |
746 | h12->Draw("p"); |
747 | c1->cd(6); |
748 | c1->cd(7); |
749 | h20->Draw("p"); |
750 | c1->cd(7); |
751 | c1->cd(8); |
752 | h21->Draw("p"); |
753 | c1->cd(8); |
754 | c1->cd(9); |
755 | h22->Draw("p"); |
756 | c1->cd(9); |
757 | c1->cd(); |
758 | |
759 | TCanvas * c2 =new TCanvas("c2","pTpi, pTK, cT",1100,1600); |
760 | c2->Divide(3,3); |
761 | c2->cd(1); |
762 | h30->Draw("p"); |
763 | c2->cd(1); |
764 | c2->cd(2); |
765 | h31->Draw("p"); |
766 | c2->cd(2); |
767 | c2->cd(3); |
768 | h32->Draw("p"); |
769 | c2->cd(3); |
770 | c2->cd(4); |
771 | h40->Draw("p"); |
772 | c2->cd(4); |
773 | c2->cd(5); |
774 | h41->Draw("p"); |
775 | c2->cd(5); |
776 | c2->cd(6); |
777 | h42->Draw("p"); |
778 | c2->cd(6); |
779 | c2->cd(7); |
780 | h50->Draw("p"); |
781 | c2->cd(7); |
782 | c2->cd(8); |
783 | h51->Draw("p"); |
784 | c2->cd(8); |
785 | c2->cd(9); |
786 | h52->Draw("p"); |
787 | c2->cd(9); |
788 | c2->cd(); |
789 | |
790 | TCanvas * c3 =new TCanvas("c3","dca, d0pi, d0K",1100,1600); |
791 | c3->Divide(3,3); |
792 | c3->cd(1); |
793 | h60->Draw("p"); |
794 | c3->cd(1); |
795 | c3->cd(2); |
796 | h61->Draw("p"); |
797 | c3->cd(2); |
798 | c3->cd(3); |
799 | h62->Draw("p"); |
800 | c3->cd(3); |
801 | c3->cd(4); |
802 | h70->Draw("p"); |
803 | c3->cd(4); |
804 | c3->cd(5); |
805 | h71->Draw("p"); |
806 | c3->cd(5); |
807 | c3->cd(6); |
808 | h72->Draw("p"); |
809 | c3->cd(6); |
810 | c3->cd(7); |
811 | h80->Draw("p"); |
812 | c3->cd(7); |
813 | c3->cd(8); |
814 | h81->Draw("p"); |
815 | c3->cd(8); |
816 | c3->cd(9); |
817 | h82->Draw("p"); |
818 | c3->cd(9); |
819 | c3->cd(); |
820 | |
821 | TCanvas * c4 =new TCanvas("c4","d0xd0, cosPointingAngle",1100,770); |
822 | c4->Divide(3,2); |
823 | c4->cd(1); |
824 | h90->Draw("p"); |
825 | c4->cd(1); |
826 | c4->cd(2); |
827 | h91->Draw("p"); |
828 | c4->cd(2); |
829 | c4->cd(3); |
830 | h92->Draw("p"); |
831 | c4->cd(3); |
832 | c4->cd(4); |
833 | h100->Draw("p"); |
834 | c4->cd(4); |
835 | c4->cd(5); |
836 | h101->Draw("p"); |
837 | c4->cd(5); |
838 | c4->cd(6); |
839 | h102->Draw("p"); |
840 | c4->cd(6); |
841 | c4->cd(); |
842 | |
843 | /* |
844 | c1->SaveAs("Plots/pT_rapidity_cosThetaStar.eps"); |
845 | c2->SaveAs("Plots/pTpi_pTK_cT.eps"); |
846 | c3->SaveAs("Plots/dca_d0pi_d0TK.eps"); |
847 | c4->SaveAs("Plots/d0xd0_cosPointingAngle.eps"); |
848 | |
849 | c1->SaveAs("Plots/pT_rapidity_cosThetaStar.gif"); |
850 | c2->SaveAs("Plots/pTpi_pTK_cT.gif"); |
851 | c3->SaveAs("Plots/dca_d0pi_d0TK.gif"); |
852 | c4->SaveAs("Plots/d0xd0_cosPointingAngle.gif"); |
853 | */ |
854 | } |
855 | |
856 | //___________________________________________________________________________ |
857 | void AliCFHeavyFlavourTaskMultiVarMultiStep::UserCreateOutputObjects() { |
858 | //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED |
859 | //TO BE SET BEFORE THE EXECUTION OF THE TASK |
860 | // |
861 | Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName()); |
862 | |
863 | //slot #1 |
864 | OpenFile(1); |
865 | fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ; |
866 | } |
867 | |
868 | //___________________________________________________________________________ |
869 | Double_t AliCFHeavyFlavourTaskMultiVarMultiStep::CosThetaStar(AliAODMCParticle* mcPart, AliAODMCParticle* mcPartDaughter0, AliAODMCParticle* mcPartDaughter1) const { |
870 | |
871 | // |
872 | // to calculate cos(ThetaStar) for generated particle |
873 | // using the K, since mcPartDaughter0 and mcPartDaughter1 always correspond to K and pi respectively |
874 | // (see where the function is called) |
875 | // |
876 | |
877 | Int_t pdgvtx = mcPart->GetPdgCode(); |
878 | /* if (pdgvtx > 0) { // setting as the first daughter always the kaon, to be used to calculate cos(ThetaStar) |
879 | Int_t pdgprong0 = TMath::Abs(mcPartDaughter0->GetPdgCode()); |
880 | Int_t pdgprong1 = TMath::Abs(mcPartDaughter1->GetPdgCode()); |
881 | AliInfo(Form("D0, with pdgprong0 = %d, pdgprong1 = %d",pdgprong0,pdgprong1)); |
882 | AliDebug(2,"This is a D0"); |
883 | AliAODMCParticle* mcPartdummy = mcPartDaughter0; |
884 | mcPartDaughter0 = mcPartDaughter1; |
885 | mcPartDaughter1 = mcPartdummy; |
886 | } |
887 | else{ |
888 | AliInfo("D0bar"); |
889 | } |
890 | */ |
891 | Int_t pdgprong0 = TMath::Abs(mcPartDaughter0->GetPdgCode()); |
892 | Int_t pdgprong1 = TMath::Abs(mcPartDaughter1->GetPdgCode()); |
893 | if (pdgvtx > 0) { // setting as the first daughter always the kaon, to be used to calculate cos(ThetaStar) |
894 | AliDebug(2,"D0"); |
895 | } |
896 | else{ |
897 | AliDebug(2,"D0bar"); |
898 | } |
899 | if (pdgprong0 == 211){ |
900 | AliDebug(2,Form("pdgprong0 = %d, pdgprong1 = %d, switching...",pdgprong0,pdgprong1)); |
901 | AliAODMCParticle* mcPartdummy = mcPartDaughter0; |
902 | mcPartDaughter0 = mcPartDaughter1; |
903 | mcPartDaughter1 = mcPartdummy; |
904 | pdgprong0 = TMath::Abs(mcPartDaughter0->GetPdgCode()); |
905 | pdgprong1 = TMath::Abs(mcPartDaughter1->GetPdgCode()); |
906 | } |
907 | |
908 | AliDebug(2,Form("After checking, pdgprong0 = %d, pdgprong1 = %d",pdgprong0,pdgprong1)); |
909 | Double_t massvtx = TDatabasePDG::Instance()->GetParticle(TMath::Abs(pdgvtx))->Mass(); |
910 | Double_t massp[2]; |
911 | massp[0] = TDatabasePDG::Instance()->GetParticle(pdgprong0)->Mass(); |
912 | massp[1] = TDatabasePDG::Instance()->GetParticle(pdgprong1)->Mass(); |
913 | |
914 | Double_t pStar = TMath::Sqrt(TMath::Power(massvtx*massvtx-massp[0]*massp[0]-massp[1]*massp[1],2.)-4.*massp[0]*massp[0]*massp[1]*massp[1])/(2.*massvtx); |
915 | |
916 | Double_t px = mcPartDaughter0->Px()+mcPartDaughter1->Px(); |
917 | Double_t py = mcPartDaughter0->Py()+mcPartDaughter1->Py(); |
918 | Double_t pz = mcPartDaughter0->Pz()+mcPartDaughter1->Pz(); |
919 | Double_t p = TMath::Sqrt(px*px+py*py+pz*pz); |
920 | Double_t e = TMath::Sqrt(massvtx*massvtx+p*p); |
921 | Double_t beta = p/e; |
922 | Double_t gamma = e/massvtx; |
923 | TVector3 mom(mcPartDaughter0->Px(),mcPartDaughter0->Py(),mcPartDaughter0->Pz()); |
924 | TVector3 momTot(mcPartDaughter0->Px()+mcPartDaughter1->Px(),mcPartDaughter0->Py()+mcPartDaughter1->Py(),mcPartDaughter0->Pz()+mcPartDaughter1->Pz()); |
925 | |
926 | Double_t qlprong = mom.Dot(momTot)/momTot.Mag(); // analog to AliAODRecoDecay::QlProng(0) |
927 | |
928 | AliDebug(2,Form("pStar = %f, beta = %f, gamma = %f, qlprong = %f, massp[0] = %f", pStar, beta, gamma, qlprong, massp[0])); |
929 | Double_t cts = (qlprong/gamma-beta*TMath::Sqrt(pStar*pStar+massp[0]*massp[0]))/pStar; |
930 | AliDebug(2,Form("cts = %f", cts)); |
931 | return cts; |
932 | } |
933 | //___________________________________________________________________________ |
934 | Double_t AliCFHeavyFlavourTaskMultiVarMultiStep::CT(AliAODMCParticle* mcPart, AliAODMCParticle* mcPartDaughter0, AliAODMCParticle* mcPartDaughter1) const { |
935 | |
936 | // |
937 | // to calculate cT for generated particle |
938 | // |
939 | |
940 | Double_t xmcPart[3] = {0,0,0}; |
941 | Double_t xdaughter0[3] = {0,0,0}; |
942 | Double_t xdaughter1[3] = {0,0,0}; |
943 | mcPart->XvYvZv(xmcPart); // cm |
944 | mcPartDaughter0->XvYvZv(xdaughter0); // cm |
945 | mcPartDaughter1->XvYvZv(xdaughter1); //cm |
946 | Double_t prodVtxD0 = TMath::Sqrt(xmcPart[0]*xmcPart[0]+ |
947 | xmcPart[1]*xmcPart[1]+ |
948 | xmcPart[2]*xmcPart[2]); |
949 | Double_t prodVtxDaughter0 = TMath::Sqrt(xdaughter0[0]*xdaughter0[0]+ |
950 | xdaughter0[1]*xdaughter0[1]+ |
951 | xdaughter0[2]*xdaughter0[2]); |
952 | Double_t prodVtxDaughter1 = TMath::Sqrt(xdaughter1[0]*xdaughter1[0]+ |
953 | xdaughter1[1]*xdaughter1[1]+ |
954 | xdaughter1[2]*xdaughter1[2]); |
955 | |
956 | AliDebug(2, Form("D0: x = %f, y = %f, z = %f, production vertex distance = %f (cm), %f (micron)", xmcPart[0], xmcPart[1], xmcPart[2], prodVtxD0, prodVtxD0*1.E4)); |
957 | AliDebug(2, Form("Daughter0: x = %f, y = %f, z = %f, production vertex distance = %f (cm) %f (micron)", xdaughter0[0], xdaughter0[1], xdaughter0[2], prodVtxDaughter0, prodVtxDaughter0*1E4)); |
958 | AliDebug(2, Form("Daughter1: x = %f, y = %f, z = %f, production vertex distance = %f (cm) %f (micron)", xdaughter1[0], xdaughter1[1], xdaughter1[2], prodVtxDaughter1, prodVtxDaughter1*1.E4)); |
959 | |
960 | Double_t cT0 = TMath::Sqrt((xdaughter0[0]-xmcPart[0])*(xdaughter0[0]-xmcPart[0])+ |
961 | (xdaughter0[1]-xmcPart[1])*(xdaughter0[1]-xmcPart[1])+ |
962 | (xdaughter0[2]-xmcPart[2])*(xdaughter0[2]-xmcPart[2])); |
963 | |
964 | Double_t cT1 = TMath::Sqrt((xdaughter1[0]-xmcPart[0])*(xdaughter1[0]-xmcPart[0])+ |
965 | (xdaughter1[1]-xmcPart[1])*(xdaughter1[1]-xmcPart[1])+ |
966 | (xdaughter1[2]-xmcPart[2])*(xdaughter1[2]-xmcPart[2])); |
967 | |
968 | if (cT0 != cT1) { |
969 | AliWarning("cT from daughter 0 different from cT from daughter 1! Using cT from daughter 0, but PLEASE, CHECK...."); |
970 | } |
971 | |
972 | // calculating cT from cT0 |
973 | |
974 | Double_t mass = TDatabasePDG::Instance()->GetParticle(mcPart->GetPdgCode())->Mass(); // mcPart->GetPdgCode() should return +/- 421 for the D0/D0bar |
975 | Double_t p = mcPart-> P(); |
976 | Double_t cT = cT0*mass/p; |
977 | AliDebug(2, Form("cT from daughter 0 = %f (micron)", cT0*1E4)); |
978 | AliDebug(2, Form("cT from daughter 1 = %f (micron)", cT1*1E4)); |
979 | AliDebug(2, Form("cT (with mass = %f and p = %f) = %f (micron)", mass, p, cT*1E4)); |
980 | return cT; |
981 | } |
982 | //________________________________________________________________________________ |
983 | Bool_t AliCFHeavyFlavourTaskMultiVarMultiStep::GetGeneratedValuesFromMCParticle(AliAODMCParticle* mcPart, TClonesArray* mcArray, Double_t* vectorMC) const { |
984 | |
985 | // |
986 | // collecting all the necessary info (pt, y, cosThetaStar, ptPi, ptKa, cT) from MC particle |
987 | // |
988 | |
989 | Bool_t isOk = kFALSE; |
990 | |
991 | // check whether the D0 decays in pi+K |
992 | // to be added!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
993 | // could use a cut in the CF, but not clear how to define a TDecayChannel |
994 | // implemented for the time being as a cut on the number of daughters - see later when |
995 | // getting the daughters |
996 | |
997 | // getting the daughters |
998 | Int_t daughter0 = mcPart->GetDaughter(0); |
999 | Int_t daughter1 = mcPart->GetDaughter(1); |
1000 | AliDebug(2, Form("daughter0 = %d and daughter1 = %d",daughter0,daughter1)); |
1001 | if (daughter0 == 0 || daughter1 == 0) { |
1002 | AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!"); |
1003 | return isOk; |
1004 | } |
1005 | if (TMath::Abs(daughter1 - daughter0 != 1)) { |
1006 | AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, skipping!!"); |
1007 | return isOk; |
1008 | } |
1009 | AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter0)); |
1010 | AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter1)); |
1011 | if (!mcPartDaughter0 || !mcPartDaughter1) { |
1012 | AliWarning("At least one Daughter Particle not found in tree, skipping"); |
1013 | return isOk; |
1014 | } |
1015 | |
1016 | Double_t vtx1[3] = {0,0,0}; // primary vertex |
1017 | Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0 |
1018 | Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1 |
1019 | mcPart->XvYvZv(vtx1); // cm |
1020 | // getting vertex from daughters |
1021 | mcPartDaughter0->XvYvZv(vtx2daughter0); // cm |
1022 | mcPartDaughter1->XvYvZv(vtx2daughter1); //cm |
1023 | if (vtx2daughter0[0] != vtx2daughter1[0] && vtx2daughter0[1] != vtx2daughter1[1] && vtx2daughter0[2] != vtx2daughter1[2]) { |
1024 | AliError("Daughters have different secondary vertex, skipping the track"); |
1025 | return isOk; |
1026 | } |
1027 | Int_t nprongs = 2; |
1028 | Short_t charge = 0; |
1029 | // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second |
1030 | AliAODMCParticle* positiveDaugh = mcPartDaughter0; |
1031 | AliAODMCParticle* negativeDaugh = mcPartDaughter1; |
1032 | if (mcPartDaughter0->GetPdgCode()<0 && mcPartDaughter1->GetPdgCode()>0){ |
1033 | // inverting in case the positive daughter is the second one |
1034 | positiveDaugh = mcPartDaughter1; |
1035 | negativeDaugh = mcPartDaughter0; |
1036 | } |
1037 | // getting the momentum from the daughters |
1038 | Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()}; |
1039 | Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()}; |
1040 | Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()}; |
1041 | |
1042 | Double_t d0[2] = {0.,0.}; |
1043 | |
1044 | AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1,vtx2daughter0,nprongs,charge,px,py,pz,d0); |
1045 | |
1046 | Double_t cosThetaStar = 0.; |
1047 | Double_t cosThetaStarD0 = 0.; |
1048 | Double_t cosThetaStarD0bar = 0.; |
1049 | cosThetaStarD0 = decay->CosThetaStar(1,421,211,321); |
1050 | cosThetaStarD0bar = decay->CosThetaStar(0,421,321,211); |
1051 | if (mcPart->GetPdgCode() == 421){ // D0 |
1052 | AliDebug(3, Form("D0, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode())); |
1053 | cosThetaStar = cosThetaStarD0; |
1054 | } |
1055 | else if (mcPart->GetPdgCode() == -421){ // D0bar{ |
1056 | AliDebug(3, Form("D0bar, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode())); |
1057 | cosThetaStar = cosThetaStarD0bar; |
1058 | } |
1059 | else{ |
1060 | AliWarning("There are problems!! particle was expected to be either a D0 or a D0bar, check..."); |
1061 | return vectorMC; |
1062 | } |
1063 | if (cosThetaStar < -1 || cosThetaStar > 1) { |
1064 | AliWarning("Invalid value for cosine Theta star, returning"); |
1065 | return isOk; |
1066 | } |
1067 | |
1068 | // calculate cos(Theta*) according to the method implemented herein |
1069 | |
1070 | Double_t cts = 9999.; |
1071 | cts = CosThetaStar(mcPart, mcPartDaughter0, mcPartDaughter1); |
1072 | if (cts < -1 || cts > 1) { |
1073 | AliWarning("Invalid value for cosine Theta star from AliCFHeavyFlavourTaskMultiVarMultiStep method"); |
1074 | } |
1075 | if (TMath::Abs(cts - cosThetaStar)>0.001) { |
1076 | AliError(Form("cosThetaStar automatically calculated different from that manually calculated!!! cosThetaStar = %f, cosThetaStar = %f", cosThetaStar,cts)); |
1077 | } |
1078 | |
1079 | Double_t cT = decay->Ct(421); |
1080 | |
1081 | // calculate cT from the method implemented herein |
1082 | Double_t cT1 = 0.; |
1083 | cT1 = CT(mcPart, mcPartDaughter0, mcPartDaughter1); |
1084 | |
1085 | if (TMath::Abs(cT1 - cT)>0.001) { |
1086 | AliError(Form("cT automatically calculated different from that manually calculated!!! cT = %f, cT1 = %f",cT,cT1)); |
1087 | } |
1088 | |
1089 | // get the pT of the daughters |
1090 | |
1091 | Double_t pTpi = 0.; |
1092 | Double_t pTK = 0.; |
1093 | |
1094 | if (TMath::Abs(mcPartDaughter0->GetPdgCode()) == 211) { |
1095 | pTpi = mcPartDaughter0->Pt(); |
1096 | pTK = mcPartDaughter1->Pt(); |
1097 | } |
1098 | else { |
1099 | pTpi = mcPartDaughter1->Pt(); |
1100 | pTK = mcPartDaughter0->Pt(); |
1101 | } |
1102 | |
1103 | vectorMC[0] = mcPart->Pt(); |
1104 | vectorMC[1] = mcPart->Y() ; |
1105 | vectorMC[2] = cosThetaStar ; |
1106 | vectorMC[3] = pTpi ; |
1107 | vectorMC[4] = pTK ; |
1108 | vectorMC[5] = cT*1.E4 ; // in micron |
1109 | isOk = kTRUE; |
1110 | return isOk; |
1111 | } |
1112 | |