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: AliPIDResponse.cxx 46193 2010-12-21 09:00:14Z wiechula $ */
18 //-----------------------------------------------------------------
19 // Base class for handling the pid response //
20 // functions of all detectors //
21 // and give access to the nsigmas //
23 // Origin: Jens Wiechula, Uni Tuebingen, jens.wiechula@cern.ch //
24 //-----------------------------------------------------------------
27 #include <TObjArray.h>
33 #include <AliVEvent.h>
34 #include <AliVTrack.h>
37 #include <AliOADBContainer.h>
38 #include <AliTRDPIDParams.h>
39 #include <AliTRDPIDReference.h>
41 #include "AliPIDResponse.h"
43 #include "AliCentrality.h"
45 ClassImp(AliPIDResponse);
47 AliPIDResponse::AliPIDResponse(Bool_t isMC/*=kFALSE*/) :
48 TNamed("PIDResponse","PIDResponse"),
55 fITSPIDmethod(kITSTruncMean),
67 fArrPidResponseMaster(0x0),
68 fResolutionCorrection(0x0),
70 fTRDPIDReference(0x0),
71 fTOFTimeZeroType(kBest_T0),
81 AliLog::SetClassDebugLevel("AliPIDResponse",10);
82 AliLog::SetClassDebugLevel("AliESDpid",10);
83 AliLog::SetClassDebugLevel("AliAODpidUtil",10);
85 memset(fTRDslicesForPID,0,sizeof(UInt_t)*2);
88 //______________________________________________________________________________
89 AliPIDResponse::~AliPIDResponse()
94 delete fArrPidResponseMaster;
96 delete fTRDPIDReference;
99 //______________________________________________________________________________
100 AliPIDResponse::AliPIDResponse(const AliPIDResponse &other) :
102 fITSResponse(other.fITSResponse),
103 fTPCResponse(other.fTPCResponse),
104 fTRDResponse(other.fTRDResponse),
105 fTOFResponse(other.fTOFResponse),
106 fEMCALResponse(other.fEMCALResponse),
107 fRange(other.fRange),
108 fITSPIDmethod(other.fITSPIDmethod),
110 fOADBPath(other.fOADBPath),
114 fMCperiodUser(other.fMCperiodUser),
117 fRecoPassUser(other.fRecoPassUser),
120 fArrPidResponseMaster(0x0),
121 fResolutionCorrection(0x0),
123 fTRDPIDReference(0x0),
124 fTOFTimeZeroType(AliPIDResponse::kBest_T0),
127 fEMCALPIDParams(0x0),
134 memset(fTRDslicesForPID,0,sizeof(UInt_t)*2);
137 //______________________________________________________________________________
138 AliPIDResponse& AliPIDResponse::operator=(const AliPIDResponse &other)
144 delete fArrPidResponseMaster;
145 TNamed::operator=(other);
146 fITSResponse=other.fITSResponse;
147 fTPCResponse=other.fTPCResponse;
148 fTRDResponse=other.fTRDResponse;
149 fTOFResponse=other.fTOFResponse;
150 fEMCALResponse=other.fEMCALResponse;
152 fITSPIDmethod=other.fITSPIDmethod;
153 fOADBPath=other.fOADBPath;
158 fMCperiodUser=other.fMCperiodUser;
161 fRecoPassUser=other.fRecoPassUser;
164 fArrPidResponseMaster=0x0;
165 fResolutionCorrection=0x0;
167 fTRDPIDReference=0x0;
169 memset(fTRDslicesForPID,0,sizeof(UInt_t)*2);
170 fTOFTimeZeroType=AliPIDResponse::kBest_T0;
173 fCurrentEvent=other.fCurrentEvent;
178 //______________________________________________________________________________
179 Float_t AliPIDResponse::NumberOfSigmas(EDetCode detCode, const AliVParticle *track, AliPID::EParticleType type) const
182 // NumberOfSigmas for 'detCode'
186 case kDetITS: return NumberOfSigmasITS(track, type); break;
187 case kDetTPC: return NumberOfSigmasTPC(track, type); break;
188 case kDetTOF: return NumberOfSigmasTOF(track, type); break;
189 // case kDetTRD: return ComputeTRDProbability(track, type); break;
190 // case kDetPHOS: return ComputePHOSProbability(track, type); break;
191 // case kDetEMCAL: return NumberOfSigmasEMCAL(track, type); break;
192 // case kDetHMPID: return ComputeHMPIDProbability(track, type); break;
193 default: return -999.;
198 //______________________________________________________________________________
199 Float_t AliPIDResponse::NumberOfSigmasEMCAL(const AliVTrack *track, AliPID::EParticleType type) const {
201 AliVCluster *matchedClus = NULL;
206 Double_t fClsE = -1.;
208 Int_t nMatchClus = -1;
212 nMatchClus = track->GetEMCALcluster();
217 charge = track->Charge();
219 matchedClus = (AliVCluster*)fCurrentEvent->GetCaloCluster(nMatchClus);
223 // matched cluster is EMCAL
224 if(matchedClus->IsEMCAL()){
226 fClsE = matchedClus->E();
230 // NSigma value really meaningful only for electrons!
231 return fEMCALResponse.GetNumberOfSigmas(pt,EovP,type,charge);
240 //______________________________________________________________________________
241 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputePIDProbability (EDetCode detCode, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
244 // Compute PID response of 'detCode'
248 case kDetITS: return ComputeITSProbability(track, nSpecies, p); break;
249 case kDetTPC: return ComputeTPCProbability(track, nSpecies, p); break;
250 case kDetTOF: return ComputeTOFProbability(track, nSpecies, p); break;
251 case kDetTRD: return ComputeTRDProbability(track, nSpecies, p); break;
252 case kDetPHOS: return ComputePHOSProbability(track, nSpecies, p); break;
253 case kDetEMCAL: return ComputeEMCALProbability(track, nSpecies, p); break;
254 case kDetHMPID: return ComputeHMPIDProbability(track, nSpecies, p); break;
255 default: return kDetNoSignal;
259 //______________________________________________________________________________
260 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeITSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
263 // Compute PID response for the ITS
266 // set flat distribution (no decision)
267 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
269 if ((track->GetStatus()&AliVTrack::kITSin)==0 &&
270 (track->GetStatus()&AliVTrack::kITSout)==0) return kDetNoSignal;
272 Double_t mom=track->P();
273 Double_t dedx=track->GetITSsignal();
276 ULong_t trStatus=track->GetStatus();
277 if(trStatus&AliVTrack::kTPCin) isSA=kFALSE;
278 UChar_t clumap=track->GetITSClusterMap();
279 Int_t nPointsForPid=0;
280 for(Int_t i=2; i<6; i++){
281 if(clumap&(1<<i)) ++nPointsForPid;
284 if(nPointsForPid<3) { // track not to be used for combined PID purposes
285 // track->ResetStatus(AliVTrack::kITSpid);
289 Bool_t mismatch=kTRUE/*, heavy=kTRUE*/;
290 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
291 Double_t mass=AliPID::ParticleMass(j);//GeV/c^2
292 Double_t bethe=fITSResponse.Bethe(momITS,mass);
293 Double_t sigma=fITSResponse.GetResolution(bethe,nPointsForPid,isSA);
294 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
295 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
297 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
301 // Check for particles heavier than (AliPID::kSPECIES - 1)
302 // if (dedx < (bethe + fRange*sigma)) heavy=kFALSE;
307 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES;
314 //______________________________________________________________________________
315 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeTPCProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
318 // Compute PID response for the TPC
321 // set flat distribution (no decision)
322 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
324 // check quality of the track
325 if ( (track->GetStatus()&AliVTrack::kTPCin )==0 && (track->GetStatus()&AliVTrack::kTPCout)==0 ) return kDetNoSignal;
327 Double_t mom = track->GetTPCmomentum();
329 Double_t dedx=track->GetTPCsignal();
330 Bool_t mismatch=kTRUE/*, heavy=kTRUE*/;
332 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
333 AliPID::EParticleType type=AliPID::EParticleType(j);
334 Double_t bethe=fTPCResponse.GetExpectedSignal(mom,type);
335 Double_t sigma=fTPCResponse.GetExpectedSigma(mom,track->GetTPCsignalN(),type);
336 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
337 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
339 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
343 // TODO: Light nuclei, also in TPC pid response
345 // Check for particles heavier than (AliPID::kSPECIES - 1)
346 // if (dedx < (bethe + fRange*sigma)) heavy=kFALSE;
351 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
357 //______________________________________________________________________________
358 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeTOFProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
361 // Compute PID response for the
364 Double_t meanCorrFactor = 0.11/fTOFtail; // Correction factor on the mean because of the tail (should be ~ 0.1 with tail = 1.1)
366 // set flat distribution (no decision)
367 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
369 if ((track->GetStatus()&AliVTrack::kTOFout)==0) return kDetNoSignal;
370 if ((track->GetStatus()&AliVTrack::kTIME)==0) return kDetNoSignal;
372 Double_t time[AliPID::kSPECIESN];
373 track->GetIntegratedTimes(time);
375 Double_t sigma[AliPID::kSPECIES];
376 for (Int_t iPart = 0; iPart < AliPID::kSPECIES; iPart++) {
377 sigma[iPart] = fTOFResponse.GetExpectedSigma(track->P(),time[iPart],AliPID::ParticleMass(iPart));
380 Bool_t mismatch = kTRUE/*, heavy = kTRUE*/;
381 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
382 AliPID::EParticleType type=AliPID::EParticleType(j);
383 Double_t nsigmas=NumberOfSigmasTOF(track,type) + meanCorrFactor;
385 Double_t sig = sigma[j];
386 if (TMath::Abs(nsigmas) > (fRange+2)) {
387 if(nsigmas < fTOFtail)
388 p[j] = TMath::Exp(-0.5*(fRange+2)*(fRange+2))/sig;
390 p[j] = TMath::Exp(-(fRange+2 - fTOFtail*0.5)*fTOFtail)/sig;
392 if(nsigmas < fTOFtail)
393 p[j] = TMath::Exp(-0.5*nsigmas*nsigmas)/sig;
395 p[j] = TMath::Exp(-(nsigmas - fTOFtail*0.5)*fTOFtail)/sig;
398 /* OLD Gaussian shape
399 if (TMath::Abs(nsigmas) > (fRange+2)) {
400 p[j] = TMath::Exp(-0.5*(fRange+2)*(fRange+2))/sig;
402 p[j] = TMath::Exp(-0.5*nsigmas*nsigmas)/sig;
405 if (TMath::Abs(nsigmas)<5.){
406 Double_t nsigmasTPC=NumberOfSigmasTPC(track,type);
407 if (TMath::Abs(nsigmasTPC)<5.) mismatch=kFALSE;
415 // TODO: Light nuclei
419 //______________________________________________________________________________
420 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
423 // Compute PID response for the
426 // set flat distribution (no decision)
427 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
428 if((track->GetStatus()&AliVTrack::kTRDout)==0) return kDetNoSignal;
431 Double_t dedx[48]; // Allocate space for the maximum number of TRD slices
432 Int_t nslices = fTRDslicesForPID[1] - fTRDslicesForPID[0] + 1;
433 AliDebug(1, Form("First Slice: %d, Last Slice: %d, Number of slices: %d", fTRDslicesForPID[0], fTRDslicesForPID[1], nslices));
434 for(UInt_t ilayer = 0; ilayer < 6; ilayer++){
435 mom[ilayer] = track->GetTRDmomentum(ilayer);
436 for(UInt_t islice = fTRDslicesForPID[0]; islice <= fTRDslicesForPID[1]; islice++){
437 dedx[ilayer*nslices+islice-fTRDslicesForPID[0]] = track->GetTRDslice(ilayer, islice);
440 fTRDResponse.GetResponse(nslices, dedx, mom, p);
443 //______________________________________________________________________________
444 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeEMCALProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
447 // Compute PID response for the EMCAL
450 AliVCluster *matchedClus = NULL;
455 Double_t fClsE = -1.;
457 Int_t nMatchClus = -1;
461 nMatchClus = track->GetEMCALcluster();
467 charge = track->Charge();
469 matchedClus = (AliVCluster*)fCurrentEvent->GetCaloCluster(nMatchClus);
473 // matched cluster is EMCAL
474 if(matchedClus->IsEMCAL()){
476 fClsE = matchedClus->E();
480 // compute the probabilities
481 if( 999 != fEMCALResponse.ComputeEMCALProbability(pt,EovP,charge,p)){
483 // in case everything is OK
491 // in all other cases set flat distribution (no decision)
492 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
496 //______________________________________________________________________________
497 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputePHOSProbability (const AliVTrack */*track*/, Int_t nSpecies, Double_t p[]) const
500 // Compute PID response for the PHOS
503 // set flat distribution (no decision)
504 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
507 //______________________________________________________________________________
508 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeHMPIDProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
511 // Compute PID response for the HMPID
514 // set flat distribution (no decision)
515 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
516 if((track->GetStatus()&AliVTrack::kHMPIDpid)==0) return kDetNoSignal;
518 track->GetHMPIDpid(p);
523 //______________________________________________________________________________
524 void AliPIDResponse::InitialiseEvent(AliVEvent *event, Int_t pass)
527 // Apply settings for the current event
534 fRun=event->GetRunNumber();
541 //TPC resolution parametrisation PbPb
542 if ( fResolutionCorrection ){
543 Double_t corrSigma=fResolutionCorrection->Eval(GetTPCMultiplicityBin(event));
544 fTPCResponse.SetSigma(3.79301e-03*corrSigma, 2.21280e+04);
548 SetTOFResponse(event, (AliPIDResponse::EStartTimeType_t)fTOFTimeZeroType);
550 // Get and set centrality
551 AliCentrality *centrality = event->GetCentrality();
553 fCurrCentrality = centrality->GetCentralityPercentile("V0M");
556 fCurrCentrality = -1;
560 //______________________________________________________________________________
561 void AliPIDResponse::ExecNewRun()
564 // Things to Execute upon a new run
568 SetITSParametrisation();
570 SetTPCPidResponseMaster();
571 SetTPCParametrisation();
573 SetTRDPidResponseMaster();
574 InitializeTRDResponse();
576 SetEMCALPidResponseMaster();
577 InitializeEMCALResponse();
579 fTOFResponse.SetTimeResolution(fTOFres);
582 //_____________________________________________________
583 Double_t AliPIDResponse::GetTPCMultiplicityBin(const AliVEvent * const event)
586 // Get TPC multiplicity in bins of 150
589 const AliVVertex* vertexTPC = event->GetPrimaryVertex();
590 Double_t tpcMulti=0.;
592 Double_t vertexContribTPC=vertexTPC->GetNContributors();
593 tpcMulti=vertexContribTPC/150.;
594 if (tpcMulti>20.) tpcMulti=20.;
600 //______________________________________________________________________________
601 void AliPIDResponse::SetRecoInfo()
604 // Set reconstruction information
615 TPRegexp reg(".*(LHC11[a-z]+[0-9]+[a-z_]*)/.*");
616 //find the period by run number (UGLY, but not stored in ESD and AOD... )
617 if (fRun>=114737&&fRun<=117223) { fLHCperiod="LHC10B"; fMCperiodTPC="LHC10D1"; }
618 else if (fRun>=118503&&fRun<=121040) { fLHCperiod="LHC10C"; fMCperiodTPC="LHC10D1"; }
619 else if (fRun>=122195&&fRun<=126437) { fLHCperiod="LHC10D"; fMCperiodTPC="LHC10F6A"; }
620 else if (fRun>=127710&&fRun<=130850) { fLHCperiod="LHC10E"; fMCperiodTPC="LHC10F6A"; }
621 else if (fRun>=133004&&fRun<=135029) { fLHCperiod="LHC10F"; fMCperiodTPC="LHC10F6A"; }
622 else if (fRun>=135654&&fRun<=136377) { fLHCperiod="LHC10G"; fMCperiodTPC="LHC10F6A"; }
623 else if (fRun>=136851&&fRun<=139517) {
625 fMCperiodTPC="LHC10H8";
626 if (reg.MatchB(fCurrentFile)) fMCperiodTPC="LHC11A10";
629 else if (fRun>=139699&&fRun<=146860) { fLHCperiod="LHC11A"; fMCperiodTPC="LHC10F6A"; }
630 //TODO: periods 11B, 11C are not yet treated assume 11d for the moment
631 else if (fRun>=148531&&fRun<=155384) { fLHCperiod="LHC11D"; fMCperiodTPC="LHC10F6A"; }
632 else if (fRun>=156477&&fRun<=159635) { fLHCperiod="LHC11D"; fMCperiodTPC="LHC10F6A"; }
633 else if (fRun>=166529) {
635 fMCperiodTPC="LHC11A10";
640 //exception new pp MC productions from 2011
641 if (fBeamType=="PP" && reg.MatchB(fCurrentFile)) fMCperiodTPC="LHC11B2";
644 //______________________________________________________________________________
645 void AliPIDResponse::SetITSParametrisation()
648 // Set the ITS parametrisation
652 //______________________________________________________________________________
653 void AliPIDResponse::SetTPCPidResponseMaster()
656 // Load the TPC pid response functions from the OADB
658 //don't load twice for the moment
659 if (fArrPidResponseMaster) return;
662 //reset the PID response functions
663 delete fArrPidResponseMaster;
664 fArrPidResponseMaster=0x0;
666 TString fileName(Form("%s/COMMON/PID/data/TPCPIDResponse.root", fOADBPath.Data()));
668 TFile *f=TFile::Open(fileName.Data());
669 if (f && f->IsOpen() && !f->IsZombie()){
670 fArrPidResponseMaster=dynamic_cast<TObjArray*>(f->Get("TPCPIDResponse"));
674 if (!fArrPidResponseMaster){
675 AliFatal(Form("Could not retrieve the TPC pid response from: %s",fileName.Data()));
678 fArrPidResponseMaster->SetOwner();
681 //______________________________________________________________________________
682 void AliPIDResponse::SetTPCParametrisation()
685 // Change BB parametrisation for current run
688 if (fLHCperiod.IsNull()) {
689 AliFatal("No period set, not changing parametrisation");
694 // Set default parametrisations for data and MC
698 TString datatype="DATA";
699 //in case of mc fRecoPass is per default 1
708 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec){
709 fTPCResponse.SetResponseFunction((AliPID::EParticleType)ispec,0x0);
713 //set the new PID splines
715 TString period=fLHCperiod;
716 if (fArrPidResponseMaster){
718 //for MC don't use period information
719 // if (fIsMC) period="[A-Z0-9]*";
720 //for MC use MC period information
721 if (fIsMC) period=fMCperiodTPC;
722 //pattern for the default entry (valid for all particles)
723 TPRegexp reg(Form("TSPLINE3_%s_([A-Z]*)_%s_PASS%d_%s_MEAN",datatype.Data(),period.Data(),fRecoPass,fBeamType.Data()));
725 //loop over entries and filter them
726 for (Int_t iresp=0; iresp<fArrPidResponseMaster->GetEntriesFast();++iresp){
727 TObject *responseFunction=fArrPidResponseMaster->At(iresp);
728 if (responseFunction==0x0) continue;
729 TString responseName=responseFunction->GetName();
731 if (!reg.MatchB(responseName)) continue;
733 TObjArray *arr=reg.MatchS(responseName);
734 TString particleName=arr->At(1)->GetName();
736 if (particleName.IsNull()) continue;
737 if (particleName=="ALL") grAll=responseFunction;
740 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec){
741 TString particle=AliPID::ParticleName(ispec);
743 if ( particle == particleName ){
744 fTPCResponse.SetResponseFunction((AliPID::EParticleType)ispec,responseFunction);
745 fTPCResponse.SetUseDatabase(kTRUE);
746 AliInfo(Form("Adding graph: %d - %s",ispec,responseFunction->GetName()));
753 //set default response function to all particles which don't have a specific one
755 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec){
756 if (!fTPCResponse.GetResponseFunction((AliPID::EParticleType)ispec)){
757 fTPCResponse.SetResponseFunction((AliPID::EParticleType)ispec,grAll);
758 AliInfo(Form("Adding graph: %d - %s",ispec,grAll->GetName()));
765 // Setup resolution parametrisation
769 fTPCResponse.SetSigma(3.79301e-03, 2.21280e+04);
772 fTPCResponse.SetSigma(2.30176e-02, 5.60422e+02);
774 if (fArrPidResponseMaster)
775 fResolutionCorrection=(TF1*)fArrPidResponseMaster->FindObject(Form("TF1_%s_ALL_%s_PASS%d_%s_SIGMA",datatype.Data(),period.Data(),fRecoPass,fBeamType.Data()));
777 if (fResolutionCorrection) AliInfo(Form("Setting multiplicity correction function: %s",fResolutionCorrection->GetName()));
780 //______________________________________________________________________________
781 void AliPIDResponse::SetTRDPidResponseMaster()
784 // Load the TRD pid params and references from the OADB
786 if(fTRDPIDParams) return;
787 AliOADBContainer contParams("contParams");
789 Int_t statusPars = contParams.InitFromFile(Form("%s/COMMON/PID/data/TRDPIDParams.root", fOADBPath.Data()), "AliTRDPIDParams");
791 AliError("Failed initializing PID Params from OADB");
793 AliInfo(Form("Loading TRD Params from %s/COMMON/PID/data/TRDPIDParams.root", fOADBPath.Data()));
794 fTRDPIDParams = dynamic_cast<AliTRDPIDParams *>(contParams.GetObject(fRun));
796 AliError(Form("TRD Params not found in run %d", fRun));
800 AliOADBContainer contRefs("contRefs");
801 Int_t statusRefs = contRefs.InitFromFile(Form("%s/COMMON/PID/data/TRDPIDReferenceLQ1D.root", fOADBPath.Data()), "AliTRDPIDReference");
803 AliInfo("Failed Loading References for TRD");
805 AliInfo(Form("Loading TRD References from %s/COMMON/PID/data/TRDPIDReferenceLQ1D.root", fOADBPath.Data()));
806 fTRDPIDReference = dynamic_cast<AliTRDPIDReference *>(contRefs.GetObject(fRun));
807 if(!fTRDPIDReference){
808 AliError(Form("TRD References not found in OADB Container for run %d", fRun));
813 //______________________________________________________________________________
814 void AliPIDResponse::InitializeTRDResponse(){
816 // Set PID Params and references to the TRD PID response
818 fTRDResponse.SetPIDParams(fTRDPIDParams);
819 fTRDResponse.Load(fTRDPIDReference);
820 if(fLHCperiod == "LHC10b" || fLHCperiod == "LHC10c" || fLHCperiod == "LHC10d" || fLHCperiod == "LHC10e"){
821 fTRDslicesForPID[0] = 0;
822 fTRDslicesForPID[1] = 7;
826 //_________________________________________________________________________
827 Bool_t AliPIDResponse::IdentifiedAsElectronTRD(const AliVTrack *vtrack, Double_t efficiencyLevel) const {
829 // Check whether track is identified as electron under a given electron efficiency hypothesis
831 Double_t probs[AliPID::kSPECIES];
832 ComputeTRDProbability(vtrack, AliPID::kSPECIES, probs);
834 Int_t ntracklets = vtrack->GetTRDntrackletsPID();
835 // Take mean of the TRD momenta in the given tracklets
836 Float_t p = 0, trdmomenta[AliVTrack::kTRDnPlanes];
838 for(Int_t iPl=0;iPl<AliVTrack::kTRDnPlanes;iPl++){
839 if(vtrack->GetTRDmomentum(iPl) > 0.){
840 trdmomenta[nmomenta++] = vtrack->GetTRDmomentum(iPl);
843 p = TMath::Mean(nmomenta, trdmomenta);
845 return fTRDResponse.IdentifiedAsElectron(ntracklets, probs, p, efficiencyLevel);
848 //______________________________________________________________________________
849 void AliPIDResponse::SetEMCALPidResponseMaster()
852 // Load the EMCAL pid response functions from the OADB
854 TObjArray* fEMCALPIDParamsRun = NULL;
855 TObjArray* fEMCALPIDParamsPass = NULL;
857 if(fEMCALPIDParams) return;
858 AliOADBContainer contParams("contParams");
860 Int_t statusPars = contParams.InitFromFile(Form("%s/COMMON/PID/data/EMCALPIDParams.root", fOADBPath.Data()), "AliEMCALPIDParams");
862 AliError("Failed initializing PID Params from OADB");
865 AliInfo(Form("Loading EMCAL Params from %s/COMMON/PID/data/EMCALPIDParams.root", fOADBPath.Data()));
867 fEMCALPIDParamsRun = dynamic_cast<TObjArray *>(contParams.GetObject(fRun));
868 if(fEMCALPIDParamsRun) fEMCALPIDParamsPass = dynamic_cast<TObjArray *>(fEMCALPIDParamsRun->FindObject(Form("pass%d",fRecoPass)));
869 if(fEMCALPIDParamsPass) fEMCALPIDParams = dynamic_cast<TObjArray *>(fEMCALPIDParamsPass->FindObject(Form("EMCALPIDParams_Particles")));
871 if(!fEMCALPIDParams){
872 AliError(Form("EMCAL Params not found in run %d pass %d", fRun, fRecoPass));
873 AliInfo("Will take the standard LHC11d instead ...");
875 fEMCALPIDParamsRun = dynamic_cast<TObjArray *>(contParams.GetObject(156477));
876 if(fEMCALPIDParamsRun) fEMCALPIDParamsPass = dynamic_cast<TObjArray *>(fEMCALPIDParamsRun->FindObject(Form("pass%d",1)));
877 if(fEMCALPIDParamsPass) fEMCALPIDParams = dynamic_cast<TObjArray *>(fEMCALPIDParamsPass->FindObject(Form("EMCALPIDParams_Particles")));
879 if(!fEMCALPIDParams){
880 AliError(Form("DEFAULT EMCAL Params (LHC11d) not found in file %s/COMMON/PID/data/EMCALPIDParams.root", fOADBPath.Data()));
886 //______________________________________________________________________________
887 void AliPIDResponse::InitializeEMCALResponse(){
889 // Set PID Params to the EMCAL PID response
891 fEMCALResponse.SetPIDParams(fEMCALPIDParams);