test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetTracksAssociationXtrpCalo.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 
18 
19 // -----------------------------------------------------------------------------
20 //
22 {}
23 
24 // -----------------------------------------------------------------------------
25 //
27 {}
28 
29 
30 // -----------------------------------------------------------------------------
31 //
32 
34  JetRefs const & fJets,
35  std::vector<reco::TrackExtrapolation> const & fExtrapolations,
36  CaloGeometry const & fGeo,
37  double dR )
38 {
39  for ( JetRefs::const_iterator jetsBegin = fJets.begin(),
40  jetsEnd = fJets.end(),
41  ijet = jetsBegin;
42  ijet != jetsEnd; ++ijet ) {
43  reco::TrackRefVector associated;
44  associateInputTracksToJet( associated, **ijet, fExtrapolations, dR );
45  reco::JetTracksAssociation::setValue( fAssociation, *ijet, associated );
46  }
47 
48 
49 }
50 
51 
52 
54  const reco::Jet& fJet,
55  std::vector<reco::TrackExtrapolation> const & fExtrapolations,
56  double dR )
57 {
58  reco::CaloJet const * pCaloJet = dynamic_cast<reco::CaloJet const *>(&fJet);
59  if ( pCaloJet == 0 ) {
60  throw cms::Exception("InvalidInput") << "Expecting calo jets only in JetTracksAssociationXtrpCalo";
61  }
62  // Loop over CaloTowers
63  double jetPhi = pCaloJet->phi();
64  double jetEta = pCaloJet->detectorP4().eta();
65 
66  // now cache the mapping of (det ID --> track)
67 
68 // std::cout<<" New jet "<<jetEta<<" "<<jetPhi<<" Jet ET "<<pCaloJet->et()<<std::endl;
69 
70  for ( std::vector<reco::TrackExtrapolation>::const_iterator xtrpBegin = fExtrapolations.begin(),
71  xtrpEnd = fExtrapolations.end(), ixtrp = xtrpBegin;
72  ixtrp != xtrpEnd; ++ixtrp ) {
73 
74  if ( ixtrp->positions().size()==0 ) continue;
75  reco::TrackBase::Point const & point = ixtrp->positions().at(0);
76 
77 
78  double dr = reco::deltaR<double>( jetEta, jetPhi, point.eta(), point.phi() );
79  if ( dr < dR ) {
80 
81 // std::cout<<" JetTracksAssociationXtrpCalo::associateInputTracksToJet:: initial track "<<ixtrp->track()->pt()<<" "<<ixtrp->track()->eta()<<
82 // " "<<ixtrp->track()->phi()<< " Extrapolated position "<<point.eta()<<" "<<point.phi()<<" Valid? "<<ixtrp->isValid().at(0)<<" Jet eta, phi "<<jetEta<<" "<<jetPhi<<" Jet ET "<<pCaloJet->et()<<
83 // " dr "<<dr<<" dR "<<dR<<std::endl;
84 
85  reco::TrackRef matchedTrack = ixtrp->track();
86  associated.push_back( matchedTrack );
87  }
88  }
89 
90 
91 }
Jets made from CaloTowers.
Definition: CaloJet.h:29
LorentzVector detectorP4() const
detector p4 for full 3d vertex correction.
Definition: CaloJet.cc:64
Base class for all types of Jets.
Definition: Jet.h:20
void associateInputTracksToJet(reco::TrackRefVector &associated, const reco::Jet &fJet, std::vector< reco::TrackExtrapolation > const &fExtrapolations, double dR)
virtual double phi() const final
momentum azimuthal angle
void produce(Association *, JetRefs const &, std::vector< reco::TrackExtrapolation > const &, CaloGeometry const &, double dR)
Associates tracks to jets.
bool setValue(Container &, const reco::JetBaseRef &, reco::TrackRefVector)
associate jet with value. Returns false and associate nothing if jet is already associated ...
math::XYZPoint Point
point in the space
Definition: TrackBase.h:83
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:62
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5