CMS 3D CMS Logo

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

#include <CosmicMuonLinksProducer.h>

Inheritance diagram for CosmicMuonLinksProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CosmicMuonLinksProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~CosmicMuonLinksProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

reco::TrackToTrackMap mapTracks (const edm::Handle< reco::TrackCollection > &, const edm::Handle< reco::TrackCollection > &) const
 
int sharedHits (const reco::Track &track1, const reco::Track &track2) const
 

Private Attributes

std::string category_
 
MuonServiceProxytheService
 
std::vector< std::pair< std::string, std::string > > theTrackLinkNames
 
std::vector< std::pair< edm::EDGetTokenT< reco::TrackCollection >, edm::EDGetTokenT< reco::TrackCollection > > > theTrackLinks
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Original Author: Chang Liu - Purdue University chang.nosp@m..liu.nosp@m.@cern.nosp@m..ch

Definition at line 16 of file CosmicMuonLinksProducer.h.

Constructor & Destructor Documentation

◆ CosmicMuonLinksProducer()

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

Definition at line 36 of file CosmicMuonLinksProducer.cc.

36  {
37  category_ = "Muon|RecoMuon|CosmicMuon|CosmicMuonLinksProducer";
38 
39  ParameterSet serviceParameters = iConfig.getParameter<ParameterSet>("ServiceParameters");
40 
41  theService = new MuonServiceProxy(serviceParameters, consumesCollector());
42 
43  std::vector<edm::ParameterSet> theMapPSets = iConfig.getParameter<std::vector<edm::ParameterSet> >("Maps");
44  for (std::vector<edm::ParameterSet>::const_iterator iMPS = theMapPSets.begin(); iMPS != theMapPSets.end(); iMPS++) {
45  edm::InputTag sTag = (*iMPS).getParameter<edm::InputTag>("subTrack");
46  edm::InputTag pTag = (*iMPS).getParameter<edm::InputTag>("parentTrack");
47 
48  edm::EDGetTokenT<reco::TrackCollection> subTrackTag = consumes<reco::TrackCollection>(sTag);
49  edm::EDGetTokenT<reco::TrackCollection> parentTrackTag = consumes<reco::TrackCollection>(pTag);
50  theTrackLinks.push_back(make_pair(subTrackTag, parentTrackTag));
51  theTrackLinkNames.push_back(make_pair(sTag.label(), pTag.label()));
52 
53  LogDebug(category_) << "preparing map between " << sTag << " & " << pTag;
54  std::string mapname = sTag.label() + "To" + pTag.label();
55  produces<reco::TrackToTrackMap>(mapname);
56  }
57 }

References edm::ParameterSet::getParameter(), edm::InputTag::label(), LogDebug, MuonServiceProxy_cff::MuonServiceProxy, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~CosmicMuonLinksProducer()

CosmicMuonLinksProducer::~CosmicMuonLinksProducer ( )
override

Definition at line 59 of file CosmicMuonLinksProducer.cc.

59  {
60  if (theService)
61  delete theService;
62 }

Member Function Documentation

◆ mapTracks()

reco::TrackToTrackMap CosmicMuonLinksProducer::mapTracks ( const edm::Handle< reco::TrackCollection > &  subTracks,
const edm::Handle< reco::TrackCollection > &  parentTracks 
) const
private

Definition at line 103 of file CosmicMuonLinksProducer.cc.

104  {
105  reco::TrackToTrackMap map(subTracks, parentTracks);
106  for (unsigned int position1 = 0; position1 != subTracks->size(); ++position1) {
107  TrackRef track1(subTracks, position1);
108  for (unsigned int position2 = 0; position2 != parentTracks->size(); ++position2) {
109  TrackRef track2(parentTracks, position2);
110  int shared = sharedHits(*track1, *track2);
111  LogTrace(category_) << "sharedHits " << shared << " track1 " << track1->found() << " track2 " << track2->found()
112  << endl;
113 
114  if (shared > (track1->found()) / 2)
115  map.insert(track1, track2);
116  }
117  }
118 
119  return map;
120 }

References LogTrace, genParticles_cff::map, and muonCosmicCompatibility_cfi::sharedHits.

◆ produce()

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

DAMN I cannot read the label of the TOKEN so I need to do this stupid thing to create the labels of the products!

Implements edm::EDProducer.

Definition at line 65 of file CosmicMuonLinksProducer.cc.

65  {
66  LogInfo(category_) << "Processing event number: " << iEvent.id();
67 
68  theService->update(iSetup);
69 
70  unsigned int counter =
71  0;
72  for (std::vector<std::pair<edm::EDGetTokenT<reco::TrackCollection>,
73  edm::EDGetTokenT<reco::TrackCollection> > >::const_iterator iLink = theTrackLinks.begin();
74  iLink != theTrackLinks.end();
75  iLink++) {
76 #ifdef EDM_ML_DEBUG
77  edm::EDConsumerBase::Labels labels_first;
78  edm::EDConsumerBase::Labels labels_second;
79  labelsForToken(iLink->first, labels_first);
80  labelsForToken(iLink->second, labels_second);
81  LogDebug(category_) << "making map between " << labels_first.module << " and " << labels_second.module;
82 #endif
83  std::string mapname = theTrackLinkNames[counter].first + "To" + theTrackLinkNames[counter].second;
85 
87  Handle<reco::TrackCollection> parentTracks;
88 
89  iEvent.getByToken((*iLink).first, subTracks);
90  iEvent.getByToken((*iLink).second, parentTracks);
91 
92  ttmap = mapTracks(subTracks, parentTracks);
93  LogTrace(category_) << "Mapped: " << theTrackLinkNames[counter].first << " " << subTracks->size() << " and "
94  << theTrackLinkNames[counter].second << " " << parentTracks->size()
95  << ", results: " << ttmap.size() << endl;
96 
97  iEvent.put(std::make_unique<reco::TrackToTrackMap>(ttmap), mapname);
98 
99  counter++;
100  }
101 }

References counter, iEvent, LogDebug, LogTrace, edm::ProductLabels::module, edm::AssociationMap< Tag >::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ sharedHits()

int CosmicMuonLinksProducer::sharedHits ( const reco::Track track1,
const reco::Track track2 
) const
private

Definition at line 122 of file CosmicMuonLinksProducer.cc.

122  {
123  int match = 0;
124 
125  for (trackingRecHit_iterator hit1 = track1.recHitsBegin(); hit1 != track1.recHitsEnd(); ++hit1) {
126  if (!(*hit1)->isValid())
127  continue;
128  DetId id1 = (*hit1)->geographicalId();
129  if (id1.det() != DetId::Muon)
130  continue; //ONLY MUON
131  LogTrace(category_) << "first ID " << id1.rawId() << " " << (*hit1)->localPosition() << endl;
132  GlobalPoint pos1 = theService->trackingGeometry()->idToDet(id1)->surface().toGlobal((*hit1)->localPosition());
133 
134  for (trackingRecHit_iterator hit2 = track2.recHitsBegin(); hit2 != track2.recHitsEnd(); ++hit2) {
135  if (!(*hit2)->isValid())
136  continue;
137 
138  DetId id2 = (*hit2)->geographicalId();
139  if (id2.det() != DetId::Muon)
140  continue; //ONLY MUON
141 
142  // LogTrace(category_)<<"second ID "<<id2.rawId()<< (*hit2)->localPosition()<<endl;
143 
144  if (id2.rawId() != id1.rawId())
145  continue;
146 
147  GlobalPoint pos2 = theService->trackingGeometry()->idToDet(id2)->surface().toGlobal((*hit2)->localPosition());
148  if ((pos1 - pos2).mag() < 10e-5)
149  match++;
150  }
151  }
152 
153  return match;
154 }

References MillePedeFileConverter_cfg::e, globals_cff::id1, globals_cff::id2, LogTrace, edm::match(), DetId::Muon, reco::Track::recHitsBegin(), and reco::Track::recHitsEnd().

Member Data Documentation

◆ category_

std::string CosmicMuonLinksProducer::category_
private

Definition at line 36 of file CosmicMuonLinksProducer.h.

◆ theService

MuonServiceProxy* CosmicMuonLinksProducer::theService
private

Definition at line 30 of file CosmicMuonLinksProducer.h.

◆ theTrackLinkNames

std::vector<std::pair<std::string, std::string> > CosmicMuonLinksProducer::theTrackLinkNames
private

Definition at line 34 of file CosmicMuonLinksProducer.h.

◆ theTrackLinks

std::vector<std::pair<edm::EDGetTokenT<reco::TrackCollection>, edm::EDGetTokenT<reco::TrackCollection> > > CosmicMuonLinksProducer::theTrackLinks
private

Definition at line 33 of file CosmicMuonLinksProducer.h.

counter
Definition: counter.py:1
reco::Track::recHitsBegin
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
edm::EDGetTokenT< reco::TrackCollection >
CosmicMuonLinksProducer::theService
MuonServiceProxy * theService
Definition: CosmicMuonLinksProducer.h:30
edm::ProductLabels::module
char const * module
Definition: ProductLabels.h:5
globals_cff.id1
id1
Definition: globals_cff.py:32
edm::LogInfo
Definition: MessageLogger.h:254
CosmicMuonLinksProducer::category_
std::string category_
Definition: CosmicMuonLinksProducer.h:36
CosmicMuonLinksProducer::sharedHits
int sharedHits(const reco::Track &track1, const reco::Track &track2) const
Definition: CosmicMuonLinksProducer.cc:122
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:71
CosmicMuonLinksProducer::theTrackLinks
std::vector< std::pair< edm::EDGetTokenT< reco::TrackCollection >, edm::EDGetTokenT< reco::TrackCollection > > > theTrackLinks
Definition: CosmicMuonLinksProducer.h:33
edm::Handle< reco::TrackCollection >
MuonServiceProxy_cff.MuonServiceProxy
MuonServiceProxy
Definition: MuonServiceProxy_cff.py:15
edm::Ref< TrackCollection >
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
DetId
Definition: DetId.h:17
reco::Track::recHitsEnd
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
Point3DBase< float, GlobalTag >
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
CosmicMuonLinksProducer::mapTracks
reco::TrackToTrackMap mapTracks(const edm::Handle< reco::TrackCollection > &, const edm::Handle< reco::TrackCollection > &) const
Definition: CosmicMuonLinksProducer.cc:103
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
edm::AssociationMap::size
size_type size() const
map size
Definition: AssociationMap.h:162
edm::AssociationMap
Definition: AssociationMap.h:48
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
iEvent
int iEvent
Definition: GenABIO.cc:224
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:15
edm::EDConsumerBase::labelsForToken
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
Definition: EDConsumerBase.cc:347
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
DetId::Muon
Definition: DetId.h:26
genParticles_cff.map
map
Definition: genParticles_cff.py:11
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
globals_cff.id2
id2
Definition: globals_cff.py:33
CosmicMuonLinksProducer::theTrackLinkNames
std::vector< std::pair< std::string, std::string > > theTrackLinkNames
Definition: CosmicMuonLinksProducer.h:34
edm::InputTag
Definition: InputTag.h:15
edm::ProductLabels
Definition: ProductLabels.h:4
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37