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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // Container for the distributions of dE/dx and the time bin of the //
20 // max. cluster for electrons and pions //
23 // Prashant Shukla <shukla@pi0.physi.uni-heidelberg.de> //
25 ///////////////////////////////////////////////////////////////////////////////
33 #include "AliTRDCalPIDLQ.h"
35 ClassImp(AliTRDCalPIDLQ)
37 Char_t* AliTRDCalPIDLQ::fpartName[AliPID::kSPECIES] = {"electron", "muon", "pion", "kaon", "proton"};
39 //_________________________________________________________________________
40 AliTRDCalPIDLQ::AliTRDCalPIDLQ()
51 // The Default constructor
56 //_________________________________________________________________________
57 AliTRDCalPIDLQ::AliTRDCalPIDLQ(const Text_t *name, const Text_t *title)
68 // The main constructor
75 //_____________________________________________________________________________
76 AliTRDCalPIDLQ::AliTRDCalPIDLQ(const AliTRDCalPIDLQ &c)
80 ,fMeanChargeRatio(c.fMeanChargeRatio)
90 AliTRDCalPIDLQ& target = (AliTRDCalPIDLQ &) c;
92 target.fTrackMomentum = new Double_t[fNMom];
93 for (Int_t i=0; i<fNMom; ++i) {
94 target.fTrackMomentum[i] = fTrackMomentum[i];
97 target.fHistdEdx = (TObjArray*) fHistdEdx->Clone();
101 target.fHistTimeBin = (TObjArray*) fHistTimeBin->Clone();
106 //_________________________________________________________________________
107 AliTRDCalPIDLQ::~AliTRDCalPIDLQ()
117 //_________________________________________________________________________
118 void AliTRDCalPIDLQ::CleanUp()
121 // Delets all newly created objects
134 if (fTrackMomentum) {
135 delete[] fTrackMomentum;
141 //_____________________________________________________________________________
142 AliTRDCalPIDLQ &AliTRDCalPIDLQ::operator=(const AliTRDCalPIDLQ &c)
145 // Assignment operator
148 if (this != &c) ((AliTRDCalPIDLQ &) c).Copy(*this);
153 //_____________________________________________________________________________
154 void AliTRDCalPIDLQ::Copy(TObject &c) const
160 AliTRDCalPIDLQ& target = (AliTRDCalPIDLQ &) c;
164 target.fNMom = fNMom;
165 target.fNbins = fNbins;
166 target.fBinSize = fBinSize;
167 target.fMeanChargeRatio = fMeanChargeRatio;
169 target.fTrackMomentum = new Double_t[fNMom];
170 for (Int_t i=0; i<fNMom; ++i) {
171 target.fTrackMomentum[i] = fTrackMomentum[i];
175 target.fHistdEdx = (TObjArray*) fHistdEdx->Clone();
178 target.fHistTimeBin = (TObjArray*) fHistTimeBin->Clone();
185 //_________________________________________________________________________
186 void AliTRDCalPIDLQ::Init()
192 const Int_t kNMom = 11;
195 fTrackMomentum = new Double_t[fNMom];
196 Double_t trackMomentum[kNMom] = { 0.6, 0.8, 1.0, 1.5, 2.0
197 , 3.0, 4.0, 5.0, 6.0, 8.0
199 for (Int_t imom = 0; imom < kNMom; imom++) {
200 fTrackMomentum[imom] = trackMomentum[imom];
203 fHistdEdx = new TObjArray(AliPID::kSPECIES * fNMom);
204 fHistdEdx->SetOwner();
205 fHistTimeBin = new TObjArray(AliPID::kSPECIES * fNMom);
206 fHistTimeBin->SetOwner();
208 // ADC Gain normalization
209 fMeanChargeRatio = 1.0;
211 // Number of bins and bin size
217 //_________________________________________________________________________
218 Bool_t AliTRDCalPIDLQ::ReadData(Char_t *responseFile)
221 // Read the TRD dEdx histograms.
224 // Read histogram Root file
225 TFile *histFile = new TFile(responseFile, "READ");
226 if (!histFile || !histFile->IsOpen()) {
227 AliError(Form("Opening TRD histgram file %s failed", responseFile));
234 for (Int_t particle = 0; particle < AliPID::kSPECIES; ++particle)
236 Char_t* particleKey = "";
239 case AliPID::kElectron: particleKey = "EL"; break;
240 case AliPID::kPion: particleKey = "PI"; break;
241 case AliPID::kMuon: particleKey = "MU"; break;
242 case AliPID::kKaon: particleKey = "KA"; break;
243 case AliPID::kProton: particleKey = "PR"; break;
246 for (Int_t imom = 0; imom < fNMom; imom++)
248 sprintf(text, "h1dEdx%s%01d", particleKey, imom+1);
249 TH1F* hist = (TH1F*)histFile->Get(text)->Clone();
250 hist->Scale(1.0/hist->Integral());
251 fHistdEdx->AddAt(hist, GetHistID(particle, imom));
253 if (particle == AliPID::kElectron || particle == AliPID::kPion)
255 sprintf(text,"h1MaxTimBin%s%01d", particleKey, imom+1);
256 TH1F* hist = (TH1F*)histFile->Get(text)->Clone();
257 hist->Scale(1.0/hist->Integral());
258 fHistTimeBin->AddAt(hist, GetHistID(particle,imom));
266 // Number of bins and bin size
267 TH1F* hist = (TH1F*) fHistdEdx->At(GetHistID(AliPID::kPion, 1));
268 fNbins = hist->GetNbinsX();
269 fBinSize = hist->GetBinWidth(1);
275 //_________________________________________________________________________
276 Double_t AliTRDCalPIDLQ::GetMean(Int_t k, Int_t ip) const
279 // Gets mean of de/dx dist. of e
282 AliInfo(Form("Mean for particle = %s and momentum = %.2f is:\n"
284 ,fTrackMomentum[ip]));
285 if (k < 0 || k > AliPID::kSPECIES) {
289 return ((TH1F*) fHistdEdx->At(GetHistID(k,ip)))->GetMean();
293 //_________________________________________________________________________
294 Double_t AliTRDCalPIDLQ::GetNormalization(Int_t k, Int_t ip) const
297 // Gets Normalization of de/dx dist. of e
300 AliInfo(Form("Normalization for particle = %s and momentum = %.2f is:\n"
302 ,fTrackMomentum[ip]));
303 if (k < 0 || k > AliPID::kSPECIES) {
307 return ((TH1F*) fHistdEdx->At(GetHistID(k,ip)))->Integral();
311 //_________________________________________________________________________
312 TH1F* AliTRDCalPIDLQ::GetHistogram(Int_t k, Int_t ip) const
315 // Returns one selected dEdx histogram
318 AliInfo(Form("Histogram for particle = %s and momentum = %.2f is:\n"
320 ,fTrackMomentum[ip]));
321 if (k < 0 || k > AliPID::kSPECIES) {
325 return (TH1F*) fHistdEdx->At(GetHistID(k,ip));
329 //_________________________________________________________________________
330 TH1F* AliTRDCalPIDLQ::GetHistogramT(Int_t k, Int_t ip) const
333 // Returns one selected time bin max histogram
336 AliInfo(Form("Histogram for particle = %s and momentum = %.2f is:\n"
338 ,fTrackMomentum[ip]));
339 if (k < 0 || k > AliPID::kSPECIES)
342 return (TH1F*) fHistTimeBin->At(GetHistID(k,ip));
346 //_________________________________________________________________________
347 Double_t AliTRDCalPIDLQ::GetProbability(Int_t k, Double_t mom, Double_t dedx1) const
350 // Gets the Probability of having dedx at a given momentum (mom)
351 // and particle type k (0 for e) and (2 for pi)
352 // from the precalculated de/dx distributions
355 Double_t dedx = dedx1/fMeanChargeRatio;
356 Int_t iEnBin = ((Int_t) (dedx/fBinSize+1));
357 if(iEnBin > fNbins) iEnBin = fNbins;
359 if (k < 0 || k > AliPID::kSPECIES) {
369 if (mom<=fTrackMomentum[0]) {
370 hist1 = (TH1F*) fHistdEdx->At(GetHistID(k,1));
371 hist2 = (TH1F*) fHistdEdx->At(GetHistID(k,0));
372 mom1 = fTrackMomentum[1];
373 mom2 = fTrackMomentum[0];
377 if(mom>=fTrackMomentum[fNMom-1]) {
378 hist2 = (TH1F*) fHistdEdx->At(GetHistID(k,fNMom-1));
379 hist1 = (TH1F*) fHistdEdx->At(GetHistID(k,fNMom-2));
380 mom2 = fTrackMomentum[fNMom-1];
381 mom1 = fTrackMomentum[fNMom-2];
385 for (Int_t ip=1; ip<fNMom; ip++) {
386 if ((fTrackMomentum[ip-1]<= mom) && (mom<fTrackMomentum[ip])) {
387 hist1 = (TH1F*) fHistdEdx->At(GetHistID(k,ip));
388 hist2 = (TH1F*) fHistdEdx->At(GetHistID(k,ip-1));
389 mom1 = fTrackMomentum[ip];
390 mom2 = fTrackMomentum[ip-1];
394 Double_t slop = (hist1->GetBinContent(iEnBin) - hist2->GetBinContent(iEnBin))
396 return hist2->GetBinContent(iEnBin) + slop * (mom - mom2);
400 //_________________________________________________________________________
401 Double_t AliTRDCalPIDLQ::GetProbabilityT(Int_t k, Double_t mom, Int_t timbin) const
404 // Gets the Probability of having timbin at a given momentum (mom)
405 // and particle type k (0 for e) and (2 for pi)
406 // from the precalculated timbin distributions
413 Int_t iTBin = timbin+1;
415 // Everything which is not an electron counts as a pion for time bin max
416 if (k != AliPID::kElectron) {
420 if (mom<=fTrackMomentum[0]) {
421 return ((TH1F*) fHistTimeBin->At(GetHistID(k,0)))->GetBinContent(iTBin);
423 if (mom>=fTrackMomentum[fNMom-1]) {
424 return ((TH1F*) fHistTimeBin->At(GetHistID(k,fNMom-1)))->GetBinContent(iTBin);
427 for (Int_t ip=1; ip<fNMom; ip++) {
428 if ((fTrackMomentum[ip-1]<= mom) && (mom<fTrackMomentum[ip])) {
429 Double_t slop = (((TH1F*) fHistTimeBin->At(GetHistID(k,ip)))->GetBinContent(iTBin)
430 - ((TH1F*) fHistTimeBin->At(GetHistID(k,ip-1)))->GetBinContent(iTBin))
431 / (fTrackMomentum[ip] - fTrackMomentum[ip-1]);
432 // Linear interpolation
433 return ((TH1F*) fHistTimeBin->At(GetHistID(k,ip-1)))->GetBinContent(iTBin)
434 + slop * (mom - fTrackMomentum[ip-1]);