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 Revision 1.2.8.2 2002/07/24 10:09:31 alibrary
21 Revision 1.2.8.1 2002/06/10 15:28:58 hristov
24 Revision 1.4 2002/03/28 15:44:55 cblume
25 Remove const from GetIndex()
27 Revision 1.3 2002/03/28 14:59:07 cblume
30 Revision 1.4 2002/03/28 15:44:55 cblume
31 Remove const from GetIndex()
33 Revision 1.3 2002/03/28 14:59:07 cblume
36 Revision 1.2 2001/11/07 11:04:22 hristov
37 Minor corrections needed on Sun (arrays with undefined size created by new, inline decration removed when the body was hot in the header file)
39 Revision 1.1 2001/11/06 17:19:41 cblume
40 Add detailed geometry and simple simulator
44 ///////////////////////////////////////////////////////////////////////////////
46 // The TRD particle identification class //
48 // Its main purposes are: //
49 // - Creation and bookkeeping of the propability distributions //
50 // - Assignment of a e/pi propability to a given track based on //
53 ///////////////////////////////////////////////////////////////////////////////
60 #include <TObjArray.h>
63 #include <TParticle.h>
67 #include "AliTRDpidLQ.h"
68 #include "AliTRDcluster.h"
69 #include "AliTRDtrack.h"
70 #include "AliTRDtracker.h"
71 #include "AliTRDgeometry.h"
75 //_____________________________________________________________________________
76 AliTRDpidLQ::AliTRDpidLQ():AliTRDpid()
79 // AliTRDpidLQ default constructor
98 //_____________________________________________________________________________
99 AliTRDpidLQ::AliTRDpidLQ(const char* name, const char* title)
100 :AliTRDpid(name,title)
103 // AliTRDpidLQ constructor
121 //_____________________________________________________________________________
122 AliTRDpidLQ::AliTRDpidLQ(const AliTRDpidLQ &p)
125 // AliTRDpidLQ copy constructor
128 ((AliTRDpidLQ &) p).Copy(*this);
132 //_____________________________________________________________________________
133 AliTRDpidLQ::~AliTRDpidLQ()
136 // AliTRDpidLQ destructor
146 //_____________________________________________________________________________
147 AliTRDpidLQ &AliTRDpidLQ::operator=(const AliTRDpidLQ &p)
150 // Assignment operator
153 if (this != &p) ((AliTRDpidLQ &) p).Copy(*this);
158 //_____________________________________________________________________________
159 void AliTRDpidLQ::Copy(TObject &p)
165 fHist->Copy(*((AliTRDpidLQ &) p).fHist);
167 ((AliTRDpidLQ &) p).fNMom = fNMom;
168 ((AliTRDpidLQ &) p).fMinMom = fMinMom;
169 ((AliTRDpidLQ &) p).fMaxMom = fMaxMom;
170 ((AliTRDpidLQ &) p).fWidMom = fWidMom;
171 ((AliTRDpidLQ &) p).fChargeMin = fChargeMin;
172 ((AliTRDpidLQ &) p).fNClusterMin = fNClusterMin;
173 ((AliTRDpidLQ &) p).fNLh = fNLh;
174 ((AliTRDpidLQ &) p).fMinLh = fMinLh;
175 ((AliTRDpidLQ &) p).fMaxLh = fMaxLh;
181 //_____________________________________________________________________________
182 Bool_t AliTRDpidLQ::Init()
185 // Initializes the PID object
199 //_____________________________________________________________________________
200 Bool_t AliTRDpidLQ::AssignLikelihood(AliTRDtrack *t)
203 // Assigns the e / pi likelihood to a given track
206 const Int_t kNpla = AliTRDgeometry::Nplan();
207 Float_t * charge = new Float_t[kNpla];
208 Int_t * nCluster = new Int_t[kNpla];
222 t->SetLikelihoodElectron(-1.);
223 if (isnan(t->GetP())) return kFALSE;
224 Float_t mom = t->GetP();
226 // Calculate the total charge in each plane
227 if (!SumCharge(t,charge,nCluster)) return kFALSE;
229 indexEl = GetIndex(mom,kElectron);
230 indexPi = GetIndex(mom,kPion);
231 if ((indexEl > -1) && (indexPi > -1)) {
232 hTmpEl = (TH1F *) fHist->UncheckedAt(indexEl);
233 hTmpPi = (TH1F *) fHist->UncheckedAt(indexPi);
234 for (Int_t ipla = 0; ipla < kNpla; ipla++) {
235 Float_t chargePlane = charge[ipla];
236 Int_t nClusterPlane = nCluster[ipla];
237 if ((chargePlane > fChargeMin) &&
238 (nClusterPlane > fNClusterMin)){
239 Float_t chargeNorm = chargePlane / ((Float_t) nClusterPlane);
240 if (chargeNorm < fMaxLh) {
241 Int_t ibinEl = hTmpEl->FindBin(chargeNorm);
242 Float_t pElPlane = hTmpEl->GetBinContent(ibinEl);
244 pEl = pEl * pElPlane;
246 Int_t ibinPi = hTmpPi->FindBin(chargeNorm);
247 Float_t pPiPlane = hTmpPi->GetBinContent(ibinPi);
249 pPi = pPi * pPiPlane;
251 // printf(" ipla = %d, nCluster = %d, charge = %f\n"
252 // ,ipla,nClusterPlane,chargeNorm);
253 // printf("electron: pElPlane = %f, ibinEl = %d, pEl = %f\n"
254 // ,pElPlane,ibinEl,pEl);
255 // printf(" pion: pPiPlane = %f, ibinPi = %d, pPi = %f\n"
256 // ,pPiPlane,ibinPi,pPi);
276 // printf("---- mom = %f, lhEl = %f, lhPi = %f\n",mom,lhEl,lhPi);
278 // Assign the likelihoods
279 t->SetLikelihoodElectron(lhEl);
287 //_____________________________________________________________________________
288 Bool_t AliTRDpidLQ::CreateHistograms(const Int_t nmom
289 , const Float_t minmom
290 , const Float_t maxmom)
293 // Creates the histograms
302 fWidMom = (maxmom - minmom) / ((Float_t) nmom);
304 fHist = new TObjArray(kNpid * nmom);
305 for (imom = 0; imom < nmom; imom++) {
306 for (ipid = 0; ipid < kNpid; ipid++) {
308 Int_t index = GetIndex(imom,ipid);
311 sprintf(name ,"hQ%03d",index);
312 if (ipid == kElectron) {
313 sprintf(title,"Q electron p-bin %03d",imom);
316 sprintf(title,"Q pion p-bin %03d",imom);
318 TH1F *hTmp = new TH1F(name,title,fNLh,fMinLh,fMaxLh);
319 fHist->AddAt(hTmp,index);
328 // //_____________________________________________________________________________
329 // Bool_t AliTRDpidLQ::FillSpectra(const AliTRDtrack *t)
332 // // Fills the energy loss distributions with track <t>.
335 // Bool_t status = kTRUE;
337 // if (isnan(t->GetP())) return kFALSE;
339 // Float_t mom = t->GetP();
340 // Int_t ipid = MCpid(t);
341 // TH1F *hTmp = NULL;
342 // AliTRDcluster *cluster = NULL;
344 // Int_t index = GetIndex(mom,ipid);
346 // hTmp = (TH1F *) fHist->UncheckedAt(index);
347 // // Loop through all clusters associated to this track
348 // Int_t nClus = t->GetNclusters();
349 // for (Int_t iClus = 0; iClus < nClus; iClus++) {
351 // Int_t idxClus = t->GetClusterIndex(iClus);
352 // if (!(cluster = (AliTRDcluster *) fClusterArray->UncheckedAt(idxClus))) {
356 // hTmp->Fill(cluster->GetQ());
364 //_____________________________________________________________________________
365 Bool_t AliTRDpidLQ::FillSpectra(const AliTRDtrack *t)
368 // Fills the energy loss distributions with track <t>.
371 const Int_t kNpla = AliTRDgeometry::Nplan();
373 if (isnan(t->GetP())) return kFALSE;
375 Float_t * charge = new Float_t[kNpla];
376 Int_t * nCluster = new Int_t[kNpla];
377 Float_t mom = t->GetP();
378 Int_t ipid = MCpid(t);
381 if (!SumCharge(t,charge,nCluster)) {
387 Int_t index = GetIndex(mom,ipid);
389 hTmp = (TH1F *) fHist->UncheckedAt(index);
390 for (Int_t ipla = 0; ipla < kNpla; ipla++) {
391 if ((charge[ipla] > fChargeMin) &&
392 (nCluster[ipla] > fNClusterMin)){
393 hTmp->Fill(charge[ipla] / ((Float_t) nCluster[ipla]));
404 //_____________________________________________________________________________
405 Int_t AliTRDpidLQ::GetIndex(const AliTRDtrack *t)
408 // Returns the histogram index
411 if (isnan(t->GetP())) return -1;
412 Float_t mom = t->GetP();
413 Int_t ipid = MCpid(t);
415 return GetIndex(mom,ipid);
419 //_____________________________________________________________________________
420 Int_t AliTRDpidLQ::GetIndex(const Float_t mom, const Int_t ipid)
423 // Returns the histogram index
426 if ((mom < fMinMom) || (mom > fMaxMom)) return -1;
427 Int_t imom = ((Int_t) ((mom - fMinMom) / fWidMom));
428 return GetIndex(imom,ipid);
432 //_____________________________________________________________________________
433 Int_t AliTRDpidLQ::GetIndex(const Int_t imom, const Int_t ipid)
436 // Returns the histogram index
439 if ((ipid < 0) || (ipid >= kNpid)) return -1;
440 return imom * kNpid + ipid;