]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AOD/AliAODpidUtil.cxx
h-mu
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODpidUtil.cxx
CommitLineData
1423bac9 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/* $Id: AliAODpidUtil.cxx 38329 2010-01-17 19:17:24Z hristov $ */
17
18//-----------------------------------------------------------------
19// Implementation of the combined PID class
20// For the AOD Class
21// containing information on the particle identification
22// Origin: Rosa Romita, GSI, r.romita@gsi.de
23//-----------------------------------------------------------------
24
539a5a59 25#include "TRandom.h"
1423bac9 26#include "AliLog.h"
27#include "AliPID.h"
28#include "AliAODpidUtil.h"
29#include "AliAODEvent.h"
30#include "AliAODTrack.h"
31#include "AliAODPid.h"
32#include "AliTRDPIDResponse.h"
1c2fc6e0 33#include "AliESDtrack.h"
539a5a59 34#include "AliAODMCHeader.h"
35#include "AliAODMCParticle.h"
1423bac9 36
00a38d07 37#include <AliDetectorPID.h>
38
1423bac9 39ClassImp(AliAODpidUtil)
40
1423bac9 41//_________________________________________________________________________
539a5a59 42Float_t AliAODpidUtil::GetTPCsignalTunedOnData(const AliVTrack *t) const {
43 AliAODTrack *track = (AliAODTrack *) t;
44 Float_t dedx = track->GetTPCsignalTunedOnData();
45 if(dedx > 0) return dedx;
46
539a5a59 47 dedx = t->GetTPCsignal();
48 track->SetTPCsignalTunedOnData(dedx);
49
50 if(dedx < 20) return dedx;
51
52
53 AliPID::EParticleType type = AliPID::kPion;
54
55 AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(track->GetAODEvent()->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
56 if (mcHeader) {
57 TClonesArray *mcArray = (TClonesArray*)track->GetAODEvent()->GetList()->FindObject(AliAODMCParticle::StdBranchName());
58
59 Bool_t kGood = kTRUE;
60
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;
64 }
65 else if(iS==AliPID::ParticleCode(AliPID::kMuon)){
66 type = AliPID::kMuon;
67 }
68 else if(iS==AliPID::ParticleCode(AliPID::kPion)){
69 type = AliPID::kPion;
70 }
71 else if(iS==AliPID::ParticleCode(AliPID::kKaon)){
72 type = AliPID::kKaon;
73 }
74 else if(iS==AliPID::ParticleCode(AliPID::kProton)){
75 type = AliPID::kProton;
76 }
77 else if(iS==AliPID::ParticleCode(AliPID::kDeuteron)){ // d
78 type = AliPID::kDeuteron;
79 }
80 else if(iS==AliPID::ParticleCode(AliPID::kTriton)){ // t
81 type = AliPID::kTriton;
82 }
83 else if(iS==AliPID::ParticleCode(AliPID::kHe3)){ // 3He
84 type = AliPID::kHe3;
85 }
86 else if(iS==AliPID::ParticleCode(AliPID::kAlpha)){ // 4He
87 type = AliPID::kAlpha;
88 }
89 else
90 kGood = kFALSE;
91
92 if(kGood){
f85a3764 93 //TODO maybe introduce different dEdxSources?
94 Double_t bethe = fTPCResponse.GetExpectedSignal(track, type, AliTPCPIDResponse::kdEdxDefault, this->UseTPCEtaCorrection());
95 Double_t sigma = fTPCResponse.GetExpectedSigma(track, type, AliTPCPIDResponse::kdEdxDefault, this->UseTPCEtaCorrection());
96 dedx = gRandom->Gaus(bethe,sigma);
97
567624b5 98// if(iS == AliPID::ParticleCode(AliPID::kHe3) || iS == AliPID::ParticleCode(AliPID::kAlpha)) dedx *= 5;
539a5a59 99 }
100
101 }
102
103 track->SetTPCsignalTunedOnData(dedx);
104 return dedx;
105}
567624b5 106
107//_________________________________________________________________________
108Float_t AliAODpidUtil::GetSignalDeltaTOFold(const AliVParticle *vtrack, AliPID::EParticleType type) const
109{
110 //
111 // Number of sigma implementation for the TOF
112 //
113
114 AliAODTrack *track=(AliAODTrack*)vtrack;
115
116 AliAODPid *pidObj = track->GetDetPid();
117 if (!pidObj) return -9999.;
118 Double_t tofTime=pidObj->GetTOFsignal();
119 const Double_t expTime=fTOFResponse.GetExpectedSignal((AliVTrack*)vtrack,type);
120 Double_t sigmaTOFPid[AliPID::kSPECIES];
121 pidObj->GetTOFpidResolution(sigmaTOFPid);
122 AliAODEvent *event=(AliAODEvent*)track->GetAODEvent();
123 if (event) { // protection if the user didn't call GetTrack, which sets the internal pointer
124 AliTOFHeader* tofH=(AliTOFHeader*)event->GetTOFHeader();
125 if (tofH && (TMath::Abs(sigmaTOFPid[0]) <= 1.E-16) ) { // new AOD
126 tofTime -= fTOFResponse.GetStartTime(vtrack->P());
127 }
128 } else {
129 AliError("pointer to AliAODEvent not found, please call GetTrack to set it");
130 return -9999.;
131 }
132
133 return tofTime - expTime;
134}
135
00a38d07 136//_________________________________________________________________________
355b831b 137Float_t AliAODpidUtil::GetNumberOfSigmasTOFold(const AliVParticle *vtrack, AliPID::EParticleType type) const
00a38d07 138{
139 //
140 // Number of sigma implementation for the TOF
141 //
142
143 AliAODTrack *track=(AliAODTrack*)vtrack;
144
00a38d07 145 Bool_t oldAod=kTRUE;
567624b5 146 Double_t sigTOF=0.;
00a38d07 147 AliAODPid *pidObj = track->GetDetPid();
148 if (!pidObj) return -999.;
149 Double_t tofTime=pidObj->GetTOFsignal();
150 Double_t expTime=fTOFResponse.GetExpectedSignal((AliVTrack*)vtrack,type);
151 Double_t sigmaTOFPid[AliPID::kSPECIES];
152 pidObj->GetTOFpidResolution(sigmaTOFPid);
153 AliAODEvent *event=(AliAODEvent*)track->GetAODEvent();
154 if (event) { // protection if the user didn't call GetTrack, which sets the internal pointer
155 AliTOFHeader* tofH=(AliTOFHeader*)event->GetTOFHeader();
156 if (tofH && (TMath::Abs(sigmaTOFPid[0]) <= 1.E-16) ) { // new AOD
157 sigTOF=fTOFResponse.GetExpectedSigma(track->P(),expTime,AliPID::ParticleMassZ(type)); //fTOFResponse is set in InitialiseEvent
158 tofTime -= fTOFResponse.GetStartTime(vtrack->P());
159 oldAod=kFALSE;
160 }
161 } else {
162 AliError("pointer to AliAODEvent not found, please call GetTrack to set it");
163 return -996.;
164 }
165 if (oldAod) { // old AOD
166 if (type <= AliPID::kProton) {
167 sigTOF=sigmaTOFPid[type];
168 } else return -998.; // light nuclei cannot be supported on old AOD because we don't have timeZero resolution
169 }
170 if (sigTOF>0) return (tofTime - expTime)/sigTOF;
171 else return -997.;
172}