CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/RecoJets/JetAssociationAlgorithms/src/JetTracksAssociationXtrpCalo.cc

Go to the documentation of this file.
00001 // Associate jets with tracks by simple "dR" criteria
00002 // Fedor Ratnikov (UMd), Aug. 28, 2007
00003 // $Id: JetTracksAssociationXtrpCalo.cc,v 1.4 2011/02/26 05:59:34 dlange Exp $
00004 
00005 #include "RecoJets/JetAssociationAlgorithms/interface/JetTracksAssociationXtrpCalo.h"
00006 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
00007 #include "DataFormats/GeometrySurface/interface/Plane.h"
00008 #include "DataFormats/Math/interface/deltaR.h"
00009 #include "DataFormats/Math/interface/Vector3D.h"
00010 #include "MagneticField/Engine/interface/MagneticField.h"
00011 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
00012 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00013 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00014 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00015 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00016 #include "DataFormats/DetId/interface/DetId.h"
00017 #include "DataFormats/JetReco/interface/CaloJet.h"
00018 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00019 
00020 // -----------------------------------------------------------------------------
00021 //
00022 JetTracksAssociationXtrpCalo::JetTracksAssociationXtrpCalo() 
00023 {}
00024 
00025 // -----------------------------------------------------------------------------
00026 //
00027 JetTracksAssociationXtrpCalo::~JetTracksAssociationXtrpCalo() 
00028 {}
00029 
00030 
00031 // -----------------------------------------------------------------------------
00032 //
00033 
00034 void JetTracksAssociationXtrpCalo::produce( Association* fAssociation,
00035                                             JetRefs const & fJets,
00036                                             std::vector<reco::TrackExtrapolation> const & fExtrapolations,
00037                                             CaloGeometry const & fGeo,
00038                                             double dR )
00039 {
00040   for ( JetRefs::const_iterator jetsBegin = fJets.begin(),
00041           jetsEnd = fJets.end(), 
00042           ijet = jetsBegin;
00043         ijet != jetsEnd; ++ijet ) {
00044     reco::TrackRefVector associated;
00045     associateInputTracksToJet( associated, **ijet, fExtrapolations, dR );
00046     reco::JetTracksAssociation::setValue( fAssociation, *ijet, associated );
00047   }
00048   
00049   
00050 }
00051 
00052 
00053 
00054 void JetTracksAssociationXtrpCalo::associateInputTracksToJet( reco::TrackRefVector& associated,
00055                                                               const reco::Jet& fJet,
00056                                                               std::vector<reco::TrackExtrapolation> const & fExtrapolations,
00057                                                               double dR ) 
00058 {
00059   reco::CaloJet const * pCaloJet = dynamic_cast<reco::CaloJet const *>(&fJet);
00060   if ( pCaloJet == 0 ) {
00061     throw cms::Exception("InvalidInput") << "Expecting calo jets only in JetTracksAssociationXtrpCalo";
00062   }
00063   // Loop over CaloTowers
00064   double jetPhi = pCaloJet->phi();
00065   double jetEta = pCaloJet->detectorP4().eta();
00066 
00067   // now cache the mapping of (det ID --> track)
00068 
00069 //  std::cout<<" New jet "<<jetEta<<" "<<jetPhi<<" Jet ET "<<pCaloJet->et()<<std::endl;
00070 
00071   for ( std::vector<reco::TrackExtrapolation>::const_iterator xtrpBegin = fExtrapolations.begin(),
00072           xtrpEnd = fExtrapolations.end(), ixtrp = xtrpBegin;
00073         ixtrp != xtrpEnd; ++ixtrp ) {
00074         
00075     if ( ixtrp->positions().size()==0 ) continue;
00076     reco::TrackBase::Point const & point = ixtrp->positions().at(0);
00077     
00078     
00079     double dr = reco::deltaR<double>( jetEta, jetPhi, point.eta(), point.phi() );
00080     if ( dr < dR ) {
00081 
00082 //    std::cout<<" JetTracksAssociationXtrpCalo::associateInputTracksToJet:: initial track "<<ixtrp->track()->pt()<<" "<<ixtrp->track()->eta()<<
00083 //    " "<<ixtrp->track()->phi()<< " Extrapolated position "<<point.eta()<<" "<<point.phi()<<" Valid? "<<ixtrp->isValid().at(0)<<" Jet eta, phi "<<jetEta<<" "<<jetPhi<<" Jet ET "<<pCaloJet->et()<<
00084 //    " dr "<<dr<<" dR "<<dR<<std::endl;
00085 
00086       reco::TrackRef matchedTrack = ixtrp->track(); 
00087       associated.push_back( matchedTrack );      
00088     }
00089   }
00090 
00091 
00092 }