67 template<
typename Hand,
typename T>
70 const std::vector<T> &
values,
79 labelL1_(iConfig.getParameter<std::
string>(
"setL1Label")),
80 labelProp_(iConfig.getParameter<std::
string>(
"setPropLabel")),
81 writeExtraInfo_(iConfig.getParameter<bool>(
"writeExtraInfo")),
82 useStage2L1_(iConfig.getParameter<bool>(
"useStage2L1")),
83 firstBX_(iConfig.getParameter<int>(
"firstBX")),
84 lastBX_(iConfig.getParameter<int>(
"lastBX"))
91 produces<PATPrimitiveCollection>(
"l1muons");
92 produces<PATPrimitiveCollection>(
"propagatedReco");
93 produces<PATTriggerAssociation>(
"propagatedReco");
94 produces<PATTriggerAssociation>();
96 produces<edm::ValueMap<float> >(
"deltaR");
97 produces<edm::ValueMap<float> >(
"deltaPhi");
98 produces<edm::ValueMap<int> >(
"quality");
99 produces<edm::ValueMap<int> >(
"bx");
101 produces<edm::ValueMap<int> >(
"iPhi");
102 produces<edm::ValueMap<int> >(
"tfIndex");
104 produces<edm::ValueMap<int> >(
"isolated");
105 produces<edm::ValueMap<reco::CandidatePtr> >();
106 produces<edm::ValueMap<reco::CandidatePtr> >(
"l1ToReco");
119 std::vector<l1t::Muon> l1ts;
120 std::vector<size_t> bxIdxs;
129 l1size = l1tBX->size();
131 int minBX =
max(firstBX_,l1tBX->getFirstBX());
132 int maxBX =
min(lastBX_,l1tBX->getLastBX());
134 minBxIdx = l1tBX->begin(minBX) - l1tBX->begin();
135 std::copy(l1tBX->begin(minBX), l1tBX->end(maxBX), std::back_inserter(l1ts));
137 for (
int ibx = l1tBX->getFirstBX(); ibx <= l1tBX->getLastBX(); ++ibx) {
138 bxIdxs.push_back(l1tBX->end(ibx) - l1tBX->begin());
142 l1size =
l1s->size();
147 std::vector<edm::Ptr<reco::Candidate> > l1rawMatches(
reco->size());
148 vector<int> isSelected(l1size, -1);
149 std::vector<edm::Ptr<reco::Candidate> > whichRecoMatch(l1size);
150 vector<int> propMatches(
reco->size(), -1);
151 vector<int> fullMatches(
reco->size(), -1);
152 vector<float> deltaRs(
reco->size(), 999), deltaPhis(
reco->size(), 999);
153 vector<int>
quality(
reco->size(), 0), bx(
reco->size(), -999), isolated(
reco->size(), -999);
154 vector<int> iPhi(
reco->size(), 0), tfIndex(
reco->size(), -999);
155 for (
int i = 0,
n =
reco->size();
i <
n; ++
i) {
158 int match = useStage2L1_ ?
159 matcher_.match(mu, l1ts, deltaRs[
i], deltaPhis[i], propagated) :
160 matcher_.match(mu, *
l1s, deltaRs[i], deltaPhis[i], propagated);
163 propMatches[
i] = propOut->size();
165 propOut->back().addFilterLabel(labelProp_);
166 propOut->back().setCharge(mu.
charge());
190 if (isSelected[match] == -1) {
191 isSelected[
match] = l1Out->size();
193 l1Out->back().addFilterLabel(labelL1_);
194 l1Out->back().setCharge(charge);
197 fullMatches[
i] = isSelected[
match];
202 bx[
i] = l1tBX->getFirstBX() + (std::upper_bound(bxIdxs.begin(),bxIdxs.end(),
match) - bxIdxs.begin());
203 isolated[
i] = l1t.
hwIso();
212 isolated[
i] = gmt.
isol();
223 propFiller.
insert(
reco, propMatches.begin(), propMatches.end());
229 fullFiller.
insert(
reco, fullMatches.begin(), fullMatches.end());
233 if (writeExtraInfo_) {
234 storeExtraInfo(iEvent,
reco, deltaRs,
"deltaR");
235 storeExtraInfo(iEvent,
reco, deltaPhis,
"deltaPhi");
236 storeExtraInfo(iEvent,
reco, bx,
"bx");
237 storeExtraInfo(iEvent,
reco, isolated,
"isolated");
239 storeExtraInfo(iEvent,
reco, l1rawMatches,
"");
241 storeExtraInfo(iEvent, l1tBX, whichRecoMatch,
"l1ToReco");
242 storeExtraInfo(iEvent,
reco, tfIndex,
"tfIndex");
243 storeExtraInfo(iEvent,
reco, iPhi,
"iPhi");
246 storeExtraInfo(iEvent,
l1s, whichRecoMatch,
"l1ToReco");
252 template<
typename Hand,
typename T>
256 const std::vector<T> &
values,
258 using namespace edm;
using namespace std;
259 unique_ptr<ValueMap<T> > valMap(
new ValueMap<T>());
261 filler.
insert(handle, values.begin(), values.end());
269 matcher_.init(iSetup);
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
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)
GlobalPoint globalPosition() const
pat::TriggerObjectStandAloneCollection PATPrimitiveCollection
L1MuonMatcherAlgo matcher_
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
pat::TriggerObjectStandAlone PATPrimitive
bool isol() const
get isolation
virtual void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override
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.
tuple quality
[pTError/pT]*max(1,normChi2) <= ptErrorCut
int bx() const
get bunch crossing identifier
pat::TriggerObjectStandAloneMatch PATTriggerAssociation
virtual int charge() const final
electric charge
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.
unsigned int quality() const
get quality
int firstBX_
Skim stage2 BX vector.
edm::EDGetTokenT< edm::View< reco::Candidate > > recoToken_
Tokens for input collections.
virtual const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
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.
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Analysis-level trigger object class (stand-alone)