Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:45

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   /// get a count of the errors discovered thus far
0054   unsigned int get_errors() { return _errors + _towereval.get_errors(); }
0055 
0056   /// adjust the messaging from the evalutaion module
0057   void set_verbosity(int verbosity)
0058   {
0059     _verbosity = verbosity;
0060     _towereval.set_verbosity(verbosity);
0061   }
0062 
0063   /// get a copy of the lower level truth eval and its memory cache
0064   CaloTruthEval* get_truth_eval() { return _towereval.get_truth_eval(); }
0065 
0066   /// get a copy of the lower level tower eval and its memory cache
0067   CaloRawTowerEval* get_rawtower_eval() { return &_towereval; }
0068 
0069   // ---reduced sim node or better----------------------------------------------
0070 
0071   /// has the eval initialized correctly for reduced sim DST nodes?
0072   bool has_reduced_node_pointers();
0073 
0074   // shower interface
0075 
0076   /// what primary showers contributed energy to this cluster?
0077   std::set<PHG4Shower*> all_truth_primary_showers(RawCluster* cluster);
0078 
0079   /// which primary shower contributed the most energy to this cluster?
0080   PHG4Shower* max_truth_primary_shower_by_energy(RawCluster* cluster);
0081 
0082   /// what clusters did this primary truth shower contribute energy to?
0083   std::set<RawCluster*> all_clusters_from(PHG4Shower* primary);
0084 
0085   /// which cluster did this primary truth shower contribute the most energy to?
0086   RawCluster* best_cluster_from(PHG4Shower* primary);
0087 
0088   /// how much energy did this primary truth shower contribute to this cluster
0089   float get_energy_contribution(RawCluster* cluster, PHG4Shower* primary);
0090 
0091   // particle interface
0092 
0093   /// what particles contributed energy to this cluster?
0094   std::set<PHG4Particle*> all_truth_primary_particles(RawCluster* cluster);
0095 
0096   /// which particle contributed the most energy to this cluster?
0097   PHG4Particle* max_truth_primary_particle_by_energy(RawCluster* cluster);
0098 
0099   /// what clusters did this primary truth particle contribute energy to?
0100   std::set<RawCluster*> all_clusters_from(PHG4Particle* primary);
0101 
0102   /// which cluster did this primary truth particle contribute the most energy to?
0103   RawCluster* best_cluster_from(PHG4Particle* primary);
0104 
0105   /// how much energy did this primary truth particle contribute to this cluster
0106   float get_energy_contribution(RawCluster* cluster, PHG4Particle* primary);
0107 
0108   // ---full sim node required--------------------------------------------------
0109 
0110   /// has the eval initialized correctly for full sim DST nodes?
0111   bool has_full_node_pointers();
0112 
0113   /// what truth hits contributed energy to this tower?
0114   std::set<PHG4Hit*> all_truth_hits(RawCluster* cluster);
0115 
0116  private:
0117   void get_node_pointers(PHCompositeNode* topNode);
0118   unsigned int get_towerinfo_key(RawTowerDefs::keytype tower_key);
0119 
0120   std::string _caloname;
0121   CaloRawTowerEval _towereval;
0122   RawClusterContainer* _clusters = nullptr;
0123   RawTowerContainer* _towers = nullptr;
0124   TowerInfoContainer* _towerinfos = nullptr;
0125 
0126   bool _strict = false;
0127   bool _usetowerinfo = false;
0128   int _verbosity = 1;
0129   unsigned int _errors = 0;
0130 
0131   bool _do_cache = true;
0132   std::map<RawCluster*, std::set<PHG4Shower*> > _cache_all_truth_primary_showers;
0133   std::map<RawCluster*, PHG4Shower*> _cache_max_truth_primary_shower_by_energy;
0134   std::map<PHG4Shower*, std::set<RawCluster*> > _cache_all_clusters_from_primary_shower;
0135   std::map<PHG4Shower*, RawCluster*> _cache_best_cluster_from_primary_shower;
0136   std::map<std::pair<RawCluster*, PHG4Shower*>, float> _cache_get_energy_contribution_primary_shower;
0137 
0138   std::map<RawCluster*, std::set<PHG4Particle*> > _cache_all_truth_primary_particles;
0139   std::map<RawCluster*, PHG4Particle*> _cache_max_truth_primary_particle_by_energy;
0140   std::map<PHG4Particle*, std::set<RawCluster*> > _cache_all_clusters_from_primary_particle;
0141   std::map<PHG4Particle*, RawCluster*> _cache_best_cluster_from_primary_particle;
0142   std::map<std::pair<RawCluster*, PHG4Particle*>, float> _cache_get_energy_contribution_primary_particle;
0143 
0144   std::map<RawCluster*, std::set<PHG4Hit*> > _cache_all_truth_hits;
0145 };
0146 
0147 #endif  // G4EVAL_CALORAWCLUSTEREVAL_H