AliPhysics  1811c8f (1811c8f)
AliAnalysisTaskSECleanupVertexingHF.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 #include <Riostream.h>
21 #include <TClonesArray.h>
22 #include <TTree.h>
23 #include <TList.h>
24 #include <TChain.h>
25 #include <TH1F.h>
26 #include <TDatabasePDG.h>
27 
28 #include <AliAnalysisDataSlot.h>
29 #include <AliAnalysisDataContainer.h>
30 #include "AliAnalysisManager.h"
31 #include "AliAODHandler.h"
32 #include "AliAODEvent.h"
33 #include "AliAODVertex.h"
34 #include "AliAODTrack.h"
35 #include "AliAODMCHeader.h"
36 #include "AliAODMCParticle.h"
37 #include "AliRDHFCuts.h"
40 #include "AliAODRecoCascadeHF.h"
41 #include "AliAnalysisVertexingHF.h"
42 #include "AliAnalysisTaskSE.h"
44 
45 using std::cout;
46 using std::endl;
47 
49 
50 
51 //________________________________________________________________________
54 //fNentries(0)
55 {
56  // Default constructor
57 
58 }
59 //_______________________________________________________
61  AliAnalysisTaskSE(name)//,
62  //fNentries(0)
63 {
64  // Default constructor
65  //DefineInput(0,TChain::Class());
66  // DefineOutput(0,TH1F::Class()); //My private output
67 }
68 //_______________________________________________________
70 {
71  //if (fNentries){
72  // delete fNentries;
73  // fNentries = 0;
74  // }
75 }
76 //________________________________________________________
78 {
79 
80  //const char* nameoutput=GetOutputSlot(1)->GetContainer()->GetName();
81  //fNentries=new TH1F(nameoutput, "Integral(1,2) = number of AODs ", 7,-0.5,6.5);
82 
83  //fNentries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
84  //fNentries->GetXaxis()->SetNdivisions(1,kFALSE);
85 
86  //PostData(1,fNentries);
87 
88 }
89 //________________________________________________________________________
91 {
92 
93  //3prong
94  TClonesArray *array3Prong = 0;
95  //2prong D0 TClones Array
96  TClonesArray *inputArrayD0=0;
97  //DStar TClonesArray
98  TClonesArray *arrayDStartoD0pi=0;
99  //Cascade TClonesArray
100  TClonesArray *arrayCascade=0;
101 
102  AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
103  if(!aod && AODEvent() && IsStandardAOD()) {
104  // In case there is an AOD handler writing a standard AOD, use the AOD
105  // event in memory rather than the input (ESD) event.
106  aod = dynamic_cast<AliAODEvent*> (AODEvent());
107  // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
108  // have to taken from the AOD event hold by the AliAODExtension
109  AliAODHandler* aodHandler = (AliAODHandler*)
110  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
111  if(aodHandler->GetExtensions()) {
112  AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
113  AliAODEvent *aodFromExt = ext->GetAOD();
114  array3Prong=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
115  inputArrayD0=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
116  arrayDStartoD0pi=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar");
117  arrayCascade=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
118  }
119  } else if(aod) {
120  array3Prong=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
121  inputArrayD0=(TClonesArray*)aod->GetList()->FindObject("D0toKpi");
122  arrayDStartoD0pi=(TClonesArray*)aod->GetList()->FindObject("Dstar");
123  arrayCascade=(TClonesArray*)aod->GetList()->FindObject("CascadesHF");
124  }
125  if(!aod){
126  printf("AliAnalysisTaskSECleanupVertexingHF::UserExec: aod not found!\n");
127  return;
128  }
129  if(!array3Prong || !inputArrayD0 || !arrayDStartoD0pi) {
130  printf("AliAnalysisTaskSECleanupVertexingHF::UserExec: an input branch not found!\n");
131  }
132  // the AODs with null vertex pointer didn't pass the PhysSel
133  if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
134 
135  // DStar
136  for(Int_t iDStartoD0pi = 0; iDStartoD0pi<arrayDStartoD0pi->GetEntriesFast(); iDStartoD0pi++) { // D* candidates and D0 from D*
137  AliAODRecoCascadeHF* recdstarD0pi = (AliAODRecoCascadeHF*)arrayDStartoD0pi->At(iDStartoD0pi);
138  if(!recdstarD0pi)continue;
139  if(recdstarD0pi->GetIsFilled()==2){
140  AliAODVertex *vtxDS = (AliAODVertex*)recdstarD0pi->GetSecondaryVtx();
141  if(vtxDS) {delete vtxDS; vtxDS=0;}
142  }else continue;
143  }
144 
145  // D0toKpi
146  for (Int_t iD0toKpi = 0; iD0toKpi < inputArrayD0->GetEntriesFast(); iD0toKpi++) {
147  AliAODRecoDecayHF2Prong *recd = (AliAODRecoDecayHF2Prong*)inputArrayD0->UncheckedAt(iD0toKpi);
148  if(!recd)continue;
149  if(recd->GetIsFilled()==2){
150  AliAODVertex *vtx2 = (AliAODVertex*)recd->GetSecondaryVtx();
151  if(vtx2){delete vtx2;vtx2=0;}
152  }else continue;
153  }
154  //3Prong
155  for (Int_t i3prong = 0; i3prong < array3Prong->GetEntriesFast(); i3prong++) {
156  AliAODRecoDecayHF3Prong *recd3 = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3prong);
157  if(!recd3)continue;
158  if(recd3->GetIsFilled()==2){
159  AliAODVertex *vtx3 = (AliAODVertex*)recd3->GetSecondaryVtx();
160  if(vtx3){delete vtx3;vtx3=0;}
161  }else continue;
162  }
163  //Cascade
164  if(arrayCascade){
165  for(Int_t iCasc=0; iCasc<arrayCascade->GetEntriesFast(); iCasc++){
166  AliAODRecoCascadeHF* recCasc = dynamic_cast<AliAODRecoCascadeHF*>(arrayCascade->At(iCasc));
167  if(!recCasc)continue;
168  if(recCasc->GetIsFilled()==2){
169  AliAODVertex *vtxCasc = (AliAODVertex*)recCasc->GetSecondaryVtx();
170  if(vtxCasc){delete vtxCasc; vtxCasc=0;}
171  }else continue;
172  }
173  }
174 
175  return;
176 }
177 //_________________________
179 {
180  // Terminate analysis
181  //
182  //fNentries = dynamic_cast<TH1F*>(GetOutputData(0));
183  //if(!fNentries){
184  // printf("ERROR: fNEntries not available\n");
185  return;
186 }
187 
188 
189 
int Int_t
Definition: External.C:63
Int_t GetIsFilled() const
const char Option_t
Definition: External.C:48