CMS 3D CMS Logo

TevMuonProducer.cc
Go to the documentation of this file.
1 
10 // Framework
19 
21 
22 // TrackFinder and specific GLB Trajectory Builder
28 
29 using namespace edm;
30 using namespace std;
31 using namespace reco;
32 
33 //
34 // constructor with config
35 //
37  LogDebug("Muon|RecoMuon|TevMuonProducer") << "constructor called" << endl;
38 
39  // GLB Muon Collection Label
40  theGLBCollectionLabel = parameterSet.getParameter<InputTag>("MuonCollectionLabel");
41  glbMuonsToken = consumes<reco::TrackCollection>(theGLBCollectionLabel);
42  glbMuonsTrajToken = consumes<std::vector<Trajectory> >(theGLBCollectionLabel.label());
43 
44  // service parameters
45  ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
46 
47  // the services
48  theService = std::make_unique<MuonServiceProxy>(serviceParameters, consumesCollector());
49  edm::ConsumesCollector iC = consumesCollector();
50 
51  // TrackRefitter parameters
52  ParameterSet refitterParameters = parameterSet.getParameter<ParameterSet>("RefitterParameters");
53  theRefitter = std::make_unique<GlobalMuonRefitter>(refitterParameters, theService.get(), iC);
54 
55  // TrackLoader parameters
56  ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
57  theTrackLoader = std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get());
58 
59  theRefits = parameterSet.getParameter<std::vector<std::string> >("Refits");
60  theRefitIndex = parameterSet.getParameter<std::vector<int> >("RefitIndex");
61 
62  for (unsigned int ww = 0; ww < theRefits.size(); ww++) {
63  LogDebug("Muon|RecoMuon|TevMuonProducer") << "Refit " << theRefits[ww];
64  produces<reco::TrackCollection>(theRefits[ww]);
65  produces<TrackingRecHitCollection>(theRefits[ww]);
66  produces<reco::TrackExtraCollection>(theRefits[ww]);
67  produces<vector<Trajectory> >(theRefits[ww]);
68  produces<TrajTrackAssociationCollection>(theRefits[ww]);
69  produces<reco::TrackToTrackMap>(theRefits[ww]);
70  }
71  produces<DYTestimators>("dytInfo");
72 }
73 
74 //
75 // destructor
76 //
77 TevMuonProducer::~TevMuonProducer() { LogTrace("Muon|RecoMuon|TevMuonProducer") << "destructor called" << endl; }
78 
79 //
80 // reconstruct muons
81 //
82 void TevMuonProducer::produce(Event& event, const EventSetup& eventSetup) {
83  const string metname = "Muon|RecoMuon|TevMuonProducer";
84  LogTrace(metname) << endl << endl;
85  LogTrace(metname) << "TeV Muon Reconstruction started" << endl;
86 
87  // Update the services
88  theService->update(eventSetup);
89 
90  theRefitter->setEvent(event);
91 
92  theRefitter->setServices(theService->eventSetup());
93 
94  //Retrieve tracker topology from geometry
96  eventSetup.get<TrackerTopologyRcd>().get(tTopoHand);
97  const TrackerTopology* tTopo = tTopoHand.product();
98 
99  // Take the GLB muon container(s)
101  event.getByToken(glbMuonsToken, glbMuons);
102 
103  auto dytInfo = std::make_unique<DYTestimators>();
104  DYTestimators::Filler filler(*dytInfo);
105  size_t GLBmuonSize = glbMuons->size();
106  vector<DYTInfo> dytTmp(GLBmuonSize);
107 
108  Handle<vector<Trajectory> > glbMuonsTraj;
109 
110  LogTrace(metname) << "Taking " << glbMuons->size() << " Global Muons " << theGLBCollectionLabel << endl;
111 
112  vector<MuonTrajectoryBuilder::TrackCand> glbTrackCands;
113 
114  event.getByToken(glbMuonsTrajToken, glbMuonsTraj);
115 
116  const reco::TrackCollection* glbTracks = glbMuons.product();
117 
118  for (unsigned int ww = 0; ww < theRefits.size(); ww++) {
119  LogDebug(metname) << "TeVRefit for Refit: " << theRefitIndex[ww];
120  std::vector<std::pair<Trajectory*, reco::TrackRef> > miniMap;
122  reco::TrackRef::key_type trackIndex = 0;
123  int glbCounter = 0;
124  for (reco::TrackCollection::const_iterator track = glbTracks->begin(); track != glbTracks->end();
125  track++, ++trackIndex) {
126  reco::TrackRef glbRef(glbMuons, trackIndex);
127 
128  vector<Trajectory> refitted = theRefitter->refit(*track, theRefitIndex[ww], tTopo);
129 
130  if (theRefits[ww] == "dyt")
131  dytTmp[glbCounter] = *theRefitter->getDYTInfo();
132  glbCounter++;
133 
134  if (!refitted.empty()) {
135  auto refit = std::make_unique<Trajectory>(refitted.front());
136  LogDebug(metname) << "TeVTrackLoader for Refit: " << theRefits[ww];
137  std::pair<Trajectory*, reco::TrackRef> thisPair(refit.get(), glbRef);
138  miniMap.push_back(thisPair);
139  trajectories.push_back(std::move(refit));
140  }
141  }
142  theTrackLoader->loadTracks(trajectories, event, miniMap, glbMuons, *tTopo, theRefits[ww]);
143  }
144 
145  filler.insert(glbMuons, dytTmp.begin(), dytTmp.end());
146  filler.fill();
147  event.put(std::move(dytInfo), "dytInfo");
148 
149  LogTrace(metname) << "Done." << endl;
150 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
Handle.h
GlobalMuonRefitter.h
GlobalMuonTrajectoryBuilder.h
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EDProducer.h
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
FastTrackerRecHitMaskProducer_cfi.trajectories
trajectories
Definition: FastTrackerRecHitMaskProducer_cfi.py:7
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::TrackCollection >
edm::Ref< TrackCollection >
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
MuonTrackLoader.h
edm::ESHandle< TrackerTopology >
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
TevMuonProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
reconstruct muons
Definition: TevMuonProducer.cc:82
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:669
MuonTrackFinder.h
edm::EventSetup
Definition: EventSetup.h:57
edm::Ref< TrackCollection >::key_type
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
TevMuonProducer::TevMuonProducer
TevMuonProducer(const edm::ParameterSet &)
constructor with config
Definition: TevMuonProducer.cc:36
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TevMuonProducer.h
MuonServiceProxy.h
edm::parameterSet
ParameterSet const & parameterSet(Provenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
EventSetup.h
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
MuonTrackLoader::TrajectoryContainer
MuonCandidate::TrajectoryContainer TrajectoryContainer
Definition: MuonTrackLoader.h:45
ConsumesCollector.h
edm::helper::Filler
Definition: ValueMap.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
TevMuonProducer::~TevMuonProducer
~TevMuonProducer() override
destructor
Definition: TevMuonProducer.cc:77
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:43