CMS 3D CMS Logo

TrackExtrapolator.cc
Go to the documentation of this file.
4 
5 #include <vector>
6 
7 //
8 // constructors and destructor
9 //
11  tracksSrc_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("trackSrc"));
13  if (trackQuality_ == reco::TrackBase::undefQuality) { // we have a problem
14  throw cms::Exception("InvalidInput") << "Unknown trackQuality value '"
15  << iConfig.getParameter<std::string>("trackQuality")
16  << "'. See possible values in 'reco::TrackBase::qualityByName'";
17  }
18 
19  produces<std::vector<reco::TrackExtrapolation>>();
20 }
21 
23 
24 //
25 // member functions
26 //
27 
28 // ------------ method called on each new Event ------------
30  // get stuff from Event Setup
32  iSetup.get<IdealMagneticFieldRecord>().get(field_h);
33  edm::ESHandle<Propagator> propagator_h;
34  iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAlong", propagator_h);
35  edm::ESHandle<DetIdAssociator> ecalDetIdAssociator_h;
36  iSetup.get<DetIdAssociatorRecord>().get("EcalDetIdAssociator", ecalDetIdAssociator_h);
37  FiducialVolume const& ecalvolume = ecalDetIdAssociator_h->volume();
38 
39  // get stuff from Event
41  iEvent.getByToken(tracksSrc_, tracks_h);
42 
43  auto extrapolations = std::make_unique<std::vector<reco::TrackExtrapolation>>();
44 
45  // Get list of tracks we want to extrapolate
46  std::vector<reco::TrackRef> goodTracks;
47  for (reco::TrackCollection::const_iterator trkBegin = tracks_h->begin(), trkEnd = tracks_h->end(), itrk = trkBegin;
48  itrk != trkEnd;
49  ++itrk) {
51 
52  // Cut on track quality
53  if (itrk->quality(trackQuality)) {
54  goodTracks.push_back(reco::TrackRef(tracks_h, itrk - trkBegin));
55  }
56  }
57  std::vector<reco::TrackBase::Point> vresultPos(1);
58  std::vector<reco::TrackBase::Vector> vresultMom(1);
59 
60  // Now loop through the list of tracks and extrapolate them
61  for (std::vector<reco::TrackRef>::const_iterator trkBegin = goodTracks.begin(),
62  trkEnd = goodTracks.end(),
63  itrk = trkBegin;
64  itrk != trkEnd;
65  ++itrk) {
66  if (propagateTrackToVolume(**itrk, *field_h, *propagator_h, ecalvolume, vresultPos[0], vresultMom[0])) {
67  extrapolations->push_back(reco::TrackExtrapolation(*itrk, vresultPos, vresultMom));
68  }
69  }
71 }
72 
73 // -----------------------------------------------------------------------------
74 //
76  const MagneticField& fField,
77  const Propagator& fPropagator,
78  const FiducialVolume& volume,
79  reco::TrackBase::Point& resultPos,
80  reco::TrackBase::Vector& resultMom) {
81  GlobalPoint trackPosition(fTrack.vx(), fTrack.vy(), fTrack.vz()); // reference point
82  GlobalVector trackMomentum(fTrack.px(), fTrack.py(), fTrack.pz()); // reference momentum
83  if (fTrack.extra().isAvailable()) { // use outer point information, if available
84  trackPosition = GlobalPoint(fTrack.outerX(), fTrack.outerY(), fTrack.outerZ());
85  trackMomentum = GlobalVector(fTrack.outerPx(), fTrack.outerPy(), fTrack.outerPz());
86  }
87 
88  GlobalTrajectoryParameters trackParams(trackPosition, trackMomentum, fTrack.charge(), &fField);
89  FreeTrajectoryState trackState(trackParams);
90 
91  TrajectoryStateOnSurface propagatedInfo = fPropagator.propagate(
92  trackState, *Cylinder::build(volume.minR(), Surface::PositionType(0, 0, 0), Surface::RotationType()));
93 
94  // if the track went through either side of the endcaps, repropagate the track
95  double minz = volume.minZ();
96  if (propagatedInfo.isValid() && propagatedInfo.globalPosition().z() > minz) {
97  propagatedInfo =
98  fPropagator.propagate(trackState, *Plane::build(Surface::PositionType(0, 0, minz), Surface::RotationType()));
99 
100  } else if (propagatedInfo.isValid() && propagatedInfo.globalPosition().z() < -minz) {
101  propagatedInfo =
102  fPropagator.propagate(trackState, *Plane::build(Surface::PositionType(0, 0, -minz), Surface::RotationType()));
103  }
104 
105  if (propagatedInfo.isValid()) {
106  resultPos = propagatedInfo.globalPosition();
107  resultMom = propagatedInfo.globalMomentum();
108  return true;
109  } else {
110  return false;
111  }
112 }
113 
114 //define this as a plug-in
Vector3DBase
Definition: Vector3DBase.h:8
TkRotation< float >
DetIdAssociator::volume
const FiducialVolume & volume() const
get active detector volume
Definition: DetIdAssociator.cc:352
reco::Track::outerPy
double outerPy() const
y coordinate of momentum vector at the outermost hit position
Definition: Track.h:103
StandaloneTrackMonitor_cfi.trackQuality
trackQuality
Definition: StandaloneTrackMonitor_cfi.py:11
reco::Track::outerPx
double outerPx() const
x coordinate of momentum vector at the outermost hit position
Definition: Track.h:100
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
TrackExtrapolator::tracksSrc_
edm::EDGetTokenT< reco::TrackCollection > tracksSrc_
Definition: TrackExtrapolator.h:67
reco::TrackBase::undefQuality
Definition: TrackBase.h:151
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
FiducialVolume::minR
double minR(bool withTolerance=true) const
Definition: FiducialVolume.h:37
reco::TrackBase::vx
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:626
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition: TrackBase.h:150
reco::Track::outerX
double outerX() const
x coordinate of the outermost hit position
Definition: Track.h:109
reco::TrackBase::px
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:611
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
TrackExtrapolator::TrackExtrapolator
TrackExtrapolator(const edm::ParameterSet &)
Definition: TrackExtrapolator.cc:10
edm::Handle< reco::TrackCollection >
GloballyPositioned< float >::RotationType
TkRotation< float > RotationType
Definition: GloballyPositioned.h:22
reco::Track::extra
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:139
edm::Ref< TrackCollection >
reco::Track::outerPz
double outerPz() const
z coordinate of momentum vector at the outermost hit position
Definition: Track.h:106
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
Propagator
Definition: Propagator.h:44
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
reco::Track::outerZ
double outerZ() const
z coordinate of the outermost hit position
Definition: Track.h:115
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::TrackBase::py
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:614
TrackExtrapolator.h
reco::TrackBase::vz
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:632
reco::Track
Definition: Track.h:27
edm::ESHandle< MagneticField >
reco::btau::trackMomentum
Definition: TaggingVariable.h:41
reco::TrackBase::charge
int charge() const
track electric charge
Definition: TrackBase.h:581
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
TrackExtrapolator::trackQuality_
reco::TrackBase::TrackQuality trackQuality_
Input tracks.
Definition: TrackExtrapolator.h:68
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Plane::build
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
edm::ParameterSet
Definition: ParameterSet.h:36
TrackExtrapolator
Definition: TrackExtrapolator.h:57
FiducialVolume::minZ
double minZ(bool withTolerance=true) const
Definition: FiducialVolume.h:49
Cylinder::build
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=nullptr)
Definition: Cylinder.h:45
iEvent
int iEvent
Definition: GenABIO.cc:224
DetIdAssociatorRecord.h
FiducialVolume
Definition: FiducialVolume.h:25
edm::EventSetup
Definition: EventSetup.h:57
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
get
#define get
DetIdAssociatorRecord
Definition: DetIdAssociatorRecord.h:13
reco::TrackBase::Point
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TrackExtrapolator::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: TrackExtrapolator.cc:29
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::TrackBase::vy
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:629
GloballyPositioned< float >::PositionType
Point3DBase< float, GlobalTag > PositionType
Definition: GloballyPositioned.h:21
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
DetIdAssociator.h
Exception
Definition: hltDiff.cc:246
goodTracks_cfi.goodTracks
goodTracks
Definition: goodTracks_cfi.py:3
reco::TrackBase::pz
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:617
reco::TrackExtrapolation
Definition: TrackExtrapolation.h:22
edm::Event
Definition: Event.h:73
MagneticField
Definition: MagneticField.h:19
j2tParametersCALO_cfi.extrapolations
extrapolations
Definition: j2tParametersCALO_cfi.py:6
edm::InputTag
Definition: InputTag.h:15
reco::Track::outerY
double outerY() const
y coordinate of the outermost hit position
Definition: Track.h:112
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
TrackExtrapolator::~TrackExtrapolator
~TrackExtrapolator() override
Definition: TrackExtrapolator.cc:22
TrackExtrapolator::propagateTrackToVolume
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
Definition: TrackExtrapolator.cc:75
reco::TrackBase::Vector
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:77
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12