Warning, /coresoftware/offline/packages/trackreco/PHActsInitialVertexFinder.h.outdated is written in an unsupported language. File is not indexed.
0001 #ifndef TRACKRECO_PHACTSINITIALVERTEXFINDER_H
0002 #define TRACKRECO_PHACTSINITIALVERTEXFINDER_H
0003
0004 #include "PHInitVertexing.h"
0005 #include <trackbase/ActsTrackingGeometry.h>
0006
0007 #include <trackbase/TrkrDefs.h>
0008
0009 #include <Acts/Utilities/Result.hpp>
0010 #include <Acts/Vertexing/Vertex.hpp>
0011
0012 #include <ActsExamples/EventData/Track.hpp>
0013 #include <ActsExamples/EventData/TrkrClusterMultiTrajectory.hpp>
0014
0015 #include <random>
0016
0017 class PHCompositeNode;
0018 class SvtxTrack;
0019 class SvtxTrackMap;
0020 class SvtxVertexMap;
0021 class SvtxVertex;
0022
0023 using VertexVector = std::vector<Acts::Vertex<Acts::BoundTrackParameters>>;
0024
0025 using TrackParamVec = std::vector<const Acts::BoundTrackParameters*>;
0026
0027 using InitKeyMap = std::map<const Acts::BoundTrackParameters*, const unsigned int>;
0028
0029 using CentroidMap = std::map<unsigned int, std::vector<SvtxTrack*>>;
0030
0031 class PHActsInitialVertexFinder: public PHInitVertexing
0032 {
0033 public:
0034 PHActsInitialVertexFinder(const std::string& name="PHActsInitialVertexFinder");
0035 ~PHActsInitialVertexFinder() override {}
0036
0037 void setMaxVertices(const int maxVertices)
0038 { m_maxVertices = maxVertices;}
0039
0040 void setSvtxVertexMapName(const std::string& name)
0041 { m_svtxVertexMapName = name; }
0042
0043 void setSvtxTrackMapName(const std::string& name)
0044 { m_svtxTrackMapName = name; }
0045
0046 void disablePtWeights(const bool weight)
0047 { m_disableWeights = weight; }
0048
0049 void resetTrackCovariance(const bool initial)
0050 { m_resetTrackCovariance = initial; }
0051
0052 void setCentroids(const int centroids)
0053 { m_nCentroids = centroids;}
0054
0055 void setIterations(const int iterations)
0056 {m_nIterations = iterations;}
0057
0058 void removeSiliconSeeds(const bool removeSeeds)
0059 {m_removeSeeds = removeSeeds;}
0060 void magFieldName(const std::string& magfield)
0061 {m_magField = magfield;}
0062
0063 void setPCACut(const float pcaCut)
0064 {m_pcaCut = pcaCut;}
0065
0066 protected:
0067 int Setup(PHCompositeNode *topNode) override;
0068 int Process(PHCompositeNode *topNode) override;
0069 int ResetEvent(PHCompositeNode *topNode) override;
0070 int End(PHCompositeNode *topNode) override;
0071
0072 private:
0073 int getNodes(PHCompositeNode *topNode);
0074 int createNodes(PHCompositeNode *topNode);
0075
0076 /// Gets silicon stubs to send to Acts IVF
0077 TrackParamVec getTrackPointers(InitKeyMap& keyMap);
0078
0079 /// Calls Acts IVF
0080 VertexVector findVertices(TrackParamVec& tracks);
0081
0082 /// Creates SvtxVertexMap
0083 void fillVertexMap(VertexVector& vertices, InitKeyMap& keyMap);
0084
0085 /// Makes a dummy vertex only if Acts returns 0 vertices or there
0086 /// are either 0 or 1 silicon seeds
0087 void createDummyVertex(const float x, const float y, const float z);
0088
0089 /// Assigns silicon seed a vertex ID if it was left out of Acts IVF
0090 void checkTrackVertexAssociation();
0091
0092 /// Implements a k-means cluster algorithm to identify bad seeds
0093 /// to remove from Acts initial vertexing
0094 std::vector<SvtxTrack*> sortTracks();
0095
0096 /// Helper functions for the k-means cluster algorithm
0097 CentroidMap createCentroidMap(std::vector<Acts::Vector3D>& centroids);
0098
0099 std::vector<SvtxTrack*> getIVFTracks(CentroidMap& clusters,
0100 std::vector<Acts::Vector3D>& centroids);
0101
0102 /// Number of centroids for k-means clustering algorithm
0103 int m_nCentroids = 5;
0104 /// Number of times to iterate for clusters to converge
0105 int m_nIterations = 15;
0106 /// Max number of vertices allowed by the Acts IVF
0107 int m_maxVertices = 5;
0108 /// Maximum centroid transverse PCA cut
0109 float m_pcaCut = 0.03; // cm
0110 /// Event num
0111 int m_event = 0;
0112 /// Diagnostic vertex numbers
0113 unsigned int m_totVertexFits = 0;
0114 unsigned int m_successFits = 0;
0115
0116 unsigned int m_seed = 0;
0117 std::mt19937 m_random_number_generator;
0118
0119 std::string m_svtxTrackMapName = "SvtxSiliconTrackMap";
0120 std::string m_svtxVertexMapName = "SvtxVertexMap";
0121 std::string m_magField = "";
0122 bool m_resetTrackCovariance = true;
0123 bool m_disableWeights = true;
0124 bool m_removeSeeds = false;
0125
0126 SvtxTrackMap *m_trackMap = nullptr;
0127 SvtxVertexMap *m_vertexMap = nullptr;
0128 ActsTrackingGeometry *m_tGeometry = nullptr;
0129
0130 };
0131
0132
0133 #endif