Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SvtxClusterEval.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SvtxClusterEval.h
1 #ifndef G4EVAL_SVTXCLUSTEREVAL_H
2 #define G4EVAL_SVTXCLUSTEREVAL_H
3 
4 #include "SvtxHitEval.h"
5 
7 #include <trackbase/TrkrDefs.h>
8 
9 #include <map>
10 #include <memory> // for shared_ptr, less
11 #include <set>
12 #include <utility>
13 
14 class PHCompositeNode;
15 
16 class PHG4Hit;
17 class PHG4HitContainer;
18 class PHG4Particle;
20 
21 class TrkrCluster;
24 class TrkrHitTruthAssoc;
26 
27 typedef std::multimap<float, TrkrDefs::cluskey> innerMap;
28 
30 {
31  public:
33  virtual ~SvtxClusterEval();
34 
35  void next_event(PHCompositeNode* topNode);
36  void do_caching(bool do_cache)
37  {
38  _do_cache = do_cache;
39  _hiteval.do_caching(do_cache);
40  }
41  void set_strict(bool strict)
42  {
43  _strict = strict;
44  _hiteval.set_strict(strict);
45  }
47  {
49  _hiteval.set_verbosity(verbosity);
50  }
51 
52  // access the clustereval (and its cached values)
55 
56  // backtrace through to PHG4Hits
57  std::set<PHG4Hit*> all_truth_hits(TrkrDefs::cluskey cluster);
59 
60  // get all truth clusters matching a given layer
61  std::map<TrkrDefs::cluskey, std::shared_ptr<TrkrCluster>> all_truth_clusters(TrkrDefs::cluskey cluster_key);
62 
63  std::pair<TrkrDefs::cluskey, std::shared_ptr<TrkrCluster>> max_truth_cluster_by_energy(TrkrDefs::cluskey cluster_key);
64 
66  std::pair<int, int> gtrackid_and_layer_by_nhit(TrkrDefs::cluskey cluster);
67 
68  // backtrace through to PHG4Particles
69  std::set<PHG4Particle*> all_truth_particles(TrkrDefs::cluskey);
72 
73  // forwardtrace through to SvtxClusters
74  std::set<TrkrDefs::cluskey> all_clusters_from(PHG4Particle* truthparticle);
75  std::set<TrkrDefs::cluskey> all_clusters_from(PHG4Hit* truthhit);
79  // overlap calculations
80  float get_energy_contribution(TrkrDefs::cluskey cluster_key, PHG4Particle* truthparticle);
81  float get_energy_contribution(TrkrDefs::cluskey cluster_key, PHG4Hit* truthhit);
82 
83  std::pair<TrkrDefs::cluskey, TrkrCluster*> reco_cluster_from_truth_cluster(TrkrDefs::cluskey, const std::shared_ptr<TrkrCluster>& gclus);
84 
85  unsigned int get_errors() { return _errors + _hiteval.get_errors(); }
86 
87  private:
88  void get_node_pointers(PHCompositeNode* topNode);
90  // void fill_g4hit_layer_map();
91  bool has_node_pointers();
92 
95  float fast_approx_atan2(float y, float x);
96  float fast_approx_atan2(float y2x);
97 
108 
109  bool _strict = false;
110  int _verbosity = 0;
111  unsigned int _errors = 0;
112 
114 
115  bool _do_cache = true;
116  std::map<TrkrDefs::cluskey, std::set<PHG4Hit*>> _cache_all_truth_hits;
117  std::map<TrkrDefs::cluskey, std::map<TrkrDefs::cluskey, std::shared_ptr<TrkrCluster>>> _cache_all_truth_clusters;
118  std::map<TrkrDefs::cluskey, PHG4Hit*> _cache_max_truth_hit_by_energy;
119  std::map<TrkrDefs::cluskey, std::pair<TrkrDefs::cluskey, std::shared_ptr<TrkrCluster>>> _cache_max_truth_cluster_by_energy;
120  std::map<TrkrDefs::cluskey, std::set<PHG4Particle*>> _cache_all_truth_particles;
121  std::map<TrkrDefs::cluskey, PHG4Particle*> _cache_max_truth_particle_by_energy;
122  std::map<TrkrDefs::cluskey, PHG4Particle*> _cache_max_truth_particle_by_cluster_energy;
123  std::map<PHG4Particle*, std::set<TrkrDefs::cluskey>> _cache_all_clusters_from_particle;
124  std::map<PHG4Hit*, std::set<TrkrDefs::cluskey>> _cache_all_clusters_from_g4hit;
125  std::map<PHG4Hit*, TrkrDefs::cluskey> _cache_best_cluster_from_g4hit;
127  std::map<std::pair<TrkrDefs::cluskey, PHG4Particle*>, float> _cache_get_energy_contribution_g4particle;
128  std::map<std::pair<TrkrDefs::cluskey, PHG4Hit*>, float> _cache_get_energy_contribution_g4hit;
129  std::map<std::shared_ptr<TrkrCluster>, std::pair<TrkrDefs::cluskey, TrkrCluster*>> _cache_reco_cluster_from_truth_cluster;
130 
131  // measured for low occupancy events, all in cm
132  const float sig_tpc_rphi_inner = 220e-04;
133  const float sig_tpc_rphi_mid = 155e-04;
134  const float sig_tpc_rphi_outer = 165e-04;
135  const float sig_tpc_z = 750e-04;
136  const float sig_intt_rphi = 17e-04;
137  const float range_intt_z = 0.9;
138  const float sig_mvtx_rphi = 4.0e-04;
139  const float sig_mvtx_z = 4.7e-04;
140  const float sig_mms_rphi_55 = 100e-04;
141  const float sig_mms_z_56 = 200e-04;
142 
144  static constexpr float _clusters_searching_window = 0.1f;
145  std::multimap<unsigned int, innerMap> _clusters_per_layer;
146  // std::multimap<unsigned int, PHG4Hit*> _g4hits_per_layer;
147 };
148 
149 #endif // G4EVAL_SVTXCLUSTEREVAL_H