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 //////////////////////////////////////////////////////////////////////////
37 #include "AliTRDCalPIDLQ.h"
38 #include "AliTRDcalibDB.h"
40 ClassImp(AliTRDCalPIDLQ)
42 Float_t AliTRDCalPIDLQ::fgTrackSegLength[kNLength] = { 3.7, 3.9, 4.2, 5.0 };
44 //_________________________________________________________________________
45 AliTRDCalPIDLQ::AliTRDCalPIDLQ()
46 :AliTRDCalPID("pid", "LQ PID references for TRD")
49 // The Default constructor
56 //_________________________________________________________________________
57 AliTRDCalPIDLQ::AliTRDCalPIDLQ(const Text_t *name, const Text_t *title)
58 :AliTRDCalPID(name,title)
61 // 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_2DLQ")))) {
86 AliError("PID data not available");
89 fModel=(TObjArray*)pdf->Clone("PDF");
94 //_________________________________________________________________________
95 TObject* AliTRDCalPIDLQ::GetModel(Int_t ip, Int_t iType, Int_t iplane) const // iType not needed
98 // Returns one selected dEdx histogram
101 if (iType < 0 || iType >= 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(iType), fgTrackMomentum[ip]));
105 return fModel->At(GetModelID(ip, iType, iplane));
108 //_________________________________________________________________________
109 Double_t AliTRDCalPIDLQ::GetProbability(Int_t spec, Float_t mom
110 , const Float_t * const dedx
111 , Float_t length, Int_t iplane) const
114 // Core function of AliTRDCalPID class for calculating the
115 // likelihood for species "spec" (see AliTRDtrack::kNspecie) of a
116 // given momentum "mom" and a given dE/dx (slice "dedx") yield per
120 if (spec < 0 || spec >= AliPID::kSPECIES) return 0.;
121 Double_t x[AliTRDCalPID::kNSlicesLQ];
122 if(!CookdEdx(dedx, x)) return 0.;
124 // find the interval in momentum and track segment length which applies for this data
125 /* Int_t ilength = 1;
126 while(ilength<kNLength-1 && length>fgTrackSegLength[ilength]){
130 while(imom<kNMom-1 && mom>fgTrackMomentum[imom]) imom++;
132 Double_t p[2], e[2], r;
135 AliDebug(2, Form("Looking for %s@p=%6.4f[GeV/c] dEdx={%7.2f %7.2f}[a.u.] l=%4.2f[cm].", AliPID::ParticleShortName(spec), mom, dedx[0], dedx[1], length));
136 if(!(pdf = dynamic_cast<TKDPDF*>(fModel->At(GetModelID(imom-1, spec, iplane))))) {
137 AliError(Form("Ref data @ idx[%d] not found in DB.", GetModelID(imom-1, spec, iplane)));
141 pdf->Eval(x, r, e[0], kFALSE);
142 p[0]=TMath::Abs(r); // conversion from interpolation to PDF
143 AliDebug(2, Form("LQ=%6.3f+-%5.2f%% @ %4.1f[GeV/c]", p[0], 1.E2*e[0]/p[0], fgTrackMomentum[imom-1]));
145 if(!(pdf = dynamic_cast<TKDPDF*>(fModel->At(GetModelID(imom, spec, iplane))))){
146 AliError(Form("Ref data @ idx[%d] not found in DB.", GetModelID(imom, spec, iplane)));
150 pdf->Eval(x, r, e[1], kFALSE);
151 p[1]=TMath::Abs(r); // conversion from interpolation to PDF
152 AliDebug(2, Form("LQ=%6.3f+-%5.2f%% @ %4.1f[GeV/c]", p[1], 1.E2*e[1]/p[1], fgTrackMomentum[imom]));
154 // return interpolation over momentum binning
155 if(mom < fgTrackMomentum[0]) return p[0];
156 else if(mom > fgTrackMomentum[kNMom-1]) return p[1];
158 Double_t lmom[2] = {fgTrackMomentum[imom-1], fgTrackMomentum[imom]};
159 return p[0] + (p[1] - p[0])*(mom - lmom[0])/(lmom[1] - lmom[0]);
163 //_________________________________________________________________________
164 void AliTRDCalPIDLQ::Init()
167 // PID LQ list initialization
169 fModel = new TObjArray(AliPID::kSPECIES * kNMom);
170 fModel -> SetOwner();