CMS 3D CMS Logo

TrajectorySeedFromMuonProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Authors: Y.Gao (FNAL)
4 //
5 // system include files
6 #include <memory>
7 
8 // user include files
17 
18 // related to reco::Track
21 
22 // related to reco::Muon
25 
26 // TrajectorSeed Related
30 
31 // TrajectorSeed Related
40 
45 
47 
49 public:
51  void produce(edm::Event&, const edm::EventSetup&) override;
52 
53 private:
61 };
62 
64  muonCollectionTag_ = iConfig.getParameter<edm::InputTag>("muonCollectionTag");
65  trackCollectionTag_ = iConfig.getParameter<edm::InputTag>("trackCollectionTag");
66  skipMatchedMuons_ = iConfig.getParameter<bool>("skipMatchedMuons");
67 
68  muonCollectionToken_ = consumes<edm::View<reco::Muon> >(muonCollectionTag_);
69  trackCollectionToken_ = consumes<reco::TrackCollection>(trackCollectionTag_);
70  magneticFieldToken_ = esConsumes<MagneticField, IdealMagneticFieldRecord>();
71  trackerGeometryToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
72 
73  produces<TrajectorySeedCollection>();
74 }
75 
77  using namespace edm;
78  using namespace reco;
79  using namespace std;
80 
81  // Product
82  auto result = std::make_unique<TrajectorySeedCollection>();
83 
85 
87 
88  edm::Handle<edm::View<Muon> > muonCollectionHandle;
89  iEvent.getByToken(muonCollectionToken_, muonCollectionHandle);
90 
91  edm::Handle<reco::TrackCollection> trackCollectionHandle;
92  iEvent.getByToken(trackCollectionToken_, trackCollectionHandle);
93 
94  // Loop over the muon track
95  for (edm::View<Muon>::const_iterator muon = muonCollectionHandle->begin(); muon != muonCollectionHandle->end();
96  ++muon) {
97  // muon must have a tracker track
98  if (muon->innerTrack().isNull())
99  continue;
100  edm::RefToBase<reco::Track> track(muon->innerTrack());
101  // check if there is a back-to-back track
102  if (skipMatchedMuons_ && muonid::findOppositeTrack(trackCollectionHandle, *track).isNonnull())
103  continue;
104  if ((!track->innerOk()) || (!track->recHit(0)->isValid()))
105  continue;
106  GlobalPoint innerPosition(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
107  GlobalVector innerMomentum(track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
108  int charge = track->charge();
109  const reco::Track::CovarianceMatrix innerStateCovariance = track->innerStateCovariance();
110  DetId innerDetId = DetId(track->innerDetId());
111  // Construct the information necessary to make a TrajectoryStateOnSurface
112  GlobalTrajectoryParameters globalTrajParams(innerPosition, innerMomentum, charge, &(*magneticField));
113  CurvilinearTrajectoryError curviError(innerStateCovariance);
114  FreeTrajectoryState tracker_state(globalTrajParams, curviError);
115  LogTrace("MuonIdentification") << "Track Inner FTS: " << tracker_state;
116 
117  TrajectoryStateOnSurface tracker_tsos =
118  TrajectoryStateOnSurface(globalTrajParams, curviError, trackerGeometry->idToDet(innerDetId)->surface());
119 
120  // Make Hits, push back the innermost Hit
122  trackHits.push_back(track->recHit(0)->clone());
123 
124  // Make TrajectorySeed
125  PTrajectoryStateOnDet const& PTraj = trajectoryStateTransform::persistentState(tracker_tsos, innerDetId.rawId());
126  TrajectorySeed trajectorySeed(PTraj, trackHits, oppositeToMomentum);
127  LogTrace("MuonIdentification") << "Trajectory Seed Direction: " << trajectorySeed.direction() << endl;
128  result->push_back(trajectorySeed);
129  }
130 
131  iEvent.put(std::move(result));
132 }
133 
edm::EDGetTokenT< reco::TrackCollection > trackCollectionToken_
void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
edm::EDGetTokenT< edm::View< reco::Muon > > muonCollectionToken_
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
#define LogTrace(id)
void push_back(D *&d)
Definition: OwnVector.h:326
int iEvent
Definition: GenABIO.cc:224
TrajectorySeedFromMuonProducer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const TrackerGeomDet * idToDet(DetId) const override
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
Definition: DetId.h:17
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
def move(src, dest)
Definition: eostools.py:511
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74