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/VertexReco/interface/Vertex.h"
13 #include "DataFormats/VertexReco/interface/VertexFwd.h"
14 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
20 #include "DataFormats/MuonReco/interface/Muon.h"
21 #include "DataFormats/MuonReco/interface/MuonFwd.h"
22 #include "DataFormats/PatCandidates/interface/Muon.h"
23 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
27 : charged_all(pset.getParameter<
edm::InputTag>(
"chargedAll")),
28 charged(pset.getParameter<
edm::InputTag>(
"charged")),
29 neutral(pset.getParameter<
edm::InputTag>(
"neutral")),
30 gamma(pset.getParameter<
edm::InputTag>(
"gamma")),
31 pu(pset.getParameter<
edm::InputTag>(
"pu")) {
32 collector.consumes<edm::ValueMap<double>>(charged_all);
33 collector.consumes<edm::ValueMap<double>>(charged);
34 collector.consumes<edm::ValueMap<double>>(neutral);
35 collector.consumes<edm::ValueMap<double>>(
gamma);
36 collector.consumes<edm::ValueMap<double>>(pu);
40 : input_(config.getParameter<
edm::InputTag>(
"input")),
41 branch_(config.getParameter<
std::string>(
"branch")),
42 is_pf_(config.getParameter<bool>(
"isPF")),
43 input_vertices_(config.getParameter<
edm::InputTag>(
"inputVertices")),
44 do_vertex_ip_(config.getParameter<bool>(
"includeVertexIP")),
45 input_beamspot_(config.getParameter<
edm::InputTag>(
"inputBeamspot")),
46 do_beamspot_ip_(config.getParameter<bool>(
"includeBeamspotIP")),
49 do_pf_iso_03_(config.getParameter<bool>(
"includePFIso03")),
50 do_pf_iso_04_(config.getParameter<bool>(
"includePFIso04")) {
52 consumes<edm::View<reco::PFCandidate>>(input_);
54 consumes<edm::View<reco::Muon>>(input_);
56 consumes<edm::View<reco::Vertex>>(input_vertices_);
57 consumes<reco::BeamSpot>(input_beamspot_);
58 muons_ =
new std::vector<ic::Muon>();
60 edm::ParameterSet pset_floats =
61 config.getParameter<edm::ParameterSet>(
"includeFloats");
62 std::vector<std::string> vec =
63 pset_floats.getParameterNamesForType<edm::InputTag>();
64 for (
unsigned i = 0; i < vec.size(); ++i) {
65 input_vmaps_.push_back(std::make_pair(
66 vec[i], pset_floats.getParameter<edm::InputTag>(vec[i])));
67 consumes<edm::ValueMap<float>>(input_vmaps_[i].second);
70 edm::ParameterSet pset_doubles =
71 config.getParameter<edm::ParameterSet>(
"includeDoubles");
72 std::vector<std::string> doubles_vec =
73 pset_doubles.getParameterNamesForType<edm::InputTag>();
74 for (
unsigned i = 0; i < doubles_vec.size(); ++i) {
75 input_double_vmaps_.push_back(std::make_pair(
76 doubles_vec[i], pset_doubles.getParameter<edm::InputTag>(doubles_vec[i])));
77 consumes<edm::ValueMap<double>>(input_double_vmaps_[i].second);
90 void ICMuonProducer::produce(edm::Event& event,
const edm::EventSetup& setup) {
91 edm::Handle<edm::View<reco::Muon> > muons_handle;
92 edm::Handle<edm::View<reco::PFCandidate> > pfs_handle;
95 event.getByLabel(input_, pfs_handle);
96 n_muons = pfs_handle->size();
98 event.getByLabel(input_, muons_handle);
99 n_muons = muons_handle->size();
102 edm::Handle<edm::View<reco::Vertex> > vertices_handle;
103 if (do_vertex_ip_)
event.getByLabel(input_vertices_, vertices_handle);
105 edm::Handle<reco::BeamSpot> beamspot_handle;
106 if (do_beamspot_ip_)
event.getByLabel(input_beamspot_, beamspot_handle);
108 std::vector<edm::Handle<edm::ValueMap<float> > > float_handles(
109 input_vmaps_.size());
110 for (
unsigned i = 0; i < float_handles.size(); ++i) {
111 event.getByLabel(input_vmaps_[i].second, float_handles[i]);
114 std::vector<edm::Handle<edm::ValueMap<double> > > double_handles(
115 input_double_vmaps_.size());
116 for (
unsigned i = 0; i < double_handles.size(); ++i) {
117 event.getByLabel(input_double_vmaps_[i].second, double_handles[i]);
120 edm::Handle<edm::ValueMap<double> > charged_all_03;
121 edm::Handle<edm::ValueMap<double> > charged_03;
122 edm::Handle<edm::ValueMap<double> > neutral_03;
123 edm::Handle<edm::ValueMap<double> > gamma_03;
124 edm::Handle<edm::ValueMap<double> > pu_03;
125 edm::Handle<edm::ValueMap<double> > neutral_pfw_03;
126 edm::Handle<edm::ValueMap<double> > gamma_pfw_03;
128 event.getByLabel(pf_iso_03_.charged_all, charged_all_03);
129 event.getByLabel(pf_iso_03_.charged, charged_03);
130 event.getByLabel(pf_iso_03_.neutral, neutral_03);
131 event.getByLabel(pf_iso_03_.gamma, gamma_03);
132 event.getByLabel(pf_iso_03_.pu, pu_03);
135 edm::Handle<edm::ValueMap<double> > charged_all_04;
136 edm::Handle<edm::ValueMap<double> > charged_04;
137 edm::Handle<edm::ValueMap<double> > neutral_04;
138 edm::Handle<edm::ValueMap<double> > gamma_04;
139 edm::Handle<edm::ValueMap<double> > pu_04;
140 edm::Handle<edm::ValueMap<double> > neutral_pfw_04;
141 edm::Handle<edm::ValueMap<double> > gamma_pfw_04;
143 event.getByLabel(pf_iso_04_.charged_all, charged_all_04);
144 event.getByLabel(pf_iso_04_.charged, charged_04);
145 event.getByLabel(pf_iso_04_.neutral, neutral_04);
146 event.getByLabel(pf_iso_04_.gamma, gamma_04);
147 event.getByLabel(pf_iso_04_.pu, pu_04);
152 muons_->resize(n_muons,
ic::Muon());
154 for (
unsigned i = 0; i < n_muons; ++i) {
157 reco::MuonRef muon_ref;
158 edm::RefToBase<reco::Muon> muon_base_ref;
159 edm::RefToBase<reco::PFCandidate> pf_base_ref;
161 reco::PFCandidate
const& pf_src = pfs_handle->at(i);
162 dest.
set_id(pf_hasher_(&pf_src));
169 muon_ref = pf_src.muonRef();
170 pf_base_ref = pfs_handle->refAt(i);
172 reco::Muon
const& reco_src = muons_handle->at(i);
173 dest.
set_id(muon_hasher_(&reco_src));
174 dest.
set_pt(reco_src.pt());
180 muon_base_ref = muons_handle->refAt(i);
183 reco::Muon
const& src =
184 is_pf_ ? *(pfs_handle->at(i).muonRef()) : *muons_handle->refAt(i);
197 if (src.isGlobalMuon() && src.globalTrack().isNonnull()) {
202 src.globalTrack()->hitPattern().numberOfValidMuonHits());
205 if (src.isTrackerMuon() && src.innerTrack().isNonnull()) {
207 src.innerTrack()->hitPattern().numberOfValidPixelHits());
209 src.innerTrack()->hitPattern().numberOfValidTrackerHits());
211 src.innerTrack()->hitPattern().trackerLayersWithMeasurement());
213 src.innerTrack()->validFraction());
222 for (
unsigned v = 0; v < float_handles.size(); ++v) {
224 dest.
SetIdIso(input_vmaps_[v].first,
225 (*(float_handles[v]))[pf_base_ref]);
227 dest.
SetIdIso(input_vmaps_[v].first,
228 (*(float_handles[v]))[muon_base_ref]);
232 for (
unsigned v = 0; v < double_handles.size(); ++v) {
234 dest.
SetIdIso(input_double_vmaps_[v].first,
235 float((*(double_handles[v]))[pf_base_ref]));
237 dest.
SetIdIso(input_double_vmaps_[v].first,
238 float((*(double_handles[v]))[muon_base_ref]));
274 if (do_vertex_ip_ && vertices_handle->size() > 0 &&
275 src.muonBestTrack().isNonnull()) {
276 reco::Vertex
const& vtx = vertices_handle->at(0);
280 if (do_beamspot_ip_&& src.muonBestTrack().isNonnull()) {
286 void ICMuonProducer::beginJob() {
290 void ICMuonProducer::endJob() {}
void set_vy(double const &y)
The y-coordinate of the ref_point()
void set_is_global(bool const &is_global)
Muon was reconstructed by the global algorithm.
void set_dr04_pfiso_charged_all(float const &dr04_pfiso_charged_all)
PF isolation, using all charged particles in a cone with .
void set_cq_chi2_localposition(float const &cq_chi2_localposition)
for the sta-tk matching of local position
void set_is_calo(bool const &is_calo)
Muon was reconstructed by the calo-muon algorithm.
void set_dr03_ecal_rechit_sum_et(float const &dr03_ecal_rechit_sum_et)
ECAL isolation in a cone with .
void set_phi(double const &phi)
Direct access to .
void set_dxy_beamspot(double const &dxy_beamspot)
Transverse impact parameter of the tracker track with the beamspot.
void set_vz(double const &z)
The z-coordinate of the ref_point()
void set_id(std::size_t const &id)
Unique identifier.
DEFINE_FWK_MODULE(ICMuonProducer)
void set_is_pf(bool const &is_pf)
Muon was reconstructed by the PF algorithm.
void set_dr03_pfiso_gamma(float const &dr03_pfiso_gamma)
PF isolation, using photons in a cone with .
void set_segment_compatibility(float const &segment_compatibility)
Compatibility of segment with global fit.
void set_is_tracker(bool const &is_tracker)
Muon was reconstructed by the tracker-only algorithm.
void set_charge(int const &charge)
Electric charge.
void set_dr03_hcal_tower_sum_et(float const &dr03_hcal_tower_sum_et)
HCAL isolation in a cone with .
void set_vx(double const &x)
The x-coordinate of the ref_point()
void set_is_standalone(bool const &is_standalone)
Muon was reconstructed by the stand-alone algorithm.
void set_it_pixel_hits(int const &it_pixel_hits)
Number of pixel layer hits in the tracker.
void set_dr03_pfiso_neutral(float const &dr03_pfiso_neutral)
PF isolation, using neutral hadrons in a cone with .
void set_gt_valid_muon_hits(int const >_valid_muon_hits)
Number of muon station hits used in the global track fit.
void set_dr04_pfiso_charged(float const &dr04_pfiso_charged)
PF isolation, using charged hadrons in a cone with .
void set_dr03_pfiso_charged(float const &dr03_pfiso_charged)
PF isolation, using charged hadrons in a cone with .
void set_it_tracker_hits(int const &it_tracker_hits)
Number of hits in the tracker.
void set_cq_trk_kink(float const &cq_trk_kink)
Kink position for the tracker stub and global track.
This class stores a subset of the reco::Muon properties which are most commonly used in analysis...
void set_energy(double const &energy)
Direct access to the energy.
void set_dr04_pfiso_pu(float const &dr04_pfiso_pu)
PF isolation, using charged pileup in a cone with .
void set_dr04_pfiso_gamma(float const &dr04_pfiso_gamma)
PF isolation, using photons in a cone with .
ICMuonProducer(const edm::ParameterSet &)
void set_dxy_vertex(double const &dxy_vertex)
Transverse impact parameter of the tracker track with the primary vertex.
void set_dr03_tk_sum_pt(float const &dr03_tk_sum_pt)
Tracker isolation in a cone with .
void SetIdIso(std::string const &name, float const &value)
Add a new entry, overwriting any existing one with the same name.
void set_dr03_pfiso_pu(float const &dr03_pfiso_pu)
PF isolation, using charged pileup in a cone with .
void set_dr04_pfiso_neutral(float const &dr04_pfiso_neutral)
PF isolation, using neutral hadrons in a cone with .
edm::ConsumesCollector consumesCollector()
void set_pt(double const &pt)
Direct access to the .
void set_gt_normalized_chi2(double const >_normalized_chi2)
Normalised of the global track fit.
void set_eta(double const &eta)
Direct access to .
void set_matched_stations(int const &matched_stations)
Number of matched muon station track segments.
void set_dz_vertex(double const &dz_vertex)
Longitudinal impact parameter of the tracker track with primary vertex.
void set_dr03_pfiso_charged_all(float const &dr03_pfiso_charged_all)
PF isolation, using all charged particles in a cone with .
void set_it_valid_fraction(double const &it_valid_fraction)
Fraction of valid inner tracker hits.
void set_it_layers_with_measurement(int const &it_layers_with_measurement)
Number of tracker layers with measurement.