27 : maxNumWarnings_(3), numWarnings_(0) {
83 LogWarning(
"PF_PU_AssoMapAlgos::GetInputCollections")
84 <<
"No Extra objects available in input file --> skipping reconstruction of displaced vertices !!" << endl;
101 std::pair<std::unique_ptr<TrackToVertexAssMap>, std::unique_ptr<VertexToTrackAssMap>>
106 int num_vertices =
vtxcollH->size();
109 vector<VertexRef> vtxColl_help;
114 for (
size_t idxTrack = 0; idxTrack < trkcollH->size(); ++idxTrack) {
119 transtrk.
setES(iSetup);
126 int step = assocVtx.second;
136 track2vertex->insert(assocVtx.first, make_pair(trackref, quality));
137 vertex2track->insert(trackref, make_pair(assocVtx.first, quality));
140 if (input_MaxNumAssociations_ > 1)
180 assomap_ite != trackvertexassInput->
end();
190 for (
unsigned int trckcoll_ite = 0; trckcoll_ite < trckcoll.size(); trckcoll_ite++) {
191 trackref = trckcoll[trckcoll_ite].first;
192 int quality = trckcoll[trckcoll_ite].second;
197 double man_pT = trackref->pt() - trackref->ptError();
199 ptsum += man_pT * man_pT;
202 vertexptsumvector.push_back(make_pair(assomap_vertexref, ptsum));
205 while (!vertexptsumvector.empty()) {
207 float highestpT = 0.;
208 int highestpT_index = 0;
210 for (
unsigned int vtxptsumvec_ite = 0; vtxptsumvec_ite < vertexptsumvector.size(); vtxptsumvec_ite++) {
211 if (vertexptsumvector[vtxptsumvec_ite].
second > highestpT) {
212 vertexref_highestpT = vertexptsumvector[vtxptsumvec_ite].first;
213 highestpT = vertexptsumvector[vtxptsumvec_ite].second;
214 highestpT_index = vtxptsumvec_ite;
220 assomap_ite != trackvertexassInput->
end();
227 if (assomap_vertexref == vertexref_highestpT)
228 for (
unsigned int trckcoll_ite = 0; trckcoll_ite < trckcoll.size(); trckcoll_ite++)
229 trackvertexassOutput->insert(assomap_vertexref, trckcoll[trckcoll_ite]);
232 vertexptsumvector.erase(vertexptsumvector.begin() + highestpT_index);
235 return trackvertexassOutput;
250 output.reserve(vtxcollH->size());
251 auto const nVtx = vtxcollH->size();
252 for (
unsigned int i = 0;
i < nVtx; ++
i)
253 output.emplace_back(vtxcollH,
i);
263 for (
unsigned int index_vtx = 0; index_vtx < vtxcollV.size(); ++index_vtx) {
264 VertexRef vertexref = vtxcollV.at(index_vtx);
266 if (vertexref == toErase) {
267 vtxcollV.erase(vtxcollV.begin() + index_vtx);
278 const std::vector<reco::VertexRef>& vtxcollV,
280 double ztrack = trkref->vertex().z();
282 VertexRef foundVertexRef = vtxcollV.at(0);
287 for (
unsigned int index_vtx = 0; index_vtx < vtxcollV.size(); ++index_vtx) {
288 VertexRef vertexref = vtxcollV.at(index_vtx);
292 double z_distance = fabs(ztrack - vertexref->z());
294 double weightedDistance = z_distance - tWeight *
nTracks;
296 if (weightedDistance < dzmin) {
297 dzmin = weightedDistance;
298 foundVertexRef = vertexref;
302 return foundVertexRef;
310 const std::vector<reco::VertexRef>& vtxcollV,
312 VertexRef foundVertexRef = vtxcollV.at(0);
317 for (
unsigned int index_vtx = 0; index_vtx < vtxcollV.size(); ++index_vtx) {
318 VertexRef vertexref = vtxcollV.at(index_vtx);
326 distance = IpPair.second.value();
328 double weightedDistance = distance - tWeight *
nTracks;
330 if (weightedDistance < d3min) {
331 d3min = weightedDistance;
332 foundVertexRef = vertexref;
336 return foundVertexRef;
346 double bs_x = bsH->
x0();
347 double bs_y = bsH->
y0();
348 double bs_z = bsH->
z0();
350 double connVec_x = vtx_pos.x() - bs_x;
351 double connVec_y = vtx_pos.y() - bs_y;
352 double connVec_z = vtx_pos.z() - bs_z;
354 double connVec_r =
sqrt(connVec_x * connVec_x + connVec_y * connVec_y + connVec_z * connVec_z);
355 double connVec_theta = acos(connVec_z * 1. / connVec_r);
357 double connVec_eta = -1. *
log(
tan(connVec_theta * 1. / 2.));
358 double connVec_phi = atan2(connVec_y, connVec_x);
360 return deltaR(vtx_mom.eta(), vtx_mom.phi(), connVec_eta, connVec_phi);
371 for (
unsigned int convcoll_idx = 0; convcoll_idx < convCollH->size(); convcoll_idx++) {
375 cleanedConvColl->push_back(*convref);
379 if ((convref->nTracks() == 2) && (fabs(convref->pairInvariantMass()) <= 0.1)) {
380 cleanedConvColl->push_back(*convref);
384 return cleanedConvColl;
394 for (
unsigned int convcoll_ite = 0; convcoll_ite < cleanedConvColl.size(); convcoll_ite++) {
396 *gamma = cleanedConvColl.at(convcoll_ite);
413 const std::vector<reco::VertexRef>& vtxcollV,
420 Track photon(trackref->chi2(), trackref->ndof(), conv_pos, conv_mom, 0, trackref->covariance());
423 transpho.setBeamSpot(*bsH);
424 transpho.setES(iSetup);
437 for (
unsigned int kscoll_idx = 0; kscoll_idx < KshortsH->size(); kscoll_idx++) {
441 cleanedKaonColl->push_back(*ksref);
450 ksref->vertexCovariance(0, 1),
451 ksref->vertexCovariance(1, 1),
452 ksref->vertexCovariance(0, 2),
453 ksref->vertexCovariance(1, 2),
454 ksref->vertexCovariance(2, 2));
456 math::XYZVector dec_mom(ksref->momentum().x(), ksref->momentum().y(), ksref->momentum().z());
461 double kaon_significance =
465 if ((ksref->vertex().rho() >= 3.) && (ksref->vertexNormalizedChi2() <= 3.) &&
466 (fabs(ksref->mass() -
kMass) <= 0.01) && (kaon_significance > 15.) &&
468 cleanedKaonColl->push_back(*ksref);
472 return cleanedKaonColl;
483 for (
unsigned int lambdacoll_idx = 0; lambdacoll_idx < LambdasH->size(); lambdacoll_idx++) {
487 cleanedLambdaColl->push_back(*lambdaref);
496 lambdaref->vertexCovariance(0, 1),
497 lambdaref->vertexCovariance(1, 1),
498 lambdaref->vertexCovariance(0, 2),
499 lambdaref->vertexCovariance(1, 2),
500 lambdaref->vertexCovariance(2, 2));
502 math::XYZVector dec_mom(lambdaref->momentum().x(), lambdaref->momentum().y(), lambdaref->momentum().z());
507 double lambda_significance =
511 if ((lambdaref->vertex().rho() >= 3.) && (lambdaref->vertexNormalizedChi2() <= 3.) &&
512 (fabs(lambdaref->mass() -
lamMass) <= 0.005) && (lambda_significance > 15.) &&
514 cleanedLambdaColl->push_back(*lambdaref);
518 return cleanedLambdaColl;
530 for (VertexCompositeCandidateCollection::const_iterator iKS = cleanedKshort.begin(); iKS != cleanedKshort.end();
537 if ((trackref == dauTk1) || (trackref == dauTk2)) {
544 for (VertexCompositeCandidateCollection::const_iterator iLambda = cleanedLambda.begin();
545 iLambda != cleanedLambda.end();
552 if ((trackref == dauTk1) || (trackref == dauTk2)) {
570 const std::vector<reco::VertexRef>& vtxcollV,
576 Track V0(trackref->chi2(), trackref->ndof(), dec_pos, dec_mom, 0, trackref->covariance());
579 transV0.setBeamSpot(*bsH);
580 transV0.setES(iSetup);
594 for (PFDisplacedVertexCollection::const_iterator niref = NuclIntH->begin(); niref != NuclIntH->end(); niref++) {
595 if ((niref->isFake()) || !(niref->isNucl()))
599 cleanedNIColl->push_back(*niref);
608 math::XYZVector ni_mom(niref->primaryMomentum().x(), niref->primaryMomentum().y(), niref->primaryMomentum().z());
613 double nuclint_significance =
617 if ((niref->position().rho() >= 3.) && (nuclint_significance > 15.) &&
619 cleanedNIColl->push_back(*niref);
623 return cleanedNIColl;
634 for (PFDisplacedVertexCollection::const_iterator iDisplV = cleanedNI.begin(); iDisplV != cleanedNI.end(); iDisplV++) {
635 if (iDisplV->trackWeight(trackref) > 1.e-5) {
636 *displVtx = *iDisplV;
653 const std::vector<reco::VertexRef>& vtxcollV,
658 for (TrackCollection::const_iterator trkcoll_ite = refittedTracks.begin(); trkcoll_ite != refittedTracks.end();
665 if (VOAssociation->trackWeight(retrackbaseref) >= 1.e-5) {
666 return VOAssociation;
671 transIncom.
setES(iSetup);
683 Track incom(trackref->chi2(), trackref->ndof(), ni_pos, ni_mom, 0, trackref->covariance());
686 transIncom.setBeamSpot(*bsH);
687 transIncom.setES(iSetup);
695 template <
typename TREF>
697 const std::vector<reco::VertexRef>& vtxcollV) {
698 VertexRef bestvertexref = vtxcollV.at(0);
699 float bestweight = 0.;
702 for (
auto const& vertexref : vtxcollV) {
704 float weight = vertexref->trackWeight(trackRef);
705 if (weight > bestweight) {
707 bestvertexref = vertexref;
711 return bestvertexref;
719 const std::vector<reco::VertexRef>& vtxColl,
735 if (foundVertex->trackWeight(trackref) >= 1.e-5) {
736 return make_pair(foundVertex, 0.);
750 return make_pair(foundVertex, 1.);
758 return make_pair(foundVertex, 1.);
767 return make_pair(foundVertex, 1.);
791 transtrk.
setES(iSetup);
799 foundVertex = vtxColl.at(0);
804 return make_pair(foundVertex, 2.);
817 if (distance <=
tw_90) {
820 if (distance <=
tw_70) {
823 if (distance <=
tw_50) {
849 if (assoc_ite == 1) {
852 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)
T getParameter(std::string const &) const
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedLambda(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
double z0() const
z coordinate
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_
const unsigned int nTracks(const reco::Vertex &sv)
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 >)
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
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 reco::VertexRef FindV0Vertex(const reco::TrackRef, const reco::VertexCompositeCandidate &, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
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_
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.
std::vector< Vertex > VertexCollection
collection of Vertex objects
key_type key() const
Accessor for product key.
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
std::unique_ptr< TrackToVertexAssMap > CreateTrackToVertexMap(edm::Handle< reco::TrackCollection >, const edm::EventSetup &)
std::unique_ptr< reco::PFDisplacedVertexCollection > cleanedNICollP
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedLambdaCollP
const Point & position() const
position
std::pair< reco::VertexRef, int > VertexStepPair
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
std::vector< VertexPtsumPair > VertexPtsumVector
U second(std::pair< T, U > const &p)
VertexStepPair FindAssociation(const reco::TrackRef &, const std::vector< reco::VertexRef > &, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, int)
Vector momentum() const final
spatial momentum vector
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
static std::unique_ptr< reco::ConversionCollection > GetCleanedConversions(edm::Handle< reco::ConversionCollection >, edm::Handle< reco::BeamSpot >, bool)
const Point & vertex() const override
vertex position (overwritten by PF...)
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 &)
reco::TrackRef track() const override
reference to a track
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings(edm::Handle< reco::TrackCollection > trkcollH, const edm::EventSetup &iSetup)
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 reco::VertexRef FindConversionVertex(const reco::TrackRef, const reco::Conversion &, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
edm::EDGetTokenT< reco::PFDisplacedVertexCollection > NIVertexCollectionToken_
void setES(const edm::EventSetup &es)
edm::Handle< reco::VertexCollection > vtxcollH
bool ignoremissingpfcollection_
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_
std::unique_ptr< VertexToTrackAssMap > CreateVertexToTrackMap(edm::Handle< reco::TrackCollection >, const edm::EventSetup &)
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
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedKshortCollP
void EraseVertex(std::vector< reco::VertexRef > &, reco::VertexRef)
static bool ComesFromConversion(const reco::TrackRef, const reco::ConversionCollection &, reco::Conversion *)
double y0() const
y coordinate
const Point & position() const
position
edm::Handle< reco::BeamSpot > beamspotH
const_iterator begin() const
first iterator over the map (read only)
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
static reco::VertexRef FindNIVertex(const reco::TrackRef, const reco::PFDisplacedVertex &, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
double x0() const
x coordinate
std::unique_ptr< reco::ConversionCollection > cleanedConvCollP