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"
36 #include "AliTOFPIDParams.h"
38 #include <AliDetectorPID.h>
40 ClassImp(AliAODpidUtil)
42 //_________________________________________________________________________
43 Float_t AliAODpidUtil::GetTPCsignalTunedOnData(const AliVTrack *t) const {
44 AliAODTrack *track = (AliAODTrack *) t;
45 Float_t dedx = track->GetTPCsignalTunedOnData();
46 if(dedx > 0) return dedx;
48 dedx = t->GetTPCsignal();
49 track->SetTPCsignalTunedOnData(dedx);
51 if(dedx < 20) return dedx;
54 AliPID::EParticleType type = AliPID::kPion;
56 AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(track->GetAODEvent()->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
59 TClonesArray *mcArray = (TClonesArray*)track->GetAODEvent()->GetList()->FindObject(AliAODMCParticle::StdBranchName());
63 if ( mcArray->At(TMath::Abs(t->GetLabel())) != NULL ) { // protects against label-0 tracks e.g. the initial proton for Phythia events
64 Int_t iS = TMath::Abs(((AliAODMCParticle*)mcArray->At(TMath::Abs(t->GetLabel())))->GetPdgCode());
65 if(iS==AliPID::ParticleCode(AliPID::kElectron)){
66 type = AliPID::kElectron;
68 else if(iS==AliPID::ParticleCode(AliPID::kMuon)){
71 else if(iS==AliPID::ParticleCode(AliPID::kPion)){
74 else if(iS==AliPID::ParticleCode(AliPID::kKaon)){
77 else if(iS==AliPID::ParticleCode(AliPID::kProton)){
78 type = AliPID::kProton;
80 else if(iS==AliPID::ParticleCode(AliPID::kDeuteron)){ // d
81 type = AliPID::kDeuteron;
83 else if(iS==AliPID::ParticleCode(AliPID::kTriton)){ // t
84 type = AliPID::kTriton;
86 else if(iS==AliPID::ParticleCode(AliPID::kHe3)){ // 3He
89 else if(iS==AliPID::ParticleCode(AliPID::kAlpha)){ // 4He
90 type = AliPID::kAlpha;
94 } else kGood = kFALSE;
97 //TODO maybe introduce different dEdxSources?
98 Double_t bethe = fTPCResponse.GetExpectedSignal(track, type, AliTPCPIDResponse::kdEdxDefault, this->UseTPCEtaCorrection(),
99 this->UseTPCMultiplicityCorrection());
100 Double_t sigma = fTPCResponse.GetExpectedSigma(track, type, AliTPCPIDResponse::kdEdxDefault, this->UseTPCEtaCorrection(),
101 this->UseTPCMultiplicityCorrection());
102 dedx = gRandom->Gaus(bethe,sigma);
104 // if(iS == AliPID::ParticleCode(AliPID::kHe3) || iS == AliPID::ParticleCode(AliPID::kAlpha)) dedx *= 5;
109 track->SetTPCsignalTunedOnData(dedx);
112 //_________________________________________________________________________
113 Float_t AliAODpidUtil::GetTOFsignalTunedOnData(const AliVTrack *t) const {
114 AliAODTrack *track = (AliAODTrack *) t;
115 Double_t tofSignal = track->GetTOFsignalTunedOnData();
117 if(tofSignal < 99999) return (Float_t)tofSignal; // it has been already set
119 // read additional mismatch fraction
120 Float_t addmism = GetTOFPIDParams()->GetTOFadditionalMismForMC();
122 Float_t centr = GetCurrentCentrality();
123 if(centr > 50) addmism *= 0.1667;
124 else if(centr > 20) addmism *= 0.33;
127 AliAODPid *pidObj = track->GetDetPid();
128 tofSignal = pidObj->GetTOFsignal() + fTOFResponse.GetTailRandomValue(t->Pt(),t->Eta(),pidObj->GetTOFsignal(),addmism);
129 track->SetTOFsignalTunedOnData(tofSignal);
130 return (Float_t)tofSignal;
133 //_________________________________________________________________________
134 Float_t AliAODpidUtil::GetSignalDeltaTOFold(const AliVParticle *vtrack, AliPID::EParticleType type, Bool_t ratio/*=kFALSE*/) const
137 // Number of sigma implementation for the TOF
140 AliAODTrack *track=(AliAODTrack*)vtrack;
141 AliAODPid *pidObj = track->GetDetPid();
142 if (!pidObj) return -9999.;
143 Double_t tofTime = 99999;
144 if (fTuneMConData && ((fTuneMConDataMask & kDetTOF) == kDetTOF) ) tofTime = (Double_t)this->GetTOFsignalTunedOnData((AliVTrack*)vtrack);
145 else tofTime=pidObj->GetTOFsignal();
146 const Double_t expTime=fTOFResponse.GetExpectedSignal((AliVTrack*)vtrack,type);
147 Double_t sigmaTOFPid[AliPID::kSPECIES];
148 pidObj->GetTOFpidResolution(sigmaTOFPid);
149 AliAODEvent *event=(AliAODEvent*)track->GetAODEvent();
150 if (event) { // protection if the user didn't call GetTrack, which sets the internal pointer
151 AliTOFHeader* tofH=(AliTOFHeader*)event->GetTOFHeader();
152 if (tofH && (TMath::Abs(sigmaTOFPid[0]) <= 1.E-16) ) { // new AOD
153 tofTime -= fTOFResponse.GetStartTime(vtrack->P());
156 AliError("pointer to AliAODEvent not found, please call GetTrack to set it");
160 Double_t delta=-9999.;
162 if (!ratio) delta=tofTime-expTime;
163 else if (expTime>1.e-20) delta=tofTime/expTime;
168 //_________________________________________________________________________
169 Float_t AliAODpidUtil::GetNumberOfSigmasTOFold(const AliVParticle *vtrack, AliPID::EParticleType type) const
172 // Number of sigma implementation for the TOF
175 AliAODTrack *track=(AliAODTrack*)vtrack;
179 AliAODPid *pidObj = track->GetDetPid();
180 if (!pidObj) return -999.;
181 Double_t tofTime = 99999;
182 if (fTuneMConData && ((fTuneMConDataMask & kDetTOF) == kDetTOF) ) tofTime = (Double_t)this->GetTOFsignalTunedOnData((AliVTrack*)vtrack);
183 else tofTime=pidObj->GetTOFsignal();
184 Double_t expTime=fTOFResponse.GetExpectedSignal((AliVTrack*)vtrack,type);
185 Double_t sigmaTOFPid[AliPID::kSPECIES];
186 pidObj->GetTOFpidResolution(sigmaTOFPid);
187 AliAODEvent *event=(AliAODEvent*)track->GetAODEvent();
188 if (event) { // protection if the user didn't call GetTrack, which sets the internal pointer
189 AliTOFHeader* tofH=(AliTOFHeader*)event->GetTOFHeader();
190 if (tofH && (TMath::Abs(sigmaTOFPid[0]) <= 1.E-16) ) { // new AOD
191 sigTOF=fTOFResponse.GetExpectedSigma(track->P(),expTime,AliPID::ParticleMassZ(type)); //fTOFResponse is set in InitialiseEvent
192 tofTime -= fTOFResponse.GetStartTime(vtrack->P());
196 AliError("pointer to AliAODEvent not found, please call GetTrack to set it");
199 if (oldAod) { // old AOD
200 if (type <= AliPID::kProton) {
201 sigTOF=sigmaTOFPid[type];
202 } else return -998.; // light nuclei cannot be supported on old AOD because we don't have timeZero resolution
204 if (sigTOF>0) return (tofTime - expTime)/sigTOF;