CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
JetTracksAssociationDRCalo.cc
Go to the documentation of this file.
1 // Associate jets with tracks by simple "dR" criteria
2 // Fedor Ratnikov (UMd), Aug. 28, 2007
3 
5 
8 
11 
14 
20 
21 namespace {
22  // basic geometry constants, imported from Geometry/HcalTowerAlgo/src/CaloTowerHardcodeGeometryLoader.cc
23  const double rBarrel = 129.;
24  const double zEndcap = 320.;
25  const double zVF = 1100.;
26  const double rEndcapMin = zEndcap * tan(2 * atan(exp(-3.)));
27  const double rVFMin = zEndcap * tan(2 * atan(exp(-5.191)));
28 
29  struct ImpactPoint {
30  unsigned index;
31  double eta;
32  double phi;
33  };
34 
35  GlobalPoint propagateTrackToCalo(const reco::Track& fTrack,
36  const MagneticField& fField,
37  const Propagator& fPropagator) {
38  GlobalPoint trackPosition(fTrack.vx(), fTrack.vy(), fTrack.vz()); // reference point
39  GlobalVector trackMomentum(fTrack.px(), fTrack.py(), fTrack.pz()); // reference momentum
40  if (fTrack.extra().isAvailable()) { // use outer point information, if available
41  trackPosition = GlobalPoint(fTrack.outerX(), fTrack.outerY(), fTrack.outerZ());
42  trackMomentum = GlobalVector(fTrack.outerPx(), fTrack.outerPy(), fTrack.outerPz());
43  }
44  // std::cout << "propagateTrackToCalo-> start propagating track"
45  // << " x/y/z: " << trackPosition.x() << '/' << trackPosition.y() << '/' << trackPosition.z()
46  // << ", pt/eta/phi: " << trackMomentum.perp() << '/' << trackMomentum.eta() << '/' << trackMomentum.barePhi()
47  // << std::endl;
48  GlobalTrajectoryParameters trackParams(trackPosition, trackMomentum, fTrack.charge(), &fField);
49  FreeTrajectoryState trackState(trackParams);
50 
51  // first propagate to barrel
52  TrajectoryStateOnSurface propagatedInfo = fPropagator.propagate(
53  trackState, *Cylinder::build(rBarrel, Surface::PositionType(0, 0, 0), Surface::RotationType()));
54  if (propagatedInfo.isValid()) {
55  GlobalPoint result(propagatedInfo.globalPosition());
56  if (fabs(result.z()) < zEndcap) {
57  // std::cout << "propagateTrackToCalo-> propagated to barrel:"
58  // << " x/y/z/r: " << result.x() << '/' << result.y() << '/' << result.z() << '/' << result.perp()
59  // << std::endl;
60  return result;
61  }
62  }
63 
64  // failed with barrel, try endcap
65  double zTarget = trackMomentum.z() > 0 ? zEndcap : -zEndcap;
66  propagatedInfo =
67  fPropagator.propagate(trackState, *Plane::build(Surface::PositionType(0, 0, zTarget), Surface::RotationType()));
68  if (propagatedInfo.isValid()) {
69  GlobalPoint result(propagatedInfo.globalPosition());
70  if (fabs(result.perp()) > rEndcapMin) {
71  // std::cout << "propagateTrackToCalo-> propagated to endcap:"
72  // << " x/y/z/r: " << result.x() << '/' << result.y() << '/' << result.z() << '/' << result.perp()
73  // << std::endl;
74  return result;
75  }
76  }
77  // failed with endcap, try VF
78  zTarget = trackMomentum.z() > 0 ? zVF : -zVF;
79  propagatedInfo =
80  fPropagator.propagate(trackState, *Plane::build(Surface::PositionType(0, 0, zTarget), Surface::RotationType()));
81  if (propagatedInfo.isValid()) {
82  GlobalPoint result(propagatedInfo.globalPosition());
83  if (fabs(result.perp()) > rVFMin) {
84  // std::cout << "propagateTrackToCalo-> propagated to VF:"
85  // << " x/y/z/r: " << result.x() << '/' << result.y() << '/' << result.z() << '/' << result.perp()
86  // << std::endl;
87  return result;
88  }
89  }
90  // no luck
91  // std::cout << "propagateTrackToCalo-> failed to propagate track to calorimeter" << std::endl;
92  return GlobalPoint(0, 0, 0);
93  }
94 } // namespace
95 
96 JetTracksAssociationDRCalo::JetTracksAssociationDRCalo(double fDr) : mDeltaR2Threshold(fDr * fDr) {}
97 
100  const std::vector<reco::TrackRef>& fTracks,
101  const MagneticField& fField,
102  const Propagator& fPropagator) const {
103  // cache track parameters
104  std::vector<ImpactPoint> impacts;
105  for (unsigned t = 0; t < fTracks.size(); ++t) {
106  GlobalPoint impact = propagateTrackToCalo(*(fTracks[t]), fField, fPropagator);
107  if (impact.mag() > 0) { // successful extrapolation
108  ImpactPoint goodTrack;
109  goodTrack.index = t;
110  goodTrack.eta = impact.eta();
111  goodTrack.phi = impact.barePhi();
112  impacts.push_back(goodTrack);
113  }
114  }
115 
116  for (unsigned j = 0; j < fJets.size(); ++j) {
117  reco::TrackRefVector assoTracks;
118  const reco::Jet* jet = &*(fJets[j]);
119  double jetEta = jet->eta();
120  double jetPhi = jet->phi();
121  for (unsigned t = 0; t < impacts.size(); ++t) {
122  double dR2 = deltaR2(jetEta, jetPhi, impacts[t].eta, impacts[t].phi);
123  if (dR2 < mDeltaR2Threshold)
124  assoTracks.push_back(fTracks[impacts[t].index]);
125  }
126  reco::JetTracksAssociation::setValue(fAssociation, fJets[j], assoTracks);
127  }
128 }
129 
131  const MagneticField& fField,
132  const Propagator& fPropagator) {
133  GlobalPoint result(propagateTrackToCalo(fTrack, fField, fPropagator));
134  return math::XYZPoint(result.x(), result.y(), result.z());
135 }
bool isAvailable() const
Definition: Ref.h:537
double outerPy() const
y coordinate of momentum vector at the outermost hit position
Definition: Track.h:103
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:139
Base class for all types of Jets.
Definition: Jet.h:20
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:640
double outerZ() const
z coordinate of the outermost hit position
Definition: Track.h:115
tuple result
Definition: mps_fire.py:311
T barePhi() const
Definition: PV3DBase.h:65
T mag() const
Definition: PV3DBase.h:64
double mDeltaR2Threshold
fidutial dR between track in the vertex and jet&#39;s reference direction
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
bool setValue(Container &, const reco::JetBaseRef &, reco::TrackRefVector)
associate jet with value. Returns false and associate nothing if jet is already associated ...
static PlanePointer build(Args &&...args)
Definition: Plane.h:33
T z() const
Definition: PV3DBase.h:61
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static math::XYZPoint propagateTrackToCalorimeter(const reco::Track &fTrack, const MagneticField &fField, const Propagator &fPropagator)
propagating the track to the Calorimeter
double outerX() const
x coordinate of the outermost hit position
Definition: Track.h:109
double outerPz() const
z coordinate of momentum vector at the outermost hit position
Definition: Track.h:106
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:646
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:661
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=nullptr)
Definition: Cylinder.h:45
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
T eta() const
Definition: PV3DBase.h:73
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:658
double outerY() const
y coordinate of the outermost hit position
Definition: Track.h:112
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:67
void produce(reco::JetTracksAssociation::Container *fAssociation, const std::vector< edm::RefToBase< reco::Jet > > &fJets, const std::vector< reco::TrackRef > &fTracks, const MagneticField &fField, const Propagator &fPropagator) const
int charge() const
track electric charge
Definition: TrackBase.h:596
double phi() const final
momentum azimuthal angle
T x() const
Definition: PV3DBase.h:59
double outerPx() const
x coordinate of momentum vector at the outermost hit position
Definition: Track.h:100
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:643
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:655
Global3DVector GlobalVector
Definition: GlobalVector.h:10
double eta() const final
momentum pseudorapidity