From 20bcfcc3dfbb35655be3fb20902206d0b6f107c9 Mon Sep 17 00:00:00 2001
From: Walter Lampl <Walter.Lampl@cern.ch>
Date: Fri, 20 Feb 2015 13:12:15 +0100
Subject: [PATCH] LArCellRec:Protect against hvcorr=0.0 (LArCellRec-02-12-93)

2015-02-20 Walter Lampl <walter.lampl@ cern.ch>
	* LArCellRec:Protect against hvcorr=0.0
	* tag LArCellRec-02-12-93

2015-02-04 Charles Leggett
	* make Hive compatible (no DataPools for now) with #ifdef ATHENAHIVE
	* tag LArCellRec-02-12-92

M       src/LArCellBuilderFromLArRawChannelTool.cxx

2015-01-30 Hong Ma<hma@bnl.gov>
---
 .../src/LArCellBuilderFromLArRawChannelTool.cxx          | 9 +++++++++
 LArCalorimeter/LArCellRec/src/LArCellHVCorr.cxx          | 9 ++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/LArCalorimeter/LArCellRec/src/LArCellBuilderFromLArRawChannelTool.cxx b/LArCalorimeter/LArCellRec/src/LArCellBuilderFromLArRawChannelTool.cxx
index 75a99d46471..14ea1c75309 100755
--- a/LArCalorimeter/LArCellRec/src/LArCellBuilderFromLArRawChannelTool.cxx
+++ b/LArCalorimeter/LArCellRec/src/LArCellBuilderFromLArRawChannelTool.cxx
@@ -170,8 +170,13 @@ LArCellBuilderFromLArRawChannelTool::geoInit(IOVSVC_CALLBACK_ARGS) {
 // ========================================================================================== //
 StatusCode LArCellBuilderFromLArRawChannelTool::process(CaloCellContainer * theCellContainer) {
  
+#ifndef ATHENAHIVE
   if (theCellContainer->ownPolicy() == SG::OWN_ELEMENTS) {
     msg(MSG::ERROR) << "Called with a CaloCellContainer with wrong ownership policy! Need a VIEW container!" << endreq;
+#else
+  if (theCellContainer->ownPolicy() != SG::OWN_ELEMENTS) {
+    msg(MSG::ERROR) << "Called with a CaloCellContainer with wrong ownership policy! Need a OWN container!" << endreq;
+#endif
     return StatusCode::FAILURE;
   }
 
@@ -296,10 +301,14 @@ LArCell* LArCellBuilderFromLArRawChannelTool::getCell(const LArRawChannel& theRa
     const uint16_t provenance = (theRawChannel.provenance() & 0x3FFF);   // to be sure not to set by error "dead" bit
     const CaloGain::CaloGain gain = theRawChannel.gain();
 
+#ifndef ATHENAHIVE
     static DataPool<LArCell> larCellsP(m_initialDataPoolSize);
       
     //LArCell * theCell = new LArCell(theDDE,energy,time,quality,gain);
     LArCell *pCell   = larCellsP.nextElementPtr();
+#else
+    LArCell *pCell   = new LArCell();
+#endif
     pCell->m_energy  = energy;
     pCell->m_time    = time;    
     pCell->m_qualProv[0] = quality;
diff --git a/LArCalorimeter/LArCellRec/src/LArCellHVCorr.cxx b/LArCalorimeter/LArCellRec/src/LArCellHVCorr.cxx
index e141950d8f9..c476927d8bb 100755
--- a/LArCalorimeter/LArCellRec/src/LArCellHVCorr.cxx
+++ b/LArCalorimeter/LArCellRec/src/LArCellHVCorr.cxx
@@ -57,6 +57,13 @@ void LArCellHVCorr::MakeCorrection(CaloCell* theCell) {
     if (hvonline>0. && hvonline<100.) hvcorr = hvcorr/hvonline;
   }
 
-  theCell->setEnergy(theCell->energy()*hvcorr);
+  if (hvcorr>0.01) {
+    //hvcorr might be zero in case of problems with the DCS database
+    theCell->setEnergy(theCell->energy()*hvcorr);
+  }
+  // else
+  //   msg(MSG::WARNING) << "HVScaleCorr is zero for cell with id 0x" 
+  // 		      << std::hex << theCell->ID().get_identifier32().get_compact() << std::dec 
+  // 		      << " Correction NOT applied" << std::endl;
   return;
 }
-- 
GitLab