CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackExtrapolator.cc
Go to the documentation of this file.
3 
4 
5 #include <vector>
6 
7 
8 //
9 // constructors and destructor
10 //
12  tracksSrc_(iConfig.getParameter<edm::InputTag> ("trackSrc"))
13 {
14  trackQuality_ =
15  reco::TrackBase::qualityByName (iConfig.getParameter<std::string> ("trackQuality"));
16  if (trackQuality_ == reco::TrackBase::undefQuality) { // we have a problem
17  throw cms::Exception("InvalidInput") << "Unknown trackQuality value '"
18  << iConfig.getParameter<std::string> ("trackQuality")
19  << "'. See possible values in 'reco::TrackBase::qualityByName'";
20  }
21 
22  produces< std::vector<reco::TrackExtrapolation> > ();
23 }
24 
25 
27 {
28 }
29 
30 
31 //
32 // member functions
33 //
34 
35 // ------------ method called on each new Event ------------
36 void
38 {
39 
40  // get stuff from Event Setup
42  iSetup.get<IdealMagneticFieldRecord>().get(field_h);
43  edm::ESHandle<Propagator> propagator_h;
44  iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAlong", propagator_h);
45  edm::ESHandle<DetIdAssociator> ecalDetIdAssociator_h;
46  iSetup.get<DetIdAssociatorRecord>().get("EcalDetIdAssociator", ecalDetIdAssociator_h);
47  FiducialVolume const & ecalvolume = ecalDetIdAssociator_h->volume();
48 
49  // get stuff from Event
51  iEvent.getByLabel (tracksSrc_, tracks_h);
52 
53  std::auto_ptr< std::vector<reco::TrackExtrapolation> > extrapolations( new std::vector<reco::TrackExtrapolation>() );
54 
55  // Get list of tracks we want to extrapolate
56  std::vector <reco::TrackRef> goodTracks;
57  for ( reco::TrackCollection::const_iterator trkBegin = tracks_h->begin(),
58  trkEnd = tracks_h->end(), itrk = trkBegin;
59  itrk != trkEnd; ++itrk ) {
61 
62  // Cut on track quality
63  if (itrk->quality (trackQuality)) {
64  goodTracks.push_back (reco::TrackRef (tracks_h, itrk - trkBegin));
65  }
66  }
67  std::vector<reco::TrackBase::Point> vresultPos(1);
68  std::vector<reco::TrackBase::Vector> vresultMom(1);
69 
70 
71  // Now loop through the list of tracks and extrapolate them
72  for ( std::vector<reco::TrackRef>::const_iterator trkBegin = goodTracks.begin(),
73  trkEnd = goodTracks.end(), itrk = trkBegin;
74  itrk != trkEnd; ++itrk ) {
75  if( propagateTrackToVolume( **itrk, *field_h, *propagator_h, ecalvolume,
76  vresultPos[0], vresultMom[0]) ) {
77  extrapolations->push_back( reco::TrackExtrapolation( *itrk,
78  vresultPos,
79  vresultMom ) );
80  }
81  }
82  iEvent.put( extrapolations );
83 }
84 
85 // ------------ method called once each job just before starting event loop ------------
86 void
88 {
89 }
90 
91 // ------------ method called once each job just after ending the event loop ------------
92 void
94 }
95 
96 
97 
98 
99 // -----------------------------------------------------------------------------
100 //
102  const MagneticField& fField,
103  const Propagator& fPropagator,
104  const FiducialVolume& volume,
105  reco::TrackBase::Point & resultPos,
106  reco::TrackBase::Vector & resultMom
107  )
108 {
109  GlobalPoint trackPosition (fTrack.vx(), fTrack.vy(), fTrack.vz()); // reference point
110  GlobalVector trackMomentum (fTrack.px(), fTrack.py(), fTrack.pz()); // reference momentum
111  if (fTrack.extra().isAvailable() ) { // use outer point information, if available
112  trackPosition = GlobalPoint (fTrack.outerX(), fTrack.outerY(), fTrack.outerZ());
113  trackMomentum = GlobalVector (fTrack.outerPx(), fTrack.outerPy(), fTrack.outerPz());
114  }
115 
116  GlobalTrajectoryParameters trackParams(trackPosition, trackMomentum, fTrack.charge(), &fField);
117  FreeTrajectoryState trackState (trackParams);
118 
120  propagatedInfo = fPropagator.propagate (trackState,
123  volume.minR())
124  );
125 
126  // if the track went through either side of the endcaps, repropagate the track
127  double minz=volume.minZ();
128  if(propagatedInfo.isValid() && propagatedInfo.globalPosition().z()>minz) {
129  propagatedInfo = fPropagator.propagate (trackState,
130  *Plane::build (Surface::PositionType (0,0,minz),
132  );
133 
134  } else if(propagatedInfo.isValid() && propagatedInfo.globalPosition().z()<-minz) {
135  propagatedInfo = fPropagator.propagate (trackState,
136  *Plane::build (Surface::PositionType (0,0,-minz),
138  );
139  }
140 
141 
142  if (propagatedInfo.isValid()) {
143  resultPos = propagatedInfo.globalPosition ();
144  resultMom = propagatedInfo.globalMomentum ();
145  return true;
146  }
147  else {
148  return false;
149  }
150 }
151 
152 
153 
154 
155 //define this as a plug-in
T getParameter(std::string const &) const
virtual void endJob()
TrackExtrapolator(const edm::ParameterSet &)
double outerPy() const
y coordinate of momentum vector at the outermost hit position
Definition: Track.h:73
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:97
TrackQuality
track quality
Definition: TrackBase.h:95
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint globalPosition() const
bool propagateTrackToVolume(const reco::Track &fTrack, const MagneticField &fField, const Propagator &fPropagator, const FiducialVolume &volume, reco::TrackBase::Point &resultPos, reco::TrackBase::Vector &resultMom)
track quality of the tracks we care about
static PlanePointer build(const PositionType &pos, const RotationType &rot, MediumProperties *mp=0)
Definition: Plane.h:25
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:133
bool isAvailable() const
Definition: Ref.h:276
double minZ(bool withTolerance=true) const
double outerZ() const
z coordinate of the outermost hit position
Definition: Track.h:81
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
T z() const
Definition: PV3DBase.h:63
virtual void produce(edm::Event &, const edm::EventSetup &)
double outerX() const
x coordinate of the outermost hit position
Definition: Track.h:77
math::XYZPoint Point
point in the space
Definition: TrackBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::InputTag tracksSrc_
double outerPz() const
z coordinate of momentum vector at the outermost hit position
Definition: Track.h:75
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:137
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
double minR(bool withTolerance=true) const
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:147
reco::TrackBase::TrackQuality trackQuality_
Input tracks.
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
virtual void beginJob()
const T & get() const
Definition: EventSetup.h:55
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, MediumProperties *mp=0)
Definition: Cylinder.h:29
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:145
GlobalVector globalMomentum() const
double outerY() const
y coordinate of the outermost hit position
Definition: Track.h:79
int charge() const
track electric charge
Definition: TrackBase.h:113
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:74
double outerPx() const
x coordinate of momentum vector at the outermost hit position
Definition: Track.h:71
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:135
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:143
Global3DVector GlobalVector
Definition: GlobalVector.h:10