CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
49 
50 public:
52  virtual void produce(edm::Event&, const edm::EventSetup&) override;
53 
54 private:
60 
61 };
62 
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 }
74 
75 
77 {
78  using namespace edm;
79  using namespace reco;
80  using namespace std;
81 
82  // Product
83  std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
84 
85  edm::ESHandle<MagneticField> magneticField;
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(result);
133 
134 }
135 
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > trackCollectionToken_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
virtual void produce(edm::Event &, const edm::EventSetup &) override
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_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
double charge(const std::vector< uint8_t > &Ampls)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void push_back(D *&d)
Definition: OwnVector.h:274
int iEvent
Definition: GenABIO.cc:230
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
tuple result
Definition: query.py:137
TrajectorySeedFromMuonProducer(const edm::ParameterSet &)
#define LogTrace(id)
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:70