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
16 
17 // related to reco::Track
20 
21 // related to reco::Muon
24 
25 // TrajectorSeed Related
29 
30 // TrajectorSeed Related
39 
44 
46 
48 public:
50  void produce(edm::Event&, const edm::EventSetup&) override;
51 
52 private:
58 };
59 
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 }
70 
72  using namespace edm;
73  using namespace reco;
74  using namespace std;
75 
76  // Product
77  auto result = std::make_unique<TrajectorySeedCollection>();
78 
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 }
130 
Vector3DBase
Definition: Vector3DBase.h:8
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
TrajectorySeedFromMuonProducer::muonCollectionTag_
edm::InputTag muonCollectionTag_
Definition: TrajectorySeedFromMuonProducer.cc:53
FreeTrajectoryState.h
Muon.h
TrackerGeometry.h
ESHandle.h
muon
Definition: MuonCocktails.h:17
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
oppositeToMomentum
Definition: PropagationDirection.h:4
EDProducer.h
TrajectoryMeasurement.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HLT_2018_cff.muon
muon
Definition: HLT_2018_cff.py:10349
edm::Handle
Definition: AssociativeIterator.h:50
TrajectorySeedFromMuonProducer::trackCollectionTag_
edm::InputTag trackCollectionTag_
Definition: TrajectorySeedFromMuonProducer.cc:54
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TrajectorySeedFromMuonProducer::trackCollectionToken_
edm::EDGetTokenT< reco::TrackCollection > trackCollectionToken_
Definition: TrajectorySeedFromMuonProducer.cc:56
MakerMacros.h
Track.h
TrajectorySeedFromMuonProducer::muonCollectionToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonCollectionToken_
Definition: TrajectorySeedFromMuonProducer.cc:55
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackFwd.h
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MuonFwd.h
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
Point3DBase< float, GlobalTag >
TrajectorySeed.h
TrajectorySeedFromMuonProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: TrajectorySeedFromMuonProducer.cc:71
GlobalTrackingGeometryRecord.h
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
TrajectorySeedCollection.h
TrajectorySeedFromMuonProducer::skipMatchedMuons_
bool skipMatchedMuons_
Definition: TrajectorySeedFromMuonProducer.cc:57
PropagationDirection.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
Frameworkfwd.h
TrajectorySeed
Definition: TrajectorySeed.h:17
EventSetup.h
edm::RefToBase< reco::Track >
TrajectoryStateTransform.h
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
TrajectorySeedFromMuonProducer
Definition: TrajectorySeedFromMuonProducer.cc:47
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
mps_fire.result
result
Definition: mps_fire.py:303
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
TrajectorySeedFromMuonProducer::TrajectorySeedFromMuonProducer
TrajectorySeedFromMuonProducer(const edm::ParameterSet &)
Definition: TrajectorySeedFromMuonProducer.cc:60
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
ParameterSet.h
muonid::findOppositeTrack
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
Definition: MuonCosmicsId.cc:28
GlobalTrackingGeometry.h
reco::TrackBase::CovarianceMatrix
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
MuonCosmicsId.h
edm::OwnVector< TrackingRecHit >