CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MuonLinksProducerForHLT Class Reference

#include <MuonLinksProducerForHLT.h>

Inheritance diagram for MuonLinksProducerForHLT:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonLinksProducerForHLT (const edm::ParameterSet &)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~MuonLinksProducerForHLT () override
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::EDGetTokenT< reco::MuonTrackLinksCollectionlinkToken_
 
double pMin
 
double ptMin
 
double shareHitFraction
 
edm::InputTag theInclusiveTrackCollectionInInput
 
edm::InputTag theLinkCollectionInInput
 
edm::EDGetTokenT< reco::TrackCollectiontrackToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Author
R. Bellan - UCSB ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Simple producer to make reco::MuonTrackLinks collection out of the global muons from "muons" collection to restore dropped links used as input for MuonIdProducer.

Author
R. Bellan - UCSB ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Definition at line 24 of file MuonLinksProducerForHLT.h.

Constructor & Destructor Documentation

◆ MuonLinksProducerForHLT()

MuonLinksProducerForHLT::MuonLinksProducerForHLT ( const edm::ParameterSet iConfig)
explicit

Definition at line 22 of file MuonLinksProducerForHLT.cc.

References edm::ParameterSet::getParameter(), linkToken_, pMin, ptMin, shareHitFraction, theInclusiveTrackCollectionInInput, theLinkCollectionInInput, and trackToken_.

22  {
23  produces<reco::MuonTrackLinksCollection>();
24  theLinkCollectionInInput = iConfig.getParameter<edm::InputTag>("LinkCollection");
25  theInclusiveTrackCollectionInInput = iConfig.getParameter<edm::InputTag>("InclusiveTrackerTrackCollection");
26  ptMin = iConfig.getParameter<double>("ptMin");
27  pMin = iConfig.getParameter<double>("pMin");
28  shareHitFraction = iConfig.getParameter<double>("shareHitFraction");
29 
30  linkToken_ = consumes<reco::MuonTrackLinksCollection>(theLinkCollectionInInput);
31  trackToken_ = consumes<reco::TrackCollection>(theInclusiveTrackCollectionInInput);
32 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::TrackCollection > trackToken_
edm::EDGetTokenT< reco::MuonTrackLinksCollection > linkToken_
edm::InputTag theInclusiveTrackCollectionInInput

◆ ~MuonLinksProducerForHLT()

MuonLinksProducerForHLT::~MuonLinksProducerForHLT ( )
override

Definition at line 34 of file MuonLinksProducerForHLT.cc.

34 {}

Member Function Documentation

◆ produce()

void MuonLinksProducerForHLT::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 36 of file MuonLinksProducerForHLT.cc.

References newFWLiteAna::found, HLT_2023v12_cff::fraction, iEvent, electronStore::links, linkToken_, eostools::move(), pMin, ptMin, shareHitFraction, TrackingRecHit::some, HLT_2023v12_cff::track, and trackToken_.

36  {
37  auto output = std::make_unique<reco::MuonTrackLinksCollection>();
38 
40  iEvent.getByToken(linkToken_, links);
41 
43  iEvent.getByToken(trackToken_, incTracks);
44 
45  for (reco::MuonTrackLinksCollection::const_iterator link = links->begin(); link != links->end(); ++link) {
46  bool found = false;
47  unsigned int trackIndex = 0;
48  unsigned int muonTrackHits = link->trackerTrack()->extra()->recHitsSize();
49  for (reco::TrackCollection::const_iterator track = incTracks->begin(); track != incTracks->end();
50  ++track, ++trackIndex) {
51  if (track->pt() < ptMin)
52  continue;
53  if (track->p() < pMin)
54  continue;
55  //std::cout << "pt (muon/track) " << link->trackerTrack()->pt() << " " << track->pt() << std::endl;
56  unsigned trackHits = track->extra()->recHitsSize();
57  //std::cout << "hits (muon/track) " << muonTrackHits << " " << trackHits() << std::endl;
58  unsigned int smallestNumberOfHits = trackHits < muonTrackHits ? trackHits : muonTrackHits;
59  int numberOfCommonDetIds = 0;
60  for (auto hit = track->extra()->recHitsBegin(); hit != track->extra()->recHitsEnd(); ++hit) {
61  for (auto mit = link->trackerTrack()->extra()->recHitsBegin();
62  mit != link->trackerTrack()->extra()->recHitsEnd();
63  ++mit) {
64  if ((*hit)->geographicalId() == (*mit)->geographicalId() &&
65  (*hit)->sharesInput((*mit), TrackingRecHit::some)) {
66  numberOfCommonDetIds++;
67  break;
68  }
69  }
70  }
71  double fraction = (double)numberOfCommonDetIds / smallestNumberOfHits;
72  // std::cout << "Overlap/Smallest/fraction = " << numberOfCommonDetIds << " " << smallestNumberOfHits << " " << fraction << std::endl;
73  if (fraction > shareHitFraction) {
74  output->push_back(
75  reco::MuonTrackLinks(reco::TrackRef(incTracks, trackIndex), link->standAloneTrack(), link->globalTrack()));
76  found = true;
77  break;
78  }
79  }
80  if (!found)
81  output->push_back(reco::MuonTrackLinks(link->trackerTrack(), link->standAloneTrack(), link->globalTrack()));
82  }
83  iEvent.put(std::move(output));
84 }
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::TrackCollection > trackToken_
edm::EDGetTokenT< reco::MuonTrackLinksCollection > linkToken_
Definition: output.py:1
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ linkToken_

edm::EDGetTokenT<reco::MuonTrackLinksCollection> MuonLinksProducerForHLT::linkToken_
private

Definition at line 35 of file MuonLinksProducerForHLT.h.

Referenced by MuonLinksProducerForHLT(), and produce().

◆ pMin

double MuonLinksProducerForHLT::pMin
private

Definition at line 38 of file MuonLinksProducerForHLT.h.

Referenced by MuonLinksProducerForHLT(), and produce().

◆ ptMin

double MuonLinksProducerForHLT::ptMin
private

Definition at line 37 of file MuonLinksProducerForHLT.h.

Referenced by MuonLinksProducerForHLT(), and produce().

◆ shareHitFraction

double MuonLinksProducerForHLT::shareHitFraction
private

Definition at line 39 of file MuonLinksProducerForHLT.h.

Referenced by MuonLinksProducerForHLT(), and produce().

◆ theInclusiveTrackCollectionInInput

edm::InputTag MuonLinksProducerForHLT::theInclusiveTrackCollectionInInput
private

Definition at line 34 of file MuonLinksProducerForHLT.h.

Referenced by MuonLinksProducerForHLT().

◆ theLinkCollectionInInput

edm::InputTag MuonLinksProducerForHLT::theLinkCollectionInInput
private

Definition at line 33 of file MuonLinksProducerForHLT.h.

Referenced by MuonLinksProducerForHLT().

◆ trackToken_

edm::EDGetTokenT<reco::TrackCollection> MuonLinksProducerForHLT::trackToken_
private

Definition at line 36 of file MuonLinksProducerForHLT.h.

Referenced by MuonLinksProducerForHLT(), and produce().