test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalMuonTrackCleaner.cc
Go to the documentation of this file.
1 
22 
29 
31 
33 
34 #include <vector>
35 #include <algorithm>
36 
38 {
39  public:
42 
43  private:
44  virtual void produceTrackExtras(edm::Event&, const edm::EventSetup&);
45 
47 
48  typedef std::vector<reco::MuonTrackLinks> MuonTrackLinksCollection;
49 };
50 
52  : MuonTrackCleanerBase(cfg),
53  srcMuons_(cfg.getParameter<edm::InputTag>("srcMuons"))
54 {
55  for ( typename std::vector<todoListEntryType>::const_iterator todoItem = todoList_.begin();
56  todoItem != todoList_.end(); ++todoItem ) {
57  produces<MuonTrackLinksCollection>(todoItem->srcTracks_.instance());
58  }
59 }
60 
62 {
63  if ( verbosity_ ) std::cout << "<GlobalMuonTrackCleaner::produceTrackExtras (" << moduleLabel_ << ")>:" << std::endl;
64 
66  evt.getByLabel(srcMuons_, muons);
67 
68  for ( typename std::vector<todoListEntryType>::const_iterator todoItem = todoList_.begin();
69  todoItem != todoList_.end(); ++todoItem ) {
70  std::auto_ptr<MuonTrackLinksCollection> trackLinks_cleaned(new MuonTrackLinksCollection());
71 
72  for ( std::map<reco::TrackRef, reco::TrackRef>::const_iterator cleanedToUncleanedTrackAssociation = todoItem->trackRefMap_.begin();
73  cleanedToUncleanedTrackAssociation != todoItem->trackRefMap_.end(); ++cleanedToUncleanedTrackAssociation ) {
74  const reco::Muon* matchedMuon = 0;
75  double dRmatch = 1.e+3;
76  for ( reco::MuonCollection::const_iterator muon = muons->begin();
77  muon != muons->end(); ++muon ) {
78  if ( muon->globalTrack().isNull() ) continue;
79  if ( muon->globalTrack() == cleanedToUncleanedTrackAssociation->second ) { // match by edm::Ref
80  matchedMuon = &(*muon);
81  dRmatch = 0.;
82  break;
83  } else { // match by dR
84  double dR = reco::deltaR(muon->globalTrack()->eta(), muon->globalTrack()->phi(), cleanedToUncleanedTrackAssociation->second->eta(), cleanedToUncleanedTrackAssociation->second->phi());
85  if ( dR < 1.e-2 && dR < dRmatch ) {
86  matchedMuon = &(*muon);
87  dRmatch = dR;
88  }
89  }
90  }
91  if ( matchedMuon ) {
92  reco::MuonTrackLinks trackLink;
93  trackLink.setTrackerTrack(matchedMuon->innerTrack());
94  trackLink.setStandAloneTrack(matchedMuon->outerTrack());
95  trackLink.setGlobalTrack(cleanedToUncleanedTrackAssociation->first);
96  if ( verbosity_ ) {
97  std::cout << "creating new MuonTrackLinks:" << std::endl;
98  std::cout << " innerTrack = " << trackLink.trackerTrack().id() << ":" << trackLink.trackerTrack().key() << std::endl;
99  std::cout << " outerTrack = " << trackLink.standAloneTrack().id() << ":" << trackLink.standAloneTrack().key() << std::endl;
100  std::cout << " globalTrack = " << trackLink.globalTrack().id() << ":" << trackLink.globalTrack().key() << std::endl;
101  }
102  trackLinks_cleaned->push_back(trackLink);
103  }
104  }
105 
106  evt.put(trackLinks_cleaned, todoItem->srcTracks_.instance());
107  }
108 }
109 
111 
tuple cfg
Definition: looper.py:293
virtual TrackRef innerTrack() const
Definition: Muon.h:48
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
key_type key() const
Accessor for product key.
Definition: Ref.h:264
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
GlobalMuonTrackCleaner(const edm::ParameterSet &)
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
std::vector< reco::MuonTrackLinks > MuonTrackLinksCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
virtual void produceTrackExtras(edm::Event &, const edm::EventSetup &)
tuple muons
Definition: patZpeak.py:38
tuple cout
Definition: gather_cfg.py:145
std::vector< todoListEntryType > todoList_