Coverity fixes + additional protections
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Mar 2011 20:08:03 +0000 (20:08 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Mar 2011 20:08:03 +0000 (20:08 +0000)
STEER/AliAODpidUtil.cxx
STEER/AliAODpidUtil.h

index 1f5acf1..fe85dda 100644 (file)
@@ -240,3 +240,65 @@ void AliAODpidUtil::MakeTRDPID(AliAODTrack *track,Double_t *p) const
   fTRDResponse.GetResponse(pidObj->GetTRDnSlices(),dedx,mom,p,norm);
   return;
 }
+
+//_________________________________________________________________________
+Float_t AliAODpidUtil::NumberOfSigmasTPC(const AliAODTrack *track, AliPID::EParticleType type) const {
+  
+  Double_t mom = 0.0;
+  AliAODPid *pidObj = 0x0;
+  if (track) {
+    mom = track->P();
+    pidObj = track->GetDetPid();
+  }
+  UShort_t nTPCClus=0;
+  Double_t tpcSignal=0.0;
+  if (pidObj) {
+    nTPCClus=pidObj->GetTPCsignalN();
+    mom = pidObj->GetTPCmomentum();
+    tpcSignal = pidObj->GetTPCsignal();
+  }
+  return fTPCResponse.GetNumberOfSigmas(mom,tpcSignal,nTPCClus,type); 
+}
+
+//_________________________________________________________________________
+Float_t AliAODpidUtil::NumberOfSigmasTOF(const AliAODTrack *track, AliPID::EParticleType type) const {
+  Double_t times[AliPID::kSPECIES]={0.};
+  Double_t sigmaTOFPid[AliPID::kSPECIES]={0.};
+  AliAODPid *pidObj = 0x0;
+  Double_t mom = 0.0;
+  if (track) {
+    pidObj = track->GetDetPid();
+    mom = track->P();
+  }
+  Double_t tofSignal = 0.0;
+  if (pidObj) {
+    pidObj->GetIntegratedTimes(times);
+    pidObj->GetTOFpidResolution(sigmaTOFPid);
+    tofSignal = pidObj->GetTOFsignal();
+  }
+  if (sigmaTOFPid[type]>0) return (tofSignal - times[type])/sigmaTOFPid[type];
+  else return (tofSignal - times[type])/fTOFResponse.GetExpectedSigma(mom,times[type],AliPID::ParticleMass(type));
+}
+
+//_________________________________________________________________________
+Float_t AliAODpidUtil::NumberOfSigmasITS(const AliAODTrack *track, AliPID::EParticleType type) const {
+  AliAODPid *pidObj = 0x0;
+  UChar_t clumap=0;
+  Float_t mom=0.0;
+  UShort_t nTPCClus=0;
+  if (track) {
+    pidObj = track->GetDetPid();
+    clumap=track->GetITSClusterMap();
+    mom=track->P();
+    nTPCClus=track->GetTPCNcls();
+  }
+  Int_t nPointsForPid=0;
+  for(Int_t i=2; i<6; i++){
+    if(clumap&(1<<i)) ++nPointsForPid;
+  }
+  Float_t dEdx=0.0;
+  if (pidObj) dEdx=pidObj->GetITSsignal();
+  Bool_t isSA=kTRUE;  
+  if(nTPCClus>0) isSA=kFALSE;
+  return fITSResponse.GetNumberOfSigmas(mom,dEdx,type,nPointsForPid,isSA);
+}
index ed36528..8bee355 100644 (file)
@@ -54,39 +54,6 @@ private:
   ClassDef(AliAODpidUtil,1)  // PID calculation class
 };
 
-inline Float_t AliAODpidUtil::NumberOfSigmasTPC(const AliAODTrack *track, AliPID::EParticleType type) const {
-  
-  Double_t mom = track->P();
-  AliAODPid *pidObj = track->GetDetPid();
-  UShort_t nTPCClus=pidObj->GetTPCsignalN();
-  if (pidObj)
-    mom = pidObj->GetTPCmomentum();
-  return fTPCResponse.GetNumberOfSigmas(mom,pidObj->GetTPCsignal(),nTPCClus,type); 
-}
-
-inline Float_t AliAODpidUtil::NumberOfSigmasTOF(const AliAODTrack *track, AliPID::EParticleType type) const {
-  Double_t times[AliPID::kSPECIES];
-  Double_t sigmaTOFPid[AliPID::kSPECIES];
-  AliAODPid *pidObj = track->GetDetPid();
-  pidObj->GetIntegratedTimes(times);
-  pidObj->GetTOFpidResolution(sigmaTOFPid);
-  if (sigmaTOFPid[type]>0) return (pidObj->GetTOFsignal() - times[type])/sigmaTOFPid[type];
-  else return (pidObj->GetTOFsignal() - times[type])/fTOFResponse.GetExpectedSigma(track->P(),times[type],AliPID::ParticleMass(type));
-}
-
-inline Float_t AliAODpidUtil::NumberOfSigmasITS(const AliAODTrack *track, AliPID::EParticleType type) const {
-  AliAODPid *pidObj = track->GetDetPid();
-  Float_t dEdx=pidObj->GetITSsignal();
-  UChar_t clumap=track->GetITSClusterMap();
-  Int_t nPointsForPid=0;
-  for(Int_t i=2; i<6; i++){
-    if(clumap&(1<<i)) ++nPointsForPid;
-  }
-  Float_t mom=track->P();
-  Bool_t isSA=kTRUE;  
-  if(track->GetTPCNcls()>0) isSA=kFALSE;
-  return fITSResponse.GetNumberOfSigmas(mom,dEdx,type,nPointsForPid,isSA);
-}
 #endif