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;
70 selectedPFCands =
qcuts_->filterCandRefs(chargedPFCands);
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")) {
175 qcuts_ = std::make_unique<RecoTauQualityCuts>(
pset.getParameterSet(
"vxAssocQualityCuts"));
178 qcuts_ = std::make_unique<RecoTauQualityCuts>(
pset.getParameterSet(
"signalQualityCuts"));
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";
241 for (
size_t idxVertex = 0; idxVertex <
vertices->size(); ++idxVertex) {
262 if (
tau.leadChargedHadrCand().isNonnull()) {
264 if (
track !=
nullptr)
272 jetRef =
tau.pfTauTagInfoRef()->pfjetRef();
285 double closestDistance = 1.e+6;
288 for (std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
291 double dZ = dzToTrack(*selectedVertex,
track);
293 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x()
294 <<
", y = " << (*selectedVertex)->position().y()
295 <<
", z = " << (*selectedVertex)->position().z() <<
" --> dZ = " << dZ << std::endl;
297 if (dZ < closestDistance) {
298 trkVertex = (*selectedVertex);
299 closestDistance = dZ;
307 std::cout <<
"--> returning vertex: x = " << trkVertex->position().x() <<
", y = " << trkVertex->position().y()
308 <<
", z = " << trkVertex->position().z() << std::endl;
318 if (
track.isNonnull()) {
319 double largestWeight = -1.;
322 for (std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
325 double weight = trackWeightInVertex(*selectedVertex,
track);
327 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x()
328 <<
", y = " << (*selectedVertex)->position().y()
329 <<
", z = " << (*selectedVertex)->position().z() <<
" --> weight = " <<
weight << std::endl;
331 if (
weight > largestWeight) {
332 trkVertex = (*selectedVertex);
340 std::cout <<
"No vertex had positive weight! Trying dZ instead... " << std::endl;
342 double closestDistance = 1.e+6;
345 for (std::vector<reco::VertexRef>::const_iterator selectedVertex =
selectedVertices_.begin();
348 double dZ = dzToTrack(*selectedVertex,
track.get());
350 std::cout <<
"vertex #" << idxVertex <<
": x = " << (*selectedVertex)->position().x()
351 <<
", y = " << (*selectedVertex)->position().y()
352 <<
", z = " << (*selectedVertex)->position().z() <<
" --> dZ = " << dZ << std::endl;
354 if (dZ < closestDistance) {
355 trkVertex = (*selectedVertex);
356 closestDistance = dZ;
365 std::cout <<
"--> returning vertex: x = " << trkVertex->position().x() <<
", y = " << trkVertex->position().y()
366 <<
", z = " << trkVertex->position().z() << std::endl;
374 std::cout <<
"<RecoTauVertexAssociator::associatedVertex>:" << std::endl;
375 std::cout <<
" jet: Pt = " <<
jet.pt() <<
", eta = " <<
jet.eta() <<
", phi = " <<
jet.phi() << std::endl;
389 jetVertex = vertexPtr->second;
401 <<
", phi = " <<
leadTrack->phi() << std::endl;
403 std::cout <<
"leadTrack: N/A" << std::endl;
414 <<
", phi = " <<
leadTrack->phi() << std::endl;
416 std::cout <<
"leadTrack: N/A" << std::endl;
427 std::cout <<
"--> returning vertex: x = " << jetVertex->position().x() <<
", y = " << jetVertex->position().y()
428 <<
", z = " << jetVertex->position().z() << std::endl;
std::unique_ptr< JetToVtxAssoc > jetToVertexAssociation_
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)
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...
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
const Track * getLeadTrack(const Jet &) const
RecoTauVertexAssociator(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
std::unique_ptr< RecoTauQualityCuts > qcuts_
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
edm::EDGetTokenT< reco::VertexCollection > vxToken_
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > vertexSelector_
Log< level::Warning, false > LogWarning
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.