00001
00002
00003
00004
00005 #include "RecoJets/JetAssociationAlgorithms/interface/JetTracksAssociationDRCalo.h"
00006
00007 #include "DataFormats/JetReco/interface/Jet.h"
00008 #include "DataFormats/TrackReco/interface/Track.h"
00009
00010 #include "DataFormats/Math/interface/deltaR.h"
00011 #include "DataFormats/Math/interface/Vector3D.h"
00012
00013 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
00014 #include "DataFormats/GeometrySurface/interface/Plane.h"
00015
00016 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
00017 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00018 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00019 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00020 #include "MagneticField/Engine/interface/MagneticField.h"
00021
00022
00023 namespace {
00024
00025 const double rBarrel = 129.;
00026 const double zEndcap = 320.;
00027 const double zVF = 1100.;
00028 const double rEndcapMin = zEndcap * tan ( 2*atan (exp (-3.)));
00029 const double rVFMin = zEndcap * tan ( 2*atan (exp (-5.191)));
00030
00031 struct ImpactPoint {
00032 unsigned index;
00033 double eta;
00034 double phi;
00035 };
00036
00037 GlobalPoint propagateTrackToCalo (const reco::Track& fTrack,
00038 const MagneticField& fField,
00039 const Propagator& fPropagator)
00040 {
00041 GlobalPoint trackPosition (fTrack.vx(), fTrack.vy(), fTrack.vz());
00042 GlobalVector trackMomentum (fTrack.px(), fTrack.py(), fTrack.pz());
00043 if (fTrack.extra().isAvailable() ) {
00044 trackPosition = GlobalPoint (fTrack.outerX(), fTrack.outerY(), fTrack.outerZ());
00045 trackMomentum = GlobalVector (fTrack.outerPx(), fTrack.outerPy(), fTrack.outerPz());
00046 }
00047
00048
00049
00050
00051 GlobalTrajectoryParameters trackParams(trackPosition, trackMomentum, fTrack.charge(), &fField);
00052 FreeTrajectoryState trackState (trackParams);
00053
00054
00055 TrajectoryStateOnSurface
00056 propagatedInfo = fPropagator.propagate (trackState,
00057 *Cylinder::build (Surface::PositionType (0,0,0),
00058 Surface::RotationType(),
00059 rBarrel)
00060 );
00061 if (propagatedInfo.isValid()) {
00062 GlobalPoint result (propagatedInfo.globalPosition ());
00063 if (fabs (result.z()) < zEndcap) {
00064
00065
00066
00067 return result;
00068 }
00069 }
00070
00071
00072 double zTarget = trackMomentum.z() > 0 ? zEndcap : -zEndcap;
00073 propagatedInfo = fPropagator.propagate (trackState,
00074 *Plane::build( Surface::PositionType(0, 0, zTarget),
00075 Surface::RotationType())
00076 );
00077 if (propagatedInfo.isValid()) {
00078 GlobalPoint result (propagatedInfo.globalPosition ());
00079 if (fabs (result.perp()) > rEndcapMin) {
00080
00081
00082
00083 return result;
00084 }
00085 }
00086
00087 zTarget = trackMomentum.z() > 0 ? zVF : -zVF;
00088 propagatedInfo = fPropagator.propagate (trackState,
00089 *Plane::build( Surface::PositionType(0, 0, zTarget),
00090 Surface::RotationType())
00091 );
00092 if (propagatedInfo.isValid()) {
00093 GlobalPoint result (propagatedInfo.globalPosition ());
00094 if (fabs (result.perp()) > rVFMin) {
00095
00096
00097
00098 return result;
00099 }
00100 }
00101
00102
00103 return GlobalPoint (0, 0, 0);
00104 }
00105 }
00106
00107 JetTracksAssociationDRCalo::JetTracksAssociationDRCalo (double fDr)
00108 : mDeltaR2Threshold (fDr*fDr)
00109 {}
00110
00111 void JetTracksAssociationDRCalo::produce (reco::JetTracksAssociation::Container* fAssociation,
00112 const std::vector <edm::RefToBase<reco::Jet> >& fJets,
00113 const std::vector <reco::TrackRef>& fTracks,
00114 const MagneticField& fField,
00115 const Propagator& fPropagator) const
00116 {
00117
00118 std::vector<ImpactPoint> impacts;
00119 for (unsigned t = 0; t < fTracks.size(); ++t) {
00120 GlobalPoint impact = propagateTrackToCalo (*(fTracks[t]), fField, fPropagator);
00121 if (impact.mag () > 0) {
00122 ImpactPoint goodTrack;
00123 goodTrack.index = t;
00124 goodTrack.eta = impact.eta ();
00125 goodTrack.phi = impact.barePhi();
00126 impacts.push_back (goodTrack);
00127 }
00128 }
00129
00130 for (unsigned j = 0; j < fJets.size(); ++j) {
00131 reco::TrackRefVector assoTracks;
00132 const reco::Jet* jet = &*(fJets[j]);
00133 double jetEta = jet->eta();
00134 double jetPhi = jet->phi();
00135 for (unsigned t = 0; t < impacts.size(); ++t) {
00136 double dR2 = deltaR2 (jetEta, jetPhi, impacts[t].eta, impacts[t].phi);
00137 if (dR2 < mDeltaR2Threshold) assoTracks.push_back (fTracks[impacts[t].index]);
00138 }
00139 reco::JetTracksAssociation::setValue (fAssociation, fJets[j], assoTracks);
00140 }
00141 }
00142
00143 math::XYZPoint JetTracksAssociationDRCalo::propagateTrackToCalorimeter (const reco::Track& fTrack,
00144 const MagneticField& fField,
00145 const Propagator& fPropagator)
00146 {
00147 GlobalPoint result (propagateTrackToCalo (fTrack, fField, fPropagator));
00148 return math::XYZPoint (result.x(), result.y(), result.z());
00149 }