]>
Commit | Line | Data |
---|---|---|
72c0a987 | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | //* Sedat Altinpinar <Sedat.Altinpinar@cern.ch> * | |
9 | //* Hege Erdal <hege.erdal@gmail.com> * | |
10 | //* * | |
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 | //************************************************************************** | |
19 | ||
20 | /// @file AliDxHFEParticleSelectionD0.cxx | |
21 | /// @author Sedat Altinpinar, Hege Erdal, Matthias Richter | |
22 | /// @date 2012-03-19 | |
23 | /// @brief D0 selection for D0-HFE correlation | |
24 | /// | |
25 | ||
26 | #include "AliDxHFEParticleSelectionD0.h" | |
27 | #include "AliVParticle.h" | |
9535cec9 | 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 | |
93fcaf9f | 32 | #include "AliAODRecoDecayHF2Prong.h" // libPWGHFvertexingHF |
9535cec9 | 33 | #include "AliRDHFCutsD0toKpi.h" |
72c0a987 | 34 | #include "TObjArray.h" |
93fcaf9f | 35 | #include "THnSparse.h" |
36 | #include "TAxis.h" | |
9535cec9 | 37 | #include "TString.h" |
93fcaf9f | 38 | #include <iostream> |
39 | #include <cerrno> | |
40 | #include <memory> | |
72c0a987 | 41 | |
9535cec9 | 42 | using namespace std; |
43 | ||
72c0a987 | 44 | /// ROOT macro for the implementation of ROOT specific class methods |
45 | ClassImp(AliDxHFEParticleSelectionD0) | |
46 | ||
47 | AliDxHFEParticleSelectionD0::AliDxHFEParticleSelectionD0(const char* opt) | |
93fcaf9f | 48 | : AliDxHFEParticleSelection("D0", opt) |
49 | , fD0Properties(NULL) | |
9535cec9 | 50 | , fD0Daughter0(NULL) |
51 | , fD0Daughter1(NULL) | |
52 | , fCuts(NULL) | |
53 | , fFillOnlyD0D0bar(0) | |
d731501a | 54 | , fD0InvMass(0.0) |
55 | , fPtBin(-1) | |
72c0a987 | 56 | { |
57 | // constructor | |
58 | // | |
59 | // | |
60 | // | |
61 | // | |
9535cec9 | 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; | |
72c0a987 | 68 | } |
69 | ||
70 | AliDxHFEParticleSelectionD0::~AliDxHFEParticleSelectionD0() | |
71 | { | |
72 | // destructor | |
9535cec9 | 73 | if (fD0Properties) { |
74 | delete fD0Properties; | |
75 | fD0Properties=NULL; | |
76 | } | |
77 | if (fD0Daughter0) { | |
78 | delete fD0Daughter0; | |
79 | fD0Daughter0=NULL; | |
80 | } | |
81 | if (fD0Daughter1) { | |
82 | delete fD0Daughter1; | |
83 | fD0Daughter1=NULL; | |
84 | } | |
85 | ||
86 | // Note: external object deleted elsewhere | |
87 | fCuts=NULL; | |
72c0a987 | 88 | } |
89 | ||
d731501a | 90 | const char* AliDxHFEParticleSelectionD0::fgkTrackControlBinNames[]={ |
91 | "Pt", | |
92 | "Phi", | |
93 | "Ptbin", | |
94 | "D0InvMass", | |
95 | "Eta" | |
96 | }; | |
97 | ||
98 | const char* AliDxHFEParticleSelectionD0::fgkDgTrackControlBinNames[]={ | |
99 | "Pt", | |
100 | "Phi", | |
101 | "Ptbin", | |
102 | "D0InvMass", | |
103 | "Eta" | |
104 | }; | |
105 | ||
93fcaf9f | 106 | int AliDxHFEParticleSelectionD0::InitControlObjects() |
107 | { | |
108 | /// init the control objects, can be overloaded by childs which should | |
109 | /// call AliDxHFEParticleSelection::InitControlObjects() explicitly | |
93fcaf9f | 110 | |
d731501a | 111 | fD0Properties=DefineTHnSparse(); |
93fcaf9f | 112 | AddControlObject(fD0Properties); |
113 | ||
9535cec9 | 114 | //Adding control objects for the daughters |
115 | InitControlObjectsDaughters("pi information",0); | |
116 | InitControlObjectsDaughters("K information",1); | |
117 | ||
93fcaf9f | 118 | return AliDxHFEParticleSelection::InitControlObjects(); |
119 | } | |
120 | ||
d731501a | 121 | THnSparse* AliDxHFEParticleSelectionD0::DefineTHnSparse() const |
122 | { | |
123 | // | |
124 | // Defines the THnSparse. For now, only calls CreateControlTHnSparse | |
125 | // TODO: remove pt?? (Have ptbin) | |
126 | ||
127 | const int thnSize2 = 5; | |
128 | const double Pi=TMath::Pi(); | |
129 | TString name; | |
130 | name.Form("%s info", GetName()); | |
131 | ||
132 | // 0 1 2 3 4 | |
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. }; | |
137 | ||
138 | return CreateControlTHnSparse(name,thnSize2,thnBins,thnMin,thnMax,fgkTrackControlBinNames); | |
139 | ||
140 | } | |
141 | ||
142 | int AliDxHFEParticleSelectionD0::DefineParticleProperties(AliVParticle* p, Double_t* data, int dimension) const | |
143 | { | |
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; | |
149 | int i=0; | |
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 | |
155 | return -ENOSPC; | |
156 | } | |
157 | data[i++]=track->Pt(); | |
158 | data[i++]=track->Phi(); | |
159 | data[i++]=fPtBin; | |
160 | data[i++]=fD0InvMass; | |
161 | data[i++]=track->Eta(); | |
162 | ||
163 | return i; | |
164 | } | |
165 | ||
9535cec9 | 166 | int AliDxHFEParticleSelectionD0::InitControlObjectsDaughters(TString name, int daughter) |
167 | { | |
d731501a | 168 | // Setting up Control objects for the daughters. |
169 | // Move to ParticleSelection?? | |
9535cec9 | 170 | AliInfo("Setting up daughter THnSparse"); |
171 | ||
172 | const int thnSize2 = 5; | |
173 | const double Pi=TMath::Pi(); | |
174 | // 0 1 2 3 4 | |
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.}; | |
179 | ||
180 | std::auto_ptr<THnSparseF> DaughterProperties(new THnSparseF(name, name, thnSize2, thnBins, thnMin, thnMax)); | |
181 | ||
182 | if (DaughterProperties.get()==NULL) { | |
183 | return -ENOMEM; | |
184 | } | |
d731501a | 185 | |
186 | for(int iLabel=0; iLabel< 5;iLabel++) | |
187 | DaughterProperties->GetAxis(iLabel)->SetTitle(fgkDgTrackControlBinNames[iLabel]); | |
9535cec9 | 188 | |
189 | if(daughter==0){ | |
190 | fD0Daughter0=DaughterProperties.release(); | |
191 | AddControlObject(fD0Daughter0); | |
192 | } | |
193 | ||
194 | if(daughter==1){ | |
195 | fD0Daughter1=DaughterProperties.release(); | |
196 | AddControlObject(fD0Daughter1); | |
197 | } | |
198 | return 0; | |
199 | } | |
200 | ||
201 | int AliDxHFEParticleSelectionD0::HistogramParticleProperties(AliVParticle* p, int selectionCode) | |
93fcaf9f | 202 | { |
9535cec9 | 203 | |
93fcaf9f | 204 | /// histogram particle properties |
205 | if (!p) return -EINVAL; | |
206 | ||
207 | // fill the common histograms | |
9535cec9 | 208 | AliDxHFEParticleSelection::HistogramParticleProperties(p, selectionCode); |
93fcaf9f | 209 | |
9535cec9 | 210 | // no daughters to fill if 0 (= no candidate) |
211 | if (selectionCode==0) return 0; | |
93fcaf9f | 212 | |
93fcaf9f | 213 | AliAODRecoDecayHF2Prong* part=dynamic_cast<AliAODRecoDecayHF2Prong*>(p); |
9535cec9 | 214 | |
215 | if(!part) return 0; | |
216 | // Convention: 1. daughter is postive track, 2. = negative | |
217 | AliAODTrack *prongpos=(AliAODTrack*)part->GetDaughter(0); | |
218 | AliAODTrack *prongneg=(AliAODTrack*)part->GetDaughter(1); | |
219 | ||
220 | if(!prongpos || !prongneg) { | |
221 | return 0; | |
222 | } | |
223 | ||
224 | // Only D0s are filled | |
225 | // TODO: Also include D0bar | |
226 | if ((selectionCode==1 || selectionCode==3) && fFillOnlyD0D0bar<2) { | |
d731501a | 227 | fD0InvMass= part->InvMassD0(); |
228 | fPtBin=fCuts->PtBin(part->Pt()); | |
229 | ||
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()}; | |
233 | ||
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); | |
9535cec9 | 238 | if(fD0Daughter0) fD0Daughter0->Fill(piProperties); |
239 | if(fD0Daughter1) fD0Daughter1->Fill(KProperties); | |
93fcaf9f | 240 | } |
241 | ||
242 | return 0; | |
243 | } | |
244 | ||
9535cec9 | 245 | TObjArray* AliDxHFEParticleSelectionD0::Select(TObjArray* pTracks, const AliVEvent *pEvent) |
246 | { | |
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); | |
253 | TObject* pObj=NULL; | |
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); | |
9535cec9 | 259 | |
d731501a | 260 | //TODO: Also add selection for D0bar |
9535cec9 | 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); | |
265 | } | |
266 | return selectedTracks; | |
267 | } | |
268 | ||
269 | int AliDxHFEParticleSelectionD0::IsSelected(AliVParticle* p, const AliVEvent* pEvent) | |
72c0a987 | 270 | { |
271 | /// TODO: implement specific selection of D0 candidates | |
d731501a | 272 | /// Could also return values based on where where selection "failed |
273 | /// Selected. Return 0 (none), 1(D0), 2(D0bar) or 3 (both) | |
274 | ||
9535cec9 | 275 | int selectionCode=0; |
276 | ||
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 | |
281 | } | |
282 | ||
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); | |
286 | if (!cuts) { | |
d731501a | 287 | selectionCode=0; |
9535cec9 | 288 | } else if(cuts->IsInFiducialAcceptance(d0->Pt(),d0->Y(421)) ) { |
d731501a | 289 | |
9535cec9 | 290 | Int_t ptbin=cuts->PtBin(d0->Pt()); |
291 | if(ptbin==-1) { | |
292 | AliDebug(1,"Pt out of bounds"); | |
293 | return 0; | |
294 | } //out of bounds | |
295 | ||
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)); | |
300 | ||
d731501a | 301 | // Selected. Return 0 (none), 1 (D0), 2 (D0bar) or 3 (both) |
9535cec9 | 302 | selectionCode=cuts->IsSelected(d0,AliRDHFCuts::kAll,aod); |
303 | ||
304 | AliDebug(1,Form("Candidate is %d \n", selectionCode)); | |
305 | TObjArray daughters; | |
306 | daughters.AddAt((AliAODTrack*)d0->GetDaughter(0),0); | |
307 | daughters.AddAt((AliAODTrack*)d0->GetDaughter(1),1); | |
308 | ||
309 | //check daughters | |
310 | if(!daughters.UncheckedAt(0) || !daughters.UncheckedAt(1)) { | |
311 | AliDebug(1,"at least one daughter not found!"); | |
312 | daughters.Clear(); | |
313 | return 0; | |
314 | } | |
315 | } | |
316 | ||
317 | return selectionCode; | |
318 | } | |
319 | ||
320 | void AliDxHFEParticleSelectionD0::SetCuts(TObject* cuts, int /*level*/) | |
321 | { | |
322 | /// set cuts objects | |
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())); | |
326 | } | |
72c0a987 | 327 | } |