CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TrajectorySeedFromMuonProducer Class Reference
Inheritance diagram for TrajectorySeedFromMuonProducer:
edm::stream::EDProducer<>

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 TrajectorySeedFromMuonProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

edm::InputTag muonCollectionTag_
 
edm::EDGetTokenT< edm::View< reco::Muon > > muonCollectionToken_
 
bool skipMatchedMuons_
 
edm::InputTag trackCollectionTag_
 
edm::EDGetTokenT< reco::TrackCollectiontrackCollectionToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 47 of file TrajectorySeedFromMuonProducer.cc.

Constructor & Destructor Documentation

TrajectorySeedFromMuonProducer::TrajectorySeedFromMuonProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 60 of file TrajectorySeedFromMuonProducer.cc.

References edm::ParameterSet::getParameter(), muonCollectionTag_, muonCollectionToken_, skipMatchedMuons_, trackCollectionTag_, and trackCollectionToken_.

60  {
61  muonCollectionTag_ = iConfig.getParameter<edm::InputTag>("muonCollectionTag");
62  trackCollectionTag_ = iConfig.getParameter<edm::InputTag>("trackCollectionTag");
63  skipMatchedMuons_ = iConfig.getParameter<bool>("skipMatchedMuons");
64 
65  muonCollectionToken_ = consumes<edm::View<reco::Muon> >(muonCollectionTag_);
66  trackCollectionToken_ = consumes<reco::TrackCollection>(trackCollectionTag_);
67 
68  produces<TrajectorySeedCollection>();
69 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > trackCollectionToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonCollectionToken_

Member Function Documentation

void TrajectorySeedFromMuonProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 71 of file TrajectorySeedFromMuonProducer.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, DEFINE_FWK_MODULE, muonid::findOppositeTrack(), edm::EventSetup::get(), edm::Event::getByToken(), TrackerGeometry::idToDet(), edm::Ref< C, T, F >::isNonnull(), LogTrace, HLT_2018_cff::magneticField, eostools::move(), HLT_2018_cff::muon, muonCollectionToken_, oppositeToMomentum, trajectoryStateTransform::persistentState(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), mps_fire::result, skipMatchedMuons_, GeomDet::surface(), HLT_2018_cff::track, and trackCollectionToken_.

71  {
72  using namespace edm;
73  using namespace reco;
74  using namespace std;
75 
76  // Product
77  auto result = std::make_unique<TrajectorySeedCollection>();
78 
80  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
81 
82  edm::ESHandle<TrackerGeometry> trackerGeometry;
83  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
84 
85  edm::Handle<edm::View<Muon> > muonCollectionHandle;
86  iEvent.getByToken(muonCollectionToken_, muonCollectionHandle);
87 
88  edm::Handle<reco::TrackCollection> trackCollectionHandle;
89  iEvent.getByToken(trackCollectionToken_, trackCollectionHandle);
90 
91  // Loop over the muon track
92  for (edm::View<Muon>::const_iterator muon = muonCollectionHandle->begin(); muon != muonCollectionHandle->end();
93  ++muon) {
94  // muon must have a tracker track
95  if (muon->innerTrack().isNull())
96  continue;
97  edm::RefToBase<reco::Track> track(muon->innerTrack());
98  // check if there is a back-to-back track
99  if (skipMatchedMuons_ && muonid::findOppositeTrack(trackCollectionHandle, *track).isNonnull())
100  continue;
101  if ((!track->innerOk()) || (!track->recHit(0)->isValid()))
102  continue;
103  GlobalPoint innerPosition(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
104  GlobalVector innerMomentum(track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
105  int charge = track->charge();
106  const reco::Track::CovarianceMatrix innerStateCovariance = track->innerStateCovariance();
107  DetId innerDetId = DetId(track->innerDetId());
108  // Construct the information necessary to make a TrajectoryStateOnSurface
109  GlobalTrajectoryParameters globalTrajParams(innerPosition, innerMomentum, charge, &(*magneticField));
110  CurvilinearTrajectoryError curviError(innerStateCovariance);
111  FreeTrajectoryState tracker_state(globalTrajParams, curviError);
112  LogTrace("MuonIdentification") << "Track Inner FTS: " << tracker_state;
113 
114  TrajectoryStateOnSurface tracker_tsos =
115  TrajectoryStateOnSurface(globalTrajParams, curviError, trackerGeometry->idToDet(innerDetId)->surface());
116 
117  // Make Hits, push back the innermost Hit
119  trackHits.push_back(track->recHit(0)->clone());
120 
121  // Make TrajectorySeed
122  PTrajectoryStateOnDet const& PTraj = trajectoryStateTransform::persistentState(tracker_tsos, innerDetId.rawId());
123  TrajectorySeed trajectorySeed(PTraj, trackHits, oppositeToMomentum);
124  LogTrace("MuonIdentification") << "Trajectory Seed Direction: " << trajectorySeed.direction() << endl;
125  result->push_back(trajectorySeed);
126  }
127 
128  iEvent.put(std::move(result));
129 }
edm::EDGetTokenT< reco::TrackCollection > trackCollectionToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
edm::EDGetTokenT< edm::View< reco::Muon > > muonCollectionToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
void push_back(D *&d)
Definition: OwnVector.h:326
#define LogTrace(id)
Definition: DetId.h:17
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
T get() const
Definition: EventSetup.h:73
const TrackerGeomDet * idToDet(DetId) const override
def move(src, dest)
Definition: eostools.py:511
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74

Member Data Documentation

edm::InputTag TrajectorySeedFromMuonProducer::muonCollectionTag_
private

Definition at line 53 of file TrajectorySeedFromMuonProducer.cc.

Referenced by TrajectorySeedFromMuonProducer().

edm::EDGetTokenT<edm::View<reco::Muon> > TrajectorySeedFromMuonProducer::muonCollectionToken_
private

Definition at line 55 of file TrajectorySeedFromMuonProducer.cc.

Referenced by produce(), and TrajectorySeedFromMuonProducer().

bool TrajectorySeedFromMuonProducer::skipMatchedMuons_
private

Definition at line 57 of file TrajectorySeedFromMuonProducer.cc.

Referenced by produce(), and TrajectorySeedFromMuonProducer().

edm::InputTag TrajectorySeedFromMuonProducer::trackCollectionTag_
private

Definition at line 54 of file TrajectorySeedFromMuonProducer.cc.

Referenced by TrajectorySeedFromMuonProducer().

edm::EDGetTokenT<reco::TrackCollection> TrajectorySeedFromMuonProducer::trackCollectionToken_
private

Definition at line 56 of file TrajectorySeedFromMuonProducer.cc.

Referenced by produce(), and TrajectorySeedFromMuonProducer().