diff --git a/Calibration/EcalAlCaRecoProducers/plugins/SelectedElectronFEDListProducer.cc b/Calibration/EcalAlCaRecoProducers/plugins/SelectedElectronFEDListProducer.cc index c020bc7a498c9..71e552878eb9a 100644 --- a/Calibration/EcalAlCaRecoProducers/plugins/SelectedElectronFEDListProducer.cc +++ b/Calibration/EcalAlCaRecoProducers/plugins/SelectedElectronFEDListProducer.cc @@ -8,21 +8,13 @@ #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" -//#include "DataFormats/Common/interface/Handle.h" - #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "FWCore/Utilities/interface/InputTag.h" // raw data #include "DataFormats/FEDRawData/interface/FEDRawData.h" -//#include "DataFormats/FEDRawData/interface/FEDNumbering.h" // Geometry -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h" -#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h" -// strip geometry -#include "CalibFormats/SiStripObjects/interface/SiStripRegionCabling.h" -#include "CalibTracker/Records/interface/SiStripRegionCablingRcd.h" // egamma objects #include "DataFormats/EgammaReco/interface/SuperCluster.h" @@ -37,7 +29,6 @@ // Strip and pixel #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h" -#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" // detector id #include "DataFormats/HcalDetId/interface/HcalDetId.h" @@ -47,30 +38,26 @@ #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h" // Geometry #include "Geometry/Records/interface/CaloTopologyRecord.h" -#include "Geometry/EcalMapping/interface/EcalMappingRcd.h" #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" // strip geometry #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h" -#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h" // Message logger #include "FWCore/MessageLogger/interface/MessageLogger.h" // Strip and pixel #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h" -#include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h" -// Hcal objects -#include "CalibFormats/HcalObjects/interface/HcalDbService.h" -#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h" - using namespace std; /// Producer constructor template -SelectedElectronFEDListProducer::SelectedElectronFEDListProducer(const edm::ParameterSet& iConfig) { +SelectedElectronFEDListProducer::SelectedElectronFEDListProducer(const edm::ParameterSet& iConfig) + : hcalDbToken_(esConsumes()), + ecalMappingToken_(esConsumes()), + caloGeometryToken_(esConsumes()), + siPixelFedCablingMapToken_(esConsumes()), + trackerGeometryToken_(esConsumes()), + siStripRegionCablingToken_(esConsumes()) { // input electron collection Tag if (iConfig.existsAs>("electronTags")) { electronTags_ = iConfig.getParameter>("electronTags"); @@ -309,36 +296,30 @@ void SelectedElectronFEDListProducer::beginJob() { template void SelectedElectronFEDListProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // get the hcal electronics map - edm::ESHandle pSetup; - iSetup.get().get(pSetup); - HcalReadoutMap_ = pSetup->getHcalMapping(); + const auto& pSetup = iSetup.getData(hcalDbToken_); + HcalReadoutMap_ = pSetup.getHcalMapping(); // get the ecal electronics map - edm::ESHandle ecalmapping; - iSetup.get().get(ecalmapping); - EcalMapping_ = ecalmapping.product(); + EcalMapping_ = &iSetup.getData(ecalMappingToken_); // get the calo geometry - edm::ESHandle caloGeometry; - iSetup.get().get(caloGeometry); - GeometryCalo_ = caloGeometry.product(); + const auto& caloGeometry = iSetup.getData(caloGeometryToken_); + GeometryCalo_ = &caloGeometry; //ES geometry - GeometryES_ = caloGeometry->getSubdetectorGeometry(DetId::Ecal, EcalPreshower); + GeometryES_ = caloGeometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower); // pixel tracker cabling map - edm::ESTransientHandle pixelCablingMap; - iSetup.get().get(pixelCablingMap); + const auto pixelCablingMap = iSetup.getTransientHandle(siPixelFedCablingMapToken_); PixelCabling_.reset(); PixelCabling_ = pixelCablingMap->cablingTree(); - edm::ESHandle trackerGeometry; - iSetup.get().get(trackerGeometry); + const auto& trackerGeometry = iSetup.getData(trackerGeometryToken_); if (pixelModuleVector_.empty()) { // build the tracker pixel module map - std::vector::const_iterator itTracker = trackerGeometry->dets().begin(); - for (; itTracker != trackerGeometry->dets().end(); ++itTracker) { + std::vector::const_iterator itTracker = trackerGeometry.dets().begin(); + for (; itTracker != trackerGeometry.dets().end(); ++itTracker) { int subdet = (*itTracker)->geographicalId().subdetId(); if (!(subdet == PixelSubdetector::PixelBarrel || subdet == PixelSubdetector::PixelEndcap)) continue; @@ -357,9 +338,7 @@ void SelectedElectronFEDListProducer::produce(edm::Event& iEvent, c std::sort(pixelModuleVector_.begin(), pixelModuleVector_.end()); } - edm::ESHandle SiStripCablingHandle; - iSetup.get().get(SiStripCablingHandle); - StripRegionCabling_ = SiStripCablingHandle.product(); + StripRegionCabling_ = &iSetup.getData(siStripRegionCablingToken_); SiStripRegionCabling::Cabling SiStripCabling; SiStripCabling = StripRegionCabling_->getRegionCabling(); diff --git a/Calibration/EcalAlCaRecoProducers/plugins/SelectedElectronFEDListProducer.h b/Calibration/EcalAlCaRecoProducers/plugins/SelectedElectronFEDListProducer.h index 006b01cf69721..16157c5d0e6ec 100644 --- a/Calibration/EcalAlCaRecoProducers/plugins/SelectedElectronFEDListProducer.h +++ b/Calibration/EcalAlCaRecoProducers/plugins/SelectedElectronFEDListProducer.h @@ -1,17 +1,33 @@ -#ifndef SelectedElectronFEDListProducer_h -#define SelectedElectronFEDListProducer_h +#ifndef Calibration_EcalAlCaRecoProducers_SelectedElectronFEDListProducer_h +#define Calibration_EcalAlCaRecoProducers_SelectedElectronFEDListProducer_h #include "DataFormats/BeamSpot/interface/BeamSpot.h" // egamma objects #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h" +#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h" +// Geometry +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/EcalMapping/interface/EcalMappingRcd.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +// strip geometry +#include "CalibFormats/SiStripObjects/interface/SiStripRegionCabling.h" +#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h" +#include "CalibTracker/Records/interface/SiStripRegionCablingRcd.h" +// Strip and pixel +#include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" +// Hcal objects +#include "CalibFormats/HcalObjects/interface/HcalDbService.h" +#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h" + // Math #include "DataFormats/Math/interface/normalizedPhi.h" #include "FWCore/Framework/interface/stream/EDProducer.h" -// #include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" // Message logger #include "FWCore/ServiceRegistry/interface/Service.h" @@ -19,14 +35,10 @@ class InputTag; class FEDRawDataCollection; -class SiPixelFedCablingMap; class SiPixelFedCablingTree; class SiStripFedCabling; -class SiStripRegionCabling; -class CaloGeometry; class CaloSubdetectorGeometry; -class EcalElectronicsMapping; class HcalElectronicsMap; // Hcal rec hit: this is a Fwd file defining typedefs @@ -131,6 +143,14 @@ class SelectedElectronFEDListProducer : public edm::stream::EDProducer<> { std::vector > recoEcalCandidateToken_; std::vector > electronToken_; + // Token for the input collection + const edm::ESGetToken hcalDbToken_; + const edm::ESGetToken ecalMappingToken_; + const edm::ESGetToken caloGeometryToken_; + const edm::ESGetToken siPixelFedCablingMapToken_; + const edm::ESGetToken trackerGeometryToken_; + const edm::ESGetToken siStripRegionCablingToken_; + // used inside the producer math::XYZVector beamSpotPosition_; diff --git a/Calibration/EcalCalibAlgos/interface/ECALpedestalPCLHarvester.h b/Calibration/EcalCalibAlgos/interface/ECALpedestalPCLHarvester.h index 388ccf14639be..bb607057da860 100644 --- a/Calibration/EcalCalibAlgos/interface/ECALpedestalPCLHarvester.h +++ b/Calibration/EcalCalibAlgos/interface/ECALpedestalPCLHarvester.h @@ -29,6 +29,8 @@ #include "DataFormats/EcalDetId/interface/EEDetId.h" #include "CondFormats/EcalObjects/interface/EcalPedestals.h" #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h" +#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h" +#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" class ECALpedestalPCLHarvester : public DQMEDHarvester { public: @@ -41,24 +43,30 @@ class ECALpedestalPCLHarvester : public DQMEDHarvester { void dqmPlots(const EcalPedestals& newpeds, DQMStore::IBooker& ibooker); - const EcalPedestals* currentPedestals_; - const EcalPedestals* g6g1Pedestals_; - const EcalChannelStatus* channelStatus_; + bool checkVariation(const EcalPedestalsMap& oldPedestals, const EcalPedestalsMap& newPedestals); bool checkStatusCode(const DetId& id); bool isGood(const DetId& id); - bool checkVariation(const EcalPedestalsMap& oldPedestals, const EcalPedestalsMap& newPedestals); std::vector chStatusToExclude_; - int minEntries_; + const int minEntries_; int entriesEB_[EBDetId::kSizeForDenseIndexing]; int entriesEE_[EEDetId::kSizeForDenseIndexing]; - bool checkAnomalies_; // whether or not to avoid creating sqlite file in case of many changed pedestals - double nSigma_; // threshold in sigmas to define a pedestal as changed - double thresholdAnomalies_; // threshold (fraction of changed pedestals) to avoid creation of sqlite file - std::string dqmDir_; // DQM directory where histograms are stored - std::string labelG6G1_; // DB label from which pedestals for G6 and G1 are to be copied - float threshDiffEB_; // if the new pedestals differs more than this from old, keep old - float threshDiffEE_; // same as above for EE. Stray channel protection - float threshChannelsAnalyzed_; // threshold for minimum percentage of channels analized to produce DQM plots + const bool checkAnomalies_; // whether or not to avoid creating sqlite file in case of many changed pedestals + const double nSigma_; // threshold in sigmas to define a pedestal as changed + const double thresholdAnomalies_; // threshold (fraction of changed pedestals) to avoid creation of sqlite file + const std::string dqmDir_; // DQM directory where histograms are stored + const std::string labelG6G1_; // DB label from which pedestals for G6 and G1 are to be copied + const float threshDiffEB_; // if the new pedestals differs more than this from old, keep old + const float threshDiffEE_; // same as above for EE. Stray channel protection + const float threshChannelsAnalyzed_; // threshold for minimum percentage of channels analized to produce DQM plots + + // ES token + const edm::ESGetToken channelsStatusToken_; + const edm::ESGetToken pedestalsToken_; + const edm::ESGetToken g6g1PedestalsToken_; + + const EcalPedestals* currentPedestals_; + const EcalPedestals* g6g1Pedestals_; + const EcalChannelStatus* channelStatus_; }; diff --git a/Calibration/EcalCalibAlgos/interface/ECALpedestalPCLworker.h b/Calibration/EcalCalibAlgos/interface/ECALpedestalPCLworker.h index 8c5014c873740..2dc10a29a8577 100644 --- a/Calibration/EcalCalibAlgos/interface/ECALpedestalPCLworker.h +++ b/Calibration/EcalCalibAlgos/interface/ECALpedestalPCLworker.h @@ -23,6 +23,8 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CondFormats/EcalObjects/interface/EcalPedestals.h" +#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h" #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" #include "DataFormats/TCDS/interface/BSTRecord.h" #include "DataFormats/TCDS/interface/TCDSRecord.h" @@ -43,6 +45,7 @@ class ECALpedestalPCLworker : public DQMEDAnalyzer { edm::EDGetTokenT digiTokenEB_; edm::EDGetTokenT digiTokenEE_; edm::EDGetTokenT tcdsToken_; + const edm::ESGetToken pedestalToken_; std::vector meEB_; std::vector meEE_; diff --git a/Calibration/EcalCalibAlgos/interface/EcalEleCalibLooper.h b/Calibration/EcalCalibAlgos/interface/EcalEleCalibLooper.h index 4508b89ebd4a0..856124fc12240 100644 --- a/Calibration/EcalCalibAlgos/interface/EcalEleCalibLooper.h +++ b/Calibration/EcalCalibAlgos/interface/EcalEleCalibLooper.h @@ -25,6 +25,8 @@ #include "DataFormats/EgammaCandidates/interface/Electron.h" #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" #include "CLHEP/Matrix/GenMatrix.h" #include "CLHEP/Matrix/Matrix.h" @@ -60,64 +62,64 @@ class EcalEleCalibLooper : public edm::EDLooper { private: //! EcalBarrel Input Collection name - edm::InputTag m_barrelAlCa; + const edm::InputTag m_barrelAlCa; //! EcalEndcap Input Collection name - edm::InputTag m_endcapAlCa; + const edm::InputTag m_endcapAlCa; + //! To take the electrons + edm::InputTag m_ElectronLabel; //! reconstruction window size - int m_recoWindowSidex; - int m_recoWindowSidey; + const int m_recoWindowSidex; + const int m_recoWindowSidey; //! eta size of the sub-matrix - int m_etaWidth; //PG sub matrix size and borders + const int m_etaWidth; //PG sub matrix size and borders //! eta size of the additive border to the sub-matrix // int m_etaBorder ; //FIXME //! phi size of the sub-matrix - int m_phiWidthEB; + const int m_phiWidthEB; //! phi size of the additive border to the sub-matrix // int m_phiBorderEB //FIXME; //! eta start of the region of interest - int m_etaStart; //PG ECAL region to be calibrated + const int m_etaStart; //PG ECAL region to be calibrated //! eta end of the region of interest - int m_etaEnd; + const int m_etaEnd; //! phi start of the region of interest - int m_phiStartEB; + const int m_phiStartEB; //! phi end of the region of interest - int m_phiEndEB; + const int m_phiEndEB; //!DS For the EE - int m_radStart; - int m_radEnd; - int m_radWidth; + const int m_radStart; + const int m_radEnd; + const int m_radWidth; //FIXME int m_radBorder ; - int m_phiStartEE; - int m_phiEndEE; - int m_phiWidthEE; + const int m_phiStartEE; + const int m_phiEndEE; + const int m_phiWidthEE; //! maximum number of events per crystal - int m_maxSelectedNumPerXtal; + const int m_maxSelectedNumPerXtal; //! single blocks calibrators std::vector m_EcalCalibBlocks; //! minimum energy per crystal cut - double m_minEnergyPerCrystal; + const double m_minEnergyPerCrystal; //! maximum energy per crystal cut - double m_maxEnergyPerCrystal; + const double m_maxEnergyPerCrystal; //! minimum coefficient accepted (RAW) - double m_minCoeff; + const double m_minCoeff; //! maximum coefficient accepted (RAW) - double m_maxCoeff; + const double m_maxCoeff; //! to exclude the blocksolver - int m_usingBlockSolver; + const int m_usingBlockSolver; //!the maps of recalib coeffs EcalIntercalibConstantMap m_barrelMap; EcalIntercalibConstantMap m_endcapMap; //! DS sets the number of loops to do - unsigned int m_loops; - //! To take the electrons - edm::InputTag m_ElectronLabel; + const unsigned int m_loops; //The map Filler VFillMap *m_MapFiller; @@ -136,6 +138,13 @@ class EcalEleCalibLooper : public edm::EDLooper { std::map m_xtalNumOfHits; bool isfirstcall_; + + //! ED token + const edm::EDGetTokenT m_ebRecHitToken; + const edm::EDGetTokenT m_eeRecHitToken; + const edm::EDGetTokenT m_gsfElectronToken; + //! ES token + const edm::ESGetToken m_geometryToken; }; #endif #endif diff --git a/Calibration/EcalCalibAlgos/interface/ElectronCalibrationUniv.h b/Calibration/EcalCalibAlgos/interface/ElectronCalibrationUniv.h index d5d2d4d9d215c..a602561587602 100644 --- a/Calibration/EcalCalibAlgos/interface/ElectronCalibrationUniv.h +++ b/Calibration/EcalCalibAlgos/interface/ElectronCalibrationUniv.h @@ -24,9 +24,8 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" // Geometry @@ -40,6 +39,9 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" +#include "DataFormats/EgammaCandidates/interface/Electron.h" +#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" +#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" #include "Calibration/Tools/interface/HouseholderDecomposition.h" #include "Calibration/Tools/interface/MinL3Algorithm.h" #include "Calibration/Tools/interface/CalibrationCluster.h" @@ -53,7 +55,7 @@ // class decleration // -class ElectronCalibrationUniv : public edm::EDAnalyzer { +class ElectronCalibrationUniv : public edm::one::EDAnalyzer { public: explicit ElectronCalibrationUniv(const edm::ParameterSet &); ~ElectronCalibrationUniv() override; @@ -61,6 +63,7 @@ class ElectronCalibrationUniv : public edm::EDAnalyzer { void analyze(const edm::Event &, const edm::EventSetup &) override; void beginJob() override; void beginRun(edm::Run const &, edm::EventSetup const &) override; + void endRun(edm::Run const &, edm::EventSetup const &) override; void endJob() override; private: @@ -69,35 +72,32 @@ class ElectronCalibrationUniv : public edm::EDAnalyzer { // ----------member data --------------------------- - std::string rootfile_; - edm::InputTag EBrecHitLabel_; - edm::InputTag EErecHitLabel_; - edm::InputTag electronLabel_; - edm::InputTag trackLabel_; - std::string calibAlgo_; - std::string miscalibfile_; - std::string miscalibfileEndCap_; - int keventweight_; - double ElePt_; - int maxeta_; - int mineta_; - int maxphi_; - int minphi_; - double cut1_; - double cut2_; - double cut3_; - double cutEPCalo1_; - double cutEPCalo2_; - double cutEPin1_; - double cutEPin2_; - double cutCalo1_; - double cutCalo2_; - double cutESeed_; - int ClusterSize_; - int elecclass_; - int theMaxLoops; - - bool FirstIteration; + const edm::InputTag ebRecHitLabel_; + const edm::InputTag eeRecHitLabel_; + const edm::InputTag electronLabel_; + const std::string rootfile_; + const std::string calibAlgo_; + const std::string miscalibfile_; + const std::string miscalibfileEndCap_; + const int keventweight_; + const double elePt_; + const int maxeta_; + const int mineta_; + const int maxphi_; + const int minphi_; + const double cut1_; + const double cut2_; + const double cut3_; + const int numevent_; + const double cutEPCalo1_; + const double cutEPCalo2_; + const double cutEPin1_; + const double cutEPin2_; + const double cutCalo1_; + const double cutCalo2_; + const double cutESeed_; + const int clusterSize_; + const int elecclass_; int read_events; @@ -116,7 +116,11 @@ class ElectronCalibrationUniv : public edm::EDAnalyzer { MinL3Algorithm *MyL3Algo1; MinL3AlgoUniv *UnivL3; - edm::ESHandle theCaloTopology; + const edm::EDGetTokenT ebRecHitToken_; + const edm::EDGetTokenT eeRecHitToken_; + const edm::EDGetTokenT gsfElectronToken_; + const edm::ESGetToken topologyToken_; + const CaloTopology *theCaloTopology_; std::vector solution; std::vector solutionNoCuts; @@ -126,7 +130,6 @@ class ElectronCalibrationUniv : public edm::EDAnalyzer { std::map Univsolution; // int eventcrystal[25][25]; - int numevent_; TFile *f; diff --git a/Calibration/EcalCalibAlgos/interface/InvRingCalib.h b/Calibration/EcalCalibAlgos/interface/InvRingCalib.h index 822ca0c490944..8e0b4623b9980 100644 --- a/Calibration/EcalCalibAlgos/interface/InvRingCalib.h +++ b/Calibration/EcalCalibAlgos/interface/InvRingCalib.h @@ -13,13 +13,17 @@ #include "FWCore/Framework/interface/Event.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/CaloRecHit/interface/CaloRecHit.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" +#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" +#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" #include "FWCore/Framework/interface/EventSetup.h" #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" #include #include -//#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" -#include "DataFormats/CaloRecHit/interface/CaloRecHit.h" #include "Calibration/EcalCalibAlgos/interface/VFillMap.h" @@ -60,37 +64,37 @@ class InvRingCalib : public edm::EDLooper { private: //! EcalBarrel Input Collection name - edm::InputTag m_barrelAlCa; + const edm::InputTag m_barrelAlCa; //! EcalEndcap Input Collection name - edm::InputTag m_endcapAlCa; + const edm::InputTag m_endcapAlCa; //! To take the electrons - edm::InputTag m_ElectronLabel; + const edm::InputTag m_ElectronLabel; //! reconstruction window size - int m_recoWindowSidex; - int m_recoWindowSidey; + const int m_recoWindowSidex; + const int m_recoWindowSidey; //! minimum energy per crystal cut - double m_minEnergyPerCrystal; + const double m_minEnergyPerCrystal; //! maximum energy per crystal cut - double m_maxEnergyPerCrystal; + const double m_maxEnergyPerCrystal; //! eta start of the zone of interest - int m_etaStart; + const int m_etaStart; //! eta end of the zone of interest - int m_etaEnd; + const int m_etaEnd; //! eta size of the regions - int m_etaWidth; + const int m_etaWidth; // std::map m_eta; //! maximum number of events per Ring - int m_maxSelectedNumPerRing; + const int m_maxSelectedNumPerRing; //! number of events already read per Ring std::map m_RingNumOfHits; //! single blocks calibrators std::vector m_IMACalibBlocks; //! minimum coefficient accepted (RAW) - double m_minCoeff; + const double m_minCoeff; //! maximum coefficient accepted (RAW) - double m_maxCoeff; + const double m_maxCoeff; //! to exclude the blocksolver - int m_usingBlockSolver; + const int m_usingBlockSolver; //!position of the cell, borders, coords etc... std::map m_cellPos; std::map m_cellPhi; @@ -101,8 +105,8 @@ class InvRingCalib : public edm::EDLooper { //! LP sets the number of loops to do unsigned int m_loops; //! LP define the EE region to calibrate - int m_startRing; - int m_endRing; + const int m_startRing; + const int m_endRing; //!association map between Raw detIds and Rings std::map m_xtalRing; //!association map between raw detIds and Region @@ -114,14 +118,21 @@ class InvRingCalib : public edm::EDLooper { std::vector m_barrelCells; std::vector m_endcapCells; //!coeffs filenames - std::string m_EBcoeffFile; - std::string m_EEcoeffFile; + const std::string m_EBcoeffFile; + const std::string m_EEcoeffFile; //!endcap zone to be calibrated - int m_EEZone; + const int m_EEZone; //!EB regions vs. eta index std::map m_Reg; std::string m_mapFillerType; bool isfirstcall_; + + //! ED token + const edm::EDGetTokenT m_ebRecHitToken; + const edm::EDGetTokenT m_eeRecHitToken; + const edm::EDGetTokenT m_gsfElectronToken; + //! ES token + const edm::ESGetToken m_geometryToken; }; #endif #endif diff --git a/Calibration/EcalCalibAlgos/interface/PhiSymmetryCalibration.h b/Calibration/EcalCalibAlgos/interface/PhiSymmetryCalibration.h index 00033a1c2e5c9..ec976ea70b01a 100644 --- a/Calibration/EcalCalibAlgos/interface/PhiSymmetryCalibration.h +++ b/Calibration/EcalCalibAlgos/interface/PhiSymmetryCalibration.h @@ -19,19 +19,25 @@ #include "Calibration/EcalCalibAlgos/interface/EcalGeomPhiSymHelper.h" // Framework -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ProducerBase.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" +#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" +#include "CondFormats/EcalObjects/interface/EcalChannelStatus.h" +#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/DetId/interface/DetId.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" class TH1F; -class PhiSymmetryCalibration : public edm::EDAnalyzer { +class PhiSymmetryCalibration + : public edm::one::EDAnalyzer { public: /// Constructor PhiSymmetryCalibration(const edm::ParameterSet& iConfig); @@ -41,7 +47,9 @@ class PhiSymmetryCalibration : public edm::EDAnalyzer { /// Called at beginning of job void beginJob() override; + void beginRun(edm::Run const&, const edm::EventSetup&) override; void endRun(edm::Run const&, const edm::EventSetup&) override; + void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; /// Called at end of job @@ -111,27 +119,32 @@ class PhiSymmetryCalibration : public edm::EDAnalyzer { // steering parameters - std::string ecalHitsProducer_; - std::string barrelHits_; - std::string endcapHits_; + const std::string ecalHitsProducer_; + const std::string barrelHits_; + const std::string endcapHits_; + + const edm::EDGetTokenT ebRecHitToken_; + const edm::EDGetTokenT eeRecHitToken_; + const edm::ESGetToken channelStatusToken_; + const edm::ESGetToken geometryToken_; // energy cut in the barrel - double eCut_barl_; + const double eCut_barl_; // parametrized energy cut EE : e_cut = ap + eta_ring*b - double ap_; - double b_; + const double ap_; + const double b_; - int eventSet_; + const int eventSet_; /// threshold in channel status beyond which channel is marked bad - int statusThreshold_; + const int statusThreshold_; static const int kMaxEndciPhi = 360; float phi_endc[kMaxEndciPhi][kEndcEtaRings]; - bool reiteration_; - std::string oldcalibfile_; //searched for in Calibration/EcalCalibAlgos/data + const bool reiteration_; + const std::string oldcalibfile_; //searched for in Calibration/EcalCalibAlgos/data /// the old calibration constants (when reiterating, the last ones derived) EcalIntercalibConstants oldCalibs_; diff --git a/Calibration/EcalCalibAlgos/interface/Pi0FixedMassWindowCalibration.h b/Calibration/EcalCalibAlgos/interface/Pi0FixedMassWindowCalibration.h index 1d462def498a3..b39ceb82c72e3 100644 --- a/Calibration/EcalCalibAlgos/interface/Pi0FixedMassWindowCalibration.h +++ b/Calibration/EcalCalibAlgos/interface/Pi0FixedMassWindowCalibration.h @@ -11,16 +11,15 @@ // Framework #include "FWCore/Framework/interface/LooperFactory.h" #include "FWCore/Framework/interface/ESProducerLooper.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" +#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/EcalRecHit/interface/EcalRecHit.h" @@ -34,13 +33,10 @@ #include "DataFormats/EcalDetId/interface/ESDetId.h" #include "DataFormats/DetId/interface/DetId.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "RecoEcal/EgammaClusterAlgos/interface/IslandClusterAlgo.h" #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h" #include "RecoEcal/EgammaCoreTools/interface/ClusterShapeAlgo.h" @@ -87,9 +83,9 @@ class Pi0FixedMassWindowCalibration : public edm::ESProducerLooper { int nevent; - unsigned int theMaxLoops; - std::string ecalHitsProducer_; - std::string barrelHits_; + const unsigned int theMaxLoops; + const std::string ecalHitsProducer_; + const std::string barrelHits_; IslandClusterAlgo::VerbosityLevel verbosity; @@ -140,6 +136,10 @@ class Pi0FixedMassWindowCalibration : public edm::ESProducerLooper { const EcalRecHitCollection* ecalRecHitBarrelCollection; const EcalRecHitCollection* recalibEcalRecHitCollection; + const edm::EDGetTokenT recHitToken_; + const edm::ESGetToken intercalibConstantsToken_; + const edm::ESGetToken geometryToken_; + // root tree TFile* theFile; diff --git a/Calibration/EcalCalibAlgos/interface/ZeeCalibration.h b/Calibration/EcalCalibAlgos/interface/ZeeCalibration.h index b10e543e039df..9e78f35854233 100644 --- a/Calibration/EcalCalibAlgos/interface/ZeeCalibration.h +++ b/Calibration/EcalCalibAlgos/interface/ZeeCalibration.h @@ -21,17 +21,16 @@ #include #include #include +#include // user include files #include "FWCore/Framework/interface/LooperFactory.h" #include "FWCore/Framework/interface/ESProducerLooper.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Calibration/Tools/interface/ZIterativeAlgorithmWithFit.h" #include "Calibration/Tools/interface/CalibElectron.h" @@ -42,9 +41,13 @@ #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" +#include "DataFormats/Common/interface/TriggerResults.h" #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/DetId/interface/DetId.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" + #include "TTree.h" #include "TFile.h" #include "TGraph.h" @@ -53,18 +56,12 @@ #include "TH2.h" #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" #include "DataFormats/EgammaCandidates/interface/Electron.h" #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include -#include - // class declaration // @@ -145,23 +142,33 @@ class ZeeCalibration : public edm::ESProducerLooper { std::string outputFileName_; - std::string rechitProducer_; - std::string rechitCollection_; - std::string erechitProducer_; - std::string erechitCollection_; - std::string scProducer_; - std::string scCollection_; + const edm::InputTag hlTriggerResults_; - std::string scIslandProducer_; - std::string scIslandCollection_; + const std::string mcProducer_; + const std::string rechitProducer_; + const std::string rechitCollection_; + const std::string erechitProducer_; + const std::string erechitCollection_; + const std::string scProducer_; + const std::string scCollection_; + + const std::string scIslandProducer_; + const std::string scIslandCollection_; + + const std::string electronProducer_; + const std::string electronCollection_; - std::string mcProducer_; std::string calibMode_; - std::string electronProducer_; - std::string electronCollection_; + const edm::EDGetTokenT trigResultsToken_; + const edm::EDGetTokenT hepMCToken_; + const edm::EDGetTokenT ebRecHitToken_; + const edm::EDGetTokenT eeRecHitToken_; + const edm::EDGetTokenT scToken_; + const edm::EDGetTokenT islandSCToken_; + const edm::EDGetTokenT gsfElectronToken_; - std::string RecalibBarrelHits_; + const edm::ESGetToken geometryToken_; unsigned int etaBins_; unsigned int etBins_; @@ -338,8 +345,6 @@ class ZeeCalibration : public edm::ESProducerLooper { int CRACK_ELECTRONS_IN_BARREL; int CRACK_ELECTRONS_IN_ENDCAP; - edm::InputTag hlTriggerResults_; - unsigned int nEvents_; // number of events processed unsigned int nWasRun_; // # where at least one HLT was run diff --git a/Calibration/EcalCalibAlgos/src/ECALpedestalPCLHarvester.cc b/Calibration/EcalCalibAlgos/src/ECALpedestalPCLHarvester.cc index 1b2d111e3006f..1876ff44fd6ba 100644 --- a/Calibration/EcalCalibAlgos/src/ECALpedestalPCLHarvester.cc +++ b/Calibration/EcalCalibAlgos/src/ECALpedestalPCLHarvester.cc @@ -5,29 +5,29 @@ // user include files #include "Calibration/EcalCalibAlgos/interface/ECALpedestalPCLHarvester.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "CondFormats/EcalObjects/interface/EcalChannelStatus.h" #include "CondFormats/EcalObjects/interface/EcalChannelStatusCode.h" -#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h" -#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" #include "CommonTools/Utils/interface/StringToEnumValue.h" -#include #include ECALpedestalPCLHarvester::ECALpedestalPCLHarvester(const edm::ParameterSet& ps) - : currentPedestals_(nullptr), channelStatus_(nullptr) { + : minEntries_(ps.getParameter("MinEntries")), + checkAnomalies_(ps.getParameter("checkAnomalies")), + nSigma_(ps.getParameter("nSigma")), + thresholdAnomalies_(ps.getParameter("thresholdAnomalies")), + dqmDir_(ps.getParameter("dqmDir")), + labelG6G1_(ps.getParameter("labelG6G1")), + threshDiffEB_(ps.getParameter("threshDiffEB")), + threshDiffEE_(ps.getParameter("threshDiffEE")), + threshChannelsAnalyzed_(ps.getParameter("threshChannelsAnalyzed")), + channelsStatusToken_(esConsumes()), + pedestalsToken_(esConsumes()), + g6g1PedestalsToken_(esConsumes(edm::ESInputTag("", labelG6G1_))), + currentPedestals_(nullptr), + g6g1Pedestals_(nullptr), + channelStatus_(nullptr) { chStatusToExclude_ = StringToEnumValue( ps.getParameter >("ChannelStatusToExclude")); - minEntries_ = ps.getParameter("MinEntries"); - checkAnomalies_ = ps.getParameter("checkAnomalies"); - nSigma_ = ps.getParameter("nSigma"); - thresholdAnomalies_ = ps.getParameter("thresholdAnomalies"); - dqmDir_ = ps.getParameter("dqmDir"); - labelG6G1_ = ps.getParameter("labelG6G1"); - threshDiffEB_ = ps.getParameter("threshDiffEB"); - threshDiffEE_ = ps.getParameter("threshDiffEE"); - threshChannelsAnalyzed_ = ps.getParameter("threshChannelsAnalyzed"); } void ECALpedestalPCLHarvester::dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::IGetter& igetter_) { @@ -155,17 +155,9 @@ void ECALpedestalPCLHarvester::fillDescriptions(edm::ConfigurationDescriptions& } void ECALpedestalPCLHarvester::endRun(edm::Run const& run, edm::EventSetup const& isetup) { - edm::ESHandle chStatus; - isetup.get().get(chStatus); - channelStatus_ = chStatus.product(); - - edm::ESHandle peds; - isetup.get().get(peds); - currentPedestals_ = peds.product(); - - edm::ESHandle g6g1peds; - isetup.get().get(labelG6G1_, g6g1peds); - g6g1Pedestals_ = g6g1peds.product(); + channelStatus_ = &isetup.getData(channelsStatusToken_); + currentPedestals_ = &isetup.getData(pedestalsToken_); + g6g1Pedestals_ = &isetup.getData(g6g1PedestalsToken_); } bool ECALpedestalPCLHarvester::checkStatusCode(const DetId& id) { diff --git a/Calibration/EcalCalibAlgos/src/ECALpedestalPCLworker.cc b/Calibration/EcalCalibAlgos/src/ECALpedestalPCLworker.cc index 90296dc37b65c..e90fcfbbf8427 100644 --- a/Calibration/EcalCalibAlgos/src/ECALpedestalPCLworker.cc +++ b/Calibration/EcalCalibAlgos/src/ECALpedestalPCLworker.cc @@ -2,16 +2,11 @@ #include "Calibration/EcalCalibAlgos/interface/ECALpedestalPCLworker.h" #include "DataFormats/EcalDetId/interface/EBDetId.h" #include "DataFormats/EcalDetId/interface/EEDetId.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "CondFormats/EcalObjects/interface/EcalPedestals.h" -#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h" -#include #include ECALpedestalPCLworker::ECALpedestalPCLworker(const edm::ParameterSet& iConfig) - -{ + : pedestalToken_(esConsumes()) { edm::InputTag digiTagEB = iConfig.getParameter("BarrelDigis"); edm::InputTag digiTagEE = iConfig.getParameter("EndcapDigis"); @@ -106,8 +101,7 @@ void ECALpedestalPCLworker::bookHistograms(DQMStore::IBooker& ibooker, edm::Run ibooker.cd(); ibooker.setCurrentFolder(dqmDir_); - edm::ESHandle peds; - es.get().get(peds); + const auto& peds = es.getData(pedestalToken_); for (uint32_t i = 0; i < EBDetId::kSizeForDenseIndexing; ++i) { ibooker.setCurrentFolder(dqmDir_ + "/EB/" + std::to_string(int(i / 100))); @@ -117,7 +111,7 @@ void ECALpedestalPCLworker::bookHistograms(DQMStore::IBooker& ibooker, edm::Run int centralBin = fixedBookingCenterBin_; if (dynamicBooking_) { - centralBin = int((peds->find(id))->mean_x12); + centralBin = int((peds.find(id))->mean_x12); } int min = centralBin - nBins_ / 2; @@ -135,7 +129,7 @@ void ECALpedestalPCLworker::bookHistograms(DQMStore::IBooker& ibooker, edm::Run int centralBin = fixedBookingCenterBin_; if (dynamicBooking_) { - centralBin = int((peds->find(id))->mean_x12); + centralBin = int((peds.find(id))->mean_x12); } int min = centralBin - nBins_ / 2; diff --git a/Calibration/EcalCalibAlgos/src/EcalEleCalibLooper.cc b/Calibration/EcalCalibAlgos/src/EcalEleCalibLooper.cc index 137c8cd0c5719..f6b3c73d5b09b 100644 --- a/Calibration/EcalCalibAlgos/src/EcalEleCalibLooper.cc +++ b/Calibration/EcalCalibAlgos/src/EcalEleCalibLooper.cc @@ -1,6 +1,5 @@ #include #include -#include #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -9,11 +8,8 @@ #include "Calibration/EcalCalibAlgos/interface/EcalEleCalibLooper.h" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/EgammaReco/interface/ClusterShape.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" -#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" #include "Calibration/Tools/interface/calibXMLwriter.h" #include "CalibCalorimetry/CaloMiscalibTools/interface/CaloMiscalibTools.h" #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h" @@ -33,6 +29,7 @@ EcalEleCalibLooper::EcalEleCalibLooper(const edm::ParameterSet& iConfig) : m_barrelAlCa(iConfig.getParameter("alcaBarrelHitCollection")), m_endcapAlCa(iConfig.getParameter("alcaEndcapHitCollection")), + m_ElectronLabel(iConfig.getParameter("electronLabel")), m_recoWindowSidex(iConfig.getParameter("recoWindowSidex")), m_recoWindowSidey(iConfig.getParameter("recoWindowSidey")), m_etaWidth(iConfig.getParameter("etaWidth")), @@ -54,7 +51,10 @@ EcalEleCalibLooper::EcalEleCalibLooper(const edm::ParameterSet& iConfig) m_maxCoeff(iConfig.getParameter("maxCoeff")), m_usingBlockSolver(iConfig.getParameter("usingBlockSolver")), m_loops(iConfig.getParameter("loops")), - m_ElectronLabel(iConfig.getParameter("electronLabel")) { + m_ebRecHitToken(consumes(m_barrelAlCa)), + m_eeRecHitToken(consumes(m_endcapAlCa)), + m_gsfElectronToken(consumes(m_ElectronLabel)), + m_geometryToken(esConsumes()) { edm::LogInfo("IML") << "[EcalEleCalibLooper][ctor] asserts"; assert(!((m_etaEnd - m_etaStart) % m_etaWidth)); @@ -168,9 +168,7 @@ edm::EDLooper::Status EcalEleCalibLooper::duringLoop(const edm::Event& iEvent, c // with the beginJob without arguments migration if (isfirstcall_) { - edm::ESHandle geoHandle; - iSetup.get().get(geoHandle); - const CaloGeometry& geometry = *geoHandle; + const auto& geometry = iSetup.getData(m_geometryToken); m_barrelCells = geometry.getValidDetIds(DetId::Ecal, EcalBarrel); m_endcapCells = geometry.getValidDetIds(DetId::Ecal, EcalEndcap); for (std::vector::const_iterator barrelIt = m_barrelCells.begin(); barrelIt != m_barrelCells.end(); @@ -190,7 +188,7 @@ edm::EDLooper::Status EcalEleCalibLooper::duringLoop(const edm::Event& iEvent, c //take the collection of recHits in the barrel const EBRecHitCollection* barrelHitsCollection = nullptr; edm::Handle barrelRecHitsHandle; - iEvent.getByLabel(m_barrelAlCa, barrelRecHitsHandle); + iEvent.getByToken(m_ebRecHitToken, barrelRecHitsHandle); barrelHitsCollection = barrelRecHitsHandle.product(); if (!barrelRecHitsHandle.isValid()) { edm::LogError("reading") << "[EcalEleCalibLooper] barrel rec hits not found"; @@ -200,7 +198,7 @@ edm::EDLooper::Status EcalEleCalibLooper::duringLoop(const edm::Event& iEvent, c //take the collection of rechis in the endcap const EERecHitCollection* endcapHitsCollection = nullptr; edm::Handle endcapRecHitsHandle; - iEvent.getByLabel(m_endcapAlCa, endcapRecHitsHandle); + iEvent.getByToken(m_eeRecHitToken, endcapRecHitsHandle); endcapHitsCollection = endcapRecHitsHandle.product(); if (!endcapRecHitsHandle.isValid()) { edm::LogError("reading") << "[EcalEleCalibLooper] endcap rec hits not found"; @@ -209,7 +207,7 @@ edm::EDLooper::Status EcalEleCalibLooper::duringLoop(const edm::Event& iEvent, c //Takes the electron collection of the pixel detector edm::Handle pElectrons; - iEvent.getByLabel(m_ElectronLabel, pElectrons); + iEvent.getByToken(m_gsfElectronToken, pElectrons); if (!pElectrons.isValid()) { edm::LogError("reading") << "[EcalEleCalibLooper] electrons not found"; return kContinue; diff --git a/Calibration/EcalCalibAlgos/src/ElectronCalibrationUniv.cc b/Calibration/EcalCalibAlgos/src/ElectronCalibrationUniv.cc index fe6aefb4eba96..4b49ad3749602 100644 --- a/Calibration/EcalCalibAlgos/src/ElectronCalibrationUniv.cc +++ b/Calibration/EcalCalibAlgos/src/ElectronCalibrationUniv.cc @@ -1,25 +1,14 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/EcalDetId/interface/EBDetId.h" #include "DataFormats/DetId/interface/DetId.h" -#include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" -#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" #include "Calibration/Tools/interface/calibXMLwriter.h" #include "Calibration/Tools/interface/CalibrationCluster.h" #include "Calibration/Tools/interface/HouseholderDecomposition.h" #include "Calibration/Tools/interface/MinL3Algorithm.h" #include "Calibration/EcalCalibAlgos/interface/ElectronCalibrationUniv.h" -#include "DataFormats/EgammaCandidates/interface/Electron.h" -#include "DataFormats/EgammaReco/interface/SuperCluster.h" -#include "DataFormats/TrackReco/interface/Track.h" -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "DataFormats/TrackReco/interface/TrackExtraFwd.h" #include "FWCore/Utilities/interface/isFinite.h" -#include "TFile.h" -#include "TH1.h" -#include "TH2.h" #include "TF1.h" #include "TRandom.h" @@ -28,40 +17,37 @@ #include #include -#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" -#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" - -ElectronCalibrationUniv::ElectronCalibrationUniv(const edm::ParameterSet& iConfig) { - rootfile_ = iConfig.getParameter("rootfile"); - EBrecHitLabel_ = iConfig.getParameter("ebRecHitsLabel"); - EErecHitLabel_ = iConfig.getParameter("eeRecHitsLabel"); - electronLabel_ = iConfig.getParameter("electronLabel"); - trackLabel_ = iConfig.getParameter("trackLabel"); - calibAlgo_ = iConfig.getParameter("CALIBRATION_ALGO"); - keventweight_ = iConfig.getParameter("keventweight"); - ClusterSize_ = iConfig.getParameter("Clustersize"); - ElePt_ = iConfig.getParameter("ElePt"); - maxeta_ = iConfig.getParameter("maxeta"); - mineta_ = iConfig.getParameter("mineta"); - maxphi_ = iConfig.getParameter("maxphi"); - minphi_ = iConfig.getParameter("minphi"); - cut1_ = iConfig.getParameter("cut1"); - cut2_ = iConfig.getParameter("cut2"); - cut3_ = iConfig.getParameter("cut3"); - elecclass_ = iConfig.getParameter("elecclass"); - numevent_ = iConfig.getParameter("numevent"); - miscalibfile_ = iConfig.getParameter("miscalibfile"); - miscalibfileEndCap_ = iConfig.getParameter("miscalibfileEndCap"); - - cutEPCalo1_ = iConfig.getParameter("cutEPCaloMin"); - cutEPCalo2_ = iConfig.getParameter("cutEPCaloMax"); - cutEPin1_ = iConfig.getParameter("cutEPinMin"); - cutEPin2_ = iConfig.getParameter("cutEPinMax"); - cutCalo1_ = iConfig.getParameter("cutCaloMin"); - cutCalo2_ = iConfig.getParameter("cutCaloMax"); - - cutESeed_ = iConfig.getParameter("cutESeed"); -} +ElectronCalibrationUniv::ElectronCalibrationUniv(const edm::ParameterSet& iConfig) + : ebRecHitLabel_(iConfig.getParameter("ebRecHitsLabel")), + eeRecHitLabel_(iConfig.getParameter("eeRecHitsLabel")), + electronLabel_(iConfig.getParameter("electronLabel")), + rootfile_(iConfig.getParameter("rootfile")), + calibAlgo_(iConfig.getParameter("CALIBRATION_ALGO")), + miscalibfile_(iConfig.getParameter("miscalibfile")), + miscalibfileEndCap_(iConfig.getParameter("miscalibfileEndCap")), + keventweight_(iConfig.getParameter("keventweight")), + elePt_(iConfig.getParameter("ElePt")), + maxeta_(iConfig.getParameter("maxeta")), + mineta_(iConfig.getParameter("mineta")), + maxphi_(iConfig.getParameter("maxphi")), + minphi_(iConfig.getParameter("minphi")), + cut1_(iConfig.getParameter("cut1")), + cut2_(iConfig.getParameter("cut2")), + cut3_(iConfig.getParameter("cut3")), + numevent_(iConfig.getParameter("numevent")), + cutEPCalo1_(iConfig.getParameter("cutEPCaloMin")), + cutEPCalo2_(iConfig.getParameter("cutEPCaloMax")), + cutEPin1_(iConfig.getParameter("cutEPinMin")), + cutEPin2_(iConfig.getParameter("cutEPinMax")), + cutCalo1_(iConfig.getParameter("cutCaloMin")), + cutCalo2_(iConfig.getParameter("cutCaloMax")), + cutESeed_(iConfig.getParameter("cutESeed")), + clusterSize_(iConfig.getParameter("Clustersize")), + elecclass_(iConfig.getParameter("elecclass")), + ebRecHitToken_(consumes(ebRecHitLabel_)), + eeRecHitToken_(consumes(eeRecHitLabel_)), + gsfElectronToken_(consumes(electronLabel_)), + topologyToken_(esConsumes()) {} ElectronCalibrationUniv::~ElectronCalibrationUniv() {} @@ -223,7 +209,7 @@ void ElectronCalibrationUniv::beginJob() { GeneralMapEndCapPlusBeforePt = new TH2F("GeneralMapEndCapPlusBeforePt", "Map without any cuts", 100, 0, 100, 100, 0, 100); - calibClusterSize = ClusterSize_; + calibClusterSize = clusterSize_; etaMin = int(mineta_); etaMax = int(maxeta_); phiMin = int(minphi_); @@ -250,9 +236,13 @@ void ElectronCalibrationUniv::beginRun(edm::Run const&, edm::EventSetup const& i //======================================================================== //To Deal with Geometry: - iSetup.get().get(theCaloTopology); + theCaloTopology_ = &iSetup.getData(topologyToken_); } +//======================================================================== +void ElectronCalibrationUniv::endRun(edm::Run const&, edm::EventSetup const& iSetup) {} +//======================================================================== + //======================================================================== void ElectronCalibrationUniv::endJob() { @@ -622,7 +612,7 @@ void ElectronCalibrationUniv::analyze(const edm::Event& iEvent, const edm::Event // Get EBRecHits edm::Handle EBphits; - iEvent.getByLabel(EBrecHitLabel_, EBphits); + iEvent.getByToken(ebRecHitToken_, EBphits); if (!EBphits.isValid()) { std::cerr << "Error! can't get the product EBRecHitCollection: " << std::endl; } @@ -631,7 +621,7 @@ void ElectronCalibrationUniv::analyze(const edm::Event& iEvent, const edm::Event // Get EERecHits edm::Handle EEphits; - iEvent.getByLabel(EErecHitLabel_, EEphits); + iEvent.getByToken(eeRecHitToken_, EEphits); if (!EEphits.isValid()) { std::cerr << "Error! can't get the product EERecHitCollection: " << std::endl; } @@ -639,7 +629,7 @@ void ElectronCalibrationUniv::analyze(const edm::Event& iEvent, const edm::Event // Get pixelElectrons edm::Handle pElectrons; - iEvent.getByLabel(electronLabel_, pElectrons); + iEvent.getByToken(gsfElectronToken_, pElectrons); if (!pElectrons.isValid()) { std::cerr << "Error! can't get the product ElectronCollection: " << std::endl; } @@ -737,9 +727,9 @@ void ElectronCalibrationUniv::analyze(const edm::Event& iEvent, const edm::Event float energy3x3 = 0.; float energy5x5 = 0.; //Should be moved to cfg file! - int ClusterSize = ClusterSize_; + int ClusterSize = clusterSize_; - const CaloSubdetectorTopology* topology = theCaloTopology->getSubdetectorTopology(DetId::Ecal, maxHitId.subdetId()); + const CaloSubdetectorTopology* topology = theCaloTopology_->getSubdetectorTopology(DetId::Ecal, maxHitId.subdetId()); std::vector NxNaroundMax = topology->getWindow(maxHitId, ClusterSize, ClusterSize); //ToCompute 3x3 std::vector S9aroundMax = topology->getWindow(maxHitId, 3, 3); @@ -822,7 +812,7 @@ void ElectronCalibrationUniv::analyze(const edm::Event& iEvent, const edm::Event } EventsAfterCuts->Fill(11); - if (highestElePt < ElePt_) + if (highestElePt < elePt_) return; if (maxHitId.subdetId() == EcalBarrel) { diff --git a/Calibration/EcalCalibAlgos/src/InvRingCalib.cc b/Calibration/EcalCalibAlgos/src/InvRingCalib.cc index 0d0f78d9ae3bd..e476a262457af 100644 --- a/Calibration/EcalCalibAlgos/src/InvRingCalib.cc +++ b/Calibration/EcalCalibAlgos/src/InvRingCalib.cc @@ -1,8 +1,6 @@ #include #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Calibration/EcalCalibAlgos/interface/InvRingCalib.h" @@ -12,7 +10,6 @@ #include "Calibration/Tools/interface/calibXMLwriter.h" #include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalBarrel.h" #include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalEndcap.h" -#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" #include "DataFormats/EgammaReco/interface/SuperCluster.h" #include "DataFormats/EgammaReco/interface/BasicCluster.h" #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h" @@ -23,7 +20,6 @@ //Not to remain in the final version #include "TH2.h" #include "TFile.h" -#include //---------------------------------------------------------------- //ctor @@ -46,7 +42,11 @@ InvRingCalib::InvRingCalib(const edm::ParameterSet& iConfig) m_endRing(iConfig.getParameter("endRing")), m_EBcoeffFile(iConfig.getParameter("EBcoeffs")), m_EEcoeffFile(iConfig.getParameter("EEcoeffs")), - m_EEZone(iConfig.getParameter("EEZone")) { + m_EEZone(iConfig.getParameter("EEZone")), + m_ebRecHitToken(consumes(m_barrelAlCa)), + m_eeRecHitToken(consumes(m_endcapAlCa)), + m_gsfElectronToken(consumes(m_ElectronLabel)), + m_geometryToken(esConsumes()) { //controls if the parameters inputed are correct if ((m_etaEnd * m_etaStart) > 0) assert(!((m_etaEnd - m_etaStart) % m_etaWidth)); @@ -130,13 +130,11 @@ edm::EDLooper::Status InvRingCalib::duringLoop(const edm::Event& iEvent, const e if (isfirstcall_) { edm::LogInfo("IML") << "[InvRingCalib][beginOfJob]"; //gets the geometry from the event setup - edm::ESHandle geoHandle; - iSetup.get().get(geoHandle); - const CaloGeometry* geometry = geoHandle.product(); + const auto& geometry = iSetup.getData(m_geometryToken); edm::LogInfo("IML") << "[InvRingCalib] Event Setup read"; //fills a vector with all the cells - m_barrelCells = geometry->getValidDetIds(DetId::Ecal, EcalBarrel); - m_endcapCells = geometry->getValidDetIds(DetId::Ecal, EcalEndcap); + m_barrelCells = geometry.getValidDetIds(DetId::Ecal, EcalBarrel); + m_endcapCells = geometry.getValidDetIds(DetId::Ecal, EcalEndcap); //Defines the EB regions edm::LogInfo("IML") << "[InvRingCalib] Defining Barrel Regions"; EBRegionDef(); @@ -234,17 +232,18 @@ edm::EDLooper::Status InvRingCalib::duringLoop(const edm::Event& iEvent, const e double pTk = 0.; const EcalRecHitCollection* barrelHitsCollection = nullptr; edm::Handle barrelRecHitsHandle; - iEvent.getByLabel(m_barrelAlCa, barrelRecHitsHandle); + iEvent.getByToken(m_ebRecHitToken, barrelRecHitsHandle); barrelHitsCollection = barrelRecHitsHandle.product(); if (!barrelRecHitsHandle.isValid()) { edm::LogError("IML") << "[EcalEleCalibLooper] barrel rec hits not found"; return kContinue; } + //gets the endcap recHits const EcalRecHitCollection* endcapHitsCollection = nullptr; edm::Handle endcapRecHitsHandle; - iEvent.getByLabel(m_endcapAlCa, endcapRecHitsHandle); + iEvent.getByToken(m_eeRecHitToken, endcapRecHitsHandle); endcapHitsCollection = endcapRecHitsHandle.product(); if (!endcapRecHitsHandle.isValid()) { @@ -254,7 +253,7 @@ edm::EDLooper::Status InvRingCalib::duringLoop(const edm::Event& iEvent, const e //gets the electrons edm::Handle pElectrons; - iEvent.getByLabel(m_ElectronLabel, pElectrons); + iEvent.getByToken(m_gsfElectronToken, pElectrons); if (!pElectrons.isValid()) { edm::LogError("IML") << "[EcalEleCalibLooper] electrons not found"; @@ -382,13 +381,9 @@ void InvRingCalib::endOfJob() { //!EE ring definition void InvRingCalib::EERingDef(const edm::EventSetup& iSetup) { - //Gets the Handle for the geometry from the eventSetup - edm::ESHandle geoHandle; - iSetup.get().get(geoHandle); //Gets the geometry of the endcap - const CaloGeometry* geometry = geoHandle.product(); - const CaloSubdetectorGeometry* endcapGeometry = geometry->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); - // const CaloSubdetectorGeometry *barrelGeometry = geometry->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + const auto& geometry = iSetup.getData(m_geometryToken); + const CaloSubdetectorGeometry* endcapGeometry = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap); //for every xtal gets the position Vector and the phi position // for (std::vector::const_iterator barrelIt = m_barrelCells.begin(); diff --git a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration.cc b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration.cc index d0f5d8f8e449a..65aef4d2e594c 100644 --- a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration.cc +++ b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration.cc @@ -5,26 +5,19 @@ // Framework #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/EcalDetId/interface/EBDetId.h" #include "DataFormats/EcalDetId/interface/EEDetId.h" -#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" #include "CondFormats/EcalObjects/interface/EcalIntercalibErrors.h" #include "CondTools/Ecal/interface/EcalIntercalibConstantsXMLTranslator.h" #include "FWCore/Framework/interface/LuminosityBlock.h" // Geometry -#include "Geometry/Records/interface/CaloGeometryRecord.h" #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" //Channel status -#include "CondFormats/EcalObjects/interface/EcalChannelStatus.h" -#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" #include "CondFormats/EcalObjects/interface/EcalChannelStatusCode.h" #include "FWCore/Framework/interface/Run.h" @@ -47,11 +40,13 @@ const float PhiSymmetryCalibration::kMiscalRangeEE = .10; // Class constructor PhiSymmetryCalibration::PhiSymmetryCalibration(const edm::ParameterSet& iConfig) - : - - ecalHitsProducer_(iConfig.getParameter("ecalRecHitsProducer")), + : ecalHitsProducer_(iConfig.getParameter("ecalRecHitsProducer")), barrelHits_(iConfig.getParameter("barrelHitCollection")), endcapHits_(iConfig.getParameter("endcapHitCollection")), + ebRecHitToken_(consumes(edm::InputTag(ecalHitsProducer_, barrelHits_))), + eeRecHitToken_(consumes(edm::InputTag(ecalHitsProducer_, endcapHits_))), + channelStatusToken_(esConsumes()), + geometryToken_(esConsumes()), eCut_barl_(iConfig.getParameter("eCut_barrel")), ap_(iConfig.getParameter("ap")), b_(iConfig.getParameter("b")), @@ -71,6 +66,9 @@ PhiSymmetryCalibration::PhiSymmetryCalibration(const edm::ParameterSet& iConfig) nevents_ = 0; eventsinrun_ = 0; eventsinlb_ = 0; + + // because ROOT draws something + usesResource(); } //_____________________________________________________________________________ @@ -239,21 +237,20 @@ void PhiSymmetryCalibration::analyze(const edm::Event& event, const edm::EventSe Handle barrelRecHitsHandle; Handle endcapRecHitsHandle; - event.getByLabel(ecalHitsProducer_, barrelHits_, barrelRecHitsHandle); + event.getByToken(ebRecHitToken_, barrelRecHitsHandle); if (!barrelRecHitsHandle.isValid()) { LogError("") << "[PhiSymmetryCalibration] Error! Can't get product!" << std::endl; } - event.getByLabel(ecalHitsProducer_, endcapHits_, endcapRecHitsHandle); + event.getByToken(ebRecHitToken_, endcapRecHitsHandle); if (!endcapRecHitsHandle.isValid()) { LogError("") << "[PhiSymmetryCalibration] Error! Can't get product!" << std::endl; } // get the ecal geometry - edm::ESHandle geoHandle; - setup.get().get(geoHandle); - const CaloSubdetectorGeometry* barrelGeometry = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); - const CaloSubdetectorGeometry* endcapGeometry = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); + const auto& geometry = setup.getData(geometryToken_); + const auto* barrelGeometry = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + const auto* endcapGeometry = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap); bool pass = false; // select interesting EcalRecHits (barrel) @@ -377,6 +374,8 @@ void PhiSymmetryCalibration::analyze(const edm::Event& event, const edm::EventSe } } +void PhiSymmetryCalibration::beginRun(edm::Run const&, const edm::EventSetup&) {} + void PhiSymmetryCalibration::endRun(edm::Run const& run, const edm::EventSetup&) { std::cout << "PHIREPRT : run " << run.run() << " start " << (run.beginTime().value() >> 32) << " end " << (run.endTime().value() >> 32) << " dur " @@ -478,13 +477,11 @@ void PhiSymmetryCalibration::getKfactors() { //_____________________________________________________________________________ void PhiSymmetryCalibration::setUp(const edm::EventSetup& setup) { - edm::ESHandle chStatus; - setup.get().get(chStatus); + const auto& chStatus = setup.getData(channelStatusToken_); - edm::ESHandle geoHandle; - setup.get().get(geoHandle); + const auto& geometry = setup.getData(geometryToken_); - e_.setup(&(*geoHandle), &(*chStatus), statusThreshold_); + e_.setup(&geometry, &chStatus, statusThreshold_); if (reiteration_) { EcalCondHeader h; @@ -498,16 +495,11 @@ void PhiSymmetryCalibration::setUp(const edm::EventSetup& setup) { int ret = EcalIntercalibConstantsXMLTranslator::readXML(fip.fullPath(), h, oldCalibs_); if (ret) edm::LogError("PhiSym") << "Error reading XML files" << endl; - ; - - } else { - // in fact if not reiterating, oldCalibs_ will never be used - edm::ESHandle pIcal; - setup.get().get(pIcal); - oldCalibs_ = *pIcal; } } +void PhiSymmetryCalibration::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {} + void PhiSymmetryCalibration::endLuminosityBlock(edm::LuminosityBlock const& lb, edm::EventSetup const&) { if ((lb.endTime().value() >> 32) - (lb.beginTime().value() >> 32) < 60) return; diff --git a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2.cc b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2.cc index b0a3b2cbb9883..525c8a40c77ea 100644 --- a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2.cc +++ b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2.cc @@ -4,9 +4,6 @@ #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" #include "CondTools/Ecal/interface/EcalIntercalibConstantsXMLTranslator.h" #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" -#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "TH2F.h" @@ -20,14 +17,15 @@ using namespace std; PhiSymmetryCalibration_step2::~PhiSymmetryCalibration_step2() {} -PhiSymmetryCalibration_step2::PhiSymmetryCalibration_step2(const edm::ParameterSet& iConfig) { - statusThreshold_ = iConfig.getUntrackedParameter("statusThreshold", 0); - have_initial_miscalib_ = iConfig.getUntrackedParameter("haveInitialMiscalib", false); - initialmiscalibfile_ = iConfig.getUntrackedParameter("initialmiscalibfile", "InitialMiscalib.xml"); - oldcalibfile_ = iConfig.getUntrackedParameter("oldcalibfile", "EcalIntercalibConstants.xml"); - reiteration_ = iConfig.getUntrackedParameter("reiteration", false); - firstpass_ = true; -} +PhiSymmetryCalibration_step2::PhiSymmetryCalibration_step2(const edm::ParameterSet& iConfig) + : channelStatusToken_(esConsumes()), + geometryToken_(esConsumes()), + firstpass_(true), + statusThreshold_(iConfig.getUntrackedParameter("statusThreshold", 0)), + reiteration_(iConfig.getUntrackedParameter("reiteration", false)), + oldcalibfile_(iConfig.getUntrackedParameter("oldcalibfile", "EcalIntercalibConstants.xml")), + have_initial_miscalib_(iConfig.getUntrackedParameter("haveInitialMiscalib", false)), + initialmiscalibfile_(iConfig.getUntrackedParameter("initialmiscalibfile", "InitialMiscalib.xml")) {} void PhiSymmetryCalibration_step2::analyze(const edm::Event& ev, const edm::EventSetup& se) { if (firstpass_) { @@ -37,16 +35,14 @@ void PhiSymmetryCalibration_step2::analyze(const edm::Event& ev, const edm::Even } void PhiSymmetryCalibration_step2::setUp(const edm::EventSetup& se) { - edm::ESHandle chStatus; - se.get().get(chStatus); + const auto& chStatus = se.getData(channelStatusToken_); - edm::ESHandle geoHandle; - se.get().get(geoHandle); + const auto& geometry = se.getData(geometryToken_); - barrelCells = geoHandle->getValidDetIds(DetId::Ecal, EcalBarrel); - endcapCells = geoHandle->getValidDetIds(DetId::Ecal, EcalEndcap); + barrelCells = geometry.getValidDetIds(DetId::Ecal, EcalBarrel); + endcapCells = geometry.getValidDetIds(DetId::Ecal, EcalEndcap); - e_.setup(&(*geoHandle), &(*chStatus), statusThreshold_); + e_.setup(&geometry, &chStatus, statusThreshold_); /// if a miscalibration was applied, load it, if not put it to 1 if (have_initial_miscalib_) { diff --git a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2.h b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2.h index 99bb7044b2611..bc6de209ed439 100644 --- a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2.h +++ b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2.h @@ -1,15 +1,20 @@ +#ifndef Calibration_EcalCalibAlgos_PhiSymmetryCalibration_step2_h +#define Calibration_EcalCalibAlgos_PhiSymmetryCalibration_step2_h + #include "Calibration/EcalCalibAlgos/interface/EcalGeomPhiSymHelper.h" +#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ProducerBase.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" class TH1F; class TH2F; -class PhiSymmetryCalibration_step2 : public edm::EDAnalyzer { +class PhiSymmetryCalibration_step2 : public edm::one::EDAnalyzer<> { public: PhiSymmetryCalibration_step2(const edm::ParameterSet& iConfig); ~PhiSymmetryCalibration_step2() override; @@ -29,6 +34,9 @@ class PhiSymmetryCalibration_step2 : public edm::EDAnalyzer { void readEtSums(); private: + const edm::ESGetToken channelStatusToken_; + const edm::ESGetToken geometryToken_; + // Transverse energy sum arrays double etsum_barl_[kBarlRings][kBarlWedges][kSides]; double etsum_endc_[kEndcWedgesX][kEndcWedgesX][kSides]; @@ -62,10 +70,10 @@ class PhiSymmetryCalibration_step2 : public edm::EDAnalyzer { std::vector endcapCells; bool firstpass_; - int statusThreshold_; + const int statusThreshold_; - bool reiteration_; - std::string oldcalibfile_; + const bool reiteration_; + const std::string oldcalibfile_; /// the old calibration constants (when reiterating, the last ones derived) EcalIntercalibConstants oldCalibs_; @@ -77,8 +85,8 @@ class PhiSymmetryCalibration_step2 : public edm::EDAnalyzer { EcalIntercalibConstants miscalib_; /// - bool have_initial_miscalib_; - std::string initialmiscalibfile_; + const bool have_initial_miscalib_; + const std::string initialmiscalibfile_; /// res miscalib histos std::vector miscal_resid_barl_histos; @@ -87,3 +95,4 @@ class PhiSymmetryCalibration_step2 : public edm::EDAnalyzer { std::vector miscal_resid_endc_histos; std::vector correl_endc_histos; }; +#endif diff --git a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2_SM.cc b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2_SM.cc index 26920ad29267f..412de801b7bf1 100644 --- a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2_SM.cc +++ b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2_SM.cc @@ -4,9 +4,6 @@ #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" #include "CondTools/Ecal/interface/EcalIntercalibConstantsXMLTranslator.h" #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" -#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "TH2F.h" @@ -20,14 +17,15 @@ using namespace std; PhiSymmetryCalibration_step2_SM::~PhiSymmetryCalibration_step2_SM() {} -PhiSymmetryCalibration_step2_SM::PhiSymmetryCalibration_step2_SM(const edm::ParameterSet& iConfig) { - statusThreshold_ = iConfig.getUntrackedParameter("statusThreshold", 0); - have_initial_miscalib_ = iConfig.getUntrackedParameter("haveInitialMiscalib", false); - initialmiscalibfile_ = iConfig.getUntrackedParameter("initialmiscalibfile", "InitialMiscalib.xml"); - oldcalibfile_ = iConfig.getUntrackedParameter("oldcalibfile", "EcalIntercalibConstants.xml"); - reiteration_ = iConfig.getUntrackedParameter("reiteration", false); - firstpass_ = true; -} +PhiSymmetryCalibration_step2_SM::PhiSymmetryCalibration_step2_SM(const edm::ParameterSet& iConfig) + : channelStatusToken_(esConsumes()), + geometryToken_(esConsumes()), + firstpass_(true), + statusThreshold_(iConfig.getUntrackedParameter("statusThreshold", 0)), + reiteration_(iConfig.getUntrackedParameter("reiteration", false)), + oldcalibfile_(iConfig.getUntrackedParameter("oldcalibfile", "EcalIntercalibConstants.xml")), + have_initial_miscalib_(iConfig.getUntrackedParameter("haveInitialMiscalib", false)), + initialmiscalibfile_(iConfig.getUntrackedParameter("initialmiscalibfile", "InitialMiscalib.xml")) {} void PhiSymmetryCalibration_step2_SM::analyze(const edm::Event& ev, const edm::EventSetup& se) { if (firstpass_) { @@ -37,16 +35,14 @@ void PhiSymmetryCalibration_step2_SM::analyze(const edm::Event& ev, const edm::E } void PhiSymmetryCalibration_step2_SM::setUp(const edm::EventSetup& se) { - edm::ESHandle chStatus; - se.get().get(chStatus); + const auto& chStatus = se.getData(channelStatusToken_); - edm::ESHandle geoHandle; - se.get().get(geoHandle); + const auto& geometry = se.getData(geometryToken_); - barrelCells = geoHandle->getValidDetIds(DetId::Ecal, EcalBarrel); - endcapCells = geoHandle->getValidDetIds(DetId::Ecal, EcalEndcap); + barrelCells = geometry.getValidDetIds(DetId::Ecal, EcalBarrel); + endcapCells = geometry.getValidDetIds(DetId::Ecal, EcalEndcap); - e_.setup(&(*geoHandle), &(*chStatus), statusThreshold_); + e_.setup(&geometry, &chStatus, statusThreshold_); for (int sign = 0; sign < kSides; sign++) { for (int ieta = 0; ieta < kBarlRings; ieta++) { diff --git a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2_SM.h b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2_SM.h index 9e6fb71e8d9ea..a042821b6c560 100644 --- a/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2_SM.h +++ b/Calibration/EcalCalibAlgos/src/PhiSymmetryCalibration_step2_SM.h @@ -1,15 +1,20 @@ +#ifndef Calibration_EcalCalibAlgos_PhiSymmetryCalibration_step2_SM_h +#define Calibration_EcalCalibAlgos_PhiSymmetryCalibration_step2_SM_h + #include "Calibration/EcalCalibAlgos/interface/EcalGeomPhiSymHelper.h" +#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ProducerBase.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" class TH1F; class TH2F; -class PhiSymmetryCalibration_step2_SM : public edm::EDAnalyzer { +class PhiSymmetryCalibration_step2_SM : public edm::one::EDAnalyzer<> { public: PhiSymmetryCalibration_step2_SM(const edm::ParameterSet& iConfig); ~PhiSymmetryCalibration_step2_SM() override; @@ -29,6 +34,9 @@ class PhiSymmetryCalibration_step2_SM : public edm::EDAnalyzer { void readEtSums(); private: + const edm::ESGetToken channelStatusToken_; + const edm::ESGetToken geometryToken_; + // Transverse energy sum arrays double etsum_barl_[kBarlRings][kBarlWedges][kSides]; @@ -71,10 +79,10 @@ class PhiSymmetryCalibration_step2_SM : public edm::EDAnalyzer { std::vector endcapCells; bool firstpass_; - int statusThreshold_; + const int statusThreshold_; - bool reiteration_; - std::string oldcalibfile_; + const bool reiteration_; + const std::string oldcalibfile_; /// the old calibration constants (when reiterating, the last ones derived) EcalIntercalibConstants oldCalibs_; @@ -86,8 +94,8 @@ class PhiSymmetryCalibration_step2_SM : public edm::EDAnalyzer { EcalIntercalibConstants miscalib_; /// - bool have_initial_miscalib_; - std::string initialmiscalibfile_; + const bool have_initial_miscalib_; + const std::string initialmiscalibfile_; /// res miscalib histos std::vector miscal_resid_barl_histos; @@ -96,3 +104,4 @@ class PhiSymmetryCalibration_step2_SM : public edm::EDAnalyzer { std::vector miscal_resid_endc_histos; std::vector correl_endc_histos; }; +#endif diff --git a/Calibration/EcalCalibAlgos/src/Pi0FixedMassWindowCalibration.cc b/Calibration/EcalCalibAlgos/src/Pi0FixedMassWindowCalibration.cc index 3a7c38e93878c..dc0f53472473e 100644 --- a/Calibration/EcalCalibAlgos/src/Pi0FixedMassWindowCalibration.cc +++ b/Calibration/EcalCalibAlgos/src/Pi0FixedMassWindowCalibration.cc @@ -6,17 +6,14 @@ // Conditions database -#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" #include "Calibration/Tools/interface/Pi0CalibXMLwriter.h" // Reconstruction Classes #include "DataFormats/EgammaReco/interface/BasicCluster.h" #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h" // Geometry -#include "Geometry/Records/interface/CaloGeometryRecord.h" #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/CaloTopology/interface/EcalEndcapTopology.h" #include "Geometry/CaloTopology/interface/EcalBarrelTopology.h" @@ -35,7 +32,10 @@ using namespace std; Pi0FixedMassWindowCalibration::Pi0FixedMassWindowCalibration(const edm::ParameterSet& iConfig) : theMaxLoops(iConfig.getUntrackedParameter("maxLoops", 0)), ecalHitsProducer_(iConfig.getParameter("ecalRecHitsProducer")), - barrelHits_(iConfig.getParameter("barrelHitCollection")) { + barrelHits_(iConfig.getParameter("barrelHitCollection")), + recHitToken_(consumes(edm::InputTag(ecalHitsProducer_, barrelHits_))), + intercalibConstantsToken_(esConsumes()), + geometryToken_(esConsumes()) { std::cout << "[Pi0FixedMassWindowCalibration] Constructor " << std::endl; // The verbosity level std::string verbosityString = iConfig.getParameter("VerbosityLevel"); @@ -272,6 +272,9 @@ edm::EDLooper::Status Pi0FixedMassWindowCalibration::duringLoop(const edm::Event // this chunk used to belong to beginJob(isetup). Moved here // with the beginJob without arguments migration + // get the ecal geometry: + const auto& geometry = setup.getData(geometryToken_); + if (isfirstcall_) { // initialize arrays @@ -288,23 +291,9 @@ edm::EDLooper::Status Pi0FixedMassWindowCalibration::duringLoop(const edm::Event // get initial constants out of DB - edm::ESHandle pIcal; - EcalIntercalibConstantMap imap; - - try { - setup.get().get(pIcal); - std::cout << "Taken EcalIntercalibConstants" << std::endl; - imap = pIcal.product()->getMap(); - std::cout << "imap.size() = " << imap.size() << std::endl; - } catch (std::exception& ex) { - std::cerr << "Error! can't get EcalIntercalibConstants " << std::endl; - } - - // get the ecal geometry: - edm::ESHandle geoHandle; - setup.get().get(geoHandle); - const CaloGeometry& geometry = *geoHandle; - //const CaloSubdetectorGeometry *barrelGeometry = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + const auto& pIcal = setup.getData(intercalibConstantsToken_); + const auto& imap = pIcal.getMap(); + std::cout << "imap.size() = " << imap.size() << std::endl; // loop over all barrel crystals barrelCells = geometry.getValidDetIds(DetId::Ecal, EcalBarrel); @@ -340,7 +329,7 @@ edm::EDLooper::Status Pi0FixedMassWindowCalibration::duringLoop(const edm::Event int nRecHitsEB = 0; Handle pEcalRecHitBarrelCollection; - event.getByLabel(ecalHitsProducer_, barrelHits_, pEcalRecHitBarrelCollection); + event.getByToken(recHitToken_, pEcalRecHitBarrelCollection); const EcalRecHitCollection* ecalRecHitBarrelCollection = pEcalRecHitBarrelCollection.product(); cout << " ECAL Barrel RecHits # " << ecalRecHitBarrelCollection->size() << endl; for (EcalRecHitCollection::const_iterator aRecHitEB = ecalRecHitBarrelCollection->begin(); @@ -380,18 +369,14 @@ edm::EDLooper::Status Pi0FixedMassWindowCalibration::duringLoop(const edm::Event irecalib++; } - // get the geometry and topology from the event setup: - edm::ESHandle geoHandle; - setup.get().get(geoHandle); - const CaloSubdetectorGeometry* geometry_p; std::string clustershapetag; - geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); - EcalBarrelTopology topology{*geoHandle}; + geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + EcalBarrelTopology topology{geometry}; const CaloSubdetectorGeometry* geometryES_p; - geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower); + geometryES_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower); /* reco::BasicClusterCollection clusters; diff --git a/Calibration/EcalCalibAlgos/src/ZeeCalibration.cc b/Calibration/EcalCalibAlgos/src/ZeeCalibration.cc index 7d483783b7514..316830af6c303 100644 --- a/Calibration/EcalCalibAlgos/src/ZeeCalibration.cc +++ b/Calibration/EcalCalibAlgos/src/ZeeCalibration.cc @@ -1,22 +1,12 @@ #include #include -#include -#include -#include #include -#include #include #include #include -#include -#include -#include -#include -#include #include #include -#include #include @@ -35,36 +25,39 @@ #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h" #include "DataFormats/CaloRecHit/interface/CaloRecHit.h" #include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/Common/interface/TriggerResults.h" -#include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/EcalDetId/interface/EBDetId.h" #include "DataFormats/EcalDetId/interface/EEDetId.h" -#include "DataFormats/EcalRecHit/interface/EcalRecHit.h" -#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" -#include "DataFormats/EgammaCandidates/interface/Electron.h" -#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" -#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" #include "DataFormats/EgammaReco/interface/BasicCluster.h" #include "DataFormats/EgammaReco/interface/SuperCluster.h" -#include "DataFormats/TrackReco/interface/Track.h" -#include "DataFormats/TrackReco/interface/TrackExtraFwd.h" -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/TriggerNamesService.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" #define MZ 91.1876 #define DEBUG 1 -ZeeCalibration::ZeeCalibration(const edm::ParameterSet& iConfig) { +ZeeCalibration::ZeeCalibration(const edm::ParameterSet& iConfig) + : hlTriggerResults_(iConfig.getParameter("HLTriggerResults")), + mcProducer_(iConfig.getUntrackedParameter("mcProducer", "")), + rechitProducer_(iConfig.getParameter("rechitProducer")), + rechitCollection_(iConfig.getParameter("rechitCollection")), + erechitProducer_(iConfig.getParameter("erechitProducer")), + erechitCollection_(iConfig.getParameter("erechitCollection")), + scProducer_(iConfig.getParameter("scProducer")), + scCollection_(iConfig.getParameter("scCollection")), + scIslandProducer_(iConfig.getParameter("scIslandProducer")), + scIslandCollection_(iConfig.getParameter("scIslandCollection")), + electronProducer_(iConfig.getParameter("electronProducer")), + electronCollection_(iConfig.getParameter("electronCollection")), + trigResultsToken_(consumes(hlTriggerResults_)), + hepMCToken_(consumes(edm::InputTag(mcProducer_))), + ebRecHitToken_(consumes(edm::InputTag(rechitProducer_, rechitCollection_))), + eeRecHitToken_(consumes(edm::InputTag(erechitProducer_, erechitCollection_))), + scToken_(consumes(edm::InputTag(scProducer_, scCollection_))), + islandSCToken_(consumes(edm::InputTag(scIslandProducer_, scIslandCollection_))), + gsfElectronToken_(consumes(edm::InputTag(electronProducer_, electronCollection_))), + geometryToken_(esConsumes()) { #ifdef DEBUG std::cout << "[ZeeCalibration] Starting the ctor" << std::endl; #endif @@ -78,25 +71,8 @@ ZeeCalibration::ZeeCalibration(const edm::ParameterSet& iConfig) { minInvMassCut_ = iConfig.getUntrackedParameter("minInvMassCut", 70.); maxInvMassCut_ = iConfig.getUntrackedParameter("maxInvMassCut", 110.); - rechitProducer_ = iConfig.getParameter("rechitProducer"); - rechitCollection_ = iConfig.getParameter("rechitCollection"); - - erechitProducer_ = iConfig.getParameter("erechitProducer"); - erechitCollection_ = iConfig.getParameter("erechitCollection"); - - scProducer_ = iConfig.getParameter("scProducer"); - scCollection_ = iConfig.getParameter("scCollection"); - - scIslandProducer_ = iConfig.getParameter("scIslandProducer"); - scIslandCollection_ = iConfig.getParameter("scIslandCollection"); - calibMode_ = iConfig.getUntrackedParameter("ZCalib_CalibType"); - mcProducer_ = iConfig.getUntrackedParameter("mcProducer", ""); - - electronProducer_ = iConfig.getParameter("electronProducer"); - electronCollection_ = iConfig.getParameter("electronCollection"); - outputFile_ = TFile::Open(outputFileName_.c_str(), "RECREATE"); // open output file to store histograms myTree = new TTree("myTree", "myTree"); @@ -124,8 +100,6 @@ ZeeCalibration::ZeeCalibration(const edm::ParameterSet& iConfig) { //ZeeCalibrationPLots("zeeCalibPlots"); //ZeecaPlots->bookHistos(maxsIter); - hlTriggerResults_ = iConfig.getParameter("HLTriggerResults"); - theParameterSet = iConfig; EcalIndexingTools* myIndexTool = nullptr; @@ -585,9 +559,8 @@ edm::EDLooper::Status ZeeCalibration::duringLoop(const edm::Event& iEvent, const // code that used to be in beginJob if (isfirstcall_) { //inizializzare la geometria di ecal - edm::ESHandle pG; - iSetup.get().get(pG); - EcalRingCalibrationTools::setCaloGeometry(&(*pG)); + const auto& geometry = iSetup.getData(geometryToken_); + EcalRingCalibrationTools::setCaloGeometry(&geometry); myZeePlots_ = new ZeePlots("zeePlots.root"); // myZeeRescaleFactorPlots_ = new ZeeRescaleFactorPlots("zeeRescaleFactorPlots.root"); @@ -717,7 +690,7 @@ edm::EDLooper::Status ZeeCalibration::duringLoop(const edm::Event& iEvent, const #endif edm::Handle hltTriggerResultHandle; - iEvent.getByLabel(hlTriggerResults_, hltTriggerResultHandle); + iEvent.getByToken(trigResultsToken_, hltTriggerResultHandle); if (!hltTriggerResultHandle.isValid()) { //std::cout << "invalid handle for HLT TriggerResults" << std::endl; @@ -757,8 +730,7 @@ edm::EDLooper::Status ZeeCalibration::duringLoop(const edm::Event& iEvent, const if (!mcProducer_.empty()) { //DUMP GENERATED Z MASS - BEGIN Handle hepProd; - // iEvent.getByLabel( "source", hepProd ) ; - iEvent.getByLabel(mcProducer_, hepProd); + iEvent.getByToken(hepMCToken_, hepProd); const HepMC::GenEvent* myGenEvent = hepProd->GetEvent(); @@ -809,27 +781,24 @@ edm::EDLooper::Status ZeeCalibration::duringLoop(const edm::Event& iEvent, const // Get EBRecHits Handle phits; - try { - iEvent.getByLabel(rechitProducer_, rechitCollection_, phits); - } catch (std::exception& ex) { + iEvent.getByToken(ebRecHitToken_, phits); + if (!phits.isValid()) { std::cerr << "Error! can't get the product EBRecHitCollection " << std::endl; } const EBRecHitCollection* hits = phits.product(); // get a ptr to the product // Get EERecHits Handle ephits; - try { - iEvent.getByLabel(erechitProducer_, erechitCollection_, ephits); - } catch (std::exception& ex) { + iEvent.getByToken(eeRecHitToken_, ephits); + if (!ephits.isValid()) { std::cerr << "Error! can't get the product EERecHitCollection " << std::endl; } const EERecHitCollection* ehits = ephits.product(); // get a ptr to the product //Get Hybrid SuperClusters Handle pSuperClusters; - try { - iEvent.getByLabel(scProducer_, scCollection_, pSuperClusters); - } catch (std::exception& ex) { + iEvent.getByToken(scToken_, pSuperClusters); + if (!pSuperClusters.isValid()) { std::cerr << "Error! can't get the product SuperClusterCollection " << std::endl; } const reco::SuperClusterCollection* scCollection = pSuperClusters.product(); @@ -843,9 +812,8 @@ edm::EDLooper::Status ZeeCalibration::duringLoop(const edm::Event& iEvent, const //Get Island SuperClusters Handle pIslandSuperClusters; - try { - iEvent.getByLabel(scIslandProducer_, scIslandCollection_, pIslandSuperClusters); - } catch (std::exception& ex) { + iEvent.getByToken(islandSCToken_, pIslandSuperClusters); + if (!pIslandSuperClusters.isValid()) { std::cerr << "Error! can't get the product IslandSuperClusterCollection " << std::endl; } const reco::SuperClusterCollection* scIslandCollection = pIslandSuperClusters.product(); @@ -859,9 +827,8 @@ edm::EDLooper::Status ZeeCalibration::duringLoop(const edm::Event& iEvent, const // Get Electrons Handle pElectrons; - try { - iEvent.getByLabel(electronProducer_, electronCollection_, pElectrons); - } catch (std::exception& ex) { + iEvent.getByToken(gsfElectronToken_, pElectrons); + if (!pElectrons.isValid()) { std::cerr << "Error! can't get the product ElectronCollection " << std::endl; } const reco::GsfElectronCollection* electronCollection = pElectrons.product();