21 if (pfCandPtr !=
nullptr) {
22 if (pfCandPtr->trackRef().isNonnull())
23 return pfCandPtr->trackRef().get();
24 else if (pfCandPtr->gsfTrackRef().isNonnull())
25 return pfCandPtr->gsfTrackRef().get();
40 if (pfCandPtr !=
nullptr) {
41 if (pfCandPtr->trackRef().isNonnull())
43 else if (pfCandPtr->gsfTrackRef().isNonnull())
58 std::cout <<
"<RecoTauVertexAssociator::getLeadTrack>:" << std::endl;
59 std::cout <<
" jet: Pt = " <<
jet.pt() <<
", eta = " <<
jet.eta() <<
", phi = " <<
jet.phi() << std::endl;
60 std::cout <<
" num. chargedPFCands = " << chargedPFCands.size() << std::endl;
64 if (chargedPFCands.empty()) {
68 std::vector<CandidatePtr> selectedPFCands;
72 selectedPFCands = chargedPFCands;
75 std::cout <<
" num. selectedPFCands = " << selectedPFCands.size() << std::endl;
79 if (!selectedPFCands.empty()) {
84 for (std::vector<CandidatePtr>::const_iterator pfCand = selectedPFCands.begin();
85 pfCand != selectedPFCands.end();
88 double actualTrackPt = 0., actualTrackPtError = 0.;
89 if (
track !=
nullptr) {
90 actualTrackPt =
track->pt();
91 actualTrackPtError =
track->ptError();
95 trackPt = actualTrackPt - 2. * actualTrackPtError;
118 <<
", phi = " <<
leadCand->phi() << std::endl;
152 return vtx->trackWeight(trk);
157 : vertexSelector_(nullptr), qcuts_(nullptr), jetToVertexAssociation_(nullptr), lastEvent_(0) {
163 if (!
pset.exists(
"primaryVertexSrc") || !
pset.exists(
"pvFindingAlgo")) {
165 <<
"The PSet passed to the RecoTauVertexAssociator was incorrectly configured." 166 <<
" The vertex will be taken as the highest Pt vertex from the 'offlinePrimaryVertices' collection." 173 if (
pset.exists(
"vxAssocQualityCuts")) {
183 if (!
pset.exists(
"vertexTrackFiltering") &&
pset.exists(
"vxAssocQualityCuts")) {
185 <<
"The PSet passed to the RecoTauVertexAssociator was incorrectly configured." 186 <<
" Please define vertexTrackFiltering in config file." 187 <<
" No filtering of tracks to vertices will be applied." << std::endl;
189 vxTrkFiltering_ =
pset.exists(
"vertexTrackFiltering") ?
pset.getParameter<
bool>(
"vertexTrackFiltering") :
false;
191 if (
pset.exists(
"vertexSelection")) {
202 }
else if (
algorithm_ ==
"highestWeightForLeadTrack") {
208 <<
"Invalid Configuration parameter 'algorithm' " <<
algorithm_ <<
"." 209 <<
" Valid options are: 'highestPtInEvent', 'closestInDeltaZ', 'highestWeightForLeadTrack' and " 217 std::string leadingTrkOrPFCandOption_string =
pset.exists(
"leadingTrkOrPFCandOption")
220 if (leadingTrkOrPFCandOption_string ==
"leadTrack")
222 else if (leadingTrkOrPFCandOption_string ==
"leadPFCand")
224 else if (leadingTrkOrPFCandOption_string ==
"minLeadTrackOrPFCand")
226 else if (leadingTrkOrPFCandOption_string ==
"firstTrack")
230 <<
"Invalid Configuration parameter 'leadingTrkOrPFCandOption' " << leadingTrkOrPFCandOption_string <<
"." 231 <<
" Valid options are: 'leadTrack', 'leadPFCand', 'firstTrack'.\n";
247 for (
size_t idxVertex = 0; idxVertex <
vertices->size(); ++idxVertex) {
268 if (
tau.leadChargedHadrCand().isNonnull()) {
270 if (
track !=
nullptr)
278 jetRef =
tau.pfTauTagInfoRef()->pfjetRef();
291 double closestDistance = 1.e+6;
294 for (std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
297 double dZ = dzToTrack(*selectedVertex,
track);
299 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x()
300 <<
", y = " << (*selectedVertex)->position().y()
301 <<
", z = " << (*selectedVertex)->position().z() <<
" --> dZ = " << dZ << std::endl;
303 if (dZ < closestDistance) {
304 trkVertex = (*selectedVertex);
305 closestDistance = dZ;
313 std::cout <<
"--> returning vertex: x = " << trkVertex->position().x() <<
", y = " << trkVertex->position().y()
314 <<
", z = " << trkVertex->position().z() << std::endl;
324 if (
track.isNonnull()) {
325 double largestWeight = -1.;
328 for (std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
331 double weight = trackWeightInVertex(*selectedVertex,
track);
333 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x()
334 <<
", y = " << (*selectedVertex)->position().y()
335 <<
", z = " << (*selectedVertex)->position().z() <<
" --> weight = " <<
weight << std::endl;
337 if (
weight > largestWeight) {
338 trkVertex = (*selectedVertex);
346 std::cout <<
"No vertex had positive weight! Trying dZ instead... " << std::endl;
348 double closestDistance = 1.e+6;
351 for (std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
354 double dZ = dzToTrack(*selectedVertex,
track.get());
356 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x()
357 <<
", y = " << (*selectedVertex)->position().y()
358 <<
", z = " << (*selectedVertex)->position().z() <<
" --> dZ = " << dZ << std::endl;
360 if (dZ < closestDistance) {
361 trkVertex = (*selectedVertex);
362 closestDistance = dZ;
371 std::cout <<
"--> returning vertex: x = " << trkVertex->position().x() <<
", y = " << trkVertex->position().y()
372 <<
", z = " << trkVertex->position().z() << std::endl;
380 std::cout <<
"<RecoTauVertexAssociator::associatedVertex>:" << std::endl;
381 std::cout <<
" jet: Pt = " <<
jet.pt() <<
", eta = " <<
jet.eta() <<
", phi = " <<
jet.phi() << std::endl;
395 jetVertex = vertexPtr->second;
407 <<
", phi = " <<
leadTrack->phi() << std::endl;
409 std::cout <<
"leadTrack: N/A" << std::endl;
420 <<
", phi = " <<
leadTrack->phi() << std::endl;
422 std::cout <<
"leadTrack: N/A" << std::endl;
433 std::cout <<
"--> returning vertex: x = " << jetVertex->position().x() <<
", y = " << jetVertex->position().y()
434 <<
", z = " << jetVertex->position().z() << std::endl;
unsigned long long EventNumber_t
std::vector< Vertex > VertexCollection
collection of Vertex objects
void setEvent(const edm::Event &evt)
Load the vertices from the event.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< CandidatePtr > pfChargedCands(const Jet &jet, bool sort=true)
Extract all non-neutral candidates from a PFJet.
InputIterator leadCand(InputIterator begin, InputIterator end)
virtual ~RecoTauVertexAssociator()
reco::VertexRef associatedVertex(const Jet &jet) const
std::vector< reco::VertexRef > selectedVertices_
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...
RecoTauQualityCuts * qcuts_
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Abs< T >::type abs(const T &t)
bool isNull() const
Checks for null.
const TrackBaseRef getLeadTrackRef(const Jet &) const
StringCutObjectSelector< reco::Vertex > * vertexSelector_
const Track * getLeadTrack(const Jet &) const
RecoTauVertexAssociator(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
Coll filterCandRefs(const Coll &refcoll, bool invert=false) const
Filter a ref vector of Candidates.
std::map< const reco::Jet *, reco::VertexRef > * jetToVertexAssociation_
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
edm::EDGetTokenT< reco::VertexCollection > vxToken_
Log< level::Warning, false > LogWarning
void setPV(const reco::VertexRef &vtx)
Update the primary vertex.
int leadingTrkOrPFCandOption_
EventNumber_t event() const
const CandidatePtr getLeadCand(const Jet &) const
virtual const reco::Track & pseudoTrack() const
edm::EventNumber_t lastEvent_
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.