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 
5 
8 
11 
14 
20 
21 
22 namespace {
23  // basic geometry constants, imported from Geometry/HcalTowerAlgo/src/CaloTowerHardcodeGeometryLoader.cc
24  const double rBarrel = 129.;
25  const double zEndcap = 320.;
26  const double zVF = 1100.;
27  const double rEndcapMin = zEndcap * tan ( 2*atan (exp (-3.)));
28  const double rVFMin = zEndcap * tan ( 2*atan (exp (-5.191)));
29 
30  struct ImpactPoint {
31  unsigned index;
32  double eta;
33  double phi;
34  };
35 
36  GlobalPoint propagateTrackToCalo (const reco::Track& fTrack,
37  const MagneticField& fField,
38  const Propagator& fPropagator)
39  {
40  GlobalPoint trackPosition (fTrack.vx(), fTrack.vy(), fTrack.vz()); // reference point
41  GlobalVector trackMomentum (fTrack.px(), fTrack.py(), fTrack.pz()); // reference momentum
42  if (fTrack.extra().isAvailable() ) { // use outer point information, if available
43  trackPosition = GlobalPoint (fTrack.outerX(), fTrack.outerY(), fTrack.outerZ());
44  trackMomentum = GlobalVector (fTrack.outerPx(), fTrack.outerPy(), fTrack.outerPz());
45  }
46 // std::cout << "propagateTrackToCalo-> start propagating track"
47 // << " x/y/z: " << trackPosition.x() << '/' << trackPosition.y() << '/' << trackPosition.z()
48 // << ", pt/eta/phi: " << trackMomentum.perp() << '/' << trackMomentum.eta() << '/' << trackMomentum.barePhi()
49 // << std::endl;
50  GlobalTrajectoryParameters trackParams(trackPosition, trackMomentum, fTrack.charge(), &fField);
51  FreeTrajectoryState trackState (trackParams);
52 
53  // first propagate to barrel
55  propagatedInfo = fPropagator.propagate (trackState,
56  *Cylinder::build (rBarrel, Surface::PositionType (0,0,0),
58  );
59  if (propagatedInfo.isValid()) {
60  GlobalPoint result (propagatedInfo.globalPosition ());
61  if (fabs (result.z()) < zEndcap) {
62 // std::cout << "propagateTrackToCalo-> propagated to barrel:"
63 // << " x/y/z/r: " << result.x() << '/' << result.y() << '/' << result.z() << '/' << result.perp()
64 // << std::endl;
65  return result;
66  }
67  }
68 
69  // failed with barrel, try endcap
70  double zTarget = trackMomentum.z() > 0 ? zEndcap : -zEndcap;
71  propagatedInfo = fPropagator.propagate (trackState,
72  *Plane::build( Surface::PositionType(0, 0, zTarget),
74  );
75  if (propagatedInfo.isValid()) {
76  GlobalPoint result (propagatedInfo.globalPosition ());
77  if (fabs (result.perp()) > rEndcapMin) {
78 // std::cout << "propagateTrackToCalo-> propagated to endcap:"
79 // << " x/y/z/r: " << result.x() << '/' << result.y() << '/' << result.z() << '/' << result.perp()
80 // << std::endl;
81  return result;
82  }
83  }
84  // failed with endcap, try VF
85  zTarget = trackMomentum.z() > 0 ? zVF : -zVF;
86  propagatedInfo = fPropagator.propagate (trackState,
87  *Plane::build( Surface::PositionType(0, 0, zTarget),
89  );
90  if (propagatedInfo.isValid()) {
91  GlobalPoint result (propagatedInfo.globalPosition ());
92  if (fabs (result.perp()) > rVFMin) {
93 // std::cout << "propagateTrackToCalo-> propagated to VF:"
94 // << " x/y/z/r: " << result.x() << '/' << result.y() << '/' << result.z() << '/' << result.perp()
95 // << std::endl;
96  return result;
97  }
98  }
99  // no luck
100 // std::cout << "propagateTrackToCalo-> failed to propagate track to calorimeter" << std::endl;
101  return GlobalPoint (0, 0, 0);
102  }
103 }
104 
106 : mDeltaR2Threshold (fDr*fDr)
107 {}
108 
110  const std::vector <edm::RefToBase<reco::Jet> >& fJets,
111  const std::vector <reco::TrackRef>& fTracks,
112  const MagneticField& fField,
113  const Propagator& fPropagator) const
114 {
115  // cache track parameters
116  std::vector<ImpactPoint> impacts;
117  for (unsigned t = 0; t < fTracks.size(); ++t) {
118  GlobalPoint impact = propagateTrackToCalo (*(fTracks[t]), fField, fPropagator);
119  if (impact.mag () > 0) { // successful extrapolation
120  ImpactPoint goodTrack;
121  goodTrack.index = t;
122  goodTrack.eta = impact.eta ();
123  goodTrack.phi = impact.barePhi();
124  impacts.push_back (goodTrack);
125  }
126  }
127 
128  for (unsigned j = 0; j < fJets.size(); ++j) {
129  reco::TrackRefVector assoTracks;
130  const reco::Jet* jet = &*(fJets[j]);
131  double jetEta = jet->eta();
132  double jetPhi = jet->phi();
133  for (unsigned t = 0; t < impacts.size(); ++t) {
134  double dR2 = deltaR2 (jetEta, jetPhi, impacts[t].eta, impacts[t].phi);
135  if (dR2 < mDeltaR2Threshold) assoTracks.push_back (fTracks[impacts[t].index]);
136  }
137  reco::JetTracksAssociation::setValue (fAssociation, fJets[j], assoTracks);
138  }
139 }
140 
142  const MagneticField& fField,
143  const Propagator& fPropagator)
144 {
145  GlobalPoint result (propagateTrackToCalo (fTrack, fField, fPropagator));
146  return math::XYZPoint (result.x(), result.y(), result.z());
147 }
bool isAvailable() const
Definition: Ref.h:576
double outerPy() const
y coordinate of momentum vector at the outermost hit position
Definition: Track.h:129
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:189
Base class for all types of Jets.
Definition: Jet.h:20
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
virtual double phi() const final
momentum azimuthal angle
GlobalPoint globalPosition() const
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:622
double outerZ() const
z coordinate of the outermost hit position
Definition: Track.h:149
tuple result
Definition: mps_fire.py:83
T barePhi() const
Definition: PV3DBase.h:68
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
Definition: Cylinder.h:51
T mag() const
Definition: PV3DBase.h:67
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:64
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:139
double outerPz() const
z coordinate of momentum vector at the outermost hit position
Definition: Track.h:134
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:634
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:664
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:53
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
T eta() const
Definition: PV3DBase.h:76
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:144
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:62
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:562
virtual double eta() const final
momentum pseudorapidity
T x() const
Definition: PV3DBase.h:62
double outerPx() const
x coordinate of momentum vector at the outermost hit position
Definition: Track.h:124
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:628
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:652
Global3DVector GlobalVector
Definition: GlobalVector.h:10