diff --git a/L1Trigger/L1THGCal/interface/HGCalCoarseTriggerCellMapping.h b/L1Trigger/L1THGCal/interface/HGCalCoarseTriggerCellMapping.h index 5dfc93cc5ef96..5dbce5e91860a 100644 --- a/L1Trigger/L1THGCal/interface/HGCalCoarseTriggerCellMapping.h +++ b/L1Trigger/L1THGCal/interface/HGCalCoarseTriggerCellMapping.h @@ -14,7 +14,7 @@ class HGCalCoarseTriggerCellMapping { GlobalPoint getCoarseTriggerCellPosition(uint32_t ctcId) const; uint32_t getCoarseTriggerCellId(uint32_t detid) const; void checkSizeValidity(int ctcSize) const; - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } static constexpr int kCTCsizeCoarse_ = 16; static constexpr int kCTCsizeMid_ = 8; diff --git a/L1Trigger/L1THGCal/interface/HGCalProcessorBaseT.h b/L1Trigger/L1THGCal/interface/HGCalProcessorBaseT.h index ad3389173ddde..babf7425e920b 100644 --- a/L1Trigger/L1THGCal/interface/HGCalProcessorBaseT.h +++ b/L1Trigger/L1THGCal/interface/HGCalProcessorBaseT.h @@ -16,16 +16,19 @@ class HGCalProcessorBaseT { const std::string& name() const { return name_; } - void setGeometry(const HGCalTriggerGeometryBase* const geom) { geometry_ = geom; } + virtual void setGeometry(const HGCalTriggerGeometryBase* const geom) { geometry_ = geom; } - virtual void eventSetup(const edm::EventSetup& es){}; - - virtual void run(const InputCollection& inputColl, OutputCollection& outColl, const edm::EventSetup& es) = 0; + virtual void run(const InputCollection& inputColl, OutputCollection& outColl) = 0; protected: - const HGCalTriggerGeometryBase* geometry_; + const HGCalTriggerGeometryBase* geometry() const { + if (!geometry_) + throw cms::Exception("HGCTriggerSetupError") << "The geometry has not been set in processor " << name_; + return geometry_; + } private: + const HGCalTriggerGeometryBase* geometry_; const std::string name_; }; diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerCellCalibration.h b/L1Trigger/L1THGCal/interface/HGCalTriggerCellCalibration.h index db87d5f9843a2..e8b2738183129 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerCellCalibration.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerCellCalibration.h @@ -9,7 +9,7 @@ class HGCalTriggerCellCalibration { public: HGCalTriggerCellCalibration(const edm::ParameterSet& conf); - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } void calibrateInMipT(l1t::HGCalTriggerCell&) const; void calibrateMipTinGeV(l1t::HGCalTriggerCell&) const; void calibrateInGeV(l1t::HGCalTriggerCell&) const; diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerTools.h b/L1Trigger/L1THGCal/interface/HGCalTriggerTools.h index 239d65ddde182..b677124c2b4ce 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerTools.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerTools.h @@ -24,16 +24,16 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" namespace edm { - class Event; class EventSetup; -} // namespace edm +} class HGCalTriggerTools { public: HGCalTriggerTools() : geom_(nullptr), eeLayers_(0), fhLayers_(0), bhLayers_(0), noseLayers_(0), totalLayers_(0) {} ~HGCalTriggerTools() {} - void eventSetup(const edm::EventSetup&); + void setGeometry(const HGCalTriggerGeometryBase* const); + void eventSetup(const edm::EventSetup&); // Kept for backward compatibility: used in L1Trigger/L1CaloTrigger/test GlobalPoint getTCPosition(const DetId& id) const; unsigned layers(ForwardSubdetector type) const; unsigned layers(DetId::Detector type) const; diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h b/L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h index e5ac5b9f0d0e3..79eff1455bd4a 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h @@ -30,7 +30,7 @@ class HGCalTriggerTowerGeometryHelper { ~HGCalTriggerTowerGeometryHelper() {} - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } const std::vector& getTowerCoordinates() const; diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h index fae1512ef4af8..9e33fe4a1b9cd 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h @@ -14,7 +14,7 @@ class HGCalClusteringDummyImpl { public: HGCalClusteringDummyImpl(const edm::ParameterSet& conf); - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } void clusterizeDummy(const std::vector>& triggerCellsPtrs, l1t::HGCalClusterBxCollection& clusters); diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalClusteringImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalClusteringImpl.h index 65dc53b0a8d4b..da8824b15de23 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalClusteringImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalClusteringImpl.h @@ -22,7 +22,7 @@ class HGCalClusteringImpl { public: HGCalClusteringImpl(const edm::ParameterSet& conf); - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } /* dR-algorithms */ bool isPertinent(const l1t::HGCalTriggerCell& tc, const l1t::HGCalCluster& clu, double distXY) const; diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h index dd82e8f743688..3dbd3c9c06d35 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h @@ -15,9 +15,9 @@ class HGCalHistoClusteringImpl { public: HGCalHistoClusteringImpl(const edm::ParameterSet& conf); - void eventSetup(const edm::EventSetup& es) { - triggerTools_.eventSetup(es); - shape_.eventSetup(es); + void setGeometry(const HGCalTriggerGeometryBase* const geom) { + triggerTools_.setGeometry(geom); + shape_.setGeometry(geom); if ((!dr_byLayer_coefficientA_.empty() && (dr_byLayer_coefficientA_.size() - 1) < triggerTools_.lastLayerBH()) || (!dr_byLayer_coefficientB_.empty() && (dr_byLayer_coefficientB_.size() - 1) < triggerTools_.lastLayerBH())) { throw cms::Exception("Configuration") diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h index 03519dc76dad6..faf484603533a 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h @@ -108,7 +108,7 @@ class HGCalHistoSeedingImpl { public: HGCalHistoSeedingImpl(const edm::ParameterSet& conf); - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } float dR(const l1t::HGCalCluster& clu, const GlobalPoint& seed) const; diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h index 62024a868490c..7c82c1c999f28 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h @@ -15,9 +15,9 @@ class HGCalMulticlusteringImpl { public: HGCalMulticlusteringImpl(const edm::ParameterSet& conf); - void eventSetup(const edm::EventSetup& es) { - triggerTools_.eventSetup(es); - shape_.eventSetup(es); + void setGeometry(const HGCalTriggerGeometryBase* const geom) { + triggerTools_.setGeometry(geom); + shape_.setGeometry(geom); } bool isPertinent(const l1t::HGCalCluster& clu, const l1t::HGCalMulticluster& mclu, double dR) const; diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h b/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h index 90cc4989a876c..f5d33a224b125 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h @@ -18,7 +18,7 @@ class HGCalShowerShape { ~HGCalShowerShape() {} - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } int firstLayer(const l1t::HGCalMulticluster& c3d) const; int lastLayer(const l1t::HGCalMulticluster& c3d) const; diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h index 89aee5cb9def8..fe0d4568e1aeb 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h @@ -3,7 +3,6 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "DataFormats/L1THGCal/interface/HGCalTriggerSums.h" #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" @@ -49,9 +48,9 @@ class HGCalTowerMap2DImpl { } } - void eventSetup(const edm::EventSetup& es) { - triggerTools_.eventSetup(es); - towerGeometryHelper_.eventSetup(es); + void setGeometry(const HGCalTriggerGeometryBase* const geom) { + triggerTools_.setGeometry(geom); + towerGeometryHelper_.setGeometry(geom); } private: diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterInterpreterBase.h b/L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterInterpreterBase.h index da20964db8705..9d65b7f3288cc 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterInterpreterBase.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterInterpreterBase.h @@ -3,13 +3,14 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" +#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" class HGCalTriggerClusterInterpreterBase { public: HGCalTriggerClusterInterpreterBase(){}; virtual ~HGCalTriggerClusterInterpreterBase(){}; virtual void initialize(const edm::ParameterSet& conf) = 0; - virtual void eventSetup(const edm::EventSetup& es) = 0; + virtual void setGeometry(const HGCalTriggerGeometryBase* const) = 0; virtual void interpret(l1t::HGCalMulticlusterBxCollection& multiclusters) const = 0; }; diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorAutoEncoderImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorAutoEncoderImpl.h index c16e5efffdfd5..d81206e068719 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorAutoEncoderImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorAutoEncoderImpl.h @@ -20,7 +20,7 @@ class HGCalConcentratorAutoEncoderImpl { std::vector& trigCellVecOutput, std::vector& ae_EncodedOutput); - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } private: static constexpr int nTriggerCells_ = 48; diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorBestChoiceImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorBestChoiceImpl.h index 9057cab77d2ba..0abec461ff7db 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorBestChoiceImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorBestChoiceImpl.h @@ -16,7 +16,7 @@ class HGCalConcentratorBestChoiceImpl { std::vector& trigCellVecOutput, std::vector& trigCellVecNotSelected); - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } private: std::vector nData_; diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorCoarsenerImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorCoarsenerImpl.h index 7a10b34a1ad34..c61a5ec7814d7 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorCoarsenerImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorCoarsenerImpl.h @@ -13,10 +13,10 @@ class HGCalConcentratorCoarsenerImpl { void coarsen(const std::vector& trigCellVecInput, std::vector& trigCellVecOutput); - void eventSetup(const edm::EventSetup& es) { - triggerTools_.eventSetup(es); - coarseTCmapping_.eventSetup(es); - calibration_.eventSetup(es); + void setGeometry(const HGCalTriggerGeometryBase* const geom) { + triggerTools_.setGeometry(geom); + coarseTCmapping_.setGeometry(geom); + calibration_.setGeometry(geom); } private: diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorProcessorSelection.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorProcessorSelection.h index 57f14d61add2e..f810816c5dc48 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorProcessorSelection.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorProcessorSelection.h @@ -27,8 +27,7 @@ class HGCalConcentratorProcessorSelection : public HGCalConcentratorProcessorBas void run(const edm::Handle& triggerCellCollInput, std::tuple& triggerCollOutput, - const edm::EventSetup& es) override; + l1t::HGCalConcentratorDataBxCollection>& triggerCollOutput) override; private: bool fixedDataSizePerHGCROC_; diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h index 24225625c5528..13550787bdcd4 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h @@ -16,14 +16,14 @@ class HGCalConcentratorSuperTriggerCellImpl { void select(const std::vector& trigCellVecInput, std::vector& trigCellVecOutput); - void eventSetup(const edm::EventSetup& es) { - triggerTools_.eventSetup(es); - coarseTCmapping_.eventSetup(es); - superTCmapping_.eventSetup(es); - calibrationEE_.eventSetup(es); - calibrationHEsi_.eventSetup(es); - calibrationHEsc_.eventSetup(es); - calibrationNose_.eventSetup(es); + void setGeometry(const HGCalTriggerGeometryBase* const geom) { + triggerTools_.setGeometry(geom); + coarseTCmapping_.setGeometry(geom); + superTCmapping_.setGeometry(geom); + calibrationEE_.setGeometry(geom); + calibrationHEsi_.setGeometry(geom); + calibrationHEsc_.setGeometry(geom); + calibrationNose_.setGeometry(geom); } private: diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorThresholdImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorThresholdImpl.h index 9fb0ea4e07bae..f259a2b01511b 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorThresholdImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorThresholdImpl.h @@ -14,7 +14,7 @@ class HGCalConcentratorThresholdImpl { std::vector& trigCellVecOutput, std::vector& trigCellVecNotSelected); - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } private: double threshold_silicon_; diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorTrigSumImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorTrigSumImpl.h index 484c30ba24073..2ba40e0a4a93a 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorTrigSumImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorTrigSumImpl.h @@ -15,7 +15,7 @@ class HGCalConcentratorTrigSumImpl { const std::vector& trigCellVecInput, std::vector& trigSumsVecOutput) const; - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } private: HGCalTriggerTools triggerTools_; diff --git a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFEProcessorSums.h b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFEProcessorSums.h index a0fc29253ecf0..f569d25eed843 100644 --- a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFEProcessorSums.h +++ b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFEProcessorSums.h @@ -13,9 +13,7 @@ class HGCalVFEProcessorSums : public HGCalVFEProcessorBase { public: HGCalVFEProcessorSums(const edm::ParameterSet& conf); - void run(const HGCalDigiCollection& digiColl, - l1t::HGCalTriggerCellBxCollection& triggerCellColl, - const edm::EventSetup& es) override; + void run(const HGCalDigiCollection& digiColl, l1t::HGCalTriggerCellBxCollection& triggerCellColl) override; private: std::unique_ptr vfeLinearizationSiImpl_; diff --git a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h index 500eff9c29a1a..c53e1c1ae3d74 100644 --- a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h +++ b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h @@ -13,7 +13,7 @@ class HGCalVFESummationImpl { public: HGCalVFESummationImpl(const edm::ParameterSet& conf); - void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } void triggerCellSums(const std::vector >&, std::unordered_map&); private: diff --git a/L1Trigger/L1THGCal/plugins/HFNoseVFEProducer.cc b/L1Trigger/L1THGCal/plugins/HFNoseVFEProducer.cc index 61a688b7252df..d1fb8fcffcd76 100644 --- a/L1Trigger/L1THGCal/plugins/HFNoseVFEProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HFNoseVFEProducer.cc @@ -27,6 +27,7 @@ class HFNoseVFEProducer : public edm::stream::EDProducer<> { // inputs edm::EDGetToken inputnose_; edm::ESHandle triggerGeometry_; + edm::ESGetToken triggerGeomToken_; std::unique_ptr vfeProcess_; }; @@ -34,7 +35,8 @@ class HFNoseVFEProducer : public edm::stream::EDProducer<> { DEFINE_FWK_MODULE(HFNoseVFEProducer); HFNoseVFEProducer::HFNoseVFEProducer(const edm::ParameterSet& conf) - : inputnose_(consumes(conf.getParameter("noseDigis"))) { + : inputnose_(consumes(conf.getParameter("noseDigis"))), + triggerGeomToken_(esConsumes()) { // setup VFE parameters const edm::ParameterSet& vfeParamConfig = conf.getParameterSet("ProcessorParameters"); const std::string& vfeProcessorName = vfeParamConfig.getParameter("ProcessorName"); @@ -45,7 +47,7 @@ HFNoseVFEProducer::HFNoseVFEProducer(const edm::ParameterSet& conf) } void HFNoseVFEProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { - es.get().get(triggerGeometry_); + triggerGeometry_ = es.getHandle(triggerGeomToken_); vfeProcess_->setGeometry(triggerGeometry_.product()); } @@ -58,7 +60,7 @@ void HFNoseVFEProducer::produce(edm::Event& e, const edm::EventSetup& es) { if (nose_digis_h.isValid()) { const HGCalDigiCollection& nose_digis = *nose_digis_h; - vfeProcess_->run(nose_digis, *vfe_trigcell_output, es); + vfeProcess_->run(nose_digis, *vfe_trigcell_output); } // Put in the event diff --git a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc index 189b495ea1095..50a07dbd136e5 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc @@ -61,6 +61,6 @@ void HGCalBackendLayer1Producer::produce(edm::Event& e, const edm::EventSetup& e edm::Handle trigCellBxColl; e.getByToken(input_cell_, trigCellBxColl); - backendProcess_->run(trigCellBxColl, *be_cluster_output, es); + backendProcess_->run(trigCellBxColl, *be_cluster_output); e.put(std::move(be_cluster_output), backendProcess_->name()); } diff --git a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer2Producer.cc b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer2Producer.cc index 21a4fa1a33658..fd38eb5929ed5 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer2Producer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer2Producer.cc @@ -64,7 +64,7 @@ void HGCalBackendLayer2Producer::produce(edm::Event& e, const edm::EventSetup& e e.getByToken(input_clusters_, trigCluster2DBxColl); - backendProcess_->run(trigCluster2DBxColl, be_output, es); + backendProcess_->run(trigCluster2DBxColl, be_output); e.put(std::make_unique(std::move(be_output.first)), backendProcess_->name()); e.put(std::make_unique(std::move(be_output.second)), diff --git a/L1Trigger/L1THGCal/plugins/HGCalConcentratorProducer.cc b/L1Trigger/L1THGCal/plugins/HGCalConcentratorProducer.cc index 175ae1436ac94..9521cc24b0314 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalConcentratorProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalConcentratorProducer.cc @@ -53,7 +53,6 @@ HGCalConcentratorProducer::HGCalConcentratorProducer(const edm::ParameterSet& co void HGCalConcentratorProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { triggerGeometry_ = es.getHandle(triggerGeomToken_); - concentratorProcess_->setGeometry(triggerGeometry_.product()); } @@ -66,7 +65,7 @@ void HGCalConcentratorProducer::produce(edm::Event& e, const edm::EventSetup& es edm::Handle trigCellBxColl; e.getByToken(input_cell_, trigCellBxColl); - concentratorProcess_->run(trigCellBxColl, cc_output, es); + concentratorProcess_->run(trigCellBxColl, cc_output); // Put in the event e.put(std::make_unique(std::move(std::get<0>(cc_output))), concentratorProcess_->name()); diff --git a/L1Trigger/L1THGCal/plugins/HGCalTowerMapProducer.cc b/L1Trigger/L1THGCal/plugins/HGCalTowerMapProducer.cc index a15f948808c9f..03f5aa4396856 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalTowerMapProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalTowerMapProducer.cc @@ -59,7 +59,7 @@ void HGCalTowerMapProducer::produce(edm::Event& e, const edm::EventSetup& es) { e.getByToken(input_sums_, trigSumBxColl); - towersMapProcess_->run(trigSumBxColl, *towersMap_output, es); + towersMapProcess_->run(trigSumBxColl, *towersMap_output); e.put(std::move(towersMap_output), towersMapProcess_->name()); } diff --git a/L1Trigger/L1THGCal/plugins/HGCalTowerProducer.cc b/L1Trigger/L1THGCal/plugins/HGCalTowerProducer.cc index f0637e95b0f3c..349bcab812cd1 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalTowerProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalTowerProducer.cc @@ -48,7 +48,6 @@ HGCalTowerProducer::HGCalTowerProducer(const edm::ParameterSet& conf) } void HGCalTowerProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { - towersProcess_->eventSetup(es); triggerGeometry_ = es.getHandle(triggerGeomToken_); towersProcess_->setGeometry(triggerGeometry_.product()); } @@ -65,7 +64,7 @@ void HGCalTowerProducer::produce(edm::Event& e, const edm::EventSetup& es) { e.getByToken(input_towers_map_, towersMapBxColl); e.getByToken(input_trigger_cells_, clustersBxColl); - towersProcess_->run(inputsColl, *towers_output, es); + towersProcess_->run(inputsColl, *towers_output); e.put(std::move(towers_output), towersProcess_->name()); } diff --git a/L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc b/L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc index 75c09a733bf15..ccf601ae7a529 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc @@ -68,17 +68,17 @@ void HGCalVFEProducer::produce(edm::Event& e, const edm::EventSetup& es) { // Processing DigiCollections and putting the results into the HGCalTriggerCellBxCollectio if (ee_digis_h.isValid()) { const HGCalDigiCollection& ee_digis = *ee_digis_h; - vfeProcess_->run(ee_digis, *vfe_trigcell_output, es); + vfeProcess_->run(ee_digis, *vfe_trigcell_output); } if (fh_digis_h.isValid()) { const HGCalDigiCollection& fh_digis = *fh_digis_h; - vfeProcess_->run(fh_digis, *vfe_trigcell_output, es); + vfeProcess_->run(fh_digis, *vfe_trigcell_output); } if (bh_digis_h.isValid()) { const HGCalDigiCollection& bh_digis = *bh_digis_h; - vfeProcess_->run(bh_digis, *vfe_trigcell_output, es); + vfeProcess_->run(bh_digis, *vfe_trigcell_output); } // Put in the event diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc index 3bfef0b69959d..36271c9d422a8 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc @@ -29,13 +29,11 @@ class HGCalBackendLayer1Processor2DClustering : public HGCalBackendLayer1Process } void run(const edm::Handle& collHandle, - l1t::HGCalClusterBxCollection& collCluster2D, - const edm::EventSetup& es) override { - es.get().get("", triggerGeometry_); + l1t::HGCalClusterBxCollection& collCluster2D) override { if (clustering_) - clustering_->eventSetup(es); + clustering_->setGeometry(geometry()); if (clusteringDummy_) - clusteringDummy_->eventSetup(es); + clusteringDummy_->setGeometry(geometry()); /* create a persistent vector of pointers to the trigger-cells */ std::vector> triggerCellsPtrs; @@ -56,10 +54,10 @@ class HGCalBackendLayer1Processor2DClustering : public HGCalBackendLayer1Process clustering_->clusterizeDR(triggerCellsPtrs, collCluster2D); break; case NNC2d: - clustering_->clusterizeNN(triggerCellsPtrs, collCluster2D, *triggerGeometry_); + clustering_->clusterizeNN(triggerCellsPtrs, collCluster2D, *geometry()); break; case dRNNC2d: - clustering_->clusterizeDRNN(triggerCellsPtrs, collCluster2D, *triggerGeometry_); + clustering_->clusterizeDRNN(triggerCellsPtrs, collCluster2D, *geometry()); break; case dummyC2d: clusteringDummy_->clusterizeDummy(triggerCellsPtrs, collCluster2D); @@ -73,8 +71,6 @@ class HGCalBackendLayer1Processor2DClustering : public HGCalBackendLayer1Process private: enum ClusterType { dRC2d, NNC2d, dRNNC2d, dummyC2d }; - edm::ESHandle triggerGeometry_; - /* algorithms instances */ std::unique_ptr clustering_; std::unique_ptr clusteringDummy_; diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc index d1e2cb1f20452..84c667fade067 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc @@ -41,15 +41,13 @@ class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2Process } void run(const edm::Handle& collHandle, - std::pair& be_output, - const edm::EventSetup& es) override { - es.get().get("", triggerGeometry_); + std::pair& be_output) override { if (multiclustering_) - multiclustering_->eventSetup(es); + multiclustering_->setGeometry(geometry()); if (multiclusteringHistoSeeding_) - multiclusteringHistoSeeding_->eventSetup(es); + multiclusteringHistoSeeding_->setGeometry(geometry()); if (multiclusteringHistoClustering_) - multiclusteringHistoClustering_->eventSetup(es); + multiclusteringHistoClustering_->setGeometry(geometry()); auto& collCluster3D = be_output.first; auto& rejectedClusters = be_output.second; @@ -67,15 +65,15 @@ class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2Process /* call to multiclustering and compute shower shape*/ switch (multiclusteringAlgoType_) { case dRC3d: - multiclustering_->clusterizeDR(clustersPtrs, collCluster3D, *triggerGeometry_); + multiclustering_->clusterizeDR(clustersPtrs, collCluster3D, *geometry()); break; case DBSCANC3d: - multiclustering_->clusterizeDBSCAN(clustersPtrs, collCluster3D, *triggerGeometry_); + multiclustering_->clusterizeDBSCAN(clustersPtrs, collCluster3D, *geometry()); break; case HistoC3d: multiclusteringHistoSeeding_->findHistoSeeds(clustersPtrs, seedPositionsEnergy); multiclusteringHistoClustering_->clusterizeHisto( - clustersPtrs, seedPositionsEnergy, *triggerGeometry_, collCluster3D, rejectedClusters); + clustersPtrs, seedPositionsEnergy, *geometry(), collCluster3D, rejectedClusters); break; default: // Should not happen, clustering type checked in constructor @@ -84,7 +82,7 @@ class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2Process // Call all the energy interpretation modules on the cluster collection for (const auto& interpreter : energy_interpreters_) { - interpreter->eventSetup(es); + interpreter->setGeometry(geometry()); interpreter->interpret(collCluster3D); } } @@ -92,8 +90,6 @@ class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2Process private: enum MulticlusterType { dRC3d, DBSCANC3d, HistoC3d }; - edm::ESHandle triggerGeometry_; - /* algorithms instances */ std::unique_ptr multiclustering_; std::unique_ptr multiclusteringHistoSeeding_; diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalTowerMapProcessor.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalTowerMapProcessor.cc index 4525ac9f6c204..552058d59b5e0 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalTowerMapProcessor.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalTowerMapProcessor.cc @@ -15,10 +15,8 @@ class HGCalTowerMapProcessor : public HGCalTowerMapProcessorBase { } void run(const edm::Handle& collHandle, - l1t::HGCalTowerMapBxCollection& collTowerMap, - const edm::EventSetup& es) override { - es.get().get("", triggerGeometry_); - towermap2D_->eventSetup(es); + l1t::HGCalTowerMapBxCollection& collTowerMap) override { + towermap2D_->setGeometry(geometry()); /* create a persistent vector of pointers to the trigger-sums */ std::vector> triggerSumsPtrs; @@ -32,8 +30,6 @@ class HGCalTowerMapProcessor : public HGCalTowerMapProcessorBase { } private: - edm::ESHandle triggerGeometry_; - /* algorithms instances */ std::unique_ptr towermap2D_; }; diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc index fc0b107a785e8..c726d2b337206 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc @@ -17,14 +17,14 @@ class HGCalTowerProcessor : public HGCalTowerProcessorBase { towermap3D_ = std::make_unique(); } - void eventSetup(const edm::EventSetup& es) override { towermap2D_->eventSetup(es); } + void setGeometry(const HGCalTriggerGeometryBase* const geom) override { + HGCalTowerProcessorBase::setGeometry(geom); + towermap2D_->setGeometry(geom); + } void run(const std::pair, edm::Handle>& collHandle, - l1t::HGCalTowerBxCollection& collTowers, - const edm::EventSetup& es) override { - es.get().get("", triggerGeometry_); - + l1t::HGCalTowerBxCollection& collTowers) override { auto& towerMapCollHandle = collHandle.first; auto& unclTCsCollHandle = collHandle.second; @@ -65,7 +65,6 @@ class HGCalTowerProcessor : public HGCalTowerProcessorBase { } private: - edm::ESHandle triggerGeometry_; bool includeTrigCells_; /* algorithms instances */ diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalTriggerClusterInterpretationEM.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalTriggerClusterInterpretationEM.cc index a68f29ea5c572..927cfe95bc196 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalTriggerClusterInterpretationEM.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalTriggerClusterInterpretationEM.cc @@ -9,7 +9,7 @@ class HGCalTriggerClusterInterpretationEM : public HGCalTriggerClusterInterprete HGCalTriggerClusterInterpretationEM(); ~HGCalTriggerClusterInterpretationEM() override{}; void initialize(const edm::ParameterSet& conf) final; - void eventSetup(const edm::EventSetup& es) final; + void setGeometry(const HGCalTriggerGeometryBase* const) final; void interpret(l1t::HGCalMulticlusterBxCollection& multiclusters) const final; private: @@ -42,7 +42,9 @@ void HGCalTriggerClusterInterpretationEM::initialize(const edm::ParameterSet& co } } -void HGCalTriggerClusterInterpretationEM::eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } +void HGCalTriggerClusterInterpretationEM::setGeometry(const HGCalTriggerGeometryBase* const geom) { + triggerTools_.setGeometry(geom); +} void HGCalTriggerClusterInterpretationEM::interpret(l1t::HGCalMulticlusterBxCollection& multiclusters) const { for (unsigned int idx = 0; idx != multiclusters.size(); idx++) { diff --git a/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc b/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc index b56a0948d3eb3..67a667b4239ff 100644 --- a/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc +++ b/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc @@ -55,21 +55,20 @@ HGCalConcentratorProcessorSelection::HGCalConcentratorProcessorSelection(const e void HGCalConcentratorProcessorSelection::run(const edm::Handle& triggerCellCollInput, std::tuple& triggerCollOutput, - const edm::EventSetup& es) { + l1t::HGCalConcentratorDataBxCollection>& triggerCollOutput) { if (thresholdImpl_) - thresholdImpl_->eventSetup(es); + thresholdImpl_->setGeometry(geometry()); if (bestChoiceImpl_) - bestChoiceImpl_->eventSetup(es); + bestChoiceImpl_->setGeometry(geometry()); if (superTriggerCellImpl_) - superTriggerCellImpl_->eventSetup(es); + superTriggerCellImpl_->setGeometry(geometry()); if (autoEncoderImpl_) - autoEncoderImpl_->eventSetup(es); + autoEncoderImpl_->setGeometry(geometry()); if (coarsenerImpl_) - coarsenerImpl_->eventSetup(es); + coarsenerImpl_->setGeometry(geometry()); if (trigSumImpl_) - trigSumImpl_->eventSetup(es); - triggerTools_.eventSetup(es); + trigSumImpl_->setGeometry(geometry()); + triggerTools_.setGeometry(geometry()); auto& triggerCellCollOutput = std::get<0>(triggerCollOutput); auto& triggerSumCollOutput = std::get<1>(triggerCollOutput); @@ -79,7 +78,7 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handle> tc_modules; for (const auto& trigCell : collInput) { - uint32_t module = geometry_->getModuleFromTriggerCell(trigCell.detId()); + uint32_t module = geometry()->getModuleFromTriggerCell(trigCell.detId()); tc_modules[module].push_back(trigCell); } @@ -103,14 +102,14 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handleselect(geometry_->getLinksInModule(module_trigcell.first), - geometry_->getModuleSize(module_trigcell.first), + bestChoiceImpl_->select(geometry()->getLinksInModule(module_trigcell.first), + geometry()->getModuleSize(module_trigcell.first), module_trigcell.second, trigCellVecOutput, trigCellVecNotSelected); } else { - bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first), - geometry_->getModuleSize(module_trigcell.first), + bestChoiceImpl_->select(geometry()->getLinksInModule(module_trigcell.first), + geometry()->getModuleSize(module_trigcell.first), trigCellVecCoarsened, trigCellVecOutput, trigCellVecNotSelected); @@ -120,7 +119,7 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handleselect(trigCellVecCoarsened, trigCellVecOutput); break; case autoEncoderSelect: - autoEncoderImpl_->select(geometry_->getLinksInModule(module_trigcell.first), + autoEncoderImpl_->select(geometry()->getLinksInModule(module_trigcell.first), trigCellVecCoarsened, trigCellVecOutput, ae_EncodedLayerOutput); @@ -139,8 +138,8 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handleselect(module_trigcell.second, trigCellVecOutput, trigCellVecNotSelected); break; case bestChoiceSelect: - bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first), - geometry_->getModuleSize(module_trigcell.first), + bestChoiceImpl_->select(geometry()->getLinksInModule(module_trigcell.first), + geometry()->getModuleSize(module_trigcell.first), module_trigcell.second, trigCellVecOutput, trigCellVecNotSelected); @@ -149,7 +148,7 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handleselect(module_trigcell.second, trigCellVecOutput); break; case autoEncoderSelect: - autoEncoderImpl_->select(geometry_->getLinksInModule(module_trigcell.first), + autoEncoderImpl_->select(geometry()->getLinksInModule(module_trigcell.first), module_trigcell.second, trigCellVecOutput, ae_EncodedLayerOutput); diff --git a/L1Trigger/L1THGCal/plugins/veryfrontend/HGCalVFEProcessorSums.cc b/L1Trigger/L1THGCal/plugins/veryfrontend/HGCalVFEProcessorSums.cc index 4c94a2711bafe..e45d3d534b212 100644 --- a/L1Trigger/L1THGCal/plugins/veryfrontend/HGCalVFEProcessorSums.cc +++ b/L1Trigger/L1THGCal/plugins/veryfrontend/HGCalVFEProcessorSums.cc @@ -26,14 +26,13 @@ HGCalVFEProcessorSums::HGCalVFEProcessorSums(const edm::ParameterSet& conf) : HG } void HGCalVFEProcessorSums::run(const HGCalDigiCollection& digiColl, - l1t::HGCalTriggerCellBxCollection& triggerCellColl, - const edm::EventSetup& es) { - vfeSummationImpl_->eventSetup(es); - calibrationEE_->eventSetup(es); - calibrationHEsi_->eventSetup(es); - calibrationHEsc_->eventSetup(es); - calibrationNose_->eventSetup(es); - triggerTools_.eventSetup(es); + l1t::HGCalTriggerCellBxCollection& triggerCellColl) { + vfeSummationImpl_->setGeometry(geometry()); + calibrationEE_->setGeometry(geometry()); + calibrationHEsi_->setGeometry(geometry()); + calibrationHEsc_->setGeometry(geometry()); + calibrationNose_->setGeometry(geometry()); + triggerTools_.setGeometry(geometry()); std::vector dataframes; std::vector> linearized_dataframes; @@ -44,13 +43,13 @@ void HGCalVFEProcessorSums::run(const HGCalDigiCollection& digiColl, for (const auto& digiData : digiColl) { if (DetId(digiData.id()).det() == DetId::Hcal && HcalDetId(digiData.id()).subdetId() != HcalEndcap) continue; - if (!geometry_->validCell(digiData.id())) + if (!geometry()->validCell(digiData.id())) continue; - uint32_t module = geometry_->getModuleFromCell(digiData.id()); + uint32_t module = geometry()->getModuleFromCell(digiData.id()); // no disconnected layer for HFNose if (DetId(digiData.id()).subdetId() != ForwardSubdetector::HFNose) { - if (geometry_->disconnectedModule(module)) + if (geometry()->disconnectedModule(module)) continue; } @@ -89,7 +88,7 @@ void HGCalVFEProcessorSums::run(const HGCalDigiCollection& digiColl, l1t::HGCalTriggerCell triggerCell(reco::LeafCandidate::LorentzVector(), tc_compressed_value, 0, 0, 0, tc_id); triggerCell.setCompressedCharge(tc_compressed_code); triggerCell.setUncompressedCharge(tc_value); - GlobalPoint point = geometry_->getTriggerCellPosition(tc_id); + GlobalPoint point = geometry()->getTriggerCellPosition(tc_id); // 'value' is hardware, so p4 is meaningless, except for eta and phi math::PtEtaPhiMLorentzVector p4((double)tc_compressed_value / cosh(point.eta()), point.eta(), point.phi(), 0.); diff --git a/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc b/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc index fbad7dade5f36..58cc087664d17 100644 --- a/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc +++ b/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc @@ -30,11 +30,15 @@ namespace { } } // namespace +// Kept for backward compatibility: used in L1Trigger/L1CaloTrigger/test void HGCalTriggerTools::eventSetup(const edm::EventSetup& es) { - edm::ESHandle triggerGeometry_; - es.get().get(triggerGeometry_); - geom_ = triggerGeometry_.product(); + edm::ESHandle triggerGeometry; + es.get().get(triggerGeometry); + setGeometry(triggerGeometry.product()); +} +void HGCalTriggerTools::setGeometry(const HGCalTriggerGeometryBase* const geom) { + geom_ = geom; eeLayers_ = geom_->eeTopology().dddConstants().layers(true); fhLayers_ = geom_->fhTopology().dddConstants().layers(true); if (geom_->isWithNoseGeometry()) diff --git a/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h b/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h index 44dad5863dd7a..33cbd3b76aed4 100644 --- a/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h +++ b/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h @@ -3,19 +3,51 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "TTree.h" +namespace HepPDT { + class ParticleDataTable; +} +class MagneticField; +class HGCalTriggerGeometryBase; + +struct HGCalTriggerNtupleEventSetup { + edm::ESHandle pdt; + edm::ESHandle magfield; + edm::ESHandle geometry; +}; + class HGCalTriggerNtupleBase { public: - HGCalTriggerNtupleBase(const edm::ParameterSet& conf){}; + HGCalTriggerNtupleBase(const edm::ParameterSet& conf) : name_(conf.getParameter("NtupleName")){}; virtual ~HGCalTriggerNtupleBase(){}; + const std::string& name() const { return name_; } virtual void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) = 0; - virtual void fill(const edm::Event&, const edm::EventSetup&) = 0; + virtual void fill(const edm::Event&, const HGCalTriggerNtupleEventSetup&) { + edm::LogWarning("NotImplemented") << "Calling ntuplizer fill(edm::Event, HGCalTriggerNtupleEventSetup), but it is " + "not implemented in the concrete class '" + << name() << "'. " + << "You might want to set 'accessEventSetup_' to true in order to call " + "fill(edm::Event, edm::EventSetup) instead."; + } + // Kept for backward compatibility: used in L1Trigger/L1CaloTrigger/test + virtual void fill(const edm::Event&, const edm::EventSetup&) { + edm::LogWarning("NotImplemented") + << "Calling ntuplizer fill(edm::Event, edm::EventSetup), but it is not implemented in the concrete class '" + << name() << "'. " + << "You might want to set 'accessEventSetup_' to false in order to call fill(edm::Event, " + "HGCalTriggerNtupleEventSetup) instead."; + } + bool accessEventSetup() const { return accessEventSetup_; } protected: virtual void clear() = 0; + bool accessEventSetup_ = true; + const std::string name_; }; #include "FWCore/PluginManager/interface/PluginFactory.h" diff --git a/L1Trigger/L1THGCalUtilities/plugins/CaloTruthCellsProducer.cc b/L1Trigger/L1THGCalUtilities/plugins/CaloTruthCellsProducer.cc index 13fad4113aefa..d3200dfed83f7 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/CaloTruthCellsProducer.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/CaloTruthCellsProducer.cc @@ -31,6 +31,7 @@ class CaloTruthCellsProducer : public edm::stream::EDProducer<> { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: + void beginRun(const edm::Run&, const edm::EventSetup&) override; void produce(edm::Event&, edm::EventSetup const&) override; std::unordered_map makeHitMap(edm::Event const&, @@ -45,6 +46,8 @@ class CaloTruthCellsProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT> simHitsTokenEE_; edm::EDGetTokenT> simHitsTokenHEfront_; edm::EDGetTokenT> simHitsTokenHEback_; + edm::ESGetToken triggerGeomToken_; + edm::ESHandle triggerGeomHandle_; HGCalClusteringDummyImpl dummyClustering_; HGCalShowerShape showerShape_; @@ -60,6 +63,7 @@ CaloTruthCellsProducer::CaloTruthCellsProducer(edm::ParameterSet const& config) simHitsTokenEE_(consumes>(config.getParameter("simHitsEE"))), simHitsTokenHEfront_(consumes>(config.getParameter("simHitsHEfront"))), simHitsTokenHEback_(consumes>(config.getParameter("simHitsHEback"))), + triggerGeomToken_(esConsumes()), dummyClustering_(config.getParameterSet("dummyClustering")) { produces(); produces(); @@ -70,6 +74,10 @@ CaloTruthCellsProducer::CaloTruthCellsProducer(edm::ParameterSet const& config) CaloTruthCellsProducer::~CaloTruthCellsProducer() {} +void CaloTruthCellsProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { + triggerGeomHandle_ = es.getHandle(triggerGeomToken_); +} + void CaloTruthCellsProducer::produce(edm::Event& event, edm::EventSetup const& setup) { edm::Handle caloParticlesHandle; event.getByToken(caloParticlesToken_, caloParticlesHandle); @@ -79,13 +87,11 @@ void CaloTruthCellsProducer::produce(edm::Event& event, edm::EventSetup const& s event.getByToken(triggerCellsToken_, triggerCellsHandle); auto const& triggerCells(*triggerCellsHandle); - dummyClustering_.eventSetup(setup); - showerShape_.eventSetup(setup); - triggerTools_.eventSetup(setup); + auto const& geometry(*triggerGeomHandle_); - edm::ESHandle geometryHandle; - setup.get().get(geometryHandle); - auto const& geometry(*geometryHandle); + dummyClustering_.setGeometry(triggerGeomHandle_.product()); + showerShape_.setGeometry(triggerGeomHandle_.product()); + triggerTools_.setGeometry(triggerGeomHandle_.product()); std::unordered_map tcToCalo; diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc index 24506ebbabcd1..e5ab2cfa684f5 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc @@ -5,7 +5,7 @@ class HGCalTriggerNtupleEvent : public HGCalTriggerNtupleBase { HGCalTriggerNtupleEvent(const edm::ParameterSet&); void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event&, const edm::EventSetup&) final; + void fill(const edm::Event&, const HGCalTriggerNtupleEventSetup&) final; private: void clear() final; @@ -17,7 +17,9 @@ class HGCalTriggerNtupleEvent : public HGCalTriggerNtupleBase { DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleEvent, "HGCalTriggerNtupleEvent"); -HGCalTriggerNtupleEvent::HGCalTriggerNtupleEvent(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {} +HGCalTriggerNtupleEvent::HGCalTriggerNtupleEvent(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleEvent::initialize(TTree& tree, const edm::ParameterSet&, edm::ConsumesCollector&&) { clear(); @@ -26,7 +28,7 @@ void HGCalTriggerNtupleEvent::initialize(TTree& tree, const edm::ParameterSet&, tree.Branch("lumi", &lumi_, "lumi/I"); } -void HGCalTriggerNtupleEvent::fill(const edm::Event& e, const edm::EventSetup& es) { +void HGCalTriggerNtupleEvent::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { run_ = e.id().run(); lumi_ = e.luminosityBlock(); event_ = e.id().event(); diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc index cf815780a859c..4b1cbdf02f372 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc @@ -7,14 +7,11 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" #include "MagneticField/Engine/interface/MagneticField.h" -#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "TrackPropagation/RungeKutta/interface/defaultRKPropagator.h" #include "TrackPropagation/RungeKutta/interface/RKPropagatorInS.h" #include "FastSimulation/Event/interface/FSimEvent.h" -#include "SimGeneral/HepPDTRecord/interface/PDTRecord.h" #include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/ESWatcher.h" #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" @@ -120,7 +117,7 @@ class HGCalTriggerNtupleGen : public HGCalTriggerNtupleBase { HGCalTriggerNtupleGen(const edm::ParameterSet &); void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final; - void fill(const edm::Event &, const edm::EventSetup &) final; + void fill(const edm::Event &, const HGCalTriggerNtupleEventSetup &) final; enum ReachHGCal { notReach = 0, outsideEESurface = 1, onEESurface = 2 }; @@ -185,18 +182,16 @@ class HGCalTriggerNtupleGen : public HGCalTriggerNtupleBase { HGCalTriggerTools triggerTools_; - // edm::EDGetTokenT > genParticles_; edm::EDGetToken simTracks_token_; edm::EDGetToken simVertices_token_; edm::EDGetToken hepmcev_token_; - - edm::ESWatcher pdt_watcher_; - edm::ESWatcher magfield_watcher_; }; DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleGen, "HGCalTriggerNtupleGen"); -HGCalTriggerNtupleGen::HGCalTriggerNtupleGen(const edm::ParameterSet &conf) : HGCalTriggerNtupleBase(conf) {} +HGCalTriggerNtupleGen::HGCalTriggerNtupleGen(const edm::ParameterSet &conf) : HGCalTriggerNtupleBase(conf) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleGen::initialize(TTree &tree, const edm::ParameterSet &conf, edm::ConsumesCollector &&collector) { edm::ParameterSet particleFilter_(conf.getParameter("particleFilter")); @@ -251,26 +246,16 @@ void HGCalTriggerNtupleGen::initialize(TTree &tree, const edm::ParameterSet &con tree.Branch("genpart_posz", &genpart_posz_); } -void HGCalTriggerNtupleGen::fill(const edm::Event &iEvent, const edm::EventSetup &es) { +void HGCalTriggerNtupleGen::fill(const edm::Event &iEvent, const HGCalTriggerNtupleEventSetup &es) { clear(); edm::Handle> PupInfo_h; iEvent.getByToken(gen_PU_token_, PupInfo_h); const std::vector &PupInfo = *PupInfo_h; - if (pdt_watcher_.check(es)) { - edm::ESHandle pdt; - es.get().get(pdt); - mySimEvent_->initializePdt(&(*pdt)); - } - - if (magfield_watcher_.check(es)) { - edm::ESHandle magfield; - es.get().get(magfield); - aField_ = &(*magfield); - } - - triggerTools_.eventSetup(es); + mySimEvent_->initializePdt(&(*es.pdt)); + aField_ = &(*es.magfield); + triggerTools_.setGeometry(es.geometry.product()); // This balck magic is needed to use the mySimEvent_ edm::Handle hevH; diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc index 260a21925f260..6d49fc282e16d 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc @@ -9,7 +9,7 @@ class HGCalTriggerNtupleGenJet : public HGCalTriggerNtupleBase { HGCalTriggerNtupleGenJet(const edm::ParameterSet&); void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event&, const edm::EventSetup&) final; + void fill(const edm::Event&, const HGCalTriggerNtupleEventSetup&) final; private: void clear() final; @@ -25,7 +25,9 @@ class HGCalTriggerNtupleGenJet : public HGCalTriggerNtupleBase { DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleGenJet, "HGCalTriggerNtupleGenJet"); -HGCalTriggerNtupleGenJet::HGCalTriggerNtupleGenJet(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {} +HGCalTriggerNtupleGenJet::HGCalTriggerNtupleGenJet(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleGenJet::initialize(TTree& tree, const edm::ParameterSet& conf, @@ -38,7 +40,7 @@ void HGCalTriggerNtupleGenJet::initialize(TTree& tree, tree.Branch("genjet_phi", &genjet_phi_); } -void HGCalTriggerNtupleGenJet::fill(const edm::Event& e, const edm::EventSetup& es) { +void HGCalTriggerNtupleGenJet::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { edm::Handle genjets_h; e.getByToken(genjet_token_, genjets_h); const reco::GenJetCollection& genjets = *genjets_h; diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc index 18c3ce09ab380..90c24807aebad 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc @@ -11,7 +11,7 @@ class HGCalTriggerNtupleGenTau : public HGCalTriggerNtupleBase { HGCalTriggerNtupleGenTau(const edm::ParameterSet&); void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event&, const edm::EventSetup&) final; + void fill(const edm::Event&, const HGCalTriggerNtupleEventSetup&) final; private: void clear() final; @@ -58,7 +58,9 @@ class HGCalTriggerNtupleGenTau : public HGCalTriggerNtupleBase { DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleGenTau, "HGCalTriggerNtupleGenTau"); -HGCalTriggerNtupleGenTau::HGCalTriggerNtupleGenTau(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {} +HGCalTriggerNtupleGenTau::HGCalTriggerNtupleGenTau(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleGenTau::initialize(TTree& tree, const edm::ParameterSet& conf, @@ -143,7 +145,7 @@ bool HGCalTriggerNtupleGenTau::isStableNeutralHadron(const reco::GenParticle& ca candidate.status() == 1); } -void HGCalTriggerNtupleGenTau::fill(const edm::Event& e, const edm::EventSetup& es) { +void HGCalTriggerNtupleGenTau::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { edm::Handle gen_particles_h; e.getByToken(gen_token_, gen_particles_h); const reco::GenParticleCollection& gen_particles = *gen_particles_h; diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc index 0b6a6bfa58fa6..049a3b12e217a 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc @@ -2,7 +2,6 @@ #include #include "DataFormats/L1THGCal/interface/HGCalCluster.h" #include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" @@ -12,7 +11,7 @@ class HGCalTriggerNtupleHGCClusters : public HGCalTriggerNtupleBase { HGCalTriggerNtupleHGCClusters(const edm::ParameterSet& conf); ~HGCalTriggerNtupleHGCClusters() override{}; void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; + void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final; private: void clear() final; @@ -40,7 +39,9 @@ DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCClusters, "HGC HGCalTriggerNtupleHGCClusters::HGCalTriggerNtupleHGCClusters(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf), - filter_clusters_in_multiclusters_(conf.getParameter("FilterClustersInMulticlusters")) {} + filter_clusters_in_multiclusters_(conf.getParameter("FilterClustersInMulticlusters")) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleHGCClusters::initialize(TTree& tree, const edm::ParameterSet& conf, @@ -73,7 +74,7 @@ void HGCalTriggerNtupleHGCClusters::initialize(TTree& tree, tree.Branch(withPrefix("multicluster_pt"), &cl_multicluster_pt_); } -void HGCalTriggerNtupleHGCClusters::fill(const edm::Event& e, const edm::EventSetup& es) { +void HGCalTriggerNtupleHGCClusters::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { // retrieve clusters edm::Handle clusters_h; e.getByToken(clusters_token_, clusters_h); @@ -82,11 +83,7 @@ void HGCalTriggerNtupleHGCClusters::fill(const edm::Event& e, const edm::EventSe e.getByToken(multiclusters_token_, multiclusters_h); const l1t::HGCalMulticlusterBxCollection& multiclusters = *multiclusters_h; - // retrieve geometry - edm::ESHandle geometry; - es.get().get(geometry); - - triggerTools_.eventSetup(es); + triggerTools_.setGeometry(es.geometry.product()); // Associate cells to clusters std::unordered_map cluster2multicluster; diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCConcentratorData.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCConcentratorData.cc index f7d717316c090..ada98e6777a1b 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCConcentratorData.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCConcentratorData.cc @@ -13,7 +13,7 @@ class HGCalTriggerNtupleHGCConcentratorData : public HGCalTriggerNtupleBase { HGCalTriggerNtupleHGCConcentratorData(const edm::ParameterSet& conf); ~HGCalTriggerNtupleHGCConcentratorData() override{}; void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; + void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final; private: void clear() final; @@ -21,7 +21,6 @@ class HGCalTriggerNtupleHGCConcentratorData : public HGCalTriggerNtupleBase { HGCalTriggerTools triggerTools_; edm::EDGetToken concentrator_data_token_; - edm::ESHandle geometry_; int econ_n_; std::vector econ_id_; @@ -40,7 +39,9 @@ DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, "HGCalTriggerNtupleHGCConcentratorData"); HGCalTriggerNtupleHGCConcentratorData::HGCalTriggerNtupleHGCConcentratorData(const edm::ParameterSet& conf) - : HGCalTriggerNtupleBase(conf) {} + : HGCalTriggerNtupleBase(conf) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleHGCConcentratorData::initialize(TTree& tree, const edm::ParameterSet& conf, @@ -68,16 +69,13 @@ void HGCalTriggerNtupleHGCConcentratorData::initialize(TTree& tree, tree.Branch(withPrefix("data"), &econ_data_); } -void HGCalTriggerNtupleHGCConcentratorData::fill(const edm::Event& e, const edm::EventSetup& es) { +void HGCalTriggerNtupleHGCConcentratorData::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { // retrieve trigger cells edm::Handle concentrator_data_h; e.getByToken(concentrator_data_token_, concentrator_data_h); const l1t::HGCalConcentratorDataBxCollection& concentrator_data = *concentrator_data_h; - // retrieve geometry - es.get().get(geometry_); - - triggerTools_.eventSetup(es); + triggerTools_.setGeometry(es.geometry.product()); clear(); for (auto econ_itr = concentrator_data.begin(0); econ_itr != concentrator_data.end(0); econ_itr++) { diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc index 95c4b383a437a..1f3e52d907e71 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc @@ -15,7 +15,7 @@ class HGCalTriggerNtupleHGCDigis : public HGCalTriggerNtupleBase { HGCalTriggerNtupleHGCDigis(const edm::ParameterSet& conf); ~HGCalTriggerNtupleHGCDigis() override{}; void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; + void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final; private: void simhits(const edm::Event& e, @@ -63,13 +63,12 @@ class HGCalTriggerNtupleHGCDigis : public HGCalTriggerNtupleBase { std::vector> bhdigi_data_; std::vector> bhdigi_isadc_; std::vector bhdigi_simenergy_; - - edm::ESHandle triggerGeometry_; }; DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCDigis, "HGCalTriggerNtupleHGCDigis"); HGCalTriggerNtupleHGCDigis::HGCalTriggerNtupleHGCDigis(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) { + accessEventSetup_ = false; is_Simhit_comp_ = conf.getParameter("isSimhitComp"); digiBXselect_ = conf.getParameter>("digiBXselect"); @@ -149,9 +148,7 @@ void HGCalTriggerNtupleHGCDigis::initialize(TTree& tree, tree.Branch("bhdigi_simenergy", &bhdigi_simenergy_); } -void HGCalTriggerNtupleHGCDigis::fill(const edm::Event& e, const edm::EventSetup& es) { - es.get().get(triggerGeometry_); - +void HGCalTriggerNtupleHGCDigis::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { edm::Handle ee_digis_h; e.getByToken(ee_token_, ee_digis_h); const HGCalDigiCollection& ee_digis = *ee_digis_h; @@ -162,7 +159,7 @@ void HGCalTriggerNtupleHGCDigis::fill(const edm::Event& e, const edm::EventSetup e.getByToken(bh_token_, bh_digis_h); const HGCalDigiCollection& bh_digis = *bh_digis_h; - triggerTools_.eventSetup(es); + triggerTools_.setGeometry(es.geometry.product()); // sim hit association std::unordered_map simhits_ee; @@ -215,7 +212,7 @@ void HGCalTriggerNtupleHGCDigis::fill(const edm::Event& e, const edm::EventSetup hgcdigi_subdet_.emplace_back(id.det()); hgcdigi_side_.emplace_back(triggerTools_.zside(id)); hgcdigi_layer_.emplace_back(triggerTools_.layerWithOffset(id)); - GlobalPoint cellpos = triggerGeometry_->eeGeometry()->getPosition(id.rawId()); + GlobalPoint cellpos = triggerTools_.getTriggerGeometry()->eeGeometry()->getPosition(id.rawId()); hgcdigi_eta_.emplace_back(cellpos.eta()); hgcdigi_phi_.emplace_back(cellpos.phi()); hgcdigi_z_.emplace_back(cellpos.z()); @@ -244,7 +241,7 @@ void HGCalTriggerNtupleHGCDigis::fill(const edm::Event& e, const edm::EventSetup hgcdigi_subdet_.emplace_back(id.det()); hgcdigi_side_.emplace_back(triggerTools_.zside(id)); hgcdigi_layer_.emplace_back(triggerTools_.layerWithOffset(id)); - GlobalPoint cellpos = triggerGeometry_->hsiGeometry()->getPosition(id.rawId()); + GlobalPoint cellpos = triggerTools_.getTriggerGeometry()->hsiGeometry()->getPosition(id.rawId()); hgcdigi_eta_.emplace_back(cellpos.eta()); hgcdigi_phi_.emplace_back(cellpos.phi()); hgcdigi_z_.emplace_back(cellpos.z()); @@ -273,7 +270,7 @@ void HGCalTriggerNtupleHGCDigis::fill(const edm::Event& e, const edm::EventSetup bhdigi_subdet_.emplace_back(id.det()); bhdigi_side_.emplace_back(triggerTools_.zside(id)); bhdigi_layer_.emplace_back(triggerTools_.layerWithOffset(id)); - GlobalPoint cellpos = triggerGeometry_->hscGeometry()->getPosition(id.rawId()); + GlobalPoint cellpos = triggerTools_.getTriggerGeometry()->hscGeometry()->getPosition(id.rawId()); bhdigi_eta_.emplace_back(cellpos.eta()); bhdigi_phi_.emplace_back(cellpos.phi()); bhdigi_z_.emplace_back(cellpos.z()); @@ -310,7 +307,7 @@ void HGCalTriggerNtupleHGCDigis::simhits(const edm::Event& e, //EE for (const auto& simhit : ee_simhits) { - DetId id = triggerTools_.simToReco(simhit.id(), triggerGeometry_->eeTopology()); + DetId id = triggerTools_.simToReco(simhit.id(), triggerTools_.getTriggerGeometry()->eeTopology()); if (id.rawId() == 0) continue; auto itr_insert = simhits_ee.emplace(id, 0.); @@ -318,7 +315,7 @@ void HGCalTriggerNtupleHGCDigis::simhits(const edm::Event& e, } // FH for (const auto& simhit : fh_simhits) { - DetId id = triggerTools_.simToReco(simhit.id(), triggerGeometry_->fhTopology()); + DetId id = triggerTools_.simToReco(simhit.id(), triggerTools_.getTriggerGeometry()->fhTopology()); if (id.rawId() == 0) continue; auto itr_insert = simhits_fh.emplace(id, 0.); @@ -326,7 +323,7 @@ void HGCalTriggerNtupleHGCDigis::simhits(const edm::Event& e, } // BH for (const auto& simhit : bh_simhits) { - DetId id = triggerTools_.simToReco(simhit.id(), triggerGeometry_->hscTopology()); + DetId id = triggerTools_.simToReco(simhit.id(), triggerTools_.getTriggerGeometry()->hscTopology()); if (id.rawId() == 0) continue; auto itr_insert = simhits_bh.emplace(id, 0.); diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc index 4061e8a8dc405..34c72aa4df886 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc @@ -9,7 +9,7 @@ class HGCalTriggerNtupleHGCMulticlusters : public HGCalTriggerNtupleBase { HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet& conf); ~HGCalTriggerNtupleHGCMulticlusters() override{}; void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; + void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final; private: void clear() final; @@ -62,7 +62,9 @@ DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCMulticlusters, HGCalTriggerNtupleHGCMulticlusters::HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf), fill_layer_info_(conf.getParameter("FillLayerInfo")), - fill_interpretation_info_(conf.getParameter("FillInterpretationInfo")) {} + fill_interpretation_info_(conf.getParameter("FillInterpretationInfo")) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleHGCMulticlusters::initialize(TTree& tree, const edm::ParameterSet& conf, @@ -119,16 +121,12 @@ void HGCalTriggerNtupleHGCMulticlusters::initialize(TTree& tree, } } -void HGCalTriggerNtupleHGCMulticlusters::fill(const edm::Event& e, const edm::EventSetup& es) { +void HGCalTriggerNtupleHGCMulticlusters::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { // retrieve clusters 3D edm::Handle multiclusters_h; e.getByToken(multiclusters_token_, multiclusters_h); const l1t::HGCalMulticlusterBxCollection& multiclusters = *multiclusters_h; - // retrieve geometry - edm::ESHandle geometry; - es.get().get(geometry); - clear(); for (auto cl3d_itr = multiclusters.begin(0); cl3d_itr != multiclusters.end(0); cl3d_itr++) { cl3d_n_++; @@ -174,10 +172,10 @@ void HGCalTriggerNtupleHGCMulticlusters::fill(const edm::Event& e, const edm::Ev //Per layer cluster information if (fill_layer_info_) { - const unsigned nlayers = geometry->lastTriggerLayer(); + const unsigned nlayers = es.geometry->lastTriggerLayer(); std::vector layer_pt(nlayers, 0.0); for (const auto& cl_ptr : cl3d_itr->constituents()) { - unsigned layer = geometry->triggerLayer(cl_ptr.second->detId()); + unsigned layer = es.geometry->triggerLayer(cl_ptr.second->detId()); layer_pt[layer] += cl_ptr.second->pt(); } cl3d_layer_pt_.emplace_back(layer_pt); diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc index 538f96e03c47d..1fdcb9e1975de 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc @@ -11,7 +11,6 @@ #include "SimDataFormats/CaloAnalysis/interface/CaloParticleFwd.h" #include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h" #include "DataFormats/ForwardDetId/interface/HGCalTriggerDetId.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" @@ -21,7 +20,7 @@ class HGCalTriggerNtupleHGCTriggerCells : public HGCalTriggerNtupleBase { HGCalTriggerNtupleHGCTriggerCells(const edm::ParameterSet& conf); ~HGCalTriggerNtupleHGCTriggerCells() override{}; void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; + void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final; private: double calibrate(double, int, unsigned); @@ -43,7 +42,6 @@ class HGCalTriggerNtupleHGCTriggerCells : public HGCalTriggerNtupleBase { std::vector fcPerMip_; std::vector layerWeights_; std::vector thicknessCorrections_; - edm::ESHandle geometry_; int tc_n_; std::vector tc_id_; @@ -85,7 +83,9 @@ HGCalTriggerNtupleHGCTriggerCells::HGCalTriggerNtupleHGCTriggerCells(const edm:: keV2fC_(conf.getParameter("keV2fC")), fcPerMip_(conf.getParameter>("fcPerMip")), layerWeights_(conf.getParameter>("layerWeights")), - thicknessCorrections_(conf.getParameter>("thicknessCorrections")) {} + thicknessCorrections_(conf.getParameter>("thicknessCorrections")) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleHGCTriggerCells::initialize(TTree& tree, const edm::ParameterSet& conf, @@ -143,7 +143,7 @@ void HGCalTriggerNtupleHGCTriggerCells::initialize(TTree& tree, tree.Branch(withPrefix("genparticle_index"), &tc_genparticle_index_); } -void HGCalTriggerNtupleHGCTriggerCells::fill(const edm::Event& e, const edm::EventSetup& es) { +void HGCalTriggerNtupleHGCTriggerCells::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { // retrieve trigger cells edm::Handle trigger_cells_h; e.getByToken(trigger_cells_token_, trigger_cells_h); @@ -154,9 +154,6 @@ void HGCalTriggerNtupleHGCTriggerCells::fill(const edm::Event& e, const edm::Eve e.getByToken(multiclusters_token_, multiclusters_h); const l1t::HGCalMulticlusterBxCollection& multiclusters = *multiclusters_h; - // retrieve geometry - es.get().get(geometry_); - // sim hit association std::unordered_map simhits_ee; std::unordered_map simhits_fh; @@ -188,7 +185,7 @@ void HGCalTriggerNtupleHGCTriggerCells::fill(const edm::Event& e, const edm::Eve } } - triggerTools_.eventSetup(es); + triggerTools_.setGeometry(es.geometry.product()); clear(); for (auto tc_itr = trigger_cells.begin(0); tc_itr != trigger_cells.end(0); tc_itr++) { @@ -248,7 +245,7 @@ void HGCalTriggerNtupleHGCTriggerCells::fill(const edm::Event& e, const edm::Eve double energy = 0; unsigned layer = triggerTools_.layerWithOffset(id); // search for simhit for all the cells inside the trigger cell - for (uint32_t c_id : geometry_->getCellsFromTriggerCell(id)) { + for (uint32_t c_id : triggerTools_.getTriggerGeometry()->getCellsFromTriggerCell(id)) { int thickness = triggerTools_.thicknessIndex(c_id); if (triggerTools_.isEm(id)) { auto itr = simhits_ee.find(c_id); @@ -302,7 +299,7 @@ void HGCalTriggerNtupleHGCTriggerCells::simhits(const edm::Event& e, // EE for (const auto& simhit : ee_simhits) { - DetId id = triggerTools_.simToReco(simhit.id(), geometry_->eeTopology()); + DetId id = triggerTools_.simToReco(simhit.id(), triggerTools_.getTriggerGeometry()->eeTopology()); if (id.rawId() == 0) continue; auto itr_insert = simhits_ee.emplace(id, 0.); @@ -310,7 +307,7 @@ void HGCalTriggerNtupleHGCTriggerCells::simhits(const edm::Event& e, } // FH for (const auto& simhit : fh_simhits) { - DetId id = triggerTools_.simToReco(simhit.id(), geometry_->fhTopology()); + DetId id = triggerTools_.simToReco(simhit.id(), triggerTools_.getTriggerGeometry()->fhTopology()); if (id.rawId() == 0) continue; auto itr_insert = simhits_fh.emplace(id, 0.); @@ -318,7 +315,7 @@ void HGCalTriggerNtupleHGCTriggerCells::simhits(const edm::Event& e, } // BH for (const auto& simhit : bh_simhits) { - DetId id = triggerTools_.simToReco(simhit.id(), geometry_->hscTopology()); + DetId id = triggerTools_.simToReco(simhit.id(), triggerTools_.getTriggerGeometry()->hscTopology()); if (id.rawId() == 0) continue; auto itr_insert = simhits_bh.emplace(id, 0.); diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerSums.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerSums.cc index 8a5c3d292e550..7ca8a32288ebd 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerSums.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerSums.cc @@ -13,7 +13,7 @@ class HGCalTriggerNtupleHGCTriggerSums : public HGCalTriggerNtupleBase { HGCalTriggerNtupleHGCTriggerSums(const edm::ParameterSet& conf); ~HGCalTriggerNtupleHGCTriggerSums() override{}; void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; + void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final; private: void clear() final; @@ -45,7 +45,9 @@ class HGCalTriggerNtupleHGCTriggerSums : public HGCalTriggerNtupleBase { DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCTriggerSums, "HGCalTriggerNtupleHGCTriggerSums"); HGCalTriggerNtupleHGCTriggerSums::HGCalTriggerNtupleHGCTriggerSums(const edm::ParameterSet& conf) - : HGCalTriggerNtupleBase(conf) {} + : HGCalTriggerNtupleBase(conf) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleHGCTriggerSums::initialize(TTree& tree, const edm::ParameterSet& conf, @@ -79,13 +81,13 @@ void HGCalTriggerNtupleHGCTriggerSums::initialize(TTree& tree, tree.Branch(withPrefix("z"), &ts_z_); } -void HGCalTriggerNtupleHGCTriggerSums::fill(const edm::Event& e, const edm::EventSetup& es) { +void HGCalTriggerNtupleHGCTriggerSums::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { // retrieve trigger cells edm::Handle trigger_sums_h; e.getByToken(trigger_sums_token_, trigger_sums_h); const l1t::HGCalTriggerSumsBxCollection& trigger_sums = *trigger_sums_h; - triggerTools_.eventSetup(es); + triggerTools_.setGeometry(es.geometry.product()); clear(); for (auto ts_itr = trigger_sums.begin(0); ts_itr != trigger_sums.end(0); ts_itr++) { diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc index 9e32a4a65c4f2..c90a5f7712914 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc @@ -8,6 +8,12 @@ #include "CommonTools/UtilAlgos/interface/TFileService.h" #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "SimGeneral/HepPDTRecord/interface/PDTRecord.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" + class HGCalTriggerNtupleManager : public edm::EDAnalyzer { public: typedef std::unique_ptr ntuple_ptr; @@ -15,18 +21,26 @@ class HGCalTriggerNtupleManager : public edm::EDAnalyzer { public: explicit HGCalTriggerNtupleManager(const edm::ParameterSet& conf); ~HGCalTriggerNtupleManager() override{}; - void beginRun(const edm::Run&, const edm::EventSetup&) override{}; + void beginRun(const edm::Run&, const edm::EventSetup&) override; void analyze(const edm::Event&, const edm::EventSetup&) override; private: edm::Service file_service_; std::vector hgc_ntuples_; TTree* tree_; + + HGCalTriggerNtupleEventSetup ntuple_es_; + edm::ESGetToken pdtToken_; + edm::ESGetToken magfieldToken_; + edm::ESGetToken triggerGeomToken_; }; DEFINE_FWK_MODULE(HGCalTriggerNtupleManager); -HGCalTriggerNtupleManager::HGCalTriggerNtupleManager(const edm::ParameterSet& conf) { +HGCalTriggerNtupleManager::HGCalTriggerNtupleManager(const edm::ParameterSet& conf) + : pdtToken_(esConsumes()), + magfieldToken_(esConsumes()), + triggerGeomToken_(esConsumes()) { tree_ = file_service_->make("HGCalTriggerNtuple", "HGCalTriggerNtuple"); const std::vector& ntuple_cfgs = conf.getParameterSetVector("Ntuples"); for (const auto& ntuple_cfg : ntuple_cfgs) { @@ -36,9 +50,20 @@ HGCalTriggerNtupleManager::HGCalTriggerNtupleManager(const edm::ParameterSet& co } } +void HGCalTriggerNtupleManager::beginRun(const edm::Run& run, const edm::EventSetup& es) { + ntuple_es_.pdt = es.getHandle(pdtToken_); + ntuple_es_.magfield = es.getHandle(magfieldToken_); + ntuple_es_.geometry = es.getHandle(triggerGeomToken_); +} + void HGCalTriggerNtupleManager::analyze(const edm::Event& e, const edm::EventSetup& es) { for (auto& hgc_ntuple : hgc_ntuples_) { - hgc_ntuple->fill(e, es); + if (hgc_ntuple->accessEventSetup()) { + hgc_ntuple->fill(e, es); + } else { + hgc_ntuple->fill(e, ntuple_es_); + } } + tree_->Fill(); } diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc index e833b09e36c8f..9f328400f9a21 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc @@ -1,6 +1,4 @@ #include "DataFormats/L1THGCal/interface/HGCalTower.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" class HGCalTriggerNtupleHGCTowers : public HGCalTriggerNtupleBase { @@ -8,7 +6,7 @@ class HGCalTriggerNtupleHGCTowers : public HGCalTriggerNtupleBase { HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf); ~HGCalTriggerNtupleHGCTowers() override{}; void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; + void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final; private: void clear() final; @@ -28,8 +26,9 @@ class HGCalTriggerNtupleHGCTowers : public HGCalTriggerNtupleBase { DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCTowers, "HGCalTriggerNtupleHGCTowers"); -HGCalTriggerNtupleHGCTowers::HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf) - : HGCalTriggerNtupleBase(conf) {} +HGCalTriggerNtupleHGCTowers::HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) { + accessEventSetup_ = false; +} void HGCalTriggerNtupleHGCTowers::initialize(TTree& tree, const edm::ParameterSet& conf, @@ -55,16 +54,12 @@ void HGCalTriggerNtupleHGCTowers::initialize(TTree& tree, tree.Branch(withPrefix("iPhi"), &tower_iPhi_); } -void HGCalTriggerNtupleHGCTowers::fill(const edm::Event& e, const edm::EventSetup& es) { +void HGCalTriggerNtupleHGCTowers::fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) { // retrieve towers edm::Handle towers_h; e.getByToken(towers_token_, towers_h); const l1t::HGCalTowerBxCollection& towers = *towers_h; - // retrieve geometry - edm::ESHandle geometry; - es.get().get(geometry); - clear(); for (auto tower_itr = towers.begin(0); tower_itr != towers.end(0); tower_itr++) { tower_n_++;