Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:06

0001 #ifndef G4EVAL_CALOTRUTHEVAL_H
0002 #define G4EVAL_CALOTRUTHEVAL_H
0003 
0004 #include "BaseTruthEval.h"
0005 
0006 #include <map>
0007 #include <set>
0008 #include <string>
0009 
0010 class PHCompositeNode;
0011 
0012 class PHG4Hit;
0013 class PHG4HitContainer;
0014 class PHG4Particle;
0015 class PHG4TruthInfoContainer;
0016 class PHG4Shower;
0017 class PHG4VtxPoint;
0018 
0019 class CaloTruthEval
0020 {
0021  public:
0022   /// example caloname: CEMC, HCALIN, HCALOUT
0023   CaloTruthEval(PHCompositeNode* topNode, const std::string& caloname);
0024   virtual ~CaloTruthEval();
0025 
0026   /// get the hash id for this calorimeter volume
0027   int get_caloid() { return _caloid; }
0028 
0029   /// reinitialize the eval for a new event
0030   void next_event(PHCompositeNode* topNode);
0031 
0032   /// activate or deactivate the memory caching inside the evaluation module
0033   void do_caching(bool do_cache) { _do_cache = do_cache; }
0034 
0035   /// strict mode will assert when an error is detected
0036   /// non-strict mode will notice and report at the End()
0037   void set_strict(bool strict)
0038   {
0039     _strict = strict;
0040     _basetrutheval.set_strict(strict);
0041   }
0042 
0043   /// get a count of the errors discovered thus far
0044   unsigned int get_errors() { return _errors; }
0045 
0046   /// adjust the messaging from the evalutaion module
0047   void set_verbosity(int verbosity)
0048   {
0049     _verbosity = verbosity;
0050     _basetrutheval.set_verbosity(verbosity);
0051   }
0052 
0053   // ---reduced sim node or better----------------------------------------------
0054 
0055   /// has the eval initialized correctly for reduced sim DST nodes?
0056   bool has_reduced_node_pointers();
0057 
0058   /// what was the primary shower associated with the shower object?
0059   PHG4Shower* get_primary_shower(PHG4Shower* shower);
0060 
0061   /// what was the primary shower associated with the shower object?
0062   PHG4Shower* get_primary_shower(PHG4Particle* particle);
0063 
0064   /// what was the primary particle associated with the shower object?
0065   PHG4Particle* get_primary_particle(PHG4Shower* shower);
0066 
0067   /// what was the primary particle associated with another or same particle?
0068   PHG4Particle* get_primary_particle(PHG4Particle* particle);
0069 
0070   /// what was the embed flag passed with this particle?
0071   int get_embed(PHG4Particle* particle);
0072 
0073   /// what was particle's creation point?
0074   PHG4VtxPoint* get_vertex(PHG4Particle* particle);
0075 
0076   /// are these two pointers in fact the same shower?
0077   bool are_same_shower(PHG4Shower* s1, PHG4Shower* s2);
0078 
0079   /// are these two pointers in fact the same particle?
0080   bool are_same_particle(PHG4Particle* p1, PHG4Particle* p2);
0081 
0082   /// are these two pointers in fact the same vertex?
0083   bool are_same_vertex(PHG4VtxPoint* vtx1, PHG4VtxPoint* vtx2);
0084 
0085   /// is this a primary shower?
0086   bool is_primary(PHG4Shower* shower);
0087 
0088   /// is this a primary particle?
0089   bool is_primary(PHG4Particle* particle);
0090 
0091   /// how much energy did this primary and its shower deposit in the calo volume?
0092   float get_shower_energy_deposit(PHG4Particle* primary);
0093 
0094   /// what was the electron/hadron radio of energy deposits inside the calo colume?
0095   float get_shower_eh_ratio(PHG4Particle* primary);
0096 
0097   // ---full sim node required--------------------------------------------------
0098 
0099   /// has the eval initialized correctly for full sim DST nodes?
0100   bool has_full_node_pointers();
0101 
0102   /// what truth hits are contained within this shower entry in this calo volume?
0103   std::set<PHG4Hit*> all_truth_hits(PHG4Shower* shower);
0104 
0105   /// what truth hits were left behind by this particle in this calo volume?
0106   std::set<PHG4Hit*> all_truth_hits(PHG4Particle* particle);
0107 
0108   /// what particle created this truth hit?
0109   PHG4Particle* get_parent_particle(PHG4Hit* g4hit);
0110 
0111   /// what primary particle was responsible for this truth hit?
0112   PHG4Particle* get_primary_particle(PHG4Hit* g4hit);
0113 
0114   /// did this particle create this truth hit?
0115   bool is_g4hit_from_particle(PHG4Hit* g4hit, PHG4Particle* particle);
0116 
0117   /// what truth hits are the result of this primary particle and its shower
0118   std::set<PHG4Hit*> get_shower_hits_from_primary(PHG4Particle* primary);
0119 
0120  private:
0121   void get_node_pointers(PHCompositeNode* topNode);
0122 
0123   BaseTruthEval _basetrutheval;
0124 
0125   std::string _caloname;
0126   int _caloid;
0127   PHG4TruthInfoContainer* _truthinfo{nullptr};
0128   PHG4HitContainer* _g4hits{nullptr};
0129   int _g4hit_container_id{-1};
0130 
0131   bool _strict{false};
0132   int _verbosity{1};
0133   unsigned int _errors{0};
0134 
0135   bool _do_cache{true};
0136   std::map<PHG4Particle*, float> _cache_get_shower_energy_deposit;
0137   std::map<PHG4Shower*, std::set<PHG4Hit*> > _cache_all_truth_hits_g4shower;
0138   std::map<PHG4Particle*, std::set<PHG4Hit*> > _cache_all_truth_hits_g4particle;
0139   std::map<PHG4Hit*, PHG4Particle*> _cache_get_primary_particle_g4hit;
0140   std::map<PHG4Particle*, std::set<PHG4Hit*> > _cache_get_shower_hits_from_primary;
0141 };
0142 
0143 #endif  // G4EVAL_CALOTRUTHEVAL_H