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 //
36 TevMuonProducer::TevMuonProducer(const ParameterSet& parameterSet) : tTopoToken(esConsumes()) {
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
95  const TrackerTopology* tTopo = &eventSetup.getData(tTopoToken);
96 
97  // Take the GLB muon container(s)
99  event.getByToken(glbMuonsToken, glbMuons);
100 
101  auto dytInfo = std::make_unique<DYTestimators>();
102  DYTestimators::Filler filler(*dytInfo);
103  size_t GLBmuonSize = glbMuons->size();
104  vector<DYTInfo> dytTmp(GLBmuonSize);
105 
106  Handle<vector<Trajectory> > glbMuonsTraj;
107 
108  LogTrace(metname) << "Taking " << glbMuons->size() << " Global Muons " << theGLBCollectionLabel << endl;
109 
110  vector<MuonTrajectoryBuilder::TrackCand> glbTrackCands;
111 
112  event.getByToken(glbMuonsTrajToken, glbMuonsTraj);
113 
114  const reco::TrackCollection* glbTracks = glbMuons.product();
115 
116  for (unsigned int ww = 0; ww < theRefits.size(); ww++) {
117  LogDebug(metname) << "TeVRefit for Refit: " << theRefitIndex[ww];
118  std::vector<std::pair<Trajectory*, reco::TrackRef> > miniMap;
120  reco::TrackRef::key_type trackIndex = 0;
121  int glbCounter = 0;
122  for (reco::TrackCollection::const_iterator track = glbTracks->begin(); track != glbTracks->end();
123  track++, ++trackIndex) {
124  reco::TrackRef glbRef(glbMuons, trackIndex);
125 
126  vector<Trajectory> refitted = theRefitter->refit(*track, theRefitIndex[ww], tTopo);
127 
128  if (theRefits[ww] == "dyt")
129  dytTmp[glbCounter] = *theRefitter->getDYTInfo();
130  glbCounter++;
131 
132  if (!refitted.empty()) {
133  auto refit = std::make_unique<Trajectory>(refitted.front());
134  LogDebug(metname) << "TeVTrackLoader for Refit: " << theRefits[ww];
135  std::pair<Trajectory*, reco::TrackRef> thisPair(refit.get(), glbRef);
136  miniMap.push_back(thisPair);
137  trajectories.push_back(std::move(refit));
138  }
139  }
140  theTrackLoader->loadTracks(trajectories, event, miniMap, glbMuons, *tTopo, theRefits[ww]);
141  }
142 
143  filler.insert(glbMuons, dytTmp.begin(), dytTmp.end());
144  filler.fill();
145  event.put(std::move(dytInfo), "dytInfo");
146 
147  LogTrace(metname) << "Done." << endl;
148 }
Handle.h
GlobalMuonRefitter.h
GlobalMuonTrajectoryBuilder.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11776
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
TevMuonProducer::theRefitter
std::unique_ptr< GlobalMuonRefitter > theRefitter
Definition: TevMuonProducer.h:60
FastTrackerRecHitMaskProducer_cfi.trajectories
trajectories
Definition: FastTrackerRecHitMaskProducer_cfi.py:7
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::TrackCollection >
edm::Ref< TrackCollection >
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
TrackerTopologyRcd.h
MuonTrackLoader.h
TevMuonProducer::theGLBCollectionLabel
edm::InputTag theGLBCollectionLabel
STA Label.
Definition: TevMuonProducer.h:52
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
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
TevMuonProducer::glbMuonsTrajToken
edm::EDGetTokenT< std::vector< Trajectory > > glbMuonsTrajToken
Definition: TevMuonProducer.h:54
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::tTopoToken
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken
Definition: TevMuonProducer.h:55
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
TevMuonProducer::TevMuonProducer
TevMuonProducer(const edm::ParameterSet &)
constructor with config
Definition: TevMuonProducer.cc:36
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
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TevMuonProducer::theRefits
std::vector< std::string > theRefits
Definition: TevMuonProducer.h:65
TevMuonProducer::theRefitIndex
std::vector< int > theRefitIndex
Definition: TevMuonProducer.h:66
TevMuonProducer::glbMuonsToken
edm::EDGetTokenT< reco::TrackCollection > glbMuonsToken
Definition: TevMuonProducer.h:53
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:224
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:45
TevMuonProducer::theService
std::unique_ptr< MuonServiceProxy > theService
the event setup proxy, it takes care the services update
Definition: TevMuonProducer.h:58
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40
TevMuonProducer::theTrackLoader
std::unique_ptr< MuonTrackLoader > theTrackLoader
Definition: TevMuonProducer.h:62