20 if (pfCandPtr !=
nullptr) {
21 if (pfCandPtr->trackRef().isNonnull())
22 return pfCandPtr->trackRef().get();
23 else if (pfCandPtr->gsfTrackRef().isNonnull())
24 return pfCandPtr->gsfTrackRef().get();
39 if (pfCandPtr !=
nullptr) {
40 if (pfCandPtr->trackRef().isNonnull())
42 else if (pfCandPtr->gsfTrackRef().isNonnull())
57 std::cout <<
"<RecoTauVertexAssociator::getLeadTrack>:" << std::endl;
58 std::cout <<
" jet: Pt = " <<
jet.pt() <<
", eta = " <<
jet.eta() <<
", phi = " <<
jet.phi() << std::endl;
59 std::cout <<
" num. chargedPFCands = " << chargedPFCands.size() << std::endl;
63 if (chargedPFCands.empty()) {
67 std::vector<CandidatePtr> selectedPFCands;
71 selectedPFCands = chargedPFCands;
74 std::cout <<
" num. selectedPFCands = " << selectedPFCands.size() << std::endl;
78 if (!selectedPFCands.empty()) {
83 for (std::vector<CandidatePtr>::const_iterator pfCand = selectedPFCands.begin();
84 pfCand != selectedPFCands.end();
87 double actualTrackPt = 0., actualTrackPtError = 0.;
88 if (
track !=
nullptr) {
89 actualTrackPt =
track->pt();
90 actualTrackPtError =
track->ptError();
94 trackPt = actualTrackPt - 2. * actualTrackPtError;
117 <<
", phi = " <<
leadCand->phi() << std::endl;
151 return vtx->trackWeight(trk);
156 : vertexSelector_(nullptr), qcuts_(nullptr), jetToVertexAssociation_(nullptr), lastEvent_(0) {
162 if (!
pset.exists(
"primaryVertexSrc") || !
pset.exists(
"pvFindingAlgo")) {
164 <<
"The PSet passed to the RecoTauVertexAssociator was incorrectly configured."
165 <<
" The vertex will be taken as the highest Pt vertex from the 'offlinePrimaryVertices' collection."
172 if (
pset.exists(
"vxAssocQualityCuts")) {
182 if (!
pset.exists(
"vertexTrackFiltering") &&
pset.exists(
"vxAssocQualityCuts")) {
184 <<
"The PSet passed to the RecoTauVertexAssociator was incorrectly configured."
185 <<
" Please define vertexTrackFiltering in config file."
186 <<
" No filtering of tracks to vertices will be applied." << std::endl;
188 vxTrkFiltering_ =
pset.exists(
"vertexTrackFiltering") ?
pset.getParameter<
bool>(
"vertexTrackFiltering") :
false;
190 if (
pset.exists(
"vertexSelection")) {
201 }
else if (
algorithm_ ==
"highestWeightForLeadTrack") {
207 <<
"Invalid Configuration parameter 'algorithm' " <<
algorithm_ <<
"."
208 <<
" Valid options are: 'highestPtInEvent', 'closestInDeltaZ', 'highestWeightForLeadTrack' and "
216 std::string leadingTrkOrPFCandOption_string =
pset.exists(
"leadingTrkOrPFCandOption")
219 if (leadingTrkOrPFCandOption_string ==
"leadTrack")
221 else if (leadingTrkOrPFCandOption_string ==
"leadPFCand")
223 else if (leadingTrkOrPFCandOption_string ==
"minLeadTrackOrPFCand")
225 else if (leadingTrkOrPFCandOption_string ==
"firstTrack")
229 <<
"Invalid Configuration parameter 'leadingTrkOrPFCandOption' " << leadingTrkOrPFCandOption_string <<
"."
230 <<
" Valid options are: 'leadTrack', 'leadPFCand', 'firstTrack'.\n";
246 for (
size_t idxVertex = 0; idxVertex <
vertices->size(); ++idxVertex) {
267 if (
tau.leadChargedHadrCand().isNonnull()) {
269 if (
track !=
nullptr)
277 jetRef =
tau.pfTauTagInfoRef()->pfjetRef();
290 double closestDistance = 1.e+6;
293 for (std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
296 double dZ = dzToTrack(*selectedVertex,
track);
298 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x()
299 <<
", y = " << (*selectedVertex)->position().y()
300 <<
", z = " << (*selectedVertex)->position().z() <<
" --> dZ = " << dZ << std::endl;
302 if (dZ < closestDistance) {
303 trkVertex = (*selectedVertex);
304 closestDistance = dZ;
312 std::cout <<
"--> returning vertex: x = " << trkVertex->position().x() <<
", y = " << trkVertex->position().y()
313 <<
", z = " << trkVertex->position().z() << std::endl;
323 if (
track.isNonnull()) {
324 double largestWeight = -1.;
327 for (std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
330 double weight = trackWeightInVertex(*selectedVertex,
track);
332 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x()
333 <<
", y = " << (*selectedVertex)->position().y()
334 <<
", z = " << (*selectedVertex)->position().z() <<
" --> weight = " <<
weight << std::endl;
336 if (
weight > largestWeight) {
337 trkVertex = (*selectedVertex);
345 std::cout <<
"No vertex had positive weight! Trying dZ instead... " << std::endl;
347 double closestDistance = 1.e+6;
350 for (std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
353 double dZ = dzToTrack(*selectedVertex,
track.get());
355 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x()
356 <<
", y = " << (*selectedVertex)->position().y()
357 <<
", z = " << (*selectedVertex)->position().z() <<
" --> dZ = " << dZ << std::endl;
359 if (dZ < closestDistance) {
360 trkVertex = (*selectedVertex);
361 closestDistance = dZ;
370 std::cout <<
"--> returning vertex: x = " << trkVertex->position().x() <<
", y = " << trkVertex->position().y()
371 <<
", z = " << trkVertex->position().z() << std::endl;
379 std::cout <<
"<RecoTauVertexAssociator::associatedVertex>:" << std::endl;
380 std::cout <<
" jet: Pt = " <<
jet.pt() <<
", eta = " <<
jet.eta() <<
", phi = " <<
jet.phi() << std::endl;
394 jetVertex = vertexPtr->second;
406 <<
", phi = " <<
leadTrack->phi() << std::endl;
408 std::cout <<
"leadTrack: N/A" << std::endl;
419 <<
", phi = " <<
leadTrack->phi() << std::endl;
421 std::cout <<
"leadTrack: N/A" << std::endl;
432 std::cout <<
"--> returning vertex: x = " << jetVertex->position().x() <<
", y = " << jetVertex->position().y()
433 <<
", z = " << jetVertex->position().z() << std::endl;