89 LogWarning(
"PF_PU_AssoMapAlgos::GetInputCollections")
90 <<
"No Extra objects available in input file --> skipping reconstruction of displaced vertices !!" << endl;
108 std::pair<std::unique_ptr<TrackToVertexAssMap>, std::unique_ptr<VertexToTrackAssMap>>
113 int num_vertices =
vtxcollH->size();
116 vector<VertexRef> vtxColl_help;
121 for (
size_t idxTrack = 0; idxTrack < trkcollH->size(); ++idxTrack) {
134 int step = assocVtx.second;
144 track2vertex->insert(assocVtx.first, make_pair(trackref, quality));
145 vertex2track->insert(trackref, make_pair(assocVtx.first, quality));
148 if (input_MaxNumAssociations_ > 1)
188 assomap_ite != trackvertexassInput->
end();
198 for (
unsigned int trckcoll_ite = 0; trckcoll_ite < trckcoll.size(); trckcoll_ite++) {
199 trackref = trckcoll[trckcoll_ite].first;
200 int quality = trckcoll[trckcoll_ite].second;
205 double man_pT = trackref->pt() - trackref->ptError();
207 ptsum += man_pT * man_pT;
210 vertexptsumvector.push_back(make_pair(assomap_vertexref, ptsum));
213 while (!vertexptsumvector.empty()) {
215 float highestpT = 0.;
216 int highestpT_index = 0;
218 for (
unsigned int vtxptsumvec_ite = 0; vtxptsumvec_ite < vertexptsumvector.size(); vtxptsumvec_ite++) {
219 if (vertexptsumvector[vtxptsumvec_ite].
second > highestpT) {
220 vertexref_highestpT = vertexptsumvector[vtxptsumvec_ite].first;
221 highestpT = vertexptsumvector[vtxptsumvec_ite].second;
222 highestpT_index = vtxptsumvec_ite;
228 assomap_ite != trackvertexassInput->
end();
235 if (assomap_vertexref == vertexref_highestpT)
236 for (
unsigned int trckcoll_ite = 0; trckcoll_ite < trckcoll.size(); trckcoll_ite++)
237 trackvertexassOutput->insert(assomap_vertexref, trckcoll[trckcoll_ite]);
240 vertexptsumvector.erase(vertexptsumvector.begin() + highestpT_index);
243 return trackvertexassOutput;
258 output.reserve(vtxcollH->size());
259 auto const nVtx = vtxcollH->size();
260 for (
unsigned int i = 0;
i < nVtx; ++
i)
261 output.emplace_back(vtxcollH,
i);
271 for (
unsigned int index_vtx = 0; index_vtx < vtxcollV.size(); ++index_vtx) {
272 VertexRef vertexref = vtxcollV.at(index_vtx);
274 if (vertexref == toErase) {
275 vtxcollV.erase(vtxcollV.begin() + index_vtx);
286 const std::vector<reco::VertexRef>& vtxcollV,
288 double ztrack = trkref->vertex().z();
290 VertexRef foundVertexRef = vtxcollV.at(0);
295 for (
unsigned int index_vtx = 0; index_vtx < vtxcollV.size(); ++index_vtx) {
296 VertexRef vertexref = vtxcollV.at(index_vtx);
300 double z_distance = fabs(ztrack - vertexref->z());
302 double weightedDistance = z_distance - tWeight *
nTracks;
304 if (weightedDistance < dzmin) {
305 dzmin = weightedDistance;
306 foundVertexRef = vertexref;
310 return foundVertexRef;
318 const std::vector<reco::VertexRef>& vtxcollV,
320 VertexRef foundVertexRef = vtxcollV.at(0);
325 for (
unsigned int index_vtx = 0; index_vtx < vtxcollV.size(); ++index_vtx) {
326 VertexRef vertexref = vtxcollV.at(index_vtx);
334 distance = IpPair.second.value();
336 double weightedDistance = distance - tWeight *
nTracks;
338 if (weightedDistance < d3min) {
339 d3min = weightedDistance;
340 foundVertexRef = vertexref;
344 return foundVertexRef;
354 double bs_x = bsH->x0();
355 double bs_y = bsH->y0();
356 double bs_z = bsH->z0();
358 double connVec_x = vtx_pos.x() - bs_x;
359 double connVec_y = vtx_pos.y() - bs_y;
360 double connVec_z = vtx_pos.z() - bs_z;
362 double connVec_r =
sqrt(connVec_x * connVec_x + connVec_y * connVec_y + connVec_z * connVec_z);
363 double connVec_theta = acos(connVec_z * 1. / connVec_r);
365 double connVec_eta = -1. *
log(
tan(connVec_theta * 1. / 2.));
366 double connVec_phi = atan2(connVec_y, connVec_x);
368 return deltaR(vtx_mom.eta(), vtx_mom.phi(), connVec_eta, connVec_phi);
379 for (
unsigned int convcoll_idx = 0; convcoll_idx < convCollH->size(); convcoll_idx++) {
383 cleanedConvColl->push_back(*convref);
387 if ((convref->nTracks() == 2) && (fabs(convref->pairInvariantMass()) <= 0.1)) {
388 cleanedConvColl->push_back(*convref);
392 return cleanedConvColl;
402 for (
unsigned int convcoll_ite = 0; convcoll_ite < cleanedConvColl.size(); convcoll_ite++) {
404 *gamma = cleanedConvColl.at(convcoll_ite);
421 const std::vector<reco::VertexRef>& vtxcollV,
428 Track photon(trackref->chi2(), trackref->ndof(), conv_pos, conv_mom, 0, trackref->covariance());
431 transpho.setBeamSpot(*bsH);
432 transpho.setTrackingGeometry(tgH);
445 for (
unsigned int kscoll_idx = 0; kscoll_idx < KshortsH->size(); kscoll_idx++) {
449 cleanedKaonColl->push_back(*ksref);
458 ksref->vertexCovariance(0, 1),
459 ksref->vertexCovariance(1, 1),
460 ksref->vertexCovariance(0, 2),
461 ksref->vertexCovariance(1, 2),
462 ksref->vertexCovariance(2, 2));
464 math::XYZVector dec_mom(ksref->momentum().x(), ksref->momentum().y(), ksref->momentum().z());
469 double kaon_significance =
473 if ((ksref->vertex().rho() >= 3.) && (ksref->vertexNormalizedChi2() <= 3.) &&
474 (fabs(ksref->mass() -
kMass) <= 0.01) && (kaon_significance > 15.) &&
476 cleanedKaonColl->push_back(*ksref);
480 return cleanedKaonColl;
491 for (
unsigned int lambdacoll_idx = 0; lambdacoll_idx < LambdasH->size(); lambdacoll_idx++) {
495 cleanedLambdaColl->push_back(*lambdaref);
504 lambdaref->vertexCovariance(0, 1),
505 lambdaref->vertexCovariance(1, 1),
506 lambdaref->vertexCovariance(0, 2),
507 lambdaref->vertexCovariance(1, 2),
508 lambdaref->vertexCovariance(2, 2));
510 math::XYZVector dec_mom(lambdaref->momentum().x(), lambdaref->momentum().y(), lambdaref->momentum().z());
515 double lambda_significance =
519 if ((lambdaref->vertex().rho() >= 3.) && (lambdaref->vertexNormalizedChi2() <= 3.) &&
520 (fabs(lambdaref->mass() -
lamMass) <= 0.005) && (lambda_significance > 15.) &&
522 cleanedLambdaColl->push_back(*lambdaref);
526 return cleanedLambdaColl;
538 for (VertexCompositeCandidateCollection::const_iterator iKS = cleanedKshort.begin(); iKS != cleanedKshort.end();
545 if ((trackref == dauTk1) || (trackref == dauTk2)) {
552 for (VertexCompositeCandidateCollection::const_iterator iLambda = cleanedLambda.begin();
553 iLambda != cleanedLambda.end();
560 if ((trackref == dauTk1) || (trackref == dauTk2)) {
578 const std::vector<reco::VertexRef>& vtxcollV,
584 Track V0(trackref->chi2(), trackref->ndof(), dec_pos, dec_mom, 0, trackref->covariance());
587 transV0.setBeamSpot(*bsH);
588 transV0.setTrackingGeometry(trackingGeometryH);
602 for (PFDisplacedVertexCollection::const_iterator niref = NuclIntH->begin(); niref != NuclIntH->end(); niref++) {
603 if ((niref->isFake()) || !(niref->isNucl()))
607 cleanedNIColl->push_back(*niref);
616 math::XYZVector ni_mom(niref->primaryMomentum().x(), niref->primaryMomentum().y(), niref->primaryMomentum().z());
621 double nuclint_significance =
625 if ((niref->position().rho() >= 3.) && (nuclint_significance > 15.) &&
627 cleanedNIColl->push_back(*niref);
631 return cleanedNIColl;
642 for (PFDisplacedVertexCollection::const_iterator iDisplV = cleanedNI.begin(); iDisplV != cleanedNI.end(); iDisplV++) {
643 if (iDisplV->trackWeight(trackref) > 1.e-5) {
644 *displVtx = *iDisplV;
661 const std::vector<reco::VertexRef>& vtxcollV,
666 for (TrackCollection::const_iterator trkcoll_ite = refittedTracks.begin(); trkcoll_ite != refittedTracks.end();
673 if (VOAssociation->trackWeight(retrackbaseref) >= 1.e-5) {
674 return VOAssociation;
691 Track incom(trackref->chi2(), trackref->ndof(), ni_pos, ni_mom, 0, trackref->covariance());
694 transIncom.setBeamSpot(*bsH);
695 transIncom.setTrackingGeometry(trackingGeometryH);
703 template <
typename TREF>
705 const std::vector<reco::VertexRef>& vtxcollV) {
706 VertexRef bestvertexref = vtxcollV.at(0);
707 float bestweight = 0.;
710 for (
auto const& vertexref : vtxcollV) {
712 float weight = vertexref->trackWeight(trackRef);
713 if (weight > bestweight) {
715 bestvertexref = vertexref;
719 return bestvertexref;
727 const std::vector<reco::VertexRef>& vtxColl,
743 if (foundVertex->trackWeight(trackref) >= 1.e-5) {
744 return make_pair(foundVertex, 0.);
758 return make_pair(foundVertex, 1.);
766 return make_pair(foundVertex, 1.);
775 return make_pair(foundVertex, 1.);
807 foundVertex = vtxColl.at(0);
812 return make_pair(foundVertex, 2.);
825 if (distance <=
tw_90) {
828 if (distance <=
tw_70) {
831 if (distance <=
tw_50) {
857 if (assoc_ite == 1) {
860 if (assoc_ite >= 2) {
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > LambdaCollectionToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
reco::Vertex::Point convertPos(const GlobalPoint &p)
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedLambda(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
edm::ESHandle< MagneticField > bFieldH
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot_
std::unique_ptr< VertexToTrackAssMap > CreateVertexToTrackMap(edm::Handle< reco::TrackCollection >)
static reco::VertexRef FindNIVertex(const reco::TrackRef, const reco::PFDisplacedVertex &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
static std::vector< std::string > checklist log
Vector momentum() const final
spatial momentum vector
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
static std::unique_ptr< reco::PFDisplacedVertexCollection > GetCleanedNI(edm::Handle< reco::PFDisplacedVertexCollection >, edm::Handle< reco::BeamSpot >, bool)
std::unique_ptr< TrackToVertexAssMap > SortAssociationMap(TrackToVertexAssMap *, edm::Handle< reco::TrackCollection >)
const bool isTherePrimaryTracks() const
--—— Provide useful information --—— ///
const_iterator end() const
last iterator over the map (read only)
void setBeamSpot(const reco::BeamSpot &beamSpot)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackBaseRef originalTrack(const Track &refTrack) const
static bool ComesFromNI(const reco::TrackRef, const reco::PFDisplacedVertexCollection &, reco::PFDisplacedVertex *)
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedKshort(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
int DefineQuality(int, int, double)
static reco::VertexRef TrackWeightAssociation(const TREF &, const std::vector< reco::VertexRef > &)
int input_MaxNumAssociations_
bool input_doReassociation_
VertexStepPair FindAssociation(const reco::TrackRef &, const std::vector< reco::VertexRef > &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, int)
reco::Vertex::Error convertError(const GlobalError &ge)
std::vector< Track > TrackCollection
collection of Tracks
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
const bool isIncomingTrack(const reco::TrackBaseRef &originalTrack) const
Is primary or merged track.
edm::ESHandle< GlobalTrackingGeometry > trackingGeometryH
std::vector< Vertex > VertexCollection
collection of Vertex objects
const Point & vertex() const override
vertex position (overwritten by PF...)
key_type key() const
Accessor for product key.
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
std::unique_ptr< reco::PFDisplacedVertexCollection > cleanedNICollP
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedLambdaCollP
const Point & position() const
position
static reco::VertexRef FindConversionVertex(const reco::TrackRef, const reco::Conversion &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
std::pair< reco::VertexRef, int > VertexStepPair
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
std::vector< VertexPtsumPair > VertexPtsumVector
std::unique_ptr< TrackToVertexAssMap > CreateTrackToVertexMap(edm::Handle< reco::TrackCollection >)
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings(edm::Handle< reco::TrackCollection > trkcollH)
U second(std::pair< T, U > const &p)
static std::unique_ptr< reco::ConversionCollection > GetCleanedConversions(edm::Handle< reco::ConversionCollection >, edm::Handle< reco::BeamSpot >, bool)
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > token_TrackingGeometry_
reco::TrackRef track() const override
reference to a track
PF_PU_AssoMapAlgos(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
edm::Handle< reco::PFDisplacedVertexCollection > displVertexCollH
Tan< T >::type tan(const T &t)
virtual void GetInputCollections(edm::Event &, const edm::EventSetup &)
static bool ComesFromV0Decay(const reco::TrackRef, const reco::VertexCompositeCandidateCollection &, const reco::VertexCompositeCandidateCollection &, reco::VertexCompositeCandidate *)
edm::AssociationMap< edm::OneToManyWithQuality< reco::VertexCollection, reco::TrackCollection, int > > TrackToVertexAssMap
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
edm::EDGetTokenT< reco::PFDisplacedVertexCollection > NIVertexCollectionToken_
edm::Handle< reco::VertexCollection > vtxcollH
bool ignoremissingpfcollection_
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
math::XYZTLorentzVectorF refittedPair4Momentum() const
Conversion track pair 4-momentum from the tracks refitted with vertex constraint. ...
static reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector< reco::VertexRef > &, double tWeight=0.)
std::vector< reco::VertexRef > CreateVertexVector(edm::Handle< reco::VertexCollection >)
int input_FinalAssociation_
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > KshortCollectionToken_
std::vector< TrackQualityPair > TrackQualityPairVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
const math::XYZTLorentzVector primaryMomentum(std::string massHypo="PI", bool useRefitted=true, double mass=0.0) const
Momentum of primary or merged track calculated with a mass hypothesis.
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
edm::EDGetTokenT< reco::ConversionCollection > ConversionsCollectionToken_
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollLambdaH
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
static reco::VertexRef FindV0Vertex(const reco::TrackRef, const reco::VertexCompositeCandidate &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedKshortCollP
void EraseVertex(std::vector< reco::VertexRef > &, reco::VertexRef)
void setTrackingGeometry(const edm::ESHandle< GlobalTrackingGeometry > &tg)
static bool ComesFromConversion(const reco::TrackRef, const reco::ConversionCollection &, reco::Conversion *)
edm::Handle< reco::BeamSpot > beamspotH
const_iterator begin() const
first iterator over the map (read only)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Warning, false > LogWarning
edm::Handle< reco::ConversionCollection > convCollH
const bool isThereMergedTracks() const
If a merged track was identified.
static reco::VertexRef FindClosestZ(const reco::TrackRef, const std::vector< reco::VertexRef > &, double tWeight=0.)
edm::AssociationMap< edm::OneToManyWithQuality< reco::TrackCollection, reco::VertexCollection, int > > VertexToTrackAssMap
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollKshortH
std::unique_ptr< reco::ConversionCollection > cleanedConvCollP
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > token_bField_