Updates on TRD PID Response
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Oct 2011 07:17:27 +0000 (07:17 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Oct 2011 07:17:27 +0000 (07:17 +0000)
M. Fasel

OADB/COMMON/PID/data/TRDPIDParams.root
OADB/COMMON/PID/data/TRDPIDReferenceLQ1D.root
STEER/CMakelibSTEERBase.pkg
STEER/STEERBase/AliPIDResponse.h
STEER/STEERBase/AliTRDPIDParams.cxx [new file with mode: 0644]
STEER/STEERBase/AliTRDPIDParams.h [new file with mode: 0644]
STEER/STEERBase/AliTRDPIDResponse.cxx
STEER/STEERBase/AliTRDPIDResponse.h
STEER/STEERBaseLinkDef.h

index 78ed8e6..f86b290 100644 (file)
Binary files a/OADB/COMMON/PID/data/TRDPIDParams.root and b/OADB/COMMON/PID/data/TRDPIDParams.root differ
index 698080e..bdf0ddd 100644 (file)
Binary files a/OADB/COMMON/PID/data/TRDPIDReferenceLQ1D.root and b/OADB/COMMON/PID/data/TRDPIDReferenceLQ1D.root differ
index 2140c2a..20e5167 100644 (file)
@@ -61,6 +61,7 @@ set ( SRCS
     STEERBase/AliQA.cxx 
     STEERBase/AliITSPidParams.cxx 
     STEERBase/AliTRDPIDReference.cxx 
+    STEERBase/AliTRDPIDParams.cxx 
     STEERBase/AliPIDResponse.cxx 
     STEERBase/AliITSPIDResponse.cxx 
     STEERBase/AliTPCPIDResponse.cxx 
index e34ae65..17a265e 100644 (file)
@@ -120,7 +120,7 @@ private:
   TObjArray *fArrPidResponseMaster;    //!  TPC pid splines
   TF1       *fResolutionCorrection;    //! TPC resolution correction
 
-  TObjArray *fTRDPIDParams;             //! TRD PID Params
+  AliTRDPIDParams *fTRDPIDParams;       //! TRD PID Params
   AliTRDPIDReference *fTRDPIDReference; //! TRD PID References
   UInt_t fTRDslicesForPID[2];           //! TRD PID slices
 
diff --git a/STEER/STEERBase/AliTRDPIDParams.cxx b/STEER/STEERBase/AliTRDPIDParams.cxx
new file mode 100644 (file)
index 0000000..f0be60a
--- /dev/null
@@ -0,0 +1,207 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Container for TRD Threshold parameters stored in the OADB
+//
+// Author: Markus Fasel <M.Fasel@gsi.de>
+//
+#include <TMath.h>
+#include <TSortedList.h>
+
+#include "AliLog.h"
+
+#include "AliTRDPIDParams.h"
+
+ClassImp(AliTRDPIDParams)
+
+const Double_t AliTRDPIDParams::kVerySmall = 1e-5;
+
+//____________________________________________________________
+AliTRDPIDParams::AliTRDPIDParams():
+  TNamed(),
+  fEntries(NULL)
+{
+  //
+  // Dummy constructor
+  //
+}
+
+//____________________________________________________________
+AliTRDPIDParams::AliTRDPIDParams(const char *name) :
+  TNamed(name, ""),
+  fEntries(NULL)
+{
+  //
+  // Default constructor
+  //
+  fEntries = new TSortedList;
+}
+
+//____________________________________________________________
+AliTRDPIDParams::~AliTRDPIDParams(){
+  //
+  // Destructor
+  //
+  delete fEntries;
+}
+
+//____________________________________________________________
+Bool_t AliTRDPIDParams::GetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params) const{
+  //
+  // Retrieve params
+  // Use IsEqual definition
+  //
+  AliTRDPIDThresholds test(ntracklets, efficiency);
+  TObject *result = fEntries->FindObject(&test);
+  if(!result){ 
+    AliDebug(1, Form("No threshold params found for %d tracklets and an electron efficiency of %f", ntracklets, efficiency));
+    return kFALSE;
+  }
+  AliTRDPIDThresholds *parResult = static_cast<AliTRDPIDThresholds *>(result);
+  AliDebug(1, Form("Threshold params found: NTracklets %d, Electron Efficiency %f", parResult->GetNTracklets(), parResult->GetElectronEfficiency()));
+  memcpy(params, parResult->GetThresholdParams(), sizeof(Double_t) * 4);
+  return kTRUE;
+}
+
+//____________________________________________________________
+void AliTRDPIDParams::SetThresholdParameters(Int_t ntracklets, Double_t effMin, Double_t effMax, Double_t *params){
+  // 
+  // Store new Params in the Object
+  //
+  if(effMin > effMax){
+    AliError("Min. efficiency has to be >= max. efficiency");
+    return;
+  }
+  AliDebug(1, Form("Save Parameters for %d tracklets at and electron efficiency of [%f|%f]", ntracklets, effMin, effMax));
+  fEntries->Add(new AliTRDPIDThresholds(ntracklets, effMin, effMax, params));
+}
+
+//____________________________________________________________
+void AliTRDPIDParams::Print(Option_t *) const {
+  printf("Available thresholds:\n");
+  printf("_________________________________________\n");
+  TIter objects(fEntries);
+  AliTRDPIDThresholds *par;
+  while((par = dynamic_cast<AliTRDPIDThresholds *>(objects()))){
+    printf("Number of tracklets %d, Electron efficiency %f\n", par->GetNTracklets(), par->GetElectronEfficiency());
+  }
+}
+
+//____________________________________________________________
+AliTRDPIDParams::AliTRDPIDThresholds::AliTRDPIDThresholds():
+  TObject(),
+  fNTracklets(0)
+{
+   // 
+   // Default constructor
+   //
+   memset(fParams, 0, sizeof(Double_t) * 4);
+   memset(fEfficiency, 0, sizeof(Double_t) * 2);
+}
+
+//____________________________________________________________
+AliTRDPIDParams::AliTRDPIDThresholds::AliTRDPIDThresholds(Int_t nTracklets, Double_t effMin, Double_t effMax, Double_t *params) :
+  TObject(),
+  fNTracklets(nTracklets)
+{
+  //
+  // Default Constructor 
+  //
+  fEfficiency[0] = effMin;
+  fEfficiency[1] = effMax;  
+  if(params) memcpy(fParams, params, sizeof(Double_t) * 4);
+  else memset(fParams, 0, sizeof(Double_t) * 4);
+}
+
+//____________________________________________________________
+AliTRDPIDParams::AliTRDPIDThresholds::AliTRDPIDThresholds(Int_t nTracklets, Double_t eff, Double_t *params) :
+  TObject(),
+  fNTracklets(nTracklets)
+{
+  //
+  // Constructor used to find object in sorted list
+  //
+  fEfficiency[0] = fEfficiency[1] = eff;  
+  if(params) memcpy(fParams, params, sizeof(Double_t) * 4);
+  else memset(fParams, 0, sizeof(Double_t) * 4);
+}
+
+//____________________________________________________________
+AliTRDPIDParams::AliTRDPIDThresholds::AliTRDPIDThresholds(const AliTRDPIDThresholds &ref) :
+  TObject(ref),
+  fNTracklets(ref.fNTracklets)
+{
+  //
+  // Copy constructor
+  //
+  memcpy(fParams, ref.fParams, sizeof(Double_t) * 4);
+  memcpy(fEfficiency, ref.fEfficiency, sizeof(Double_t) * 2);
+}
+
+//____________________________________________________________
+AliTRDPIDParams::AliTRDPIDThresholds &AliTRDPIDParams::AliTRDPIDThresholds::operator=(const AliTRDPIDThresholds &ref){
+  //
+  // Assignment operator
+  //
+  TObject::operator=(ref);
+
+  fNTracklets = ref.fNTracklets;
+  memcpy(fEfficiency, ref.fEfficiency, sizeof(Double_t) * 2);
+  memcpy(fParams, ref.fParams, sizeof(Double_t) * 4);
+  return *this;
+}
+        
+//____________________________________________________________
+Int_t AliTRDPIDParams::AliTRDPIDThresholds::Compare(const TObject *ref) const{
+  //
+  // Compares two objects
+  // Order:
+  //   First compare number of tracklets, if they are equal compare electron efficiency
+  //
+  const AliTRDPIDThresholds *refObj = static_cast<const AliTRDPIDThresholds *>(ref);
+  if(fNTracklets < refObj->GetNTracklets()) return -1;
+  else if(fNTracklets > refObj->GetNTracklets()) return 1;
+  else{
+    if(fEfficiency[1] < refObj->GetElectronEfficiency(0)) return -1;
+    else if(fEfficiency[0] > refObj->GetElectronEfficiency(1)) return 1;
+    else return 0;
+  }
+}
+
+//____________________________________________________________
+Bool_t AliTRDPIDParams::AliTRDPIDThresholds::IsEqual(const TObject *ref) const {
+  //
+  // Check for equality 
+  // Tracklets and Efficiency are used
+  //
+  const AliTRDPIDThresholds *refObj = dynamic_cast<const AliTRDPIDThresholds *>(ref);
+  if(!refObj) return kFALSE;
+  Bool_t eqNTracklets = fNTracklets == refObj->GetNTracklets();
+  Bool_t eqEff = kFALSE;
+  Bool_t hasRange = TMath::Abs(fEfficiency[1] - fEfficiency[0]) > kVerySmall;
+  Bool_t hasRangeRef = TMath::Abs(refObj->GetElectronEfficiency(1) - refObj->GetElectronEfficiency(0)) > kVerySmall;
+  if(hasRange && hasRangeRef){
+    // Both have ranges, check if they match
+    eqEff = TMath::Abs(fEfficiency[0] - refObj->GetElectronEfficiency(0)) < kVerySmall && TMath::Abs(fEfficiency[1] - refObj->GetElectronEfficiency(1)) < kVerySmall;
+  } else if(hasRange){
+    // this object has ranges, check if the efficiency of ref is inside the range
+    eqEff = refObj->GetElectronEfficiency(0) >= fEfficiency[0] && refObj->GetElectronEfficiency(0) < fEfficiency[1];
+  } else {
+    // ref has ranges, check if this is in range
+    eqEff = fEfficiency[0] >= refObj->GetElectronEfficiency(0) && fEfficiency[0] < refObj->GetElectronEfficiency(1);
+  }
+  
+  return  eqNTracklets && eqEff;
+}
diff --git a/STEER/STEERBase/AliTRDPIDParams.h b/STEER/STEERBase/AliTRDPIDParams.h
new file mode 100644 (file)
index 0000000..bbadcae
--- /dev/null
@@ -0,0 +1,73 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+//
+// Container for TRD thresholds stored in the OADB
+//
+#ifndef ALITRDPIDPARAMS_H
+#define ALITRDPIDPARAMS_H
+
+#ifndef ROOT_TNamed
+#include <TNamed.h>
+#endif
+
+class TSortedList;
+
+class AliTRDPIDParams : public TNamed{
+  public:
+    AliTRDPIDParams();
+    AliTRDPIDParams(const char *name);
+    virtual ~AliTRDPIDParams();
+    virtual void Print(Option_t *) const;
+
+    Bool_t GetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params) const;
+    void SetThresholdParameters(Int_t ntracklets, Double_t effMin, Double_t effMax, Double_t *params);
+
+  private:
+    class AliTRDPIDThresholds : public TObject{
+      public:
+        AliTRDPIDThresholds();
+        AliTRDPIDThresholds(Int_t nTracklets, Double_t effMin, Double_t effMax, Double_t *params = NULL);
+        AliTRDPIDThresholds(Int_t nTracklets, Double_t eff, Double_t *params = NULL);
+        AliTRDPIDThresholds(const AliTRDPIDThresholds &);
+        AliTRDPIDThresholds &operator=(const AliTRDPIDThresholds &);
+        virtual ~AliTRDPIDThresholds() {}
+        
+        Int_t GetNTracklets() const { return fNTracklets; }
+        Double_t GetElectronEfficiency(Int_t step = 0) const { if(step == 0) return fEfficiency[0]; else return fEfficiency[1]; }
+        const Double_t *GetThresholdParams() const { return fParams; }
+
+        virtual Bool_t IsSortable() const { return kTRUE; }
+        virtual Int_t Compare(const TObject *ref) const;
+        virtual Bool_t IsEqual(const TObject *ref) const;
+
+      private:
+        Int_t fNTracklets;          //
+        Double_t fEfficiency[2];    //
+        Double_t fParams[4];        //
+
+        ClassDef(AliTRDPIDThresholds, 1);
+    };
+
+    static const Double_t kVerySmall;
+
+    AliTRDPIDParams(const AliTRDPIDParams &);
+    AliTRDPIDParams &operator=(const AliTRDPIDParams &);
+    
+    TSortedList *fEntries; //
+
+    ClassDef(AliTRDPIDParams, 1);
+};
+#endif
+
index e9256a1..edff1a1 100644 (file)
 #include <TROOT.h> 
 #include <TString.h>
 #include <TSystem.h>
-#include <TVectorT.h>
 
 #include "AliLog.h"
 
+#include "AliTRDPIDParams.h"
 #include "AliTRDPIDReference.h"
 #include "AliTRDPIDResponse.h"
 
@@ -262,39 +262,13 @@ Bool_t AliTRDPIDResponse::IdentifiedAsElectron(Int_t nTracklets, const Double_t
     return kTRUE;
   } 
   Double_t probEle = like[AliPID::kElectron]/(like[AliPID::kElectron] + like[AliPID::kPion]);
-  const TVectorD *params = GetParams(nTracklets, level);
-  if(!params){
+  Double_t params[4];
+  if(!fkPIDParams->GetThresholdParameters(nTracklets, level, params)){
     AliError("No Params found for the given configuration");
     return kTRUE;
   }
-  Double_t threshold = 1. - (*params)[0] - (*params)[1] * p - (*params)[2] * TMath::Exp(-(*params)[3] * p);
+  Double_t threshold = 1. - params[0] - params[1] * p - params[2] * TMath::Exp(-params[3] * p);
   if(probEle > TMath::Max(TMath::Min(threshold, 0.99), 0.2)) return kTRUE; // truncate the threshold upperwards to 0.999 and lowerwards to 0.2 and exclude unphysical values
   return kFALSE;
 }
 
-//____________________________________________________________
-const TVectorD* AliTRDPIDResponse::GetParams(Int_t ntracklets, Double_t level) const {
-  //
-  // returns the threshold for a given number of tracklets and a given efficiency level
-  //tby definition the lower of step is given.
-  //
-  if(ntracklets > 6 || ntracklets <=0) return NULL;
-  TObjArray * entry = dynamic_cast<TObjArray *>(fkPIDParams->At(ntracklets - 1));
-  if(!entry) return NULL;
-  
-  TObjArray*cut = NULL;
-  TVectorF *effLevel = NULL; const TVectorD *parameters = NULL;
-  Float_t currentLower = 0.;
-  TIter cutIter(entry);
-  while((cut = dynamic_cast<TObjArray *>(cutIter()))){
-    effLevel = static_cast<TVectorF *>(cut->At(0));
-    if((*effLevel)[0] > currentLower && (*effLevel)[0] <= level){
-      // New Lower entry found
-      parameters = static_cast<const TVectorD *>(cut->At(1));
-      currentLower = (*effLevel)[0];
-    }
-  }  
-  AliDebug(2, Form("Taking params for %d tracklets and %f electron Efficiency\n", ntracklets, currentLower));
-
-  return parameters;
-}
index cb462a4..53d90de 100644 (file)
 #include "AliPID.h"
 #endif
 
-#include <TVectorDfwd.h>
-
 class TObjArray;
 class AliVTrack;
+class AliTRDPIDParams;
 class AliTRDPIDReference;
 class AliTRDPIDResponse : public TObject {
   public:
@@ -66,7 +65,7 @@ class AliTRDPIDResponse : public TObject {
     void      SetOwner();
     void      SetPIDmethod(ETRDPIDMethod m) {fPIDmethod=m;}
     void      SetGainNormalisationFactor(Double_t gainFactor) { fGainNormalisationFactor = gainFactor; }
-    void      SetPIDParams(const TObjArray * params) { fkPIDParams = params; }
+    void      SetPIDParams(const AliTRDPIDParams * params) { fkPIDParams = params; }
 
     Bool_t    Load(const Char_t *filename = NULL, const Char_t *refName = "RefTRDLQ1D");
     Bool_t    Load(const AliTRDPIDReference *ref) { fkPIDReference = ref; return kTRUE; }
@@ -76,10 +75,9 @@ class AliTRDPIDResponse : public TObject {
   private:
     Bool_t    CookdEdx(Int_t nSlice, const Double_t * const in, Double_t *out) const;
     Double_t  GetProbabilitySingleLayer(Int_t species, Double_t plocal, Double_t dEdx) const;
-    const TVectorD * GetParams(Int_t ntracklets, Double_t level) const;
     
     const AliTRDPIDReference *fkPIDReference;   // PID References
-    const TObjArray *fkPIDParams;               // PID Params
+    const AliTRDPIDParams *fkPIDParams;         // PID Params
     Double_t  fGainNormalisationFactor;         // Gain normalisation factor
     ETRDPIDMethod   fPIDmethod;                 // PID method selector
       
index a17a7b4..8710cba 100644 (file)
@@ -85,6 +85,8 @@
 #pragma link C++ class AliQA+;
 
 #pragma link C++ class AliTRDPIDReference+;
+#pragma link C++ class AliTRDPIDParams+;
+#pragma link C++ class AliTRDPIDParams::AliTRDPIDThresholds+;
 #pragma link C++ class AliITSPidParams+;
 #pragma link C++ class AliPIDResponse+;
 #pragma link C++ class AliITSPIDResponse+;