From 0742fcef030a66f5ad8d012213a9fbe30beba51a Mon Sep 17 00:00:00 2001 From: David Date: Fri, 23 Oct 2015 10:47:34 +0200 Subject: [PATCH 1/2] protect against bogus hcal det Ids even if they should not exist --- .../interface/HcalDigitizer.h | 3 +- .../HcalSimProducers/src/HcalDigitizer.cc | 28 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h index 7ffbe8a6d2d90..b0782f4b063e8 100644 --- a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h +++ b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h @@ -31,6 +31,7 @@ class HcalBaseSignalGenerator; class HcalShapes; class PCaloHit; class PileUpEventPrincipal; +class HcalTopology; namespace edm { class ConsumesCollector; @@ -61,7 +62,7 @@ class HcalDigitizer void setZDCNoiseSignalGenerator(HcalBaseSignalGenerator * noiseGenerator); private: - void accumulateCaloHits(edm::Handle > const& hcalHits, edm::Handle > const& zdcHits, int bunchCrossing, CLHEP::HepRandomEngine*); + void accumulateCaloHits(edm::Handle > const& hcalHits, edm::Handle > const& zdcHits, int bunchCrossing, CLHEP::HepRandomEngine*, const HcalTopology *h); /// some hits in each subdetector, just for testing purposes void fillFakeHits(); diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index 331026d8bdb1e..96845d41463e2 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -431,11 +431,23 @@ void HcalDigitizer::initializeEvent(edm::Event const& e, edm::EventSetup const& } -void HcalDigitizer::accumulateCaloHits(edm::Handle > const& hcalHandle, edm::Handle > const& zdcHandle, int bunchCrossing, CLHEP::HepRandomEngine* engine) { +void HcalDigitizer::accumulateCaloHits(edm::Handle > const& hcalHandle, edm::Handle > const& zdcHandle, int bunchCrossing, CLHEP::HepRandomEngine* engine, const HcalTopology *htopoP) { // Step A: pass in inputs, and accumulate digirs if(isHCAL) { - std::vector hcalHits = *hcalHandle.product(); + std::vector hcalHitsOrig = *hcalHandle.product(); + std::vector hcalHits; + hcalHits.reserve(hcalHitsOrig.size()); + + for ( unsigned int i=0; i< hcalHitsOrig.size(); i++) { + DetId id(hcalHitsOrig[i].id()); + HcalDetId hid(id); + + // if ( id.subdetId()==2 && hid.ietaAbs()<16 ) edm::LogError("HcalDigitizer") << "bad hcal id found in digitizer. Skipping " << id.rawId() << std::endl; + if ( htopoP->validHcal(hid) ) edm::LogError("HcalDigitizer") << "bad hcal id found in digitizer. Skipping " << id.rawId() << std::endl; + else + hcalHits.push_back(hcalHitsOrig[i]); + } //evaluate darkening before relabeling if(m_HEDarkening || m_HFRecalibration){ darkening(hcalHits); @@ -490,7 +502,11 @@ void HcalDigitizer::accumulate(edm::Event const& e, edm::EventSetup const& event e.getByLabel(hcalTag, hcalHandle); isHCAL = hcalHandle.isValid(); - accumulateCaloHits(hcalHandle, zdcHandle, 0, engine); + edm::ESHandle htopo; + eventSetup.get().get(htopo); + const HcalTopology *htopoP=htopo.product(); + + accumulateCaloHits(hcalHandle, zdcHandle, 0, engine, htopoP); } void HcalDigitizer::accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& eventSetup, CLHEP::HepRandomEngine* engine) { @@ -505,7 +521,11 @@ void HcalDigitizer::accumulate(PileUpEventPrincipal const& e, edm::EventSetup co e.getByLabel(hcalTag, hcalHandle); isHCAL = hcalHandle.isValid(); - accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine); + edm::ESHandle htopo; + eventSetup.get().get(htopo); + const HcalTopology *htopoP=htopo.product(); + + accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine, htopoP); } void HcalDigitizer::finalizeEvent(edm::Event& e, const edm::EventSetup& eventSetup, CLHEP::HepRandomEngine* engine) { From efe6811c4a33a8ed4a294d562491b63d2b0a4e6b Mon Sep 17 00:00:00 2001 From: David Date: Fri, 23 Oct 2015 10:54:45 +0200 Subject: [PATCH 2/2] whoops its when its NOT valid --- SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index 96845d41463e2..08d363b0c47a5 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -444,7 +444,7 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle > const HcalDetId hid(id); // if ( id.subdetId()==2 && hid.ietaAbs()<16 ) edm::LogError("HcalDigitizer") << "bad hcal id found in digitizer. Skipping " << id.rawId() << std::endl; - if ( htopoP->validHcal(hid) ) edm::LogError("HcalDigitizer") << "bad hcal id found in digitizer. Skipping " << id.rawId() << std::endl; + if ( !htopoP->validHcal(hid) ) edm::LogError("HcalDigitizer") << "bad hcal id found in digitizer. Skipping " << id.rawId() << std::endl; else hcalHits.push_back(hcalHitsOrig[i]); }