]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliPIDResponse.cxx
changing msg to aliinfo
[u/mrichter/AliRoot.git] / STEER / AliPIDResponse.cxx
CommitLineData
29bf19f2 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
4ec8e76d 16/* $Id: AliPIDResponse.cxx 46193 2010-12-21 09:00:14Z wiechula $ */
29bf19f2 17
18//-----------------------------------------------------------------
4ec8e76d 19// Base class for handling the pid response //
20// functions of all detectors //
21// and give access to the nsigmas //
22// //
23// Origin: Jens Wiechula, Uni Tuebingen, jens.wiechula@cern.ch //
29bf19f2 24//-----------------------------------------------------------------
25
4ec8e76d 26#include <TList.h>
27#include <TObjArray.h>
28#include <TPRegexp.h>
29#include <TF1.h>
30#include <TSpline.h>
31#include <TFile.h>
32
33#include <AliVEvent.h>
34#include <AliLog.h>
35#include <AliPID.h>
29bf19f2 36
37#include "AliPIDResponse.h"
38
39ClassImp(AliPIDResponse);
40
4ec8e76d 41AliPIDResponse::AliPIDResponse(Bool_t isMC/*=kFALSE*/) :
42TNamed("PIDResponse","PIDResponse"),
43fITSResponse(isMC),
44fTPCResponse(),
45fTRDResponse(),
46fTOFResponse(),
47fIsMC(isMC),
48fOADBPath(),
49fBeamType("PP"),
50fLHCperiod(),
51fMCperiodTPC(),
52fRecoPass(0),
53fRun(0),
54fOldRun(0),
55fArrPidResponseMaster(0x0),
56fResolutionCorrection(0x0),
57fTOFTimeZeroType(kBest_T0),
58fTOFres(100.)
59{
60 //
61 // default ctor
62 //
63 AliLog::SetClassDebugLevel("AliPIDResponse",10);
64 AliLog::SetClassDebugLevel("AliESDpid",10);
65 AliLog::SetClassDebugLevel("AliAODpidUtil",10);
66}
67
68//______________________________________________________________________________
69AliPIDResponse::~AliPIDResponse()
70{
71 //
72 // dtor
73 //
74 delete fArrPidResponseMaster;
75}
76
77//______________________________________________________________________________
78AliPIDResponse::AliPIDResponse(const AliPIDResponse &other) :
79TNamed(other),
80fITSResponse(other.fITSResponse),
81fTPCResponse(other.fTPCResponse),
82fTRDResponse(other.fTRDResponse),
83fTOFResponse(other.fTOFResponse),
84fIsMC(other.fIsMC),
85fOADBPath(other.fOADBPath),
86fBeamType("PP"),
87fLHCperiod(),
88fMCperiodTPC(),
89fRecoPass(0),
90fRun(0),
91fOldRun(0),
92fArrPidResponseMaster(0x0),
93fResolutionCorrection(0x0),
94fTOFTimeZeroType(AliPIDResponse::kBest_T0),
95fTOFres(100.)
96{
97 //
98 // copy ctor
99 //
100}
101
102//______________________________________________________________________________
103AliPIDResponse& AliPIDResponse::operator=(const AliPIDResponse &other)
104{
105 //
106 // copy ctor
107 //
108 if(this!=&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;
116 fIsMC=other.fIsMC;
117 fBeamType="PP";
118 fLHCperiod="";
119 fMCperiodTPC="";
120 fRecoPass=0;
121 fRun=0;
122 fOldRun=0;
123 fArrPidResponseMaster=0x0;
124 fResolutionCorrection=0x0;
125 fTOFTimeZeroType=AliPIDResponse::kBest_T0;
126 fTOFres=100.;
127 }
128 return *this;
129}
130
131//______________________________________________________________________________
132void AliPIDResponse::InitialiseEvent(AliVEvent *event, Int_t pass)
133{
134 //
135 // Apply settings for the current event
136 //
137 fRecoPass=pass;
138
139 if (!event) return;
140 fRun=event->GetRunNumber();
141
142 if (fRun!=fOldRun){
143 ExecNewRun();
144 fOldRun=fRun;
145 }
146
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);
151 }
152
153 //TOF resolution
154 SetTOFResponse(event, (AliPIDResponse::EStartTimeType_t)fTOFTimeZeroType);
155
156}
157
158//______________________________________________________________________________
159void AliPIDResponse::ExecNewRun()
160{
161 //
162 // Things to Execute upon a new run
163 //
164 SetRecoInfo();
165
166 SetITSParametrisation();
167
168 SetTPCPidResponseMaster();
169 SetTPCParametrisation();
170
171 fTOFResponse.SetTimeResolution(fTOFres);
172}
173
174//_____________________________________________________
175Double_t AliPIDResponse::GetTPCMultiplicityBin(const AliVEvent * const event)
176{
177 //
178 // Get TPC multiplicity in bins of 150
179 //
180
181 const AliVVertex* vertexTPC = event->GetPrimaryVertex();
182 Double_t tpcMulti=0.;
183 if(vertexTPC){
184 Double_t vertexContribTPC=vertexTPC->GetNContributors();
185 tpcMulti=vertexContribTPC/150.;
186 if (tpcMulti>20.) tpcMulti=20.;
187 }
188
189 return tpcMulti;
190}
191
192//______________________________________________________________________________
193void AliPIDResponse::SetRecoInfo()
194{
195 //
196 // Set reconstruction information
197 //
198
199 //reset information
200 fLHCperiod="";
201 fMCperiodTPC="";
202
203 fBeamType="";
204
205 fBeamType="PP";
206
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"; }
216
217}
218
219//______________________________________________________________________________
220void AliPIDResponse::SetITSParametrisation()
221{
222 //
223 // Set the ITS parametrisation
224 //
225}
226
227//______________________________________________________________________________
228void AliPIDResponse::SetTPCPidResponseMaster()
229{
230 //
231 // Load the TPC pid response functions from the OADB
232 //
09b50a42 233 //don't load twice for the moment
234 if (fArrPidResponseMaster) return;
235
236
4ec8e76d 237 //reset the PID response functions
238 delete fArrPidResponseMaster;
239 fArrPidResponseMaster=0x0;
240
241 TString fileName(Form("%s/COMMON/PID/data/TPCPIDResponse.root", fOADBPath.Data()));
242
243 TFile f(fileName.Data());
244 if (f.IsOpen() && !f.IsZombie()){
245 fArrPidResponseMaster=dynamic_cast<TObjArray*>(f.Get("TPCPIDResponse"));
246 f.Close();
247 }
248
249 if (!fArrPidResponseMaster){
250 AliFatal(Form("Could not retrieve the TPC pid response from: %s",fileName.Data()));
251 return;
252 }
253 fArrPidResponseMaster->SetOwner();
254}
255
256//______________________________________________________________________________
257void AliPIDResponse::SetTPCParametrisation()
258{
259 //
260 // Change BB parametrisation for current run
261 //
262
263 if (fLHCperiod.IsNull()) {
264 AliFatal("No period set, not changing parametrisation");
265 return;
266 }
267
268 //
269 // Set default parametrisations for data and MC
270 //
271
272 //data type
273 TString datatype="DATA";
274 //in case of mc fRecoPass is per default 1
275 if (fIsMC) {
276 datatype="MC";
277 fRecoPass=1;
278 }
279
280 //
281 //reset old splines
282 //
283 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec){
284 fTPCResponse.SetResponseFunction((AliPID::EParticleType)ispec,0x0);
285 }
286
287 //
288 //set the new PID splines
289 //
290 TString period=fLHCperiod;
291 if (fArrPidResponseMaster){
292 TObject *grAll=0x0;
293 //for MC don't use period information
294// if (fIsMC) period="[A-Z0-9]*";
295 //for MC use MC period information
296 if (fIsMC) period=fMCperiodTPC;
297//pattern for the default entry (valid for all particles)
298 TPRegexp reg(Form("TSPLINE3_%s_([A-Z]*)_%s_PASS%d_%s_MEAN",datatype.Data(),period.Data(),fRecoPass,fBeamType.Data()));
299
300 //loop over entries and filter them
301 for (Int_t iresp=0; iresp<fArrPidResponseMaster->GetEntriesFast();++iresp){
302 TObject *responseFunction=fArrPidResponseMaster->At(iresp);
303 if (responseFunction==0x0) continue;
304 TString responseName=responseFunction->GetName();
305
306 if (!reg.MatchB(responseName)) continue;
307
308 TObjArray *arr=reg.MatchS(responseName);
309 TString particleName=arr->At(1)->GetName();
310 delete arr;
311 if (particleName.IsNull()) continue;
312 if (particleName=="ALL") grAll=responseFunction;
313 else {
314 //find particle id
315 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec){
316 TString particle=AliPID::ParticleName(ispec);
317 particle.ToUpper();
318 if ( particle == particleName ){
319 fTPCResponse.SetResponseFunction((AliPID::EParticleType)ispec,responseFunction);
320 fTPCResponse.SetUseDatabase(kTRUE);
321 AliInfo(Form("Adding graph: %d - %s",ispec,responseFunction->GetName()));
322 break;
323 }
324 }
325 }
326 }
327
328 //set default response function to all particles which don't have a specific one
329 if (grAll){
330 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec){
331 if (!fTPCResponse.GetResponseFunction((AliPID::EParticleType)ispec)){
332 fTPCResponse.SetResponseFunction((AliPID::EParticleType)ispec,grAll);
333 AliInfo(Form("Adding graph: %d - %s",ispec,grAll->GetName()));
334 }
335 }
336 }
337 }
338
339 //
340 // Setup resolution parametrisation
341 //
342
343 //default
344 fTPCResponse.SetSigma(3.79301e-03, 2.21280e+04);
345
346 if (fRun>=122195){
347 fTPCResponse.SetSigma(2.30176e-02, 5.60422e+02);
348 }
23425eb2 349 if (fArrPidResponseMaster)
4ec8e76d 350 fResolutionCorrection=(TF1*)fArrPidResponseMaster->FindObject(Form("TF1_%s_ALL_%s_PASS%d_%s_SIGMA",datatype.Data(),period.Data(),fRecoPass,fBeamType.Data()));
351
352 if (fResolutionCorrection) AliInfo(Form("Setting multiplicity correction function: %s",fResolutionCorrection->GetName()));
353}
354