]>
Commit | Line | Data |
---|---|---|
3a219f60 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2008, 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 | // | |
18 | // AliAnalysisTaskSE for the comparison of heavy flavor | |
19 | // decay candidates with the MC truth. | |
20 | // | |
21 | // Author: A.Dainese, andrea.dainese@lnl.infn.it | |
22 | ///////////////////////////////////////////////////////////// | |
23 | ||
24 | #include <TClonesArray.h> | |
25 | #include <TNtuple.h> | |
26 | #include <TList.h> | |
27 | #include <TH1F.h> | |
28 | ||
29 | #include "AliAODEvent.h" | |
30 | #include "AliAODVertex.h" | |
31 | #include "AliAODTrack.h" | |
32 | #include "AliAODMCHeader.h" | |
33 | #include "AliAODMCParticle.h" | |
34 | #include "AliAODRecoDecayHF2Prong.h" | |
b3999999 | 35 | #include "AliAODRecoCascadeHF.h" |
2ae9c7cb | 36 | #include "AliAnalysisVertexingHF.h" |
3a219f60 | 37 | #include "AliAnalysisTaskSE.h" |
38 | #include "AliAnalysisTaskSECompareHF.h" | |
39 | ||
40 | ClassImp(AliAnalysisTaskSECompareHF) | |
41 | ||
42 | ||
43 | //________________________________________________________________________ | |
44 | AliAnalysisTaskSECompareHF::AliAnalysisTaskSECompareHF(): | |
45 | AliAnalysisTaskSE(), | |
46 | fOutput(0), | |
2a041947 | 47 | fNtupleCmp(0), |
12bfc069 | 48 | fHistMass(0), |
49 | fVHF(0) | |
3a219f60 | 50 | { |
51 | // Default constructor | |
3a219f60 | 52 | |
9d6d35b0 | 53 | // NO DefineOutput() HERE (ONLY IN STANDARD CONSTRUCTOR) |
3a219f60 | 54 | } |
55 | ||
56 | //________________________________________________________________________ | |
57 | AliAnalysisTaskSECompareHF::AliAnalysisTaskSECompareHF(const char *name): | |
58 | AliAnalysisTaskSE(name), | |
59 | fOutput(0), | |
2a041947 | 60 | fNtupleCmp(0), |
12bfc069 | 61 | fHistMass(0), |
62 | fVHF(0) | |
3a219f60 | 63 | { |
9d6d35b0 | 64 | // Standard constructor |
3a219f60 | 65 | |
66 | // Output slot #1 writes into a TList container | |
67 | DefineOutput(1,TList::Class()); //My private output | |
10bdd1ae | 68 | // Output slot #2 writes into a TNtuple container |
69 | DefineOutput(2,TNtuple::Class()); //My private output | |
3a219f60 | 70 | } |
71 | ||
72 | //________________________________________________________________________ | |
73 | AliAnalysisTaskSECompareHF::~AliAnalysisTaskSECompareHF() | |
74 | { | |
75 | // Destructor | |
76 | if (fOutput) { | |
77 | delete fOutput; | |
78 | fOutput = 0; | |
79 | } | |
12bfc069 | 80 | if (fVHF) { |
81 | delete fVHF; | |
82 | fVHF = 0; | |
83 | } | |
3a219f60 | 84 | } |
85 | ||
86 | //________________________________________________________________________ | |
87 | void AliAnalysisTaskSECompareHF::Init() | |
88 | { | |
89 | // Initialization | |
90 | ||
91 | if(fDebug > 1) printf("AnalysisTaskSECompareHF::Init() \n"); | |
9d6d35b0 | 92 | |
12bfc069 | 93 | gROOT->LoadMacro("ConfigVertexingHF.C"); |
94 | ||
95 | fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()"); | |
96 | fVHF->PrintStatus(); | |
9d6d35b0 | 97 | |
3a219f60 | 98 | return; |
99 | } | |
100 | ||
101 | //________________________________________________________________________ | |
102 | void AliAnalysisTaskSECompareHF::UserCreateOutputObjects() | |
103 | { | |
104 | // Create the output container | |
105 | // | |
106 | if(fDebug > 1) printf("AnalysisTaskSECompareHF::UserCreateOutputObjects() \n"); | |
107 | ||
108 | // Several histograms are more conveniently managed in a TList | |
109 | fOutput = new TList(); | |
110 | fOutput->SetOwner(); | |
111 | ||
112 | fHistMass = new TH1F("fHistMass", "D^{0} invariant mass; M [GeV]; Entries",200,1.765,1.965); | |
113 | fHistMass->Sumw2(); | |
114 | fHistMass->SetMinimum(0); | |
115 | fOutput->Add(fHistMass); | |
116 | ||
2a041947 | 117 | fNtupleCmp = new TNtuple("fNtupleCmp","Charm comparison","pdg:nprongs:VxRec:VxTrue:ErrVx:VyRec:VyTrue:ErrVy:VzRec:VzTrue:ErrVz:Chi2toNDF:PtRec:Mrec"); |
3a219f60 | 118 | |
119 | return; | |
120 | } | |
121 | ||
122 | //________________________________________________________________________ | |
123 | void AliAnalysisTaskSECompareHF::UserExec(Option_t */*option*/) | |
124 | { | |
125 | // Execute analysis for current event: | |
126 | // heavy flavor candidates association to MC truth | |
9d6d35b0 | 127 | |
3a219f60 | 128 | |
129 | AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent()); | |
9d6d35b0 | 130 | |
2a041947 | 131 | |
132 | // load HF vertices | |
133 | TClonesArray *inputArrayVertices = | |
134 | (TClonesArray*)aod->GetList()->FindObject("VerticesHF"); | |
135 | if(!inputArrayVertices) { | |
136 | printf("AliAnalysisTaskSECompareHF::UserExec: Vertices branch not found!\n"); | |
137 | return; | |
138 | } | |
139 | ||
3a219f60 | 140 | // load D0->Kpi candidates |
141 | TClonesArray *inputArrayD0toKpi = | |
142 | (TClonesArray*)aod->GetList()->FindObject("D0toKpi"); | |
143 | if(!inputArrayD0toKpi) { | |
144 | printf("AliAnalysisTaskSECompareHF::UserExec: D0toKpi branch not found!\n"); | |
145 | return; | |
146 | } | |
147 | ||
9d6d35b0 | 148 | |
b3999999 | 149 | // load D*+ candidates |
150 | TClonesArray *inputArrayDstar = | |
151 | (TClonesArray*)aod->GetList()->FindObject("Dstar"); | |
152 | if(!inputArrayDstar) { | |
153 | printf("AliAnalysisTaskSECompareHF::UserExec: Dstar branch not found!\n"); | |
154 | return; | |
155 | } | |
9d6d35b0 | 156 | |
b3999999 | 157 | |
3a219f60 | 158 | // AOD primary vertex |
159 | AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex(); | |
160 | //vtx1->Print(); | |
161 | ||
162 | // load MC particles | |
163 | TClonesArray *mcArray = | |
164 | (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()); | |
165 | if(!mcArray) { | |
166 | printf("AliAnalysisTaskSECompareHF::UserExec: MC particles branch not found!\n"); | |
167 | return; | |
168 | } | |
169 | ||
170 | // load MC header | |
171 | AliAODMCHeader *mcHeader = | |
172 | (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName()); | |
173 | if(!mcHeader) { | |
174 | printf("AliAnalysisTaskSECompareHF::UserExec: MC header branch not found!\n"); | |
175 | return; | |
176 | } | |
177 | ||
2a041947 | 178 | Int_t nprongs,lab,okD0,okD0bar,pdg; |
179 | Bool_t unsetvtx; | |
180 | Double_t invmass,cov[6],errx,erry,errz; | |
952f1e33 | 181 | AliAODRecoDecayHF2Prong *d2=0; |
182 | AliAODRecoDecayHF3Prong *d3=0; | |
183 | AliAODRecoDecayHF4Prong *d4=0; | |
2a041947 | 184 | |
185 | // loop over vertices | |
186 | Int_t nVertices = inputArrayVertices->GetEntriesFast(); | |
187 | printf("Number of vertices: %d\n",nVertices); | |
188 | ||
189 | for (Int_t iVtx = 0; iVtx < nVertices; iVtx++) { | |
190 | AliAODVertex *vtx = (AliAODVertex*)inputArrayVertices->UncheckedAt(iVtx); | |
191 | ||
192 | // get parent AliAODRecoDecayHF | |
193 | nprongs= vtx->GetNDaughters(); | |
194 | ||
195 | switch(nprongs) { | |
196 | case 2: // look for D0->Kpi | |
952f1e33 | 197 | d2 = (AliAODRecoDecayHF2Prong*)vtx->GetParent(); |
2a041947 | 198 | lab = d2->MatchToMC(421,mcArray); |
199 | if(lab>=0) { | |
200 | unsetvtx=kFALSE; | |
201 | if(!d2->GetOwnPrimaryVtx()) { | |
202 | d2->SetOwnPrimaryVtx(vtx1); // needed to compute all variables | |
203 | unsetvtx=kTRUE; | |
204 | } | |
205 | okD0=0; okD0bar=0; | |
206 | if(d2->SelectD0(fVHF->GetD0toKpiCuts(),okD0,okD0bar)) { | |
207 | AliAODMCParticle *part = (AliAODMCParticle*)mcArray->At(lab); | |
208 | pdg = part->GetPdgCode(); | |
209 | invmass = (pdg==421 ? d2->InvMassD0() : d2->InvMassD0bar()); | |
210 | fHistMass->Fill(invmass); | |
211 | // Post the data already here | |
212 | PostData(1,fOutput); | |
213 | ||
214 | AliAODVertex *secVtx = d2->GetSecondaryVtx(); | |
215 | secVtx->GetCovarianceMatrix(cov); | |
216 | errx=1.; erry=1.; errz=1.; | |
217 | if(cov[0]>0) errx = TMath::Sqrt(cov[0]); | |
218 | if(cov[2]>0) erry = TMath::Sqrt(cov[2]); | |
219 | if(cov[5]>0) errz = TMath::Sqrt(cov[5]); | |
220 | ||
221 | fNtupleCmp->Fill(pdg,nprongs,d2->Xv(),part->Xv(),errx,d2->Yv(),part->Yv(),erry,d2->Zv(),part->Zv(),errz,d2->GetReducedChi2(),d2->Pt(),invmass); | |
222 | PostData(2,fNtupleCmp); | |
223 | } | |
224 | if(unsetvtx) d2->UnsetOwnPrimaryVtx(); | |
3a219f60 | 225 | } |
2a041947 | 226 | break; |
227 | case 3: // look for D+ | |
952f1e33 | 228 | d3 = (AliAODRecoDecayHF3Prong*)vtx->GetParent(); |
2a041947 | 229 | lab = d3->MatchToMC(411,mcArray); |
230 | if(lab>=0) { | |
231 | unsetvtx=kFALSE; | |
232 | if(!d3->GetOwnPrimaryVtx()) { | |
233 | d3->SetOwnPrimaryVtx(vtx1); // needed to compute all variables | |
234 | unsetvtx=kTRUE; | |
235 | } | |
236 | if(d3->SelectDplus(fVHF->GetDplusCuts())) { | |
237 | AliAODMCParticle *part = (AliAODMCParticle*)mcArray->At(lab); | |
238 | pdg = part->GetPdgCode(); | |
239 | invmass = d3->InvMassDplus(); | |
240 | AliAODVertex *secVtx = d3->GetSecondaryVtx(); | |
241 | secVtx->GetCovarianceMatrix(cov); | |
242 | errx=1.; erry=1.; errz=1.; | |
243 | if(cov[0]>0) errx = TMath::Sqrt(cov[0]); | |
244 | if(cov[2]>0) erry = TMath::Sqrt(cov[2]); | |
245 | if(cov[5]>0) errz = TMath::Sqrt(cov[5]); | |
246 | ||
247 | fNtupleCmp->Fill(pdg,nprongs,d3->Xv(),part->Xv(),errx,d3->Yv(),part->Yv(),erry,d3->Zv(),part->Zv(),errz,d3->GetReducedChi2(),d3->Pt(),invmass); | |
248 | PostData(2,fNtupleCmp); | |
249 | } | |
250 | if(unsetvtx) d3->UnsetOwnPrimaryVtx(); | |
251 | } | |
252 | break; | |
253 | case 4: // look for D0->Kpipipi | |
952f1e33 | 254 | d4 = (AliAODRecoDecayHF4Prong*)vtx->GetParent(); |
2a041947 | 255 | lab = d4->MatchToMC(421,mcArray); |
256 | if(lab>=0) { | |
257 | unsetvtx=kFALSE; | |
258 | if(!d4->GetOwnPrimaryVtx()) { | |
259 | d4->SetOwnPrimaryVtx(vtx1); // needed to compute all variables | |
260 | unsetvtx=kTRUE; | |
261 | } | |
262 | okD0=0; okD0bar=0; | |
263 | if(d4->SelectD0(fVHF->GetD0to4ProngsCuts(),okD0,okD0bar)) { | |
264 | AliAODMCParticle *part = (AliAODMCParticle*)mcArray->At(lab); | |
265 | pdg = part->GetPdgCode(); | |
266 | //invmass = (pdg==421 ? d->InvMassD0() : d->InvMassD0bar()); | |
267 | invmass = 10.; | |
268 | ||
269 | AliAODVertex *secVtx = d4->GetSecondaryVtx(); | |
270 | secVtx->GetCovarianceMatrix(cov); | |
271 | errx=1.; erry=1.; errz=1.; | |
272 | if(cov[0]>0) errx = TMath::Sqrt(cov[0]); | |
273 | if(cov[2]>0) erry = TMath::Sqrt(cov[2]); | |
274 | if(cov[5]>0) errz = TMath::Sqrt(cov[5]); | |
275 | ||
276 | fNtupleCmp->Fill(pdg,nprongs,d4->Xv(),part->Xv(),errx,d4->Yv(),part->Yv(),erry,d4->Zv(),part->Zv(),errz,d4->GetReducedChi2(),d4->Pt(),invmass); | |
277 | PostData(2,fNtupleCmp); | |
278 | ||
279 | } | |
280 | if(unsetvtx) d4->UnsetOwnPrimaryVtx(); | |
281 | } | |
282 | break; | |
3a219f60 | 283 | } |
3a219f60 | 284 | |
2a041947 | 285 | } // end loop on vertices |
3a219f60 | 286 | |
9d6d35b0 | 287 | |
b3999999 | 288 | // loop over D*+ candidates |
4dd17b11 | 289 | /* |
b3999999 | 290 | for (Int_t iDstar = 0; iDstar < inputArrayDstar->GetEntries(); iDstar++) { |
291 | AliAODRecoCascadeHF *c = (AliAODRecoCascadeHF*)inputArrayDstar->UncheckedAt(iDstar); | |
292 | Int_t labDstar = c->MatchToMC(413,421,mcArray); | |
293 | if(labDstar>=0) printf("GOOD MATCH FOR D*+\n"); | |
294 | } | |
4dd17b11 | 295 | */ |
2a041947 | 296 | |
4dd17b11 | 297 | // Post the data already here |
298 | PostData(1,fOutput); | |
2a041947 | 299 | PostData(2,fNtupleCmp); |
b3999999 | 300 | |
3a219f60 | 301 | return; |
302 | } | |
3a219f60 | 303 | //________________________________________________________________________ |
304 | void AliAnalysisTaskSECompareHF::Terminate(Option_t */*option*/) | |
305 | { | |
306 | // Terminate analysis | |
307 | // | |
308 | if(fDebug > 1) printf("AnalysisTaskSECompareHF: Terminate() \n"); | |
309 | ||
310 | fOutput = dynamic_cast<TList*> (GetOutputData(1)); | |
311 | if (!fOutput) { | |
312 | printf("ERROR: fOutput not available\n"); | |
313 | return; | |
314 | } | |
315 | ||
3a219f60 | 316 | fHistMass = dynamic_cast<TH1F*>(fOutput->FindObject("fHistMass")); |
317 | ||
2a041947 | 318 | fNtupleCmp = dynamic_cast<TNtuple*> (GetOutputData(2)); |
10bdd1ae | 319 | |
3a219f60 | 320 | return; |
321 | } | |
322 |