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, const edm::EventSetup &iSetup)
 
std::unique_ptr< TrackToVertexAssMapCreateTrackToVertexMap (edm::Handle< reco::TrackCollection >, const edm::EventSetup &)
 
std::unique_ptr< VertexToTrackAssMapCreateVertexToTrackMap (edm::Handle< reco::TrackCollection >, const edm::EventSetup &)
 
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 ()(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 >, const edm::EventSetup &, 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 >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
 
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)
 
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::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_
 
edm::EDGetTokenT< reco::VertexCollectiontoken_VertexCollection_
 
edm::Handle< reco::VertexCompositeCandidateCollectionvertCompCandCollKshortH
 
edm::Handle< reco::VertexCompositeCandidateCollectionvertCompCandCollLambdaH
 
edm::Handle< reco::VertexCollectionvtxcollH
 

Detailed Description

Definition at line 82 of file PF_PU_AssoMapAlgos.h.

Constructor & Destructor Documentation

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  :
88  PF_PU_AssoMapAlgos(iConfig, iC) {};
PF_PU_AssoMapAlgos(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
PF_PU_AssoMapAlgos::PF_PU_AssoMapAlgos ( const edm::ParameterSet iConfig,
edm::ConsumesCollector iC 
)

Definition at line 26 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_.

27  : maxNumWarnings_(3),
28  numWarnings_(0)
29 {
30 
31  input_MaxNumAssociations_ = iConfig.getParameter<int>("MaxNumberOfAssociations");
32 
33  token_VertexCollection_= iC.consumes<VertexCollection>(iConfig.getParameter<InputTag>("VertexCollection"));
34 
35  token_BeamSpot_= iC.consumes<BeamSpot>(iConfig.getParameter<InputTag>("BeamSpot"));
36 
37  input_doReassociation_= iConfig.getParameter<bool>("doReassociation");
38  cleanedColls_ = iConfig.getParameter<bool>("GetCleanedCollections");
39 
40  ConversionsCollectionToken_= iC.consumes<ConversionCollection>(iConfig.getParameter<InputTag>("ConversionsCollection"));
41 
44 
46 
47  input_FinalAssociation_= iConfig.getUntrackedParameter<int>("FinalAssociation", 0);
48 
49  ignoremissingpfcollection_ = iConfig.getParameter<bool>("ignoreMissingCollection");
50 
51  input_nTrack_ = iConfig.getParameter<double>("nTrackWeight");
52 
53 }
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > LambdaCollectionToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
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
edm::EDGetTokenT< reco::PFDisplacedVertexCollection > NIVertexCollectionToken_
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > KshortCollectionToken_
edm::EDGetTokenT< reco::ConversionCollection > ConversionsCollectionToken_
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
virtual PF_PU_AssoMapAlgos::~PF_PU_AssoMapAlgos ( )
inlinevirtual

Member Function Documentation

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

Definition at line 441 of file PF_PU_AssoMapAlgos.cc.

References ConversionTools::matchesConversion().

Referenced by FindAssociation(), and ~PF_PU_AssoMapAlgos().

442 {
443 
444  for(unsigned int convcoll_ite=0; convcoll_ite<cleanedConvColl.size(); convcoll_ite++){
445 
446  if(ConversionTools::matchesConversion(trackref,cleanedConvColl.at(convcoll_ite))){
447 
448  *gamma = cleanedConvColl.at(convcoll_ite);
449  return true;
450 
451  }
452 
453  }
454 
455  return false;
456 }
static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false)
bool PF_PU_AssoMapAlgos::ComesFromNI ( const reco::TrackRef  trackref,
const reco::PFDisplacedVertexCollection cleanedNI,
reco::PFDisplacedVertex displVtx 
)
staticprivate

Definition at line 706 of file PF_PU_AssoMapAlgos.cc.

Referenced by FindAssociation(), and ~PF_PU_AssoMapAlgos().

707 {
708 
709  //the part for the reassociation of particles from nuclear interactions
710  for(PFDisplacedVertexCollection::const_iterator iDisplV=cleanedNI.begin(); iDisplV!=cleanedNI.end(); iDisplV++){
711 
712  if(iDisplV->trackWeight(trackref)>1.e-5){
713 
714  *displVtx = *iDisplV;
715  return true;
716 
717  }
718 
719  }
720 
721  return false;
722 }
bool PF_PU_AssoMapAlgos::ComesFromV0Decay ( const reco::TrackRef  trackref,
const reco::VertexCompositeCandidateCollection cleanedKshort,
const reco::VertexCompositeCandidateCollection cleanedLambda,
reco::VertexCompositeCandidate V0 
)
staticprivate

Definition at line 587 of file PF_PU_AssoMapAlgos.cc.

References reco::RecoChargedCandidate::track().

Referenced by FindAssociation(), and ~PF_PU_AssoMapAlgos().

588 {
589 
590  //the part for the reassociation of particles from Kshort decays
591  for(VertexCompositeCandidateCollection::const_iterator iKS=cleanedKshort.begin(); iKS!=cleanedKshort.end(); iKS++){
592 
593  const RecoChargedCandidate *dauCand1 = dynamic_cast<const RecoChargedCandidate*>(iKS->daughter(0));
594  TrackRef dauTk1 = dauCand1->track();
595  const RecoChargedCandidate *dauCand2 = dynamic_cast<const RecoChargedCandidate*>(iKS->daughter(1));
596  TrackRef dauTk2 = dauCand2->track();
597 
598  if((trackref==dauTk1) || (trackref==dauTk2)){
599 
600  *V0 = *iKS;
601  return true;
602 
603  }
604 
605  }
606 
607  //the part for the reassociation of particles from Lambda decays
608  for(VertexCompositeCandidateCollection::const_iterator iLambda=cleanedLambda.begin(); iLambda!=cleanedLambda.end(); iLambda++){
609 
610  const RecoChargedCandidate *dauCand1 = dynamic_cast<const RecoChargedCandidate*>(iLambda->daughter(0));
611  TrackRef dauTk1 = dauCand1->track();
612  const RecoChargedCandidate *dauCand2 = dynamic_cast<const RecoChargedCandidate*>(iLambda->daughter(1));
613  TrackRef dauTk2 = dauCand2->track();
614 
615  if((trackref==dauTk1) || (trackref==dauTk2)){
616 
617  *V0 = *iLambda;
618  return true;
619 
620  }
621 
622  }
623 
624  return false;
625 }
reco::TrackRef track() const override
reference to a track
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > PF_PU_AssoMapAlgos::createMappings ( edm::Handle< reco::TrackCollection trkcollH,
const edm::EventSetup iSetup 
)

Definition at line 110 of file PF_PU_AssoMapAlgos.cc.

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

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

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

Definition at line 165 of file PF_PU_AssoMapAlgos.cc.

References createMappings().

Referenced by ~PF_PU_AssoMapAlgos().

166 {
167  return createMappings(trkcollH,iSetup).first;
168 }
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings(edm::Handle< reco::TrackCollection > trkcollH, const edm::EventSetup &iSetup)
std::unique_ptr< VertexToTrackAssMap > PF_PU_AssoMapAlgos::CreateVertexToTrackMap ( edm::Handle< reco::TrackCollection trkcollH,
const edm::EventSetup iSetup 
)

Definition at line 175 of file PF_PU_AssoMapAlgos.cc.

References createMappings().

Referenced by ~PF_PU_AssoMapAlgos().

176 {
177  return createMappings(trkcollH,iSetup).second;
178 }
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings(edm::Handle< reco::TrackCollection > trkcollH, const edm::EventSetup &iSetup)
std::vector< reco::VertexRef > PF_PU_AssoMapAlgos::CreateVertexVector ( edm::Handle< reco::VertexCollection vtxcollH)
protected

Definition at line 271 of file PF_PU_AssoMapAlgos.cc.

References mps_fire::i, and convertSQLitetoXML_cfg::output.

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

272 {
273 
274  vector<VertexRef> output;
275  output.reserve(vtxcollH->size());
276  auto const nVtx = vtxcollH->size();
277  for (unsigned int i = 0; i < nVtx; ++i) output.emplace_back(vtxcollH,i);
278 
279  return output;
280 
281 }
int PF_PU_AssoMapAlgos::DefineQuality ( int  assoc_ite,
int  step,
double  distance 
)
protected

Definition at line 915 of file PF_PU_AssoMapAlgos.cc.

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

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

916 {
917 
918  int quality = 0;
919 
920  switch (step) {
921 
922  case 0:{
923 
924  //TrackWeight association
925  if ( distance <= tw_90 ) {
926  quality = 5;
927  } else {
928  if ( distance <= tw_70 ) {
929  quality = 4;
930  } else {
931  if ( distance <= tw_50 ) {
932  quality = 3;
933  } else {
934  quality = 2;
935  }
936  }
937  }
938  break;
939 
940  }
941 
942  case 1:{
943 
944  //Secondary association
945  if ( distance <= sec_70 ) {
946  quality = 4;
947  } else {
948  if ( distance <= sec_50 ) {
949  quality = 3;
950  } else {
951  quality = 2;
952  }
953  }
954  break;
955 
956  }
957 
958  case 2:{
959 
960  //Final association
961  if ( assoc_ite == 1 ) {
962  quality = 1;
963  } else {
964  if ( assoc_ite >= 2 ) {
965  quality = 0;
966  } else {
967  if ( distance <= fin_70 ) {
968  quality = 4;
969  } else {
970  if ( distance <= fin_50 ) {
971  quality = 3;
972  } else {
973  quality = 2;
974  }
975  }
976  }
977  }
978  break;
979 
980  }
981 
982  default:{
983 
984  quality = -1;
985  break;
986  }
987 
988  }
989 
990  return quality;
991 
992 }
const double tw_70
const double fin_70
const double sec_50
const double tw_50
const double sec_70
step
Definition: StallMonitor.cc:94
const double tw_90
const double fin_50
double PF_PU_AssoMapAlgos::dR ( const math::XYZPoint vtx_pos,
const math::XYZVector vtx_mom,
edm::Handle< reco::BeamSpot bsH 
)
staticprivate

Definition at line 383 of file PF_PU_AssoMapAlgos.cc.

References boostedElectronIsolation_cff::deltaR, cmsBatch::log, mathSSE::sqrt(), funct::tan(), reco::BeamSpot::x0(), reco::BeamSpot::y0(), and reco::BeamSpot::z0().

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

384 {
385 
386  double bs_x = bsH->x0();
387  double bs_y = bsH->y0();
388  double bs_z = bsH->z0();
389 
390  double connVec_x = vtx_pos.x() - bs_x;
391  double connVec_y = vtx_pos.y() - bs_y;
392  double connVec_z = vtx_pos.z() - bs_z;
393 
394  double connVec_r = sqrt(connVec_x*connVec_x + connVec_y*connVec_y + connVec_z*connVec_z);
395  double connVec_theta = acos(connVec_z*1./connVec_r);
396 
397  double connVec_eta = -1.*log(tan(connVec_theta*1./2.));
398  double connVec_phi = atan2(connVec_y,connVec_x);
399 
400  return deltaR(vtx_mom.eta(),vtx_mom.phi(),connVec_eta,connVec_phi);
401 
402 }
double z0() const
z coordinate
Definition: BeamSpot.h:68
T sqrt(T t)
Definition: SSEVec.h:18
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double y0() const
y coordinate
Definition: BeamSpot.h:66
double x0() const
x coordinate
Definition: BeamSpot.h:64
void PF_PU_AssoMapAlgos::EraseVertex ( std::vector< reco::VertexRef > &  vtxcollV,
reco::VertexRef  toErase 
)
protected

Definition at line 288 of file PF_PU_AssoMapAlgos.cc.

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

289 {
290 
291  for(unsigned int index_vtx=0; index_vtx<vtxcollV.size(); ++index_vtx){
292 
293  VertexRef vertexref = vtxcollV.at(index_vtx);
294 
295  if ( vertexref == toErase ){
296  vtxcollV.erase(vtxcollV.begin()+index_vtx);
297  break;
298  }
299 
300  }
301 
302 }
VertexStepPair PF_PU_AssoMapAlgos::FindAssociation ( const reco::TrackRef trackref,
const std::vector< reco::VertexRef > &  vtxColl,
edm::ESHandle< MagneticField bfH,
const edm::EventSetup iSetup,
edm::Handle< reco::BeamSpot bsH,
int  assocNum 
)
protected

Definition at line 810 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::setES(), and TrackWeightAssociation().

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

812 {
813 
814  VertexRef foundVertex;
815 
816  //if it is not the first try of an association jump to the final association
817  //to avoid multiple (secondary) associations and/or unphysical (primary and secondary) associations
818  if ( assocNum>0 ) goto finalStep;
819 
820  // Step 1: First round of association:
821  // Find the vertex with the highest track-to-vertex association weight
822  foundVertex = TrackWeightAssociation(trackref, vtxColl);
823 
824  if ( foundVertex->trackWeight(trackref) >= 1.e-5 ){
825  return make_pair( foundVertex, 0. );
826  }
827 
828  // Step 2: Reassociation
829  // Second round of association:
830  // In case no vertex with track-to-vertex association weight > 1.e-5 is found,
831  // check the track originates from a neutral hadron decay, photon conversion or nuclear interaction
832 
833  if ( input_doReassociation_ ) {
834 
835  // Test if the track comes from a photon conversion:
836  // If so, try to find the vertex of the mother particle
838  if ( ComesFromConversion(trackref, *cleanedConvCollP, &gamma) ){
839  foundVertex = FindConversionVertex(trackref, gamma, bfH, iSetup, bsH, vtxColl, input_nTrack_);
840  return make_pair( foundVertex, 1. );
841  }
842 
843  // Test if the track comes from a Kshort or Lambda decay:
844  // If so, reassociate the track to the vertex of the V0
846  if ( ComesFromV0Decay(trackref, *cleanedKshortCollP, *cleanedLambdaCollP, &V0) ) {
847  foundVertex = FindV0Vertex(trackref, V0, bfH, iSetup, bsH, vtxColl, input_nTrack_);
848  return make_pair( foundVertex, 1. );
849  }
850 
851  if ( !missingColls ) {
852 
853  // Test if the track comes from a nuclear interaction:
854  // If so, reassociate the track to the vertex of the incoming particle
855  PFDisplacedVertex displVtx;
856  if ( ComesFromNI(trackref, *cleanedNICollP, &displVtx) ){
857  foundVertex = FindNIVertex(trackref, displVtx, bfH, iSetup, bsH, vtxColl, input_nTrack_);
858  return make_pair( foundVertex, 1. );
859  }
860 
861  }
862 
863  }
864 
865  // Step 3: Final association
866  // If no vertex is found with track-to-vertex association weight > 1.e-5
867  // and no reassociation was done do the final association
868  // look for the closest vertex in 3D or in z/longitudinal distance
869  // or associate the track always to the first vertex (default)
870 
871  finalStep:
872 
873  switch (input_FinalAssociation_) {
874 
875  case 1:{
876 
877  // closest in z
878  foundVertex = FindClosestZ(trackref,vtxColl,input_nTrack_);
879  break;
880 
881 
882  }
883 
884  case 2:{
885 
886  // closest in 3D
887  TransientTrack transtrk(trackref, &(*bfH) );
888  transtrk.setBeamSpot(*bsH);
889  transtrk.setES(iSetup);
890 
891  foundVertex = FindClosest3D(transtrk,vtxColl,input_nTrack_);
892  break;
893 
894  }
895 
896  default:{
897 
898  // allways first vertex
899  foundVertex = vtxColl.at(0);
900  break;
901 
902  }
903 
904  }
905 
906  return make_pair( foundVertex, 2. );
907 
908 }
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 reco::VertexRef TrackWeightAssociation(const TREF &, const std::vector< reco::VertexRef > &)
std::unique_ptr< reco::PFDisplacedVertexCollection > cleanedNICollP
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedLambdaCollP
static bool ComesFromV0Decay(const reco::TrackRef, const reco::VertexCompositeCandidateCollection &, const reco::VertexCompositeCandidateCollection &, reco::VertexCompositeCandidate *)
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 reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector< reco::VertexRef > &, double tWeight=0.)
Block of elements.
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.)
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)
std::unique_ptr< reco::ConversionCollection > cleanedConvCollP
VertexRef PF_PU_AssoMapAlgos::FindClosest3D ( reco::TransientTrack  transtrk,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight = 0. 
)
staticprivate

Definition at line 346 of file PF_PU_AssoMapAlgos.cc.

References IPTools::absoluteImpactParameter3D(), SoftLeptonByDistance_cfi::distance, nTracks(), and mathSSE::sqrt().

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

347 {
348 
349  VertexRef foundVertexRef = vtxcollV.at(0);
350 
351  double d3min = 1e5;
352 
353  //loop over all vertices with a good quality in the vertex collection
354  for(unsigned int index_vtx=0; index_vtx<vtxcollV.size(); ++index_vtx){
355 
356  VertexRef vertexref = vtxcollV.at(index_vtx);
357 
358  double nTracks = sqrt(vertexref->tracksSize());
359 
360  double distance = 1e5;
361  pair<bool,Measurement1D> IpPair = IPTools::absoluteImpactParameter3D(transtrk, *vertexref);
362 
363  if(IpPair.first)
364  distance = IpPair.second.value();
365 
366  double weightedDistance = distance-tWeight*nTracks;
367 
368  if(weightedDistance<d3min) {
369  d3min = weightedDistance;
370  foundVertexRef = vertexref;
371  }
372 
373  }
374 
375  return foundVertexRef;
376 }
const unsigned int nTracks(const reco::Vertex &sv)
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:37
T sqrt(T t)
Definition: SSEVec.h:18
VertexRef PF_PU_AssoMapAlgos::FindClosestZ ( const reco::TrackRef  trkref,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight = 0. 
)
staticprivate

Definition at line 310 of file PF_PU_AssoMapAlgos.cc.

References nTracks(), and mathSSE::sqrt().

Referenced by FindAssociation(), and ~PF_PU_AssoMapAlgos().

311 {
312 
313  double ztrack = trkref->vertex().z();
314 
315  VertexRef foundVertexRef = vtxcollV.at(0);
316 
317  double dzmin = 1e5;
318 
319  //loop over all vertices with a good quality in the vertex collection
320  for(unsigned int index_vtx=0; index_vtx<vtxcollV.size(); ++index_vtx){
321 
322  VertexRef vertexref = vtxcollV.at(index_vtx);
323 
324  double nTracks = sqrt(vertexref->tracksSize());
325 
326  double z_distance = fabs(ztrack - vertexref->z());
327 
328  double weightedDistance = z_distance-tWeight*nTracks;
329 
330  if(weightedDistance<dzmin) {
331  dzmin = weightedDistance;
332  foundVertexRef = vertexref;
333  }
334 
335  }
336 
337  return foundVertexRef;
338 }
const unsigned int nTracks(const reco::Vertex &sv)
T sqrt(T t)
Definition: SSEVec.h:18
VertexRef PF_PU_AssoMapAlgos::FindConversionVertex ( const reco::TrackRef  trackref,
const reco::Conversion gamma,
edm::ESHandle< MagneticField bfH,
const edm::EventSetup iSetup,
edm::Handle< reco::BeamSpot bsH,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight 
)
staticprivate

Definition at line 464 of file PF_PU_AssoMapAlgos.cc.

References reco::Conversion::conversionVertex(), FindClosest3D(), muons2muons_cfi::photon, reco::Vertex::position(), and reco::Conversion::refittedPair4Momentum().

Referenced by FindAssociation(), and ~PF_PU_AssoMapAlgos().

466 {
467 
468  math::XYZPoint conv_pos = gamma.conversionVertex().position();
469 
470  math::XYZVector conv_mom(gamma.refittedPair4Momentum().x(),
471  gamma.refittedPair4Momentum().y(),
472  gamma.refittedPair4Momentum().z());
473 
474  Track photon(trackref->chi2(), trackref->ndof(), conv_pos, conv_mom, 0, trackref->covariance());
475 
476  TransientTrack transpho(photon, &(*bfH) );
477  transpho.setBeamSpot(*bsH);
478  transpho.setES(iSetup);
479 
480  return FindClosest3D(transpho, vtxcollV, tWeight);
481 
482 }
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
Definition: Conversion.h:98
const Point & position() const
position
Definition: Vertex.h:109
math::XYZTLorentzVectorF refittedPair4Momentum() const
Conversion track pair 4-momentum from the tracks refitted with vertex constraint. ...
Definition: Conversion.cc:235
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:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
VertexRef PF_PU_AssoMapAlgos::FindNIVertex ( const reco::TrackRef  trackref,
const reco::PFDisplacedVertex displVtx,
edm::ESHandle< MagneticField bFieldH,
const edm::EventSetup iSetup,
edm::Handle< reco::BeamSpot bsH,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight 
)
staticprivate

Definition at line 730 of file PF_PU_AssoMapAlgos.cc.

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

Referenced by FindAssociation(), and ~PF_PU_AssoMapAlgos().

732 {
733 
734  TrackCollection refittedTracks = displVtx.refittedTracks();
735 
736  if((displVtx.isTherePrimaryTracks()) || (displVtx.isThereMergedTracks())){
737 
738  for(TrackCollection::const_iterator trkcoll_ite=refittedTracks.begin(); trkcoll_ite!=refittedTracks.end(); trkcoll_ite++){
739 
740  const TrackBaseRef retrackbaseref = displVtx.originalTrack(*trkcoll_ite);
741 
742  if(displVtx.isIncomingTrack(retrackbaseref)){
743 
744  VertexRef VOAssociation = TrackWeightAssociation(retrackbaseref, vtxcollV);
745 
746  if( VOAssociation->trackWeight(retrackbaseref) >= 1.e-5 ){
747  return VOAssociation;
748  }
749 
750  TransientTrack transIncom(*retrackbaseref, &(*bFieldH) );
751  transIncom.setBeamSpot(*bsH);
752  transIncom.setES(iSetup);
753 
754  return FindClosest3D(transIncom, vtxcollV, tWeight);
755 
756  }
757 
758  }
759 
760  }
761 
762  const math::XYZPoint& ni_pos = displVtx.position();
763 
764  math::XYZVector ni_mom(displVtx.primaryMomentum().x(),
765  displVtx.primaryMomentum().y(),
766  displVtx.primaryMomentum().z());
767 
768  Track incom(trackref->chi2(), trackref->ndof(), ni_pos, ni_mom, 0, trackref->covariance());
769 
770  TransientTrack transIncom(incom, &(*bFieldH) );
771  transIncom.setBeamSpot(*bsH);
772  transIncom.setES(iSetup);
773 
774  return FindClosest3D(transIncom, vtxcollV, tWeight);
775 
776 }
const bool isTherePrimaryTracks() const
--—— Provide useful information --—— ///
TrackBaseRef originalTrack(const Track &refTrack) const
Definition: Vertex.cc:108
static reco::VertexRef TrackWeightAssociation(const TREF &, const std::vector< reco::VertexRef > &)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
const bool isIncomingTrack(const reco::TrackBaseRef &originalTrack) const
Is primary or merged track.
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
Definition: Vertex.h:164
const Point & position() const
position
Definition: Vertex.h:109
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:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
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 isThereMergedTracks() const
If a merged track was identified.
VertexRef PF_PU_AssoMapAlgos::FindV0Vertex ( const reco::TrackRef  trackref,
const reco::VertexCompositeCandidate V0_vtx,
edm::ESHandle< MagneticField bFieldH,
const edm::EventSetup iSetup,
edm::Handle< reco::BeamSpot bsH,
const std::vector< reco::VertexRef > &  vtxcollV,
double  tWeight 
)
staticprivate

Definition at line 633 of file PF_PU_AssoMapAlgos.cc.

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

Referenced by FindAssociation(), and ~PF_PU_AssoMapAlgos().

635 {
636 
637  const math::XYZPoint& dec_pos = V0_vtx.vertex();
638 
639  math::XYZVector dec_mom(V0_vtx.momentum().x(),
640  V0_vtx.momentum().y(),
641  V0_vtx.momentum().z());
642 
643  Track V0(trackref->chi2(), trackref->ndof(), dec_pos, dec_mom, 0, trackref->covariance());
644 
645  TransientTrack transV0(V0, &(*bFieldH) );
646  transV0.setBeamSpot(*bsH);
647  transV0.setES(iSetup);
648 
649  return FindClosest3D(transV0, vtxcollV, tWeight);
650 
651 }
Vector momentum() const final
spatial momentum vector
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:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
unique_ptr< ConversionCollection > PF_PU_AssoMapAlgos::GetCleanedConversions ( edm::Handle< reco::ConversionCollection convCollH,
edm::Handle< reco::BeamSpot bsH,
bool  cleanedColl 
)
staticprivate

Definition at line 409 of file PF_PU_AssoMapAlgos.cc.

Referenced by GetInputCollections(), and ~PF_PU_AssoMapAlgos().

410 {
411  unique_ptr<ConversionCollection> cleanedConvColl(new ConversionCollection() );
412 
413  for (unsigned int convcoll_idx=0; convcoll_idx<convCollH->size(); convcoll_idx++){
414 
415  ConversionRef convref(convCollH,convcoll_idx);
416 
417  if(!cleanedColl){
418  cleanedConvColl->push_back(*convref);
419  continue;
420  }
421 
422  if( (convref->nTracks()==2) &&
423  (fabs(convref->pairInvariantMass())<=0.1) ){
424 
425  cleanedConvColl->push_back(*convref);
426 
427  }
428 
429  }
430 
431  return cleanedConvColl;
432 
433 }
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
unique_ptr< VertexCompositeCandidateCollection > PF_PU_AssoMapAlgos::GetCleanedKshort ( edm::Handle< reco::VertexCompositeCandidateCollection KshortsH,
edm::Handle< reco::BeamSpot bsH,
bool  cleanedColl 
)
staticprivate

Definition at line 489 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(), and ~PF_PU_AssoMapAlgos().

490 {
491 
492  unique_ptr<VertexCompositeCandidateCollection> cleanedKaonColl(new VertexCompositeCandidateCollection() );
493 
494  for (unsigned int kscoll_idx=0; kscoll_idx<KshortsH->size(); kscoll_idx++){
495 
496  VertexCompositeCandidateRef ksref(KshortsH,kscoll_idx);
497 
498  if(!cleanedColl){
499  cleanedKaonColl->push_back(*ksref);
500  continue;
501  }
502 
503  VertexDistance3D distanceComputer;
504 
505  GlobalPoint dec_pos = RecoVertex::convertPos(ksref->vertex());
506 
507  GlobalError decayVertexError = GlobalError(ksref->vertexCovariance(0,0), ksref->vertexCovariance(0,1), ksref->vertexCovariance(1,1), ksref->vertexCovariance(0,2), ksref->vertexCovariance(1,2), ksref->vertexCovariance(2,2));
508 
509  math::XYZVector dec_mom(ksref->momentum().x(),
510  ksref->momentum().y(),
511  ksref->momentum().z());
512 
513  GlobalPoint bsPosition = RecoVertex::convertPos(bsH->position());
515 
516  double kaon_significance = (distanceComputer.distance(VertexState(bsPosition,bsError), VertexState(dec_pos, decayVertexError))).significance();
517 
518  if ((ksref->vertex().rho()>=3.) &&
519  (ksref->vertexNormalizedChi2()<=3.) &&
520  (fabs(ksref->mass() - kMass)<=0.01) &&
521  (kaon_significance>15.) &&
522  (PF_PU_AssoMapAlgos::dR(ksref->vertex(),dec_mom,bsH)<=0.3) ){
523 
524  cleanedKaonColl->push_back(*ksref);
525 
526  }
527 
528  }
529 
530  return cleanedKaonColl;
531 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:118
const double kMass
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
significance
Definition: met_cff.py:19
const Point & position() const
position
Definition: BeamSpot.h:62
unique_ptr< VertexCompositeCandidateCollection > PF_PU_AssoMapAlgos::GetCleanedLambda ( edm::Handle< reco::VertexCompositeCandidateCollection LambdasH,
edm::Handle< reco::BeamSpot bsH,
bool  cleanedColl 
)
staticprivate

Definition at line 538 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(), and ~PF_PU_AssoMapAlgos().

539 {
540 
541  unique_ptr<VertexCompositeCandidateCollection> cleanedLambdaColl(new VertexCompositeCandidateCollection() );
542 
543  for (unsigned int lambdacoll_idx=0; lambdacoll_idx<LambdasH->size(); lambdacoll_idx++){
544 
545  VertexCompositeCandidateRef lambdaref(LambdasH,lambdacoll_idx);
546 
547  if(!cleanedColl){
548  cleanedLambdaColl->push_back(*lambdaref);
549  continue;
550  }
551 
552  VertexDistance3D distanceComputer;
553 
554  GlobalPoint dec_pos = RecoVertex::convertPos(lambdaref->vertex());
555 
556  GlobalError decayVertexError = GlobalError(lambdaref->vertexCovariance(0,0), lambdaref->vertexCovariance(0,1), lambdaref->vertexCovariance(1,1), lambdaref->vertexCovariance(0,2), lambdaref->vertexCovariance(1,2), lambdaref->vertexCovariance(2,2));
557 
558  math::XYZVector dec_mom(lambdaref->momentum().x(),
559  lambdaref->momentum().y(),
560  lambdaref->momentum().z());
561 
562  GlobalPoint bsPosition = RecoVertex::convertPos(bsH->position());
564 
565  double lambda_significance = (distanceComputer.distance(VertexState(bsPosition,bsError), VertexState(dec_pos, decayVertexError))).significance();
566 
567  if ((lambdaref->vertex().rho()>=3.) &&
568  (lambdaref->vertexNormalizedChi2()<=3.) &&
569  (fabs(lambdaref->mass() - lamMass)<=0.005) &&
570  (lambda_significance>15.) &&
571  (PF_PU_AssoMapAlgos::dR(lambdaref->vertex(),dec_mom,bsH)<=0.3) ){
572 
573  cleanedLambdaColl->push_back(*lambdaref);
574 
575  }
576 
577  }
578 
579  return cleanedLambdaColl;
580 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
const double lamMass
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:118
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
significance
Definition: met_cff.py:19
const Point & position() const
position
Definition: BeamSpot.h:62
unique_ptr< PFDisplacedVertexCollection > PF_PU_AssoMapAlgos::GetCleanedNI ( edm::Handle< reco::PFDisplacedVertexCollection NuclIntH,
edm::Handle< reco::BeamSpot bsH,
bool  cleanedColl 
)
staticprivate

Definition at line 659 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(), and ~PF_PU_AssoMapAlgos().

660 {
661 
662  unique_ptr<PFDisplacedVertexCollection> cleanedNIColl(new PFDisplacedVertexCollection() );
663 
664  for (PFDisplacedVertexCollection::const_iterator niref=NuclIntH->begin(); niref!=NuclIntH->end(); niref++){
665 
666 
667  if( (niref->isFake()) || !(niref->isNucl()) ) continue;
668 
669  if(!cleanedColl){
670  cleanedNIColl->push_back(*niref);
671  continue;
672  }
673 
674  VertexDistance3D distanceComputer;
675 
676  GlobalPoint ni_pos = RecoVertex::convertPos(niref->position());
677  GlobalError interactionVertexError = RecoVertex::convertError(niref->error());
678 
679  math::XYZVector ni_mom(niref->primaryMomentum().x(),
680  niref->primaryMomentum().y(),
681  niref->primaryMomentum().z());
682 
683  GlobalPoint bsPosition = RecoVertex::convertPos(bsH->position());
685 
686  double nuclint_significance = (distanceComputer.distance(VertexState(bsPosition,bsError), VertexState(ni_pos, interactionVertexError))).significance();
687 
688  if ((niref->position().rho()>=3.) &&
689  (nuclint_significance>15.) &&
690  (PF_PU_AssoMapAlgos::dR(niref->position(),ni_mom,bsH)<=0.3) ){
691 
692  cleanedNIColl->push_back(*niref);
693 
694  }
695 
696  }
697 
698  return cleanedNIColl;
699 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:118
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
significance
Definition: met_cff.py:19
const Point & position() const
position
Definition: BeamSpot.h:62
void PF_PU_AssoMapAlgos::GetInputCollections ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Reimplemented in PFCand_AssoMapAlgos.

Definition at line 60 of file PF_PU_AssoMapAlgos.cc.

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

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

61 {
62 
63  //get the offline beam spot
65 
66  //get the conversion collection for the gamma conversions
69 
70  //get the vertex composite candidate collection for the Kshort's
73 
74  //get the vertex composite candidate collection for the Lambda's
77 
78  //get the displaced vertex collection for nuclear interactions
79  //create a new bool, true if no displaced vertex collection is in the event, mostly for AOD
80  missingColls = false;
83 
84  missingColls = true;
85 
86  if ( numWarnings_ < maxNumWarnings_ ) {
87  LogWarning("PF_PU_AssoMapAlgos::GetInputCollections")
88  << "No Extra objects available in input file --> skipping reconstruction of displaced vertices !!" << endl;
89  ++numWarnings_;
90  }
91 
92  }
93  } else {
94 
96 
97  }
98 
99  //get the input vertex collection
101 
102  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
103 
104 }
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)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedKshort(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
std::unique_ptr< reco::PFDisplacedVertexCollection > cleanedNICollP
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedLambdaCollP
static std::unique_ptr< reco::ConversionCollection > GetCleanedConversions(edm::Handle< reco::ConversionCollection >, edm::Handle< reco::BeamSpot >, bool)
edm::Handle< reco::PFDisplacedVertexCollection > displVertexCollH
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
T get() const
Definition: EventSetup.h:71
edm::Handle< reco::BeamSpot > beamspotH
edm::Handle< reco::ConversionCollection > convCollH
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollKshortH
std::unique_ptr< reco::ConversionCollection > cleanedConvCollP
unique_ptr< TrackToVertexAssMap > PF_PU_AssoMapAlgos::SortAssociationMap ( TrackToVertexAssMap trackvertexassInput,
edm::Handle< reco::TrackCollection trkcollH 
)

Definition at line 185 of file PF_PU_AssoMapAlgos.cc.

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

Referenced by PF_PU_AssoMap::produce(), and ~PF_PU_AssoMapAlgos().

186 {
187  //create a new TrackVertexAssMap for the Output which will be sorted
188  unique_ptr<TrackToVertexAssMap> trackvertexassOutput(new TrackToVertexAssMap(vtxcollH, trkcollH));
189 
190  //Create and fill a vector of pairs of vertex and the summed (pT-pT_Error)**2 of the tracks associated to the vertex
191  VertexPtsumVector vertexptsumvector;
192 
193  //loop over all vertices in the association map
194  for(TrackToVertexAssMap::const_iterator assomap_ite=trackvertexassInput->begin(); assomap_ite!=trackvertexassInput->end(); assomap_ite++){
195 
196  const VertexRef assomap_vertexref = assomap_ite->key;
197  const TrackQualityPairVector trckcoll = assomap_ite->val;
198 
199  float ptsum = 0;
200 
201  TrackRef trackref;
202 
203  //get the tracks associated to the vertex and calculate the manipulated pT**2
204  for(unsigned int trckcoll_ite=0; trckcoll_ite<trckcoll.size(); trckcoll_ite++){
205 
206  trackref = trckcoll[trckcoll_ite].first;
207  int quality = trckcoll[trckcoll_ite].second;
208 
209  if ( quality<=2 ) continue;
210 
211  double man_pT = trackref->pt() - trackref->ptError();
212  if(man_pT>0.) ptsum+=man_pT*man_pT;
213 
214  }
215 
216  vertexptsumvector.push_back(make_pair(assomap_vertexref,ptsum));
217 
218  }
219 
220  while (!vertexptsumvector.empty()){
221 
222  VertexRef vertexref_highestpT;
223  float highestpT = 0.;
224  int highestpT_index = 0;
225 
226  for(unsigned int vtxptsumvec_ite=0; vtxptsumvec_ite<vertexptsumvector.size(); vtxptsumvec_ite++){
227 
228  if(vertexptsumvector[vtxptsumvec_ite].second>highestpT){
229 
230  vertexref_highestpT = vertexptsumvector[vtxptsumvec_ite].first;
231  highestpT = vertexptsumvector[vtxptsumvec_ite].second;
232  highestpT_index = vtxptsumvec_ite;
233 
234  }
235 
236  }
237 
238  //loop over all vertices in the association map
239  for(TrackToVertexAssMap::const_iterator assomap_ite=trackvertexassInput->begin(); assomap_ite!=trackvertexassInput->end(); assomap_ite++){
240 
241  const VertexRef assomap_vertexref = assomap_ite->key;
242  const TrackQualityPairVector trckcoll = assomap_ite->val;
243 
244  //if the vertex from the association map the vertex with the highest manipulated pT
245  //insert all associated tracks in the output Association Map
246  if(assomap_vertexref==vertexref_highestpT)
247  for(unsigned int trckcoll_ite=0; trckcoll_ite<trckcoll.size(); trckcoll_ite++)
248  trackvertexassOutput->insert(assomap_vertexref,trckcoll[trckcoll_ite]);
249 
250  }
251 
252  vertexptsumvector.erase(vertexptsumvector.begin()+highestpT_index);
253 
254  }
255 
256  return trackvertexassOutput;
257 
258 }
std::vector< TrackQualityPair > TrackQualityPairVector
const_iterator end() const
last iterator over the map (read only)
key_type key() const
Accessor for product key.
Definition: Ref.h:263
U second(std::pair< T, U > const &p)
std::vector< VertexPtsumPair > VertexPtsumVector
edm::AssociationMap< edm::OneToManyWithQuality< reco::VertexCollection, reco::TrackCollection, int > > TrackToVertexAssMap
edm::Handle< reco::VertexCollection > vtxcollH
const_iterator begin() const
first iterator over the map (read only)
template<typename TREF >
static reco::VertexRef PF_PU_AssoMapAlgos::TrackWeightAssociation ( const TREF &  ,
const std::vector< reco::VertexRef > &   
)
staticprivate
template<typename TREF >
VertexRef PF_PU_AssoMapAlgos::TrackWeightAssociation ( const TREF &  trackRef,
const std::vector< reco::VertexRef > &  vtxcollV 
)

Definition at line 783 of file PF_PU_AssoMapAlgos.cc.

References mps_merge::weight.

784 {
785 
786  VertexRef bestvertexref = vtxcollV.at(0);
787  float bestweight = 0.;
788 
789  //loop over all vertices in the vertex collection
790  for(auto const& vertexref : vtxcollV){
791 
792  //get the most probable vertex for the track
793  float weight = vertexref->trackWeight(trackRef);
794  if(weight>bestweight){
795  bestweight = weight;
796  bestvertexref = vertexref;
797  }
798 
799  }
800 
801  return bestvertexref;
802 
803 }
Definition: weight.py:1

Member Data Documentation

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

Definition at line 186 of file PF_PU_AssoMapAlgos.h.

Referenced by createMappings(), and GetInputCollections().

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

Definition at line 188 of file PF_PU_AssoMapAlgos.h.

Referenced by createMappings(), and GetInputCollections().

bool PF_PU_AssoMapAlgos::cleanedColls_
private

Definition at line 191 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

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

Definition at line 195 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

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

Definition at line 199 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

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

Definition at line 203 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

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

Definition at line 207 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

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

Definition at line 194 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

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

Definition at line 193 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

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

Definition at line 206 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

bool PF_PU_AssoMapAlgos::ignoremissingpfcollection_
private

Definition at line 211 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

bool PF_PU_AssoMapAlgos::input_doReassociation_
private

Definition at line 190 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and PF_PU_AssoMapAlgos().

int PF_PU_AssoMapAlgos::input_FinalAssociation_
private

Definition at line 209 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and PF_PU_AssoMapAlgos().

int PF_PU_AssoMapAlgos::input_MaxNumAssociations_
private

Definition at line 180 of file PF_PU_AssoMapAlgos.h.

Referenced by createMappings(), and PF_PU_AssoMapAlgos().

double PF_PU_AssoMapAlgos::input_nTrack_
private

Definition at line 214 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and PF_PU_AssoMapAlgos().

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

Definition at line 197 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

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

Definition at line 201 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

int PF_PU_AssoMapAlgos::maxNumWarnings_
private

Definition at line 216 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

bool PF_PU_AssoMapAlgos::missingColls
private

Definition at line 212 of file PF_PU_AssoMapAlgos.h.

Referenced by FindAssociation(), and GetInputCollections().

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

Definition at line 205 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

int PF_PU_AssoMapAlgos::numWarnings_
private

Definition at line 217 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

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

Definition at line 185 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

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

Definition at line 182 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections(), and PF_PU_AssoMapAlgos().

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

Definition at line 198 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

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

Definition at line 202 of file PF_PU_AssoMapAlgos.h.

Referenced by GetInputCollections().

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

Definition at line 183 of file PF_PU_AssoMapAlgos.h.

Referenced by createMappings(), GetInputCollections(), and SortAssociationMap().