4 #include <boost/foreach.hpp> 16 namespace reco {
namespace tau {
22 std::vector<PFCandidatePtr> chargedPFCands =
pfChargedCands(jet,
true);
24 std::cout <<
"<RecoTauVertexAssociator::getLeadTrack>:" << std::endl;
25 std::cout <<
" jet: Pt = " << jet.
pt() <<
", eta = " << jet.
eta() <<
", phi = " << jet.
phi() << std::endl;
26 std::cout <<
" num. chargedPFCands = " << chargedPFCands.size() << std::endl;
30 if ( chargedPFCands.empty() ) {
34 std::vector<PFCandidatePtr> selectedPFCands;
38 selectedPFCands = chargedPFCands;
41 std::cout <<
" num. selectedPFCands = " << selectedPFCands.size() << std::endl;
45 if ( !selectedPFCands.empty() ) {
50 for ( std::vector<PFCandidatePtr>::const_iterator pfCand = selectedPFCands.begin();
51 pfCand != selectedPFCands.end(); ++pfCand ) {
53 if ( (*pfCand)->trackRef().isNonnull() ) track = (*pfCand)->trackRef().get();
54 else if ( (*pfCand)->gsfTrackRef().isNonnull() ) track = (*pfCand)->gsfTrackRef().get();
55 if ( !track )
continue;
59 trackPt = track->
pt() - 2.*track->
ptError();
61 trackPt = (*pfCand)->pt();
63 trackPt =
TMath::Min(track->
pt(), (double)(*pfCand)->pt());
65 if ( trackPt > leadTrackPt ) {
66 leadPFCand = (*pfCand);
72 if ( leadPFCand.
isNull() ) {
74 leadPFCand = chargedPFCands[0];
80 std::cout <<
"leadPFCand: Pt = " << leadPFCand->pt() <<
", eta = " << leadPFCand->eta() <<
", phi = " << leadPFCand->phi() << std::endl;
83 if ( leadPFCand->trackRef().
isNonnull() ) {
85 }
else if ( leadPFCand->gsfTrackRef().
isNonnull() ) {
104 if ( !trk || !vtx ) {
107 return vtx->trackWeight(trk);
122 if ( !pset.
exists(
"primaryVertexSrc") || !pset.
exists(
"pvFindingAlgo") ) {
124 <<
"The PSet passed to the RecoTauVertexAssociator was incorrectly configured." 125 <<
" The vertex will be taken as the highest Pt vertex from the 'offlinePrimaryVertices' collection." 132 if ( pset.
exists(
"vxAssocQualityCuts") ) {
142 if ( !pset.
exists(
"vertexTrackFiltering") && pset.
exists(
"vxAssocQualityCuts") ) {
144 <<
"The PSet passed to the RecoTauVertexAssociator was incorrectly configured." 145 <<
" Please define vertexTrackFiltering in config file." 146 <<
" No filtering of tracks to vertices will be applied." 150 pset.
getParameter<
bool>(
"vertexTrackFiltering") :
false;
152 if ( pset.
exists(
"vertexSelection") ) {
154 if ( !vertexSelection.empty() ) {
161 }
else if (
algorithm_ ==
"closestInDeltaZ" ) {
163 }
else if (
algorithm_ ==
"highestWeightForLeadTrack" ) {
169 <<
"Invalid Configuration parameter 'algorithm' " <<
algorithm_ <<
"." 170 <<
" Valid options are: 'highestPtInEvent', 'closestInDeltaZ', 'highestWeightForLeadTrack' and 'combined'.\n";
184 <<
"Invalid Configuration parameter 'leadingTrkOrPFCandOption' " << leadingTrkOrPFCandOption_string <<
"." 185 <<
" Valid options are: 'leadTrack', 'leadPFCand', 'firstTrack'.\n";
204 for (
size_t idxVertex = 0; idxVertex < vertices->size(); ++idxVertex ) {
249 double closestDistance = 1.e+6;
252 for ( std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
254 double dZ = dzToTrack(*selectedVertex, track);
256 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x() <<
", y = " << (*selectedVertex)->position().y() <<
", z = " << (*selectedVertex)->position().z()
257 <<
" --> dZ = " << dZ << std::endl;
259 if ( dZ < closestDistance ) {
260 trkVertex = (*selectedVertex);
261 closestDistance = dZ;
268 double largestWeight = -1.;
271 for ( std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
273 double weight = trackWeightInVertex(*selectedVertex, track);
275 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x() <<
", y = " << (*selectedVertex)->position().y() <<
", z = " << (*selectedVertex)->position().z()
276 <<
" --> weight = " << weight << std::endl;
278 if ( weight > largestWeight ) {
279 trkVertex = (*selectedVertex);
287 std::cout <<
"No vertex had positive weight! Trying dZ instead... " << std::endl;
289 double closestDistance = 1.e+6;
292 for ( std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
294 double dZ = dzToTrack(*selectedVertex, track);
296 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x() <<
", y = " << (*selectedVertex)->position().y() <<
", z = " << (*selectedVertex)->position().z()
297 <<
" --> dZ = " << dZ << std::endl;
299 if ( dZ < closestDistance ) {
300 trkVertex = (*selectedVertex);
301 closestDistance = dZ;
310 std::cout <<
"--> returning vertex: x = " << trkVertex->position().x() <<
", y = " << trkVertex->position().y() <<
", z = " << trkVertex->position().z() << std::endl;
320 std::cout <<
"<RecoTauVertexAssociator::associatedVertex>:" << std::endl;
321 std::cout <<
" jet: Pt = " << jet.
pt() <<
", eta = " << jet.
eta() <<
", phi = " << jet.
phi() << std::endl;
335 jetVertex = vertexPtr->second;
346 if ( leadTrack.
isNonnull() )
std::cout <<
"leadTrack: Pt = " << leadTrack->
pt() <<
", eta = " << leadTrack->
eta() <<
", phi = " << leadTrack->
phi() << std::endl;
347 else std::cout <<
"leadTrack: N/A" << std::endl;
358 std::cout <<
"--> returning vertex: x = " << jetVertex->position().x() <<
", y = " << jetVertex->position().y() <<
", z = " << jetVertex->position().z() << std::endl;
T getParameter(std::string const &) const
EventNumber_t event() const
const PFJetRef & jetRef() const
double eta() const final
momentum pseudorapidity
const PFCandidatePtr & leadPFChargedHadrCand() const
Coll filterCandRefs(const Coll &refcoll, bool invert=false) const
Filter a ref vector of PFCandidates.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
reco::VertexRef associatedVertex(const PFJet &jet) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
unsigned long long EventNumber_t
double phi() const
azimuthal angle of momentum vector
double pt() const final
transverse momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
void setEvent(const edm::Event &evt)
Load the vertices from the event.
bool isNonnull() const
Checks for non-null.
reco::TrackBaseRef getLeadTrack(const PFJet &jet) const
Jets made from PFObjects.
virtual ~RecoTauVertexAssociator()
std::vector< reco::VertexRef > selectedVertices_
double eta() const
pseudorapidity of momentum vector
RecoTauQualityCuts * qcuts_
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
void setPV(const reco::VertexRef &vtx) const
Update the primary vertex.
double pt() const
track transverse momentum
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
bool isNull() const
Checks for null.
Abs< T >::type abs(const T &t)
bool isNull() const
Checks for null.
InputIterator leadPFCand(InputIterator begin, InputIterator end)
StringCutObjectSelector< reco::Vertex > * vertexSelector_
bool isNonnull() const
Checks for non-null.
RecoTauVertexAssociator(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
const PFTauTagInfoRef & pfTauTagInfoRef() const
ParameterSet const & getParameterSet(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > vxToken_
std::vector< PFCandidatePtr > pfChargedCands(const PFJet &jet, bool sort=true)
Extract all non-neutral candidates from a PFJet.
double phi() const final
momentum azimuthal angle
int leadingTrkOrPFCandOption_
std::map< const reco::PFJet *, reco::VertexRef > * jetToVertexAssociation_
edm::EventNumber_t lastEvent_