CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalMuonTrackMixer.cc
Go to the documentation of this file.
1 
23 
27 
29 
30 #include <vector>
31 
33 {
34  public:
35  explicit GlobalMuonTrackMixer(const edm::ParameterSet&);
37 
38  private:
39  virtual void produceTrackExtras(edm::Event&, const edm::EventSetup&);
40 
41  typedef std::vector<reco::MuonTrackLinks> MuonTrackLinksCollection;
42 };
43 
45  : TrackMixerBase(cfg)
46 {
47  for ( typename std::vector<todoListEntryType>::const_iterator todoItem = todoList_.begin();
48  todoItem != todoList_.end(); ++todoItem ) {
49  produces<MuonTrackLinksCollection>(todoItem->srcTrackCollection1_.instance());
50  }
51 }
52 
53 namespace
54 {
55  reco::MuonTrackLinks makeMuonTrackLink(const reco::MuonTrackLinks& trackLink, const std::map<reco::TrackRef, reco::TrackRef>& trackRefMap)
56  {
57  reco::MuonTrackLinks trackLink_output;
58  trackLink_output.setTrackerTrack(trackLink.trackerTrack());
59  trackLink_output.setStandAloneTrack(trackLink.standAloneTrack());
60  trackLink_output.setGlobalTrack(trackLink.globalTrack());
61 
62  // update edm::Refs to globalMuon collection
63  for ( std::map<reco::TrackRef, reco::TrackRef>::const_iterator outputToInputTrackAssociation = trackRefMap.begin();
64  outputToInputTrackAssociation != trackRefMap.end(); ++outputToInputTrackAssociation ) {
65  reco::TrackRef track_output = outputToInputTrackAssociation->first;
66  reco::TrackRef track_input = outputToInputTrackAssociation->second;
67  if ( track_input == trackLink.globalTrack() ) trackLink_output.setGlobalTrack(track_output);
68  }
69 
70  return trackLink_output;
71  }
72 }
73 
75 {
76  if ( verbosity_ ) std::cout << "<GlobalMuonTrackMixer::produceTrackExtras (" << moduleLabel_ << ")>:" << std::endl;
77 
78  for ( typename std::vector<todoListEntryType>::const_iterator todoItem = todoList_.begin();
79  todoItem != todoList_.end(); ++todoItem ) {
80  edm::Handle<MuonTrackLinksCollection> trackLinksCollection1;
81  evt.getByLabel(todoItem->srcTrackCollection1_, trackLinksCollection1);
82 
83  edm::Handle<MuonTrackLinksCollection> trackLinksCollection2;
84  evt.getByLabel(todoItem->srcTrackCollection2_, trackLinksCollection2);
85 
86  std::auto_ptr<MuonTrackLinksCollection> trackLinks_output(new MuonTrackLinksCollection());
87 
88  for ( MuonTrackLinksCollection::const_iterator trackLink = trackLinksCollection1->begin();
89  trackLink != trackLinksCollection1->end(); ++trackLink ) {
90  reco::MuonTrackLinks trackLink_output = makeMuonTrackLink(*trackLink, todoItem->trackRefMap_);
91  trackLinks_output->push_back(trackLink_output);
92  }
93  for ( MuonTrackLinksCollection::const_iterator trackLink = trackLinksCollection2->begin();
94  trackLink != trackLinksCollection2->end(); ++trackLink ) {
95  reco::MuonTrackLinks trackLink_output = makeMuonTrackLink(*trackLink, todoItem->trackRefMap_);
96  trackLinks_output->push_back(trackLink_output);
97  }
98 
99  if ( verbosity_ ) {
100  std::cout << "instanceLabel = " << todoItem->srcTrackCollection1_.instance() << ": #entries = " << trackLinks_output->size() << std::endl;
101  int idx = 0;
102  for ( MuonTrackLinksCollection::const_iterator trackLink = trackLinks_output->begin();
103  trackLink != trackLinks_output->end(); ++trackLink ) {
104  std::cout << "trackLink #" << idx << ":" << std::endl;
105  std::cout << " trackerTrack = " << trackLink->trackerTrack().id() << ":" << trackLink->trackerTrack().key() << std::endl;
106  std::cout << " standAloneTrack = " << trackLink->standAloneTrack().id() << ":" << trackLink->standAloneTrack().key() << std::endl;
107  std::cout << " globalTrack = " << trackLink->globalTrack().id() << ":" << trackLink->globalTrack().key() << std::endl;
108  ++idx;
109  }
110  }
111 
112  evt.put(trackLinks_output, todoItem->srcTrackCollection1_.instance());
113  }
114 }
115 
117 
std::vector< todoListEntryType > todoList_
tuple cfg
Definition: looper.py:293
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
key_type key() const
Accessor for product key.
Definition: Ref.h:264
virtual void produceTrackExtras(edm::Event &, const edm::EventSetup &)
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:120
GlobalMuonTrackMixer(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
std::vector< reco::MuonTrackLinks > MuonTrackLinksCollection
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:121
std::string moduleLabel_