591 const std::vector<const xAOD::TruthVertex*>& truthHSVertices,
592 const std::vector<const xAOD::TruthVertex*>& truthPUVertices,
593 float actualMu,
float weight) {
599 int nRecoVertices =
static_cast<int>(vertexContainer.
size()-1);
605 if (!truthHSVertices.empty()) {
606 if (truthHSVertices.size() != 1) {
607 ATH_MSG_WARNING(
"Size of truth HS vertex vector is >1 -- only using the first one in the vector.");
609 truthHSVtx = truthHSVertices.at(0);
612 ATH_MSG_WARNING(
"Size of truth HS vertex vector is 0 -- assuming truth HS vertex to NOT be reconstructed.");
616 ATH_MSG_INFO(
"No truthHSVtx vertex - not filling vertex truth matching.");
626 bool isHSVtx_vtx_matched = bestRecoHSVtx_truth && (recoHardScatter == bestRecoHSVtx_truth);
634 float residual_z = isHSVtx_reco ? truthHSVtx->
z() - bestRecoHSVtx_truth->
z() : -9999.;
639 int nTruthVertices =
static_cast<int>(truthHSVertices.size() + truthPUVertices.size());
644 const static xAOD::Vertex::Decorator<InDetVertexTruthMatchUtils::VertexMatchType> recoVtxMatchTypeInfo(
"VertexMatchType");
645 std::map<InDetVertexTruthMatchUtils::VertexMatchType, int> breakdown = {};
655 float localPUDensity =
getLocalPUDensity(truthHSVtx, truthHSVertices, truthPUVertices);
663 float number_matched = 0;
664 float number_merged = 0;
665 float number_split = 0;
666 float number_fake = 0;
667 float number_matched_HS = 0;
668 float number_merged_HS = 0;
669 float number_split_HS = 0;
670 float number_fake_HS = 0;
671 float number_matched_PU = 0;
672 float number_merged_PU = 0;
673 float number_split_PU = 0;
674 float number_fake_PU = 0;
677 float vx_hs_mindz=9999.;
681 for (
const auto& vertex : vertexContainer.
stdcont()) {
683 unsigned int nTrackPart = vertex->nTrackParticles();
692 matchType = recoVtxMatchTypeInfo(*vertex);
693 breakdown[matchType] += 1;
697 float residual_z = matchVertex->
z() - vertex->z();
698 float residual_x = matchVertex->
x() - vertex->x();
699 float residual_y = matchVertex->
y() - vertex->y();
700 const AmgSymMatrix(3)& covariance = vertex->covariancePosition();
701 float vtxerr_x = std::abs(
Amg::error(covariance, 0)) > 1e-7 ?
Amg::error(covariance, 0) : 1000.;
702 float vtxerr_y = std::abs(
Amg::error(covariance, 1)) > 1e-7 ?
Amg::error(covariance, 1) : 1000.;
703 float vtxerr_z = std::abs(
Amg::error(covariance, 2)) > 1e-7 ?
Amg::error(covariance, 2) : 1000.;
709 float localPUDensity =
getLocalPUDensity(matchVertex, truthHSVertices, truthPUVertices);
739 float minpt = 20000 ;
747 float weighted_sumDZ = 0;
748 float weighted_deltaZ = 0;
749 float weighted_modsumDZ = 0;
750 float weighted_z_asym =0;
753 std::vector<float> track_deltaZ;
754 std::vector<float> track_deltaPt;
755 std::vector<float> track_deltaZ_weighted;
758 for (
size_t i = 0; i < nTrackPart; i++) {
759 trackTmp = vertex->trackParticle(i);
762 trackPt = trackTmp->
pt();
763 sumPt = sumPt + trackPt;
764 deltaZ = trackTmp->
z0() - vertex->z();
765 track_deltaZ.push_back(deltaZ);
767 float trk_weight = vertex->trackWeight(i);
768 weighted_deltaZ = deltaZ*trk_weight;
770 sumDZ = sumDZ + deltaZ;
771 modsumDZ = modsumDZ + std::abs(deltaZ);
772 weighted_sumDZ = weighted_sumDZ + weighted_deltaZ;
773 weighted_modsumDZ = weighted_modsumDZ + std::abs(weighted_deltaZ);
777 if (modsumDZ >0) z_asym = sumDZ/modsumDZ;
778 if (weighted_modsumDZ >0) weighted_z_asym = weighted_sumDZ/weighted_modsumDZ;
781 mean_Dz=sumDZ/track_deltaZ.size();
782 double number_tracks =0;
783 number_tracks = track_deltaZ.size();
791 for (
auto i : track_deltaZ) {
792 z_zbar = (i - mean_Dz);
793 z_var =(z_var + z_zbar*z_zbar);
794 z_skew =(z_skew + z_zbar*z_zbar*z_zbar);
795 z_kurt =(z_kurt + z_zbar*z_zbar*z_zbar*z_zbar);
798 z_var = z_var/(number_tracks -1);
799 z_sd = std::sqrt(z_var);
800 z_skew = z_skew/((number_tracks -1)*z_sd*z_sd*z_sd);
801 z_kurt = z_kurt/((number_tracks -1)*z_sd*z_sd*z_sd*z_sd);
803 float ndf = vertex->numberDoF();
807 if (vertex == bestRecoHSVtx_truth) {
816 for (
const float& trkWeight : vertex->trackWeights()) {
829 for (
const float& trkWeight : vertex->trackWeights()) {
844 for (
const float& trkWeight : vertex->trackWeights()) {
853 if (vertex == bestRecoHSVtx_truth) {
861 for (
const float& trkWeight : vertex->trackWeights()) {
874 for (
const float& trkWeight : vertex->trackWeights()) {
888 for (
const float& trkWeight : vertex->trackWeights()) {
896 if (vertex == bestRecoHSVtx_truth) {
904 for (
const float& trkWeight : vertex->trackWeights()) {
916 for (
const float& trkWeight : vertex->trackWeights()) {
931 for (
const float& trkWeight : vertex->trackWeights()) {
940 if (vertex == bestRecoHSVtx_truth) number_matched_HS++;
941 else number_matched_PU++;
942 if (sumPt > minpt) number_matched++;
944 if (vertex == bestRecoHSVtx_truth) number_merged_HS++;
945 else number_merged_PU++;
946 if (sumPt > minpt) number_merged++;
948 if (vertex == bestRecoHSVtx_truth) number_split_HS++;
949 else number_split_PU++;
950 if (sumPt > minpt) number_split++;
952 if (vertex == bestRecoHSVtx_truth) number_fake_HS++;
953 else number_fake_PU++;
954 if (sumPt > minpt) number_fake++;
959 if (vertex == bestRecoHSVtx_truth) {
1006 if(bestRecoHSVtx_truth && bestRecoHSVtx_truth != vertex) {
1007 float dz = bestRecoHSVtx_truth->
z() - vertex->z();
1008 if(std::abs(dz) < std::abs(vx_hs_mindz)) vx_hs_mindz = dz;
1012 for (
const auto& vertex2 : vertexContainer.
stdcont()) {
1014 if(vertex2 == vertex)
continue;
1038 if (!truthHSVertices.empty()) {
1050 float residual_x = truthHSVtx->
x() - bestRecoHSVtx_truth->
x();
1051 float residual_y = truthHSVtx->
y() - bestRecoHSVtx_truth->
y();
1052 float residual_r = std::hypot(residual_x, residual_y);
1057 const AmgSymMatrix(3)& covariance = bestRecoHSVtx_truth->covariancePosition();