Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-hcx369 Allow only valid ZDChits to enter the digitization phase #46286

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Geometry/ForwardGeometry/src/ZdcTopology.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool ZdcTopology::isExcluded(const HcalZDCDetId& id) const {
exed = excludeRPD_;
break;
default:
exed = false;
exed = true;
}

// check the entire list
Expand Down Expand Up @@ -167,7 +167,6 @@ bool ZdcTopology::validRaw(const HcalZDCDetId& id) const {
ok = false;
else if (id.channel() <= 0)
ok = false;
//else if (!(id.section() == HcalZDCDetId::EM || id.section() == HcalZDCDetId::HAD || id.section() == HcalZDCDetId::LUM))
else if (!(id.section() == HcalZDCDetId::EM || id.section() == HcalZDCDetId::HAD ||
id.section() == HcalZDCDetId::LUM || id.section() == HcalZDCDetId::RPD))
ok = false;
Expand All @@ -179,6 +178,8 @@ bool ZdcTopology::validRaw(const HcalZDCDetId& id) const {
ok = false;
else if (id.section() == HcalZDCDetId::RPD && id.channel() > HcalZDCDetId::kDepRPD)
ok = false;
else if (id.section() == HcalZDCDetId::Unknown)
ok = false;
return ok;
}

Expand Down
1 change: 1 addition & 0 deletions SimCalorimetry/HcalSimProducers/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/Utilities"/>
<use name="Geometry/ForwardGeometry"/>
<use name="SimCalorimetry/HcalSimAlgos"/>
<use name="SimGeneral/MixingModule"/>
<use name="DataFormats/HcalDetId"/>
Expand Down
5 changes: 4 additions & 1 deletion SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class HcalBaseSignalGenerator;
class HcalShapes;
class PileUpEventPrincipal;
class HcalTopology;
class ZdcTopology;

namespace CLHEP {
class HepRandomEngine;
Expand Down Expand Up @@ -67,7 +68,8 @@ class HcalDigitizer {
edm::Handle<std::vector<PCaloHit>> const &zdcHits,
int bunchCrossing,
CLHEP::HepRandomEngine *,
const HcalTopology *h);
const HcalTopology *h,
const ZdcTopology *z);

/// some hits in each subdetector, just for testing purposes
void fillFakeHits();
Expand All @@ -86,6 +88,7 @@ class HcalDigitizer {

const edm::ESGetToken<HcalDbService, HcalDbRecord> conditionsToken_;
const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> topoToken_;
const edm::ESGetToken<ZdcTopology, HcalRecNumberingRecord> topoZToken_;
edm::ESGetToken<HBHEDarkening, HBHEDarkeningRecord> m_HBDarkeningToken;
edm::ESGetToken<HBHEDarkening, HBHEDarkeningRecord> m_HEDarkeningToken;
const edm::ESGetToken<HcalTimeSlew, HcalTimeSlewRecord> hcalTimeSlew_delay_token_;
Expand Down
31 changes: 27 additions & 4 deletions SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "Geometry/CaloTopology/interface/HcalTopology.h"
#include "Geometry/ForwardGeometry/interface/ZdcTopology.h"
#include "SimCalorimetry/CaloSimAlgos/interface/CaloHitResponse.h"
#include "SimCalorimetry/CaloSimAlgos/interface/CaloTDigitizer.h"
#include "SimCalorimetry/HcalSimAlgos/interface/HPDIonFeedbackSim.h"
Expand All @@ -34,6 +35,7 @@
HcalDigitizer::HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
: conditionsToken_(iC.esConsumes()),
topoToken_(iC.esConsumes()),
topoZToken_(iC.esConsumes()),
hcalTimeSlew_delay_token_(iC.esConsumes(edm::ESInputTag("", "HBHE"))),
theGeometryToken(iC.esConsumes()),
theRecNumberToken(iC.esConsumes()),
Expand Down Expand Up @@ -348,7 +350,8 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit>> const
edm::Handle<std::vector<PCaloHit>> const &zdcHandle,
int bunchCrossing,
CLHEP::HepRandomEngine *engine,
const HcalTopology *htopoP) {
const HcalTopology *htopoP,
const ZdcTopology *ztopoP) {
// Step A: pass in inputs, and accumulate digis
if (isHCAL) {
std::vector<PCaloHit> hcalHitsOrig = *hcalHandle.product();
Expand Down Expand Up @@ -420,7 +423,25 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit>> const

if (isZDC) {
if (zdcgeo && theZDCDigitizer) {
theZDCDigitizer->add(*zdcHandle.product(), bunchCrossing, engine);
std::vector<PCaloHit> zdcHitsOrig = *zdcHandle.product();
std::vector<PCaloHit> zdcHits;
zdcHits.reserve(zdcHitsOrig.size());
// eliminate bad hits
for (unsigned int i = 0; i < zdcHitsOrig.size(); i++) {
DetId id(zdcHitsOrig[i].id());
HcalZDCDetId hid(id);
if (!ztopoP->valid(hid)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsunanda , in real run there will be many events. Is it correct to have unlimited printouts of wrong ZDC hits?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shall protect the printout of good ones - but the wrong DetId is an error and should not happen in normal runs. We have similar error printouts for HCAL which do not produce large printouts

edm::LogError("HcalDigitizer") << "bad zdc id found in digitizer. Skipping " << std::hex << id.rawId()
<< std::dec << " " << hid;
continue;
}
zdcHits.push_back(zdcHitsOrig[i]);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HcalSim") << "Hit " << i << " out of " << zdcHitsOrig.size() << " " << std::hex << id.rawId()
<< " " << hid;
#endif
}
theZDCDigitizer->add(zdcHits, bunchCrossing, engine);
}
} else {
edm::LogInfo("HcalDigitizer") << "We don't have ZDC hit collection available ";
Expand All @@ -436,8 +457,9 @@ void HcalDigitizer::accumulate(edm::Event const &e, edm::EventSetup const &event
isHCAL = hcalHandle.isValid() or injectTestHits_;

const HcalTopology *htopoP = &eventSetup.getData(topoToken_);
const ZdcTopology *ztopoP = &eventSetup.getData(topoZToken_);

accumulateCaloHits(hcalHandle, zdcHandle, 0, engine, htopoP);
accumulateCaloHits(hcalHandle, zdcHandle, 0, engine, htopoP, ztopoP);
}

void HcalDigitizer::accumulate(PileUpEventPrincipal const &e,
Expand All @@ -455,8 +477,9 @@ void HcalDigitizer::accumulate(PileUpEventPrincipal const &e,
isHCAL = hcalHandle.isValid();

const HcalTopology *htopoP = &eventSetup.getData(topoToken_);
const ZdcTopology *ztopoP = &eventSetup.getData(topoZToken_);

accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine, htopoP);
accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine, htopoP, ztopoP);
}

void HcalDigitizer::finalizeEvent(edm::Event &e, const edm::EventSetup &eventSetup, CLHEP::HepRandomEngine *engine) {
Expand Down