]>
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" |
dfe96b90 | 36 | #include "AliReducedParticle.h" |
93fcaf9f | 37 | #include "TAxis.h" |
9535cec9 | 38 | #include "TString.h" |
93fcaf9f | 39 | #include <iostream> |
40 | #include <cerrno> | |
41 | #include <memory> | |
72c0a987 | 42 | |
9535cec9 | 43 | using namespace std; |
44 | ||
72c0a987 | 45 | /// ROOT macro for the implementation of ROOT specific class methods |
46 | ClassImp(AliDxHFEParticleSelectionD0) | |
47 | ||
48 | AliDxHFEParticleSelectionD0::AliDxHFEParticleSelectionD0(const char* opt) | |
93fcaf9f | 49 | : AliDxHFEParticleSelection("D0", opt) |
50 | , fD0Properties(NULL) | |
9535cec9 | 51 | , fD0Daughter0(NULL) |
52 | , fD0Daughter1(NULL) | |
53 | , fCuts(NULL) | |
54 | , fFillOnlyD0D0bar(0) | |
d731501a | 55 | , fD0InvMass(0.0) |
56 | , fPtBin(-1) | |
72c0a987 | 57 | { |
58 | // constructor | |
59 | // | |
60 | // | |
61 | // | |
62 | // | |
9535cec9 | 63 | TString strOption(opt); |
64 | // TODO: one might need a proper argument parsing including | |
65 | // chopping whole string into individual arguments | |
66 | if (strOption.Contains("FillD0D0bar")) fFillOnlyD0D0bar=0; | |
67 | else if (strOption.Contains("FillOnlyD0")) fFillOnlyD0D0bar=1; | |
68 | else if (strOption.Contains("FillOnlyD0bar")) fFillOnlyD0D0bar=2; | |
72c0a987 | 69 | } |
70 | ||
71 | AliDxHFEParticleSelectionD0::~AliDxHFEParticleSelectionD0() | |
72 | { | |
73 | // destructor | |
9535cec9 | 74 | if (fD0Properties) { |
75 | delete fD0Properties; | |
76 | fD0Properties=NULL; | |
77 | } | |
78 | if (fD0Daughter0) { | |
79 | delete fD0Daughter0; | |
80 | fD0Daughter0=NULL; | |
81 | } | |
82 | if (fD0Daughter1) { | |
83 | delete fD0Daughter1; | |
84 | fD0Daughter1=NULL; | |
85 | } | |
86 | ||
87 | // Note: external object deleted elsewhere | |
88 | fCuts=NULL; | |
72c0a987 | 89 | } |
90 | ||
d731501a | 91 | const char* AliDxHFEParticleSelectionD0::fgkDgTrackControlBinNames[]={ |
92 | "Pt", | |
93 | "Phi", | |
94 | "Ptbin", | |
95 | "D0InvMass", | |
96 | "Eta" | |
97 | }; | |
98 | ||
93fcaf9f | 99 | int AliDxHFEParticleSelectionD0::InitControlObjects() |
100 | { | |
101 | /// init the control objects, can be overloaded by childs which should | |
102 | /// call AliDxHFEParticleSelection::InitControlObjects() explicitly | |
93fcaf9f | 103 | |
d731501a | 104 | fD0Properties=DefineTHnSparse(); |
93fcaf9f | 105 | AddControlObject(fD0Properties); |
106 | ||
9535cec9 | 107 | //Adding control objects for the daughters |
108 | InitControlObjectsDaughters("pi information",0); | |
109 | InitControlObjectsDaughters("K information",1); | |
110 | ||
93fcaf9f | 111 | return AliDxHFEParticleSelection::InitControlObjects(); |
112 | } | |
113 | ||
dcf83226 | 114 | THnSparse* AliDxHFEParticleSelectionD0::DefineTHnSparse() |
d731501a | 115 | { |
116 | // | |
dfe96b90 | 117 | // Defines the THnSparse. |
d731501a | 118 | |
dcf83226 | 119 | // here is the only place to change the dimension |
d731501a | 120 | const int thnSize2 = 5; |
dcf83226 | 121 | InitTHnSparseArray(thnSize2); |
122 | ||
d731501a | 123 | const double Pi=TMath::Pi(); |
124 | TString name; | |
125 | name.Form("%s info", GetName()); | |
126 | ||
dfe96b90 | 127 | // 0 1 2 3 4 |
dcf83226 | 128 | // Pt Phi Ptbin D0InvMass Eta |
dfe96b90 | 129 | int thnBins [thnSize2] = {1000, 200, 15, 200, 500 }; |
130 | double thnMin [thnSize2] = { 0, 0, 0, 1.5648, -1. }; | |
131 | double thnMax [thnSize2] = { 100, 2*Pi, 14, 2.1648, 1. }; | |
132 | const char* thnNames[thnSize2] = {"Pt", "Phi","Ptbin","D0InvMass","Eta"}; | |
d731501a | 133 | |
dcf83226 | 134 | return CreateControlTHnSparse(name,thnSize2,thnBins,thnMin,thnMax,thnNames); |
d731501a | 135 | } |
136 | ||
dcf83226 | 137 | int AliDxHFEParticleSelectionD0::FillParticleProperties(AliVParticle* p, Double_t* data, int dimension) const |
d731501a | 138 | { |
139 | // fill the data array from the particle data | |
140 | if (!data) return -EINVAL; | |
d731501a | 141 | AliAODRecoDecayHF2Prong* track=dynamic_cast<AliAODRecoDecayHF2Prong*>(p); |
142 | if (!track) return -ENODATA; | |
143 | int i=0; | |
dcf83226 | 144 | if (dimension!=GetDimTHnSparse()) { |
d731501a | 145 | // TODO: think about filling only the available data and throwing a warning |
146 | return -ENOSPC; | |
147 | } | |
148 | data[i++]=track->Pt(); | |
149 | data[i++]=track->Phi(); | |
150 | data[i++]=fPtBin; | |
151 | data[i++]=fD0InvMass; | |
152 | data[i++]=track->Eta(); | |
153 | ||
154 | return i; | |
155 | } | |
156 | ||
9535cec9 | 157 | int AliDxHFEParticleSelectionD0::InitControlObjectsDaughters(TString name, int daughter) |
158 | { | |
d731501a | 159 | // Setting up Control objects for the daughters. |
160 | // Move to ParticleSelection?? | |
9535cec9 | 161 | AliInfo("Setting up daughter THnSparse"); |
162 | ||
163 | const int thnSize2 = 5; | |
164 | const double Pi=TMath::Pi(); | |
165 | // 0 1 2 3 4 | |
166 | // Pt Phi Ptbin D0InvMass Eta | |
167 | int thnBins[thnSize2] = { 1000, 200, 21, 200, 500}; | |
168 | double thnMin [thnSize2] = { 0, 0, 0, 1.5648, -1.}; | |
169 | double thnMax [thnSize2] = { 100, 2*Pi, 20, 2.1648, 1.}; | |
170 | ||
171 | std::auto_ptr<THnSparseF> DaughterProperties(new THnSparseF(name, name, thnSize2, thnBins, thnMin, thnMax)); | |
172 | ||
173 | if (DaughterProperties.get()==NULL) { | |
174 | return -ENOMEM; | |
175 | } | |
d731501a | 176 | |
177 | for(int iLabel=0; iLabel< 5;iLabel++) | |
178 | DaughterProperties->GetAxis(iLabel)->SetTitle(fgkDgTrackControlBinNames[iLabel]); | |
9535cec9 | 179 | |
180 | if(daughter==0){ | |
181 | fD0Daughter0=DaughterProperties.release(); | |
182 | AddControlObject(fD0Daughter0); | |
183 | } | |
184 | ||
185 | if(daughter==1){ | |
186 | fD0Daughter1=DaughterProperties.release(); | |
187 | AddControlObject(fD0Daughter1); | |
188 | } | |
189 | return 0; | |
190 | } | |
191 | ||
192 | int AliDxHFEParticleSelectionD0::HistogramParticleProperties(AliVParticle* p, int selectionCode) | |
93fcaf9f | 193 | { |
9535cec9 | 194 | |
93fcaf9f | 195 | /// histogram particle properties |
196 | if (!p) return -EINVAL; | |
197 | ||
198 | // fill the common histograms | |
9535cec9 | 199 | AliDxHFEParticleSelection::HistogramParticleProperties(p, selectionCode); |
93fcaf9f | 200 | |
9535cec9 | 201 | // no daughters to fill if 0 (= no candidate) |
202 | if (selectionCode==0) return 0; | |
93fcaf9f | 203 | |
93fcaf9f | 204 | AliAODRecoDecayHF2Prong* part=dynamic_cast<AliAODRecoDecayHF2Prong*>(p); |
9535cec9 | 205 | |
206 | if(!part) return 0; | |
207 | // Convention: 1. daughter is postive track, 2. = negative | |
208 | AliAODTrack *prongpos=(AliAODTrack*)part->GetDaughter(0); | |
209 | AliAODTrack *prongneg=(AliAODTrack*)part->GetDaughter(1); | |
210 | ||
211 | if(!prongpos || !prongneg) { | |
212 | return 0; | |
213 | } | |
214 | ||
dfe96b90 | 215 | fD0InvMass= part->InvMassD0(); |
216 | fPtBin=fCuts->PtBin(part->Pt()); | |
217 | ||
218 | // TODO: avoid repeated allocation of the arrays | |
219 | Double_t KProperties[]={prongneg->Pt(),prongneg->Phi(),fPtBin, fD0InvMass,prongneg->Eta()}; | |
220 | Double_t piProperties[]={prongpos->Pt(),prongpos->Phi(),fPtBin,fD0InvMass,prongpos->Eta()}; | |
d731501a | 221 | |
dfe96b90 | 222 | |
223 | // Fills only for D0 or both.. | |
224 | if ((selectionCode==1 || selectionCode==3) && fFillOnlyD0D0bar<2) { | |
d731501a | 225 | |
dcf83226 | 226 | if(fD0Properties && ParticleProperties()) { |
227 | memset(ParticleProperties(), 0, GetDimTHnSparse()*sizeof(ParticleProperties()[0])); | |
228 | FillParticleProperties(p, ParticleProperties(), GetDimTHnSparse()); | |
229 | fD0Properties->Fill(ParticleProperties()); | |
230 | } | |
9535cec9 | 231 | if(fD0Daughter0) fD0Daughter0->Fill(piProperties); |
232 | if(fD0Daughter1) fD0Daughter1->Fill(KProperties); | |
93fcaf9f | 233 | } |
dfe96b90 | 234 | else{ |
235 | // If not D0 (or both), check for D0bar (actually now also checks for both, not sure if this is needed) | |
236 | if ((selectionCode==2 || selectionCode==3) && (fFillOnlyD0D0bar==0 || fFillOnlyD0D0bar==2)) { | |
237 | ||
238 | if(fD0Properties && ParticleProperties()) { | |
239 | memset(ParticleProperties(), 0, GetDimTHnSparse()*sizeof(ParticleProperties()[0])); | |
240 | FillParticleProperties(p, ParticleProperties(), GetDimTHnSparse()); | |
241 | fD0Properties->Fill(ParticleProperties()); | |
242 | } | |
243 | if(fD0Daughter0) fD0Daughter0->Fill(piProperties); | |
244 | if(fD0Daughter1) fD0Daughter1->Fill(KProperties); | |
245 | } | |
246 | } | |
93fcaf9f | 247 | return 0; |
248 | } | |
249 | ||
9535cec9 | 250 | TObjArray* AliDxHFEParticleSelectionD0::Select(TObjArray* pTracks, const AliVEvent *pEvent) |
251 | { | |
252 | /// create selection, array contains only pointers but does not own the objects | |
253 | /// object array needs to be deleted by caller | |
254 | if (!pTracks) return NULL; | |
255 | TObjArray* selectedTracks=new TObjArray; | |
256 | if (!selectedTracks) return NULL; | |
dfe96b90 | 257 | selectedTracks->SetOwner(); |
9535cec9 | 258 | TIter itrack(pTracks); |
259 | TObject* pObj=NULL; | |
260 | while ((pObj=itrack())!=NULL) { | |
261 | AliVParticle* track=dynamic_cast<AliVParticle*>(pObj); | |
262 | if (!track) continue; | |
263 | int selectionCode=IsSelected(track,pEvent); | |
264 | HistogramParticleProperties(track, selectionCode); | |
9535cec9 | 265 | |
dfe96b90 | 266 | // This should make sure the array only gets filled with D0, D0bar or both: |
267 | ||
9535cec9 | 268 | // Add track if it is either defined as D0(selectionCode==1) or both |
269 | // D0bar and a D0 (selectionCode==3) | |
dfe96b90 | 270 | if ((selectionCode==1 || selectionCode==3) && fFillOnlyD0D0bar<2) |
271 | selectedTracks->Add(CreateParticle(track)); | |
272 | else{ | |
273 | // Add track if it is either defined as D0bar(selectionCode==2) or both | |
274 | // D0bar and a D0 (selectionCode==3) | |
275 | if ((selectionCode==2 || selectionCode==3) && (fFillOnlyD0D0bar==0 || fFillOnlyD0D0bar==2)) | |
276 | selectedTracks->Add(CreateParticle(track)); | |
277 | } | |
9535cec9 | 278 | } |
279 | return selectedTracks; | |
280 | } | |
281 | ||
282 | int AliDxHFEParticleSelectionD0::IsSelected(AliVParticle* p, const AliVEvent* pEvent) | |
72c0a987 | 283 | { |
284 | /// TODO: implement specific selection of D0 candidates | |
d731501a | 285 | /// Could also return values based on where where selection "failed |
286 | /// Selected. Return 0 (none), 1(D0), 2(D0bar) or 3 (both) | |
287 | ||
9535cec9 | 288 | int selectionCode=0; |
289 | ||
290 | AliAODRecoDecayHF2Prong *d0 = dynamic_cast<AliAODRecoDecayHF2Prong*>(p); | |
3b40764c | 291 | if (!d0) return 0; |
9535cec9 | 292 | if(d0->GetSelectionMap()) if(!d0->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)){ |
293 | AliDebug(1,"Skip D0 from Dstar"); | |
294 | return 0; //skip the D0 from Dstar | |
295 | } | |
296 | ||
297 | // TODO: the cuts instance should be const but the function definition of | |
298 | // AliRDHFCuts::IsSelected does not allow this | |
299 | AliRDHFCuts* cuts=const_cast<AliRDHFCuts*>(fCuts); | |
300 | if (!cuts) { | |
d731501a | 301 | selectionCode=0; |
dfe96b90 | 302 | } |
303 | else if(cuts->IsInFiducialAcceptance(d0->Pt(),d0->Y(421)) ) { | |
d731501a | 304 | |
9535cec9 | 305 | Int_t ptbin=cuts->PtBin(d0->Pt()); |
306 | if(ptbin==-1) { | |
307 | AliDebug(1,"Pt out of bounds"); | |
308 | return 0; | |
309 | } //out of bounds | |
310 | ||
311 | // TODO: the aod pointer should also be const but the function definition of | |
312 | // AliRDHFCuts::IsSelected does not allow this | |
313 | AliAODEvent* aod=NULL; | |
314 | if (pEvent) aod=dynamic_cast<AliAODEvent*>(const_cast<AliVEvent*>(pEvent)); | |
315 | ||
d731501a | 316 | // Selected. Return 0 (none), 1 (D0), 2 (D0bar) or 3 (both) |
9535cec9 | 317 | selectionCode=cuts->IsSelected(d0,AliRDHFCuts::kAll,aod); |
318 | ||
319 | AliDebug(1,Form("Candidate is %d \n", selectionCode)); | |
320 | TObjArray daughters; | |
321 | daughters.AddAt((AliAODTrack*)d0->GetDaughter(0),0); | |
322 | daughters.AddAt((AliAODTrack*)d0->GetDaughter(1),1); | |
323 | ||
324 | //check daughters | |
325 | if(!daughters.UncheckedAt(0) || !daughters.UncheckedAt(1)) { | |
326 | AliDebug(1,"at least one daughter not found!"); | |
327 | daughters.Clear(); | |
328 | return 0; | |
329 | } | |
330 | } | |
331 | ||
332 | return selectionCode; | |
333 | } | |
334 | ||
335 | void AliDxHFEParticleSelectionD0::SetCuts(TObject* cuts, int /*level*/) | |
336 | { | |
337 | /// set cuts objects | |
338 | fCuts=dynamic_cast<AliRDHFCuts*>(cuts); | |
339 | if (!fCuts && cuts) { | |
340 | AliError(Form("cuts object is not of required type AliRDHFCuts but %s", cuts->ClassName())); | |
341 | } | |
72c0a987 | 342 | } |
dfe96b90 | 343 | |
344 | AliVParticle *AliDxHFEParticleSelectionD0::CreateParticle(AliVParticle* track) | |
345 | { | |
346 | // | |
347 | // Creates object containing only the variables needed for correlation | |
348 | // | |
349 | ||
350 | AliReducedParticle *part = new AliReducedParticle(track->Eta(), track->Phi(), track->Pt(),fD0InvMass,fPtBin); | |
351 | ||
352 | return part; | |
353 | ||
354 | } |