CMS 3D CMS Logo

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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > trackingGeomToken_
T perp() const
Definition: PV3DBase.h:69
edm::EDGetTokenT< reco::MuonTrackLinksCollection > trackLinkToken_
GlobalMuonToMuonProducer(const edm::ParameterSet &)
Constructor.
~GlobalMuonToMuonProducer() override
Destructor.
const std::string metname
const GeomDet * idToDet(DetId) const override
#define LogTrace(id)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void setAlias(std::string alias)
T sqrt(T t)
Definition: SSEVec.h:23
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
void printTrackRecHits(const reco::Track &track, edm::ESHandle< GlobalTrackingGeometry > trackingGeometry) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const PositionType & position() const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
reconstruct muons
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1