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 //-----------------------------------------------------------------
17 // Class for dE/dx and Time Bin of Max. Cluster for Electrons and
19 // It is instantiated in class AliTRDpidESD for particle identification
21 // Prashant Shukla <shukla@pi0.physi.uni-heidelberg.de>
22 //-----------------------------------------------------------------
24 #include "AliTRDCalPIDLQ.h"
28 ClassImp(AliTRDCalPIDLQ)
30 Char_t* AliTRDCalPIDLQ::fpartName[AliPID::kSPECIES] = {"electron", "muon", "pion", "kaon", "proton"};
32 //_________________________________________________________________________
33 AliTRDCalPIDLQ::AliTRDCalPIDLQ():
44 // The Default constructor
49 //_________________________________________________________________________
50 AliTRDCalPIDLQ::AliTRDCalPIDLQ(const Text_t *name, const Text_t *title) : TNamed(name, title)
53 // The main constructor
59 //_____________________________________________________________________________
60 AliTRDCalPIDLQ::AliTRDCalPIDLQ(const AliTRDCalPIDLQ &c) : TNamed(c)
68 ((AliTRDCalPIDLQ &) c).Copy(*this);
71 //_________________________________________________________________________
72 AliTRDCalPIDLQ::~AliTRDCalPIDLQ()
81 //_________________________________________________________________________
82 void AliTRDCalPIDLQ::CleanUp()
98 delete[] fTrackMomentum;
103 //_____________________________________________________________________________
104 AliTRDCalPIDLQ &AliTRDCalPIDLQ::operator=(const AliTRDCalPIDLQ &c)
107 // Assignment operator
110 if (this != &c) ((AliTRDCalPIDLQ &) c).Copy(*this);
114 //_____________________________________________________________________________
115 void AliTRDCalPIDLQ::Copy(TObject &c) const
121 AliTRDCalPIDLQ& target = (AliTRDCalPIDLQ &) c;
125 target.fNMom = fNMom;
127 target.fTrackMomentum = new Double_t[fNMom];
128 for (Int_t i=0; i<fNMom; ++i)
129 target.fTrackMomentum[i] = fTrackMomentum[i];
131 target.fMeanChargeRatio = fMeanChargeRatio;
133 target.fNbins = fNbins;
134 target.fBinSize = fBinSize;
137 target.fHistdEdx = (TObjArray*) fHistdEdx->Clone();
140 target.fHistTimeBin = (TObjArray*) fHistTimeBin->Clone();
145 //_________________________________________________________________________
146 void AliTRDCalPIDLQ::Init()
150 fTrackMomentum = new Double_t[fNMom];
151 Double_t trackMomentum[11] = {0.6, 0.8, 1, 1.5, 2, 3, 4, 5, 6, 8, 10};
152 for (Int_t imom = 0; imom < 11; imom++)
153 fTrackMomentum[imom] = trackMomentum[imom];
155 fHistdEdx = new TObjArray(AliPID::kSPECIES * fNMom);
156 fHistdEdx->SetOwner();
157 fHistTimeBin = new TObjArray(AliPID::kSPECIES * fNMom);
158 fHistTimeBin->SetOwner();
160 // ADC Gain normalization
161 fMeanChargeRatio=1.0;
163 // Number of bins and bin size
168 //_________________________________________________________________________
169 Bool_t AliTRDCalPIDLQ::ReadData(Char_t *responseFile)
172 // Read the TRD dEdx histograms.
174 // Read histogram Root file
175 TFile *histFile = new TFile(responseFile, "READ");
176 if (!histFile || !histFile->IsOpen()) {
177 Error("AliTRDCalPIDLQ", "opening TRD histgram file %s failed", responseFile);
184 for (Int_t particle = 0; particle < AliPID::kSPECIES; ++particle)
186 Char_t* particleKey = "";
189 case AliPID::kElectron: particleKey = "EL"; break;
190 case AliPID::kPion: particleKey = "PI"; break;
191 case AliPID::kMuon: particleKey = "MU"; break;
192 case AliPID::kKaon: particleKey = "KA"; break;
193 case AliPID::kProton: particleKey = "PR"; break;
196 for (Int_t imom = 0; imom < fNMom; imom++)
198 sprintf(text, "h1dEdx%s%01d", particleKey, imom+1);
199 TH1F* hist = (TH1F*)histFile->Get(text)->Clone();
200 hist->Scale(1.0/hist->Integral());
201 fHistdEdx->AddAt(hist, GetHistID(particle, imom));
203 if (particle == AliPID::kElectron || particle == AliPID::kPion)
205 sprintf(text,"h1MaxTimBin%s%01d", particleKey, imom+1);
206 TH1F* hist = (TH1F*)histFile->Get(text)->Clone();
207 hist->Scale(1.0/hist->Integral());
208 fHistTimeBin->AddAt(hist, GetHistID(particle,imom));
216 // Number of bins and bin size
217 TH1F* hist = (TH1F*) fHistdEdx->At(GetHistID(AliPID::kPion, 1));
218 fNbins = hist->GetNbinsX();
219 fBinSize = hist->GetBinWidth(1);
224 //_________________________________________________________________________
225 Double_t AliTRDCalPIDLQ::GetMean(Int_t k, Int_t ip) const
228 // Gets mean of de/dx dist. of e
229 printf("Mean for particle = %s and momentum = %.2f is:\n", fpartName[k], fTrackMomentum[ip]);
230 if (k < 0 || k > AliPID::kSPECIES)
233 return ((TH1F*) fHistdEdx->At(GetHistID(k,ip)))->GetMean();
236 //_________________________________________________________________________
237 Double_t AliTRDCalPIDLQ::GetNormalization(Int_t k, Int_t ip) const
240 // Gets Normalization of de/dx dist. of e
242 printf("Normalization for particle = %s and momentum = %.2f is:\n",fpartName[k], fTrackMomentum[ip]);
243 if (k < 0 || k > AliPID::kSPECIES)
246 return ((TH1F*) fHistdEdx->At(GetHistID(k,ip)))->Integral();
249 //_________________________________________________________________________
250 TH1F* AliTRDCalPIDLQ::GetHistogram(Int_t k, Int_t ip) const
254 printf("Histogram for particle = %s and momentum = %.2f is:\n", fpartName[k], fTrackMomentum[ip]);
255 if (k < 0 || k > AliPID::kSPECIES)
258 return (TH1F*) fHistdEdx->At(GetHistID(k,ip));
261 //_________________________________________________________________________
262 Double_t AliTRDCalPIDLQ::GetProbability(Int_t k, Double_t mom, Double_t dedx1) const
265 // Gets the Probability of having dedx at a given momentum (mom)
266 // and particle type k (0 for e) and (2 for pi)
267 // from the precalculated de/dx distributions
269 Double_t dedx = dedx1/fMeanChargeRatio;
270 Int_t iEnBin= ((Int_t) (dedx/fBinSize+1));
271 if(iEnBin > fNbins) iEnBin = fNbins;
273 if (k < 0 || k > AliPID::kSPECIES)
282 if (mom<=fTrackMomentum[0])
284 hist1 = (TH1F*) fHistdEdx->At(GetHistID(k,1));
285 hist2 = (TH1F*) fHistdEdx->At(GetHistID(k,0));
286 mom1 = fTrackMomentum[1];
287 mom2 = fTrackMomentum[0];
291 if(mom>=fTrackMomentum[fNMom-1])
293 hist2 = (TH1F*) fHistdEdx->At(GetHistID(k,fNMom-1));
294 hist1 = (TH1F*) fHistdEdx->At(GetHistID(k,fNMom-2));
295 mom2 = fTrackMomentum[fNMom-1];
296 mom1 = fTrackMomentum[fNMom-2];
300 for (Int_t ip=1; ip<fNMom; ip++)
302 if ((fTrackMomentum[ip-1]<= mom) && (mom<fTrackMomentum[ip]))
304 hist1 = (TH1F*) fHistdEdx->At(GetHistID(k,ip));
305 hist2 = (TH1F*) fHistdEdx->At(GetHistID(k,ip-1));
306 mom1 = fTrackMomentum[ip];
307 mom2 = fTrackMomentum[ip-1];
311 Double_t slop = (hist1->GetBinContent(iEnBin) - hist2->GetBinContent(iEnBin)) / (mom1 - mom2);
312 return hist2->GetBinContent(iEnBin) + slop * (mom - mom2);
315 //_________________________________________________________________________
316 Double_t AliTRDCalPIDLQ::GetProbabilityT(Int_t k, Double_t mom, Int_t timbin) const
319 // Gets the Probability of having timbin at a given momentum (mom)
320 // and particle type k (0 for e) and (2 for pi)
321 // from the precalculated timbin distributions
325 Int_t iTBin=timbin+1;
327 // everything which is not electron counts as pion for time bin
328 if (k != AliPID::kElectron)
331 if (mom<=fTrackMomentum[0])
332 return ((TH1F*) fHistTimeBin->At(GetHistID(k,0)))->GetBinContent(iTBin);
334 if (mom>=fTrackMomentum[fNMom-1])
335 return ((TH1F*) fHistTimeBin->At(GetHistID(k,fNMom-1)))->GetBinContent(iTBin);
337 for (Int_t ip=1; ip<fNMom; ip++)
339 if ((fTrackMomentum[ip-1]<= mom) && (mom<fTrackMomentum[ip]))
341 Double_t slop=(((TH1F*) fHistTimeBin->At(GetHistID(k,ip)))->GetBinContent(iTBin) - ((TH1F*) fHistTimeBin->At(GetHistID(k,ip-1)))->GetBinContent(iTBin)) / (fTrackMomentum[ip] - fTrackMomentum[ip-1]);
342 // Linear Interpolation
343 return ((TH1F*) fHistTimeBin->At(GetHistID(k,ip-1)))->GetBinContent(iTBin) + slop * (mom - fTrackMomentum[ip-1]);