]>
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 | ||
d52f7b50 | 283 | fHistNEvents=new TH1F("fHistNEvents","Number of AODs scanned",5,0,5.); |
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"); | |
d52f7b50 | 288 | fHistNEvents->GetXaxis()->SetBinLabel(5,"Pile-up Rej"); |
cbedddce | 289 | fHistNEvents->GetXaxis()->SetNdivisions(1,kFALSE); |
290 | fOutput->Add(fHistNEvents); | |
291 | ||
292 | ||
293 | return; | |
294 | } | |
295 | ||
296 | //________________________________________________________________________ | |
297 | void AliAnalysisTaskSESignificance::UserExec(Option_t */*option*/) | |
298 | { | |
299 | // Execute analysis for current event: | |
300 | // heavy flavor candidates association to MC truth | |
301 | ||
302 | AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent()); | |
83e7d8d8 | 303 | if(fDebug>2) printf("Analysing decay %d\n",fDecChannel); |
cbedddce | 304 | // Post the data already here |
305 | PostData(1,fOutput); | |
306 | TClonesArray *arrayProng =0; | |
307 | ||
308 | if(!aod && AODEvent() && IsStandardAOD()) { | |
309 | // In case there is an AOD handler writing a standard AOD, use the AOD | |
310 | // event in memory rather than the input (ESD) event. | |
311 | aod = dynamic_cast<AliAODEvent*> (AODEvent()); | |
312 | // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root) | |
313 | // have to taken from the AOD event hold by the AliAODExtension | |
314 | AliAODHandler* aodHandler = (AliAODHandler*) | |
315 | ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); | |
316 | if(aodHandler->GetExtensions()) { | |
317 | ||
318 | AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root"); | |
319 | AliAODEvent *aodFromExt = ext->GetAOD(); | |
320 | ||
321 | ||
322 | switch(fDecChannel){ | |
323 | case 0: | |
324 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong"); | |
325 | break; | |
326 | case 1: | |
327 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi"); | |
328 | break; | |
329 | case 2: | |
330 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar"); | |
331 | break; | |
332 | case 3: | |
333 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong"); | |
334 | break; | |
335 | case 4: | |
336 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm4Prong"); | |
337 | break; | |
338 | case 5: | |
339 | arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong"); | |
340 | break; | |
341 | } | |
342 | } | |
343 | } else { | |
344 | switch(fDecChannel){ | |
345 | case 0: | |
346 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong"); | |
347 | break; | |
348 | case 1: | |
349 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("D0toKpi"); | |
350 | break; | |
351 | case 2: | |
352 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Dstar"); | |
353 | break; | |
354 | case 3: | |
355 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong"); | |
356 | break; | |
357 | case 4: | |
358 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm4Prong"); | |
359 | break; | |
360 | case 5: | |
361 | arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong"); | |
362 | break; | |
363 | } | |
364 | } | |
365 | if(!arrayProng) { | |
f80a6da9 | 366 | AliError("AliAnalysisTaskSESignificance::UserExec:Branch not found!\n"); |
cbedddce | 367 | return; |
368 | } | |
369 | ||
7c23877d | 370 | // fix for temporary bug in ESDfilter |
371 | // the AODs with null vertex pointer didn't pass the PhysSel | |
f80a6da9 | 372 | if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return; |
cbedddce | 373 | TClonesArray *arrayMC=0; |
374 | AliAODMCHeader *mcHeader=0; | |
375 | ||
376 | // load MC particles | |
377 | if(fReadMC){ | |
378 | ||
379 | arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()); | |
380 | if(!arrayMC) { | |
f80a6da9 | 381 | AliWarning("AliAnalysisTaskSESignificance::UserExec:MC particles branch not found!\n"); |
cbedddce | 382 | // return; |
383 | } | |
384 | ||
385 | // load MC header | |
386 | mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName()); | |
387 | if(!mcHeader) { | |
f80a6da9 | 388 | AliError("AliAnalysisTaskSESignificance::UserExec:MC header branch not found!\n"); |
cbedddce | 389 | return; |
390 | } | |
391 | } | |
392 | ||
393 | fHistNEvents->Fill(0); // count event | |
394 | ||
395 | AliAODRecoDecayHF *d=0; | |
396 | Int_t nprongs=1; | |
397 | Int_t *pdgdaughters=0x0; | |
f80a6da9 | 398 | Int_t absPdgMom=411; |
cbedddce | 399 | |
400 | ||
401 | switch(fDecChannel){ | |
402 | case 0: | |
403 | //D+ | |
404 | pdgdaughters =new Int_t[3]; | |
405 | pdgdaughters[0]=211;//pi | |
406 | pdgdaughters[1]=321;//K | |
407 | pdgdaughters[2]=211;//pi | |
408 | nprongs=3; | |
f80a6da9 | 409 | absPdgMom=411; |
cbedddce | 410 | break; |
411 | case 1: | |
412 | //D0 | |
413 | pdgdaughters =new Int_t[2]; | |
414 | pdgdaughters[0]=211;//pi | |
415 | pdgdaughters[1]=321;//K | |
416 | nprongs=2; | |
f80a6da9 | 417 | absPdgMom=421; |
cbedddce | 418 | break; |
419 | case 2: | |
420 | //D* | |
421 | pdgdaughters =new Int_t[3]; | |
422 | pdgdaughters[1]=211;//pi | |
423 | pdgdaughters[0]=321;//K | |
424 | pdgdaughters[2]=211;//pi (soft?) | |
425 | nprongs=3; | |
f80a6da9 | 426 | absPdgMom=413; |
cbedddce | 427 | break; |
428 | case 3: | |
429 | //Ds | |
430 | pdgdaughters =new Int_t[3]; | |
4d829de7 | 431 | pdgdaughters[0]=321;//K |
cbedddce | 432 | pdgdaughters[1]=321;//K |
4d829de7 | 433 | pdgdaughters[2]=211;//pi |
cbedddce | 434 | nprongs=3; |
f80a6da9 | 435 | absPdgMom=431; |
cbedddce | 436 | break; |
437 | case 4: | |
f80a6da9 | 438 | //D0 in 4 prongs |
cbedddce | 439 | pdgdaughters =new Int_t[4]; |
440 | pdgdaughters[0]=321; | |
441 | pdgdaughters[1]=211; | |
442 | pdgdaughters[2]=211; | |
443 | pdgdaughters[3]=211; | |
444 | nprongs=4; | |
f80a6da9 | 445 | absPdgMom=421; |
cbedddce | 446 | break; |
447 | case 5: | |
448 | //Lambda_c | |
449 | pdgdaughters =new Int_t[3]; | |
cbedddce | 450 | pdgdaughters[0]=2212;//p |
451 | pdgdaughters[1]=321;//K | |
452 | pdgdaughters[2]=211;//pi | |
453 | nprongs=3; | |
f80a6da9 | 454 | absPdgMom=4122; |
cbedddce | 455 | break; |
456 | } | |
457 | ||
458 | Int_t nHistpermv=((AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0"))->GetNTotCells(); | |
459 | Int_t nProng = arrayProng->GetEntriesFast(); | |
460 | if(fDebug>1) printf("Number of D2H: %d\n",nProng); | |
461 | ||
5ecc6e9b | 462 | if(!fRDCuts->IsEventSelected(aod)){ |
463 | fHistNEvents->Fill(1); | |
d52f7b50 | 464 | if(fRDCuts->GetWhyRejection()==1) // rejected for pileup |
465 | fHistNEvents->Fill(4); | |
5ecc6e9b | 466 | return; |
467 | } | |
468 | ||
cbedddce | 469 | for (Int_t iProng = 0; iProng < nProng; iProng++) { |
f80a6da9 | 470 | |
cbedddce | 471 | d=(AliAODRecoDecayHF*)arrayProng->UncheckedAt(iProng); |
cbedddce | 472 | |
f80a6da9 | 473 | Bool_t isFidAcc = fRDCuts->IsInFiducialAcceptance(d->Pt(),d->Y(absPdgMom)); |
a4bb4427 | 474 | Int_t isSelected=fRDCuts->IsSelected(d,fSelectionlevel,aod); |
cbedddce | 475 | |
f80a6da9 | 476 | if(isSelected&&isFidAcc) { |
5ecc6e9b | 477 | fHistNEvents->Fill(2); // count selected with loosest cuts |
83e7d8d8 | 478 | if(fDebug>1) printf("+++++++Is Selected\n"); |
cbedddce | 479 | |
f80a6da9 | 480 | Double_t* invMass=0x0; |
481 | Int_t nmasses; | |
482 | CalculateInvMasses(d,invMass,nmasses); | |
483 | ||
cbedddce | 484 | const Int_t nvars=fRDCuts->GetNVarsForOpt(); |
485 | Float_t *vars = new Float_t[nvars]; | |
486 | Int_t nVals=0; | |
487 | ||
488 | fRDCuts->GetCutVarsForOpt(d,vars,nvars,pdgdaughters); | |
489 | Int_t ptbin=fRDCuts->PtBin(d->Pt()); | |
490 | if(ptbin==-1) continue; | |
491 | TString mdvname=Form("multiDimVectorPtBin%d",ptbin); | |
492 | ULong64_t *addresses = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetGlobalAddressesAboveCuts(vars,(Float_t)d->Pt(),nVals); | |
493 | if(fDebug>1)printf("nvals = %d\n",nVals); | |
cbedddce | 494 | for(Int_t ivals=0;ivals<nVals;ivals++){ |
495 | if(addresses[ivals]>=((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetNTotCells()){ | |
496 | if (fDebug>1) printf("Overflow!!\n"); | |
497 | return; | |
498 | } | |
cbedddce | 499 | |
f80a6da9 | 500 | fHistNEvents->Fill(3); |
cbedddce | 501 | |
f80a6da9 | 502 | //fill the histograms with the appropriate method |
503 | switch (fDecChannel){ | |
504 | case 0: | |
505 | FillDplus(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
506 | break; | |
507 | case 1: | |
508 | FillD02p(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
509 | break; | |
510 | case 2: | |
511 | FillDstar(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
512 | break; | |
513 | case 3: | |
514 | FillDs(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
515 | break; | |
516 | case 4: | |
517 | FillD04p(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
518 | break; | |
519 | case 5: | |
520 | FillLambdac(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),invMass,isSelected); | |
521 | break; | |
522 | default: | |
523 | break; | |
cbedddce | 524 | } |
f80a6da9 | 525 | |
cbedddce | 526 | } |
cbedddce | 527 | }// end if selected |
cbedddce | 528 | |
529 | } | |
f80a6da9 | 530 | |
cbedddce | 531 | PostData(1,fOutput); |
532 | return; | |
533 | } | |
534 | ||
f80a6da9 | 535 | //*************************************************************************** |
536 | ||
537 | // Methods used in the UserExec | |
538 | ||
539 | void AliAnalysisTaskSESignificance::CalculateInvMasses(AliAODRecoDecayHF* d,Double_t*& masses,Int_t& nmasses){ | |
540 | //Calculates all the possible invariant masses for each candidate | |
541 | //NB: the implementation for each candidate is responsibility of the corresponding developer | |
542 | ||
543 | switch(fDecChannel){ | |
544 | case 0: | |
545 | //D+ -- Giacomo, Renu ? | |
546 | { | |
547 | nmasses=1; | |
548 | masses=new Double_t[nmasses]; | |
549 | Int_t pdgdaughters[3] = {211,321,211}; | |
550 | masses[0]=d->InvMass(3,(UInt_t*)pdgdaughters); | |
551 | } | |
552 | break; | |
553 | case 1: | |
554 | //D0 (Kpi) -- Chiara | |
555 | { | |
556 | const Int_t ndght=2; | |
557 | nmasses=2; | |
558 | masses=new Double_t[nmasses]; | |
559 | Int_t pdgdaughtersD0[ndght]={211,321};//pi,K | |
560 | masses[0]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0); //D0 | |
561 | Int_t pdgdaughtersD0bar[ndght]={321,211};//K,pi | |
562 | masses[1]=d->InvMass(ndght,(UInt_t*)pdgdaughtersD0bar); //D0bar | |
563 | } | |
564 | break; | |
565 | case 2: | |
566 | //D* -- ? Yifei, Alessandro | |
567 | { | |
568 | //..... | |
569 | } | |
570 | break; | |
571 | case 3: | |
572 | //Ds -- Sergey, Sahdana | |
573 | { | |
4d829de7 | 574 | const Int_t ndght=3; |
575 | nmasses=2; | |
576 | masses=new Double_t[nmasses]; | |
577 | Int_t pdgdaughtersDsKKpi[ndght]={321,321,211};//K,K,pi | |
578 | masses[0]=d->InvMass(ndght,(UInt_t*)pdgdaughtersDsKKpi); //Ds | |
579 | Int_t pdgdaughtersDspiKK[ndght]={211,321,321};//pi,K,K | |
580 | masses[1]=d->InvMass(ndght,(UInt_t*)pdgdaughtersDspiKK); //Dsbar | |
581 | ||
f80a6da9 | 582 | //..... |
583 | } | |
584 | break; | |
585 | case 4: | |
586 | //D0 (Kpipipi) -- ? Rossella, Fabio ??? | |
587 | { | |
588 | //..... | |
589 | } | |
590 | break; | |
591 | case 5: | |
592 | //Lambda_c -- Rossella | |
593 | { | |
594 | //..... | |
595 | } | |
596 | break; | |
597 | default: | |
598 | break; | |
599 | } | |
600 | } | |
601 | ||
602 | //******************************************************************************************** | |
603 | ||
604 | //Methods to fill the istograms with MC information, one for each candidate | |
605 | //NB: the implementation for each candidate is responsibility of the corresponding developer | |
606 | ||
607 | void AliAnalysisTaskSESignificance::FillDplus(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Double_t* masses,Int_t isSel){ | |
608 | //D+ channel | |
609 | if(!isSel){ | |
610 | AliError("Candidate not selected\n"); | |
611 | return; | |
612 | } | |
613 | ||
614 | if(fPartOrAndAntiPart*d->GetCharge()<0)return; | |
615 | ||
616 | fMassHist[index]->Fill(masses[0]); | |
617 | ||
618 | Int_t pdgdaughters[3] = {211,321,211}; | |
619 | ||
620 | if(fReadMC){ | |
621 | Int_t lab=-1; | |
622 | lab = d->MatchToMC(411,arrayMC,3,pdgdaughters); | |
623 | if(lab>=0){ //signal | |
624 | fSigHist[index]->Fill(masses[0]); | |
625 | } else{ //background | |
626 | fBkgHist[index]->Fill(masses[0]); | |
627 | } | |
628 | } | |
629 | } | |
630 | ||
631 | ||
632 | void AliAnalysisTaskSESignificance::FillD02p(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Double_t* masses,Int_t isSel){ | |
633 | ||
634 | //D0->Kpi channel | |
635 | ||
636 | //mass histograms | |
637 | if(!masses){ | |
638 | AliError("Masses not calculated\n"); | |
639 | return; | |
640 | } | |
641 | if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0) fMassHist[index]->Fill(masses[0]); | |
642 | if(isSel>=2 && fPartOrAndAntiPart<=0) fMassHist[index]->Fill(masses[1]); | |
643 | ||
644 | ||
4d829de7 | 645 | |
f80a6da9 | 646 | //MC histograms |
647 | if(fReadMC){ | |
648 | ||
649 | Int_t matchtoMC=-1; | |
650 | ||
651 | //D0 | |
652 | Int_t pdgdaughters[2]; | |
653 | pdgdaughters[0]=211;//pi | |
654 | pdgdaughters[1]=321;//K | |
655 | Int_t nprongs=2; | |
656 | Int_t absPdgMom=421; | |
657 | ||
658 | matchtoMC = d->MatchToMC(absPdgMom,arrayMC,nprongs,pdgdaughters); | |
659 | ||
660 | Int_t prongPdgPlus=421,prongPdgMinus=(-1)*421; | |
661 | if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0){ //D0 | |
662 | if(matchtoMC>=0){ | |
663 | AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC); | |
664 | Int_t pdgMC = dMC->GetPdgCode(); | |
665 | ||
666 | if(pdgMC==prongPdgPlus) fSigHist[index]->Fill(masses[0]); | |
667 | else fRflHist[index]->Fill(masses[0]); | |
668 | ||
669 | } else fBkgHist[index]->Fill(masses[0]); | |
670 | ||
671 | } | |
672 | if(isSel>=2 && fPartOrAndAntiPart<=0){ //D0bar | |
673 | if(matchtoMC>=0){ | |
674 | AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC); | |
675 | Int_t pdgMC = dMC->GetPdgCode(); | |
676 | ||
677 | if(pdgMC==prongPdgMinus) fSigHist[index]->Fill(masses[1]); | |
678 | else fRflHist[index]->Fill(masses[1]); | |
679 | } else fBkgHist[index]->Fill(masses[1]); | |
680 | } | |
681 | } | |
682 | } | |
683 | ||
684 | void AliAnalysisTaskSESignificance::FillDstar(AliAODRecoDecayHF* /*d*/,TClonesArray */*arrayMC*/,Int_t /*index*/,Double_t* /*masses*/,Int_t /*matchtoMC*/){ | |
685 | //D* channel | |
686 | ||
687 | AliInfo("Dstar channel not implemented\n"); | |
688 | ||
689 | } | |
690 | ||
691 | ||
4d829de7 | 692 | void AliAnalysisTaskSESignificance::FillDs(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Double_t* masses,Int_t isSel){ |
693 | ||
694 | //AliInfo("Ds channel not implemented\n"); | |
695 | ||
696 | ||
697 | if(!masses){ | |
698 | AliError("Masses not calculated\n"); | |
699 | return; | |
700 | } | |
701 | ||
702 | Int_t pdgDstoKKpi[3]={321,321,211}; | |
703 | Int_t labDs=-1; | |
704 | if(fReadMC){ | |
705 | labDs = d->MatchToMC(431,arrayMC,3,pdgDstoKKpi); | |
706 | } | |
707 | ||
708 | ||
709 | if(isSel&1 && fPartOrAndAntiPart*d->GetCharge()>=0) { | |
710 | ||
711 | fMassHist[index]->Fill(masses[0]); | |
712 | ||
713 | if(fReadMC){ | |
f80a6da9 | 714 | |
4d829de7 | 715 | if(labDs>=0){ |
716 | Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel(); | |
717 | AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0); | |
718 | Int_t pdgCode0=TMath::Abs(p->GetPdgCode()); | |
719 | ||
720 | if(pdgCode0==321) { | |
721 | ||
722 | fSigHist[index]->Fill(masses[0]); //signal | |
723 | }else{ | |
724 | fRflHist[index]->Fill(masses[0]); //Reflected signal | |
725 | } | |
726 | }else{ | |
727 | fBkgHist[index]->Fill(masses[0]); // Background | |
728 | } | |
729 | } | |
730 | } | |
731 | ||
732 | if(isSel&2 && fPartOrAndAntiPart*d->GetCharge()>=0){ | |
733 | fMassHist[index]->Fill(masses[1]); | |
734 | if(fReadMC){ | |
735 | if(labDs>=0){ | |
736 | Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel(); | |
737 | AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0); | |
738 | Int_t pdgCode0=TMath::Abs(p->GetPdgCode()); | |
739 | ||
740 | if(pdgCode0==211) { | |
741 | ||
742 | fSigHist[index]->Fill(masses[1]); | |
743 | }else{ | |
744 | fRflHist[index]->Fill(masses[1]); | |
745 | } | |
746 | }else{ | |
747 | fBkgHist[index]->Fill(masses[1]); | |
748 | } | |
749 | } | |
750 | } | |
751 | ||
752 | ||
753 | //MC histograms | |
754 | ||
f80a6da9 | 755 | //Ds channel |
756 | // Int_t isKKpi=0; | |
757 | // Int_t ispiKK=0; | |
758 | // isKKpi=isSelected&1; | |
759 | // ispiKK=isSelected&2; | |
760 | ||
761 | // Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel(); | |
762 | // AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0); | |
763 | // Int_t pdgCode0=TMath::Abs(p->GetPdgCode()); | |
764 | ||
765 | // if(isKKpi){ | |
766 | // if(pdgCode0==321){ | |
767 | // fSigHist[index]->Fill(masses[0]); | |
768 | // }else{ | |
769 | // fRflHist[index]->Fill(masses[0]); | |
770 | // } | |
771 | // } | |
772 | // if(ispiKK){ | |
773 | // if(pdgCode0==211){ | |
774 | // fSigHist[index]->Fill(masses[1]); | |
775 | // }else{ | |
776 | // fRflHist[index]->Fill(masses[1]); | |
777 | // } | |
778 | // } | |
779 | ||
780 | } | |
781 | ||
782 | void AliAnalysisTaskSESignificance::FillD04p(AliAODRecoDecayHF* /*d*/,TClonesArray */*arrayMC*/,Int_t /*index*/,Double_t* /*masses*/,Int_t /*matchtoMC*/){ | |
783 | //D0->Kpipipi channel | |
784 | AliInfo("D0 in 4 prongs channel not implemented\n"); | |
785 | ||
786 | } | |
787 | ||
788 | void AliAnalysisTaskSESignificance::FillLambdac(AliAODRecoDecayHF* /*d*/,TClonesArray */*arrayMC*/,Int_t /*index*/,Double_t* /*masses*/,Int_t /*matchtoMC*/){ | |
789 | AliInfo("Lambdac channel not implemented\n"); | |
790 | ||
791 | //Lambdac channel | |
792 | // Int_t ispKpi=0; | |
793 | // Int_t ispiKp=0; | |
794 | ||
795 | // ispKpi=isSelected&1; | |
796 | // ispiKp=isSelected&2; | |
797 | // if(matchtoMC>=0){ | |
798 | // Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel(); | |
799 | // AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0); | |
800 | // Int_t pdgCode0=TMath::Abs(p->GetPdgCode()); | |
801 | // if(ispKpi){ | |
802 | // if(pdgCode0==2212){ | |
803 | // fSigHist[index]->Fill(invMass[0]); | |
804 | // }else{ | |
805 | // fRflHist[index]->Fill(invMass[0]); | |
806 | // } | |
807 | // } | |
808 | // if(ispiKp){ | |
809 | // if(pdgCode0==211){ | |
810 | // fSigHist[index]->Fill(invMass[1]); | |
811 | // }else{ | |
812 | // fRflHist[index]->Fill(invMass[1]); | |
813 | // } | |
814 | // } | |
815 | // }else{ | |
816 | // fBkgHist[index] | |
817 | // } | |
818 | ||
819 | ||
820 | } | |
821 | ||
cbedddce | 822 | |
823 | //________________________________________________________________________ | |
824 | void AliAnalysisTaskSESignificance::Terminate(Option_t */*option*/) | |
825 | { | |
826 | // Terminate analysis | |
827 | // | |
828 | if(fDebug > 1) printf("AnalysisTaskSESignificance: Terminate() \n"); | |
829 | ||
830 | ||
831 | fOutput = dynamic_cast<TList*> (GetOutputData(1)); | |
832 | if (!fOutput) { | |
833 | printf("ERROR: fOutput not available\n"); | |
834 | return; | |
835 | } | |
836 | ||
837 | fCutList = dynamic_cast<TList*> (GetOutputData(2)); | |
838 | if (!fCutList) { | |
839 | printf("ERROR: fCutList not available\n"); | |
840 | return; | |
841 | } | |
842 | ||
843 | AliMultiDimVector* mdvtmp=(AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0"); | |
844 | if (!mdvtmp){ | |
845 | cout<<"multidimvec not found in TList"<<endl; | |
846 | fCutList->ls(); | |
847 | return; | |
848 | } | |
849 | Int_t nHist=mdvtmp->GetNTotCells(); | |
850 | TCanvas *c1=new TCanvas("c1","Invariant mass distribution - loose cuts",500,500); | |
851 | Bool_t drawn=kFALSE; | |
852 | for(Int_t i=0;i<nHist;i++){ | |
853 | ||
854 | TString hisname; | |
855 | TString signame; | |
856 | TString bkgname; | |
857 | TString rflname; | |
858 | ||
859 | hisname.Form("hMass_%d",i); | |
860 | signame.Form("hSig_%d",i); | |
861 | bkgname.Form("hBkg_%d",i); | |
862 | rflname.Form("hRfl_%d",i); | |
863 | ||
864 | fMassHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data())); | |
865 | ||
866 | if (!drawn && fMassHist[i]->GetEntries() > 0){ | |
867 | c1->cd(); | |
868 | fMassHist[i]->Draw(); | |
869 | drawn=kTRUE; | |
870 | } | |
871 | ||
872 | if(fReadMC){ | |
873 | fSigHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(signame.Data())); | |
874 | fBkgHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(bkgname.Data())); | |
f80a6da9 | 875 | if(fDecChannel != AliAnalysisTaskSESignificance::kDplustoKpipi) fRflHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(rflname.Data())); |
cbedddce | 876 | } |
877 | ||
878 | } | |
879 | ||
880 | ||
881 | ||
882 | ||
883 | return; | |
884 | } | |
ab3e5f67 | 885 | //------------------------------------------- |
cbedddce | 886 |