CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Static Private Member Functions | Private Attributes
PF_PU_AssoMapAlgos Class Reference

#include <PF_PU_AssoMapAlgos.h>

Inheritance diagram for PF_PU_AssoMapAlgos:
PF_PU_AssoMap PFCand_AssoMapAlgos PFCand_AssoMap

Public Member Functions

std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings (edm::Handle< reco::TrackCollection > trkcollH)
 
std::unique_ptr< TrackToVertexAssMapCreateTrackToVertexMap (edm::Handle< reco::TrackCollection >)
 
std::unique_ptr< VertexToTrackAssMapCreateVertexToTrackMap (edm::Handle< reco::TrackCollection >)
 
virtual void GetInputCollections (edm::Event &, const edm::EventSetup &)
 
 PF_PU_AssoMapAlgos (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
 PF_PU_AssoMapAlgos (const edm::ParameterSet &, edm::ConsumesCollector &)
 
std::unique_ptr< TrackToVertexAssMapSortAssociationMap (TrackToVertexAssMap *, edm::Handle< reco::TrackCollection >)
 
template<typename TREF >
VertexRef TrackWeightAssociation (const TREF &trackRef, const std::vector< reco::VertexRef > &vtxcollV)
 
virtual ~PF_PU_AssoMapAlgos () noexcept(false)
 

Protected Member Functions

std::vector< reco::VertexRefCreateVertexVector (edm::Handle< reco::VertexCollection >)
 
int DefineQuality (int, int, double)
 
void EraseVertex (std::vector< reco::VertexRef > &, reco::VertexRef)
 
VertexStepPair FindAssociation (const reco::TrackRef &, const std::vector< reco::VertexRef > &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, int)
 

Static Private Member Functions

static bool ComesFromConversion (const reco::TrackRef, const reco::ConversionCollection &, reco::Conversion *)
 
static bool ComesFromNI (const reco::TrackRef, const reco::PFDisplacedVertexCollection &, reco::PFDisplacedVertex *)
 
static bool ComesFromV0Decay (const reco::TrackRef, const reco::VertexCompositeCandidateCollection &, const reco::VertexCompositeCandidateCollection &, reco::VertexCompositeCandidate *)
 
static double dR (const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
 
static reco::VertexRef FindClosest3D (reco::TransientTrack, const std::vector< reco::VertexRef > &, double tWeight=0.)
 
static reco::VertexRef FindClosestZ (const reco::TrackRef, const std::vector< reco::VertexRef > &, double tWeight=0.)
 
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)
 
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 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)
 
static std::unique_ptr< reco::ConversionCollectionGetCleanedConversions (edm::Handle< reco::ConversionCollection >, edm::Handle< reco::BeamSpot >, bool)
 
static std::unique_ptr< reco::VertexCompositeCandidateCollectionGetCleanedKshort (edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
 
static std::unique_ptr< reco::VertexCompositeCandidateCollectionGetCleanedLambda (edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
 
static std::unique_ptr< reco::PFDisplacedVertexCollectionGetCleanedNI (edm::Handle< reco::PFDisplacedVertexCollection >, edm::Handle< reco::BeamSpot >, bool)
 
template<typename TREF >
static reco::VertexRef TrackWeightAssociation (const TREF &, const std::vector< reco::VertexRef > &)
 

Private Attributes

edm::Handle< reco::BeamSpotbeamspotH
 
edm::ESHandle< MagneticFieldbFieldH
 
bool cleanedColls_
 
std::unique_ptr< reco::ConversionCollectioncleanedConvCollP
 
std::unique_ptr< reco::VertexCompositeCandidateCollectioncleanedKshortCollP
 
std::unique_ptr< reco::VertexCompositeCandidateCollectioncleanedLambdaCollP
 
std::unique_ptr< reco::PFDisplacedVertexCollectioncleanedNICollP
 
edm::Handle< reco::ConversionCollectionconvCollH
 
edm::EDGetTokenT< reco::ConversionCollectionConversionsCollectionToken_
 
edm::Handle< reco::PFDisplacedVertexCollectiondisplVertexCollH
 
bool ignoremissingpfcollection_
 
bool input_doReassociation_
 
int input_FinalAssociation_
 
int input_MaxNumAssociations_
 
double input_nTrack_
 
edm::EDGetTokenT< reco::VertexCompositeCandidateCollectionKshortCollectionToken_
 
edm::EDGetTokenT< reco::VertexCompositeCandidateCollectionLambdaCollectionToken_
 
int maxNumWarnings_
 
bool missingColls
 
edm::EDGetTokenT< reco::PFDisplacedVertexCollectionNIVertexCollectionToken_
 
int numWarnings_
 
edm::EDGetTokenT< reco::BeamSpottoken_BeamSpot_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordtoken_bField_
 
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordtoken_TrackingGeometry_
 
edm::EDGetTokenT< reco::VertexCollectiontoken_VertexCollection_
 
edm::ESHandle< GlobalTrackingGeometrytrackingGeometryH
 
edm::Handle< reco::VertexCompositeCandidateCollectionvertCompCandCollKshortH
 
edm::Handle< reco::VertexCompositeCandidateCollectionvertCompCandCollLambdaH
 
edm::Handle< reco::VertexCollectionvtxcollH
 

Detailed Description

Definition at line 84 of file PF_PU_AssoMapAlgos.h.

Constructor & Destructor Documentation

◆ PF_PU_AssoMapAlgos() [1/2]

PF_PU_AssoMapAlgos::PF_PU_AssoMapAlgos ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 87 of file PF_PU_AssoMapAlgos.h.

87 : PF_PU_AssoMapAlgos(iConfig, iC) {}
PF_PU_AssoMapAlgos(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)

◆ PF_PU_AssoMapAlgos() [2/2]

PF_PU_AssoMapAlgos::PF_PU_AssoMapAlgos ( const edm::ParameterSet iConfig,
edm::ConsumesCollector iC 
)

Definition at line 27 of file PF_PU_AssoMapAlgos.cc.

References cleanedColls_, edm::ConsumesCollector::consumes(), ConversionsCollectionToken_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), ignoremissingpfcollection_, input_doReassociation_, input_FinalAssociation_, input_MaxNumAssociations_, input_nTrack_, KshortCollectionToken_, LambdaCollectionToken_, NIVertexCollectionToken_, token_BeamSpot_, and token_VertexCollection_.

28  : token_bField_(iC.esConsumes()),
30  maxNumWarnings_(3),
31  numWarnings_(0)
32 
33 {
34  input_MaxNumAssociations_ = iConfig.getParameter<int>("MaxNumberOfAssociations");
35 
36  token_VertexCollection_ = iC.consumes<VertexCollection>(iConfig.getParameter<InputTag>("VertexCollection"));
37 
38  token_BeamSpot_ = iC.consumes<BeamSpot>(iConfig.getParameter<InputTag>("BeamSpot"));
39 
40  input_doReassociation_ = iConfig.getParameter<bool>("doReassociation");
41  cleanedColls_ = iConfig.getParameter<bool>("GetCleanedCollections");
42 
44  iC.consumes<ConversionCollection>(iConfig.getParameter<InputTag>("ConversionsCollection"));
45 
47  iC.consumes<VertexCompositeCandidateCollection>(iConfig.getParameter<InputTag>("V0KshortCollection"));
49  iC.consumes<VertexCompositeCandidateCollection>(iConfig.getParameter<InputTag>("V0LambdaCollection"));
50 
52  iC.consumes<PFDisplacedVertexCollection>(iConfig.getParameter<InputTag>("NIVertexCollection"));
53 
54  input_FinalAssociation_ = iConfig.getUntrackedParameter<int>("FinalAssociation", 0);
55 
56  ignoremissingpfcollection_ = iConfig.getParameter<bool>("ignoreMissingCollection");
57 
58  input_nTrack_ = iConfig.getParameter<double>("nTrackWeight");
59 }
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > LambdaCollectionToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot_
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > token_TrackingGeometry_
edm::EDGetTokenT< reco::PFDisplacedVertexCollection > NIVertexCollectionToken_
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > KshortCollectionToken_
edm::EDGetTokenT< reco::ConversionCollection > ConversionsCollectionToken_
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > token_bField_

◆ ~PF_PU_AssoMapAlgos()

virtual PF_PU_AssoMapAlgos::~PF_PU_AssoMapAlgos ( )
inlinevirtualnoexcept

Definition at line 90 of file PF_PU_AssoMapAlgos.h.

90 {}

Member Function Documentation

◆ ComesFromConversion()

bool PF_PU_AssoMapAlgos::ComesFromConversion ( const reco::TrackRef  trackref,
const reco::ConversionCollection cleanedConvColl,
reco::Conversion gamma 
)
staticprivate

Definition at line 399 of file PF_PU_AssoMapAlgos.cc.

References CustomPhysics_cfi::gamma, and ConversionTools::matchesConversion().

Referenced by FindAssociation().

401  {
402  for (unsigned int convcoll_ite = 0; convcoll_ite < cleanedConvColl.size(); convcoll_ite++) {
403  if (ConversionTools::matchesConversion(trackref, cleanedConvColl.at(convcoll_ite))) {
404  *gamma = cleanedConvColl.at(convcoll_ite);
405  return true;
406  }
407  }
408 
409  return false;
410 }
static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false)

◆ ComesFromNI()

bool PF_PU_AssoMapAlgos::ComesFromNI ( const reco::TrackRef  trackref,
const reco::PFDisplacedVertexCollection cleanedNI,
reco::PFDisplacedVertex displVtx 
)
staticprivate

Definition at line 638 of file PF_PU_AssoMapAlgos.cc.

Referenced by FindAssociation().

640  {
641  //the part for the reassociation of particles from nuclear interactions
642  for (PFDisplacedVertexCollection::const_iterator iDisplV = cleanedNI.begin(); iDisplV != cleanedNI.end(); iDisplV++) {
643  if (iDisplV->trackWeight(trackref) > 1.e-5) {
644  *displVtx = *iDisplV;
645  return true;
646  }
647  }
648 
649  return false;
650 }

◆ ComesFromV0Decay()

bool PF_PU_AssoMapAlgos::ComesFromV0Decay ( const reco::TrackRef  trackref,
const reco::VertexCompositeCandidateCollection cleanedKshort,
const reco::VertexCompositeCandidateCollection cleanedLambda,
reco::VertexCompositeCandidate V0 
)
staticprivate

Definition at line 533 of file PF_PU_AssoMapAlgos.cc.

References reco::RecoChargedCandidate::track().

Referenced by FindAssociation().

536  {
537  //the part for the reassociation of particles from Kshort decays
538  for (VertexCompositeCandidateCollection::const_iterator iKS = cleanedKshort.begin(); iKS != cleanedKshort.end();
539  iKS++) {
540  const RecoChargedCandidate* dauCand1 = dynamic_cast<const RecoChargedCandidate*>(iKS->daughter(0));
541  TrackRef dauTk1 = dauCand1->track();
542  const RecoChargedCandidate* dauCand2 = dynamic_cast<const RecoChargedCandidate*>(iKS->daughter(1));
543  TrackRef dauTk2 = dauCand2->track();
544 
545  if ((trackref == dauTk1) || (trackref == dauTk2)) {
546  *V0 = *iKS;
547  return true;
548  }
549  }
550 
551  //the part for the reassociation of particles from Lambda decays
552  for (VertexCompositeCandidateCollection::const_iterator iLambda = cleanedLambda.begin();
553  iLambda != cleanedLambda.end();
554  iLambda++) {
555  const RecoChargedCandidate* dauCand1 = dynamic_cast<const RecoChargedCandidate*>(iLambda->daughter(0));
556  TrackRef dauTk1 = dauCand1->track();
557  const RecoChargedCandidate* dauCand2 = dynamic_cast<const RecoChargedCandidate*>(iLambda->daughter(1));
558  TrackRef dauTk2 = dauCand2->track();
559 
560  if ((trackref == dauTk1) || (trackref == dauTk2)) {
561  *V0 = *iLambda;
562  return true;
563  }
564  }
565 
566  return false;
567 }
reco::TrackRef track() const override
reference to a track

◆ createMappings()

std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > PF_PU_AssoMapAlgos::createMappings ( edm::Handle< reco::TrackCollection trkcollH)

Definition at line 109 of file PF_PU_AssoMapAlgos.cc.

References IPTools::absoluteImpactParameter3D(), beamspotH, bFieldH, CreateVertexVector(), DefineQuality(), HLT_2024v14_cff::distance, EraseVertex(), FindAssociation(), input_MaxNumAssociations_, eostools::move(), quality, edm::second(), reco::TransientTrack::setBeamSpot(), reco::TransientTrack::setTrackingGeometry(), trackingGeometryH, and vtxcollH.

Referenced by CreateTrackToVertexMap(), CreateVertexToTrackMap(), and PF_PU_AssoMap::produce().

109  {
110  unique_ptr<TrackToVertexAssMap> track2vertex(new TrackToVertexAssMap(vtxcollH, trkcollH));
111  unique_ptr<VertexToTrackAssMap> vertex2track(new VertexToTrackAssMap(trkcollH, vtxcollH));
112 
113  int num_vertices = vtxcollH->size();
114  if (num_vertices < input_MaxNumAssociations_)
115  input_MaxNumAssociations_ = num_vertices;
116  vector<VertexRef> vtxColl_help;
117  if (input_MaxNumAssociations_ == 1)
118  vtxColl_help = CreateVertexVector(vtxcollH);
119 
120  //loop over all tracks of the track collection
121  for (size_t idxTrack = 0; idxTrack < trkcollH->size(); ++idxTrack) {
122  TrackRef trackref = TrackRef(trkcollH, idxTrack);
123 
124  TransientTrack transtrk(trackref, &(*bFieldH));
125  transtrk.setBeamSpot(*beamspotH);
126  transtrk.setTrackingGeometry(trackingGeometryH);
127 
129  vtxColl_help = CreateVertexVector(vtxcollH);
130 
131  for (int assoc_ite = 0; assoc_ite < input_MaxNumAssociations_; ++assoc_ite) {
132  VertexStepPair assocVtx =
133  FindAssociation(trackref, vtxColl_help, bFieldH, trackingGeometryH, beamspotH, assoc_ite);
134  int step = assocVtx.second;
135  double distance = (IPTools::absoluteImpactParameter3D(transtrk, *(assocVtx.first))).second.value();
136 
137  int quality = DefineQuality(assoc_ite, step, distance);
138 
139  //std::cout << "associating track: Pt = " << trackref->pt() << ","
140  // << " eta = " << trackref->eta() << ", phi = " << trackref->phi()
141  // << " to vertex: z = " << associatedVertex.first->position().z() << " with quality q = " << quality << std::endl;
142 
143  // Insert the best vertex and the pair of track and the quality of this association in the map
144  track2vertex->insert(assocVtx.first, make_pair(trackref, quality));
145  vertex2track->insert(trackref, make_pair(assocVtx.first, quality));
146 
147  //cleanup only if multiple iterations are made
149  PF_PU_AssoMapAlgos::EraseVertex(vtxColl_help, assocVtx.first);
150  }
151  }
152 
153  return {std::move(track2vertex), std::move(vertex2track)};
154 }
edm::ESHandle< MagneticField > bFieldH
int DefineQuality(int, int, double)
VertexStepPair FindAssociation(const reco::TrackRef &, const std::vector< reco::VertexRef > &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, int)
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:38
edm::ESHandle< GlobalTrackingGeometry > trackingGeometryH
std::pair< reco::VertexRef, int > VertexStepPair
U second(std::pair< T, U > const &p)
string quality
edm::AssociationMap< edm::OneToManyWithQuality< reco::VertexCollection, reco::TrackCollection, int > > TrackToVertexAssMap
edm::Handle< reco::VertexCollection > vtxcollH
std::vector< reco::VertexRef > CreateVertexVector(edm::Handle< reco::VertexCollection >)
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
void EraseVertex(std::vector< reco::VertexRef > &, reco::VertexRef)
step
Definition: StallMonitor.cc:83
edm::Handle< reco::BeamSpot > beamspotH
edm::AssociationMap< edm::OneToManyWithQuality< reco::TrackCollection, reco::VertexCollection, int > > VertexToTrackAssMap
def move(src, dest)
Definition: eostools.py:511

◆ CreateTrackToVertexMap()

std::unique_ptr< TrackToVertexAssMap > PF_PU_AssoMapAlgos::CreateTrackToVertexMap ( edm::Handle< reco::TrackCollection trkcollH)

Definition at line 160 of file PF_PU_AssoMapAlgos.cc.

References createMappings().

161  {
162  return createMappings(trkcollH).first;
163 }
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings(edm::Handle< reco::TrackCollection > trkcollH)

◆ CreateVertexToTrackMap()

std::unique_ptr< VertexToTrackAssMap > PF_PU_AssoMapAlgos::CreateVertexToTrackMap ( edm::Handle< reco::TrackCollection trkcollH)

Definition at line 169 of file PF_PU_AssoMapAlgos.cc.

References createMappings().

170  {
171  return createMappings(trkcollH).second;
172 }
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings(edm::Handle< reco::TrackCollection > trkcollH)

◆ CreateVertexVector()

std::vector< reco::VertexRef > PF_PU_AssoMapAlgos::CreateVertexVector ( edm::Handle< reco::VertexCollection vtxcollH)
protected

Definition at line 256 of file PF_PU_AssoMapAlgos.cc.

References mps_fire::i, l1ctLayer1_cff::nVtx, convertSQLitetoXML_cfg::output, and vtxcollH.

Referenced by PFCand_AssoMapAlgos::createMappings(), and createMappings().

256  {
257  vector<VertexRef> output;
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);
262 
263  return output;
264 }
edm::Handle< reco::VertexCollection > vtxcollH
Definition: output.py:1

◆ DefineQuality()

int PF_PU_AssoMapAlgos::DefineQuality ( int  assoc_ite,
int  step,
double  distance 
)
protected

Definition at line 819 of file PF_PU_AssoMapAlgos.cc.

References HLT_2024v14_cff::distance, fin_50, fin_70, quality, sec_50, sec_70, tw_50, tw_70, and tw_90.

Referenced by PFCand_AssoMapAlgos::createMappings(), and createMappings().

819  {
820  int quality = 0;
821 
822  switch (step) {
823  case 0: {
824  //TrackWeight association
825  if (distance <= tw_90) {
826  quality = 5;
827  } else {
828  if (distance <= tw_70) {
829  quality = 4;
830  } else {
831  if (distance <= tw_50) {
832  quality = 3;
833  } else {
834  quality = 2;
835  }
836  }
837  }
838  break;
839  }
840 
841  case 1: {
842  //Secondary association
843  if (distance <= sec_70) {
844  quality = 4;
845  } else {
846  if (distance <= sec_50) {
847  quality = 3;
848  } else {
849  quality = 2;
850  }
851  }
852  break;
853  }
854 
855  case 2: {
856  //Final association
857  if (assoc_ite == 1) {
858  quality = 1;
859  } else {
860  if (assoc_ite >= 2) {
861  quality = 0;
862  } else {
863  if (distance <= fin_70) {
864  quality = 4;
865  } else {
866  if (distance <= fin_50) {
867  quality = 3;
868  } else {
869  quality = 2;
870  }
871  }
872  }
873  }
874  break;
875  }
876 
877  default: {
878  quality = -1;
879  break;
880  }
881  }
882 
883  return quality;
884 }
const double tw_70
const double fin_70
string quality
const double sec_50
const double tw_50
const double sec_70
step
Definition: StallMonitor.cc:83
const double tw_90
const double fin_50

◆ dR()

double PF_PU_AssoMapAlgos::dR ( const math::XYZPoint vtx_pos,
const math::XYZVector vtx_mom,
edm::Handle< reco::BeamSpot bsH 
)
staticprivate

Definition at line 351 of file PF_PU_AssoMapAlgos.cc.

References Matriplex::atan2(), eleIsoSequence_cff::deltaR, CrabHelper::log, mathSSE::sqrt(), funct::tan(), reco::BeamSpot::x0(), reco::BeamSpot::y0(), and reco::BeamSpot::z0().

Referenced by GetCleanedKshort(), GetCleanedLambda(), and GetCleanedNI().

353  {
354  double bs_x = bsH->x0();
355  double bs_y = bsH->y0();
356  double bs_z = bsH->z0();
357 
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;
361 
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);
364 
365  double connVec_eta = -1. * log(tan(connVec_theta * 1. / 2.));
366  double connVec_phi = atan2(connVec_y, connVec_x);
367 
368  return deltaR(vtx_mom.eta(), vtx_mom.phi(), connVec_eta, connVec_phi);
369 }
double x0() const
x coordinate
Definition: BeamSpot.h:61
T sqrt(T t)
Definition: SSEVec.h:23
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double y0() const
y coordinate
Definition: BeamSpot.h:63
double z0() const
z coordinate
Definition: BeamSpot.h:65
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)
Definition: Matriplex.h:648

◆ EraseVertex()

void PF_PU_AssoMapAlgos::EraseVertex ( std::vector< reco::VertexRef > &  vtxcollV,
reco::VertexRef  toErase 
)
protected

Definition at line 270 of file PF_PU_AssoMapAlgos.cc.

Referenced by PFCand_AssoMapAlgos::createMappings(), and createMappings().

270  {
271  for (unsigned int index_vtx = 0; index_vtx < vtxcollV.size(); ++index_vtx) {
272  VertexRef vertexref = vtxcollV.at(index_vtx);
273 
274  if (vertexref == toErase) {
275  vtxcollV.erase(vtxcollV.begin() + index_vtx);
276  break;
277  }
278  }
279 }

◆ FindAssociation()

VertexStepPair PF_PU_AssoMapAlgos::FindAssociation ( const reco::TrackRef trackref,
const std::vector< reco::VertexRef > &  vtxColl,
edm::ESHandle< MagneticField bfH,
edm::ESHandle< GlobalTrackingGeometry tgH,
edm::Handle< reco::BeamSpot bsH,
int  assocNum 
)
protected

Definition at line 726 of file PF_PU_AssoMapAlgos.cc.

References cleanedConvCollP, cleanedKshortCollP, cleanedLambdaCollP, cleanedNICollP, ComesFromConversion(), ComesFromNI(), ComesFromV0Decay(), FindClosest3D(), FindClosestZ(), FindConversionVertex(), FindNIVertex(), FindV0Vertex(), CustomPhysics_cfi::gamma, input_doReassociation_, input_FinalAssociation_, input_nTrack_, missingColls, reco::TransientTrack::setBeamSpot(), reco::TransientTrack::setTrackingGeometry(), trackingGeometryH, and TrackWeightAssociation().

Referenced by PFCand_AssoMapAlgos::createMappings(), and createMappings().

731  {
732  VertexRef foundVertex;
733 
734  //if it is not the first try of an association jump to the final association
735  //to avoid multiple (secondary) associations and/or unphysical (primary and secondary) associations
736  if (assocNum > 0)
737  goto finalStep;
738 
739  // Step 1: First round of association:
740  // Find the vertex with the highest track-to-vertex association weight
741  foundVertex = TrackWeightAssociation(trackref, vtxColl);
742 
743  if (foundVertex->trackWeight(trackref) >= 1.e-5) {
744  return make_pair(foundVertex, 0.);
745  }
746 
747  // Step 2: Reassociation
748  // Second round of association:
749  // In case no vertex with track-to-vertex association weight > 1.e-5 is found,
750  // check the track originates from a neutral hadron decay, photon conversion or nuclear interaction
751 
753  // Test if the track comes from a photon conversion:
754  // If so, try to find the vertex of the mother particle
756  if (ComesFromConversion(trackref, *cleanedConvCollP, &gamma)) {
757  foundVertex = FindConversionVertex(trackref, gamma, bfH, tgH, bsH, vtxColl, input_nTrack_);
758  return make_pair(foundVertex, 1.);
759  }
760 
761  // Test if the track comes from a Kshort or Lambda decay:
762  // If so, reassociate the track to the vertex of the V0
764  if (ComesFromV0Decay(trackref, *cleanedKshortCollP, *cleanedLambdaCollP, &V0)) {
765  foundVertex = FindV0Vertex(trackref, V0, bfH, tgH, bsH, vtxColl, input_nTrack_);
766  return make_pair(foundVertex, 1.);
767  }
768 
769  if (!missingColls) {
770  // Test if the track comes from a nuclear interaction:
771  // If so, reassociate the track to the vertex of the incoming particle
772  PFDisplacedVertex displVtx;
773  if (ComesFromNI(trackref, *cleanedNICollP, &displVtx)) {
774  foundVertex = FindNIVertex(trackref, displVtx, bfH, tgH, bsH, vtxColl, input_nTrack_);
775  return make_pair(foundVertex, 1.);
776  }
777  }
778  }
779 
780  // Step 3: Final association
781  // If no vertex is found with track-to-vertex association weight > 1.e-5
782  // and no reassociation was done do the final association
783  // look for the closest vertex in 3D or in z/longitudinal distance
784  // or associate the track always to the first vertex (default)
785 
786 finalStep:
787 
788  switch (input_FinalAssociation_) {
789  case 1: {
790  // closest in z
791  foundVertex = FindClosestZ(trackref, vtxColl, input_nTrack_);
792  break;
793  }
794 
795  case 2: {
796  // closest in 3D
797  TransientTrack transtrk(trackref, &(*bfH));
798  transtrk.setBeamSpot(*bsH);
799  transtrk.setTrackingGeometry(trackingGeometryH);
800 
801  foundVertex = FindClosest3D(transtrk, vtxColl, input_nTrack_);
802  break;
803  }
804 
805  default: {
806  // allways first vertex
807  foundVertex = vtxColl.at(0);
808  break;
809  }
810  }
811 
812  return make_pair(foundVertex, 2.);
813 }
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 bool ComesFromNI(const reco::TrackRef, const reco::PFDisplacedVertexCollection &, reco::PFDisplacedVertex *)
static reco::VertexRef TrackWeightAssociation(const TREF &, const std::vector< reco::VertexRef > &)
edm::ESHandle< GlobalTrackingGeometry > trackingGeometryH
std::unique_ptr< reco::PFDisplacedVertexCollection > cleanedNICollP
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedLambdaCollP
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)
static bool ComesFromV0Decay(const reco::TrackRef, const reco::VertexCompositeCandidateCollection &, const reco::VertexCompositeCandidateCollection &, reco::VertexCompositeCandidate *)
static reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector< reco::VertexRef > &, double tWeight=0.)
Block of elements.
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
static bool ComesFromConversion(const reco::TrackRef, const reco::ConversionCollection &, reco::Conversion *)
static reco::VertexRef FindClosestZ(const reco::TrackRef, const std::vector< reco::VertexRef > &, double tWeight=0.)
std::unique_ptr< reco::ConversionCollection > cleanedConvCollP

◆ FindClosest3D()

VertexRef PF_PU_AssoMapAlgos::FindClosest3D ( reco::TransientTrack  transtrk,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight = 0. 
)
staticprivate

Definition at line 317 of file PF_PU_AssoMapAlgos.cc.

References IPTools::absoluteImpactParameter3D(), HLT_2024v14_cff::distance, TrackValidation_cff::e5, beamSpotPI::nTracks, and mathSSE::sqrt().

Referenced by FindAssociation(), FindConversionVertex(), FindNIVertex(), and FindV0Vertex().

319  {
320  VertexRef foundVertexRef = vtxcollV.at(0);
321 
322  double d3min = 1e5;
323 
324  //loop over all vertices with a good quality in the vertex collection
325  for (unsigned int index_vtx = 0; index_vtx < vtxcollV.size(); ++index_vtx) {
326  const VertexRef& vertexref = vtxcollV.at(index_vtx);
327 
328  double nTracks = sqrt(vertexref->tracksSize());
329 
330  double distance = 1e5;
331  pair<bool, Measurement1D> IpPair = IPTools::absoluteImpactParameter3D(transtrk, *vertexref);
332 
333  if (IpPair.first)
334  distance = IpPair.second.value();
335 
336  double weightedDistance = distance - tWeight * nTracks;
337 
338  if (weightedDistance < d3min) {
339  d3min = weightedDistance;
340  foundVertexRef = vertexref;
341  }
342  }
343 
344  return foundVertexRef;
345 }
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:38
T sqrt(T t)
Definition: SSEVec.h:23

◆ FindClosestZ()

VertexRef PF_PU_AssoMapAlgos::FindClosestZ ( const reco::TrackRef  trkref,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight = 0. 
)
staticprivate

Definition at line 285 of file PF_PU_AssoMapAlgos.cc.

References TrackValidation_cff::e5, beamSpotPI::nTracks, and mathSSE::sqrt().

Referenced by FindAssociation().

287  {
288  double ztrack = trkref->vertex().z();
289 
290  VertexRef foundVertexRef = vtxcollV.at(0);
291 
292  double dzmin = 1e5;
293 
294  //loop over all vertices with a good quality in the vertex collection
295  for (unsigned int index_vtx = 0; index_vtx < vtxcollV.size(); ++index_vtx) {
296  const VertexRef& vertexref = vtxcollV.at(index_vtx);
297 
298  double nTracks = sqrt(vertexref->tracksSize());
299 
300  double z_distance = fabs(ztrack - vertexref->z());
301 
302  double weightedDistance = z_distance - tWeight * nTracks;
303 
304  if (weightedDistance < dzmin) {
305  dzmin = weightedDistance;
306  foundVertexRef = vertexref;
307  }
308  }
309 
310  return foundVertexRef;
311 }
T sqrt(T t)
Definition: SSEVec.h:23

◆ FindConversionVertex()

VertexRef PF_PU_AssoMapAlgos::FindConversionVertex ( const reco::TrackRef  trackref,
const reco::Conversion gamma,
edm::ESHandle< MagneticField bfH,
edm::ESHandle< GlobalTrackingGeometry tgH,
edm::Handle< reco::BeamSpot bsH,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight 
)
staticprivate

Definition at line 416 of file PF_PU_AssoMapAlgos.cc.

References FindClosest3D(), CustomPhysics_cfi::gamma, and displacedMuons_cfi::photon.

Referenced by FindAssociation().

422  {
423  math::XYZPoint conv_pos = gamma.conversionVertex().position();
424 
425  math::XYZVector conv_mom(
426  gamma.refittedPair4Momentum().x(), gamma.refittedPair4Momentum().y(), gamma.refittedPair4Momentum().z());
427 
428  Track photon(trackref->chi2(), trackref->ndof(), conv_pos, conv_mom, 0, trackref->covariance());
429 
430  TransientTrack transpho(photon, &(*bfH));
431  transpho.setBeamSpot(*bsH);
432  transpho.setTrackingGeometry(tgH);
433 
434  return FindClosest3D(transpho, vtxcollV, tWeight);
435 }
static reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector< reco::VertexRef > &, double tWeight=0.)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12

◆ FindNIVertex()

VertexRef PF_PU_AssoMapAlgos::FindNIVertex ( const reco::TrackRef  trackref,
const reco::PFDisplacedVertex displVtx,
edm::ESHandle< MagneticField bFieldH,
edm::ESHandle< GlobalTrackingGeometry trackingGeometryH,
edm::Handle< reco::BeamSpot bsH,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight 
)
staticprivate

Definition at line 656 of file PF_PU_AssoMapAlgos.cc.

References bFieldH, FindClosest3D(), reco::PFDisplacedVertex::isIncomingTrack(), reco::PFDisplacedVertex::isThereMergedTracks(), reco::PFDisplacedVertex::isTherePrimaryTracks(), reco::Vertex::originalTrack(), reco::Vertex::position(), reco::PFDisplacedVertex::primaryMomentum(), tkAlTrackRefitSequence_cff::refittedTracks, reco::Vertex::refittedTracks(), reco::TransientTrack::setBeamSpot(), reco::TransientTrack::setTrackingGeometry(), trackingGeometryH, and TrackWeightAssociation().

Referenced by FindAssociation().

662  {
664 
665  if ((displVtx.isTherePrimaryTracks()) || (displVtx.isThereMergedTracks())) {
666  for (TrackCollection::const_iterator trkcoll_ite = refittedTracks.begin(); trkcoll_ite != refittedTracks.end();
667  trkcoll_ite++) {
668  const TrackBaseRef retrackbaseref = displVtx.originalTrack(*trkcoll_ite);
669 
670  if (displVtx.isIncomingTrack(retrackbaseref)) {
671  VertexRef VOAssociation = TrackWeightAssociation(retrackbaseref, vtxcollV);
672 
673  if (VOAssociation->trackWeight(retrackbaseref) >= 1.e-5) {
674  return VOAssociation;
675  }
676 
677  TransientTrack transIncom(*retrackbaseref, &(*bFieldH));
678  transIncom.setBeamSpot(*bsH);
679  transIncom.setTrackingGeometry(trackingGeometryH);
680 
681  return FindClosest3D(transIncom, vtxcollV, tWeight);
682  }
683  }
684  }
685 
686  const math::XYZPoint& ni_pos = displVtx.position();
687 
688  math::XYZVector ni_mom(
689  displVtx.primaryMomentum().x(), displVtx.primaryMomentum().y(), displVtx.primaryMomentum().z());
690 
691  Track incom(trackref->chi2(), trackref->ndof(), ni_pos, ni_mom, 0, trackref->covariance());
692 
693  TransientTrack transIncom(incom, &(*bFieldH));
694  transIncom.setBeamSpot(*bsH);
695  transIncom.setTrackingGeometry(trackingGeometryH);
696 
697  return FindClosest3D(transIncom, vtxcollV, tWeight);
698 }
edm::ESHandle< MagneticField > bFieldH
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.
const bool isTherePrimaryTracks() const
--—— Provide useful information --—— ///
const Point & position() const
position
Definition: Vertex.h:128
static reco::VertexRef TrackWeightAssociation(const TREF &, const std::vector< reco::VertexRef > &)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ESHandle< GlobalTrackingGeometry > trackingGeometryH
const bool isIncomingTrack(const reco::TrackBaseRef &originalTrack) const
Is primary or merged track.
const bool isThereMergedTracks() const
If a merged track was identified.
static reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector< reco::VertexRef > &, double tWeight=0.)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
Definition: Vertex.h:197
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
TrackBaseRef originalTrack(const Track &refTrack) const
Definition: Vertex.cc:81

◆ FindV0Vertex()

VertexRef PF_PU_AssoMapAlgos::FindV0Vertex ( const reco::TrackRef  trackref,
const reco::VertexCompositeCandidate V0_vtx,
edm::ESHandle< MagneticField bFieldH,
edm::ESHandle< GlobalTrackingGeometry trackingGeometryH,
edm::Handle< reco::BeamSpot bsH,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight 
)
staticprivate

Definition at line 573 of file PF_PU_AssoMapAlgos.cc.

References bFieldH, FindClosest3D(), reco::LeafCandidate::momentum(), trackingGeometryH, and reco::LeafCandidate::vertex().

Referenced by FindAssociation().

579  {
580  const math::XYZPoint& dec_pos = V0_vtx.vertex();
581 
582  math::XYZVector dec_mom(V0_vtx.momentum().x(), V0_vtx.momentum().y(), V0_vtx.momentum().z());
583 
584  Track V0(trackref->chi2(), trackref->ndof(), dec_pos, dec_mom, 0, trackref->covariance());
585 
586  TransientTrack transV0(V0, &(*bFieldH));
587  transV0.setBeamSpot(*bsH);
588  transV0.setTrackingGeometry(trackingGeometryH);
589 
590  return FindClosest3D(transV0, vtxcollV, tWeight);
591 }
edm::ESHandle< MagneticField > bFieldH
Vector momentum() const final
spatial momentum vector
edm::ESHandle< GlobalTrackingGeometry > trackingGeometryH
const Point & vertex() const override
vertex position (overwritten by PF...)
static reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector< reco::VertexRef > &, double tWeight=0.)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12

◆ GetCleanedConversions()

unique_ptr< ConversionCollection > PF_PU_AssoMapAlgos::GetCleanedConversions ( edm::Handle< reco::ConversionCollection convCollH,
edm::Handle< reco::BeamSpot bsH,
bool  cleanedColl 
)
staticprivate

Definition at line 375 of file PF_PU_AssoMapAlgos.cc.

References convCollH.

Referenced by GetInputCollections().

376  {
377  unique_ptr<ConversionCollection> cleanedConvColl(new ConversionCollection());
378 
379  for (unsigned int convcoll_idx = 0; convcoll_idx < convCollH->size(); convcoll_idx++) {
380  ConversionRef convref(convCollH, convcoll_idx);
381 
382  if (!cleanedColl) {
383  cleanedConvColl->push_back(*convref);
384  continue;
385  }
386 
387  if ((convref->nTracks() == 2) && (fabs(convref->pairInvariantMass()) <= 0.1)) {
388  cleanedConvColl->push_back(*convref);
389  }
390  }
391 
392  return cleanedConvColl;
393 }
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
edm::Handle< reco::ConversionCollection > convCollH

◆ GetCleanedKshort()

unique_ptr< VertexCompositeCandidateCollection > PF_PU_AssoMapAlgos::GetCleanedKshort ( edm::Handle< reco::VertexCompositeCandidateCollection KshortsH,
edm::Handle< reco::BeamSpot bsH,
bool  cleanedColl 
)
staticprivate

Definition at line 441 of file PF_PU_AssoMapAlgos.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), reco::BeamSpot::covariance3D(), VertexDistance3D::distance(), dR(), kMass, reco::BeamSpot::position(), and met_cff::significance.

Referenced by GetInputCollections().

442  {
443  unique_ptr<VertexCompositeCandidateCollection> cleanedKaonColl(new VertexCompositeCandidateCollection());
444 
445  for (unsigned int kscoll_idx = 0; kscoll_idx < KshortsH->size(); kscoll_idx++) {
446  VertexCompositeCandidateRef ksref(KshortsH, kscoll_idx);
447 
448  if (!cleanedColl) {
449  cleanedKaonColl->push_back(*ksref);
450  continue;
451  }
452 
453  VertexDistance3D distanceComputer;
454 
455  GlobalPoint dec_pos = RecoVertex::convertPos(ksref->vertex());
456 
457  GlobalError decayVertexError = GlobalError(ksref->vertexCovariance(0, 0),
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));
463 
464  math::XYZVector dec_mom(ksref->momentum().x(), ksref->momentum().y(), ksref->momentum().z());
465 
466  GlobalPoint bsPosition = RecoVertex::convertPos(bsH->position());
468 
469  double kaon_significance =
470  (distanceComputer.distance(VertexState(bsPosition, bsError), VertexState(dec_pos, decayVertexError)))
471  .significance();
472 
473  if ((ksref->vertex().rho() >= 3.) && (ksref->vertexNormalizedChi2() <= 3.) &&
474  (fabs(ksref->mass() - kMass) <= 0.01) && (kaon_significance > 15.) &&
475  (PF_PU_AssoMapAlgos::dR(ksref->vertex(), dec_mom, bsH) <= 0.3)) {
476  cleanedKaonColl->push_back(*ksref);
477  }
478  }
479 
480  return cleanedKaonColl;
481 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
const Point & position() const
position
Definition: BeamSpot.h:59
const double kMass
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:112
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
significance
Definition: met_cff.py:20

◆ GetCleanedLambda()

unique_ptr< VertexCompositeCandidateCollection > PF_PU_AssoMapAlgos::GetCleanedLambda ( edm::Handle< reco::VertexCompositeCandidateCollection LambdasH,
edm::Handle< reco::BeamSpot bsH,
bool  cleanedColl 
)
staticprivate

Definition at line 487 of file PF_PU_AssoMapAlgos.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), reco::BeamSpot::covariance3D(), VertexDistance3D::distance(), dR(), lamMass, reco::BeamSpot::position(), and met_cff::significance.

Referenced by GetInputCollections().

488  {
489  unique_ptr<VertexCompositeCandidateCollection> cleanedLambdaColl(new VertexCompositeCandidateCollection());
490 
491  for (unsigned int lambdacoll_idx = 0; lambdacoll_idx < LambdasH->size(); lambdacoll_idx++) {
492  VertexCompositeCandidateRef lambdaref(LambdasH, lambdacoll_idx);
493 
494  if (!cleanedColl) {
495  cleanedLambdaColl->push_back(*lambdaref);
496  continue;
497  }
498 
499  VertexDistance3D distanceComputer;
500 
501  GlobalPoint dec_pos = RecoVertex::convertPos(lambdaref->vertex());
502 
503  GlobalError decayVertexError = GlobalError(lambdaref->vertexCovariance(0, 0),
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));
509 
510  math::XYZVector dec_mom(lambdaref->momentum().x(), lambdaref->momentum().y(), lambdaref->momentum().z());
511 
512  GlobalPoint bsPosition = RecoVertex::convertPos(bsH->position());
514 
515  double lambda_significance =
516  (distanceComputer.distance(VertexState(bsPosition, bsError), VertexState(dec_pos, decayVertexError)))
517  .significance();
518 
519  if ((lambdaref->vertex().rho() >= 3.) && (lambdaref->vertexNormalizedChi2() <= 3.) &&
520  (fabs(lambdaref->mass() - lamMass) <= 0.005) && (lambda_significance > 15.) &&
521  (PF_PU_AssoMapAlgos::dR(lambdaref->vertex(), dec_mom, bsH) <= 0.3)) {
522  cleanedLambdaColl->push_back(*lambdaref);
523  }
524  }
525 
526  return cleanedLambdaColl;
527 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
const double lamMass
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
const Point & position() const
position
Definition: BeamSpot.h:59
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:112
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
significance
Definition: met_cff.py:20

◆ GetCleanedNI()

unique_ptr< PFDisplacedVertexCollection > PF_PU_AssoMapAlgos::GetCleanedNI ( edm::Handle< reco::PFDisplacedVertexCollection NuclIntH,
edm::Handle< reco::BeamSpot bsH,
bool  cleanedColl 
)
staticprivate

Definition at line 597 of file PF_PU_AssoMapAlgos.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), reco::BeamSpot::covariance3D(), VertexDistance3D::distance(), dR(), reco::BeamSpot::position(), and met_cff::significance.

Referenced by GetInputCollections().

599  {
600  unique_ptr<PFDisplacedVertexCollection> cleanedNIColl(new PFDisplacedVertexCollection());
601 
602  for (PFDisplacedVertexCollection::const_iterator niref = NuclIntH->begin(); niref != NuclIntH->end(); niref++) {
603  if ((niref->isFake()) || !(niref->isNucl()))
604  continue;
605 
606  if (!cleanedColl) {
607  cleanedNIColl->push_back(*niref);
608  continue;
609  }
610 
611  VertexDistance3D distanceComputer;
612 
613  GlobalPoint ni_pos = RecoVertex::convertPos(niref->position());
614  GlobalError interactionVertexError = RecoVertex::convertError(niref->error());
615 
616  math::XYZVector ni_mom(niref->primaryMomentum().x(), niref->primaryMomentum().y(), niref->primaryMomentum().z());
617 
618  GlobalPoint bsPosition = RecoVertex::convertPos(bsH->position());
620 
621  double nuclint_significance =
622  (distanceComputer.distance(VertexState(bsPosition, bsError), VertexState(ni_pos, interactionVertexError)))
623  .significance();
624 
625  if ((niref->position().rho() >= 3.) && (nuclint_significance > 15.) &&
626  (PF_PU_AssoMapAlgos::dR(niref->position(), ni_mom, bsH) <= 0.3)) {
627  cleanedNIColl->push_back(*niref);
628  }
629  }
630 
631  return cleanedNIColl;
632 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
const Point & position() const
position
Definition: BeamSpot.h:59
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:112
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
significance
Definition: met_cff.py:20

◆ GetInputCollections()

void PF_PU_AssoMapAlgos::GetInputCollections ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Reimplemented in PFCand_AssoMapAlgos.

Definition at line 65 of file PF_PU_AssoMapAlgos.cc.

References beamspotH, bFieldH, cleanedColls_, cleanedConvCollP, cleanedKshortCollP, cleanedLambdaCollP, cleanedNICollP, convCollH, ConversionsCollectionToken_, displVertexCollH, GetCleanedConversions(), GetCleanedKshort(), GetCleanedLambda(), GetCleanedNI(), edm::EventSetup::getHandle(), iEvent, ignoremissingpfcollection_, KshortCollectionToken_, LambdaCollectionToken_, maxNumWarnings_, missingColls, NIVertexCollectionToken_, numWarnings_, token_BeamSpot_, token_bField_, token_TrackingGeometry_, token_VertexCollection_, trackingGeometryH, vertCompCandCollKshortH, vertCompCandCollLambdaH, and vtxcollH.

Referenced by PFCand_AssoMapAlgos::GetInputCollections(), and PF_PU_AssoMap::produce().

65  {
66  //get the offline beam spot
67  iEvent.getByToken(token_BeamSpot_, beamspotH);
68 
69  //get the conversion collection for the gamma conversions
72 
73  //get the vertex composite candidate collection for the Kshort's
76 
77  //get the vertex composite candidate collection for the Lambda's
80 
81  //get the displaced vertex collection for nuclear interactions
82  //create a new bool, true if no displaced vertex collection is in the event, mostly for AOD
83  missingColls = false;
86  missingColls = true;
87 
89  LogWarning("PF_PU_AssoMapAlgos::GetInputCollections")
90  << "No Extra objects available in input file --> skipping reconstruction of displaced vertices !!" << endl;
91  ++numWarnings_;
92  }
93  }
94  } else {
96  }
97 
98  //get the input vertex collection
100 
101  bFieldH = iSetup.getHandle(token_bField_);
103 }
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > LambdaCollectionToken_
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedLambda(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
edm::ESHandle< MagneticField > bFieldH
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot_
static std::unique_ptr< reco::PFDisplacedVertexCollection > GetCleanedNI(edm::Handle< reco::PFDisplacedVertexCollection >, edm::Handle< reco::BeamSpot >, bool)
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedKshort(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
edm::ESHandle< GlobalTrackingGeometry > trackingGeometryH
std::unique_ptr< reco::PFDisplacedVertexCollection > cleanedNICollP
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedLambdaCollP
int iEvent
Definition: GenABIO.cc:224
static std::unique_ptr< reco::ConversionCollection > GetCleanedConversions(edm::Handle< reco::ConversionCollection >, edm::Handle< reco::BeamSpot >, bool)
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > token_TrackingGeometry_
edm::Handle< reco::PFDisplacedVertexCollection > displVertexCollH
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
edm::EDGetTokenT< reco::PFDisplacedVertexCollection > NIVertexCollectionToken_
edm::Handle< reco::VertexCollection > vtxcollH
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > KshortCollectionToken_
edm::EDGetTokenT< reco::ConversionCollection > ConversionsCollectionToken_
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollLambdaH
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedKshortCollP
edm::Handle< reco::BeamSpot > beamspotH
Log< level::Warning, false > LogWarning
edm::Handle< reco::ConversionCollection > convCollH
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollKshortH
std::unique_ptr< reco::ConversionCollection > cleanedConvCollP
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > token_bField_

◆ SortAssociationMap()

unique_ptr< TrackToVertexAssMap > PF_PU_AssoMapAlgos::SortAssociationMap ( TrackToVertexAssMap trackvertexassInput,
edm::Handle< reco::TrackCollection trkcollH 
)

Definition at line 178 of file PF_PU_AssoMapAlgos.cc.

References edm::AssociationMap< Tag >::begin(), edm::AssociationMap< Tag >::end(), edm::Ref< C, T, F >::key(), quality, edm::second(), and vtxcollH.

Referenced by PF_PU_AssoMap::produce().

179  {
180  //create a new TrackVertexAssMap for the Output which will be sorted
181  unique_ptr<TrackToVertexAssMap> trackvertexassOutput(new TrackToVertexAssMap(vtxcollH, trkcollH));
182 
183  //Create and fill a vector of pairs of vertex and the summed (pT-pT_Error)**2 of the tracks associated to the vertex
184  VertexPtsumVector vertexptsumvector;
185 
186  //loop over all vertices in the association map
187  for (TrackToVertexAssMap::const_iterator assomap_ite = trackvertexassInput->begin();
188  assomap_ite != trackvertexassInput->end();
189  assomap_ite++) {
190  const VertexRef assomap_vertexref = assomap_ite->key;
191  const TrackQualityPairVector trckcoll = assomap_ite->val;
192 
193  float ptsum = 0;
194 
195  TrackRef trackref;
196 
197  //get the tracks associated to the vertex and calculate the manipulated pT**2
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;
201 
202  if (quality <= 2)
203  continue;
204 
205  double man_pT = trackref->pt() - trackref->ptError();
206  if (man_pT > 0.)
207  ptsum += man_pT * man_pT;
208  }
209 
210  vertexptsumvector.push_back(make_pair(assomap_vertexref, ptsum));
211  }
212 
213  while (!vertexptsumvector.empty()) {
214  VertexRef vertexref_highestpT;
215  float highestpT = 0.;
216  int highestpT_index = 0;
217 
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;
223  }
224  }
225 
226  //loop over all vertices in the association map
227  for (TrackToVertexAssMap::const_iterator assomap_ite = trackvertexassInput->begin();
228  assomap_ite != trackvertexassInput->end();
229  assomap_ite++) {
230  const VertexRef assomap_vertexref = assomap_ite->key;
231  const TrackQualityPairVector trckcoll = assomap_ite->val;
232 
233  //if the vertex from the association map the vertex with the highest manipulated pT
234  //insert all associated tracks in the output Association Map
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]);
238  }
239 
240  vertexptsumvector.erase(vertexptsumvector.begin() + highestpT_index);
241  }
242 
243  return trackvertexassOutput;
244 }
key_type key() const
Accessor for product key.
Definition: Ref.h:244
std::vector< VertexPtsumPair > VertexPtsumVector
const_iterator end() const
last iterator over the map (read only)
U second(std::pair< T, U > const &p)
string quality
edm::AssociationMap< edm::OneToManyWithQuality< reco::VertexCollection, reco::TrackCollection, int > > TrackToVertexAssMap
edm::Handle< reco::VertexCollection > vtxcollH
std::vector< TrackQualityPair > TrackQualityPairVector
const_iterator begin() const
first iterator over the map (read only)

◆ TrackWeightAssociation() [1/2]

template<typename TREF >
static reco::VertexRef PF_PU_AssoMapAlgos::TrackWeightAssociation ( const TREF &  ,
const std::vector< reco::VertexRef > &   
)
staticprivate

Referenced by FindAssociation(), and FindNIVertex().

◆ TrackWeightAssociation() [2/2]

template<typename TREF >
VertexRef PF_PU_AssoMapAlgos::TrackWeightAssociation ( const TREF &  trackRef,
const std::vector< reco::VertexRef > &  vtxcollV 
)

Definition at line 704 of file PF_PU_AssoMapAlgos.cc.

References mps_merge::weight.

705  {
706  VertexRef bestvertexref = vtxcollV.at(0);
707  float bestweight = 0.;
708 
709  //loop over all vertices in the vertex collection
710  for (auto const& vertexref : vtxcollV) {
711  //get the most probable vertex for the track
712  float weight = vertexref->trackWeight(trackRef);
713  if (weight > bestweight) {
714  bestweight = weight;
715  bestvertexref = vertexref;
716  }
717  }
718 
719  return bestvertexref;
720 }
Definition: weight.py:1

Member Data Documentation

◆ beamspotH

edm::Handle<reco::BeamSpot> PF_PU_AssoMapAlgos::beamspotH
private

Definition at line 206 of file PF_PU_AssoMapAlgos.h.

Referenced by createMappings(), and GetInputCollections().

◆ bFieldH

edm::ESHandle<MagneticField> PF_PU_AssoMapAlgos::bFieldH
private

◆ cleanedColls_

bool PF_PU_AssoMapAlgos::cleanedColls_
private

Definition at line 214 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

◆ cleanedConvCollP

std::unique_ptr<reco::ConversionCollection> PF_PU_AssoMapAlgos::cleanedConvCollP
private

Definition at line 218 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

◆ cleanedKshortCollP

std::unique_ptr<reco::VertexCompositeCandidateCollection> PF_PU_AssoMapAlgos::cleanedKshortCollP
private

Definition at line 222 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

◆ cleanedLambdaCollP

std::unique_ptr<reco::VertexCompositeCandidateCollection> PF_PU_AssoMapAlgos::cleanedLambdaCollP
private

Definition at line 226 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

◆ cleanedNICollP

std::unique_ptr<reco::PFDisplacedVertexCollection> PF_PU_AssoMapAlgos::cleanedNICollP
private

Definition at line 230 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

◆ convCollH

edm::Handle<reco::ConversionCollection> PF_PU_AssoMapAlgos::convCollH
private

Definition at line 217 of file PF_PU_AssoMapAlgos.h.

Referenced by GetCleanedConversions(), and GetInputCollections().

◆ ConversionsCollectionToken_

edm::EDGetTokenT<reco::ConversionCollection> PF_PU_AssoMapAlgos::ConversionsCollectionToken_
private

Definition at line 216 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

◆ displVertexCollH

edm::Handle<reco::PFDisplacedVertexCollection> PF_PU_AssoMapAlgos::displVertexCollH
private

Definition at line 229 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

◆ ignoremissingpfcollection_

bool PF_PU_AssoMapAlgos::ignoremissingpfcollection_
private

Definition at line 234 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

◆ input_doReassociation_

bool PF_PU_AssoMapAlgos::input_doReassociation_
private

Definition at line 213 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and PF_PU_AssoMapAlgos().

◆ input_FinalAssociation_

int PF_PU_AssoMapAlgos::input_FinalAssociation_
private

Definition at line 232 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and PF_PU_AssoMapAlgos().

◆ input_MaxNumAssociations_

int PF_PU_AssoMapAlgos::input_MaxNumAssociations_
private

Definition at line 200 of file PF_PU_AssoMapAlgos.h.

Referenced by createMappings(), and PF_PU_AssoMapAlgos().

◆ input_nTrack_

double PF_PU_AssoMapAlgos::input_nTrack_
private

Definition at line 237 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and PF_PU_AssoMapAlgos().

◆ KshortCollectionToken_

edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> PF_PU_AssoMapAlgos::KshortCollectionToken_
private

Definition at line 220 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

◆ LambdaCollectionToken_

edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> PF_PU_AssoMapAlgos::LambdaCollectionToken_
private

Definition at line 224 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

◆ maxNumWarnings_

int PF_PU_AssoMapAlgos::maxNumWarnings_
private

Definition at line 239 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

◆ missingColls

bool PF_PU_AssoMapAlgos::missingColls
private

Definition at line 235 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

◆ NIVertexCollectionToken_

edm::EDGetTokenT<reco::PFDisplacedVertexCollection> PF_PU_AssoMapAlgos::NIVertexCollectionToken_
private

Definition at line 228 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

◆ numWarnings_

int PF_PU_AssoMapAlgos::numWarnings_
private

Definition at line 240 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

◆ token_BeamSpot_

edm::EDGetTokenT<reco::BeamSpot> PF_PU_AssoMapAlgos::token_BeamSpot_
private

Definition at line 205 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

◆ token_bField_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> PF_PU_AssoMapAlgos::token_bField_
private

Definition at line 208 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

◆ token_TrackingGeometry_

const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> PF_PU_AssoMapAlgos::token_TrackingGeometry_
private

Definition at line 210 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

◆ token_VertexCollection_

edm::EDGetTokenT<reco::VertexCollection> PF_PU_AssoMapAlgos::token_VertexCollection_
private

Definition at line 202 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

◆ trackingGeometryH

edm::ESHandle<GlobalTrackingGeometry> PF_PU_AssoMapAlgos::trackingGeometryH
private

◆ vertCompCandCollKshortH

edm::Handle<reco::VertexCompositeCandidateCollection> PF_PU_AssoMapAlgos::vertCompCandCollKshortH
private

Definition at line 221 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

◆ vertCompCandCollLambdaH

edm::Handle<reco::VertexCompositeCandidateCollection> PF_PU_AssoMapAlgos::vertCompCandCollLambdaH
private

Definition at line 225 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

◆ vtxcollH

edm::Handle<reco::VertexCollection> PF_PU_AssoMapAlgos::vtxcollH
private