CMS 3D CMS Logo

GlobalMuonToMuonProducer.cc
Go to the documentation of this file.
1 
8 
13 
14 // tmp
20 
23  theLinksCollectionLabel = pSet.getParameter<edm::InputTag>("InputObjects");
24 
25  setAlias(pSet.getParameter<std::string>("@module_label"));
26  produces<reco::MuonCollection>().setBranchAlias(theAlias + "s");
27  trackLinkToken_ = consumes<reco::MuonTrackLinksCollection>(theLinksCollectionLabel);
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  eventSetup.get<GlobalTrackingGeometryRecord>().get(trackingGeometry);
68 
69  for (reco::MuonTrackLinksCollection::const_iterator links = linksCollection->begin(); links != linksCollection->end();
70  ++links) {
71  // some temporary print-out
72  LogTrace(metname) << "trackerTrack";
73  printTrackRecHits(*(links->trackerTrack()), trackingGeometry);
74  LogTrace(metname) << "standAloneTrack";
75  printTrackRecHits(*(links->standAloneTrack()), trackingGeometry);
76  LogTrace(metname) << "globalTrack";
77  printTrackRecHits(*(links->globalTrack()), trackingGeometry);
78 
79  // Fill the muon
81  muon.setStandAlone(links->standAloneTrack());
82  muon.setTrack(links->trackerTrack());
83  muon.setCombined(links->globalTrack());
84 
85  // FIXME: can this break in case combined info cannot be added to some tracks?
86  muon.setCharge(links->globalTrack()->charge());
87 
88  //FIXME: E = sqrt(p^2 + m^2), where m == 0.105658369(9)GeV
89  double energy = sqrt(links->globalTrack()->p() * links->globalTrack()->p() + 0.011163691);
91  links->globalTrack()->px(), links->globalTrack()->py(), links->globalTrack()->pz(), energy);
92 
93  muon.setP4(p4);
94  muon.setVertex(links->globalTrack()->vertex());
95 
96  muonCollection->push_back(muon);
97  }
98 
99  event.put(std::move(muonCollection));
100 }
T getParameter(std::string const &) const
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
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
double p4[4]
Definition: TauolaWrapper.h:92
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
#define LogTrace(id)
void printTrackRecHits(const reco::Track &track, edm::ESHandle< GlobalTrackingGeometry > trackingGeometry) const
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
T get() const
Definition: EventSetup.h:73
const GeomDet * idToDet(DetId) const override
const PositionType & position() const
void setP4(const LorentzVector &p4) final
set 4-momentum
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91