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 **************************************************************************/
18 //////////////////////////////////////////////////////////////////////////
20 // Container for the distributions of dE/dx and the time bin of the //
21 // max. cluster for electrons and pions //
24 // Prashant Shukla <shukla@pi0.physi.uni-heidelberg.de> //
25 // Alex Bercuci <a.bercuci@gsi.de> //
27 //////////////////////////////////////////////////////////////////////////
38 #include "AliTRDCalPIDLQ.h"
39 #include "AliTRDcalibDB.h"
41 ClassImp(AliTRDCalPIDLQ)
43 Float_t AliTRDCalPIDLQ::fgTrackSegLength[kNLength] = { 3.7, 3.9, 4.2, 5.0 };
45 //_________________________________________________________________________
46 AliTRDCalPIDLQ::AliTRDCalPIDLQ()
47 :AliTRDCalPID("pid", "LQ PID references for TRD")
50 // The Default constructor
57 //_________________________________________________________________________
58 AliTRDCalPIDLQ::AliTRDCalPIDLQ(const Text_t *name, const Text_t *title)
59 :AliTRDCalPID(name,title)
62 // The main constructor
69 //_________________________________________________________________________
70 Bool_t AliTRDCalPIDLQ::LoadReferences(Char_t *refFile)
73 // Read the TRD dEdx histograms.
76 if(gSystem->AccessPathName(refFile, kReadPermission)){
77 AliError(Form("File %s.root not readable", refFile));
80 if(!TFile::Open(refFile)){
81 AliError(Form("File %s corrupted", refFile));
85 if (!( pdf = dynamic_cast<TObjArray*>(gFile->Get("PDF_LQ")))) {
86 AliError("PID data not available");
89 fModel=(TObjArray*)pdf->Clone("PDF");
94 //_________________________________________________________________________
95 TObject* AliTRDCalPIDLQ::GetModel(Int_t ip, Int_t is, Int_t slices) const
98 // Returns one selected dEdx histogram
101 if (is < 0 || is >= AliPID::kSPECIES) return NULL;
102 if(ip<0 || ip>= kNMom ) return NULL;
104 AliDebug(2, Form("Retrive dEdx distribution for %s @ p=%5.2f [GeV/c].", AliPID::ParticleShortName(is), fgTrackMomentum[ip]));
105 return fModel->At(GetModelID(ip, is, slices));
108 //_________________________________________________________________________
109 Int_t AliTRDCalPIDLQ::GetNrefs()
111 // Returns the number of PDF distribution
112 return AliTRDCalPID::kNMom*AliPID::kSPECIES*2;
115 //_________________________________________________________________________
116 Double_t AliTRDCalPIDLQ::GetProbability(Int_t spec, Float_t mom
117 , const Float_t * const dedx
119 , Int_t slices) const
122 // Core function of AliTRDCalPID class for calculating the
123 // likelihood for species "spec" (see AliTRDtrack::kNspecie) of a
124 // given momentum "mom" and a given dE/dx (slice "dedx") yield per
128 if (spec < 0 || spec >= AliPID::kSPECIES) return 0.;
130 Bool_t k2D(slices==2);
131 Double_t x[]={0., 0.};
132 if(!CookdEdx(dedx, x, k2D)) return 0.;
134 // find the interval in momentum and track segment length which applies for this data
135 /* Int_t ilength = 1;
136 while(ilength<kNLength-1 && length>fgTrackSegLength[ilength]){
140 while(imom<kNMom-1 && mom>fgTrackMomentum[imom]) imom++;
142 Double_t p[2], e[2], r;
145 AliDebug(2, Form("Looking %cD for %s@p=%6.4f[GeV/c] log(dEdx)={%7.2f %7.2f}[a.u.] l=%4.2f[cm].", k2D?'2':'1', AliPID::ParticleShortName(spec), mom, x[0], x[1], length));
146 if(!(pdf = dynamic_cast<TKDPDF*>(fModel->At(GetModelID(imom-1, spec, slices))))) {
147 AliError(Form("%cD Ref data @ idx[%d] not found in DB.", k2D?'2':'1', GetModelID(imom-1, spec, slices)));
150 if(!pdf->GetSize()) pdf->Bootstrap();
151 pdf->Eval(x, r, e[0], kFALSE);
152 p[0]=TMath::Abs(r); // conversion from interpolation to PDF
153 AliDebug(2, Form("LQ=%6.3f+-%5.2f%% @ %4.1f[GeV/c]", p[0], 1.E2*e[0]/p[0], fgTrackMomentum[imom-1]));
155 if(!(pdf = dynamic_cast<TKDPDF*>(fModel->At(GetModelID(imom, spec, slices))))){
156 AliError(Form("%cD Ref data @ idx[%d] not found in DB.", k2D?'2':'1', GetModelID(imom, spec, slices)));
159 if(!pdf->GetSize()) pdf->Bootstrap();
160 pdf->Eval(x, r, e[1], kFALSE);
161 p[1]=TMath::Abs(r); // conversion from interpolation to PDF
162 AliDebug(2, Form("LQ=%6.3f+-%5.2f%% @ %4.1f[GeV/c]", p[1], 1.E2*e[1]/p[1], fgTrackMomentum[imom]));
164 // return interpolation over momentum binning
165 if(mom < fgTrackMomentum[0]) return p[0];
166 else if(mom > fgTrackMomentum[kNMom-1]) return p[1];
168 Double_t lmom[2] = {fgTrackMomentum[imom-1], fgTrackMomentum[imom]};
169 return p[0] + (p[1] - p[0])*(mom - lmom[0])/(lmom[1] - lmom[0]);
173 //_________________________________________________________________________
174 void AliTRDCalPIDLQ::Init()
177 // PID LQ list initialization
179 fModel = new TObjArray(AliPID::kSPECIES * kNMom * 2);