CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 // $Id: JetTracksAssociationDRCalo.cc,v 1.9 2010/03/18 12:17:58 bainbrid Exp $
4 
6 
9 
12 
15 
21 
22 
23 namespace {
24  // basic geometry constants, imported from Geometry/HcalTowerAlgo/src/CaloTowerHardcodeGeometryLoader.cc
25  const double rBarrel = 129.;
26  const double zEndcap = 320.;
27  const double zVF = 1100.;
28  const double rEndcapMin = zEndcap * tan ( 2*atan (exp (-3.)));
29  const double rVFMin = zEndcap * tan ( 2*atan (exp (-5.191)));
30 
31  struct ImpactPoint {
32  unsigned index;
33  double eta;
34  double phi;
35  };
36 
37  GlobalPoint propagateTrackToCalo (const reco::Track& fTrack,
38  const MagneticField& fField,
39  const Propagator& fPropagator)
40  {
41  GlobalPoint trackPosition (fTrack.vx(), fTrack.vy(), fTrack.vz()); // reference point
42  GlobalVector trackMomentum (fTrack.px(), fTrack.py(), fTrack.pz()); // reference momentum
43  if (fTrack.extra().isAvailable() ) { // use outer point information, if available
44  trackPosition = GlobalPoint (fTrack.outerX(), fTrack.outerY(), fTrack.outerZ());
45  trackMomentum = GlobalVector (fTrack.outerPx(), fTrack.outerPy(), fTrack.outerPz());
46  }
47 // std::cout << "propagateTrackToCalo-> start propagating track"
48 // << " x/y/z: " << trackPosition.x() << '/' << trackPosition.y() << '/' << trackPosition.z()
49 // << ", pt/eta/phi: " << trackMomentum.perp() << '/' << trackMomentum.eta() << '/' << trackMomentum.barePhi()
50 // << std::endl;
51  GlobalTrajectoryParameters trackParams(trackPosition, trackMomentum, fTrack.charge(), &fField);
52  FreeTrajectoryState trackState (trackParams);
53 
54  // first propagate to barrel
56  propagatedInfo = fPropagator.propagate (trackState,
59  rBarrel)
60  );
61  if (propagatedInfo.isValid()) {
62  GlobalPoint result (propagatedInfo.globalPosition ());
63  if (fabs (result.z()) < zEndcap) {
64 // std::cout << "propagateTrackToCalo-> propagated to barrel:"
65 // << " x/y/z/r: " << result.x() << '/' << result.y() << '/' << result.z() << '/' << result.perp()
66 // << std::endl;
67  return result;
68  }
69  }
70 
71  // failed with barrel, try endcap
72  double zTarget = trackMomentum.z() > 0 ? zEndcap : -zEndcap;
73  propagatedInfo = fPropagator.propagate (trackState,
74  *Plane::build( Surface::PositionType(0, 0, zTarget),
76  );
77  if (propagatedInfo.isValid()) {
78  GlobalPoint result (propagatedInfo.globalPosition ());
79  if (fabs (result.perp()) > rEndcapMin) {
80 // std::cout << "propagateTrackToCalo-> propagated to endcap:"
81 // << " x/y/z/r: " << result.x() << '/' << result.y() << '/' << result.z() << '/' << result.perp()
82 // << std::endl;
83  return result;
84  }
85  }
86  // failed with endcap, try VF
87  zTarget = trackMomentum.z() > 0 ? zVF : -zVF;
88  propagatedInfo = fPropagator.propagate (trackState,
89  *Plane::build( Surface::PositionType(0, 0, zTarget),
91  );
92  if (propagatedInfo.isValid()) {
93  GlobalPoint result (propagatedInfo.globalPosition ());
94  if (fabs (result.perp()) > rVFMin) {
95 // std::cout << "propagateTrackToCalo-> propagated to VF:"
96 // << " x/y/z/r: " << result.x() << '/' << result.y() << '/' << result.z() << '/' << result.perp()
97 // << std::endl;
98  return result;
99  }
100  }
101  // no luck
102 // std::cout << "propagateTrackToCalo-> failed to propagate track to calorimeter" << std::endl;
103  return GlobalPoint (0, 0, 0);
104  }
105 }
106 
108 : mDeltaR2Threshold (fDr*fDr)
109 {}
110 
112  const std::vector <edm::RefToBase<reco::Jet> >& fJets,
113  const std::vector <reco::TrackRef>& fTracks,
114  const MagneticField& fField,
115  const Propagator& fPropagator) const
116 {
117  // cache track parameters
118  std::vector<ImpactPoint> impacts;
119  for (unsigned t = 0; t < fTracks.size(); ++t) {
120  GlobalPoint impact = propagateTrackToCalo (*(fTracks[t]), fField, fPropagator);
121  if (impact.mag () > 0) { // successful extrapolation
122  ImpactPoint goodTrack;
123  goodTrack.index = t;
124  goodTrack.eta = impact.eta ();
125  goodTrack.phi = impact.barePhi();
126  impacts.push_back (goodTrack);
127  }
128  }
129 
130  for (unsigned j = 0; j < fJets.size(); ++j) {
131  reco::TrackRefVector assoTracks;
132  const reco::Jet* jet = &*(fJets[j]);
133  double jetEta = jet->eta();
134  double jetPhi = jet->phi();
135  for (unsigned t = 0; t < impacts.size(); ++t) {
136  double dR2 = deltaR2 (jetEta, jetPhi, impacts[t].eta, impacts[t].phi);
137  if (dR2 < mDeltaR2Threshold) assoTracks.push_back (fTracks[impacts[t].index]);
138  }
139  reco::JetTracksAssociation::setValue (fAssociation, fJets[j], assoTracks);
140  }
141 }
142 
144  const MagneticField& fField,
145  const Propagator& fPropagator)
146 {
147  GlobalPoint result (propagateTrackToCalo (fTrack, fField, fPropagator));
148  return math::XYZPoint (result.x(), result.y(), result.z());
149 }
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
Base class for all types of Jets.
Definition: Jet.h:21
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:62
GlobalPoint globalPosition() const
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
T eta() const
virtual double eta() const
momentum pseudorapidity
double outerZ() const
z coordinate of the outermost hit position
Definition: Track.h:81
T barePhi() const
Definition: PV3DBase.h:67
T mag() const
Definition: PV3DBase.h:66
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 ...
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int j
Definition: DBlmapReader.cc:9
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:77
double deltaR2(const Vector1 &v1, const Vector2 &v2)
Definition: VectorUtil.h:78
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 vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:147
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, MediumProperties *mp=0)
Definition: Cylinder.h:29
T eta() const
Definition: PV3DBase.h:75
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:145
double outerY() const
y coordinate of the outermost hit position
Definition: Track.h:79
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
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:113
T x() const
Definition: PV3DBase.h:61
virtual double phi() const
momentum azimuthal angle
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
Definition: DDAxes.h:10