3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* Sedat Altinpinar <Sedat.Altinpinar@cern.ch> *
9 //* Hege Erdal <hege.erdal@gmail.com> *
11 //* Permission to use, copy, modify and distribute this software and its *
12 //* documentation strictly for non-commercial purposes is hereby granted *
13 //* without fee, provided that the above copyright notice appears in all *
14 //* copies and that both the copyright notice and this permission notice *
15 //* appear in the supporting documentation. The authors make no claims *
16 //* about the suitability of this software for any purpose. It is *
17 //* provided "as is" without express or implied warranty. *
18 //**************************************************************************
20 /// @file AliDxHFEParticleSelectionD0.cxx
21 /// @author Sedat Altinpinar, Hege Erdal, Matthias Richter
23 /// @brief D0 selection for D0-HFE correlation
26 #include "AliDxHFEParticleSelectionD0.h"
27 #include "AliVParticle.h"
28 //#include "AliAnalysisCuts.h" // required dependency libANALYSISalice.so
29 //#include "AliFlowTrackSimple.h" // required dependency libPWGflowBase.so
30 //#include "AliFlowCandidateTrack.h" // required dependency libPWGflowTasks.so
31 //#include "AliCFContainer.h" // required dependency libCORRFW.so
32 #include "AliAODRecoDecayHF2Prong.h" // libPWGHFvertexingHF
33 #include "AliRDHFCutsD0toKpi.h"
34 #include "TObjArray.h"
35 #include "THnSparse.h"
44 /// ROOT macro for the implementation of ROOT specific class methods
45 ClassImp(AliDxHFEParticleSelectionD0)
47 AliDxHFEParticleSelectionD0::AliDxHFEParticleSelectionD0(const char* opt)
48 : AliDxHFEParticleSelection("D0", opt)
62 TString strOption(opt);
63 // TODO: one might need a proper argument parsing including
64 // chopping whole string into individual arguments
65 if (strOption.Contains("FillD0D0bar")) fFillOnlyD0D0bar=0;
66 else if (strOption.Contains("FillOnlyD0")) fFillOnlyD0D0bar=1;
67 else if (strOption.Contains("FillOnlyD0bar")) fFillOnlyD0D0bar=2;
70 AliDxHFEParticleSelectionD0::~AliDxHFEParticleSelectionD0()
86 // Note: external object deleted elsewhere
90 const char* AliDxHFEParticleSelectionD0::fgkTrackControlBinNames[]={
98 const char* AliDxHFEParticleSelectionD0::fgkDgTrackControlBinNames[]={
106 int AliDxHFEParticleSelectionD0::InitControlObjects()
108 /// init the control objects, can be overloaded by childs which should
109 /// call AliDxHFEParticleSelection::InitControlObjects() explicitly
111 fD0Properties=DefineTHnSparse();
112 AddControlObject(fD0Properties);
114 //Adding control objects for the daughters
115 InitControlObjectsDaughters("pi information",0);
116 InitControlObjectsDaughters("K information",1);
118 return AliDxHFEParticleSelection::InitControlObjects();
121 THnSparse* AliDxHFEParticleSelectionD0::DefineTHnSparse() const
124 // Defines the THnSparse. For now, only calls CreateControlTHnSparse
125 // TODO: remove pt?? (Have ptbin)
127 const int thnSize2 = 5;
128 const double Pi=TMath::Pi();
130 name.Form("%s info", GetName());
133 // Pt Phi Ptbin D0InvMass Eta
134 int thnBins[thnSize2] = { 1000, 200, 21, 200, 500 };
135 double thnMin [thnSize2] = { 0, 0, 0, 1.5648, -1. };
136 double thnMax [thnSize2] = { 100, 2*Pi, 20, 2.1648, 1. };
138 return CreateControlTHnSparse(name,thnSize2,thnBins,thnMin,thnMax,fgkTrackControlBinNames);
142 int AliDxHFEParticleSelectionD0::DefineParticleProperties(AliVParticle* p, Double_t* data, int dimension) const
144 // fill the data array from the particle data
145 if (!data) return -EINVAL;
146 // AliAODTrack *track=(AliAODTrack*)p;
147 AliAODRecoDecayHF2Prong* track=dynamic_cast<AliAODRecoDecayHF2Prong*>(p);
148 if (!track) return -ENODATA;
150 // TODO: this corresponds to the THnSparse dimensions which is available in the same class
151 // use this consistently
152 const int requiredDimension=5;
153 if (dimension!=requiredDimension) {
154 // TODO: think about filling only the available data and throwing a warning
157 data[i++]=track->Pt();
158 data[i++]=track->Phi();
160 data[i++]=fD0InvMass;
161 data[i++]=track->Eta();
166 int AliDxHFEParticleSelectionD0::InitControlObjectsDaughters(TString name, int daughter)
168 // Setting up Control objects for the daughters.
169 // Move to ParticleSelection??
170 AliInfo("Setting up daughter THnSparse");
172 const int thnSize2 = 5;
173 const double Pi=TMath::Pi();
175 // Pt Phi Ptbin D0InvMass Eta
176 int thnBins[thnSize2] = { 1000, 200, 21, 200, 500};
177 double thnMin [thnSize2] = { 0, 0, 0, 1.5648, -1.};
178 double thnMax [thnSize2] = { 100, 2*Pi, 20, 2.1648, 1.};
180 std::auto_ptr<THnSparseF> DaughterProperties(new THnSparseF(name, name, thnSize2, thnBins, thnMin, thnMax));
182 if (DaughterProperties.get()==NULL) {
186 for(int iLabel=0; iLabel< 5;iLabel++)
187 DaughterProperties->GetAxis(iLabel)->SetTitle(fgkDgTrackControlBinNames[iLabel]);
190 fD0Daughter0=DaughterProperties.release();
191 AddControlObject(fD0Daughter0);
195 fD0Daughter1=DaughterProperties.release();
196 AddControlObject(fD0Daughter1);
201 int AliDxHFEParticleSelectionD0::HistogramParticleProperties(AliVParticle* p, int selectionCode)
204 /// histogram particle properties
205 if (!p) return -EINVAL;
207 // fill the common histograms
208 AliDxHFEParticleSelection::HistogramParticleProperties(p, selectionCode);
210 // no daughters to fill if 0 (= no candidate)
211 if (selectionCode==0) return 0;
213 AliAODRecoDecayHF2Prong* part=dynamic_cast<AliAODRecoDecayHF2Prong*>(p);
216 // Convention: 1. daughter is postive track, 2. = negative
217 AliAODTrack *prongpos=(AliAODTrack*)part->GetDaughter(0);
218 AliAODTrack *prongneg=(AliAODTrack*)part->GetDaughter(1);
220 if(!prongpos || !prongneg) {
224 // Only D0s are filled
225 // TODO: Also include D0bar
226 if ((selectionCode==1 || selectionCode==3) && fFillOnlyD0D0bar<2) {
227 fD0InvMass= part->InvMassD0();
228 fPtBin=fCuts->PtBin(part->Pt());
230 // TODO: avoid repeated allocation of the arrays
231 Double_t KProperties[]={prongneg->Pt(),prongneg->Phi(),fPtBin, fD0InvMass,prongneg->Eta()};
232 Double_t piProperties[]={prongpos->Pt(),prongpos->Phi(),fPtBin,fD0InvMass,prongpos->Eta()};
234 // TODO: make array a member, consistent dimensions for THnSparse and array
235 Double_t d0Properties[5]={0.0, 0.0, 0.0, 0.0, 0.0};
236 DefineParticleProperties(p, d0Properties, 5);
237 if(fD0Properties) fD0Properties->Fill(d0Properties);
238 if(fD0Daughter0) fD0Daughter0->Fill(piProperties);
239 if(fD0Daughter1) fD0Daughter1->Fill(KProperties);
245 TObjArray* AliDxHFEParticleSelectionD0::Select(TObjArray* pTracks, const AliVEvent *pEvent)
247 /// create selection, array contains only pointers but does not own the objects
248 /// object array needs to be deleted by caller
249 if (!pTracks) return NULL;
250 TObjArray* selectedTracks=new TObjArray;
251 if (!selectedTracks) return NULL;
252 TIter itrack(pTracks);
254 while ((pObj=itrack())!=NULL) {
255 AliVParticle* track=dynamic_cast<AliVParticle*>(pObj);
256 if (!track) continue;
257 int selectionCode=IsSelected(track,pEvent);
258 HistogramParticleProperties(track, selectionCode);
260 //TODO: Also add selection for D0bar
261 // Add track if it is either defined as D0(selectionCode==1) or both
262 // D0bar and a D0 (selectionCode==3)
263 if (! ((selectionCode==1 || selectionCode==3) && fFillOnlyD0D0bar<2)) continue;
264 selectedTracks->Add(track);
266 return selectedTracks;
269 int AliDxHFEParticleSelectionD0::IsSelected(AliVParticle* p, const AliVEvent* pEvent)
271 /// TODO: implement specific selection of D0 candidates
272 /// Could also return values based on where where selection "failed
273 /// Selected. Return 0 (none), 1(D0), 2(D0bar) or 3 (both)
277 AliAODRecoDecayHF2Prong *d0 = dynamic_cast<AliAODRecoDecayHF2Prong*>(p);
278 if(d0->GetSelectionMap()) if(!d0->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)){
279 AliDebug(1,"Skip D0 from Dstar");
280 return 0; //skip the D0 from Dstar
283 // TODO: the cuts instance should be const but the function definition of
284 // AliRDHFCuts::IsSelected does not allow this
285 AliRDHFCuts* cuts=const_cast<AliRDHFCuts*>(fCuts);
288 } else if(cuts->IsInFiducialAcceptance(d0->Pt(),d0->Y(421)) ) {
290 Int_t ptbin=cuts->PtBin(d0->Pt());
292 AliDebug(1,"Pt out of bounds");
296 // TODO: the aod pointer should also be const but the function definition of
297 // AliRDHFCuts::IsSelected does not allow this
298 AliAODEvent* aod=NULL;
299 if (pEvent) aod=dynamic_cast<AliAODEvent*>(const_cast<AliVEvent*>(pEvent));
301 // Selected. Return 0 (none), 1 (D0), 2 (D0bar) or 3 (both)
302 selectionCode=cuts->IsSelected(d0,AliRDHFCuts::kAll,aod);
304 AliDebug(1,Form("Candidate is %d \n", selectionCode));
306 daughters.AddAt((AliAODTrack*)d0->GetDaughter(0),0);
307 daughters.AddAt((AliAODTrack*)d0->GetDaughter(1),1);
310 if(!daughters.UncheckedAt(0) || !daughters.UncheckedAt(1)) {
311 AliDebug(1,"at least one daughter not found!");
317 return selectionCode;
320 void AliDxHFEParticleSelectionD0::SetCuts(TObject* cuts, int /*level*/)
323 fCuts=dynamic_cast<AliRDHFCuts*>(cuts);
324 if (!fCuts && cuts) {
325 AliError(Form("cuts object is not of required type AliRDHFCuts but %s", cuts->ClassName()));