]>
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) | |
2229ac91 | 57 | , fHistoList(NULL) |
72c0a987 | 58 | { |
59 | // constructor | |
60 | // | |
61 | // | |
62 | // | |
63 | // | |
b4779749 | 64 | ParseArguments(opt); |
72c0a987 | 65 | } |
66 | ||
67 | AliDxHFEParticleSelectionD0::~AliDxHFEParticleSelectionD0() | |
68 | { | |
69 | // destructor | |
9535cec9 | 70 | if (fD0Properties) { |
71 | delete fD0Properties; | |
72 | fD0Properties=NULL; | |
73 | } | |
74 | if (fD0Daughter0) { | |
75 | delete fD0Daughter0; | |
76 | fD0Daughter0=NULL; | |
77 | } | |
78 | if (fD0Daughter1) { | |
79 | delete fD0Daughter1; | |
80 | fD0Daughter1=NULL; | |
81 | } | |
2229ac91 | 82 | if (fHistoList){ |
83 | delete fHistoList; | |
84 | fHistoList=NULL; | |
85 | } | |
9535cec9 | 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 | ||
2229ac91 | 99 | const char* AliDxHFEParticleSelectionD0::fgkCutBinNames[]={ |
100 | "nDstar->D0", | |
101 | "nCandSel(Tr)", | |
102 | "ptbin-1", | |
103 | "No daugthers", | |
104 | "Selectioncode 0", | |
105 | "Selected D0", | |
106 | "Selected D0bar", | |
107 | "Selected as both" | |
108 | }; | |
109 | ||
110 | ||
93fcaf9f | 111 | int AliDxHFEParticleSelectionD0::InitControlObjects() |
112 | { | |
113 | /// init the control objects, can be overloaded by childs which should | |
114 | /// call AliDxHFEParticleSelection::InitControlObjects() explicitly | |
93fcaf9f | 115 | |
d731501a | 116 | fD0Properties=DefineTHnSparse(); |
93fcaf9f | 117 | AddControlObject(fD0Properties); |
118 | ||
9535cec9 | 119 | //Adding control objects for the daughters |
120 | InitControlObjectsDaughters("pi information",0); | |
121 | InitControlObjectsDaughters("K information",1); | |
2229ac91 | 122 | AliInfo(Form("D0 filling scheme: %d\n",fFillOnlyD0D0bar)); |
123 | ||
124 | fHistoList=new TList; | |
125 | fHistoList->SetName("D0 Histograms"); | |
126 | fHistoList->SetOwner(); | |
127 | ||
128 | // Histogram storing which cuts have been applied to the tracks | |
129 | fHistoList->Add(CreateControlHistogram("fWhichCutD0","effective cut for a rejected particle", kNCutLabels, fgkCutBinNames)); | |
130 | ||
131 | AddControlObject(fHistoList); | |
9535cec9 | 132 | |
93fcaf9f | 133 | return AliDxHFEParticleSelection::InitControlObjects(); |
134 | } | |
135 | ||
dcf83226 | 136 | THnSparse* AliDxHFEParticleSelectionD0::DefineTHnSparse() |
d731501a | 137 | { |
138 | // | |
dfe96b90 | 139 | // Defines the THnSparse. |
d731501a | 140 | |
dcf83226 | 141 | // here is the only place to change the dimension |
d731501a | 142 | const int thnSize2 = 5; |
dcf83226 | 143 | InitTHnSparseArray(thnSize2); |
144 | ||
d731501a | 145 | const double Pi=TMath::Pi(); |
146 | TString name; | |
147 | name.Form("%s info", GetName()); | |
148 | ||
dfe96b90 | 149 | // 0 1 2 3 4 |
dcf83226 | 150 | // Pt Phi Ptbin D0InvMass Eta |
dfe96b90 | 151 | int thnBins [thnSize2] = {1000, 200, 15, 200, 500 }; |
152 | double thnMin [thnSize2] = { 0, 0, 0, 1.5648, -1. }; | |
153 | double thnMax [thnSize2] = { 100, 2*Pi, 14, 2.1648, 1. }; | |
154 | const char* thnNames[thnSize2] = {"Pt", "Phi","Ptbin","D0InvMass","Eta"}; | |
d731501a | 155 | |
dcf83226 | 156 | return CreateControlTHnSparse(name,thnSize2,thnBins,thnMin,thnMax,thnNames); |
d731501a | 157 | } |
158 | ||
dcf83226 | 159 | int AliDxHFEParticleSelectionD0::FillParticleProperties(AliVParticle* p, Double_t* data, int dimension) const |
d731501a | 160 | { |
161 | // fill the data array from the particle data | |
162 | if (!data) return -EINVAL; | |
d731501a | 163 | AliAODRecoDecayHF2Prong* track=dynamic_cast<AliAODRecoDecayHF2Prong*>(p); |
164 | if (!track) return -ENODATA; | |
165 | int i=0; | |
dcf83226 | 166 | if (dimension!=GetDimTHnSparse()) { |
d731501a | 167 | // TODO: think about filling only the available data and throwing a warning |
168 | return -ENOSPC; | |
169 | } | |
170 | data[i++]=track->Pt(); | |
171 | data[i++]=track->Phi(); | |
172 | data[i++]=fPtBin; | |
173 | data[i++]=fD0InvMass; | |
174 | data[i++]=track->Eta(); | |
175 | ||
176 | return i; | |
177 | } | |
178 | ||
9535cec9 | 179 | int AliDxHFEParticleSelectionD0::InitControlObjectsDaughters(TString name, int daughter) |
180 | { | |
d731501a | 181 | // Setting up Control objects for the daughters. |
182 | // Move to ParticleSelection?? | |
9535cec9 | 183 | AliInfo("Setting up daughter THnSparse"); |
184 | ||
185 | const int thnSize2 = 5; | |
186 | const double Pi=TMath::Pi(); | |
187 | // 0 1 2 3 4 | |
188 | // Pt Phi Ptbin D0InvMass Eta | |
189 | int thnBins[thnSize2] = { 1000, 200, 21, 200, 500}; | |
190 | double thnMin [thnSize2] = { 0, 0, 0, 1.5648, -1.}; | |
191 | double thnMax [thnSize2] = { 100, 2*Pi, 20, 2.1648, 1.}; | |
192 | ||
193 | std::auto_ptr<THnSparseF> DaughterProperties(new THnSparseF(name, name, thnSize2, thnBins, thnMin, thnMax)); | |
194 | ||
195 | if (DaughterProperties.get()==NULL) { | |
196 | return -ENOMEM; | |
197 | } | |
d731501a | 198 | |
199 | for(int iLabel=0; iLabel< 5;iLabel++) | |
200 | DaughterProperties->GetAxis(iLabel)->SetTitle(fgkDgTrackControlBinNames[iLabel]); | |
9535cec9 | 201 | |
202 | if(daughter==0){ | |
203 | fD0Daughter0=DaughterProperties.release(); | |
204 | AddControlObject(fD0Daughter0); | |
205 | } | |
206 | ||
207 | if(daughter==1){ | |
208 | fD0Daughter1=DaughterProperties.release(); | |
209 | AddControlObject(fD0Daughter1); | |
210 | } | |
211 | return 0; | |
212 | } | |
213 | ||
214 | int AliDxHFEParticleSelectionD0::HistogramParticleProperties(AliVParticle* p, int selectionCode) | |
93fcaf9f | 215 | { |
9535cec9 | 216 | |
93fcaf9f | 217 | /// histogram particle properties |
218 | if (!p) return -EINVAL; | |
219 | ||
220 | // fill the common histograms | |
9535cec9 | 221 | AliDxHFEParticleSelection::HistogramParticleProperties(p, selectionCode); |
93fcaf9f | 222 | |
9535cec9 | 223 | // no daughters to fill if 0 (= no candidate) |
224 | if (selectionCode==0) return 0; | |
93fcaf9f | 225 | |
93fcaf9f | 226 | AliAODRecoDecayHF2Prong* part=dynamic_cast<AliAODRecoDecayHF2Prong*>(p); |
9535cec9 | 227 | |
228 | if(!part) return 0; | |
229 | // Convention: 1. daughter is postive track, 2. = negative | |
230 | AliAODTrack *prongpos=(AliAODTrack*)part->GetDaughter(0); | |
231 | AliAODTrack *prongneg=(AliAODTrack*)part->GetDaughter(1); | |
232 | ||
233 | if(!prongpos || !prongneg) { | |
234 | return 0; | |
235 | } | |
236 | ||
dfe96b90 | 237 | fD0InvMass= part->InvMassD0(); |
238 | fPtBin=fCuts->PtBin(part->Pt()); | |
239 | ||
240 | // TODO: avoid repeated allocation of the arrays | |
b4779749 | 241 | Double_t KProperties[]={prongneg->Pt(),prongneg->Phi(),(Double_t)fPtBin, fD0InvMass,prongneg->Eta()}; |
242 | Double_t piProperties[]={prongpos->Pt(),prongpos->Phi(),(Double_t)fPtBin,fD0InvMass,prongpos->Eta()}; | |
d731501a | 243 | |
dfe96b90 | 244 | |
245 | // Fills only for D0 or both.. | |
246 | if ((selectionCode==1 || selectionCode==3) && fFillOnlyD0D0bar<2) { | |
d731501a | 247 | |
dcf83226 | 248 | if(fD0Properties && ParticleProperties()) { |
249 | memset(ParticleProperties(), 0, GetDimTHnSparse()*sizeof(ParticleProperties()[0])); | |
250 | FillParticleProperties(p, ParticleProperties(), GetDimTHnSparse()); | |
251 | fD0Properties->Fill(ParticleProperties()); | |
252 | } | |
9535cec9 | 253 | if(fD0Daughter0) fD0Daughter0->Fill(piProperties); |
254 | if(fD0Daughter1) fD0Daughter1->Fill(KProperties); | |
93fcaf9f | 255 | } |
2229ac91 | 256 | // Checks for D0bar (or hypothesis both) |
257 | if ((selectionCode==2 || selectionCode==3) && (fFillOnlyD0D0bar==0 || fFillOnlyD0D0bar==2)) { | |
258 | // Set the fD0InvMass to InvMassD0bar instead.. | |
259 | fD0InvMass= part->InvMassD0bar(); | |
260 | if(fD0Properties && ParticleProperties()) { | |
261 | memset(ParticleProperties(), 0, GetDimTHnSparse()*sizeof(ParticleProperties()[0])); | |
262 | FillParticleProperties(p, ParticleProperties(), GetDimTHnSparse()); | |
263 | fD0Properties->Fill(ParticleProperties()); | |
dfe96b90 | 264 | } |
2229ac91 | 265 | if(fD0Daughter0) fD0Daughter0->Fill(piProperties); |
266 | if(fD0Daughter1) fD0Daughter1->Fill(KProperties); | |
267 | //reset value to InvMassD0 for when CreateParticle() is called | |
268 | fD0InvMass= part->InvMassD0(); | |
269 | ||
dfe96b90 | 270 | } |
93fcaf9f | 271 | return 0; |
272 | } | |
273 | ||
9535cec9 | 274 | TObjArray* AliDxHFEParticleSelectionD0::Select(TObjArray* pTracks, const AliVEvent *pEvent) |
275 | { | |
276 | /// create selection, array contains only pointers but does not own the objects | |
277 | /// object array needs to be deleted by caller | |
278 | if (!pTracks) return NULL; | |
279 | TObjArray* selectedTracks=new TObjArray; | |
280 | if (!selectedTracks) return NULL; | |
b4779749 | 281 | selectedTracks->SetOwner(kFALSE); |
9535cec9 | 282 | TIter itrack(pTracks); |
283 | TObject* pObj=NULL; | |
284 | while ((pObj=itrack())!=NULL) { | |
285 | AliVParticle* track=dynamic_cast<AliVParticle*>(pObj); | |
286 | if (!track) continue; | |
287 | int selectionCode=IsSelected(track,pEvent); | |
288 | HistogramParticleProperties(track, selectionCode); | |
9535cec9 | 289 | |
290 | // Add track if it is either defined as D0(selectionCode==1) or both | |
291 | // D0bar and a D0 (selectionCode==3) | |
dfe96b90 | 292 | if ((selectionCode==1 || selectionCode==3) && fFillOnlyD0D0bar<2) |
293 | selectedTracks->Add(CreateParticle(track)); | |
2229ac91 | 294 | |
295 | // Add track if it is either defined as D0bar(selectionCode==2) or both | |
296 | // D0bar and a D0 (selectionCode==3) | |
297 | if ((selectionCode==2 || selectionCode==3) && (fFillOnlyD0D0bar==0 || fFillOnlyD0D0bar==2)){ | |
6101915d | 298 | AliAODRecoDecayHF2Prong* prong=dynamic_cast<AliAODRecoDecayHF2Prong*>(track); |
299 | fD0InvMass=prong?prong->InvMassD0bar():0.; | |
2229ac91 | 300 | selectedTracks->Add(CreateParticle(track)); |
301 | } | |
9535cec9 | 302 | } |
303 | return selectedTracks; | |
304 | } | |
305 | ||
306 | int AliDxHFEParticleSelectionD0::IsSelected(AliVParticle* p, const AliVEvent* pEvent) | |
72c0a987 | 307 | { |
308 | /// TODO: implement specific selection of D0 candidates | |
d731501a | 309 | /// Could also return values based on where where selection "failed |
310 | /// Selected. Return 0 (none), 1(D0), 2(D0bar) or 3 (both) | |
311 | ||
9535cec9 | 312 | int selectionCode=0; |
313 | ||
314 | AliAODRecoDecayHF2Prong *d0 = dynamic_cast<AliAODRecoDecayHF2Prong*>(p); | |
3b40764c | 315 | if (!d0) return 0; |
9535cec9 | 316 | if(d0->GetSelectionMap()) if(!d0->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)){ |
317 | AliDebug(1,"Skip D0 from Dstar"); | |
2229ac91 | 318 | ((TH1D*)fHistoList->FindObject("fWhichCutD0"))->Fill(kDstar); |
319 | ||
9535cec9 | 320 | return 0; //skip the D0 from Dstar |
321 | } | |
322 | ||
323 | // TODO: the cuts instance should be const but the function definition of | |
324 | // AliRDHFCuts::IsSelected does not allow this | |
325 | AliRDHFCuts* cuts=const_cast<AliRDHFCuts*>(fCuts); | |
326 | if (!cuts) { | |
d731501a | 327 | selectionCode=0; |
dfe96b90 | 328 | } |
329 | else if(cuts->IsInFiducialAcceptance(d0->Pt(),d0->Y(421)) ) { | |
d731501a | 330 | |
2229ac91 | 331 | // TODO: the aod pointer should also be const but the function definition of |
332 | // AliRDHFCuts::IsSelected does not allow this | |
333 | AliAODEvent* aod=NULL; | |
334 | if (pEvent) aod=dynamic_cast<AliAODEvent*>(const_cast<AliVEvent*>(pEvent)); | |
335 | ||
336 | //TODO: Should add fSystem for PbPb if(fSys==0){ | |
337 | if(cuts->IsSelected(d0,AliRDHFCuts::kTracks,aod)) ((TH1D*)fHistoList->FindObject("fWhichCutD0"))->Fill(kCandSelTrack); | |
338 | ||
9535cec9 | 339 | Int_t ptbin=cuts->PtBin(d0->Pt()); |
340 | if(ptbin==-1) { | |
2229ac91 | 341 | ((TH1D*)fHistoList->FindObject("fWhichCutD0"))->Fill(kNegPtbin); |
9535cec9 | 342 | AliDebug(1,"Pt out of bounds"); |
343 | return 0; | |
344 | } //out of bounds | |
345 | ||
d731501a | 346 | // Selected. Return 0 (none), 1 (D0), 2 (D0bar) or 3 (both) |
9535cec9 | 347 | selectionCode=cuts->IsSelected(d0,AliRDHFCuts::kAll,aod); |
2229ac91 | 348 | if(selectionCode==0) |
349 | ((TH1D*)fHistoList->FindObject("fWhichCutD0"))->Fill(kSelected0); | |
350 | ||
351 | if(selectionCode==1) | |
352 | ((TH1D*)fHistoList->FindObject("fWhichCutD0"))->Fill(kSelectedD0); | |
353 | ||
354 | if(selectionCode==2) | |
355 | ((TH1D*)fHistoList->FindObject("fWhichCutD0"))->Fill(kSelectedD0bar); | |
356 | ||
357 | if(selectionCode==3) | |
358 | ((TH1D*)fHistoList->FindObject("fWhichCutD0"))->Fill(kSelectedboth); | |
9535cec9 | 359 | |
360 | AliDebug(1,Form("Candidate is %d \n", selectionCode)); | |
2229ac91 | 361 | |
362 | // check daughters before calling as there is unchecked code in | |
363 | // AliAODRecoDecayHF::HasBadDaughters called | |
364 | TObject* o=NULL; | |
365 | if (!((o=d0->GetDaughter(0))!=NULL && dynamic_cast<AliAODTrack*>(o)!=NULL && | |
366 | (o=d0->GetDaughter(1))!=NULL && dynamic_cast<AliAODTrack*>(o)!=NULL)) { | |
367 | ((TH1D*)fHistoList->FindObject("fWhichCutD0"))->Fill(kNoDaugthers); | |
9535cec9 | 368 | AliDebug(1,"at least one daughter not found!"); |
2229ac91 | 369 | |
9535cec9 | 370 | } |
371 | } | |
372 | ||
373 | return selectionCode; | |
374 | } | |
375 | ||
2229ac91 | 376 | void AliDxHFEParticleSelectionD0::SetCuts(TObject* cuts, int level) |
9535cec9 | 377 | { |
378 | /// set cuts objects | |
2229ac91 | 379 | if (level==kCutD0) { |
380 | fCuts=dynamic_cast<AliRDHFCuts*>(cuts); | |
381 | if (!fCuts && cuts) { | |
382 | AliError(Form("cuts object is not of required type AliRDHFCuts but %s", cuts->ClassName())); | |
383 | } | |
384 | return; | |
385 | } | |
386 | if (level==kCutList){ | |
387 | TList* CutList=dynamic_cast<TList*>(cuts); | |
388 | if (!CutList && cuts) { | |
389 | AliError(Form("cuts object is not of required type TList but %s", cuts->ClassName())); | |
390 | } | |
391 | else{ | |
392 | TObject *obj=NULL; | |
393 | int iii=0; | |
394 | TIter next(CutList); | |
395 | while((obj = next())){ | |
396 | iii++; | |
397 | if(iii==1) { | |
398 | fCuts=dynamic_cast<AliRDHFCuts*>(obj); | |
399 | if (!fCuts) | |
400 | AliError(Form("Cut object is not of required type AliRDHFCuts but %s", obj->ClassName())); | |
401 | } | |
402 | } | |
403 | } | |
404 | return; | |
9535cec9 | 405 | } |
2229ac91 | 406 | return; |
72c0a987 | 407 | } |
dfe96b90 | 408 | |
b4779749 | 409 | int AliDxHFEParticleSelectionD0::ParseArguments(const char* arguments) |
410 | { | |
411 | // parse arguments and set internal flags | |
412 | TString strArguments(arguments); | |
413 | auto_ptr<TObjArray> tokens(strArguments.Tokenize(" ")); | |
414 | if (!tokens.get()) return 0; | |
415 | ||
416 | AliInfo(strArguments); | |
417 | TIter next(tokens.get()); | |
418 | TObject* token; | |
419 | while ((token=next())) { | |
420 | TString argument=token->GetName(); | |
421 | if (argument.BeginsWith("fillD0scheme=")){ | |
422 | argument.ReplaceAll("fillD0scheme=", ""); | |
423 | if (argument.CompareTo("both")==0){ fFillOnlyD0D0bar=0;} | |
424 | else if (argument.CompareTo("D0")==0){ fFillOnlyD0D0bar=1;} | |
425 | else if (argument.CompareTo("D0bar")==0){ fFillOnlyD0D0bar=2;} | |
426 | else { | |
427 | AliWarning(Form("can not set D0 filling scheme, unknown parameter '%s'", argument.Data())); | |
428 | fFillOnlyD0D0bar=0; | |
429 | } | |
430 | continue; | |
431 | } | |
432 | // forwarding of single argument works, unless key-option pairs separated | |
433 | // by blanks are introduced | |
434 | AliDxHFEParticleSelection::ParseArguments(argument); | |
435 | } | |
436 | ||
437 | return 0; | |
438 | } | |
439 | ||
dfe96b90 | 440 | AliVParticle *AliDxHFEParticleSelectionD0::CreateParticle(AliVParticle* track) |
441 | { | |
442 | // | |
443 | // Creates object containing only the variables needed for correlation | |
444 | // | |
445 | ||
446 | AliReducedParticle *part = new AliReducedParticle(track->Eta(), track->Phi(), track->Pt(),fD0InvMass,fPtBin); | |
447 | ||
448 | return part; | |
449 | ||
450 | } |