4 #include "FWCore/Framework/interface/Event.h"
5 #include "FWCore/Framework/interface/EventSetup.h"
6 #include "FWCore/Framework/interface/MakerMacros.h"
7 #include "FWCore/ParameterSet/interface/ParameterSet.h"
8 #include "FWCore/Utilities/interface/InputTag.h"
9 #include "DataFormats/Common/interface/Handle.h"
10 #include "DataFormats/Common/interface/View.h"
11 #include "DataFormats/Common/interface/ValueMap.h"
12 #include "DataFormats/EgammaCandidates/interface/Photon.h"
13 #include "DataFormats/PatCandidates/interface/Photon.h"
14 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
15 #include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
20 : charged_all(pset.getParameter<
edm::InputTag>(
"chargedAll")),
21 charged(pset.getParameter<
edm::InputTag>(
"charged")),
22 neutral(pset.getParameter<
edm::InputTag>(
"neutral")),
23 gamma(pset.getParameter<
edm::InputTag>(
"gamma")),
24 pu(pset.getParameter<
edm::InputTag>(
"pu")) {
25 collector.consumes<edm::ValueMap<double>>(charged_all);
26 collector.consumes<edm::ValueMap<double>>(charged);
27 collector.consumes<edm::ValueMap<double>>(neutral);
28 collector.consumes<edm::ValueMap<double>>(
gamma);
29 collector.consumes<edm::ValueMap<double>>(pu);
34 : input_(config.getParameter<
edm::InputTag>(
"input")),
35 branch_(config.getParameter<
std::string>(
"branch")),
37 config.getParameter<
edm::InputTag>(
"inputElectronVeto")),
38 do_electron_veto_(config.getParameter<bool>(
"includeElectronVeto")),
39 do_had_tow_over_em_(config.getParameter<bool>(
"includeHadTowOverEm")),
42 do_pf_iso_03_(config.getParameter<bool>(
"includePFIso03")),
43 do_pf_iso_04_(config.getParameter<bool>(
"includePFIso04")),
44 do_iso_from_pat_(config.getParameter<bool>(
"includeIsoFromPat")) {
48 consumes<edm::View<reco::Photon>>(input_);
49 consumes<edm::View<pat::Photon>>(input_);
55 consumes<edm::ValueMap<bool>>(input_electron_veto_);
56 photons_ =
new std::vector<ic::Photon>();
71 void ICPhotonProducer::produce(edm::Event& event,
72 const edm::EventSetup& setup) {
73 edm::Handle<edm::View<reco::Photon> > photons_handle;
74 event.getByLabel(input_, photons_handle);
75 edm::Handle<edm::View<pat::Photon> > pat_photons_handle;
76 if(do_iso_from_pat_)
event.getByLabel(input_, pat_photons_handle);
78 edm::Handle<edm::ValueMap<bool> > electron_veto_handle;
79 if (do_electron_veto_)
80 event.getByLabel(input_electron_veto_, electron_veto_handle);
82 edm::Handle<edm::ValueMap<double> > charged_all_03;
83 edm::Handle<edm::ValueMap<double> > charged_03;
84 edm::Handle<edm::ValueMap<double> > neutral_03;
85 edm::Handle<edm::ValueMap<double> > gamma_03;
86 edm::Handle<edm::ValueMap<double> > pu_03;
91 if (do_pf_iso_03_&&!do_iso_from_pat_) {
92 event.getByLabel(pf_iso_03_.charged_all, charged_all_03);
93 event.getByLabel(pf_iso_03_.charged, charged_03);
94 event.getByLabel(pf_iso_03_.neutral, neutral_03);
95 event.getByLabel(pf_iso_03_.gamma, gamma_03);
96 event.getByLabel(pf_iso_03_.pu, pu_03);
99 edm::Handle<edm::ValueMap<double> > charged_all_04;
100 edm::Handle<edm::ValueMap<double> > charged_04;
101 edm::Handle<edm::ValueMap<double> > neutral_04;
102 edm::Handle<edm::ValueMap<double> > gamma_04;
103 edm::Handle<edm::ValueMap<double> > pu_04;
104 if (do_pf_iso_04_&&!do_iso_from_pat_) {
105 event.getByLabel(pf_iso_04_.charged_all, charged_all_04);
106 event.getByLabel(pf_iso_04_.charged, charged_04);
107 event.getByLabel(pf_iso_04_.neutral, neutral_04);
108 event.getByLabel(pf_iso_04_.gamma, gamma_04);
109 event.getByLabel(pf_iso_04_.pu, pu_04);
119 photons_->resize(photons_handle->size(),
ic::Photon());
122 for (
unsigned i = 0; i < photons_handle->size(); ++i) {
123 reco::Photon
const& src = photons_handle->at(i);
124 edm::RefToBase<reco::Photon> ref = photons_handle->refAt(i);
127 dest.
set_id(photon_hasher_(&src));
142 if (do_electron_veto_) {
146 if (do_had_tow_over_em_) {
150 if (do_pf_iso_03_&&!do_iso_from_pat_) {
158 if (do_pf_iso_04_&&!do_iso_from_pat_) {
166 if(do_pf_iso_03_&&do_iso_from_pat_&&do_pf_iso_04_){
167 throw cms::Exception(
"FillingTwoIsosFromOnePatIso") <<
"You are trying to fill both the 03 and 04 photon isolation from the single pat isolation values!!";
170 if(do_pf_iso_03_&&do_iso_from_pat_) {
171 pat::Photon
const& patsrc = pat_photons_handle->at(i);
175 #if CMSSW_MAJOR_VERSION >= 7 && CMSSW_MINOR_VERSION >= 0
176 #if CMSSW_MAJOR_VERSION > 7 || (CMSSW_MAJOR_VERSION == 7 && CMSSW_MINOR_VERSION >= 6)
185 if(do_pf_iso_04_&&do_iso_from_pat_) {
186 pat::Photon
const& patsrc = pat_photons_handle->at(i);
190 #if CMSSW_MAJOR_VERSION >= 7 && CMSSW_MINOR_VERSION >= 0
191 #if CMSSW_MAJOR_VERSION > 7 || (CMSSW_MAJOR_VERSION == 7 && CMSSW_MINOR_VERSION >= 6)
210 void ICPhotonProducer::beginJob() {
214 void ICPhotonProducer::endJob() {}
void set_dr03_pfiso_gamma(float const &dr03_pfiso_gamma)
PF isolation, using photons in a cone with .
void set_dr03_pfiso_neutral(float const &dr03_pfiso_neutral)
PF isolation, using neutral hadrons in a cone with .
void set_dr04_pfiso_neutral(float const &dr04_pfiso_neutral)
PF isolation, using neutral hadrons in a cone with .
void set_phi(double const &phi)
Direct access to .
void set_id(std::size_t const &id)
Unique identifier.
void set_charge(int const &charge)
Electric charge.
void set_sigma_IetaIeta(float const &sigma_IetaIeta)
Weighted cluster RMS in the -direction, measured in units of crystals in a 5x5 block centred on the s...
void set_had_tower_over_em(float const &had_tower_over_em)
Hadronic over electromagnetic energy fraction.
void set_dr04_pfiso_charged_all(float const &dr04_pfiso_charged_all)
PF isolation, using all charged particles in a cone with .
void set_dr04_pfiso_gamma(float const &dr04_pfiso_gamma)
PF isolation, using photons in a cone with .
This class stores a subset of the reco::Photon properties which are most commonly used in analysis...
void set_dr04_pfiso_charged(float const &dr04_pfiso_charged)
PF isolation, using charged hadrons in a cone with .
void set_pass_electron_veto(bool const &pass_electron_veto)
True if photon passes the electron veto.
void set_energy(double const &energy)
Direct access to the energy.
ICPhotonProducer(const edm::ParameterSet &)
void set_dr03_pfiso_charged_all(float const &dr03_pfiso_charged_all)
PF isolation, using all charged particles in a cone with .
void set_dr04_pfiso_pu(float const &dr04_pfiso_pu)
PF isolation, using charged pileup in a cone with .
void set_dr03_pfiso_pu(float const &dr03_pfiso_pu)
PF isolation, using charged pileup in a cone with .
DEFINE_FWK_MODULE(ICPhotonProducer)
edm::ConsumesCollector consumesCollector()
void set_pt(double const &pt)
Direct access to the .
void set_eta(double const &eta)
Direct access to .
void set_dr03_pfiso_charged(float const &dr03_pfiso_charged)
PF isolation, using charged hadrons in a cone with .