]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/Cal/AliTRDCalPIDLQ.cxx
Adding omega3pi task, swtich on PhysicsSelection for GammaConv, added option -use...
[u/mrichter/AliRoot.git] / TRD / Cal / AliTRDCalPIDLQ.cxx
CommitLineData
44dbae42 1/**************************************************************************
e7d6a389 2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
44dbae42 15
16/* $Id$ */
17
18//////////////////////////////////////////////////////////////////////////
19// //
20// Container for the distributions of dE/dx and the time bin of the //
21// max. cluster for electrons and pions //
22// //
23// Authors: //
24// Prashant Shukla <shukla@pi0.physi.uni-heidelberg.de> //
25// Alex Bercuci <a.bercuci@gsi.de> //
26// //
27//////////////////////////////////////////////////////////////////////////
28
44dbae42 29#include <TFile.h>
30#include <TROOT.h>
9ded305e 31#include <TSystem.h>
44dbae42 32
33#include "AliLog.h"
34#include "AliPID.h"
35
9ded305e 36#include "TKDPDF.h"
44dbae42 37#include "AliTRDCalPIDLQ.h"
38#include "AliTRDcalibDB.h"
39
40ClassImp(AliTRDCalPIDLQ)
41
2e32a5ae 42Float_t AliTRDCalPIDLQ::fgTrackSegLength[kNLength] = { 3.7, 3.9, 4.2, 5.0 };
44dbae42 43
44//_________________________________________________________________________
45AliTRDCalPIDLQ::AliTRDCalPIDLQ()
46 :AliTRDCalPID("pid", "LQ PID references for TRD")
47{
48 //
49 // The Default constructor
50 //
51
1fcc78b7 52 //Init();
44dbae42 53
54}
55
56//_________________________________________________________________________
57AliTRDCalPIDLQ::AliTRDCalPIDLQ(const Text_t *name, const Text_t *title)
58 :AliTRDCalPID(name,title)
59{
60 //
61 // The main constructor
62 //
63
64 Init();
65
66}
67
44dbae42 68
69//_________________________________________________________________________
70Bool_t AliTRDCalPIDLQ::LoadReferences(Char_t *refFile)
71{
72 //
73 // Read the TRD dEdx histograms.
74 //
75
9ded305e 76 if(gSystem->AccessPathName(refFile, kReadPermission)){
77 AliError(Form("File %s.root not readable", refFile));
78 return kFALSE;
e7d6a389 79 }
9ded305e 80 if(!TFile::Open(refFile)){
81 AliError(Form("File %s corrupted", refFile));
44dbae42 82 return kFALSE;
83 }
9ded305e 84 TObjArray *pdf(NULL);
85 if (!( pdf = dynamic_cast<TObjArray*>(gFile->Get("PDF_2DLQ")))) {
86 AliError("PID data not available");
87 return kFALSE;
44dbae42 88 }
9ded305e 89 fModel=(TObjArray*)pdf->Clone("PDF");
90 gFile->Close();
44dbae42 91 return kTRUE;
44dbae42 92}
93
94//_________________________________________________________________________
95TObject* AliTRDCalPIDLQ::GetModel(Int_t ip, Int_t iType, Int_t iplane) const // iType not needed
96{
97 //
98 // Returns one selected dEdx histogram
99 //
100
9ded305e 101 if (iType < 0 || iType >= AliPID::kSPECIES) return NULL;
102 if(ip<0 || ip>= kNMom ) return NULL;
44dbae42 103
9ded305e 104 AliDebug(2, Form("Retrive dEdx distribution for %s @ p=%5.2f [GeV/c].", AliPID::ParticleShortName(iType), fgTrackMomentum[ip]));
44dbae42 105 return fModel->At(GetModelID(ip, iType, iplane));
106}
107
108//_________________________________________________________________________
1fcc78b7 109Double_t AliTRDCalPIDLQ::GetProbability(Int_t spec, Float_t mom
110 , const Float_t * const dedx
111 , Float_t length, Int_t iplane) const
44dbae42 112{
113 //
e7d6a389 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
117 // layer
44dbae42 118 //
119
e7d6a389 120 if (spec < 0 || spec >= AliPID::kSPECIES) return 0.;
9ded305e 121 Double_t x[AliTRDCalPID::kNSlicesLQ];
122 if(!CookdEdx(dedx, x)) return 0.;
e7d6a389 123
e7d6a389 124 // find the interval in momentum and track segment length which applies for this data
9ded305e 125/* Int_t ilength = 1;
2e32a5ae 126 while(ilength<kNLength-1 && length>fgTrackSegLength[ilength]){
e7d6a389 127 ilength++;
9ded305e 128 }*/
e7d6a389 129 Int_t imom = 1;
2e32a5ae 130 while(imom<kNMom-1 && mom>fgTrackMomentum[imom]) imom++;
44dbae42 131
9ded305e 132 Double_t p[2], e[2], r;
133 TKDPDF *pdf(NULL);
134
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)));
138 fModel->ls();
e7d6a389 139 return 0.;
140 }
a4f67853 141 if(!pdf->GetSize()) pdf->Bootstrap();
9ded305e 142 pdf->Eval(x, r, e[0], kFALSE);
143 p[0]=TMath::Abs(r); // conversion from interpolation to PDF
144 AliDebug(2, Form("LQ=%6.3f+-%5.2f%% @ %4.1f[GeV/c]", p[0], 1.E2*e[0]/p[0], fgTrackMomentum[imom-1]));
145
146 if(!(pdf = dynamic_cast<TKDPDF*>(fModel->At(GetModelID(imom, spec, iplane))))){
147 AliError(Form("Ref data @ idx[%d] not found in DB.", GetModelID(imom, spec, iplane)));
148 fModel->ls();
149 return p[0];
e7d6a389 150 }
a4f67853 151 if(!pdf->GetSize()) pdf->Bootstrap();
9ded305e 152 pdf->Eval(x, r, e[1], kFALSE);
153 p[1]=TMath::Abs(r); // conversion from interpolation to PDF
154 AliDebug(2, Form("LQ=%6.3f+-%5.2f%% @ %4.1f[GeV/c]", p[1], 1.E2*e[1]/p[1], fgTrackMomentum[imom]));
e7d6a389 155
9ded305e 156 // return interpolation over momentum binning
157 if(mom < fgTrackMomentum[0]) return p[0];
158 else if(mom > fgTrackMomentum[kNMom-1]) return p[1];
159 else{
160 Double_t lmom[2] = {fgTrackMomentum[imom-1], fgTrackMomentum[imom]};
161 return p[0] + (p[1] - p[0])*(mom - lmom[0])/(lmom[1] - lmom[0]);
162 }
44dbae42 163}
164
165//_________________________________________________________________________
166void AliTRDCalPIDLQ::Init()
167{
9ded305e 168//
169// PID LQ list initialization
170//
44dbae42 171 fModel = new TObjArray(AliPID::kSPECIES * kNMom);
172 fModel -> SetOwner();
44dbae42 173}