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