Rename AliTRDCalPIDLQ
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Jul 2007 12:22:55 +0000 (12:22 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Jul 2007 12:22:55 +0000 (12:22 +0000)
12 files changed:
TRD/AliTRDcalibDB.cxx
TRD/AliTRDcalibDB.h
TRD/AliTRDgtuTrack.cxx
TRD/AliTRDpidESD.cxx
TRD/AliTRDtrack.cxx
TRD/AliTRDtrack.h
TRD/AliTRDtrigger.cxx
TRD/Cal/AliTRDCalPID.cxx [new file with mode: 0644]
TRD/Cal/AliTRDCalPID.h [new file with mode: 0644]
TRD/Cal/AliTRDCalPIDRefMaker.cxx
TRD/TRDbaseLinkDef.h
TRD/libTRDbase.pkg

index 2d03ac5..2f3e1f0 100644 (file)
@@ -45,7 +45,7 @@
 #include "Cal/AliTRDCalPad.h"
 #include "Cal/AliTRDCalDet.h"
 #include "Cal/AliTRDCalFEE.h"
-#include "Cal/AliTRDCalPIDLQ.h"
+#include "Cal/AliTRDCalPID.h"
 #include "Cal/AliTRDCalMonitoring.h"
 #include "Cal/AliTRDCalChamberStatus.h"
 #include "Cal/AliTRDCalPadStatus.h"
@@ -798,13 +798,13 @@ Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
 }
 
 //_____________________________________________________________________________
-const AliTRDCalPIDLQ *AliTRDcalibDB::GetPIDLQObject()
+const AliTRDCalPID *AliTRDcalibDB::GetPIDLQObject()
 {
   //
   // Returns the object storing the distributions for PID with likelihood
   //
 
-  return dynamic_cast<const AliTRDCalPIDLQ *> 
+  return dynamic_cast<const AliTRDCalPID *> 
          (GetCachedCDBObject(kIDPIDLQ));
 
 }
index 5a1799d..a153728 100644 (file)
@@ -15,7 +15,7 @@
 
 class AliCDBEntry;
 
-class AliTRDCalPIDLQ;
+class AliTRDCalPID;
 class AliTRDCalMonitoring;
 class AliTRDCalROC;
 class AliTRDCalDet;
@@ -66,7 +66,7 @@ class AliTRDcalibDB : public TObject {
   Bool_t                     IsChamberMasked(Int_t det);
 
   const AliTRDCalMonitoring *GetMonitoringObject();
-  const AliTRDCalPIDLQ      *GetPIDLQObject();
+  const AliTRDCalPID        *GetPIDLQObject();
 
   // Related functions, these depend on calibration data
   static Float_t             GetOmegaTau(Float_t vdrift, Float_t bz);
index e08f09b..abbb809 100644 (file)
@@ -33,7 +33,7 @@
 #include "AliTRDcalibDB.h"
 #include "AliTRDltuTracklet.h"
 #include "AliTRDgtuTrack.h"
-#include "Cal/AliTRDCalPIDLQ.h"
+#include "Cal/AliTRDCalPID.h"
 
 ClassImp(AliTRDgtuTrack)
 
@@ -390,7 +390,7 @@ void AliTRDgtuTrack::MakePID()
     AliError("No instance of AliTRDcalibDB.");
     return;  
   }
-  const AliTRDCalPIDLQ *pd = calibration->GetPIDLQObject();
+  const AliTRDCalPID *pd = calibration->GetPIDLQObject();
   
   AliTRDltuTracklet *trk;
   Int_t   nTracklets = GetNtracklets();
index 1744285..87b15a7 100644 (file)
@@ -41,7 +41,7 @@
 #include "AliTRDcalibDB.h"
 #include "AliRun.h"
 #include "AliTRDtrack.h"
-#include "Cal/AliTRDCalPIDLQ.h"
+#include "Cal/AliTRDCalPID.h"
 
 
 ClassImp(AliTRDpidESD)
@@ -116,7 +116,7 @@ Int_t AliTRDpidESD::MakePID(AliESDEvent *event)
   // The method produces probabilities based on the charge
   // and the position of the maximum time bin in each layer.
   // The dE/dx information can be used as global charge or 2 to 3
-  // slices. Check AliTRDCalPIDLQ and AliTRDCalPIDLQRef for the actual
+  // slices. Check AliTRDCalPID and AliTRDCalPIDRefMaker for the actual
   // implementation.
   //
   // Author
@@ -130,10 +130,10 @@ Int_t AliTRDpidESD::MakePID(AliESDEvent *event)
        }
        
        // Retrieve the CDB container class with the probability distributions
-       const AliTRDCalPIDLQ *pd = calibration->GetPIDLQObject();
+       const AliTRDCalPID *pd = calibration->GetPIDLQObject();
        if (!pd) {
                AliErrorGeneral("AliTRDpidESD::MakePID()"
-                       ,"No access to AliTRDCalPIDLQ");
+                       ,"No access to AliTRDCalPID");
                return -1;
        }
 
index d53b358..ab47ca7 100644 (file)
@@ -30,7 +30,7 @@
 
 // A. Bercuci - used for PID calculations
 #include "AliTRDcalibDB.h"
-#include "Cal/AliTRDCalPIDLQ.h"
+#include "Cal/AliTRDCalPID.h"
 
 ClassImp(AliTRDtrack)
 
@@ -578,7 +578,7 @@ Int_t AliTRDtrack::CookPID(AliESDtrack *esd)
   // The method produces probabilities based on the charge
   // and the position of the maximum time bin in each layer.
   // The dE/dx information can be used as global charge or 2 to 3
-  // slices. Check AliTRDCalPIDLQ and AliTRDCalPIDLQRef for the actual
+  // slices. Check AliTRDCalPID and AliTRDCalPIDRefMaker for the actual
   // implementation.
   //
   // Author
@@ -592,9 +592,9 @@ Int_t AliTRDtrack::CookPID(AliESDtrack *esd)
        }
        
        // Retrieve the CDB container class with the probability distributions
-       const AliTRDCalPIDLQ *pd = calibration->GetPIDLQObject();
+       const AliTRDCalPID *pd = calibration->GetPIDLQObject();
        if (!pd) {
-               AliError("No access to AliTRDCalPIDLQ");
+               AliError("No access to AliTRDCalPID");
                return -1;
        }
 
index 236fea3..486757a 100644 (file)
@@ -101,7 +101,7 @@ class AliTRDtrack : public AliKalmanTrack {
        inline  Float_t GetMomentumPlane(Int_t plane) const {return (plane >= 0 && plane < kNplane) ? fMom[plane] : 0.;}
        inline  Float_t GetSnpPlane(Int_t plane) const {return (plane >= 0 && plane < kNplane) ? fSnp[plane] : 0.;}
        inline  Float_t GetTglPlane(Int_t plane) const {return (plane >= 0 && plane < kNplane) ? fTgl[plane] : 0.;}
-       inline  Float_t GetTrackLengthPlane(Int_t plane) const;
+               Float_t GetTrackLengthPlane(Int_t plane) const;
 //end A.Bercuci
 
                                         void     MakeBackupTrack();
index b1b9537..48962e4 100644 (file)
@@ -45,7 +45,7 @@
 #include "AliTRDmcm.h"
 #include "AliTRDzmaps.h"
 #include "AliTRDCalibraFillHisto.h"
-#include "Cal/AliTRDCalPIDLQ.h"
+#include "Cal/AliTRDCalPID.h"
 
 ClassImp(AliTRDtrigger)
 
diff --git a/TRD/Cal/AliTRDCalPID.cxx b/TRD/Cal/AliTRDCalPID.cxx
new file mode 100644 (file)
index 0000000..3541e0a
--- /dev/null
@@ -0,0 +1,412 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+//////////////////////////////////////////////////////////////////////////
+//                                                                      //
+// Container for the distributions of dE/dx and the time bin of the     //
+// max. cluster for electrons and pions                                 //
+//                                                                      //
+// Authors:                                                             //
+//   Prashant Shukla <shukla@pi0.physi.uni-heidelberg.de>               //
+//   Alex Bercuci <a.bercuci@gsi.de>                                    //
+//                                                                      //
+//////////////////////////////////////////////////////////////////////////
+
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TFile.h>
+#include <TROOT.h>
+
+#include "AliLog.h"
+#include "AliPID.h"
+#include "AliESD.h"
+#include "AliESDtrack.h"
+
+#include "AliTRDCalPID.h"
+#include "AliTRDcalibDB.h"
+
+ClassImp(AliTRDCalPID)
+
+Char_t* AliTRDCalPID::fpartName[AliPID::kSPECIES] = {"electron", "muon", "pion", "kaon", "proton"};
+
+Char_t* AliTRDCalPID::fpartSymb[AliPID::kSPECIES] = {"EL", "MU", "PI", "KA", "PR"};
+
+Float_t AliTRDCalPID::fTrackMomentum[kNMom] = {0.6,  0.8,  1.0,  1.5,  2.0,  3.0,  4.0,  5.0,  6.0,  8.0,  10.0};
+  
+Float_t AliTRDCalPID::fTrackSegLength[kNLength] = {3.7, 3.9, 4.2, 5.0};
+
+    
+//_________________________________________________________________________
+AliTRDCalPID::AliTRDCalPID()
+  :TNamed("pid", "PID for TRD")
+  ,fMeanChargeRatio(0)
+  ,fHistdEdx(0x0)
+  ,fHistTimeBin(0x0)
+{
+  //
+  //  The Default constructor
+  //
+
+  Init();
+
+}
+
+//_________________________________________________________________________
+AliTRDCalPID::AliTRDCalPID(const Text_t *name, const Text_t *title) 
+  :TNamed(name,title)
+  ,fMeanChargeRatio(0)
+  ,fHistdEdx(0x0)
+  ,fHistTimeBin(0x0)
+{
+  //
+  //  The main constructor
+  //
+  
+  Init();
+
+}
+
+//_____________________________________________________________________________
+AliTRDCalPID::AliTRDCalPID(const AliTRDCalPID &c) 
+  :TNamed(c)
+  ,fMeanChargeRatio(c.fMeanChargeRatio)
+  ,fHistdEdx(0x0)
+  ,fHistTimeBin(0x0)
+{
+  //
+  // Copy constructor
+  //
+
+  if (this != &c) ((AliTRDCalPID &) c).Copy(*this);
+  
+}
+
+//_________________________________________________________________________
+AliTRDCalPID::~AliTRDCalPID()
+{
+  //
+  // Destructor
+  //
+  
+  CleanUp();
+
+}
+
+//_________________________________________________________________________
+void AliTRDCalPID::CleanUp()
+{
+  //
+  // Delets all newly created objects
+  //
+
+  if (fHistdEdx) {
+    delete fHistdEdx;
+    fHistdEdx = 0x0;
+  }
+  
+  if (fHistTimeBin) {
+    delete fHistTimeBin;
+    fHistTimeBin = 0x0;
+  }
+}
+
+//_____________________________________________________________________________
+AliTRDCalPID &AliTRDCalPID::operator=(const AliTRDCalPID &c)
+{
+  //
+  // Assignment operator
+  //
+
+  if (this != &c) ((AliTRDCalPID &) c).Copy(*this);
+  return *this;
+
+}
+
+//_____________________________________________________________________________
+void AliTRDCalPID::Copy(TObject &c) const
+{
+  //
+  // Copy function
+  //
+
+  AliTRDCalPID& target = (AliTRDCalPID &) c;
+  
+  target.CleanUp();
+  
+  target.fMeanChargeRatio = fMeanChargeRatio;
+
+  if (fHistdEdx) {
+    target.fHistdEdx = (TObjArray*) fHistdEdx->Clone();
+  }
+  if (fHistTimeBin) {
+    target.fHistTimeBin = (TObjArray*) fHistTimeBin->Clone();
+  }
+
+  TObject::Copy(c);
+
+}
+
+//_________________________________________________________________________
+void AliTRDCalPID::Init()
+{
+  //
+  // Initialization
+  //
+
+  fHistdEdx    = new TObjArray(AliPID::kSPECIES * kNMom/* * kNLength*/);
+  fHistdEdx->SetOwner();
+  fHistTimeBin = new TObjArray(2 * kNMom);
+  fHistTimeBin->SetOwner();  
+
+       // Initialization of estimator at object instantiation because late
+       // initialization in function GetProbability() is not working due to
+       // constantness of this function. 
+       // fEstimator = new AliTRDCalPIDRefMaker();
+       
+  // ADC Gain normalization
+  fMeanChargeRatio = 1.0;
+}
+
+//_________________________________________________________________________
+Bool_t AliTRDCalPID::LoadLQReferences(Char_t *refFile)
+{
+  //
+  // Read the TRD dEdx histograms.
+  //
+
+       Int_t nTimeBins = 22;
+       // Get number of time bins from CDB
+       AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
+       if(!calibration){
+               AliWarning(Form("No AliTRDcalibDB available. Using %d time bins.", nTimeBins));
+       }else{
+               if(calibration->GetRun() > -1) nTimeBins = calibration->GetNumberOfTimeBins();
+               else AliWarning(Form("Run number not set. Using %d time bins.", nTimeBins));
+       }
+
+       
+  // Read histogram Root file  
+  TFile *histFile = TFile::Open(refFile, "READ");
+  if (!histFile || !histFile->IsOpen()) {
+    AliError(Form("Opening TRD histgram file %s failed", refFile));
+    return kFALSE;
+  }
+  gROOT->cd();
+
+  // Read histograms
+  for (Int_t iparticle = 0; iparticle < AliPID::kSPECIES; iparticle++){
+    for (Int_t imom = 0; imom < kNMom; imom++){
+                       TH2D* hist = (TH2D*)histFile->Get(Form("h2dEdx%s%02d", fpartSymb[iparticle], imom/*, ilength*/))->Clone();
+                       hist->Scale(1./hist->Integral());
+                       fHistdEdx->AddAt(hist, GetHistID(iparticle, imom));
+
+                       if (iparticle != AliPID::kElectron && iparticle != AliPID::kPion) continue;
+
+                       TH1F* ht = (TH1F*)histFile->Get(Form("h1MaxTB%s%02d", fpartSymb[iparticle], imom))->Clone();
+                       if(ht->GetNbinsX() != nTimeBins) AliWarning(Form("The number of time bins %d defined in h1MaxTB%s%02d differs from calibration value of %d. This may lead to erroneous results.", ht->GetNbinsX(), fpartSymb[iparticle], imom, nTimeBins));
+                       ht->Scale(1./ht->Integral());
+                       fHistTimeBin->AddAt(ht, ((iparticle==AliPID::kElectron)?0:1)*kNMom + imom);
+               }
+  }
+  
+  histFile->Close();
+  delete histFile;
+  
+  // Number of bins and bin size
+  //TH1F* hist = (TH1F*) fHistdEdx->At(GetHistID(AliPID::kPion, 1));
+  //fNbins   = hist->GetNbinsX();
+  //fBinSize = hist->GetBinWidth(1);
+  
+  return kTRUE;
+
+}
+
+// //_________________________________________________________________________
+// Double_t  AliTRDCalPID::GetMean(Int_t k, Int_t ip) const
+// {
+//   //
+//   // Gets mean of de/dx dist. of e
+//   //
+// 
+//   AliInfo(Form("Mean for particle = %s and momentum = %.2f is:\n"
+//               ,fpartName[k]
+//               ,fTrackMomentum[ip]));
+//   if (k < 0 || k > AliPID::kSPECIES) {
+//     return 0;
+//   }
+// 
+//   return ((TH1F*) fHistdEdx->At(GetHistID(k,ip)))->GetMean();
+// 
+// }
+// 
+// //_________________________________________________________________________
+// Double_t  AliTRDCalPID::GetNormalization(Int_t k, Int_t ip) const
+// {
+//   //
+//   // Gets Normalization of de/dx dist. of e
+//   //
+// 
+//   AliInfo(Form("Normalization for particle = %s and momentum = %.2f is:\n"
+//               ,fpartName[k]
+//               ,fTrackMomentum[ip]));
+//   if (k < 0 || k > AliPID::kSPECIES) {
+//     return 0;
+//   }
+//   
+//   return ((TH1F*) fHistdEdx->At(GetHistID(k,ip)))->Integral();
+// 
+// }
+
+//_________________________________________________________________________
+TH1* AliTRDCalPID::GetHistogram(Int_t k, Int_t ip/*, Int_t il*/) const
+{
+  //
+  // Returns one selected dEdx histogram
+  //
+
+  if (k < 0 || k >= AliPID::kSPECIES) return 0x0;
+       if(ip<0 || ip>= kNMom ) return 0x0;
+
+       AliInfo(Form("Retrive dEdx histogram for %s of %5.2f GeV/c", fpartName[k], fTrackMomentum[ip]));
+  
+  return (TH1*)fHistdEdx->At(GetHistID(k, ip));
+
+}
+
+//_________________________________________________________________________
+TH1* AliTRDCalPID::GetHistogramT(Int_t k, Int_t ip) const
+{
+  //
+  // Returns one selected time bin max histogram
+  //
+
+  if (k < 0 || k >= AliPID::kSPECIES) return 0x0;
+       if(ip<0 || ip>= kNMom ) return 0x0;
+         
+       AliInfo(Form("Retrive MaxTB histogram for %s of %5.2f GeV/c", fpartName[k], fTrackMomentum[ip]));
+
+       return (TH1*)fHistTimeBin->At(((k==AliPID::kElectron)?0:1)*kNMom+ip);
+}
+
+
+
+//_________________________________________________________________________
+Double_t AliTRDCalPID::GetProbability(Int_t spec, Float_t mom, Float_t *dedx, Float_t length) const
+{
+  //
+       // Core function of AliTRDCalPID class for calculating the
+       // likelihood for species "spec" (see AliTRDtrack::kNspecie) of a
+       // given momentum "mom" and a given dE/dx (slice "dedx") yield per
+       // layer
+  //
+
+       if (spec < 0 || spec >= AliPID::kSPECIES) return 0.;
+               
+       //Double_t dedx   = dedx1/fMeanChargeRatio;
+       
+       // find the interval in momentum and track segment length which applies for this data
+       Int_t ilength = 1;
+  while(ilength<kNLength-1 && length>fTrackSegLength[ilength]){
+               ilength++;
+       }
+       Int_t imom = 1;
+  while(imom<kNMom-1 && mom>fTrackMomentum[imom]) imom++;
+       
+       Int_t nbinsx, nbinsy;
+       TAxis *ax = 0x0, *ay = 0x0;
+       Double_t LQ1, LQ2;
+       Double_t mom1 = fTrackMomentum[imom-1], mom2 = fTrackMomentum[imom];
+       TH2 *hist = 0x0;
+       if(!(hist = (TH2D*)fHistdEdx->At(GetHistID(spec, imom-1/*, ilength*/)))){
+               AliInfo(Form("Looking for spec(%d) mom(%f) Ex(%f) Ey(%f) length(%f)", spec, mom, dedx[0], dedx[1], length));
+               AliError(Form("EHistogram id %d not found in DB.", GetHistID(spec, imom-1)));
+               return 0.;
+       }
+       ax = hist->GetXaxis(); nbinsx = ax->GetNbins();
+       ay = hist->GetYaxis(); nbinsy = ay->GetNbins();
+       Float_t x = dedx[0]+dedx[1], y = dedx[2];
+  Bool_t kX = (x < ax->GetBinUpEdge(nbinsx));
+       Bool_t kY = (y < ay->GetBinUpEdge(nbinsy));
+       if(kX)
+               if(kY) LQ1 = hist->GetBinContent( hist->FindBin(x, y)); 
+    //fEstimator->Estimate2D2(hist, x, y);
+               else LQ1 = hist->GetBinContent(ax->FindBin(x), nbinsy);
+       else
+               if(kY) LQ1 = hist->GetBinContent(nbinsx, ay->FindBin(y));
+               else LQ1 = hist->GetBinContent(nbinsx, nbinsy);
+
+
+       if(!(hist = (TH2D*)fHistdEdx->At(GetHistID(spec, imom/*, ilength*/)))){
+               AliInfo(Form("Looking for spec(%d) mom(%f) Ex(%f) Ey(%f) length(%f)", spec, mom, dedx[0], dedx[1], length));
+               AliError(Form("EHistogram id %d not found in DB.", GetHistID(spec, imom)));
+               return LQ1;
+       }
+       if(kX)
+               if(kY) LQ2 = hist->GetBinContent( hist->FindBin(x, y)); 
+    //fEstimator->Estimate2D2(hist, x, y);
+               else LQ2 = hist->GetBinContent(ax->FindBin(x), nbinsy);
+       else
+               if(kY) LQ2 = hist->GetBinContent(nbinsx, ay->FindBin(y));
+               else LQ2 = hist->GetBinContent(nbinsx, nbinsy);
+
+       
+       // return interpolation over momentum binning
+  return LQ1 + (LQ2 - LQ1)*(mom - mom1)/(mom2 - mom1);
+
+}
+
+//_________________________________________________________________________
+Double_t AliTRDCalPID::GetProbabilityT(Int_t spec, Double_t mom, Int_t timbin) const
+{
+  //
+  // Gets the Probability of having timbin at a given momentum (mom)
+  // and particle type (spec) (0 for e) and (2 for pi)
+  // from the precalculated timbin distributions 
+  //
+  
+       if (spec < 0 || spec >= AliPID::kSPECIES) return 0.;
+
+  Int_t iTBin = timbin+1;
+  
+  // Everything which is not an electron counts as a pion for time bin max
+  //if(spec != AliPID::kElectron) spec = AliPID::kPion;
+  
+
+  
+       Int_t imom = 1;
+  while(imom<kNMom-1 && mom>fTrackMomentum[imom]) imom++;
+
+       Double_t mom1 = fTrackMomentum[imom-1], mom2 = fTrackMomentum[imom];
+       TH1F *hist = 0x0;
+       if(!(hist = (TH1F*) fHistTimeBin->At(((spec==AliPID::kElectron)?0:1)*kNMom+imom-1))){
+               AliInfo(Form("Looking for spec(%d) mom(%f) timbin(%d)", spec, mom, timbin));
+               AliError(Form("THistogram id %d not found in DB.", ((spec==AliPID::kElectron)?0:1)*kNMom+imom-1));
+               return 0.;
+       }
+       Double_t LQ1 = hist->GetBinContent(iTBin);
+
+       if(!(hist = (TH1F*) fHistTimeBin->At(((spec==AliPID::kElectron)?0:1)*kNMom+imom))){
+               AliInfo(Form("Looking for spec(%d) mom(%f) timbin(%d)", spec, mom, timbin));
+               AliError(Form("THistogram id %d not found in DB.", ((spec==AliPID::kElectron)?0:1)*kNMom+imom));
+               return LQ1;
+       }
+       Double_t LQ2 = hist->GetBinContent(iTBin);
+
+       // return interpolation over momentum binning
+  return LQ1 + (LQ2 - LQ1)*(mom - mom1)/(mom2 - mom1);
+}
+
diff --git a/TRD/Cal/AliTRDCalPID.h b/TRD/Cal/AliTRDCalPID.h
new file mode 100644 (file)
index 0000000..5dfdbb0
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef ALITRDCALPID_H
+#define ALITRDCALPID_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// Container for the distributions of dE/dx and the time bin of the          //
+// max. cluster for electrons and pions                                      //
+//                                                                           //
+// Authors:                                                                  //
+//   Prashant Shukla <shukla@pi0.physi.uni-heidelberg.de>                    //
+//   Alex Bercuci <A.Bercuci@gsi.de>                                         //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef ROOT_TNamed
+#include <TNamed.h>
+#endif
+
+class TH1;
+class TObjArray;
+class AliTRDCalPID : public TNamed {
+public:
+       enum {
+               kNMom = 11,
+               kNLength = 4
+       };
+
+  AliTRDCalPID();
+  AliTRDCalPID(const Text_t *name, const Text_t *title);
+  AliTRDCalPID(const AliTRDCalPID& pd);
+  virtual        ~AliTRDCalPID();
+  AliTRDCalPID&   operator=(const AliTRDCalPID &c);
+  virtual void    Copy(TObject &c) const;
+           Bool_t   LoadLQReferences(Char_t* refFile);
+           Bool_t   LoadNNReferences(Char_t* /*refFile*/) {return kTRUE;}
+  //void         SetMeanChargeRatio(Double_t ratio)     { fMeanChargeRatio = ratio;  }
+
+  //Double_t     GetMeanChargeRatio() const             { return fMeanChargeRatio;   }
+  static   Double_t GetMomentum(Int_t ip)            { return (ip<0 || ip>=kNMom)    ? -1. : fTrackMomentum[ip];  }
+  static   Double_t GetLength(Int_t il)              { return (il<0 || il>=kNLength) ? -1. : fTrackSegLength[il]; }
+  //Double_t   GetMean(Int_t iType, Int_t ip) const;
+  //Double_t   GetNormalization(Int_t iType, Int_t ip) const;
+
+           TH1*     GetHistogram(Int_t iType, Int_t ip/*, Int_t il*/) const;
+           TH1*     GetHistogramT(Int_t iType, Int_t ip) const;
+           Double_t GetProbability(Int_t spec, Float_t mom, Float_t *dedx, Float_t length) const;
+           Double_t GetProbabilityT(Int_t spec, Double_t mom, Int_t timbin) const;
+
+ protected:
+
+           void     Init();
+  inline  Int_t     GetHistID(Int_t part, Int_t mom/*, Int_t length=0*/) const { return part*kNMom + mom; }
+           void     CleanUp();
+ public:
+  static  Char_t   *fpartName[5];     //! Names of particle species
+  static  Char_t   *fpartSymb[5];     //! Symbols of particle species
+  
+ protected:
+       static Float_t   fTrackMomentum[kNMom];     // Track momenta for which response functions are available
+        static Float_t   fTrackSegLength[kNLength]; // Track segment lengths for which response functions are available
+         Double_t  fMeanChargeRatio;  //  Ratio of mean charge from real Det. to prob. dist.
+         TObjArray *fHistdEdx;        //  Prob. of dEdx for 5 particles and for several momenta
+         TObjArray *fHistTimeBin;     //  Prob. of max time bin for 5 particles and for several momenta
+
+       
+  ClassDef(AliTRDCalPID, 1)           //   The TRD PID response container class
+
+};
+
+#endif
+
index 35bc773..a5d430c 100644 (file)
@@ -55,7 +55,7 @@
 #include "AliESDtrack.h"
 
 #include "AliTRDCalPIDRefMaker.h"
-#include "AliTRDCalPIDLQ.h"
+#include "AliTRDCalPID.h"
 #include "AliTRDcalibDB.h"
 #include "AliTRDgeometry.h"
 #include "AliTRDtrack.h"
@@ -178,12 +178,12 @@ Bool_t AliTRDCalPIDRefMaker::BuildLQReferences(Char_t *File, Char_t *dir)
        // Print statistics header
        Int_t nPart[AliPID::kSPECIES], nTotPart;
        printf("P[GeV/c] ");
-       for(Int_t ispec=0; ispec<AliPID::kSPECIES; ispec++) printf(" %s[%%] ", AliTRDCalPIDLQ::fpartSymb[ispec]);
+       for(Int_t ispec=0; ispec<AliPID::kSPECIES; ispec++) printf(" %s[%%] ", AliTRDCalPID::fpartSymb[ispec]);
        printf("\n-----------------------------------------------\n");
        
-       Float_t trackMomentum[AliTRDCalPIDLQ::kNMom];
-        //Float_t trackSegLength[AliTRDCalPIDLQ::kNLength];
-       for(int i=0; i<AliTRDCalPIDLQ::kNMom; i++) trackMomentum[i] = AliTRDCalPIDLQ::GetMomentum(i);
+       Float_t trackMomentum[AliTRDCalPID::kNMom];
+        //Float_t trackSegLength[AliTRDCalPID::kNLength];
+       for(int i=0; i<AliTRDCalPID::kNMom; i++) trackMomentum[i] = AliTRDCalPID::GetMomentum(i);
        AliRunLoader *fRunLoader = 0x0;
        TFile *esdFile = 0x0;
        TTree *esdTree = 0x0;
@@ -192,7 +192,7 @@ Bool_t AliTRDCalPIDRefMaker::BuildLQReferences(Char_t *File, Char_t *dir)
        
        //
        // Momentum loop
-       for (Int_t imom = 0; imom < AliTRDCalPIDLQ::kNMom; imom++) {
+       for (Int_t imom = 0; imom < AliTRDCalPID::kNMom; imom++) {
                Reset();
                
                // init statistics for momentum
@@ -309,14 +309,14 @@ Bool_t AliTRDCalPIDRefMaker::BuildLQReferences(Char_t *File, Char_t *dir)
                                                
                                                // find segment length and momentum bin
                                                Int_t jmom = 1, refMom = -1;
-                                               while(jmom<AliTRDCalPIDLQ::kNMom-1 && mom>trackMomentum[jmom]) jmom++;
+                                               while(jmom<AliTRDCalPID::kNMom-1 && mom>trackMomentum[jmom]) jmom++;
                                                if(TMath::Abs(trackMomentum[jmom-1] - mom) < trackMomentum[jmom-1] * .2) refMom = jmom-1;
                                                else if(TMath::Abs(trackMomentum[jmom] - mom) < trackMomentum[jmom] * .2) refMom = jmom;
                                                if(refMom<0){
                                                        AliInfo(Form("Momentum at plane %d entrance not in momentum window. [@ momentum %3.1f batch %03d event %d track %d]", iPlane, trackMomentum[imom], ibatch, iEvent, iTrack));
                                                        continue;
                                                }
-                                               /*while(jleng<AliTRDCalPIDLQ::kNLength-1 && length>trackSegLength[jleng]) jleng++;*/
+                                               /*while(jleng<AliTRDCalPID::kNLength-1 && length>trackSegLength[jleng]) jleng++;*/
                                                
                                                // this track segment has fulfilled all requierments
                                                //nPlanePID++;
@@ -517,9 +517,9 @@ Int_t AliTRDCalPIDRefMaker::CheckProdDirTree(Char_t *dir)
 
        Int_t iDir;
        Int_t nDir = Int_t(1.E6);
-       for(int imom=0; imom<AliTRDCalPIDLQ::kNMom; imom++){
-               if(!gSystem->ChangeDirectory(Form("%3.1fGeV", AliTRDCalPIDLQ::GetMomentum(imom)))){
-                       AliError(Form("Couldn't find data for momentum %3.1f GeV/c.", AliTRDCalPIDLQ::GetMomentum(imom)));
+       for(int imom=0; imom<AliTRDCalPID::kNMom; imom++){
+               if(!gSystem->ChangeDirectory(Form("%3.1fGeV", AliTRDCalPID::GetMomentum(imom)))){
+                       AliError(Form("Couldn't find data for momentum %3.1f GeV/c.", AliTRDCalPID::GetMomentum(imom)));
                        return 0;       
                }
                
@@ -552,7 +552,7 @@ void  AliTRDCalPIDRefMaker::Prepare2D()
        for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){
                // check PCA data
                if(!fPrinc[ispec]){
-                       AliError(Form("No data defined for %s.", AliTRDCalPIDLQ::fpartName[ispec]));
+                       AliError(Form("No data defined for %s.", AliTRDCalPID::fpartName[ispec]));
                        return;
                }
                // build reference histograms
@@ -562,7 +562,7 @@ void  AliTRDCalPIDRefMaker::Prepare2D()
                xmin = ymin = 0.;
                xmax = 8000.; ymax = 6000.;
                if(!fH2dEdx[ispec]){
-                       fH2dEdx[ispec] = new  TH2D(Form("h2%s", AliTRDCalPIDLQ::fpartSymb[ispec]), "", nbinsx, xmin, xmax, nbinsy, ymin, ymax);
+                       fH2dEdx[ispec] = new  TH2D(Form("h2%s", AliTRDCalPID::fpartSymb[ispec]), "", nbinsx, xmin, xmax, nbinsy, ymin, ymax);
                        fH2dEdx[ispec]->SetLineColor(color[ispec]);
                }
        }
@@ -871,13 +871,13 @@ void  AliTRDCalPIDRefMaker::SaveReferences(const Int_t mom, const char *fn)
        if(!kFOUND) fSave = TFile::Open(fn, "RECREATE");
        fSave->cd();
 
-       Float_t fmom = AliTRDCalPIDLQ::GetMomentum(mom);
+       Float_t fmom = AliTRDCalPID::GetMomentum(mom);
        
        // save dE/dx references
        TH2 *h2 = 0x0;
        for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){
-               h2 = (TH2D*)fH2dEdx[ispec]->Clone(Form("h2dEdx%s%d", AliTRDCalPIDLQ::fpartSymb[ispec], mom));
-               h2->SetTitle(Form("2D dEdx for particle %s @ %d", AliTRDCalPIDLQ::fpartName[ispec], mom));
+               h2 = (TH2D*)fH2dEdx[ispec]->Clone(Form("h2dEdx%s%d", AliTRDCalPID::fpartSymb[ispec], mom));
+               h2->SetTitle(Form("2D dEdx for particle %s @ %d", AliTRDCalPID::fpartName[ispec], mom));
                h2->GetXaxis()->SetTitle("dE/dx_{TRD}^{amplif} [au]");
                h2->GetYaxis()->SetTitle("dE/dx_{TRD}^{drift} [au]");
                h2->GetZaxis()->SetTitle("Entries");
index 64f4dcc..c466b12 100644 (file)
@@ -36,7 +36,7 @@
 #pragma link C++ class  AliTRDCalPad+;
 #pragma link C++ class  AliTRDCalDet+;
 #pragma link C++ class  AliTRDCalFEE+;
-#pragma link C++ class  AliTRDCalPIDLQ+;
+#pragma link C++ class  AliTRDCalPID+;
 #pragma link C++ class  AliTRDCalPIDRefMaker+;
 #pragma link C++ class  AliTRDCalMonitoring+;
 
index a60cdc3..9eb38c5 100644 (file)
@@ -19,7 +19,7 @@ SRCS= AliTRDarrayI.cxx \
       Cal/AliTRDCalPad.cxx \
       Cal/AliTRDCalDet.cxx \
       Cal/AliTRDCalFEE.cxx \
-      Cal/AliTRDCalPIDLQ.cxx \
+      Cal/AliTRDCalPID.cxx \
       Cal/AliTRDCalPIDRefMaker.cxx \
       Cal/AliTRDCalMonitoring.cxx \
       Cal/AliTRDCalChamberStatus.cxx \