CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~CosmicMuonLinksProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
< edm::InputTag, edm::InputTag > > 
theTrackLinks
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

Date:
2009/01/05 21:58:19
Revision:
1.2

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

Definition at line 18 of file CosmicMuonLinksProducer.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file CosmicMuonLinksProducer.cc.

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

38 {
39 
40  category_ = "Muon|RecoMuon|CosmicMuon|CosmicMuonLinksProducer";
41 
42  ParameterSet serviceParameters = iConfig.getParameter<ParameterSet>("ServiceParameters");
43 
44  theService = new MuonServiceProxy(serviceParameters);
45 
46  std::vector<edm::ParameterSet> theMapPSets = iConfig.getParameter<std::vector<edm::ParameterSet> >("Maps");
47  for (std::vector<edm::ParameterSet>::const_iterator iMPS = theMapPSets.begin();
48  iMPS != theMapPSets.end(); iMPS++) {
49  edm::InputTag subTrackTag = (*iMPS).getParameter<edm::InputTag>("subTrack");
50  edm::InputTag parentTrackTag = (*iMPS).getParameter<edm::InputTag>("parentTrack");
51  theTrackLinks.push_back( make_pair(subTrackTag, parentTrackTag) );
52  }
53 
54  for(std::vector<std::pair<edm::InputTag, edm::InputTag> >::const_iterator iLink = theTrackLinks.begin();
55  iLink != theTrackLinks.end(); iLink++) {
56  LogDebug(category_) << "preparing map between " << (*iLink).first<<" & "<< (*iLink).second;
57  std::string mapname = (*iLink).first.label() + "To" + (*iLink).second.label();
58  produces<reco::TrackToTrackMap>(mapname);
59  }
60 
61 }
#define LogDebug(id)
T getParameter(std::string const &) const
std::vector< std::pair< edm::InputTag, edm::InputTag > > theTrackLinks
CosmicMuonLinksProducer::~CosmicMuonLinksProducer ( )

Definition at line 63 of file CosmicMuonLinksProducer.cc.

64 {
65  if (theService) delete theService;
66 }

Member Function Documentation

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

Definition at line 100 of file CosmicMuonLinksProducer.cc.

References edm::AssociationMap< Tag >::insert(), LogTrace, Association::map, and EgAmbiguityTools::sharedHits().

100  {
102  for ( unsigned int position1 = 0; position1 != subTracks->size(); ++position1) {
103  TrackRef track1(subTracks, position1);
104  for ( unsigned int position2 = 0; position2 != parentTracks->size(); ++position2) {
105  TrackRef track2(parentTracks, position2);
106  int shared = sharedHits(*track1, *track2);
107  LogTrace(category_)<<"sharedHits "<<shared<<" track1 "<<track1->found()<<" track2 "<<track2->found()<<endl;
108 
109  if (shared > (track1->found())/2 ) map.insert(track1, track2);
110  }
111  }
112 
113  return map;
114 }
int sharedHits(const reco::Track &track1, const reco::Track &track2) const
dictionary map
Definition: Association.py:205
#define LogTrace(id)
void insert(const key_type &k, const data_type &v)
insert an association
void CosmicMuonLinksProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 71 of file CosmicMuonLinksProducer.cc.

References edm::Event::getByLabel(), edm::EventBase::id(), LogDebug, LogTrace, edm::Event::put(), edm::AssociationMap< Tag >::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

72 {
73  LogInfo(category_) << "Processing event number: " << iEvent.id();
74 
75  theService->update(iSetup);
76 
77  for(std::vector<std::pair<edm::InputTag, edm::InputTag> >::const_iterator iLink = theTrackLinks.begin();
78  iLink != theTrackLinks.end(); iLink++){
79  LogDebug(category_) << "making map between " << (*iLink).first<<" and "<< (*iLink).second;
80  std::string mapname = (*iLink).first.label() + "To" + (*iLink).second.label();
82 
84  Handle<reco::TrackCollection> parentTracks;
85 
86  if ( iEvent.getByLabel( (*iLink).first, subTracks) && iEvent.getByLabel( (*iLink).second, parentTracks) ) {
87 
88  ttmap = mapTracks(subTracks, parentTracks);
89  LogTrace(category_) << "Mapped: "<<
90 (*iLink).first.label()<<" "<<subTracks->size()<< " and "<<(*iLink).second.label()<<" "<<parentTracks->size()<<", results: "<< ttmap.size() <<endl;
91 
92  }
93 
94  auto_ptr<reco::TrackToTrackMap> trackToTrackmap(new reco::TrackToTrackMap(ttmap));
95  iEvent.put(trackToTrackmap, mapname);
96  }
97 
98 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
#define LogTrace(id)
std::vector< std::pair< edm::InputTag, edm::InputTag > > theTrackLinks
size_type size() const
map size
edm::EventID id() const
Definition: EventBase.h:56
reco::TrackToTrackMap mapTracks(const edm::Handle< reco::TrackCollection > &, const edm::Handle< reco::TrackCollection > &) const
int CosmicMuonLinksProducer::sharedHits ( const reco::Track track1,
const reco::Track track2 
) const
private

Definition at line 116 of file CosmicMuonLinksProducer.cc.

References DetId::det(), alignCSCRings::e, LogTrace, edm::match(), DetId::Muon, DetId::rawId(), reco::Track::recHitsBegin(), and reco::Track::recHitsEnd().

116  {
117 
118  int match = 0;
119 
120  for (trackingRecHit_iterator hit1 = track1.recHitsBegin(); hit1 != track1.recHitsEnd(); ++hit1) {
121  if ( !(*hit1)->isValid() ) continue;
122  DetId id1 = (*hit1)->geographicalId();
123  if ( id1.det() != DetId::Muon ) continue; //ONLY MUON
124  LogTrace(category_)<<"first ID "<<id1.rawId()<<" "<<(*hit1)->localPosition()<<endl;
125  GlobalPoint pos1 = theService->trackingGeometry()->idToDet(id1)->surface().toGlobal((*hit1)->localPosition());
126 
127  for (trackingRecHit_iterator hit2 = track2.recHitsBegin(); hit2 != track2.recHitsEnd(); ++hit2) {
128 
129  if ( !(*hit2)->isValid() ) continue;
130 
131  DetId id2 = (*hit2)->geographicalId();
132  if ( id2.det() != DetId::Muon ) continue; //ONLY MUON
133 
134 // LogTrace(category_)<<"second ID "<<id2.rawId()<< (*hit2)->localPosition()<<endl;
135 
136  if (id2.rawId() != id1.rawId() ) continue;
137 
138  GlobalPoint pos2 = theService->trackingGeometry()->idToDet(id2)->surface().toGlobal((*hit2)->localPosition());
139  if ( ( pos1 - pos2 ).mag()< 10e-5 ) match++;
140 
141  }
142 
143  }
144 
145  return match;
146 
147 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
#define LogTrace(id)
Definition: DetId.h:20
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65

Member Data Documentation

std::string CosmicMuonLinksProducer::category_
private

Definition at line 36 of file CosmicMuonLinksProducer.h.

MuonServiceProxy* CosmicMuonLinksProducer::theService
private

Definition at line 32 of file CosmicMuonLinksProducer.h.

std::vector<std::pair<edm::InputTag, edm::InputTag> > CosmicMuonLinksProducer::theTrackLinks
private

Definition at line 34 of file CosmicMuonLinksProducer.h.