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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 63 of file TrajectorySeedFromMuonProducer.cc.

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

64 {
65  muonCollectionTag_ = iConfig.getParameter<edm::InputTag>("muonCollectionTag");
66  trackCollectionTag_ = iConfig.getParameter<edm::InputTag>("trackCollectionTag");
67  skipMatchedMuons_ = iConfig.getParameter<bool>("skipMatchedMuons");
68 
69  muonCollectionToken_ = consumes<edm::View<reco::Muon> >(muonCollectionTag_);
70  trackCollectionToken_ = consumes<reco::TrackCollection> (trackCollectionTag_);
71 
72  produces<TrajectorySeedCollection>();
73 }
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 76 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, seedCreatorFromRegionConsecutiveHitsEDProducer_cff::magneticField, eostools::move(), metsig::muon, muonCollectionToken_, oppositeToMomentum, trajectoryStateTransform::persistentState(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), mps_fire::result, skipMatchedMuons_, GeomDet::surface(), HiIsolationCommonParameters_cff::track, and trackCollectionToken_.

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

Member Data Documentation

edm::InputTag TrajectorySeedFromMuonProducer::muonCollectionTag_
private

Definition at line 55 of file TrajectorySeedFromMuonProducer.cc.

Referenced by TrajectorySeedFromMuonProducer().

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

Definition at line 57 of file TrajectorySeedFromMuonProducer.cc.

Referenced by produce(), and TrajectorySeedFromMuonProducer().

bool TrajectorySeedFromMuonProducer::skipMatchedMuons_
private

Definition at line 59 of file TrajectorySeedFromMuonProducer.cc.

Referenced by produce(), and TrajectorySeedFromMuonProducer().

edm::InputTag TrajectorySeedFromMuonProducer::trackCollectionTag_
private

Definition at line 56 of file TrajectorySeedFromMuonProducer.cc.

Referenced by TrajectorySeedFromMuonProducer().

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

Definition at line 58 of file TrajectorySeedFromMuonProducer.cc.

Referenced by produce(), and TrajectorySeedFromMuonProducer().