AliPhysics  ced2227 (ced2227)
AliAnalysisTaskSEBkgLikeSignD0.cxx
Go to the documentation of this file.
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 /* $Id$ */
17 
19 //
20 // AliAnalysisTaskSE for reading both reconstructed D0->Kpi candidates
21 // and like sign pairs and for drawing corresponding distributions
22 //
23 // Author: C.Di Giglio, carmelo.digiglio@ba.infn.it
25 
26 #include <TSystem.h>
27 #include <TROOT.h>
28 #include <TClonesArray.h>
29 #include <TList.h>
30 #include <TH1F.h>
31 
32 #include "AliAnalysisManager.h"
33 #include "AliAODHandler.h"
34 #include "AliAODEvent.h"
35 #include "AliAODVertex.h"
36 #include "AliAODTrack.h"
38 #include "AliAnalysisVertexingHF.h"
39 #include "AliAnalysisTaskSE.h"
41 
45 
46 //________________________________________________________________________
49 fOutput(0),
50 fHistMassD0(0),
51 fHistMassLS(0),
52 fHistCtsD0(0),
53 fHistCtsLS(0),
54 fHistCtsLSpos(0),
55 fHistCtsLSneg(0),
56 fHistCPtaD0(0),
57 fHistCPtaLS(0),
58 fHistd0d0D0(0),
59 fHistd0d0LS(0),
60 fHistDCAD0(0),
61 fHistDCALS(0),
62 fVHF(0),
63 fNentries(0),
64 fTotPosPairs(0),
65 fTotNegPairs(0),
66 fLsNormalization(1.)
67 {
68  //
70  //
71 }
72 
73 //________________________________________________________________________
75 AliAnalysisTaskSE(name),
76 fOutput(0),
77 fHistMassD0(0),
78 fHistMassLS(0),
79 fHistCtsD0(0),
80 fHistCtsLS(0),
81 fHistCtsLSpos(0),
82 fHistCtsLSneg(0),
83 fHistCPtaD0(0),
84 fHistCPtaLS(0),
85 fHistd0d0D0(0),
86 fHistd0d0LS(0),
87 fHistDCAD0(0),
88 fHistDCALS(0),
89 fVHF(0),
90 fNentries(0),
91 fTotPosPairs(0),
92 fTotNegPairs(0),
94 {
95  //
97  //
98  // Output slot #1 writes into a TList container
99  DefineOutput(1,TList::Class()); //My private output
100  // Output slot #2 writes into a TH1F container
101  DefineOutput(2,TH1F::Class()); //My private output
102 
103 }
104 
105 //________________________________________________________________________
107 {
109  if (fOutput) {
110  delete fOutput;
111  fOutput = 0;
112  }
113 
114  if (fVHF) {
115  delete fVHF;
116  fVHF = 0;
117  }
118 
119  if (fNentries){
120  delete fNentries;
121  fNentries = 0;
122  }
123 
124 }
125 //________________________________________________________________________
127 {
129 
130  if(fDebug > 1) printf("AnalysisTaskSEBkgLikeSignD0::Init() \n");
131 
132  gROOT->LoadMacro("ConfigVertexingHF.C");
133 
134  fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
135  //fVHF->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,1,1,-0.00025,0.8);
136  fVHF->PrintStatus();
137 
138  return;
139 }
140 
141 //________________________________________________________________________
143 {
145  //
146  if(fDebug > 1) printf("AnalysisTaskSEBkgLikeSignD0::UserCreateOutputObjects() \n");
147 
148  // Several histograms are more conveniently managed in a TList
149  fOutput = new TList();
150  fOutput->SetOwner();
151 
152  fHistMassD0 = new TH1F("fHistMassD0", "D0 invariant mass; M [GeV]; Entries",200,1.765,1.965);
153  fHistMassD0->Sumw2();
154  fHistMassD0->SetMinimum(0);
155  fOutput->Add(fHistMassD0);
156 
157  fHistMassLS = new TH1F("fHistMassLS", "Like sign pairs invariant mass; M [GeV]; Entries",200,1.765,1.965);
158  fHistMassLS->Sumw2();
159  fHistMassLS->SetMinimum(0);
160  fOutput->Add(fHistMassLS);
161 
162  fHistCtsD0 = new TH1F("fHistCtsD0", "D0 cosine of decay angle; Cos#Theta*; Entries",200,-1.,1.);
163  fHistCtsD0->Sumw2();
164  fHistCtsD0->SetMinimum(0);
165  fOutput->Add(fHistCtsD0);
166 
167  fHistCtsLS = new TH1F("fHistCtsLS", "Like sign pairs cosine of decay angle; Cos#Theta*; Entries",200,-1.,1.);
168  fHistCtsLS->Sumw2();
169  fHistCtsLS->SetMinimum(0);
170  fOutput->Add(fHistCtsLS);
171 
172  fHistCtsLSpos = new TH1F("fHistCtsLSpos", "Like sign ++ pairs cosine of decay angle; Cos#Theta*; Entries",200,-1.,1.);
173  fHistCtsLSpos->Sumw2();
174  fHistCtsLSpos->SetMinimum(0);
175  fOutput->Add(fHistCtsLSpos);
176 
177  fHistCtsLSneg = new TH1F("fHistCtsLSneg", "Like sign -- pairs cosine of decay angle; Cos#Theta*; Entries",200,-1.,1.);
178  fHistCtsLSneg->Sumw2();
179  fHistCtsLSneg->SetMinimum(0);
180  fOutput->Add(fHistCtsLSneg);
181 
182  fHistCPtaD0 = new TH1F("fHistCPtaD0", "D0 cosine of pointing angle; Cos#Theta_{point}; Entries",200,0,1.);
183  fHistCPtaD0->Sumw2();
184  fHistCPtaD0->SetMinimum(0);
185  fOutput->Add(fHistCPtaD0);
186 
187  fHistCPtaLS = new TH1F("fHistCPtaLS", "Like sign pairs cosine of pointing angle; Cos#Theta_{point}; Entries",200,0,1.);
188  fHistCPtaLS->Sumw2();
189  fHistCPtaLS->SetMinimum(0);
190  fOutput->Add(fHistCPtaLS);
191 
192  fHistd0d0D0 = new TH1F("fHistd0d0D0", "D0 product of impact parameters; d0xd0 [#mu m^{2}]; Entries",200,-100000.,100000.);
193  fHistd0d0D0->Sumw2();
194  fHistd0d0D0->SetMinimum(0);
195  fOutput->Add(fHistd0d0D0);
196 
197  fHistd0d0LS = new TH1F("fHistd0d0LS", "Like sign pairs product of impact parameters; d0xd0 [#mu m^{2}]; Entries",200,-100000.,100000.);
198  fHistd0d0LS->Sumw2();
199  fHistd0d0LS->SetMinimum(0);
200  fOutput->Add(fHistd0d0LS);
201 
202  fHistDCAD0 = new TH1F("fHistDCAD0", "D0 distance of closest approach; dca [10^{2}#mu m]; Entries",100,0.,5.);
203  fHistDCAD0->Sumw2();
204  fHistDCAD0->SetMinimum(0);
205  fOutput->Add(fHistDCAD0);
206 
207  fHistDCALS = new TH1F("fHistDCALS", "Like sign pairs distance of closest approach; dca [10^{2}#mu m]; Entries",100,0.,5.);
208  fHistDCALS->Sumw2();
209  fHistDCALS->SetMinimum(0);
210  fOutput->Add(fHistDCALS);
211 
212  fNentries=new TH1F("nentriesLS", "Look at the number of entries! it is = to the number of AODs", 2,1.,2.);
213 
214  return;
215 }
216 
217 //________________________________________________________________________
219 {
222 
223  AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
224 
225  TClonesArray *arrayD0toKpi = 0;
226  TClonesArray *arrayLikeSign = 0;
227 
228  if(!aod && AODEvent() && IsStandardAOD()) {
229  // In case there is an AOD handler writing a standard AOD, use the AOD
230  // event in memory rather than the input (ESD) event.
231  aod = dynamic_cast<AliAODEvent*> (AODEvent());
232  // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
233  // have to taken from the AOD event hold by the AliAODExtension
234  AliAODHandler* aodHandler = (AliAODHandler*)
235  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
236  if(aodHandler->GetExtensions()) {
237  AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
238  AliAODEvent *aodFromExt = ext->GetAOD();
239  // load D0 candidates
240  arrayD0toKpi=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
241  // load like sign candidates
242  arrayLikeSign=(TClonesArray*)aodFromExt->GetList()->FindObject("LikeSign2Prong");
243  }
244  } else if(aod) {
245  // load D0 candidates
246  arrayD0toKpi=(TClonesArray*)aod->GetList()->FindObject("D0toKpi");
247  // load like sign candidates
248  arrayLikeSign=(TClonesArray*)aod->GetList()->FindObject("LikeSign2Prong");
249  }
250 
251 
252  if(!aod || !arrayD0toKpi) {
253  printf("AliAnalysisTaskSEBkgLikeSignD0::UserExec: D0toKpi branch not found!\n");
254  return;
255  }
256  if(!arrayLikeSign) {
257  printf("AliAnalysisTaskSEBkgLikeSignD0::UserExec: LikeSign2Prong branch not found!\n");
258  return;
259  }
260 
261  // fix for temporary bug in ESDfilter
262  // the AODs with null vertex pointer didn't pass the PhysSel
263  if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
264 
265 
266  // AOD primary vertex
267  AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
268 
269  // make trkIDtoEntry register (temporary)
270  Int_t trkIDtoEntry[100000];
271  for(Int_t it=0;it<aod->GetNumberOfTracks();it++) {
272  AliAODTrack *track = dynamic_cast<AliAODTrack*>(aod->GetTrack(it));
273  if(!track) AliFatal("Not a standard AOD");
274  trkIDtoEntry[track->GetID()]=it;
275  }
276 
277  //histogram filled with 1 for every AOD
278  fNentries->Fill(1);
279  PostData(2,fNentries);
280 
281  // loop over Like sign candidates
282  Int_t nPosPairs=0,nNegPairs=0;
283  Int_t nLikeSign = arrayLikeSign->GetEntriesFast();
284  if(fDebug>1) printf("+++\n+++Number of like sign pairs ---> %d \n+++\n", nLikeSign);
285 
286  for(Int_t iLikeSign = 0; iLikeSign < nLikeSign; iLikeSign++) {
287  AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayLikeSign->UncheckedAt(iLikeSign);
288  Bool_t unsetvtx=kFALSE;
289  if(!d->GetOwnPrimaryVtx()) {
290  d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
291  unsetvtx=kTRUE;
292  }
293  /*
294  Int_t okD0ls=0; Int_t okD0barls=0;
295  //if(d->SelectD0(fVHF->GetD0toKpiCuts(),okD0ls,okD0barls)) {
296  if(d) {
297  AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0);
298  if(!trk0) {
299  trk0=aod->GetTrack(trkIDtoEntry[d->GetProngID(0)]);
300  printf("references to standard AOD not available \n");
301  }
302  if(okD0ls) fHistMassLS->Fill(d->InvMassD0());
303  if(okD0barls) fHistMassLS->Fill(d->InvMassD0bar());
304  fHistCPtaLS->Fill(d->CosPointingAngle());
305  fHistd0d0LS->Fill(1e8*d->Prodd0d0());
306  if(okD0ls) fHistCtsLS->Fill(d->CosThetaStarD0());
307  if(okD0barls) fHistCtsLS->Fill(d->CosThetaStarD0bar());
308  fHistDCALS->Fill(100*d->GetDCA());
309  //PostData(1,fOutput);
310  if((trk0->Charge())==1) {
311  nPosPairs++;
312  fHistCtsLSpos->Fill(d->CosThetaStarD0());
313  //PostData(1,fOutput);
314  } else {
315  nNegPairs++;
316  fHistCtsLSneg->Fill(d->CosThetaStarD0());
317  //PostData(1,fOutput);
318  }
319  PostData(1,fOutput);
320  }
321  */
322  if(unsetvtx) d->UnsetOwnPrimaryVtx();
323  }
324 
325  if(fDebug>1) printf("------------ N. of positive pairs in Event ----- %d \n", nPosPairs);
326  if(fDebug>1) printf("------------ N. of negative pairs in Event ----- %d \n", nNegPairs);
327 
328  fTotPosPairs += nPosPairs;
329  fTotNegPairs += nNegPairs;
330 
331  // loop over D0 candidates
332  Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast();
333  if(fDebug>1) printf("Number of like D0 -> Kpi candidates ---> %d \n", nD0toKpi);
334 
335  for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) {
336  AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
337  Bool_t unsetvtx=kFALSE;
338  if(!d->GetOwnPrimaryVtx()) {
339  d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
340  unsetvtx=kTRUE;
341  }
342  //Int_t okD0=0; Int_t okD0bar=0;
343  //if(d->SelectD0(fVHF->GetD0toKpiCuts(),okD0,okD0bar)) {
344  fHistMassD0->Fill(d->InvMassD0());
345  fHistMassD0->Fill(d->InvMassD0bar());
346  fHistCtsD0->Fill(d->CosThetaStarD0());
347  fHistCtsD0->Fill(d->CosThetaStarD0bar());
348  fHistd0d0D0->Fill(1e8*d->Prodd0d0());
349  fHistCPtaD0->Fill(d->CosPointingAngle());
350  fHistDCAD0->Fill(100*d->GetDCA());
351  PostData(1,fOutput);
352 
353  if(unsetvtx) d->UnsetOwnPrimaryVtx();
354  }
355 
356  return;
357 }
358 
359 //________________________________________________________________________
361 {
363  //
364  if(fDebug > 1) printf("AnalysisTaskSEBkgLikeSignD0: Terminate() \n");
365 
366  fOutput = dynamic_cast<TList*> (GetOutputData(1));
367  if (!fOutput) {
368  printf("ERROR: fOutput not available\n");
369  return;
370  }
371 
372  fLsNormalization = 2.*TMath::Sqrt(fTotPosPairs*fTotNegPairs);
373 
374  fHistMassD0 = dynamic_cast<TH1F*>(fOutput->FindObject("fHistMassD0"));
375  fHistMassLS = dynamic_cast<TH1F*>(fOutput->FindObject("fHistMassLS"));
376  fHistCtsD0 = dynamic_cast<TH1F*>(fOutput->FindObject("fHistCtsD0"));
377  fHistCtsLS = dynamic_cast<TH1F*>(fOutput->FindObject("fHistCtsLS"));
378  fHistCtsLSpos = dynamic_cast<TH1F*>(fOutput->FindObject("fHistCtsLSpos"));
379  fHistCtsLSneg = dynamic_cast<TH1F*>(fOutput->FindObject("fHistCtsLSneg"));
380  fHistCPtaD0 = dynamic_cast<TH1F*>(fOutput->FindObject("fHistCPtaD0"));
381  fHistCPtaLS = dynamic_cast<TH1F*>(fOutput->FindObject("fHistCPtaLS"));
382  fHistd0d0D0 = dynamic_cast<TH1F*>(fOutput->FindObject("fHistd0d0D0"));
383  fHistd0d0LS = dynamic_cast<TH1F*>(fOutput->FindObject("fHistd0d0LS"));
384  fHistDCAD0 = dynamic_cast<TH1F*>(fOutput->FindObject("fHistDCAD0"));
385  fHistDCALS = dynamic_cast<TH1F*>(fOutput->FindObject("fHistDCALS"));
386 
387  if(fLsNormalization>0) {
388  if(fHistMassLS) fHistMassLS->Scale((1/fLsNormalization)*fHistMassLS->GetEntries());
389  if(fHistCtsLS) fHistCtsLS->Scale((1/fLsNormalization)*fHistCtsLS->GetEntries());
390  if(fHistCtsLSpos) fHistCtsLSpos->Scale((1/fLsNormalization)*fHistCtsLSpos->GetEntries());
391  if(fHistCtsLSneg) fHistCtsLSneg->Scale((1/fLsNormalization)*fHistCtsLSneg->GetEntries());
392  if(fHistCPtaLS) fHistCPtaLS->Scale((1/fLsNormalization)*fHistCPtaLS->GetEntries());
393  if(fHistd0d0LS) fHistd0d0LS->Scale((1/fLsNormalization)*fHistd0d0LS->GetEntries());
394  if(fHistDCALS) fHistDCALS->Scale((1/fLsNormalization)*fHistDCALS->GetEntries());
395  }
396 
397  return;
398 }
TH1F * fNentries
Vertexer heavy flavour (used to pass the cuts)
TH1F * fHistCPtaD0
! Cosine of pointing angle
TH1F * fHistd0d0D0
! Product of impact parameters
TH1F * fHistDCAD0
! Distance of closest approach
int Int_t
Definition: External.C:63
Double_t CosThetaStarD0bar() const
angle of K
AliAODVertex * GetOwnPrimaryVtx() const
TH1F * fHistCtsD0
! Cosine of decay angle
virtual void UserCreateOutputObjects()
Implementation of interface methods.
void SetOwnPrimaryVtx(const AliAODVertex *vtx)
const char Option_t
Definition: External.C:48
TList * fOutput
! list send on output slot 0
bool Bool_t
Definition: External.C:53
Double_t CosPointingAngle() const