65 template <
typename Hand,
typename T>
68 const std::vector<T> &
values,
75 : matcher_(iConfig, consumesCollector()),
77 labelL1_(iConfig.getParameter<
std::
string>(
"setL1Label")),
78 labelProp_(iConfig.getParameter<
std::
string>(
"setPropLabel")),
79 writeExtraInfo_(iConfig.getParameter<
bool>(
"writeExtraInfo")),
80 useStage2L1_(iConfig.getParameter<
bool>(
"useStage2L1")),
81 firstBX_(iConfig.getParameter<
int>(
"firstBX")),
82 lastBX_(iConfig.getParameter<
int>(
"lastBX")) {
88 produces<PATPrimitiveCollection>(
"l1muons");
89 produces<PATPrimitiveCollection>(
"propagatedReco");
90 produces<PATTriggerAssociation>(
"propagatedReco");
91 produces<PATTriggerAssociation>();
93 produces<edm::ValueMap<float> >(
"deltaR");
94 produces<edm::ValueMap<float> >(
"deltaPhi");
95 produces<edm::ValueMap<int> >(
"quality");
96 produces<edm::ValueMap<int> >(
"bx");
98 produces<edm::ValueMap<int> >(
"iPhi");
99 produces<edm::ValueMap<int> >(
"tfIndex");
101 produces<edm::ValueMap<int> >(
"isolated");
102 produces<edm::ValueMap<reco::CandidatePtr> >();
103 produces<edm::ValueMap<reco::CandidatePtr> >(
"l1ToReco");
111 matcher_.init(iSetup);
117 std::vector<l1t::Muon> l1ts;
118 std::vector<size_t> bxIdxs;
126 iEvent.getByToken(l1tToken_, l1tBX);
127 l1size = l1tBX->
size();
136 bxIdxs.push_back(l1tBX->
end(ibx) - l1tBX->
begin());
140 l1size =
l1s->size();
145 std::vector<edm::Ptr<reco::Candidate> > l1rawMatches(
reco->size());
147 std::vector<edm::Ptr<reco::Candidate> > whichRecoMatch(l1size);
148 vector<int> propMatches(
reco->size(), -1);
149 vector<int> fullMatches(
reco->size(), -1);
152 vector<int> iPhi(
reco->size(), 0), tfIndex(
reco->size(), -999);
153 for (
int i = 0,
n =
reco->size();
i <
n; ++
i) {
156 int match = useStage2L1_ ? matcher_.match(
mu, l1ts, deltaRs[
i],
deltaPhis[
i], propagated)
160 propMatches[
i] = propOut->size();
162 propOut->back().addFilterLabel(labelProp_);
163 propOut->back().setCharge(
mu.charge());
188 l1Out->back().addFilterLabel(labelL1_);
189 l1Out->back().setCharge(
charge);
198 isolated[
i] =
l1t.hwIso();
200 iPhi[
i] =
l1t.hwPhi();
201 tfIndex[
i] =
l1t.tfMuonIndex();
206 isolated[
i] = gmt.
isol();
217 propFiller.
insert(
reco, propMatches.begin(), propMatches.end());
223 fullFiller.
insert(
reco, fullMatches.begin(), fullMatches.end());
227 if (writeExtraInfo_) {
228 storeExtraInfo(
iEvent,
reco, deltaRs,
"deltaR");
231 storeExtraInfo(
iEvent,
reco, isolated,
"isolated");
233 storeExtraInfo(
iEvent,
reco, l1rawMatches,
"");
235 storeExtraInfo(
iEvent, l1tBX, whichRecoMatch,
"l1ToReco");
236 storeExtraInfo(
iEvent,
reco, tfIndex,
"tfIndex");
239 storeExtraInfo(
iEvent,
l1s, whichRecoMatch,
"l1ToReco");
244 template <
typename Hand,
typename T>
247 const std::vector<T> &
values,
251 unique_ptr<ValueMap<T> > valMap(
new ValueMap<T>());
bool isol() const
get isolation
T getParameter(std::string const &) const
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
bool writeExtraInfo_
Write out additional info as ValueMaps.
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
L1MuonMatcher(const edm::ParameterSet &iConfig)
pat::TriggerObjectStandAloneCollection PATPrimitiveCollection
L1MuonMatcherAlgo matcher_
int bx() const
get bunch crossing identifier
pat::TriggerObjectStandAlone PATPrimitive
const_iterator begin(int bx) const
unsigned size(int bx) const
unsigned int quality() const
get quality
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
edm::EDGetTokenT< std::vector< l1extra::L1MuonParticle > > l1Token_
std::string labelL1_
Labels to set as filter names in the output.
GlobalPoint globalPosition() const
pat::TriggerObjectStandAloneMatch PATTriggerAssociation
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
edm::EDGetTokenT< l1t::MuonBxCollection > l1tToken_
Matcher of reconstructed objects to L1 Muons.
bool useStage2L1_
Allow to run both on legacy or stage2 (2016) L1 Muon trigger output.
~L1MuonMatcher() override
int firstBX_
Skim stage2 BX vector.
bool isSelected(const std::vector< L1HPSPFTauQualityCut > &qualityCuts, const l1t::PFCandidate &pfCand, float_t primaryVertexZ)
edm::EDGetTokenT< edm::View< reco::Candidate > > recoToken_
Tokens for input collections.
const_iterator end(int bx) const
void storeExtraInfo(edm::Event &iEvent, const Hand &handle, const std::vector< T > &values, const std::string &label) const
Store extra information in a ValueMap.
Matcher of reconstructed objects to L1 Muons.
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
int charge() const final
electric charge
Analysis-level trigger object class (stand-alone)