diff --git a/RecoEgamma/EgammaHLTProducers/interface/ESListOfFEDSProducer.h b/RecoEgamma/EgammaHLTProducers/interface/ESListOfFEDSProducer.h index 5ddaf8c085b91..83c884e2d4772 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/ESListOfFEDSProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/ESListOfFEDSProducer.h @@ -3,7 +3,7 @@ #include #include - + #include #include #include @@ -29,61 +29,55 @@ namespace edm { } class ESListOfFEDSProducer : public edm::stream::EDProducer<> { - public: - ESListOfFEDSProducer(const edm::ParameterSet& pset); - ~ESListOfFEDSProducer() override; - void produce(edm::Event & e, const edm::EventSetup& c) override; - void Egamma(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs); - void Muon(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs); - void Jets(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + ESListOfFEDSProducer(const edm::ParameterSet& pset); + ~ESListOfFEDSProducer() override; + void produce(edm::Event& e, const edm::EventSetup& c) override; + void Egamma(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs); + void Muon(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs); + void Jets(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - //edm::InputTag Pi0ListToIgnore_; - bool EGamma_; - edm::EDGetTokenT EMl1TagIsolated_; - edm::EDGetTokenT EMl1TagNonIsolated_; - bool EMdoIsolated_; - bool EMdoNonIsolated_; - double EMregionEtaMargin_; - double EMregionPhiMargin_; - double Ptmin_iso_ ; - double Ptmin_noniso_; - - bool Muon_ ; - double MUregionEtaMargin_; - double MUregionPhiMargin_; - double Ptmin_muon_ ; - edm::EDGetTokenT MuonSource_ ; - - bool Jets_ ; - bool JETSdoCentral_ ; - bool JETSdoForward_ ; - bool JETSdoTau_ ; - double JETSregionEtaMargin_; - double JETSregionPhiMargin_; - double Ptmin_jets_ ; - edm::EDGetTokenT CentralSource_; - edm::EDGetTokenT ForwardSource_; - edm::EDGetTokenT TauSource_; - - std::string OutputLabel_; - EcalElectronicsMapping* TheMapping; - - /// ESElectronicsMapping* TheESMapping; - ESElectronicsMapper *TheESMapping; - - bool first_ ; - bool debug_ ; - - std::vector ListOfFEDS(double etaLow, double etaHigh, double phiLow, - double phiHigh, double etamargin, double phimargin); - - - + //edm::InputTag Pi0ListToIgnore_; + bool EGamma_; + edm::EDGetTokenT EMl1TagIsolated_; + edm::EDGetTokenT EMl1TagNonIsolated_; + bool EMdoIsolated_; + bool EMdoNonIsolated_; + double EMregionEtaMargin_; + double EMregionPhiMargin_; + double Ptmin_iso_; + double Ptmin_noniso_; + + bool Muon_; + double MUregionEtaMargin_; + double MUregionPhiMargin_; + double Ptmin_muon_; + edm::EDGetTokenT MuonSource_; + + bool Jets_; + bool JETSdoCentral_; + bool JETSdoForward_; + bool JETSdoTau_; + double JETSregionEtaMargin_; + double JETSregionPhiMargin_; + double Ptmin_jets_; + edm::EDGetTokenT CentralSource_; + edm::EDGetTokenT ForwardSource_; + edm::EDGetTokenT TauSource_; + + std::string OutputLabel_; + EcalElectronicsMapping* TheMapping; + + /// ESElectronicsMapping* TheESMapping; + ESElectronicsMapper* TheESMapping; + + bool first_; + bool debug_; + + std::vector ListOfFEDS( + double etaLow, double etaHigh, double phiLow, double phiHigh, double etamargin, double phimargin); }; #endif - - diff --git a/RecoEgamma/EgammaHLTProducers/interface/ESRecHitsMerger.h b/RecoEgamma/EgammaHLTProducers/interface/ESRecHitsMerger.h index 9269ea14fcf1a..7bc4fc42db69b 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/ESRecHitsMerger.h +++ b/RecoEgamma/EgammaHLTProducers/interface/ESRecHitsMerger.h @@ -3,7 +3,7 @@ #include #include - + #include #include #include @@ -19,32 +19,27 @@ namespace edm { } class ESRecHitsMerger : public edm::global::EDProducer<> { - public: - ESRecHitsMerger(const edm::ParameterSet& pset); - ~ESRecHitsMerger() override; - void produce(edm::StreamID sid, edm::Event & e, const edm::EventSetup& c) const override; - void beginJob(void) override; - void endJob(void) override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + ESRecHitsMerger(const edm::ParameterSet& pset); + ~ESRecHitsMerger() override; + void produce(edm::StreamID sid, edm::Event& e, const edm::EventSetup& c) const override; + void beginJob(void) override; + void endJob(void) override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - edm::InputTag EgammaSourceES_; - edm::InputTag MuonsSourceES_ ; - edm::InputTag TausSourceES_ ; - edm::InputTag JetsSourceES_ ; - edm::InputTag RestSourceES_ ; - edm::InputTag Pi0SourceES_ ; - edm::InputTag EtaSourceES_ ; - std::string OutputLabelES_; - - std::string InputRecHitES_; - - - bool debug_ ; - + edm::InputTag EgammaSourceES_; + edm::InputTag MuonsSourceES_; + edm::InputTag TausSourceES_; + edm::InputTag JetsSourceES_; + edm::InputTag RestSourceES_; + edm::InputTag Pi0SourceES_; + edm::InputTag EtaSourceES_; + std::string OutputLabelES_; + + std::string InputRecHitES_; + + bool debug_; }; #endif - - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EcalListOfFEDSProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EcalListOfFEDSProducer.h index a5c76ba5103e1..81628d2c97388 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EcalListOfFEDSProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EcalListOfFEDSProducer.h @@ -3,7 +3,7 @@ #include #include - + #include #include #include @@ -18,7 +18,7 @@ #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h" #include "DataFormats/L1Trigger/interface/L1JetParticle.h" #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h" - + #include #include #include @@ -28,19 +28,18 @@ namespace edm { } class EcalListOfFEDSProducer : public edm::stream::EDProducer<> { - - public: +public: EcalListOfFEDSProducer(const edm::ParameterSet& pset); ~EcalListOfFEDSProducer() override; - void produce(edm::Event & e, const edm::EventSetup& c) override; + void produce(edm::Event& e, const edm::EventSetup& c) override; void Egamma(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs); void Muon(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs); void Jets(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - edm::InputTag Pi0ListToIgnore_; +private: + edm::InputTag Pi0ListToIgnore_; bool EGamma_; edm::EDGetTokenT EMl1TagIsolated_; edm::EDGetTokenT EMl1TagNonIsolated_; @@ -48,34 +47,32 @@ class EcalListOfFEDSProducer : public edm::stream::EDProducer<> { bool EMdoNonIsolated_; double EMregionEtaMargin_; double EMregionPhiMargin_; - double Ptmin_iso_ ; + double Ptmin_iso_; double Ptmin_noniso_; - - bool Muon_ ; + + bool Muon_; double MUregionEtaMargin_; double MUregionPhiMargin_; - double Ptmin_muon_ ; - edm::EDGetTokenT MuonSource_ ; - - bool Jets_ ; - bool JETSdoCentral_ ; - bool JETSdoForward_ ; - bool JETSdoTau_ ; + double Ptmin_muon_; + edm::EDGetTokenT MuonSource_; + + bool Jets_; + bool JETSdoCentral_; + bool JETSdoForward_; + bool JETSdoTau_; double JETSregionEtaMargin_; double JETSregionPhiMargin_; - double Ptmin_jets_ ; + double Ptmin_jets_; edm::EDGetTokenT CentralSource_; edm::EDGetTokenT ForwardSource_; edm::EDGetTokenT TauSource_; - + std::string OutputLabel_; EcalElectronicsMapping* TheMapping; - bool first_ ; - bool debug_ ; - - std::vector ListOfFEDS(double etaLow, double etaHigh, double phiLow, - double phiHigh, double etamargin, double phimargin); + bool first_; + bool debug_; + + std::vector ListOfFEDS( + double etaLow, double etaHigh, double phiLow, double phiHigh, double etamargin, double phimargin); }; #endif - - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EcalRecHitsMerger.h b/RecoEgamma/EgammaHLTProducers/interface/EcalRecHitsMerger.h index 81d74d34b9694..f6b60d1880cc4 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EcalRecHitsMerger.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EcalRecHitsMerger.h @@ -3,7 +3,7 @@ #include #include - + #include #include #include @@ -19,40 +19,35 @@ namespace edm { } class EcalRecHitsMerger : public edm::global::EDProducer<> { - public: - EcalRecHitsMerger(const edm::ParameterSet& pset); - ~EcalRecHitsMerger() override; - void produce(edm::StreamID sid, edm::Event & e, const edm::EventSetup& c) const override; - void beginJob(void) override; - void endJob(void) override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + EcalRecHitsMerger(const edm::ParameterSet& pset); + ~EcalRecHitsMerger() override; + void produce(edm::StreamID sid, edm::Event& e, const edm::EventSetup& c) const override; + void beginJob(void) override; + void endJob(void) override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - edm::InputTag EgammaSourceEB_; - edm::InputTag MuonsSourceEB_ ; - edm::InputTag TausSourceEB_ ; - edm::InputTag JetsSourceEB_ ; - edm::InputTag RestSourceEB_ ; - edm::InputTag Pi0SourceEB_ ; - std::string OutputLabelEB_; - - edm::InputTag EgammaSourceEE_; - edm::InputTag MuonsSourceEE_ ; - edm::InputTag TausSourceEE_ ; - edm::InputTag JetsSourceEE_ ; - edm::InputTag RestSourceEE_ ; - edm::InputTag Pi0SourceEE_ ; - std::string OutputLabelEE_; - - std::string InputRecHitEB_; - std::string InputRecHitEE_; - - - bool debug_ ; - + edm::InputTag EgammaSourceEB_; + edm::InputTag MuonsSourceEB_; + edm::InputTag TausSourceEB_; + edm::InputTag JetsSourceEB_; + edm::InputTag RestSourceEB_; + edm::InputTag Pi0SourceEB_; + std::string OutputLabelEB_; + + edm::InputTag EgammaSourceEE_; + edm::InputTag MuonsSourceEE_; + edm::InputTag TausSourceEE_; + edm::InputTag JetsSourceEE_; + edm::InputTag RestSourceEE_; + edm::InputTag Pi0SourceEE_; + std::string OutputLabelEE_; + + std::string InputRecHitEB_; + std::string InputRecHitEE_; + + bool debug_; }; #endif - - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTBcHcalIsolationProducersRegional.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTBcHcalIsolationProducersRegional.h index 9353ecf1924fc..7779058867bf8 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTBcHcalIsolationProducersRegional.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTBcHcalIsolationProducersRegional.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTBcHcalIsolationProducersRegional -// +// // Original Author: Matteo Sani (UCSD) // Created: Thu Nov 24 11:38:00 CEST 2011 // @@ -33,35 +33,34 @@ class EgammaTowerIsolation; class EgammaHLTBcHcalIsolationProducersRegional : public edm::stream::EDProducer<> { public: - explicit EgammaHLTBcHcalIsolationProducersRegional(const edm::ParameterSet&); + explicit EgammaHLTBcHcalIsolationProducersRegional(const edm::ParameterSet &); ~EgammaHLTBcHcalIsolationProducersRegional() override; // non-copiable EgammaHLTBcHcalIsolationProducersRegional(EgammaHLTBcHcalIsolationProducersRegional const &) = delete; - EgammaHLTBcHcalIsolationProducersRegional& operator=(EgammaHLTBcHcalIsolationProducersRegional const &) = delete; + EgammaHLTBcHcalIsolationProducersRegional &operator=(EgammaHLTBcHcalIsolationProducersRegional const &) = delete; public: - void produce(edm::Event&, const edm::EventSetup&) final; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + void produce(edm::Event &, const edm::EventSetup &) final; + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); private: - const bool doEtSum_; + const bool doEtSum_; const double etMin_; const double innerCone_; const double outerCone_; - const int depth_; - const bool useSingleTower_; + const int depth_; + const bool useSingleTower_; - const bool doRhoCorrection_; + const bool doRhoCorrection_; const double rhoScale_; const double rhoMax_; const std::vector effectiveAreas_; const std::vector absEtaLowEdges_; const edm::EDGetTokenT recoEcalCandidateProducer_; - const edm::EDGetTokenT caloTowerProducer_; - const edm::EDGetTokenT rhoProducer_; + const edm::EDGetTokenT caloTowerProducer_; + const edm::EDGetTokenT rhoProducer_; ElectronHcalHelper *hcalHelper_; }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCaloTowerProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCaloTowerProducer.h index b7f188929de69..31647a2bd2b11 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCaloTowerProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCaloTowerProducer.h @@ -21,13 +21,11 @@ namespace edm { class ConfigurationDescriptions; } - class EgammaHLTCaloTowerProducer : public edm::global::EDProducer<> { - public: - - EgammaHLTCaloTowerProducer( const edm::ParameterSet & ); - ~EgammaHLTCaloTowerProducer() override {}; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); +public: + EgammaHLTCaloTowerProducer(const edm::ParameterSet &); + ~EgammaHLTCaloTowerProducer() override{}; + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const final; const edm::EDGetTokenT towers_; diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h index 954f99a1e1dbd..6368bd030c23b 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTClusterShapeProducer -// +// /**\class EgammaHLTClusterShapeProducer EgammaHLTClusterShapeProducer.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h */ // @@ -32,17 +32,15 @@ class EgammaHLTClusterShapeProducer : public edm::global::EDProducer<> { public: explicit EgammaHLTClusterShapeProducer(const edm::ParameterSet&); ~EgammaHLTClusterShapeProducer() override; - + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; private: // ----------member data --------------------------- - + const edm::EDGetTokenT recoEcalCandidateProducer_; - const edm::EDGetTokenT ecalRechitEBToken_; - const edm::EDGetTokenT ecalRechitEEToken_; + const edm::EDGetTokenT ecalRechitEBToken_; + const edm::EDGetTokenT ecalRechitEEToken_; const bool EtaOrIeta_; - }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCombinedIsolationProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCombinedIsolationProducer.h index 65226ea20d280..f091dcb596f39 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCombinedIsolationProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCombinedIsolationProducer.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTCombinedIsolationProducer -// +// /**\class EgammaHLTCombinedIsolationProducer EgammaHLTCombinedIsolationProducer.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCombinedIsolationProducer.h */ // @@ -31,16 +31,15 @@ class EgammaHLTCombinedIsolationProducer : public edm::global::EDProducer<> { public: explicit EgammaHLTCombinedIsolationProducer(const edm::ParameterSet&); ~EgammaHLTCombinedIsolationProducer() override; - + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + private: // ----------member data --------------------------- - + edm::EDGetTokenT recoEcalCandidateProducer_; std::vector > IsolTag_; std::vector IsolWeight_; const edm::ParameterSet conf_; - }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalIsolationProducersRegional.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalIsolationProducersRegional.h index 545edeb598031..15448fb5c63fc 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalIsolationProducersRegional.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalIsolationProducersRegional.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTEcalIsolationProducersRegional -// +// /**\class EgammaHLTEcalIsolationProducersRegional EgammaHLTEcalIsolationProducersRegional.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalIsolationProducersRegional.h Description: @@ -17,7 +17,6 @@ // // - // system include files #include @@ -58,9 +57,8 @@ class EgammaHLTEcalIsolationProducersRegional : public edm::global::EDProducer<> const edm::EDGetTokenT scIslandBarrelProducer_; const edm::EDGetTokenT scIslandEndcapProducer_; - const double egEcalIsoEtMin_; - const double egEcalIsoConeSize_; + const double egEcalIsoEtMin_; + const double egEcalIsoConeSize_; const int algoType_; - EgammaHLTEcalIsolation const * const test_; + EgammaHLTEcalIsolation const* const test_; }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalRecIsolationProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalRecIsolationProducer.h index 145e6f41afbf3..c9ef113b169ba 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalRecIsolationProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalRecIsolationProducer.h @@ -12,7 +12,6 @@ // -*- C++ -*- // - // system include files #include @@ -32,26 +31,26 @@ namespace edm { } class EgammaHLTEcalRecIsolationProducer : public edm::global::EDProducer<> { - public: +public: explicit EgammaHLTEcalRecIsolationProducer(const edm::ParameterSet&); ~EgammaHLTEcalRecIsolationProducer() override; void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: +private: edm::EDGetTokenT recoEcalCandidateProducer_; edm::EDGetTokenT ecalBarrelRecHitProducer_; edm::EDGetTokenT ecalEndcapRecHitProducer_; edm::EDGetTokenT rhoProducer_; - double egIsoPtMinBarrel_; //minimum Et noise cut - double egIsoEMinBarrel_; //minimum E noise cut - double egIsoPtMinEndcap_; //minimum Et noise cut - double egIsoEMinEndcap_; //minimum E noise cut - double egIsoConeSizeOut_; //outer cone size - double egIsoConeSizeInBarrel_; //inner cone size - double egIsoConeSizeInEndcap_; //inner cone size - double egIsoJurassicWidth_ ; // exclusion strip width for jurassic veto + double egIsoPtMinBarrel_; //minimum Et noise cut + double egIsoEMinBarrel_; //minimum E noise cut + double egIsoPtMinEndcap_; //minimum Et noise cut + double egIsoEMinEndcap_; //minimum E noise cut + double egIsoConeSizeOut_; //outer cone size + double egIsoConeSizeInBarrel_; //inner cone size + double egIsoConeSizeInEndcap_; //inner cone size + double egIsoJurassicWidth_; // exclusion strip width for jurassic veto float effectiveAreaBarrel_; float effectiveAreaEndcap_; @@ -59,10 +58,10 @@ class EgammaHLTEcalRecIsolationProducer : public edm::global::EDProducer<> { float rhoScale_; float rhoMax_; - bool useIsolEt_; //switch for isolEt rather than isolE - bool tryBoth_ ; // use rechits from barrel + endcap - bool subtract_ ; // subtract SC energy (allows veto cone of zero size) - bool useNumCrystals_;// veto cones are specified in number of crystals not eta + bool useIsolEt_; //switch for isolEt rather than isolE + bool tryBoth_; // use rechits from barrel + endcap + bool subtract_; // subtract SC energy (allows veto cone of zero size) + bool useNumCrystals_; // veto cones are specified in number of crystals not eta edm::ParameterSet conf_; }; diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronCombinedIsolationProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronCombinedIsolationProducer.h index bcc015d19ef5d..d0b067b9bc61d 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronCombinedIsolationProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronCombinedIsolationProducer.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTElectronCombinedIsolationProducer -// +// /**\class EgammaHLTElectronCombinedIsolationProducer EgammaHLTElectronCombinedIsolationProducer.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronCombinedIsolationProducer.h */ // @@ -38,14 +38,12 @@ class EgammaHLTElectronCombinedIsolationProducer : public edm::global::EDProduce static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - edm::EDGetTokenT recoEcalCandidateProducer_; edm::EDGetTokenT electronProducer_; std::vector > CaloIsolTag_; edm::EDGetTokenT TrackIsolTag_; - + std::vector CaloIsolWeight_; double TrackIsolWeight_; edm::ParameterSet conf_; }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronDetaDphiProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronDetaDphiProducer.h index bdee7e8fafe4c..abcec9efa71fd 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronDetaDphiProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronDetaDphiProducer.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTElectronDetaDphiProducer -// +// /**\class EgammaHLTElectronDetaDphiProducer EgammaHLTElectronDetaDphiProducer.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronDetaDphiProducer.h */ // @@ -12,7 +12,6 @@ // // - // system include files #include @@ -41,19 +40,21 @@ class EgammaHLTElectronDetaDphiProducer : public edm::stream::EDProducer<> { void produce(edm::Event&, const edm::EventSetup&) override; void beginRun(edm::Run const&, edm::EventSetup const&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - + private: - std::pair calDEtaDPhiSCTrk(reco::ElectronRef& eleref, const reco::BeamSpot::Point& BSPosition,const MagneticField *magField); - static reco::ElectronRef getEleRef(const reco::RecoEcalCandidateRef& recoEcalCandRef,const edm::Handle& electronHandle); - + std::pair calDEtaDPhiSCTrk(reco::ElectronRef& eleref, + const reco::BeamSpot::Point& BSPosition, + const MagneticField* magField); + static reco::ElectronRef getEleRef(const reco::RecoEcalCandidateRef& recoEcalCandRef, + const edm::Handle& electronHandle); + const edm::EDGetTokenT electronProducer_; const edm::EDGetTokenT bsProducer_; const edm::EDGetTokenT recoEcalCandidateProducer_; - + const bool useSCRefs_; const bool useTrackProjectionToEcal_; const bool variablesAtVtx_; const MagneticField* magField_; }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronTrackIsolationProducers.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronTrackIsolationProducers.h index 09dfe5d423703..4fe1d8a14f9e1 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronTrackIsolationProducers.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronTrackIsolationProducers.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTElectronTrackIsolationProducers -// +// /**\class EgammaHLTElectronTrackIsolationProducers EgammaHLTElectronTrackIsolationProducers.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronTrackIsolationProducers.h */ // @@ -12,7 +12,6 @@ // // - // system include files #include @@ -50,13 +49,12 @@ class EgammaHLTElectronTrackIsolationProducers : public edm::global::EDProducer< const bool useGsfTrack_; const bool useSCRefs_; - const double egTrkIsoPtMin_; + const double egTrkIsoPtMin_; const double egTrkIsoConeSize_; - const double egTrkIsoZSpan_; - const double egTrkIsoRSpan_; + const double egTrkIsoZSpan_; + const double egTrkIsoRSpan_; const double egTrkIsoVetoConeSizeBarrel_; const double egTrkIsoVetoConeSizeEndcap_; const double egTrkIsoStripBarrel_; const double egTrkIsoStripEndcap_; }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTFilteredObjProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTFilteredObjProducer.h index 542150dfff0bd..02cb5ce03b58a 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTFilteredObjProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTFilteredObjProducer.h @@ -1,14 +1,13 @@ #ifndef RECOEGAMMA_EGAMMAHLTPRODUCERS_EGAMMAHLTFILTEREDOBJPRODUCER_H #define RECOEGAMMA_EGAMMAHLTPRODUCERS_EGAMMAHLTFILTEREDOBJPRODUCER_H - #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" @@ -17,70 +16,69 @@ #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h" namespace { - template edm::Handle getHandle(const edm::Event& event,const edm::EDGetTokenT& token) - { + template + edm::Handle getHandle(const edm::Event& event, const edm::EDGetTokenT& token) { edm::Handle handle; - event.getByToken(token,handle); + event.getByToken(token, handle); return handle; } -} +} // namespace template -class EgammaHLTFilteredObjProducer : public edm::stream::EDProducer<>{ -public: +class EgammaHLTFilteredObjProducer : public edm::stream::EDProducer<> { +public: class SelectionCut { public: - SelectionCut(const edm::ParameterSet& pset,edm::ConsumesCollector && iC): - ebCut_(pset.getParameter("barrelCut")), - eeCut_(pset.getParameter("endcapCut")), - varToken_(iC.consumes(pset.getParameter("var"))) - {} - - ~SelectionCut()=default; - - bool operator()(const reco::RecoEcalCandidateRef& cand)const{ - CutValues cut = std::abs(cand->eta())<1.479 ? ebCut_ : eeCut_; - return cut(*cand,getVar(cand)); + SelectionCut(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC) + : ebCut_(pset.getParameter("barrelCut")), + eeCut_(pset.getParameter("endcapCut")), + varToken_(iC.consumes(pset.getParameter("var"))) {} + + ~SelectionCut() = default; + + bool operator()(const reco::RecoEcalCandidateRef& cand) const { + CutValues cut = std::abs(cand->eta()) < 1.479 ? ebCut_ : eeCut_; + return cut(*cand, getVar(cand)); } - float getVar(const reco::RecoEcalCandidateRef& cand)const{ + float getVar(const reco::RecoEcalCandidateRef& cand) const { auto res = varHandle_->find(cand); - if(res!=varHandle_->end()) return res->val; - else{ - //FIX ME: add some provenance info to this - throw cms::Exception("LogicError") <<" candidate not found in collection "; + if (res != varHandle_->end()) + return res->val; + else { + //FIX ME: add some provenance info to this + throw cms::Exception("LogicError") << " candidate not found in collection "; } } - void getHandles(const edm::Event& event){ - event.getByToken(varToken_,varHandle_); - } + void getHandles(const edm::Event& event) { event.getByToken(varToken_, varHandle_); } + private: struct CutValues { float cut; float cutOverE; float cutOverE2; bool useEt; - std::function compFunc; - - CutValues(const edm::ParameterSet& pset): - cut(pset.getParameter("cut")), - cutOverE(pset.getParameter("cutOverE")), - cutOverE2(pset.getParameter("cutOverE2")), - useEt(pset.getParameter("useEt")), - compFunc(std::less()) {} - - bool operator()(const reco::RecoEcalCandidate& cand,float value)const{ - if(compFunc(value,cut)) return true; - else{ - float energyInv = useEt ? 1./cand.et() : 1./cand.energy(); - return compFunc(value*energyInv,cutOverE) || - compFunc(value*energyInv*energyInv,cutOverE2); - } + std::function compFunc; + + CutValues(const edm::ParameterSet& pset) + : cut(pset.getParameter("cut")), + cutOverE(pset.getParameter("cutOverE")), + cutOverE2(pset.getParameter("cutOverE2")), + useEt(pset.getParameter("useEt")), + compFunc(std::less()) {} + + bool operator()(const reco::RecoEcalCandidate& cand, float value) const { + if (compFunc(value, cut)) + return true; + else { + float energyInv = useEt ? 1. / cand.et() : 1. / cand.energy(); + return compFunc(value * energyInv, cutOverE) || compFunc(value * energyInv * energyInv, cutOverE2); + } } }; - + CutValues ebCut_; CutValues eeCut_; edm::EDGetTokenT varToken_; @@ -88,87 +86,79 @@ class EgammaHLTFilteredObjProducer : public edm::stream::EDProducer<>{ }; explicit EgammaHLTFilteredObjProducer(const edm::ParameterSet& pset); - ~EgammaHLTFilteredObjProducer() override =default; - static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + ~EgammaHLTFilteredObjProducer() override = default; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + void produce(edm::Event&, const edm::EventSetup&) override; - void produce(edm::Event&, const edm::EventSetup&) override; - private: //different collection types may need to specialise this function //eg if you wanted superclusters it would output.push_back(cand->superCluster()) - static void addObj(const reco::RecoEcalCandidateRef& cand,OutCollType& output){ - output.push_back(cand); - } + static void addObj(const reco::RecoEcalCandidateRef& cand, OutCollType& output) { output.push_back(cand); } edm::EDGetTokenT candsToken_; std::vector cuts_; }; - -template -EgammaHLTFilteredObjProducer:: -EgammaHLTFilteredObjProducer(const edm::ParameterSet& pset): - candsToken_(consumes(pset.getParameter("cands"))) -{ +template +EgammaHLTFilteredObjProducer::EgammaHLTFilteredObjProducer(const edm::ParameterSet& pset) + : candsToken_(consumes(pset.getParameter("cands"))) { const auto& cutPsets = pset.getParameter >("cuts"); - for(auto& cutPset : cutPsets){ - cuts_.push_back(SelectionCut(cutPset,consumesCollector())); + for (auto& cutPset : cutPsets) { + cuts_.push_back(SelectionCut(cutPset, consumesCollector())); } produces(); - } - -template -void EgammaHLTFilteredObjProducer:: -fillDescriptions(edm::ConfigurationDescriptions & descriptions) -{ + +template +void EgammaHLTFilteredObjProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("cands",edm::InputTag("hltEgammaCandidates")); - + desc.add("cands", edm::InputTag("hltEgammaCandidates")); + edm::ParameterSetDescription cutsDesc; edm::ParameterSetDescription regionCutsDesc; - regionCutsDesc.add("cut",-1); - regionCutsDesc.add("cutOverE",-1); - regionCutsDesc.add("cutOverE2",-1); - regionCutsDesc.add("useEt",false); + regionCutsDesc.add("cut", -1); + regionCutsDesc.add("cutOverE", -1); + regionCutsDesc.add("cutOverE2", -1); + regionCutsDesc.add("useEt", false); edm::ParameterSet cutDefaults; - cutDefaults.addParameter("cutOverE",0.2); - cutDefaults.addParameter("useEt",false); - - cutsDesc.add("barrelCut",regionCutsDesc); - cutsDesc.add("endcapCut",regionCutsDesc); - cutsDesc.add("var",edm::InputTag("hltEgammaHoverE")); - + cutDefaults.addParameter("cutOverE", 0.2); + cutDefaults.addParameter("useEt", false); + + cutsDesc.add("barrelCut", regionCutsDesc); + cutsDesc.add("endcapCut", regionCutsDesc); + cutsDesc.add("var", edm::InputTag("hltEgammaHoverE")); + edm::ParameterSet defaults; - defaults.addParameter("var",edm::InputTag("hltEgammaHoverE")); - defaults.addParameter("barrelCut",cutDefaults); - defaults.addParameter("endcapCut",cutDefaults); - desc.addVPSet("cuts",cutsDesc,std::vector{defaults}); + defaults.addParameter("var", edm::InputTag("hltEgammaHoverE")); + defaults.addParameter("barrelCut", cutDefaults); + defaults.addParameter("endcapCut", cutDefaults); + desc.addVPSet("cuts", cutsDesc, std::vector{defaults}); descriptions.addWithDefaultLabel(desc); } -template -void EgammaHLTFilteredObjProducer:: -produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - for(auto& cut : cuts_) cut.getHandles(iEvent); - auto candsHandle = getHandle(iEvent,candsToken_); - +template +void EgammaHLTFilteredObjProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + for (auto& cut : cuts_) + cut.getHandles(iEvent); + auto candsHandle = getHandle(iEvent, candsToken_); + auto output = std::make_unique(); - for(size_t candNr=0;candNrsize();candNr++){ - reco::RecoEcalCandidateRef candRef(candsHandle,candNr); - bool passAllCuts=true; - for(const auto& cut: cuts_){ - if(!cut(candRef)){ - passAllCuts=false; - break; + for (size_t candNr = 0; candNr < candsHandle->size(); candNr++) { + reco::RecoEcalCandidateRef candRef(candsHandle, candNr); + bool passAllCuts = true; + for (const auto& cut : cuts_) { + if (!cut(candRef)) { + passAllCuts = false; + break; } } - if(passAllCuts) addObj(candRef,*output); + if (passAllCuts) + addObj(candRef, *output); } - + iEvent.put(std::move(output)); } diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTGsfTrackVarProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTGsfTrackVarProducer.h index 5130c260704c5..e7310cfe8851d 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTGsfTrackVarProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTGsfTrackVarProducer.h @@ -1,7 +1,6 @@ #ifndef RECOEGAMMA_EGAMMAHLTPRODUCERS_EGAMMAHLTGSFTRACKVARPRODUCER #define RECOEGAMMA_EGAMMAHLTPRODUCERS_EGAMMAHLTGSFTRACKVARPRODUCER - // system include files #include @@ -39,43 +38,43 @@ namespace edm { } class EgammaHLTGsfTrackVarProducer : public edm::stream::EDProducer<> { - private: +private: class TrackExtrapolator { unsigned long long cacheIDTDGeom_; unsigned long long cacheIDMagField_; - + edm::ESHandle magField_; edm::ESHandle trackerHandle_; - - const MultiTrajectoryStateTransform * mtsTransform_; //we own it - + + const MultiTrajectoryStateTransform* mtsTransform_; //we own it + public: - TrackExtrapolator():cacheIDTDGeom_(0),cacheIDMagField_(0),mtsTransform_(nullptr){} + TrackExtrapolator() : cacheIDTDGeom_(0), cacheIDMagField_(0), mtsTransform_(nullptr) {} TrackExtrapolator(const TrackExtrapolator& rhs); - ~TrackExtrapolator(){delete mtsTransform_;} + ~TrackExtrapolator() { delete mtsTransform_; } TrackExtrapolator* operator=(const TrackExtrapolator& rhs); - + void setup(const edm::EventSetup& iSetup); - - GlobalPoint extrapolateTrackPosToPoint(const reco::GsfTrack& gsfTrack,const GlobalPoint& pointToExtrapTo); - GlobalVector extrapolateTrackMomToPoint(const reco::GsfTrack& gsfTrack,const GlobalPoint& pointToExtrapTo); - - edm::ESHandle trackerGeomHandle()const{return trackerHandle_;} - const MultiTrajectoryStateTransform * mtsTransform()const{return mtsTransform_;} + + GlobalPoint extrapolateTrackPosToPoint(const reco::GsfTrack& gsfTrack, const GlobalPoint& pointToExtrapTo); + GlobalVector extrapolateTrackMomToPoint(const reco::GsfTrack& gsfTrack, const GlobalPoint& pointToExtrapTo); + + edm::ESHandle trackerGeomHandle() const { return trackerHandle_; } + const MultiTrajectoryStateTransform* mtsTransform() const { return mtsTransform_; } }; - - public: + +public: explicit EgammaHLTGsfTrackVarProducer(const edm::ParameterSet&); ~EgammaHLTGsfTrackVarProducer() override; - void produce(edm::Event&, const edm::EventSetup&) override; + void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: +private: const edm::EDGetTokenT recoEcalCandTag_; const edm::EDGetTokenT inputCollectionTag1_; const edm::EDGetTokenT inputCollectionTag2_; const edm::EDGetTokenT beamSpotTag_; - + TrackExtrapolator trackExtrapolator_; const int upperTrackNrToRemoveCut_; const int lowerTrackNrToRemoveCut_; diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationDoubleConeProducers.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationDoubleConeProducers.h index b3a5c1b5b5d70..73abf5ab57f8e 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationDoubleConeProducers.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationDoubleConeProducers.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTHcalIsolationDoubleConeProducers -// +// /**\class EgammaHLTHcalIsolationDoubleConeProducers EgammaHLTHcalIsolationDoubleConeProducers.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationDoubleConeProducers.h */ // @@ -11,10 +11,9 @@ // $Id: EgammaHLTHcalIsolationDoubleConeProducers.h,v 1.4 2006/10/24 15:25:53 monicava Exp $ // // -// mostly identical to EgammaHLTHcalIsolationRegionalProducers, but produces excludes +// mostly identical to EgammaHLTHcalIsolationRegionalProducers, but produces excludes // Hcal energy in an exclusion cone around the eg candidate - // system include files #include @@ -42,7 +41,6 @@ class EgammaHLTHcalIsolationDoubleConeProducers : public edm::global::EDProducer static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - const edm::ParameterSet conf_; const edm::EDGetTokenT recoEcalCandidateProducer_; @@ -52,7 +50,6 @@ class EgammaHLTHcalIsolationDoubleConeProducers : public edm::global::EDProducer const double egHcalIsoPtMin_; const double egHcalIsoConeSize_; const double egHcalExclusion_; - - EgammaHLTHcalIsolationDoubleCone const * const test_; -}; + EgammaHLTHcalIsolationDoubleCone const* const test_; +}; diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationProducersRegional.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationProducersRegional.h index 280f13581e7ad..19117fdff9671 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationProducersRegional.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationProducersRegional.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTHcalIsolationProducersRegional -// +// /**\class EgammaHLTHcalIsolationProducersRegional EgammaHLTHcalIsolationProducersRegional.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationProducersRegional.h */ // @@ -12,7 +12,6 @@ // // - // system include files #include @@ -44,7 +43,6 @@ class EgammaHLTHcalIsolationProducersRegional : public edm::global::EDProducer<> static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - const edm::EDGetTokenT recoEcalCandidateProducer_; const edm::EDGetTokenT hbheRecHitProducer_; const edm::EDGetTokenT rhoProducer_; @@ -56,6 +54,5 @@ class EgammaHLTHcalIsolationProducersRegional : public edm::global::EDProducer<> const float effectiveAreaBarrel_; const float effectiveAreaEndcap_; - EgammaHLTHcalIsolation const * const isolAlgo_; + EgammaHLTHcalIsolation const* const isolAlgo_; }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHybridClusterProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHybridClusterProducer.h index 15d5dab163643..f16bf1accd4f3 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHybridClusterProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHybridClusterProducer.h @@ -20,15 +20,14 @@ namespace edm { class ConfigurationDescriptions; } -class EgammaHLTHybridClusterProducer : public edm::stream::EDProducer<> { - public: +class EgammaHLTHybridClusterProducer : public edm::stream::EDProducer<> { +public: EgammaHLTHybridClusterProducer(const edm::ParameterSet& ps); ~EgammaHLTHybridClusterProducer() override; void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - +private: const std::string basicclusterCollection_; const std::string superclusterCollection_; const edm::EDGetTokenT hittoken_; @@ -41,14 +40,11 @@ class EgammaHLTHybridClusterProducer : public edm::stream::EDProducer<> { const double l1LowerThr_; const double l1UpperThr_; const double l1LowerThrIgnoreIsolation_; - + const double regionEtaMargin_; const double regionPhiMargin_; - - const PositionCalc posCalculator_; // position calculation algorithm - HybridClusterAlgo * const hybrid_p; // clustering algorithm - + + const PositionCalc posCalculator_; // position calculation algorithm + HybridClusterAlgo* const hybrid_p; // clustering algorithm }; #endif - - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTIslandClusterProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTIslandClusterProducer.h index 85fc3534c6c27..9674818cd6468 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTIslandClusterProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTIslandClusterProducer.h @@ -23,47 +23,46 @@ namespace edm { } class EgammaHLTIslandClusterProducer : public edm::stream::EDProducer<> { - public: +public: EgammaHLTIslandClusterProducer(const edm::ParameterSet& ps); ~EgammaHLTIslandClusterProducer() override; void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - +private: const bool doBarrel_; const bool doEndcaps_; const bool doIsolated_; - + const edm::InputTag barrelHitCollection_; const edm::InputTag endcapHitCollection_; const edm::EDGetTokenT barrelHitToken_; const edm::EDGetTokenT endcapHitToken_; - + const std::string barrelClusterCollection_; const std::string endcapClusterCollection_; - + const edm::EDGetTokenT l1TagIsolated_; const edm::EDGetTokenT l1TagNonIsolated_; const double l1LowerThr_; const double l1UpperThr_; const double l1LowerThrIgnoreIsolation_; - + const double regionEtaMargin_; const double regionPhiMargin_; - - const PositionCalc posCalculator_; // position calculation algorithm + + const PositionCalc posCalculator_; // position calculation algorithm const std::string verb_; - IslandClusterAlgo * const island_p; - - const EcalRecHitCollection * getCollection(edm::Event& evt, - const edm::EDGetTokenT& hitToken) const ; - - - void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, - const edm::EDGetTokenT& hitToken, - const std::string& clusterCollection, - const std::vector& regions, - const IslandClusterAlgo::EcalPart& ecalPart) const ; + IslandClusterAlgo* const island_p; + + const EcalRecHitCollection* getCollection(edm::Event& evt, + const edm::EDGetTokenT& hitToken) const; + + void clusterizeECALPart(edm::Event& evt, + const edm::EventSetup& es, + const edm::EDGetTokenT& hitToken, + const std::string& clusterCollection, + const std::vector& regions, + const IslandClusterAlgo::EcalPart& ecalPart) const; }; #endif diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTMulti5x5ClusterProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTMulti5x5ClusterProducer.h index 79052399fc8b2..2434336d76884 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTMulti5x5ClusterProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTMulti5x5ClusterProducer.h @@ -25,14 +25,13 @@ namespace edm { } class EgammaHLTMulti5x5ClusterProducer : public edm::stream::EDProducer<> { - public: +public: EgammaHLTMulti5x5ClusterProducer(const edm::ParameterSet& ps); ~EgammaHLTMulti5x5ClusterProducer() override; void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - +private: bool doBarrel_; bool doEndcaps_; bool doIsolated_; @@ -43,31 +42,30 @@ class EgammaHLTMulti5x5ClusterProducer : public edm::stream::EDProducer<> { edm::InputTag endcapHitCollection_; edm::EDGetTokenT barrelHitToken_; edm::EDGetTokenT endcapHitToken_; - + std::string barrelClusterCollection_; std::string endcapClusterCollection_; double l1LowerThr_; double l1UpperThr_; double l1LowerThrIgnoreIsolation_; - + double regionEtaMargin_; double regionPhiMargin_; - - PositionCalc posCalculator_; // position calculation algorithm - Multi5x5ClusterAlgo * Multi5x5_p; - - const EcalRecHitCollection * getCollection(edm::Event& evt, - const edm::EDGetTokenT& hitToken) const ; - - - void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, - const edm::EDGetTokenT& hitToken, - const std::string& clusterCollection, - const std::vector& regions, - const reco::CaloID::Detectors detector) const ; - - void outputValidationInfo(reco::CaloClusterPtrVector &clusterPtrVector); + PositionCalc posCalculator_; // position calculation algorithm + Multi5x5ClusterAlgo* Multi5x5_p; + + const EcalRecHitCollection* getCollection(edm::Event& evt, + const edm::EDGetTokenT& hitToken) const; + + void clusterizeECALPart(edm::Event& evt, + const edm::EventSetup& es, + const edm::EDGetTokenT& hitToken, + const std::string& clusterCollection, + const std::vector& regions, + const reco::CaloID::Detectors detector) const; + + void outputValidationInfo(reco::CaloClusterPtrVector& clusterPtrVector); }; #endif diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTNxNClusterProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTNxNClusterProducer.h index 88a6a504722ab..1de9ef00ae72c 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTNxNClusterProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTNxNClusterProducer.h @@ -28,49 +28,49 @@ Description: simple NxN ( 3x3 etc) clustering ,( for low energy photon reconstru #include #include - namespace edm { class ConfigurationDescriptions; } class EgammaHLTNxNClusterProducer : public edm::stream::EDProducer<> { - public: - - EgammaHLTNxNClusterProducer(const edm::ParameterSet& ps); +public: + EgammaHLTNxNClusterProducer(const edm::ParameterSet &ps); ~EgammaHLTNxNClusterProducer() override; - - void produce(edm::Event&, const edm::EventSetup&) override ; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - private: - - void makeNxNClusters(edm::Event &evt, const edm::EventSetup &es,const EcalRecHitCollection *hits, const reco::CaloID::Detectors detector); - + + void produce(edm::Event &, const edm::EventSetup &) override; + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + +private: + void makeNxNClusters(edm::Event &evt, + const edm::EventSetup &es, + const EcalRecHitCollection *hits, + const reco::CaloID::Detectors detector); + bool checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus, const EcalRecHit &rh); - + //std::map providedParameters; - + const bool doBarrel_; - const bool doEndcaps_; + const bool doEndcaps_; const edm::EDGetTokenT barrelHitProducer_; const edm::EDGetTokenT endcapHitProducer_; - const int clusEtaSize_ ; + const int clusEtaSize_; const int clusPhiSize_; const std::string barrelClusterCollection_; const std::string endcapClusterCollection_; const double clusSeedThr_; const double clusSeedThrEndCap_; - const bool useRecoFlag_; - const int flagLevelRecHitsToUse_; - const bool useDBStatus_; + const bool useRecoFlag_; + const int flagLevelRecHitsToUse_; + const bool useDBStatus_; const int statusLevelRecHitsToUse_; - const int maxNumberofSeeds_ ; - const int maxNumberofClusters_; + const int maxNumberofSeeds_; + const int maxNumberofClusters_; - const int debug_; + const int debug_; - PositionCalc posCalculator_; // position calculation algorithm + PositionCalc posCalculator_; // position calculation algorithm }; #endif diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFChargedIsolationProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFChargedIsolationProducer.h index 2e5368049720d..4228c310190ad 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFChargedIsolationProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFChargedIsolationProducer.h @@ -29,23 +29,22 @@ namespace edm { } class EgammaHLTPFChargedIsolationProducer : public edm::global::EDProducer<> { - public: +public: explicit EgammaHLTPFChargedIsolationProducer(const edm::ParameterSet&); - ~EgammaHLTPFChargedIsolationProducer() override {}; + ~EgammaHLTPFChargedIsolationProducer() override{}; void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: +private: edm::EDGetTokenT electronProducer_; edm::EDGetTokenT recoEcalCandidateProducer_; const edm::EDGetTokenT pfCandidateProducer_; const edm::EDGetTokenT beamSpotProducer_; - + const bool useGsfTrack_; const bool useSCRefs_; - + const double drMax_; const double drVetoBarrel_; const double drVetoEndcap_; @@ -53,7 +52,6 @@ class EgammaHLTPFChargedIsolationProducer : public edm::global::EDProducer<> { const double dzMax_; const double dxyMax_; const int pfToUse_; - }; #endif diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFNeutralIsolationProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFNeutralIsolationProducer.h index 792a51a32cfb0..afb30ad1f8f61 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFNeutralIsolationProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFNeutralIsolationProducer.h @@ -30,15 +30,14 @@ namespace edm { } class EgammaHLTPFNeutralIsolationProducer : public edm::global::EDProducer<> { - public: +public: explicit EgammaHLTPFNeutralIsolationProducer(const edm::ParameterSet&); - ~EgammaHLTPFNeutralIsolationProducer() override {}; - + ~EgammaHLTPFNeutralIsolationProducer() override{}; + void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - private: +private: edm::EDGetTokenT electronProducer_; edm::EDGetTokenT recoEcalCandidateProducer_; edm::EDGetTokenT pfCandidateProducer_; @@ -60,7 +59,6 @@ class EgammaHLTPFNeutralIsolationProducer : public edm::global::EDProducer<> { bool doRhoCorrection_; float rhoScale_; float rhoMax_; - }; #endif diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFPhotonIsolationProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFPhotonIsolationProducer.h index c1bf1bb4048dc..951b4dbd138a0 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFPhotonIsolationProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPFPhotonIsolationProducer.h @@ -30,14 +30,14 @@ namespace edm { } class EgammaHLTPFPhotonIsolationProducer : public edm::global::EDProducer<> { - public: +public: explicit EgammaHLTPFPhotonIsolationProducer(const edm::ParameterSet&); - ~EgammaHLTPFPhotonIsolationProducer() override {}; - + ~EgammaHLTPFPhotonIsolationProducer() override{}; + void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - private: + +private: edm::EDGetTokenT electronProducer_; edm::EDGetTokenT recoEcalCandidateProducer_; edm::EDGetTokenT pfCandidateProducer_; diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPhotonTrackIsolationProducersRegional.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPhotonTrackIsolationProducersRegional.h index 6ad7b6d9c7538..c9e84d963aad9 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPhotonTrackIsolationProducersRegional.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPhotonTrackIsolationProducersRegional.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTPhotonTrackIsolationProducersRegional -// +// /**\class EgammaHLTPhotonTrackIsolationProducersRegional EgammaHLTPhotonTrackIsolationProducersRegional.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPhotonTrackIsolationProducersRegional.h */ // @@ -12,7 +12,6 @@ // // - // system include files #include @@ -37,15 +36,15 @@ namespace edm { } class EgammaHLTPhotonTrackIsolationProducersRegional : public edm::global::EDProducer<> { - public: - explicit EgammaHLTPhotonTrackIsolationProducersRegional(const edm::ParameterSet&); - ~EgammaHLTPhotonTrackIsolationProducersRegional() override; +public: + explicit EgammaHLTPhotonTrackIsolationProducersRegional(const edm::ParameterSet&); + ~EgammaHLTPhotonTrackIsolationProducersRegional() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; - + private: - // ----------member data --------------------------- + // ----------member data --------------------------- const edm::EDGetTokenT recoEcalCandidateProducer_; const edm::EDGetTokenT trackProducer_; @@ -54,14 +53,13 @@ class EgammaHLTPhotonTrackIsolationProducersRegional : public edm::global::EDPro const bool countTracks_; - const double egTrkIsoPtMin_; + const double egTrkIsoPtMin_; const double egTrkIsoConeSize_; - const double egTrkIsoZSpan_; - const double egTrkIsoRSpan_; + const double egTrkIsoZSpan_; + const double egTrkIsoRSpan_; const double egTrkIsoVetoConeSize_; const double egTrkIsoStripBarrel_; const double egTrkIsoStripEndcap_; EgammaHLTTrackIsolation* test_; }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPixelMatchElectronProducers.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPixelMatchElectronProducers.h index 3b45929c967d4..c42b93765f47d 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPixelMatchElectronProducers.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPixelMatchElectronProducers.h @@ -1,13 +1,12 @@ #ifndef EgammaHLTPixelMatchElectronProducers_h #define EgammaHLTPixelMatchElectronProducers_h - + // // Package: RecoEgamma/EgammaHLTProducers // Class: EgammaHLTPixelMatchElectronProducers -// +// // $Id: EgammaHLTPixelMatchElectronProducers.h,v 1.3 2009/10/14 14:32:23 covarell Exp $ - - + #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "DataFormats/Common/interface/Handle.h" @@ -18,7 +17,6 @@ #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" - #include #include @@ -29,16 +27,13 @@ namespace edm { class EgammaHLTPixelMatchElectronAlgo; class EgammaHLTPixelMatchElectronProducers : public edm::stream::EDProducer<> { - - public: - +public: explicit EgammaHLTPixelMatchElectronProducers(const edm::ParameterSet& conf); void produce(edm::Event& e, const edm::EventSetup& c) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - +private: EgammaHLTPixelMatchElectronAlgo algo_; const edm::EDPutTokenT token_; }; diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPixelMatchParamObjects.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPixelMatchParamObjects.h index 3a5c5ed0b83f6..f8af52d285f77 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPixelMatchParamObjects.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPixelMatchParamObjects.h @@ -2,19 +2,19 @@ //design: // the function and parameterisation can be changing without having to change the interface // or breaking backwards compatibiltiy with existing configs. -// This is vital for the HLT and the main driving force behind the design which otherwise +// This is vital for the HLT and the main driving force behind the design which otherwise // could have been a lot simplier // //usage: -// The variables used are defined by an intermediate object which defines the -// variables x,y, and z. 1D objects only need to define x, 2D objects x,y, etc. -// Example is "AbsEtaNrClus" which defines x as |supercluster eta| and y as #subclusters of the supercluster. -// The object also defines a pass function where it determines if x (and y,z) is -// within the specificed xmin and xmax range. This is mainly done as individual -// objects can decide whether this means min<=x(); x = std::abs(scRef->eta()); y = scRef->clustersSize(); } - bool pass(float absEtaMin,float absEtaMax,size_t nrClusMin,size_t nrClusMax)const{ - return x>=absEtaMin && x=nrClusMin && y<=nrClusMax; + bool pass(float absEtaMin, float absEtaMax, size_t nrClusMin, size_t nrClusMax) const { + return x >= absEtaMin && x < absEtaMax && y >= nrClusMin && y <= nrClusMax; } }; - struct AbsEtaNrClusPhi{ + struct AbsEtaNrClusPhi { float x; size_t y; float z; - AbsEtaNrClusPhi(const reco::ElectronSeed& seed){ + AbsEtaNrClusPhi(const reco::ElectronSeed& seed) { reco::SuperClusterRef scRef = seed.caloCluster().castTo(); x = std::abs(scRef->eta()); y = scRef->clustersSize(); z = scRef->phi(); } - bool pass(float absEtaMin,float absEtaMax,size_t nrClusMin,size_t nrClusMax, - float phiMin,float phiMax)const{ - return x>=absEtaMin && x=nrClusMin && y<=nrClusMax - && z>=phiMin && z < phiMax; + bool pass(float absEtaMin, float absEtaMax, size_t nrClusMin, size_t nrClusMax, float phiMin, float phiMax) const { + return x >= absEtaMin && x < absEtaMax && y >= nrClusMin && y <= nrClusMax && z >= phiMin && z < phiMax; } }; @@ -76,254 +73,267 @@ namespace egPM { size_t y; float z; - AbsEtaNrClusEt(const reco::ElectronSeed& seed){ + AbsEtaNrClusEt(const reco::ElectronSeed& seed) { reco::SuperClusterRef scRef = seed.caloCluster().castTo(); x = std::abs(scRef->eta()); y = scRef->clustersSize(); - z = scRef->energy()*sin(scRef->position().Theta()); + z = scRef->energy() * sin(scRef->position().Theta()); } - bool pass(float absEtaMin,float absEtaMax,size_t nrClusMin,size_t nrClusMax, - float etMin,float etMax)const{ - return x>=absEtaMin && x=nrClusMin && y<=nrClusMax - && z>=etMin && z < etMax; + bool pass(float absEtaMin, float absEtaMax, size_t nrClusMin, size_t nrClusMax, float etMin, float etMax) const { + return x >= absEtaMin && x < absEtaMax && y >= nrClusMin && y <= nrClusMax && z >= etMin && z < etMax; } }; - //these structs wrap the TF1 object //also if the ParamType doesnt have a high enough dimension //(ie using only one with x,y for a TF3), then the second //template parameter disables the function - template - struct TF1Wrap{ + template + struct TF1Wrap { private: TF1 func_; + public: - TF1Wrap(const std::string& funcExpr,const std::vector& params): - func_("func",funcExpr.c_str()){ - for(size_t paraNr=0;paraNr& params) : func_("func", funcExpr.c_str()) { + for (size_t paraNr = 0; paraNr < params.size(); paraNr++) { + func_.SetParameter(paraNr, params[paraNr]); } } - float operator()(const ParamType& obj){ - return func_.Eval(obj.x); - }; + float operator()(const ParamType& obj) { return func_.Eval(obj.x); }; }; - template - class TF1Wrap{ + template + class TF1Wrap { public: - TF1Wrap(const std::string& funcExpr,const std::vector& params){} - float operator()(const ParamType& obj){return 1.;}; + TF1Wrap(const std::string& funcExpr, const std::vector& params) {} + float operator()(const ParamType& obj) { return 1.; }; }; - - template - struct TF2Wrap{ + + template + struct TF2Wrap { private: TF2 func_; + public: - TF2Wrap(const std::string& funcExpr,const std::vector& params): - func_("func",funcExpr.c_str()){ - for(size_t paraNr=0;paraNr& params) : func_("func", funcExpr.c_str()) { + for (size_t paraNr = 0; paraNr < params.size(); paraNr++) { + func_.SetParameter(paraNr, params[paraNr]); } - } - float operator()(const ParamType& obj){ - return func_.Eval(obj.x,obj.y); - }; + } + float operator()(const ParamType& obj) { return func_.Eval(obj.x, obj.y); }; }; - template - class TF2Wrap{ + template + class TF2Wrap { public: - TF2Wrap(const std::string& funcExpr,const std::vector& params){} - float operator()(const ParamType& obj){return 1.;}; + TF2Wrap(const std::string& funcExpr, const std::vector& params) {} + float operator()(const ParamType& obj) { return 1.; }; }; - template - struct TF3Wrap{ + template + struct TF3Wrap { private: TF3 func_; + public: - TF3Wrap(const std::string& funcExpr,const std::vector& params): - func_("func",funcExpr.c_str()){ - for(size_t paraNr=0;paraNr& params) : func_("func", funcExpr.c_str()) { + for (size_t paraNr = 0; paraNr < params.size(); paraNr++) { + func_.SetParameter(paraNr, params[paraNr]); } - } - float operator()(const ParamType& obj){ - return func_.Eval(obj.x,obj.y,obj.z); - }; + } + float operator()(const ParamType& obj) { return func_.Eval(obj.x, obj.y, obj.z); }; }; - template - class TF3Wrap{ + template + class TF3Wrap { public: - TF3Wrap(const std::string& funcExpr,const std::vector& params){} - float operator()(const ParamType& obj){return 1.;}; + TF3Wrap(const std::string& funcExpr, const std::vector& params) {} + float operator()(const ParamType& obj) { return 1.; }; }; - - //the following functions allow for the fact that the type in the CMSSW PSet does not + + //the following functions allow for the fact that the type in the CMSSW PSet does not //have floats do when it sees a float parameter, it retrieves a double - template - struct ConfigType{ + template + struct ConfigType { typedef T type; }; - template<> - struct ConfigType{ + template <> + struct ConfigType { typedef double type; }; - template<> - struct ConfigType{ + template <> + struct ConfigType { typedef int type; }; - //helper functions to figure out what dimension the ParamType is //and not generate functions which require a higher dimension - template - constexpr auto has1D(int) -> decltype(T::x,bool()){return true;} - template - constexpr bool has1D(...){return false;} - template - constexpr auto has2D(int) -> decltype(T::y,bool()){return true;} - template - constexpr bool has2D(...){return false;} - template - constexpr auto has3D(int) -> decltype(T::z,bool()){return true;} - template - constexpr bool has3D(...){return false;} + template + constexpr auto has1D(int) -> decltype(T::x, bool()) { + return true; + } + template + constexpr bool has1D(...) { + return false; + } + template + constexpr auto has2D(int) -> decltype(T::y, bool()) { + return true; + } + template + constexpr bool has2D(...) { + return false; + } + template + constexpr auto has3D(int) -> decltype(T::z, bool()) { + return true; + } + template + constexpr bool has3D(...) { + return false; + } - template + template class ParamBin { public: - ParamBin(){} - virtual ~ParamBin(){} - virtual bool pass(const InputType&)const=0; - virtual float operator()(const InputType&)const=0; + ParamBin() {} + virtual ~ParamBin() {} + virtual bool pass(const InputType&) const = 0; + virtual float operator()(const InputType&) const = 0; + protected: //the FUNCTYPE:=funcExpr is designed for future extensions - static std::pair readFuncStr(const std::string& inStr){ - size_t pos=inStr.find(":="); - if(pos!=std::string::npos) return std::make_pair(inStr.substr(0,pos),inStr.substr(pos+2)); - else return std::make_pair(inStr,std::string("")); + static std::pair readFuncStr(const std::string& inStr) { + size_t pos = inStr.find(":="); + if (pos != std::string::npos) + return std::make_pair(inStr.substr(0, pos), inStr.substr(pos + 2)); + else + return std::make_pair(inStr, std::string("")); } - template - static std::function makeFunc(const edm::ParameterSet& config){ + template + static std::function makeFunc(const edm::ParameterSet& config) { auto funcType = readFuncStr(config.getParameter("funcType")); - auto funcParams = config.getParameter >("funcParams"); - if(funcType.first=="TF1" && has1D(0)) return TF1Wrap(0)>(funcType.second,funcParams); - else if(funcType.first=="TF2" && has2D(0)) return TF2Wrap(0)>(funcType.second,funcParams); - else if(funcType.first=="TF3" && has3D(0)) return TF3Wrap(0)>(funcType.second,funcParams); - else throw cms::Exception("InvalidConfig") << " type "<>("funcParams"); + if (funcType.first == "TF1" && has1D(0)) + return TF1Wrap(0)>(funcType.second, funcParams); + else if (funcType.first == "TF2" && has2D(0)) + return TF2Wrap(0)>(funcType.second, funcParams); + else if (funcType.first == "TF3" && has3D(0)) + return TF3Wrap(0)>(funcType.second, funcParams); + else + throw cms::Exception("InvalidConfig") << " type " << funcType.first + << " is not recognised or is imcompatable with the ParamType, " + "configuration is invalid and needs to be fixed" + << std::endl; } }; - template + template class ParamBin1D : public ParamBin { private: using XType = decltype(ParamType::x); - XType xMin_,xMax_; + XType xMin_, xMax_; std::function func_; - public: - ParamBin1D(const edm::ParameterSet& config): - xMin_(config.getParameter::type >("xMin")), - xMax_(config.getParameter::type >("xMax")), - func_(ParamBin::template makeFunc(config)) - { - } - bool pass(const InputType& input)const override { - return ParamType(input).pass(xMin_,xMax_); - } - float operator()(const InputType& input)const override{ - if(!pass(input)) return 0; - else return func_(ParamType(input)); + + public: + ParamBin1D(const edm::ParameterSet& config) + : xMin_(config.getParameter::type>("xMin")), + xMax_(config.getParameter::type>("xMax")), + func_(ParamBin::template makeFunc(config)) {} + bool pass(const InputType& input) const override { return ParamType(input).pass(xMin_, xMax_); } + float operator()(const InputType& input) const override { + if (!pass(input)) + return 0; + else + return func_(ParamType(input)); } }; - - - - template + + template class ParamBin2D : public ParamBin { private: using XType = decltype(ParamType::x); using YType = decltype(ParamType::y); - XType xMin_,xMax_; - YType yMin_,yMax_; + XType xMin_, xMax_; + YType yMin_, yMax_; std::function func_; + public: - ParamBin2D(const edm::ParameterSet& config): - xMin_(config.getParameter::type >("xMin")), - xMax_(config.getParameter::type >("xMax")), - yMin_(config.getParameter::type >("yMin")), - yMax_(config.getParameter::type >("yMax")), - func_(ParamBin::template makeFunc(config)) - { - } + ParamBin2D(const edm::ParameterSet& config) + : xMin_(config.getParameter::type>("xMin")), + xMax_(config.getParameter::type>("xMax")), + yMin_(config.getParameter::type>("yMin")), + yMax_(config.getParameter::type>("yMax")), + func_(ParamBin::template makeFunc(config)) {} - bool pass(const InputType& input)const override { - return ParamType(input).pass(xMin_,xMax_,yMin_,yMax_); - } - float operator()(const InputType& input)const override{ - if(!pass(input)) return 0; - else return func_(ParamType(input)); + bool pass(const InputType& input) const override { return ParamType(input).pass(xMin_, xMax_, yMin_, yMax_); } + float operator()(const InputType& input) const override { + if (!pass(input)) + return 0; + else + return func_(ParamType(input)); } }; - - template + template class ParamBin3D : public ParamBin { using XType = decltype(ParamType::x); using YType = decltype(ParamType::y); using ZType = decltype(ParamType::z); - XType xMin_,xMax_; - YType yMin_,yMax_; - ZType zMin_,zMax_; + XType xMin_, xMax_; + YType yMin_, yMax_; + ZType zMin_, zMax_; std::function func_; + public: - ParamBin3D(const edm::ParameterSet& config): - xMin_(config.getParameter::type >("xMin")), - xMax_(config.getParameter::type >("xMax")), - yMin_(config.getParameter::type >("yMin")), - yMax_(config.getParameter::type >("yMax")), - zMin_(config.getParameter::type >("zMin")), - zMax_(config.getParameter::type >("zMax")), - func_(ParamBin::template makeFunc(config)) - { - } + ParamBin3D(const edm::ParameterSet& config) + : xMin_(config.getParameter::type>("xMin")), + xMax_(config.getParameter::type>("xMax")), + yMin_(config.getParameter::type>("yMin")), + yMax_(config.getParameter::type>("yMax")), + zMin_(config.getParameter::type>("zMin")), + zMax_(config.getParameter::type>("zMax")), + func_(ParamBin::template makeFunc(config)) {} - bool pass(const InputType& input)const override { - return ParamType(input).pass(xMin_,xMax_,yMin_,yMax_,zMin_,zMax_); - } - float operator()(const InputType& input)const override{ - if(!pass(input)) return 0; - else return func_(ParamType(input)); + bool pass(const InputType& input) const override { + return ParamType(input).pass(xMin_, xMax_, yMin_, yMax_, zMin_, zMax_); + } + float operator()(const InputType& input) const override { + if (!pass(input)) + return 0; + else + return func_(ParamType(input)); } }; - - - - template + template class Param { - std::vector > > bins_; + std::vector>> bins_; + public: - Param(const edm::ParameterSet& config){ - std::vector binConfigs = config.getParameter >("bins"); - for(auto& binConfig : binConfigs) bins_.emplace_back(createParamBin_(binConfig)); + Param(const edm::ParameterSet& config) { + std::vector binConfigs = config.getParameter>("bins"); + for (auto& binConfig : binConfigs) + bins_.emplace_back(createParamBin_(binConfig)); } - float operator()(const InputType& input)const{ - for(auto& bin : bins_){ - if(bin->pass(input)) return (*bin)(input); + float operator()(const InputType& input) const { + for (auto& bin : bins_) { + if (bin->pass(input)) + return (*bin)(input); } - return -1; //didnt find a suitable bin, just return -1 for now - } - + return -1; //didnt find a suitable bin, just return -1 for now + } + private: - std::unique_ptr > createParamBin_(const edm::ParameterSet& config){ + std::unique_ptr> createParamBin_(const edm::ParameterSet& config) { std::string type = config.getParameter("binType"); - if(type=="AbsEtaClus") return std::make_unique>(config); - else if(type=="AbsEtaClusPhi") return std::make_unique>(config); - else if(type=="AbsEtaClusEt") return std::make_unique>(config); - else throw cms::Exception("InvalidConfig") << " type "<>(config); + else if (type == "AbsEtaClusPhi") + return std::make_unique>(config); + else if (type == "AbsEtaClusEt") + return std::make_unique>(config); + else + throw cms::Exception("InvalidConfig") + << " type " << type << " is not recognised, configuration is invalid and needs to be fixed" << std::endl; } }; -} +} // namespace egPM diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h index c55dc5d147aa7..6f9249362e81f 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTR9IDProducer -// +// /**\class EgammaHLTR9IDProducer EgammaHLTR9IDProducer.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h */ // @@ -13,7 +13,6 @@ // // - // system include files #include @@ -39,15 +38,14 @@ class EgammaHLTR9IDProducer : public edm::global::EDProducer<> { public: explicit EgammaHLTR9IDProducer(const edm::ParameterSet&); ~EgammaHLTR9IDProducer() override; - + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; private: // ----------member data --------------------------- - + const edm::EDGetTokenT recoEcalCandidateProducer_; const edm::EDGetTokenT ecalRechitEBToken_; const edm::EDGetTokenT ecalRechitEEToken_; }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9Producer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9Producer.h index b177c4a72dacb..da22496a2266a 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9Producer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9Producer.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTR9Producer -// +// /**\class EgammaHLTR9Producer EgammaHLTR9Producer.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9Producer.h */ // @@ -12,7 +12,6 @@ // // - // system include files #include @@ -41,17 +40,16 @@ class EgammaHLTR9Producer : public edm::global::EDProducer<> { public: explicit EgammaHLTR9Producer(const edm::ParameterSet&); ~EgammaHLTR9Producer() override; - + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; private: - // ----------member data --------------------------- + // ----------member data --------------------------- const edm::EDGetTokenT recoEcalCandidateProducer_; const edm::EDGetTokenT ecalRechitEBToken_; const edm::EDGetTokenT ecalRechitEEToken_; - + const bool useSwissCross_; }; - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRecoEcalCandidateProducers.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRecoEcalCandidateProducers.h index 641cbf69a57dc..e978457602680 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRecoEcalCandidateProducers.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRecoEcalCandidateProducers.h @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTRecoEcalCandidateProducers -// +// /**\class EgammaHLTRecoEcalCandidateProducers.h EgammaHLTRecoEcalCandidateProducers.cc RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRecoEcalCandidateProducers.h.h */ // @@ -26,19 +26,15 @@ namespace edm { } class EgammaHLTRecoEcalCandidateProducers : public edm::global::EDProducer<> { - - public: - - EgammaHLTRecoEcalCandidateProducers (const edm::ParameterSet& ps); +public: + EgammaHLTRecoEcalCandidateProducers(const edm::ParameterSet& ps); ~EgammaHLTRecoEcalCandidateProducers() override; void produce(edm::StreamID sid, edm::Event& evt, const edm::EventSetup& es) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: +private: const edm::EDGetTokenT scHybridBarrelProducer_; const edm::EDGetTokenT scIslandEndcapProducer_; const std::string recoEcalCandidateCollection_; }; - - diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRegionalPixelSeedGeneratorProducers.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRegionalPixelSeedGeneratorProducers.h index 87200bb086187..e777251b84e84 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRegionalPixelSeedGeneratorProducers.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRegionalPixelSeedGeneratorProducers.h @@ -4,11 +4,10 @@ // // Package: RecoEgamma/EgammaHLTProducers // Class: EgammaHLTRegionalPixelSeedGeneratorProducers -// +// // Description: Calls RoadSeachSeedFinderAlgorithm // to find TrajectorySeeds. - #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "DataFormats/Common/interface/Handle.h" @@ -28,10 +27,8 @@ namespace edm { class ConfigurationDescriptions; } -class EgammaHLTRegionalPixelSeedGeneratorProducers : public edm::stream::EDProducer<> -{ - public: - +class EgammaHLTRegionalPixelSeedGeneratorProducers : public edm::stream::EDProducer<> { +public: explicit EgammaHLTRegionalPixelSeedGeneratorProducers(const edm::ParameterSet& conf); ~EgammaHLTRegionalPixelSeedGeneratorProducers() override; @@ -39,7 +36,7 @@ class EgammaHLTRegionalPixelSeedGeneratorProducers : public edm::stream::EDProdu void produce(edm::Event& e, const edm::EventSetup& c) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: +private: std::unique_ptr combinatorialSeedGenerator; double ptmin_; double vertexz_; @@ -54,7 +51,6 @@ class EgammaHLTRegionalPixelSeedGeneratorProducers : public edm::stream::EDProdu edm::EDGetTokenT BSProducer_; bool useZvertex_; - }; #endif diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRemoveDuplicatedSC.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRemoveDuplicatedSC.h index 15705b0c40248..91a32975a26aa 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRemoveDuplicatedSC.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRemoveDuplicatedSC.h @@ -5,7 +5,7 @@ // // Package: EgammaHLTRemoveDuplicatedSC // Class: EgammaHLTRemoveDuplicatedSC -// +// // Description: Remove from the L1NonIso SCs those SCs that are already // there in the L1Iso SCs. // @@ -29,19 +29,17 @@ namespace edm { } class EgammaHLTRemoveDuplicatedSC : public edm::global::EDProducer<> { - - public: +public: explicit EgammaHLTRemoveDuplicatedSC(const edm::ParameterSet&); ~EgammaHLTRemoveDuplicatedSC() override; void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: +private: // vars to get products edm::EDGetTokenT sCInputProducer_; edm::EDGetTokenT alreadyExistingSC_; - + std::string outputCollection_; - }; #endif diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTTimeCleanedRechitProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTTimeCleanedRechitProducer.h index 5cd3b9782f697..1ba3c142e495a 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTTimeCleanedRechitProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTTimeCleanedRechitProducer.h @@ -13,16 +13,14 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" class EgammaHLTTimeCleanedRechitProducer : public edm::global::EDProducer<> { - - public: - +public: EgammaHLTTimeCleanedRechitProducer(const edm::ParameterSet& ps); ~EgammaHLTTimeCleanedRechitProducer() override; void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: +private: double timeMax_; double timeMin_; std::vector hitLabels; @@ -31,7 +29,4 @@ class EgammaHLTTimeCleanedRechitProducer : public edm::global::EDProducer<> { std::vector> uncalibHitTokens; }; - #endif - - diff --git a/RecoEgamma/EgammaHLTProducers/interface/HLTCaloObjInRegionsProducer.h b/RecoEgamma/EgammaHLTProducers/interface/HLTCaloObjInRegionsProducer.h index 7f177fc0d1abe..489cc8d44d656 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/HLTCaloObjInRegionsProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/HLTCaloObjInRegionsProducer.h @@ -46,35 +46,35 @@ //this is a struct which contains all the eta/phi regions //from which to filter the calo objs -class EtaPhiRegion{ +class EtaPhiRegion { private: - float centreEta_; - float centrePhi_; - float maxDeltaR2_; - float maxDEta_; - float maxDPhi_; - public: - EtaPhiRegion(float iEta,float iPhi,float iDR,float iDEta,float iDPhi): - centreEta_(iEta),centrePhi_(iPhi),maxDeltaR2_(iDR*iDR), - maxDEta_(iDEta),maxDPhi_(iDPhi){} - ~EtaPhiRegion(){} - bool operator()(float eta,float phi)const{ - return reco::deltaR2(eta,phi,centreEta_,centrePhi_)&)const=0; + virtual void getEtaPhiRegions(const edm::Event&, std::vector&) const = 0; }; - //this class stores the tokens to access the objects around which we wish to filter //it makes a vector of EtaPhiRegions which are then used to filter the CaloObjs -template class EtaPhiRegionData : public EtaPhiRegionDataBase{ +template +class EtaPhiRegionData : public EtaPhiRegionDataBase { private: float minEt_; float maxEt_; @@ -82,45 +82,51 @@ template class EtaPhiRegionData : public EtaPhiRegionDataBase{ float maxDEta_; float maxDPhi_; edm::EDGetTokenT token_; + public: - EtaPhiRegionData(const edm::ParameterSet& para,edm::ConsumesCollector & consumesColl): - minEt_(para.getParameter("minEt")), - maxEt_(para.getParameter("maxEt")), - maxDeltaR_(para.getParameter("maxDeltaR")), - maxDEta_(para.getParameter("maxDEta")), - maxDPhi_(para.getParameter("maxDPhi")), - token_(consumesColl.consumes(para.getParameter("inputColl"))){} - - void getEtaPhiRegions(const edm::Event&,std::vector&)const override; - templatestatic typename T2::const_iterator beginIt(const T2& coll){return coll.begin();} - templatestatic typename T2::const_iterator endIt(const T2& coll){return coll.end();} - templatestatic typename BXVector::const_iterator beginIt(const BXVector& coll){return coll.begin(0);} - templatestatic typename BXVector::const_iterator endIt(const BXVector& coll){return coll.end(0);} - + EtaPhiRegionData(const edm::ParameterSet& para, edm::ConsumesCollector& consumesColl) + : minEt_(para.getParameter("minEt")), + maxEt_(para.getParameter("maxEt")), + maxDeltaR_(para.getParameter("maxDeltaR")), + maxDEta_(para.getParameter("maxDEta")), + maxDPhi_(para.getParameter("maxDPhi")), + token_(consumesColl.consumes(para.getParameter("inputColl"))) {} + + void getEtaPhiRegions(const edm::Event&, std::vector&) const override; + template + static typename T2::const_iterator beginIt(const T2& coll) { + return coll.begin(); + } + template + static typename T2::const_iterator endIt(const T2& coll) { + return coll.end(); + } + template + static typename BXVector::const_iterator beginIt(const BXVector& coll) { + return coll.begin(0); + } + template + static typename BXVector::const_iterator endIt(const BXVector& coll) { + return coll.end(0); + } }; - -template > +template > class HLTCaloObjInRegionsProducer : public edm::stream::EDProducer<> { - - - public: - - - +public: HLTCaloObjInRegionsProducer(const edm::ParameterSet& ps); - ~HLTCaloObjInRegionsProducer() override{} + ~HLTCaloObjInRegionsProducer() override {} void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - EtaPhiRegionDataBase* createEtaPhiRegionData(const std::string&,const edm::ParameterSet&,edm::ConsumesCollector &&); //calling function owns this - static std::unique_ptr - makeFilteredColl(const edm::Handle& inputColl, - const edm::ESHandle& caloGeomHandle, - const std::vector& regions); +private: + EtaPhiRegionDataBase* createEtaPhiRegionData(const std::string&, + const edm::ParameterSet&, + edm::ConsumesCollector&&); //calling function owns this + static std::unique_ptr makeFilteredColl(const edm::Handle& inputColl, + const edm::ESHandle& caloGeomHandle, + const std::vector& regions); static bool validIDForGeom(const DetId& id); std::vector outputProductNames_; std::vector inputCollTags_; @@ -128,30 +134,34 @@ class HLTCaloObjInRegionsProducer : public edm::stream::EDProducer<> { std::vector> etaPhiRegionData_; }; - -template -HLTCaloObjInRegionsProducer::HLTCaloObjInRegionsProducer(const edm::ParameterSet& para) -{ - const std::vector etaPhiRegions = para.getParameter>("etaPhiRegions"); - for(auto& pset : etaPhiRegions){ - const std::string type=pset.getParameter("type"); - etaPhiRegionData_.emplace_back(createEtaPhiRegionData(type,pset,consumesCollector())); //meh I was going to use a factory but it was going to be overly complex for my needs +template +HLTCaloObjInRegionsProducer::HLTCaloObjInRegionsProducer(const edm::ParameterSet& para) { + const std::vector etaPhiRegions = + para.getParameter>("etaPhiRegions"); + for (auto& pset : etaPhiRegions) { + const std::string type = pset.getParameter("type"); + etaPhiRegionData_.emplace_back(createEtaPhiRegionData( + type, + pset, + consumesCollector())); //meh I was going to use a factory but it was going to be overly complex for my needs } - outputProductNames_=para.getParameter>("outputProductNames"); - inputCollTags_=para.getParameter>("inputCollTags"); - if(outputProductNames_.size()!=inputCollTags_.size()){ - throw cms::Exception("InvalidConfiguration") <<" error outputProductNames and inputCollTags must be the same size, they are "<>("outputProductNames"); + inputCollTags_ = para.getParameter>("inputCollTags"); + if (outputProductNames_.size() != inputCollTags_.size()) { + throw cms::Exception("InvalidConfiguration") + << " error outputProductNames and inputCollTags must be the same size, they are " << outputProductNames_.size() + << " vs " << inputCollTags_.size(); } - for (unsigned int collNr=0; collNr(inputCollTags_[collNr])); - produces (outputProductNames_[collNr]); + produces(outputProductNames_[collNr]); } } -template -void HLTCaloObjInRegionsProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) -{ +template +void HLTCaloObjInRegionsProducer::fillDescriptions( + edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; std::vector outputProductNames; outputProductNames.push_back("EcalRegionalRecHitsEB"); @@ -160,17 +170,17 @@ void HLTCaloObjInRegionsProducer::fillDescriptions( inputColls.push_back(edm::InputTag("hltHcalDigis")); desc.add>("inputCollTags", inputColls); std::vector etaPhiRegions; - + edm::ParameterSet ecalCandPSet; - ecalCandPSet.addParameter("type","RecoEcalCandidate"); - ecalCandPSet.addParameter("minEt",-1); - ecalCandPSet.addParameter("maxEt",-1); - ecalCandPSet.addParameter("maxDeltaR",0.5); - ecalCandPSet.addParameter("maxDEta",0.); - ecalCandPSet.addParameter("maxDPhi",0.); - ecalCandPSet.addParameter("inputColl",edm::InputTag("hltEgammaCandidates")); + ecalCandPSet.addParameter("type", "RecoEcalCandidate"); + ecalCandPSet.addParameter("minEt", -1); + ecalCandPSet.addParameter("maxEt", -1); + ecalCandPSet.addParameter("maxDeltaR", 0.5); + ecalCandPSet.addParameter("maxDEta", 0.); + ecalCandPSet.addParameter("maxDPhi", 0.); + ecalCandPSet.addParameter("inputColl", edm::InputTag("hltEgammaCandidates")); etaPhiRegions.push_back(ecalCandPSet); - + edm::ParameterSetDescription etaPhiRegionDesc; etaPhiRegionDesc.add("type"); etaPhiRegionDesc.add("minEt"); @@ -179,144 +189,133 @@ void HLTCaloObjInRegionsProducer::fillDescriptions( etaPhiRegionDesc.add("maxDEta"); etaPhiRegionDesc.add("maxDPhi"); etaPhiRegionDesc.add("inputColl"); - desc.addVPSet("etaPhiRegions",etaPhiRegionDesc,etaPhiRegions); - - descriptions.add(defaultModuleLabel>(), desc); -} - + desc.addVPSet("etaPhiRegions", etaPhiRegionDesc, etaPhiRegions); -template -void HLTCaloObjInRegionsProducer::produce(edm::Event& event, const edm::EventSetup& setup) { + descriptions.add(defaultModuleLabel>(), desc); +} +template +void HLTCaloObjInRegionsProducer::produce(edm::Event& event, + const edm::EventSetup& setup) { // get the collection geometry: edm::ESHandle caloGeomHandle; setup.get().get(caloGeomHandle); - + std::vector regions; - std::for_each(etaPhiRegionData_.begin(),etaPhiRegionData_.end(), - [&event,®ions](const std::unique_ptr& input) - {input->getEtaPhiRegions(event,regions);} - ); - - for(size_t inputCollNr=0;inputCollNr& input) { + input->getEtaPhiRegions(event, regions); + }); + + for (size_t inputCollNr = 0; inputCollNr < inputTokens_.size(); inputCollNr++) { edm::Handle inputColl; - event.getByToken(inputTokens_[inputCollNr],inputColl); - + event.getByToken(inputTokens_[inputCollNr], inputColl); + if (!(inputColl.isValid())) { - edm::LogError("ProductNotFound")<< "could not get a handle on the "< -std::unique_ptr -HLTCaloObjInRegionsProducer:: -makeFilteredColl(const edm::Handle& inputColl, - const edm::ESHandle& caloGeomHandle, - const std::vector& regions) -{ - +template +std::unique_ptr HLTCaloObjInRegionsProducer::makeFilteredColl( + const edm::Handle& inputColl, + const edm::ESHandle& caloGeomHandle, + const std::vector& regions) { auto outputColl = std::make_unique(); - if(!inputColl->empty()){ - const CaloSubdetectorGeometry* subDetGeom=caloGeomHandle->getSubdetectorGeometry(inputColl->begin()->id()); - if(!regions.empty()){ - for(const CaloObjType& obj : *inputColl){ - auto objGeom = subDetGeom->getGeometry(obj.id()); - if(objGeom==nullptr){ - //wondering what to do here - //something is very very wrong - //given HLT should never crash or throw, decided to log an error - //update: so turns out HCAL can pass through calibration channels in QIE11 so for that module, its an expected behaviour - //so we check if the ID is valid - if(validIDForGeom(obj.id())) { - edm::LogError("HLTCaloObjInRegionsProducer") << "for an object of type "<begin()->id()).rawId()<<" in HLTCaloObjsInRegion, this shouldnt be possible and something has gone wrong, auto accepting hit"; - } - outputColl->push_back(obj); - continue; - } - float eta = objGeom->getPosition().eta(); - float phi = objGeom->getPosition().phi(); - - for(const auto& region : regions){ - if(region(eta,phi)) { - outputColl->push_back(obj); - break; - } - } + if (!inputColl->empty()) { + const CaloSubdetectorGeometry* subDetGeom = caloGeomHandle->getSubdetectorGeometry(inputColl->begin()->id()); + if (!regions.empty()) { + for (const CaloObjType& obj : *inputColl) { + auto objGeom = subDetGeom->getGeometry(obj.id()); + if (objGeom == nullptr) { + //wondering what to do here + //something is very very wrong + //given HLT should never crash or throw, decided to log an error + //update: so turns out HCAL can pass through calibration channels in QIE11 so for that module, its an expected behaviour + //so we check if the ID is valid + if (validIDForGeom(obj.id())) { + edm::LogError("HLTCaloObjInRegionsProducer") + << "for an object of type " << typeid(CaloObjType).name() << " the geometry returned null for id " + << DetId(obj.id()).rawId() << " with initial ID " << DetId(inputColl->begin()->id()).rawId() + << " in HLTCaloObjsInRegion, this shouldnt be possible and something has gone wrong, auto accepting " + "hit"; + } + outputColl->push_back(obj); + continue; + } + float eta = objGeom->getPosition().eta(); + float phi = objGeom->getPosition().phi(); + + for (const auto& region : regions) { + if (region(eta, phi)) { + outputColl->push_back(obj); + break; + } + } } - }//end check of empty regions - }//end check of empty rec-hits + } //end check of empty regions + } //end check of empty rec-hits return outputColl; - } //tells us if an ID should have a valid geometry //it assumes that all IDs do except those specifically mentioned -//HCAL for example have laser calibs in the digi collection so +//HCAL for example have laser calibs in the digi collection so //so we have to ensure that HCAL is HB,HE or HO -template -bool HLTCaloObjInRegionsProducer:: -validIDForGeom(const DetId& id) -{ - if(id.det()==DetId::Hcal){ - if(id.subdetId() == HcalSubdetector::HcalEmpty || - id.subdetId() == HcalSubdetector::HcalOther){ +template +bool HLTCaloObjInRegionsProducer::validIDForGeom(const DetId& id) { + if (id.det() == DetId::Hcal) { + if (id.subdetId() == HcalSubdetector::HcalEmpty || id.subdetId() == HcalSubdetector::HcalOther) { return false; } } return true; } - - - -template -EtaPhiRegionDataBase* -HLTCaloObjInRegionsProducer:: -createEtaPhiRegionData(const std::string& type,const edm::ParameterSet& para, - edm::ConsumesCollector && consumesColl) -{ - if(type=="L1EGamma"){ - return new EtaPhiRegionData(para,consumesColl); - }else if(type=="L1Jet"){ - return new EtaPhiRegionData(para,consumesColl); - }else if(type=="L1Muon"){ - return new EtaPhiRegionData(para,consumesColl); - }else if(type=="L1Tau"){ - return new EtaPhiRegionData(para,consumesColl); - }else if(type=="RecoEcalCandidate"){ - return new EtaPhiRegionData(para,consumesColl); - }else if(type=="RecoChargedCandidate"){ - return new EtaPhiRegionData(para,consumesColl); - }else if(type=="Electron"){ - return new EtaPhiRegionData(para,consumesColl); - }else{ +template +EtaPhiRegionDataBase* HLTCaloObjInRegionsProducer::createEtaPhiRegionData( + const std::string& type, const edm::ParameterSet& para, edm::ConsumesCollector&& consumesColl) { + if (type == "L1EGamma") { + return new EtaPhiRegionData(para, consumesColl); + } else if (type == "L1Jet") { + return new EtaPhiRegionData(para, consumesColl); + } else if (type == "L1Muon") { + return new EtaPhiRegionData(para, consumesColl); + } else if (type == "L1Tau") { + return new EtaPhiRegionData(para, consumesColl); + } else if (type == "RecoEcalCandidate") { + return new EtaPhiRegionData(para, consumesColl); + } else if (type == "RecoChargedCandidate") { + return new EtaPhiRegionData(para, consumesColl); + } else if (type == "Electron") { + return new EtaPhiRegionData(para, consumesColl); + } else { //this is a major issue and could lead to rather subtle efficiency losses, so if its incorrectly configured, we're aborting the job! - throw cms::Exception("InvalidConfig") << " type "< -void EtaPhiRegionData::getEtaPhiRegions(const edm::Event& event,std::vector®ions)const -{ +template +void EtaPhiRegionData::getEtaPhiRegions(const edm::Event& event, + std::vector& regions) const { edm::Handle cands; - event.getByToken(token_,cands); - - for(auto candIt = beginIt(*cands);candIt!=endIt(*cands);++candIt){ - if(candIt->et() >= minEt_ && (maxEt_<0 || candIt->et() < maxEt_)){ - regions.push_back(EtaPhiRegion(candIt->eta(),candIt->phi(), - maxDeltaR_,maxDEta_,maxDPhi_)); + event.getByToken(token_, cands); + + for (auto candIt = beginIt(*cands); candIt != endIt(*cands); ++candIt) { + if (candIt->et() >= minEt_ && (maxEt_ < 0 || candIt->et() < maxEt_)) { + regions.push_back(EtaPhiRegion(candIt->eta(), candIt->phi(), maxDeltaR_, maxDEta_, maxDPhi_)); } - } } - - #endif - - diff --git a/RecoEgamma/EgammaHLTProducers/interface/HLTEcalPFClusterIsolationProducer.h b/RecoEgamma/EgammaHLTProducers/interface/HLTEcalPFClusterIsolationProducer.h index b1ba54d89f164..7aeec75ca45f1 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/HLTEcalPFClusterIsolationProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/HLTEcalPFClusterIsolationProducer.h @@ -24,28 +24,26 @@ namespace edm { class ConfigurationDescriptions; } -template +template class HLTEcalPFClusterIsolationProducer : public edm::stream::EDProducer<> { - typedef std::vector T1Collection; typedef edm::Ref T1Ref; - typedef edm::AssociationMap, float > > T1IsolationMap; - - public: + typedef edm::AssociationMap, float> > T1IsolationMap; + +public: explicit HLTEcalPFClusterIsolationProducer(const edm::ParameterSet&); - ~HLTEcalPFClusterIsolationProducer() override; - + ~HLTEcalPFClusterIsolationProducer() override; + void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - private: +private: bool computedRVeto(T1Ref candRef, reco::PFClusterRef pfclu); - + edm::EDGetTokenT recoCandidateProducer_; const edm::EDGetTokenT pfClusterProducer_; const edm::EDGetTokenT rhoProducer_; - + double drVeto2_; const double drMax_; const double drVetoBarrel_; @@ -60,7 +58,6 @@ class HLTEcalPFClusterIsolationProducer : public edm::stream::EDProducer<> { const double rhoScale_; const std::vector effectiveAreas_; const std::vector absEtaLowEdges_; - }; #endif diff --git a/RecoEgamma/EgammaHLTProducers/interface/HLTHcalPFClusterIsolationProducer.h b/RecoEgamma/EgammaHLTProducers/interface/HLTHcalPFClusterIsolationProducer.h index 60efbb4a5b9c4..5d7f4fc4955ec 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/HLTHcalPFClusterIsolationProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/HLTHcalPFClusterIsolationProducer.h @@ -20,34 +20,31 @@ #include "DataFormats/ParticleFlowReco/interface/PFCluster.h" #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" - namespace edm { class ConfigurationDescriptions; } -template +template class HLTHcalPFClusterIsolationProducer : public edm::global::EDProducer<> { - typedef std::vector T1Collection; typedef edm::Ref T1Ref; - typedef edm::AssociationMap, float > > T1IsolationMap; + typedef edm::AssociationMap, float> > T1IsolationMap; - public: +public: explicit HLTHcalPFClusterIsolationProducer(const edm::ParameterSet&); - ~HLTHcalPFClusterIsolationProducer() override; - + ~HLTHcalPFClusterIsolationProducer() override; + void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - private: +private: edm::EDGetTokenT recoCandidateProducer_; const edm::EDGetTokenT pfClusterProducerHCAL_; const edm::EDGetTokenT rhoProducer_; const edm::EDGetTokenT pfClusterProducerHFEM_; const edm::EDGetTokenT pfClusterProducerHFHAD_; - const bool useHF_; + const bool useHF_; const double drMax_; const double drVetoBarrel_; diff --git a/RecoEgamma/EgammaHLTProducers/interface/HLTRecHitInAllL1RegionsProducer.h b/RecoEgamma/EgammaHLTProducers/interface/HLTRecHitInAllL1RegionsProducer.h index 0fb3d7c458682..6aa1293edd05d 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/HLTRecHitInAllL1RegionsProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/HLTRecHitInAllL1RegionsProducer.h @@ -27,7 +27,7 @@ // Level 1 Trigger #include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h" #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h" -#include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h" +#include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h" #include "DataFormats/L1Trigger/interface/L1EmParticle.h" #include "DataFormats/L1Trigger/interface/L1JetParticle.h" #include "DataFormats/L1Trigger/interface/L1MuonParticle.h" @@ -51,82 +51,93 @@ //think the only difference now is that it wont throw if its not ECALBarrel, ECALEndcap or ECAL PS rec-hit type class L1RegionDataBase { public: - virtual ~L1RegionDataBase(){} - virtual void getEtaPhiRegions(const edm::Event&,std::vector&,const L1CaloGeometry&)const=0; -}; + virtual ~L1RegionDataBase() {} + virtual void getEtaPhiRegions(const edm::Event&, + std::vector&, + const L1CaloGeometry&) const = 0; +}; -template class L1RegionData : public L1RegionDataBase { +template +class L1RegionData : public L1RegionDataBase { private: double minEt_; double maxEt_; double regionEtaMargin_; double regionPhiMargin_; edm::EDGetTokenT token_; -public: - L1RegionData(const edm::ParameterSet& para,edm::ConsumesCollector & consumesColl): - minEt_(para.getParameter("minEt")), - maxEt_(para.getParameter("maxEt")), - regionEtaMargin_(para.getParameter("regionEtaMargin")), - regionPhiMargin_(para.getParameter("regionPhiMargin")), - token_(consumesColl.consumes(para.getParameter("inputColl"))){} - - void getEtaPhiRegions(const edm::Event&,std::vector&,const L1CaloGeometry&)const override; - templatestatic typename T2::const_iterator beginIt(const T2& coll){return coll.begin();} - templatestatic typename T2::const_iterator endIt(const T2& coll){return coll.end();} - templatestatic typename BXVector::const_iterator beginIt(const BXVector& coll){return coll.begin(0);} - templatestatic typename BXVector::const_iterator endIt(const BXVector& coll){return coll.end(0);} - +public: + L1RegionData(const edm::ParameterSet& para, edm::ConsumesCollector& consumesColl) + : minEt_(para.getParameter("minEt")), + maxEt_(para.getParameter("maxEt")), + regionEtaMargin_(para.getParameter("regionEtaMargin")), + regionPhiMargin_(para.getParameter("regionPhiMargin")), + token_(consumesColl.consumes(para.getParameter("inputColl"))) {} + + void getEtaPhiRegions(const edm::Event&, std::vector&, const L1CaloGeometry&) const override; + template + static typename T2::const_iterator beginIt(const T2& coll) { + return coll.begin(); + } + template + static typename T2::const_iterator endIt(const T2& coll) { + return coll.end(); + } + template + static typename BXVector::const_iterator beginIt(const BXVector& coll) { + return coll.begin(0); + } + template + static typename BXVector::const_iterator endIt(const BXVector& coll) { + return coll.end(0); + } }; - - -template +template class HLTRecHitInAllL1RegionsProducer : public edm::stream::EDProducer<> { - - using RecHitCollectionType =edm::SortedCollection; - - public: + using RecHitCollectionType = edm::SortedCollection; +public: HLTRecHitInAllL1RegionsProducer(const edm::ParameterSet& ps); - ~HLTRecHitInAllL1RegionsProducer() override{} + ~HLTRecHitInAllL1RegionsProducer() override {} void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - L1RegionDataBase* createL1RegionData(const std::string&,const edm::ParameterSet&,edm::ConsumesCollector &&); //calling function owns this - +private: + L1RegionDataBase* createL1RegionData(const std::string&, + const edm::ParameterSet&, + edm::ConsumesCollector&&); //calling function owns this + std::vector> l1RegionData_; - + std::vector recHitLabels_; std::vector productLabels_; std::vector> recHitTokens_; - - }; - -template -HLTRecHitInAllL1RegionsProducer::HLTRecHitInAllL1RegionsProducer(const edm::ParameterSet& para) -{ - const std::vector l1InputRegions = para.getParameter>("l1InputRegions"); - for(auto& pset : l1InputRegions){ - const std::string type=pset.getParameter("type"); - l1RegionData_.emplace_back(createL1RegionData(type,pset,consumesCollector())); //meh I was going to use a factory but it was going to be overly complex for my needs +template +HLTRecHitInAllL1RegionsProducer::HLTRecHitInAllL1RegionsProducer(const edm::ParameterSet& para) { + const std::vector l1InputRegions = + para.getParameter>("l1InputRegions"); + for (auto& pset : l1InputRegions) { + const std::string type = pset.getParameter("type"); + l1RegionData_.emplace_back(createL1RegionData( + type, + pset, + consumesCollector())); //meh I was going to use a factory but it was going to be overly complex for my needs } - recHitLabels_ =para.getParameter>("recHitLabels"); - productLabels_=para.getParameter>("productLabels"); + recHitLabels_ = para.getParameter>("recHitLabels"); + productLabels_ = para.getParameter>("productLabels"); - for (unsigned int collNr=0; collNr(recHitLabels_[collNr])); - produces (productLabels_[collNr]); + produces(productLabels_[collNr]); } } -template -void HLTRecHitInAllL1RegionsProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) -{ +template +void HLTRecHitInAllL1RegionsProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; std::vector productTags; productTags.push_back("EcalRegionalRecHitsEB"); @@ -138,45 +149,44 @@ void HLTRecHitInAllL1RegionsProducer::fillDescriptions(edm::Configur recHitLabels.push_back(edm::InputTag("hltESRegionalEgammaRecHit:EcalRecHitsES")); desc.add>("recHitLabels", recHitLabels); std::vector l1InputRegions; - + edm::ParameterSet emIsoPSet; - emIsoPSet.addParameter("type","L1EmParticle"); - emIsoPSet.addParameter("minEt",5); - emIsoPSet.addParameter("maxEt",999); - emIsoPSet.addParameter("regionEtaMargin",0.14); - emIsoPSet.addParameter("regionPhiMargin",0.4); - emIsoPSet.addParameter("inputColl",edm::InputTag("hltL1extraParticles:NonIsolated")); + emIsoPSet.addParameter("type", "L1EmParticle"); + emIsoPSet.addParameter("minEt", 5); + emIsoPSet.addParameter("maxEt", 999); + emIsoPSet.addParameter("regionEtaMargin", 0.14); + emIsoPSet.addParameter("regionPhiMargin", 0.4); + emIsoPSet.addParameter("inputColl", edm::InputTag("hltL1extraParticles:NonIsolated")); l1InputRegions.push_back(emIsoPSet); edm::ParameterSet emNonIsoPSet; - emNonIsoPSet.addParameter("type","L1EmParticle"); - emNonIsoPSet.addParameter("minEt",5); - emNonIsoPSet.addParameter("maxEt",999); - emNonIsoPSet.addParameter("regionEtaMargin",0.14); - emNonIsoPSet.addParameter("regionPhiMargin",0.4); - emNonIsoPSet.addParameter("inputColl",edm::InputTag("hltL1extraParticles:Isolated")); + emNonIsoPSet.addParameter("type", "L1EmParticle"); + emNonIsoPSet.addParameter("minEt", 5); + emNonIsoPSet.addParameter("maxEt", 999); + emNonIsoPSet.addParameter("regionEtaMargin", 0.14); + emNonIsoPSet.addParameter("regionPhiMargin", 0.4); + emNonIsoPSet.addParameter("inputColl", edm::InputTag("hltL1extraParticles:Isolated")); l1InputRegions.push_back(emNonIsoPSet); - - // Why no Central Jets here? They are present in the python config, e.g. OnLine_HLT_GRun.py + + // Why no Central Jets here? They are present in the python config, e.g. OnLine_HLT_GRun.py // SHarper: because these are the default parameters designed to reproduce the original (no jets) behaviour // edm::ParameterSet egPSet; - egPSet.addParameter("type","EGamma"); - egPSet.addParameter("minEt",5); - egPSet.addParameter("maxEt",999); - egPSet.addParameter("regionEtaMargin",0.4); - egPSet.addParameter("regionPhiMargin",0.5); - egPSet.addParameter("inputColl",edm::InputTag("hltCaloStage2Digis")); + egPSet.addParameter("type", "EGamma"); + egPSet.addParameter("minEt", 5); + egPSet.addParameter("maxEt", 999); + egPSet.addParameter("regionEtaMargin", 0.4); + egPSet.addParameter("regionPhiMargin", 0.5); + egPSet.addParameter("inputColl", edm::InputTag("hltCaloStage2Digis")); l1InputRegions.push_back(egPSet); - + edm::ParameterSet jetPSet; - jetPSet.addParameter("type","EGamma"); - jetPSet.addParameter("minEt",200); - jetPSet.addParameter("maxEt",999); - jetPSet.addParameter("regionEtaMargin",0.4); - jetPSet.addParameter("regionPhiMargin",0.5); - jetPSet.addParameter("inputColl",edm::InputTag("hltCaloStage2Digis")); + jetPSet.addParameter("type", "EGamma"); + jetPSet.addParameter("minEt", 200); + jetPSet.addParameter("maxEt", 999); + jetPSet.addParameter("regionEtaMargin", 0.4); + jetPSet.addParameter("regionPhiMargin", 0.5); + jetPSet.addParameter("inputColl", edm::InputTag("hltCaloStage2Digis")); l1InputRegions.push_back(jetPSet); - edm::ParameterSetDescription l1InputRegionDesc; l1InputRegionDesc.add("type"); @@ -185,176 +195,166 @@ void HLTRecHitInAllL1RegionsProducer::fillDescriptions(edm::Configur l1InputRegionDesc.add("regionEtaMargin"); l1InputRegionDesc.add("regionPhiMargin"); l1InputRegionDesc.add("inputColl"); - desc.addVPSet("l1InputRegions",l1InputRegionDesc,l1InputRegions); - - descriptions.add(defaultModuleLabel>(), desc); -} + desc.addVPSet("l1InputRegions", l1InputRegionDesc, l1InputRegions); + descriptions.add(defaultModuleLabel>(), desc); +} -template +template void HLTRecHitInAllL1RegionsProducer::produce(edm::Event& event, const edm::EventSetup& setup) { - // get the collection geometry: edm::ESHandle caloGeomHandle; setup.get().get(caloGeomHandle); - - // Get the CaloGeometry - edm::ESHandle l1CaloGeom ; - setup.get().get(l1CaloGeom) ; - + + // Get the CaloGeometry + edm::ESHandle l1CaloGeom; + setup.get().get(l1CaloGeom); + std::vector regions; - std::for_each(l1RegionData_.begin(),l1RegionData_.end(), - [&event,®ions,l1CaloGeom](const std::unique_ptr& input) - {input->getEtaPhiRegions(event,regions,*l1CaloGeom);} - ); - - for(size_t recHitCollNr=0;recHitCollNr& input) { + input->getEtaPhiRegions(event, regions, *l1CaloGeom); + }); + + for (size_t recHitCollNr = 0; recHitCollNr < recHitTokens_.size(); recHitCollNr++) { edm::Handle recHits; - event.getByToken(recHitTokens_[recHitCollNr],recHits); - + event.getByToken(recHitTokens_[recHitCollNr], recHits); + if (!(recHits.isValid())) { - edm::LogError("ProductNotFound")<< "could not get a handle on the "<(); - - if(!recHits->empty()){ - const CaloSubdetectorGeometry* subDetGeom=caloGeomHandle->getSubdetectorGeometry(recHits->front().id()); - if(!regions.empty()){ - - for(const RecHitType& recHit : *recHits){ - auto this_cell = subDetGeom->getGeometry(recHit.id()); - for(const auto& region : regions){ - if (region.inRegion(this_cell->etaPos(),this_cell->phiPos())) { - filteredRecHits->push_back(recHit); - break; - } - } - } - }//end check of empty regions - }//end check of empty rec-hits - // std::cout <<"putting fileter coll in "<size()<empty()) { + const CaloSubdetectorGeometry* subDetGeom = caloGeomHandle->getSubdetectorGeometry(recHits->front().id()); + if (!regions.empty()) { + for (const RecHitType& recHit : *recHits) { + auto this_cell = subDetGeom->getGeometry(recHit.id()); + for (const auto& region : regions) { + if (region.inRegion(this_cell->etaPos(), this_cell->phiPos())) { + filteredRecHits->push_back(recHit); + break; + } + } + } + } //end check of empty regions + } //end check of empty rec-hits + // std::cout <<"putting fileter coll in "<size()< -L1RegionDataBase* HLTRecHitInAllL1RegionsProducer::createL1RegionData(const std::string& type,const edm::ParameterSet& para,edm::ConsumesCollector && consumesColl) -{ - if(type=="L1EmParticle"){ - return new L1RegionData(para,consumesColl); - }else if(type=="L1JetParticle"){ - return new L1RegionData(para,consumesColl); - }else if(type=="L1MuonParticle"){ - return new L1RegionData(para,consumesColl); - }else if(type=="EGamma"){ - return new L1RegionData(para,consumesColl); - }else if(type=="Jet"){ - return new L1RegionData(para,consumesColl); - }else if(type=="Muon"){ - return new L1RegionData(para,consumesColl); - }else if(type=="Tau"){ - return new L1RegionData(para,consumesColl); - }else{ +template +L1RegionDataBase* HLTRecHitInAllL1RegionsProducer::createL1RegionData( + const std::string& type, const edm::ParameterSet& para, edm::ConsumesCollector&& consumesColl) { + if (type == "L1EmParticle") { + return new L1RegionData(para, consumesColl); + } else if (type == "L1JetParticle") { + return new L1RegionData(para, consumesColl); + } else if (type == "L1MuonParticle") { + return new L1RegionData(para, consumesColl); + } else if (type == "EGamma") { + return new L1RegionData(para, consumesColl); + } else if (type == "Jet") { + return new L1RegionData(para, consumesColl); + } else if (type == "Muon") { + return new L1RegionData(para, consumesColl); + } else if (type == "Tau") { + return new L1RegionData(para, consumesColl); + } else { //this is a major issue and could lead to rather subtle efficiency losses, so if its incorrectly configured, we're aborting the job! - throw cms::Exception("InvalidConfig") << " type "< -void L1RegionData::getEtaPhiRegions(const edm::Event& event,std::vector®ions,const L1CaloGeometry&)const -{ +template +void L1RegionData::getEtaPhiRegions(const edm::Event& event, + std::vector& regions, + const L1CaloGeometry&) const { edm::Handle l1Cands; - event.getByToken(token_,l1Cands); - - for(auto l1CandIt = beginIt(*l1Cands);l1CandIt!=endIt(*l1Cands);++l1CandIt){ - if(l1CandIt->et() >= minEt_ && l1CandIt->et() < maxEt_){ - + event.getByToken(token_, l1Cands); + + for (auto l1CandIt = beginIt(*l1Cands); l1CandIt != endIt(*l1Cands); ++l1CandIt) { + if (l1CandIt->et() >= minEt_ && l1CandIt->et() < maxEt_) { double etaLow = l1CandIt->eta() - regionEtaMargin_; double etaHigh = l1CandIt->eta() + regionEtaMargin_; double phiLow = l1CandIt->phi() - regionPhiMargin_; double phiHigh = l1CandIt->phi() + regionPhiMargin_; - - regions.push_back(RectangularEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh)); + + regions.push_back(RectangularEtaPhiRegion(etaLow, etaHigh, phiLow, phiHigh)); } } } -template<> -void L1RegionData::getEtaPhiRegions(const edm::Event& event,std::vector®ions,const L1CaloGeometry& l1CaloGeom)const -{ +template <> +void L1RegionData::getEtaPhiRegions(const edm::Event& event, + std::vector& regions, + const L1CaloGeometry& l1CaloGeom) const { edm::Handle l1Cands; - event.getByToken(token_,l1Cands); - - for(const auto& l1Cand : *l1Cands){ - if(l1Cand.et() >= minEt_ && l1Cand.et() < maxEt_){ - + event.getByToken(token_, l1Cands); + + for (const auto& l1Cand : *l1Cands) { + if (l1Cand.et() >= minEt_ && l1Cand.et() < maxEt_) { // Access the GCT hardware object corresponding to the L1Extra EM object. int etaIndex = l1Cand.gctJetCand()->etaIndex(); int phiIndex = l1Cand.gctJetCand()->phiIndex(); - + // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom.etaBinLowEdge(etaIndex); + double etaLow = l1CaloGeom.etaBinLowEdge(etaIndex); double etaHigh = l1CaloGeom.etaBinHighEdge(etaIndex); - double phiLow = l1CaloGeom.emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom.emJetPhiBinHighEdge( phiIndex ) ; - + double phiLow = l1CaloGeom.emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom.emJetPhiBinHighEdge(phiIndex); + etaLow -= regionEtaMargin_; etaHigh += regionEtaMargin_; phiLow -= regionPhiMargin_; phiHigh += regionPhiMargin_; - - regions.push_back(RectangularEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh)); + regions.push_back(RectangularEtaPhiRegion(etaLow, etaHigh, phiLow, phiHigh)); } } } -template<> -void L1RegionData::getEtaPhiRegions(const edm::Event& event,std::vector®ions,const L1CaloGeometry& l1CaloGeom)const -{ +template <> +void L1RegionData::getEtaPhiRegions(const edm::Event& event, + std::vector& regions, + const L1CaloGeometry& l1CaloGeom) const { edm::Handle l1Cands; - event.getByToken(token_,l1Cands); - - for(const auto& l1Cand : *l1Cands){ - if(l1Cand.et() >= minEt_ && l1Cand.et() < maxEt_){ - + event.getByToken(token_, l1Cands); + + for (const auto& l1Cand : *l1Cands) { + if (l1Cand.et() >= minEt_ && l1Cand.et() < maxEt_) { // Access the GCT hardware object corresponding to the L1Extra EM object. int etaIndex = l1Cand.gctEmCand()->etaIndex(); int phiIndex = l1Cand.gctEmCand()->phiIndex(); - + // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom.etaBinLowEdge(etaIndex); + double etaLow = l1CaloGeom.etaBinLowEdge(etaIndex); double etaHigh = l1CaloGeom.etaBinHighEdge(etaIndex); - double phiLow = l1CaloGeom.emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom.emJetPhiBinHighEdge( phiIndex ) ; - + double phiLow = l1CaloGeom.emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom.emJetPhiBinHighEdge(phiIndex); + etaLow -= regionEtaMargin_; etaHigh += regionEtaMargin_; phiLow -= regionPhiMargin_; phiHigh += regionPhiMargin_; - - regions.push_back(RectangularEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh)); + + regions.push_back(RectangularEtaPhiRegion(etaLow, etaHigh, phiLow, phiHigh)); } } } - - typedef HLTRecHitInAllL1RegionsProducer HLTEcalRecHitInAllL1RegionsProducer; DEFINE_FWK_MODULE(HLTEcalRecHitInAllL1RegionsProducer); typedef HLTRecHitInAllL1RegionsProducer HLTEcalUncalibratedRecHitInAllL1RegionsProducer; DEFINE_FWK_MODULE(HLTEcalUncalibratedRecHitInAllL1RegionsProducer); - #endif - - diff --git a/RecoEgamma/EgammaHLTProducers/interface/HLTRechitInRegionsProducer.h b/RecoEgamma/EgammaHLTProducers/interface/HLTRechitInRegionsProducer.h index 8cd2fa5c50d10..ea83499635af3 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/HLTRechitInRegionsProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/HLTRechitInRegionsProducer.h @@ -34,24 +34,21 @@ #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h" #include "CondFormats/DataRecord/interface/L1CaloGeometryRecord.h" - -template +template class HLTRechitInRegionsProducer : public edm::stream::EDProducer<> { - typedef std::vector T1Collection; - typedef typename T1::const_iterator T1iterator; - - public: - + typedef std::vector T1Collection; + typedef typename T1::const_iterator T1iterator; + +public: HLTRechitInRegionsProducer(const edm::ParameterSet& ps); ~HLTRechitInRegionsProducer() override; void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - - void getEtaPhiRegions(std::vector *, T1Collection, const L1CaloGeometry&, bool); - +private: + void getEtaPhiRegions(std::vector*, T1Collection, const L1CaloGeometry&, bool); + const bool useUncalib_; const bool doIsolated_; @@ -72,7 +69,4 @@ class HLTRechitInRegionsProducer : public edm::stream::EDProducer<> { std::vector> uncalibHitTokens; }; - #endif - - diff --git a/RecoEgamma/EgammaHLTProducers/src/ESListOfFEDSProducer.cc b/RecoEgamma/EgammaHLTProducers/src/ESListOfFEDSProducer.cc index c9dc73616f5ce..8d312fde2a59a 100644 --- a/RecoEgamma/EgammaHLTProducers/src/ESListOfFEDSProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/ESListOfFEDSProducer.cc @@ -5,15 +5,14 @@ #include "DataFormats/EcalRawData/interface/ESListOfFEDS.h" #include "DataFormats/EcalRawData/interface/EcalListOfFEDS.h" -// Ecal Mapping +// Ecal Mapping #include "Geometry/EcalMapping/interface/EcalMappingRcd.h" #include - // Level 1 Trigger #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h" #include "CondFormats/DataRecord/interface/L1CaloGeometryRecord.h" - + // EgammaCoreTools #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h" #include "DataFormats/Math/interface/RectangularEtaPhiRegion.h" @@ -29,73 +28,73 @@ using namespace l1extra; ESListOfFEDSProducer::ESListOfFEDSProducer(const edm::ParameterSet& pset) { - debug_ = pset.getUntrackedParameter("debug"); - + // Pi0ListToIgnore_ = pset.getParameter("Pi0ListToIgnore"); - EGamma_ = pset.getUntrackedParameter("EGamma",false); - Muon_ = pset.getUntrackedParameter("Muon",false); - Jets_ = pset.getUntrackedParameter("Jets",false); - + EGamma_ = pset.getUntrackedParameter("EGamma", false); + Muon_ = pset.getUntrackedParameter("Muon", false); + Jets_ = pset.getUntrackedParameter("Jets", false); + if (EGamma_ && Muon_) { - throw cms::Exception("ESListOfFEDSProducer") << - " Wrong configuration : EGamma and Muon should not be true at the same time." ; + throw cms::Exception("ESListOfFEDSProducer") + << " Wrong configuration : EGamma and Muon should not be true at the same time."; } - + if (EGamma_) { - EMl1TagIsolated_ = consumes(pset.getUntrackedParameter("EM_l1TagIsolated")); - EMl1TagNonIsolated_ = consumes(pset.getUntrackedParameter("EM_l1TagNonIsolated")); - EMdoIsolated_ = pset.getUntrackedParameter("EM_doIsolated",true); - EMdoNonIsolated_ = pset.getUntrackedParameter("EM_doNonIsolated",true); - EMregionEtaMargin_ = pset.getUntrackedParameter("EM_regionEtaMargin",0.25); - EMregionPhiMargin_ = pset.getUntrackedParameter("EM_regionPhiMargin",0.40); - Ptmin_iso_ = pset.getUntrackedParameter("Ptmin_iso",0.); - Ptmin_noniso_ = pset.getUntrackedParameter("Ptmin_noniso",0.); + EMl1TagIsolated_ = + consumes(pset.getUntrackedParameter("EM_l1TagIsolated")); + EMl1TagNonIsolated_ = + consumes(pset.getUntrackedParameter("EM_l1TagNonIsolated")); + EMdoIsolated_ = pset.getUntrackedParameter("EM_doIsolated", true); + EMdoNonIsolated_ = pset.getUntrackedParameter("EM_doNonIsolated", true); + EMregionEtaMargin_ = pset.getUntrackedParameter("EM_regionEtaMargin", 0.25); + EMregionPhiMargin_ = pset.getUntrackedParameter("EM_regionPhiMargin", 0.40); + Ptmin_iso_ = pset.getUntrackedParameter("Ptmin_iso", 0.); + Ptmin_noniso_ = pset.getUntrackedParameter("Ptmin_noniso", 0.); } if (Muon_) { - MUregionEtaMargin_ = pset.getUntrackedParameter("MU_regionEtaMargin",1.0); - MUregionPhiMargin_ = pset.getUntrackedParameter("MU_regionPhiMargin",1.0); - Ptmin_muon_ = pset.getUntrackedParameter("Ptmin_muon",0.); - MuonSource_ = consumes(pset.getUntrackedParameter("MuonSource")); + MUregionEtaMargin_ = pset.getUntrackedParameter("MU_regionEtaMargin", 1.0); + MUregionPhiMargin_ = pset.getUntrackedParameter("MU_regionPhiMargin", 1.0); + Ptmin_muon_ = pset.getUntrackedParameter("Ptmin_muon", 0.); + MuonSource_ = consumes(pset.getUntrackedParameter("MuonSource")); } - + if (Jets_) { - JETSregionEtaMargin_ = pset.getUntrackedParameter("JETS_regionEtaMargin",1.0); - JETSregionPhiMargin_ = pset.getUntrackedParameter("JETS_regionPhiMargin",1.0); - Ptmin_jets_ = pset.getUntrackedParameter("Ptmin_jets",0.); - CentralSource_ = consumes(pset.getUntrackedParameter("CentralSource")); - ForwardSource_ = consumes(pset.getUntrackedParameter("ForwardSource")); - TauSource_ = consumes(pset.getUntrackedParameter("TauSource")); - JETSdoCentral_ = pset.getUntrackedParameter("JETS_doCentral",true); - JETSdoForward_ = pset.getUntrackedParameter("JETS_doForward",true); - JETSdoTau_ = pset.getUntrackedParameter("JETS_doTau",true); + JETSregionEtaMargin_ = pset.getUntrackedParameter("JETS_regionEtaMargin", 1.0); + JETSregionPhiMargin_ = pset.getUntrackedParameter("JETS_regionPhiMargin", 1.0); + Ptmin_jets_ = pset.getUntrackedParameter("Ptmin_jets", 0.); + CentralSource_ = + consumes(pset.getUntrackedParameter("CentralSource")); + ForwardSource_ = + consumes(pset.getUntrackedParameter("ForwardSource")); + TauSource_ = consumes(pset.getUntrackedParameter("TauSource")); + JETSdoCentral_ = pset.getUntrackedParameter("JETS_doCentral", true); + JETSdoForward_ = pset.getUntrackedParameter("JETS_doForward", true); + JETSdoTau_ = pset.getUntrackedParameter("JETS_doTau", true); } OutputLabel_ = pset.getUntrackedParameter("OutputLabel"); - + TheMapping = new EcalElectronicsMapping(); first_ = true; - + TheESMapping = new ESElectronicsMapper(pset); - + consumesMany(); produces(OutputLabel_); } -ESListOfFEDSProducer::~ESListOfFEDSProducer() { - delete TheMapping; -} +ESListOfFEDSProducer::~ESListOfFEDSProducer() { delete TheMapping; } void ESListOfFEDSProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - - edm::ParameterSetDescription desc; + edm::ParameterSetDescription desc; desc.add("debug", false); desc.add("EGamma", true); desc.add("Muon", false); desc.add("Jets", false); - desc.add("EM_l1TagIsolated", edm::InputTag("l1extraParticles","Isolated")); - desc.add("EM_l1TagNonIsolated", edm::InputTag("l1extraParticles","NonIsolated")); + desc.add("EM_l1TagIsolated", edm::InputTag("l1extraParticles", "Isolated")); + desc.add("EM_l1TagNonIsolated", edm::InputTag("l1extraParticles", "NonIsolated")); desc.add("EM_doIsolated", true); desc.add("EM_doNonIsolated", true); desc.add("EM_regionEtaMargin", 0.25); @@ -109,372 +108,395 @@ void ESListOfFEDSProducer::fillDescriptions(edm::ConfigurationDescriptions& desc desc.add("JETS_regionEtaMargin", 1.0); desc.add("JETS_regionPhiMargin", 1.0); desc.add("Ptmin_jets", 50.); - desc.add("CentralSource", edm::InputTag("l1extraParticles","Central")); - desc.add("ForwardSource", edm::InputTag("l1extraParticles","Forward")); - desc.add("TauSource", edm::InputTag("l1extraParticles","Tau")); + desc.add("CentralSource", edm::InputTag("l1extraParticles", "Central")); + desc.add("ForwardSource", edm::InputTag("l1extraParticles", "Forward")); + desc.add("TauSource", edm::InputTag("l1extraParticles", "Tau")); desc.add("JETS_doCentral", true); desc.add("JETS_doForward", true); desc.add("JETS_doTau", true); desc.add("OutputLabel", ""); - descriptions.add(("hltESListOfFEDSProducer"), desc); + descriptions.add(("hltESListOfFEDSProducer"), desc); } - -void ESListOfFEDSProducer::produce(edm::Event & e, const edm::EventSetup& iSetup){ - +void ESListOfFEDSProducer::produce(edm::Event& e, const edm::EventSetup& iSetup) { if (first_) { - edm::ESHandle< EcalElectronicsMapping > ecalmapping; - iSetup.get< EcalMappingRcd >().get(ecalmapping); + edm::ESHandle ecalmapping; + iSetup.get().get(ecalmapping); const EcalElectronicsMapping* TheMapping_ = ecalmapping.product(); *TheMapping = *TheMapping_; first_ = false; - } - + } + auto productAddress = std::make_unique(); - std::vector feds; // the list of Ecal FEDS produced - + std::vector feds; // the list of Ecal FEDS produced + /// std::vector Done; if (EGamma_) { // feds = Egamma(e, iSetup, Done); Egamma(e, iSetup, Done, feds); } - + if (Muon_) { ///commented out at this moment, for muon and jets. // feds = Muon(e, iSetup, Done); // Muon(e, iSetup, Done, feds); } - + if (Jets_) { // feds = Jets(e, iSetup, Done); //Jets(e, iSetup, Done, feds); } - - if ( !EGamma_ && !Muon_ && ! Jets_) { - for (int i=1; i <= 54; i++) { - if ( std::find(Done.begin(), Done.end(), i) == Done.end()) - feds.push_back(i); + + if (!EGamma_ && !Muon_ && !Jets_) { + for (int i = 1; i <= 54; i++) { + if (std::find(Done.begin(), Done.end(), i) == Done.end()) + feds.push_back(i); } } - - + int nf = (int)feds.size(); - for (int i=0; i es_feds = TheESMapping->GetListofFEDs(feds); - + std::vector es_feds = TheESMapping->GetListofFEDs(feds); + //check ES List if some of them already done - std::vector< edm::Handle > esFEDs_Done; + std::vector > esFEDs_Done; e.getManyByType(esFEDs_Done); unsigned int esnDone = esFEDs_Done.size(); - - if(debug_){ - std::cout< done = esFEDs_Done[i]-> GetList(); - for(int n=0; n::iterator it = find(es_feds.begin(),es_feds.end(),done[n]); - if( it != es_feds.end()){ - es_feds.erase(it); - j--; - } + + for (int i = 0; i < int(esFEDs_Done.size()); i++) { + std::vector done = esFEDs_Done[i]->GetList(); + for (int n = 0; n < int(done.size()); n++) { + for (int j = 0; j < int(es_feds.size()); j++) { + std::vector::iterator it = find(es_feds.begin(), es_feds.end(), done[n]); + if (it != es_feds.end()) { + es_feds.erase(it); + j--; + } } } } - - if (debug_ ){ - std::cout<<"ESListofFEDSProducer: new ES_list will be put into event: total "< SetList(es_feds); - e.put(std::move(productAddress),OutputLabel_); - + productAddress.get()->SetList(es_feds); + e.put(std::move(productAddress), OutputLabel_); } -void ESListOfFEDSProducer::Egamma(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs ) { - +void ESListOfFEDSProducer::Egamma(edm::Event& e, + const edm::EventSetup& es, + std::vector& done, + std::vector& FEDs) { // std::vector FEDs; - - if (debug_) std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Egamma" << std::endl; - + + if (debug_) + std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Egamma" << std::endl; + //Get the L1 EM Particle Collection - edm::Handle emIsolColl ; - if(EMdoIsolated_) + edm::Handle emIsolColl; + if (EMdoIsolated_) e.getByToken(EMl1TagIsolated_, emIsolColl); //Get the L1 EM Particle Collection - edm::Handle emNonIsolColl ; + edm::Handle emNonIsolColl; if (EMdoNonIsolated_) e.getByToken(EMl1TagNonIsolated_, emNonIsolColl); - + // Get the CaloGeometry - edm::ESHandle l1CaloGeom ; - es.get().get(l1CaloGeom) ; - - if(EMdoIsolated_) { - - for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); - emItr != emIsolColl->end() ;++emItr ){ - - float pt = emItr -> pt(); - if (pt < Ptmin_iso_ ) continue; - if (debug_) std::cout << " Here is an L1 isoEM candidate of pt " << pt << std::endl; + edm::ESHandle l1CaloGeom; + es.get().get(l1CaloGeom); + + if (EMdoIsolated_) { + for (l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end(); + ++emItr) { + float pt = emItr->pt(); + if (pt < Ptmin_iso_) + continue; + if (debug_) + std::cout << " Here is an L1 isoEM candidate of pt " << pt << std::endl; // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - int phiIndex = emItr->gctEmCand()->phiIndex() ; + int etaIndex = emItr->gctEmCand()->etaIndex(); + int phiIndex = emItr->gctEmCand()->phiIndex(); // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + std::vector feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_); - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } - } // end loop on L1EmParticleCollection - } // endif doIsolated_ + } // end loop on L1EmParticleCollection + } // endif doIsolated_ if (EMdoNonIsolated_) { - - for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); - emItr != emNonIsolColl->end() ;++emItr ){ - - float pt = emItr -> pt(); - if (debug_) std::cout << " Here is an L1 nonisoEM candidate of pt " << pt << std::endl; - if (pt < Ptmin_noniso_ ) continue; + for (l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end(); + ++emItr) { + float pt = emItr->pt(); + if (debug_) + std::cout << " Here is an L1 nonisoEM candidate of pt " << pt << std::endl; + if (pt < Ptmin_noniso_) + continue; // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - int phiIndex = emItr->gctEmCand()->phiIndex() ; + int etaIndex = emItr->gctEmCand()->etaIndex(); + int phiIndex = emItr->gctEmCand()->phiIndex(); // std::cout << " etaIndex phiIndex " << etaIndex << " " << phiIndex << std::endl; // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + std::vector feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_); - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); - + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } - } // end loop on L1EmParticleCollection + } // end loop on L1EmParticleCollection } - + if (debug_) { std::cout << std::endl; - for (int i=0; i < (int)FEDs.size(); i++) { + for (int i = 0; i < (int)FEDs.size(); i++) { std::cout << "Egamma: unpack FED " << FEDs[i] << std::endl; } std::cout << "Number of FEDS is " << FEDs.size() << std::endl; } - + // return FEDs; - } -void ESListOfFEDSProducer::Muon(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs) { - - if (debug_) std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Muon" << std::endl; +void ESListOfFEDSProducer::Muon(edm::Event& e, + const edm::EventSetup& es, + std::vector& done, + std::vector& FEDs) { + if (debug_) + std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Muon" << std::endl; edm::Handle muColl; e.getByToken(MuonSource_, muColl); double epsilon = 0.01; - - for (L1MuonParticleCollection::const_iterator it=muColl->begin(); it != muColl->end(); it++) { - + + for (L1MuonParticleCollection::const_iterator it = muColl->begin(); it != muColl->end(); it++) { const L1MuGMTExtendedCand muonCand = (*it).gmtMuonCand(); - double pt = (*it).pt(); - double eta = (*it).eta(); - double phi = (*it).phi(); - - if (debug_) std::cout << " here is a L1 muon Seed with (eta,phi) = " << - eta << " " << phi << " and pt " << pt << std::endl; - if (pt < Ptmin_muon_ ) continue; - - std::vector feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, MUregionEtaMargin_, MUregionPhiMargin_); - - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); + double pt = (*it).pt(); + double eta = (*it).eta(); + double phi = (*it).phi(); + + if (debug_) + std::cout << " here is a L1 muon Seed with (eta,phi) = " << eta << " " << phi << " and pt " << pt << std::endl; + if (pt < Ptmin_muon_) + continue; + + std::vector feds = ListOfFEDS(eta, eta, phi - epsilon, phi + epsilon, MUregionEtaMargin_, MUregionPhiMargin_); + + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } } - + if (debug_) { std::cout << std::endl; - for (int i=0; i < (int)FEDs.size(); i++) { + for (int i = 0; i < (int)FEDs.size(); i++) { std::cout << "Muons: unpack FED " << FEDs[i] << std::endl; } std::cout << "Number of FEDS is " << FEDs.size() << std::endl; } - + // return FEDs; - } -void ESListOfFEDSProducer::Jets(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs) { - +void ESListOfFEDSProducer::Jets(edm::Event& e, + const edm::EventSetup& es, + std::vector& done, + std::vector& FEDs) { // std::vector FEDs; - - if (debug_) std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Jets" << std::endl; + + if (debug_) + std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Jets" << std::endl; double epsilon = 0.01; if (JETSdoCentral_) { - edm::Handle jetColl; - e.getByToken(CentralSource_,jetColl); - - for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) { - - double pt = it -> pt(); - double eta = it -> eta(); - double phi = it -> phi(); - - if (debug_) std::cout << " here is a L1 CentralJet Seed with (eta,phi) = " << - eta << " " << phi << " and pt " << pt << std::endl; - if (pt < Ptmin_jets_ ) continue; - - std::vector feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); - - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); + e.getByToken(CentralSource_, jetColl); + + for (L1JetParticleCollection::const_iterator it = jetColl->begin(); it != jetColl->end(); it++) { + double pt = it->pt(); + double eta = it->eta(); + double phi = it->phi(); + + if (debug_) + std::cout << " here is a L1 CentralJet Seed with (eta,phi) = " << eta << " " << phi << " and pt " << pt + << std::endl; + if (pt < Ptmin_jets_) + continue; + + std::vector feds = + ListOfFEDS(eta, eta, phi - epsilon, phi + epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); + + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } } } - + if (JETSdoForward_) { - edm::Handle jetColl; - e.getByToken(ForwardSource_,jetColl); - - for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) { - - double pt = it -> pt(); - double eta = it -> eta(); - double phi = it -> phi(); - - if (debug_) std::cout << " here is a L1 ForwardJet Seed with (eta,phi) = " << - eta << " " << phi << " and pt " << pt << std::endl; - if (pt < Ptmin_jets_ ) continue; - - std::vector feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); - - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); + e.getByToken(ForwardSource_, jetColl); + + for (L1JetParticleCollection::const_iterator it = jetColl->begin(); it != jetColl->end(); it++) { + double pt = it->pt(); + double eta = it->eta(); + double phi = it->phi(); + + if (debug_) + std::cout << " here is a L1 ForwardJet Seed with (eta,phi) = " << eta << " " << phi << " and pt " << pt + << std::endl; + if (pt < Ptmin_jets_) + continue; + + std::vector feds = + ListOfFEDS(eta, eta, phi - epsilon, phi + epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); + + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } } } - + if (JETSdoTau_) { - edm::Handle jetColl; - e.getByToken(TauSource_,jetColl); - - for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) { - - double pt = it -> pt(); - double eta = it -> eta(); - double phi = it -> phi(); - - if (debug_) std::cout << " here is a L1 TauJet Seed with (eta,phi) = " << - eta << " " << phi << " and pt " << pt << std::endl; - if (pt < Ptmin_jets_ ) continue; - - std::vector feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); - - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); + e.getByToken(TauSource_, jetColl); + + for (L1JetParticleCollection::const_iterator it = jetColl->begin(); it != jetColl->end(); it++) { + double pt = it->pt(); + double eta = it->eta(); + double phi = it->phi(); + + if (debug_) + std::cout << " here is a L1 TauJet Seed with (eta,phi) = " << eta << " " << phi << " and pt " << pt + << std::endl; + if (pt < Ptmin_jets_) + continue; + + std::vector feds = + ListOfFEDS(eta, eta, phi - epsilon, phi + epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); + + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } } } - + if (debug_) { std::cout << std::endl; - for (int i=0; i < (int)FEDs.size(); i++) { + for (int i = 0; i < (int)FEDs.size(); i++) { std::cout << "Jets: unpack FED " << FEDs[i] << std::endl; } std::cout << "Number of FEDS is " << FEDs.size() << std::endl; } - + // return FEDs; } - -std::vector ESListOfFEDSProducer::ListOfFEDS(double etaLow, double etaHigh, double phiLow, - double phiHigh, double etamargin, double phimargin) -{ - +std::vector ESListOfFEDSProducer::ListOfFEDS( + double etaLow, double etaHigh, double phiLow, double phiHigh, double etamargin, double phimargin) { std::vector FEDs; - - if (phimargin > Geom::pi()) phimargin = Geom::pi() ; - - - if (debug_) std::cout << " etaLow etaHigh phiLow phiHigh " << etaLow << " " << - etaHigh << " " << phiLow << " " << phiHigh << std::endl; - + + if (phimargin > Geom::pi()) + phimargin = Geom::pi(); + + if (debug_) + std::cout << " etaLow etaHigh phiLow phiHigh " << etaLow << " " << etaHigh << " " << phiLow << " " << phiHigh + << std::endl; + etaLow -= etamargin; etaHigh += etamargin; double phiMinus = phiLow - phimargin; double phiPlus = phiHigh + phimargin; - + bool all = false; - double dd = fabs(phiPlus-phiMinus); - if (debug_) std::cout << " dd = " << dd << std::endl; - if (dd > 2.*Geom::pi() ) all = true; - - while (phiPlus > Geom::pi()) { phiPlus -= 2.*Geom::pi() ; } - while (phiMinus < 0) { phiMinus += 2.*Geom::pi() ; } - if ( phiMinus > Geom::pi()) phiMinus -= 2.*Geom::pi() ; - + double dd = fabs(phiPlus - phiMinus); + if (debug_) + std::cout << " dd = " << dd << std::endl; + if (dd > 2. * Geom::pi()) + all = true; + + while (phiPlus > Geom::pi()) { + phiPlus -= 2. * Geom::pi(); + } + while (phiMinus < 0) { + phiMinus += 2. * Geom::pi(); + } + if (phiMinus > Geom::pi()) + phiMinus -= 2. * Geom::pi(); + double dphi = phiPlus - phiMinus; - if (dphi < 0) dphi += 2.*Geom::pi() ; - if (debug_) std::cout << "dphi = " << dphi << std::endl; + if (dphi < 0) + dphi += 2. * Geom::pi(); + if (debug_) + std::cout << "dphi = " << dphi << std::endl; if (dphi > Geom::pi()) { - int fed_low1 = TheMapping -> GetFED(etaLow,phiMinus*180./Geom::pi()); - int fed_low2 = TheMapping -> GetFED(etaLow,phiPlus*180./Geom::pi()); - if (debug_) std::cout << "fed_low1 fed_low2 " << fed_low1 << " " << fed_low2 << std::endl; - if (fed_low1 == fed_low2) all = true; - int fed_hi1 = TheMapping -> GetFED(etaHigh,phiMinus*180./Geom::pi()); - int fed_hi2 = TheMapping -> GetFED(etaHigh,phiPlus*180./Geom::pi()); - if (debug_) std::cout << "fed_hi1 fed_hi2 " << fed_hi1 << " " << fed_hi2 << std::endl; - if (fed_hi1 == fed_hi2) all = true; + int fed_low1 = TheMapping->GetFED(etaLow, phiMinus * 180. / Geom::pi()); + int fed_low2 = TheMapping->GetFED(etaLow, phiPlus * 180. / Geom::pi()); + if (debug_) + std::cout << "fed_low1 fed_low2 " << fed_low1 << " " << fed_low2 << std::endl; + if (fed_low1 == fed_low2) + all = true; + int fed_hi1 = TheMapping->GetFED(etaHigh, phiMinus * 180. / Geom::pi()); + int fed_hi2 = TheMapping->GetFED(etaHigh, phiPlus * 180. / Geom::pi()); + if (debug_) + std::cout << "fed_hi1 fed_hi2 " << fed_hi1 << " " << fed_hi2 << std::endl; + if (fed_hi1 == fed_hi2) + all = true; } - - + if (all) { - if (debug_) std::cout << " unpack everything in phi ! " << std::endl; + if (debug_) + std::cout << " unpack everything in phi ! " << std::endl; phiMinus = -20 * Geom::pi() / 180.; // -20 deg - phiPlus = -40 * Geom::pi() / 180.; // -20 deg + phiPlus = -40 * Geom::pi() / 180.; // -20 deg } - - if (debug_) std::cout << " with margins : " << etaLow << " " << etaHigh << " " << - phiMinus << " " << phiPlus << std::endl; - - - const RectangularEtaPhiRegion ecalregion(etaLow,etaHigh,phiMinus,phiPlus); - - FEDs = TheMapping -> GetListofFEDs(ecalregion); - + + if (debug_) + std::cout << " with margins : " << etaLow << " " << etaHigh << " " << phiMinus << " " << phiPlus << std::endl; + + const RectangularEtaPhiRegion ecalregion(etaLow, etaHigh, phiMinus, phiPlus); + + FEDs = TheMapping->GetListofFEDs(ecalregion); + return FEDs; } diff --git a/RecoEgamma/EgammaHLTProducers/src/ESRecHitsMerger.cc b/RecoEgamma/EgammaHLTProducers/src/ESRecHitsMerger.cc index a5cd9f6165b53..99823438ed62d 100644 --- a/RecoEgamma/EgammaHLTProducers/src/ESRecHitsMerger.cc +++ b/RecoEgamma/EgammaHLTProducers/src/ESRecHitsMerger.cc @@ -11,128 +11,104 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" - using namespace edm; using namespace std; - ESRecHitsMerger::ESRecHitsMerger(const edm::ParameterSet& pset) { + debug_ = pset.getUntrackedParameter("debug"); + + EgammaSourceES_ = pset.getUntrackedParameter("EgammaSource_ES", edm::InputTag("dummyEgamma")); + MuonsSourceES_ = pset.getUntrackedParameter("MuonsSource_ES", edm::InputTag("dummyMuons")); + TausSourceES_ = pset.getUntrackedParameter("TausSource_ES", edm::InputTag("dummyTaus")); + JetsSourceES_ = pset.getUntrackedParameter("JetsSource_ES", edm::InputTag("dummyJets")); + RestSourceES_ = pset.getUntrackedParameter("RestSource_ES", edm::InputTag("dummyRest")); + Pi0SourceES_ = pset.getUntrackedParameter("Pi0Source_ES", edm::InputTag("dummyPi0")); + EtaSourceES_ = pset.getUntrackedParameter("EtaSource_ES", edm::InputTag("dummyEta")); - debug_ = pset.getUntrackedParameter("debug"); - - EgammaSourceES_ = pset.getUntrackedParameter("EgammaSource_ES",edm::InputTag("dummyEgamma")); - MuonsSourceES_ = pset.getUntrackedParameter("MuonsSource_ES",edm::InputTag("dummyMuons")); - TausSourceES_ = pset.getUntrackedParameter("TausSource_ES",edm::InputTag("dummyTaus")); - JetsSourceES_ = pset.getUntrackedParameter("JetsSource_ES",edm::InputTag("dummyJets")); - RestSourceES_ = pset.getUntrackedParameter("RestSource_ES",edm::InputTag("dummyRest")); - Pi0SourceES_ = pset.getUntrackedParameter("Pi0Source_ES",edm::InputTag("dummyPi0")); - EtaSourceES_ = pset.getUntrackedParameter("EtaSource_ES",edm::InputTag("dummyEta")); - - OutputLabelES_ = pset.getUntrackedParameter("OutputLabel_ES"); - InputRecHitES_ = pset.getUntrackedParameter("EcalRecHitCollectionES"); - - consumesMany(); - produces(OutputLabelES_); - + OutputLabelES_ = pset.getUntrackedParameter("OutputLabel_ES"); + InputRecHitES_ = pset.getUntrackedParameter("EcalRecHitCollectionES"); + + consumesMany(); + produces(OutputLabelES_); } void ESRecHitsMerger::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("debug", false); desc.add("EgammaSource_ES", edm::InputTag("dummyEgamma")); - desc.add("MuonsSource_ES",edm::InputTag("dummyMuons")); - desc.add("TausSource_ES",edm::InputTag("dummyTaus")); - desc.add("JetsSource_ES",edm::InputTag("dummyJets")); - desc.add("RestSource_ES",edm::InputTag("dummyRest")); - desc.add("Pi0Source_ES",edm::InputTag("dummyPi0")); - desc.add("EtaSource_ES",edm::InputTag("dummyEta")); + desc.add("MuonsSource_ES", edm::InputTag("dummyMuons")); + desc.add("TausSource_ES", edm::InputTag("dummyTaus")); + desc.add("JetsSource_ES", edm::InputTag("dummyJets")); + desc.add("RestSource_ES", edm::InputTag("dummyRest")); + desc.add("Pi0Source_ES", edm::InputTag("dummyPi0")); + desc.add("EtaSource_ES", edm::InputTag("dummyEta")); desc.add("OutputLabel_ES", "EcalRecHitsES"); desc.add("EcalRecHitCollectionES", "EcalRecHitsES"); - descriptions.add("hltESRecHitsMerger", desc); + descriptions.add("hltESRecHitsMerger", desc); } +ESRecHitsMerger::~ESRecHitsMerger() {} +void ESRecHitsMerger::beginJob() {} -ESRecHitsMerger::~ESRecHitsMerger() { -} +void ESRecHitsMerger::endJob() {} +void ESRecHitsMerger::produce(edm::StreamID, edm::Event& e, const edm::EventSetup& iSetup) const { + if (debug_) + std::cout << " ESRecHitMerger : Run " << e.id().run() << " Event " << e.id().event() << std::endl; -void ESRecHitsMerger::beginJob(){ -} + std::vector > EcalRecHits_done; + e.getManyByType(EcalRecHits_done); -void ESRecHitsMerger::endJob(){ -} + auto ESMergedRecHits = std::make_unique(); -void ESRecHitsMerger::produce(edm::StreamID, edm::Event & e, const edm::EventSetup& iSetup) const { - - if (debug_) std::cout << " ESRecHitMerger : Run " << e.id().run() << " Event " << e.id().event() << std::endl; - - - std::vector< edm::Handle > EcalRecHits_done; - e.getManyByType(EcalRecHits_done); - - auto ESMergedRecHits = std::make_unique(); - - - unsigned int nColl = EcalRecHits_done.size(); - - int nES = 0; - - - for (unsigned int i=0; i < nColl; i++) { - - std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); - std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel(); - - - if (debug_){ - std::cout<<"ESrechit to be merged from "< size(); - } - - } - - - ESMergedRecHits -> reserve(nES); - - if (debug_) std::cout << " Number of ES Rechits to merge = " << nES << std::endl; - - for (unsigned int i=0; i < nColl; i++) { - std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); - - std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel(); - if ( module_label != EgammaSourceES_.label() && - module_label != MuonsSourceES_.label() && - module_label != JetsSourceES_.label() && - module_label != TausSourceES_.label() && - module_label != RestSourceES_.label() && - module_label != Pi0SourceES_.label() && - module_label != EtaSourceES_.label() ) continue; - - if (instance == InputRecHitES_) { - for (EcalRecHitCollection::const_iterator it=EcalRecHits_done[i]->begin(); it !=EcalRecHits_done[i]->end(); it++) { - ESMergedRecHits -> push_back(*it); - } - } - - } - - - // std::cout << " avant le put " << std::endl; - e.put(std::move(ESMergedRecHits),OutputLabelES_); - // std::cout << " apres le put " << std::endl; + unsigned int nColl = EcalRecHits_done.size(); -} + int nES = 0; + + for (unsigned int i = 0; i < nColl; i++) { + std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); + std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel(); + if (debug_) { + std::cout << "ESrechit to be merged from " << module_label.c_str() << " " << instance.c_str() << std::endl; + } + + if (module_label != EgammaSourceES_.label() && module_label != MuonsSourceES_.label() && + module_label != JetsSourceES_.label() && module_label != TausSourceES_.label() && + module_label != RestSourceES_.label() && module_label != Pi0SourceES_.label() && + module_label != EtaSourceES_.label()) + continue; + + if (instance == InputRecHitES_) { + nES += EcalRecHits_done[i]->size(); + } + } + + ESMergedRecHits->reserve(nES); + + if (debug_) + std::cout << " Number of ES Rechits to merge = " << nES << std::endl; + + for (unsigned int i = 0; i < nColl; i++) { + std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); + + std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel(); + if (module_label != EgammaSourceES_.label() && module_label != MuonsSourceES_.label() && + module_label != JetsSourceES_.label() && module_label != TausSourceES_.label() && + module_label != RestSourceES_.label() && module_label != Pi0SourceES_.label() && + module_label != EtaSourceES_.label()) + continue; + + if (instance == InputRecHitES_) { + for (EcalRecHitCollection::const_iterator it = EcalRecHits_done[i]->begin(); it != EcalRecHits_done[i]->end(); + it++) { + ESMergedRecHits->push_back(*it); + } + } + } + + // std::cout << " avant le put " << std::endl; + e.put(std::move(ESMergedRecHits), OutputLabelES_); + // std::cout << " apres le put " << std::endl; +} diff --git a/RecoEgamma/EgammaHLTProducers/src/EcalListOfFEDSProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EcalListOfFEDSProducer.cc index 438ef8af11200..cfb82dd4b0014 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EcalListOfFEDSProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EcalListOfFEDSProducer.cc @@ -5,14 +5,14 @@ #include "RecoEgamma/EgammaHLTProducers/interface/EcalListOfFEDSProducer.h" #include "DataFormats/EcalRawData/interface/EcalListOfFEDS.h" -// Ecal Mapping +// Ecal Mapping #include "Geometry/EcalMapping/interface/EcalMappingRcd.h" #include // Level 1 Trigger #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h" #include "CondFormats/DataRecord/interface/L1CaloGeometryRecord.h" - + // EgammaCoreTools #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h" #include "DataFormats/Math/interface/RectangularEtaPhiRegion.h" @@ -25,376 +25,391 @@ using namespace l1extra; EcalListOfFEDSProducer::EcalListOfFEDSProducer(const edm::ParameterSet& pset) { - debug_ = pset.getUntrackedParameter("debug"); - + Pi0ListToIgnore_ = pset.getParameter("Pi0ListToIgnore"); - - EGamma_ = pset.getUntrackedParameter("EGamma",false); - Muon_ = pset.getUntrackedParameter("Muon",false); - Jets_ = pset.getUntrackedParameter("Jets",false); - + + EGamma_ = pset.getUntrackedParameter("EGamma", false); + Muon_ = pset.getUntrackedParameter("Muon", false); + Jets_ = pset.getUntrackedParameter("Jets", false); + if (EGamma_ && Muon_) { - throw cms::Exception("EcalListOfFEDSProducer") << - " Wrong configuration : EGamma and Muon should not be true at the same time." ; + throw cms::Exception("EcalListOfFEDSProducer") + << " Wrong configuration : EGamma and Muon should not be true at the same time."; } - - + if (EGamma_) { - - EMl1TagIsolated_ = consumes(pset.getUntrackedParameter("EM_l1TagIsolated")); - EMl1TagNonIsolated_ = consumes(pset.getUntrackedParameter("EM_l1TagNonIsolated")); - EMdoIsolated_ = pset.getUntrackedParameter("EM_doIsolated", true); - EMdoNonIsolated_ = pset.getUntrackedParameter("EM_doNonIsolated",true); - EMregionEtaMargin_ = pset.getUntrackedParameter("EM_regionEtaMargin", 0.25); - EMregionPhiMargin_ = pset.getUntrackedParameter("EM_regionPhiMargin", 0.40); - Ptmin_iso_ = pset.getUntrackedParameter("Ptmin_iso", 0.); - Ptmin_noniso_ = pset.getUntrackedParameter("Ptmin_noniso", 0.); + EMl1TagIsolated_ = consumes(pset.getUntrackedParameter("EM_l1TagIsolated")); + EMl1TagNonIsolated_ = + consumes(pset.getUntrackedParameter("EM_l1TagNonIsolated")); + EMdoIsolated_ = pset.getUntrackedParameter("EM_doIsolated", true); + EMdoNonIsolated_ = pset.getUntrackedParameter("EM_doNonIsolated", true); + EMregionEtaMargin_ = pset.getUntrackedParameter("EM_regionEtaMargin", 0.25); + EMregionPhiMargin_ = pset.getUntrackedParameter("EM_regionPhiMargin", 0.40); + Ptmin_iso_ = pset.getUntrackedParameter("Ptmin_iso", 0.); + Ptmin_noniso_ = pset.getUntrackedParameter("Ptmin_noniso", 0.); } - + if (Muon_) { MUregionEtaMargin_ = pset.getUntrackedParameter("MU_regionEtaMargin", 1.0); MUregionPhiMargin_ = pset.getUntrackedParameter("MU_regionPhiMargin", 1.0); - Ptmin_muon_ = pset.getUntrackedParameter("Ptmin_muon", 0.); - MuonSource_ = consumes(pset.getUntrackedParameter("MuonSource")); + Ptmin_muon_ = pset.getUntrackedParameter("Ptmin_muon", 0.); + MuonSource_ = consumes(pset.getUntrackedParameter("MuonSource")); } - if (Jets_) { - JETSregionEtaMargin_ = pset.getUntrackedParameter("JETS_regionEtaMargin", 1.0); - JETSregionPhiMargin_ = pset.getUntrackedParameter("JETS_regionPhiMargin", 1.0); - Ptmin_jets_ = pset.getUntrackedParameter("Ptmin_jets", 0.); - CentralSource_ = consumes(pset.getUntrackedParameter("CentralSource")); - ForwardSource_ = consumes(pset.getUntrackedParameter("ForwardSource")); - TauSource_ = consumes(pset.getUntrackedParameter("TauSource")); - JETSdoCentral_ = pset.getUntrackedParameter("JETS_doCentral", true); - JETSdoForward_ = pset.getUntrackedParameter("JETS_doForward", true); - JETSdoTau_ = pset.getUntrackedParameter("JETS_doTau", true); - } - - OutputLabel_ = pset.getUntrackedParameter("OutputLabel"); - - TheMapping = new EcalElectronicsMapping(); - first_ = true; - - consumesMany(); - produces(OutputLabel_); -} + if (Jets_) { + JETSregionEtaMargin_ = pset.getUntrackedParameter("JETS_regionEtaMargin", 1.0); + JETSregionPhiMargin_ = pset.getUntrackedParameter("JETS_regionPhiMargin", 1.0); + Ptmin_jets_ = pset.getUntrackedParameter("Ptmin_jets", 0.); + CentralSource_ = consumes(pset.getUntrackedParameter("CentralSource")); + ForwardSource_ = consumes(pset.getUntrackedParameter("ForwardSource")); + TauSource_ = consumes(pset.getUntrackedParameter("TauSource")); + JETSdoCentral_ = pset.getUntrackedParameter("JETS_doCentral", true); + JETSdoForward_ = pset.getUntrackedParameter("JETS_doForward", true); + JETSdoTau_ = pset.getUntrackedParameter("JETS_doTau", true); + } + + OutputLabel_ = pset.getUntrackedParameter("OutputLabel"); + + TheMapping = new EcalElectronicsMapping(); + first_ = true; -EcalListOfFEDSProducer::~EcalListOfFEDSProducer() { - delete TheMapping; + consumesMany(); + produces(OutputLabel_); } -void EcalListOfFEDSProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +EcalListOfFEDSProducer::~EcalListOfFEDSProducer() { delete TheMapping; } +void EcalListOfFEDSProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("debug", false); - desc.add("Pi0ListToIgnore", edm::InputTag("")); - desc.add("EGamma",false); - desc.add("Muon",false); - desc.add("Jets",false); - desc.add("EM_l1TagIsolated", edm::InputTag("")); - desc.add("EM_l1TagNonIsolated", edm::InputTag("")); - desc.add("EM_doIsolated",true); - desc.add("EM_doNonIsolated",true); - desc.add("EM_regionEtaMargin",0.25); - desc.add("EM_regionPhiMargin",0.40); - desc.add("Ptmin_iso",0.); - desc.add("Ptmin_noniso",0.); - desc.add("MU_regionEtaMargin",1.0); - desc.add("MU_regionPhiMargin",1.0); - desc.add("Ptmin_muon",0.); - desc.add("MuonSource", edm::InputTag("")); - desc.add("JETS_regionEtaMargin",1.0); - desc.add("JETS_regionPhiMargin",1.0); - desc.add("Ptmin_jets",0.); - desc.add("CentralSource", edm::InputTag("")); - desc.add("ForwardSource", edm::InputTag("")); -desc.add("TauSource", edm::InputTag("")); - desc.add("JETS_doCentral",true); - desc.add("JETS_doForward",true); - desc.add("JETS_doTau",true); -desc.add("OutputLabel", ""); - descriptions.add(("hltEcalListOfFEDSProducer"), desc); + desc.add("Pi0ListToIgnore", edm::InputTag("")); + desc.add("EGamma", false); + desc.add("Muon", false); + desc.add("Jets", false); + desc.add("EM_l1TagIsolated", edm::InputTag("")); + desc.add("EM_l1TagNonIsolated", edm::InputTag("")); + desc.add("EM_doIsolated", true); + desc.add("EM_doNonIsolated", true); + desc.add("EM_regionEtaMargin", 0.25); + desc.add("EM_regionPhiMargin", 0.40); + desc.add("Ptmin_iso", 0.); + desc.add("Ptmin_noniso", 0.); + desc.add("MU_regionEtaMargin", 1.0); + desc.add("MU_regionPhiMargin", 1.0); + desc.add("Ptmin_muon", 0.); + desc.add("MuonSource", edm::InputTag("")); + desc.add("JETS_regionEtaMargin", 1.0); + desc.add("JETS_regionPhiMargin", 1.0); + desc.add("Ptmin_jets", 0.); + desc.add("CentralSource", edm::InputTag("")); + desc.add("ForwardSource", edm::InputTag("")); + desc.add("TauSource", edm::InputTag("")); + desc.add("JETS_doCentral", true); + desc.add("JETS_doForward", true); + desc.add("JETS_doTau", true); + desc.add("OutputLabel", ""); + descriptions.add(("hltEcalListOfFEDSProducer"), desc); } -void EcalListOfFEDSProducer::produce(edm::Event & e, const edm::EventSetup& iSetup){ - +void EcalListOfFEDSProducer::produce(edm::Event& e, const edm::EventSetup& iSetup) { if (first_) { - edm::ESHandle< EcalElectronicsMapping > ecalmapping; - iSetup.get< EcalMappingRcd >().get(ecalmapping); + edm::ESHandle ecalmapping; + iSetup.get().get(ecalmapping); const EcalElectronicsMapping* TheMapping_ = ecalmapping.product(); *TheMapping = *TheMapping_; first_ = false; - } - + } + auto productAddress = std::make_unique(); - - std::vector feds; // the list of FEDS produced by this module - - + + std::vector feds; // the list of FEDS produced by this module + // ---- First, get the list of ECAL FEDs which have already been unpacked - - std::vector< edm::Handle > FEDs_Done; + + std::vector > FEDs_Done; std::vector Done; e.getManyByType(FEDs_Done); unsigned int nDone = FEDs_Done.size(); - if (debug_) std::cout << " ECAL unpacking module has already run " << nDone << " times. " << std::endl; - for (unsigned int id=0; id < nDone; id++) { + if (debug_) + std::cout << " ECAL unpacking module has already run " << nDone << " times. " << std::endl; + for (unsigned int id = 0; id < nDone; id++) { // ignore the FEDs coming from unpacking in pi0 paths - if( Pi0ListToIgnore_.label() == FEDs_Done[id].provenance()->moduleLabel() ){continue;} - std::vector done = FEDs_Done[id]-> GetList(); - for (int jd=0; jd < (int)done.size(); jd++) { + if (Pi0ListToIgnore_.label() == FEDs_Done[id].provenance()->moduleLabel()) { + continue; + } + std::vector done = FEDs_Done[id]->GetList(); + for (int jd = 0; jd < (int)done.size(); jd++) { Done.push_back(done[jd] - FEDNumbering::MINECALFEDID); } } - if (debug_) std::cout << " For this event, " << Done.size() << " ECAL FEDs have already been unpacked." << std::endl; - - + if (debug_) + std::cout << " For this event, " << Done.size() << " ECAL FEDs have already been unpacked." << std::endl; + if (EGamma_) { // feds = Egamma(e, iSetup, Done); Egamma(e, iSetup, Done, feds); } - + if (Muon_) { // feds = Muon(e, iSetup, Done); Muon(e, iSetup, Done, feds); } - + if (Jets_) { // feds = Jets(e, iSetup, Done); Jets(e, iSetup, Done, feds); } - - if ( !EGamma_ && !Muon_ && ! Jets_) { - for (int i=1; i <= 54; i++) { - if ( std::find(Done.begin(), Done.end(), i) == Done.end()) - feds.push_back(i); + + if (!EGamma_ && !Muon_ && !Jets_) { + for (int i = 1; i <= 54; i++) { + if (std::find(Done.begin(), Done.end(), i) == Done.end()) + feds.push_back(i); } } - + int nf = (int)feds.size(); - for (int i=0; i SetList(feds); - e.put(std::move(productAddress),OutputLabel_); + + if (debug_ && nf < 1) + std::cout << " Warning : no ECAL FED to unpack for Run " << e.id().run() << " Event " << e.id().event() + << std::endl; + + productAddress.get()->SetList(feds); + e.put(std::move(productAddress), OutputLabel_); } -void EcalListOfFEDSProducer::Egamma(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs ) { - +void EcalListOfFEDSProducer::Egamma(edm::Event& e, + const edm::EventSetup& es, + std::vector& done, + std::vector& FEDs) { // std::vector FEDs; - - if (debug_) std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Egamma" << std::endl; - + + if (debug_) + std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Egamma" << std::endl; + //Get the L1 EM Particle Collection //Get the L1 EM Particle Collection - edm::Handle emIsolColl ; - if(EMdoIsolated_) + edm::Handle emIsolColl; + if (EMdoIsolated_) e.getByToken(EMl1TagIsolated_, emIsolColl); //Get the L1 EM Particle Collection - edm::Handle emNonIsolColl ; + edm::Handle emNonIsolColl; if (EMdoNonIsolated_) e.getByToken(EMl1TagNonIsolated_, emNonIsolColl); - + // Get the CaloGeometry - edm::ESHandle l1CaloGeom ; - es.get().get(l1CaloGeom) ; - - if(EMdoIsolated_) { - - for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); - emItr != emIsolColl->end() ;++emItr ){ - - float pt = emItr -> pt(); - if (pt < Ptmin_iso_ ) continue; - if (debug_) std::cout << " Here is an L1 isoEM candidate of pt " << pt << std::endl; - // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - int phiIndex = emItr->gctEmCand()->phiIndex() ; - // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - - std::vector feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_); - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); - } - } // end loop on L1EmParticleCollection - } // endif doIsolated_ - + edm::ESHandle l1CaloGeom; + es.get().get(l1CaloGeom); + + if (EMdoIsolated_) { + for (l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end(); + ++emItr) { + float pt = emItr->pt(); + if (pt < Ptmin_iso_) + continue; + if (debug_) + std::cout << " Here is an L1 isoEM candidate of pt " << pt << std::endl; + // Access the GCT hardware object corresponding to the L1Extra EM object. + int etaIndex = emItr->gctEmCand()->etaIndex(); + int phiIndex = emItr->gctEmCand()->phiIndex(); + // Use the L1CaloGeometry to find the eta, phi bin boundaries. + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + + std::vector feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_); + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); + } + } // end loop on L1EmParticleCollection + } // endif doIsolated_ + if (EMdoNonIsolated_) { - - for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); - emItr != emNonIsolColl->end() ;++emItr ){ - - float pt = emItr -> pt(); - if (debug_) std::cout << " Here is an L1 nonisoEM candidate of pt " << pt << std::endl; - if (pt < Ptmin_noniso_ ) continue; + for (l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end(); + ++emItr) { + float pt = emItr->pt(); + if (debug_) + std::cout << " Here is an L1 nonisoEM candidate of pt " << pt << std::endl; + if (pt < Ptmin_noniso_) + continue; // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - int phiIndex = emItr->gctEmCand()->phiIndex() ; + int etaIndex = emItr->gctEmCand()->etaIndex(); + int phiIndex = emItr->gctEmCand()->phiIndex(); // std::cout << " etaIndex phiIndex " << etaIndex << " " << phiIndex << std::endl; // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + std::vector feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_); - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); - + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } - - } // end loop on L1EmParticleCollection + + } // end loop on L1EmParticleCollection } - + // std::cout << "end of get list of feds " << std::endl; - + if (debug_) { std::cout << std::endl; - for (int i=0; i < (int)FEDs.size(); i++) { + for (int i = 0; i < (int)FEDs.size(); i++) { std::cout << "Egamma: unpack FED " << FEDs[i] << std::endl; } std::cout << "Number of FEDS is " << FEDs.size() << std::endl; } - + // return FEDs; - } -void EcalListOfFEDSProducer::Muon(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs) { - +void EcalListOfFEDSProducer::Muon(edm::Event& e, + const edm::EventSetup& es, + std::vector& done, + std::vector& FEDs) { // std::vector FEDs; - - if (debug_) std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Muon" << std::endl; - + + if (debug_) + std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Muon" << std::endl; + edm::Handle muColl; e.getByToken(MuonSource_, muColl); - + double epsilon = 0.01; - - for (L1MuonParticleCollection::const_iterator it=muColl->begin(); it != muColl->end(); it++) { + + for (L1MuonParticleCollection::const_iterator it = muColl->begin(); it != muColl->end(); it++) { const L1MuGMTExtendedCand muonCand = (*it).gmtMuonCand(); - double pt = (*it).pt(); - double eta = (*it).eta(); - double phi = (*it).phi(); - - if (debug_) std::cout << " here is a L1 muon Seed with (eta,phi) = " << - eta << " " << phi << " and pt " << pt << std::endl; - if (pt < Ptmin_muon_ ) continue; - - std::vector feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, MUregionEtaMargin_, MUregionPhiMargin_); - - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); + double pt = (*it).pt(); + double eta = (*it).eta(); + double phi = (*it).phi(); + + if (debug_) + std::cout << " here is a L1 muon Seed with (eta,phi) = " << eta << " " << phi << " and pt " << pt << std::endl; + if (pt < Ptmin_muon_) + continue; + + std::vector feds = ListOfFEDS(eta, eta, phi - epsilon, phi + epsilon, MUregionEtaMargin_, MUregionPhiMargin_); + + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } } - + if (debug_) { std::cout << std::endl; - for (int i=0; i < (int)FEDs.size(); i++) { + for (int i = 0; i < (int)FEDs.size(); i++) { std::cout << "Muons: unpack FED " << FEDs[i] << std::endl; } std::cout << "Number of FEDS is " << FEDs.size() << std::endl; } - + // return FEDs; - } -void EcalListOfFEDSProducer::Jets(edm::Event& e, const edm::EventSetup& es, std::vector& done, std::vector& FEDs) { - +void EcalListOfFEDSProducer::Jets(edm::Event& e, + const edm::EventSetup& es, + std::vector& done, + std::vector& FEDs) { // std::vector FEDs; - - if (debug_) std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Jets" << std::endl; + + if (debug_) + std::cout << std::endl << std::endl << " enter in EcalListOfFEDSProducer::Jets" << std::endl; double epsilon = 0.01; - + if (JETSdoCentral_) { edm::Handle jetColl; - e.getByToken(CentralSource_,jetColl); - - for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) { - - double pt = it -> pt(); - double eta = it -> eta(); - double phi = it -> phi(); - - if (debug_) std::cout << " here is a L1 CentralJet Seed with (eta,phi) = " << - eta << " " << phi << " and pt " << pt << std::endl; - - if (pt < Ptmin_jets_ ) continue; - - std::vector feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); - - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); + e.getByToken(CentralSource_, jetColl); + + for (L1JetParticleCollection::const_iterator it = jetColl->begin(); it != jetColl->end(); it++) { + double pt = it->pt(); + double eta = it->eta(); + double phi = it->phi(); + + if (debug_) + std::cout << " here is a L1 CentralJet Seed with (eta,phi) = " << eta << " " << phi << " and pt " << pt + << std::endl; + + if (pt < Ptmin_jets_) + continue; + + std::vector feds = + ListOfFEDS(eta, eta, phi - epsilon, phi + epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); + + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } } } - + if (JETSdoForward_) { edm::Handle jetColl; - e.getByToken(ForwardSource_,jetColl); - - for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) { - - double pt = it -> pt(); - double eta = it -> eta(); - double phi = it -> phi(); - - if (debug_) std::cout << " here is a L1 ForwardJet Seed with (eta,phi) = " << - eta << " " << phi << " and pt " << pt << std::endl; - if (pt < Ptmin_jets_ ) continue; - - std::vector feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); - - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); + e.getByToken(ForwardSource_, jetColl); + + for (L1JetParticleCollection::const_iterator it = jetColl->begin(); it != jetColl->end(); it++) { + double pt = it->pt(); + double eta = it->eta(); + double phi = it->phi(); + + if (debug_) + std::cout << " here is a L1 ForwardJet Seed with (eta,phi) = " << eta << " " << phi << " and pt " << pt + << std::endl; + if (pt < Ptmin_jets_) + continue; + + std::vector feds = + ListOfFEDS(eta, eta, phi - epsilon, phi + epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); + + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } } } - + if (JETSdoTau_) { edm::Handle jetColl; - e.getByToken(TauSource_,jetColl); - - for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) { - - double pt = it -> pt(); - double eta = it -> eta(); - double phi = it -> phi(); - - if (debug_) std::cout << " here is a L1 TauJet Seed with (eta,phi) = " << - eta << " " << phi << " and pt " << pt << std::endl; - if (pt < Ptmin_jets_ ) continue; - - std::vector feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); - - for (int i=0; i < (int)feds.size(); i++) { - if ( std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && - std::find(done.begin(), done.end(), feds[i]) == done.end() ) FEDs.push_back(feds[i]); + e.getByToken(TauSource_, jetColl); + + for (L1JetParticleCollection::const_iterator it = jetColl->begin(); it != jetColl->end(); it++) { + double pt = it->pt(); + double eta = it->eta(); + double phi = it->phi(); + + if (debug_) + std::cout << " here is a L1 TauJet Seed with (eta,phi) = " << eta << " " << phi << " and pt " << pt + << std::endl; + if (pt < Ptmin_jets_) + continue; + + std::vector feds = + ListOfFEDS(eta, eta, phi - epsilon, phi + epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_); + + for (int i = 0; i < (int)feds.size(); i++) { + if (std::find(FEDs.begin(), FEDs.end(), feds[i]) == FEDs.end() && + std::find(done.begin(), done.end(), feds[i]) == done.end()) + FEDs.push_back(feds[i]); } } } - - - + if (debug_) { std::cout << std::endl; - for (int i=0; i < (int)FEDs.size(); i++) { + for (int i = 0; i < (int)FEDs.size(); i++) { std::cout << "Jets: unpack FED " << FEDs[i] << std::endl; } std::cout << "Number of FEDS is " << FEDs.size() << std::endl; @@ -402,63 +417,70 @@ void EcalListOfFEDSProducer::Jets(edm::Event& e, const edm::EventSetup& es, std: // return FEDs; } - -std::vector EcalListOfFEDSProducer::ListOfFEDS(double etaLow, double etaHigh, double phiLow, - double phiHigh, double etamargin, double phimargin) { - +std::vector EcalListOfFEDSProducer::ListOfFEDS( + double etaLow, double etaHigh, double phiLow, double phiHigh, double etamargin, double phimargin) { std::vector FEDs; - - if (phimargin > Geom::pi()) phimargin = Geom::pi() ; - - - if (debug_) std::cout << " etaLow etaHigh phiLow phiHigh " << etaLow << " " << - etaHigh << " " << phiLow << " " << phiHigh << std::endl; - + + if (phimargin > Geom::pi()) + phimargin = Geom::pi(); + + if (debug_) + std::cout << " etaLow etaHigh phiLow phiHigh " << etaLow << " " << etaHigh << " " << phiLow << " " << phiHigh + << std::endl; + etaLow -= etamargin; etaHigh += etamargin; double phiMinus = phiLow - phimargin; double phiPlus = phiHigh + phimargin; - + bool all = false; - double dd = fabs(phiPlus-phiMinus); - if (debug_) std::cout << " dd = " << dd << std::endl; - if (dd > 2.*Geom::pi() ) all = true; - - while (phiPlus > Geom::pi()) { phiPlus -= 2.*Geom::pi() ; } - while (phiMinus < 0) { phiMinus += 2.*Geom::pi() ; } - if ( phiMinus > Geom::pi()) phiMinus -= 2.*Geom::pi() ; - + double dd = fabs(phiPlus - phiMinus); + if (debug_) + std::cout << " dd = " << dd << std::endl; + if (dd > 2. * Geom::pi()) + all = true; + + while (phiPlus > Geom::pi()) { + phiPlus -= 2. * Geom::pi(); + } + while (phiMinus < 0) { + phiMinus += 2. * Geom::pi(); + } + if (phiMinus > Geom::pi()) + phiMinus -= 2. * Geom::pi(); + double dphi = phiPlus - phiMinus; - if (dphi < 0) dphi += 2.*Geom::pi() ; - if (debug_) std::cout << "dphi = " << dphi << std::endl; + if (dphi < 0) + dphi += 2. * Geom::pi(); + if (debug_) + std::cout << "dphi = " << dphi << std::endl; if (dphi > Geom::pi()) { - int fed_low1 = TheMapping -> GetFED(etaLow,phiMinus*180./Geom::pi()); - int fed_low2 = TheMapping -> GetFED(etaLow,phiPlus*180./Geom::pi()); - if (debug_) std::cout << "fed_low1 fed_low2 " << fed_low1 << " " << fed_low2 << std::endl; - if (fed_low1 == fed_low2) all = true; - int fed_hi1 = TheMapping -> GetFED(etaHigh,phiMinus*180./Geom::pi()); - int fed_hi2 = TheMapping -> GetFED(etaHigh,phiPlus*180./Geom::pi()); - if (debug_) std::cout << "fed_hi1 fed_hi2 " << fed_hi1 << " " << fed_hi2 << std::endl; - if (fed_hi1 == fed_hi2) all = true; + int fed_low1 = TheMapping->GetFED(etaLow, phiMinus * 180. / Geom::pi()); + int fed_low2 = TheMapping->GetFED(etaLow, phiPlus * 180. / Geom::pi()); + if (debug_) + std::cout << "fed_low1 fed_low2 " << fed_low1 << " " << fed_low2 << std::endl; + if (fed_low1 == fed_low2) + all = true; + int fed_hi1 = TheMapping->GetFED(etaHigh, phiMinus * 180. / Geom::pi()); + int fed_hi2 = TheMapping->GetFED(etaHigh, phiPlus * 180. / Geom::pi()); + if (debug_) + std::cout << "fed_hi1 fed_hi2 " << fed_hi1 << " " << fed_hi2 << std::endl; + if (fed_hi1 == fed_hi2) + all = true; } - - + if (all) { - if (debug_) std::cout << " unpack everything in phi ! " << std::endl; + if (debug_) + std::cout << " unpack everything in phi ! " << std::endl; phiMinus = -20 * Geom::pi() / 180.; // -20 deg - phiPlus = -40 * Geom::pi() / 180.; // -20 deg + phiPlus = -40 * Geom::pi() / 180.; // -20 deg } - - if (debug_) std::cout << " with margins : " << etaLow << " " << etaHigh << " " << - phiMinus << " " << phiPlus << std::endl; - - - const RectangularEtaPhiRegion ecalregion(etaLow,etaHigh,phiMinus,phiPlus); - - FEDs = TheMapping -> GetListofFEDs(ecalregion); - return FEDs; -} - + if (debug_) + std::cout << " with margins : " << etaLow << " " << etaHigh << " " << phiMinus << " " << phiPlus << std::endl; + const RectangularEtaPhiRegion ecalregion(etaLow, etaHigh, phiMinus, phiPlus); + FEDs = TheMapping->GetListofFEDs(ecalregion); + return FEDs; +} diff --git a/RecoEgamma/EgammaHLTProducers/src/EcalRecHitsMerger.cc b/RecoEgamma/EgammaHLTProducers/src/EcalRecHitsMerger.cc index 9b54cbf1b28f5..c8aa2bdcdb2ec 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EcalRecHitsMerger.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EcalRecHitsMerger.cc @@ -11,145 +11,126 @@ #include "FWCore/Utilities/interface/Exception.h" - using namespace edm; using namespace std; - EcalRecHitsMerger::EcalRecHitsMerger(const edm::ParameterSet& pset) { - - debug_ = pset.getUntrackedParameter("debug"); - - EgammaSourceEB_ = pset.getUntrackedParameter("EgammaSource_EB"); - MuonsSourceEB_ = pset.getUntrackedParameter("MuonsSource_EB"); - TausSourceEB_ = pset.getUntrackedParameter("TausSource_EB"); - JetsSourceEB_ = pset.getUntrackedParameter("JetsSource_EB"); - RestSourceEB_ = pset.getUntrackedParameter("RestSource_EB"); - Pi0SourceEB_ = pset.getUntrackedParameter("Pi0Source_EB",edm::InputTag("dummyPi0")); - - EgammaSourceEE_ = pset.getUntrackedParameter("EgammaSource_EE"); - MuonsSourceEE_ = pset.getUntrackedParameter("MuonsSource_EE"); - TausSourceEE_ = pset.getUntrackedParameter("TausSource_EE"); - JetsSourceEE_ = pset.getUntrackedParameter("JetsSource_EE"); - RestSourceEE_ = pset.getUntrackedParameter("RestSource_EE"); - Pi0SourceEE_ = pset.getUntrackedParameter("Pi0Source_EE",edm::InputTag("dummyPi0")); - - OutputLabelEB_ = pset.getUntrackedParameter("OutputLabel_EB"); - OutputLabelEE_ = pset.getUntrackedParameter("OutputLabel_EE"); - - InputRecHitEB_ = pset.getUntrackedParameter("EcalRecHitCollectionEB"); - InputRecHitEE_ = pset.getUntrackedParameter("EcalRecHitCollectionEE"); - - produces(OutputLabelEB_); - produces(OutputLabelEE_); - + debug_ = pset.getUntrackedParameter("debug"); + + EgammaSourceEB_ = pset.getUntrackedParameter("EgammaSource_EB"); + MuonsSourceEB_ = pset.getUntrackedParameter("MuonsSource_EB"); + TausSourceEB_ = pset.getUntrackedParameter("TausSource_EB"); + JetsSourceEB_ = pset.getUntrackedParameter("JetsSource_EB"); + RestSourceEB_ = pset.getUntrackedParameter("RestSource_EB"); + Pi0SourceEB_ = pset.getUntrackedParameter("Pi0Source_EB", edm::InputTag("dummyPi0")); + + EgammaSourceEE_ = pset.getUntrackedParameter("EgammaSource_EE"); + MuonsSourceEE_ = pset.getUntrackedParameter("MuonsSource_EE"); + TausSourceEE_ = pset.getUntrackedParameter("TausSource_EE"); + JetsSourceEE_ = pset.getUntrackedParameter("JetsSource_EE"); + RestSourceEE_ = pset.getUntrackedParameter("RestSource_EE"); + Pi0SourceEE_ = pset.getUntrackedParameter("Pi0Source_EE", edm::InputTag("dummyPi0")); + + OutputLabelEB_ = pset.getUntrackedParameter("OutputLabel_EB"); + OutputLabelEE_ = pset.getUntrackedParameter("OutputLabel_EE"); + + InputRecHitEB_ = pset.getUntrackedParameter("EcalRecHitCollectionEB"); + InputRecHitEE_ = pset.getUntrackedParameter("EcalRecHitCollectionEE"); + + produces(OutputLabelEB_); + produces(OutputLabelEE_); } - - -EcalRecHitsMerger::~EcalRecHitsMerger() { -} +EcalRecHitsMerger::~EcalRecHitsMerger() {} void EcalRecHitsMerger::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("debug", false); - desc.add("EgammaSource_EB", edm::InputTag("ecalRegionalEgammaRecHitTmp","EcalRecHitsEB")); - desc.add("MuonsSource_EB", edm::InputTag("ecalRegionalMuonsRecHitTmp","EcalRecHitsEB")); - desc.add("TausSource_EB", edm::InputTag("ecalRegionalTausRecHitTmp","EcalRecHitsEB")); - desc.add("JetsSource_EB", edm::InputTag("ecalRegionalJetsRecHitTmp","EcalRecHitsEB")); - desc.add("RestSource_EB", edm::InputTag("ecalRegionalRestRecHitTmp","EcalRecHitsEB")); + desc.add("EgammaSource_EB", edm::InputTag("ecalRegionalEgammaRecHitTmp", "EcalRecHitsEB")); + desc.add("MuonsSource_EB", edm::InputTag("ecalRegionalMuonsRecHitTmp", "EcalRecHitsEB")); + desc.add("TausSource_EB", edm::InputTag("ecalRegionalTausRecHitTmp", "EcalRecHitsEB")); + desc.add("JetsSource_EB", edm::InputTag("ecalRegionalJetsRecHitTmp", "EcalRecHitsEB")); + desc.add("RestSource_EB", edm::InputTag("ecalRegionalRestRecHitTmp", "EcalRecHitsEB")); desc.add("Pi0Source_EB", edm::InputTag("dummyPi0")); - desc.add("EgammaSource_EE", edm::InputTag("ecalRegionalEgammaRecHitTmp","EcalRecHitsEE")); - desc.add("MuonsSource_EE", edm::InputTag("ecalRegionalMuonsRecHitTmp","EcalRecHitsEE")); - desc.add("TausSource_EE", edm::InputTag("ecalRegionalTausRecHitTmp","EcalRecHitsEE")); - desc.add("JetsSource_EE", edm::InputTag("ecalRegionalJetsRecHitTmp","EcalRecHitsEE")); - desc.add("RestSource_EE", edm::InputTag("ecalRegionalRestRecHitTmp","EcalRecHitsEE")); + desc.add("EgammaSource_EE", edm::InputTag("ecalRegionalEgammaRecHitTmp", "EcalRecHitsEE")); + desc.add("MuonsSource_EE", edm::InputTag("ecalRegionalMuonsRecHitTmp", "EcalRecHitsEE")); + desc.add("TausSource_EE", edm::InputTag("ecalRegionalTausRecHitTmp", "EcalRecHitsEE")); + desc.add("JetsSource_EE", edm::InputTag("ecalRegionalJetsRecHitTmp", "EcalRecHitsEE")); + desc.add("RestSource_EE", edm::InputTag("ecalRegionalRestRecHitTmp", "EcalRecHitsEE")); desc.add("Pi0Source_EE", edm::InputTag("dummyPi0")); desc.add("OutputLabel_EB", "EcalRecHitsEB"); desc.add("OutputLabel_EE", "EcalRecHitsEE"); desc.add("EcalRecHitCollectionEB", "EcalRecHitsEB"); desc.add("EcalRecHitCollectionEE", "EcalRecHitsEE"); - descriptions.add("hltEcalRecHitsMerger", desc); -} - -void EcalRecHitsMerger::beginJob(){ -} - -void EcalRecHitsMerger::endJob(){ + descriptions.add("hltEcalRecHitsMerger", desc); } -void EcalRecHitsMerger::produce(edm::StreamID, edm::Event & e, const edm::EventSetup& iSetup) const { - - if (debug_) std::cout << " EcalRecHitMerger : Run " << e.id().run() << " Event " << e.id().event() << std::endl; - - std::vector< edm::Handle > EcalRecHits_done; - e.getManyByType(EcalRecHits_done); - - auto EBMergedRecHits = std::make_unique(); - auto EEMergedRecHits = std::make_unique(); - - unsigned int nColl = EcalRecHits_done.size(); +void EcalRecHitsMerger::beginJob() {} - int nEB = 0; - int nEE = 0; +void EcalRecHitsMerger::endJob() {} +void EcalRecHitsMerger::produce(edm::StreamID, edm::Event& e, const edm::EventSetup& iSetup) const { + if (debug_) + std::cout << " EcalRecHitMerger : Run " << e.id().run() << " Event " << e.id().event() << std::endl; - for (unsigned int i=0; i < nColl; i++) { + std::vector > EcalRecHits_done; + e.getManyByType(EcalRecHits_done); - std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); - std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel(); + auto EBMergedRecHits = std::make_unique(); + auto EEMergedRecHits = std::make_unique(); - if ( module_label != EgammaSourceEB_.label() && - module_label != MuonsSourceEB_.label() && - module_label != JetsSourceEB_.label() && - module_label != TausSourceEB_.label() && - module_label != RestSourceEB_.label() && - module_label != Pi0SourceEB_.label() ) continue; + unsigned int nColl = EcalRecHits_done.size(); - if (instance == InputRecHitEB_) { - nEB += EcalRecHits_done[i] -> size(); - } - else if (instance == InputRecHitEE_) { - nEE += EcalRecHits_done[i] -> size(); - } + int nEB = 0; + int nEE = 0; - } + for (unsigned int i = 0; i < nColl; i++) { + std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); + std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel(); - EBMergedRecHits -> reserve(nEB); - EEMergedRecHits -> reserve(nEE); - if (debug_) std::cout << " Number of EB Rechits to merge = " << nEB << std::endl; - if (debug_) std::cout << " Number of EE Rechits to merge = " << nEE << std::endl; - - for (unsigned int i=0; i < nColl; i++) { - std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); - - std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel(); - if ( module_label != EgammaSourceEB_.label() && - module_label != MuonsSourceEB_.label() && - module_label != JetsSourceEB_.label() && - module_label != TausSourceEB_.label() && - module_label != RestSourceEB_.label() && - module_label != Pi0SourceEB_.label() ) continue; + if (module_label != EgammaSourceEB_.label() && module_label != MuonsSourceEB_.label() && + module_label != JetsSourceEB_.label() && module_label != TausSourceEB_.label() && + module_label != RestSourceEB_.label() && module_label != Pi0SourceEB_.label()) + continue; if (instance == InputRecHitEB_) { - for (EcalRecHitCollection::const_iterator it=EcalRecHits_done[i]->begin(); it !=EcalRecHits_done[i]->end(); it++) { - EBMergedRecHits -> push_back(*it); - } - } - else if (instance == InputRecHitEE_) { - for (EcalRecHitCollection::const_iterator it=EcalRecHits_done[i]->begin(); it !=EcalRecHits_done[i]->end(); it++) { - EEMergedRecHits -> push_back(*it); - } - } - - } - - - // std::cout << " avant le put " << std::endl; - e.put(std::move(EBMergedRecHits),OutputLabelEB_); - e.put(std::move(EEMergedRecHits),OutputLabelEE_); - // std::cout << " apres le put " << std::endl; + nEB += EcalRecHits_done[i]->size(); + } else if (instance == InputRecHitEE_) { + nEE += EcalRecHits_done[i]->size(); + } + } + + EBMergedRecHits->reserve(nEB); + EEMergedRecHits->reserve(nEE); + if (debug_) + std::cout << " Number of EB Rechits to merge = " << nEB << std::endl; + if (debug_) + std::cout << " Number of EE Rechits to merge = " << nEE << std::endl; + + for (unsigned int i = 0; i < nColl; i++) { + std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); + + std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel(); + if (module_label != EgammaSourceEB_.label() && module_label != MuonsSourceEB_.label() && + module_label != JetsSourceEB_.label() && module_label != TausSourceEB_.label() && + module_label != RestSourceEB_.label() && module_label != Pi0SourceEB_.label()) + continue; + if (instance == InputRecHitEB_) { + for (EcalRecHitCollection::const_iterator it = EcalRecHits_done[i]->begin(); it != EcalRecHits_done[i]->end(); + it++) { + EBMergedRecHits->push_back(*it); + } + } else if (instance == InputRecHitEE_) { + for (EcalRecHitCollection::const_iterator it = EcalRecHits_done[i]->begin(); it != EcalRecHits_done[i]->end(); + it++) { + EEMergedRecHits->push_back(*it); + } + } + } + + // std::cout << " avant le put " << std::endl; + e.put(std::move(EBMergedRecHits), OutputLabelEB_); + e.put(std::move(EEMergedRecHits), OutputLabelEE_); + // std::cout << " apres le put " << std::endl; } - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTBcHcalIsolationProducersRegional.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTBcHcalIsolationProducersRegional.cc index e9c87f43896eb..e48cd067b44e1 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTBcHcalIsolationProducersRegional.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTBcHcalIsolationProducersRegional.cc @@ -28,23 +28,23 @@ #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" -EgammaHLTBcHcalIsolationProducersRegional::EgammaHLTBcHcalIsolationProducersRegional(const edm::ParameterSet& config) : - doEtSum_( config.getParameter("doEtSum") ), - etMin_( config.getParameter("etMin") ), - innerCone_( config.getParameter("innerCone") ), - outerCone_( config.getParameter("outerCone") ), - depth_( config.getParameter("depth") ), - useSingleTower_( config.getParameter("useSingleTower") ), - doRhoCorrection_( config.getParameter("doRhoCorrection") ), - rhoScale_( config.getParameter("rhoScale") ), - rhoMax_( config.getParameter("rhoMax") ), - effectiveAreas_( config.getParameter >("effectiveAreas") ), - absEtaLowEdges_( config.getParameter >("absEtaLowEdges") ), - recoEcalCandidateProducer_( consumes(config.getParameter("recoEcalCandidateProducer")) ), - caloTowerProducer_( consumes(config.getParameter("caloTowerProducer")) ), - rhoProducer_( doRhoCorrection_ ? consumes(config.getParameter("rhoProducer")) : edm::EDGetTokenT() ) -{ - +EgammaHLTBcHcalIsolationProducersRegional::EgammaHLTBcHcalIsolationProducersRegional(const edm::ParameterSet& config) + : doEtSum_(config.getParameter("doEtSum")), + etMin_(config.getParameter("etMin")), + innerCone_(config.getParameter("innerCone")), + outerCone_(config.getParameter("outerCone")), + depth_(config.getParameter("depth")), + useSingleTower_(config.getParameter("useSingleTower")), + doRhoCorrection_(config.getParameter("doRhoCorrection")), + rhoScale_(config.getParameter("rhoScale")), + rhoMax_(config.getParameter("rhoMax")), + effectiveAreas_(config.getParameter >("effectiveAreas")), + absEtaLowEdges_(config.getParameter >("absEtaLowEdges")), + recoEcalCandidateProducer_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + caloTowerProducer_(consumes(config.getParameter("caloTowerProducer"))), + rhoProducer_(doRhoCorrection_ ? consumes(config.getParameter("rhoProducer")) + : edm::EDGetTokenT()) { if (doRhoCorrection_) { if (absEtaLowEdges_.size() != effectiveAreas_.size()) throw cms::Exception("IncompatibleVects") << "absEtaLowEdges and effectiveAreas should be of the same size. \n"; @@ -53,27 +53,24 @@ EgammaHLTBcHcalIsolationProducersRegional::EgammaHLTBcHcalIsolationProducersRegi throw cms::Exception("IncompleteCoverage") << "absEtaLowEdges should start from 0. \n"; for (unsigned int aIt = 0; aIt < absEtaLowEdges_.size() - 1; aIt++) { - if ( !(absEtaLowEdges_.at( aIt ) < absEtaLowEdges_.at( aIt + 1 )) ) + if (!(absEtaLowEdges_.at(aIt) < absEtaLowEdges_.at(aIt + 1))) throw cms::Exception("ImproperBinning") << "absEtaLowEdges entries should be in increasing order. \n"; } } ElectronHcalHelper::Configuration hcalCfg; - hcalCfg.hOverEConeSize = outerCone_; - hcalCfg.useTowers = true; - hcalCfg.hcalTowers = caloTowerProducer_; - hcalCfg.hOverEPtMin = etMin_; + hcalCfg.hOverEConeSize = outerCone_; + hcalCfg.useTowers = true; + hcalCfg.hcalTowers = caloTowerProducer_; + hcalCfg.hOverEPtMin = etMin_; hcalHelper_ = new ElectronHcalHelper(hcalCfg); produces(); } -EgammaHLTBcHcalIsolationProducersRegional::~EgammaHLTBcHcalIsolationProducersRegional() { - delete hcalHelper_; -} +EgammaHLTBcHcalIsolationProducersRegional::~EgammaHLTBcHcalIsolationProducersRegional() { delete hcalHelper_; } void EgammaHLTBcHcalIsolationProducersRegional::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalCandidate")); @@ -88,13 +85,12 @@ void EgammaHLTBcHcalIsolationProducersRegional::fillDescriptions(edm::Configurat desc.add(("depth"), -1); desc.add(("doEtSum"), false); desc.add(("useSingleTower"), false); - desc.add >("effectiveAreas", {0.079, 0.25}); // 2016 post-ichep sinEle default - desc.add >("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap + desc.add >("effectiveAreas", {0.079, 0.25}); // 2016 post-ichep sinEle default + desc.add >("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap descriptions.add(("hltEgammaHLTBcHcalIsolationProducersRegional"), desc); } void EgammaHLTBcHcalIsolationProducersRegional::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { - // Get the HLT filtered objects edm::Handle recoEcalCandHandle; iEvent.getByToken(recoEcalCandidateProducer_, recoEcalCandHandle); @@ -113,15 +109,14 @@ void EgammaHLTBcHcalIsolationProducersRegional::produce(edm::Event& iEvent, cons if (rho > rhoMax_) rho = rhoMax_; - rho = rho*rhoScale_; + rho = rho * rhoScale_; hcalHelper_->checkSetup(iSetup); hcalHelper_->readEvent(iEvent); reco::RecoEcalCandidateIsolationMap isoMap(recoEcalCandHandle); - for(unsigned int iRecoEcalCand=0; iRecoEcalCand size(); iRecoEcalCand++) { - + for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoEcalCandHandle->size(); iRecoEcalCand++) { reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand); float isol = 0; @@ -131,31 +126,32 @@ void EgammaHLTBcHcalIsolationProducersRegional::produce(edm::Event& iEvent, cons if (useSingleTower_) towersBehindCluster = hcalHelper_->hcalTowersBehindClusters(*(recoEcalCandRef->superCluster())); - if (doEtSum_) { //calculate hcal isolation excluding the towers behind the cluster which will be used for H for H/E + if (doEtSum_) { //calculate hcal isolation excluding the towers behind the cluster which will be used for H for H/E EgammaTowerIsolation isolAlgo(outerCone_, innerCone_, etMin_, depth_, caloTowersHandle.product()); if (useSingleTower_) - isol = isolAlgo.getTowerEtSum(&(*recoEcalCandRef), &(towersBehindCluster)); // towersBehindCluster are excluded from the isolation sum + isol = isolAlgo.getTowerEtSum( + &(*recoEcalCandRef), &(towersBehindCluster)); // towersBehindCluster are excluded from the isolation sum else - isol = isolAlgo.getTowerEtSum(&(*recoEcalCandRef)); + isol = isolAlgo.getTowerEtSum(&(*recoEcalCandRef)); - } else { //calcuate H for H/E + } else { //calcuate H for H/E if (useSingleTower_) - isol = hcalHelper_->hcalESumDepth1BehindClusters(towersBehindCluster) + hcalHelper_->hcalESumDepth2BehindClusters(towersBehindCluster); + isol = hcalHelper_->hcalESumDepth1BehindClusters(towersBehindCluster) + + hcalHelper_->hcalESumDepth2BehindClusters(towersBehindCluster); else - isol = hcalHelper_->hcalESum(*(recoEcalCandRef->superCluster())); - + isol = hcalHelper_->hcalESum(*(recoEcalCandRef->superCluster())); } if (doRhoCorrection_) { int iEA = -1; auto scEta = std::abs(recoEcalCandRef->superCluster()->eta()); for (int bIt = absEtaLowEdges_.size() - 1; bIt > -1; bIt--) { - if ( scEta > absEtaLowEdges_.at(bIt) ) { + if (scEta > absEtaLowEdges_.at(bIt)) { iEA = bIt; break; } } - isol = isol - rho*effectiveAreas_.at(iEA); + isol = isol - rho * effectiveAreas_.at(iEA); } isoMap.insert(recoEcalCandRef, isol); diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTCaloTowerProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTCaloTowerProducer.cc index ab9776a35e835..341ab66ea3326 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTCaloTowerProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTCaloTowerProducer.cc @@ -22,69 +22,68 @@ using namespace edm; using namespace reco; using namespace std; -using namespace l1extra ; +using namespace l1extra; -EgammaHLTCaloTowerProducer::EgammaHLTCaloTowerProducer( const ParameterSet & p ) : towers_ (consumes(p.getParameter ("towerCollection"))), - cone_ (p.getParameter ("useTowersInCone")), - l1isoseeds_ (consumes>(p.getParameter< edm::InputTag > ("L1IsoCand"))), - l1nonisoseeds_ (consumes>(p.getParameter< edm::InputTag > ("L1NonIsoCand"))), - EtThreshold_ (p.getParameter ("EtMin")), - EThreshold_ (p.getParameter ("EMin")) { - +EgammaHLTCaloTowerProducer::EgammaHLTCaloTowerProducer(const ParameterSet& p) + : towers_(consumes(p.getParameter("towerCollection"))), + cone_(p.getParameter("useTowersInCone")), + l1isoseeds_(consumes>(p.getParameter("L1IsoCand"))), + l1nonisoseeds_(consumes>(p.getParameter("L1NonIsoCand"))), + EtThreshold_(p.getParameter("EtMin")), + EThreshold_(p.getParameter("EMin")) { produces(); } void EgammaHLTCaloTowerProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - + desc.add(("towerCollection"), edm::InputTag("hltRecoEcalCandidate")); desc.add(("L1IsoCand"), edm::InputTag("hltTowerMakerForAll")); desc.add(("L1NonIsoCand"), edm::InputTag("fixedGridRhoFastjetAllCalo")); - desc.add(("useTowersInCone"), 0.8); - desc.add(("EtMin"), 1.0); - desc.add(("EMin"), 1.0); - descriptions.add(("hltCaloTowerForEgamma"), desc); + desc.add(("useTowersInCone"), 0.8); + desc.add(("EtMin"), 1.0); + desc.add(("EMin"), 1.0); + descriptions.add(("hltCaloTowerForEgamma"), desc); } - -void EgammaHLTCaloTowerProducer::produce(edm::StreamID, edm::Event & evt, edm::EventSetup const &) const -{ +void EgammaHLTCaloTowerProducer::produce(edm::StreamID, edm::Event& evt, edm::EventSetup const&) const { edm::Handle caloTowers; evt.getByToken(towers_, caloTowers); edm::Handle> emIsolColl; evt.getByToken(l1isoseeds_, emIsolColl); - edm::Handle > emNonIsolColl; + edm::Handle> emNonIsolColl; evt.getByToken(l1nonisoseeds_, emNonIsolColl); auto cands = std::make_unique(); cands->reserve(caloTowers->size()); for (unsigned idx = 0; idx < caloTowers->size(); idx++) { - const CaloTower* cal = &((*caloTowers) [idx]); + const CaloTower* cal = &((*caloTowers)[idx]); if (cal->et() >= EtThreshold_ && cal->energy() >= EThreshold_) { bool fill = false; math::PtEtaPhiELorentzVector p(cal->et(), cal->eta(), cal->phi(), cal->energy()); - for (edm::View::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr) { - double delta = ROOT::Math::VectorUtil::DeltaR((*emItr).p4().Vect(), p); - if(delta < cone_) { - cands->push_back(*cal); - fill = true; - break; - } + for (edm::View::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end(); + ++emItr) { + double delta = ROOT::Math::VectorUtil::DeltaR((*emItr).p4().Vect(), p); + if (delta < cone_) { + cands->push_back(*cal); + fill = true; + break; + } } - + if (!fill) { - for(edm::View::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr) { - double delta = ROOT::Math::VectorUtil::DeltaR((*emItr).p4().Vect(), p); - if(delta < cone_) { - cands->push_back(*cal); - break; - } - } + for (edm::View::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end(); + ++emItr) { + double delta = ROOT::Math::VectorUtil::DeltaR((*emItr).p4().Vect(), p); + if (delta < cone_) { + cands->push_back(*cal); + break; + } + } } } } - evt.put(std::move(cands)); + evt.put(std::move(cands)); } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTClusterShapeProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTClusterShapeProducer.cc index 9f37f65df408a..5753e76a89375 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTClusterShapeProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTClusterShapeProducer.cc @@ -15,66 +15,62 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -EgammaHLTClusterShapeProducer::EgammaHLTClusterShapeProducer(const edm::ParameterSet& config) : - recoEcalCandidateProducer_(consumes(config.getParameter("recoEcalCandidateProducer"))), - ecalRechitEBToken_(consumes(config.getParameter< edm::InputTag > ("ecalRechitEB"))), - ecalRechitEEToken_(consumes(config.getParameter< edm::InputTag > ("ecalRechitEE"))), - EtaOrIeta_(config.getParameter< bool > ("isIeta")) { - +EgammaHLTClusterShapeProducer::EgammaHLTClusterShapeProducer(const edm::ParameterSet& config) + : recoEcalCandidateProducer_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + ecalRechitEBToken_(consumes(config.getParameter("ecalRechitEB"))), + ecalRechitEEToken_(consumes(config.getParameter("ecalRechitEE"))), + EtaOrIeta_(config.getParameter("isIeta")) { //register your products - produces < reco::RecoEcalCandidateIsolationMap >(); - produces < reco::RecoEcalCandidateIsolationMap >("sigmaIEtaIEta5x5"); + produces(); + produces("sigmaIEtaIEta5x5"); } -EgammaHLTClusterShapeProducer::~EgammaHLTClusterShapeProducer() -{} +EgammaHLTClusterShapeProducer::~EgammaHLTClusterShapeProducer() {} void EgammaHLTClusterShapeProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add(("recoEcalCandidateProducer"), edm::InputTag("hltL1SeededRecoEcalCandidate")); - desc.add< edm::InputTag >(("ecalRechitEB"), edm::InputTag("hltEcalRegionalEgammaRecHit","EcalRecHitsEB")); - desc.add< edm::InputTag >(("ecalRechitEE"), edm::InputTag("hltEcalRegionalEgammaRecHit","EcalRecHitsEE")); - desc.add< bool >(("isIeta"), true); - descriptions.add(("hltEgammaHLTClusterShapeProducer"), desc); + desc.add(("ecalRechitEB"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEB")); + desc.add(("ecalRechitEE"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEE")); + desc.add(("isIeta"), true); + descriptions.add(("hltEgammaHLTClusterShapeProducer"), desc); } -void EgammaHLTClusterShapeProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTClusterShapeProducer::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { // Get the HLT filtered objects edm::Handle recoecalcandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); + iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); - EcalClusterLazyTools lazyTools( iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_ ); - noZS::EcalClusterLazyTools lazyTools5x5(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_ ); + EcalClusterLazyTools lazyTools(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); + noZS::EcalClusterLazyTools lazyTools5x5(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); reco::RecoEcalCandidateIsolationMap clshMap(recoecalcandHandle); reco::RecoEcalCandidateIsolationMap clsh5x5Map(recoecalcandHandle); - - - for(unsigned int iRecoEcalCand = 0; iRecoEcalCandsize(); iRecoEcalCand++) { - + + for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoecalcandHandle->size(); iRecoEcalCand++) { reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand); - - std::vector vCov ; + + std::vector vCov; double sigmaee; if (EtaOrIeta_) { - vCov = lazyTools.localCovariances( *(recoecalcandref->superCluster()->seed()) ); + vCov = lazyTools.localCovariances(*(recoecalcandref->superCluster()->seed())); sigmaee = sqrt(vCov[0]); } else { - vCov = lazyTools.covariances( *(recoecalcandref->superCluster()->seed()) ); + vCov = lazyTools.covariances(*(recoecalcandref->superCluster()->seed())); sigmaee = sqrt(vCov[0]); double EtaSC = recoecalcandref->eta(); - if (EtaSC > 1.479) sigmaee = sigmaee - 0.02*(EtaSC - 2.3); + if (EtaSC > 1.479) + sigmaee = sigmaee - 0.02 * (EtaSC - 2.3); } - - double sigmaee5x5 = sqrt(lazyTools5x5.localCovariances(*(recoecalcandref->superCluster()->seed()) )[0]); - clshMap.insert(recoecalcandref, sigmaee); - clsh5x5Map.insert(recoecalcandref,sigmaee5x5); - + double sigmaee5x5 = sqrt(lazyTools5x5.localCovariances(*(recoecalcandref->superCluster()->seed()))[0]); + clshMap.insert(recoecalcandref, sigmaee); + clsh5x5Map.insert(recoecalcandref, sigmaee5x5); } iEvent.put(std::make_unique(clshMap)); - iEvent.put(std::make_unique(clsh5x5Map),"sigmaIEtaIEta5x5"); + iEvent.put(std::make_unique(clsh5x5Map), "sigmaIEtaIEta5x5"); } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTCombinedIsolationProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTCombinedIsolationProducer.cc index 405ccf6009b3d..cb03f9a37c18e 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTCombinedIsolationProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTCombinedIsolationProducer.cc @@ -15,71 +15,71 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -EgammaHLTCombinedIsolationProducer::EgammaHLTCombinedIsolationProducer(const edm::ParameterSet& config) : conf_(config) -{ - // use configuration file to setup input/output collection names - recoEcalCandidateProducer_ = consumes(conf_.getParameter("recoEcalCandidateProducer")); - - std::vector tempIsolTag = conf_.getParameter< std::vector > ("IsolationMapTags"); - for (unsigned int i=0; i(conf_.getParameter("recoEcalCandidateProducer")); + + std::vector tempIsolTag = conf_.getParameter>("IsolationMapTags"); + for (unsigned int i = 0; i < tempIsolTag.size(); i++) IsolTag_.push_back(consumes(tempIsolTag[i])); - - IsolWeight_ = conf_.getParameter< std::vector > ("IsolationWeight"); + + IsolWeight_ = conf_.getParameter>("IsolationWeight"); //register your products - produces < reco::RecoEcalCandidateIsolationMap >(); + produces(); - if (IsolTag_.size() != IsolWeight_.size()){ + if (IsolTag_.size() != IsolWeight_.size()) { throw cms::Exception("BadConfig") << "vectors IsolationMapTags and IsolationWeight need to have the same size"; } } -EgammaHLTCombinedIsolationProducer::~EgammaHLTCombinedIsolationProducer() -{} +EgammaHLTCombinedIsolationProducer::~EgammaHLTCombinedIsolationProducer() {} void EgammaHLTCombinedIsolationProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidate")); - desc.add>("IsolationMapTags", std::vector()); + desc.add>("IsolationMapTags", std::vector()); desc.add>("IsolationWeight", std::vector()); - descriptions.add("hltEgammaHLTCombinedIsolationProducer", desc); + descriptions.add("hltEgammaHLTCombinedIsolationProducer", desc); } - // ------------ method called to produce the data ------------ -void -EgammaHLTCombinedIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTCombinedIsolationProducer::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { edm::Handle recoecalcandHandle; iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); reco::RecoEcalCandidateIsolationMap TotalIsolMap; - double TotalIso=0; + double TotalIso = 0; - std::vector< edm::Handle > IsoMap; - for( unsigned int u=0; u < IsolWeight_.size(); u++){ + std::vector> IsoMap; + for (unsigned int u = 0; u < IsolWeight_.size(); u++) { edm::Handle depMapTemp; - if(IsolWeight_[u] != 0) + if (IsolWeight_[u] != 0) iEvent.getByToken(IsolTag_[u], depMapTemp); - + IsoMap.push_back(depMapTemp); } - - for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){ - reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand-recoecalcandHandle->begin()); - TotalIso = 0; - for( unsigned int u=0; u < IsolWeight_.size(); u++){ - if(IsolWeight_[u]==0){continue;} - reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*IsoMap[u]).find( recoecalcandref ); + + for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); + iRecoEcalCand != recoecalcandHandle->end(); + iRecoEcalCand++) { + reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand - recoecalcandHandle->begin()); + TotalIso = 0; + for (unsigned int u = 0; u < IsolWeight_.size(); u++) { + if (IsolWeight_[u] == 0) { + continue; + } + reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*IsoMap[u]).find(recoecalcandref); TotalIso += mapi->val * IsolWeight_[u]; } TotalIsolMap.insert(recoecalcandref, TotalIso); - } iEvent.put(std::make_unique(TotalIsolMap)); - } //define this as a plug-in diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTEcalIsolationProducersRegional.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTEcalIsolationProducersRegional.cc index ae6532236f0b7..ebd42d67a7bd8 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTEcalIsolationProducersRegional.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTEcalIsolationProducersRegional.cc @@ -15,28 +15,27 @@ #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" EgammaHLTEcalIsolationProducersRegional::EgammaHLTEcalIsolationProducersRegional(const edm::ParameterSet& config) - : conf_(config) - , recoEcalCandidateProducer_ (consumes(conf_.getParameter("recoEcalCandidateProducer"))) - , bcBarrelProducer_ (consumes(conf_.getParameter("bcBarrelProducer"))) - , bcEndcapProducer_ (consumes(conf_.getParameter("bcEndcapProducer"))) - , scIslandBarrelProducer_ (consumes(conf_.getParameter("scIslandBarrelProducer"))) - , scIslandEndcapProducer_ (consumes(conf_.getParameter("scIslandEndcapProducer"))) - , egEcalIsoEtMin_ (conf_.getParameter("egEcalIsoEtMin")) - , egEcalIsoConeSize_ (conf_.getParameter("egEcalIsoConeSize")) - , algoType_ (conf_.getParameter("SCAlgoType")) - , test_ (new EgammaHLTEcalIsolation(egEcalIsoEtMin_,egEcalIsoConeSize_,algoType_)) -{ - + : conf_(config), + recoEcalCandidateProducer_( + consumes(conf_.getParameter("recoEcalCandidateProducer"))), + bcBarrelProducer_(consumes(conf_.getParameter("bcBarrelProducer"))), + bcEndcapProducer_(consumes(conf_.getParameter("bcEndcapProducer"))), + scIslandBarrelProducer_( + consumes(conf_.getParameter("scIslandBarrelProducer"))), + scIslandEndcapProducer_( + consumes(conf_.getParameter("scIslandEndcapProducer"))), + egEcalIsoEtMin_(conf_.getParameter("egEcalIsoEtMin")), + egEcalIsoConeSize_(conf_.getParameter("egEcalIsoConeSize")), + algoType_(conf_.getParameter("SCAlgoType")), + test_(new EgammaHLTEcalIsolation(egEcalIsoEtMin_, egEcalIsoConeSize_, algoType_)) { //register your products - produces < reco::RecoEcalCandidateIsolationMap >(); + produces(); } -EgammaHLTEcalIsolationProducersRegional::~EgammaHLTEcalIsolationProducersRegional() { - delete test_; -} +EgammaHLTEcalIsolationProducersRegional::~EgammaHLTEcalIsolationProducersRegional() { delete test_; } void EgammaHLTEcalIsolationProducersRegional::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; + edm::ParameterSetDescription desc; desc.add("bcBarrelProducer", edm::InputTag("")); desc.add("bcEndcapProducer", edm::InputTag("")); desc.add("scIslandBarrelProducer", edm::InputTag("")); @@ -45,12 +44,12 @@ void EgammaHLTEcalIsolationProducersRegional::fillDescriptions(edm::Configuratio desc.add("egEcalIsoEtMin", 0.); desc.add("egEcalIsoConeSize", 0.3); desc.add("SCAlgoType", 1); - descriptions.add("hltEgammaHLTEcalIsolationProducersRegional", desc); + descriptions.add("hltEgammaHLTEcalIsolationProducersRegional", desc); } - -void EgammaHLTEcalIsolationProducersRegional::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTEcalIsolationProducersRegional::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { // Get the basic cluster collection in the Barrel edm::Handle bcBarrelHandle; iEvent.getByToken(bcBarrelProducer_, bcBarrelHandle); @@ -61,44 +60,52 @@ void EgammaHLTEcalIsolationProducersRegional::produce(edm::StreamID sid, edm::Ev const reco::BasicClusterCollection* clusterEndcapCollection = (bcEndcapHandle.product()); // Get the Barrel Super Cluster collection edm::Handle scBarrelHandle; - iEvent.getByToken(scIslandBarrelProducer_,scBarrelHandle); + iEvent.getByToken(scIslandBarrelProducer_, scBarrelHandle); const reco::SuperClusterCollection* scBarrelCollection = (scBarrelHandle.product()); // Get the Endcap Super Cluster collection edm::Handle scEndcapHandle; - iEvent.getByToken(scIslandEndcapProducer_,scEndcapHandle); + iEvent.getByToken(scIslandEndcapProducer_, scEndcapHandle); const reco::SuperClusterCollection* scEndcapCollection = (scEndcapHandle.product()); // Get the RecoEcalCandidate Collection edm::Handle recoecalcandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); + iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); std::vector clusterCollection; - for (reco::BasicClusterCollection::const_iterator ibc = clusterBarrelCollection->begin(); - ibc < clusterBarrelCollection->end(); ibc++ ){clusterCollection.push_back(&(*ibc));} - for (reco::BasicClusterCollection::const_iterator iec = clusterEndcapCollection->begin(); - iec < clusterEndcapCollection->end(); iec++ ){clusterCollection.push_back(&(*iec));} + for (reco::BasicClusterCollection::const_iterator ibc = clusterBarrelCollection->begin(); + ibc < clusterBarrelCollection->end(); + ibc++) { + clusterCollection.push_back(&(*ibc)); + } + for (reco::BasicClusterCollection::const_iterator iec = clusterEndcapCollection->begin(); + iec < clusterEndcapCollection->end(); + iec++) { + clusterCollection.push_back(&(*iec)); + } std::vector scCollection; - for (reco::SuperClusterCollection::const_iterator ibsc = scBarrelCollection->begin(); - ibsc < scBarrelCollection->end(); ibsc++ ){scCollection.push_back(&(*ibsc));} - for (reco::SuperClusterCollection::const_iterator iesc = scEndcapCollection->begin(); - iesc < scEndcapCollection->end(); iesc++ ){scCollection.push_back(&(*iesc));} + for (reco::SuperClusterCollection::const_iterator ibsc = scBarrelCollection->begin(); + ibsc < scBarrelCollection->end(); + ibsc++) { + scCollection.push_back(&(*ibsc)); + } + for (reco::SuperClusterCollection::const_iterator iesc = scEndcapCollection->begin(); + iesc < scEndcapCollection->end(); + iesc++) { + scCollection.push_back(&(*iesc)); + } reco::RecoEcalCandidateIsolationMap isoMap; + for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); + iRecoEcalCand != recoecalcandHandle->end(); + iRecoEcalCand++) { + reco::RecoEcalCandidateRef recoecalcandref( + reco::RecoEcalCandidateRef(recoecalcandHandle, iRecoEcalCand - recoecalcandHandle->begin())); - - for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand= recoecalcandHandle->begin(); iRecoEcalCand!=recoecalcandHandle->end(); iRecoEcalCand++) { - - - reco::RecoEcalCandidateRef recoecalcandref(reco::RecoEcalCandidateRef(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin())); - - - const reco::RecoCandidate *tempiRecoEcalCand = &(*recoecalcandref); - float isol = test_->isolPtSum(tempiRecoEcalCand,scCollection, clusterCollection); + const reco::RecoCandidate* tempiRecoEcalCand = &(*recoecalcandref); + float isol = test_->isolPtSum(tempiRecoEcalCand, scCollection, clusterCollection); isoMap.insert(recoecalcandref, isol); - } iEvent.put(std::make_unique(isoMap)); - } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTEcalRecIsolationProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTEcalRecIsolationProducer.cc index fc4b3175dc04f..218735a1c8b4c 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTEcalRecIsolationProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTEcalRecIsolationProducer.cc @@ -7,7 +7,6 @@ //============================================================================= //***************************************************************************** - #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalRecIsolationProducer.h" #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h" @@ -22,53 +21,53 @@ #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" EgammaHLTEcalRecIsolationProducer::EgammaHLTEcalRecIsolationProducer(const edm::ParameterSet& config) : conf_(config) { - - recoEcalCandidateProducer_ = consumes(conf_.getParameter("recoEcalCandidateProducer")); - ecalBarrelRecHitProducer_ = consumes(conf_.getParameter("ecalBarrelRecHitProducer")); - ecalEndcapRecHitProducer_ = consumes(conf_.getParameter("ecalEndcapRecHitProducer")); - - doRhoCorrection_ = config.getParameter("doRhoCorrection"); + recoEcalCandidateProducer_ = + consumes(conf_.getParameter("recoEcalCandidateProducer")); + ecalBarrelRecHitProducer_ = + consumes(conf_.getParameter("ecalBarrelRecHitProducer")); + ecalEndcapRecHitProducer_ = + consumes(conf_.getParameter("ecalEndcapRecHitProducer")); + + doRhoCorrection_ = config.getParameter("doRhoCorrection"); if (doRhoCorrection_) - rhoProducer_ = consumes(config.getParameter("rhoProducer")); + rhoProducer_ = consumes(config.getParameter("rhoProducer")); - rhoMax_ = config.getParameter("rhoMax"); - rhoScale_ = config.getParameter("rhoScale"); + rhoMax_ = config.getParameter("rhoMax"); + rhoScale_ = config.getParameter("rhoScale"); //vetos - egIsoPtMinBarrel_ = conf_.getParameter("etMinBarrel"); - egIsoEMinBarrel_ = conf_.getParameter("eMinBarrel"); - egIsoPtMinEndcap_ = conf_.getParameter("etMinEndcap"); - egIsoEMinEndcap_ = conf_.getParameter("eMinEndcap"); - egIsoConeSizeInBarrel_ = conf_.getParameter("intRadiusBarrel"); - egIsoConeSizeInEndcap_ = conf_.getParameter("intRadiusEndcap"); - egIsoConeSizeOut_ = conf_.getParameter("extRadius"); - egIsoJurassicWidth_ = conf_.getParameter("jurassicWidth"); - effectiveAreaBarrel_ = config.getParameter("effectiveAreaBarrel"); - effectiveAreaEndcap_ = config.getParameter("effectiveAreaEndcap"); - + egIsoPtMinBarrel_ = conf_.getParameter("etMinBarrel"); + egIsoEMinBarrel_ = conf_.getParameter("eMinBarrel"); + egIsoPtMinEndcap_ = conf_.getParameter("etMinEndcap"); + egIsoEMinEndcap_ = conf_.getParameter("eMinEndcap"); + egIsoConeSizeInBarrel_ = conf_.getParameter("intRadiusBarrel"); + egIsoConeSizeInEndcap_ = conf_.getParameter("intRadiusEndcap"); + egIsoConeSizeOut_ = conf_.getParameter("extRadius"); + egIsoJurassicWidth_ = conf_.getParameter("jurassicWidth"); + effectiveAreaBarrel_ = config.getParameter("effectiveAreaBarrel"); + effectiveAreaEndcap_ = config.getParameter("effectiveAreaEndcap"); + // options useIsolEt_ = conf_.getParameter("useIsolEt"); - tryBoth_ = conf_.getParameter("tryBoth"); - subtract_ = conf_.getParameter("subtract"); + tryBoth_ = conf_.getParameter("tryBoth"); + subtract_ = conf_.getParameter("subtract"); useNumCrystals_ = conf_.getParameter("useNumCrystals"); - + //register your products - produces < reco::RecoEcalCandidateIsolationMap >(); + produces(); } -EgammaHLTEcalRecIsolationProducer::~EgammaHLTEcalRecIsolationProducer() -{} +EgammaHLTEcalRecIsolationProducer::~EgammaHLTEcalRecIsolationProducer() {} void EgammaHLTEcalRecIsolationProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidate")); desc.add("ecalBarrelRecHitProducer", edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEB")); desc.add("ecalEndcapRecHitProducer", edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEE")); desc.add("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo")); desc.add("doRhoCorrection", false); - desc.add("rhoMax", 9.9999999E7); - desc.add("rhoScale", 1.0); + desc.add("rhoMax", 9.9999999E7); + desc.add("rhoScale", 1.0); desc.add("etMinBarrel", -9999.0); desc.add("eMinBarrel", 0.095); desc.add("etMinEndcap", 0.11); @@ -83,20 +82,21 @@ void EgammaHLTEcalRecIsolationProducer::fillDescriptions(edm::ConfigurationDescr desc.add("tryBoth", true); desc.add("subtract", false); desc.add("useNumCrystals", true); - - descriptions.add(("hltEgammaHLTEcalRecIsolationProducer"), desc); + + descriptions.add(("hltEgammaHLTEcalRecIsolationProducer"), desc); } -void EgammaHLTEcalRecIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTEcalRecIsolationProducer::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { // Get the RecoEcalCandidate Collection edm::Handle recoecalcandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); - + iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); + // Next get Ecal hits barrel - edm::Handle ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to + edm::Handle ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to iEvent.getByToken(ecalBarrelRecHitProducer_, ecalBarrelRecHitHandle); - + // Next get Ecal hits endcap edm::Handle ecalEndcapRecHitHandle; iEvent.getByToken(ecalEndcapRecHitProducer_, ecalEndcapRecHitHandle); @@ -109,7 +109,7 @@ void EgammaHLTEcalRecIsolationProducer::produce(edm::StreamID sid, edm::Event& i edm::ESHandle sevlv; iSetup.get().get(sevlv); const EcalSeverityLevelAlgo* sevLevel = sevlv.product(); - + edm::Handle rhoHandle; double rho = 0.0; if (doRhoCorrection_) { @@ -120,22 +120,40 @@ void EgammaHLTEcalRecIsolationProducer::produce(edm::StreamID sid, edm::Event& i if (rho > rhoMax_) rho = rhoMax_; - rho = rho*rhoScale_; + rho = rho * rhoScale_; //prepare product reco::RecoEcalCandidateIsolationMap isoMap(recoecalcandHandle); //create algorithm objects - EgammaRecHitIsolation ecalBarrelIsol(egIsoConeSizeOut_,egIsoConeSizeInBarrel_,egIsoJurassicWidth_,egIsoPtMinBarrel_,egIsoEMinBarrel_,edm::ESHandle(caloGeom),*ecalBarrelRecHitHandle,sevLevel,DetId::Ecal); + EgammaRecHitIsolation ecalBarrelIsol(egIsoConeSizeOut_, + egIsoConeSizeInBarrel_, + egIsoJurassicWidth_, + egIsoPtMinBarrel_, + egIsoEMinBarrel_, + edm::ESHandle(caloGeom), + *ecalBarrelRecHitHandle, + sevLevel, + DetId::Ecal); ecalBarrelIsol.setUseNumCrystals(useNumCrystals_); - EgammaRecHitIsolation ecalEndcapIsol(egIsoConeSizeOut_,egIsoConeSizeInEndcap_,egIsoJurassicWidth_,egIsoPtMinEndcap_,egIsoEMinEndcap_,edm::ESHandle(caloGeom),*ecalEndcapRecHitHandle,sevLevel,DetId::Ecal); + EgammaRecHitIsolation ecalEndcapIsol(egIsoConeSizeOut_, + egIsoConeSizeInEndcap_, + egIsoJurassicWidth_, + egIsoPtMinEndcap_, + egIsoEMinEndcap_, + edm::ESHandle(caloGeom), + *ecalEndcapRecHitHandle, + sevLevel, + DetId::Ecal); ecalEndcapIsol.setUseNumCrystals(useNumCrystals_); - for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand= recoecalcandHandle->begin(); iRecoEcalCand!=recoecalcandHandle->end(); iRecoEcalCand++) { - + for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); + iRecoEcalCand != recoecalcandHandle->end(); + iRecoEcalCand++) { //create reference for storage in isolation map - reco::RecoEcalCandidateRef recoecalcandref(reco::RecoEcalCandidateRef(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin())); - + reco::RecoEcalCandidateRef recoecalcandref( + reco::RecoEcalCandidateRef(recoecalcandHandle, iRecoEcalCand - recoecalcandHandle->begin())); + //ecal isolation is centered on supecluster reco::SuperClusterRef superClus = iRecoEcalCand->get(); @@ -143,41 +161,45 @@ void EgammaHLTEcalRecIsolationProducer::produce(edm::StreamID sid, edm::Event& i //this might not be the best way, are we guaranteed that eta<1.5 is barrel //this can be safely replaced by another method which determines where the emobject is //then we either get the isolation Et or isolation Energy depending on user selection - float isol =0.; + float isol = 0.; - if(tryBoth_){ //barrel + endcap - if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEtSum(&(*iRecoEcalCand)); - else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand)); - } - else if( fabs(superClus->eta())<1.479) { //barrel - if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)); - else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)); - } - else{ //endcap - if(useIsolEt_) isol = ecalEndcapIsol.getEtSum(&(*iRecoEcalCand)); - else isol = ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand)); + if (tryBoth_) { //barrel + endcap + if (useIsolEt_) + isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEtSum(&(*iRecoEcalCand)); + else + isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand)); + } else if (fabs(superClus->eta()) < 1.479) { //barrel + if (useIsolEt_) + isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)); + else + isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)); + } else { //endcap + if (useIsolEt_) + isol = ecalEndcapIsol.getEtSum(&(*iRecoEcalCand)); + else + isol = ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand)); } //we subtract off the electron energy here as well - double subtractVal=0; + double subtractVal = 0; + + if (useIsolEt_) + subtractVal = superClus.get()->rawEnergy() * sin(2 * atan(exp(-superClus.get()->eta()))); + else + subtractVal = superClus.get()->rawEnergy(); - if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta()))); - else subtractVal = superClus.get()->rawEnergy(); + if (subtract_) + isol -= subtractVal; - if(subtract_) isol-= subtractVal; - if (doRhoCorrection_) { - if (fabs(superClus->eta()) < 1.442) - isol = isol - rho*effectiveAreaBarrel_; + if (fabs(superClus->eta()) < 1.442) + isol = isol - rho * effectiveAreaBarrel_; else - isol = isol - rho*effectiveAreaEndcap_; + isol = isol - rho * effectiveAreaEndcap_; } isoMap.insert(recoecalcandref, isol); } iEvent.put(std::make_unique(isoMap)); - } - - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronCombinedIsolationProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronCombinedIsolationProducer.cc index 4ee71fb764bce..7bbc2c232fa10 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronCombinedIsolationProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronCombinedIsolationProducer.cc @@ -10,94 +10,96 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -EgammaHLTElectronCombinedIsolationProducer::EgammaHLTElectronCombinedIsolationProducer(const edm::ParameterSet& config) : conf_(config) { +EgammaHLTElectronCombinedIsolationProducer::EgammaHLTElectronCombinedIsolationProducer(const edm::ParameterSet& config) + : conf_(config) { + electronProducer_ = consumes(conf_.getParameter("electronProducer")); + recoEcalCandidateProducer_ = + consumes(conf_.getParameter("recoEcalCandidateProducer")); - electronProducer_ = consumes(conf_.getParameter("electronProducer")); - recoEcalCandidateProducer_ = consumes(conf_.getParameter("recoEcalCandidateProducer")); - - for (edm::InputTag const & tag : conf_.getParameter< std::vector > ("CaloIsolationMapTags")) + for (edm::InputTag const& tag : conf_.getParameter >("CaloIsolationMapTags")) CaloIsolTag_.push_back(consumes(tag)); - - TrackIsolTag_ = consumes(conf_.getParameter("TrackIsolationMapTag")); - CaloIsolWeight_ = conf_.getParameter< std::vector > ("CaloIsolationWeight"); + TrackIsolTag_ = consumes(conf_.getParameter("TrackIsolationMapTag")); + + CaloIsolWeight_ = conf_.getParameter >("CaloIsolationWeight"); TrackIsolWeight_ = conf_.getParameter("TrackIsolationWeight"); - - if (CaloIsolTag_.size() != CaloIsolWeight_.size()){ + + if (CaloIsolTag_.size() != CaloIsolWeight_.size()) { throw cms::Exception("BadConfig") << "vectors CaloIsolationMapTags and CaloIsolationWeight need to have size 3"; } - + //register your products - produces < reco::ElectronIsolationMap >(); + produces(); } -EgammaHLTElectronCombinedIsolationProducer::~EgammaHLTElectronCombinedIsolationProducer() -{} +EgammaHLTElectronCombinedIsolationProducer::~EgammaHLTElectronCombinedIsolationProducer() {} void EgammaHLTElectronCombinedIsolationProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("electronProducer", edm::InputTag("")); desc.add("recoEcalCandidateProducer", edm::InputTag("")); desc.add >("CaloIsolationMapTags", std::vector()); desc.add("TrackIsolationMapTag", edm::InputTag("")); -desc.add >("CaloIsolationWeight", std::vector()); + desc.add >("CaloIsolationWeight", std::vector()); desc.add("TrackIsolationWeight", 0); - descriptions.add("hltEgammaHLTElectronCombinedIsolationProducer", desc); + descriptions.add("hltEgammaHLTElectronCombinedIsolationProducer", desc); } -void EgammaHLTElectronCombinedIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTElectronCombinedIsolationProducer::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { edm::Handle electronHandle; - iEvent.getByToken(electronProducer_,electronHandle); + iEvent.getByToken(electronProducer_, electronHandle); edm::Handle recoecalcandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); - - std::vector< edm::Handle > CaloIsoMap; - for( unsigned int u=0; u < CaloIsolTag_.size(); u++){ + iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); + + std::vector > CaloIsoMap; + for (unsigned int u = 0; u < CaloIsolTag_.size(); u++) { edm::Handle depMapTemp; - if(CaloIsolWeight_[u] != 0) - iEvent.getByToken(CaloIsolTag_[u],depMapTemp); + if (CaloIsolWeight_[u] != 0) + iEvent.getByToken(CaloIsolTag_[u], depMapTemp); CaloIsoMap.push_back(depMapTemp); } - + edm::Handle TrackIsoMap; - if(TrackIsolWeight_ != 0) - iEvent.getByToken(TrackIsolTag_,TrackIsoMap); - + if (TrackIsolWeight_ != 0) + iEvent.getByToken(TrackIsolTag_, TrackIsoMap); + reco::ElectronIsolationMap TotalIsolMap(electronHandle); - double TotalIso=0; - for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){ - TotalIso=0; - reco::ElectronRef electronref(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin())); + double TotalIso = 0; + for (reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); + iElectron++) { + TotalIso = 0; + reco::ElectronRef electronref(reco::ElectronRef(electronHandle, iElectron - electronHandle->begin())); const reco::SuperClusterRef theEleClus = electronref->superCluster(); - - //look for corresponding recoecal candidates to search for in the ecal and Hcal iso map - for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){ - reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand-recoecalcandHandle->begin()); + + //look for corresponding recoecal candidates to search for in the ecal and Hcal iso map + for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); + iRecoEcalCand != recoecalcandHandle->end(); + iRecoEcalCand++) { + reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand - recoecalcandHandle->begin()); const reco::SuperClusterRef cluster = recoecalcandref->superCluster(); - if(&(*cluster) == &(*theEleClus)) {//recoecalcand and electron have the same SC - for(unsigned int u=0; u < CaloIsolTag_.size() ;u++){ - if(CaloIsolWeight_[u]==0){continue;} - reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*CaloIsoMap[u]).find( recoecalcandref ); - TotalIso += mapi->val * CaloIsolWeight_[u]; - } - break; + if (&(*cluster) == &(*theEleClus)) { //recoecalcand and electron have the same SC + for (unsigned int u = 0; u < CaloIsolTag_.size(); u++) { + if (CaloIsolWeight_[u] == 0) { + continue; + } + reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*CaloIsoMap[u]).find(recoecalcandref); + TotalIso += mapi->val * CaloIsolWeight_[u]; + } + break; } } - + //add the track isolation - if(TrackIsolWeight_ != 0){ - reco::ElectronIsolationMap::const_iterator mapi = (*TrackIsoMap).find( electronref ); + if (TrackIsolWeight_ != 0) { + reco::ElectronIsolationMap::const_iterator mapi = (*TrackIsoMap).find(electronref); TotalIso += mapi->val * TrackIsolWeight_; } TotalIsolMap.insert(electronref, TotalIso); - } iEvent.put(std::make_unique(TotalIsolMap)); - } - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronDetaDphiProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronDetaDphiProducer.cc index 5dc76e868c3f1..5fe16aa36f11a 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronDetaDphiProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronDetaDphiProducer.cc @@ -28,148 +28,159 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -EgammaHLTElectronDetaDphiProducer::EgammaHLTElectronDetaDphiProducer(const edm::ParameterSet& config): - electronProducer_ (consumes(config.getParameter("electronProducer"))), - bsProducer_ (consumes(config.getParameter("BSProducer"))), - recoEcalCandidateProducer_ (consumes(config.getParameter("recoEcalCandidateProducer"))), - useSCRefs_ (config.getParameter("useSCRefs")), - useTrackProjectionToEcal_ (config.getParameter("useTrackProjectionToEcal")), - variablesAtVtx_ (config.getParameter("variablesAtVtx")) { - +EgammaHLTElectronDetaDphiProducer::EgammaHLTElectronDetaDphiProducer(const edm::ParameterSet& config) + : electronProducer_(consumes(config.getParameter("electronProducer"))), + bsProducer_(consumes(config.getParameter("BSProducer"))), + recoEcalCandidateProducer_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + useSCRefs_(config.getParameter("useSCRefs")), + useTrackProjectionToEcal_(config.getParameter("useTrackProjectionToEcal")), + variablesAtVtx_(config.getParameter("variablesAtVtx")) { //register your products - if(!useSCRefs_){ - produces < reco::ElectronIsolationMap >( "Deta" ).setBranchAlias( "deta" ); - produces < reco::ElectronIsolationMap >( "Dphi" ).setBranchAlias( "dphi" ); - }else{ - produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" ); - produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" ); + if (!useSCRefs_) { + produces("Deta").setBranchAlias("deta"); + produces("Dphi").setBranchAlias("dphi"); + } else { + produces("Deta").setBranchAlias("deta"); + produces("Dphi").setBranchAlias("dphi"); } } -EgammaHLTElectronDetaDphiProducer::~EgammaHLTElectronDetaDphiProducer() -{} +EgammaHLTElectronDetaDphiProducer::~EgammaHLTElectronDetaDphiProducer() {} void EgammaHLTElectronDetaDphiProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add(("electronProducer"), edm::InputTag("hltEleAnyWP80PixelMatchElectronsL1Seeded")); desc.add(("BSProducer"), edm::InputTag("hltOnlineBeamSpot")); - desc.add(("recoEcalCandidateProducer"), edm::InputTag()); + desc.add(("recoEcalCandidateProducer"), edm::InputTag()); desc.add(("useSCRefs"), false); desc.add(("useTrackProjectionToEcal"), false); desc.add(("variablesAtVtx"), true); - descriptions.add(("hltEgammaHLTElectronDetaDphiProducer"), desc); + descriptions.add(("hltEgammaHLTElectronDetaDphiProducer"), desc); } - + void EgammaHLTElectronDetaDphiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // Get the HLT filtered objects edm::Handle electronHandle; - iEvent.getByToken(electronProducer_,electronHandle); - + iEvent.getByToken(electronProducer_, electronHandle); + edm::Handle recoBeamSpotHandle; - iEvent.getByToken(bsProducer_,recoBeamSpotHandle); + iEvent.getByToken(bsProducer_, recoBeamSpotHandle); // gets its position - const reco::BeamSpot::Point& bsPosition = recoBeamSpotHandle->position(); + const reco::BeamSpot::Point& bsPosition = recoBeamSpotHandle->position(); edm::ESHandle theMagField; iSetup.get().get(theMagField); reco::ElectronIsolationMap detaMap(electronHandle); reco::ElectronIsolationMap dphiMap(electronHandle); - - if(!useSCRefs_){ - - for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){ - - reco::ElectronRef eleref(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin())); - std::pair dEtaDPhi = calDEtaDPhiSCTrk(eleref,bsPosition,theMagField.product()); - + + if (!useSCRefs_) { + for (reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); + iElectron != electronHandle->end(); + iElectron++) { + reco::ElectronRef eleref(reco::ElectronRef(electronHandle, iElectron - electronHandle->begin())); + std::pair dEtaDPhi = calDEtaDPhiSCTrk(eleref, bsPosition, theMagField.product()); + detaMap.insert(eleref, dEtaDPhi.first); dphiMap.insert(eleref, dEtaDPhi.second); } - }else { //we loop over reco ecal candidates - edm::Handle recoEcalCandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoEcalCandHandle); - reco::RecoEcalCandidateIsolationMap detaCandMap(recoEcalCandHandle); - reco::RecoEcalCandidateIsolationMap dphiCandMap(recoEcalCandHandle); - - for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){ - - reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin()); - - reco::ElectronRef eleRef = getEleRef(recoEcalCandRef,electronHandle); - std::pair dEtaDPhi(999999,999999); - if(eleRef.isNonnull()) dEtaDPhi = calDEtaDPhiSCTrk(eleRef,bsPosition,theMagField.product()); - detaCandMap.insert(recoEcalCandRef, dEtaDPhi.first); - dphiCandMap.insert(recoEcalCandRef, dEtaDPhi.second); - }//end loop over reco ecal candidates - - iEvent.put(std::make_unique(detaCandMap), "Deta" ); - iEvent.put(std::make_unique(dphiCandMap), "Dphi" ); - - }//end if between electrons or reco ecal candidates - - if(!useSCRefs_){ - iEvent.put(std::make_unique(detaMap), "Deta" ); - iEvent.put(std::make_unique(dphiMap), "Dphi" ); + } else { //we loop over reco ecal candidates + edm::Handle recoEcalCandHandle; + iEvent.getByToken(recoEcalCandidateProducer_, recoEcalCandHandle); + reco::RecoEcalCandidateIsolationMap detaCandMap(recoEcalCandHandle); + reco::RecoEcalCandidateIsolationMap dphiCandMap(recoEcalCandHandle); + + for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); + iRecoEcalCand != recoEcalCandHandle->end(); + iRecoEcalCand++) { + reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand - recoEcalCandHandle->begin()); + + reco::ElectronRef eleRef = getEleRef(recoEcalCandRef, electronHandle); + std::pair dEtaDPhi(999999, 999999); + if (eleRef.isNonnull()) + dEtaDPhi = calDEtaDPhiSCTrk(eleRef, bsPosition, theMagField.product()); + detaCandMap.insert(recoEcalCandRef, dEtaDPhi.first); + dphiCandMap.insert(recoEcalCandRef, dEtaDPhi.second); + } //end loop over reco ecal candidates + + iEvent.put(std::make_unique(detaCandMap), "Deta"); + iEvent.put(std::make_unique(dphiCandMap), "Dphi"); + + } //end if between electrons or reco ecal candidates + + if (!useSCRefs_) { + iEvent.put(std::make_unique(detaMap), "Deta"); + iEvent.put(std::make_unique(dphiMap), "Dphi"); } } -std::pair EgammaHLTElectronDetaDphiProducer::calDEtaDPhiSCTrk(reco::ElectronRef& eleref, const reco::BeamSpot::Point& bsPosition,const MagneticField *magField) { - +std::pair EgammaHLTElectronDetaDphiProducer::calDEtaDPhiSCTrk(reco::ElectronRef& eleref, + const reco::BeamSpot::Point& bsPosition, + const MagneticField* magField) { const reco::SuperClusterRef theClus = eleref->superCluster(); - const math::XYZVector trackMom = eleref->track()->momentum(); - - math::XYZPoint SCcorrPosition(theClus->x()-bsPosition.x(), theClus->y()-bsPosition.y() , theClus->z()-eleref->track()->vz() ); - float deltaeta = fabs(SCcorrPosition.eta()-eleref->track()->eta()); + const math::XYZVector trackMom = eleref->track()->momentum(); + + math::XYZPoint SCcorrPosition( + theClus->x() - bsPosition.x(), theClus->y() - bsPosition.y(), theClus->z() - eleref->track()->vz()); + float deltaeta = fabs(SCcorrPosition.eta() - eleref->track()->eta()); float deltaphi = 999.; - + if (variablesAtVtx_) { reco::TrackRef track = eleref->track(); reco::TransientTrack tt(track, magField_); - TrajectoryStateOnSurface sclTSOS = tt.stateOnSurface(GlobalPoint(theClus->x(),theClus->y(),theClus->z())); + TrajectoryStateOnSurface sclTSOS = tt.stateOnSurface(GlobalPoint(theClus->x(), theClus->y(), theClus->z())); if (sclTSOS.isValid()) { EleRelPointPair scAtVtx(theClus->position(), sclTSOS.globalPosition(), bsPosition); deltaeta = fabs(scAtVtx.dEta()); deltaphi = fabs(scAtVtx.dPhi()); } - } else if (useTrackProjectionToEcal_) { - const math::XYZPoint vertex(bsPosition.x(),bsPosition.y(),eleref->track()->vz()); - - float phi1 = egammaTools::ecalPhi(*magField,trackMom,vertex,1); - float phi2 = egammaTools::ecalPhi(*magField,trackMom,vertex,-1); - - float deltaphi1=fabs( phi1 - theClus->position().phi() ); - if(deltaphi1>6.283185308) deltaphi1 -= 6.283185308; - if(deltaphi1>3.141592654) deltaphi1 = 6.283185308-deltaphi1; - - float deltaphi2=fabs( phi2 - theClus->position().phi() ); - if(deltaphi2>6.283185308) deltaphi2 -= 6.283185308; - if(deltaphi2>3.141592654) deltaphi2 = 6.283185308-deltaphi2; - + } else if (useTrackProjectionToEcal_) { + const math::XYZPoint vertex(bsPosition.x(), bsPosition.y(), eleref->track()->vz()); + + float phi1 = egammaTools::ecalPhi(*magField, trackMom, vertex, 1); + float phi2 = egammaTools::ecalPhi(*magField, trackMom, vertex, -1); + + float deltaphi1 = fabs(phi1 - theClus->position().phi()); + if (deltaphi1 > 6.283185308) + deltaphi1 -= 6.283185308; + if (deltaphi1 > 3.141592654) + deltaphi1 = 6.283185308 - deltaphi1; + + float deltaphi2 = fabs(phi2 - theClus->position().phi()); + if (deltaphi2 > 6.283185308) + deltaphi2 -= 6.283185308; + if (deltaphi2 > 3.141592654) + deltaphi2 = 6.283185308 - deltaphi2; + deltaphi = deltaphi1; - if(deltaphi2track()->outerPosition().phi()-theClus->phi()); - if(deltaphi>6.283185308) deltaphi -= 6.283185308; - if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi; + deltaphi = fabs(eleref->track()->outerPosition().phi() - theClus->phi()); + if (deltaphi > 6.283185308) + deltaphi -= 6.283185308; + if (deltaphi > 3.141592654) + deltaphi = 6.283185308 - deltaphi; } - - return std::make_pair(deltaeta,deltaphi); + + return std::make_pair(deltaeta, deltaphi); } -reco::ElectronRef EgammaHLTElectronDetaDphiProducer::getEleRef(const reco::RecoEcalCandidateRef& recoEcalCandRef,const edm::Handle& electronHandle) -{ +reco::ElectronRef EgammaHLTElectronDetaDphiProducer::getEleRef( + const reco::RecoEcalCandidateRef& recoEcalCandRef, const edm::Handle& electronHandle) { reco::ElectronRef eleRef; - for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){ - if(eleIt->superCluster()==recoEcalCandRef->superCluster()){ - eleRef = reco::ElectronRef(electronHandle,eleIt - electronHandle->begin()); + for (reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); + eleIt++) { + if (eleIt->superCluster() == recoEcalCandRef->superCluster()) { + eleRef = reco::ElectronRef(electronHandle, eleIt - electronHandle->begin()); break; } } return eleRef; } - void EgammaHLTElectronDetaDphiProducer::beginRun(edm::Run const&, edm::EventSetup const& iSetup) { using namespace edm; @@ -177,7 +188,6 @@ void EgammaHLTElectronDetaDphiProducer::beginRun(edm::Run const&, edm::EventSetu ESHandle magneticField; iSetup.get().get(magneticField); magField_ = magneticField.product(); - } //define this as a plug-in diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronTrackIsolationProducers.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronTrackIsolationProducers.cc index 580d32169f49d..83e5faa19c3d7 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronTrackIsolationProducers.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronTrackIsolationProducers.cc @@ -16,37 +16,36 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -EgammaHLTElectronTrackIsolationProducers::EgammaHLTElectronTrackIsolationProducers(const edm::ParameterSet& config): - electronProducer_ (consumes(config.getParameter("electronProducer"))), - trackProducer_ (consumes(config.getParameter("trackProducer"))), - recoEcalCandidateProducer_ (consumes(config.getParameter("recoEcalCandidateProducer"))), - beamSpotProducer_ (consumes(config.getParameter("beamSpotProducer"))), - useGsfTrack_ (config.getParameter("useGsfTrack")), - useSCRefs_ (config.getParameter("useSCRefs")), - egTrkIsoPtMin_ (config.getParameter("egTrkIsoPtMin")), - egTrkIsoConeSize_ (config.getParameter("egTrkIsoConeSize")), - egTrkIsoZSpan_ (config.getParameter("egTrkIsoZSpan")), - egTrkIsoRSpan_ (config.getParameter("egTrkIsoRSpan")), - egTrkIsoVetoConeSizeBarrel_ (config.getParameter("egTrkIsoVetoConeSizeBarrel")), - egTrkIsoVetoConeSizeEndcap_ (config.getParameter("egTrkIsoVetoConeSizeEndcap")), - egTrkIsoStripBarrel_ (config.getParameter("egTrkIsoStripBarrel")), - egTrkIsoStripEndcap_ (config.getParameter("egTrkIsoStripEndcap")) { - +EgammaHLTElectronTrackIsolationProducers::EgammaHLTElectronTrackIsolationProducers(const edm::ParameterSet& config) + : electronProducer_(consumes(config.getParameter("electronProducer"))), + trackProducer_(consumes(config.getParameter("trackProducer"))), + recoEcalCandidateProducer_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + beamSpotProducer_(consumes(config.getParameter("beamSpotProducer"))), + useGsfTrack_(config.getParameter("useGsfTrack")), + useSCRefs_(config.getParameter("useSCRefs")), + egTrkIsoPtMin_(config.getParameter("egTrkIsoPtMin")), + egTrkIsoConeSize_(config.getParameter("egTrkIsoConeSize")), + egTrkIsoZSpan_(config.getParameter("egTrkIsoZSpan")), + egTrkIsoRSpan_(config.getParameter("egTrkIsoRSpan")), + egTrkIsoVetoConeSizeBarrel_(config.getParameter("egTrkIsoVetoConeSizeBarrel")), + egTrkIsoVetoConeSizeEndcap_(config.getParameter("egTrkIsoVetoConeSizeEndcap")), + egTrkIsoStripBarrel_(config.getParameter("egTrkIsoStripBarrel")), + egTrkIsoStripEndcap_(config.getParameter("egTrkIsoStripEndcap")) { //register your products - if(useSCRefs_) - produces < reco::RecoEcalCandidateIsolationMap >(); - else - produces < reco::ElectronIsolationMap >(); + if (useSCRefs_) + produces(); + else + produces(); } -EgammaHLTElectronTrackIsolationProducers::~EgammaHLTElectronTrackIsolationProducers() -{} +EgammaHLTElectronTrackIsolationProducers::~EgammaHLTElectronTrackIsolationProducers() {} void EgammaHLTElectronTrackIsolationProducers::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; + edm::ParameterSetDescription desc; desc.add("electronProducer", edm::InputTag("hltEleAnyWP80PixelMatchElectronsL1Seeded")); desc.add("trackProducer", edm::InputTag("hltL1SeededEgammaRegionalCTFFinalFitWithMaterial")); - desc.add("recoEcalCandidateProducer", edm::InputTag()); + desc.add("recoEcalCandidateProducer", edm::InputTag()); desc.add("beamSpotProducer", edm::InputTag("hltOnlineBeamSpot")); desc.add("egTrkIsoPtMin", 1.0); desc.add("egTrkIsoConeSize", 0.3); @@ -59,14 +58,15 @@ void EgammaHLTElectronTrackIsolationProducers::fillDescriptions(edm::Configurati desc.add("useGsfTrack", false); desc.add("useSCRefs", false); - descriptions.add("hltEgammaHLTElectronTrackIsolationProducers", desc); + descriptions.add("hltEgammaHLTElectronTrackIsolationProducers", desc); } -void EgammaHLTElectronTrackIsolationProducers::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTElectronTrackIsolationProducers::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { edm::Handle electronHandle; - iEvent.getByToken(electronProducer_,electronHandle); + iEvent.getByToken(electronProducer_, electronHandle); - // Get the general tracks + // Get the general tracks edm::Handle trackHandle; iEvent.getByToken(trackProducer_, trackHandle); const reco::TrackCollection* trackCollection = trackHandle.product(); @@ -74,42 +74,54 @@ void EgammaHLTElectronTrackIsolationProducers::produce(edm::StreamID sid, edm::E reco::ElectronIsolationMap eleMap(electronHandle); edm::Handle recoBeamSpotHandle; - iEvent.getByToken(beamSpotProducer_,recoBeamSpotHandle); - - const reco::BeamSpot::Point& beamSpotPosition = recoBeamSpotHandle->position(); - - ElectronTkIsolation isoAlgo(egTrkIsoConeSize_,egTrkIsoVetoConeSizeBarrel_,egTrkIsoVetoConeSizeEndcap_,egTrkIsoStripBarrel_,egTrkIsoStripEndcap_,egTrkIsoPtMin_,egTrkIsoZSpan_,egTrkIsoRSpan_,trackCollection,beamSpotPosition); - - if(useSCRefs_){ - + iEvent.getByToken(beamSpotProducer_, recoBeamSpotHandle); + + const reco::BeamSpot::Point& beamSpotPosition = recoBeamSpotHandle->position(); + + ElectronTkIsolation isoAlgo(egTrkIsoConeSize_, + egTrkIsoVetoConeSizeBarrel_, + egTrkIsoVetoConeSizeEndcap_, + egTrkIsoStripBarrel_, + egTrkIsoStripEndcap_, + egTrkIsoPtMin_, + egTrkIsoZSpan_, + egTrkIsoRSpan_, + trackCollection, + beamSpotPosition); + + if (useSCRefs_) { edm::Handle recoEcalCandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoEcalCandHandle); + iEvent.getByToken(recoEcalCandidateProducer_, recoEcalCandHandle); reco::RecoEcalCandidateIsolationMap recoEcalCandMap(recoEcalCandHandle); - for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){ - - reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin()); - + for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); + iRecoEcalCand != recoEcalCandHandle->end(); + iRecoEcalCand++) { + reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand - recoEcalCandHandle->begin()); + reco::ElectronRef eleRef; - for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){ - if(eleIt->superCluster()==recoEcalCandRef->superCluster()){ - eleRef = reco::ElectronRef(electronHandle,eleIt - electronHandle->begin()); - break; - } + for (reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); + eleIt++) { + if (eleIt->superCluster() == recoEcalCandRef->superCluster()) { + eleRef = reco::ElectronRef(electronHandle, eleIt - electronHandle->begin()); + break; + } } - float isol=999999; - if(eleRef.isNonnull()){ - const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track(); - isol = isoAlgo.getIso(eleTrk).second; + float isol = 999999; + if (eleRef.isNonnull()) { + const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track(); + isol = isoAlgo.getIso(eleTrk).second; } - recoEcalCandMap.insert(recoEcalCandRef,isol); - }//end reco ecal candidate ref + recoEcalCandMap.insert(recoEcalCandRef, isol); + } //end reco ecal candidate ref iEvent.put(std::make_unique(recoEcalCandMap)); - }else{ //we are going to loop over electron instead - for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){ - reco::ElectronRef eleRef(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin())); + } else { //we are going to loop over electron instead + for (reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); + iElectron != electronHandle->end(); + iElectron++) { + reco::ElectronRef eleRef(reco::ElectronRef(electronHandle, iElectron - electronHandle->begin())); const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track(); float isol = isoAlgo.getIso(eleTrk).second; eleMap.insert(eleRef, isol); @@ -118,4 +130,3 @@ void EgammaHLTElectronTrackIsolationProducers::produce(edm::StreamID sid, edm::E iEvent.put(std::make_unique(eleMap)); } } - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTFilteredEcalCandProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTFilteredEcalCandProducer.cc index a80c56b86582a..7889b6dbd52c8 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTFilteredEcalCandProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTFilteredEcalCandProducer.cc @@ -3,24 +3,20 @@ #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/Common/interface/RefToPtr.h" -template<> -void EgammaHLTFilteredObjProducer:: -addObj(const reco::RecoEcalCandidateRef& cand, reco::RecoEcalCandidateCollection& output) -{ +template <> +void EgammaHLTFilteredObjProducer::addObj( + const reco::RecoEcalCandidateRef& cand, reco::RecoEcalCandidateCollection& output) { output.push_back(*cand); } -using EgammaHLTFilteredEcalCandProducer=EgammaHLTFilteredObjProducer; +using EgammaHLTFilteredEcalCandProducer = EgammaHLTFilteredObjProducer; DEFINE_FWK_MODULE(EgammaHLTFilteredEcalCandProducer); - -template<> -void EgammaHLTFilteredObjProducer > >:: -addObj(const reco::RecoEcalCandidateRef& cand, std::vector >& output) -{ +template <> +void EgammaHLTFilteredObjProducer > >::addObj( + const reco::RecoEcalCandidateRef& cand, std::vector >& output) { output.push_back(edm::refToPtr(cand)); } -using EgammaHLTFilteredEcalCandPtrProducer=EgammaHLTFilteredObjProducer > >; +using EgammaHLTFilteredEcalCandPtrProducer = EgammaHLTFilteredObjProducer > >; DEFINE_FWK_MODULE(EgammaHLTFilteredEcalCandPtrProducer); - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTFilteredSuperClusterProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTFilteredSuperClusterProducer.cc index a16984391a33f..974815ca859dd 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTFilteredSuperClusterProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTFilteredSuperClusterProducer.cc @@ -3,13 +3,11 @@ #include "DataFormats/EgammaReco/interface/SuperCluster.h" #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" -template<> -void EgammaHLTFilteredObjProducer>:: -addObj(const reco::RecoEcalCandidateRef& cand, std::vector& output) -{ +template <> +void EgammaHLTFilteredObjProducer>::addObj( + const reco::RecoEcalCandidateRef& cand, std::vector& output) { output.push_back(cand->superCluster()); } -using EgammaHLTFilteredSuperClusterProducer=EgammaHLTFilteredObjProducer>; +using EgammaHLTFilteredSuperClusterProducer = EgammaHLTFilteredObjProducer>; DEFINE_FWK_MODULE(EgammaHLTFilteredSuperClusterProducer); - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTGsfTrackVarProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTGsfTrackVarProducer.cc index 89edeeb61bd93..1ecb390f95490 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTGsfTrackVarProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTGsfTrackVarProducer.cc @@ -29,62 +29,59 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -EgammaHLTGsfTrackVarProducer::EgammaHLTGsfTrackVarProducer(const edm::ParameterSet& config): - recoEcalCandTag_ (consumes(config.getParameter("recoEcalCandidateProducer"))), - inputCollectionTag1_ (consumes(config.getParameter("inputCollection"))), - inputCollectionTag2_ (consumes(config.getParameter("inputCollection"))), - beamSpotTag_ (consumes(config.getParameter("beamSpotProducer"))), - upperTrackNrToRemoveCut_ (config.getParameter("upperTrackNrToRemoveCut")), - lowerTrackNrToRemoveCut_ (config.getParameter("lowerTrackNrToRemoveCut")), - useDefaultValuesForBarrel_ (config.getParameter("useDefaultValuesForBarrel")), - useDefaultValuesForEndcap_ (config.getParameter("useDefaultValuesForEndcap")) -{ - +EgammaHLTGsfTrackVarProducer::EgammaHLTGsfTrackVarProducer(const edm::ParameterSet& config) + : recoEcalCandTag_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + inputCollectionTag1_(consumes(config.getParameter("inputCollection"))), + inputCollectionTag2_(consumes(config.getParameter("inputCollection"))), + beamSpotTag_(consumes(config.getParameter("beamSpotProducer"))), + upperTrackNrToRemoveCut_(config.getParameter("upperTrackNrToRemoveCut")), + lowerTrackNrToRemoveCut_(config.getParameter("lowerTrackNrToRemoveCut")), + useDefaultValuesForBarrel_(config.getParameter("useDefaultValuesForBarrel")), + useDefaultValuesForEndcap_(config.getParameter("useDefaultValuesForEndcap")) { //register your products - produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" ); - produces < reco::RecoEcalCandidateIsolationMap >( "DetaSeed" ).setBranchAlias( "detaseed" ); - produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" ); - produces < reco::RecoEcalCandidateIsolationMap >( "OneOESuperMinusOneOP" ); - produces < reco::RecoEcalCandidateIsolationMap >( "OneOESeedMinusOneOP" ); - produces < reco::RecoEcalCandidateIsolationMap >( "MissingHits" ).setBranchAlias( "missinghits" ); - produces < reco::RecoEcalCandidateIsolationMap >( "Chi2" ).setBranchAlias( "chi2" ); - produces < reco::RecoEcalCandidateIsolationMap >( "ValidHits" ).setBranchAlias( "validhits" ); + produces("Deta").setBranchAlias("deta"); + produces("DetaSeed").setBranchAlias("detaseed"); + produces("Dphi").setBranchAlias("dphi"); + produces("OneOESuperMinusOneOP"); + produces("OneOESeedMinusOneOP"); + produces("MissingHits").setBranchAlias("missinghits"); + produces("Chi2").setBranchAlias("chi2"); + produces("ValidHits").setBranchAlias("validhits"); } -EgammaHLTGsfTrackVarProducer::~EgammaHLTGsfTrackVarProducer() -{} +EgammaHLTGsfTrackVarProducer::~EgammaHLTGsfTrackVarProducer() {} void EgammaHLTGsfTrackVarProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalSuperClusterActivityCandidate")); desc.add(("inputCollection"), edm::InputTag("hltActivityElectronGsfTracks")); desc.add(("beamSpotProducer"), edm::InputTag("hltOnlineBeamSpot")); - desc.add(("upperTrackNrToRemoveCut"), 9999); + desc.add(("upperTrackNrToRemoveCut"), 9999); desc.add(("lowerTrackNrToRemoveCut"), -1); - desc.add(("useDefaultValuesForBarrel"),false); - desc.add(("useDefaultValuesForEndcap"),false); - + desc.add(("useDefaultValuesForBarrel"), false); + desc.add(("useDefaultValuesForEndcap"), false); + descriptions.add("hltEgammaHLTGsfTrackVarProducer", desc); } void EgammaHLTGsfTrackVarProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { - trackExtrapolator_.setup(iSetup); - + // Get the HLT filtered objects edm::Handle recoEcalCandHandle; - iEvent.getByToken(recoEcalCandTag_,recoEcalCandHandle); + iEvent.getByToken(recoEcalCandTag_, recoEcalCandHandle); edm::Handle electronHandle; - iEvent.getByToken(inputCollectionTag1_,electronHandle); + iEvent.getByToken(inputCollectionTag1_, electronHandle); edm::Handle gsfTracksHandle; - if(!electronHandle.isValid()) + if (!electronHandle.isValid()) iEvent.getByToken(inputCollectionTag2_, gsfTracksHandle); edm::Handle recoBeamSpotHandle; - iEvent.getByToken(beamSpotTag_,recoBeamSpotHandle); + iEvent.getByToken(beamSpotTag_, recoBeamSpotHandle); // gets its position - const reco::BeamSpot& beamSpot = *recoBeamSpotHandle; + const reco::BeamSpot& beamSpot = *recoBeamSpotHandle; edm::ESHandle theMagField; iSetup.get().get(theMagField); @@ -98,97 +95,100 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::Event& iEvent, const edm::EventS reco::RecoEcalCandidateIsolationMap validHitsMap(recoEcalCandHandle); reco::RecoEcalCandidateIsolationMap chi2Map(recoEcalCandHandle); - for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){ - reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin()); - + for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); + iRecoEcalCand != recoEcalCandHandle->end(); + iRecoEcalCand++) { + reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand - recoEcalCandHandle->begin()); + const reco::SuperClusterRef scRef = recoEcalCandRef->superCluster(); - bool isBarrel = std::abs(recoEcalCandRef->eta())<1.479; + bool isBarrel = std::abs(recoEcalCandRef->eta()) < 1.479; //the idea is that we can take the tracks from properly associated electrons or just take all gsf tracks with that sc as a seed std::vector gsfTracks; - if(electronHandle.isValid()){ - for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){ - if(eleIt->superCluster()==scRef){ - gsfTracks.push_back(&*eleIt->gsfTrack()); - } + if (electronHandle.isValid()) { + for (reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); + eleIt++) { + if (eleIt->superCluster() == scRef) { + gsfTracks.push_back(&*eleIt->gsfTrack()); + } } - }else{ - for(reco::GsfTrackCollection::const_iterator trkIt =gsfTracksHandle->begin();trkIt!=gsfTracksHandle->end();++trkIt){ - edm::RefToBase seed = trkIt->extra()->seedRef() ; - reco::ElectronSeedRef elseed = seed.castTo() ; - edm::RefToBase caloCluster = elseed->caloCluster() ; - reco::SuperClusterRef scRefFromTrk = caloCluster.castTo() ; - if(scRefFromTrk==scRef){ - gsfTracks.push_back(&*trkIt); - } + } else { + for (reco::GsfTrackCollection::const_iterator trkIt = gsfTracksHandle->begin(); trkIt != gsfTracksHandle->end(); + ++trkIt) { + edm::RefToBase seed = trkIt->extra()->seedRef(); + reco::ElectronSeedRef elseed = seed.castTo(); + edm::RefToBase caloCluster = elseed->caloCluster(); + reco::SuperClusterRef scRefFromTrk = caloCluster.castTo(); + if (scRefFromTrk == scRef) { + gsfTracks.push_back(&*trkIt); + } } - } int validHitsValue = 0; float chi2Value = 9999999.; float missingHitsValue = 9999999; - float dEtaInValue=999999; - float dEtaSeedInValue=999999; - float dPhiInValue=999999; - float oneOverESuperMinusOneOverPValue=999999; - float oneOverESeedMinusOneOverPValue=999999; - + float dEtaInValue = 999999; + float dEtaSeedInValue = 999999; + float dPhiInValue = 999999; + float oneOverESuperMinusOneOverPValue = 999999; + float oneOverESeedMinusOneOverPValue = 999999; + const int nrTracks = gsfTracks.size(); - const bool rmCutsDueToNrTracks = nrTracks <= lowerTrackNrToRemoveCut_ || - nrTracks >= upperTrackNrToRemoveCut_; + const bool rmCutsDueToNrTracks = nrTracks <= lowerTrackNrToRemoveCut_ || nrTracks >= upperTrackNrToRemoveCut_; //to use the default values, we require at least one track... - const bool useDefaultValues = isBarrel ? useDefaultValuesForBarrel_ && nrTracks>=1 : useDefaultValuesForEndcap_ && nrTracks>=1; + const bool useDefaultValues = + isBarrel ? useDefaultValuesForBarrel_ && nrTracks >= 1 : useDefaultValuesForEndcap_ && nrTracks >= 1; - if(rmCutsDueToNrTracks || useDefaultValues){ - dEtaInValue=0; - dEtaSeedInValue=0; - dPhiInValue=0; + if (rmCutsDueToNrTracks || useDefaultValues) { + dEtaInValue = 0; + dEtaSeedInValue = 0; + dPhiInValue = 0; missingHitsValue = 0; validHitsValue = 100; chi2Value = 0; oneOverESuperMinusOneOverPValue = 0; oneOverESeedMinusOneOverPValue = 0; - }else{ - for(size_t trkNr=0;trkNrx(),scRef->y(),scRef->z()); - GlobalPoint trackExtrapToSC = trackExtrapolator_.extrapolateTrackPosToPoint(*gsfTracks[trkNr],scPos); - EleRelPointPair scAtVtx(scRef->position(),trackExtrapToSC,beamSpot.position()); - - float trkP = gsfTracks[trkNr]->p(); - if(scRef->energy()!=0 && trkP!=0){ - if(fabs(1/scRef->energy() - 1/trkP)energy() - 1/trkP); - } - if(scRef->seed().isNonnull() && scRef->seed()->energy()!=0 && trkP!=0){ - if(fabs(1/scRef->seed()->energy() - 1/trkP)seed()->energy() - 1/trkP); - } - - - if (gsfTracks[trkNr]->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) < missingHitsValue) - missingHitsValue = gsfTracks[trkNr]->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); - - if (gsfTracks[trkNr]->numberOfValidHits() < validHitsValue) - validHitsValue = gsfTracks[trkNr]->numberOfValidHits(); - - if (gsfTracks[trkNr]->numberOfValidHits() < chi2Value) - chi2Value = gsfTracks[trkNr]->normalizedChi2(); - - if (fabs(scAtVtx.dEta())position().eta()+scRef->seed()->position().eta()); - - if (fabs(scAtVtx.dPhi())x(), scRef->y(), scRef->z()); + GlobalPoint trackExtrapToSC = trackExtrapolator_.extrapolateTrackPosToPoint(*gsfTracks[trkNr], scPos); + EleRelPointPair scAtVtx(scRef->position(), trackExtrapToSC, beamSpot.position()); + + float trkP = gsfTracks[trkNr]->p(); + if (scRef->energy() != 0 && trkP != 0) { + if (fabs(1 / scRef->energy() - 1 / trkP) < oneOverESuperMinusOneOverPValue) + oneOverESuperMinusOneOverPValue = fabs(1 / scRef->energy() - 1 / trkP); + } + if (scRef->seed().isNonnull() && scRef->seed()->energy() != 0 && trkP != 0) { + if (fabs(1 / scRef->seed()->energy() - 1 / trkP) < oneOverESeedMinusOneOverPValue) + oneOverESeedMinusOneOverPValue = fabs(1 / scRef->seed()->energy() - 1 / trkP); + } + + if (gsfTracks[trkNr]->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) < missingHitsValue) + missingHitsValue = gsfTracks[trkNr]->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); + + if (gsfTracks[trkNr]->numberOfValidHits() < validHitsValue) + validHitsValue = gsfTracks[trkNr]->numberOfValidHits(); + + if (gsfTracks[trkNr]->numberOfValidHits() < chi2Value) + chi2Value = gsfTracks[trkNr]->normalizedChi2(); + + if (fabs(scAtVtx.dEta()) < dEtaInValue) + dEtaInValue = fabs(scAtVtx.dEta()); //we are allowing them to come from different tracks + + if (fabs(scAtVtx.dEta()) < dEtaSeedInValue) + dEtaSeedInValue = fabs(scAtVtx.dEta() - scRef->position().eta() + scRef->seed()->position().eta()); + + if (fabs(scAtVtx.dPhi()) < dPhiInValue) + dPhiInValue = fabs(scAtVtx.dPhi()); //we are allowing them to come from different tracks + } } - + dEtaMap.insert(recoEcalCandRef, dEtaInValue); dEtaSeedMap.insert(recoEcalCandRef, dEtaSeedInValue); dPhiMap.insert(recoEcalCandRef, dPhiInValue); - oneOverESuperMinusOneOverPMap.insert(recoEcalCandRef,oneOverESuperMinusOneOverPValue); - oneOverESeedMinusOneOverPMap.insert(recoEcalCandRef,oneOverESeedMinusOneOverPValue); + oneOverESuperMinusOneOverPMap.insert(recoEcalCandRef, oneOverESuperMinusOneOverPValue); + oneOverESeedMinusOneOverPMap.insert(recoEcalCandRef, oneOverESeedMinusOneOverPValue); missingHitsMap.insert(recoEcalCandRef, missingHitsValue); validHitsMap.insert(recoEcalCandRef, validHitsValue); chi2Map.insert(recoEcalCandRef, chi2Value); @@ -197,15 +197,17 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::Event& iEvent, const edm::EventS auto dEtaMapForEvent = std::make_unique(dEtaMap); auto dEtaSeedMapForEvent = std::make_unique(dEtaSeedMap); auto dPhiMapForEvent = std::make_unique(dPhiMap); - auto oneOverESuperMinusOneOverPMapForEvent = std::make_unique(oneOverESuperMinusOneOverPMap); - auto oneOverESeedMinusOneOverPMapForEvent = std::make_unique(oneOverESeedMinusOneOverPMap); + auto oneOverESuperMinusOneOverPMapForEvent = + std::make_unique(oneOverESuperMinusOneOverPMap); + auto oneOverESeedMinusOneOverPMapForEvent = + std::make_unique(oneOverESeedMinusOneOverPMap); auto missingHitsForEvent = std::make_unique(missingHitsMap); auto validHitsForEvent = std::make_unique(validHitsMap); auto chi2ForEvent = std::make_unique(chi2Map); - iEvent.put(std::move(dEtaMapForEvent), "Deta" ); - iEvent.put(std::move(dEtaSeedMapForEvent), "DetaSeed" ); - iEvent.put(std::move(dPhiMapForEvent), "Dphi" ); + iEvent.put(std::move(dEtaMapForEvent), "Deta"); + iEvent.put(std::move(dEtaSeedMapForEvent), "DetaSeed"); + iEvent.put(std::move(dPhiMapForEvent), "Dphi"); iEvent.put(std::move(oneOverESuperMinusOneOverPMapForEvent), "OneOESuperMinusOneOP"); iEvent.put(std::move(oneOverESeedMinusOneOverPMapForEvent), "OneOESeedMinusOneOP"); iEvent.put(std::move(missingHitsForEvent), "MissingHits"); @@ -213,70 +215,71 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::Event& iEvent, const edm::EventS iEvent.put(std::move(chi2ForEvent), "Chi2"); } +EgammaHLTGsfTrackVarProducer::TrackExtrapolator::TrackExtrapolator( + const EgammaHLTGsfTrackVarProducer::TrackExtrapolator& rhs) + : cacheIDTDGeom_(rhs.cacheIDTDGeom_), + cacheIDMagField_(rhs.cacheIDMagField_), + magField_(rhs.magField_), + trackerHandle_(rhs.trackerHandle_) { + if (rhs.mtsTransform_) + mtsTransform_ = new MultiTrajectoryStateTransform(*rhs.mtsTransform_); + else + mtsTransform_ = nullptr; +} -EgammaHLTGsfTrackVarProducer::TrackExtrapolator::TrackExtrapolator(const EgammaHLTGsfTrackVarProducer::TrackExtrapolator& rhs): - cacheIDTDGeom_(rhs.cacheIDTDGeom_), - cacheIDMagField_(rhs.cacheIDMagField_), - magField_(rhs.magField_), - trackerHandle_(rhs.trackerHandle_) -{ - if(rhs.mtsTransform_) mtsTransform_ = new MultiTrajectoryStateTransform(*rhs.mtsTransform_); - else mtsTransform_ =nullptr; - -} - -EgammaHLTGsfTrackVarProducer::TrackExtrapolator* EgammaHLTGsfTrackVarProducer::TrackExtrapolator::operator=(const EgammaHLTGsfTrackVarProducer::TrackExtrapolator& rhs) -{ - if(this!=&rhs){ //just to ensure we're not copying ourselves +EgammaHLTGsfTrackVarProducer::TrackExtrapolator* EgammaHLTGsfTrackVarProducer::TrackExtrapolator::operator=( + const EgammaHLTGsfTrackVarProducer::TrackExtrapolator& rhs) { + if (this != &rhs) { //just to ensure we're not copying ourselves cacheIDTDGeom_ = rhs.cacheIDTDGeom_; cacheIDMagField_ = rhs.cacheIDMagField_; magField_ = rhs.magField_; trackerHandle_ = rhs.trackerHandle_; - + delete mtsTransform_; - if(rhs.mtsTransform_) mtsTransform_ = new MultiTrajectoryStateTransform(*rhs.mtsTransform_); - else mtsTransform_ =nullptr; + if (rhs.mtsTransform_) + mtsTransform_ = new MultiTrajectoryStateTransform(*rhs.mtsTransform_); + else + mtsTransform_ = nullptr; } return this; } -void EgammaHLTGsfTrackVarProducer::TrackExtrapolator::setup(const edm::EventSetup& iSetup) -{ +void EgammaHLTGsfTrackVarProducer::TrackExtrapolator::setup(const edm::EventSetup& iSetup) { bool updateField(false); - if (cacheIDMagField_!=iSetup.get().cacheIdentifier()){ + if (cacheIDMagField_ != iSetup.get().cacheIdentifier()) { updateField = true; - cacheIDMagField_=iSetup.get().cacheIdentifier(); + cacheIDMagField_ = iSetup.get().cacheIdentifier(); iSetup.get().get(magField_); } - + bool updateGeometry(false); - if (cacheIDTDGeom_!=iSetup.get().cacheIdentifier()){ + if (cacheIDTDGeom_ != iSetup.get().cacheIdentifier()) { updateGeometry = true; - cacheIDTDGeom_=iSetup.get().cacheIdentifier(); + cacheIDTDGeom_ = iSetup.get().cacheIdentifier(); iSetup.get().get(trackerHandle_); } - - if ( updateField || updateGeometry || !mtsTransform_ ) { + + if (updateField || updateGeometry || !mtsTransform_) { delete mtsTransform_; - mtsTransform_ = new MultiTrajectoryStateTransform(trackerHandle_.product(),magField_.product()); + mtsTransform_ = new MultiTrajectoryStateTransform(trackerHandle_.product(), magField_.product()); } } -GlobalPoint EgammaHLTGsfTrackVarProducer::TrackExtrapolator::extrapolateTrackPosToPoint(const reco::GsfTrack& gsfTrack,const GlobalPoint& pointToExtrapTo) -{ +GlobalPoint EgammaHLTGsfTrackVarProducer::TrackExtrapolator::extrapolateTrackPosToPoint( + const reco::GsfTrack& gsfTrack, const GlobalPoint& pointToExtrapTo) { TrajectoryStateOnSurface innTSOS = mtsTransform()->innerStateOnSurface(gsfTrack); - TrajectoryStateOnSurface posTSOS = mtsTransform()->extrapolatedState(innTSOS,pointToExtrapTo); - GlobalPoint extrapolatedPos; - multiTrajectoryStateMode::positionFromModeCartesian(posTSOS,extrapolatedPos); + TrajectoryStateOnSurface posTSOS = mtsTransform()->extrapolatedState(innTSOS, pointToExtrapTo); + GlobalPoint extrapolatedPos; + multiTrajectoryStateMode::positionFromModeCartesian(posTSOS, extrapolatedPos); return extrapolatedPos; } -GlobalVector EgammaHLTGsfTrackVarProducer::TrackExtrapolator::extrapolateTrackMomToPoint(const reco::GsfTrack& gsfTrack,const GlobalPoint& pointToExtrapTo) -{ +GlobalVector EgammaHLTGsfTrackVarProducer::TrackExtrapolator::extrapolateTrackMomToPoint( + const reco::GsfTrack& gsfTrack, const GlobalPoint& pointToExtrapTo) { TrajectoryStateOnSurface innTSOS = mtsTransform()->innerStateOnSurface(gsfTrack); - TrajectoryStateOnSurface posTSOS = mtsTransform()->extrapolatedState(innTSOS,pointToExtrapTo); - GlobalVector extrapolatedMom; - multiTrajectoryStateMode::momentumFromModeCartesian(posTSOS,extrapolatedMom); + TrajectoryStateOnSurface posTSOS = mtsTransform()->extrapolatedState(innTSOS, pointToExtrapTo); + GlobalVector extrapolatedMom; + multiTrajectoryStateMode::momentumFromModeCartesian(posTSOS, extrapolatedMom); return extrapolatedMom; } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationDoubleConeProducers.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationDoubleConeProducers.cc index 4e75c3b2f3073..735127d80beea 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationDoubleConeProducers.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationDoubleConeProducers.cc @@ -21,22 +21,20 @@ #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" EgammaHLTHcalIsolationDoubleConeProducers::EgammaHLTHcalIsolationDoubleConeProducers(const edm::ParameterSet& config) - : conf_(config) - , recoEcalCandidateProducer_ (consumes(conf_.getParameter("recoEcalCandidateProducer"))) - , hbRecHitProducer_ (consumes(conf_.getParameter("hbRecHitProducer"))) - , hfRecHitProducer_ (consumes(conf_.getParameter("hfRecHitProducer"))) - , egHcalIsoPtMin_ (conf_.getParameter("egHcalIsoPtMin")) - , egHcalIsoConeSize_ (conf_.getParameter("egHcalIsoConeSize")) - , egHcalExclusion_ (conf_.getParameter("egHcalExclusion")) - , test_ (new EgammaHLTHcalIsolationDoubleCone(egHcalIsoPtMin_,egHcalIsoConeSize_,egHcalExclusion_)) -{ - + : conf_(config), + recoEcalCandidateProducer_( + consumes(conf_.getParameter("recoEcalCandidateProducer"))), + hbRecHitProducer_(consumes(conf_.getParameter("hbRecHitProducer"))), + hfRecHitProducer_(consumes(conf_.getParameter("hfRecHitProducer"))), + egHcalIsoPtMin_(conf_.getParameter("egHcalIsoPtMin")), + egHcalIsoConeSize_(conf_.getParameter("egHcalIsoConeSize")), + egHcalExclusion_(conf_.getParameter("egHcalExclusion")), + test_(new EgammaHLTHcalIsolationDoubleCone(egHcalIsoPtMin_, egHcalIsoConeSize_, egHcalExclusion_)) { //register your products - produces < reco::RecoEcalCandidateIsolationMap >(); + produces(); } - -EgammaHLTHcalIsolationDoubleConeProducers::~EgammaHLTHcalIsolationDoubleConeProducers(){delete test_;} +EgammaHLTHcalIsolationDoubleConeProducers::~EgammaHLTHcalIsolationDoubleConeProducers() { delete test_; } void EgammaHLTHcalIsolationDoubleConeProducers::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -49,11 +47,13 @@ void EgammaHLTHcalIsolationDoubleConeProducers::fillDescriptions(edm::Configurat descriptions.add(("hltEgammaHLTHcalIsolationDoubleConeProducers"), desc); } -void EgammaHLTHcalIsolationDoubleConeProducers::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { +void EgammaHLTHcalIsolationDoubleConeProducers::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { // Get the HLT filtered objects edm::Handle recoecalcandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); - + iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); + // Get the barrel hcal hits edm::Handle hhitBarrelHandle; iEvent.getByToken(hbRecHitProducer_, hhitBarrelHandle); @@ -66,17 +66,15 @@ void EgammaHLTHcalIsolationDoubleConeProducers::produce(edm::StreamID sid, edm:: edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* caloGeom = pG.product(); - + reco::RecoEcalCandidateIsolationMap isoMap; - - for(unsigned int iRecoEcalCand=0; iRecoEcalCandsize(); iRecoEcalCand++) { - + + for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoecalcandHandle->size(); iRecoEcalCand++) { reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand); - float isol = test_->isolPtSum(&(*recoecalcandref), hcalhitBarrelCollection, hcalhitEndcapCollection, caloGeom); - + float isol = test_->isolPtSum(&(*recoecalcandref), hcalhitBarrelCollection, hcalhitEndcapCollection, caloGeom); + isoMap.insert(recoecalcandref, isol); } iEvent.put(std::make_unique(isoMap)); - } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationProducersRegional.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationProducersRegional.cc index 4796d20cf2d7c..4ea9fed94eeb0 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationProducersRegional.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationProducersRegional.cc @@ -17,7 +17,6 @@ #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h" #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h" - #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" @@ -25,30 +24,28 @@ #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" EgammaHLTHcalIsolationProducersRegional::EgammaHLTHcalIsolationProducersRegional(const edm::ParameterSet& config) - : recoEcalCandidateProducer_ (consumes(config.getParameter("recoEcalCandidateProducer"))) - , hbheRecHitProducer_ (consumes(config.getParameter("hbheRecHitProducer"))) - , rhoProducer_ (consumes(config.getParameter("rhoProducer"))) - , doRhoCorrection_ (config.getParameter("doRhoCorrection")) - , rhoMax_ (config.getParameter("rhoMax")) - , rhoScale_ (config.getParameter("rhoScale")) - , doEtSum_ (config.getParameter("doEtSum")) - , effectiveAreaBarrel_ (config.getParameter("effectiveAreaBarrel")) - , effectiveAreaEndcap_ (config.getParameter("effectiveAreaEndcap")) - , isolAlgo_ (new EgammaHLTHcalIsolation(config.getParameter("eMinHB"), - config.getParameter("eMinHE"), - config.getParameter("etMinHB"), - config.getParameter("etMinHE"), - config.getParameter("innerCone"), - config.getParameter("outerCone"), - config.getParameter("depth"))) -{ + : recoEcalCandidateProducer_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + hbheRecHitProducer_(consumes(config.getParameter("hbheRecHitProducer"))), + rhoProducer_(consumes(config.getParameter("rhoProducer"))), + doRhoCorrection_(config.getParameter("doRhoCorrection")), + rhoMax_(config.getParameter("rhoMax")), + rhoScale_(config.getParameter("rhoScale")), + doEtSum_(config.getParameter("doEtSum")), + effectiveAreaBarrel_(config.getParameter("effectiveAreaBarrel")), + effectiveAreaEndcap_(config.getParameter("effectiveAreaEndcap")), + isolAlgo_(new EgammaHLTHcalIsolation(config.getParameter("eMinHB"), + config.getParameter("eMinHE"), + config.getParameter("etMinHB"), + config.getParameter("etMinHE"), + config.getParameter("innerCone"), + config.getParameter("outerCone"), + config.getParameter("depth"))) { //register your products - produces < reco::RecoEcalCandidateIsolationMap >(); + produces(); } -EgammaHLTHcalIsolationProducersRegional::~EgammaHLTHcalIsolationProducersRegional() { - delete isolAlgo_; -} +EgammaHLTHcalIsolationProducersRegional::~EgammaHLTHcalIsolationProducersRegional() { delete isolAlgo_; } void EgammaHLTHcalIsolationProducersRegional::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -56,34 +53,35 @@ void EgammaHLTHcalIsolationProducersRegional::fillDescriptions(edm::Configuratio desc.add(("hbheRecHitProducer"), edm::InputTag("hltHbhereco")); desc.add(("rhoProducer"), edm::InputTag("fixedGridRhoFastjetAllCalo")); desc.add(("doRhoCorrection"), false); - desc.add(("rhoMax"), 9.9999999E7); - desc.add(("rhoScale"), 1.0); + desc.add(("rhoMax"), 9.9999999E7); + desc.add(("rhoScale"), 1.0); desc.add(("eMinHB"), 0.7); desc.add(("eMinHE"), 0.8); - desc.add(("etMinHB"), -1.0); + desc.add(("etMinHB"), -1.0); desc.add(("etMinHE"), -1.0); desc.add(("innerCone"), 0); desc.add(("outerCone"), 0.15); - desc.add(("depth"), -1); + desc.add(("depth"), -1); desc.add(("doEtSum"), false); desc.add(("effectiveAreaBarrel"), 0.105); desc.add(("effectiveAreaEndcap"), 0.170); - descriptions.add(("hltEgammaHLTHcalIsolationProducersRegional"), desc); + descriptions.add(("hltEgammaHLTHcalIsolationProducersRegional"), desc); } -void EgammaHLTHcalIsolationProducersRegional::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTHcalIsolationProducersRegional::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { // Get the HLT filtered objects edm::Handle recoEcalCandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoEcalCandHandle); + iEvent.getByToken(recoEcalCandidateProducer_, recoEcalCandHandle); // Get the barrel hcal hits - edm::Handle hbheRecHitHandle; + edm::Handle hbheRecHitHandle; iEvent.getByToken(hbheRecHitProducer_, hbheRecHitHandle); const HBHERecHitCollection* hbheRecHitCollection = hbheRecHitHandle.product(); - - edm::ESHandle hcalChStatusHandle; - iSetup.get().get( "withTopo", hcalChStatusHandle ); + + edm::ESHandle hcalChStatusHandle; + iSetup.get().get("withTopo", hcalChStatusHandle); const HcalChannelQuality* hcalChStatus = hcalChStatusHandle.product(); edm::ESHandle hcalSevLvlComp; @@ -99,42 +97,47 @@ void EgammaHLTHcalIsolationProducersRegional::produce(edm::StreamID sid, edm::Ev if (rho > rhoMax_) rho = rhoMax_; - rho = rho*rhoScale_; + rho = rho * rhoScale_; edm::ESHandle caloGeomHandle; iSetup.get().get(caloGeomHandle); const CaloGeometry* caloGeom = caloGeomHandle.product(); - + reco::RecoEcalCandidateIsolationMap isoMap(recoEcalCandHandle); - - - for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){ - - reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand -recoEcalCandHandle ->begin()); - + + for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); + iRecoEcalCand != recoEcalCandHandle->end(); + iRecoEcalCand++) { + reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand - recoEcalCandHandle->begin()); + float isol = 0; - if(doEtSum_) { + if (doEtSum_) { isol = isolAlgo_->getEtSum(recoEcalCandRef->superCluster()->eta(), - recoEcalCandRef->superCluster()->phi(),hbheRecHitCollection,caloGeom, - hcalSevLvlComp.product(),hcalChStatus); - + recoEcalCandRef->superCluster()->phi(), + hbheRecHitCollection, + caloGeom, + hcalSevLvlComp.product(), + hcalChStatus); + if (doRhoCorrection_) { - if (fabs(recoEcalCandRef->superCluster()->eta()) < 1.442) - isol = isol - rho*effectiveAreaBarrel_; - else - isol = isol - rho*effectiveAreaEndcap_; + if (fabs(recoEcalCandRef->superCluster()->eta()) < 1.442) + isol = isol - rho * effectiveAreaBarrel_; + else + isol = isol - rho * effectiveAreaEndcap_; } } else { - isol = isolAlgo_->getESum(recoEcalCandRef->superCluster()->eta(),recoEcalCandRef->superCluster()->phi(), - hbheRecHitCollection,caloGeom, - hcalSevLvlComp.product(),hcalChStatus); + isol = isolAlgo_->getESum(recoEcalCandRef->superCluster()->eta(), + recoEcalCandRef->superCluster()->phi(), + hbheRecHitCollection, + caloGeom, + hcalSevLvlComp.product(), + hcalChStatus); } - isoMap.insert(recoEcalCandRef, isol); + isoMap.insert(recoEcalCandRef, isol); } iEvent.put(std::make_unique(isoMap)); - } //define this as a plug-in diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHybridClusterProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHybridClusterProducer.cc index ca9b9f0a82406..eb53439a8cc5f 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHybridClusterProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHybridClusterProducer.cc @@ -42,71 +42,69 @@ // Class header file #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHybridClusterProducer.h" - EgammaHLTHybridClusterProducer::EgammaHLTHybridClusterProducer(const edm::ParameterSet& ps) - : basicclusterCollection_ (ps.getParameter("basicclusterCollection")) - , superclusterCollection_ (ps.getParameter("superclusterCollection")) - , hittoken_ (consumes(hitcollection_)) - , hitcollection_ (ps.getParameter("ecalhitcollection")) - - // L1 matching parameters - , l1TagIsolated_ (consumes(ps.getParameter< edm::InputTag > ("l1TagIsolated"))) - , l1TagNonIsolated_ (consumes(ps.getParameter< edm::InputTag > ("l1TagNonIsolated"))) - - , doIsolated_ (ps.getParameter("doIsolated")) - - , l1LowerThr_ (ps.getParameter ("l1LowerThr")) - , l1UpperThr_ (ps.getParameter ("l1UpperThr")) - , l1LowerThrIgnoreIsolation_ (ps.getParameter ("l1LowerThrIgnoreIsolation")) - - , regionEtaMargin_ (ps.getParameter("regionEtaMargin")) - , regionPhiMargin_ (ps.getParameter("regionPhiMargin")) - - // Parameters for the position calculation: - , posCalculator_ (PositionCalc( ps.getParameter("posCalcParameters") )) - - , hybrid_p (new HybridClusterAlgo( - ps.getParameter("HybridBarrelSeedThr"), - ps.getParameter("step"), - ps.getParameter("ethresh"), - ps.getParameter("eseed"), - ps.getParameter("xi"), - ps.getParameter("useEtForXi"), - ps.getParameter("ewing"), - StringToEnumValue( - ps.getParameter >("RecHitFlagToBeExcluded")), - posCalculator_, - ps.getParameter("dynamicEThresh"), - ps.getParameter("eThreshA"), - ps.getParameter("eThreshB"), - StringToEnumValue( - ps.getParameter >("RecHitSeverityToBeExcluded")), - ps.getParameter("excludeFlagged"))) -{ + : basicclusterCollection_(ps.getParameter("basicclusterCollection")), + superclusterCollection_(ps.getParameter("superclusterCollection")), + hittoken_(consumes(hitcollection_)), + hitcollection_(ps.getParameter("ecalhitcollection")) + + // L1 matching parameters + , + l1TagIsolated_(consumes(ps.getParameter("l1TagIsolated"))), + l1TagNonIsolated_(consumes(ps.getParameter("l1TagNonIsolated"))) + + , + doIsolated_(ps.getParameter("doIsolated")) + + , + l1LowerThr_(ps.getParameter("l1LowerThr")), + l1UpperThr_(ps.getParameter("l1UpperThr")), + l1LowerThrIgnoreIsolation_(ps.getParameter("l1LowerThrIgnoreIsolation")) + + , + regionEtaMargin_(ps.getParameter("regionEtaMargin")), + regionPhiMargin_(ps.getParameter("regionPhiMargin")) + + // Parameters for the position calculation: + , + posCalculator_(PositionCalc(ps.getParameter("posCalcParameters"))) + + , + hybrid_p(new HybridClusterAlgo( + ps.getParameter("HybridBarrelSeedThr"), + ps.getParameter("step"), + ps.getParameter("ethresh"), + ps.getParameter("eseed"), + ps.getParameter("xi"), + ps.getParameter("useEtForXi"), + ps.getParameter("ewing"), + StringToEnumValue(ps.getParameter>("RecHitFlagToBeExcluded")), + posCalculator_, + ps.getParameter("dynamicEThresh"), + ps.getParameter("eThreshA"), + ps.getParameter("eThreshB"), + StringToEnumValue( + ps.getParameter>("RecHitSeverityToBeExcluded")), + ps.getParameter("excludeFlagged"))) { if (ps.getParameter("dynamicPhiRoad")) { - edm::ParameterSet bremRecoveryPset = ps.getParameter("bremRecoveryPset"); - hybrid_p->setDynamicPhiRoad(bremRecoveryPset); + edm::ParameterSet bremRecoveryPset = ps.getParameter("bremRecoveryPset"); + hybrid_p->setDynamicPhiRoad(bremRecoveryPset); } - produces< reco::BasicClusterCollection >(basicclusterCollection_); - produces< reco::SuperClusterCollection >(superclusterCollection_); + produces(basicclusterCollection_); + produces(superclusterCollection_); } - -EgammaHLTHybridClusterProducer::~EgammaHLTHybridClusterProducer() -{ - delete hybrid_p; -} +EgammaHLTHybridClusterProducer::~EgammaHLTHybridClusterProducer() { delete hybrid_p; } void EgammaHLTHybridClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add("debugLevel" , "INFO"); + desc.add("debugLevel", "INFO"); desc.add("basicclusterCollection", ""); desc.add("superclusterCollection", ""); - desc.add("ecalhitcollection", edm::InputTag("ecalRecHit","EcalRecHitsEB")); - desc.add("l1TagIsolated", edm::InputTag("l1extraParticles","Isolated")); - desc.add("l1TagNonIsolated", edm::InputTag("l1extraParticles","NonIsolated")); + desc.add("ecalhitcollection", edm::InputTag("ecalRecHit", "EcalRecHitsEB")); + desc.add("l1TagIsolated", edm::InputTag("l1extraParticles", "Isolated")); + desc.add("l1TagNonIsolated", edm::InputTag("l1extraParticles", "NonIsolated")); desc.add("doIsolated", true); desc.add("l1LowerThr", 0); desc.add("l1UpperThr", 9999.0); @@ -124,7 +122,7 @@ void EgammaHLTHybridClusterProducer::fillDescriptions(edm::ConfigurationDescript desc.add("posCalcParameters", posCalcPSET); desc.add>("RecHitFlagToBeExcluded", std::vector()); - desc.add >("RecHitSeverityToBeExcluded", std::vector()); + desc.add>("RecHitSeverityToBeExcluded", std::vector()); desc.add("severityRecHitThreshold", 4.0); desc.add("HybridBarrelSeedThr", 1.0); desc.add("step", 10); @@ -139,154 +137,155 @@ void EgammaHLTHybridClusterProducer::fillDescriptions(edm::ConfigurationDescript desc.add("excludeFlagged", false); desc.add("dynamicPhiRoad", false); //desc.add("bremRecoveryPset", edm::ParameterSet()); - - descriptions.add("hltEgammaHLTHybridClusterProducer", desc); -} + descriptions.add("hltEgammaHLTHybridClusterProducer", desc); +} void EgammaHLTHybridClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es) { - // get the hit collection from the event: edm::Handle rhcHandle; evt.getByToken(hittoken_, rhcHandle); - - if (!(rhcHandle.isValid())) - { - edm::LogError("ProductNotFound")<< "could not get a handle on the EcalRecHitCollection!" << std::endl; - return; - } - const EcalRecHitCollection *hit_collection = rhcHandle.product(); + + if (!(rhcHandle.isValid())) { + edm::LogError("ProductNotFound") << "could not get a handle on the EcalRecHitCollection!" << std::endl; + return; + } + const EcalRecHitCollection* hit_collection = rhcHandle.product(); // get the collection geometry: edm::ESHandle geoHandle; es.get().get(geoHandle); const CaloGeometry& geometry = *geoHandle; - const CaloSubdetectorGeometry *geometry_p; + const CaloSubdetectorGeometry* geometry_p; std::unique_ptr topology; //edm::ESHandle chStatus; //es.get().get(chStatus); //const EcalChannelStatus* theEcalChStatus = chStatus.product(); - + edm::ESHandle sevlv; es.get().get(sevlv); const EcalSeverityLevelAlgo* sevLevel = sevlv.product(); - - if(hitcollection_.instance() == "EcalRecHitsEB") { + + if (hitcollection_.instance() == "EcalRecHitsEB") { geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel); topology = std::make_unique(*geoHandle); - } else if(hitcollection_.instance() == "EcalRecHitsEE") { + } else if (hitcollection_.instance() == "EcalRecHitsEE") { geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap); topology = std::make_unique(*geoHandle); - } else if(hitcollection_.instance() == "EcalRecHitsPS") { + } else if (hitcollection_.instance() == "EcalRecHitsPS") { geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower); topology = std::make_unique(); - } else throw(std::runtime_error("\n\nHybrid Cluster Producer encountered invalied ecalhitcollection type.\n\n")); - + } else + throw(std::runtime_error("\n\nHybrid Cluster Producer encountered invalied ecalhitcollection type.\n\n")); + //Get the L1 EM Particle Collection //Get the L1 EM Particle Collection - edm::Handle< l1extra::L1EmParticleCollection > emIsolColl ; - if(doIsolated_) + edm::Handle emIsolColl; + if (doIsolated_) evt.getByToken(l1TagIsolated_, emIsolColl); //Get the L1 EM Particle Collection - edm::Handle< l1extra::L1EmParticleCollection > emNonIsolColl ; + edm::Handle emNonIsolColl; evt.getByToken(l1TagNonIsolated_, emNonIsolColl); // Get the CaloGeometry - edm::ESHandle l1CaloGeom ; - es.get().get(l1CaloGeom) ; + edm::ESHandle l1CaloGeom; + es.get().get(l1CaloGeom); std::vector regions; - if(doIsolated_) { - for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr ){ - - if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) { - - // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - int phiIndex = emItr->gctEmCand()->phiIndex() ; - // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - - int isbarl=0; - //Part of the region is in the barel if either the upper or lower - //edge of the region is within the barrel - if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) || - ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1; - - - etaLow -= regionEtaMargin_; - etaHigh += regionEtaMargin_; - phiLow -= regionPhiMargin_; - phiHigh += regionPhiMargin_; - - if (etaHigh>1.479) etaHigh=1.479; - if (etaLow<-1.479) etaLow=-1.479; - - if(isbarl) regions.push_back(RectangularEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh)); - + if (doIsolated_) { + for (l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end(); + ++emItr) { + if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) { + // Access the GCT hardware object corresponding to the L1Extra EM object. + int etaIndex = emItr->gctEmCand()->etaIndex(); + int phiIndex = emItr->gctEmCand()->phiIndex(); + // Use the L1CaloGeometry to find the eta, phi bin boundaries. + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + + int isbarl = 0; + //Part of the region is in the barel if either the upper or lower + //edge of the region is within the barrel + if (((float)(etaLow) > -1.479 && (float)(etaLow) < 1.479) || + ((float)(etaHigh) > -1.479 && (float)(etaHigh) < 1.479)) + isbarl = 1; + + etaLow -= regionEtaMargin_; + etaHigh += regionEtaMargin_; + phiLow -= regionPhiMargin_; + phiHigh += regionPhiMargin_; + + if (etaHigh > 1.479) + etaHigh = 1.479; + if (etaLow < -1.479) + etaLow = -1.479; + + if (isbarl) + regions.push_back(RectangularEtaPhiRegion(etaLow, etaHigh, phiLow, phiHigh)); + } } } - } - if(!doIsolated_||l1LowerThrIgnoreIsolation_<64) { - for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr ){ - - if(doIsolated_&&emItr->et()et() > l1LowerThr_ && emItr->et() < l1UpperThr_) { - - // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - int phiIndex = emItr->gctEmCand()->phiIndex() ; - // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - - int isbarl=0; - //Part of the region is in the barel if either the upper or lower - //edge of the region is within the barrel - if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) || - ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1; - - - etaLow -= regionEtaMargin_; - etaHigh += regionEtaMargin_; - phiLow -= regionPhiMargin_; - phiHigh += regionPhiMargin_; - - if (etaHigh>1.479) etaHigh=1.479; - if (etaLow<-1.479) etaLow=-1.479; - - if(isbarl) regions.push_back(RectangularEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh)); - - } + if (!doIsolated_ || l1LowerThrIgnoreIsolation_ < 64) { + for (l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end(); + ++emItr) { + if (doIsolated_ && emItr->et() < l1LowerThrIgnoreIsolation_) + continue; + + if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) { + // Access the GCT hardware object corresponding to the L1Extra EM object. + int etaIndex = emItr->gctEmCand()->etaIndex(); + int phiIndex = emItr->gctEmCand()->phiIndex(); + // Use the L1CaloGeometry to find the eta, phi bin boundaries. + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + + int isbarl = 0; + //Part of the region is in the barel if either the upper or lower + //edge of the region is within the barrel + if (((float)(etaLow) > -1.479 && (float)(etaLow) < 1.479) || + ((float)(etaHigh) > -1.479 && (float)(etaHigh) < 1.479)) + isbarl = 1; + + etaLow -= regionEtaMargin_; + etaHigh += regionEtaMargin_; + phiLow -= regionPhiMargin_; + phiHigh += regionPhiMargin_; + + if (etaHigh > 1.479) + etaHigh = 1.479; + if (etaLow < -1.479) + etaLow = -1.479; + + if (isbarl) + regions.push_back(RectangularEtaPhiRegion(etaLow, etaHigh, phiLow, phiHigh)); + } } } - + // make the Basic clusters! reco::BasicClusterCollection basicClusters; hybrid_p->makeClusters(hit_collection, geometry_p, basicClusters, sevLevel, true, regions); - + // create an unique_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event: auto basicclusters_p = std::make_unique(); basicclusters_p->assign(basicClusters.begin(), basicClusters.end()); - edm::OrphanHandle bccHandle = evt.put(std::move(basicclusters_p), - basicclusterCollection_); + edm::OrphanHandle bccHandle = + evt.put(std::move(basicclusters_p), basicclusterCollection_); if (!(bccHandle.isValid())) { return; } reco::BasicClusterCollection clusterCollection = *bccHandle; reco::CaloClusterPtrVector clusterRefVector; - for (unsigned int i = 0; i < clusterCollection.size(); i++){ + for (unsigned int i = 0; i < clusterCollection.size(); i++) { clusterRefVector.push_back(reco::CaloClusterPtr(bccHandle, i)); } @@ -296,5 +295,3 @@ void EgammaHLTHybridClusterProducer::produce(edm::Event& evt, const edm::EventSe superclusters_p->assign(superClusters.begin(), superClusters.end()); evt.put(std::move(superclusters_p), superclusterCollection_); } - - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTIslandClusterProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTIslandClusterProducer.cc index f2d543e9d9c04..963f6be0b3ede 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTIslandClusterProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTIslandClusterProducer.cc @@ -36,58 +36,62 @@ #include "CommonTools/Utils/interface/StringToEnumValue.h" EgammaHLTIslandClusterProducer::EgammaHLTIslandClusterProducer(const edm::ParameterSet& ps) - : doBarrel_ (ps.getParameter("doBarrel")) - , doEndcaps_ (ps.getParameter("doEndcaps")) - , doIsolated_ (ps.getParameter("doIsolated")) - - // Parameters to identify the hit collections - , barrelHitCollection_ (ps.getParameter("barrelHitProducer")) - , endcapHitCollection_ (ps.getParameter("endcapHitProducer")) - , barrelHitToken_ (consumes(barrelHitCollection_)) - , endcapHitToken_ (consumes(endcapHitCollection_)) - - // The names of the produced cluster collections - , barrelClusterCollection_ (ps.getParameter("barrelClusterCollection")) - , endcapClusterCollection_ (ps.getParameter("endcapClusterCollection")) - - // L1 matching parameters - , l1TagIsolated_ (consumes(ps.getParameter< edm::InputTag > ("l1TagIsolated"))) - , l1TagNonIsolated_ (consumes(ps.getParameter< edm::InputTag > ("l1TagNonIsolated"))) - , l1LowerThr_ (ps.getParameter ("l1LowerThr")) - , l1UpperThr_ (ps.getParameter ("l1UpperThr")) - , l1LowerThrIgnoreIsolation_ (ps.getParameter ("l1LowerThrIgnoreIsolation")) - - , regionEtaMargin_ (ps.getParameter("regionEtaMargin")) - , regionPhiMargin_ (ps.getParameter("regionPhiMargin")) - - // Parameters for the position calculation: - , posCalculator_ (PositionCalc( ps.getParameter("posCalcParameters") )) - // Island algorithm parameters - , verb_ (ps.getParameter("VerbosityLevel")) - , island_p (new IslandClusterAlgo(ps.getParameter("IslandBarrelSeedThr"), - ps.getParameter("IslandEndcapSeedThr"), - posCalculator_, - StringToEnumValue(ps.getParameter >("SeedRecHitFlagToBeExcludedEB")), - StringToEnumValue(ps.getParameter >("SeedRecHitFlagToBeExcludedEE")), - StringToEnumValue(ps.getParameter >("RecHitFlagToBeExcludedEB")), - StringToEnumValue(ps.getParameter >("RecHitFlagToBeExcludedEE")), - verb_ == "DEBUG" ? IslandClusterAlgo::pDEBUG : - (verb_ == "WARNING" ? IslandClusterAlgo::pWARNING : - (verb_ == "INFO" ? IslandClusterAlgo::pINFO : - IslandClusterAlgo::pERROR))) - ) -{ + : doBarrel_(ps.getParameter("doBarrel")), + doEndcaps_(ps.getParameter("doEndcaps")), + doIsolated_(ps.getParameter("doIsolated")) + + // Parameters to identify the hit collections + , + barrelHitCollection_(ps.getParameter("barrelHitProducer")), + endcapHitCollection_(ps.getParameter("endcapHitProducer")), + barrelHitToken_(consumes(barrelHitCollection_)), + endcapHitToken_(consumes(endcapHitCollection_)) + + // The names of the produced cluster collections + , + barrelClusterCollection_(ps.getParameter("barrelClusterCollection")), + endcapClusterCollection_(ps.getParameter("endcapClusterCollection")) + + // L1 matching parameters + , + l1TagIsolated_(consumes(ps.getParameter("l1TagIsolated"))), + l1TagNonIsolated_(consumes(ps.getParameter("l1TagNonIsolated"))), + l1LowerThr_(ps.getParameter("l1LowerThr")), + l1UpperThr_(ps.getParameter("l1UpperThr")), + l1LowerThrIgnoreIsolation_(ps.getParameter("l1LowerThrIgnoreIsolation")) + + , + regionEtaMargin_(ps.getParameter("regionEtaMargin")), + regionPhiMargin_(ps.getParameter("regionPhiMargin")) + + // Parameters for the position calculation: + , + posCalculator_(PositionCalc(ps.getParameter("posCalcParameters"))) + // Island algorithm parameters + , + verb_(ps.getParameter("VerbosityLevel")), + island_p(new IslandClusterAlgo( + ps.getParameter("IslandBarrelSeedThr"), + ps.getParameter("IslandEndcapSeedThr"), + posCalculator_, + StringToEnumValue( + ps.getParameter>("SeedRecHitFlagToBeExcludedEB")), + StringToEnumValue( + ps.getParameter>("SeedRecHitFlagToBeExcludedEE")), + StringToEnumValue(ps.getParameter>("RecHitFlagToBeExcludedEB")), + StringToEnumValue(ps.getParameter>("RecHitFlagToBeExcludedEE")), + verb_ == "DEBUG" + ? IslandClusterAlgo::pDEBUG + : (verb_ == "WARNING" ? IslandClusterAlgo::pWARNING + : (verb_ == "INFO" ? IslandClusterAlgo::pINFO : IslandClusterAlgo::pERROR)))) { // Produces a collection of barrel and a collection of endcap clusters - produces< reco::BasicClusterCollection >(endcapClusterCollection_); - produces< reco::BasicClusterCollection >(barrelClusterCollection_); + produces(endcapClusterCollection_); + produces(barrelClusterCollection_); } -EgammaHLTIslandClusterProducer::~EgammaHLTIslandClusterProducer() { - delete island_p; -} +EgammaHLTIslandClusterProducer::~EgammaHLTIslandClusterProducer() { delete island_p; } void EgammaHLTIslandClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("VerbosityLevel", "ERROR"); desc.add("doBarrel", true); @@ -99,8 +103,8 @@ void EgammaHLTIslandClusterProducer::fillDescriptions(edm::ConfigurationDescript desc.add("endcapClusterCollection", "islandEndcapBasicClusters"); desc.add("IslandBarrelSeedThr", 0.5); desc.add("IslandEndcapSeedThr", 0.18); - desc.add("l1TagIsolated", edm::InputTag("l1extraParticles","Isolated")); - desc.add("l1TagNonIsolated", edm::InputTag("l1extraParticles","NonIsolated")); + desc.add("l1TagIsolated", edm::InputTag("l1extraParticles", "Isolated")); + desc.add("l1TagNonIsolated", edm::InputTag("l1extraParticles", "NonIsolated")); desc.add("l1LowerThr", 0.0); desc.add("l1UpperThr", 9999.0); desc.add("l1LowerThrIgnoreIsolation", 9999.0); @@ -111,194 +115,192 @@ void EgammaHLTIslandClusterProducer::fillDescriptions(edm::ConfigurationDescript desc.add>("SeedRecHitFlagToBeExcludedEE", {}); desc.add>("RecHitFlagToBeExcludedEB", {}); desc.add>("RecHitFlagToBeExcludedEE", {}); - descriptions.add("hltEgammaHLTIslandClusterProducer", desc); + descriptions.add("hltEgammaHLTIslandClusterProducer", desc); } void EgammaHLTIslandClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es) { - //Get the L1 EM Particle Collection - edm::Handle< l1extra::L1EmParticleCollection > emIsolColl ; - if(doIsolated_) + edm::Handle emIsolColl; + if (doIsolated_) evt.getByToken(l1TagIsolated_, emIsolColl); - + //Get the L1 EM Particle Collection - edm::Handle< l1extra::L1EmParticleCollection > emNonIsolColl ; + edm::Handle emNonIsolColl; evt.getByToken(l1TagNonIsolated_, emNonIsolColl); // Get the CaloGeometry - edm::ESHandle l1CaloGeom ; - es.get().get(l1CaloGeom) ; + edm::ESHandle l1CaloGeom; + es.get().get(l1CaloGeom); std::vector barrelRegions; std::vector endcapRegions; - if(doIsolated_) { - for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr ){ - + if (doIsolated_) { + for (l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end(); + ++emItr) { if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) { - - // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - - int phiIndex = emItr->gctEmCand()->phiIndex() ; - // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - - //Attention isForward does not work - int isforw=0; - int isbarl=0; - if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1; - if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) || - ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1; - - //std::cout<<"Island etaindex "<gctEmCand()->regionId().isForward()<<" isforwnew" <gctEmCand()->regionId().isForward()) { - if (isforw) { - if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479; - if ( etaLow>-1.479 && etaLow<1.479) etaLow=1.479; - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - endcapRegions.push_back(region); - } - if (isbarl) { - if (etaHigh>1.479) etaHigh=1.479; - if (etaLow<-1.479) etaLow=-1.479; - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - barrelRegions.push_back(region); - } - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - + // Access the GCT hardware object corresponding to the L1Extra EM object. + int etaIndex = emItr->gctEmCand()->etaIndex(); + + int phiIndex = emItr->gctEmCand()->phiIndex(); + // Use the L1CaloGeometry to find the eta, phi bin boundaries. + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + + //Attention isForward does not work + int isforw = 0; + int isbarl = 0; + if ((float)(etaHigh) > 1.479 || (float)(etaLow) < -1.479) + isforw = 1; + if (((float)(etaLow) > -1.479 && (float)(etaLow) < 1.479) || + ((float)(etaHigh) > -1.479 && (float)(etaHigh) < 1.479)) + isbarl = 1; + + //std::cout<<"Island etaindex "<gctEmCand()->regionId().isForward()<<" isforwnew" <gctEmCand()->regionId().isForward()) { + if (isforw) { + if (etaHigh > -1.479 && etaHigh < 1.479) + etaHigh = -1.479; + if (etaLow > -1.479 && etaLow < 1.479) + etaLow = 1.479; + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); + endcapRegions.push_back(region); + } + if (isbarl) { + if (etaHigh > 1.479) + etaHigh = 1.479; + if (etaLow < -1.479) + etaLow = -1.479; + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); + barrelRegions.push_back(region); + } + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); } } } - - if(!doIsolated_||l1LowerThrIgnoreIsolation_<64) { - for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr ){ - - if(doIsolated_&&emItr->et()begin(); emItr != emNonIsolColl->end(); + ++emItr) { + if (doIsolated_ && emItr->et() < l1LowerThrIgnoreIsolation_) + continue; if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) { - - // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - - - int phiIndex = emItr->gctEmCand()->phiIndex() ; - // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - - - int isforw=0; - int isbarl=0; - if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1; - if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) || - ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1; - - //std::cout<<"Island etaindex "<gctEmCand()->regionId().isForward()<<" isforwnew" <gctEmCand()->regionId().isForward()) { - if (isforw) { - if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479; - if ( etaLow>-1.479 && etaLow<1.479) etaLow=1.479; - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - endcapRegions.push_back(region); - } - if (isbarl) { - if (etaHigh>1.479) etaHigh=1.479; - if (etaLow<-1.479) etaLow=-1.479; - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - barrelRegions.push_back(region); - } - + // Access the GCT hardware object corresponding to the L1Extra EM object. + int etaIndex = emItr->gctEmCand()->etaIndex(); + + int phiIndex = emItr->gctEmCand()->phiIndex(); + // Use the L1CaloGeometry to find the eta, phi bin boundaries. + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + + int isforw = 0; + int isbarl = 0; + if ((float)(etaHigh) > 1.479 || (float)(etaLow) < -1.479) + isforw = 1; + if (((float)(etaLow) > -1.479 && (float)(etaLow) < 1.479) || + ((float)(etaHigh) > -1.479 && (float)(etaHigh) < 1.479)) + isbarl = 1; + + //std::cout<<"Island etaindex "<gctEmCand()->regionId().isForward()<<" isforwnew" <gctEmCand()->regionId().isForward()) { + if (isforw) { + if (etaHigh > -1.479 && etaHigh < 1.479) + etaHigh = -1.479; + if (etaLow > -1.479 && etaLow < 1.479) + etaLow = 1.479; + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); + endcapRegions.push_back(region); + } + if (isbarl) { + if (etaHigh > 1.479) + etaHigh = 1.479; + if (etaLow < -1.479) + etaLow = -1.479; + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); + barrelRegions.push_back(region); + } } } } - if (doEndcaps_ + if (doEndcaps_ //&&endcapRegions.size()!=0 - ) { - + ) { clusterizeECALPart(evt, es, endcapHitToken_, endcapClusterCollection_, endcapRegions, IslandClusterAlgo::endcap); } - if (doBarrel_ + if (doBarrel_ //&& barrelRegions.size()!=0 - ) { + ) { clusterizeECALPart(evt, es, barrelHitToken_, barrelClusterCollection_, barrelRegions, IslandClusterAlgo::barrel); } } - -const EcalRecHitCollection * EgammaHLTIslandClusterProducer::getCollection(edm::Event& evt, - const edm::EDGetTokenT& hitToken_) -const { +const EcalRecHitCollection* EgammaHLTIslandClusterProducer::getCollection( + edm::Event& evt, const edm::EDGetTokenT& hitToken_) const { edm::Handle rhcHandle; evt.getByToken(hitToken_, rhcHandle); - if (!(rhcHandle.isValid())) - { - std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl; - edm::LogError("EgammaHLTIslandClusterProducerError") << "Error! can't get the product "; - return nullptr; - } + if (!(rhcHandle.isValid())) { + std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl; + edm::LogError("EgammaHLTIslandClusterProducerError") << "Error! can't get the product "; + return nullptr; + } return rhcHandle.product(); } - -void EgammaHLTIslandClusterProducer::clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, - const edm::EDGetTokenT& hitToken, - const std::string& clusterCollection, - const std::vector& regions, - const IslandClusterAlgo::EcalPart& ecalPart) -const { +void EgammaHLTIslandClusterProducer::clusterizeECALPart(edm::Event& evt, + const edm::EventSetup& es, + const edm::EDGetTokenT& hitToken, + const std::string& clusterCollection, + const std::vector& regions, + const IslandClusterAlgo::EcalPart& ecalPart) const { // get the hit collection from the event: - const EcalRecHitCollection *hitCollection_p = getCollection(evt, hitToken); + const EcalRecHitCollection* hitCollection_p = getCollection(evt, hitToken); // get the geometry and topology from the event setup: edm::ESHandle geoHandle; es.get().get(geoHandle); - const CaloSubdetectorGeometry *geometry_p; + const CaloSubdetectorGeometry* geometry_p; std::unique_ptr topology_p; - if (ecalPart == IslandClusterAlgo::barrel) - { - geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); - topology_p = std::make_unique(*geoHandle); - } - else - { - geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); - topology_p = std::make_unique(*geoHandle); - } + if (ecalPart == IslandClusterAlgo::barrel) { + geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + topology_p = std::make_unique(*geoHandle); + } else { + geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); + topology_p = std::make_unique(*geoHandle); + } - const CaloSubdetectorGeometry *geometryES_p; + const CaloSubdetectorGeometry* geometryES_p; geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower); // Run the clusterization algorithm: reco::BasicClusterCollection clusters; - clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p.get(), geometryES_p, ecalPart, true, regions); + clusters = + island_p->makeClusters(hitCollection_p, geometry_p, topology_p.get(), geometryES_p, ecalPart, true, regions); // create an unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event: auto clusters_p = std::make_unique(); clusters_p->assign(clusters.begin(), clusters.end()); edm::OrphanHandle bccHandle; - if (ecalPart == IslandClusterAlgo::barrel) + if (ecalPart == IslandClusterAlgo::barrel) bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_); else bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_); diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTMulti5x5ClusterProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTMulti5x5ClusterProducer.cc index 051147c6aee5a..ea3041859478e 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTMulti5x5ClusterProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTMulti5x5ClusterProducer.cc @@ -35,62 +35,57 @@ #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTMulti5x5ClusterProducer.h" EgammaHLTMulti5x5ClusterProducer::EgammaHLTMulti5x5ClusterProducer(const edm::ParameterSet& ps) { - - doBarrel_ = ps.getParameter("doBarrel"); - doEndcaps_ = ps.getParameter("doEndcaps"); + doBarrel_ = ps.getParameter("doBarrel"); + doEndcaps_ = ps.getParameter("doEndcaps"); doIsolated_ = ps.getParameter("doIsolated"); - + // Parameters to identify the hit collections - barrelHitCollection_ = ps.getParameter("barrelHitProducer"); - endcapHitCollection_ = ps.getParameter("endcapHitProducer"); - barrelHitToken_ = consumes( barrelHitCollection_); - endcapHitToken_ = consumes( endcapHitCollection_); + barrelHitCollection_ = ps.getParameter("barrelHitProducer"); + endcapHitCollection_ = ps.getParameter("endcapHitProducer"); + barrelHitToken_ = consumes(barrelHitCollection_); + endcapHitToken_ = consumes(endcapHitCollection_); // The names of the produced cluster collections - barrelClusterCollection_ = ps.getParameter("barrelClusterCollection"); - endcapClusterCollection_ = ps.getParameter("endcapClusterCollection"); + barrelClusterCollection_ = ps.getParameter("barrelClusterCollection"); + endcapClusterCollection_ = ps.getParameter("endcapClusterCollection"); // Multi5x5 algorithm parameters double barrelSeedThreshold = ps.getParameter("Multi5x5BarrelSeedThr"); double endcapSeedThreshold = ps.getParameter("Multi5x5EndcapSeedThr"); // L1 matching parameters - l1TagIsolated_ = consumes(ps.getParameter< edm::InputTag > ("l1TagIsolated")); - l1TagNonIsolated_ = consumes(ps.getParameter< edm::InputTag > ("l1TagNonIsolated")); - l1LowerThr_ = ps.getParameter ("l1LowerThr"); - l1UpperThr_ = ps.getParameter ("l1UpperThr"); - l1LowerThrIgnoreIsolation_ = ps.getParameter ("l1LowerThrIgnoreIsolation"); + l1TagIsolated_ = consumes(ps.getParameter("l1TagIsolated")); + l1TagNonIsolated_ = consumes(ps.getParameter("l1TagNonIsolated")); + l1LowerThr_ = ps.getParameter("l1LowerThr"); + l1UpperThr_ = ps.getParameter("l1UpperThr"); + l1LowerThrIgnoreIsolation_ = ps.getParameter("l1LowerThrIgnoreIsolation"); - regionEtaMargin_ = ps.getParameter("regionEtaMargin"); - regionPhiMargin_ = ps.getParameter("regionPhiMargin"); + regionEtaMargin_ = ps.getParameter("regionEtaMargin"); + regionPhiMargin_ = ps.getParameter("regionPhiMargin"); // Parameters for the position calculation: - posCalculator_ = PositionCalc( ps.getParameter("posCalcParameters") ); + posCalculator_ = PositionCalc(ps.getParameter("posCalcParameters")); - const std::vector flagnames = - ps.getParameter >("RecHitFlagToBeExcluded"); + const std::vector flagnames = ps.getParameter >("RecHitFlagToBeExcluded"); // exclude recHit flags from seeding std::vector v_chstatus = StringToEnumValue(flagnames); - + // Produces a collection of barrel and a collection of endcap clusters - produces< reco::BasicClusterCollection >(endcapClusterCollection_); - produces< reco::BasicClusterCollection >(barrelClusterCollection_); + produces(endcapClusterCollection_); + produces(barrelClusterCollection_); Multi5x5_p = new Multi5x5ClusterAlgo(barrelSeedThreshold, endcapSeedThreshold, v_chstatus, posCalculator_); } -EgammaHLTMulti5x5ClusterProducer::~EgammaHLTMulti5x5ClusterProducer() { - delete Multi5x5_p; -} +EgammaHLTMulti5x5ClusterProducer::~EgammaHLTMulti5x5ClusterProducer() { delete Multi5x5_p; } void EgammaHLTMulti5x5ClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add(("doBarrel"), false); desc.add(("doEndcaps"), true); desc.add(("doIsolated"), true); - desc.add("VerbosityLevel" ,"ERROR"); + desc.add("VerbosityLevel", "ERROR"); edm::ParameterSetDescription posCalcPSET; posCalcPSET.add("T0_barl", 7.4); @@ -107,8 +102,8 @@ void EgammaHLTMulti5x5ClusterProducer::fillDescriptions(edm::ConfigurationDescri desc.add(("endcapClusterCollection"), "multi5x5EndcapBasicClusters"); desc.add(("Multi5x5BarrelSeedThr"), 0.5); desc.add(("Multi5x5EndcapSeedThr"), 0.5); - desc.add(("l1TagIsolated"), edm::InputTag("hltL1extraParticles","Isolated")); - desc.add(("l1TagNonIsolated"), edm::InputTag("hltL1extraParticles","NonIsolated")); + desc.add(("l1TagIsolated"), edm::InputTag("hltL1extraParticles", "Isolated")); + desc.add(("l1TagNonIsolated"), edm::InputTag("hltL1extraParticles", "NonIsolated")); desc.add(("l1LowerThr"), 5.0); desc.add(("l1UpperThr"), 9999.); desc.add(("l1LowerThrIgnoreIsolation"), 999.0); @@ -116,193 +111,191 @@ void EgammaHLTMulti5x5ClusterProducer::fillDescriptions(edm::ConfigurationDescri desc.add(("regionPhiMargin"), 0.4); desc.add >(("RecHitFlagToBeExcluded"), std::vector()); - descriptions.add(("hltEgammaHLTMulti5x5ClusterProducer"), desc); + descriptions.add(("hltEgammaHLTMulti5x5ClusterProducer"), desc); } void EgammaHLTMulti5x5ClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es) { - //Get the L1 EM Particle Collection - edm::Handle< l1extra::L1EmParticleCollection > emIsolColl ; - if(doIsolated_) + edm::Handle emIsolColl; + if (doIsolated_) evt.getByToken(l1TagIsolated_, emIsolColl); //Get the L1 EM Particle Collection - edm::Handle< l1extra::L1EmParticleCollection > emNonIsolColl ; + edm::Handle emNonIsolColl; evt.getByToken(l1TagNonIsolated_, emNonIsolColl); // Get the CaloGeometry - edm::ESHandle l1CaloGeom ; - es.get().get(l1CaloGeom) ; + edm::ESHandle l1CaloGeom; + es.get().get(l1CaloGeom); std::vector barrelRegions; std::vector endcapRegions; - if(doIsolated_) { - for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr ){ - + if (doIsolated_) { + for (l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end(); + ++emItr) { if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) { - - // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - - - int phiIndex = emItr->gctEmCand()->phiIndex() ; - // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - - //Attention isForward does not work - int isforw=0; - int isbarl=0; - if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1; - if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) || - ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1; - - //std::cout<<"Multi5x5 etaindex "<gctEmCand()->regionId().isForward()<<" isforwnew" <gctEmCand()->regionId().isForward()) { - if (isforw) { - if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479; - if ( etaLow>-1.479 && etaLow<1.479) etaLow=1.479; - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - endcapRegions.push_back(region); - } - if (isbarl) { - if (etaHigh>1.479) etaHigh=1.479; - if (etaLow<-1.479) etaLow=-1.479; - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - barrelRegions.push_back(region); - } - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - + // Access the GCT hardware object corresponding to the L1Extra EM object. + int etaIndex = emItr->gctEmCand()->etaIndex(); + + int phiIndex = emItr->gctEmCand()->phiIndex(); + // Use the L1CaloGeometry to find the eta, phi bin boundaries. + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + + //Attention isForward does not work + int isforw = 0; + int isbarl = 0; + if ((float)(etaHigh) > 1.479 || (float)(etaLow) < -1.479) + isforw = 1; + if (((float)(etaLow) > -1.479 && (float)(etaLow) < 1.479) || + ((float)(etaHigh) > -1.479 && (float)(etaHigh) < 1.479)) + isbarl = 1; + + //std::cout<<"Multi5x5 etaindex "<gctEmCand()->regionId().isForward()<<" isforwnew" <gctEmCand()->regionId().isForward()) { + if (isforw) { + if (etaHigh > -1.479 && etaHigh < 1.479) + etaHigh = -1.479; + if (etaLow > -1.479 && etaLow < 1.479) + etaLow = 1.479; + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); + endcapRegions.push_back(region); + } + if (isbarl) { + if (etaHigh > 1.479) + etaHigh = 1.479; + if (etaLow < -1.479) + etaLow = -1.479; + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); + barrelRegions.push_back(region); + } + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); } } } - - if(!doIsolated_||l1LowerThrIgnoreIsolation_<64) { - for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr ){ - - if(doIsolated_&&emItr->et()begin(); emItr != emNonIsolColl->end(); + ++emItr) { + if (doIsolated_ && emItr->et() < l1LowerThrIgnoreIsolation_) + continue; if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) { - - // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr->gctEmCand()->etaIndex() ; - - - int phiIndex = emItr->gctEmCand()->phiIndex() ; - // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ; - double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ; - double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ; - - - int isforw=0; - int isbarl=0; - if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1; - if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) || - ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1; - - //std::cout<<"Multi5x5 etaindex "<gctEmCand()->regionId().isForward()<<" isforwnew" <gctEmCand()->regionId().isForward()) { - if (isforw) { - if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479; - if ( etaLow>-1.479 && etaLow<1.479) etaLow=1.479; - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - endcapRegions.push_back(region); - } - if (isbarl) { - if (etaHigh>1.479) etaHigh=1.479; - if (etaLow<-1.479) etaLow=-1.479; - RectangularEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh); - barrelRegions.push_back(region); - } - + // Access the GCT hardware object corresponding to the L1Extra EM object. + int etaIndex = emItr->gctEmCand()->etaIndex(); + + int phiIndex = emItr->gctEmCand()->phiIndex(); + // Use the L1CaloGeometry to find the eta, phi bin boundaries. + double etaLow = l1CaloGeom->etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom->etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom->emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom->emJetPhiBinHighEdge(phiIndex); + + int isforw = 0; + int isbarl = 0; + if ((float)(etaHigh) > 1.479 || (float)(etaLow) < -1.479) + isforw = 1; + if (((float)(etaLow) > -1.479 && (float)(etaLow) < 1.479) || + ((float)(etaHigh) > -1.479 && (float)(etaHigh) < 1.479)) + isbarl = 1; + + //std::cout<<"Multi5x5 etaindex "<gctEmCand()->regionId().isForward()<<" isforwnew" <gctEmCand()->regionId().isForward()) { + if (isforw) { + if (etaHigh > -1.479 && etaHigh < 1.479) + etaHigh = -1.479; + if (etaLow > -1.479 && etaLow < 1.479) + etaLow = 1.479; + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); + endcapRegions.push_back(region); + } + if (isbarl) { + if (etaHigh > 1.479) + etaHigh = 1.479; + if (etaLow < -1.479) + etaLow = -1.479; + RectangularEtaPhiRegion region(etaLow, etaHigh, phiLow, phiHigh); + barrelRegions.push_back(region); + } } } } - if (doEndcaps_) { - clusterizeECALPart(evt, es, endcapHitToken_, endcapClusterCollection_, endcapRegions, reco::CaloID::DET_ECAL_ENDCAP); + clusterizeECALPart( + evt, es, endcapHitToken_, endcapClusterCollection_, endcapRegions, reco::CaloID::DET_ECAL_ENDCAP); } if (doBarrel_) { - clusterizeECALPart(evt, es, barrelHitToken_, barrelClusterCollection_, barrelRegions, reco::CaloID::DET_ECAL_BARREL); + clusterizeECALPart( + evt, es, barrelHitToken_, barrelClusterCollection_, barrelRegions, reco::CaloID::DET_ECAL_BARREL); } } - -const EcalRecHitCollection * EgammaHLTMulti5x5ClusterProducer::getCollection(edm::Event& evt, - const edm::EDGetTokenT& hitToken) const { - +const EcalRecHitCollection* EgammaHLTMulti5x5ClusterProducer::getCollection( + edm::Event& evt, const edm::EDGetTokenT& hitToken) const { edm::Handle rhcHandle; evt.getByToken(hitToken, rhcHandle); - - if (!(rhcHandle.isValid())) - { - std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl; - edm::LogError("EgammaHLTMulti5x5ClusterProducerError") << "Error! can't get the product "; - return nullptr; - } + + if (!(rhcHandle.isValid())) { + std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl; + edm::LogError("EgammaHLTMulti5x5ClusterProducerError") << "Error! can't get the product "; + return nullptr; + } return rhcHandle.product(); } - -void EgammaHLTMulti5x5ClusterProducer::clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, - const edm::EDGetTokenT& hitToken, - const std::string& clusterCollection, - const std::vector& regions, - const reco::CaloID::Detectors detector) const { - +void EgammaHLTMulti5x5ClusterProducer::clusterizeECALPart(edm::Event& evt, + const edm::EventSetup& es, + const edm::EDGetTokenT& hitToken, + const std::string& clusterCollection, + const std::vector& regions, + const reco::CaloID::Detectors detector) const { // get the hit collection from the event: - const EcalRecHitCollection *hitCollection_p = getCollection(evt, hitToken); + const EcalRecHitCollection* hitCollection_p = getCollection(evt, hitToken); // get the geometry and topology from the event setup: edm::ESHandle geoHandle; es.get().get(geoHandle); - const CaloSubdetectorGeometry *geometry_p; - std::unique_ptrtopology_p; - - if (detector == reco::CaloID::DET_ECAL_BARREL) - { - geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); - topology_p = std::make_unique(*geoHandle); - } - else - { - geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); - topology_p = std::make_unique(*geoHandle); - } + const CaloSubdetectorGeometry* geometry_p; + std::unique_ptr topology_p; + if (detector == reco::CaloID::DET_ECAL_BARREL) { + geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + topology_p = std::make_unique(*geoHandle); + } else { + geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); + topology_p = std::make_unique(*geoHandle); + } - const CaloSubdetectorGeometry *geometryES_p; + const CaloSubdetectorGeometry* geometryES_p; geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower); // Run the clusterization algorithm: reco::BasicClusterCollection clusters; - clusters = Multi5x5_p->makeClusters(hitCollection_p, geometry_p, topology_p.get(), geometryES_p, detector, true, regions); + clusters = + Multi5x5_p->makeClusters(hitCollection_p, geometry_p, topology_p.get(), geometryES_p, detector, true, regions); // create an unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event: auto clusters_p = std::make_unique(); clusters_p->assign(clusters.begin(), clusters.end()); edm::OrphanHandle bccHandle; - if (detector == reco::CaloID::DET_ECAL_BARREL) + if (detector == reco::CaloID::DET_ECAL_BARREL) bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_); else bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_); diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTNxNClusterProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTNxNClusterProducer.cc index bb2fd42ba1688..c5de3b146b0c3 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTNxNClusterProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTNxNClusterProducer.cc @@ -24,41 +24,37 @@ #include -EgammaHLTNxNClusterProducer::EgammaHLTNxNClusterProducer(const edm::ParameterSet& ps): - doBarrel_ (ps.getParameter("doBarrel")), - doEndcaps_ (ps.getParameter("doEndcaps")), - barrelHitProducer_ (consumes(ps.getParameter< edm::InputTag > ("barrelHitProducer"))), - endcapHitProducer_ (consumes(ps.getParameter< edm::InputTag > ("endcapHitProducer"))), - clusEtaSize_ (ps.getParameter ("clusEtaSize")), - clusPhiSize_ (ps.getParameter ("clusPhiSize")), - barrelClusterCollection_(ps.getParameter("barrelClusterCollection")), - endcapClusterCollection_(ps.getParameter("endcapClusterCollection")), - clusSeedThr_ (ps.getParameter ("clusSeedThr")), - clusSeedThrEndCap_ (ps.getParameter ("clusSeedThrEndCap")), - useRecoFlag_ (ps.getParameter("useRecoFlag")), - flagLevelRecHitsToUse_ (ps.getParameter("flagLevelRecHitsToUse")), - useDBStatus_ (ps.getParameter("useDBStatus")), - statusLevelRecHitsToUse_(ps.getParameter("statusLevelRecHitsToUse")), - maxNumberofSeeds_ (ps.getParameter ("maxNumberofSeeds")), - maxNumberofClusters_ (ps.getParameter ("maxNumberofClusters")), - debug_ (ps.getParameter ("debugLevel")), - posCalculator_ (PositionCalc( ps.getParameter("posCalcParameters"))) { - - produces< reco::BasicClusterCollection >(barrelClusterCollection_); - produces< reco::BasicClusterCollection >(endcapClusterCollection_); +EgammaHLTNxNClusterProducer::EgammaHLTNxNClusterProducer(const edm::ParameterSet &ps) + : doBarrel_(ps.getParameter("doBarrel")), + doEndcaps_(ps.getParameter("doEndcaps")), + barrelHitProducer_(consumes(ps.getParameter("barrelHitProducer"))), + endcapHitProducer_(consumes(ps.getParameter("endcapHitProducer"))), + clusEtaSize_(ps.getParameter("clusEtaSize")), + clusPhiSize_(ps.getParameter("clusPhiSize")), + barrelClusterCollection_(ps.getParameter("barrelClusterCollection")), + endcapClusterCollection_(ps.getParameter("endcapClusterCollection")), + clusSeedThr_(ps.getParameter("clusSeedThr")), + clusSeedThrEndCap_(ps.getParameter("clusSeedThrEndCap")), + useRecoFlag_(ps.getParameter("useRecoFlag")), + flagLevelRecHitsToUse_(ps.getParameter("flagLevelRecHitsToUse")), + useDBStatus_(ps.getParameter("useDBStatus")), + statusLevelRecHitsToUse_(ps.getParameter("statusLevelRecHitsToUse")), + maxNumberofSeeds_(ps.getParameter("maxNumberofSeeds")), + maxNumberofClusters_(ps.getParameter("maxNumberofClusters")), + debug_(ps.getParameter("debugLevel")), + posCalculator_(PositionCalc(ps.getParameter("posCalcParameters"))) { + produces(barrelClusterCollection_); + produces(endcapClusterCollection_); } +EgammaHLTNxNClusterProducer::~EgammaHLTNxNClusterProducer() {} -EgammaHLTNxNClusterProducer::~EgammaHLTNxNClusterProducer() -{} - -void EgammaHLTNxNClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - +void EgammaHLTNxNClusterProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; desc.add(("doBarrel"), true); desc.add(("doEndcaps"), true); - desc.add(("barrelHitProducer"), edm::InputTag("hltEcalRegionalPi0EtaRecHit","EcalRecHitsEB")); - desc.add(("endcapHitProducer"), edm::InputTag("hltEcalRegionalPi0EtaRecHit","EcalRecHitsEE")); + desc.add(("barrelHitProducer"), edm::InputTag("hltEcalRegionalPi0EtaRecHit", "EcalRecHitsEB")); + desc.add(("endcapHitProducer"), edm::InputTag("hltEcalRegionalPi0EtaRecHit", "EcalRecHitsEE")); desc.add(("clusEtaSize"), 3); desc.add(("clusPhiSize"), 3); desc.add(("barrelClusterCollection"), "Simple3x3ClustersBarrel"); @@ -66,7 +62,7 @@ void EgammaHLTNxNClusterProducer::fillDescriptions(edm::ConfigurationDescription desc.add(("clusSeedThr"), 0.5); desc.add(("clusSeedThrEndCap"), 1.0); desc.add(("useRecoFlag"), false); - desc.add(("flagLevelRecHitsToUse"), 1); + desc.add(("flagLevelRecHitsToUse"), 1); desc.add(("useDBStatus"), true); desc.add(("statusLevelRecHitsToUse"), 1); @@ -78,189 +74,184 @@ void EgammaHLTNxNClusterProducer::fillDescriptions(edm::ConfigurationDescription posCalcPSET.add("X0", 0.89); posCalcPSET.add("LogWeighted", true); desc.add("posCalcParameters", posCalcPSET); - + desc.add(("maxNumberofSeeds"), 1000); desc.add(("maxNumberofClusters"), 200); desc.add(("debugLevel"), 0); - descriptions.add(("hltEgammaHLTNxNClusterProducer"), desc); + descriptions.add(("hltEgammaHLTNxNClusterProducer"), desc); } -void EgammaHLTNxNClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es) { - - if(doBarrel_) { +void EgammaHLTNxNClusterProducer::produce(edm::Event &evt, const edm::EventSetup &es) { + if (doBarrel_) { edm::Handle barrelRecHitsHandle; evt.getByToken(barrelHitProducer_, barrelRecHitsHandle); if (!barrelRecHitsHandle.isValid()) { LogDebug("") << "EgammaHLTNxNClusterProducer Error! can't get product eb hit!" << std::endl; } - + const EcalRecHitCollection *hits_eb = barrelRecHitsHandle.product(); - if( debug_>=2 ) - LogDebug("")<<"EgammaHLTNxNClusterProducer nEBrechits: "<< evt.id().run()<<" event "<size()<= 2) + LogDebug("") << "EgammaHLTNxNClusterProducer nEBrechits: " << evt.id().run() << " event " << evt.id().event() + << " " << hits_eb->size() << std::endl; + + makeNxNClusters(evt, es, hits_eb, reco::CaloID::DET_ECAL_BARREL); } - - - if(doEndcaps_) { + + if (doEndcaps_) { edm::Handle endcapRecHitsHandle; evt.getByToken(endcapHitProducer_, endcapRecHitsHandle); if (!endcapRecHitsHandle.isValid()) { LogDebug("") << "EgammaHLTNxNClusterProducer Error! can't get product ee hit!" << std::endl; } - + const EcalRecHitCollection *hits_ee = endcapRecHitsHandle.product(); - if( debug_>=2 ) - LogDebug("")<<"EgammaHLTNxNClusterProducer nEErechits: "<< evt.id().run()<<" event "<size()<= 2) + LogDebug("") << "EgammaHLTNxNClusterProducer nEErechits: " << evt.id().run() << " event " << evt.id().event() + << " " << hits_ee->size() << std::endl; + makeNxNClusters(evt, es, hits_ee, reco::CaloID::DET_ECAL_ENDCAP); } } - - -bool EgammaHLTNxNClusterProducer::checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus,const EcalRecHit &rh){ - - if(useRecoFlag_ ){ ///from recoFlag() +bool EgammaHLTNxNClusterProducer::checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus, + const EcalRecHit &rh) { + if (useRecoFlag_) { ///from recoFlag() int flag = rh.recoFlag(); - if( flagLevelRecHitsToUse_ ==0){ ///good - if( flag != 0) return false; - } - else if( flagLevelRecHitsToUse_ ==1){ ///good || PoorCalib - if( flag !=0 && flag != 4 ) return false; - } - else if( flagLevelRecHitsToUse_ ==2){ ///good || PoorCalib || LeadingEdgeRecovered || kNeighboursRecovered, - if( flag !=0 && flag != 4 && flag != 6 && flag != 7) return false; + if (flagLevelRecHitsToUse_ == 0) { ///good + if (flag != 0) + return false; + } else if (flagLevelRecHitsToUse_ == 1) { ///good || PoorCalib + if (flag != 0 && flag != 4) + return false; + } else if (flagLevelRecHitsToUse_ == 2) { ///good || PoorCalib || LeadingEdgeRecovered || kNeighboursRecovered, + if (flag != 0 && flag != 4 && flag != 6 && flag != 7) + return false; } } - if ( useDBStatus_){ //// from DB - int status = int(channelStatus[rh.id().rawId()].getStatusCode()); - if ( status > statusLevelRecHitsToUse_ ) return false; + if (useDBStatus_) { //// from DB + int status = int(channelStatus[rh.id().rawId()].getStatusCode()); + if (status > statusLevelRecHitsToUse_) + return false; } - - return true; -} - - + return true; +} -void EgammaHLTNxNClusterProducer::makeNxNClusters(edm::Event &evt, const edm::EventSetup &es, - const EcalRecHitCollection *hits, const reco::CaloID::Detectors detector) -{ - - +void EgammaHLTNxNClusterProducer::makeNxNClusters(edm::Event &evt, + const edm::EventSetup &es, + const EcalRecHitCollection *hits, + const reco::CaloID::Detectors detector) { ///get status from DB edm::ESHandle csHandle; - if ( useDBStatus_ ) es.get().get(csHandle); - const EcalChannelStatus &channelStatus = *csHandle; - - + if (useDBStatus_) + es.get().get(csHandle); + const EcalChannelStatus &channelStatus = *csHandle; + std::vector seeds; - - double clusterSeedThreshold ; - if (detector == reco::CaloID::DET_ECAL_BARREL){ + + double clusterSeedThreshold; + if (detector == reco::CaloID::DET_ECAL_BARREL) { clusterSeedThreshold = clusSeedThr_; - }else{ - clusterSeedThreshold = clusSeedThrEndCap_; + } else { + clusterSeedThreshold = clusSeedThrEndCap_; } - - for(EcalRecHitCollection::const_iterator itt = hits->begin(); itt != hits->end(); itt++){ + for (EcalRecHitCollection::const_iterator itt = hits->begin(); itt != hits->end(); itt++) { double energy = itt->energy(); - if( ! checkStatusOfEcalRecHit(channelStatus, *itt) ) continue; - if (energy > clusterSeedThreshold ) seeds.push_back(*itt); - - if( int(seeds.size()) > maxNumberofSeeds_){ //too many seeds, like beam splash events - seeds.clear(); //// empty seeds vector, don't do clustering anymore - break; + if (!checkStatusOfEcalRecHit(channelStatus, *itt)) + continue; + if (energy > clusterSeedThreshold) + seeds.push_back(*itt); + + if (int(seeds.size()) > maxNumberofSeeds_) { //too many seeds, like beam splash events + seeds.clear(); //// empty seeds vector, don't do clustering anymore + break; } } - + // get the geometry and topology from the event setup: edm::ESHandle geoHandle; es.get().get(geoHandle); - + const CaloSubdetectorGeometry *geometry_p; std::unique_ptr topology_p; if (detector == reco::CaloID::DET_ECAL_BARREL) { geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); topology_p = std::make_unique(*geoHandle); - }else { + } else { geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); topology_p = std::make_unique(*geoHandle); } - + const CaloSubdetectorGeometry *geometryES_p; geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower); - - std::vector clusters; std::vector usedXtals; - + // sort seed according to Energy - sort(seeds.begin(), seeds.end(), [](auto const& x, auto const& y){ - return (x.energy() > y.energy()); - }); - - - - for (std::vector::iterator itseed=seeds.begin(); itseed!=seeds.end(); itseed++) { + sort(seeds.begin(), seeds.end(), [](auto const &x, auto const &y) { return (x.energy() > y.energy()); }); + + for (std::vector::iterator itseed = seeds.begin(); itseed != seeds.end(); itseed++) { DetId seed_id = itseed->id(); - - std::vector::iterator itdet = find(usedXtals.begin(),usedXtals.end(),seed_id); - if(itdet != usedXtals.end()) continue; - - std::vector clus_v = topology_p->getWindow(seed_id,clusEtaSize_,clusPhiSize_); + + std::vector::iterator itdet = find(usedXtals.begin(), usedXtals.end(), seed_id); + if (itdet != usedXtals.end()) + continue; + + std::vector clus_v = topology_p->getWindow(seed_id, clusEtaSize_, clusPhiSize_); std::vector > clus_used; - - float clus_energy = 0; - - for (std::vector::iterator det=clus_v.begin(); det!=clus_v.end(); det++) { - DetId detid = *det; - - //not yet used - std::vector::iterator itdet = find(usedXtals.begin(),usedXtals.end(),detid); - if(itdet != usedXtals.end()) continue; - //inside the collection - EcalRecHitCollection::const_iterator hit = hits->find(detid); - if( hit == hits->end()) continue; - - if( ! checkStatusOfEcalRecHit(channelStatus, *hit) ) continue; - - usedXtals.push_back(detid); - clus_used.push_back(std::pair(detid, 1.) ); - clus_energy += hit->energy(); - - } //// end of making one nxn simple cluster - - if( clus_energy <= 0 ) continue; - - math::XYZPoint clus_pos = posCalculator_.Calculate_Location(clus_used,hits,geometry_p,geometryES_p); - - if (debug_>=2 ) LogDebug("")<<"nxn_cluster in run "<< evt.id().run()<<" event "< maxNumberofClusters_){ ///if too much clusters made, then return 0 also - clusters.clear(); - break; + + float clus_energy = 0; + + for (std::vector::iterator det = clus_v.begin(); det != clus_v.end(); det++) { + DetId detid = *det; + + //not yet used + std::vector::iterator itdet = find(usedXtals.begin(), usedXtals.end(), detid); + if (itdet != usedXtals.end()) + continue; + //inside the collection + EcalRecHitCollection::const_iterator hit = hits->find(detid); + if (hit == hits->end()) + continue; + + if (!checkStatusOfEcalRecHit(channelStatus, *hit)) + continue; + + usedXtals.push_back(detid); + clus_used.push_back(std::pair(detid, 1.)); + clus_energy += hit->energy(); + + } //// end of making one nxn simple cluster + + if (clus_energy <= 0) + continue; + + math::XYZPoint clus_pos = posCalculator_.Calculate_Location(clus_used, hits, geometry_p, geometryES_p); + + if (debug_ >= 2) + LogDebug("") << "nxn_cluster in run " << evt.id().run() << " event " << evt.id().event() + << " energy: " << clus_energy << " eta: " << clus_pos.Eta() << " phi: " << clus_pos.Phi() + << " nRecHits: " << clus_used.size() << std::endl; + + clusters.push_back(reco::BasicCluster( + clus_energy, clus_pos, reco::CaloID(detector), clus_used, reco::CaloCluster::island, seed_id)); + if (int(clusters.size()) > maxNumberofClusters_) { ///if too much clusters made, then return 0 also + clusters.clear(); + break; } - } - - + //Create empty output collections auto clusters_p = std::make_unique(); clusters_p->assign(clusters.begin(), clusters.end()); - if (detector == reco::CaloID::DET_ECAL_BARREL){ - if(debug_>=1) LogDebug("")<<"nxnclusterProducer: "<size() <<" made in barrel"<= 1) + LogDebug("") << "nxnclusterProducer: " << clusters_p->size() << " made in barrel" << std::endl; evt.put(std::move(clusters_p), barrelClusterCollection_); - } - else { - if(debug_>=1) LogDebug("")<<"nxnclusterProducer: "<size() <<" made in endcap"<= 1) + LogDebug("") << "nxnclusterProducer: " << clusters_p->size() << " made in endcap" << std::endl; evt.put(std::move(clusters_p), endcapClusterCollection_); } - } - - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFChargedIsolationProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFChargedIsolationProducer.cc index 3ede7fd78fcaf..5ad9d8d293575 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFChargedIsolationProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFChargedIsolationProducer.cc @@ -17,25 +17,26 @@ #include -EgammaHLTPFChargedIsolationProducer::EgammaHLTPFChargedIsolationProducer(const edm::ParameterSet& config): - pfCandidateProducer_(consumes(config.getParameter("pfCandidatesProducer"))), - beamSpotProducer_ (consumes(config.getParameter("beamSpotProducer"))), - useGsfTrack_ (config.getParameter("useGsfTrack")), - useSCRefs_ (config.getParameter("useSCRefs")), - drMax_ (config.getParameter("drMax")), - drVetoBarrel_ (config.getParameter("drVetoBarrel")), - drVetoEndcap_ (config.getParameter("drVetoEndcap")), - ptMin_ (config.getParameter("ptMin")), - dzMax_ (config.getParameter("dzMax")), - dxyMax_ (config.getParameter("dxyMax")), - pfToUse_ (config.getParameter("pfCandidateType")) { - - if(useSCRefs_) { - recoEcalCandidateProducer_ = consumes(config.getParameter("recoEcalCandidateProducer")); - produces < reco::RecoEcalCandidateIsolationMap >(); +EgammaHLTPFChargedIsolationProducer::EgammaHLTPFChargedIsolationProducer(const edm::ParameterSet& config) + : pfCandidateProducer_( + consumes(config.getParameter("pfCandidatesProducer"))), + beamSpotProducer_(consumes(config.getParameter("beamSpotProducer"))), + useGsfTrack_(config.getParameter("useGsfTrack")), + useSCRefs_(config.getParameter("useSCRefs")), + drMax_(config.getParameter("drMax")), + drVetoBarrel_(config.getParameter("drVetoBarrel")), + drVetoEndcap_(config.getParameter("drVetoEndcap")), + ptMin_(config.getParameter("ptMin")), + dzMax_(config.getParameter("dzMax")), + dxyMax_(config.getParameter("dxyMax")), + pfToUse_(config.getParameter("pfCandidateType")) { + if (useSCRefs_) { + recoEcalCandidateProducer_ = + consumes(config.getParameter("recoEcalCandidateProducer")); + produces(); } else { - electronProducer_ = consumes(config.getParameter("electronProducer")); - produces < reco::ElectronIsolationMap >(); + electronProducer_ = consumes(config.getParameter("electronProducer")); + produces(); } } @@ -43,7 +44,7 @@ void EgammaHLTPFChargedIsolationProducer::fillDescriptions(edm::ConfigurationDes edm::ParameterSetDescription desc; desc.add("electronProducer", edm::InputTag("hltEle27WP80PixelMatchElectronsL1SeededPF")); desc.add("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidatePF")); - desc.add("pfCandidatesProducer", edm::InputTag("hltParticleFlowReg")); + desc.add("pfCandidatesProducer", edm::InputTag("hltParticleFlowReg")); desc.add("beamSpotProducer", edm::InputTag("hltOnlineBeamSpot")); desc.add("useGsfTrack", false); desc.add("useSCRefs", false); @@ -57,8 +58,9 @@ void EgammaHLTPFChargedIsolationProducer::fillDescriptions(edm::ConfigurationDes descriptions.add(("hltEgammaHLTPFChargedIsolationProducer"), desc); } -void EgammaHLTPFChargedIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTPFChargedIsolationProducer::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { edm::Handle electronHandle; edm::Handle recoEcalCandHandle; edm::Handle pfHandle; @@ -67,99 +69,104 @@ void EgammaHLTPFChargedIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent.getByToken(pfCandidateProducer_, pfHandle); const reco::PFCandidateCollection* forIsolation = pfHandle.product(); - if(useSCRefs_) { - + if (useSCRefs_) { iEvent.getByToken(recoEcalCandidateProducer_, recoEcalCandHandle); reco::RecoEcalCandidateIsolationMap recoEcalCandMap(recoEcalCandHandle); iEvent.getByToken(beamSpotProducer_, recoBeamSpotHandle); - const reco::BeamSpot::Point& beamSpotPosition = recoBeamSpotHandle->position(); + const reco::BeamSpot::Point& beamSpotPosition = recoBeamSpotHandle->position(); float dRveto = -1; - for(unsigned int iReco=0; iRecosize(); iReco++) { + for (unsigned int iReco = 0; iReco < recoEcalCandHandle->size(); iReco++) { reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, iReco); - - if (fabs(candRef->eta())<1.479) - dRveto = drVetoBarrel_; + + if (fabs(candRef->eta()) < 1.479) + dRveto = drVetoBarrel_; else - dRveto = drVetoEndcap_; - + dRveto = drVetoEndcap_; + // Shift the RecoEcalCandidate direction vector according to the vertex math::XYZVector candDirectionWrtVtx(candRef->superCluster()->x() - beamSpotPosition.x(), - candRef->superCluster()->y() - beamSpotPosition.y(), - candRef->superCluster()->z() - beamSpotPosition.z()); - + candRef->superCluster()->y() - beamSpotPosition.y(), + candRef->superCluster()->z() - beamSpotPosition.z()); + float sum = 0; // Loop over the PFCandidates - for(unsigned i=0; isize(); i++) { - const reco::PFCandidate& pfc = (*forIsolation)[i]; - - //require that the PFCandidate is a charged hadron - if (pfc.particleId() == pfToUse_) { - - if(pfc.pt() < ptMin_) continue; - - float dz = fabs(pfc.trackRef()->dz(beamSpotPosition)); - if(dz > dzMax_) continue; - - float dxy = fabs(pfc.trackRef()->dxy(beamSpotPosition)); - if(fabs(dxy) > dxyMax_) continue; - - float dR = deltaR(candDirectionWrtVtx.Eta(), candDirectionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); - if(dR > drMax_ || dR < dRveto) continue; - - sum += pfc.pt(); - } + for (unsigned i = 0; i < forIsolation->size(); i++) { + const reco::PFCandidate& pfc = (*forIsolation)[i]; + + //require that the PFCandidate is a charged hadron + if (pfc.particleId() == pfToUse_) { + if (pfc.pt() < ptMin_) + continue; + + float dz = fabs(pfc.trackRef()->dz(beamSpotPosition)); + if (dz > dzMax_) + continue; + + float dxy = fabs(pfc.trackRef()->dxy(beamSpotPosition)); + if (fabs(dxy) > dxyMax_) + continue; + + float dR = + deltaR(candDirectionWrtVtx.Eta(), candDirectionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); + if (dR > drMax_ || dR < dRveto) + continue; + + sum += pfc.pt(); + } } - + recoEcalCandMap.insert(candRef, sum); } iEvent.put(std::make_unique(recoEcalCandMap)); } else { - - iEvent.getByToken(electronProducer_,electronHandle); - reco::ElectronIsolationMap eleMap(electronHandle); + iEvent.getByToken(electronProducer_, electronHandle); + reco::ElectronIsolationMap eleMap(electronHandle); float dRveto = -1; - for(unsigned int iEl=0; iElsize(); iEl++) { + for (unsigned int iEl = 0; iEl < electronHandle->size(); iEl++) { reco::ElectronRef eleRef(electronHandle, iEl); //const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track(); - if (fabs(eleRef->eta())<1.479) - dRveto = drVetoBarrel_; + if (fabs(eleRef->eta()) < 1.479) + dRveto = drVetoBarrel_; else - dRveto = drVetoEndcap_; - + dRveto = drVetoEndcap_; + float sum = 0; // Loop over the PFCandidates - for(unsigned i=0; isize(); i++) { - const reco::PFCandidate& pfc = (*forIsolation)[i]; - - //require that the PFCandidate is a charged hadron - if (pfc.particleId() == pfToUse_) { - - if(pfc.pt() < ptMin_) continue; - - float dz = fabs(pfc.trackRef()->dz(eleRef->vertex())); - if(dz > dzMax_) continue; - - float dxy = fabs(pfc.trackRef()->dxy(eleRef->vertex())); - if(fabs(dxy) > dxyMax_) continue; - - float dR = deltaR(eleRef->eta(), eleRef->phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); - if(dR > drMax_ || dR < dRveto) continue; - - sum += pfc.pt(); - } + for (unsigned i = 0; i < forIsolation->size(); i++) { + const reco::PFCandidate& pfc = (*forIsolation)[i]; + + //require that the PFCandidate is a charged hadron + if (pfc.particleId() == pfToUse_) { + if (pfc.pt() < ptMin_) + continue; + + float dz = fabs(pfc.trackRef()->dz(eleRef->vertex())); + if (dz > dzMax_) + continue; + + float dxy = fabs(pfc.trackRef()->dxy(eleRef->vertex())); + if (fabs(dxy) > dxyMax_) + continue; + + float dR = deltaR(eleRef->eta(), eleRef->phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); + if (dR > drMax_ || dR < dRveto) + continue; + + sum += pfc.pt(); + } } eleMap.insert(eleRef, sum); - } + } iEvent.put(std::make_unique(eleMap)); } } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFNeutralIsolationProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFNeutralIsolationProducer.cc index 19e61c671f0ff..7a4185f068427 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFNeutralIsolationProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFNeutralIsolationProducer.cc @@ -24,35 +24,36 @@ #include EgammaHLTPFNeutralIsolationProducer::EgammaHLTPFNeutralIsolationProducer(const edm::ParameterSet& config) { - - pfCandidateProducer_ = consumes(config.getParameter("pfCandidatesProducer")); + pfCandidateProducer_ = + consumes(config.getParameter("pfCandidatesProducer")); useSCRefs_ = config.getParameter("useSCRefs"); - drMax_ = config.getParameter("drMax"); - drVetoBarrel_ = config.getParameter("drVetoBarrel"); - drVetoEndcap_ = config.getParameter("drVetoEndcap"); + drMax_ = config.getParameter("drMax"); + drVetoBarrel_ = config.getParameter("drVetoBarrel"); + drVetoEndcap_ = config.getParameter("drVetoEndcap"); etaStripBarrel_ = config.getParameter("etaStripBarrel"); etaStripEndcap_ = config.getParameter("etaStripEndcap"); - energyBarrel_ = config.getParameter("energyBarrel"); - energyEndcap_ = config.getParameter("energyEndcap"); - pfToUse_ = config.getParameter("pfCandidateType"); + energyBarrel_ = config.getParameter("energyBarrel"); + energyEndcap_ = config.getParameter("energyEndcap"); + pfToUse_ = config.getParameter("pfCandidateType"); - doRhoCorrection_ = config.getParameter("doRhoCorrection"); + doRhoCorrection_ = config.getParameter("doRhoCorrection"); if (doRhoCorrection_) - rhoProducer_ = consumes(config.getParameter("rhoProducer")); - - rhoMax_ = config.getParameter("rhoMax"); - rhoScale_ = config.getParameter("rhoScale"); - effectiveAreaBarrel_ = config.getParameter("effectiveAreaBarrel"); - effectiveAreaEndcap_ = config.getParameter("effectiveAreaEndcap"); - - if(useSCRefs_) { - produces < reco::RecoEcalCandidateIsolationMap >(); - recoEcalCandidateProducer_ = consumes(config.getParameter("recoEcalCandidateProducer")); + rhoProducer_ = consumes(config.getParameter("rhoProducer")); + + rhoMax_ = config.getParameter("rhoMax"); + rhoScale_ = config.getParameter("rhoScale"); + effectiveAreaBarrel_ = config.getParameter("effectiveAreaBarrel"); + effectiveAreaEndcap_ = config.getParameter("effectiveAreaEndcap"); + + if (useSCRefs_) { + produces(); + recoEcalCandidateProducer_ = + consumes(config.getParameter("recoEcalCandidateProducer")); } else { - produces < reco::ElectronIsolationMap >(); - electronProducer_ = consumes(config.getParameter("electronProducer")); + produces(); + electronProducer_ = consumes(config.getParameter("electronProducer")); } } @@ -60,11 +61,11 @@ void EgammaHLTPFNeutralIsolationProducer::fillDescriptions(edm::ConfigurationDes edm::ParameterSetDescription desc; desc.add("electronProducer", edm::InputTag("hltEle27WP80PixelMatchElectronsL1SeededPF")); desc.add("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidatePF")); - desc.add("pfCandidatesProducer", edm::InputTag("hltParticleFlowReg")); + desc.add("pfCandidatesProducer", edm::InputTag("hltParticleFlowReg")); desc.add("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo")); desc.add("doRhoCorrection", false); - desc.add("rhoMax", 9.9999999E7); - desc.add("rhoScale", 1.0); + desc.add("rhoMax", 9.9999999E7); + desc.add("rhoScale", 1.0); desc.add("effectiveAreaBarrel", 0.101); desc.add("effectiveAreaEndcap", 0.046); desc.add("useSCRefs", false); @@ -79,19 +80,20 @@ void EgammaHLTPFNeutralIsolationProducer::fillDescriptions(edm::ConfigurationDes descriptions.add(("hltEgammaHLTPFNeutralIsolationProducer"), desc); } -void EgammaHLTPFNeutralIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTPFNeutralIsolationProducer::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { edm::Handle rhoHandle; double rho = 0.0; if (doRhoCorrection_) { iEvent.getByToken(rhoProducer_, rhoHandle); rho = *(rhoHandle.product()); } - + if (rho > rhoMax_) rho = rhoMax_; - - rho = rho*rhoScale_; + + rho = rho * rhoScale_; edm::Handle electronHandle; edm::Handle recoecalcandHandle; @@ -100,124 +102,125 @@ void EgammaHLTPFNeutralIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent.getByToken(pfCandidateProducer_, pfHandle); const reco::PFCandidateCollection* forIsolation = pfHandle.product(); - if(useSCRefs_) { - - iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); + if (useSCRefs_) { + iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); reco::RecoEcalCandidateIsolationMap recoEcalCandMap(recoecalcandHandle); float dRVeto = -1.; float etaStrip = -1; - + for (unsigned int iReco = 0; iReco < recoecalcandHandle->size(); iReco++) { reco::RecoEcalCandidateRef candRef(recoecalcandHandle, iReco); - + if (fabs(candRef->eta()) < 1.479) { - dRVeto = drVetoBarrel_; - etaStrip = etaStripBarrel_; + dRVeto = drVetoBarrel_; + etaStrip = etaStripBarrel_; } else { - dRVeto = drVetoEndcap_; - etaStrip = etaStripEndcap_; + dRVeto = drVetoEndcap_; + etaStrip = etaStripEndcap_; } - + float sum = 0; // Loop over the PFCandidates - for(unsigned i=0; isize(); i++) { - const reco::PFCandidate& pfc = (*forIsolation)[i]; - - //require that the PFCandidate is a neutral hadron - if (pfc.particleId() == pfToUse_) { - - if (fabs(candRef->eta()) < 1.479) { - if (fabs(pfc.pt()) < energyBarrel_) - continue; - } else { - if (fabs(pfc.energy()) < energyEndcap_) - continue; - } - - // Shift the RecoEcalCandidate direction vector according to the PF vertex - const math::XYZPoint& pfvtx = pfc.vertex(); - math::XYZVector candDirectionWrtVtx(candRef->superCluster()->x() - pfvtx.x(), - candRef->superCluster()->y() - pfvtx.y(), - candRef->superCluster()->z() - pfvtx.z()); - - float dEta = fabs(candDirectionWrtVtx.Eta() - pfc.momentum().Eta()); - if(dEta < etaStrip) continue; - - float dR = deltaR(candDirectionWrtVtx.Eta(), candDirectionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); - if(dR > drMax_ || dR < dRVeto) continue; - - sum += pfc.pt(); - } + for (unsigned i = 0; i < forIsolation->size(); i++) { + const reco::PFCandidate& pfc = (*forIsolation)[i]; + + //require that the PFCandidate is a neutral hadron + if (pfc.particleId() == pfToUse_) { + if (fabs(candRef->eta()) < 1.479) { + if (fabs(pfc.pt()) < energyBarrel_) + continue; + } else { + if (fabs(pfc.energy()) < energyEndcap_) + continue; + } + + // Shift the RecoEcalCandidate direction vector according to the PF vertex + const math::XYZPoint& pfvtx = pfc.vertex(); + math::XYZVector candDirectionWrtVtx(candRef->superCluster()->x() - pfvtx.x(), + candRef->superCluster()->y() - pfvtx.y(), + candRef->superCluster()->z() - pfvtx.z()); + + float dEta = fabs(candDirectionWrtVtx.Eta() - pfc.momentum().Eta()); + if (dEta < etaStrip) + continue; + + float dR = + deltaR(candDirectionWrtVtx.Eta(), candDirectionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); + if (dR > drMax_ || dR < dRVeto) + continue; + + sum += pfc.pt(); + } } - + if (doRhoCorrection_) { - if (fabs(candRef->eta()) < 1.479) - sum = sum - rho*effectiveAreaBarrel_; - else - sum = sum - rho*effectiveAreaEndcap_; + if (fabs(candRef->eta()) < 1.479) + sum = sum - rho * effectiveAreaBarrel_; + else + sum = sum - rho * effectiveAreaEndcap_; } - + recoEcalCandMap.insert(candRef, sum); } iEvent.put(std::make_unique(recoEcalCandMap)); - - } else { - iEvent.getByToken(electronProducer_,electronHandle); + } else { + iEvent.getByToken(electronProducer_, electronHandle); reco::ElectronIsolationMap eleMap(electronHandle); - + float dRVeto = -1.; float etaStrip = -1; - for(unsigned int iEl=0; iElsize(); iEl++) { + for (unsigned int iEl = 0; iEl < electronHandle->size(); iEl++) { reco::ElectronRef eleRef(electronHandle, iEl); - + if (fabs(eleRef->eta()) < 1.479) { - dRVeto = drVetoBarrel_; - etaStrip = etaStripBarrel_; + dRVeto = drVetoBarrel_; + etaStrip = etaStripBarrel_; } else { - dRVeto = drVetoEndcap_; - etaStrip = etaStripEndcap_; + dRVeto = drVetoEndcap_; + etaStrip = etaStripEndcap_; } - + float sum = 0; // Loop over the PFCandidates - for(unsigned i=0; isize(); i++) { - const reco::PFCandidate& pfc = (*forIsolation)[i]; - - //require that the PFCandidate is a neutral hadron - if (pfc.particleId() == pfToUse_) { - - if (fabs(eleRef->eta()) < 1.479) { - if (fabs(pfc.pt()) < energyBarrel_) - continue; - } else { - if (fabs(pfc.energy()) < energyEndcap_) - continue; - } - - float dEta = fabs(eleRef->eta() - pfc.momentum().Eta()); - if(dEta < etaStrip) continue; - - float dR = deltaR(eleRef->eta(), eleRef->phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); - if(dR > drMax_ || dR < dRVeto) continue; - - sum += pfc.pt(); - } + for (unsigned i = 0; i < forIsolation->size(); i++) { + const reco::PFCandidate& pfc = (*forIsolation)[i]; + + //require that the PFCandidate is a neutral hadron + if (pfc.particleId() == pfToUse_) { + if (fabs(eleRef->eta()) < 1.479) { + if (fabs(pfc.pt()) < energyBarrel_) + continue; + } else { + if (fabs(pfc.energy()) < energyEndcap_) + continue; + } + + float dEta = fabs(eleRef->eta() - pfc.momentum().Eta()); + if (dEta < etaStrip) + continue; + + float dR = deltaR(eleRef->eta(), eleRef->phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); + if (dR > drMax_ || dR < dRVeto) + continue; + + sum += pfc.pt(); + } } - + if (doRhoCorrection_) { - if (fabs(eleRef->superCluster()->eta()) < 1.479) - sum = sum - rho*effectiveAreaBarrel_; - else - sum = sum - rho*effectiveAreaEndcap_; + if (fabs(eleRef->superCluster()->eta()) < 1.479) + sum = sum - rho * effectiveAreaBarrel_; + else + sum = sum - rho * effectiveAreaEndcap_; } - + eleMap.insert(eleRef, sum); - } + } iEvent.put(std::make_unique(eleMap)); } } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFPhotonIsolationProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFPhotonIsolationProducer.cc index 1f9589d356dcf..d5f2010eb82ed 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFPhotonIsolationProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPFPhotonIsolationProducer.cc @@ -30,35 +30,36 @@ #include EgammaHLTPFPhotonIsolationProducer::EgammaHLTPFPhotonIsolationProducer(const edm::ParameterSet& config) { - - pfCandidateProducer_ = consumes(config.getParameter("pfCandidatesProducer")); + pfCandidateProducer_ = + consumes(config.getParameter("pfCandidatesProducer")); useSCRefs_ = config.getParameter("useSCRefs"); - drMax_ = config.getParameter("drMax"); - drVetoBarrel_ = config.getParameter("drVetoBarrel"); - drVetoEndcap_ = config.getParameter("drVetoEndcap"); + drMax_ = config.getParameter("drMax"); + drVetoBarrel_ = config.getParameter("drVetoBarrel"); + drVetoEndcap_ = config.getParameter("drVetoEndcap"); etaStripBarrel_ = config.getParameter("etaStripBarrel"); etaStripEndcap_ = config.getParameter("etaStripEndcap"); - energyBarrel_ = config.getParameter("energyBarrel"); - energyEndcap_ = config.getParameter("energyEndcap"); - pfToUse_ = config.getParameter("pfCandidateType"); + energyBarrel_ = config.getParameter("energyBarrel"); + energyEndcap_ = config.getParameter("energyEndcap"); + pfToUse_ = config.getParameter("pfCandidateType"); - doRhoCorrection_ = config.getParameter("doRhoCorrection"); + doRhoCorrection_ = config.getParameter("doRhoCorrection"); if (doRhoCorrection_) - rhoProducer_ = consumes(config.getParameter("rhoProducer")); - - rhoMax_ = config.getParameter("rhoMax"); - rhoScale_ = config.getParameter("rhoScale"); - effectiveAreaBarrel_ = config.getParameter("effectiveAreaBarrel"); - effectiveAreaEndcap_ = config.getParameter("effectiveAreaEndcap"); - - if(useSCRefs_) { - produces < reco::RecoEcalCandidateIsolationMap >(); - recoEcalCandidateProducer_ = consumes(config.getParameter("recoEcalCandidateProducer")); + rhoProducer_ = consumes(config.getParameter("rhoProducer")); + + rhoMax_ = config.getParameter("rhoMax"); + rhoScale_ = config.getParameter("rhoScale"); + effectiveAreaBarrel_ = config.getParameter("effectiveAreaBarrel"); + effectiveAreaEndcap_ = config.getParameter("effectiveAreaEndcap"); + + if (useSCRefs_) { + produces(); + recoEcalCandidateProducer_ = + consumes(config.getParameter("recoEcalCandidateProducer")); } else { - produces < reco::ElectronIsolationMap >(); - electronProducer_ = consumes(config.getParameter("electronProducer")); + produces(); + electronProducer_ = consumes(config.getParameter("electronProducer")); } } @@ -66,11 +67,11 @@ void EgammaHLTPFPhotonIsolationProducer::fillDescriptions(edm::ConfigurationDesc edm::ParameterSetDescription desc; desc.add("electronProducer", edm::InputTag("hltEle27WP80PixelMatchElectronsL1SeededPF")); desc.add("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidatePF")); - desc.add("pfCandidatesProducer", edm::InputTag("hltParticleFlowReg")); + desc.add("pfCandidatesProducer", edm::InputTag("hltParticleFlowReg")); desc.add("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo")); desc.add("doRhoCorrection", false); - desc.add("rhoMax", 9.9999999E7); - desc.add("rhoScale", 1.0); + desc.add("rhoMax", 9.9999999E7); + desc.add("rhoScale", 1.0); desc.add("effectiveAreaBarrel", 0.101); desc.add("effectiveAreaEndcap", 0.046); desc.add("useSCRefs", false); @@ -85,19 +86,20 @@ void EgammaHLTPFPhotonIsolationProducer::fillDescriptions(edm::ConfigurationDesc descriptions.add(("hltEgammaHLTPFPhotonIsolationProducer"), desc); } -void EgammaHLTPFPhotonIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTPFPhotonIsolationProducer::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { edm::Handle rhoHandle; double rho = 0.0; if (doRhoCorrection_) { iEvent.getByToken(rhoProducer_, rhoHandle); rho = *(rhoHandle.product()); } - + if (rho > rhoMax_) rho = rhoMax_; - - rho = rho*rhoScale_; + + rho = rho * rhoScale_; edm::Handle electronHandle; edm::Handle recoecalcandHandle; @@ -105,170 +107,181 @@ void EgammaHLTPFPhotonIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent.getByToken(pfCandidateProducer_, pfHandle); - if(useSCRefs_) { - - iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); + if (useSCRefs_) { + iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); reco::RecoEcalCandidateIsolationMap recoEcalCandMap(recoecalcandHandle); float dRVeto = -1.; float etaStrip = -1; - + for (unsigned int iReco = 0; iReco < recoecalcandHandle->size(); iReco++) { reco::RecoEcalCandidateRef candRef(recoecalcandHandle, iReco); - + if (fabs(candRef->eta()) < 1.479) { - dRVeto = drVetoBarrel_; - etaStrip = etaStripBarrel_; + dRVeto = drVetoBarrel_; + etaStrip = etaStripBarrel_; } else { - dRVeto = drVetoEndcap_; - etaStrip = etaStripEndcap_; + dRVeto = drVetoEndcap_; + etaStrip = etaStripEndcap_; } - + float sum = 0; // Loop over the PFCandidates - for(unsigned i=0; isize(); i++) { - reco::PFCandidateRef pfc(pfHandle, i); - - //require that the PFCandidate is a photon - if (pfc->particleId() == pfToUse_) { - - if (fabs(candRef->eta()) < 1.479) { - if (fabs(pfc->pt()) < energyBarrel_) - continue; - } else { - if (fabs(pfc->energy()) < energyEndcap_) - continue; - } - - // Shift the RecoEcalCandidate direction vector according to the PF vertex - math::XYZPoint pfvtx = pfc->vertex(); - math::XYZVector candDirectionWrtVtx(candRef->superCluster()->x() - pfvtx.x(), - candRef->superCluster()->y() - pfvtx.y(), - candRef->superCluster()->z() - pfvtx.z()); - - float dEta = fabs(candDirectionWrtVtx.Eta() - pfc->momentum().Eta()); - if(dEta < etaStrip) continue; - - float dR = deltaR(candDirectionWrtVtx.Eta(), candDirectionWrtVtx.Phi(), pfc->momentum().Eta(), pfc->momentum().Phi()); - if(dR > drMax_ || dR < dRVeto) continue; - - // Exclude PF photons which clusters are part of the candidate - bool clusterOverlap = false; - for(unsigned b=0; belementsInBlocks().size(); b++){ - reco::PFBlockRef blockRef = pfc->elementsInBlocks()[b].first; - unsigned elementIndex = pfc->elementsInBlocks()[b].second; - if(blockRef.isNull()) continue; - const edm::OwnVector< reco::PFBlockElement >& elements = blockRef->elements(); - const reco::PFBlockElement& pfbe(elements[elementIndex]); - if( pfbe.type() == reco::PFBlockElement::ECAL ){ - const reco::PFClusterRef& myPFClusterRef = pfbe.clusterRef(); - if(myPFClusterRef.isNull()) continue; - for(reco::CaloCluster_iterator it = candRef->superCluster()->clustersBegin(); it != candRef->superCluster()->clustersEnd(); ++it){ - if( myPFClusterRef->seed() == (*it)->seed() ){ - clusterOverlap = true; - break; - } - } - } - if(clusterOverlap) break; - } - if(clusterOverlap) continue; - - sum += pfc->pt(); - } + for (unsigned i = 0; i < pfHandle->size(); i++) { + reco::PFCandidateRef pfc(pfHandle, i); + + //require that the PFCandidate is a photon + if (pfc->particleId() == pfToUse_) { + if (fabs(candRef->eta()) < 1.479) { + if (fabs(pfc->pt()) < energyBarrel_) + continue; + } else { + if (fabs(pfc->energy()) < energyEndcap_) + continue; + } + + // Shift the RecoEcalCandidate direction vector according to the PF vertex + math::XYZPoint pfvtx = pfc->vertex(); + math::XYZVector candDirectionWrtVtx(candRef->superCluster()->x() - pfvtx.x(), + candRef->superCluster()->y() - pfvtx.y(), + candRef->superCluster()->z() - pfvtx.z()); + + float dEta = fabs(candDirectionWrtVtx.Eta() - pfc->momentum().Eta()); + if (dEta < etaStrip) + continue; + + float dR = deltaR( + candDirectionWrtVtx.Eta(), candDirectionWrtVtx.Phi(), pfc->momentum().Eta(), pfc->momentum().Phi()); + if (dR > drMax_ || dR < dRVeto) + continue; + + // Exclude PF photons which clusters are part of the candidate + bool clusterOverlap = false; + for (unsigned b = 0; b < pfc->elementsInBlocks().size(); b++) { + reco::PFBlockRef blockRef = pfc->elementsInBlocks()[b].first; + unsigned elementIndex = pfc->elementsInBlocks()[b].second; + if (blockRef.isNull()) + continue; + const edm::OwnVector& elements = blockRef->elements(); + const reco::PFBlockElement& pfbe(elements[elementIndex]); + if (pfbe.type() == reco::PFBlockElement::ECAL) { + const reco::PFClusterRef& myPFClusterRef = pfbe.clusterRef(); + if (myPFClusterRef.isNull()) + continue; + for (reco::CaloCluster_iterator it = candRef->superCluster()->clustersBegin(); + it != candRef->superCluster()->clustersEnd(); + ++it) { + if (myPFClusterRef->seed() == (*it)->seed()) { + clusterOverlap = true; + break; + } + } + } + if (clusterOverlap) + break; + } + if (clusterOverlap) + continue; + + sum += pfc->pt(); + } } if (doRhoCorrection_) { - if (fabs(candRef->eta()) < 1.479) - sum = sum - rho*effectiveAreaBarrel_; - else - sum = sum - rho*effectiveAreaEndcap_; + if (fabs(candRef->eta()) < 1.479) + sum = sum - rho * effectiveAreaBarrel_; + else + sum = sum - rho * effectiveAreaEndcap_; } - + recoEcalCandMap.insert(candRef, sum); } iEvent.put(std::make_unique(recoEcalCandMap)); - - } else { - iEvent.getByToken(electronProducer_,electronHandle); + } else { + iEvent.getByToken(electronProducer_, electronHandle); reco::ElectronIsolationMap eleMap(electronHandle); - + float dRVeto = -1.; float etaStrip = -1; - for(unsigned int iEl=0; iElsize(); iEl++) { + for (unsigned int iEl = 0; iEl < electronHandle->size(); iEl++) { reco::ElectronRef eleRef(electronHandle, iEl); if (fabs(eleRef->eta()) < 1.479) { - dRVeto = drVetoBarrel_; - etaStrip = etaStripBarrel_; + dRVeto = drVetoBarrel_; + etaStrip = etaStripBarrel_; } else { - dRVeto = drVetoEndcap_; - etaStrip = etaStripEndcap_; + dRVeto = drVetoEndcap_; + etaStrip = etaStripEndcap_; } - + float sum = 0; // Loop over the PFCandidates - for(unsigned i=0; isize(); i++) { - reco::PFCandidateRef pfc(pfHandle, i); - - //require that the PFCandidate is a photon - if (pfc->particleId() == pfToUse_) { - - if (fabs(eleRef->eta()) < 1.479) { - if (fabs(pfc->pt()) < energyBarrel_) - continue; - } else { - if (fabs(pfc->energy()) < energyEndcap_) - continue; - } - - float dEta = fabs(eleRef->eta() - pfc->momentum().Eta()); - if(dEta < etaStrip) - continue; - - float dR = deltaR(eleRef->eta(), eleRef->phi(), pfc->momentum().Eta(), pfc->momentum().Phi()); - if(dR > drMax_ || dR < dRVeto) - continue; - - // Exclude PF photons which clusters are part of the electron supercluster - bool clusterOverlap = false; - for(unsigned b=0; belementsInBlocks().size(); b++){ - reco::PFBlockRef blockRef = pfc->elementsInBlocks()[b].first; - unsigned elementIndex = pfc->elementsInBlocks()[b].second; - if(blockRef.isNull()) continue; - const edm::OwnVector< reco::PFBlockElement >& elements = blockRef->elements(); - const reco::PFBlockElement& pfbe(elements[elementIndex]); - if( pfbe.type() == reco::PFBlockElement::ECAL ){ - const reco::PFClusterRef& myPFClusterRef = pfbe.clusterRef(); - if(myPFClusterRef.isNull()) continue; - for(reco::CaloCluster_iterator it = eleRef->superCluster()->clustersBegin(); it != eleRef->superCluster()->clustersEnd(); ++it){ - if( myPFClusterRef->seed() == (*it)->seed() ){ - clusterOverlap = true; - break; - } - } - } - if(clusterOverlap) break; - } - if(clusterOverlap) continue; - - sum += pfc->pt(); - } + for (unsigned i = 0; i < pfHandle->size(); i++) { + reco::PFCandidateRef pfc(pfHandle, i); + + //require that the PFCandidate is a photon + if (pfc->particleId() == pfToUse_) { + if (fabs(eleRef->eta()) < 1.479) { + if (fabs(pfc->pt()) < energyBarrel_) + continue; + } else { + if (fabs(pfc->energy()) < energyEndcap_) + continue; + } + + float dEta = fabs(eleRef->eta() - pfc->momentum().Eta()); + if (dEta < etaStrip) + continue; + + float dR = deltaR(eleRef->eta(), eleRef->phi(), pfc->momentum().Eta(), pfc->momentum().Phi()); + if (dR > drMax_ || dR < dRVeto) + continue; + + // Exclude PF photons which clusters are part of the electron supercluster + bool clusterOverlap = false; + for (unsigned b = 0; b < pfc->elementsInBlocks().size(); b++) { + reco::PFBlockRef blockRef = pfc->elementsInBlocks()[b].first; + unsigned elementIndex = pfc->elementsInBlocks()[b].second; + if (blockRef.isNull()) + continue; + const edm::OwnVector& elements = blockRef->elements(); + const reco::PFBlockElement& pfbe(elements[elementIndex]); + if (pfbe.type() == reco::PFBlockElement::ECAL) { + const reco::PFClusterRef& myPFClusterRef = pfbe.clusterRef(); + if (myPFClusterRef.isNull()) + continue; + for (reco::CaloCluster_iterator it = eleRef->superCluster()->clustersBegin(); + it != eleRef->superCluster()->clustersEnd(); + ++it) { + if (myPFClusterRef->seed() == (*it)->seed()) { + clusterOverlap = true; + break; + } + } + } + if (clusterOverlap) + break; + } + if (clusterOverlap) + continue; + + sum += pfc->pt(); + } } if (doRhoCorrection_) { - if (fabs(eleRef->eta()) < 1.479) - sum = sum - rho*effectiveAreaBarrel_; - else - sum = sum - rho*effectiveAreaEndcap_; + if (fabs(eleRef->eta()) < 1.479) + sum = sum - rho * effectiveAreaBarrel_; + else + sum = sum - rho * effectiveAreaEndcap_; } eleMap.insert(eleRef, sum); - } + } iEvent.put(std::make_unique(eleMap)); } } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPhotonTrackIsolationProducersRegional.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPhotonTrackIsolationProducersRegional.cc index aeb12babe817a..5a32ed58564cf 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPhotonTrackIsolationProducersRegional.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPhotonTrackIsolationProducersRegional.cc @@ -13,29 +13,32 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -EgammaHLTPhotonTrackIsolationProducersRegional::EgammaHLTPhotonTrackIsolationProducersRegional(const edm::ParameterSet& config): - recoEcalCandidateProducer_(consumes (config.getParameter("recoEcalCandidateProducer"))), - trackProducer_ (consumes(config.getParameter("trackProducer"))), - countTracks_ (config.getParameter("countTracks")), - egTrkIsoPtMin_ (config.getParameter("egTrkIsoPtMin")), - egTrkIsoConeSize_ (config.getParameter("egTrkIsoConeSize")), - egTrkIsoZSpan_ (config.getParameter("egTrkIsoZSpan")), - egTrkIsoRSpan_ (config.getParameter("egTrkIsoRSpan")), - egTrkIsoVetoConeSize_ (config.getParameter("egTrkIsoVetoConeSize")), - egTrkIsoStripBarrel_ (config.getParameter("egTrkIsoStripBarrel")), - egTrkIsoStripEndcap_ (config.getParameter("egTrkIsoStripEndcap")) { - - test_ = new EgammaHLTTrackIsolation(egTrkIsoPtMin_, egTrkIsoConeSize_, - egTrkIsoZSpan_, egTrkIsoRSpan_, egTrkIsoVetoConeSize_, - egTrkIsoStripBarrel_, egTrkIsoStripEndcap_); +EgammaHLTPhotonTrackIsolationProducersRegional::EgammaHLTPhotonTrackIsolationProducersRegional( + const edm::ParameterSet& config) + : recoEcalCandidateProducer_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + trackProducer_(consumes(config.getParameter("trackProducer"))), + countTracks_(config.getParameter("countTracks")), + egTrkIsoPtMin_(config.getParameter("egTrkIsoPtMin")), + egTrkIsoConeSize_(config.getParameter("egTrkIsoConeSize")), + egTrkIsoZSpan_(config.getParameter("egTrkIsoZSpan")), + egTrkIsoRSpan_(config.getParameter("egTrkIsoRSpan")), + egTrkIsoVetoConeSize_(config.getParameter("egTrkIsoVetoConeSize")), + egTrkIsoStripBarrel_(config.getParameter("egTrkIsoStripBarrel")), + egTrkIsoStripEndcap_(config.getParameter("egTrkIsoStripEndcap")) { + test_ = new EgammaHLTTrackIsolation(egTrkIsoPtMin_, + egTrkIsoConeSize_, + egTrkIsoZSpan_, + egTrkIsoRSpan_, + egTrkIsoVetoConeSize_, + egTrkIsoStripBarrel_, + egTrkIsoStripEndcap_); //register your products - produces < reco::RecoEcalCandidateIsolationMap >(); + produces(); } -EgammaHLTPhotonTrackIsolationProducersRegional::~EgammaHLTPhotonTrackIsolationProducersRegional() { - delete test_; -} +EgammaHLTPhotonTrackIsolationProducersRegional::~EgammaHLTPhotonTrackIsolationProducersRegional() { delete test_; } void EgammaHLTPhotonTrackIsolationProducersRegional::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -49,42 +52,38 @@ void EgammaHLTPhotonTrackIsolationProducersRegional::fillDescriptions(edm::Confi desc.add(("egTrkIsoVetoConeSize"), 0.06); desc.add(("egTrkIsoStripBarrel"), 0.03); desc.add(("egTrkIsoStripEndcap"), 0.03); - descriptions.add(("hltEgammaHLTPhotonTrackIsolationProducersRegional"), desc); + descriptions.add(("hltEgammaHLTPhotonTrackIsolationProducersRegional"), desc); } - // ------------ method called to produce the data ------------ -void -EgammaHLTPhotonTrackIsolationProducersRegional::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +void EgammaHLTPhotonTrackIsolationProducersRegional::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { // Get the HLT filtered objects edm::Handle recoecalcandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); + iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); - // Get the barrel hcal hits + // Get the barrel hcal hits edm::Handle trackHandle; iEvent.getByToken(trackProducer_, trackHandle); const reco::TrackCollection* trackCollection = trackHandle.product(); reco::RecoEcalCandidateIsolationMap isoMap(recoecalcandHandle); - - for(unsigned int iRecoEcalCand=0; iRecoEcalCandsize(); iRecoEcalCand++) { - + + for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoecalcandHandle->size(); iRecoEcalCand++) { reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand); bool usePhotonVertex = false; - + float isol; if (countTracks_) { isol = test_->photonTrackCount(&(*recoecalcandref), trackCollection, usePhotonVertex); } else { isol = test_->photonPtSum(&(*recoecalcandref), trackCollection, usePhotonVertex); } - - isoMap.insert(recoecalcandref, isol); + isoMap.insert(recoecalcandref, isol); } iEvent.put(std::make_unique(isoMap)); - } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchElectronProducers.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchElectronProducers.cc index 621fa79ae7e1e..2eb0172adaa49 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchElectronProducers.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchElectronProducers.cc @@ -2,7 +2,7 @@ // // Package: EgammaHLTProducers // Class: EgammaHLTPixelMatchElectronProducers -// +// /**\class EgammaHLTPixelMatchElectronProducers RecoEgamma/ElectronProducers/src/EgammaHLTPixelMatchElectronProducers.cc Description: EDProducer of HLT Electron objects @@ -31,40 +31,34 @@ #include using namespace reco; - -EgammaHLTPixelMatchElectronProducers::EgammaHLTPixelMatchElectronProducers(const edm::ParameterSet& iConfig) : - algo_(iConfig,consumesCollector()), - token_( produces() ) -{ + +EgammaHLTPixelMatchElectronProducers::EgammaHLTPixelMatchElectronProducers(const edm::ParameterSet& iConfig) + : algo_(iConfig, consumesCollector()), token_(produces()) { consumes(iConfig.getParameter("TrackProducer")); consumes(iConfig.getParameter("GsfTrackProducer")); consumes(iConfig.getParameter("BSProducer")); } - void EgammaHLTPixelMatchElectronProducers::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add(("TrackProducer"), edm::InputTag("hltEleAnyWP80CleanMergedTracks")); desc.add(("GsfTrackProducer"), edm::InputTag("")); desc.add(("UseGsfTracks"), false); - desc.add(("BSProducer"), edm::InputTag("hltOnlineBeamSpot")); - descriptions.add(("hltEgammaHLTPixelMatchElectronProducers"), desc); + desc.add(("BSProducer"), edm::InputTag("hltOnlineBeamSpot")); + descriptions.add(("hltEgammaHLTPixelMatchElectronProducers"), desc); } // ------------ method called to produce the data ------------ void EgammaHLTPixelMatchElectronProducers::produce(edm::Event& e, const edm::EventSetup& iSetup) { // Update the algorithm conditions - algo_.setupES(iSetup); - - // Create the output collections - ElectronCollection outEle; - + algo_.setupES(iSetup); + + // Create the output collections + ElectronCollection outEle; + // invoke algorithm - algo_.run(e,outEle); + algo_.run(e, outEle); // put result into the Event - e.emplace(token_,std::move(outEle)); + e.emplace(token_, std::move(outEle)); } - - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchVarProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchVarProducer.cc index f47c2ce75f925..34270e32efd8e 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchVarProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchVarProducer.cc @@ -29,61 +29,64 @@ #include "FWCore/Framework/interface/ESHandle.h" namespace { - //first 4 bits are sub detect of each hit (0=barrel, 1 = endcap) + //first 4 bits are sub detect of each hit (0=barrel, 1 = endcap) //next 8 bits are layer information (0=no hit, 1 = hit), first 4 are barrel, next 4 are endcap (theres an empty bit here //next 4 bits are nr of layers info - int makeSeedInfo(const reco::ElectronSeed& seed){ + int makeSeedInfo(const reco::ElectronSeed& seed) { int info = 0; - for(size_t hitNr=0;hitNr& candHandle): - name_(std::move(name)),hitNr_(hitNr),func_(func), - val_(std::numeric_limits::max()), - valInfo_(0) - { - valMap_=std::make_unique(candHandle); - valInfoMap_=std::make_unique(candHandle); + PixelData(std::string name, + size_t hitNr, + float (reco::ElectronSeed::*func)(size_t) const, + const edm::Handle& candHandle) + : name_(std::move(name)), hitNr_(hitNr), func_(func), val_(std::numeric_limits::max()), valInfo_(0) { + valMap_ = std::make_unique(candHandle); + valInfoMap_ = std::make_unique(candHandle); + } + PixelData(PixelData&& rhs) = default; + + void resetVal() { + val_ = std::numeric_limits::max(); + valInfo_ = 0; } - PixelData(PixelData&& rhs)=default; - - void resetVal(){val_=std::numeric_limits::max();valInfo_=0;} - void fill(const reco::ElectronSeed& seed){ - if(hitNr_insert(candRef,val_); - valInfoMap_->insert(candRef,valInfo_); + void fill(const reco::RecoEcalCandidateRef& candRef) { + valMap_->insert(candRef, val_); + valInfoMap_->insert(candRef, valInfo_); val_ = std::numeric_limits::max(); valInfo_ = 0; } - - void putInto(edm::Event& event){ - event.put(std::move(valMap_),name_+std::to_string(hitNr_+1)); - event.put(std::move(valInfoMap_),name_+std::to_string(hitNr_+1)+"Info"); + + void putInto(edm::Event& event) { + event.put(std::move(valMap_), name_ + std::to_string(hitNr_ + 1)); + event.put(std::move(valInfoMap_), name_ + std::to_string(hitNr_ + 1) + "Info"); } private: @@ -91,234 +94,224 @@ struct PixelData { std::unique_ptr valInfoMap_; std::string name_; size_t hitNr_; - float (reco::ElectronSeed::*func_)(size_t)const; + float (reco::ElectronSeed::*func_)(size_t) const; float val_; float valInfo_; - }; - class EgammaHLTPixelMatchVarProducer : public edm::stream::EDProducer<> { public: - explicit EgammaHLTPixelMatchVarProducer(const edm::ParameterSet&); ~EgammaHLTPixelMatchVarProducer() override; - + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); void produce(edm::Event&, const edm::EventSetup&) override; - std::array calS2(const reco::ElectronSeed& seed,int charge)const; + std::array calS2(const reco::ElectronSeed& seed, int charge) const; -private: +private: // ----------member data --------------------------- - + const edm::EDGetTokenT recoEcalCandidateToken_; const edm::EDGetTokenT pixelSeedsToken_; egPM::Param dPhi1Para_; egPM::Param dPhi2Para_; egPM::Param dRZ2Para_; - + int productsToWrite_; size_t nrHits_; }; -EgammaHLTPixelMatchVarProducer::EgammaHLTPixelMatchVarProducer(const edm::ParameterSet& config) : - recoEcalCandidateToken_(consumes(config.getParameter("recoEcalCandidateProducer"))), - pixelSeedsToken_(consumes(config.getParameter("pixelSeedsProducer"))), - dPhi1Para_(config.getParameter("dPhi1SParams")), - dPhi2Para_(config.getParameter("dPhi2SParams")), - dRZ2Para_(config.getParameter("dRZ2SParams")), - productsToWrite_(config.getParameter("productsToWrite")), - nrHits_(4) - +EgammaHLTPixelMatchVarProducer::EgammaHLTPixelMatchVarProducer(const edm::ParameterSet& config) + : recoEcalCandidateToken_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + pixelSeedsToken_( + consumes(config.getParameter("pixelSeedsProducer"))), + dPhi1Para_(config.getParameter("dPhi1SParams")), + dPhi2Para_(config.getParameter("dPhi2SParams")), + dRZ2Para_(config.getParameter("dRZ2SParams")), + productsToWrite_(config.getParameter("productsToWrite")), + nrHits_(4) + { - //register your products - produces < reco::RecoEcalCandidateIsolationMap >("s2"); - if(productsToWrite_>=1){ - produces < reco::RecoEcalCandidateIsolationMap >("dPhi1BestS2"); - produces < reco::RecoEcalCandidateIsolationMap >("dPhi2BestS2"); - produces < reco::RecoEcalCandidateIsolationMap >("dzBestS2"); + //register your products + produces("s2"); + if (productsToWrite_ >= 1) { + produces("dPhi1BestS2"); + produces("dPhi2BestS2"); + produces("dzBestS2"); } - if(productsToWrite_>=2){ + if (productsToWrite_ >= 2) { //note for product names we start from index 1 - for(size_t hitNr=1;hitNr<=nrHits_;hitNr++){ - produces < reco::RecoEcalCandidateIsolationMap >("dPhi"+std::to_string(hitNr)); - produces < reco::RecoEcalCandidateIsolationMap >("dPhi"+std::to_string(hitNr)+"Info"); - produces < reco::RecoEcalCandidateIsolationMap >("dRZ"+std::to_string(hitNr)); - produces < reco::RecoEcalCandidateIsolationMap >("dRZ"+std::to_string(hitNr)+"Info"); - } - produces < reco::RecoEcalCandidateIsolationMap >("nrClus"); - produces < reco::RecoEcalCandidateIsolationMap >("seedClusEFrac"); - produces < reco::RecoEcalCandidateIsolationMap >("phiWidth"); - produces < reco::RecoEcalCandidateIsolationMap >("etaWidth"); + for (size_t hitNr = 1; hitNr <= nrHits_; hitNr++) { + produces("dPhi" + std::to_string(hitNr)); + produces("dPhi" + std::to_string(hitNr) + "Info"); + produces("dRZ" + std::to_string(hitNr)); + produces("dRZ" + std::to_string(hitNr) + "Info"); + } + produces("nrClus"); + produces("seedClusEFrac"); + produces("phiWidth"); + produces("etaWidth"); } - } -EgammaHLTPixelMatchVarProducer::~EgammaHLTPixelMatchVarProducer() -{} +EgammaHLTPixelMatchVarProducer::~EgammaHLTPixelMatchVarProducer() {} void EgammaHLTPixelMatchVarProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add(("recoEcalCandidateProducer"), edm::InputTag("hltL1SeededRecoEcalCandidate")); desc.add(("pixelSeedsProducer"), edm::InputTag("electronPixelSeeds")); - + edm::ParameterSetDescription varParamDesc; edm::ParameterSetDescription binParamDesc; - - auto binDescCases = - "AbsEtaClus" >> - (edm::ParameterDescription("xMin",0.0,true) and - edm::ParameterDescription("xMax",3.0,true) and - edm::ParameterDescription("yMin",0,true) and - edm::ParameterDescription("yMax",99999,true) and - edm::ParameterDescription("funcType","pol0",true) and - edm::ParameterDescription>("funcParams",{0.},true)) or - "AbsEtaClusPhi" >> - (edm::ParameterDescription("xMin",0.0,true) and - edm::ParameterDescription("xMax",3.0,true) and - edm::ParameterDescription("yMin",0,true) and - edm::ParameterDescription("yMax",99999,true) and - edm::ParameterDescription("funcType","pol0",true) and - edm::ParameterDescription>("funcParams",{0.},true)) or - "AbsEtaClusEt" >> - (edm::ParameterDescription("xMin",0.0,true) and - edm::ParameterDescription("xMax",3.0,true) and - edm::ParameterDescription("yMin",0,true) and - edm::ParameterDescription("yMax",99999,true) and - edm::ParameterDescription("funcType","pol0",true) and - edm::ParameterDescription>("funcParams",{0.},true)); - - binParamDesc.ifValue(edm::ParameterDescription("binType","AbsEtaClus",true), std::move(binDescCases)); - - - varParamDesc.addVPSet("bins",binParamDesc); - desc.add("dPhi1SParams",varParamDesc); - desc.add("dPhi2SParams",varParamDesc); - desc.add("dRZ2SParams",varParamDesc); - desc.add("productsToWrite",0); - descriptions.add(("hltEgammaHLTPixelMatchVarProducer"), desc); + + auto binDescCases = "AbsEtaClus" >> (edm::ParameterDescription("xMin", 0.0, true) and + edm::ParameterDescription("xMax", 3.0, true) and + edm::ParameterDescription("yMin", 0, true) and + edm::ParameterDescription("yMax", 99999, true) and + edm::ParameterDescription("funcType", "pol0", true) and + edm::ParameterDescription>("funcParams", {0.}, true)) or + "AbsEtaClusPhi" >> (edm::ParameterDescription("xMin", 0.0, true) and + edm::ParameterDescription("xMax", 3.0, true) and + edm::ParameterDescription("yMin", 0, true) and + edm::ParameterDescription("yMax", 99999, true) and + edm::ParameterDescription("funcType", "pol0", true) and + edm::ParameterDescription>("funcParams", {0.}, true)) or + "AbsEtaClusEt" >> (edm::ParameterDescription("xMin", 0.0, true) and + edm::ParameterDescription("xMax", 3.0, true) and + edm::ParameterDescription("yMin", 0, true) and + edm::ParameterDescription("yMax", 99999, true) and + edm::ParameterDescription("funcType", "pol0", true) and + edm::ParameterDescription>("funcParams", {0.}, true)); + + binParamDesc.ifValue(edm::ParameterDescription("binType", "AbsEtaClus", true), std::move(binDescCases)); + + varParamDesc.addVPSet("bins", binParamDesc); + desc.add("dPhi1SParams", varParamDesc); + desc.add("dPhi2SParams", varParamDesc); + desc.add("dRZ2SParams", varParamDesc); + desc.add("productsToWrite", 0); + descriptions.add(("hltEgammaHLTPixelMatchVarProducer"), desc); } -void EgammaHLTPixelMatchVarProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){ - +void EgammaHLTPixelMatchVarProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // Get the HLT filtered objects edm::Handle recoEcalCandHandle; - iEvent.getByToken(recoEcalCandidateToken_,recoEcalCandHandle); - + iEvent.getByToken(recoEcalCandidateToken_, recoEcalCandHandle); edm::Handle pixelSeedsHandle; - iEvent.getByToken(pixelSeedsToken_,pixelSeedsHandle); + iEvent.getByToken(pixelSeedsToken_, pixelSeedsHandle); - if(!recoEcalCandHandle.isValid()) return; - else if(!pixelSeedsHandle.isValid()){ + if (!recoEcalCandHandle.isValid()) + return; + else if (!pixelSeedsHandle.isValid()) { auto s2Map = std::make_unique(recoEcalCandHandle); - for(unsigned int candNr = 0; candNrsize(); candNr++) { - reco::RecoEcalCandidateRef candRef(recoEcalCandHandle,candNr); - s2Map->insert(candRef,0); + for (unsigned int candNr = 0; candNr < recoEcalCandHandle->size(); candNr++) { + reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, candNr); + s2Map->insert(candRef, 0); } - iEvent.put(std::move(s2Map),"s2"); + iEvent.put(std::move(s2Map), "s2"); return; } edm::ESHandle trackerTopoHandle; iSetup.get().get(trackerTopoHandle); - + auto dPhi1BestS2Map = std::make_unique(recoEcalCandHandle); auto dPhi2BestS2Map = std::make_unique(recoEcalCandHandle); auto dzBestS2Map = std::make_unique(recoEcalCandHandle); auto s2Map = std::make_unique(recoEcalCandHandle); - + auto nrClusMap = std::make_unique(recoEcalCandHandle); - auto seedClusEFracMap = std::make_unique(recoEcalCandHandle); - auto phiWidthMap = std::make_unique(recoEcalCandHandle); - auto etaWidthMap = std::make_unique(recoEcalCandHandle); - + auto seedClusEFracMap = std::make_unique(recoEcalCandHandle); + auto phiWidthMap = std::make_unique(recoEcalCandHandle); + auto etaWidthMap = std::make_unique(recoEcalCandHandle); + std::vector pixelData; - for(size_t hitNr=0;hitNrsize(); candNr++) { - - reco::RecoEcalCandidateRef candRef(recoEcalCandHandle,candNr); + for (unsigned int candNr = 0; candNr < recoEcalCandHandle->size(); candNr++) { + reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, candNr); reco::SuperClusterRef candSCRef = candRef->superCluster(); - - std::array bestS2{{std::numeric_limits::max(),std::numeric_limits::max(),std::numeric_limits::max(),std::numeric_limits::max()}}; - for(auto & seed : *pixelSeedsHandle){ - const edm::RefToBase& pixelClusterRef = seed.caloCluster() ; - reco::SuperClusterRef pixelSCRef = pixelClusterRef.castTo() ; - if(&(*candSCRef) == &(*pixelSCRef)){ - - std::array s2Data = calS2(seed,-1); - std::array s2DataPos = calS2(seed,+1); - if(s2Data[0]=2){ - for(auto& pixelDatum : pixelData){ - pixelDatum.fill(seed); - } - } + + std::array bestS2{{std::numeric_limits::max(), + std::numeric_limits::max(), + std::numeric_limits::max(), + std::numeric_limits::max()}}; + for (auto& seed : *pixelSeedsHandle) { + const edm::RefToBase& pixelClusterRef = seed.caloCluster(); + reco::SuperClusterRef pixelSCRef = pixelClusterRef.castTo(); + if (&(*candSCRef) == &(*pixelSCRef)) { + std::array s2Data = calS2(seed, -1); + std::array s2DataPos = calS2(seed, +1); + if (s2Data[0] < bestS2[0]) + bestS2 = s2Data; + if (s2DataPos[0] < bestS2[0]) + bestS2 = s2DataPos; + + if (productsToWrite_ >= 2) { + for (auto& pixelDatum : pixelData) { + pixelDatum.fill(seed); + } + } } } - - s2Map->insert(candRef,bestS2[0]); - if(productsToWrite_>=1){ - dPhi1BestS2Map->insert(candRef,bestS2[1]); - dPhi2BestS2Map->insert(candRef,bestS2[2]); - dzBestS2Map->insert(candRef,bestS2[3]); + s2Map->insert(candRef, bestS2[0]); + if (productsToWrite_ >= 1) { + dPhi1BestS2Map->insert(candRef, bestS2[1]); + dPhi2BestS2Map->insert(candRef, bestS2[2]); + dzBestS2Map->insert(candRef, bestS2[3]); + } + if (productsToWrite_ >= 2) { + nrClusMap->insert(candRef, candSCRef->clustersSize()); + float seedClusEFrac = candSCRef->rawEnergy() > 0 ? candSCRef->seed()->energy() / candSCRef->rawEnergy() : 0.; + // std::cout <<"cand "<energy()<<" E Corr "<correctedEnergyUncertainty()<<" "<correctedEnergy()<<" width "<phiWidth()<phiWidth(); + seedClusEFracMap->insert(candRef, seedClusEFrac); + float phiWidth = candSCRef->phiWidth(); + float etaWidth = candSCRef->etaWidth(); + phiWidthMap->insert(candRef, phiWidth); + etaWidthMap->insert(candRef, etaWidth); + + for (auto& pixelDatum : pixelData) { + pixelDatum.fill(candRef); + } } - if(productsToWrite_>=2){ - nrClusMap->insert(candRef,candSCRef->clustersSize()); - float seedClusEFrac = candSCRef->rawEnergy()>0 ? candSCRef->seed()->energy() / candSCRef->rawEnergy() : 0.; - // std::cout <<"cand "<energy()<<" E Corr "<correctedEnergyUncertainty()<<" "<correctedEnergy()<<" width "<phiWidth()<phiWidth(); - seedClusEFracMap->insert(candRef,seedClusEFrac); - float phiWidth = candSCRef->phiWidth(); - float etaWidth = candSCRef->etaWidth(); - phiWidthMap->insert(candRef,phiWidth); - etaWidthMap->insert(candRef,etaWidth); - - for(auto& pixelDatum : pixelData){ - pixelDatum.fill(candRef); - } - } } - iEvent.put(std::move(s2Map),"s2"); - if(productsToWrite_>=1){ - iEvent.put(std::move(dPhi1BestS2Map),"dPhi1BestS2"); - iEvent.put(std::move(dPhi2BestS2Map),"dPhi2BestS2"); - iEvent.put(std::move(dzBestS2Map),"dzBestS2"); + iEvent.put(std::move(s2Map), "s2"); + if (productsToWrite_ >= 1) { + iEvent.put(std::move(dPhi1BestS2Map), "dPhi1BestS2"); + iEvent.put(std::move(dPhi2BestS2Map), "dPhi2BestS2"); + iEvent.put(std::move(dzBestS2Map), "dzBestS2"); } - if(productsToWrite_>=2){ - for(auto& pixelDatum : pixelData){ + if (productsToWrite_ >= 2) { + for (auto& pixelDatum : pixelData) { pixelDatum.putInto(iEvent); - } - iEvent.put(std::move(nrClusMap),"nrClus"); - iEvent.put(std::move(seedClusEFracMap),"seedClusEFrac"); - iEvent.put(std::move(phiWidthMap),"phiWidth"); - iEvent.put(std::move(etaWidthMap),"etaWidth"); + } + iEvent.put(std::move(nrClusMap), "nrClus"); + iEvent.put(std::move(seedClusEFracMap), "seedClusEFrac"); + iEvent.put(std::move(phiWidthMap), "phiWidth"); + iEvent.put(std::move(etaWidthMap), "etaWidth"); } } -std::array EgammaHLTPixelMatchVarProducer::calS2(const reco::ElectronSeed& seed,int charge)const -{ - const float dPhi1Const = dPhi1Para_(seed); +std::array EgammaHLTPixelMatchVarProducer::calS2(const reco::ElectronSeed& seed, int charge) const { + const float dPhi1Const = dPhi1Para_(seed); const float dPhi2Const = dPhi2Para_(seed); const float dRZ2Const = dRZ2Para_(seed); - - float dPhi1 = (charge <0 ? seed.dPhiNeg(0) : seed.dPhiPos(0))/dPhi1Const; - float dPhi2 = (charge <0 ? seed.dPhiNeg(1) : seed.dPhiPos(1))/dPhi2Const; - float dRz2 = (charge <0 ? seed.dRZNeg(1) : seed.dRZPos(1))/dRZ2Const; - - float s2 = dPhi1*dPhi1+dPhi2*dPhi2+dRz2*dRz2; - return std::array{{s2,dPhi1,dPhi2,dRz2}}; -} + float dPhi1 = (charge < 0 ? seed.dPhiNeg(0) : seed.dPhiPos(0)) / dPhi1Const; + float dPhi2 = (charge < 0 ? seed.dPhiNeg(1) : seed.dPhiPos(1)) / dPhi2Const; + float dRz2 = (charge < 0 ? seed.dRZNeg(1) : seed.dRZPos(1)) / dRZ2Const; + + float s2 = dPhi1 * dPhi1 + dPhi2 * dPhi2 + dRz2 * dRz2; + return std::array{{s2, dPhi1, dPhi2, dRz2}}; +} DEFINE_FWK_MODULE(EgammaHLTPixelMatchVarProducer); diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9IDProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9IDProducer.cc index 1d276600345ae..a31bf61b435e6 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9IDProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9IDProducer.cc @@ -15,64 +15,58 @@ #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" -EgammaHLTR9IDProducer::EgammaHLTR9IDProducer(const edm::ParameterSet& config): - recoEcalCandidateProducer_(consumes(config.getParameter("recoEcalCandidateProducer"))), - ecalRechitEBToken_(consumes(config.getParameter< edm::InputTag > ("ecalRechitEB"))), - ecalRechitEEToken_(consumes(config.getParameter< edm::InputTag > ("ecalRechitEE"))) { - +EgammaHLTR9IDProducer::EgammaHLTR9IDProducer(const edm::ParameterSet& config) + : recoEcalCandidateProducer_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + ecalRechitEBToken_(consumes(config.getParameter("ecalRechitEB"))), + ecalRechitEEToken_(consumes(config.getParameter("ecalRechitEE"))) { //register your products - produces < reco::RecoEcalCandidateIsolationMap >(); - produces < reco::RecoEcalCandidateIsolationMap >("r95x5"); + produces(); + produces("r95x5"); } -EgammaHLTR9IDProducer::~EgammaHLTR9IDProducer() -{} +EgammaHLTR9IDProducer::~EgammaHLTR9IDProducer() {} void EgammaHLTR9IDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalCandidate")); - desc.add(("ecalRechitEB"), edm::InputTag("hltEcalRegionalEgammaRecHit","EcalRecHitsEB")); - desc.add(("ecalRechitEE"), edm::InputTag("hltEcalRegionalEgammaRecHit","EcalRecHitsEE")); - descriptions.add(("hltEgammaHLTR9IDProducer"), desc); + desc.add(("ecalRechitEB"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEB")); + desc.add(("ecalRechitEE"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEE")); + descriptions.add(("hltEgammaHLTR9IDProducer"), desc); } - // ------------ method called to produce the data ------------ void EgammaHLTR9IDProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - // Get the HLT filtered objects edm::Handle recoecalcandHandle; iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); - EcalClusterLazyTools lazyTools( iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_ ); - noZS::EcalClusterLazyTools lazyTools5x5(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_ ); + EcalClusterLazyTools lazyTools(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); + noZS::EcalClusterLazyTools lazyTools5x5(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); reco::RecoEcalCandidateIsolationMap r9Map(recoecalcandHandle); - reco::RecoEcalCandidateIsolationMap r95x5Map(recoecalcandHandle); - for(unsigned int iRecoEcalCand=0; iRecoEcalCandsize(); iRecoEcalCand++) { - - reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand);//-recoecalcandHandle->begin()); + reco::RecoEcalCandidateIsolationMap r95x5Map(recoecalcandHandle); + for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoecalcandHandle->size(); iRecoEcalCand++) { + reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand); //-recoecalcandHandle->begin()); float r9 = -1; float r95x5 = -1; - float e9 = lazyTools.e3x3( *(recoecalcandref->superCluster()->seed()) ); - float e95x5 = lazyTools5x5.e3x3( *(recoecalcandref->superCluster()->seed()) ); + float e9 = lazyTools.e3x3(*(recoecalcandref->superCluster()->seed())); + float e95x5 = lazyTools5x5.e3x3(*(recoecalcandref->superCluster()->seed())); float eraw = recoecalcandref->superCluster()->rawEnergy(); - if (eraw > 0. ) { - r9 = e9/eraw; - r95x5 = e95x5/eraw; + if (eraw > 0.) { + r9 = e9 / eraw; + r95x5 = e95x5 / eraw; } r9Map.insert(recoecalcandref, r9); - r95x5Map.insert(recoecalcandref,r95x5); - + r95x5Map.insert(recoecalcandref, r95x5); } iEvent.put(std::make_unique(r9Map)); - iEvent.put(std::make_unique(r95x5Map),"r95x5"); + iEvent.put(std::make_unique(r95x5Map), "r95x5"); } //define this as a plug-in diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9Producer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9Producer.cc index 9571bb8f33cbd..963c2483ee98c 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9Producer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9Producer.cc @@ -14,62 +14,58 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -EgammaHLTR9Producer::EgammaHLTR9Producer(const edm::ParameterSet& config): - recoEcalCandidateProducer_(consumes (config.getParameter("recoEcalCandidateProducer"))), - ecalRechitEBToken_(consumes(config.getParameter< edm::InputTag > ("ecalRechitEB"))), - ecalRechitEEToken_(consumes(config.getParameter< edm::InputTag > ("ecalRechitEE"))), - useSwissCross_(config.getParameter< bool > ("useSwissCross")) { - +EgammaHLTR9Producer::EgammaHLTR9Producer(const edm::ParameterSet& config) + : recoEcalCandidateProducer_( + consumes(config.getParameter("recoEcalCandidateProducer"))), + ecalRechitEBToken_(consumes(config.getParameter("ecalRechitEB"))), + ecalRechitEEToken_(consumes(config.getParameter("ecalRechitEE"))), + useSwissCross_(config.getParameter("useSwissCross")) { //register your products - produces < reco::RecoEcalCandidateIsolationMap >(); + produces(); } -EgammaHLTR9Producer::~EgammaHLTR9Producer() -{} +EgammaHLTR9Producer::~EgammaHLTR9Producer() {} // ------------ method called to produce the data ------------ void EgammaHLTR9Producer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalCandidate")); - desc.add(("ecalRechitEB"), edm::InputTag("hltEcalRegionalEgammaRecHit","EcalRecHitsEB")); - desc.add(("ecalRechitEE"), edm::InputTag("hltEcalRegionalEgammaRecHit","EcalRecHitsEE")); - desc.add (("useSwissCross"), false); - descriptions.add(("hltEgammaHLTR9Producer"), desc); + desc.add(("ecalRechitEB"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEB")); + desc.add(("ecalRechitEE"), edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEE")); + desc.add(("useSwissCross"), false); + descriptions.add(("hltEgammaHLTR9Producer"), desc); } - void EgammaHLTR9Producer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - // Get the HLT filtered objects edm::Handle recoecalcandHandle; - iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); + iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); EcalClusterLazyTools lazyTools(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); - + reco::RecoEcalCandidateIsolationMap r9Map; - - for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){ - - reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand-recoecalcandHandle->begin()); + + for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); + iRecoEcalCand != recoecalcandHandle->end(); + iRecoEcalCand++) { + reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle, iRecoEcalCand - recoecalcandHandle->begin()); float r9 = -1; - if (useSwissCross_){ - edm::Handle< EcalRecHitCollection > pEBRecHits; + if (useSwissCross_) { + edm::Handle pEBRecHits; iEvent.getByToken(ecalRechitEBToken_, pEBRecHits); r9 = -1; - } - else{ - float e9 = lazyTools.e3x3( *(recoecalcandref->superCluster()->seed()) ); - if (e9 != 0 ) {r9 = lazyTools.eMax(*(recoecalcandref->superCluster()->seed()) )/e9;} + } else { + float e9 = lazyTools.e3x3(*(recoecalcandref->superCluster()->seed())); + if (e9 != 0) { + r9 = lazyTools.eMax(*(recoecalcandref->superCluster()->seed())) / e9; + } } r9Map.insert(recoecalcandref, r9); - } iEvent.put(std::make_unique(r9Map)); - } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRecoEcalCandidateProducers.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRecoEcalCandidateProducers.cc index 209e87a63c4c9..dcb443473c515 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRecoEcalCandidateProducers.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRecoEcalCandidateProducers.cc @@ -17,29 +17,29 @@ #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRecoEcalCandidateProducers.h" - -EgammaHLTRecoEcalCandidateProducers::EgammaHLTRecoEcalCandidateProducers(const edm::ParameterSet& config) : - scHybridBarrelProducer_(consumes(config.getParameter("scHybridBarrelProducer"))), - scIslandEndcapProducer_(consumes(config.getParameter("scIslandEndcapProducer"))), - recoEcalCandidateCollection_(config.getParameter("recoEcalCandidateCollection")) { - +EgammaHLTRecoEcalCandidateProducers::EgammaHLTRecoEcalCandidateProducers(const edm::ParameterSet& config) + : scHybridBarrelProducer_( + consumes(config.getParameter("scHybridBarrelProducer"))), + scIslandEndcapProducer_( + consumes(config.getParameter("scIslandEndcapProducer"))), + recoEcalCandidateCollection_(config.getParameter("recoEcalCandidateCollection")) { // Register the product - produces< reco::RecoEcalCandidateCollection >(recoEcalCandidateCollection_); + produces(recoEcalCandidateCollection_); } -EgammaHLTRecoEcalCandidateProducers::~EgammaHLTRecoEcalCandidateProducers() -{} +EgammaHLTRecoEcalCandidateProducers::~EgammaHLTRecoEcalCandidateProducers() {} void EgammaHLTRecoEcalCandidateProducers::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add(("scHybridBarrelProducer"), edm::InputTag("correctedHybridSuperClusters")); desc.add(("scIslandEndcapProducer"), edm::InputTag("correctedEndcapSuperClustersWithPreshower")); desc.add(("recoEcalCandidateCollection"), ""); - descriptions.add(("hltEgammaHLTRecoEcalCandidateProducers"), desc); + descriptions.add(("hltEgammaHLTRecoEcalCandidateProducers"), desc); } -void EgammaHLTRecoEcalCandidateProducers::produce(edm::StreamID sid, edm::Event& theEvent, const edm::EventSetup& theEventSetup) const { - +void EgammaHLTRecoEcalCandidateProducers::produce(edm::StreamID sid, + edm::Event& theEvent, + const edm::EventSetup& theEventSetup) const { using namespace edm; // @@ -51,24 +51,23 @@ void EgammaHLTRecoEcalCandidateProducers::produce(edm::StreamID sid, edm::Event& // Get the Barrel Super Cluster collection Handle scBarrelHandle; - theEvent.getByToken(scHybridBarrelProducer_,scBarrelHandle); + theEvent.getByToken(scHybridBarrelProducer_, scBarrelHandle); // Get the Endcap Super Cluster collection Handle scEndcapHandle; - theEvent.getByToken(scIslandEndcapProducer_,scEndcapHandle); + theEvent.getByToken(scIslandEndcapProducer_, scEndcapHandle); // Loop over barrel SC and fill the recoecal collection - int iSC=0; // index in recoecal collection - int lSC=0; // local index on barrel + int iSC = 0; // index in recoecal collection + int lSC = 0; // local index on barrel - -for(reco::SuperClusterCollection::const_iterator aClus = scBarrelHandle->begin(); aClus != scBarrelHandle->end(); aClus++) { - - const reco::Particle::Point vtx( 0, 0, 0 ); + for (reco::SuperClusterCollection::const_iterator aClus = scBarrelHandle->begin(); aClus != scBarrelHandle->end(); + aClus++) { + const reco::Particle::Point vtx(0, 0, 0); // compute correctly the momentum vector of the recoecal from primary vertex and cluster position - math::XYZVector direction =aClus->position() - vtx; + math::XYZVector direction = aClus->position() - vtx; math::XYZVector momentum = direction.unit() * aClus->energy(); - const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() ); + const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy()); reco::RecoEcalCandidate newCandidate(0, p4, vtx); @@ -78,34 +77,31 @@ for(reco::SuperClusterCollection::const_iterator aClus = scBarrelHandle->begin() lSC++; iSC++; - } // Loop over Endcap SC and fill the recoecal collection - lSC=0; // reset local index for endcap + lSC = 0; // reset local index for endcap -for(reco::SuperClusterCollection::const_iterator aClus = scEndcapHandle->begin(); aClus != scEndcapHandle->end(); aClus++) { + for (reco::SuperClusterCollection::const_iterator aClus = scEndcapHandle->begin(); aClus != scEndcapHandle->end(); + aClus++) { + const reco::Particle::Point vtx(0, 0, 0); - const reco::Particle::Point vtx( 0, 0, 0 ); - - math::XYZVector direction =aClus->position() - vtx; + math::XYZVector direction = aClus->position() - vtx; math::XYZVector momentum = direction.unit() * aClus->energy(); - const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() ); + const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy()); reco::RecoEcalCandidate newCandidate(0, p4, vtx); outputRecoEcalCandidateCollection.push_back(newCandidate); reco::SuperClusterRef scRef(reco::SuperClusterRef(scEndcapHandle, lSC)); outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef); - + iSC++; lSC++; - } // put the product in the event - outputRecoEcalCandidateCollection_p->assign(outputRecoEcalCandidateCollection.begin(),outputRecoEcalCandidateCollection.end()); + outputRecoEcalCandidateCollection_p->assign(outputRecoEcalCandidateCollection.begin(), + outputRecoEcalCandidateCollection.end()); theEvent.put(std::move(outputRecoEcalCandidateCollection_p), recoEcalCandidateCollection_); - } - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc index 9df08d566253b..045212c75271f 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc @@ -40,45 +40,43 @@ using namespace std; using namespace reco; -EgammaHLTRegionalPixelSeedGeneratorProducers::EgammaHLTRegionalPixelSeedGeneratorProducers(edm::ParameterSet const& conf) -{ - +EgammaHLTRegionalPixelSeedGeneratorProducers::EgammaHLTRegionalPixelSeedGeneratorProducers( + edm::ParameterSet const& conf) { produces(); - ptmin_ = conf.getParameter("ptMin"); - vertexz_ = conf.getParameter("vertexZ"); - originradius_= conf.getParameter("originRadius"); - halflength_ = conf.getParameter("originHalfLength"); - deltaEta_ = conf.getParameter("deltaEtaRegion"); - deltaPhi_ = conf.getParameter("deltaPhiRegion"); + ptmin_ = conf.getParameter("ptMin"); + vertexz_ = conf.getParameter("vertexZ"); + originradius_ = conf.getParameter("originRadius"); + halflength_ = conf.getParameter("originHalfLength"); + deltaEta_ = conf.getParameter("deltaEtaRegion"); + deltaPhi_ = conf.getParameter("deltaPhiRegion"); + + candTag_ = consumes(conf.getParameter("candTag")); + candTagEle_ = consumes(conf.getParameter("candTagEle")); + BSProducer_ = consumes(conf.getParameter("BSProducer")); - candTag_ = consumes(conf.getParameter< edm::InputTag > ("candTag")); - candTagEle_ = consumes(conf.getParameter< edm::InputTag > ("candTagEle")); - BSProducer_ = consumes(conf.getParameter("BSProducer")); - - useZvertex_ = conf.getParameter("UseZInVertex"); + useZvertex_ = conf.getParameter("UseZInVertex"); edm::ParameterSet hitsfactoryPSet = conf.getParameter("OrderedHitsFactoryPSet"); std::string hitsfactoryName = hitsfactoryPSet.getParameter("ComponentName"); // start seed generator edm::ParameterSet creatorPSet; - creatorPSet.addParameter("propagator","PropagatorWithMaterial"); + creatorPSet.addParameter("propagator", "PropagatorWithMaterial"); edm::ConsumesCollector iC = consumesCollector(); - combinatorialSeedGenerator = std::make_unique( std::unique_ptr{OrderedHitsGeneratorFactory::get()->create( hitsfactoryName, hitsfactoryPSet, iC)}, - nullptr, - std::unique_ptr{SeedCreatorFactory::get()->create("SeedFromConsecutiveHitsCreator", creatorPSet)} - ); + combinatorialSeedGenerator = std::make_unique( + std::unique_ptr{ + OrderedHitsGeneratorFactory::get()->create(hitsfactoryName, hitsfactoryPSet, iC)}, + nullptr, + std::unique_ptr{SeedCreatorFactory::get()->create("SeedFromConsecutiveHitsCreator", creatorPSet)}); // setup orderedhits setup (in order to tell seed generator to use pairs/triplets, which layers) } // Virtual destructor needed. -EgammaHLTRegionalPixelSeedGeneratorProducers::~EgammaHLTRegionalPixelSeedGeneratorProducers() { -} +EgammaHLTRegionalPixelSeedGeneratorProducers::~EgammaHLTRegionalPixelSeedGeneratorProducers() {} void EgammaHLTRegionalPixelSeedGeneratorProducers::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("ptMin", 1.5); desc.add("vertexZ", 0); @@ -97,62 +95,64 @@ void EgammaHLTRegionalPixelSeedGeneratorProducers::fillDescriptions(edm::Configu orderedHitsPSET.add("SeedingLayers", edm::InputTag("PixelLayerPairs")); orderedHitsPSET.add("maxElement", 0); desc.add("OrderedHitsFactoryPSet", orderedHitsPSET); - - descriptions.add(("hltEgammaHLTRegionalPixelSeedGeneratorProducers"), desc); + + descriptions.add(("hltEgammaHLTRegionalPixelSeedGeneratorProducers"), desc); } // Functions that gets called by framework every event -void EgammaHLTRegionalPixelSeedGeneratorProducers::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - +void EgammaHLTRegionalPixelSeedGeneratorProducers::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // resulting collection - auto output = std::make_unique< TrajectorySeedCollection>(); + auto output = std::make_unique(); // Get the recoEcalCandidates edm::Handle recoecalcands; - iEvent.getByToken(candTag_,recoecalcands); + iEvent.getByToken(candTag_, recoecalcands); //Get the Beam Spot position edm::Handle recoBeamSpotHandle; - iEvent.getByToken(BSProducer_,recoBeamSpotHandle); + iEvent.getByToken(BSProducer_, recoBeamSpotHandle); // gets its position - const BeamSpot::Point& BSPosition = recoBeamSpotHandle->position(); + const BeamSpot::Point& BSPosition = recoBeamSpotHandle->position(); //Get the HLT electrons collection if needed edm::Handle electronHandle; - if(useZvertex_) - iEvent.getByToken(candTagEle_,electronHandle); + if (useZvertex_) + iEvent.getByToken(candTagEle_, electronHandle); reco::SuperClusterRef scRef; - for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand= recoecalcands->begin(); recoecalcand!=recoecalcands->end(); recoecalcand++) { + for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand = recoecalcands->begin(); + recoecalcand != recoecalcands->end(); + recoecalcand++) { scRef = recoecalcand->superCluster(); float zvertex = 0; - if( useZvertex_ ){ + if (useZvertex_) { reco::SuperClusterRef scRefEle; - for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){ - //Compare electron SC with EcalCandidate SC - scRefEle = iElectron->superCluster(); - if(&(*scRef) == &(*scRefEle)){ - if(iElectron->track().isNonnull()) zvertex = iElectron->track()->vz(); - else zvertex = iElectron->gsfTrack()->vz(); - break; - } + for (reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); + iElectron != electronHandle->end(); + iElectron++) { + //Compare electron SC with EcalCandidate SC + scRefEle = iElectron->superCluster(); + if (&(*scRef) == &(*scRefEle)) { + if (iElectron->track().isNonnull()) + zvertex = iElectron->track()->vz(); + else + zvertex = iElectron->gsfTrack()->vz(); + break; + } } - } - GlobalVector dirVector((recoecalcand)->px(),(recoecalcand)->py(),(recoecalcand)->pz()); - RectangularEtaPhiTrackingRegion etaphiRegion( dirVector, - GlobalPoint( BSPosition.x(), BSPosition.y(), zvertex ), - ptmin_, - originradius_, - halflength_, - deltaEta_, - deltaPhi_); + GlobalVector dirVector((recoecalcand)->px(), (recoecalcand)->py(), (recoecalcand)->pz()); + RectangularEtaPhiTrackingRegion etaphiRegion(dirVector, + GlobalPoint(BSPosition.x(), BSPosition.y(), zvertex), + ptmin_, + originradius_, + halflength_, + deltaEta_, + deltaPhi_); // fill Trajectory seed collection combinatorialSeedGenerator->run(*output, etaphiRegion, iEvent, iSetup); - } - iEvent.put(std::move(output)); + iEvent.put(std::move(output)); } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRemoveDuplicatedSC.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRemoveDuplicatedSC.cc index e89692c86f09f..09eda2df2cc84 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRemoveDuplicatedSC.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRemoveDuplicatedSC.cc @@ -11,76 +11,69 @@ #include -EgammaHLTRemoveDuplicatedSC::EgammaHLTRemoveDuplicatedSC(const edm::ParameterSet& ps) -{ - - +EgammaHLTRemoveDuplicatedSC::EgammaHLTRemoveDuplicatedSC(const edm::ParameterSet& ps) { // the input producers sCInputProducer_ = consumes(ps.getParameter("L1NonIsoUskimmedSC")); - alreadyExistingSC_= consumes(ps.getParameter("L1IsoSC")); + alreadyExistingSC_ = consumes(ps.getParameter("L1IsoSC")); // set the producer parameters outputCollection_ = ps.getParameter("L1NonIsoSkimmedCollection"); produces(outputCollection_); - } -EgammaHLTRemoveDuplicatedSC::~EgammaHLTRemoveDuplicatedSC() -{} +EgammaHLTRemoveDuplicatedSC::~EgammaHLTRemoveDuplicatedSC() {} void EgammaHLTRemoveDuplicatedSC::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add(("L1NonIsoUskimmedSC"), edm::InputTag("hltCorrectedMulti5x5EndcapSuperClustersWithPreshowerL1NonIsolatedTemp")); + desc.add(("L1NonIsoUskimmedSC"), + edm::InputTag("hltCorrectedMulti5x5EndcapSuperClustersWithPreshowerL1NonIsolatedTemp")); desc.add(("L1IsoSC"), edm::InputTag("hltCorrectedMulti5x5EndcapSuperClustersWithPreshowerL1Isolated")); - desc.add(("L1NonIsoSkimmedCollection"), ""); - descriptions.add(("hltEgammaHLTRemoveDuplicatedSC"), desc); + desc.add(("L1NonIsoSkimmedCollection"), ""); + descriptions.add(("hltEgammaHLTRemoveDuplicatedSC"), desc); } - -void -EgammaHLTRemoveDuplicatedSC::produce(edm::StreamID sid, edm::Event& evt, const edm::EventSetup& es) const { - +void EgammaHLTRemoveDuplicatedSC::produce(edm::StreamID sid, edm::Event& evt, const edm::EventSetup& es) const { using namespace edm; - - // Get raw SuperClusters from the event + + // Get raw SuperClusters from the event Handle UnskimmedSuperCluster; evt.getByToken(sCInputProducer_, UnskimmedSuperCluster); Handle L1IsoSuperCluster; evt.getByToken(alreadyExistingSC_, L1IsoSuperCluster); // Create a pointer to the existing SuperClusters - const reco::SuperClusterCollection *UnskimmedL1NonIsoSC = UnskimmedSuperCluster.product(); - const reco::SuperClusterCollection *L1IsoSC = L1IsoSuperCluster.product(); - + const reco::SuperClusterCollection* UnskimmedL1NonIsoSC = UnskimmedSuperCluster.product(); + const reco::SuperClusterCollection* L1IsoSC = L1IsoSuperCluster.product(); // Define a collection of corrected SuperClusters to put back into the event auto corrClusters = std::make_unique(); - + // Loop over raw clusters and make corrected ones reco::SuperClusterCollection::const_iterator aClus; reco::SuperClusterCollection::const_iterator cit; - for(aClus = UnskimmedL1NonIsoSC->begin(); aClus != UnskimmedL1NonIsoSC->end(); aClus++) - { - bool AlreadyThere = false; - //reco::SuperCluster newClus; - for(cit = L1IsoSC->begin(); cit != L1IsoSC->end(); cit++){ - if( fabs(aClus->energy()- cit->energy()) < 0.5 && fabs(aClus->eta()- cit->eta()) < 0.0175 ){ - float deltaphi=fabs( aClus->phi() - cit->phi() ); - if(deltaphi>6.283185308) deltaphi -= 6.283185308; - if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi; - - if( deltaphi < 0.035 ){AlreadyThere = true; break;} - } + for (aClus = UnskimmedL1NonIsoSC->begin(); aClus != UnskimmedL1NonIsoSC->end(); aClus++) { + bool AlreadyThere = false; + //reco::SuperCluster newClus; + for (cit = L1IsoSC->begin(); cit != L1IsoSC->end(); cit++) { + if (fabs(aClus->energy() - cit->energy()) < 0.5 && fabs(aClus->eta() - cit->eta()) < 0.0175) { + float deltaphi = fabs(aClus->phi() - cit->phi()); + if (deltaphi > 6.283185308) + deltaphi -= 6.283185308; + if (deltaphi > 3.141592654) + deltaphi = 6.283185308 - deltaphi; + + if (deltaphi < 0.035) { + AlreadyThere = true; + break; + } } - // if(AlreadyThere){std::cout<<"AAAA: SC removed: "<energy()<<" "<eta()<<" "<phi()<push_back(*aClus);} } + // if(AlreadyThere){std::cout<<"AAAA: SC removed: "<energy()<<" "<eta()<<" "<phi()<push_back(*aClus); + } + } // Put collection of corrected SuperClusters into the event evt.put(std::move(corrClusters), outputCollection_); - } - - - diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTTimeCleanedRechitProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTTimeCleanedRechitProducer.cc index c4de2bd1d13d5..df288b7862a70 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTTimeCleanedRechitProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTTimeCleanedRechitProducer.cc @@ -19,25 +19,27 @@ #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTTimeCleanedRechitProducer.h" EgammaHLTTimeCleanedRechitProducer::EgammaHLTTimeCleanedRechitProducer(const edm::ParameterSet& ps) { - timeMax_ = ps.getParameter("TimeMax"); timeMin_ = ps.getParameter("TimeMin"); - hitLabels = ps.getParameter>("ecalhitLabels"); + hitLabels = ps.getParameter>("ecalhitLabels"); productLabels = ps.getParameter>("productLabels"); - if (!(hitLabels.size() == 2)) throw cms::Exception("ConfigError","ecalhitLabels should contain 2 labels: one for RecHits in barrel, the other for RecHits in endcaps"); - if (!(productLabels.size() == 2)) throw cms::Exception("ConfigError","productLabels should contain 2 labels: one for RecHits in barrel, the other for RecHits in endcaps"); + if (!(hitLabels.size() == 2)) + throw cms::Exception( + "ConfigError", + "ecalhitLabels should contain 2 labels: one for RecHits in barrel, the other for RecHits in endcaps"); + if (!(productLabels.size() == 2)) + throw cms::Exception( + "ConfigError", + "productLabels should contain 2 labels: one for RecHits in barrel, the other for RecHits in endcaps"); - - for (unsigned int i=0; i(hitLabels[i])); - produces (productLabels[i]); + produces(productLabels[i]); } } - -EgammaHLTTimeCleanedRechitProducer::~EgammaHLTTimeCleanedRechitProducer() -{} +EgammaHLTTimeCleanedRechitProducer::~EgammaHLTTimeCleanedRechitProducer() {} void EgammaHLTTimeCleanedRechitProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -55,27 +57,25 @@ void EgammaHLTTimeCleanedRechitProducer::fillDescriptions(edm::ConfigurationDesc } void EgammaHLTTimeCleanedRechitProducer::produce(edm::StreamID sid, edm::Event& evt, const edm::EventSetup& es) const { - edm::Handle rhcH[2]; - - for (unsigned int i=0; i(); - - evt.getByToken(hitTokens[i], rhcH[i]); + + evt.getByToken(hitTokens[i], rhcH[i]); if (!(rhcH[i].isValid())) { - edm::LogError("ProductNotFound")<< "could not get a handle on the EcalRecHitCollection! (" << hitLabels[i].encode() << ")" << std::endl; + edm::LogError("ProductNotFound") << "could not get a handle on the EcalRecHitCollection! (" + << hitLabels[i].encode() << ")" << std::endl; return; } const EcalRecHitCollection* recHits = rhcH[i].product(); - - EcalRecHitCollection::const_iterator it; - for (it = recHits->begin(); it != recHits->end(); it++){ + + EcalRecHitCollection::const_iterator it; + for (it = recHits->begin(); it != recHits->end(); it++) { if (((*it).time() < timeMax_) && ((*it).time() > timeMin_)) - hits->push_back(*it); + hits->push_back(*it); } - + evt.put(std::move(hits), productLabels[i]); } } - diff --git a/RecoEgamma/EgammaHLTProducers/src/HLTCaloObjInRegionsProducer.cc b/RecoEgamma/EgammaHLTProducers/src/HLTCaloObjInRegionsProducer.cc index 47962c608af9d..cdfefad2c3821 100644 --- a/RecoEgamma/EgammaHLTProducers/src/HLTCaloObjInRegionsProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/HLTCaloObjInRegionsProducer.cc @@ -6,23 +6,22 @@ using HLTHcalDigisInRegionsProducer = HLTCaloObjInRegionsProducer; DEFINE_FWK_MODULE(HLTHcalDigisInRegionsProducer); - #include "DataFormats/HcalDigi/interface/QIE11DataFrame.h" #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" -using HLTHcalQIE11DigisInRegionsProducer = HLTCaloObjInRegionsProducer; +using HLTHcalQIE11DigisInRegionsProducer = HLTCaloObjInRegionsProducer; DEFINE_FWK_MODULE(HLTHcalQIE11DigisInRegionsProducer); #include "DataFormats/HcalDigi/interface/QIE10DataFrame.h" #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" -using HLTHcalQIE10DigisInRegionsProducer = HLTCaloObjInRegionsProducer; +using HLTHcalQIE10DigisInRegionsProducer = HLTCaloObjInRegionsProducer; DEFINE_FWK_MODULE(HLTHcalQIE10DigisInRegionsProducer); #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" -using HLTEcalEBDigisInRegionsProducer = HLTCaloObjInRegionsProducer; +using HLTEcalEBDigisInRegionsProducer = HLTCaloObjInRegionsProducer; DEFINE_FWK_MODULE(HLTEcalEBDigisInRegionsProducer); -using HLTEcalEEDigisInRegionsProducer = HLTCaloObjInRegionsProducer; +using HLTEcalEEDigisInRegionsProducer = HLTCaloObjInRegionsProducer; DEFINE_FWK_MODULE(HLTEcalEEDigisInRegionsProducer); -using HLTEcalESDigisInRegionsProducer = HLTCaloObjInRegionsProducer; +using HLTEcalESDigisInRegionsProducer = HLTCaloObjInRegionsProducer; DEFINE_FWK_MODULE(HLTEcalESDigisInRegionsProducer); //these two classes are intended to ultimately replace the EcalRecHit and EcalUncalibratedRecHit diff --git a/RecoEgamma/EgammaHLTProducers/src/HLTEcalPFClusterIsolationProducer.cc b/RecoEgamma/EgammaHLTProducers/src/HLTEcalPFClusterIsolationProducer.cc index 746571a7ed0f8..5c08988a7e0c5 100644 --- a/RecoEgamma/EgammaHLTProducers/src/HLTEcalPFClusterIsolationProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/HLTEcalPFClusterIsolationProducer.cc @@ -25,23 +25,22 @@ #include "RecoEgamma/EgammaIsolationAlgos/interface/EcalPFClusterIsolation.h" #include "HLTrigger/HLTcore/interface/defaultModuleLabel.h" -template -HLTEcalPFClusterIsolationProducer::HLTEcalPFClusterIsolationProducer(const edm::ParameterSet& config): - pfClusterProducer_ (consumes(config.getParameter("pfClusterProducer"))), - rhoProducer_ (consumes(config.getParameter("rhoProducer"))), - drMax_ (config.getParameter("drMax")), - drVetoBarrel_ (config.getParameter("drVetoBarrel")), - drVetoEndcap_ (config.getParameter("drVetoEndcap")), - etaStripBarrel_ (config.getParameter("etaStripBarrel")), - etaStripEndcap_ (config.getParameter("etaStripEndcap")), - energyBarrel_ (config.getParameter("energyBarrel")), - energyEndcap_ (config.getParameter("energyEndcap")), - doRhoCorrection_ (config.getParameter("doRhoCorrection")), - rhoMax_ (config.getParameter("rhoMax")), - rhoScale_ (config.getParameter("rhoScale")), - effectiveAreas_ (config.getParameter >("effectiveAreas")), - absEtaLowEdges_ (config.getParameter >("absEtaLowEdges")) { - +template +HLTEcalPFClusterIsolationProducer::HLTEcalPFClusterIsolationProducer(const edm::ParameterSet& config) + : pfClusterProducer_(consumes(config.getParameter("pfClusterProducer"))), + rhoProducer_(consumes(config.getParameter("rhoProducer"))), + drMax_(config.getParameter("drMax")), + drVetoBarrel_(config.getParameter("drVetoBarrel")), + drVetoEndcap_(config.getParameter("drVetoEndcap")), + etaStripBarrel_(config.getParameter("etaStripBarrel")), + etaStripEndcap_(config.getParameter("etaStripEndcap")), + energyBarrel_(config.getParameter("energyBarrel")), + energyEndcap_(config.getParameter("energyEndcap")), + doRhoCorrection_(config.getParameter("doRhoCorrection")), + rhoMax_(config.getParameter("rhoMax")), + rhoScale_(config.getParameter("rhoScale")), + effectiveAreas_(config.getParameter>("effectiveAreas")), + absEtaLowEdges_(config.getParameter>("absEtaLowEdges")) { if (doRhoCorrection_) { if (absEtaLowEdges_.size() != effectiveAreas_.size()) throw cms::Exception("IncompatibleVects") << "absEtaLowEdges and effectiveAreas should be of the same size. \n"; @@ -50,36 +49,37 @@ HLTEcalPFClusterIsolationProducer::HLTEcalPFClusterIsolationProducer(const e throw cms::Exception("IncompleteCoverage") << "absEtaLowEdges should start from 0. \n"; for (unsigned int aIt = 0; aIt < absEtaLowEdges_.size() - 1; aIt++) { - if ( !(absEtaLowEdges_.at( aIt ) < absEtaLowEdges_.at( aIt + 1 )) ) + if (!(absEtaLowEdges_.at(aIt) < absEtaLowEdges_.at(aIt + 1))) throw cms::Exception("ImproperBinning") << "absEtaLowEdges entries should be in increasing order. \n"; } } std::string recoCandidateProducerName = "recoCandidateProducer"; - if ((typeid(HLTEcalPFClusterIsolationProducer) == typeid(HLTEcalPFClusterIsolationProducer))) recoCandidateProducerName = "recoEcalCandidateProducer"; - - recoCandidateProducer_ = consumes(config.getParameter(recoCandidateProducerName)); - produces (); + if ((typeid(HLTEcalPFClusterIsolationProducer) == + typeid(HLTEcalPFClusterIsolationProducer))) + recoCandidateProducerName = "recoEcalCandidateProducer"; + recoCandidateProducer_ = consumes(config.getParameter(recoCandidateProducerName)); + produces(); } -template -HLTEcalPFClusterIsolationProducer::~HLTEcalPFClusterIsolationProducer() -{} +template +HLTEcalPFClusterIsolationProducer::~HLTEcalPFClusterIsolationProducer() {} -template +template void HLTEcalPFClusterIsolationProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - std::string recoCandidateProducerName = "recoCandidateProducer"; - if ((typeid(HLTEcalPFClusterIsolationProducer) == typeid(HLTEcalPFClusterIsolationProducer))) recoCandidateProducerName = "recoEcalCandidateProducer"; - + if ((typeid(HLTEcalPFClusterIsolationProducer) == + typeid(HLTEcalPFClusterIsolationProducer))) + recoCandidateProducerName = "recoEcalCandidateProducer"; + edm::ParameterSetDescription desc; desc.add(recoCandidateProducerName, edm::InputTag("hltL1SeededRecoEcalCandidatePF")); - desc.add("pfClusterProducer", edm::InputTag("hltParticleFlowClusterECAL")); + desc.add("pfClusterProducer", edm::InputTag("hltParticleFlowClusterECAL")); desc.add("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo")); desc.add("doRhoCorrection", false); - desc.add("rhoMax", 9.9999999E7); - desc.add("rhoScale", 1.0); + desc.add("rhoMax", 9.9999999E7); + desc.add("rhoScale", 1.0); desc.add("drMax", 0.3); desc.add("drVetoBarrel", 0.0); desc.add("drVetoEndcap", 0.0); @@ -87,14 +87,13 @@ void HLTEcalPFClusterIsolationProducer::fillDescriptions(edm::ConfigurationD desc.add("etaStripEndcap", 0.0); desc.add("energyBarrel", 0.0); desc.add("energyEndcap", 0.0); - desc.add >("effectiveAreas", {0.29, 0.21}); // 2016 post-ichep sinEle default - desc.add >("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap + desc.add>("effectiveAreas", {0.29, 0.21}); // 2016 post-ichep sinEle default + desc.add>("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap descriptions.add(defaultModuleLabel>(), desc); } -template +template void HLTEcalPFClusterIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { - edm::Handle rhoHandle; double rho = 0.0; if (doRhoCorrection_) { @@ -104,39 +103,40 @@ void HLTEcalPFClusterIsolationProducer::produce(edm::Event& iEvent, const ed if (rho > rhoMax_) rho = rhoMax_; - - rho = rho*rhoScale_; + + rho = rho * rhoScale_; edm::Handle recoCandHandle; edm::Handle clusterHandle; - iEvent.getByToken(recoCandidateProducer_,recoCandHandle); + iEvent.getByToken(recoCandidateProducer_, recoCandHandle); iEvent.getByToken(pfClusterProducer_, clusterHandle); - EcalPFClusterIsolation isoAlgo(drMax_, drVetoBarrel_, drVetoEndcap_, etaStripBarrel_, etaStripEndcap_, energyBarrel_, energyEndcap_); + EcalPFClusterIsolation isoAlgo( + drMax_, drVetoBarrel_, drVetoEndcap_, etaStripBarrel_, etaStripEndcap_, energyBarrel_, energyEndcap_); T1IsolationMap recoCandMap(recoCandHandle); - + for (unsigned int iReco = 0; iReco < recoCandHandle->size(); iReco++) { T1Ref candRef(recoCandHandle, iReco); - + float sum = isoAlgo.getSum(candRef, clusterHandle); if (doRhoCorrection_) { int iEA = -1; auto cEta = std::abs(candRef->eta()); for (int bIt = absEtaLowEdges_.size() - 1; bIt > -1; bIt--) { - if ( cEta > absEtaLowEdges_.at(bIt) ) { + if (cEta > absEtaLowEdges_.at(bIt)) { iEA = bIt; break; } } - sum = sum - rho*effectiveAreas_.at(iEA); + sum = sum - rho * effectiveAreas_.at(iEA); } recoCandMap.insert(candRef, sum); } - + iEvent.put(std::make_unique(recoCandMap)); } diff --git a/RecoEgamma/EgammaHLTProducers/src/HLTHcalPFClusterIsolationProducer.cc b/RecoEgamma/EgammaHLTProducers/src/HLTHcalPFClusterIsolationProducer.cc index 38de74a9d3a3c..1188899a08d1c 100644 --- a/RecoEgamma/EgammaHLTProducers/src/HLTHcalPFClusterIsolationProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/HLTHcalPFClusterIsolationProducer.cc @@ -17,27 +17,29 @@ #include "RecoEgamma/EgammaIsolationAlgos/interface/HcalPFClusterIsolation.h" #include "HLTrigger/HLTcore/interface/defaultModuleLabel.h" -template -HLTHcalPFClusterIsolationProducer::HLTHcalPFClusterIsolationProducer(const edm::ParameterSet& config) : - pfClusterProducerHCAL_ ( consumes(config.getParameter("pfClusterProducerHCAL"))), - rhoProducer_ ( consumes(config.getParameter("rhoProducer"))), - pfClusterProducerHFEM_ ( consumes(config.getParameter("pfClusterProducerHFEM"))), - pfClusterProducerHFHAD_ ( consumes(config.getParameter("pfClusterProducerHFHAD"))), - useHF_ ( config.getParameter("useHF")), - drMax_ ( config.getParameter("drMax")), - drVetoBarrel_ ( config.getParameter("drVetoBarrel")), - drVetoEndcap_ ( config.getParameter("drVetoEndcap")), - etaStripBarrel_ ( config.getParameter("etaStripBarrel")), - etaStripEndcap_ ( config.getParameter("etaStripEndcap")), - energyBarrel_ ( config.getParameter("energyBarrel")), - energyEndcap_ ( config.getParameter("energyEndcap")), - useEt_ ( config.getParameter("useEt")), - doRhoCorrection_ ( config.getParameter("doRhoCorrection")), - rhoMax_ ( config.getParameter("rhoMax")), - rhoScale_ ( config.getParameter("rhoScale")), - effectiveAreas_ ( config.getParameter >("effectiveAreas")) , - absEtaLowEdges_ ( config.getParameter >("absEtaLowEdges")) { - +template +HLTHcalPFClusterIsolationProducer::HLTHcalPFClusterIsolationProducer(const edm::ParameterSet& config) + : pfClusterProducerHCAL_( + consumes(config.getParameter("pfClusterProducerHCAL"))), + rhoProducer_(consumes(config.getParameter("rhoProducer"))), + pfClusterProducerHFEM_( + consumes(config.getParameter("pfClusterProducerHFEM"))), + pfClusterProducerHFHAD_( + consumes(config.getParameter("pfClusterProducerHFHAD"))), + useHF_(config.getParameter("useHF")), + drMax_(config.getParameter("drMax")), + drVetoBarrel_(config.getParameter("drVetoBarrel")), + drVetoEndcap_(config.getParameter("drVetoEndcap")), + etaStripBarrel_(config.getParameter("etaStripBarrel")), + etaStripEndcap_(config.getParameter("etaStripEndcap")), + energyBarrel_(config.getParameter("energyBarrel")), + energyEndcap_(config.getParameter("energyEndcap")), + useEt_(config.getParameter("useEt")), + doRhoCorrection_(config.getParameter("doRhoCorrection")), + rhoMax_(config.getParameter("rhoMax")), + rhoScale_(config.getParameter("rhoScale")), + effectiveAreas_(config.getParameter>("effectiveAreas")), + absEtaLowEdges_(config.getParameter>("absEtaLowEdges")) { if (doRhoCorrection_) { if (absEtaLowEdges_.size() != effectiveAreas_.size()) throw cms::Exception("IncompatibleVects") << "absEtaLowEdges and effectiveAreas should be of the same size. \n"; @@ -46,40 +48,45 @@ HLTHcalPFClusterIsolationProducer::HLTHcalPFClusterIsolationProducer(const e throw cms::Exception("IncompleteCoverage") << "absEtaLowEdges should start from 0. \n"; for (unsigned int aIt = 0; aIt < absEtaLowEdges_.size() - 1; aIt++) { - if ( !(absEtaLowEdges_.at( aIt ) < absEtaLowEdges_.at( aIt + 1 )) ) + if (!(absEtaLowEdges_.at(aIt) < absEtaLowEdges_.at(aIt + 1))) throw cms::Exception("ImproperBinning") << "absEtaLowEdges entries should be in increasing order. \n"; } } - + std::string recoCandidateProducerName = "recoCandidateProducer"; - if ((typeid(HLTHcalPFClusterIsolationProducer) == typeid(HLTHcalPFClusterIsolationProducer))) recoCandidateProducerName = "recoEcalCandidateProducer"; + if ((typeid(HLTHcalPFClusterIsolationProducer) == + typeid(HLTHcalPFClusterIsolationProducer))) + recoCandidateProducerName = "recoEcalCandidateProducer"; recoCandidateProducer_ = consumes(config.getParameter(recoCandidateProducerName)); - - produces (); + + produces(); } -template -HLTHcalPFClusterIsolationProducer::~HLTHcalPFClusterIsolationProducer() -{} +template +HLTHcalPFClusterIsolationProducer::~HLTHcalPFClusterIsolationProducer() {} -template +template void HLTHcalPFClusterIsolationProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - std::string recoCandidateProducerName = "recoCandidateProducer"; - if ((typeid(HLTHcalPFClusterIsolationProducer) == typeid(HLTHcalPFClusterIsolationProducer))) recoCandidateProducerName = "recoEcalCandidateProducer"; + if ((typeid(HLTHcalPFClusterIsolationProducer) == + typeid(HLTHcalPFClusterIsolationProducer))) + recoCandidateProducerName = "recoEcalCandidateProducer"; edm::ParameterSetDescription desc; desc.add(recoCandidateProducerName, edm::InputTag("hltL1SeededRecoEcalCandidatePF")); desc.add("pfClusterProducerHCAL", edm::InputTag("hltParticleFlowClusterHCAL")); - desc.ifValue(edm::ParameterDescription("useHF", false, true), - true >> (edm::ParameterDescription("pfClusterProducerHFEM", edm::InputTag("hltParticleFlowClusterHFEM"), true) and - edm::ParameterDescription("pfClusterProducerHFHAD", edm::InputTag("hltParticleFlowClusterHFHAD"), true)) or - false >> (edm::ParameterDescription("pfClusterProducerHFEM", edm::InputTag(""), true) and - edm::ParameterDescription("pfClusterProducerHFHAD", edm::InputTag(""), true))); + desc.ifValue( + edm::ParameterDescription("useHF", false, true), + true >> (edm::ParameterDescription( + "pfClusterProducerHFEM", edm::InputTag("hltParticleFlowClusterHFEM"), true) and + edm::ParameterDescription( + "pfClusterProducerHFHAD", edm::InputTag("hltParticleFlowClusterHFHAD"), true)) or + false >> (edm::ParameterDescription("pfClusterProducerHFEM", edm::InputTag(""), true) and + edm::ParameterDescription("pfClusterProducerHFHAD", edm::InputTag(""), true))); desc.add("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo")); desc.add("doRhoCorrection", false); - desc.add("rhoMax", 9.9999999E7); - desc.add("rhoScale", 1.0); + desc.add("rhoMax", 9.9999999E7); + desc.add("rhoScale", 1.0); desc.add("drMax", 0.3); desc.add("drVetoBarrel", 0.0); desc.add("drVetoEndcap", 0.0); @@ -88,34 +95,35 @@ void HLTHcalPFClusterIsolationProducer::fillDescriptions(edm::ConfigurationD desc.add("energyBarrel", 0.0); desc.add("energyEndcap", 0.0); desc.add("useEt", true); - desc.add >("effectiveAreas", {0.2, 0.25}); // 2016 post-ichep sinEle default - desc.add >("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap + desc.add>("effectiveAreas", {0.2, 0.25}); // 2016 post-ichep sinEle default + desc.add>("absEtaLowEdges", {0.0, 1.479}); // Barrel, Endcap descriptions.add(defaultModuleLabel>(), desc); } -template -void HLTHcalPFClusterIsolationProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - +template +void HLTHcalPFClusterIsolationProducer::produce(edm::StreamID sid, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { edm::Handle rhoHandle; double rho = 0.0; if (doRhoCorrection_) { iEvent.getByToken(rhoProducer_, rhoHandle); rho = *(rhoHandle.product()); } - + if (rho > rhoMax_) rho = rhoMax_; - - rho = rho*rhoScale_; + + rho = rho * rhoScale_; edm::Handle recoCandHandle; - std::vector> clusterHandles; + std::vector> clusterHandles; edm::Handle clusterHcalHandle; edm::Handle clusterHfemHandle; edm::Handle clusterHfhadHandle; - iEvent.getByToken(recoCandidateProducer_,recoCandHandle); + iEvent.getByToken(recoCandidateProducer_, recoCandHandle); iEvent.getByToken(pfClusterProducerHCAL_, clusterHcalHandle); //const reco::PFClusterCollection* forIsolationHcal = clusterHcalHandle.product(); clusterHandles.push_back(clusterHcalHandle); @@ -128,29 +136,30 @@ void HLTHcalPFClusterIsolationProducer::produce(edm::StreamID sid, edm::Even } T1IsolationMap recoCandMap(recoCandHandle); - HcalPFClusterIsolation isoAlgo(drMax_, drVetoBarrel_, drVetoEndcap_, etaStripBarrel_, etaStripEndcap_, energyBarrel_, energyEndcap_, useEt_); - + HcalPFClusterIsolation isoAlgo( + drMax_, drVetoBarrel_, drVetoEndcap_, etaStripBarrel_, etaStripEndcap_, energyBarrel_, energyEndcap_, useEt_); + for (unsigned int iReco = 0; iReco < recoCandHandle->size(); iReco++) { T1Ref candRef(recoCandHandle, iReco); - + float sum = isoAlgo.getSum(candRef, clusterHandles); - + if (doRhoCorrection_) { int iEA = -1; auto cEta = std::abs(candRef->eta()); for (int bIt = absEtaLowEdges_.size() - 1; bIt > -1; bIt--) { - if ( cEta > absEtaLowEdges_.at(bIt) ) { + if (cEta > absEtaLowEdges_.at(bIt)) { iEA = bIt; break; } } - sum = sum - rho*effectiveAreas_.at(iEA); + sum = sum - rho * effectiveAreas_.at(iEA); } recoCandMap.insert(candRef, sum); } - + iEvent.put(std::make_unique(recoCandMap)); } diff --git a/RecoEgamma/EgammaHLTProducers/src/HLTRechitInRegionsProducer.cc b/RecoEgamma/EgammaHLTProducers/src/HLTRechitInRegionsProducer.cc index 3049b789267ee..299e2de1bf5dc 100644 --- a/RecoEgamma/EgammaHLTProducers/src/HLTRechitInRegionsProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/HLTRechitInRegionsProducer.cc @@ -38,38 +38,37 @@ // Class header file #include "RecoEgamma/EgammaHLTProducers/interface/HLTRechitInRegionsProducer.h" -template -HLTRechitInRegionsProducer::HLTRechitInRegionsProducer(const edm::ParameterSet& ps): - useUncalib_ (ps.getParameter("useUncalib")), - doIsolated_ (ps.getParameter("doIsolated")), - l1TokenIsolated_ (doIsolated_ ? consumes(ps.getParameter("l1TagIsolated")) : edm::EDGetTokenT()), - l1TokenNonIsolated_(consumes(ps.getParameter("l1TagNonIsolated"))), - l1LowerThr_ (ps.getParameter ("l1LowerThr")), - l1UpperThr_ (ps.getParameter ("l1UpperThr")), - l1LowerThrIgnoreIsolation_(ps.getParameter ("l1LowerThrIgnoreIsolation")), - regionEtaMargin_(ps.getParameter("regionEtaMargin")), - regionPhiMargin_(ps.getParameter("regionPhiMargin")), - hitLabels (ps.getParameter>("ecalhitLabels")), - productLabels(ps.getParameter>("productLabels")) { - +template +HLTRechitInRegionsProducer::HLTRechitInRegionsProducer(const edm::ParameterSet& ps) + : useUncalib_(ps.getParameter("useUncalib")), + doIsolated_(ps.getParameter("doIsolated")), + l1TokenIsolated_(doIsolated_ ? consumes(ps.getParameter("l1TagIsolated")) + : edm::EDGetTokenT()), + l1TokenNonIsolated_(consumes(ps.getParameter("l1TagNonIsolated"))), + l1LowerThr_(ps.getParameter("l1LowerThr")), + l1UpperThr_(ps.getParameter("l1UpperThr")), + l1LowerThrIgnoreIsolation_(ps.getParameter("l1LowerThrIgnoreIsolation")), + regionEtaMargin_(ps.getParameter("regionEtaMargin")), + regionPhiMargin_(ps.getParameter("regionPhiMargin")), + hitLabels(ps.getParameter>("ecalhitLabels")), + productLabels(ps.getParameter>("productLabels")) { if (useUncalib_) { - for (unsigned int i=0; i(hitLabels[i])); produces(productLabels[i]); } } else { - for (unsigned int i=0; i(hitLabels[i])); - produces (productLabels[i]); + produces(productLabels[i]); } } } -template -HLTRechitInRegionsProducer::~HLTRechitInRegionsProducer() -{} +template +HLTRechitInRegionsProducer::~HLTRechitInRegionsProducer() {} -template +template void HLTRechitInRegionsProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; std::vector productTags; @@ -81,8 +80,8 @@ void HLTRechitInRegionsProducer::fillDescriptions(edm::ConfigurationDescript inputTags.push_back(edm::InputTag("hltEcalRegionalEgammaRecHit:EcalRecHitsEE")); inputTags.push_back(edm::InputTag("hltESRegionalEgammaRecHit:EcalRecHitsES")); desc.add>("ecalhitLabels", inputTags); - desc.add("l1TagIsolated", edm::InputTag("l1extraParticles","Isolated")); - desc.add("l1TagNonIsolated", edm::InputTag("l1extraParticles","NonIsolated")); + desc.add("l1TagIsolated", edm::InputTag("l1extraParticles", "Isolated")); + desc.add("l1TagNonIsolated", edm::InputTag("l1extraParticles", "NonIsolated")); desc.add("useUncalib", true); desc.add("doIsolated", true); desc.add("l1LowerThr", 5.0); @@ -90,177 +89,181 @@ void HLTRechitInRegionsProducer::fillDescriptions(edm::ConfigurationDescript desc.add("l1LowerThrIgnoreIsolation", 0.0); desc.add("regionEtaMargin", 0.14); desc.add("regionPhiMargin", 0.4); - descriptions.add(defaultModuleLabel>(), desc); + descriptions.add(defaultModuleLabel>(), desc); } -template +template void HLTRechitInRegionsProducer::produce(edm::Event& evt, const edm::EventSetup& es) { - // get the collection geometry: edm::ESHandle geoHandle; es.get().get(geoHandle); const CaloGeometry& geometry = *geoHandle; - const CaloSubdetectorGeometry *geometry_p; + const CaloSubdetectorGeometry* geometry_p; std::unique_ptr topology; - + //Get the L1 EM Particle Collection - edm::Handle< T1Collection > emIsolColl ; - if(doIsolated_) { + edm::Handle emIsolColl; + if (doIsolated_) { evt.getByToken(l1TokenIsolated_, emIsolColl); } //Get the L1 EM Particle Collection - edm::Handle< T1Collection > emNonIsolColl ; + edm::Handle emNonIsolColl; evt.getByToken(l1TokenNonIsolated_, emNonIsolColl); - + // Get the CaloGeometry - edm::ESHandle l1CaloGeom ; - es.get().get(l1CaloGeom) ; + edm::ESHandle l1CaloGeom; + es.get().get(l1CaloGeom); std::vector regions; - if(doIsolated_) getEtaPhiRegions(®ions, *emIsolColl, *l1CaloGeom, true); - - if(!doIsolated_ or (l1LowerThrIgnoreIsolation_ < 64)) getEtaPhiRegions(®ions, *emNonIsolColl, *l1CaloGeom, false); + if (doIsolated_) + getEtaPhiRegions(®ions, *emIsolColl, *l1CaloGeom, true); + if (!doIsolated_ or (l1LowerThrIgnoreIsolation_ < 64)) + getEtaPhiRegions(®ions, *emNonIsolColl, *l1CaloGeom, false); if (useUncalib_) { - edm::Handle urhcH[3]; - for (unsigned int i=0; i(); - - evt.getByToken(uncalibHitTokens[i], urhcH[i]); + + evt.getByToken(uncalibHitTokens[i], urhcH[i]); if (!(urhcH[i].isValid())) { - edm::LogError("ProductNotFound")<< "could not get a handle on the EcalRecHitCollection! (" << hitLabels[i].encode() << ")" << std::endl; - return; + edm::LogError("ProductNotFound") << "could not get a handle on the EcalRecHitCollection! (" + << hitLabels[i].encode() << ")" << std::endl; + return; } const EcalUncalibratedRecHitCollection* uncalibRecHits = urhcH[i].product(); - + if (!uncalibRecHits->empty()) { - if ((*uncalibRecHits)[0].id().subdetId() == EcalBarrel) { - geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel); - topology = std::make_unique(*geoHandle); - } else if ((*uncalibRecHits)[0].id().subdetId() == EcalEndcap) { - geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap); - topology = std::make_unique(*geoHandle); - } else if ((*uncalibRecHits)[0].id().subdetId() == EcalPreshower) { - geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower); - topology = std::make_unique(); - } else throw(std::runtime_error("\n\nProducer encountered invalied ecalhitcollection type.\n\n")); - - if(!regions.empty()) { - EcalUncalibratedRecHitCollection::const_iterator it; - - for (it = uncalibRecHits->begin(); it != uncalibRecHits->end(); it++){ - auto this_cell = geometry_p->getGeometry(it->id()); - - std::vector::const_iterator region; - for (region=regions.begin(); region!=regions.end(); region++) { - if (region->inRegion(this_cell->etaPos(),this_cell->phiPos())) { - uhits->push_back(*it); - break; - } - } - } - } + if ((*uncalibRecHits)[0].id().subdetId() == EcalBarrel) { + geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + topology = std::make_unique(*geoHandle); + } else if ((*uncalibRecHits)[0].id().subdetId() == EcalEndcap) { + geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap); + topology = std::make_unique(*geoHandle); + } else if ((*uncalibRecHits)[0].id().subdetId() == EcalPreshower) { + geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower); + topology = std::make_unique(); + } else + throw(std::runtime_error("\n\nProducer encountered invalied ecalhitcollection type.\n\n")); + + if (!regions.empty()) { + EcalUncalibratedRecHitCollection::const_iterator it; + + for (it = uncalibRecHits->begin(); it != uncalibRecHits->end(); it++) { + auto this_cell = geometry_p->getGeometry(it->id()); + + std::vector::const_iterator region; + for (region = regions.begin(); region != regions.end(); region++) { + if (region->inRegion(this_cell->etaPos(), this_cell->phiPos())) { + uhits->push_back(*it); + break; + } + } + } + } } evt.put(std::move(uhits), productLabels[i]); - } } else { - edm::Handle rhcH[3]; - for (unsigned int i=0; i(); - - evt.getByToken(hitTokens[i], rhcH[i]); + + evt.getByToken(hitTokens[i], rhcH[i]); if (!(rhcH[i].isValid())) { - edm::LogError("ProductNotFound")<< "could not get a handle on the EcalRecHitCollection! (" << hitLabels[i].encode() << ")" << std::endl; - return; + edm::LogError("ProductNotFound") << "could not get a handle on the EcalRecHitCollection! (" + << hitLabels[i].encode() << ")" << std::endl; + return; } const EcalRecHitCollection* recHits = rhcH[i].product(); - + if (!recHits->empty()) { - if ((*recHits)[0].id().subdetId() == EcalBarrel) { - geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel); - topology = std::make_unique(*geoHandle); - } else if ((*recHits)[0].id().subdetId() == EcalEndcap) { - geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap); - topology = std::make_unique(*geoHandle); - } else if ((*recHits)[0].id().subdetId() == EcalPreshower) { - geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower); - topology = std::make_unique(); - } else throw(std::runtime_error("\n\nProducer encountered invalied ecalhitcollection type.\n\n")); - - if(!regions.empty()) { - EcalRecHitCollection::const_iterator it; - for (it = recHits->begin(); it != recHits->end(); it++){ - auto this_cell = geometry_p->getGeometry(it->id()); - - std::vector::const_iterator region; - for (region=regions.begin(); region!=regions.end(); region++) { - if (region->inRegion(this_cell->etaPos(),this_cell->phiPos())) { - hits->push_back(*it); - break; - } - } - } - } + if ((*recHits)[0].id().subdetId() == EcalBarrel) { + geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + topology = std::make_unique(*geoHandle); + } else if ((*recHits)[0].id().subdetId() == EcalEndcap) { + geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap); + topology = std::make_unique(*geoHandle); + } else if ((*recHits)[0].id().subdetId() == EcalPreshower) { + geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower); + topology = std::make_unique(); + } else + throw(std::runtime_error("\n\nProducer encountered invalied ecalhitcollection type.\n\n")); + + if (!regions.empty()) { + EcalRecHitCollection::const_iterator it; + for (it = recHits->begin(); it != recHits->end(); it++) { + auto this_cell = geometry_p->getGeometry(it->id()); + + std::vector::const_iterator region; + for (region = regions.begin(); region != regions.end(); region++) { + if (region->inRegion(this_cell->etaPos(), this_cell->phiPos())) { + hits->push_back(*it); + break; + } + } + } + } } evt.put(std::move(hits), productLabels[i]); - } } } -template<> -void HLTRechitInRegionsProducer::getEtaPhiRegions(std::vector * theRegions, T1Collection theCandidateCollection, const L1CaloGeometry& l1CaloGeom, bool isolatedCase){ - for (unsigned int candItr = 0 ; candItr < theCandidateCollection.size(); candItr++){ - l1extra::L1EmParticle emItr = theCandidateCollection.at(candItr); - - if (!isolatedCase){ - if(doIsolated_ and (emItr.et() < l1LowerThrIgnoreIsolation_)) continue; - } - - if ((emItr.et() > l1LowerThr_) and (emItr.et() < l1UpperThr_)) { - - // Access the GCT hardware object corresponding to the L1Extra EM object. - int etaIndex = emItr.gctEmCand()->etaIndex(); - int phiIndex = emItr.gctEmCand()->phiIndex(); - - // Use the L1CaloGeometry to find the eta, phi bin boundaries. - double etaLow = l1CaloGeom.etaBinLowEdge(etaIndex); - double etaHigh = l1CaloGeom.etaBinHighEdge(etaIndex); - double phiLow = l1CaloGeom.emJetPhiBinLowEdge( phiIndex ) ; - double phiHigh = l1CaloGeom.emJetPhiBinHighEdge( phiIndex ) ; - - etaLow -= regionEtaMargin_; - etaHigh += regionEtaMargin_; - phiLow -= regionPhiMargin_; - phiHigh += regionPhiMargin_; - - - - theRegions->push_back(RectangularEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh)); - } +template <> +void HLTRechitInRegionsProducer::getEtaPhiRegions( + std::vector* theRegions, + T1Collection theCandidateCollection, + const L1CaloGeometry& l1CaloGeom, + bool isolatedCase) { + for (unsigned int candItr = 0; candItr < theCandidateCollection.size(); candItr++) { + l1extra::L1EmParticle emItr = theCandidateCollection.at(candItr); + + if (!isolatedCase) { + if (doIsolated_ and (emItr.et() < l1LowerThrIgnoreIsolation_)) + continue; + } + + if ((emItr.et() > l1LowerThr_) and (emItr.et() < l1UpperThr_)) { + // Access the GCT hardware object corresponding to the L1Extra EM object. + int etaIndex = emItr.gctEmCand()->etaIndex(); + int phiIndex = emItr.gctEmCand()->phiIndex(); + + // Use the L1CaloGeometry to find the eta, phi bin boundaries. + double etaLow = l1CaloGeom.etaBinLowEdge(etaIndex); + double etaHigh = l1CaloGeom.etaBinHighEdge(etaIndex); + double phiLow = l1CaloGeom.emJetPhiBinLowEdge(phiIndex); + double phiHigh = l1CaloGeom.emJetPhiBinHighEdge(phiIndex); + + etaLow -= regionEtaMargin_; + etaHigh += regionEtaMargin_; + phiLow -= regionPhiMargin_; + phiHigh += regionPhiMargin_; + + theRegions->push_back(RectangularEtaPhiRegion(etaLow, etaHigh, phiLow, phiHigh)); } + } } -template -void HLTRechitInRegionsProducer::getEtaPhiRegions(std::vector * theRegions, T1Collection theCandidateCollection, const L1CaloGeometry& l1CaloGeom, bool isolatedCase){ - for (unsigned int candItr = 0 ; candItr < theCandidateCollection.size(); candItr++){ - T1 emItr = theCandidateCollection.at(candItr); - if ((emItr.et() > l1LowerThr_) and (emItr.et() < l1UpperThr_)) { - - double etaLow = emItr.eta() - regionEtaMargin_; - double etaHigh = emItr.eta() + regionEtaMargin_; - double phiLow = emItr.phi() - regionPhiMargin_; - double phiHigh = emItr.phi() + regionPhiMargin_; - - theRegions->push_back(RectangularEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh)); - } +template +void HLTRechitInRegionsProducer::getEtaPhiRegions(std::vector* theRegions, + T1Collection theCandidateCollection, + const L1CaloGeometry& l1CaloGeom, + bool isolatedCase) { + for (unsigned int candItr = 0; candItr < theCandidateCollection.size(); candItr++) { + T1 emItr = theCandidateCollection.at(candItr); + if ((emItr.et() > l1LowerThr_) and (emItr.et() < l1UpperThr_)) { + double etaLow = emItr.eta() - regionEtaMargin_; + double etaHigh = emItr.eta() + regionEtaMargin_; + double phiLow = emItr.phi() - regionPhiMargin_; + double phiHigh = emItr.phi() + regionPhiMargin_; + + theRegions->push_back(RectangularEtaPhiRegion(etaLow, etaHigh, phiLow, phiHigh)); } + } } typedef HLTRechitInRegionsProducer EgammaHLTRechitInRegionsProducer; @@ -268,4 +271,3 @@ DEFINE_FWK_MODULE(EgammaHLTRechitInRegionsProducer); typedef HLTRechitInRegionsProducer MuonHLTRechitInRegionsProducer; DEFINE_FWK_MODULE(MuonHLTRechitInRegionsProducer); - diff --git a/RecoEgamma/EgammaHLTProducers/src/SealModules.cc b/RecoEgamma/EgammaHLTProducers/src/SealModules.cc index 9145da59428bd..f5ff72e03bc8a 100644 --- a/RecoEgamma/EgammaHLTProducers/src/SealModules.cc +++ b/RecoEgamma/EgammaHLTProducers/src/SealModules.cc @@ -1,7 +1,6 @@ #include "FWCore/PluginManager/interface/ModuleDef.h" #include "FWCore/Framework/interface/MakerMacros.h" - #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronTrackIsolationProducers.h" #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCombinedIsolationProducer.h" #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronCombinedIsolationProducer.h" @@ -70,12 +69,10 @@ DEFINE_FWK_MODULE(EgammaHLTNxNClusterProducer); DEFINE_FWK_MODULE(EgammaHLTCombinedIsolationProducer); DEFINE_FWK_MODULE(EgammaHLTElectronCombinedIsolationProducer); - DEFINE_FWK_MODULE(EgammaHLTPFPhotonIsolationProducer); DEFINE_FWK_MODULE(EgammaHLTPFChargedIsolationProducer); DEFINE_FWK_MODULE(EgammaHLTPFNeutralIsolationProducer); - DEFINE_FWK_MODULE(EgammaHLTCaloTowerProducer); DEFINE_FWK_MODULE(EgammaHLTTimeCleanedRechitProducer);