CMS 3D CMS Logo

GlobalMuonProducer.cc
Go to the documentation of this file.
1 
12 // Framework
20 
22 
23 // TrackFinder and specific GLB Trajectory Builder
28 
29 using namespace edm;
30 using namespace std;
31 
32 //
33 // constructor with config
34 //
36  LogTrace("Muon|RecoMuon|GlobalMuonProducer") << "constructor called" << endl;
37 
38  // Parameter set for the Builder
39  ParameterSet trajectoryBuilderParameters = parameterSet.getParameter<ParameterSet>("GLBTrajBuilderParameters");
40  InputTag trackCollectionTag = parameterSet.getParameter<InputTag>("TrackerCollectionLabel");
41  trajectoryBuilderParameters.addParameter<InputTag>("TrackerCollectionLabel", trackCollectionTag);
42 
43  // STA Muon Collection Label
44  theSTACollectionLabel = parameterSet.getParameter<InputTag>("MuonCollectionLabel");
45  staMuonsToken = consumes<reco::TrackCollection>(parameterSet.getParameter<InputTag>("MuonCollectionLabel"));
46  staMuonsTrajToken =
47  consumes<std::vector<Trajectory> >(parameterSet.getParameter<InputTag>("MuonCollectionLabel").label());
48  staAssoMapToken =
49  consumes<TrajTrackAssociationCollection>(parameterSet.getParameter<InputTag>("MuonCollectionLabel").label());
50  updatedStaAssoMapToken =
51  consumes<reco::TrackToTrackMap>(parameterSet.getParameter<InputTag>("MuonCollectionLabel").label());
52 
53  // service parameters
54  ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
55 
56  // TrackLoader parameters
57  ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
58 
59  // the services
60  theService = new MuonServiceProxy(serviceParameters, consumesCollector());
61 
62  // instantiate the concrete trajectory builder in the Track Finder
63  edm::ConsumesCollector iC = consumesCollector();
64  auto mtl = std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService);
65  auto gmtb = std::make_unique<GlobalMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService, iC);
66 
67  theTrackFinder = std::make_unique<MuonTrackFinder>(std::move(gmtb), std::move(mtl), iC);
68 
69  setAlias(parameterSet.getParameter<std::string>("@module_label"));
70  produces<reco::TrackCollection>().setBranchAlias(theAlias + "Tracks");
71  produces<TrackingRecHitCollection>().setBranchAlias(theAlias + "RecHits");
72  produces<reco::TrackExtraCollection>().setBranchAlias(theAlias + "TrackExtras");
73  produces<vector<Trajectory> >().setBranchAlias(theAlias + "Trajectories");
74  produces<TrajTrackAssociationCollection>().setBranchAlias(theAlias + "TrajTrackMap");
75  produces<reco::MuonTrackLinksCollection>().setBranchAlias(theAlias + "s");
76 }
77 
78 //
79 // destructor
80 //
82  LogTrace("Muon|RecoMuon|GlobalMuonProducer") << "destructor called" << endl;
83  if (theService)
84  delete theService;
85 }
86 
87 //
88 // reconstruct muons
89 //
91  const string metname = "Muon|RecoMuon|GlobalMuonProducer";
92  LogTrace(metname) << endl << endl << endl;
93  LogTrace(metname) << "Global Muon Reconstruction started" << endl;
94 
95  // Update the services
96  theService->update(eventSetup);
97 
98  // Take the STA muon container(s)
100  event.getByToken(staMuonsToken, staMuons);
101 
102  Handle<vector<Trajectory> > staMuonsTraj;
103 
104  LogTrace(metname) << "Taking " << staMuons->size() << " Stand Alone Muons " << endl;
105 
106  vector<MuonTrajectoryBuilder::TrackCand> staTrackCands;
107 
109 
110  edm::Handle<reco::TrackToTrackMap> updatedStaAssoMap;
111 
112  if (event.getByToken(staMuonsTrajToken, staMuonsTraj) && event.getByToken(staAssoMapToken, staAssoMap) &&
113  event.getByToken(updatedStaAssoMapToken, updatedStaAssoMap)) {
114  for (TrajTrackAssociationCollection::const_iterator it = staAssoMap->begin(); it != staAssoMap->end(); ++it) {
115  const Ref<vector<Trajectory> > traj = it->key;
116  const reco::TrackRef tkRegular = it->val;
117  reco::TrackRef tkUpdated;
120  if (theSTACollectionLabel.instance() == "UpdatedAtVtx") {
121  iEnd = updatedStaAssoMap->end();
122  iii = updatedStaAssoMap->find(it->val);
123  if (iii != iEnd)
124  tkUpdated = (*updatedStaAssoMap)[it->val];
125  }
126 
127  int etaFlip1 =
128  ((tkUpdated.isNonnull() && tkRegular.isNonnull()) && ((tkUpdated->eta() * tkRegular->eta()) < 0)) ? -1 : 1;
129 
130  const reco::TrackRef tk = (tkUpdated.isNonnull() && etaFlip1 == 1) ? tkUpdated : tkRegular;
131 
133  if (traj->isValid())
134  tkCand.first = &*traj;
135  staTrackCands.push_back(tkCand);
136  }
137  } else {
138  for (unsigned int position = 0; position != staMuons->size(); ++position) {
139  reco::TrackRef staTrackRef(staMuons, position);
141  staTrackCands.push_back(staCand);
142  }
143  }
144 
145  theTrackFinder->reconstruct(staTrackCands, event, eventSetup);
146 
147  LogTrace(metname) << "Event loaded"
148  << "================================" << endl
149  << endl;
150 }
Handle.h
edm::AssociationMap::find
const_iterator find(const key_type &k) const
find element with specified reference key
Definition: AssociationMap.h:173
GlobalMuonTrajectoryBuilder.h
MessageLogger.h
EDProducer.h
edm
HLT enums.
Definition: AlignableModifier.h:19
GlobalMuonProducer::GlobalMuonProducer
GlobalMuonProducer(const edm::ParameterSet &)
constructor with config
Definition: GlobalMuonProducer.cc:35
GlobalMuonProducer::~GlobalMuonProducer
~GlobalMuonProducer() override
destructor
Definition: GlobalMuonProducer.cc:81
cosmics_id.trackCollectionTag
trackCollectionTag
Definition: cosmics_id.py:5
edm::Handle< reco::TrackCollection >
GlobalMuonProducer.h
MuonServiceProxy_cff.MuonServiceProxy
MuonServiceProxy
Definition: MuonServiceProxy_cff.py:14
edm::Ref
Definition: AssociativeIterator.h:58
edm::parameterSet
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition: AssociationMap.h:171
MuonTrackLoader.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator
friend struct const_iterator
Definition: AssociationMap.h:274
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
edm::ParameterSet::addParameter
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:135
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
MuonTrackFinder.h
edm::EventSetup
Definition: EventSetup.h:58
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Trajectory
Definition: Trajectory.h:38
MuonServiceProxy.h
edm::AssociationMap::begin
const_iterator begin() const
first iterator over the map (read only)
Definition: AssociationMap.h:169
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MuonTrajectoryBuilder::TrackCand
std::pair< const Trajectory *, reco::TrackRef > TrackCand
Definition: MuonTrajectoryBuilder.h:25
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
ConsumesCollector.h
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::AssociationMap::const_iterator
const iterator
Definition: AssociationMap.h:76
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
label
const char * label
Definition: PFTauDecayModeTools.cc:11
GlobalMuonProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
reconstruct muons
Definition: GlobalMuonProducer.cc:90
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40