Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:01

0001 #ifndef TRACKCLUSEVALUATOR_H
0002 #define TRACKCLUSEVALUATOR_H
0003 // A class that will collect the clusters for SVTX and PHG$ tracks and compare them.
0004 // The actual comparison, cluster to cluster, is from a pointer to a user provided TrkrClusterIsMatcher
0005 #include "TrkrClusLoc.h"
0006 
0007 #include <trackbase/TrkrDefs.h>
0008 
0009 #include <array>
0010 #include <vector>
0011 
0012 class TrkrClusterIsMatcher;
0013 class SvtxTrack;
0014 class TrkrTruthTrack;
0015 class TrkrClusterContainer;
0016 
0017 class TrackClusEvaluator
0018 {
0019  private:
0020   using Vector = std::vector<std::pair<TrkrDefs::hitsetkey, TrkrDefs::cluskey>>;
0021 
0022   using Iter = Vector::iterator;
0023 
0024   /* TrkrClusterComparer*  comp      {nullptr}; // DEPRECATED */
0025 
0026   std::array<int, 5> cntclus(Vector& keys);                                      // nclusters MVTX, INTT, TPC, TPOT, TOTAL
0027   std::array<int, 5> cnt_matchedclus(Vector& keys, std::vector<bool>& matches);  // same but number matched
0028 
0029  public:
0030   TrkrClusterIsMatcher* ismatcher{nullptr};
0031   /* void set_ismatcher(TrkrClusterIsMatcher* _ismatcher) { ismatcher = _ismatcher; }; */
0032   TrackClusEvaluator(TrkrClusterIsMatcher* tcm = nullptr)
0033     : ismatcher{tcm} {};
0034 
0035   TrkrClusterContainer* get_PHG4_clusters();
0036   TrkrClusterContainer* get_SVTX_clusters();
0037 
0038   Vector svtx_keys{};
0039   Vector phg4_keys{};
0040 
0041   bool collect_match_statistic = false;
0042   double match_stat{0};
0043 
0044   void reset();
0045   std::array<int, 3> find_matches();  // populated matches_{svtx,phg4};
0046                                       // return's {n-matched, n-phg4, n-svtx}
0047   std::array<int, 3> find_matches(TrkrTruthTrack* g4_track, SvtxTrack* sv_track);
0048 
0049   int phg4_n_matched();  // also same as phg4_cnt_matchedclus()[4]
0050   int svtx_n_matched();  // should be almost always the same
0051                          // which is ALMOST guaranteed to be same as svtx_cnt_matchedclus()[4]
0052   int phg4_nclus() { return (int) phg4_keys.size(); }
0053   int svtx_nclus() { return (int) svtx_keys.size(); }
0054 
0055   std::vector<bool> svtx_matches;
0056   std::vector<bool> phg4_matches;
0057 
0058   int addClusKeys(SvtxTrack*);       // return number of clusters
0059   int addClusKeys(TrkrTruthTrack*);  // return number of clusters
0060 
0061   std::array<int, 5> svtx_cntclus() { return cntclus(svtx_keys); };  // Mvtx Intt Tpc TPOT Sum
0062   std::array<int, 5> phg4_cntclus() { return cntclus(phg4_keys); };
0063 
0064   std::array<int, 5> svtx_cnt_matchedclus() { return cnt_matchedclus(svtx_keys, svtx_matches); };
0065   std::array<int, 5> phg4_cnt_matchedclus() { return cnt_matchedclus(phg4_keys, phg4_matches); };
0066 
0067   // Convenience functions, asking for cluster locations
0068   std::vector<TrkrClusLoc> phg4_clusloc_all();
0069   std::vector<TrkrClusLoc> phg4_clusloc_unmatched();
0070   std::vector<TrkrClusLoc> svtx_clusloc_all();
0071   std::vector<TrkrClusLoc> svtx_clusloc_unmatched();
0072   std::vector<TrkrClusLoc> clusloc_matched();
0073 };
0074 
0075 #endif