]>
Commit | Line | Data |
---|---|---|
cbedddce | 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 | // AliAnalysisTaskSESignificane to calculate effects on | |
19 | // significance of D mesons cut | |
20 | // Authors: G. Ortona, ortona@to.infn.it | |
21 | // F. Prino, prino@to.infn.it | |
22 | // Renu Bala, bala@to.infn.it | |
23 | // Chiara Bianchin, cbianchi@pd.infn.it | |
24 | ///////////////////////////////////////////////////////////// | |
25 | ||
26 | #include <Riostream.h> | |
27 | #include <TClonesArray.h> | |
28 | #include <TCanvas.h> | |
29 | #include <TList.h> | |
30 | #include <TFile.h> | |
31 | #include <TString.h> | |
32 | #include <TH1F.h> | |
33 | #include <TDatabasePDG.h> | |
34 | ||
83e7d8d8 | 35 | #include <AliLog.h> |
cbedddce | 36 | #include "AliAnalysisManager.h" |
37 | #include "AliAODHandler.h" | |
38 | #include "AliAODEvent.h" | |
39 | #include "AliAODVertex.h" | |
40 | #include "AliAODTrack.h" | |
41 | #include "AliAODMCHeader.h" | |
42 | #include "AliAODMCParticle.h" | |
43 | #include "AliAODRecoDecayHF3Prong.h" | |
44 | #include "AliAODRecoDecayHF.h" | |
45 | #include "AliAODRecoDecayHF2Prong.h" | |
46 | #include "AliAODRecoDecayHF4Prong.h" | |
47 | #include "AliAODRecoCascadeHF.h" | |
48 | ||
49 | #include "AliAnalysisTaskSE.h" | |
50 | #include "AliRDHFCutsDplustoKpipi.h" | |
83e7d8d8 | 51 | #include "AliRDHFCutsD0toKpipipi.h" |
52 | #include "AliRDHFCutsDstoKKpi.h" | |
53 | #include "AliRDHFCutsDStartoKpipi.h" | |
cbedddce | 54 | #include "AliRDHFCutsD0toKpi.h" |
83e7d8d8 | 55 | #include "AliRDHFCutsLctopKpi.h" |
cbedddce | 56 | #include "AliMultiDimVector.h" |
57 | ||
58 | #include "AliAnalysisTaskSESignificance.h" | |
59 | ||
60 | ClassImp(AliAnalysisTaskSESignificance) | |
61 | ||
62 | ||
63 | //________________________________________________________________________ | |
64 | AliAnalysisTaskSESignificance::AliAnalysisTaskSESignificance(): | |
65 | AliAnalysisTaskSE(), | |
66 | fOutput(0), | |
67 | fCutList(0), | |
68 | fHistNEvents(0), | |
69 | fUpmasslimit(1.965), | |
70 | fLowmasslimit(1.765), | |
71 | fRDCuts(0), | |
72 | fNPtBins(0), | |
73 | fReadMC(kFALSE), | |
74 | fDecChannel(0), | |
f80a6da9 | 75 | fSelectionlevel(0), |
76 | fNBins(100), | |
77 | fPartOrAndAntiPart(0) | |
cbedddce | 78 | { |
79 | // Default constructor | |
80 | } | |
81 | ||
82 | //________________________________________________________________________ | |
83 | AliAnalysisTaskSESignificance::AliAnalysisTaskSESignificance(const char *name, TList* listMDV,AliRDHFCuts *rdCuts,Int_t decaychannel,Int_t selectionlevel): | |
84 | AliAnalysisTaskSE(name), | |
85 | fOutput(0), | |
86 | fCutList(listMDV), | |
87 | fHistNEvents(0), | |
88 | fUpmasslimit(0), | |
89 | fLowmasslimit(0), | |
90 | fRDCuts(rdCuts), | |
91 | fNPtBins(0), | |
92 | fReadMC(kFALSE), | |
93 | fDecChannel(decaychannel), | |
f80a6da9 | 94 | fSelectionlevel(selectionlevel), |
95 | fNBins(100), | |
96 | fPartOrAndAntiPart(0) | |
cbedddce | 97 | { |
98 | ||
99 | Int_t pdg=421; | |
100 | switch(fDecChannel){ | |
101 | case 0: | |
102 | pdg=411; | |
103 | break; | |
104 | case 1: | |
105 | pdg=421; | |
106 | break; | |
107 | case 2: | |
108 | pdg=413; | |
109 | break; | |
110 | case 3: | |
111 | pdg=431; | |
112 | break; | |
113 | case 4: | |
114 | pdg=421; | |
115 | break; | |
116 | case 5: | |
117 | pdg=4122; | |
118 | break; | |
119 | } | |
120 | ||
f80a6da9 | 121 | SetMassLimits(0.15,pdg); //check range |
cbedddce | 122 | fNPtBins=fRDCuts->GetNPtBins(); |
83e7d8d8 | 123 | |
cbedddce | 124 | if(fDebug>1)fRDCuts->PrintAll(); |
125 | // Output slot #1 writes into a TList container | |
126 | DefineOutput(1,TList::Class()); //My private output | |
127 | DefineOutput(2,TList::Class()); | |
3aa6ce53 | 128 | CheckConsistency(); |
cbedddce | 129 | } |
130 | ||
131 | //________________________________________________________________________ | |
132 | AliAnalysisTaskSESignificance::~AliAnalysisTaskSESignificance() | |
133 | { | |
134 | // Destructor | |
135 | if (fOutput) { | |
136 | delete fOutput; | |
137 | fOutput = 0; | |
138 | } | |
139 | if (fCutList) { | |
140 | delete fCutList; | |
141 | fCutList = 0; | |
142 | } | |
143 | if(fHistNEvents){ | |
144 | delete fHistNEvents; | |
145 | fHistNEvents=0; | |
146 | } | |
147 | ||
148 | /* | |
149 | if(fRDCuts) { | |
150 | delete fRDCuts; | |
151 | fRDCuts= 0; | |
152 | } | |
153 | */ | |
154 | ||
3aa6ce53 | 155 | } |
156 | //_________________________________________________________________ | |
157 | Bool_t AliAnalysisTaskSESignificance::CheckConsistency(){ | |
158 | ||
159 | Bool_t result = kTRUE; | |
160 | ||
161 | const Int_t nvars=fRDCuts->GetNVars();//ForOpt(); | |
162 | //Float_t *vars = new Float_t[nvars]; | |
163 | Bool_t *varsforopt = fRDCuts->GetVarsForOpt(); | |
164 | Bool_t *uppervars = fRDCuts->GetIsUpperCut(); | |
165 | TString *names = fRDCuts->GetVarNames(); | |
166 | ||
167 | for(Int_t i=0;i<fNPtBins;i++){ | |
168 | TString mdvname=Form("multiDimVectorPtBin%d",i); | |
169 | Int_t ic=0; | |
170 | ||
171 | for(Int_t ivar=0;ivar<nvars;ivar++){ | |
172 | if(varsforopt[ivar]){ | |
173 | Float_t min = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetMinLimit(ic); | |
174 | Float_t max = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetMaxLimit(ic); | |
175 | if(min==max){ | |
176 | printf("AliAnalysisTaskSESignificance::CheckConsistency: ERROR! \n tight and loose cut for optimization variable number %d are the same in ptbin %d\n",ic,i); | |
177 | result = kFALSE; | |
178 | } | |
179 | Bool_t lowermdv = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetGreaterThan(ic); | |
180 | if(uppervars[ivar]&&lowermdv){ | |
f80a6da9 | 181 | AliWarning(Form("%s is declared as uppercut, but as been given tighter cut larger then loose cut in ptbin %d \n ---Task will use swapped Tight/Loose cuts \n ",names[ivar].Data(),i)); |
3aa6ce53 | 182 | ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->SwapLimits(ic); |
183 | result = kTRUE; | |
184 | } | |
185 | if(!uppervars[ivar]&&!lowermdv){ | |
f80a6da9 | 186 | AliWarning(Form("%s is declared as lower cut, but as been given tighter cut smaller then loose cut in ptbin %d \n ---Task will use swapped Tight/Loose cuts \n",names[ivar].Data(),i)); |
3aa6ce53 | 187 | ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->SwapLimits(ic); |
188 | result = kTRUE; | |
189 | } | |
190 | ic++; | |
191 | } | |
192 | } | |
193 | } | |
194 | return result; | |
195 | } | |
cbedddce | 196 | //_________________________________________________________________ |
197 | void AliAnalysisTaskSESignificance::SetMassLimits(Float_t range, Int_t pdg){ | |
198 | Float_t mass=0; | |
199 | Int_t abspdg=TMath::Abs(pdg); | |
5ecc6e9b | 200 | mass=TDatabasePDG::Instance()->GetParticle(abspdg)->Mass(); |
cbedddce | 201 | fUpmasslimit = mass+range; |
202 | fLowmasslimit = mass-range; | |
203 | } | |
204 | //_________________________________________________________________ | |
205 | void AliAnalysisTaskSESignificance::SetMassLimits(Float_t lowlimit, Float_t uplimit){ | |
206 | if(uplimit>lowlimit) | |
207 | { | |
f80a6da9 | 208 | fUpmasslimit = uplimit; |
209 | fLowmasslimit = lowlimit; | |
cbedddce | 210 | } |
211 | } | |
212 | ||
213 | ||
214 | ||
215 | //________________________________________________________________________ | |
216 | void AliAnalysisTaskSESignificance::LocalInit() | |
217 | { | |
218 | // Initialization | |
219 | ||
220 | if(fDebug > 1) printf("AnalysisTaskSESignificance::Init() \n"); | |
221 | ||
222 | TList *mdvList = new TList(); | |
223 | mdvList->SetOwner(); | |
224 | mdvList = fCutList; | |
225 | ||
226 | PostData(2,mdvList); | |
227 | ||
228 | return; | |
229 | } | |
230 | //________________________________________________________________________ | |
231 | void AliAnalysisTaskSESignificance::UserCreateOutputObjects() | |
232 | { | |
233 | // Create the output container | |
234 | ||
235 | if(fDebug > 1) printf("AnalysisTaskSESignificance::UserCreateOutputObjects() \n"); | |
236 | ||
237 | // Several histograms are more conveniently managed in a TList | |
238 | fOutput = new TList(); | |
239 | fOutput->SetOwner(); | |
240 | fOutput->SetName("OutputHistos"); | |
241 | ||
242 | //same number of steps in each multiDimVectorPtBin%d ! | |
243 | Int_t nHist=((AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0"))->GetNTotCells(); | |
83e7d8d8 | 244 | cout<<"ncells = "<<nHist<<" n ptbins = "<<fNPtBins<<endl; |
cbedddce | 245 | nHist=nHist*fNPtBins; |
83e7d8d8 | 246 | cout<<"Total = "<<nHist<<endl; |
cbedddce | 247 | for(Int_t i=0;i<nHist;i++){ |
248 | ||
249 | TString hisname; | |
250 | TString signame; | |
251 | TString bkgname; | |
252 | TString rflname; | |
253 | TString title; | |
254 | ||
255 | hisname.Form("hMass_%d",i); | |
256 | signame.Form("hSig_%d",i); | |
257 | bkgname.Form("hBkg_%d",i); | |
258 | rflname.Form("hRfl_%d",i); | |
259 | ||
260 | title.Form("Invariant mass;M[GeV/c^{2}];Entries"); | |
261 | ||
f80a6da9 | 262 | fMassHist[i]=new TH1F(hisname.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit); |
cbedddce | 263 | fMassHist[i]->Sumw2(); |
264 | fOutput->Add(fMassHist[i]); | |
265 | ||
266 | if(fReadMC){ | |
f80a6da9 | 267 | fSigHist[i]=new TH1F(signame.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit); |
cbedddce | 268 | fSigHist[i]->Sumw2(); |
269 | fOutput->Add(fSigHist[i]); | |
270 | ||
f80a6da9 | 271 | fBkgHist[i]=new TH1F(bkgname.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit); |
cbedddce | 272 | fBkgHist[i]->Sumw2(); |
273 | fOutput->Add(fBkgHist[i]); | |
274 | ||
f80a6da9 | 275 | if(fDecChannel != AliAnalysisTaskSESignificance::kDplustoKpipi){ |
276 | fRflHist[i]=new TH1F(rflname.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit); | |
277 | fRflHist[i]->Sumw2(); | |
278 | fOutput->Add(fRflHist[i]); | |
279 | } | |
cbedddce | 280 | } |
281 | } | |
282 | ||
5ecc6e9b | 283 | fHistNEvents=new TH1F("fHistNEvents","Number of AODs scanned",4,0,4.); |
cbedddce | 284 | fHistNEvents->GetXaxis()->SetBinLabel(1,"nEventsAnal"); |
83e7d8d8 | 285 | fHistNEvents->GetXaxis()->SetBinLabel(2,"nEvNotSelected"); |
5ecc6e9b | 286 | fHistNEvents->GetXaxis()->SetBinLabel(3,"nCandidatesSelected"); |
287 | fHistNEvents->GetXaxis()->SetBinLabel(4,"nTotEntries Mass hists"); | |
cbedddce | 288 | fHistNEvents->GetXaxis()->SetNdivisions(1,kFALSE); |
289 | fOutput->Add(fHistNEvents); | |
290 | ||
291 | ||
292 | return; | |
293 | } | |
294 | ||
295 | //________________________________________________________________________ | |
296 | void AliAnalysisTaskSESignificance::UserExec(Option_t */*option*/) | |
297 | { | |
298 | // Execute analysis for current event: | |
299 | // heavy flavor candidates association to MC truth | |
300 | ||
301 | AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent()); | |
83e7d8d8 | 302 | if(fDebug>2) printf("Analysing decay %d\n",fDecChannel); |
cbedddce | 303 | // Post the data already here |
304 | PostData(1,fOutput); | |
305 | TClonesArray *arrayProng =0; | |
306 | ||
307 | if(!aod && AODEvent() && IsStandardAOD()) { | |
308 | // In case there is an AOD handler writing a standard AOD, use the AOD | |
309 | // event in memory rather than the input (ESD) event. | |
310 | aod = dynamic_cast<AliAODEvent*> (AODEvent()); | |
311 | // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root) | |
312 | // have to taken from the AOD event hold by the AliAODExtension | |
313 | AliAODHandler* aodHandler = (AliAODHandler*) | |
314 | ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); | |
315 | if(aodHandler->GetExtensions()) { | |
316 | ||
317 | AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root"); | |
318 | AliAODEvent *aodFromExt = ext->GetAOD(); | |
319 | ||
320 | ||
321 | switch(fDecChannel){ | |
322 | case 0: | |
323 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong"); | |
324 | break; | |
325 | case 1: | |
326 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi"); | |
327 | break; | |
328 | case 2: | |
329 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar"); | |
330 | break; | |
331 | case 3: | |
332 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong"); | |
333 | break; | |
334 | case 4: | |
335 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm4Prong"); | |
336 | break; | |
337 | case 5: | |
338 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong"); | |
339 | break; | |
340 | } | |
341 | } | |
342 | } else { | |
343 | switch(fDecChannel){ | |
344 | case 0: | |
345 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong"); | |
346 | break; | |
347 | case 1: | |
348 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("D0toKpi"); | |
349 | break; | |
350 | case 2: | |
351 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Dstar"); | |
352 | break; | |
353 | case 3: | |
354 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong"); | |
355 | break; | |
356 | case 4: | |
357 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm4Prong"); | |
358 | break; | |
359 | case 5: | |
360 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong"); | |
361 | break; | |
362 | } | |
363 | } | |
364 | if(!arrayProng) { | |
f80a6da9 | 365 | AliError("AliAnalysisTaskSESignificance::UserExec:Branch not found!\n"); |
cbedddce | 366 | return; |
367 | } | |
368 | ||
7c23877d | 369 | // fix for temporary bug in ESDfilter |
370 | // the AODs with null vertex pointer didn't pass the PhysSel | |
f80a6da9 | 371 | if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return; |
cbedddce | 372 | TClonesArray *arrayMC=0; |
373 | AliAODMCHeader *mcHeader=0; | |
374 | ||
375 | // load MC particles | |
376 | if(fReadMC){ | |
377 | ||
378 | arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()); | |
379 | if(!arrayMC) { | |
f80a6da9 | 380 | AliWarning("AliAnalysisTaskSESignificance::UserExec:MC particles branch not found!\n"); |
cbedddce | 381 | // return; |
382 | } | |
383 | ||
384 | // load MC header | |
385 | mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName()); | |
386 | if(!mcHeader) { | |
f80a6da9 | 387 | AliError("AliAnalysisTaskSESignificance::UserExec:MC header branch not found!\n"); |
cbedddce | 388 | return; |
389 | } | |
390 | } | |
391 | ||
392 | fHistNEvents->Fill(0); // count event | |
393 | ||
394 | AliAODRecoDecayHF *d=0; | |
395 | Int_t nprongs=1; | |
396 | Int_t *pdgdaughters=0x0; | |
f80a6da9 | 397 | Int_t absPdgMom=411; |
cbedddce | 398 | |
399 | ||
400 | switch(fDecChannel){ | |
401 | case 0: | |
402 | //D+ | |
403 | pdgdaughters =new Int_t[3]; | |
404 | pdgdaughters[0]=211;//pi | |
405 | pdgdaughters[1]=321;//K | |
406 | pdgdaughters[2]=211;//pi | |
407 | nprongs=3; | |
f80a6da9 | 408 | absPdgMom=411; |
cbedddce | 409 | break; |
410 | case 1: | |
411 | //D0 | |
412 | pdgdaughters =new Int_t[2]; | |
413 | pdgdaughters[0]=211;//pi | |
414 | pdgdaughters[1]=321;//K | |
415 | nprongs=2; | |
f80a6da9 | 416 | absPdgMom=421; |
cbedddce | 417 | break; |
418 | case 2: | |
419 | //D* | |
420 | pdgdaughters =new Int_t[3]; | |
421 | pdgdaughters[1]=211;//pi | |
422 | pdgdaughters[0]=321;//K | |
423 | pdgdaughters[2]=211;//pi (soft?) | |
424 | nprongs=3; | |
f80a6da9 | 425 | absPdgMom=413; |
cbedddce | 426 | break; |
427 | case 3: | |
428 | //Ds | |
429 | pdgdaughters =new Int_t[3]; | |
4d829de7 | 430 | pdgdaughters[0]=321;//K |
cbedddce | 431 | pdgdaughters[1]=321;//K |
4d829de7 | 432 | pdgdaughters[2]=211;//pi |
cbedddce | 433 | nprongs=3; |
f80a6da9 | 434 | absPdgMom=431; |
cbedddce | 435 | break; |
436 | case 4: | |
f80a6da9 | 437 | //D0 in 4 prongs |
cbedddce | 438 | pdgdaughters =new Int_t[4]; |
439 | pdgdaughters[0]=321; | |
440 | pdgdaughters[1]=211; | |
441 | pdgdaughters[2]=211; | |
442 | pdgdaughters[3]=211; | |
443 | nprongs=4; | |
f80a6da9 | 444 | absPdgMom=421; |
cbedddce | 445 | break; |
446 | case 5: | |
447 | //Lambda_c | |
448 | pdgdaughters =new Int_t[3]; | |
cbedddce | 449 | pdgdaughters[0]=2212;//p |
450 | pdgdaughters[1]=321;//K | |
451 | pdgdaughters[2]=211;//pi | |
452 | nprongs=3; | |
f80a6da9 | 453 | absPdgMom=4122; |
cbedddce | 454 | break; |
455 | } | |
456 | ||
457 | Int_t nHistpermv=((AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0"))->GetNTotCells(); | |
458 | Int_t nProng = arrayProng->GetEntriesFast(); | |
459 | if(fDebug>1) printf("Number of D2H: %d\n",nProng); | |
460 | ||
5ecc6e9b | 461 | if(!fRDCuts->IsEventSelected(aod)){ |
462 | fHistNEvents->Fill(1); | |
463 | return; | |
464 | } | |
465 | ||
cbedddce | 466 | for (Int_t iProng = 0; iProng < nProng; iProng++) { |
f80a6da9 | 467 | |
cbedddce | 468 | d=(AliAODRecoDecayHF*)arrayProng->UncheckedAt(iProng); |
cbedddce | 469 | |
f80a6da9 | 470 | Bool_t isFidAcc = fRDCuts->IsInFiducialAcceptance(d->Pt(),d->Y(absPdgMom)); |
a4bb4427 | 471 | Int_t isSelected=fRDCuts->IsSelected(d,fSelectionlevel,aod); |
cbedddce | 472 | |
f80a6da9 | 473 | if(isSelected&&isFidAcc) { |
5ecc6e9b | 474 | fHistNEvents->Fill(2); // count selected with loosest cuts |
83e7d8d8 | 475 | if(fDebug>1) printf("+++++++Is Selected\n"); |
cbedddce | 476 | |
f80a6da9 | 477 | Double_t* invMass=0x0; |
478 | Int_t nmasses; | |
479 | CalculateInvMasses(d,invMass,nmasses); | |
480 | ||
cbedddce | 481 | const Int_t nvars=fRDCuts->GetNVarsForOpt(); |
482 | Float_t *vars = new Float_t[nvars]; | |
483 | Int_t nVals=0; | |
484 | ||
485 | fRDCuts->GetCutVarsForOpt(d,vars,nvars,pdgdaughters); | |
486 | Int_t ptbin=fRDCuts->PtBin(d->Pt()); | |
487 | if(ptbin==-1) continue; | |
488 | TString mdvname=Form("multiDimVectorPtBin%d",ptbin); | |
489 | ULong64_t *addresses = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetGlobalAddressesAboveCuts(vars,(Float_t)d->Pt(),nVals); | |
490 | if(fDebug>1)printf("nvals = %d\n",nVals); | |
cbedddce | 491 | for(Int_t ivals=0;ivals<nVals;ivals++){ |
492 | if(addresses[ivals]>=((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetNTotCells()){ | |
493 | if (fDebug>1) printf("Overflow!!\n"); | |
494 | return; | |
495 | } | |
cbedddce | 496 | |
f80a6da9 | 497 | fHistNEvents->Fill(3); |
cbedddce | 498 | |
f80a6da9 | 499 | //fill the histograms with the appropriate method |
500 | switch (fDecChannel){ | |
501 | case 0: | |
502 | FillDplus(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
503 | break; | |
504 | case 1: | |
505 | FillD02p(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
506 | break; | |
507 | case 2: | |
508 | FillDstar(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
509 | break; | |
510 | case 3: | |
511 | FillDs(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
512 | break; | |
513 | case 4: | |
514 | FillD04p(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
515 | break; | |
516 | case 5: | |
517 | FillLambdac(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
518 | break; | |
519 | default: | |
520 | break; | |
cbedddce | 521 | } |
f80a6da9 | 522 | |
cbedddce | 523 | } |
cbedddce | 524 | }// end if selected |
cbedddce | 525 | |
526 | } | |
f80a6da9 | 527 | |
cbedddce | 528 | PostData(1,fOutput); |
529 | return; | |
530 | } | |
531 | ||
f80a6da9 | 532 | //*************************************************************************** |
533 | ||
534 | // Methods used in the UserExec | |
535 | ||
536 | void AliAnalysisTaskSESignificance::CalculateInvMasses(AliAODRecoDecayHF* d,Double_t*& masses,Int_t& nmasses){ | |
537 | //Calculates all the possible invariant masses for each candidate | |
538 | //NB: the implementation for each candidate is responsibility of the corresponding developer | |
539 | ||
540 | switch(fDecChannel){ | |
541 | case 0: | |
542 | //D+ -- Giacomo, Renu ? | |
543 | { | |
544 | nmasses=1; | |
545 | masses=new Double_t[nmasses]; | |
546 | Int_t pdgdaughters[3] = {211,321,211}; | |
547 | masses[0]=d->InvMass(3,(UInt_t*)pdgdaughters); | |
548 | } | |
549 | break; | |
550 | case 1: | |
551 | //D0 (Kpi) -- Chiara | |
552 | { | |
553 | const Int_t ndght=2; | |
554 | nmasses=2; | |
555 | masses=new Double_t[nmasses]; | |
556 | Int_t pdgdaughtersD0[ndght]={211,321};//pi,K | |
557 | masses[0]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0); //D0 | |
558 | Int_t pdgdaughtersD0bar[ndght]={321,211};//K,pi | |
559 | masses[1]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0bar); //D0bar | |
560 | } | |
561 | break; | |
562 | case 2: | |
563 | //D* -- ? Yifei, Alessandro | |
564 | { | |
565 | //..... | |
566 | } | |
567 | break; | |
568 | case 3: | |
569 | //Ds -- Sergey, Sahdana | |
570 | { | |
4d829de7 | 571 | const Int_t ndght=3; |
572 | nmasses=2; | |
573 | masses=new Double_t[nmasses]; | |
574 | Int_t pdgdaughtersDsKKpi[ndght]={321,321,211};//K,K,pi | |
575 | masses[0]=d->InvMass(ndght,(UInt_t*)pdgdaughtersDsKKpi); //Ds | |
576 | Int_t pdgdaughtersDspiKK[ndght]={211,321,321};//pi,K,K | |
577 | masses[1]=d->InvMass(ndght,(UInt_t*)pdgdaughtersDspiKK); //Dsbar | |
578 | ||
f80a6da9 | 579 | //..... |
580 | } | |
581 | break; | |
582 | case 4: | |
583 | //D0 (Kpipipi) -- ? Rossella, Fabio ??? | |
584 | { | |
585 | //..... | |
586 | } | |
587 | break; | |
588 | case 5: | |
589 | //Lambda_c -- Rossella | |
590 | { | |
591 | //..... | |
592 | } | |
593 | break; | |
594 | default: | |
595 | break; | |
596 | } | |
597 | } | |
598 | ||
599 | //******************************************************************************************** | |
600 | ||
601 | //Methods to fill the istograms with MC information, one for each candidate | |
602 | //NB: the implementation for each candidate is responsibility of the corresponding developer | |
603 | ||
604 | void AliAnalysisTaskSESignificance::FillDplus(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Double_t* masses,Int_t isSel){ | |
605 | //D+ channel | |
606 | if(!isSel){ | |
607 | AliError("Candidate not selected\n"); | |
608 | return; | |
609 | } | |
610 | ||
611 | if(fPartOrAndAntiPart*d->GetCharge()<0)return; | |
612 | ||
613 | fMassHist[index]->Fill(masses[0]); | |
614 | ||
615 | Int_t pdgdaughters[3] = {211,321,211}; | |
616 | ||
617 | if(fReadMC){ | |
618 | Int_t lab=-1; | |
619 | lab = d->MatchToMC(411,arrayMC,3,pdgdaughters); | |
620 | if(lab>=0){ //signal | |
621 | fSigHist[index]->Fill(masses[0]); | |
622 | } else{ //background | |
623 | fBkgHist[index]->Fill(masses[0]); | |
624 | } | |
625 | } | |
626 | } | |
627 | ||
628 | ||
629 | void AliAnalysisTaskSESignificance::FillD02p(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Double_t* masses,Int_t isSel){ | |
630 | ||
631 | //D0->Kpi channel | |
632 | ||
633 | //mass histograms | |
634 | if(!masses){ | |
635 | AliError("Masses not calculated\n"); | |
636 | return; | |
637 | } | |
638 | if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0) fMassHist[index]->Fill(masses[0]); | |
639 | if(isSel>=2 && fPartOrAndAntiPart<=0) fMassHist[index]->Fill(masses[1]); | |
640 | ||
641 | ||
4d829de7 | 642 | |
f80a6da9 | 643 | //MC histograms |
644 | if(fReadMC){ | |
645 | ||
646 | Int_t matchtoMC=-1; | |
647 | ||
648 | //D0 | |
649 | Int_t pdgdaughters[2]; | |
650 | pdgdaughters[0]=211;//pi | |
651 | pdgdaughters[1]=321;//K | |
652 | Int_t nprongs=2; | |
653 | Int_t absPdgMom=421; | |
654 | ||
655 | matchtoMC = d->MatchToMC(absPdgMom,arrayMC,nprongs,pdgdaughters); | |
656 | ||
657 | Int_t prongPdgPlus=421,prongPdgMinus=(-1)*421; | |
658 | if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0){ //D0 | |
659 | if(matchtoMC>=0){ | |
660 | AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC); | |
661 | Int_t pdgMC = dMC->GetPdgCode(); | |
662 | ||
663 | if(pdgMC==prongPdgPlus) fSigHist[index]->Fill(masses[0]); | |
664 | else fRflHist[index]->Fill(masses[0]); | |
665 | ||
666 | } else fBkgHist[index]->Fill(masses[0]); | |
667 | ||
668 | } | |
669 | if(isSel>=2 && fPartOrAndAntiPart<=0){ //D0bar | |
670 | if(matchtoMC>=0){ | |
671 | AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC); | |
672 | Int_t pdgMC = dMC->GetPdgCode(); | |
673 | ||
674 | if(pdgMC==prongPdgMinus) fSigHist[index]->Fill(masses[1]); | |
675 | else fRflHist[index]->Fill(masses[1]); | |
676 | } else fBkgHist[index]->Fill(masses[1]); | |
677 | } | |
678 | } | |
679 | } | |
680 | ||
681 | void AliAnalysisTaskSESignificance::FillDstar(AliAODRecoDecayHF* /*d*/,TClonesArray */*arrayMC*/,Int_t /*index*/,Double_t* /*masses*/,Int_t /*matchtoMC*/){ | |
682 | //D* channel | |
683 | ||
684 | AliInfo("Dstar channel not implemented\n"); | |
685 | ||
686 | } | |
687 | ||
688 | ||
4d829de7 | 689 | void AliAnalysisTaskSESignificance::FillDs(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Double_t* masses,Int_t isSel){ |
690 | ||
691 | //AliInfo("Ds channel not implemented\n"); | |
692 | ||
693 | ||
694 | if(!masses){ | |
695 | AliError("Masses not calculated\n"); | |
696 | return; | |
697 | } | |
698 | ||
699 | Int_t pdgDstoKKpi[3]={321,321,211}; | |
700 | Int_t labDs=-1; | |
701 | if(fReadMC){ | |
702 | labDs = d->MatchToMC(431,arrayMC,3,pdgDstoKKpi); | |
703 | } | |
704 | ||
705 | ||
706 | if(isSel&1 && fPartOrAndAntiPart*d->GetCharge()>=0) { | |
707 | ||
708 | fMassHist[index]->Fill(masses[0]); | |
709 | ||
710 | if(fReadMC){ | |
f80a6da9 | 711 | |
4d829de7 | 712 | if(labDs>=0){ |
713 | Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel(); | |
714 | AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0); | |
715 | Int_t pdgCode0=TMath::Abs(p->GetPdgCode()); | |
716 | ||
717 | if(pdgCode0==321) { | |
718 | ||
719 | fSigHist[index]->Fill(masses[0]); //signal | |
720 | }else{ | |
721 | fRflHist[index]->Fill(masses[0]); //Reflected signal | |
722 | } | |
723 | }else{ | |
724 | fBkgHist[index]->Fill(masses[0]); // Background | |
725 | } | |
726 | } | |
727 | } | |
728 | ||
729 | if(isSel&2 && fPartOrAndAntiPart*d->GetCharge()>=0){ | |
730 | fMassHist[index]->Fill(masses[1]); | |
731 | if(fReadMC){ | |
732 | if(labDs>=0){ | |
733 | Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel(); | |
734 | AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0); | |
735 | Int_t pdgCode0=TMath::Abs(p->GetPdgCode()); | |
736 | ||
737 | if(pdgCode0==211) { | |
738 | ||
739 | fSigHist[index]->Fill(masses[1]); | |
740 | }else{ | |
741 | fRflHist[index]->Fill(masses[1]); | |
742 | } | |
743 | }else{ | |
744 | fBkgHist[index]->Fill(masses[1]); | |
745 | } | |
746 | } | |
747 | } | |
748 | ||
749 | ||
750 | //MC histograms | |
751 | ||
f80a6da9 | 752 | //Ds channel |
753 | // Int_t isKKpi=0; | |
754 | // Int_t ispiKK=0; | |
755 | // isKKpi=isSelected&1; | |
756 | // ispiKK=isSelected&2; | |
757 | ||
758 | // Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel(); | |
759 | // AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0); | |
760 | // Int_t pdgCode0=TMath::Abs(p->GetPdgCode()); | |
761 | ||
762 | // if(isKKpi){ | |
763 | // if(pdgCode0==321){ | |
764 | // fSigHist[index]->Fill(masses[0]); | |
765 | // }else{ | |
766 | // fRflHist[index]->Fill(masses[0]); | |
767 | // } | |
768 | // } | |
769 | // if(ispiKK){ | |
770 | // if(pdgCode0==211){ | |
771 | // fSigHist[index]->Fill(masses[1]); | |
772 | // }else{ | |
773 | // fRflHist[index]->Fill(masses[1]); | |
774 | // } | |
775 | // } | |
776 | ||
777 | } | |
778 | ||
779 | void AliAnalysisTaskSESignificance::FillD04p(AliAODRecoDecayHF* /*d*/,TClonesArray */*arrayMC*/,Int_t /*index*/,Double_t* /*masses*/,Int_t /*matchtoMC*/){ | |
780 | //D0->Kpipipi channel | |
781 | AliInfo("D0 in 4 prongs channel not implemented\n"); | |
782 | ||
783 | } | |
784 | ||
785 | void AliAnalysisTaskSESignificance::FillLambdac(AliAODRecoDecayHF* /*d*/,TClonesArray */*arrayMC*/,Int_t /*index*/,Double_t* /*masses*/,Int_t /*matchtoMC*/){ | |
786 | AliInfo("Lambdac channel not implemented\n"); | |
787 | ||
788 | //Lambdac channel | |
789 | // Int_t ispKpi=0; | |
790 | // Int_t ispiKp=0; | |
791 | ||
792 | // ispKpi=isSelected&1; | |
793 | // ispiKp=isSelected&2; | |
794 | // if(matchtoMC>=0){ | |
795 | // Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel(); | |
796 | // AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0); | |
797 | // Int_t pdgCode0=TMath::Abs(p->GetPdgCode()); | |
798 | // if(ispKpi){ | |
799 | // if(pdgCode0==2212){ | |
800 | // fSigHist[index]->Fill(invMass[0]); | |
801 | // }else{ | |
802 | // fRflHist[index]->Fill(invMass[0]); | |
803 | // } | |
804 | // } | |
805 | // if(ispiKp){ | |
806 | // if(pdgCode0==211){ | |
807 | // fSigHist[index]->Fill(invMass[1]); | |
808 | // }else{ | |
809 | // fRflHist[index]->Fill(invMass[1]); | |
810 | // } | |
811 | // } | |
812 | // }else{ | |
813 | // fBkgHist[index] | |
814 | // } | |
815 | ||
816 | ||
817 | } | |
818 | ||
cbedddce | 819 | |
820 | //________________________________________________________________________ | |
821 | void AliAnalysisTaskSESignificance::Terminate(Option_t */*option*/) | |
822 | { | |
823 | // Terminate analysis | |
824 | // | |
825 | if(fDebug > 1) printf("AnalysisTaskSESignificance: Terminate() \n"); | |
826 | ||
827 | ||
828 | fOutput = dynamic_cast<TList*> (GetOutputData(1)); | |
829 | if (!fOutput) { | |
830 | printf("ERROR: fOutput not available\n"); | |
831 | return; | |
832 | } | |
833 | ||
834 | fCutList = dynamic_cast<TList*> (GetOutputData(2)); | |
835 | if (!fCutList) { | |
836 | printf("ERROR: fCutList not available\n"); | |
837 | return; | |
838 | } | |
839 | ||
840 | AliMultiDimVector* mdvtmp=(AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0"); | |
841 | if (!mdvtmp){ | |
842 | cout<<"multidimvec not found in TList"<<endl; | |
843 | fCutList->ls(); | |
844 | return; | |
845 | } | |
846 | Int_t nHist=mdvtmp->GetNTotCells(); | |
847 | TCanvas *c1=new TCanvas("c1","Invariant mass distribution - loose cuts",500,500); | |
848 | Bool_t drawn=kFALSE; | |
849 | for(Int_t i=0;i<nHist;i++){ | |
850 | ||
851 | TString hisname; | |
852 | TString signame; | |
853 | TString bkgname; | |
854 | TString rflname; | |
855 | ||
856 | hisname.Form("hMass_%d",i); | |
857 | signame.Form("hSig_%d",i); | |
858 | bkgname.Form("hBkg_%d",i); | |
859 | rflname.Form("hRfl_%d",i); | |
860 | ||
861 | fMassHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data())); | |
862 | ||
863 | if (!drawn && fMassHist[i]->GetEntries() > 0){ | |
864 | c1->cd(); | |
865 | fMassHist[i]->Draw(); | |
866 | drawn=kTRUE; | |
867 | } | |
868 | ||
869 | if(fReadMC){ | |
870 | fSigHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(signame.Data())); | |
871 | fBkgHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(bkgname.Data())); | |
f80a6da9 | 872 | if(fDecChannel != AliAnalysisTaskSESignificance::kDplustoKpipi) fRflHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(rflname.Data())); |
cbedddce | 873 | } |
874 | ||
875 | } | |
876 | ||
877 | ||
878 | ||
879 | ||
880 | return; | |
881 | } | |
ab3e5f67 | 882 | //------------------------------------------- |
cbedddce | 883 |