]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Some long methods are not inlined anymore. The pointers to cached object are made...
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 1 Feb 2006 10:10:19 +0000 (10:10 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 1 Feb 2006 10:10:19 +0000 (10:10 +0000)
TRD/AliTRDcalibDB.cxx
TRD/AliTRDcalibDB.h
TRD/AliTRDpidESD.cxx

index bb0c73441d4132c721c61e9c1bb2f3154a57d32c..3788680d80d8d5f46b93714200d72adc940ef9ff 100644 (file)
@@ -53,7 +53,7 @@ AliTRDcalibDB* AliTRDcalibDB::Instance()
   //
   // Singleton implementation
   // Returns an instance of this class, it is created if neccessary
-  // 
+  //
   
   if (fgTerminated != kFALSE)
     return 0;
@@ -133,6 +133,137 @@ AliTRDcalibDB::~AliTRDcalibDB()
   Invalidate();
 }
 
+//_caching functions____________________________________________________________
+const TObject* AliTRDcalibDB::GetCachedCDBObject(Int_t id)
+{
+    //
+    // Retrieves a cdb object with the given id. The objects are cached as long as the run number is not changed.
+    //
+    // Put together the available objects here by using the lines
+    //   a) For usual calibration objects:
+    //      ase kID<Name> : return CacheCDBEntry(kID<Name>, "TRD/Calib/<Path>"); break;
+    //      See function CacheCDBEntry for details.
+    //   and
+    //   b) For calibration data which depends on two objects: One containing a value per detector and one the local fluctuations per pad:
+    //      case kID<Name> : return CacheMergeCDBEntry(kID<Name>, "TRD/Calib/<padPath>", "TRD/Calib/<chamberPath>"); break;
+    //      See function CacheMergeCDBEntry for details.
+    //
+    
+    switch (id)
+    {
+      // parameters defined per pad and chamber
+      case kIDVdrift : return CacheMergeCDBEntry(kIDVdrift, "TRD/Calib/LocalVdrift", "TRD/Calib/ChamberVdrift"); break;
+      case kIDT0 : return CacheMergeCDBEntry(kIDT0, "TRD/Calib/LocalT0", "TRD/Calib/ChamberT0"); break;
+      
+      // parameters defined per pad
+      case kIDGainFactor : return CacheCDBEntry(kIDGainFactor, "TRD/Calib/GainFactor"); break;
+      case kIDPRFWidth : return CacheCDBEntry(kIDPRFWidth, "TRD/Calib/PRFWidth"); break;
+    
+      // global parameters
+      case kIDGlobals : return CacheCDBEntry(kIDGlobals, "TRD/Calib/Globals"); break;
+      case kIDChamber : return CacheCDBEntry(kIDChamber, "TRD/Calib/Chamber"); break;
+      case kIDStack : return CacheCDBEntry(kIDStack, "TRD/Calib/Stack"); break;
+      case kIDPIDLQ : return CacheCDBEntry(kIDPIDLQ, "TRD/Calib/PIDLQ"); break;
+    }
+    return 0;
+}
+
+//_____________________________________________________________________________
+AliCDBEntry* AliTRDcalibDB::GetCDBEntry(const char* cdbPath)
+{
+  // 
+  // Retrieves an entry with path <cdbPath> from the CDB.
+  //
+    
+  if (fRun < 0)
+  {
+    AliFatal("AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun.");
+    //std::cerr << "AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun." << std::endl;
+    return 0;
+  }
+  if (!fLocator) 
+  { 
+    std::cerr << "AliTRDcalibDB: Storage Locator not available." << std::endl; 
+    return 0; 
+  } 
+  AliCDBEntry* entry = fLocator->Get(cdbPath, fRun); 
+  if (!entry) 
+  { 
+    std::cerr << "AliTRDcalibDB: Failed to get entry: " << cdbPath << std::endl; 
+    return 0; 
+  }
+  
+  std::cout << "AliTRDcalibDB: Retrieved object: " << cdbPath << std::endl;
+  return entry;
+}
+
+//_____________________________________________________________________________
+const TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath)
+{
+  //
+  // Caches the entry <id> with cdb path <cdbPath>
+  //
+  
+  if (!fCDBCache[id])
+  {
+    fCDBEntries[id] = GetCDBEntry(cdbPath);
+    if (fCDBEntries[id])
+      fCDBCache[id] = fCDBEntries[id]->GetObject();
+  }
+  return fCDBCache[id];
+}
+
+//_____________________________________________________________________________
+const TObject* AliTRDcalibDB::CacheMergeCDBEntry(Int_t id, const char* cdbPadPath, const char* cdbChamberPath)
+{
+  //
+  // Retrieves and caches an object (id <id>) from the CDB. This function is specialized for parameters which are stored
+  // as local variation at pad level of a global variable defined per detector chamber. It uses the classes AliTRDCalPad and AliTRDCalDet.
+  // Before storing the object it retrieves the local variations (cdbPadPath) and the global variable (cdbChamberPath) and merges them using
+  // the AliTRDCalPad::ScaleROCs.
+  //
+    
+  if (!fCDBCache[id]) 
+  {
+    AliTRDCalPad* padObject = 0;
+    AliTRDCalDet* detObject = 0;
+   
+    fCDBEntries[id] = GetCDBEntry(cdbPadPath);
+    if (fCDBEntries[id])
+      padObject = dynamic_cast<AliTRDCalPad*>(fCDBEntries[id]->GetObject());
+   
+    AliCDBEntry* mergeEntry = GetCDBEntry(cdbChamberPath);
+    if (mergeEntry)
+      detObject = dynamic_cast<AliTRDCalDet*>(mergeEntry->GetObject());
+    
+    if (!padObject || !detObject) 
+    {
+      if (fCDBEntries[id]) {
+        if (fCDBEntries[id]->IsOwner() == kFALSE && padObject)
+          delete padObject;
+        delete fCDBEntries[id];
+        fCDBEntries[id] = 0;
+      }
+      if (mergeEntry) 
+      {
+        if (mergeEntry->IsOwner() == kFALSE && detObject)
+          delete detObject;
+        delete mergeEntry;
+      }
+      return 0;
+    }
+    
+    padObject->ScaleROCs(detObject);
+    if (mergeEntry->IsOwner() == kFALSE)
+      delete detObject;
+    delete mergeEntry;
+    
+    fCDBCache[id] = padObject;
+  }
+  
+  return fCDBCache[id];
+}
+
 //_____________________________________________________________________________
 void AliTRDcalibDB::SetRun(Long64_t run)
 {
@@ -176,7 +307,7 @@ Bool_t AliTRDcalibDB::GetChamberPos(Int_t det, Float_t* xyz)
   // Returns the deviation of the chamber position from the nominal position.
   //
   
-  AliTRDCalChamberPos* chamber = dynamic_cast<AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamber));
+  const AliTRDCalChamberPos* chamber = dynamic_cast<const AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamber));
   if (!chamber)
     return kFALSE;
   
@@ -198,7 +329,7 @@ Bool_t AliTRDcalibDB::GetChamberRot(Int_t det, Float_t* xyz)
   // Returns the rotation of the chamber from the nominal position.
   //
   
-  AliTRDCalChamberPos* chamber = dynamic_cast<AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamber));
+  const AliTRDCalChamberPos* chamber = dynamic_cast<const AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamber));
   if (!chamber)
     return kFALSE;
   
@@ -220,7 +351,7 @@ Bool_t AliTRDcalibDB::GetStackPos(Int_t chamber, Int_t sector, Float_t* xyz)
   // Returns the deviation of the stack position from the nominal position.
   //
   
-  AliTRDCalStackPos* stack = dynamic_cast<AliTRDCalStackPos*>(GetCachedCDBObject(kIDStack));
+  const AliTRDCalStackPos* stack = dynamic_cast<const AliTRDCalStackPos*>(GetCachedCDBObject(kIDStack));
   if (!stack)
     return kFALSE;
   
@@ -242,7 +373,7 @@ Bool_t AliTRDcalibDB::GetStackRot(Int_t chamber, Int_t sector, Float_t* xyz)
   // Returns the rotation of the stack from the nominal position.
   //
   
-  AliTRDCalStackPos* stack = dynamic_cast<AliTRDCalStackPos*>(GetCachedCDBObject(kIDStack));
+  const AliTRDCalStackPos* stack = dynamic_cast<const AliTRDCalStackPos*>(GetCachedCDBObject(kIDStack));
   if (!stack)
     return kFALSE;
   
@@ -264,7 +395,7 @@ Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
   // Returns the drift velocity for the given pad.
   //
   
-  AliTRDCalPad* calPad = dynamic_cast<AliTRDCalPad*> (GetCachedCDBObject(kIDVdrift));
+  const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDVdrift));
   if (!calPad)
     return -1;
 
@@ -282,7 +413,7 @@ Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
   // Returns t0 for the given pad.
   //
   
-  AliTRDCalPad* calPad = dynamic_cast<AliTRDCalPad*> (GetCachedCDBObject(kIDT0));
+  const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDT0));
   if (!calPad)
     return -1;
 
@@ -300,7 +431,7 @@ Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
   // Returns the gain factor for the given pad.
   //
   
-  AliTRDCalPad* calPad = dynamic_cast<AliTRDCalPad*> (GetCachedCDBObject(kIDGainFactor));
+  const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDGainFactor));
   if (!calPad)
     return -1;
 
@@ -318,7 +449,7 @@ Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
   // Returns the PRF width for the given pad.
   //
   
-  AliTRDCalPad* calPad = dynamic_cast<AliTRDCalPad*> (GetCachedCDBObject(kIDPRFWidth));
+  const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDPRFWidth));
   if (!calPad)
     return -1;
 
@@ -336,7 +467,7 @@ Float_t AliTRDcalibDB::GetSamplingFrequency()
   // Returns the sampling frequency of the TRD read-out.
   //
   
-  AliTRDCalGlobals* calGlobal = dynamic_cast<AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
+  const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
   if (!calGlobal)
     return -1;  
   
@@ -350,7 +481,7 @@ Int_t AliTRDcalibDB::GetNumberOfTimeBins()
   // Returns the number of time bins which are read-out.
   //
   
-  AliTRDCalGlobals* calGlobal = dynamic_cast<AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
+  const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
   if (!calGlobal)
     return -1;  
   
@@ -358,19 +489,13 @@ Int_t AliTRDcalibDB::GetNumberOfTimeBins()
 }
 
 //_____________________________________________________________________________
-AliTRDCalPIDLQ* AliTRDcalibDB::GetPIDLQObject()
+const AliTRDCalPIDLQ* AliTRDcalibDB::GetPIDLQObject()
 {
   //
   // Returns the object storing the distributions for PID with likelihood
   //
   
-  // FAKE
-  /*AliTRDCalPIDLQ* pid = new AliTRDCalPIDLQ();
-  pid->ReadData("$ALICE_ROOT/TRD/TRDdEdxHistogramsV1.root");
-  return pid;*/
-  
-  // TODO due to a bug in the CDB this does not work yet
-  return dynamic_cast<AliTRDCalPIDLQ*> (GetCachedCDBObject(kIDPIDLQ));
+  return dynamic_cast<const AliTRDCalPIDLQ* const> (GetCachedCDBObject(kIDPIDLQ));
 }
 
 //_____________________________________________________________________________
index 09e5be5bc2a079aaaa13e4590bfdd3b75777162a..fe986b707dbbf227058512ff88605f35ee53dafc 100644 (file)
 #include <AliCDBStorage.h>
 #include <AliCDBEntry.h>
 
-//includes neccessary here for compiliation of dynamic_cast
-#include "AliTRDCalPad.h"
-#include "AliTRDCalDet.h"
-
 class AliTRDCalPIDLQ;
 
 class AliTRDcalibDB : public TObject
@@ -60,57 +56,26 @@ public:
   Float_t GetSamplingFrequency(); 
   Int_t GetNumberOfTimeBins();
   
-  AliTRDCalPIDLQ* GetPIDLQObject();
+  const AliTRDCalPIDLQ* GetPIDLQObject();
   
   //Related functions, these depend on calibration data
   static Float_t GetOmegaTau(Float_t vdrift);
   Int_t PadResponse(Double_t signal, Double_t dist, Int_t plane, Double_t *pad) const;
   
 protected:
+  // for caching see also implentation of GetCachedCDBObject in the .cxx file
   enum { kCDBCacheSize = 8 };   // Number of cached objects
   enum { kIDVdrift = 0, kIDT0 = 1, kIDGainFactor = 2, kIDPRFWidth = 3, kIDGlobals = 4, 
          kIDChamber = 5, kIDStack = 6, kIDPIDLQ = 7 };    // IDs of cached objects
   
-  TObject* GetCachedCDBObject(Int_t id)
-  {
-    //
-    // Retrieves a cdb object with the given id. The objects are cached as long as the run number is not changed.
-    //
-    // Put together the available objects here by using the lines
-    //   a) For usual calibration objects:
-    //      ase kID<Name> : return CacheCDBEntry(kID<Name>, "TRD/Calib/<Path>"); break;
-    //      See function CacheCDBEntry for details.
-    //   and
-    //   b) For calibration data which depends on two objects: One containing a value per detector and one the local fluctuations per pad:
-    //      case kID<Name> : return CacheMergeCDBEntry(kID<Name>, "TRD/Calib/<padPath>", "TRD/Calib/<chamberPath>"); break;
-    //      See function CacheMergeCDBEntry for details.
-    //
-    
-    switch (id)
-    {
-      // parameters defined per pad and chamber
-      case kIDVdrift : return CacheMergeCDBEntry(kIDVdrift, "TRD/Calib/LocalVdrift", "TRD/Calib/ChamberVdrift"); break;
-      case kIDT0 : return CacheMergeCDBEntry(kIDT0, "TRD/Calib/LocalT0", "TRD/Calib/ChamberT0"); break;
-      
-      // parameters defined per pad
-      case kIDGainFactor : return CacheCDBEntry(kIDGainFactor, "TRD/Calib/GainFactor"); break;
-      case kIDPRFWidth : return CacheCDBEntry(kIDPRFWidth, "TRD/Calib/PRFWidth"); break;
-    
-      // global parameters
-      case kIDGlobals : return CacheCDBEntry(kIDGlobals, "TRD/Calib/Globals"); break;
-      case kIDChamber : return CacheCDBEntry(kIDChamber, "TRD/Calib/Chamber"); break;
-      case kIDStack : return CacheCDBEntry(kIDStack, "TRD/Calib/Stack"); break;
-      case kIDPIDLQ : return CacheCDBEntry(kIDPIDLQ, "TRD/Calib/PIDLQ"); break;
-    }
-    return 0;
-  }
+  const TObject* GetCachedCDBObject(Int_t id);
   
   void Invalidate();
   void SamplePRF();
   
-  inline AliCDBEntry* GetCDBEntry(const char* cdbPath);
-  inline TObject* CacheCDBEntry(Int_t id, const char* cdbPath);
-  inline TObject* CacheMergeCDBEntry(Int_t id, const char* cdbPadPath, const char* cdbChamberPath);
+  AliCDBEntry* GetCDBEntry(const char* cdbPath);
+  const TObject* CacheCDBEntry(Int_t id, const char* cdbPath);
+  const TObject* CacheMergeCDBEntry(Int_t id, const char* cdbPadPath, const char* cdbChamberPath);
   
   static AliTRDcalibDB* fgInstance;     // Instance of this class (singleton implementation)
   static Bool_t fgTerminated;               // Defines if this class has already been terminated and therefore does not return instances in GetInstance anymore
@@ -140,97 +105,4 @@ private:
   ClassDef(AliTRDcalibDB, 0)
 };
 
-AliCDBEntry* AliTRDcalibDB::GetCDBEntry(const char* cdbPath)
-{
-  // 
-  // Retrieves an entry with path <cdbPath> from the CDB.
-  //
-    
-  if (fRun < 0)
-  {
-    AliFatal("AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun.");
-    //std::cerr << "AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun." << std::endl;
-    return 0;
-  }
-  if (!fLocator) 
-  { 
-    std::cerr << "AliTRDcalibDB: Storage Locator not available." << std::endl; 
-    return 0; 
-  } 
-  AliCDBEntry* entry = fLocator->Get(cdbPath, fRun); 
-  if (!entry) 
-  { 
-    std::cerr << "AliTRDcalibDB: Failed to get entry: " << cdbPath << std::endl; 
-    return 0; 
-  }
-  
-  std::cout << "AliTRDcalibDB: Retrieved object: " << cdbPath << std::endl;
-  return entry;
-}
-
-TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath)
-{
-  //
-  // Caches the entry <id> with cdb path <cdbPath>
-  //
-  
-  if (!fCDBCache[id])
-  {
-    fCDBEntries[id] = GetCDBEntry(cdbPath);
-    if (fCDBEntries[id])
-      fCDBCache[id] = fCDBEntries[id]->GetObject();
-  }
-  return fCDBCache[id];
-}
-
-TObject* AliTRDcalibDB::CacheMergeCDBEntry(Int_t id, const char* cdbPadPath, const char* cdbChamberPath)
-{
-  //
-  // Retrieves and caches an object (id <id>) from the CDB. This function is specialized for parameters which are stored
-  // as local variation at pad level of a global variable defined per detector chamber. It uses the classes AliTRDCalPad and AliTRDCalDet.
-  // Before storing the object it retrieves the local variations (cdbPadPath) and the global variable (cdbChamberPath) and merges them using
-  // the AliTRDCalPad::ScaleROCs.
-  //
-    
-  if (!fCDBCache[id]) 
-  {
-    AliTRDCalPad* padObject = 0;
-    AliTRDCalDet* detObject = 0;
-   
-    fCDBEntries[id] = GetCDBEntry(cdbPadPath);
-    if (fCDBEntries[id])
-      padObject = dynamic_cast<AliTRDCalPad*>(fCDBEntries[id]->GetObject());
-   
-    AliCDBEntry* mergeEntry = GetCDBEntry(cdbChamberPath);
-    if (mergeEntry)
-      detObject = dynamic_cast<AliTRDCalDet*>(mergeEntry->GetObject());
-    
-    if (!padObject || !detObject) 
-    {
-      if (fCDBEntries[id]) {
-        if (fCDBEntries[id]->IsOwner() == kFALSE && padObject)
-          delete padObject;
-        delete fCDBEntries[id];
-        fCDBEntries[id] = 0;
-      }
-      if (mergeEntry) 
-      {
-        if (mergeEntry->IsOwner() == kFALSE && detObject)
-          delete detObject;
-        delete mergeEntry;
-      }
-      return 0;
-    }
-    
-    padObject->ScaleROCs(detObject);
-    if (mergeEntry->IsOwner() == kFALSE)
-      delete detObject;
-    delete mergeEntry;
-    
-    fCDBCache[id] = padObject;
-  }
-  
-  return fCDBCache[id];
-}
-
 #endif
index 3d8733f1dda6caa772771ffc97d137cdb9afd824..eb4f888c967cedfe10b94286eaa53cfaad716fad 100644 (file)
@@ -97,7 +97,7 @@ Int_t AliTRDpidESD::MakePID(AliESD *event)
     return -1;
   
   // The class AliTRDCalPIDLQ contains precalculated prob dis.
-  AliTRDCalPIDLQ *pd = calibration->GetPIDLQObject();
+  const AliTRDCalPIDLQ *pd = calibration->GetPIDLQObject();
   if (!pd) return -1;
 
   //  Example to get mean for particle 2 (pi) and momentum number 4 (2 GeV)