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(): TNamed()
36 // The Default constructor
42 //_________________________________________________________________________
43 AliTRDCalPIDLQ::AliTRDCalPIDLQ(const Text_t *name, const Text_t *title) : TNamed(name, title)
46 // The main constructor
52 //_____________________________________________________________________________
53 AliTRDCalPIDLQ::AliTRDCalPIDLQ(const AliTRDCalPIDLQ &c) : TNamed(c)
61 ((AliTRDCalPIDLQ &) c).Copy(*this);
64 //_________________________________________________________________________
65 AliTRDCalPIDLQ::~AliTRDCalPIDLQ()
74 //_________________________________________________________________________
75 void AliTRDCalPIDLQ::CleanUp()
91 delete[] fTrackMomentum;
96 //_____________________________________________________________________________
97 AliTRDCalPIDLQ &AliTRDCalPIDLQ::operator=(const AliTRDCalPIDLQ &c)
100 // Assignment operator
103 if (this != &c) ((AliTRDCalPIDLQ &) c).Copy(*this);
107 //_____________________________________________________________________________
108 void AliTRDCalPIDLQ::Copy(TObject &c) const
114 AliTRDCalPIDLQ& target = (AliTRDCalPIDLQ &) c;
118 target.fNMom = fNMom;
120 target.fTrackMomentum = new Double_t[fNMom];
121 for (Int_t i=0; i<fNMom; ++i)
122 target.fTrackMomentum[i] = fTrackMomentum[i];
124 target.fMeanChargeRatio = fMeanChargeRatio;
126 target.fNbins = fNbins;
127 target.fBinSize = fBinSize;
130 target.fHistdEdx = (TObjArray*) fHistdEdx->Clone();
133 target.fHistTimeBin = (TObjArray*) fHistTimeBin->Clone();
138 //_________________________________________________________________________
139 void AliTRDCalPIDLQ::Init()
143 fTrackMomentum = new Double_t[fNMom];
144 Double_t trackMomentum[11] = {0.6, 0.8, 1, 1.5, 2, 3, 4, 5, 6, 8, 10};
145 for (Int_t imom = 0; imom < 11; imom++)
146 fTrackMomentum[imom] = trackMomentum[imom];
148 fHistdEdx = new TObjArray(AliPID::kSPECIES * fNMom);
149 fHistdEdx->SetOwner();
150 fHistTimeBin = new TObjArray(AliPID::kSPECIES * fNMom);
151 fHistTimeBin->SetOwner();
153 // ADC Gain normalization
154 fMeanChargeRatio=1.0;
156 // Number of bins and bin size
161 //_________________________________________________________________________
162 Bool_t AliTRDCalPIDLQ::ReadData(Char_t *responseFile)
165 // Read the TRD dEdx histograms.
167 // Read histogram Root file
168 TFile *histFile = new TFile(responseFile, "READ");
169 if (!histFile || !histFile->IsOpen()) {
170 Error("AliTRDCalPIDLQ", "opening TRD histgram file %s failed", responseFile);
177 for (Int_t particle = 0; particle < AliPID::kSPECIES; ++particle)
179 Char_t* particleKey = "";
182 case AliPID::kElectron: particleKey = "EL"; break;
183 case AliPID::kPion: particleKey = "PI"; break;
184 case AliPID::kMuon: particleKey = "MU"; break;
185 case AliPID::kKaon: particleKey = "KA"; break;
186 case AliPID::kProton: particleKey = "PR"; break;
189 for (Int_t imom = 0; imom < fNMom; imom++)
191 sprintf(text, "h1dEdx%s%01d", particleKey, imom+1);
192 TH1F* hist = (TH1F*)histFile->Get(text)->Clone();
193 hist->Scale(1.0/hist->Integral());
194 fHistdEdx->AddAt(hist, GetHistID(particle, imom));
196 if (particle == AliPID::kElectron || particle == AliPID::kPion)
198 sprintf(text,"h1MaxTimBin%s%01d", particleKey, imom+1);
199 TH1F* hist = (TH1F*)histFile->Get(text)->Clone();
200 hist->Scale(1.0/hist->Integral());
201 fHistTimeBin->AddAt(hist, GetHistID(particle,imom));
209 // Number of bins and bin size
210 TH1F* hist = (TH1F*) fHistdEdx->At(GetHistID(AliPID::kPion, 1));
211 fNbins = hist->GetNbinsX();
212 fBinSize = hist->GetBinWidth(1);
217 //_________________________________________________________________________
218 Double_t AliTRDCalPIDLQ::GetMean(Int_t k, Int_t ip) const
221 // Gets mean of de/dx dist. of e
222 printf("Mean for particle = %s and momentum = %.2f is:\n", fpartName[k], fTrackMomentum[ip]);
223 if (k < 0 || k > AliPID::kSPECIES)
226 return ((TH1F*) fHistdEdx->At(GetHistID(k,ip)))->GetMean();
229 //_________________________________________________________________________
230 Double_t AliTRDCalPIDLQ::GetNormalization(Int_t k, Int_t ip) const
233 // Gets Normalization of de/dx dist. of e
235 printf("Normalization for particle = %s and momentum = %.2f is:\n",fpartName[k], fTrackMomentum[ip]);
236 if (k < 0 || k > AliPID::kSPECIES)
239 return ((TH1F*) fHistdEdx->At(GetHistID(k,ip)))->Integral();
242 //_________________________________________________________________________
243 TH1F* AliTRDCalPIDLQ::GetHistogram(Int_t k, Int_t ip) const
247 printf("Histogram for particle = %s and momentum = %.2f is:\n", fpartName[k], fTrackMomentum[ip]);
248 if (k < 0 || k > AliPID::kSPECIES)
251 return (TH1F*) fHistdEdx->At(GetHistID(k,ip));
254 //_________________________________________________________________________
255 Double_t AliTRDCalPIDLQ::GetProbability(Int_t k, Double_t mom, Double_t dedx1) const
258 // Gets the Probability of having dedx at a given momentum (mom)
259 // and particle type k (0 for e) and (2 for pi)
260 // from the precalculated de/dx distributions
262 Double_t dedx = dedx1/fMeanChargeRatio;
263 Int_t iEnBin= ((Int_t) (dedx/fBinSize+1));
264 if(iEnBin > fNbins) iEnBin = fNbins;
266 if (k < 0 || k > AliPID::kSPECIES)
275 if (mom<=fTrackMomentum[0])
277 hist1 = (TH1F*) fHistdEdx->At(GetHistID(k,1));
278 hist2 = (TH1F*) fHistdEdx->At(GetHistID(k,0));
279 mom1 = fTrackMomentum[1];
280 mom2 = fTrackMomentum[0];
284 if(mom>=fTrackMomentum[fNMom-1])
286 hist1 = (TH1F*) fHistdEdx->At(GetHistID(k,fNMom-1));
287 hist2 = (TH1F*) fHistdEdx->At(GetHistID(k,fNMom-2));
288 mom1 = fTrackMomentum[fNMom-1];
289 mom2 = fTrackMomentum[fNMom-2];
293 for (Int_t ip=1; ip<fNMom; ip++)
295 if ((fTrackMomentum[ip-1]<= mom) && (mom<fTrackMomentum[ip]))
297 hist1 = (TH1F*) fHistdEdx->At(GetHistID(k,ip));
298 hist2 = (TH1F*) fHistdEdx->At(GetHistID(k,ip-1));
299 mom1 = fTrackMomentum[ip];
300 mom2 = fTrackMomentum[ip-1];
304 Double_t slop = (hist1->GetBinContent(iEnBin) - hist2->GetBinContent(iEnBin)) / (mom1 - mom2);
305 return hist2->GetBinContent(iEnBin) + slop * (mom - mom2);
308 //_________________________________________________________________________
309 Double_t AliTRDCalPIDLQ::GetProbabilityT(Int_t k, Double_t mom, Int_t timbin) const
312 // Gets the Probability of having timbin at a given momentum (mom)
313 // and particle type k (0 for e) and (2 for pi)
314 // from the precalculated timbin distributions
318 Int_t iTBin=timbin+1;
320 // everything which is not electron counts as pion for time bin
321 if (k != AliPID::kElectron)
324 if (mom<=fTrackMomentum[0])
325 return ((TH1F*) fHistTimeBin->At(GetHistID(k,0)))->GetBinContent(iTBin);
327 if (mom>=fTrackMomentum[fNMom-1])
328 return ((TH1F*) fHistTimeBin->At(GetHistID(k,fNMom-1)))->GetBinContent(iTBin);
330 for (Int_t ip=1; ip<fNMom; ip++)
332 if ((fTrackMomentum[ip-1]<= mom) && (mom<fTrackMomentum[ip]))
334 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]);
335 // Linear Interpolation
336 return ((TH1F*) fHistTimeBin->At(GetHistID(k,ip-1)))->GetBinContent(iTBin) + slop * (mom - fTrackMomentum[ip-1]);