]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/Correlations/DPhi/DiHadronPID/AliTrackDiHadronPID.cxx
1) Suppressed unnecessary output. 2) Added option to request multiple filter bits
[u/mrichter/AliRoot.git] / PWGCF / Correlations / DPhi / DiHadronPID / AliTrackDiHadronPID.cxx
CommitLineData
97724bd1 1/*************************************************************************
2* Copyright(c) 1998-2008, 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// -----------------------------------------------------------------------
17// Track class for the DiHadronPID analysis.
18// -----------------------------------------------------------------------
19// Author: Misha Veldhoen (misha.veldhoen@cern.ch)
6788af99 20
a5422983 21#include "AliTrackDiHadronPID.h"
6788af99 22
6788af99 23#include "AliAODVertex.h"
6788af99 24#include "AliPID.h"
6788af99 25#include "AliTPCPIDResponse.h"
26
6788af99 27ClassImp(AliTrackDiHadronPID);
28
97724bd1 29// -----------------------------------------------------------------------
6788af99 30AliTrackDiHadronPID::AliTrackDiHadronPID():
31 TObject(),
32 fAODTrack(0x0),
33 fAODGlobalTrack(0x0),
34 fAODEvent(0x0),
35 fAODMCParticle(0x0),
36 fPIDResponse(0x0),
37 fBasicInfoAvailable(kFALSE),
38 fFlagsAvailable(kFALSE),
39 fDCAInfoAvailable(kFALSE),
40 fITSInfoAvailable(kFALSE),
41 fTPCInfoAvailable(kFALSE),
42 fTOFInfoAvailable(kFALSE),
43 fMCInfoAvailable(kFALSE),
44 fPt(-999.),
45 fEta(-999.),
46 fPhi(-999.),
47 fFlags(0),
48 fFilterMap(0),
49 fID(0),
50 fLabel(0),
51 fCharge(0),
6214ec0c 52 fNclsTPC(-999),
6788af99 53 fDCAz(-999.),
54 fDCAxy(-999.),
55 fTOFsignal(-999.),
a5422983 56 fTOFMatchingStatus(-1),
6788af99 57 fTPCsignal(-999.),
58 fTPCmomentum(-999.),
f054df96 59 fITSClusterMap(0),
6788af99 60 fMCPt(-999.),
61 fMCEta(-999.),
62 fMCPhi(-999.),
63 fMCY(-999.),
64 fPdgCode(0),
65 fIsPhysicalPrimary(kFALSE),
66 fIsSecondaryFromWeakDecay(kFALSE),
67 fIsSecondaryFromMaterial(kFALSE),
68 fDebug(0)
69
70{
71
72 //
73 // Default Constructor.
74 //
75
50dfda71 76 if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 77
78 for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
79 fTOFsignalMinusExpected[iSpecies] = -999.;
80 fTOFNsigma[iSpecies] = -999.;
81 fTPCsignalMinusExpected[iSpecies] = -999.;
82 fTPCNsigma[iSpecies] = -999.;
83 fY[iSpecies] = -999.;
84 }
85
86 for (Int_t iITSlayer = 0; iITSlayer < 6; iITSlayer++) {
87 fITSHits[iITSlayer] = kFALSE;
88 }
89
a5422983 90 for (Int_t iN = 0; iN < 3; ++iN) {
91 fTOFLabel[iN] = -1; // Same convention as in ESDs
92 }
93
6788af99 94}
95
97724bd1 96// -----------------------------------------------------------------------
6788af99 97AliTrackDiHadronPID::AliTrackDiHadronPID(AliAODTrack* track, AliAODTrack* globaltrack, AliAODMCParticle* mcparticle, AliPIDResponse* pidresponse):
98 TObject(),
99 fAODTrack(0x0),
100 fAODGlobalTrack(0x0),
101 fAODEvent(0x0),
102 fAODMCParticle(0x0),
103 fPIDResponse(0x0),
104 fBasicInfoAvailable(kFALSE),
105 fFlagsAvailable(kFALSE),
106 fDCAInfoAvailable(kFALSE),
107 fITSInfoAvailable(kFALSE),
108 fTPCInfoAvailable(kFALSE),
109 fTOFInfoAvailable(kFALSE),
110 fMCInfoAvailable(kFALSE),
111 fPt(-999.),
112 fEta(-999.),
113 fPhi(-999.),
114 fFlags(0),
115 fFilterMap(0),
116 fID(0),
117 fLabel(0),
118 fCharge(0),
6214ec0c 119 fNclsTPC(-999),
6788af99 120 fDCAz(-999.),
121 fDCAxy(-999.),
122 fTOFsignal(-999.),
a5422983 123 fTOFMatchingStatus(-1),
6788af99 124 fTPCsignal(-999.),
125 fTPCmomentum(-999.),
f054df96 126 fITSClusterMap(0),
6788af99 127 fMCPt(-999.),
128 fMCEta(-999.),
129 fMCPhi(-999.),
130 fMCY(-999.),
131 fPdgCode(0),
132 fIsPhysicalPrimary(kFALSE),
133 fIsSecondaryFromWeakDecay(kFALSE),
134 fIsSecondaryFromMaterial(kFALSE),
135 fDebug(0)
136{
137
138 //
139 // Constructor.
140 //
141
50dfda71 142 if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 143
144 for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
145 fTOFsignalMinusExpected[iSpecies] = -999.;
146 fTOFNsigma[iSpecies] = -999.;
147 fTPCsignalMinusExpected[iSpecies] = -999.;
148 fTPCNsigma[iSpecies] = -999.;
149 fY[iSpecies] = -999.;
150 }
151
152 for (Int_t iITSlayer = 0; iITSlayer < 6; iITSlayer++) {
153 fITSHits[iITSlayer] = kFALSE;
154 }
155
a5422983 156 for (Int_t iN = 0; iN < 3; ++iN) {
157 fTOFLabel[iN] = -1; // Same convention as in ESDs
158 }
159
6788af99 160 if (track) {
161 fAODTrack = track;
162 fAODEvent = track->GetAODEvent();
163 }
164 if (globaltrack) fAODGlobalTrack = globaltrack;
165 if (mcparticle) fAODMCParticle = mcparticle;
166 if (pidresponse) fPIDResponse = pidresponse;
167
168 // Copy AOD Track info.
169 if (fAODTrack) {
170 CopyBasicTrackInfo();
171 } else {
172 AliError("No Track Supplied.");
173 }
174
07d62e30 175 // Copy the rest of the track parameters if the filtermap is nonzero.
176 // If fFiltermap == 0, then propagation to the DCA will result in a floating point error.
177 if (fFilterMap) {
178
179 // Find the Global Track.
180 if (fID >= 0) fAODGlobalTrack = fAODTrack;
181
182 // Copy DCA and PID info.
183 if (fAODGlobalTrack) {
184 CopyFlags();
185 if (fAODEvent) CopyDCAInfo();
186 else AliError("Couln't find AOD Event.");
187 CopyITSInfo();
188 if (fPIDResponse) CopyTPCInfo();
189 CopyTOFInfo();
190 } else {
191 AliError("Couldn't find Global Track.");
192 }
193
194 // Copy MC info.
195 if (fAODMCParticle) {
196 CopyMCInfo();
197 }
198
199 }
6788af99 200
201 // Test
202 /* Double_t sigmaTOFProton = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(fAODTrack, AliPID::kProton));
203 if ( sigmaTOFProton < 1.0) {cout<<"tofsigmabelowone: "<<sigmaTOFProton<<endl;}
204
205 Double_t sigmaTPCProton = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(fAODTrack, AliPID::kProton));
206 if ( sigmaTPCProton < 1.0) {cout<<"tpcsigmabelowone: "<<sigmaTPCProton<<endl;}*/
207}
208
97724bd1 209// -----------------------------------------------------------------------
6788af99 210Bool_t AliTrackDiHadronPID::CopyBasicTrackInfo() {
211
212 //
213 // Copies everything available in every AOD track.
214 //
215
50dfda71 216 if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 217
218 fPt = fAODTrack->Pt();
219 fEta = fAODTrack->Eta();
220 fPhi = fAODTrack->Phi();
221
222 fY[0] = fAODTrack->Y(AliAODTrack::kPion);
223 fY[1] = fAODTrack->Y(AliAODTrack::kKaon);
224 fY[2] = fAODTrack->Y(AliAODTrack::kProton);
225
226 //fFlags = fAODTrack->GetFlags(); // FLAGS MUST BE TAKEN FROM GLOBAL TRACKS.
227 fFilterMap = fAODTrack->GetFilterMap();
228
229 fID = fAODTrack->GetID();
230 fLabel = fAODTrack->GetLabel();
231
232 fCharge = fAODTrack->Charge();
6214ec0c 233 fNclsTPC = fAODTrack->GetTPCNcls();
6788af99 234
235 fBasicInfoAvailable = kTRUE;
236 return fBasicInfoAvailable;
237
238}
239
97724bd1 240// -----------------------------------------------------------------------
6788af99 241Bool_t AliTrackDiHadronPID::CopyFlags() {
242
243 //
244 // Copies Flags (properly stored in global track)
245 //
246
50dfda71 247 if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 248
249 // Copy Flags
250 fFlags = fAODGlobalTrack->GetFlags();
a5422983 251/*
6788af99 252 // Is TOF mismatch?
253 if (AliAODTrack::kTOFmismatch&fFlags) {
a5422983 254 fTOFMatchingStatus = kTRUE;
6788af99 255 //cout<<"Found TOF mismatch!"<<endl;
256 }
a5422983 257 else fTOFMatchingStatus = kFALSE;
258*/
6788af99 259 fFlagsAvailable = kTRUE;
260 return fFlagsAvailable;
261
262}
263
97724bd1 264// -----------------------------------------------------------------------
6788af99 265Bool_t AliTrackDiHadronPID::CopyDCAInfo() {
266
267 //
268 // Copies DCA info. (only stored in a global track)
269 //
270
50dfda71 271 if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 272
6214ec0c 273 if (fAODGlobalTrack->IsMuonTrack()) return kFALSE;
274
6788af99 275 // Propagate track to DCA.
276 Double_t PosAtDCA[2] = {-999,-999};
277 Double_t covar[3] = {-999,-999,-999};
278 //cout<<fAODTrack<<" "<<fAODGlobalTrack<<endl;
279 Bool_t propagate = fAODGlobalTrack->PropagateToDCA(fAODEvent->GetPrimaryVertex(),fAODEvent->GetMagneticField(),100.,PosAtDCA,covar);
280
281 if (propagate) {
282 fDCAxy = PosAtDCA[0];
283 fDCAz = PosAtDCA[1];
284 } else {
285 //AliError("Could not propagate track to DCA.");
286 }
287
288 if (propagate) fDCAInfoAvailable = kTRUE;
289 return fDCAInfoAvailable;
290
291}
292
97724bd1 293// -----------------------------------------------------------------------
6788af99 294Bool_t AliTrackDiHadronPID::CopyITSInfo() {
295
296 //
297 // Copies ITS info.
298 //
299
50dfda71 300 if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 301
302 // Get the ITS clustermap
303 fITSClusterMap = fAODGlobalTrack->GetITSClusterMap();
304
305 // Copy the ITS hits.
306 for (Int_t iITSlayer = 0; iITSlayer < 6; iITSlayer++) {
307 fITSHits[iITSlayer] = fAODGlobalTrack->HasPointOnITSLayer(iITSlayer);
308 }
309
310 fITSInfoAvailable = kTRUE;
311 return fITSInfoAvailable;
312
313}
314
97724bd1 315// -----------------------------------------------------------------------
6788af99 316Bool_t AliTrackDiHadronPID::CopyTPCInfo() {
317
318 //
319 // Copies TPC info. (needs global track and pid response)
320 //
321
50dfda71 322 if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 323
324 // Get TPC signal.
325 fTPCsignal = fAODGlobalTrack->GetTPCsignal();
326
327 // Compute expected TPC signal under pi/K/p mass assumption.
328 AliTPCPIDResponse& TPCPIDResponse = fPIDResponse->GetTPCResponse();
329 fTPCmomentum = fAODGlobalTrack->GetTPCmomentum();
330
331 fTPCsignalMinusExpected[0] = fTPCsignal - TPCPIDResponse.GetExpectedSignal(fTPCmomentum,AliPID::kPion);
332 fTPCsignalMinusExpected[1] = fTPCsignal - TPCPIDResponse.GetExpectedSignal(fTPCmomentum,AliPID::kKaon);
333 fTPCsignalMinusExpected[2] = fTPCsignal - TPCPIDResponse.GetExpectedSignal(fTPCmomentum,AliPID::kProton);
334
335 fTPCNsigma[0] = fPIDResponse->NumberOfSigmasTPC(fAODGlobalTrack, AliPID::kPion);
336 fTPCNsigma[1] = fPIDResponse->NumberOfSigmasTPC(fAODGlobalTrack, AliPID::kKaon);
337 fTPCNsigma[2] = fPIDResponse->NumberOfSigmasTPC(fAODGlobalTrack, AliPID::kProton);
338
339 fTPCInfoAvailable = kTRUE;
340 return fTPCInfoAvailable;
341
342}
343
97724bd1 344// -----------------------------------------------------------------------
6788af99 345Bool_t AliTrackDiHadronPID::CopyTOFInfo() {
346
347 //
348 // Copies TOF info. (needs global track)
349 //
350
50dfda71 351 if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 352
353 // Get TOF signal.
354 fTOFsignal = fAODGlobalTrack->GetTOFsignal();
355
356 // Compute expected TOF signal under pi/K/p mass assumption.
357 Double_t times[AliPID::kSPECIES];
358 fAODGlobalTrack->GetIntegratedTimes(times);
359 fTOFsignalMinusExpected[0] = fTOFsignal - times[AliPID::kPion];
360 fTOFsignalMinusExpected[1] = fTOFsignal - times[AliPID::kKaon];
361 fTOFsignalMinusExpected[2] = fTOFsignal - times[AliPID::kProton];
362
363 fTOFNsigma[0] = fPIDResponse->NumberOfSigmasTOF(fAODGlobalTrack, AliPID::kPion);
364 fTOFNsigma[1] = fPIDResponse->NumberOfSigmasTOF(fAODGlobalTrack, AliPID::kKaon);
365 fTOFNsigma[2] = fPIDResponse->NumberOfSigmasTOF(fAODGlobalTrack, AliPID::kProton);
366
367 fTOFInfoAvailable = kTRUE;
a5422983 368
369 // Q: what do the different TOF labels mean?
370 // It seems that in AOD090 the TOF labels aren't copied properly.
371 //Int_t TOFlabeltmp[3] = {0};
372 fAODGlobalTrack->GetTOFLabel(fTOFLabel);
373 //for (Int_t iN = 0; iN < 3; ++iN) {fTOFLabel[iN] = TOFlabeltmp[iN];}
bb2a7c0b 374 /*
a5422983 375 if (fTOFLabel[1] == fLabel || fTOFLabel[2] == fLabel) {
376 cout<<"fLabel = " << fLabel << " fTOFLabel = {" << fTOFLabel[0] << "," << fTOFLabel[1] << "," << fTOFLabel[2] <<"}"<<endl;
377 }
bb2a7c0b 378 */
a5422983 379 // The following will only work in an AOD production with the fTOFlabels set.
380 // If it wasn't set, then every track will be labeled as no match.
381 if (fTOFLabel[0] == -1) {fTOFMatchingStatus = 2;} // TPC Track was not matched to any TOF hit.
382 else if (fLabel == fTOFLabel[0]) {fTOFMatchingStatus = 0;} // TPC Track was correctly matched to a TOF hit.
383 else {fTOFMatchingStatus = 1;} // TPC Track was mismatched.
384
6788af99 385 return fTOFInfoAvailable;
386
387}
388
97724bd1 389// -----------------------------------------------------------------------
6788af99 390Bool_t AliTrackDiHadronPID::CopyMCInfo() {
391
392 // Copies MC info (needs an MC track with the same label)
393
394 // Check if the label of the current track matches the label of the
395 // generated particle. Note that the label of the AOD track can be
396 // negative. This means that the quality of this track is not awesome,
397 // but that it does correspond to the MC particle.
398
50dfda71 399 if (fDebug > 2) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 400
401 /*
402 if (fAODMCParticle->Label() != TMath::Abs(fAODTrack->GetLabel())) {
403 cout<<"Label of supplied MC particle and reconstructed track do not match."<<endl;
404 return kFALSE;
405 }
406 */
407 // Note: It seems like the Label of the AOD track points to the INDEX of the
408 // MCPArticle, not to the label (See AliAnalysisTaskCompareAODTrackCuts.cxx)
409
410 fMCPt = fAODMCParticle->Pt();
411 fMCEta = fAODMCParticle->Eta();
412 fMCPhi = fAODMCParticle->Phi();
413 fMCY = fAODMCParticle->Y();
414 fPdgCode = fAODMCParticle->PdgCode();
415
416 TClonesArray* mcArray = 0x0;
417 mcArray = dynamic_cast<TClonesArray*>(fAODEvent->FindListObject(AliAODMCParticle::StdBranchName()));
418 if (!mcArray) {
419 AliFatal("No MC array found in the AOD.");
420 }
421
422 // Primary particle
423 if ( fAODMCParticle->IsPhysicalPrimary() ){
424 fIsPhysicalPrimary = kTRUE;
425 } else {
426 // Safety check for mother existence.
427 if (fAODMCParticle->GetMother() >= 0){
428
429 Int_t mcMotherPDG = -999;
430 Int_t firstInt = -999;
431
432 AliAODMCParticle* mcMother = (AliAODMCParticle*) mcArray->At(TMath::Abs(fAODMCParticle->GetMother()));
433 mcMotherPDG = TMath::Abs(mcMother->GetPdgCode());
434
435 // Need a way to get the first intiger, for now Marek's method:
436 firstInt = Int_t (mcMotherPDG/ TMath::Power(10, Int_t(TMath::Log10(mcMotherPDG))));
437 // cout<<"Mother PDG: "<<mcMotherPDG<<"; Firt integer: "<<firstInt<<endl;
438
439 // Weak decay
440 if( firstInt == 3){
441 fIsSecondaryFromWeakDecay = kTRUE;
442 // Material decay
443 } else {
444 fIsSecondaryFromMaterial = kTRUE;
445 }
446 }
447 }
448
449 fMCInfoAvailable = kTRUE;
450 return fMCInfoAvailable;
451
452}