Skip to content

Commit

Permalink
protect against bogus hcal det Ids even if they should not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlange6 committed Oct 23, 2015
1 parent 1efc493 commit c3e52ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class HcalBaseSignalGenerator;
class HcalShapes;
class PCaloHit;
class PileUpEventPrincipal;
class HcalTopology;

namespace edm {
class ConsumesCollector;
Expand Down Expand Up @@ -61,7 +62,7 @@ class HcalDigitizer
void setZDCNoiseSignalGenerator(HcalBaseSignalGenerator * noiseGenerator);

private:
void accumulateCaloHits(edm::Handle<std::vector<PCaloHit> > const& hcalHits, edm::Handle<std::vector<PCaloHit> > const& zdcHits, int bunchCrossing, CLHEP::HepRandomEngine*);
void accumulateCaloHits(edm::Handle<std::vector<PCaloHit> > const& hcalHits, edm::Handle<std::vector<PCaloHit> > const& zdcHits, int bunchCrossing, CLHEP::HepRandomEngine*, const HcalTopology *h);

/// some hits in each subdetector, just for testing purposes
void fillFakeHits();
Expand Down
28 changes: 24 additions & 4 deletions SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,23 @@ void HcalDigitizer::initializeEvent(edm::Event const& e, edm::EventSetup const&

}

void HcalDigitizer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit> > const& hcalHandle, edm::Handle<std::vector<PCaloHit> > const& zdcHandle, int bunchCrossing, CLHEP::HepRandomEngine* engine) {
void HcalDigitizer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit> > const& hcalHandle, edm::Handle<std::vector<PCaloHit> > const& zdcHandle, int bunchCrossing, CLHEP::HepRandomEngine* engine, const HcalTopology *htopoP) {

// Step A: pass in inputs, and accumulate digirs
if(isHCAL) {
std::vector<PCaloHit> hcalHits = *hcalHandle.product();
std::vector<PCaloHit> hcalHitsOrig = *hcalHandle.product();
std::vector<PCaloHit> 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);
Expand Down Expand Up @@ -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<HcalTopology> htopo;
eventSetup.get<HcalRecNumberingRecord>().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) {
Expand All @@ -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<HcalTopology> htopo;
eventSetup.get<HcalRecNumberingRecord>().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) {
Expand Down

0 comments on commit c3e52ad

Please sign in to comment.