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");
117 std::vector<l1t::Muon> l1ts;
118 std::vector<size_t> bxIdxs;
127 l1size = l1tBX->size();
129 int minBX =
max(firstBX_, l1tBX->getFirstBX());
130 int maxBX =
min(lastBX_, l1tBX->getLastBX());
132 minBxIdx = l1tBX->begin(minBX) - l1tBX->begin();
133 std::copy(l1tBX->begin(minBX), l1tBX->end(maxBX), std::back_inserter(l1ts));
135 for (
int ibx = l1tBX->getFirstBX(); ibx <= l1tBX->getLastBX(); ++ibx) {
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) {
160 propMatches[
i] = propOut->size();
162 propOut->back().addFilterLabel(labelProp_);
163 propOut->back().setCharge(mu.
charge());
185 if (isSelected[match] == -1) {
186 isSelected[
match] = l1Out->size();
188 l1Out->back().addFilterLabel(labelL1_);
189 l1Out->back().setCharge(charge);
192 fullMatches[
i] = isSelected[
match];
198 isolated[
i] = l1t.
hwIso();
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");
230 storeExtraInfo(iEvent,
reco,
bx,
"bx");
231 storeExtraInfo(iEvent,
reco, isolated,
"isolated");
233 storeExtraInfo(iEvent,
reco, l1rawMatches,
"");
235 storeExtraInfo(iEvent, l1tBX, whichRecoMatch,
"l1ToReco");
236 storeExtraInfo(iEvent,
reco, tfIndex,
"tfIndex");
237 storeExtraInfo(iEvent,
reco, iPhi,
"iPhi");
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>());
253 filler.
insert(handle, values.begin(), values.end());
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
bool writeExtraInfo_
Write out additional info as ValueMaps.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
void storeExtraInfo(edm::Event &iEvent, const Hand &handle, const std::vector< T > &values, const std::string &label) const
Store extra information in a ValueMap.
virtual double mass() const =0
mass
Geom::Phi< T > phi() const
void insert(const H &h, I begin, I end)
L1MuonMatcher(const edm::ParameterSet &iConfig)
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
GlobalPoint globalPosition() const
pat::TriggerObjectStandAloneCollection PATPrimitiveCollection
L1MuonMatcherAlgo matcher_
pat::TriggerObjectStandAlone PATPrimitive
bool isol() const
get isolation
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.
int bx() const
get bunch crossing identifier
pat::TriggerObjectStandAloneMatch PATTriggerAssociation
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
edm::EDGetTokenT< l1t::MuonBxCollection > l1tToken_
Matcher of reconstructed objects to L1 Muons.
virtual int charge() const =0
electric charge
bool useStage2L1_
Allow to run both on legacy or stage2 (2016) L1 Muon trigger output.
~L1MuonMatcher() override
unsigned int quality() const
get quality
T getParameter(std::string const &) const
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.
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)