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>
35 #include <TLinearFitter.h>
39 #include <AliVEvent.h>
40 #include <AliVTrack.h>
43 #include <AliOADBContainer.h>
44 #include <AliTRDPIDResponseObject.h>
45 #include <AliTOFPIDParams.h>
46 #include <AliHMPIDPIDParams.h>
48 #include "AliPIDResponse.h"
49 #include "AliDetectorPID.h"
51 #include "AliCentrality.h"
53 ClassImp(AliPIDResponse);
55 AliPIDResponse::AliPIDResponse(Bool_t isMC/*=kFALSE*/) :
56 TNamed("PIDResponse","PIDResponse"),
64 fITSPIDmethod(kITSTruncMean),
65 fTuneMConData(kFALSE),
66 fTuneMConDataMask(kDetTOF|kDetTPC),
70 fCustomTPCpidResponse(),
76 fCurrentAliRootRev(-1),
84 fArrPidResponseMaster(NULL),
85 fResolutionCorrection(NULL),
86 fOADBvoltageMaps(NULL),
87 fUseTPCEtaCorrection(kFALSE),
88 fUseTPCMultiplicityCorrection(kFALSE),
89 fTRDPIDResponseObject(NULL),
92 fHMPIDPIDParams(NULL),
93 fEMCALPIDParams(NULL),
100 AliLog::SetClassDebugLevel("AliPIDResponse",0);
101 AliLog::SetClassDebugLevel("AliESDpid",0);
102 AliLog::SetClassDebugLevel("AliAODpidUtil",0);
106 //______________________________________________________________________________
107 AliPIDResponse::~AliPIDResponse()
112 delete fArrPidResponseMaster;
113 delete fTRDPIDResponseObject;
114 delete fTOFPIDParams;
117 //______________________________________________________________________________
118 AliPIDResponse::AliPIDResponse(const AliPIDResponse &other) :
120 fITSResponse(other.fITSResponse),
121 fTPCResponse(other.fTPCResponse),
122 fTRDResponse(other.fTRDResponse),
123 fTOFResponse(other.fTOFResponse),
124 fHMPIDResponse(other.fHMPIDResponse),
125 fEMCALResponse(other.fEMCALResponse),
126 fRange(other.fRange),
127 fITSPIDmethod(other.fITSPIDmethod),
128 fTuneMConData(other.fTuneMConData),
129 fTuneMConDataMask(other.fTuneMConDataMask),
131 fCachePID(other.fCachePID),
132 fOADBPath(other.fOADBPath),
133 fCustomTPCpidResponse(other.fCustomTPCpidResponse),
137 fMCperiodUser(other.fMCperiodUser),
139 fCurrentAliRootRev(other.fCurrentAliRootRev),
141 fRecoPassUser(other.fRecoPassUser),
147 fArrPidResponseMaster(NULL),
148 fResolutionCorrection(NULL),
149 fOADBvoltageMaps(NULL),
150 fUseTPCEtaCorrection(other.fUseTPCEtaCorrection),
151 fUseTPCMultiplicityCorrection(other.fUseTPCMultiplicityCorrection),
152 fTRDPIDResponseObject(NULL),
155 fHMPIDPIDParams(NULL),
156 fEMCALPIDParams(NULL),
165 //______________________________________________________________________________
166 AliPIDResponse& AliPIDResponse::operator=(const AliPIDResponse &other)
172 delete fArrPidResponseMaster;
173 TNamed::operator=(other);
174 fITSResponse=other.fITSResponse;
175 fTPCResponse=other.fTPCResponse;
176 fTRDResponse=other.fTRDResponse;
177 fTOFResponse=other.fTOFResponse;
178 fHMPIDResponse=other.fHMPIDResponse;
179 fEMCALResponse=other.fEMCALResponse;
181 fITSPIDmethod=other.fITSPIDmethod;
182 fOADBPath=other.fOADBPath;
183 fCustomTPCpidResponse=other.fCustomTPCpidResponse;
184 fTuneMConData=other.fTuneMConData;
185 fTuneMConDataMask=other.fTuneMConDataMask;
187 fCachePID=other.fCachePID;
191 fMCperiodUser=other.fMCperiodUser;
193 fCurrentAliRootRev=other.fCurrentAliRootRev;
195 fRecoPassUser=other.fRecoPassUser;
201 fArrPidResponseMaster=NULL;
202 fResolutionCorrection=NULL;
203 fOADBvoltageMaps=NULL;
204 fUseTPCEtaCorrection=other.fUseTPCEtaCorrection;
205 fUseTPCMultiplicityCorrection=other.fUseTPCMultiplicityCorrection;
206 fTRDPIDResponseObject=NULL;
207 fEMCALPIDParams=NULL;
210 fHMPIDPIDParams=NULL;
211 fCurrentEvent=other.fCurrentEvent;
217 //______________________________________________________________________________
218 Float_t AliPIDResponse::NumberOfSigmas(EDetector detector, const AliVParticle *vtrack, AliPID::EParticleType type) const
221 // NumberOfSigmas for 'detCode'
224 const AliVTrack *track=static_cast<const AliVTrack*>(vtrack);
225 // look for cached value first
226 const AliDetectorPID *detPID=track->GetDetectorPID();
228 if ( detPID && detPID->HasNumberOfSigmas(detector)){
229 return detPID->GetNumberOfSigmas(detector, type);
230 } else if (fCachePID) {
231 FillTrackDetectorPID(track, detector);
232 detPID=track->GetDetectorPID();
233 return detPID->GetNumberOfSigmas(detector, type);
236 return GetNumberOfSigmas(detector, track, type);
239 //______________________________________________________________________________
240 AliPIDResponse::EDetPidStatus AliPIDResponse::NumberOfSigmas(EDetector detCode, const AliVParticle *track,
241 AliPID::EParticleType type, Double_t &val) const
244 // NumberOfSigmas with detector status as return value
247 val=NumberOfSigmas(detCode, track, type);
248 return CheckPIDStatus(detCode, (AliVTrack*)track);
251 //______________________________________________________________________________
252 // public buffered versions of the PID calculation
255 //______________________________________________________________________________
256 Float_t AliPIDResponse::NumberOfSigmasITS(const AliVParticle *vtrack, AliPID::EParticleType type) const
259 // Calculate the number of sigmas in the ITS
262 return NumberOfSigmas(kITS, vtrack, type);
265 //______________________________________________________________________________
266 Float_t AliPIDResponse::NumberOfSigmasTPC(const AliVParticle *vtrack, AliPID::EParticleType type) const
269 // Calculate the number of sigmas in the TPC
272 return NumberOfSigmas(kTPC, vtrack, type);
275 //______________________________________________________________________________
276 Float_t AliPIDResponse::NumberOfSigmasTPC( const AliVParticle *vtrack,
277 AliPID::EParticleType type,
278 AliTPCPIDResponse::ETPCdEdxSource dedxSource) const
280 //get number of sigmas according the selected TPC gain configuration scenario
281 const AliVTrack *track=static_cast<const AliVTrack*>(vtrack);
283 Float_t nSigma=fTPCResponse.GetNumberOfSigmas(track, type, dedxSource, fUseTPCEtaCorrection, fUseTPCMultiplicityCorrection);
288 //______________________________________________________________________________
289 Float_t AliPIDResponse::NumberOfSigmasTOF(const AliVParticle *vtrack, AliPID::EParticleType type) const
292 // Calculate the number of sigmas in the TOF
295 return NumberOfSigmas(kTOF, vtrack, type);
298 //______________________________________________________________________________
299 Float_t AliPIDResponse::NumberOfSigmasHMPID(const AliVParticle *vtrack, AliPID::EParticleType type) const
302 // Calculate the number of sigmas in the EMCAL
305 return NumberOfSigmas(kHMPID, vtrack, type);
308 //______________________________________________________________________________
309 Float_t AliPIDResponse::NumberOfSigmasEMCAL(const AliVParticle *vtrack, AliPID::EParticleType type) const
312 // Calculate the number of sigmas in the EMCAL
315 return NumberOfSigmas(kEMCAL, vtrack, type);
318 //______________________________________________________________________________
319 Float_t AliPIDResponse::NumberOfSigmasEMCAL(const AliVParticle *vtrack, AliPID::EParticleType type, Double_t &eop, Double_t showershape[4]) const
322 // emcal nsigma with eop and showershape
324 AliVTrack *track=(AliVTrack*)vtrack;
326 AliVCluster *matchedClus = NULL;
331 Double_t fClsE = -1.;
333 // initialize eop and shower shape parameters
335 for(Int_t i = 0; i < 4; i++){
336 showershape[i] = -1.;
339 Int_t nMatchClus = -1;
343 nMatchClus = track->GetEMCALcluster();
348 charge = track->Charge();
350 matchedClus = (AliVCluster*)fCurrentEvent->GetCaloCluster(nMatchClus);
354 // matched cluster is EMCAL
355 if(matchedClus->IsEMCAL()){
357 fClsE = matchedClus->E();
360 // fill used EMCAL variables here
362 showershape[0] = matchedClus->GetNCells(); // number of cells in cluster
363 showershape[1] = matchedClus->GetM02(); // long axis
364 showershape[2] = matchedClus->GetM20(); // short axis
365 showershape[3] = matchedClus->GetDispersion(); // dispersion
367 // look for cached value first
368 const AliDetectorPID *detPID=track->GetDetectorPID();
369 const EDetector detector=kEMCAL;
371 if ( detPID && detPID->HasNumberOfSigmas(detector)){
372 return detPID->GetNumberOfSigmas(detector, type);
373 } else if (fCachePID) {
374 FillTrackDetectorPID(track, detector);
375 detPID=track->GetDetectorPID();
376 return detPID->GetNumberOfSigmas(detector, type);
379 // NSigma value really meaningful only for electrons!
380 return fEMCALResponse.GetNumberOfSigmas(pt,EovP,type,charge);
387 //______________________________________________________________________________
388 AliPIDResponse::EDetPidStatus AliPIDResponse::GetSignalDelta(EDetector detector, const AliVParticle *track, AliPID::EParticleType type, Double_t &val, Bool_t ratio/*=kFALSE*/) const
395 case kITS: return GetSignalDeltaITS(track,type,val,ratio); break;
396 case kTPC: return GetSignalDeltaTPC(track,type,val,ratio); break;
397 case kTOF: return GetSignalDeltaTOF(track,type,val,ratio); break;
398 case kHMPID: return GetSignalDeltaHMPID(track,type,val,ratio); break;
399 default: return kDetNoSignal;
404 //______________________________________________________________________________
405 Double_t AliPIDResponse::GetSignalDelta(EDetector detCode, const AliVParticle *track, AliPID::EParticleType type, Bool_t ratio/*=kFALSE*/) const
411 EDetPidStatus stat=GetSignalDelta(detCode, track, type, val, ratio);
412 if ( stat==kDetNoSignal ) val=-9999.;
416 //______________________________________________________________________________
417 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputePIDProbability (EDetCode detCode, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
419 // Compute PID response of 'detCode'
421 // find detector code from detector bit mask
423 for (Int_t idet=0; idet<kNdetectors; ++idet) if ( (detCode&(1<<idet)) ) { detector=idet; break; }
424 if (detector==-1) return kDetNoSignal;
426 return ComputePIDProbability((EDetector)detector, track, nSpecies, p);
429 //______________________________________________________________________________
430 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputePIDProbability (EDetector detector, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
433 // Compute PID response of 'detector'
436 const AliDetectorPID *detPID=track->GetDetectorPID();
438 if ( detPID && detPID->HasRawProbability(detector)){
439 return detPID->GetRawProbability(detector, p, nSpecies);
440 } else if (fCachePID) {
441 FillTrackDetectorPID(track, detector);
442 detPID=track->GetDetectorPID();
443 return detPID->GetRawProbability(detector, p, nSpecies);
446 //if no caching return values calculated from scratch
447 return GetComputePIDProbability(detector, track, nSpecies, p);
450 //______________________________________________________________________________
451 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeITSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
453 // Compute PID response for the ITS
454 return ComputePIDProbability(kITS, track, nSpecies, p);
457 //______________________________________________________________________________
458 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeTPCProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
460 // Compute PID response for the TPC
461 return ComputePIDProbability(kTPC, track, nSpecies, p);
464 //______________________________________________________________________________
465 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeTOFProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
467 // Compute PID response for the
468 return ComputePIDProbability(kTOF, track, nSpecies, p);
471 //______________________________________________________________________________
472 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
474 // Compute PID response for the
475 return ComputePIDProbability(kTRD, track, nSpecies, p);
478 //______________________________________________________________________________
479 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeEMCALProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
481 // Compute PID response for the EMCAL
482 return ComputePIDProbability(kEMCAL, track, nSpecies, p);
484 //______________________________________________________________________________
485 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputePHOSProbability (const AliVTrack */*track*/, Int_t nSpecies, Double_t p[]) const
487 // Compute PID response for the PHOS
489 // set flat distribution (no decision)
490 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
494 //______________________________________________________________________________
495 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeHMPIDProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
497 // Compute PID response for the HMPID
498 return ComputePIDProbability(kHMPID, track, nSpecies, p);
501 //______________________________________________________________________________
502 AliPIDResponse::EDetPidStatus AliPIDResponse::ComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[],AliTRDPIDResponse::ETRDPIDMethod PIDmethod) const
504 // Compute PID response for the
505 return GetComputeTRDProbability(track, nSpecies, p, PIDmethod);
508 //______________________________________________________________________________
509 AliPIDResponse::EDetPidStatus AliPIDResponse::CheckPIDStatus(EDetector detector, const AliVTrack *track) const
511 // calculate detector pid status
513 const Int_t iDetCode=(Int_t)detector;
514 if (iDetCode<0||iDetCode>=kNdetectors) return kDetNoSignal;
515 const AliDetectorPID *detPID=track->GetDetectorPID();
518 return detPID->GetPIDStatus(detector);
519 } else if (fCachePID) {
520 FillTrackDetectorPID(track, detector);
521 detPID=track->GetDetectorPID();
522 return detPID->GetPIDStatus(detector);
525 // if not buffered and no buffering is requested
526 return GetPIDStatus(detector, track);
529 //______________________________________________________________________________
530 void AliPIDResponse::InitialiseEvent(AliVEvent *event, Int_t pass, Int_t run)
533 // Apply settings for the current event
542 else fRun=event->GetRunNumber();
549 //TPC resolution parametrisation PbPb
550 if ( fResolutionCorrection ){
551 Double_t corrSigma=fResolutionCorrection->Eval(GetTPCMultiplicityBin(event));
552 fTPCResponse.SetSigma(3.79301e-03*corrSigma, 2.21280e+04);
555 // Set up TPC multiplicity for PbPb
556 //TODO Will NOT give the desired number for AODs -> Needs new variable/function in future.
557 // Fatal, if AOD event and correction enabled
558 //printf("DETECTED class: %s (%d)\n\n\n\n", event->IsA()->GetName(), fUseTPCMultiplicityCorrection);//TODO
559 if (fUseTPCMultiplicityCorrection && strcmp(event->IsA()->GetName(), "AliESDEvent") != 0) {
560 AliFatal("TPC multiplicity correction is enabled, but will NOT work for AOD events, only for ESD => Disabled multiplicity correction!");
561 fUseTPCMultiplicityCorrection = kFALSE;
564 if (fUseTPCMultiplicityCorrection)
565 fTPCResponse.SetCurrentEventMultiplicity(event->GetNumberOfTracks());
567 fTPCResponse.SetCurrentEventMultiplicity(0);
570 SetTOFResponse(event, (AliPIDResponse::EStartTimeType_t)fTOFPIDParams->GetStartTimeMethod());
573 // Get and set centrality
574 AliCentrality *centrality = event->GetCentrality();
576 fCurrCentrality = centrality->GetCentralityPercentile("V0M");
579 fCurrCentrality = -1;
582 // Set centrality percentile for EMCAL
583 fEMCALResponse.SetCentrality(fCurrCentrality);
587 //______________________________________________________________________________
588 void AliPIDResponse::ExecNewRun()
591 // Things to Execute upon a new run
595 SetITSParametrisation();
597 SetTPCPidResponseMaster();
598 SetTPCParametrisation();
601 SetTRDPidResponseMaster();
602 InitializeTRDResponse();
604 SetEMCALPidResponseMaster();
605 InitializeEMCALResponse();
607 SetTOFPidResponseMaster();
608 InitializeTOFResponse();
610 SetHMPIDPidResponseMaster();
611 InitializeHMPIDResponse();
613 if (fCurrentEvent) fTPCResponse.SetMagField(fCurrentEvent->GetMagneticField());
616 //______________________________________________________________________________
617 Double_t AliPIDResponse::GetTPCMultiplicityBin(const AliVEvent * const event)
620 // Get TPC multiplicity in bins of 150
623 const AliVVertex* vertexTPC = event->GetPrimaryVertex();
624 Double_t tpcMulti=0.;
626 Double_t vertexContribTPC=vertexTPC->GetNContributors();
627 tpcMulti=vertexContribTPC/150.;
628 if (tpcMulti>20.) tpcMulti=20.;
634 //______________________________________________________________________________
635 void AliPIDResponse::SetRecoInfo()
638 // Set reconstruction information
649 Bool_t hasProdInfo=(fCurrentFile.BeginsWith("LHC"));
651 TPRegexp reg(".*(LHC1[1-3][a-z]+[0-9]+[a-z_]*)/.*");
652 if (hasProdInfo) reg=TPRegexp("LHC1[1-2][a-z]+[0-9]+[a-z_]*");
653 TPRegexp reg12a17("LHC1[2-3][a-z]");
655 //find the period by run number (UGLY, but not stored in ESD and AOD... )
656 if (fRun>=114737&&fRun<=117223) { fLHCperiod="LHC10B"; fMCperiodTPC="LHC10D1"; }
657 else if (fRun>=118503&&fRun<=121040) { fLHCperiod="LHC10C"; fMCperiodTPC="LHC10D1"; }
658 else if (fRun>=122195&&fRun<=126437) { fLHCperiod="LHC10D"; fMCperiodTPC="LHC10F6A"; }
659 else if (fRun>=127710&&fRun<=130850) { fLHCperiod="LHC10E"; fMCperiodTPC="LHC10F6A"; }
660 else if (fRun>=133004&&fRun<=135029) { fLHCperiod="LHC10F"; fMCperiodTPC="LHC10F6A"; }
661 else if (fRun>=135654&&fRun<=136377) { fLHCperiod="LHC10G"; fMCperiodTPC="LHC10F6A"; }
662 else if (fRun>=136851&&fRun<=139846) {
664 fMCperiodTPC="LHC10H8";
665 if (reg.MatchB(fCurrentFile)) fMCperiodTPC="LHC11A10";
666 // exception for 13d2 and later
667 if (fCurrentAliRootRev >= 62714) fMCperiodTPC="LHC13D2";
670 else if (fRun>=139847&&fRun<=146974) { fLHCperiod="LHC11A"; fMCperiodTPC="LHC10F6A"; }
671 //TODO: periods 11B (146975-150721), 11C (150722-155837) are not yet treated assume 11d for the moment
672 else if (fRun>=146975&&fRun<=155837) { fLHCperiod="LHC11D"; fMCperiodTPC="LHC10F6A"; }
673 else if (fRun>=155838&&fRun<=159649) { fLHCperiod="LHC11D"; fMCperiodTPC="LHC10F6A"; }
674 // also for 11e (159650-162750),f(162751-165771) use 11d
675 else if (fRun>=159650&&fRun<=162750) { fLHCperiod="LHC11D"; fMCperiodTPC="LHC10F6A"; }
676 else if (fRun>=162751&&fRun<=165771) { fLHCperiod="LHC11D"; fMCperiodTPC="LHC10F6A"; }
678 else if (fRun>=165772 && fRun<=170718) {
680 fMCperiodTPC="LHC11A10";
682 if (reg12a17.MatchB(fCurrentFile)) fMCperiodTPC="LHC12A17";
684 if (fRun>=170719 && fRun<=177311) { fLHCperiod="LHC12A"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
685 // for the moment use LHC12b parameters up to LHC12e
686 if (fRun>=177312 /*&& fRun<=179356*/) { fLHCperiod="LHC12B"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
687 // if (fRun>=179357 && fRun<=183173) { fLHCperiod="LHC12C"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
688 // if (fRun>=183174 && fRun<=186345) { fLHCperiod="LHC12D"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
689 // if (fRun>=186346 && fRun<=186635) { fLHCperiod="LHC12E"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
691 // if (fRun>=186636 && fRun<=188166) { fLHCperiod="LHC12F"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
692 // if (fRun >= 188167 && fRun <= 188355 ) { fLHCperiod="LHC12G"; fBeamType="PP"; /*fMCperiodTPC="";*/ }
693 // if (fRun >= 188356 && fRun <= 188503 ) { fLHCperiod="LHC12G"; fBeamType="PPB"; /*fMCperiodTPC="";*/ }
694 // for the moment use 12g parametrisation for all full gain runs (LHC12f+)
695 if (fRun >= 186636 && fRun < 194480) { fLHCperiod="LHC12G"; fBeamType="PPB"; fMCperiodTPC="LHC12G"; }
697 // New parametrisation for 2013 pPb runs
698 if (fRun >= 194480) {
701 fMCperiodTPC="LHC12G";
703 if (fCurrentAliRootRev >= 61605)
704 fMCperiodTPC="LHC13B2_FIX";
705 if (fCurrentAliRootRev >= 62714)
706 fMCperiodTPC="LHC13B2_FIXn1";
709 //exception new pp MC productions from 2011 (11a periods have 10f6a splines!)
710 if (fBeamType=="PP" && reg.MatchB(fCurrentFile) && !fCurrentFile.Contains("LHC11a")) { fMCperiodTPC="LHC11B2"; fBeamType="PP"; }
711 // exception for 11f1
712 if (fCurrentFile.Contains("LHC11f1")) fMCperiodTPC="LHC11F1";
713 // exception for 12f1a, 12f1b and 12i3
714 if (fCurrentFile.Contains("LHC12f1") || fCurrentFile.Contains("LHC12i3")) fMCperiodTPC="LHC12F1";
715 // exception for 12c4
716 if (fCurrentFile.Contains("LHC12c4")) fMCperiodTPC="LHC12C4";
717 // exception for 12d and 13d pp periods
718 if (fBeamType=="PP" && fCurrentAliRootRev >= 61605) fMCperiodTPC="LHC13D1";
721 //______________________________________________________________________________
722 void AliPIDResponse::SetITSParametrisation()
725 // Set the ITS parametrisation
730 //______________________________________________________________________________
731 void AliPIDResponse::AddPointToHyperplane(TH2D* h, TLinearFitter* linExtrapolation, Int_t binX, Int_t binY)
733 if (h->GetBinContent(binX, binY) <= 1e-4)
734 return; // Reject bins without content (within some numerical precision) or with strange content
736 Double_t coord[2] = {0, 0};
737 coord[0] = h->GetXaxis()->GetBinCenter(binX);
738 coord[1] = h->GetYaxis()->GetBinCenter(binY);
739 Double_t binError = h->GetBinError(binX, binY);
741 binError = 1000; // Should not happen because bins without content are rejected for the map (TH2D* h)
742 printf("ERROR: This should never happen: Trying to add bin in addPointToHyperplane with error not set....\n");
744 linExtrapolation->AddPoint(coord, h->GetBinContent(binX, binY, binError));
748 //______________________________________________________________________________
749 TH2D* AliPIDResponse::RefineHistoViaLinearInterpolation(TH2D* h, Double_t refineFactorX, Double_t refineFactorY)
754 // Interpolate to finer map
755 TLinearFitter* linExtrapolation = new TLinearFitter(2, "hyp2", "");
757 Double_t upperMapBoundY = h->GetYaxis()->GetBinUpEdge(h->GetYaxis()->GetNbins());
758 Double_t lowerMapBoundY = h->GetYaxis()->GetBinLowEdge(1);
760 // Binning was find to yield good results, if 40 bins are chosen for the range 0.0016 to 0.02. For the new variable range,
761 // scale the number of bins correspondingly
762 Int_t nBinsY = TMath::Nint((upperMapBoundY - lowerMapBoundY) / (0.02 - 0.0016) * 40);
763 Int_t nBinsXrefined = nBinsX * refineFactorX;
764 Int_t nBinsYrefined = nBinsY * refineFactorY;
766 TH2D* hRefined = new TH2D(Form("%s_refined", h->GetName()), Form("%s (refined)", h->GetTitle()),
767 nBinsXrefined, h->GetXaxis()->GetBinLowEdge(1), h->GetXaxis()->GetBinUpEdge(h->GetXaxis()->GetNbins()),
768 nBinsYrefined, lowerMapBoundY, upperMapBoundY);
770 for (Int_t binX = 1; binX <= nBinsXrefined; binX++) {
771 for (Int_t binY = 1; binY <= nBinsYrefined; binY++) {
773 hRefined->SetBinContent(binX, binY, 1); // Default value is 1
775 Double_t centerX = hRefined->GetXaxis()->GetBinCenter(binX);
776 Double_t centerY = hRefined->GetYaxis()->GetBinCenter(binY);
779 linExtrapolation->ClearPoints();
781 // For interpolation: Just take the corresponding bin from the old histo.
782 // For extrapolation: take the last available bin from the old histo.
783 // If the boundaries are to be skipped, also skip the corresponding bins
784 Int_t oldBinX = h->GetXaxis()->FindBin(centerX);
787 if (oldBinX > nBinsX)
790 Int_t oldBinY = h->GetYaxis()->FindBin(centerY);
793 if (oldBinY > nBinsY)
796 // Neighbours left column
799 AddPointToHyperplane(h, linExtrapolation, oldBinX - 1, oldBinY - 1);
802 AddPointToHyperplane(h, linExtrapolation, oldBinX - 1, oldBinY);
804 if (oldBinY < nBinsY) {
805 AddPointToHyperplane(h, linExtrapolation, oldBinX - 1, oldBinY + 1);
809 // Neighbours (and point itself) same column
811 AddPointToHyperplane(h, linExtrapolation, oldBinX, oldBinY - 1);
814 AddPointToHyperplane(h, linExtrapolation, oldBinX, oldBinY);
816 if (oldBinY < nBinsY) {
817 AddPointToHyperplane(h, linExtrapolation, oldBinX, oldBinY + 1);
820 // Neighbours right column
821 if (oldBinX < nBinsX) {
823 AddPointToHyperplane(h, linExtrapolation, oldBinX + 1, oldBinY - 1);
826 AddPointToHyperplane(h, linExtrapolation, oldBinX + 1, oldBinY);
828 if (oldBinY < nBinsY) {
829 AddPointToHyperplane(h, linExtrapolation, oldBinX + 1, oldBinY + 1);
835 if (linExtrapolation->GetNpoints() <= 0)
838 if (linExtrapolation->Eval() != 0)// EvalRobust -> Takes much, much, [...], much more time (~hours instead of seconds)
841 // Fill the bin of the refined histogram with the extrapolated value
842 Double_t interpolatedValue = linExtrapolation->GetParameter(0) + linExtrapolation->GetParameter(1) * centerX
843 + linExtrapolation->GetParameter(2) * centerY;
845 Double_t interpolatedValue = h->Interpolate(centerX, centerY) ;
846 hRefined->SetBinContent(binX, binY, interpolatedValue);
851 // Problem: Interpolation does not work before/beyond center of first/last bin (as the name suggests).
852 // Therefore, for each row in dEdx: Take last bin from old map and interpolate values from center and edge.
853 // Assume line through these points and extropolate to last bin of refined map
854 const Double_t firstOldXbinUpEdge = h->GetXaxis()->GetBinUpEdge(1);
855 const Double_t firstOldXbinCenter = h->GetXaxis()->GetBinCenter(1);
857 const Double_t oldXbinHalfWidth = firstOldXbinUpEdge - firstOldXbinCenter;
859 const Double_t lastOldXbinLowEdge = h->GetXaxis()->GetBinLowEdge(h->GetNbinsX());
860 const Double_t lastOldXbinCenter = h->GetXaxis()->GetBinCenter(h->GetNbinsX());
862 for (Int_t binY = 1; binY <= nBinsYrefined; binY++) {
863 Double_t centerY = hRefined->GetYaxis()->GetBinCenter(binY);
865 const Double_t interpolatedCenterFirstXbin = h->Interpolate(firstOldXbinCenter, centerY);
866 const Double_t interpolatedUpEdgeFirstXbin = h->Interpolate(firstOldXbinUpEdge, centerY);
868 const Double_t extrapolationSlopeFirstXbin = (interpolatedUpEdgeFirstXbin - interpolatedCenterFirstXbin) / oldXbinHalfWidth;
869 const Double_t extrapolationOffsetFirstXbin = interpolatedCenterFirstXbin;
872 const Double_t interpolatedCenterLastXbin = h->Interpolate(lastOldXbinCenter, centerY);
873 const Double_t interpolatedLowEdgeLastXbin = h->Interpolate(lastOldXbinLowEdge, centerY);
875 const Double_t extrapolationSlopeLastXbin = (interpolatedCenterLastXbin - interpolatedLowEdgeLastXbin) / oldXbinHalfWidth;
876 const Double_t extrapolationOffsetLastXbin = interpolatedCenterLastXbin;
878 for (Int_t binX = 1; binX <= nBinsXrefined; binX++) {
879 Double_t centerX = hRefined->GetXaxis()->GetBinCenter(binX);
881 if (centerX < firstOldXbinCenter) {
882 Double_t extrapolatedValue = extrapolationOffsetFirstXbin + (centerX - firstOldXbinCenter) * extrapolationSlopeFirstXbin;
883 hRefined->SetBinContent(binX, binY, extrapolatedValue);
885 else if (centerX <= lastOldXbinCenter) {
889 Double_t extrapolatedValue = extrapolationOffsetLastXbin + (centerX - lastOldXbinCenter) * extrapolationSlopeLastXbin;
890 hRefined->SetBinContent(binX, binY, extrapolatedValue);
895 delete linExtrapolation;
900 //______________________________________________________________________________
901 void AliPIDResponse::SetTPCEtaMaps(Double_t refineFactorMapX, Double_t refineFactorMapY,
902 Double_t refineFactorSigmaMapX, Double_t refineFactorSigmaMapY)
905 // Load the TPC eta correction maps from the OADB
908 if (fUseTPCEtaCorrection == kFALSE) {
909 // Disable eta correction via setting no maps
910 if (!fTPCResponse.SetEtaCorrMap(0x0))
911 AliInfo("Request to disable TPC eta correction -> Eta correction has been disabled");
913 AliError("Request to disable TPC eta correction -> Some error occured when unloading the correction maps");
915 if (!fTPCResponse.SetSigmaParams(0x0, 0))
916 AliInfo("Request to disable TPC eta correction -> Using old parametrisation for sigma");
918 AliError("Request to disable TPC eta correction -> Some error occured when unloading the sigma maps");
923 TString dataType = "DATA";
924 TString period = fLHCperiod.IsNull() ? "No period information" : fLHCperiod;
927 if (!(fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC))) {
933 if (!(fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC)) && fMCperiodTPC.IsNull()) {
934 AliFatal("MC detected, but no MC period set -> Not changing eta maps!");
939 Int_t recopass = fRecoPass;
940 if (fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC) )
941 recopass = fRecoPassUser;
943 TString defaultObj = Form("Default_%s_pass%d", dataType.Data(), recopass);
945 AliInfo(Form("Current period and reco pass: %s.pass%d", period.Data(), recopass));
947 // Invalidate old maps
948 fTPCResponse.SetEtaCorrMap(0x0);
949 fTPCResponse.SetSigmaParams(0x0, 0);
951 // Load the eta correction maps
952 AliOADBContainer etaMapsCont(Form("TPCetaMaps_%s_pass%d", dataType.Data(), recopass));
954 Int_t statusCont = etaMapsCont.InitFromFile(Form("%s/COMMON/PID/data/TPCetaMaps.root", fOADBPath.Data()),
955 Form("TPCetaMaps_%s_pass%d", dataType.Data(), recopass));
957 AliError("Failed initializing TPC eta correction maps from OADB -> Disabled eta correction");
958 fUseTPCEtaCorrection = kFALSE;
961 AliInfo(Form("Loading TPC eta correction map from %s/COMMON/PID/data/TPCetaMaps.root", fOADBPath.Data()));
965 if (fIsMC && !(fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC))) {
966 TString searchMap = Form("TPCetaMaps_%s_%s_pass%d", dataType.Data(), period.Data(), recopass);
967 etaMap = dynamic_cast<TH2D *>(etaMapsCont.GetDefaultObject(searchMap.Data()));
969 // Try default object
970 etaMap = dynamic_cast<TH2D *>(etaMapsCont.GetDefaultObject(defaultObj.Data()));
974 etaMap = dynamic_cast<TH2D *>(etaMapsCont.GetObject(fRun, defaultObj.Data()));
979 AliError(Form("TPC eta correction map not found for run %d and also no default map found -> Disabled eta correction!!!", fRun));
980 fUseTPCEtaCorrection = kFALSE;
983 TH2D* etaMapRefined = RefineHistoViaLinearInterpolation(etaMap, refineFactorMapX, refineFactorMapY);
986 if (!fTPCResponse.SetEtaCorrMap(etaMapRefined)) {
987 AliError(Form("Failed to set TPC eta correction map for run %d -> Disabled eta correction!!!", fRun));
988 fTPCResponse.SetEtaCorrMap(0x0);
989 fUseTPCEtaCorrection = kFALSE;
992 AliInfo(Form("Loaded TPC eta correction map (refine factors %.2f/%.2f) from %s/COMMON/PID/data/TPCetaMaps.root: %s (MD5(map) = %s)",
993 refineFactorMapX, refineFactorMapY, fOADBPath.Data(), fTPCResponse.GetEtaCorrMap()->GetTitle(),
994 GetChecksum(fTPCResponse.GetEtaCorrMap()).Data()));
997 delete etaMapRefined;
1000 AliError(Form("Failed to set TPC eta correction map for run %d (map was loaded, but couldn't be refined) -> Disabled eta correction!!!", fRun));
1001 fUseTPCEtaCorrection = kFALSE;
1006 // If there was some problem loading the eta maps, it makes no sense to load the sigma maps (that require eta corrected data)
1007 if (fUseTPCEtaCorrection == kFALSE) {
1008 AliError("Failed to load TPC eta correction map required by sigma maps -> Using old parametrisation for sigma");
1012 // Load the sigma parametrisation (1/dEdx vs tanTheta_local (~eta))
1013 AliOADBContainer etaSigmaMapsCont(Form("TPCetaSigmaMaps_%s_pass%d", dataType.Data(), recopass));
1015 statusCont = etaSigmaMapsCont.InitFromFile(Form("%s/COMMON/PID/data/TPCetaMaps.root", fOADBPath.Data()),
1016 Form("TPCetaSigmaMaps_%s_pass%d", dataType.Data(), recopass));
1018 AliError("Failed initializing TPC eta sigma maps from OADB -> Using old sigma parametrisation");
1021 AliInfo(Form("Loading TPC eta sigma map from %s/COMMON/PID/data/TPCetaMaps.root", fOADBPath.Data()));
1023 TObjArray* etaSigmaPars = 0x0;
1025 if (fIsMC && !(fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC))) {
1026 TString searchMap = Form("TPCetaSigmaMaps_%s_%s_pass%d", dataType.Data(), period.Data(), recopass);
1027 etaSigmaPars = dynamic_cast<TObjArray *>(etaSigmaMapsCont.GetDefaultObject(searchMap.Data()));
1028 if (!etaSigmaPars) {
1029 // Try default object
1030 etaSigmaPars = dynamic_cast<TObjArray *>(etaSigmaMapsCont.GetDefaultObject(defaultObj.Data()));
1034 etaSigmaPars = dynamic_cast<TObjArray *>(etaSigmaMapsCont.GetObject(fRun, defaultObj.Data()));
1037 if (!etaSigmaPars) {
1038 AliError(Form("TPC eta sigma parametrisation not found for run %d -> Using old sigma parametrisation!!!", fRun));
1041 TH2D* etaSigmaPar1Map = dynamic_cast<TH2D *>(etaSigmaPars->FindObject("sigmaPar1Map"));
1042 TNamed* sigmaPar0Info = dynamic_cast<TNamed *>(etaSigmaPars->FindObject("sigmaPar0"));
1043 Double_t sigmaPar0 = 0.0;
1045 if (sigmaPar0Info) {
1046 TString sigmaPar0String = sigmaPar0Info->GetTitle();
1047 sigmaPar0 = sigmaPar0String.Atof();
1050 // Something is weired because the object for parameter 0 could not be loaded -> New sigma parametrisation can not be used!
1051 etaSigmaPar1Map = 0x0;
1054 TH2D* etaSigmaPar1MapRefined = RefineHistoViaLinearInterpolation(etaSigmaPar1Map, refineFactorSigmaMapX, refineFactorSigmaMapY);
1057 if (etaSigmaPar1MapRefined) {
1058 if (!fTPCResponse.SetSigmaParams(etaSigmaPar1MapRefined, sigmaPar0)) {
1059 AliError(Form("Failed to set TPC eta sigma map for run %d -> Using old sigma parametrisation!!!", fRun));
1060 fTPCResponse.SetSigmaParams(0x0, 0);
1063 AliInfo(Form("Loaded TPC sigma correction map (refine factors %.2f/%.2f) from %s/COMMON/PID/data/TPCetaMaps.root: %s (MD5(map) = %s, sigmaPar0 = %f)",
1064 refineFactorSigmaMapX, refineFactorSigmaMapY, fOADBPath.Data(), fTPCResponse.GetSigmaPar1Map()->GetTitle(),
1065 GetChecksum(fTPCResponse.GetSigmaPar1Map()).Data(), sigmaPar0));
1068 delete etaSigmaPar1MapRefined;
1071 AliError(Form("Failed to set TPC eta sigma map for run %d (map was loaded, but couldn't be refined) -> Using old sigma parametrisation!!!",
1078 //______________________________________________________________________________
1079 void AliPIDResponse::SetTPCPidResponseMaster()
1082 // Load the TPC pid response functions from the OADB
1083 // Load the TPC voltage maps from OADB
1085 //don't load twice for the moment
1086 if (fArrPidResponseMaster) return;
1089 //reset the PID response functions
1090 delete fArrPidResponseMaster;
1091 fArrPidResponseMaster=NULL;
1093 TString fileName(Form("%s/COMMON/PID/data/TPCPIDResponse.root", fOADBPath.Data()));
1095 if (!fCustomTPCpidResponse.IsNull()) fileName=fCustomTPCpidResponse;
1097 TString fileNamePIDresponse(Form("%s/COMMON/PID/data/TPCPIDResponse.root", fOADBPath.Data()));
1098 f=TFile::Open(fileNamePIDresponse.Data());
1099 if (f && f->IsOpen() && !f->IsZombie()){
1100 fArrPidResponseMaster=dynamic_cast<TObjArray*>(f->Get("TPCPIDResponse"));
1104 TString fileNameVoltageMaps(Form("%s/COMMON/PID/data/TPCvoltageSettings.root", fOADBPath.Data()));
1105 f=TFile::Open(fileNameVoltageMaps.Data());
1106 if (f && f->IsOpen() && !f->IsZombie()){
1107 fOADBvoltageMaps=dynamic_cast<AliOADBContainer*>(f->Get("TPCvoltageSettings"));
1111 if (!fArrPidResponseMaster){
1112 AliFatal(Form("Could not retrieve the TPC pid response from: %s",fileNamePIDresponse.Data()));
1115 fArrPidResponseMaster->SetOwner();
1117 if (!fOADBvoltageMaps)
1119 AliFatal(Form("Could not retrieve the TPC voltage maps from: %s",fileNameVoltageMaps.Data()));
1121 fArrPidResponseMaster->SetOwner();
1124 //______________________________________________________________________________
1125 void AliPIDResponse::SetTPCParametrisation()
1128 // Change BB parametrisation for current run
1134 fTPCResponse.ResetSplines();
1136 if (fLHCperiod.IsNull()) {
1137 AliError("No period set, not changing parametrisation");
1142 // Set default parametrisations for data and MC
1146 TString datatype="DATA";
1147 //in case of mc fRecoPass is per default 1
1149 if(!(fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC))) datatype="MC";
1154 TString period=fLHCperiod;
1155 if (fIsMC && !(fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC))) period=fMCperiodTPC;
1157 Int_t recopass = fRecoPass;
1158 if(fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC)) recopass = fRecoPassUser;
1160 AliInfo(Form("Searching splines for: %s %s PASS%d %s",datatype.Data(),period.Data(),recopass,fBeamType.Data()));
1161 Bool_t found=kFALSE;
1163 //set the new PID splines
1165 if (fArrPidResponseMaster){
1166 //for MC don't use period information
1167 //if (fIsMC) period="[A-Z0-9]*";
1168 //for MC use MC period information
1169 //pattern for the default entry (valid for all particles)
1170 TPRegexp reg(Form("TSPLINE3_%s_([A-Z]*)_%s_PASS%d_%s_MEAN(_*)([A-Z1-9]*)",datatype.Data(),period.Data(),recopass,fBeamType.Data()));
1172 //find particle id and gain scenario
1173 for (Int_t igainScenario=0; igainScenario<AliTPCPIDResponse::fgkNumberOfGainScenarios; igainScenario++)
1175 TObject *grAll=NULL;
1176 TString gainScenario = AliTPCPIDResponse::GainScenarioName(igainScenario);
1177 gainScenario.ToUpper();
1178 //loop over entries and filter them
1179 for (Int_t iresp=0; iresp<fArrPidResponseMaster->GetEntriesFast();++iresp)
1181 TObject *responseFunction=fArrPidResponseMaster->At(iresp);
1182 if (responseFunction==NULL) continue;
1183 TString responseName=responseFunction->GetName();
1185 if (!reg.MatchB(responseName)) continue;
1187 TObjArray *arr=reg.MatchS(responseName); if (!arr) continue;
1189 tmp=arr->At(1); if (!tmp) continue;
1190 TString particleName=tmp->GetName();
1191 tmp=arr->At(3); if (!tmp) continue;
1192 TString gainScenarioName=tmp->GetName();
1194 if (particleName.IsNull()) continue;
1195 if (!grAll && particleName=="ALL" && gainScenarioName==gainScenario) grAll=responseFunction;
1198 for (Int_t ispec=0; ispec<(AliTPCPIDResponse::fgkNumberOfParticleSpecies); ++ispec)
1200 TString particle=AliPID::ParticleName(ispec);
1202 //std::cout<<responseName<<" "<<particle<<" "<<particleName<<" "<<gainScenario<<" "<<gainScenarioName<<std::endl;
1203 if ( particle == particleName && gainScenario == gainScenarioName )
1205 fTPCResponse.SetResponseFunction( responseFunction,
1206 (AliPID::EParticleType)ispec,
1207 (AliTPCPIDResponse::ETPCgainScenario)igainScenario );
1208 fTPCResponse.SetUseDatabase(kTRUE);
1209 AliInfo(Form("Adding graph: %d %d - %s (MD5(spline) = %s)",ispec,igainScenario,responseFunction->GetName(),
1210 GetChecksum((TSpline3*)responseFunction).Data()));
1218 // Retrieve responsefunction for pions - will (if available) be used for muons if there are no dedicated muon splines.
1219 // For light nuclei, try to set the proton spline, if no dedicated splines are available.
1220 // In both cases: Use default splines, if no dedicated splines and no pion/proton splines are available.
1221 TObject* responseFunctionPion = fTPCResponse.GetResponseFunction( (AliPID::EParticleType)AliPID::kPion,
1222 (AliTPCPIDResponse::ETPCgainScenario)igainScenario);
1223 TObject* responseFunctionProton = fTPCResponse.GetResponseFunction( (AliPID::EParticleType)AliPID::kProton,
1224 (AliTPCPIDResponse::ETPCgainScenario)igainScenario);
1226 for (Int_t ispec=0; ispec<(AliTPCPIDResponse::fgkNumberOfParticleSpecies); ++ispec)
1228 if (!fTPCResponse.GetResponseFunction( (AliPID::EParticleType)ispec,
1229 (AliTPCPIDResponse::ETPCgainScenario)igainScenario))
1231 if (ispec == AliPID::kMuon) { // Muons
1232 if (responseFunctionPion) {
1233 fTPCResponse.SetResponseFunction( responseFunctionPion,
1234 (AliPID::EParticleType)ispec,
1235 (AliTPCPIDResponse::ETPCgainScenario)igainScenario );
1236 fTPCResponse.SetUseDatabase(kTRUE);
1237 AliInfo(Form("Adding graph: %d %d - %s (MD5(spline) = %s)",ispec,igainScenario,responseFunctionPion->GetName(),
1238 GetChecksum((TSpline3*)responseFunctionPion).Data()));
1242 fTPCResponse.SetResponseFunction( grAll,
1243 (AliPID::EParticleType)ispec,
1244 (AliTPCPIDResponse::ETPCgainScenario)igainScenario );
1245 fTPCResponse.SetUseDatabase(kTRUE);
1246 AliInfo(Form("Adding graph: %d %d - %s (MD5(spline) = %s)",ispec,igainScenario,grAll->GetName(),
1247 GetChecksum((TSpline3*)grAll).Data()));
1251 // AliError(Form("No splines found for muons (also no pion splines and no default splines) for gain scenario %d!", igainScenario));
1253 else if (ispec >= AliPID::kSPECIES) { // Light nuclei
1254 if (responseFunctionProton) {
1255 fTPCResponse.SetResponseFunction( responseFunctionProton,
1256 (AliPID::EParticleType)ispec,
1257 (AliTPCPIDResponse::ETPCgainScenario)igainScenario );
1258 fTPCResponse.SetUseDatabase(kTRUE);
1259 AliInfo(Form("Adding graph: %d %d - %s (MD5(spline) = %s)",ispec,igainScenario,responseFunctionProton->GetName(),
1260 GetChecksum((TSpline3*)responseFunctionProton).Data()));
1264 fTPCResponse.SetResponseFunction( grAll,
1265 (AliPID::EParticleType)ispec,
1266 (AliTPCPIDResponse::ETPCgainScenario)igainScenario );
1267 fTPCResponse.SetUseDatabase(kTRUE);
1268 AliInfo(Form("Adding graph: %d %d - %s (MD5(spline) = %s)",ispec,igainScenario,grAll->GetName(),
1269 GetChecksum((TSpline3*)grAll).Data()));
1273 // AliError(Form("No splines found for species %d (also no proton splines and no default splines) for gain scenario %d!",
1274 // ispec, igainScenario));
1280 else AliInfo("no fArrPidResponseMaster");
1283 AliError(Form("No splines found for: %s %s PASS%d %s",datatype.Data(),period.Data(),recopass,fBeamType.Data()));
1288 // Setup multiplicity correction
1290 if (fUseTPCMultiplicityCorrection && !(fBeamType.CompareTo("PP") == 0)) {
1291 AliInfo("Multiplicity correction enabled!");
1293 //TODO After testing, load parameters from outside
1294 /*TODO now correction for MC
1295 if (period.Contains("LHC11A10")) {//LHC11A10A
1296 AliInfo("Using multiplicity correction parameters for 11a10!");
1297 fTPCResponse.SetParameterMultiplicityCorrection(0, 6.90133e-06);
1298 fTPCResponse.SetParameterMultiplicityCorrection(1, -1.22123e-03);
1299 fTPCResponse.SetParameterMultiplicityCorrection(2, 1.80220e-02);
1300 fTPCResponse.SetParameterMultiplicityCorrection(3, 0.1);
1301 fTPCResponse.SetParameterMultiplicityCorrection(4, 6.45306e-03);
1303 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(0, -2.85505e-07);
1304 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(1, -1.31911e-06);
1305 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(2, -0.5);
1307 fTPCResponse.SetParameterMultiplicitySigmaCorrection(0, -4.29665e-05);
1308 fTPCResponse.SetParameterMultiplicitySigmaCorrection(1, 1.37023e-02);
1309 fTPCResponse.SetParameterMultiplicitySigmaCorrection(2, -6.36337e-01);
1310 fTPCResponse.SetParameterMultiplicitySigmaCorrection(3, 1.13479e-02);
1312 else*/ if (period.Contains("LHC13B") || period.Contains("LHC13C") || period.Contains("LHC13D") || period.Contains("LHC13E") ||
1313 period.Contains("LHC13F")) {// 2013 pPb data taking
1314 AliInfo("Using multiplicity correction parameters for 13b.pass2!");
1316 fTPCResponse.SetParameterMultiplicityCorrection(0, -5.906e-06);
1317 fTPCResponse.SetParameterMultiplicityCorrection(1, -5.064e-04);
1318 fTPCResponse.SetParameterMultiplicityCorrection(2, -3.521e-02);
1319 fTPCResponse.SetParameterMultiplicityCorrection(3, 2.469e-02);
1320 fTPCResponse.SetParameterMultiplicityCorrection(4, 0);
1322 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(0, -5.32e-06);
1323 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(1, 1.177e-05);
1324 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(2, -0.5);
1326 fTPCResponse.SetParameterMultiplicitySigmaCorrection(0, 0.);
1327 fTPCResponse.SetParameterMultiplicitySigmaCorrection(1, 0.);
1328 fTPCResponse.SetParameterMultiplicitySigmaCorrection(2, 0.);
1329 fTPCResponse.SetParameterMultiplicitySigmaCorrection(3, 0.);
1331 /* Not too bad, but far from perfect in the details
1332 fTPCResponse.SetParameterMultiplicityCorrection(0, -6.27187e-06);
1333 fTPCResponse.SetParameterMultiplicityCorrection(1, -4.60649e-04);
1334 fTPCResponse.SetParameterMultiplicityCorrection(2, -4.26450e-02);
1335 fTPCResponse.SetParameterMultiplicityCorrection(3, 2.40590e-02);
1336 fTPCResponse.SetParameterMultiplicityCorrection(4, 0);
1338 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(0, -5.338e-06);
1339 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(1, 1.220e-05);
1340 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(2, -0.5);
1342 fTPCResponse.SetParameterMultiplicitySigmaCorrection(0, 7.89237e-05);
1343 fTPCResponse.SetParameterMultiplicitySigmaCorrection(1, -1.30662e-02);
1344 fTPCResponse.SetParameterMultiplicitySigmaCorrection(2, 8.91548e-01);
1345 fTPCResponse.SetParameterMultiplicitySigmaCorrection(3, 1.47931e-02);
1348 else if (period.Contains("LHC10H") && recopass == 2) {
1349 AliInfo("Using multiplicity correction parameters for 10h.pass2!");
1350 fTPCResponse.SetParameterMultiplicityCorrection(0, 3.21636e-07);
1351 fTPCResponse.SetParameterMultiplicityCorrection(1, -6.65876e-04);
1352 fTPCResponse.SetParameterMultiplicityCorrection(2, 1.28786e-03);
1353 fTPCResponse.SetParameterMultiplicityCorrection(3, 1.47677e-02);
1354 fTPCResponse.SetParameterMultiplicityCorrection(4, 0);
1356 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(0, 7.23591e-08);
1357 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(1, 2.7469e-06);
1358 fTPCResponse.SetParameterMultiplicityCorrectionTanTheta(2, -0.5);
1360 fTPCResponse.SetParameterMultiplicitySigmaCorrection(0, -1.22590e-05);
1361 fTPCResponse.SetParameterMultiplicitySigmaCorrection(1, 6.88888e-03);
1362 fTPCResponse.SetParameterMultiplicitySigmaCorrection(2, -3.20788e-01);
1363 fTPCResponse.SetParameterMultiplicitySigmaCorrection(3, 1.07345e-02);
1366 AliError(Form("Multiplicity correction is enabled, but no multiplicity correction parameters have been found for period %s.pass%d -> Mulitplicity correction DISABLED!", period.Data(), recopass));
1367 fUseTPCMultiplicityCorrection = kFALSE;
1368 fTPCResponse.ResetMultiplicityCorrectionFunctions();
1372 // Just set parameters such that overall correction factor is 1, i.e. no correction.
1373 // This is just a reasonable choice for the parameters for safety reasons. Disabling
1374 // the multiplicity correction will anyhow skip the calculation of the corresponding
1375 // correction factor inside THIS class. Nevertheless, experts can access the TPCPIDResponse
1376 // directly and use it for calculations - which should still give valid results, even if
1377 // the multiplicity correction is explicitely enabled in such expert calls.
1379 AliInfo(Form("Multiplicity correction %sdisabled (%s)!", fUseTPCMultiplicityCorrection ? "automatically " : "",
1380 fUseTPCMultiplicityCorrection ? "pp collisions" : "requested by user"));
1382 fUseTPCMultiplicityCorrection = kFALSE;
1383 fTPCResponse.ResetMultiplicityCorrectionFunctions();
1388 for (Int_t i = 0; i <= 4 + 1; i++) {
1389 printf("parMultCorr: %d, %e\n", i, fTPCResponse.GetMultiplicityCorrectionFunction()->GetParameter(i));
1391 for (Int_t j = 0; j <= 2 + 1; j++) {
1392 printf("parMultCorrTanTheta: %d, %e\n", j, fTPCResponse.GetMultiplicityCorrectionFunctionTanTheta()->GetParameter(j));
1394 for (Int_t j = 0; j <= 3 + 1; j++) {
1395 printf("parMultSigmaCorr: %d, %e\n", j, fTPCResponse.GetMultiplicitySigmaCorrectionFunction()->GetParameter(j));
1402 // Setup old resolution parametrisation
1406 fTPCResponse.SetSigma(3.79301e-03, 2.21280e+04);
1409 fTPCResponse.SetSigma(2.30176e-02, 5.60422e+02);
1413 // if (fRun>=188356){
1414 fTPCResponse.SetSigma(8.62022e-04, 9.08156e+05);
1417 if (fArrPidResponseMaster)
1418 fResolutionCorrection=(TF1*)fArrPidResponseMaster->FindObject(Form("TF1_%s_ALL_%s_PASS%d_%s_SIGMA",datatype.Data(),period.Data(),recopass,fBeamType.Data()));
1420 if (fResolutionCorrection) AliInfo(Form("Setting multiplicity correction function: %s (MD5(corr function) = %s)",
1421 fResolutionCorrection->GetName(), GetChecksum(fResolutionCorrection).Data()));
1423 //read in the voltage map
1424 TVectorF* gsm = 0x0;
1425 if (fOADBvoltageMaps) gsm=dynamic_cast<TVectorF*>(fOADBvoltageMaps->GetObject(fRun));
1428 fTPCResponse.SetVoltageMap(*gsm);
1430 AliInfo(Form("Reading the voltage map for run %d\n",fRun));
1431 vals="IROC A: "; for (Int_t i=0; i<18; i++){vals+=Form("%.2f ",(*gsm)[i]);}
1432 AliInfo(vals.Data());
1433 vals="IROC C: "; for (Int_t i=18; i<36; i++){vals+=Form("%.2f ",(*gsm)[i]);}
1434 AliInfo(vals.Data());
1435 vals="OROC A: "; for (Int_t i=36; i<54; i++){vals+=Form("%.2f ",(*gsm)[i]);}
1436 AliInfo(vals.Data());
1437 vals="OROC C: "; for (Int_t i=54; i<72; i++){vals+=Form("%.2f ",(*gsm)[i]);}
1438 AliInfo(vals.Data());
1440 else AliInfo("no voltage map, ideal default assumed");
1443 //______________________________________________________________________________
1444 void AliPIDResponse::SetTRDPidResponseMaster()
1447 // Load the TRD pid params and references from the OADB
1449 if(fTRDPIDResponseObject) return;
1450 AliOADBContainer contParams("contParams");
1452 Int_t statusResponse = contParams.InitFromFile(Form("%s/COMMON/PID/data/TRDPIDResponse.root", fOADBPath.Data()), "AliTRDPIDResponseObject");
1454 AliError("Failed initializing PID Response Object from OADB");
1456 AliInfo(Form("Loading TRD Response from %s/COMMON/PID/data/TRDPIDResponse.root", fOADBPath.Data()));
1457 fTRDPIDResponseObject = dynamic_cast<AliTRDPIDResponseObject *>(contParams.GetObject(fRun));
1458 if(!fTRDPIDResponseObject){
1459 AliError(Form("TRD Response not found in run %d", fRun));
1464 //______________________________________________________________________________
1465 void AliPIDResponse::InitializeTRDResponse(){
1467 // Set PID Params and references to the TRD PID response
1469 fTRDResponse.SetPIDResponseObject(fTRDPIDResponseObject);
1472 //______________________________________________________________________________
1473 void AliPIDResponse::SetTRDSlices(UInt_t TRDslicesForPID[2],AliTRDPIDResponse::ETRDPIDMethod method) const{
1475 if(fLHCperiod.Contains("LHC10D") || fLHCperiod.Contains("LHC10E")){
1476 // backward compatibility for setting with 8 slices
1477 TRDslicesForPID[0] = 0;
1478 TRDslicesForPID[1] = 7;
1481 if(method==AliTRDPIDResponse::kLQ1D){
1482 TRDslicesForPID[0] = 0; // first Slice contains normalized dEdx
1483 TRDslicesForPID[1] = 0;
1485 if(method==AliTRDPIDResponse::kLQ2D){
1486 TRDslicesForPID[0] = 1;
1487 TRDslicesForPID[1] = 7;
1490 AliDebug(1,Form("Slice Range set to %d - %d",TRDslicesForPID[0],TRDslicesForPID[1]));
1493 //______________________________________________________________________________
1494 void AliPIDResponse::SetTOFPidResponseMaster()
1497 // Load the TOF pid params from the OADB
1500 if (fTOFPIDParams) delete fTOFPIDParams;
1503 TFile *oadbf = new TFile(Form("%s/COMMON/PID/data/TOFPIDParams.root",fOADBPath.Data()));
1504 if (oadbf && oadbf->IsOpen()) {
1505 AliInfo(Form("Loading TOF Params from %s/COMMON/PID/data/TOFPIDParams.root", fOADBPath.Data()));
1506 AliOADBContainer *oadbc = (AliOADBContainer *)oadbf->Get("TOFoadb");
1507 if (oadbc) fTOFPIDParams = dynamic_cast<AliTOFPIDParams *>(oadbc->GetObject(fRun,"TOFparams"));
1513 if (!fTOFPIDParams) AliFatal("TOFPIDParams could not be retrieved");
1516 //______________________________________________________________________________
1517 void AliPIDResponse::InitializeTOFResponse(){
1519 // Set PID Params to the TOF PID response
1522 AliInfo("TOF PID Params loaded from OADB");
1523 AliInfo(Form(" TOF resolution %5.2f [ps]",fTOFPIDParams->GetTOFresolution()));
1524 AliInfo(Form(" StartTime method %d",fTOFPIDParams->GetStartTimeMethod()));
1525 AliInfo(Form(" TOF res. mom. params: %5.2f %5.2f %5.2f %5.2f",
1526 fTOFPIDParams->GetSigParams(0),fTOFPIDParams->GetSigParams(1),fTOFPIDParams->GetSigParams(2),fTOFPIDParams->GetSigParams(3)));
1528 for (Int_t i=0;i<4;i++) {
1529 fTOFResponse.SetTrackParameter(i,fTOFPIDParams->GetSigParams(i));
1531 fTOFResponse.SetTimeResolution(fTOFPIDParams->GetTOFresolution());
1533 AliInfo("TZERO resolution loaded from ESDrun/AODheader");
1534 Float_t t0Spread[4];
1535 for (Int_t i=0;i<4;i++) t0Spread[i]=fCurrentEvent->GetT0spread(i);
1536 AliInfo(Form(" TZERO spreads from data: (A+C)/2 %f A %f C %f (A'-C')/2: %f",t0Spread[0],t0Spread[1],t0Spread[2],t0Spread[3]));
1537 Float_t a = t0Spread[1]*t0Spread[1]-t0Spread[0]*t0Spread[0]+t0Spread[3]*t0Spread[3];
1538 Float_t c = t0Spread[2]*t0Spread[2]-t0Spread[0]*t0Spread[0]+t0Spread[3]*t0Spread[3];
1539 if ( (t0Spread[0] > 50. && t0Spread[0] < 400.) && (a > 0.) && (c>0.)) {
1540 fResT0AC=t0Spread[3];
1541 fResT0A=TMath::Sqrt(a);
1542 fResT0C=TMath::Sqrt(c);
1544 AliInfo(" TZERO spreads not present or inconsistent, loading default");
1549 AliInfo(Form(" TZERO resolution set to: T0A: %f [ps] T0C: %f [ps] T0AC %f [ps]",fResT0A,fResT0C,fResT0AC));
1553 //______________________________________________________________________________
1554 void AliPIDResponse::SetHMPIDPidResponseMaster()
1557 // Load the HMPID pid params from the OADB
1560 if (fHMPIDPIDParams) delete fHMPIDPIDParams;
1561 fHMPIDPIDParams=NULL;
1563 TFile *oadbf = new TFile(Form("%s/COMMON/PID/data/HMPIDPIDParams.root",fOADBPath.Data()));
1564 if (oadbf && oadbf->IsOpen()) {
1565 AliInfo(Form("Loading HMPID Params from %s/COMMON/PID/data/HMPIDPIDParams.root", fOADBPath.Data()));
1566 AliOADBContainer *oadbc = (AliOADBContainer *)oadbf->Get("HMPoadb");
1567 if (oadbc) fHMPIDPIDParams = dynamic_cast<AliHMPIDPIDParams *>(oadbc->GetObject(fRun,"HMPparams"));
1573 if (!fHMPIDPIDParams) AliFatal("HMPIDPIDParams could not be retrieved");
1576 //______________________________________________________________________________
1577 void AliPIDResponse::InitializeHMPIDResponse(){
1579 // Set PID Params to the HMPID PID response
1582 fHMPIDResponse.SetRefIndexArray(fHMPIDPIDParams->GetHMPIDrefIndex());
1585 //______________________________________________________________________________
1586 Bool_t AliPIDResponse::IdentifiedAsElectronTRD(const AliVTrack *vtrack, Double_t efficiencyLevel,Double_t centrality,AliTRDPIDResponse::ETRDPIDMethod PIDmethod) const {
1588 // Check whether track is identified as electron under a given electron efficiency hypothesis
1591 Double_t probs[AliPID::kSPECIES];
1592 ComputeTRDProbability(vtrack, AliPID::kSPECIES, probs,PIDmethod);
1594 Int_t ntracklets = vtrack->GetTRDntrackletsPID();
1595 // Take mean of the TRD momenta in the given tracklets
1596 Float_t p = 0, trdmomenta[AliVTrack::kTRDnPlanes];
1598 for(Int_t iPl=0;iPl<AliVTrack::kTRDnPlanes;iPl++){
1599 if(vtrack->GetTRDmomentum(iPl) > 0.){
1600 trdmomenta[nmomenta++] = vtrack->GetTRDmomentum(iPl);
1603 p = TMath::Mean(nmomenta, trdmomenta);
1605 return fTRDResponse.IdentifiedAsElectron(ntracklets, probs, p, efficiencyLevel,centrality,PIDmethod);
1608 //______________________________________________________________________________
1609 void AliPIDResponse::SetEMCALPidResponseMaster()
1612 // Load the EMCAL pid response functions from the OADB
1614 TObjArray* fEMCALPIDParamsRun = NULL;
1615 TObjArray* fEMCALPIDParamsPass = NULL;
1617 if(fEMCALPIDParams) return;
1618 AliOADBContainer contParams("contParams");
1620 Int_t statusPars = contParams.InitFromFile(Form("%s/COMMON/PID/data/EMCALPIDParams.root", fOADBPath.Data()), "AliEMCALPIDParams");
1622 AliError("Failed initializing PID Params from OADB");
1625 AliInfo(Form("Loading EMCAL Params from %s/COMMON/PID/data/EMCALPIDParams.root", fOADBPath.Data()));
1627 fEMCALPIDParamsRun = dynamic_cast<TObjArray *>(contParams.GetObject(fRun));
1628 if(fEMCALPIDParamsRun) fEMCALPIDParamsPass = dynamic_cast<TObjArray *>(fEMCALPIDParamsRun->FindObject(Form("pass%d",fRecoPass)));
1629 if(fEMCALPIDParamsPass) fEMCALPIDParams = dynamic_cast<TObjArray *>(fEMCALPIDParamsPass->FindObject(Form("EMCALPIDParams_Particles")));
1631 if(!fEMCALPIDParams){
1632 AliInfo(Form("EMCAL Params not found in run %d pass %d", fRun, fRecoPass));
1633 AliInfo("Will take the standard LHC11d instead ...");
1635 fEMCALPIDParamsRun = dynamic_cast<TObjArray *>(contParams.GetObject(156477));
1636 if(fEMCALPIDParamsRun) fEMCALPIDParamsPass = dynamic_cast<TObjArray *>(fEMCALPIDParamsRun->FindObject(Form("pass%d",1)));
1637 if(fEMCALPIDParamsPass) fEMCALPIDParams = dynamic_cast<TObjArray *>(fEMCALPIDParamsPass->FindObject(Form("EMCALPIDParams_Particles")));
1639 if(!fEMCALPIDParams){
1640 AliError(Form("DEFAULT EMCAL Params (LHC11d) not found in file %s/COMMON/PID/data/EMCALPIDParams.root", fOADBPath.Data()));
1646 //______________________________________________________________________________
1647 void AliPIDResponse::InitializeEMCALResponse(){
1649 // Set PID Params to the EMCAL PID response
1651 fEMCALResponse.SetPIDParams(fEMCALPIDParams);
1655 //______________________________________________________________________________
1656 void AliPIDResponse::FillTrackDetectorPID(const AliVTrack *track, EDetector detector) const
1659 // create detector PID information and setup the transient pointer in the track
1662 // check if detector number is inside accepted range
1663 if (detector == kNdetectors) return;
1666 AliDetectorPID *detPID=const_cast<AliDetectorPID*>(track->GetDetectorPID());
1668 detPID=new AliDetectorPID;
1669 (const_cast<AliVTrack*>(track))->SetDetectorPID(detPID);
1672 //check if values exist
1673 if (detPID->HasRawProbability(detector) && detPID->HasNumberOfSigmas(detector)) return;
1675 //TODO: which particles to include? See also the loops below...
1676 Double_t values[AliPID::kSPECIESC]={0};
1679 EDetPidStatus status=GetComputePIDProbability(detector,track,AliPID::kSPECIESC,values);
1680 detPID->SetRawProbability(detector, values, (Int_t)AliPID::kSPECIESC, status);
1683 for (Int_t ipart=0; ipart<AliPID::kSPECIESC; ++ipart)
1684 values[ipart]=GetNumberOfSigmas(detector,track,(AliPID::EParticleType)ipart);
1685 // the pid status is the same for probabilities and nSigmas, so it is
1686 // fine to use the one from the probabilities also here
1687 detPID->SetNumberOfSigmas(detector, values, (Int_t)AliPID::kSPECIESC, status);
1691 //______________________________________________________________________________
1692 void AliPIDResponse::FillTrackDetectorPID()
1695 // create detector PID information and setup the transient pointer in the track
1698 if (!fCurrentEvent) return;
1700 for (Int_t itrack=0; itrack<fCurrentEvent->GetNumberOfTracks(); ++itrack){
1701 AliVTrack *track=dynamic_cast<AliVTrack*>(fCurrentEvent->GetTrack(itrack));
1702 if (!track) continue;
1704 for (Int_t idet=0; idet<kNdetectors; ++idet){
1705 FillTrackDetectorPID(track, (EDetector)idet);
1710 //______________________________________________________________________________
1711 void AliPIDResponse::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
1713 // Set TOF response function
1714 // Input option for event_time used
1717 Float_t t0spread = 0.; //vevent->GetEventTimeSpread();
1718 if(t0spread < 10) t0spread = 80;
1720 // T0 from TOF algorithm
1722 Bool_t flagT0TOF=kFALSE;
1723 Bool_t flagT0T0=kFALSE;
1724 Float_t *startTime = new Float_t[fTOFResponse.GetNmomBins()];
1725 Float_t *startTimeRes = new Float_t[fTOFResponse.GetNmomBins()];
1726 Int_t *startTimeMask = new Int_t[fTOFResponse.GetNmomBins()];
1729 Float_t *estimatedT0event = new Float_t[fTOFResponse.GetNmomBins()];
1730 Float_t *estimatedT0resolution = new Float_t[fTOFResponse.GetNmomBins()];
1731 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1732 estimatedT0event[i]=0.0;
1733 estimatedT0resolution[i]=0.0;
1734 startTimeMask[i] = 0;
1737 Float_t resT0A=fResT0A;
1738 Float_t resT0C=fResT0C;
1739 Float_t resT0AC=fResT0AC;
1740 if(vevent->GetT0TOF()){ // check if T0 detector information is available
1745 AliTOFHeader *tofHeader = (AliTOFHeader*)vevent->GetTOFHeader();
1747 if (tofHeader) { // read global info and T0-TOF
1748 fTOFResponse.SetTimeResolution(tofHeader->GetTOFResolution());
1749 t0spread = tofHeader->GetT0spread(); // read t0 sprad
1750 if(t0spread < 10) t0spread = 80;
1753 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ // read T0-TOF default value
1754 startTime[i]=tofHeader->GetDefaultEventTimeVal();
1755 startTimeRes[i]=tofHeader->GetDefaultEventTimeRes();
1756 if(startTimeRes[i] < 1.e-5) startTimeRes[i] = t0spread;
1759 TArrayI *ibin=(TArrayI*)tofHeader->GetNvalues();
1760 TArrayF *t0Bin=(TArrayF*)tofHeader->GetEventTimeValues();
1761 TArrayF *t0ResBin=(TArrayF*)tofHeader->GetEventTimeRes();
1762 for(Int_t j=0;j < tofHeader->GetNbins();j++){ // fill T0-TOF in p-bins
1763 Int_t icurrent = (Int_t)ibin->GetAt(j);
1764 startTime[icurrent]=t0Bin->GetAt(j);
1765 startTimeRes[icurrent]=t0ResBin->GetAt(j);
1766 if(startTimeRes[icurrent] < 1.e-5) startTimeRes[icurrent] = t0spread;
1770 // for cut of 3 sigma on t0 spread
1771 Float_t t0cut = 3 * t0spread;
1772 if(t0cut < 500) t0cut = 500;
1774 if(option == kFILL_T0){ // T0-FILL is used
1775 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1776 estimatedT0event[i]=0.0;
1777 estimatedT0resolution[i]=t0spread;
1779 fTOFResponse.SetT0event(estimatedT0event);
1780 fTOFResponse.SetT0resolution(estimatedT0resolution);
1783 if(option == kTOF_T0){ // T0-TOF is used when available (T0-FILL otherwise) from ESD
1785 fTOFResponse.SetT0event(startTime);
1786 fTOFResponse.SetT0resolution(startTimeRes);
1787 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1788 if(startTimeRes[i]<t0spread) startTimeMask[i]=1;
1789 fTOFResponse.SetT0binMask(i,startTimeMask[i]);
1793 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1794 estimatedT0event[i]=0.0;
1795 estimatedT0resolution[i]=t0spread;
1796 fTOFResponse.SetT0binMask(i,startTimeMask[i]);
1798 fTOFResponse.SetT0event(estimatedT0event);
1799 fTOFResponse.SetT0resolution(estimatedT0resolution);
1802 else if(option == kBest_T0){ // T0-T0 or T0-TOF are used when available (T0-FILL otherwise) from ESD
1803 Float_t t0AC=-10000;
1807 t0A= vevent->GetT0TOF()[1];
1808 t0C= vevent->GetT0TOF()[2];
1809 // t0AC= vevent->GetT0TOF()[0];
1810 t0AC= t0A/resT0A/resT0A + t0C/resT0C/resT0C;
1811 resT0AC= TMath::Sqrt(1./resT0A/resT0A + 1./resT0C/resT0C);
1812 t0AC /= resT0AC*resT0AC;
1815 Float_t t0t0Best = 0;
1816 Float_t t0t0BestRes = 9999;
1818 if(TMath::Abs(t0A) < t0cut && TMath::Abs(t0C) < t0cut && TMath::Abs(t0C-t0A) < 500){
1820 t0t0BestRes = resT0AC;
1823 else if(TMath::Abs(t0C) < t0cut){
1825 t0t0BestRes = resT0C;
1828 else if(TMath::Abs(t0A) < t0cut){
1830 t0t0BestRes = resT0A;
1834 if(flagT0TOF){ // if T0-TOF info is available
1835 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1836 if(t0t0BestRes < 999){
1837 if(startTimeRes[i] < t0spread){
1838 Double_t wtot = 1./startTimeRes[i]/startTimeRes[i] + 1./t0t0BestRes/t0t0BestRes;
1839 Double_t t0best = startTime[i]/startTimeRes[i]/startTimeRes[i] + t0t0Best/t0t0BestRes/t0t0BestRes;
1840 estimatedT0event[i]=t0best / wtot;
1841 estimatedT0resolution[i]=1./TMath::Sqrt(wtot);
1842 startTimeMask[i] = t0used+1;
1845 estimatedT0event[i]=t0t0Best;
1846 estimatedT0resolution[i]=t0t0BestRes;
1847 startTimeMask[i] = t0used;
1851 estimatedT0event[i]=startTime[i];
1852 estimatedT0resolution[i]=startTimeRes[i];
1853 if(startTimeRes[i]<t0spread) startTimeMask[i]=1;
1855 fTOFResponse.SetT0binMask(i,startTimeMask[i]);
1857 fTOFResponse.SetT0event(estimatedT0event);
1858 fTOFResponse.SetT0resolution(estimatedT0resolution);
1860 else{ // if no T0-TOF info is available
1861 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1862 fTOFResponse.SetT0binMask(i,t0used);
1863 if(t0t0BestRes < 999){
1864 estimatedT0event[i]=t0t0Best;
1865 estimatedT0resolution[i]=t0t0BestRes;
1868 estimatedT0event[i]=0.0;
1869 estimatedT0resolution[i]=t0spread;
1872 fTOFResponse.SetT0event(estimatedT0event);
1873 fTOFResponse.SetT0resolution(estimatedT0resolution);
1877 else if(option == kT0_T0){ // T0-T0 is used when available (T0-FILL otherwise)
1878 Float_t t0AC=-10000;
1882 t0A= vevent->GetT0TOF()[1];
1883 t0C= vevent->GetT0TOF()[2];
1884 // t0AC= vevent->GetT0TOF()[0];
1885 t0AC= t0A/resT0A/resT0A + t0C/resT0C/resT0C;
1886 resT0AC= TMath::Sqrt(1./resT0A/resT0A + 1./resT0C/resT0C);
1887 t0AC /= resT0AC*resT0AC;
1890 if(TMath::Abs(t0A) < t0cut && TMath::Abs(t0C) < t0cut && TMath::Abs(t0C-t0A) < 500){
1891 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1892 estimatedT0event[i]=t0AC;
1893 estimatedT0resolution[i]=resT0AC;
1894 fTOFResponse.SetT0binMask(i,6);
1897 else if(TMath::Abs(t0C) < t0cut){
1898 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1899 estimatedT0event[i]=t0C;
1900 estimatedT0resolution[i]=resT0C;
1901 fTOFResponse.SetT0binMask(i,4);
1904 else if(TMath::Abs(t0A) < t0cut){
1905 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1906 estimatedT0event[i]=t0A;
1907 estimatedT0resolution[i]=resT0A;
1908 fTOFResponse.SetT0binMask(i,2);
1912 for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
1913 estimatedT0event[i]=0.0;
1914 estimatedT0resolution[i]=t0spread;
1915 fTOFResponse.SetT0binMask(i,0);
1918 fTOFResponse.SetT0event(estimatedT0event);
1919 fTOFResponse.SetT0resolution(estimatedT0resolution);
1921 delete [] startTime;
1922 delete [] startTimeRes;
1923 delete [] startTimeMask;
1924 delete [] estimatedT0event;
1925 delete [] estimatedT0resolution;
1928 //______________________________________________________________________________
1929 // private non cached versions of the PID calculation
1933 //______________________________________________________________________________
1934 Float_t AliPIDResponse::GetNumberOfSigmas(EDetector detector, const AliVParticle *vtrack, AliPID::EParticleType type) const
1937 // NumberOfSigmas for 'detCode'
1940 const AliVTrack *track=static_cast<const AliVTrack*>(vtrack);
1943 case kITS: return GetNumberOfSigmasITS(track, type); break;
1944 case kTPC: return GetNumberOfSigmasTPC(track, type); break;
1945 case kTOF: return GetNumberOfSigmasTOF(track, type); break;
1946 case kHMPID: return GetNumberOfSigmasHMPID(track, type); break;
1947 case kEMCAL: return GetNumberOfSigmasEMCAL(track, type); break;
1948 default: return -999.;
1954 //______________________________________________________________________________
1955 Float_t AliPIDResponse::GetNumberOfSigmasITS(const AliVParticle *vtrack, AliPID::EParticleType type) const
1958 // Calculate the number of sigmas in the ITS
1961 AliVTrack *track=(AliVTrack*)vtrack;
1963 const EDetPidStatus pidStatus=GetITSPIDStatus(track);
1964 if (pidStatus!=kDetPidOk) return -999.;
1966 return fITSResponse.GetNumberOfSigmas(track,type);
1969 //______________________________________________________________________________
1970 Float_t AliPIDResponse::GetNumberOfSigmasTPC(const AliVParticle *vtrack, AliPID::EParticleType type) const
1973 // Calculate the number of sigmas in the TPC
1976 AliVTrack *track=(AliVTrack*)vtrack;
1978 const EDetPidStatus pidStatus=GetTPCPIDStatus(track);
1979 if (pidStatus!=kDetPidOk) return -999.;
1981 // the following call is needed in order to fill the transient data member
1982 // fTPCsignalTuned which is used in the TPCPIDResponse to judge
1983 // if using tuned on data
1984 if (fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC))
1985 this->GetTPCsignalTunedOnData(track);
1987 return fTPCResponse.GetNumberOfSigmas(track, type, AliTPCPIDResponse::kdEdxDefault, fUseTPCEtaCorrection, fUseTPCMultiplicityCorrection);
1990 //______________________________________________________________________________
1991 Float_t AliPIDResponse::GetNumberOfSigmasTOF(const AliVParticle *vtrack, AliPID::EParticleType type) const
1994 // Calculate the number of sigmas in the TOF
1997 AliVTrack *track=(AliVTrack*)vtrack;
1999 const EDetPidStatus pidStatus=GetTOFPIDStatus(track);
2000 if (pidStatus!=kDetPidOk) return -999.;
2002 return GetNumberOfSigmasTOFold(vtrack, type);
2004 //______________________________________________________________________________
2006 Float_t AliPIDResponse::GetNumberOfSigmasHMPID(const AliVParticle *vtrack, AliPID::EParticleType type) const
2009 // Calculate the number of sigmas in the HMPID
2011 AliVTrack *track=(AliVTrack*)vtrack;
2013 const EDetPidStatus pidStatus=GetHMPIDPIDStatus(track);
2014 if (pidStatus!=kDetPidOk) return -999.;
2016 return fHMPIDResponse.GetNumberOfSigmas(track, type);
2019 //______________________________________________________________________________
2020 Float_t AliPIDResponse::GetNumberOfSigmasEMCAL(const AliVParticle *vtrack, AliPID::EParticleType type) const
2023 // Calculate the number of sigmas in the EMCAL
2026 AliVTrack *track=(AliVTrack*)vtrack;
2028 const EDetPidStatus pidStatus=GetEMCALPIDStatus(track);
2029 if (pidStatus!=kDetPidOk) return -999.;
2031 const Int_t nMatchClus = track->GetEMCALcluster();
2032 AliVCluster *matchedClus = (AliVCluster*)fCurrentEvent->GetCaloCluster(nMatchClus);
2034 const Double_t mom = track->P();
2035 const Double_t pt = track->Pt();
2036 const Int_t charge = track->Charge();
2037 const Double_t fClsE = matchedClus->E();
2038 const Double_t EovP = fClsE/mom;
2040 return fEMCALResponse.GetNumberOfSigmas(pt,EovP,type,charge);
2043 //______________________________________________________________________________
2044 AliPIDResponse::EDetPidStatus AliPIDResponse::GetSignalDeltaITS(const AliVParticle *vtrack, AliPID::EParticleType type, Double_t &val, Bool_t ratio/*=kFALSE*/) const
2047 // Signal minus expected Signal for ITS
2049 AliVTrack *track=(AliVTrack*)vtrack;
2050 val=fITSResponse.GetSignalDelta(track,type,ratio);
2052 return GetITSPIDStatus(track);
2055 //______________________________________________________________________________
2056 AliPIDResponse::EDetPidStatus AliPIDResponse::GetSignalDeltaTPC(const AliVParticle *vtrack, AliPID::EParticleType type, Double_t &val, Bool_t ratio/*=kFALSE*/) const
2059 // Signal minus expected Signal for TPC
2061 AliVTrack *track=(AliVTrack*)vtrack;
2063 // the following call is needed in order to fill the transient data member
2064 // fTPCsignalTuned which is used in the TPCPIDResponse to judge
2065 // if using tuned on data
2066 if (fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC))
2067 this->GetTPCsignalTunedOnData(track);
2069 val=fTPCResponse.GetSignalDelta(track, type, AliTPCPIDResponse::kdEdxDefault, fUseTPCEtaCorrection, fUseTPCMultiplicityCorrection, ratio);
2071 return GetTPCPIDStatus(track);
2074 //______________________________________________________________________________
2075 AliPIDResponse::EDetPidStatus AliPIDResponse::GetSignalDeltaTOF(const AliVParticle *vtrack, AliPID::EParticleType type, Double_t &val, Bool_t ratio/*=kFALSE*/) const
2078 // Signal minus expected Signal for TOF
2080 AliVTrack *track=(AliVTrack*)vtrack;
2081 val=GetSignalDeltaTOFold(track, type, ratio);
2083 return GetTOFPIDStatus(track);
2086 //______________________________________________________________________________
2087 AliPIDResponse::EDetPidStatus AliPIDResponse::GetSignalDeltaHMPID(const AliVParticle *vtrack, AliPID::EParticleType type, Double_t &val, Bool_t ratio/*=kFALSE*/) const
2090 // Signal minus expected Signal for HMPID
2092 AliVTrack *track=(AliVTrack*)vtrack;
2093 val=fHMPIDResponse.GetSignalDelta(track, type, ratio);
2095 return GetHMPIDPIDStatus(track);
2098 //______________________________________________________________________________
2099 AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputePIDProbability (EDetector detCode, const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
2102 // Compute PID response of 'detCode'
2106 case kITS: return GetComputeITSProbability(track, nSpecies, p); break;
2107 case kTPC: return GetComputeTPCProbability(track, nSpecies, p); break;
2108 case kTRD: return GetComputeTRDProbability(track, nSpecies, p); break;
2109 case kTOF: return GetComputeTOFProbability(track, nSpecies, p); break;
2110 case kPHOS: return GetComputePHOSProbability(track, nSpecies, p); break;
2111 case kEMCAL: return GetComputeEMCALProbability(track, nSpecies, p); break;
2112 case kHMPID: return GetComputeHMPIDProbability(track, nSpecies, p); break;
2113 default: return kDetNoSignal;
2117 //______________________________________________________________________________
2118 AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputeITSProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
2121 // Compute PID response for the ITS
2124 // set flat distribution (no decision)
2125 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
2127 const EDetPidStatus pidStatus=GetITSPIDStatus(track);
2128 if (pidStatus!=kDetPidOk) return pidStatus;
2130 if (track->GetDetectorPID()){
2131 return track->GetDetectorPID()->GetRawProbability(kITS, p, nSpecies);
2134 //check for ITS standalone tracks
2136 if( track->GetStatus() & AliVTrack::kTPCin ) isSA=kFALSE;
2138 Double_t mom=track->P();
2139 Double_t dedx=track->GetITSsignal();
2140 Double_t momITS=mom;
2141 UChar_t clumap=track->GetITSClusterMap();
2142 Int_t nPointsForPid=0;
2143 for(Int_t i=2; i<6; i++){
2144 if(clumap&(1<<i)) ++nPointsForPid;
2147 Bool_t mismatch=kTRUE/*, heavy=kTRUE*/;
2148 for (Int_t j=0; j<nSpecies; j++) {
2149 Double_t mass=AliPID::ParticleMassZ(j);//GeV/c^2
2150 const Double_t chargeFactor = TMath::Power(AliPID::ParticleCharge(j),2.);
2151 Double_t bethe=fITSResponse.Bethe(momITS,mass)*chargeFactor;
2152 //TODO: in case of the electron, use the SA parametrisation,
2153 // this needs to be changed if ITS provides a parametrisation
2154 // for electrons also for ITS+TPC tracks
2155 Double_t sigma=fITSResponse.GetResolution(bethe,nPointsForPid,isSA || (j==(Int_t)AliPID::kElectron));
2156 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
2157 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
2159 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
2165 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
2170 //______________________________________________________________________________
2171 AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputeTPCProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
2174 // Compute PID response for the TPC
2177 // set flat distribution (no decision)
2178 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
2180 const EDetPidStatus pidStatus=GetTPCPIDStatus(track);
2181 if (pidStatus!=kDetPidOk) return pidStatus;
2183 Double_t dedx=track->GetTPCsignal();
2184 Bool_t mismatch=kTRUE/*, heavy=kTRUE*/;
2186 if (fTuneMConData && ((fTuneMConDataMask & kDetTPC) == kDetTPC)) dedx = this->GetTPCsignalTunedOnData(track);
2188 Double_t bethe = 0.;
2189 Double_t sigma = 0.;
2191 for (Int_t j=0; j<nSpecies; j++) {
2192 AliPID::EParticleType type=AliPID::EParticleType(j);
2194 bethe=fTPCResponse.GetExpectedSignal(track, type, AliTPCPIDResponse::kdEdxDefault, fUseTPCEtaCorrection, fUseTPCMultiplicityCorrection);
2195 sigma=fTPCResponse.GetExpectedSigma(track, type, AliTPCPIDResponse::kdEdxDefault, fUseTPCEtaCorrection, fUseTPCMultiplicityCorrection);
2197 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
2198 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
2200 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
2206 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
2211 //______________________________________________________________________________
2212 AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputeTOFProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
2215 // Compute PID probabilities for TOF
2218 // set flat distribution (no decision)
2219 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
2221 const EDetPidStatus pidStatus=GetTOFPIDStatus(track);
2222 if (pidStatus!=kDetPidOk) return pidStatus;
2224 const Double_t meanCorrFactor = 0.07/fTOFtail; // Correction factor on the mean because of the tail (should be ~ 0.1 with tail = 1.1)
2226 for (Int_t j=0; j<nSpecies; j++) {
2227 AliPID::EParticleType type=AliPID::EParticleType(j);
2228 const Double_t nsigmas=GetNumberOfSigmasTOFold(track,type) + meanCorrFactor;
2230 const Double_t expTime = fTOFResponse.GetExpectedSignal(track,type);
2231 const Double_t sig = fTOFResponse.GetExpectedSigma(track->P(),expTime,AliPID::ParticleMassZ(type));
2232 if (TMath::Abs(nsigmas) > (fRange+2)) {
2233 if(nsigmas < fTOFtail)
2234 p[j] = TMath::Exp(-0.5*(fRange+2)*(fRange+2))/sig;
2236 p[j] = TMath::Exp(-(fRange+2 - fTOFtail*0.5)*fTOFtail)/sig;
2238 if(nsigmas < fTOFtail)
2239 p[j] = TMath::Exp(-0.5*nsigmas*nsigmas)/sig;
2241 p[j] = TMath::Exp(-(nsigmas - fTOFtail*0.5)*fTOFtail)/sig;
2247 //______________________________________________________________________________
2248 AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputeTRDProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[],AliTRDPIDResponse::ETRDPIDMethod PIDmethod/*=AliTRDPIDResponse::kLQ1D*/) const
2251 // Compute PID probabilities for the TRD
2254 // set flat distribution (no decision)
2255 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
2257 const EDetPidStatus pidStatus=GetTRDPIDStatus(track);
2258 if (pidStatus!=kDetPidOk) return pidStatus;
2260 UInt_t TRDslicesForPID[2];
2261 SetTRDSlices(TRDslicesForPID,PIDmethod);
2263 Float_t mom[6]={0.};
2264 Double_t dedx[48]={0.}; // Allocate space for the maximum number of TRD slices
2265 Int_t nslices = TRDslicesForPID[1] - TRDslicesForPID[0] + 1;
2266 AliDebug(1, Form("First Slice: %d, Last Slice: %d, Number of slices: %d", TRDslicesForPID[0], TRDslicesForPID[1], nslices));
2267 for(UInt_t ilayer = 0; ilayer < 6; ilayer++){
2268 mom[ilayer] = track->GetTRDmomentum(ilayer);
2269 for(UInt_t islice = TRDslicesForPID[0]; islice <= TRDslicesForPID[1]; islice++){
2270 dedx[ilayer*nslices+islice-TRDslicesForPID[0]] = track->GetTRDslice(ilayer, islice);
2274 fTRDResponse.GetResponse(nslices, dedx, mom, p,PIDmethod);
2278 //______________________________________________________________________________
2279 AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputeEMCALProbability (const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
2282 // Compute PID response for the EMCAL
2285 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
2287 const EDetPidStatus pidStatus=GetEMCALPIDStatus(track);
2288 if (pidStatus!=kDetPidOk) return pidStatus;
2290 const Int_t nMatchClus = track->GetEMCALcluster();
2291 AliVCluster *matchedClus = (AliVCluster*)fCurrentEvent->GetCaloCluster(nMatchClus);
2293 const Double_t mom = track->P();
2294 const Double_t pt = track->Pt();
2295 const Int_t charge = track->Charge();
2296 const Double_t fClsE = matchedClus->E();
2297 const Double_t EovP = fClsE/mom;
2299 // compute the probabilities
2300 fEMCALResponse.ComputeEMCALProbability(nSpecies,pt,EovP,charge,p);
2304 //______________________________________________________________________________
2305 AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputePHOSProbability (const AliVTrack */*track*/, Int_t nSpecies, Double_t p[]) const
2308 // Compute PID response for the PHOS
2311 // set flat distribution (no decision)
2312 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
2313 return kDetNoSignal;
2316 //______________________________________________________________________________
2317 AliPIDResponse::EDetPidStatus AliPIDResponse::GetComputeHMPIDProbability(const AliVTrack *track, Int_t nSpecies, Double_t p[]) const
2320 // Compute PID response for the HMPID
2323 // set flat distribution (no decision)
2324 for (Int_t j=0; j<nSpecies; j++) p[j]=1./nSpecies;
2326 const EDetPidStatus pidStatus=GetHMPIDPIDStatus(track);
2327 if (pidStatus!=kDetPidOk) return pidStatus;
2329 fHMPIDResponse.GetProbability(track,nSpecies,p);
2334 //______________________________________________________________________________
2335 AliPIDResponse::EDetPidStatus AliPIDResponse::GetITSPIDStatus(const AliVTrack *track) const
2337 // compute ITS pid status
2339 // check status bits
2340 if ((track->GetStatus()&AliVTrack::kITSin)==0 &&
2341 (track->GetStatus()&AliVTrack::kITSout)==0) return kDetNoSignal;
2343 const Float_t dEdx=track->GetITSsignal();
2344 if (dEdx<=0) return kDetNoSignal;
2346 // requite at least 3 pid clusters
2347 const UChar_t clumap=track->GetITSClusterMap();
2348 Int_t nPointsForPid=0;
2349 for(Int_t i=2; i<6; i++){
2350 if(clumap&(1<<i)) ++nPointsForPid;
2353 if(nPointsForPid<3) {
2354 return kDetNoSignal;
2360 //______________________________________________________________________________
2361 AliPIDResponse::EDetPidStatus AliPIDResponse:: GetTPCPIDStatus(const AliVTrack *track) const
2363 // compute TPC pid status
2365 // check quality of the track
2366 if ( (track->GetStatus()&AliVTrack::kTPCin )==0 && (track->GetStatus()&AliVTrack::kTPCout)==0 ) return kDetNoSignal;
2369 const Double_t dedx=track->GetTPCsignal();
2370 const UShort_t signalN=track->GetTPCsignalN();
2371 if (signalN<10 || dedx<10) return kDetNoSignal;
2373 if (!(fArrPidResponseMaster && fArrPidResponseMaster->At(AliPID::kPion))) return kDetNoParams;
2378 //______________________________________________________________________________
2379 AliPIDResponse::EDetPidStatus AliPIDResponse::GetTRDPIDStatus(const AliVTrack *track) const
2381 // compute TRD pid status
2383 if((track->GetStatus()&AliVTrack::kTRDout)==0) return kDetNoSignal;
2387 //______________________________________________________________________________
2388 AliPIDResponse::EDetPidStatus AliPIDResponse::GetTOFPIDStatus(const AliVTrack *track) const
2390 // compute TOF pid status
2392 if ((track->GetStatus()&AliVTrack::kTOFout)==0) return kDetNoSignal;
2393 if ((track->GetStatus()&AliVTrack::kTIME)==0) return kDetNoSignal;
2398 //______________________________________________________________________________
2399 Float_t AliPIDResponse::GetTOFMismatchProbability(const AliVTrack *track) const
2401 // compute mismatch probability cross-checking at 5 sigmas with TPC
2402 // currently just implemented as a 5 sigma compatibility cut
2405 const EDetPidStatus tofStatus=GetTOFPIDStatus(track);
2406 if (tofStatus!=kDetPidOk) return 0.;
2409 const EDetPidStatus tpcStatus=GetTPCPIDStatus(track);
2410 if (tpcStatus!=kDetPidOk) return 0.;
2412 const Double_t meanCorrFactor = 0.11/fTOFtail; // Correction factor on the mean because of the tail (should be ~ 0.1 with tail = 1.1)
2413 Bool_t mismatch = kTRUE/*, heavy = kTRUE*/;
2414 for (Int_t j=0; j<AliPID::kSPECIESC; j++) {
2415 AliPID::EParticleType type=AliPID::EParticleType(j);
2416 const Double_t nsigmas=GetNumberOfSigmasTOFold(track,type) + meanCorrFactor;
2418 if (TMath::Abs(nsigmas)<5.){
2419 const Double_t nsigmasTPC=GetNumberOfSigmasTPC(track,type);
2420 if (TMath::Abs(nsigmasTPC)<5.) mismatch=kFALSE;
2431 //______________________________________________________________________________
2432 AliPIDResponse::EDetPidStatus AliPIDResponse:: GetHMPIDPIDStatus(const AliVTrack *track) const
2434 // compute HMPID pid status
2436 Int_t ch = track->GetHMPIDcluIdx()/1000000;
2437 Double_t HMPIDsignal = track->GetHMPIDsignal();
2439 if((track->GetStatus()&AliVTrack::kHMPIDpid)==0 || ch<0 || ch>6 || HMPIDsignal<0) return kDetNoSignal;
2444 //______________________________________________________________________________
2445 AliPIDResponse::EDetPidStatus AliPIDResponse:: GetPHOSPIDStatus(const AliVTrack */*track*/) const
2447 // compute PHOS pid status
2448 return kDetNoSignal;
2451 //______________________________________________________________________________
2452 AliPIDResponse::EDetPidStatus AliPIDResponse:: GetEMCALPIDStatus(const AliVTrack *track) const
2454 // compute EMCAL pid status
2458 const Int_t nMatchClus = track->GetEMCALcluster();
2459 if (nMatchClus<0) return kDetNoSignal;
2461 AliVCluster *matchedClus = (AliVCluster*)fCurrentEvent->GetCaloCluster(nMatchClus);
2463 if (!(matchedClus && matchedClus->IsEMCAL())) return kDetNoSignal;
2465 const Int_t charge = track->Charge();
2466 if (TMath::Abs(charge)!=1) return kDetNoSignal;
2468 if (!(fEMCALPIDParams && fEMCALPIDParams->At(AliPID::kElectron))) return kDetNoParams;
2474 //______________________________________________________________________________
2475 AliPIDResponse::EDetPidStatus AliPIDResponse::GetPIDStatus(EDetector detector, const AliVTrack *track) const
2478 // check pid status for a track
2482 case kITS: return GetITSPIDStatus(track); break;
2483 case kTPC: return GetTPCPIDStatus(track); break;
2484 case kTRD: return GetTRDPIDStatus(track); break;
2485 case kTOF: return GetTOFPIDStatus(track); break;
2486 case kPHOS: return GetPHOSPIDStatus(track); break;
2487 case kEMCAL: return GetEMCALPIDStatus(track); break;
2488 case kHMPID: return GetHMPIDPIDStatus(track); break;
2489 default: return kDetNoSignal;
2491 return kDetNoSignal;
2495 //______________________________________________________________________________
2496 TString AliPIDResponse::GetChecksum(const TObject* obj) const
2498 // Return the checksum for an object obj (tested to work properly at least for histograms and TSplines).
2500 TString fileName = Form("tempChecksum.C"); // File name must be fixed for data type "TSpline3", since the file name will end up in the file content!
2502 // For parallel processing, a unique file pathname is required. Uniqueness can be guaranteed by using a unique directory name
2504 TString uniquePathName = Form("tempChecksum_%u", index);
2506 // To get a unique path name, increase the index until no directory
2507 // of such a name exists.
2508 // NOTE: gSystem->AccessPathName(...) returns kTRUE, if the access FAILED!
2509 while (!gSystem->AccessPathName(uniquePathName.Data()))
2510 uniquePathName = Form("tempChecksum_%u", ++index);
2512 if (gSystem->mkdir(uniquePathName.Data()) < 0) {
2513 AliError("Could not create temporary directory to store temp file for checksum determination!");
2517 TString option = "";
2519 // Save object as a macro, which will be deleted immediately after the checksum has been computed
2520 // (does not work for desired data types if saved as *.root for some reason) - one only wants to compare the content, not
2521 // the modification time etc. ...
2522 if (dynamic_cast<const TH1*>(obj))
2523 option = "colz"; // Histos need this option, since w/o this option, a counter is added to the filename
2526 // SaveAs must be called with the fixed fileName only, since the first argument goes into the file content
2527 // for some object types. Thus, change the directory, save the file and then go back
2528 TString oldDir = gSystem->pwd();
2529 gSystem->cd(uniquePathName.Data());
2530 obj->SaveAs(fileName.Data(), option.Data());
2531 gSystem->cd(oldDir.Data());
2533 // Use the file to calculate the MD5 checksum
2534 TMD5* md5 = TMD5::FileChecksum(Form("%s/%s", uniquePathName.Data(), fileName.Data()));
2535 TString checksum = md5->AsString();
2539 gSystem->Exec(Form("rm -rf %s", uniquePathName.Data()));