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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (const edm::Run &iRun, const edm::EventSetup &iSetup) override
 
 L1MuonMatcher (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~L1MuonMatcher ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 33 of file L1MuonMatcher.cc.

Member Typedef Documentation

Definition at line 42 of file L1MuonMatcher.cc.

Definition at line 43 of file L1MuonMatcher.cc.

Definition at line 44 of file L1MuonMatcher.cc.

Constructor & Destructor Documentation

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

Definition at line 76 of file L1MuonMatcher.cc.

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

76  :
77  matcher_(iConfig),
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"))
85 {
86  if (useStage2L1_) {
87  l1tToken_ = consumes<l1t::MuonBxCollection>(iConfig.getParameter<edm::InputTag>("matched"));
88  } else {
89  l1Token_ = consumes<std::vector<l1extra::L1MuonParticle> >(iConfig.getParameter<edm::InputTag>("matched"));
90  }
91  produces<PATPrimitiveCollection>("l1muons"); // l1 in PAT format
92  produces<PATPrimitiveCollection>("propagatedReco"); // reco to muon station 2
93  produces<PATTriggerAssociation>("propagatedReco"); // asso reco to propagated reco
94  produces<PATTriggerAssociation>(); // asso reco to l1
95  if (writeExtraInfo_) {
96  produces<edm::ValueMap<float> >("deltaR");
97  produces<edm::ValueMap<float> >("deltaPhi");
98  produces<edm::ValueMap<int> >("quality");
99  produces<edm::ValueMap<int> >("bx");
100  if(useStage2L1_) {
101  produces<edm::ValueMap<int> >("iPhi");
102  produces<edm::ValueMap<int> >("tfIndex");
103  }
104  produces<edm::ValueMap<int> >("isolated");
105  produces<edm::ValueMap<reco::CandidatePtr> >();
106  produces<edm::ValueMap<reco::CandidatePtr> >("l1ToReco");
107  }
108 }
T getParameter(std::string const &) const
bool writeExtraInfo_
Write out additional info as ValueMaps.
L1MuonMatcherAlgo matcher_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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_
virtual pat::L1MuonMatcher::~L1MuonMatcher ( )
inlinevirtual

Definition at line 36 of file L1MuonMatcher.cc.

References beginRun(), iEvent, and produce().

36 { }

Member Function Documentation

void pat::L1MuonMatcher::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overridevirtual

Definition at line 268 of file L1MuonMatcher.cc.

References DEFINE_FWK_MODULE, L1MuonMatcherAlgo::init(), and matcher_.

Referenced by ~L1MuonMatcher().

268  {
269  matcher_.init(iSetup);
270 }
void init(const edm::EventSetup &iSetup)
Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators...
L1MuonMatcherAlgo matcher_
void pat::L1MuonMatcher::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Definition at line 111 of file L1MuonMatcher.cc.

References BXVector< T >::begin(), L1MuGMTCand::bx(), ALCARECOTkAlJpsiMuMu_cff::charge, reco::Candidate::charge(), reco::LeafCandidate::charge(), popcon2dropbox::copy(), BXVector< T >::end(), PV3DBase< T, PVType, FrameType >::eta(), edm::helper::Filler< Map >::fill(), firstBX_, edm::Event::getByToken(), BXVector< T >::getFirstBX(), BXVector< T >::getLastBX(), TrajectoryStateOnSurface::globalPosition(), l1t::L1Candidate::hwIso(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwQual(), mps_fire::i, edm::helper::Filler< Map >::insert(), L1MuGMTCand::isol(), GlobalTrackerMuonAlignment_cfi::isolated, TrajectoryStateOnSurface::isValid(), l1Token_, l1tToken_, labelL1_, labelProp_, lastBX_, reco::Candidate::mass(), match(), L1MuonMatcherAlgo::match(), matcher_, hpstanc_transforms::max, simTrackMatching_cfi::maxBX, min(), simTrackMatching_cfi::minBX, eostools::move(), RPCpg::mu, gen::n, p4, PV3DBase< T, PVType, FrameType >::phi(), reco::LeafCandidate::polarP4(), reco::Candidate::pt(), edm::Event::put(), btvTracks_cfi::quality, L1MuGMTCand::quality(), trackingPlots::reco, recoToken_, BXVector< T >::size(), storeExtraInfo(), l1t::Muon::tfMuonIndex(), useStage2L1_, and writeExtraInfo_.

Referenced by ~L1MuonMatcher().

111  {
112  using namespace edm;
113  using namespace std;
114 
118 
119  std::vector<l1t::Muon> l1ts;
120  std::vector<size_t> bxIdxs;
121 
122  int minBxIdx = 0;
123  size_t l1size = 0;
124 
125  iEvent.getByToken(recoToken_, reco);
126 
127  if (useStage2L1_) {
128  iEvent.getByToken(l1tToken_, l1tBX);
129  l1size = l1tBX->size();
130 
131  int minBX = max(firstBX_,l1tBX->getFirstBX());
132  int maxBX = min(lastBX_,l1tBX->getLastBX());
133 
134  minBxIdx = l1tBX->begin(minBX) - l1tBX->begin();
135  std::copy(l1tBX->begin(minBX), l1tBX->end(maxBX), std::back_inserter(l1ts));
136 
137  for (int ibx = l1tBX->getFirstBX(); ibx <= l1tBX->getLastBX(); ++ibx) {
138  bxIdxs.push_back(l1tBX->end(ibx) - l1tBX->begin());
139  }
140  } else {
141  iEvent.getByToken(l1Token_, l1s);
142  l1size = l1s->size();
143  }
144 
145  unique_ptr<PATPrimitiveCollection> propOut(new PATPrimitiveCollection());
146  unique_ptr<PATPrimitiveCollection> l1Out(new PATPrimitiveCollection());
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) {
156  TrajectoryStateOnSurface propagated;
157  const reco::Candidate &mu = (*reco)[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);
161  if (propagated.isValid()) {
162  GlobalPoint pos = propagated.globalPosition();
163  propMatches[i] = propOut->size();
164  propOut->push_back(PATPrimitive(math::PtEtaPhiMLorentzVector(mu.pt(), pos.eta(), pos.phi(), mu.mass())));
165  propOut->back().addFilterLabel(labelProp_);
166  propOut->back().setCharge(mu.charge());
167  }
168  if (match != -1) {
169 
170  if(useStage2L1_) {
171  match += minBxIdx;
172  }
173 
174  whichRecoMatch[match] = reco->ptrAt(i);
175 
176  int charge = 0;
178 
179  if (useStage2L1_) {
180  const l1t::Muon & l1t = (*l1tBX)[match];
181  charge = l1t.charge();
182  p4 = l1t.polarP4();
183  }
184  else {
185  const l1extra::L1MuonParticle & l1 = (*l1s)[match];
186  charge = l1.charge();
187  p4 = l1.polarP4();
188  }
189 
190  if (isSelected[match] == -1) { // copy to output if needed
191  isSelected[match] = l1Out->size();
192  l1Out->push_back(PATPrimitive(p4));
193  l1Out->back().addFilterLabel(labelL1_);
194  l1Out->back().setCharge(charge);
195  }
196 
197  fullMatches[i] = isSelected[match]; // index in the output collection
198 
199  if (useStage2L1_) {
200  const l1t::Muon & l1t = (*l1tBX)[match];
201  quality[i] = l1t.hwQual();
202  bx[i] = l1tBX->getFirstBX() + (std::upper_bound(bxIdxs.begin(),bxIdxs.end(), match) - bxIdxs.begin());
203  isolated[i] = l1t.hwIso();
204  l1rawMatches[i] = edm::Ptr<reco::Candidate>(l1tBX, size_t(match));
205  iPhi[i] = l1t.hwPhi();
206  tfIndex[i] = l1t.tfMuonIndex();
207  }
208  else {
209  const L1MuGMTCand & gmt = (*l1s)[match].gmtMuonCand();
210  quality[i] = gmt.quality();
211  bx[i] = gmt.bx();
212  isolated[i] = gmt.isol();
213  l1rawMatches[i] = edm::Ptr<reco::Candidate>(l1s, size_t(match));
214  }
215  }
216  }
217 
218  OrphanHandle<PATPrimitiveCollection> l1Done = iEvent.put(std::move(l1Out), "l1muons");
219  OrphanHandle<PATPrimitiveCollection> propDone = iEvent.put(std::move(propOut), "propagatedReco");
220 
221  unique_ptr<PATTriggerAssociation> propAss(new PATTriggerAssociation(propDone));
222  PATTriggerAssociation::Filler propFiller(*propAss);
223  propFiller.insert(reco, propMatches.begin(), propMatches.end());
224  propFiller.fill();
225  iEvent.put(std::move(propAss), "propagatedReco");
226 
227  unique_ptr<PATTriggerAssociation> fullAss(new PATTriggerAssociation( l1Done));
228  PATTriggerAssociation::Filler fullFiller(*fullAss);
229  fullFiller.insert(reco, fullMatches.begin(), fullMatches.end());
230  fullFiller.fill();
231  iEvent.put(std::move(fullAss));
232 
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");
238  storeExtraInfo(iEvent, reco, quality, "quality");
239  storeExtraInfo(iEvent, reco, l1rawMatches, "");
240  if (useStage2L1_) {
241  storeExtraInfo(iEvent, l1tBX, whichRecoMatch, "l1ToReco");
242  storeExtraInfo(iEvent, reco, tfIndex, "tfIndex");
243  storeExtraInfo(iEvent, reco, iPhi, "iPhi");
244  }
245  else {
246  storeExtraInfo(iEvent, l1s, whichRecoMatch, "l1ToReco");
247  }
248  }
249 
250 }
const_iterator end(int bx) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
unsigned size(int bx) const
bool writeExtraInfo_
Write out additional info as ValueMaps.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
void storeExtraInfo(edm::Event &iEvent, const Hand &handle, const std::vector< T > &values, const std::string &label) const
Store extra information in a ValueMap.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalPoint globalPosition() const
pat::TriggerObjectStandAloneCollection PATPrimitiveCollection
int hwPhi() const
Definition: L1Candidate.h:50
delete x;
Definition: CaloConfig.h:22
L1MuonMatcherAlgo matcher_
pat::TriggerObjectStandAlone PATPrimitive
bool isol() const
get isolation
Definition: L1MuGMTCand.h:114
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
edm::EDGetTokenT< std::vector< l1extra::L1MuonParticle > > l1Token_
int hwIso() const
Definition: L1Candidate.h:52
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
std::string labelL1_
Labels to set as filter names in the output.
int bx() const
get bunch crossing identifier
Definition: L1MuGMTCand.h:120
double p4[4]
Definition: TauolaWrapper.h:92
pat::TriggerObjectStandAloneMatch PATTriggerAssociation
edm::EDGetTokenT< l1t::MuonBxCollection > l1tToken_
const int mu
Definition: Constants.h:22
T min(T a, T b)
Definition: MathUtil.h:58
bool useStage2L1_
Allow to run both on legacy or stage2 (2016) L1 Muon trigger output.
int hwQual() const
Definition: L1Candidate.h:51
Definition: Muon.h:16
unsigned int quality() const
get quality
Definition: L1MuGMTCand.h:93
helper::Filler< ValueMap< int > > Filler
Definition: ValueMap.h:168
int tfMuonIndex() const
Definition: Muon.h:84
int getFirstBX() const
bool match(const reco::Track &tk, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
virtual double pt() const =0
transverse momentum
virtual double mass() const =0
mass
int firstBX_
Skim stage2 BX vector.
edm::EDGetTokenT< edm::View< reco::Candidate > > recoToken_
Tokens for input collections.
T eta() const
Definition: PV3DBase.h:76
virtual int charge() const =0
electric charge
HLT enums.
int getLastBX() const
std::string labelProp_
virtual const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
const_iterator begin(int bx) const
def move(src, dest)
Definition: eostools.py:510
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 254 of file L1MuonMatcher.cc.

References edm::helper::Filler< Map >::fill(), objects.autophobj::filler, edm::helper::Filler< Map >::insert(), eostools::move(), and edm::Event::put().

Referenced by produce().

257  {
258  using namespace edm; using namespace std;
259  unique_ptr<ValueMap<T> > valMap(new ValueMap<T>());
260  typename edm::ValueMap<T>::Filler filler(*valMap);
261  filler.insert(handle, values.begin(), values.end());
262  filler.fill();
263  iEvent.put(std::move(valMap), label);
264 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
HLT enums.
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

int pat::L1MuonMatcher::firstBX_
private

Skim stage2 BX vector.

Definition at line 63 of file L1MuonMatcher.cc.

Referenced by produce().

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

Definition at line 50 of file L1MuonMatcher.cc.

Referenced by L1MuonMatcher(), and produce().

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

Definition at line 51 of file L1MuonMatcher.cc.

Referenced by L1MuonMatcher(), and produce().

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

Labels to set as filter names in the output.

Definition at line 54 of file L1MuonMatcher.cc.

Referenced by produce().

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

Definition at line 54 of file L1MuonMatcher.cc.

Referenced by produce().

int pat::L1MuonMatcher::lastBX_
private

Definition at line 64 of file L1MuonMatcher.cc.

Referenced by produce().

L1MuonMatcherAlgo pat::L1MuonMatcher::matcher_
private

Definition at line 46 of file L1MuonMatcher.cc.

Referenced by beginRun(), and produce().

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

Tokens for input collections.

Definition at line 49 of file L1MuonMatcher.cc.

Referenced by produce().

bool pat::L1MuonMatcher::useStage2L1_
private

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

Definition at line 60 of file L1MuonMatcher.cc.

Referenced by L1MuonMatcher(), and produce().

bool pat::L1MuonMatcher::writeExtraInfo_
private

Write out additional info as ValueMaps.

Definition at line 57 of file L1MuonMatcher.cc.

Referenced by L1MuonMatcher(), and produce().