From cb937f5759f17bc0fd79eb0eeccef2925bae07e1 Mon Sep 17 00:00:00 2001 From: Andre Govinda Stahl Leiton Date: Tue, 11 Oct 2022 15:46:19 +0200 Subject: [PATCH 1/2] Changed HGCAL simulated time from (0,0,0) to detector position Implement code style changes Add protection for missing geometry Implemented review changes Implmented futher comments from Marco Fix issue for toa --- .../modules/HGCalUncalibRecHitL1Seeded_cfi.py | 4 ++ .../modules/HGCalUncalibRecHit_cfi.py | 4 ++ .../HGCalUncalibRecHitRecWeightsAlgo.h | 31 ++++++----- .../HGCalUncalibRecHitWorkerBaseClass.h | 17 ++++--- .../plugins/HGCalLayerClusterProducer.cc | 2 +- .../plugins/HGCalRecHitWorkerSimple.cc | 2 +- .../plugins/HGCalUncalibRecHitProducer.cc | 50 ++++++------------ .../plugins/HGCalUncalibRecHitProducer.h | 13 +++-- .../HGCalUncalibRecHitWorkerWeights.cc | 51 +++++++++---------- .../plugins/HGCalUncalibRecHitWorkerWeights.h | 22 +++++--- .../python/HGCalUncalibRecHit_cfi.py | 6 ++- .../SimMappers/RealisticSimClusterMapper.cc | 2 +- .../interface/HGCDigitizer.h | 3 -- .../HGCalSimProducers/plugins/HGCDigitizer.cc | 13 ++--- .../python/hgcalDigitizer_cfi.py | 8 +-- 15 files changed, 113 insertions(+), 115 deletions(-) diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py index 884ce87eefc4c..e270470d447a7 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py @@ -9,6 +9,7 @@ tdcNbits = cms.uint32(12), tdcOnset = cms.double(60), tdcSaturation = cms.double(10000), + tofDelay = cms.double(-9), toaLSB_ns = cms.double(0.0244) ), HGCEEdigiCollection = cms.InputTag("hgcalDigisL1Seeded","EE"), @@ -21,6 +22,7 @@ tdcNbits = cms.uint32(12), tdcOnset = cms.double(55), tdcSaturation = cms.double(1000), + tofDelay = cms.double(-14), toaLSB_ns = cms.double(0.0244) ), HGCHEBdigiCollection = cms.InputTag("hgcalDigisL1Seeded","HEback"), @@ -33,6 +35,7 @@ tdcNbits = cms.uint32(12), tdcOnset = cms.double(60), tdcSaturation = cms.double(10000), + tofDelay = cms.double(-11), toaLSB_ns = cms.double(0.0244) ), HGCHEFdigiCollection = cms.InputTag("hgcalDigisL1Seeded","HEfront"), @@ -45,6 +48,7 @@ tdcNbits = cms.uint32(12), tdcOnset = cms.double(60), tdcSaturation = cms.double(10000), + tofDelay = cms.double(-33), toaLSB_ns = cms.double(0.0244) ), HGCHFNosedigiCollection = cms.InputTag("hfnoseDigis","HFNose"), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py index 86b33ebc15588..031e9e33e8182 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py @@ -9,6 +9,7 @@ tdcNbits = cms.uint32(12), tdcOnset = cms.double(60), tdcSaturation = cms.double(10000), + tofDelay = cms.double(-9), toaLSB_ns = cms.double(0.0244) ), HGCEEdigiCollection = cms.InputTag("hgcalDigis","EE"), @@ -21,6 +22,7 @@ tdcNbits = cms.uint32(12), tdcOnset = cms.double(55), tdcSaturation = cms.double(1000), + tofDelay = cms.double(-14), toaLSB_ns = cms.double(0.0244) ), HGCHEBdigiCollection = cms.InputTag("hgcalDigis","HEback"), @@ -33,6 +35,7 @@ tdcNbits = cms.uint32(12), tdcOnset = cms.double(60), tdcSaturation = cms.double(10000), + tofDelay = cms.double(-11), toaLSB_ns = cms.double(0.0244) ), HGCHEFdigiCollection = cms.InputTag("hgcalDigis","HEfront"), @@ -45,6 +48,7 @@ tdcNbits = cms.uint32(12), tdcOnset = cms.double(60), tdcSaturation = cms.double(10000), + tofDelay = cms.double(-33), toaLSB_ns = cms.double(0.0244) ), HGCHFNosedigiCollection = cms.InputTag("hfnoseDigis","HFNose"), diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h index 23333f74d799a..b4ff5fe08da00 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h @@ -33,6 +33,8 @@ class HGCalUncalibRecHitRecWeightsAlgo { void set_tdcOnsetfC(const double tdcOnset) { tdcOnsetfC_ = tdcOnset; } + void set_tofDelay(const double tofDelay) { tofDelay_ = tofDelay; } + void set_fCPerMIP(const std::vector& fCPerMIP) { if (std::any_of(fCPerMIP.cbegin(), fCPerMIP.cend(), [](double conv) { return conv <= 0.0; })) { throw cms::Exception("BadConversionFactor") << "At least one of fCPerMIP is zero!" << std::endl; @@ -40,16 +42,17 @@ class HGCalUncalibRecHitRecWeightsAlgo { fCPerMIP_ = fCPerMIP; } - void setGeometry(const HGCalGeometry* geom) { - if (geom) - ddd_ = &(geom->topology().dddConstants()); + void setGeometry(const edm::ESHandle& geom) { + geom_ = geom.isValid() ? geom.product() : nullptr; + if (isSiFESim_ && geom_) + ddd_ = &(geom_->topology().dddConstants()); else ddd_ = nullptr; } /// Compute HGCUncalibratedRecHit from DataFrame virtual HGCUncalibratedRecHit makeRecHit(const C& dataFrame) { - double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.); + double amplitude_(-1.), pedestal_(-1.), jitter_(-99.), chi2_(-1.); uint32_t flag = 0; constexpr int iSample = 2; //only in-time sample @@ -68,23 +71,21 @@ class HGCalUncalibRecHitRecWeightsAlgo { // LG (11/04/2016): // offset the TDC upwards to reflect the bin center amplitude_ = (std::floor(tdcOnsetfC_ / adcLSB_) + 1.0) * adcLSB_ + (double(sample.data()) + 0.5) * tdcLSB_; - - if (sample.getToAValid()) { - jitter_ = double(sample.toa()) * toaLSBToNS_; - } } else { amplitude_ = double(sample.data()) * adcLSB_; // why do we not have +0.5 here ? - if (sample.getToAValid()) { - jitter_ = double(sample.toa()) * toaLSBToNS_; - } - } //isSiFESim_ - } //mode() + } //isSiFESim_ + } //mode() // trivial digitization, i.e. no signal shape else { amplitude_ = double(sample.data()) * adcLSB_; } + if (sample.getToAValid()) { + const auto& dist2center = geom_ ? geom_->getPosition(dataFrame.id()).mag() : 0; + jitter_ = double(sample.toa()) * toaLSBToNS_ - dist2center / c_cm_ns - tofDelay_; + } + int thickness = (ddd_ != nullptr) ? ddd_->waferType(dataFrame.id()) : 0; amplitude_ = amplitude_ / fCPerMIP_[thickness]; @@ -100,9 +101,11 @@ class HGCalUncalibRecHitRecWeightsAlgo { } private: - double adcLSB_, tdcLSB_, toaLSBToNS_, tdcOnsetfC_; + static constexpr float c_cm_ns = CLHEP::c_light * CLHEP::ns / CLHEP::cm; + double adcLSB_, tdcLSB_, toaLSBToNS_, tdcOnsetfC_, tofDelay_; bool isSiFESim_; std::vector fCPerMIP_; const HGCalDDDConstants* ddd_; + const HGCalGeometry* geom_; }; #endif diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerBaseClass.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerBaseClass.h index c291f8b0966a0..ba695de9e76a9 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerBaseClass.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerBaseClass.h @@ -4,6 +4,7 @@ #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" #include "DataFormats/HGCDigi/interface/HGCDigiCollections.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" namespace edm { class Event; @@ -18,22 +19,24 @@ class HGCalUncalibRecHitWorkerBaseClass { HGCalUncalibRecHitWorkerBaseClass(const edm::ParameterSet& ps, edm::ConsumesCollector iC) {} virtual ~HGCalUncalibRecHitWorkerBaseClass() {} - // do event setup things - virtual void set(const edm::EventSetup& es) = 0; - // run HGC-EE things - virtual bool runHGCEE(const HGCalDigiCollection::const_iterator& digi, HGCeeUncalibratedRecHitCollection& result) = 0; + virtual bool runHGCEE(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, + HGCeeUncalibratedRecHitCollection& result) = 0; // run HGC-FH things - virtual bool runHGCHEsil(const HGCalDigiCollection::const_iterator& digi, + virtual bool runHGCHEsil(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGChefUncalibratedRecHitCollection& result) = 0; // run HGC-BH things - virtual bool runHGCHEscint(const HGCalDigiCollection::const_iterator& digi, + virtual bool runHGCHEscint(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGChebUncalibratedRecHitCollection& result) = 0; // run HFNose things - virtual bool runHGCHFNose(const HGCalDigiCollection::const_iterator& digi, + virtual bool runHGCHFNose(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGChfnoseUncalibratedRecHitCollection& result) = 0; }; diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index 5a268c9bc55cd..2afb949d1ca64 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -221,7 +221,7 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt, const edm::EventSetup& //check on timeError to exclude scintillator if (rhTimeE < 0.) continue; - timeClhits.push_back(rechit->time() - timeOffset); + timeClhits.push_back(rechit->time()); timeErrorClhits.push_back(1. / (rhTimeE * rhTimeE)); } hgcalsimclustertime::ComputeClusterTime timeEstimator; diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalRecHitWorkerSimple.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalRecHitWorkerSimple.cc index c379e736e932a..1edc0c1bf1feb 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalRecHitWorkerSimple.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalRecHitWorkerSimple.cc @@ -219,7 +219,7 @@ bool HGCalRecHitWorkerSimple::run(const edm::Event& evt, float SoN = new_E / sigmaNoiseGeV; myrechit.setSignalOverSigmaNoise(SoN); - if (detid.det() == DetId::HGCalHSc || myrechit.time() < 0.) { + if (detid.det() == DetId::HGCalHSc || myrechit.time() == -99.) { myrechit.setTimeError(-1.); } else { float timeError = timeEstimatorSi_.getTimeError("recHit", SoN); diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.cc index 35d1d8f16289d..4de1603e8eca4 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.cc @@ -14,6 +14,10 @@ HGCalUncalibRecHitProducer::HGCalUncalibRecHitProducer(const edm::ParameterSet& hefDigiCollection_(consumes(ps.getParameter("HGCHEFdigiCollection"))), hebDigiCollection_(consumes(ps.getParameter("HGCHEBdigiCollection"))), hfnoseDigiCollection_(consumes(ps.getParameter("HGCHFNosedigiCollection"))), + ee_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalEESensitive"))), + hef_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalHESiliconSensitive"))), + heb_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalHEScintillatorSensitive"))), + hfnose_geometry_token_(esConsumes(edm::ESInputTag("", "HGCalHFNoseSensitive"))), eeHitCollection_(ps.getParameter("HGCEEhitCollection")), hefHitCollection_(ps.getParameter("HGCHEFhitCollection")), hebHitCollection_(ps.getParameter("HGCHEBhitCollection")), @@ -31,9 +35,6 @@ HGCalUncalibRecHitProducer::~HGCalUncalibRecHitProducer() {} void HGCalUncalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& es) { using namespace edm; - // tranparently get things from event setup - worker_->set(es); - // prepare output auto eeUncalibRechits = std::make_unique(); auto hefUncalibRechits = std::make_unique(); @@ -41,43 +42,24 @@ void HGCalUncalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& auto hfnoseUncalibRechits = std::make_unique(); // loop over HGCEE digis - edm::Handle pHGCEEDigis; - evt.getByToken(eeDigiCollection_, pHGCEEDigis); - const HGCalDigiCollection* eeDigis = pHGCEEDigis.product(); - eeUncalibRechits->reserve(eeDigis->size()); - for (auto itdg = eeDigis->begin(); itdg != eeDigis->end(); ++itdg) { - worker_->runHGCEE(itdg, *eeUncalibRechits); - } + const auto& pHGCEEDigis = evt.getHandle(eeDigiCollection_); + if (pHGCEEDigis.isValid()) + worker_->runHGCEE(es.getHandle(ee_geometry_token_), *pHGCEEDigis, *eeUncalibRechits); // loop over HGCHEsil digis - edm::Handle pHGCHEFDigis; - evt.getByToken(hefDigiCollection_, pHGCHEFDigis); - const HGCalDigiCollection* hefDigis = pHGCHEFDigis.product(); - hefUncalibRechits->reserve(hefDigis->size()); - for (auto itdg = hefDigis->begin(); itdg != hefDigis->end(); ++itdg) { - worker_->runHGCHEsil(itdg, *hefUncalibRechits); - } + const auto& pHGCHEFDigis = evt.getHandle(hefDigiCollection_); + if (pHGCHEFDigis.isValid()) + worker_->runHGCHEsil(es.getHandle(hef_geometry_token_), *pHGCHEFDigis, *hefUncalibRechits); // loop over HGCHEscint digis - edm::Handle pHGCHEBDigis; - evt.getByToken(hebDigiCollection_, pHGCHEBDigis); - const HGCalDigiCollection* hebDigis = pHGCHEBDigis.product(); - hebUncalibRechits->reserve(hebDigis->size()); - for (auto itdg = hebDigis->begin(); itdg != hebDigis->end(); ++itdg) { - worker_->runHGCHEscint(itdg, *hebUncalibRechits); - } + const auto& pHGCHEBDigis = evt.getHandle(hebDigiCollection_); + if (pHGCHEBDigis.isValid()) + worker_->runHGCHEscint(es.getHandle(heb_geometry_token_), *pHGCHEBDigis, *hebUncalibRechits); // loop over HFNose digis - edm::Handle pHGCHFNoseDigis; - evt.getByToken(hfnoseDigiCollection_, pHGCHFNoseDigis); - if (pHGCHFNoseDigis.isValid()) { - const HGCalDigiCollection* hfnoseDigis = pHGCHFNoseDigis.product(); - if (!(hfnoseDigis->empty())) { - hfnoseUncalibRechits->reserve(hfnoseDigis->size()); - for (auto itdg = hfnoseDigis->begin(); itdg != hfnoseDigis->end(); ++itdg) - worker_->runHGCHFNose(itdg, *hfnoseUncalibRechits); - } - } + const auto& pHGCHFNoseDigis = evt.getHandle(hfnoseDigiCollection_); + if (pHGCHFNoseDigis.isValid()) + worker_->runHGCHFNose(es.getHandle(hfnose_geometry_token_), *pHGCHFNoseDigis, *hfnoseUncalibRechits); // put the collection of recunstructed hits in the event evt.put(std::move(eeUncalibRechits), eeHitCollection_); diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.h b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.h index ddec377010b70..132a7dac48e0d 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.h +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.h @@ -17,10 +17,15 @@ class HGCalUncalibRecHitProducer : public edm::stream::EDProducer<> { void produce(edm::Event& evt, const edm::EventSetup& es) override; private: - const edm::EDGetTokenT eeDigiCollection_; // collection of HGCEE digis - const edm::EDGetTokenT hefDigiCollection_; // collection of HGCHEF digis - edm::EDGetTokenT hebDigiCollection_; // collection of HGCHEB digis - edm::EDGetTokenT hfnoseDigiCollection_; // collection of HGCHFNose digis + const edm::EDGetTokenT eeDigiCollection_; // collection of HGCEE digis + const edm::EDGetTokenT hefDigiCollection_; // collection of HGCHEF digis + const edm::EDGetTokenT hebDigiCollection_; // collection of HGCHEB digis + const edm::EDGetTokenT hfnoseDigiCollection_; // collection of HGCHFNose digis + + const edm::ESGetToken ee_geometry_token_; + const edm::ESGetToken hef_geometry_token_; + const edm::ESGetToken heb_geometry_token_; + const edm::ESGetToken hfnose_geometry_token_; const std::string eeHitCollection_; // instance name of HGCEE collection of hits const std::string hefHitCollection_; // instance name of HGCHEF collection of hits diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc index f5184b1b1384f..11d650f16b1a8 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc @@ -55,13 +55,12 @@ void configureIt(const edm::ParameterSet& conf, HGCalUncalibRecHitRecWeightsAlgo } else { maker.set_fCPerMIP(std::vector({1.0})); } + + maker.set_tofDelay(conf.getParameter("tofDelay")); } HGCalUncalibRecHitWorkerWeights::HGCalUncalibRecHitWorkerWeights(const edm::ParameterSet& ps, edm::ConsumesCollector iC) - : HGCalUncalibRecHitWorkerBaseClass(ps, iC), - ee_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalEESensitive"))), - hef_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalHESiliconSensitive"))), - hfnose_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalHFNoseSensitive"))) { + : HGCalUncalibRecHitWorkerBaseClass(ps, iC) { const edm::ParameterSet& ee_cfg = ps.getParameterSet("HGCEEConfig"); const edm::ParameterSet& hef_cfg = ps.getParameterSet("HGCHEFConfig"); const edm::ParameterSet& heb_cfg = ps.getParameterSet("HGCHEBConfig"); @@ -72,41 +71,39 @@ HGCalUncalibRecHitWorkerWeights::HGCalUncalibRecHitWorkerWeights(const edm::Para configureIt(hfnose_cfg, uncalibMaker_hfnose_); } -void HGCalUncalibRecHitWorkerWeights::set(const edm::EventSetup& es) { - if (uncalibMaker_ee_.isSiFESim()) { - uncalibMaker_ee_.setGeometry(&es.getData(ee_geometry_token_)); - } - if (uncalibMaker_hef_.isSiFESim()) { - uncalibMaker_hef_.setGeometry(&es.getData(hef_geometry_token_)); - } - uncalibMaker_heb_.setGeometry(nullptr); - if (uncalibMaker_hfnose_.isSiFESim()) { - uncalibMaker_hfnose_.setGeometry(&es.getData(hfnose_geometry_token_)); - } +bool HGCalUncalibRecHitWorkerWeights::run(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, + HGCalUncalibRecHitRecWeightsAlgo& uncalibMaker, + edm::SortedCollection& result) { + uncalibMaker.setGeometry(geom); + result.reserve(digis.size()); + for (const auto& digi : digis) + result.push_back(uncalibMaker.makeRecHit(digi)); + return true; } -bool HGCalUncalibRecHitWorkerWeights::runHGCEE(const HGCalDigiCollection::const_iterator& itdg, +bool HGCalUncalibRecHitWorkerWeights::runHGCEE(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGCeeUncalibratedRecHitCollection& result) { - result.push_back(uncalibMaker_ee_.makeRecHit(*itdg)); - return true; + return run(geom, digis, uncalibMaker_ee_, result); } -bool HGCalUncalibRecHitWorkerWeights::runHGCHEsil(const HGCalDigiCollection::const_iterator& itdg, +bool HGCalUncalibRecHitWorkerWeights::runHGCHEsil(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGChefUncalibratedRecHitCollection& result) { - result.push_back(uncalibMaker_hef_.makeRecHit(*itdg)); - return true; + return run(geom, digis, uncalibMaker_hef_, result); } -bool HGCalUncalibRecHitWorkerWeights::runHGCHEscint(const HGCalDigiCollection::const_iterator& itdg, +bool HGCalUncalibRecHitWorkerWeights::runHGCHEscint(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGChebUncalibratedRecHitCollection& result) { - result.push_back(uncalibMaker_heb_.makeRecHit(*itdg)); - return true; + return run(geom, digis, uncalibMaker_heb_, result); } -bool HGCalUncalibRecHitWorkerWeights::runHGCHFNose(const HGCalDigiCollection::const_iterator& itdg, +bool HGCalUncalibRecHitWorkerWeights::runHGCHFNose(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGChfnoseUncalibratedRecHitCollection& result) { - result.push_back(uncalibMaker_hfnose_.makeRecHit(*itdg)); - return true; + return run(geom, digis, uncalibMaker_hfnose_, result); } #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.h b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.h index 584915b6f7a0f..9375dba97f09f 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.h +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.h @@ -27,23 +27,29 @@ class HGCalUncalibRecHitWorkerWeights : public HGCalUncalibRecHitWorkerBaseClass HGCalUncalibRecHitWorkerWeights(const edm::ParameterSet&, edm::ConsumesCollector iC); ~HGCalUncalibRecHitWorkerWeights() override{}; - void set(const edm::EventSetup& es) override; - bool runHGCEE(const HGCalDigiCollection::const_iterator& digi, HGCeeUncalibratedRecHitCollection& result) override; - bool runHGCHEsil(const HGCalDigiCollection::const_iterator& digi, + bool runHGCEE(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, + HGCeeUncalibratedRecHitCollection& result) override; + bool runHGCHEsil(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGChefUncalibratedRecHitCollection& result) override; - bool runHGCHEscint(const HGCalDigiCollection::const_iterator& digi, + bool runHGCHEscint(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGChebUncalibratedRecHitCollection& result) override; - bool runHGCHFNose(const HGCalDigiCollection::const_iterator& digi, + bool runHGCHFNose(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, HGChfnoseUncalibratedRecHitCollection& result) override; protected: - edm::ESGetToken ee_geometry_token_; - edm::ESGetToken hef_geometry_token_; - edm::ESGetToken hfnose_geometry_token_; HGCalUncalibRecHitRecWeightsAlgo uncalibMaker_ee_; HGCalUncalibRecHitRecWeightsAlgo uncalibMaker_hef_; HGCalUncalibRecHitRecWeightsAlgo uncalibMaker_heb_; HGCalUncalibRecHitRecWeightsAlgo uncalibMaker_hfnose_; + + bool run(const edm::ESHandle& geom, + const HGCalDigiCollection& digis, + HGCalUncalibRecHitRecWeightsAlgo& uncalibMaker, + edm::SortedCollection& result); }; #endif diff --git a/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py b/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py index 899c4cfc9b05c..9d42e95851e19 100644 --- a/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py +++ b/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py @@ -27,6 +27,7 @@ tdcSaturation = hgceeDigitizer.digiCfg.feCfg.tdcSaturation_fC, tdcOnset = hgceeDigitizer.digiCfg.feCfg.tdcOnset_fC, toaLSB_ns = hgceeDigitizer.digiCfg.feCfg.toaLSB_ns, + tofDelay = hgceeDigitizer.tofDelay, fCPerMIP = fCPerMIP_mpv ), @@ -40,11 +41,12 @@ tdcSaturation = hgchefrontDigitizer.digiCfg.feCfg.tdcSaturation_fC, tdcOnset = hgchefrontDigitizer.digiCfg.feCfg.tdcOnset_fC, toaLSB_ns = hgchefrontDigitizer.digiCfg.feCfg.toaLSB_ns, + tofDelay = hgchefrontDigitizer.tofDelay, fCPerMIP = fCPerMIP_mpv ), HGCHEBConfig = cms.PSet( - isSiFE = cms.bool(True), + isSiFE = cms.bool(False), # adc information adcNbits = hgchebackDigitizer.digiCfg.feCfg.adcNbits, adcSaturation = hgchebackDigitizer.digiCfg.feCfg.adcSaturation_fC, @@ -53,6 +55,7 @@ tdcSaturation = hgchebackDigitizer.digiCfg.feCfg.tdcSaturation_fC, tdcOnset = hgchebackDigitizer.digiCfg.feCfg.tdcOnset_fC, toaLSB_ns = hgchebackDigitizer.digiCfg.feCfg.toaLSB_ns, + tofDelay = hgchebackDigitizer.tofDelay, fCPerMIP = cms.vdouble(1.0,1.0,1.0) #dummy values, it's scintillator ), @@ -66,6 +69,7 @@ tdcSaturation = hfnoseDigitizer.digiCfg.feCfg.tdcSaturation_fC, tdcOnset = hfnoseDigitizer.digiCfg.feCfg.tdcOnset_fC, toaLSB_ns = hfnoseDigitizer.digiCfg.feCfg.toaLSB_ns, + tofDelay = hfnoseDigitizer.tofDelay, fCPerMIP = fCPerMIP_mpv ), diff --git a/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/RealisticSimClusterMapper.cc b/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/RealisticSimClusterMapper.cc index 5c2197ea8c5be..a66a5b9fb0b6c 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/RealisticSimClusterMapper.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/RealisticSimClusterMapper.cc @@ -195,7 +195,7 @@ void RealisticSimClusterMapper::buildClusters(const edm::Handleposition().x() - scPosition[0]), 2) + std::pow((ref->position().y() - scPosition[1]), 2); if (distanceSquared < maxDforTimingSquared_) { - timeHits.push_back(ref->time() - timeOffset_); + timeHits.push_back(ref->time()); } } } diff --git a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizer.h b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizer.h index bd81c2faa7ad5..bdda68500d92b 100644 --- a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizer.h +++ b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizer.h @@ -118,9 +118,6 @@ class HGCDigitizer { //misc switches const uint32_t verbosity_; - //reference speed to evaluate time of arrival at the sensititive detector, assuming the center of CMS - const float refSpeed_; - //delay to apply after evaluating time of arrival at the sensitive detector const float tofDelay_; diff --git a/SimCalorimetry/HGCalSimProducers/plugins/HGCDigitizer.cc b/SimCalorimetry/HGCalSimProducers/plugins/HGCDigitizer.cc index ebf167e3d2693..ea66157858e28 100644 --- a/SimCalorimetry/HGCalSimProducers/plugins/HGCDigitizer.cc +++ b/SimCalorimetry/HGCalSimProducers/plugins/HGCDigitizer.cc @@ -32,8 +32,6 @@ namespace { constexpr std::array occupancyGuesses = {{0.5, 0.2, 0.2, 0.8}}; - float getPositionDistance(const HGCalGeometry* geom, const DetId& id) { return geom->getPosition(id).mag(); } - int getCellThickness(const HGCalGeometry* geom, const DetId& detid) { const auto& dddConst = geom->topology().dddConstants(); return (1 + dddConst.waferType(detid)); @@ -243,7 +241,6 @@ HGCDigitizer::HGCDigitizer(const edm::ParameterSet& ps, edm::ConsumesCollector& hitToken_(iC.consumes>(edm::InputTag(hitsProducer_, hitCollection_))), geomToken_(iC.esConsumes()), verbosity_(ps.getUntrackedParameter("verbosity", 0)), - refSpeed_(0.1 * CLHEP::c_light), //[CLHEP::c_light]=mm/ns convert to cm/ns tofDelay_(ps.getParameter("tofDelay")), averageOccupancies_(occupancyGuesses), nEvents_(1) { @@ -462,8 +459,7 @@ void HGCDigitizer::accumulate_forPreMix(edm::Handle cons const PCaloHit& hit = hits->at(hitidx); const float charge = hit.energy() * 1e6 * keV2fC; // * getCCE(geom, id, cce_); - const float dist2center(getPositionDistance(geom, id)); - const float tof = toa - dist2center / refSpeed_ + tofDelay_; + const float tof = toa + tofDelay_; const int itime = std::floor(tof / bxTime_) + 9; if (itime < 0 || itime > (int)maxBx_) @@ -597,12 +593,9 @@ void HGCDigitizer::accumulate(edm::Handle const& hits, const PCaloHit& hit = hits->at(hitidx); const float charge = hit.energy() * 1e6 * keV2fC; - //distance to the center of the detector - const float dist2center(getPositionDistance(geom, id)); - - //hit time: [time()]=ns [centerDist]=cm [refSpeed_]=cm/ns + delay by 1ns + //hit time: [time()]=ns + delay //accumulate in 15 buckets of 25ns (9 pre-samples, 1 in-time, 5 post-samples) - const float tof = toa - dist2center / refSpeed_ + tofDelay_; + const float tof = toa + tofDelay_; const int itime = std::floor(tof / bxTime_) + 9; //no need to add bx crossing - tof comes already corrected from the mixing module diff --git a/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py b/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py index 0138de6a2663e..84eef2c0f44f1 100644 --- a/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py +++ b/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py @@ -61,7 +61,7 @@ maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), eVPerEleHolePair = cms.double(eV_per_eh_pair), - tofDelay = cms.double(5), + tofDelay = cms.double(-9), digitizationType = cms.uint32(0), makeDigiSimLinks = cms.bool(False), premixStage1 = cms.bool(False), @@ -91,7 +91,7 @@ NoiseGeneration_Method = cms.bool(True), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), - tofDelay = cms.double(5), + tofDelay = cms.double(-11), digitizationType = cms.uint32(0), makeDigiSimLinks = cms.bool(False), premixStage1 = cms.bool(False), @@ -121,7 +121,7 @@ NoiseGeneration_Method = cms.bool(True), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), - tofDelay = cms.double(1), + tofDelay = cms.double(-14), digitizationType = cms.uint32(1), makeDigiSimLinks = cms.bool(False), premixStage1 = cms.bool(False), @@ -163,7 +163,7 @@ maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), eVPerEleHolePair = cms.double(eV_per_eh_pair), - tofDelay = cms.double(5), + tofDelay = cms.double(-33), digitizationType = cms.uint32(0), makeDigiSimLinks = cms.bool(False), premixStage1 = cms.bool(False), From 9e5fdf59d68e3f1c993c58e2066108448a8a44a1 Mon Sep 17 00:00:00 2001 From: Andre Govinda Stahl Leiton Date: Mon, 17 Oct 2022 16:21:26 +0200 Subject: [PATCH 2/2] Updated HLT configuration of HGCalUncalibRecHitProducer --- .../python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py | 2 +- .../python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py | 2 +- .../HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h | 3 ++- .../plugins/HGCalUncalibRecHitWorkerWeights.cc | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py index e270470d447a7..50df76af85569 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py @@ -18,7 +18,7 @@ adcNbits = cms.uint32(10), adcSaturation = cms.double(68.75), fCPerMIP = cms.vdouble(1.0, 1.0, 1.0), - isSiFE = cms.bool(True), + isSiFE = cms.bool(False), tdcNbits = cms.uint32(12), tdcOnset = cms.double(55), tdcSaturation = cms.double(1000), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py index 031e9e33e8182..7049a41fa3723 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py @@ -18,7 +18,7 @@ adcNbits = cms.uint32(10), adcSaturation = cms.double(68.75), fCPerMIP = cms.vdouble(1.0, 1.0, 1.0), - isSiFE = cms.bool(True), + isSiFE = cms.bool(False), tdcNbits = cms.uint32(12), tdcOnset = cms.double(55), tdcSaturation = cms.double(1000), diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h index b4ff5fe08da00..89a3eb2c819e0 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h @@ -42,12 +42,13 @@ class HGCalUncalibRecHitRecWeightsAlgo { fCPerMIP_ = fCPerMIP; } - void setGeometry(const edm::ESHandle& geom) { + bool setGeometry(const edm::ESHandle& geom) { geom_ = geom.isValid() ? geom.product() : nullptr; if (isSiFESim_ && geom_) ddd_ = &(geom_->topology().dddConstants()); else ddd_ = nullptr; + return geom_ != nullptr; } /// Compute HGCUncalibratedRecHit from DataFrame diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc index 11d650f16b1a8..ea635c3b738c0 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc @@ -76,7 +76,7 @@ bool HGCalUncalibRecHitWorkerWeights::run(const edm::ESHandle& ge HGCalUncalibRecHitRecWeightsAlgo& uncalibMaker, edm::SortedCollection& result) { uncalibMaker.setGeometry(geom); - result.reserve(digis.size()); + result.reserve(result.size() + digis.size()); for (const auto& digi : digis) result.push_back(uncalibMaker.makeRecHit(digi)); return true;