87 LogWarning(
"PF_PU_AssoMapAlgos::GetInputCollections")
88 <<
"No Extra objects available in input file --> skipping reconstruction of displaced vertices !!" << endl;
109 std::auto_ptr<TrackToVertexAssMap>
115 int num_vertices =
vtxcollH->size();
119 for (
size_t idxTrack = 0; idxTrack < trkcollH->size(); ++idxTrack ) {
125 transtrk.
setES(iSetup);
132 int step = assocVtx.second;
143 track2vertex->insert( assocVtx.first, make_pair(trackref, quality) );
161 std::auto_ptr<VertexToTrackAssMap>
167 int num_vertices =
vtxcollH->size();
171 for (
size_t idxTrack = 0; idxTrack < trkcollH->size(); ++idxTrack ) {
177 transtrk.
setES(iSetup);
184 int step = assocVtx.second;
194 vertex2track->insert( trackref, make_pair(assocVtx.first, quality) );
212 auto_ptr<TrackToVertexAssMap>
232 for(
unsigned int trckcoll_ite=0; trckcoll_ite<trckcoll.size(); trckcoll_ite++){
234 trackref = trckcoll[trckcoll_ite].first;
235 int quality = trckcoll[trckcoll_ite].second;
237 if ( quality<=2 )
continue;
239 double man_pT = trackref->pt() - trackref->ptError();
240 if(man_pT>0.) ptsum+=man_pT*man_pT;
244 vertexptsumvector.push_back(make_pair(assomap_vertexref,ptsum));
248 while (vertexptsumvector.size()!=0){
251 float highestpT = 0.;
252 int highestpT_index = 0;
254 for(
unsigned int vtxptsumvec_ite=0; vtxptsumvec_ite<vertexptsumvector.size(); vtxptsumvec_ite++){
256 if(vertexptsumvector[vtxptsumvec_ite].
second>highestpT){
258 vertexref_highestpT = vertexptsumvector[vtxptsumvec_ite].first;
259 highestpT = vertexptsumvector[vtxptsumvec_ite].second;
260 highestpT_index = vtxptsumvec_ite;
274 if(assomap_vertexref==vertexref_highestpT)
275 for(
unsigned int trckcoll_ite=0; trckcoll_ite<trckcoll.size(); trckcoll_ite++)
276 trackvertexassOutput->insert(assomap_vertexref,trckcoll[trckcoll_ite]);
280 vertexptsumvector.erase(vertexptsumvector.begin()+highestpT_index);
284 return trackvertexassOutput;
298 std::vector<reco::VertexRef>*
302 vector<VertexRef>*
output =
new vector<VertexRef>();
304 for(
unsigned int index_vtx=0; index_vtx<vtxcollH->size(); ++index_vtx){
308 output->push_back(vertexref);
324 for(
unsigned int index_vtx=0; index_vtx<vtxcollV->size(); ++index_vtx){
326 VertexRef vertexref = vtxcollV->at(index_vtx);
328 if ( vertexref == toErase ){
329 vtxcollV->erase(vtxcollV->begin()+index_vtx);
346 double ztrack = trkref->vertex().z();
348 VertexRef foundVertexRef = vtxcollV->at(0);
353 for(
unsigned int index_vtx=0; index_vtx<vtxcollV->size(); ++index_vtx){
355 VertexRef vertexref = vtxcollV->at(index_vtx);
357 double nTracks =
sqrt(vertexref->tracksSize());
359 double z_distance = fabs(ztrack - vertexref->z());
361 double weightedDistance = z_distance-tWeight*nTracks;
363 if(weightedDistance<dzmin) {
364 dzmin = weightedDistance;
365 foundVertexRef = vertexref;
370 return foundVertexRef;
382 VertexRef foundVertexRef = vtxcollV->at(0);
387 for(
unsigned int index_vtx=0; index_vtx<vtxcollV->size(); ++index_vtx){
389 VertexRef vertexref = vtxcollV->at(index_vtx);
391 double nTracks =
sqrt(vertexref->tracksSize());
393 double distance = 1e5;
397 distance = IpPair.second.value();
399 double weightedDistance = distance-tWeight*nTracks;
401 if(weightedDistance<d3min) {
402 d3min = weightedDistance;
403 foundVertexRef = vertexref;
408 return foundVertexRef;
419 double bs_x = bsH->x0();
420 double bs_y = bsH->y0();
421 double bs_z = bsH->z0();
423 double connVec_x = vtx_pos.x() - bs_x;
424 double connVec_y = vtx_pos.y() - bs_y;
425 double connVec_z = vtx_pos.z() - bs_z;
427 double connVec_r =
sqrt(connVec_x*connVec_x + connVec_y*connVec_y + connVec_z*connVec_z);
428 double connVec_theta = acos(connVec_z*1./connVec_r);
430 double connVec_eta = -1.*
log(
tan(connVec_theta*1./2.));
431 double connVec_phi = atan2(connVec_y,connVec_x);
433 return deltaR(vtx_mom.eta(),vtx_mom.phi(),connVec_eta,connVec_phi);
441 auto_ptr<ConversionCollection>
446 for (
unsigned int convcoll_idx=0; convcoll_idx<convCollH->size(); convcoll_idx++){
451 cleanedConvColl->push_back(*convref);
455 if( (convref->nTracks()==2) &&
456 (fabs(convref->pairInvariantMass())<=0.1) ){
458 cleanedConvColl->push_back(*convref);
464 return cleanedConvColl;
477 for(
unsigned int convcoll_ite=0; convcoll_ite<cleanedConvColl.size(); convcoll_ite++){
481 *gamma = cleanedConvColl.at(convcoll_ite);
506 Track photon(trackref->chi2(), trackref->ndof(), conv_pos, conv_mom, 0, trackref->covariance());
509 transpho.setBeamSpot(*bsH);
510 transpho.setES(iSetup);
520 auto_ptr<VertexCompositeCandidateCollection>
526 for (
unsigned int kscoll_idx=0; kscoll_idx<KshortsH->size(); kscoll_idx++){
531 cleanedKaonColl->push_back(*ksref);
539 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));
542 ksref->momentum().y(),
543 ksref->momentum().z());
550 if ((ksref->vertex().rho()>=3.) &&
551 (ksref->vertexNormalizedChi2()<=3.) &&
552 (fabs(ksref->mass() -
kMass)<=0.01) &&
553 (kaon_significance>15.) &&
556 cleanedKaonColl->push_back(*ksref);
562 return cleanedKaonColl;
569 auto_ptr<VertexCompositeCandidateCollection>
575 for (
unsigned int lambdacoll_idx=0; lambdacoll_idx<LambdasH->size(); lambdacoll_idx++){
580 cleanedLambdaColl->push_back(*lambdaref);
588 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));
591 lambdaref->momentum().y(),
592 lambdaref->momentum().z());
599 if ((lambdaref->vertex().rho()>=3.) &&
600 (lambdaref->vertexNormalizedChi2()<=3.) &&
601 (fabs(lambdaref->mass() -
lamMass)<=0.005) &&
602 (lambda_significance>15.) &&
605 cleanedLambdaColl->push_back(*lambdaref);
611 return cleanedLambdaColl;
623 for(VertexCompositeCandidateCollection::const_iterator iKS=cleanedKshort.begin(); iKS!=cleanedKshort.end(); iKS++){
630 if((trackref==dauTk1) || (trackref==dauTk2)){
640 for(VertexCompositeCandidateCollection::const_iterator iLambda=cleanedLambda.begin(); iLambda!=cleanedLambda.end(); iLambda++){
647 if((trackref==dauTk1) || (trackref==dauTk2)){
674 Track V0(trackref->chi2(), trackref->ndof(), dec_pos, dec_mom, 0, trackref->covariance());
677 transV0.setBeamSpot(*bsH);
678 transV0.setES(iSetup);
689 auto_ptr<PFDisplacedVertexCollection>
695 for (PFDisplacedVertexCollection::const_iterator niref=NuclIntH->begin(); niref!=NuclIntH->end(); niref++){
698 if( (niref->isFake()) || !(niref->isNucl()) )
continue;
701 cleanedNIColl->push_back(*niref);
711 niref->primaryMomentum().y(),
712 niref->primaryMomentum().z());
717 double nuclint_significance = (distanceComputer.
distance(
VertexState(bsPosition,bsError),
VertexState(ni_pos, interactionVertexError))).significance();
719 if ((niref->position().rho()>=3.) &&
720 (nuclint_significance>15.) &&
723 cleanedNIColl->push_back(*niref);
729 return cleanedNIColl;
741 for(PFDisplacedVertexCollection::const_iterator iDisplV=cleanedNI.begin(); iDisplV!=cleanedNI.end(); iDisplV++){
743 if(iDisplV->trackWeight(trackref)>1.e-5){
745 *displVtx = *iDisplV;
768 for(TrackCollection::const_iterator trkcoll_ite=refittedTracks.begin(); trkcoll_ite!=refittedTracks.end(); trkcoll_ite++){
776 if( VOAssociation->trackWeight(retrackbaseref) >= 1.e-5 ){
777 return VOAssociation;
782 transIncom.
setES(iSetup);
798 Track incom(trackref->chi2(), trackref->ndof(), ni_pos, ni_mom, 0, trackref->covariance());
801 transIncom.setBeamSpot(*bsH);
802 transIncom.setES(iSetup);
816 VertexRef bestvertexref = vtxcollV->at(0);
817 float bestweight = 0.;
820 for(
unsigned int index_vtx=0; index_vtx<vtxcollV->size(); ++index_vtx){
822 VertexRef vertexref = vtxcollV->at(index_vtx);
825 float weight = vertexref->trackWeight(trackbaseRef);
826 if(weight>bestweight){
828 bestvertexref = vertexref;
833 return bestvertexref;
851 if ( assocNum>0 )
goto finalStep;
857 if ( foundVertex->trackWeight(trackbaseRef) >= 1.e-5 ){
858 return make_pair( foundVertex, 0. );
873 return make_pair( foundVertex, 1. );
881 return make_pair( foundVertex, 1. );
891 return make_pair( foundVertex, 1. );
922 transtrk.
setES(iSetup);
932 foundVertex = vtxColl->at(0);
939 return make_pair( foundVertex, 2. );
958 if ( distance <=
tw_90 ) {
961 if ( distance <=
tw_70 ) {
964 if ( distance <=
tw_50 ) {
978 if ( distance <=
sec_70 ) {
981 if ( distance <=
sec_50 ) {
994 if ( assoc_ite == 1 ) {
997 if ( assoc_ite >= 2 ) {
1000 if ( distance <=
fin_70 ) {
1003 if ( distance <=
fin_50 ) {
const reco::Vertex & conversionVertex() const
returns the reco conversion vertex
virtual Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const
VertexStepPair FindAssociation(const reco::TrackRef &, std::vector< reco::VertexRef > *, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, int)
reco::Vertex::Point convertPos(const GlobalPoint &p)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
std::vector< TrackQualityPair > TrackQualityPairVector
edm::ESHandle< MagneticField > bFieldH
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
edm::InputTag ConversionsCollection_
const bool isTherePrimaryTracks() const
--—— Provide useful information --—— ///
const_iterator end() const
last iterator over the map (read only)
void setBeamSpot(const reco::BeamSpot &beamSpot)
TrackBaseRef originalTrack(const Track &refTrack) const
virtual const Point & vertex() const
vertex position
int DefineQuality(int, int, double)
edm::InputTag KshortCollection_
static std::auto_ptr< reco::VertexCompositeCandidateCollection > GetCleanedKshort(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
int input_MaxNumAssociations_
bool input_doReassociation_
void EraseVertex(std::vector< reco::VertexRef > *, reco::VertexRef)
reco::Vertex::Error convertError(const GlobalError &ge)
edm::InputTag LambdaCollection_
std::vector< Track > TrackCollection
collection of Tracks
virtual Vector momentum() const
spatial momentum vector
static reco::VertexRef FindClosest3D(reco::TransientTrack, std::vector< reco::VertexRef > *, double tWeight=0.)
static bool ComesFromNI(const reco::TrackRef, reco::PFDisplacedVertexCollection, reco::PFDisplacedVertex *)
const bool isIncomingTrack(const reco::TrackBaseRef &originalTrack) const
Is primary or merged track.
edm::InputTag input_VertexCollection_
std::auto_ptr< TrackToVertexAssMap > CreateTrackToVertexMap(edm::Handle< reco::TrackCollection >, const edm::EventSetup &)
static bool ComesFromConversion(const reco::TrackRef, reco::ConversionCollection, reco::Conversion *)
const std::vector< Track > & refittedTracks() const
Returns the container of refitted tracks.
const Point & position() const
position
std::pair< reco::VertexRef, int > VertexStepPair
static std::auto_ptr< reco::VertexCompositeCandidateCollection > GetCleanedLambda(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
static std::auto_ptr< reco::PFDisplacedVertexCollection > GetCleanedNI(edm::Handle< reco::PFDisplacedVertexCollection >, edm::Handle< reco::BeamSpot >, bool)
U second(std::pair< T, U > const &p)
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
std::vector< VertexPtsumPair > VertexPtsumVector
static reco::VertexRef FindClosestZ(const reco::TrackRef, std::vector< reco::VertexRef > *, double tWeight=0.)
static reco::VertexRef FindNIVertex(const reco::TrackRef, reco::PFDisplacedVertex, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, std::vector< reco::VertexRef > *, double)
edm::InputTag input_BeamSpot_
edm::InputTag NIVertexCollection_
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
static bool ComesFromV0Decay(const reco::TrackRef, reco::VertexCompositeCandidateCollection, reco::VertexCompositeCandidateCollection, reco::VertexCompositeCandidate *)
edm::Handle< reco::PFDisplacedVertexCollection > displVertexCollH
Tan< T >::type tan(const T &t)
void GetInputCollections(edm::Event &, const edm::EventSetup &)
std::auto_ptr< reco::VertexCompositeCandidateCollection > cleanedKshortCollP
static reco::VertexRef TrackWeightAssociation(const reco::TrackBaseRef &, std::vector< reco::VertexRef > *)
edm::AssociationMap< edm::OneToManyWithQuality< reco::VertexCollection, reco::TrackCollection, int > > TrackToVertexAssMap
std::auto_ptr< reco::VertexCompositeCandidateCollection > cleanedLambdaCollP
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void setES(const edm::EventSetup &es)
edm::Handle< reco::VertexCollection > vtxcollH
std::auto_ptr< TrackToVertexAssMap > SortAssociationMap(TrackToVertexAssMap *)
bool ignoremissingpfcollection_
std::auto_ptr< reco::PFDisplacedVertexCollection > cleanedNICollP
double deltaR(double eta1, double eta2, double phi1, double phi2)
math::XYZTLorentzVectorF refittedPair4Momentum() const
Conversion track pair 4-momentum from the tracks refitted with vertex constraint. ...
int input_FinalAssociation_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
const math::XYZTLorentzVector primaryMomentum(std::string massHypo="PI", bool useRefitted=true, double mass=0.0) const
Momentum of primary or merged track calculated with a mass hypothesis.
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
static double dR(math::XYZPoint, math::XYZVector, edm::Handle< reco::BeamSpot >)
key_type key() const
Accessor for product key.
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollLambdaH
virtual reco::TrackRef track() const
reference to a track
std::vector< reco::VertexRef > * CreateVertexVector(edm::Handle< reco::VertexCollection >)
static reco::VertexRef FindConversionVertex(const reco::TrackRef, reco::Conversion, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, std::vector< reco::VertexRef > *, double)
static std::auto_ptr< reco::ConversionCollection > GetCleanedConversions(edm::Handle< reco::ConversionCollection >, edm::Handle< reco::BeamSpot >, bool)
edm::Handle< reco::BeamSpot > beamspotH
const_iterator begin() const
first iterator over the map (read only)
edm::Handle< reco::ConversionCollection > convCollH
const bool isThereMergedTracks() const
If a merged track was identified.
static reco::VertexRef FindV0Vertex(const reco::TrackRef, reco::VertexCompositeCandidate, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, std::vector< reco::VertexRef > *, double)
std::auto_ptr< VertexToTrackAssMap > CreateVertexToTrackMap(edm::Handle< reco::TrackCollection >, const edm::EventSetup &)
edm::AssociationMap< edm::OneToManyWithQuality< reco::TrackCollection, reco::VertexCollection, int > > VertexToTrackAssMap
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollKshortH
PF_PU_AssoMapAlgos(const edm::ParameterSet &)
std::auto_ptr< reco::ConversionCollection > cleanedConvCollP