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 // $Id: TrajectorySeedFromMuonProducer.cc,v 1.2 2011/12/22 20:27:05 innocent Exp $
3 //
4 // Authors: Y.Gao (FNAL)
5 //
6 // system include files
7 #include <memory>
8 
9 // 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 {
50 
51 public:
53  virtual void produce(edm::Event&, const edm::EventSetup&);
54 
55 private:
59 };
60 
62 {
63  muonCollectionTag_ = iConfig.getParameter<edm::InputTag>("muonCollectionTag");
64  trackCollectionTag_ = iConfig.getParameter<edm::InputTag>("trackCollectionTag");
65  skipMatchedMuons_ = iConfig.getParameter<bool>("skipMatchedMuons");
66  produces<TrajectorySeedCollection>();
67 }
68 
69 
71 {
72  using namespace edm;
73  using namespace reco;
74  using namespace std;
75 
76  // Product
77  std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
78 
79  edm::ESHandle<MagneticField> magneticField;
80  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
81 
82  edm::ESHandle<TrackerGeometry> trackerGeometry;
83  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
84 
85 
86 
87  edm::Handle<edm::View<Muon> > muonCollectionHandle;
88  iEvent.getByLabel(muonCollectionTag_, muonCollectionHandle);
89 
90  edm::Handle<reco::TrackCollection> trackCollectionHandle;
91  iEvent.getByLabel(trackCollectionTag_, trackCollectionHandle);
92 
93  // Loop over the muon track
94  for (edm::View<Muon>::const_iterator muon = muonCollectionHandle->begin(); muon != muonCollectionHandle->end(); ++muon) {
95  // muon must have a tracker track
96  if( muon->innerTrack().isNull() ) continue;
97  edm::RefToBase<reco::Track> track(muon->innerTrack());
98  // check if there is a back-to-back track
99  if( skipMatchedMuons_ &&
100  muonid::findOppositeTrack(trackCollectionHandle, *track).isNonnull() ) continue;
101  if( (!track->innerOk()) || (!track->recHit(0)->isValid())) continue;
102  GlobalPoint innerPosition(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
103  GlobalVector innerMomentum(track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
104  int charge = track->charge();
105  const reco::Track::CovarianceMatrix innerStateCovariance = track->innerStateCovariance();
106  DetId innerDetId = DetId(track->innerDetId());
107  // Construct the information necessary to make a TrajectoryStateOnSurface
108  GlobalTrajectoryParameters globalTrajParams(innerPosition, innerMomentum, charge, &(*magneticField));
109  CurvilinearTrajectoryError curviError(innerStateCovariance);
110  FreeTrajectoryState tracker_state(globalTrajParams, curviError);
111  LogTrace("MuonIdentification") << "Track Inner FTS: "<<tracker_state;
112 
113  TrajectoryStateOnSurface tracker_tsos = TrajectoryStateOnSurface(globalTrajParams, curviError, trackerGeometry->idToDet(innerDetId)->surface());
114 
115  // Make Hits, push back the innermost Hit
117  trackHits.push_back(track->recHit(0)->clone() );
118 
119  // Make TrajectorySeed
120  PTrajectoryStateOnDet const & PTraj = trajectoryStateTransform::persistentState(tracker_tsos, innerDetId.rawId());
121  TrajectorySeed trajectorySeed(PTraj, trackHits, oppositeToMomentum);
122  LogTrace("MuonIdentification")<<"Trajectory Seed Direction: "<< trajectorySeed.direction()<<endl;
123  result->push_back(trajectorySeed);
124  }
125 
126  iEvent.put(result);
127 
128 }
129 
T getParameter(std::string const &) const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
virtual void produce(edm::Event &, const edm::EventSetup &)
double charge(const std::vector< uint8_t > &Ampls)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void push_back(D *&d)
Definition: OwnVector.h:273
int iEvent
Definition: GenABIO.cc:243
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
tuple result
Definition: query.py:137
TrajectorySeedFromMuonProducer(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:72