CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
pat::L1MuonMatcher Class Reference

Matcher of reconstructed objects to L1 Muons. More...

Inheritance diagram for pat::L1MuonMatcher:
edm::stream::EDProducer<>

Public Member Functions

 L1MuonMatcher (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~L1MuonMatcher () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

typedef pat::TriggerObjectStandAlone PATPrimitive
 
typedef pat::TriggerObjectStandAloneCollection PATPrimitiveCollection
 
typedef pat::TriggerObjectStandAloneMatch PATTriggerAssociation
 

Private Member Functions

template<typename Hand , typename T >
void storeExtraInfo (edm::Event &iEvent, const Hand &handle, const std::vector< T > &values, const std::string &label) const
 Store extra information in a ValueMap. More...
 

Private Attributes

int firstBX_
 Skim stage2 BX vector. More...
 
edm::EDGetTokenT< std::vector< l1extra::L1MuonParticle > > l1Token_
 
edm::EDGetTokenT< l1t::MuonBxCollectionl1tToken_
 
std::string labelL1_
 Labels to set as filter names in the output. More...
 
std::string labelProp_
 
int lastBX_
 
L1MuonMatcherAlgo matcher_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > recoToken_
 Tokens for input collections. More...
 
bool useStage2L1_
 Allow to run both on legacy or stage2 (2016) L1 Muon trigger output. More...
 
bool writeExtraInfo_
 Write out additional info as ValueMaps. More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Matcher of reconstructed objects to L1 Muons.

Author
Giovanni Petrucciani
Version
Id
HLTL1MuonMatcher.cc,v 1.3 2010/07/12 20:56:11 gpetrucc Exp
Author
Giovanni Petrucciani
Version
Id
L1MuonMatcher.cc,v 1.4 2011/03/31 09:59:33 gpetrucc Exp

Definition at line 32 of file L1MuonMatcher.cc.

Member Typedef Documentation

◆ PATPrimitive

Definition at line 40 of file L1MuonMatcher.cc.

◆ PATPrimitiveCollection

Definition at line 41 of file L1MuonMatcher.cc.

◆ PATTriggerAssociation

Definition at line 42 of file L1MuonMatcher.cc.

Constructor & Destructor Documentation

◆ L1MuonMatcher()

pat::L1MuonMatcher::L1MuonMatcher ( const edm::ParameterSet iConfig)
explicit

Definition at line 74 of file L1MuonMatcher.cc.

References edm::ParameterSet::getParameter(), l1Token_, l1tToken_, useStage2L1_, and writeExtraInfo_.

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")) {
83  if (useStage2L1_) {
84  l1tToken_ = consumes<l1t::MuonBxCollection>(iConfig.getParameter<edm::InputTag>("matched"));
85  } else {
86  l1Token_ = consumes<std::vector<l1extra::L1MuonParticle> >(iConfig.getParameter<edm::InputTag>("matched"));
87  }
88  produces<PATPrimitiveCollection>("l1muons"); // l1 in PAT format
89  produces<PATPrimitiveCollection>("propagatedReco"); // reco to muon station 2
90  produces<PATTriggerAssociation>("propagatedReco"); // asso reco to propagated reco
91  produces<PATTriggerAssociation>(); // asso reco to l1
92  if (writeExtraInfo_) {
93  produces<edm::ValueMap<float> >("deltaR");
94  produces<edm::ValueMap<float> >("deltaPhi");
95  produces<edm::ValueMap<int> >("quality");
96  produces<edm::ValueMap<int> >("bx");
97  if (useStage2L1_) {
98  produces<edm::ValueMap<int> >("iPhi");
99  produces<edm::ValueMap<int> >("tfIndex");
100  }
101  produces<edm::ValueMap<int> >("isolated");
102  produces<edm::ValueMap<reco::CandidatePtr> >();
103  produces<edm::ValueMap<reco::CandidatePtr> >("l1ToReco");
104  }
105 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool writeExtraInfo_
Write out additional info as ValueMaps.
L1MuonMatcherAlgo matcher_
edm::EDGetTokenT< std::vector< l1extra::L1MuonParticle > > l1Token_
std::string labelL1_
Labels to set as filter names in the output.
edm::EDGetTokenT< l1t::MuonBxCollection > l1tToken_
bool useStage2L1_
Allow to run both on legacy or stage2 (2016) L1 Muon trigger output.
int firstBX_
Skim stage2 BX vector.
edm::EDGetTokenT< edm::View< reco::Candidate > > recoToken_
Tokens for input collections.
std::string labelProp_

◆ ~L1MuonMatcher()

pat::L1MuonMatcher::~L1MuonMatcher ( )
inlineoverride

Definition at line 35 of file L1MuonMatcher.cc.

35 {}

Member Function Documentation

◆ produce()

void pat::L1MuonMatcher::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 107 of file L1MuonMatcher.cc.

References BXVector< T >::begin(), simKBmtfDigis_cfi::bx, L1MuGMTCand::bx(), ALCARECOTkAlJpsiMuMu_cff::charge, reco::LeafCandidate::charge(), filterCSVwithJSON::copy, HLT_2023v12_cff::deltaPhis, BXVector< T >::end(), edm::helper::Filler< Map >::fill(), BXVector< T >::getFirstBX(), BXVector< T >::getLastBX(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, iEvent, edm::helper::Filler< Map >::insert(), L1MuGMTCand::isol(), isSelected(), TrajectoryStateOnSurface::isValid(), L1Scalers_cfi::l1s, SiStripPI::max, hltL1TEGammaFilteredCollectionProducer_cfi::maxBX, SiStripPI::min, hltL1TEGammaFilteredCollectionProducer_cfi::minBX, eostools::move(), amptDefaultParameters_cff::mu, dqmiodumpmetadata::n, reco::LeafCandidate::polarP4(), quality, L1MuGMTCand::quality(), dt_dqm_sourceclient_common_cff::reco, BXVector< T >::size(), and pfDeepBoostedJetPreprocessParams_cfi::upper_bound.

107  {
108  using namespace edm;
109  using namespace std;
110 
111  matcher_.init(iSetup);
112 
116 
117  std::vector<l1t::Muon> l1ts;
118  std::vector<size_t> bxIdxs;
119 
120  int minBxIdx = 0;
121  size_t l1size = 0;
122 
123  iEvent.getByToken(recoToken_, reco);
124 
125  if (useStage2L1_) {
126  iEvent.getByToken(l1tToken_, l1tBX);
127  l1size = l1tBX->size();
128 
129  int minBX = max(firstBX_, l1tBX->getFirstBX());
130  int maxBX = min(lastBX_, l1tBX->getLastBX());
131 
132  minBxIdx = l1tBX->begin(minBX) - l1tBX->begin();
133  std::copy(l1tBX->begin(minBX), l1tBX->end(maxBX), std::back_inserter(l1ts));
134 
135  for (int ibx = l1tBX->getFirstBX(); ibx <= l1tBX->getLastBX(); ++ibx) {
136  bxIdxs.push_back(l1tBX->end(ibx) - l1tBX->begin());
137  }
138  } else {
139  iEvent.getByToken(l1Token_, l1s);
140  l1size = l1s->size();
141  }
142 
143  unique_ptr<PATPrimitiveCollection> propOut(new PATPrimitiveCollection());
144  unique_ptr<PATPrimitiveCollection> l1Out(new PATPrimitiveCollection());
145  std::vector<edm::Ptr<reco::Candidate> > l1rawMatches(reco->size());
146  vector<int> isSelected(l1size, -1);
147  std::vector<edm::Ptr<reco::Candidate> > whichRecoMatch(l1size);
148  vector<int> propMatches(reco->size(), -1);
149  vector<int> fullMatches(reco->size(), -1);
150  vector<float> deltaRs(reco->size(), 999), deltaPhis(reco->size(), 999);
151  vector<int> quality(reco->size(), 0), bx(reco->size(), -999), isolated(reco->size(), -999);
152  vector<int> iPhi(reco->size(), 0), tfIndex(reco->size(), -999);
153  for (int i = 0, n = reco->size(); i < n; ++i) {
154  TrajectoryStateOnSurface propagated;
155  const reco::Candidate &mu = (*reco)[i];
156  int match = useStage2L1_ ? matcher_.match(mu, l1ts, deltaRs[i], deltaPhis[i], propagated)
157  : matcher_.match(mu, *l1s, deltaRs[i], deltaPhis[i], propagated);
158  if (propagated.isValid()) {
159  GlobalPoint pos = propagated.globalPosition();
160  propMatches[i] = propOut->size();
161  propOut->push_back(PATPrimitive(math::PtEtaPhiMLorentzVector(mu.pt(), pos.eta(), pos.phi(), mu.mass())));
162  propOut->back().addFilterLabel(labelProp_);
163  propOut->back().setCharge(mu.charge());
164  }
165  if (match != -1) {
166  if (useStage2L1_) {
167  match += minBxIdx;
168  }
169 
170  whichRecoMatch[match] = reco->ptrAt(i);
171 
172  int charge = 0;
174 
175  if (useStage2L1_) {
176  const l1t::Muon &l1t = (*l1tBX)[match];
177  charge = l1t.charge();
178  p4 = l1t.polarP4();
179  } else {
180  const l1extra::L1MuonParticle &l1 = (*l1s)[match];
181  charge = l1.charge();
182  p4 = l1.polarP4();
183  }
184 
185  if (isSelected[match] == -1) { // copy to output if needed
186  isSelected[match] = l1Out->size();
187  l1Out->push_back(PATPrimitive(p4));
188  l1Out->back().addFilterLabel(labelL1_);
189  l1Out->back().setCharge(charge);
190  }
191 
192  fullMatches[i] = isSelected[match]; // index in the output collection
193 
194  if (useStage2L1_) {
195  const l1t::Muon &l1t = (*l1tBX)[match];
196  quality[i] = l1t.hwQual();
197  bx[i] = l1tBX->getFirstBX() + (std::upper_bound(bxIdxs.begin(), bxIdxs.end(), match) - bxIdxs.begin());
198  isolated[i] = l1t.hwIso();
199  l1rawMatches[i] = edm::Ptr<reco::Candidate>(l1tBX, size_t(match));
200  iPhi[i] = l1t.hwPhi();
201  tfIndex[i] = l1t.tfMuonIndex();
202  } else {
203  const L1MuGMTCand &gmt = (*l1s)[match].gmtMuonCand();
204  quality[i] = gmt.quality();
205  bx[i] = gmt.bx();
206  isolated[i] = gmt.isol();
207  l1rawMatches[i] = edm::Ptr<reco::Candidate>(l1s, size_t(match));
208  }
209  }
210  }
211 
212  OrphanHandle<PATPrimitiveCollection> l1Done = iEvent.put(std::move(l1Out), "l1muons");
213  OrphanHandle<PATPrimitiveCollection> propDone = iEvent.put(std::move(propOut), "propagatedReco");
214 
215  unique_ptr<PATTriggerAssociation> propAss(new PATTriggerAssociation(propDone));
216  PATTriggerAssociation::Filler propFiller(*propAss);
217  propFiller.insert(reco, propMatches.begin(), propMatches.end());
218  propFiller.fill();
219  iEvent.put(std::move(propAss), "propagatedReco");
220 
221  unique_ptr<PATTriggerAssociation> fullAss(new PATTriggerAssociation(l1Done));
222  PATTriggerAssociation::Filler fullFiller(*fullAss);
223  fullFiller.insert(reco, fullMatches.begin(), fullMatches.end());
224  fullFiller.fill();
225  iEvent.put(std::move(fullAss));
226 
227  if (writeExtraInfo_) {
228  storeExtraInfo(iEvent, reco, deltaRs, "deltaR");
229  storeExtraInfo(iEvent, reco, deltaPhis, "deltaPhi");
230  storeExtraInfo(iEvent, reco, bx, "bx");
231  storeExtraInfo(iEvent, reco, isolated, "isolated");
232  storeExtraInfo(iEvent, reco, quality, "quality");
233  storeExtraInfo(iEvent, reco, l1rawMatches, "");
234  if (useStage2L1_) {
235  storeExtraInfo(iEvent, l1tBX, whichRecoMatch, "l1ToReco");
236  storeExtraInfo(iEvent, reco, tfIndex, "tfIndex");
237  storeExtraInfo(iEvent, reco, iPhi, "iPhi");
238  } else {
239  storeExtraInfo(iEvent, l1s, whichRecoMatch, "l1ToReco");
240  }
241  }
242 }
int getLastBX() const
bool isol() const
get isolation
Definition: L1MuGMTCand.h:111
Definition: L1Scalers.h:16
int getFirstBX() const
bool writeExtraInfo_
Write out additional info as ValueMaps.
pat::TriggerObjectStandAloneCollection PATPrimitiveCollection
delete x;
Definition: CaloConfig.h:22
L1MuonMatcherAlgo matcher_
int bx() const
get bunch crossing identifier
Definition: L1MuGMTCand.h:117
pat::TriggerObjectStandAlone PATPrimitive
const_iterator begin(int bx) const
unsigned size(int bx) const
unsigned int quality() const
get quality
Definition: L1MuGMTCand.h:90
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
edm::EDGetTokenT< std::vector< l1extra::L1MuonParticle > > l1Token_
string quality
std::string labelL1_
Labels to set as filter names in the output.
int iEvent
Definition: GenABIO.cc:224
GlobalPoint globalPosition() const
pat::TriggerObjectStandAloneMatch PATTriggerAssociation
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
edm::EDGetTokenT< l1t::MuonBxCollection > l1tToken_
bool useStage2L1_
Allow to run both on legacy or stage2 (2016) L1 Muon trigger output.
Definition: Muon.h:21
helper::Filler< ValueMap< int > > Filler
Definition: ValueMap.h:168
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
fixed size matrix
HLT enums.
void storeExtraInfo(edm::Event &iEvent, const Hand &handle, const std::vector< T > &values, const std::string &label) const
Store extra information in a ValueMap.
std::string labelProp_
def move(src, dest)
Definition: eostools.py:511
int charge() const final
electric charge

◆ storeExtraInfo()

template<typename Hand , typename T >
void pat::L1MuonMatcher::storeExtraInfo ( edm::Event iEvent,
const Hand &  handle,
const std::vector< T > &  values,
const std::string &  label 
) const
private

Store extra information in a ValueMap.

Definition at line 245 of file L1MuonMatcher.cc.

References trigObjTnPSource_cfi::filler, patZpeak::handle, iEvent, label, eostools::move(), and contentValuesCheck::values.

248  {
249  using namespace edm;
250  using namespace std;
251  unique_ptr<ValueMap<T> > valMap(new ValueMap<T>());
252  typename edm::ValueMap<T>::Filler filler(*valMap);
253  filler.insert(handle, values.begin(), values.end());
254  filler.fill();
255  iEvent.put(std::move(valMap), label);
256 }
char const * label
int iEvent
Definition: GenABIO.cc:224
HLT enums.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ firstBX_

int pat::L1MuonMatcher::firstBX_
private

Skim stage2 BX vector.

Definition at line 61 of file L1MuonMatcher.cc.

◆ l1Token_

edm::EDGetTokenT<std::vector<l1extra::L1MuonParticle> > pat::L1MuonMatcher::l1Token_
private

Definition at line 48 of file L1MuonMatcher.cc.

Referenced by L1MuonMatcher().

◆ l1tToken_

edm::EDGetTokenT<l1t::MuonBxCollection> pat::L1MuonMatcher::l1tToken_
private

Definition at line 49 of file L1MuonMatcher.cc.

Referenced by L1MuonMatcher().

◆ labelL1_

std::string pat::L1MuonMatcher::labelL1_
private

Labels to set as filter names in the output.

Definition at line 52 of file L1MuonMatcher.cc.

◆ labelProp_

std::string pat::L1MuonMatcher::labelProp_
private

Definition at line 52 of file L1MuonMatcher.cc.

◆ lastBX_

int pat::L1MuonMatcher::lastBX_
private

Definition at line 62 of file L1MuonMatcher.cc.

◆ matcher_

L1MuonMatcherAlgo pat::L1MuonMatcher::matcher_
private

Definition at line 44 of file L1MuonMatcher.cc.

◆ recoToken_

edm::EDGetTokenT<edm::View<reco::Candidate> > pat::L1MuonMatcher::recoToken_
private

Tokens for input collections.

Definition at line 47 of file L1MuonMatcher.cc.

◆ useStage2L1_

bool pat::L1MuonMatcher::useStage2L1_
private

Allow to run both on legacy or stage2 (2016) L1 Muon trigger output.

Definition at line 58 of file L1MuonMatcher.cc.

Referenced by L1MuonMatcher().

◆ writeExtraInfo_

bool pat::L1MuonMatcher::writeExtraInfo_
private

Write out additional info as ValueMaps.

Definition at line 55 of file L1MuonMatcher.cc.

Referenced by L1MuonMatcher().