Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-10-15 08:21:04

0001 #ifndef G4EVAL_CALORAWCLUSTEREVAL_H
0002 #define G4EVAL_CALORAWCLUSTEREVAL_H
0003 
0004 #include "CaloRawTowerEval.h"
0005 #include "CaloTruthEval.h"
0006 
0007 #include <map>
0008 #include <set>
0009 #include <string>
0010 #include <utility>
0011 
0012 #include <calobase/RawTowerDefs.h>
0013 
0014 class PHCompositeNode;
0015 class PHG4Hit;
0016 class PHG4Particle;
0017 class PHG4Shower;
0018 class RawClusterContainer;
0019 class RawCluster;
0020 class RawTowerContainer;
0021 class TowerInfoContainer;
0022 
0023 class CaloRawClusterEval
0024 {
0025  public:
0026   /// example caloname: CEMC, HCALIN, HCALOUT
0027   CaloRawClusterEval(PHCompositeNode* topNode, const std::string& caloname);
0028   virtual ~CaloRawClusterEval();
0029 
0030   /// get the hash id for this calorimeter volume
0031   int get_caloid() { return get_truth_eval()->get_caloid(); }
0032 
0033   /// reinitialize the eval for a new event
0034   void next_event(PHCompositeNode* topNode);
0035 
0036   /// activate or deactivate the memory caching inside the evaluation module
0037   void do_caching(bool do_cache)
0038   {
0039     _do_cache = do_cache;
0040     _towereval.do_caching(do_cache);
0041   }
0042 
0043   /// strict mode will assert when an error is detected
0044   /// non-strict mode will notice and report at the End()
0045   void set_strict(bool strict)
0046   {
0047     _strict = strict;
0048     _towereval.set_strict(strict);
0049   }
0050 
0051   void set_usetowerinfo(bool use) { _usetowerinfo = use; }
0052 
0053   void set_is_topocluster(bool b)
0054   {
0055     _is_topocluster = b;
0056     do_caching(false);
0057   }
0058 
0059   void set_topocluster_type(const std::string &s) { _topocluster_type = s; }
0060 
0061   /// get a count of the errors discovered thus far
0062   unsigned int get_errors() { return _errors + _towereval.get_errors(); }
0063 
0064   /// adjust the messaging from the evalutaion module
0065   void set_verbosity(int verbosity)
0066   {
0067     _verbosity = verbosity;
0068     _towereval.set_verbosity(verbosity);
0069   }
0070 
0071   /// get a copy of the lower level truth eval and its memory cache
0072   CaloTruthEval* get_truth_eval() { return _towereval.get_truth_eval(); }
0073 
0074   /// get a copy of the lower level tower eval and its memory cache
0075   CaloRawTowerEval* get_rawtower_eval() { return &_towereval; }
0076 
0077   // ---reduced sim node or better----------------------------------------------
0078 
0079   /// has the eval initialized correctly for reduced sim DST nodes?
0080   bool has_reduced_node_pointers();
0081 
0082   // shower interface
0083 
0084   /// what primary showers contributed energy to this cluster?
0085   std::set<PHG4Shower*> all_truth_primary_showers(RawCluster* cluster);
0086 
0087   /// which primary shower contributed the most energy to this cluster?
0088   PHG4Shower* max_truth_primary_shower_by_energy(RawCluster* cluster);
0089 
0090   /// what clusters did this primary truth shower contribute energy to?
0091   std::set<RawCluster*> all_clusters_from(PHG4Shower* primary);
0092 
0093   /// which cluster did this primary truth shower contribute the most energy to?
0094   RawCluster* best_cluster_from(PHG4Shower* primary);
0095 
0096   /// how much energy did this primary truth shower contribute to this cluster
0097   float get_energy_contribution(RawCluster* cluster, PHG4Shower* primary);
0098 
0099   // particle interface
0100 
0101   /// what particles contributed energy to this cluster?
0102   std::set<PHG4Particle*> all_truth_primary_particles(RawCluster* cluster);
0103 
0104   /// which particle contributed the most energy to this cluster?
0105   PHG4Particle* max_truth_primary_particle_by_energy(RawCluster* cluster);
0106 
0107   /// what clusters did this primary truth particle contribute energy to?
0108   std::set<RawCluster*> all_clusters_from(PHG4Particle* primary);
0109 
0110   /// which cluster did this primary truth particle contribute the most energy to?
0111   RawCluster* best_cluster_from(PHG4Particle* primary);
0112 
0113   /// how much energy did this primary truth particle contribute to this cluster
0114   float get_energy_contribution(RawCluster* cluster, PHG4Particle* primary);
0115 
0116   // ---full sim node required--------------------------------------------------
0117 
0118   /// has the eval initialized correctly for full sim DST nodes?
0119   bool has_full_node_pointers();
0120 
0121   /// what truth hits contributed energy to this tower?
0122   std::set<PHG4Hit*> all_truth_hits(RawCluster* cluster);
0123 
0124  private:
0125   void get_node_pointers(PHCompositeNode* topNode);
0126   unsigned int get_towerinfo_key(RawTowerDefs::keytype tower_key);
0127 
0128   std::string _caloname;
0129   CaloRawTowerEval _towereval;
0130   RawClusterContainer* _clusters = nullptr;
0131   RawTowerContainer* _towers = nullptr;
0132   TowerInfoContainer* _towerinfos = nullptr;
0133 
0134   bool _strict = false;
0135   bool _usetowerinfo = false;
0136   bool _is_topocluster = false;
0137   std::string _topocluster_type = "EMCAL_HCAL";
0138   int _verbosity = 1;
0139   unsigned int _errors = 0;
0140 
0141   bool _do_cache = true;
0142   std::map<RawCluster*, std::set<PHG4Shower*> > _cache_all_truth_primary_showers;
0143   std::map<RawCluster*, PHG4Shower*> _cache_max_truth_primary_shower_by_energy;
0144   std::map<PHG4Shower*, std::set<RawCluster*> > _cache_all_clusters_from_primary_shower;
0145   std::map<PHG4Shower*, RawCluster*> _cache_best_cluster_from_primary_shower;
0146   std::map<std::pair<RawCluster*, PHG4Shower*>, float> _cache_get_energy_contribution_primary_shower;
0147 
0148   std::map<RawCluster*, std::set<PHG4Particle*> > _cache_all_truth_primary_particles;
0149   std::map<RawCluster*, PHG4Particle*> _cache_max_truth_primary_particle_by_energy;
0150   std::map<PHG4Particle*, std::set<RawCluster*> > _cache_all_clusters_from_primary_particle;
0151   std::map<PHG4Particle*, RawCluster*> _cache_best_cluster_from_primary_particle;
0152   std::map<std::pair<RawCluster*, PHG4Particle*>, float> _cache_get_energy_contribution_primary_particle;
0153 
0154   std::map<RawCluster*, std::set<PHG4Hit*> > _cache_all_truth_hits;
0155 };
0156 
0157 #endif  // G4EVAL_CALORAWCLUSTEREVAL_H