]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONCalibrationData.cxx
Added protection and 2 levels for problems
[u/mrichter/AliRoot.git] / MUON / AliMUONCalibrationData.cxx
index eb814a538658eb208c17d65530f9564f83cb5754..0be3ad8d01bc4112e6394aca55b958de5b3cf9a7 100644 (file)
@@ -59,7 +59,9 @@ fLocalTriggerBoardMasks(0x0),
 fRegionalTriggerBoardMasks(0x0),
 fGlobalTriggerBoardMasks(0x0),
 fTriggerLut(0x0),
-fTriggerEfficiency(0x0)
+fTriggerEfficiency(0x0),
+fCapacitances(0x0),
+fNeighbours(0x0)
 {
 /// Default ctor.
 
@@ -79,24 +81,17 @@ fTriggerEfficiency(0x0)
     OnDemandGlobalTriggerBoardMasks();
     OnDemandTriggerLut();
     OnDemandTriggerEfficiency();
+    OnDemandCapacitances();
+    OnDemandNeighbours();
   }
 }
 
 //_____________________________________________________________________________
 AliMUONCalibrationData::~AliMUONCalibrationData()
 {
-/// Destructor. Note that we're the owner of our pointers.
-
-  delete fPedestals;
-  delete fGains;
-  delete fHV;
-  delete fLocalTriggerBoardMasks;
-  delete fRegionalTriggerBoardMasks;
-  delete fGlobalTriggerBoardMasks;
-  delete fTriggerLut;
-  delete fTriggerEfficiency;
+  /// Destructor. Note that we're the owner of our pointers.
+  Reset();
 }
-
 //_____________________________________________________________________________
 TMap*
 AliMUONCalibrationData::HV() const
@@ -152,18 +147,26 @@ AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
   AliMUONV2DStore* gains = Gains();
   if (!gains)
   {
-    AliError("Could not get gains");
     return 0x0;
   }
   
-  AliMUONVCalibParam* g = 
-    static_cast<AliMUONVCalibParam*>(gains->Get(detElemId,manuId));
-  if (!g)
-  {
-    AliError(Form("Could not get gain for detElemId=%d manuId=%d ",
-                    detElemId,manuId));
-  }
-  return g;
+  return static_cast<AliMUONVCalibParam*>(gains->Get(detElemId,manuId));
+}
+
+//_____________________________________________________________________________
+AliMUONV1DStore*
+AliMUONCalibrationData::Capacitances() const
+{
+  /// Create (if needed) and return the internal store for capacitances.
+  return OnDemandCapacitances();
+}
+
+//_____________________________________________________________________________
+AliMUONV2DStore*
+AliMUONCalibrationData::Neighbours() const
+{
+  /// Create (if needed) and return the internal store for neighbours.
+  return OnDemandNeighbours();
 }
 
 //_____________________________________________________________________________
@@ -174,6 +177,56 @@ AliMUONCalibrationData::Gains() const
   return OnDemandGains();
 }
 
+//_____________________________________________________________________________
+AliMUONV2DStore*
+AliMUONCalibrationData::OnDemandNeighbours() const
+{
+  /// Create (if needed) and return the internal store for neighbours.
+  
+  if (!fNeighbours)
+  {
+    AliCDBEntry* entry = GetEntry("MUON/Calib/Neighbours");
+    if (entry)
+    {
+      fNeighbours = dynamic_cast<AliMUONV2DStore*>(entry->GetObject());
+      if (!fNeighbours)
+      {
+        AliError("Neighbours not of the expected type !!!");
+      }
+    }
+    else
+    {
+      AliError("Could not get neighbours !");
+    }
+  }
+  return fNeighbours;
+}
+
+//_____________________________________________________________________________
+AliMUONV1DStore*
+AliMUONCalibrationData::OnDemandCapacitances() const
+{
+  /// Create (if needed) and return the internal store for capacitances.
+  
+  if (!fCapacitances)
+  {
+    AliCDBEntry* entry = GetEntry("MUON/Calib/Capacitances");
+    if (entry)
+    {
+      fCapacitances = dynamic_cast<AliMUONV1DStore*>(entry->GetObject());
+      if (!fCapacitances)
+      {
+        AliError("Capacitances not of the expected type !!!");
+      }
+    }
+    else
+    {
+      AliError("Could not get capacitances !");
+    }
+  }
+  return fCapacitances;
+}
+
 //_____________________________________________________________________________
 AliMUONV2DStore*
 AliMUONCalibrationData::OnDemandGains() const
@@ -199,6 +252,7 @@ AliMUONCalibrationData::OnDemandGains() const
   return fGains;
 }
 
+
 //_____________________________________________________________________________
 AliMUONVCalibParam* 
 AliMUONCalibrationData::GlobalTriggerBoardMasks() const
@@ -341,19 +395,10 @@ AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
   AliMUONV2DStore* pedestals = OnDemandPedestals();
   if (!pedestals) 
   {
-    AliError(Form("Did not find pedestals for DE %d manuId %d",
-                  detElemId,manuId));
     return 0x0;
   }
   
-  AliMUONVCalibParam* ped = 
-    static_cast<AliMUONVCalibParam*>(pedestals->Get(detElemId,manuId));
-  if (!ped)
-  {
-    AliError(Form("Could not get pedestal for detElemId=%d manuId=%d ",
-                  detElemId,manuId));
-  }
-  return ped;
+  return static_cast<AliMUONVCalibParam*>(pedestals->Get(detElemId,manuId));
 }
 
 //_____________________________________________________________________________
@@ -472,5 +517,33 @@ AliMUONCalibrationData::OnDemandTriggerLut() const
   return fTriggerLut;
 }
 
+//_____________________________________________________________________________
+void
+AliMUONCalibrationData::Reset()
+{
+/// Reset all data
+
+  delete fPedestals;
+  fPedestals = 0x0;
+  delete fGains;
+  fGains = 0x0;
+  delete fHV;
+  fHV = 0x0;
+  delete fLocalTriggerBoardMasks;
+  fLocalTriggerBoardMasks = 0x0;
+  delete fRegionalTriggerBoardMasks;
+  fRegionalTriggerBoardMasks = 0x0;
+  delete fGlobalTriggerBoardMasks;
+  fGlobalTriggerBoardMasks = 0x0;
+  delete fTriggerLut;
+  fTriggerLut = 0x0;
+  delete fTriggerEfficiency;
+  fTriggerEfficiency = 0x0;
+  delete fCapacitances;
+  fCapacitances = 0x0;
+  delete fNeighbours;
+  fNeighbours = 0x0;
+}
+