CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GlobalMuonToMuonProducer.cc
Go to the documentation of this file.
1 
8 
13 
14 // tmp
19 
22  theLinksCollectionLabel = pSet.getParameter<edm::InputTag>("InputObjects");
23 
24  setAlias(pSet.getParameter<std::string>("@module_label"));
25  produces<reco::MuonCollection>().setBranchAlias(theAlias + "s");
26  trackLinkToken_ = consumes<reco::MuonTrackLinksCollection>(theLinksCollectionLabel);
27  trackingGeomToken_ = esConsumes<GlobalTrackingGeometry, GlobalTrackingGeometryRecord>();
28 }
29 
32 
34  edm::ESHandle<GlobalTrackingGeometry> trackingGeometry) const {
35  const std::string metname = "Muon|RecoMuon|MuonIdentification|GlobalMuonToMuonProducer";
36 
37  LogTrace(metname) << "Valid RecHits: " << track.found() << " invalid RecHits: " << track.lost();
38 
39  int i = 0;
40  for (trackingRecHit_iterator recHit = track.recHitsBegin(); recHit != track.recHitsEnd(); ++recHit)
41  if ((*recHit)->isValid()) {
42  const GeomDet* geomDet = trackingGeometry->idToDet((*recHit)->geographicalId());
43  double r = geomDet->surface().position().perp();
44  double z = geomDet->toGlobal((*recHit)->localPosition()).z();
45  LogTrace(metname) << i++ << " r: " << r << " z: " << z << " " << geomDet->toGlobal((*recHit)->localPosition())
46  << std::endl;
47  }
48 }
49 
52  const std::string metname = "Muon|RecoMuon|MuonIdentification|GlobalMuonToMuonProducer";
53 
54  // the muon collection, it will be loaded in the event
55  auto muonCollection = std::make_unique<reco::MuonCollection>();
56 
58  event.getByToken(trackLinkToken_, linksCollection);
59 
60  if (linksCollection->empty()) {
61  event.put(std::move(muonCollection));
62  return;
63  }
64 
65  // Global Tracking Geometry
67 
68  for (reco::MuonTrackLinksCollection::const_iterator links = linksCollection->begin(); links != linksCollection->end();
69  ++links) {
70  // some temporary print-out
71  LogTrace(metname) << "trackerTrack";
72  printTrackRecHits(*(links->trackerTrack()), trackingGeometry);
73  LogTrace(metname) << "standAloneTrack";
74  printTrackRecHits(*(links->standAloneTrack()), trackingGeometry);
75  LogTrace(metname) << "globalTrack";
76  printTrackRecHits(*(links->globalTrack()), trackingGeometry);
77 
78  // Fill the muon
80  muon.setStandAlone(links->standAloneTrack());
81  muon.setTrack(links->trackerTrack());
82  muon.setCombined(links->globalTrack());
83 
84  // FIXME: can this break in case combined info cannot be added to some tracks?
85  muon.setCharge(links->globalTrack()->charge());
86 
87  //FIXME: E = sqrt(p^2 + m^2), where m == 0.105658369(9)GeV
88  double energy = sqrt(links->globalTrack()->p() * links->globalTrack()->p() + 0.011163691);
90  links->globalTrack()->px(), links->globalTrack()->py(), links->globalTrack()->pz(), energy);
91 
92  muon.setP4(p4);
93  muon.setVertex(links->globalTrack()->vertex());
94 
95  muonCollection->push_back(muon);
96  }
97 
98  event.put(std::move(muonCollection));
99 }
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > trackingGeomToken_
edm::EDGetTokenT< reco::MuonTrackLinksCollection > trackLinkToken_
GlobalMuonToMuonProducer(const edm::ParameterSet &)
Constructor.
unsigned short lost() const
Number of lost (=invalid) hits on track.
Definition: Track.h:145
T perp() const
Definition: PV3DBase.h:69
~GlobalMuonToMuonProducer() override
Destructor.
const std::string metname
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
#define LogTrace(id)
void setVertex(const Point &vertex) override
set vertex
void setCharge(Charge q) final
set electric charge
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
virtual void setStandAlone(const TrackRef &t)
void setAlias(std::string alias)
virtual void setCombined(const TrackRef &t)
T sqrt(T t)
Definition: SSEVec.h:19
def move
Definition: eostools.py:511
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
void printTrackRecHits(const reco::Track &track, edm::ESHandle< GlobalTrackingGeometry > trackingGeometry) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
reconstruct muons
virtual void setTrack(const TrackRef &t)
unsigned short found() const
Number of valid hits on track.
Definition: Track.h:142
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
const PositionType & position() const
void setP4(const LorentzVector &p4) final
set 4-momentum
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91