File indexing completed on 2025-07-06 07:55:46
0001
0002
0003
0004 #include <edm4eic/ReconstructedParticle.h>
0005 #include <edm4eic/VertexCollection.h>
0006 #include <edm4eic/unit_system.h>
0007 #include <edm4hep/Vector4f.h>
0008 #include <fmt/core.h>
0009 #include <podio/RelationRange.h>
0010 #include <cmath>
0011 #include <functional>
0012 #include <gsl/pointers>
0013 #include <map>
0014
0015 #include "algorithms/reco/PrimaryVertices.h"
0016 #include "algorithms/reco/PrimaryVerticesConfig.h"
0017
0018 namespace eicrecon {
0019
0020
0021
0022
0023
0024 void PrimaryVertices::init() {}
0025
0026
0027
0028
0029
0030
0031
0032 void PrimaryVertices::process(const PrimaryVertices::Input& input,
0033 const PrimaryVertices::Output& output) const {
0034 const auto [rcvtx] = input;
0035 auto [out_primary_vertices] = output;
0036
0037
0038
0039
0040 std::multimap<int, edm4eic::Vertex, std::greater<>> primaryVertexMap;
0041
0042
0043
0044 out_primary_vertices->setSubsetCollection();
0045
0046 trace("We have {} candidate vertices", rcvtx->size());
0047
0048 for (const auto& vtx : *rcvtx) {
0049 const auto& v = vtx.getPosition();
0050
0051
0052 if (sqrt(v.x * v.x + v.y * v.y) / edm4eic::unit::mm > m_cfg.maxVr ||
0053 std::abs(v.z) / edm4eic::unit::mm > m_cfg.maxVz) {
0054 continue;
0055 }
0056
0057 if (vtx.getChi2() > m_cfg.maxChi2) {
0058 continue;
0059 }
0060
0061 int N_trk = vtx.getAssociatedParticles().size();
0062 trace("\t N_trk = {}", N_trk);
0063 primaryVertexMap.insert({N_trk, vtx});
0064 }
0065
0066 bool first = true;
0067
0068 for (auto [N_trk, vertex] : primaryVertexMap) {
0069
0070
0071 if (N_trk > m_cfg.maxNtrk || N_trk < m_cfg.minNtrk) {
0072 continue;
0073 }
0074
0075
0076
0077 if (first) {
0078 trace("Max N_trk Candidate:");
0079 trace("\t N_trk = {}", N_trk);
0080 trace("\t Primary vertex has xyz=( {}, {}, {} )", vertex.getPosition().x,
0081 vertex.getPosition().y, vertex.getPosition().z);
0082 first = false;
0083 }
0084 out_primary_vertices->push_back(vertex);
0085 }
0086 }
0087 }