1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliAODpidUtil.cxx 38329 2010-01-17 19:17:24Z hristov $ */
18 //-----------------------------------------------------------------
19 // Implementation of the combined PID class
21 // containing information on the particle identification
22 // Origin: Rosa Romita, GSI, r.romita@gsi.de
23 //-----------------------------------------------------------------
28 #include "AliAODpidUtil.h"
29 #include "AliAODEvent.h"
30 #include "AliAODTrack.h"
31 #include "AliAODPid.h"
32 #include "AliTRDPIDResponse.h"
33 #include "AliESDtrack.h"
34 #include "AliAODMCHeader.h"
35 #include "AliAODMCParticle.h"
37 #include <AliDetectorPID.h>
39 ClassImp(AliAODpidUtil)
41 //_________________________________________________________________________
42 Float_t AliAODpidUtil::GetTPCsignalTunedOnData(const AliVTrack *t) const {
43 AliAODTrack *track = (AliAODTrack *) t;
44 Float_t dedx = track->GetTPCsignalTunedOnData();
45 if(dedx > 0) return dedx;
47 dedx = t->GetTPCsignal();
48 track->SetTPCsignalTunedOnData(dedx);
50 if(dedx < 20) return dedx;
53 AliPID::EParticleType type = AliPID::kPion;
55 AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(track->GetAODEvent()->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
57 TClonesArray *mcArray = (TClonesArray*)track->GetAODEvent()->GetList()->FindObject(AliAODMCParticle::StdBranchName());
61 Int_t iS = TMath::Abs(((AliAODMCParticle*)mcArray->At(TMath::Abs(t->GetLabel())))->GetPdgCode());
62 if(iS==AliPID::ParticleCode(AliPID::kElectron)){
63 type = AliPID::kElectron;
65 else if(iS==AliPID::ParticleCode(AliPID::kMuon)){
68 else if(iS==AliPID::ParticleCode(AliPID::kPion)){
71 else if(iS==AliPID::ParticleCode(AliPID::kKaon)){
74 else if(iS==AliPID::ParticleCode(AliPID::kProton)){
75 type = AliPID::kProton;
77 else if(iS==AliPID::ParticleCode(AliPID::kDeuteron)){ // d
78 type = AliPID::kDeuteron;
80 else if(iS==AliPID::ParticleCode(AliPID::kTriton)){ // t
81 type = AliPID::kTriton;
83 else if(iS==AliPID::ParticleCode(AliPID::kHe3)){ // 3He
86 else if(iS==AliPID::ParticleCode(AliPID::kAlpha)){ // 4He
87 type = AliPID::kAlpha;
93 //TODO maybe introduce different dEdxSources?
94 Double_t bethe = fTPCResponse.GetExpectedSignal(track, type, AliTPCPIDResponse::kdEdxDefault, this->UseTPCEtaCorrection(),
95 this->UseTPCMultiplicityCorrection());
96 Double_t sigma = fTPCResponse.GetExpectedSigma(track, type, AliTPCPIDResponse::kdEdxDefault, this->UseTPCEtaCorrection(),
97 this->UseTPCMultiplicityCorrection());
98 dedx = gRandom->Gaus(bethe,sigma);
100 // if(iS == AliPID::ParticleCode(AliPID::kHe3) || iS == AliPID::ParticleCode(AliPID::kAlpha)) dedx *= 5;
105 track->SetTPCsignalTunedOnData(dedx);
108 //_________________________________________________________________________
109 Float_t AliAODpidUtil::GetTOFsignalTunedOnData(const AliVTrack *t) const {
110 AliAODTrack *track = (AliAODTrack *) t;
111 Double_t tofSignal = track->GetTOFsignalTunedOnData();
113 if(tofSignal < 99999) return (Float_t)tofSignal; // it has been already set
114 AliAODPid *pidObj = track->GetDetPid();
115 tofSignal = pidObj->GetTOFsignal() + fTOFResponse.GetTailRandomValue();
116 track->SetTOFsignalTunedOnData(tofSignal);
117 return (Float_t)tofSignal;
120 //_________________________________________________________________________
121 Float_t AliAODpidUtil::GetSignalDeltaTOFold(const AliVParticle *vtrack, AliPID::EParticleType type, Bool_t ratio/*=kFALSE*/) const
124 // Number of sigma implementation for the TOF
127 AliAODTrack *track=(AliAODTrack*)vtrack;
128 AliAODPid *pidObj = track->GetDetPid();
129 if (!pidObj) return -9999.;
130 Double_t tofTime = 99999;
131 if (fTuneMConData && ((fTuneMConDataMask & kDetTOF) == kDetTOF) ) tofTime = (Double_t)this->GetTOFsignalTunedOnData((AliVTrack*)vtrack);
132 else tofTime=pidObj->GetTOFsignal();
133 const Double_t expTime=fTOFResponse.GetExpectedSignal((AliVTrack*)vtrack,type);
134 Double_t sigmaTOFPid[AliPID::kSPECIES];
135 pidObj->GetTOFpidResolution(sigmaTOFPid);
136 AliAODEvent *event=(AliAODEvent*)track->GetAODEvent();
137 if (event) { // protection if the user didn't call GetTrack, which sets the internal pointer
138 AliTOFHeader* tofH=(AliTOFHeader*)event->GetTOFHeader();
139 if (tofH && (TMath::Abs(sigmaTOFPid[0]) <= 1.E-16) ) { // new AOD
140 tofTime -= fTOFResponse.GetStartTime(vtrack->P());
143 AliError("pointer to AliAODEvent not found, please call GetTrack to set it");
147 Double_t delta=-9999.;
149 if (!ratio) delta=tofTime-expTime;
150 else if (expTime>1.e-20) delta=tofTime/expTime;
155 //_________________________________________________________________________
156 Float_t AliAODpidUtil::GetNumberOfSigmasTOFold(const AliVParticle *vtrack, AliPID::EParticleType type) const
159 // Number of sigma implementation for the TOF
162 AliAODTrack *track=(AliAODTrack*)vtrack;
166 AliAODPid *pidObj = track->GetDetPid();
167 if (!pidObj) return -999.;
168 Double_t tofTime = 99999;
169 if (fTuneMConData && ((fTuneMConDataMask & kDetTOF) == kDetTOF) ) tofTime = (Double_t)this->GetTOFsignalTunedOnData((AliVTrack*)vtrack);
170 else tofTime=pidObj->GetTOFsignal();
171 Double_t expTime=fTOFResponse.GetExpectedSignal((AliVTrack*)vtrack,type);
172 Double_t sigmaTOFPid[AliPID::kSPECIES];
173 pidObj->GetTOFpidResolution(sigmaTOFPid);
174 AliAODEvent *event=(AliAODEvent*)track->GetAODEvent();
175 if (event) { // protection if the user didn't call GetTrack, which sets the internal pointer
176 AliTOFHeader* tofH=(AliTOFHeader*)event->GetTOFHeader();
177 if (tofH && (TMath::Abs(sigmaTOFPid[0]) <= 1.E-16) ) { // new AOD
178 sigTOF=fTOFResponse.GetExpectedSigma(track->P(),expTime,AliPID::ParticleMassZ(type)); //fTOFResponse is set in InitialiseEvent
179 tofTime -= fTOFResponse.GetStartTime(vtrack->P());
183 AliError("pointer to AliAODEvent not found, please call GetTrack to set it");
186 if (oldAod) { // old AOD
187 if (type <= AliPID::kProton) {
188 sigTOF=sigmaTOFPid[type];
189 } else return -998.; // light nuclei cannot be supported on old AOD because we don't have timeZero resolution
191 if (sigTOF>0) return (tofTime - expTime)/sigTOF;