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>
37 #include "AliPIDResponse.h"
39 ClassImp(AliPIDResponse);
41 AliPIDResponse::AliPIDResponse(Bool_t isMC/*=kFALSE*/) :
42 TNamed("PIDResponse","PIDResponse"),
55 fArrPidResponseMaster(0x0),
56 fResolutionCorrection(0x0),
57 fTOFTimeZeroType(kBest_T0),
63 AliLog::SetClassDebugLevel("AliPIDResponse",10);
64 AliLog::SetClassDebugLevel("AliESDpid",10);
65 AliLog::SetClassDebugLevel("AliAODpidUtil",10);
68 //______________________________________________________________________________
69 AliPIDResponse::~AliPIDResponse()
74 delete fArrPidResponseMaster;
77 //______________________________________________________________________________
78 AliPIDResponse::AliPIDResponse(const AliPIDResponse &other) :
80 fITSResponse(other.fITSResponse),
81 fTPCResponse(other.fTPCResponse),
82 fTRDResponse(other.fTRDResponse),
83 fTOFResponse(other.fTOFResponse),
85 fOADBPath(other.fOADBPath),
92 fArrPidResponseMaster(0x0),
93 fResolutionCorrection(0x0),
94 fTOFTimeZeroType(AliPIDResponse::kBest_T0),
102 //______________________________________________________________________________
103 AliPIDResponse& AliPIDResponse::operator=(const AliPIDResponse &other)
109 delete fArrPidResponseMaster;
110 TNamed::operator=(other);
111 fITSResponse=other.fITSResponse;
112 fTPCResponse=other.fTPCResponse;
113 fTRDResponse=other.fTRDResponse;
114 fTOFResponse=other.fTOFResponse;
115 fOADBPath=other.fOADBPath;
123 fArrPidResponseMaster=0x0;
124 fResolutionCorrection=0x0;
125 fTOFTimeZeroType=AliPIDResponse::kBest_T0;
131 //______________________________________________________________________________
132 void AliPIDResponse::InitialiseEvent(AliVEvent *event, Int_t pass)
135 // Apply settings for the current event
140 fRun=event->GetRunNumber();
147 //TPC resolution parametrisation PbPb
148 if ( fResolutionCorrection ){
149 Double_t corrSigma=fResolutionCorrection->Eval(GetTPCMultiplicityBin(event));
150 fTPCResponse.SetSigma(3.79301e-03*corrSigma, 2.21280e+04);
154 SetTOFResponse(event, (AliPIDResponse::EStartTimeType_t)fTOFTimeZeroType);
158 //______________________________________________________________________________
159 void AliPIDResponse::ExecNewRun()
162 // Things to Execute upon a new run
166 SetITSParametrisation();
168 SetTPCPidResponseMaster();
169 SetTPCParametrisation();
171 fTOFResponse.SetTimeResolution(fTOFres);
174 //_____________________________________________________
175 Double_t AliPIDResponse::GetTPCMultiplicityBin(const AliVEvent * const event)
178 // Get TPC multiplicity in bins of 150
181 const AliVVertex* vertexTPC = event->GetPrimaryVertex();
182 Double_t tpcMulti=0.;
184 Double_t vertexContribTPC=vertexTPC->GetNContributors();
185 tpcMulti=vertexContribTPC/150.;
186 if (tpcMulti>20.) tpcMulti=20.;
192 //______________________________________________________________________________
193 void AliPIDResponse::SetRecoInfo()
196 // Set reconstruction information
207 //find the period by run number (UGLY, but not stored in ESD and AOD... )
208 if (fRun>=114737&&fRun<=117223) { fLHCperiod="LHC10B"; fMCperiodTPC="LHC10D1"; }
209 else if (fRun>=118503&&fRun<=121040) { fLHCperiod="LHC10C"; fMCperiodTPC="LHC10D1"; }
210 else if (fRun>=122195&&fRun<=126437) { fLHCperiod="LHC10D"; fMCperiodTPC="LHC10F6A"; }
211 else if (fRun>=127719&&fRun<=130850) { fLHCperiod="LHC10E"; fMCperiodTPC="LHC10F6A"; }
212 else if (fRun>=133004&&fRun<=135029) { fLHCperiod="LHC10F"; fMCperiodTPC="LHC10F6A"; }
213 else if (fRun>=135654&&fRun<=136377) { fLHCperiod="LHC10G"; fMCperiodTPC="LHC10F6A"; }
214 else if (fRun>=136851&&fRun<=139517) { fLHCperiod="LHC10H"; fMCperiodTPC="LHC10H8"; fBeamType="PBPB"; }
215 else if (fRun>=139699) { fLHCperiod="LHC11A"; fMCperiodTPC="LHC10F6A"; }
219 //______________________________________________________________________________
220 void AliPIDResponse::SetITSParametrisation()
223 // Set the ITS parametrisation
227 //______________________________________________________________________________
228 void AliPIDResponse::SetTPCPidResponseMaster()
231 // Load the TPC pid response functions from the OADB
234 //reset the PID response functions
235 delete fArrPidResponseMaster;
236 fArrPidResponseMaster=0x0;
238 TString fileName(Form("%s/COMMON/PID/data/TPCPIDResponse.root", fOADBPath.Data()));
240 TFile f(fileName.Data());
241 if (f.IsOpen() && !f.IsZombie()){
242 fArrPidResponseMaster=dynamic_cast<TObjArray*>(f.Get("TPCPIDResponse"));
246 if (!fArrPidResponseMaster){
247 AliFatal(Form("Could not retrieve the TPC pid response from: %s",fileName.Data()));
250 fArrPidResponseMaster->SetOwner();
253 //______________________________________________________________________________
254 void AliPIDResponse::SetTPCParametrisation()
257 // Change BB parametrisation for current run
260 if (fLHCperiod.IsNull()) {
261 AliFatal("No period set, not changing parametrisation");
266 // Set default parametrisations for data and MC
270 TString datatype="DATA";
271 //in case of mc fRecoPass is per default 1
280 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec){
281 fTPCResponse.SetResponseFunction((AliPID::EParticleType)ispec,0x0);
285 //set the new PID splines
287 TString period=fLHCperiod;
288 if (fArrPidResponseMaster){
290 //for MC don't use period information
291 // if (fIsMC) period="[A-Z0-9]*";
292 //for MC use MC period information
293 if (fIsMC) period=fMCperiodTPC;
294 //pattern for the default entry (valid for all particles)
295 TPRegexp reg(Form("TSPLINE3_%s_([A-Z]*)_%s_PASS%d_%s_MEAN",datatype.Data(),period.Data(),fRecoPass,fBeamType.Data()));
297 //loop over entries and filter them
298 for (Int_t iresp=0; iresp<fArrPidResponseMaster->GetEntriesFast();++iresp){
299 TObject *responseFunction=fArrPidResponseMaster->At(iresp);
300 if (responseFunction==0x0) continue;
301 TString responseName=responseFunction->GetName();
303 if (!reg.MatchB(responseName)) continue;
305 TObjArray *arr=reg.MatchS(responseName);
306 TString particleName=arr->At(1)->GetName();
308 if (particleName.IsNull()) continue;
309 if (particleName=="ALL") grAll=responseFunction;
312 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec){
313 TString particle=AliPID::ParticleName(ispec);
315 if ( particle == particleName ){
316 fTPCResponse.SetResponseFunction((AliPID::EParticleType)ispec,responseFunction);
317 fTPCResponse.SetUseDatabase(kTRUE);
318 AliInfo(Form("Adding graph: %d - %s",ispec,responseFunction->GetName()));
325 //set default response function to all particles which don't have a specific one
327 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec){
328 if (!fTPCResponse.GetResponseFunction((AliPID::EParticleType)ispec)){
329 fTPCResponse.SetResponseFunction((AliPID::EParticleType)ispec,grAll);
330 AliInfo(Form("Adding graph: %d - %s",ispec,grAll->GetName()));
337 // Setup resolution parametrisation
341 fTPCResponse.SetSigma(3.79301e-03, 2.21280e+04);
344 fTPCResponse.SetSigma(2.30176e-02, 5.60422e+02);
347 fResolutionCorrection=(TF1*)fArrPidResponseMaster->FindObject(Form("TF1_%s_ALL_%s_PASS%d_%s_SIGMA",datatype.Data(),period.Data(),fRecoPass,fBeamType.Data()));
349 if (fResolutionCorrection) AliInfo(Form("Setting multiplicity correction function: %s",fResolutionCorrection->GetName()));