/************************************************************************** * Copyright(c) 1998-2006, ALICE Experiment at CERN, All rights reserved. * * * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * * *************************************************************************/ /* $Id$ */ //*********************************************************** // Class AliAODPidHF // class for PID with AliAODRecoDecayHF // Authors: D. Caffarri caffarri@pd.infn.it, A.Dainese andrea.dainese@pd.infn.it, S. Dash dash@to.infn.it, F. Prino prino@to.infn.it, R. Romita r.romita@gsi.de, Y. Wang yifei@pi0.physi.uni-heidelberg.de P. Antonioli pietro.antonioli@bo.infn.it //*********************************************************** #include #include "AliAODPidHF.h" #include "AliAODPid.h" #include "AliPID.h" #include "AliPIDResponse.h" #include "AliAODpidUtil.h" #include "AliESDtrack.h" ClassImp(AliAODPidHF) //------------------------------ AliAODPidHF::AliAODPidHF(): AliAODPid(), fnNSigma(5), fnSigma(), fTOFSigma(160.), fnPriors(5), fPriors(), fnPLimit(2), fPLimit(), fAsym(kFALSE), fTPC(kFALSE), fTOF(kFALSE), fITS(kFALSE), fTRD(kFALSE), fMatch(0), fCompat(kFALSE), fPCompatTOF(1.5), fnNSigmaCompat(2), fnSigmaCompat(), fMC(kFALSE), fOnePad(kFALSE), fMCLowEn2011(kFALSE), fppLowEn2011(kFALSE), fPbPb(kFALSE), fTOFdecide(kFALSE), fOldPid(kTRUE), fPtThresholdTPC(999999.), fPidResponse(0), fPidCombined(new AliPIDCombined()), fTPCResponse(new AliTPCPIDResponse()) { // // Default constructor // fPLimit=new Double_t[fnPLimit]; fnSigma=new Double_t[fnNSigma]; fPriors=new Double_t[fnPriors]; fnSigmaCompat=new Double_t[fnNSigmaCompat]; for(Int_t i=0;i performance to be checked Double_t nsigmaMin=999.; for(Int_t ipart=0;ipart<5;ipart++){ if(GetnSigmaTPC(track,ipart,nsigma)==1){ nsigma=TMath::Abs(nsigma); if((nsigmafnSigma[0]) pid=-1; else pid=specie; } } return pid; } //---------------------------- Int_t AliAODPidHF::ApplyPidITSRaw(AliAODTrack *track,Int_t specie) const{ // truncated mean, ITS PID if(!CheckITSPIDStatus(track)) return 0; Int_t pid=-1; if(fOldPid){ Double_t mom=track->P(); AliAODPid *pidObj = track->GetDetPid(); Double_t dedx=pidObj->GetITSsignal(); UChar_t clumap=track->GetITSClusterMap(); Int_t nPointsForPid=0; for(Int_t i=2; i<6; i++){ if(clumap&(1<GetStatus() & AliESDtrack::kTPCin) isSA = kFALSE; AliITSPIDResponse itsResponse; if(specie<0){ // from RawSignalPID : should return the particle specie to wich the de/dx is closer to the bethe-block curve -> performance to be checked Double_t nsigmaMax=fnSigma[4]; for(Int_t ipart=0;ipart<5;ipart++){ AliPID::EParticleType type=AliPID::EParticleType(ipart); Double_t nsigma = TMath::Abs(itsResponse.GetNumberOfSigmas(mom,dedx,type,nPointsForPid,isSA)); if((nsigmafnSigma[4]) { pid=-1; }else{ pid=specie; } } }else{ // old pid if(specie<0){ // from RawSignalPID : should return the particle specie to wich the de/dx is closer to the bethe-block curve -> performance to be checked Double_t nsigmaMax=fnSigma[4]; for(Int_t ipart=0;ipart<5;ipart++){ AliPID::EParticleType type=AliPID::EParticleType(ipart); Double_t nsigma = TMath::Abs(fPidResponse->NumberOfSigmasITS(track,type)); if((nsigmaNumberOfSigmasITS(track,type)); if (nsigma>fnSigma[4]) { pid=-1; }else{ pid=specie; } } } //new pid return pid; } //---------------------------- Int_t AliAODPidHF::ApplyPidTOFRaw(AliAODTrack *track,Int_t specie) const{ // n-sigma cut, TOF PID Double_t nsigma; Int_t pid=-1; if(specie<0){ Double_t nsigmaMin=999.; for(Int_t ipart=0;ipart<5;ipart++){ if(GetnSigmaTOF(track,ipart,nsigma)==1){ nsigma=TMath::Abs(nsigma); if((nsigmafnSigma[3]) pid=-1; else pid=specie; } } return pid; /* Double_t time[AliPID::kSPECIESN]; Double_t sigmaTOFPid[AliPID::kSPECIES]; AliAODPid *pidObj = track->GetDetPid(); pidObj->GetIntegratedTimes(time); Double_t sigTOF=pidObj->GetTOFsignal(); AliAODEvent *event=(AliAODEvent*)track->GetAODEvent(); if (event) { AliTOFHeader* tofH=(AliTOFHeader*)event->GetTOFHeader(); if (tofH && fPidResponse) { // reading new AOD with new aliroot AliTOFPIDResponse TOFres = (AliTOFPIDResponse)fPidResponse->GetTOFResponse(); sigTOF -= TOFres.GetStartTime(track->P()); if (specie<0) { for (Int_t ipart = 0; ipart<5; ipart++) { sigmaTOFPid[ipart]=TOFres.GetExpectedSigma(track->P(),time[ipart],AliPID::ParticleMass(ipart)); } } else sigmaTOFPid[specie]=TOFres.GetExpectedSigma(track->P(),time[specie],AliPID::ParticleMass(specie)); //fTOFResponse is set in InitialiseEvent } else pidObj->GetTOFpidResolution(sigmaTOFPid); // reading old AOD with new aliroot } else pidObj->GetTOFpidResolution(sigmaTOFPid); //reading old AOD with old aliroot Int_t pid=-1; if(specie<0){ Double_t sigmaTOFtrack; if (sigmaTOFPid[4]>0) sigmaTOFtrack=sigmaTOFPid[4]; else sigmaTOFtrack=fTOFSigma; Double_t nsigmaMax=sigmaTOFtrack*fnSigma[3]; for(Int_t ipart=0;ipart<5;ipart++){ Double_t nsigma=TMath::Abs(sigTOF-time[ipart]); if (sigmaTOFPid[ipart]>0) sigmaTOFtrack=sigmaTOFPid[ipart]; else sigmaTOFtrack=fTOFSigma; // backward compatibility for old AODs if((nsigma0) sigmaTOFtrack=sigmaTOFPid[specie]; else sigmaTOFtrack=fTOFSigma; // backward compatibility for old AODs if (nsigma>fnSigma[3]*sigmaTOFtrack) { pid=-1; }else{ pid=specie; } } return pid; */ } //------------------------------ void AliAODPidHF::CombinedProbability(AliAODTrack *track,Bool_t *type) const{ // combined PID stored inside the AOD track const Double_t *pid=track->PID(); Float_t max=0.; Int_t k=-1; for (Int_t i=0; i<10; i++) { if (pid[i]>max) {k=i; max=pid[i];} } if(k==2) type[0]=kTRUE; if(k==3) type[1]=kTRUE; if(k==4) type[2]=kTRUE; return; } //-------------------- void AliAODPidHF::BayesianProbability(AliAODTrack *track,Double_t *pid) const{ // bayesian PID for single detectors or combined if(fITS && !fTPC && !fTOF) {BayesianProbabilityITS(track,pid);return;} if(fTPC && !fITS && !fTOF) {BayesianProbabilityTPC(track,pid);return;} if(fTOF && !fITS && !fTPC) {BayesianProbabilityTOF(track,pid);return;} Double_t probITS[5]={1.,1.,1.,1.,1.}; Double_t probTPC[5]={1.,1.,1.,1.,1.}; Double_t probTOF[5]={1.,1.,1.,1.,1.}; if(fITS) BayesianProbabilityITS(track,probITS); if(fTPC) BayesianProbabilityTPC(track,probTPC); if(fTOF) BayesianProbabilityTOF(track,probTOF); Double_t probTot[5]={0.,0.,0.,0.,0.}; for(Int_t i=0;i<5;i++){ probTot[i]=probITS[i]*probTPC[i]*probTOF[i]; } for(Int_t i2=0;i2<5;i2++){ pid[i2]=probTot[i2]*fPriors[i2]/(probTot[0]*fPriors[0]+probTot[1]*fPriors[1]+probTot[2]*fPriors[2]+probTot[3]*fPriors[3]+probTot[4]*fPriors[4]); } return; } //------------------------------------ void AliAODPidHF::BayesianProbabilityITS(AliAODTrack *track,Double_t *prob) const{ // bayesian PID for ITS AliAODpidUtil pid; Double_t itspid[AliPID::kSPECIES]; pid.MakeITSPID(track,itspid); for(Int_t ind=0;indGetStatus()&AliESDtrack::kITSin)==0) return kFALSE; UChar_t clumap=track->GetITSClusterMap(); Int_t nPointsForPid=0; for(Int_t i=2; i<6; i++){ if(clumap&(1<GetStatus()&AliESDtrack::kTPCin )==0) return kFALSE; UShort_t nTPCClus=track->GetTPCClusterMap().CountBits(); if (nTPCClus<70) return kFALSE; return kTRUE; } //-------------------------------- Bool_t AliAODPidHF::CheckTOFPIDStatus(AliAODTrack *track) const{ // TOF PID quality cuts if ((track->GetStatus()&AliESDtrack::kTOFout )==0) return kFALSE; if ((track->GetStatus()&AliESDtrack::kTIME )==0) return kFALSE; if ((track->GetStatus()&AliESDtrack::kTOFpid )==0) return kFALSE; if (!(track->GetStatus()&AliESDtrack::kTOFmismatch)==0) return kFALSE; return kTRUE; } //-------------------------------- Bool_t AliAODPidHF::CheckTRDPIDStatus(AliAODTrack *track) const{ // TRD PID quality cuts if ((track->GetStatus()&AliESDtrack::kTRDout )==0) return kFALSE; return kTRUE; } //-------------------------------- Bool_t AliAODPidHF::CheckStatus(AliAODTrack *track,TString detectors) const{ // Quality cuts on the tracks, detector by detector if(detectors.Contains("ITS")){ if ((track->GetStatus()&AliESDtrack::kITSin)==0) return kFALSE; UChar_t clumap=track->GetITSClusterMap(); Int_t nPointsForPid=0; for(Int_t i=2; i<6; i++){ if(clumap&(1<GetStatus()&AliESDtrack::kTPCin )==0) return kFALSE; UShort_t nTPCClus=track->GetTPCClusterMap().CountBits(); if (nTPCClus<70) return kFALSE; } if(detectors.Contains("TOF")){ if ((track->GetStatus()&AliESDtrack::kTOFout )==0) return kFALSE; if ((track->GetStatus()&AliESDtrack::kTIME )==0) return kFALSE; if ((track->GetStatus()&AliESDtrack::kTOFpid )==0) return kFALSE; if (!(track->GetStatus()&AliESDtrack::kTOFmismatch)==0) return kFALSE; } if(detectors.Contains("TRD")){ if ((track->GetStatus()&AliESDtrack::kTRDout )==0) return kFALSE; //UChar_t ntracklets = track->GetTRDntrackletsPID(); //if(ntracklets<4) return kFALSE; } return kTRUE; } //-------------------------------------------- Bool_t AliAODPidHF::TPCRawAsym(AliAODTrack* track,Int_t specie) const{ // TPC nsigma cut PID, different sigmas in different p bins Double_t nsigma; if(GetnSigmaTPC(track,specie,nsigma)!=1) return kFALSE; nsigma=TMath::Abs(nsigma); AliAODPid *pidObj = track->GetDetPid(); Double_t mom = pidObj->GetTPCmomentum(); if(mom>fPtThresholdTPC) return 0; if(momfPLimit[0] && nsigmafPLimit[1] && nsigma0){ Double_t ptrack=track->P(); if(ptrack>fPCompatTOF) { Double_t sig0tmp=fnSigma[3]; SetSigma(3,fnSigmaCompat[1]); if(ApplyPidTOFRaw(track,specie)==specie) tTOFinfo=0; SetSigma(3,sig0tmp); } } } if(tTPCinfo+tTOFinfo==0 && fTOFdecide){ if(!okTOF) return tTPCinfo; return tTOFinfo; } if(tTPCinfo+tTOFinfo==0 && fITS){ if(!CheckITSPIDStatus(track)) return tTPCinfo+tTOFinfo; Int_t tITSinfo = -1; if(ApplyPidITSRaw(track,specie)==specie) tITSinfo=1; return tITSinfo; } return tTPCinfo+tTOFinfo; } if(fMatch==2){ //TPC & TOF (a la' Yifei) // convention: -1 = kFALSE, 1 = kTRUE, 0 = not identified Int_t tTPCinfo=0; if(fTPC && okTPC) { tTPCinfo=1; if(fAsym){ if(!TPCRawAsym(track,specie)) tTPCinfo=-1; }else{ if(ApplyPidTPCRaw(track,specie)!=specie) tTPCinfo=-1; } } Int_t tTOFinfo=1; if(fTOF){ if(fTPC && !okTOF) return tTPCinfo; if(ApplyPidTPCRaw(track,specie)!=specie) tTOFinfo=-1; } if(tTOFinfo==1 && tTPCinfo==1) return 1; if(tTPCinfo+tTOFinfo==0 && fITS){ if(!CheckITSPIDStatus(track)) return tTPCinfo+tTOFinfo; Int_t tITSinfo = -1; if(ApplyPidITSRaw(track,specie)==specie) tITSinfo=1; return tITSinfo; } return -1; } if(fMatch==3){ //TPC for p=fPLimit[0] (a la' Andrea A.) // convention (temporary): -1 = kFALSE, 1 = kTRUE, 0 = not identified if(fTPC && fTOF) if(!okTPC && !okTOF) return 0; Double_t ptrack=track->P(); Int_t tTPCinfo=-1; if(ptrack>=fPLimit[0] && ptrack=fPLimit[1] && fTOF){ if(!okTOF) return 0; if(ApplyPidTOFRaw(track,specie)==specie) tTOFinfo=1; return tTOFinfo; } Int_t tITSinfo=-1; if(ptrack0){ return MatchTPCTOF(track,specie); }else{ if(fTPC && !fTOF && !fITS) { Int_t tTPCres=0; if(!fAsym){ tTPCres=ApplyPidTPCRaw(track,specie); if(tTPCres==specie) return 1; else return tTPCres; }else{ if(TPCRawAsym(track,specie)) tTPCres=1; else tTPCres=-1; } return tTPCres; }else if(fTOF && !fTPC && !fITS) { Int_t tTOFres=ApplyPidTOFRaw(track,specie); if(tTOFres==specie) return 1; else return tTOFres; }else if(fITS && !fTPC && !fTOF) { Int_t tITSres=ApplyPidITSRaw(track,specie); if(tITSres==specie) return 1; else return tITSres; }else{ AliError("You should enable just one detector if you don't want to match"); return 0; } } } //-------------------------------------------- void AliAODPidHF::GetTPCBetheBlochParams(Double_t alephParameters[5]) const { // TPC bethe bloch parameters if(fMC) { // MC if(fPbPb) { // PbPb MC alephParameters[0] = 1.44405/50.; alephParameters[1] = 2.35409e+01; alephParameters[2] = TMath::Exp(-2.90330e+01); alephParameters[3] = 2.10681e+00; alephParameters[4] = 4.62254e+00; } else { // pp MC if(fMCLowEn2011){ alephParameters[0]=0.0207667; alephParameters[1]=29.9936; alephParameters[2]=3.87866e-11; alephParameters[3]=2.17291; alephParameters[4]=7.1623; }else if(fOnePad){ alephParameters[0]=0.029021; alephParameters[1]=25.4181; alephParameters[2]=4.66596e-08; alephParameters[3]=1.90008; alephParameters[4]=4.63783; }else{ alephParameters[0] = 2.15898/50.; alephParameters[1] = 1.75295e+01; alephParameters[2] = 3.40030e-09; alephParameters[3] = 1.96178e+00; alephParameters[4] = 3.91720e+00; } } } else { // Real Data if(fOnePad) { // pp 1-pad (since LHC10d) alephParameters[0] =1.34490e+00/50.; alephParameters[1] = 2.69455e+01; alephParameters[2] = TMath::Exp(-2.97552e+01); alephParameters[3] = 2.35339e+00; alephParameters[4] = 5.98079e+00; } else if(fPbPb) { // PbPb // alephParameters[0] = 1.25202/50.; // alephParameters[1] = 2.74992e+01; // alephParameters[2] = TMath::Exp(-3.31517e+01); // alephParameters[3] = 2.46246; // alephParameters[4] = 6.78938; alephParameters[0] = 5.10207e+00/50.; alephParameters[1] = 7.94982e+00; alephParameters[2] = TMath::Exp(-9.07942e+00); alephParameters[3] = 2.38808e+00; alephParameters[4] = 1.68165e+00; } else if(fppLowEn2011){ // pp low energy alephParameters[0]=0.031642; alephParameters[1]=22.353; alephParameters[2]=4.16239e-12; alephParameters[3]=2.61952; alephParameters[4]=5.76086; } else { // pp no 1-pad (LHC10bc) alephParameters[0] = 0.0283086/0.97; alephParameters[1] = 2.63394e+01; alephParameters[2] = 5.04114e-11; alephParameters[3] = 2.12543e+00; alephParameters[4] = 4.88663e+00; } } } //----------------------- void AliAODPidHF::SetBetheBloch() { // Set Bethe Bloch Parameters Double_t alephParameters[5]; GetTPCBetheBlochParams(alephParameters); fTPCResponse->SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]); return; } //----------------------- Bool_t AliAODPidHF::IsTOFPiKexcluded(AliAODTrack *track,Double_t nsigmaK){ Double_t nsigma; if(GetnSigmaTOF(track,3,nsigma)==1){ nsigma=TMath::Abs(nsigma); if(nsigma>nsigmaK) return kTRUE; } return kFALSE; /* Double_t time[AliPID::kSPECIESN]; Double_t sigmaTOFPid[AliPID::kSPECIES]; AliAODPid *pidObj = track->GetDetPid(); pidObj->GetIntegratedTimes(time); Double_t sigTOF=pidObj->GetTOFsignal(); AliAODEvent *event=(AliAODEvent*)track->GetAODEvent(); if (event) { AliTOFHeader* tofH=(AliTOFHeader*)event->GetTOFHeader(); if (tofH && fPidResponse) { AliTOFPIDResponse TOFres = (AliTOFPIDResponse)fPidResponse->GetTOFResponse(); sigTOF -= TOFres.GetStartTime(track->P()); sigmaTOFPid[3]=TOFres.GetExpectedSigma(track->P(),time[3],AliPID::ParticleMass(3)); } else pidObj->GetTOFpidResolution(sigmaTOFPid); } else pidObj->GetTOFpidResolution(sigmaTOFPid); Double_t sigmaTOFtrack; if (sigmaTOFPid[3]>0) sigmaTOFtrack=sigmaTOFPid[3]; else sigmaTOFtrack=fTOFSigma; // backward compatibility for old AODs if((sigTOF-time[3])>nsigmaK*sigmaTOFtrack)return kTRUE;// K, Pi excluded (->LIKELY A PROTON) return kFALSE; */ } //-------------------------------------------------------------------------- void AliAODPidHF::SetPriorDistribution(AliPID::EParticleType type,TH1F *prior){ // // method setting the prior distributions to the AliPIDCombined object of the AliAODPidHF data member // all the checks are done directly in the AliPIDCombined object // GetPidCombined()->SetPriorDistribution(type,prior); } //-------------------------------------------------------------------------- void AliAODPidHF::DrawPrior(AliPID::EParticleType type){ // // Drawing prior distribution for type "type" new TCanvas(); GetPidCombined()->GetPriorDistribution(type)->Draw(); } //-------------------------------------------------------------------------- Int_t AliAODPidHF::GetnSigmaTPC(AliAODTrack *track, Int_t species, Double_t &nsigma) const{ if(!CheckTPCPIDStatus(track)) return -1; Double_t nsigmaTPC=-999; if(fOldPid){ AliAODPid *pidObj = track->GetDetPid(); Double_t dedx=pidObj->GetTPCsignal(); Double_t mom = pidObj->GetTPCmomentum(); if(mom>fPtThresholdTPC) return -2; UShort_t nTPCClus=pidObj->GetTPCsignalN(); if(nTPCClus==0) {nTPCClus=track->GetTPCNcls();} AliPID::EParticleType type=AliPID::EParticleType(species); nsigmaTPC = fTPCResponse->GetNumberOfSigmas(mom,dedx,nTPCClus,type); nsigma=nsigmaTPC; } else{ if(!fPidResponse) return -1; AliPID::EParticleType type=AliPID::EParticleType(species); nsigmaTPC = fPidResponse->NumberOfSigmasTPC(track,type); nsigma=nsigmaTPC; } return 1; } //----------------------------- Int_t AliAODPidHF::GetnSigmaTOF(AliAODTrack *track,Int_t species, Double_t &nsigma) const{ if(!CheckTOFPIDStatus(track)) return -1; if(fPidResponse){ nsigma = fPidResponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)species); }else{ AliAODEvent *event=(AliAODEvent*)track->GetAODEvent(); if (event) { AliTOFHeader* tofH=(AliTOFHeader*)event->GetTOFHeader(); if (tofH) { // reading a new AOD without setting fPidResponse!!! AliFatal("To use this AOD you must start AliPIDResponseTask"); } else { Double_t time[AliPID::kSPECIESN]; Double_t sigmaTOFPid[AliPID::kSPECIES]; AliAODPid *pidObj = track->GetDetPid(); pidObj->GetIntegratedTimes(time); Double_t sigTOF=pidObj->GetTOFsignal(); pidObj->GetTOFpidResolution(sigmaTOFPid); if(sigmaTOFPid[species]<1e-99) return -2; Double_t sigmaTOF=(sigTOF-time[species])/sigmaTOFPid[species]; nsigma=sigmaTOF; } } } return 1; } //-----------------------------