Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef G4EVAL_JETRECOEVAL_H
0002 #define G4EVAL_JETRECOEVAL_H
0003 
0004 #include "JetTruthEval.h"
0005 
0006 #include <jetbase/Jet.h>
0007 
0008 #include <map>
0009 #include <set>
0010 #include <string>
0011 #include <utility>
0012 
0013 class CaloEvalStack;
0014 
0015 class JetContainer;
0016 
0017 class PHCompositeNode;
0018 
0019 class PHG4Hit;
0020 class PHG4Particle;
0021 class PHG4Shower;
0022 
0023 class RawClusterContainer;
0024 class RawTowerContainer;
0025 
0026 class SvtxEvalStack;
0027 class SvtxTrackMap;
0028 
0029 class JetRecoEval
0030 {
0031  public:
0032   /// example recojetname:  AntiKt_Tower_r03
0033   /// example truthjetname: AntiKt_Truth_r03
0034   JetRecoEval(PHCompositeNode* topNode,
0035               const std::string& recojetname,
0036               const std::string& truthjetname);
0037   virtual ~JetRecoEval();
0038 
0039   /// reinitialize the eval for a new event
0040   void next_event(PHCompositeNode* topNode);
0041 
0042   /// activate or deactivate the memory caching inside the evaluation module
0043   void do_caching(bool do_cache)
0044   {
0045     _do_cache = do_cache;
0046     _jettrutheval.do_caching(do_cache);
0047   }
0048 
0049   /// strict mode will assert when an error is detected
0050   /// non-strict mode will notice and report at the End()
0051   void set_strict(bool strict)
0052   {
0053     _strict = strict;
0054     _jettrutheval.set_strict(strict);
0055   }
0056 
0057   /// get a count of the errors discovered thus far
0058   unsigned int get_errors() { return _errors + _jettrutheval.get_errors(); }
0059 
0060   /// adjust the messaging from the evalutaion module
0061   void set_verbosity(int verbosity)
0062   {
0063     _verbosity = verbosity;
0064     _jettrutheval.set_verbosity(verbosity);
0065   }
0066 
0067   /// get a copy of the lower level eval and its memory cache
0068   JetTruthEval* get_truth_eval() { return &_jettrutheval; }
0069 
0070   /// get a copy of the lower level eval and its memory cache
0071   SvtxEvalStack* get_svtx_eval_stack() { return _jettrutheval.get_svtx_eval_stack(); }
0072 
0073   /// get a copy of the lower level eval and its memory cache
0074   CaloEvalStack* get_cemc_eval_stack() { return _jettrutheval.get_cemc_eval_stack(); }
0075 
0076   /// get a copy of the lower level eval and its memory cache
0077   CaloEvalStack* get_hcalin_eval_stack() { return _jettrutheval.get_hcalin_eval_stack(); }
0078 
0079   /// get a copy of the lower level eval and its memory cache
0080   CaloEvalStack* get_hcalout_eval_stack() { return _jettrutheval.get_hcalout_eval_stack(); }
0081 
0082   /// get a copy of the lower level eval and its memory cache
0083   CaloEvalStack* get_femc_eval_stack() { return _jettrutheval.get_femc_eval_stack(); }
0084 
0085   /// get a copy of the lower level eval and its memory cache
0086   CaloEvalStack* get_fhcal_eval_stack() { return _jettrutheval.get_fhcal_eval_stack(); }
0087 
0088   /// get a copy of the lower level eval and its memory cache
0089   CaloEvalStack* get_eemc_eval_stack() { return _jettrutheval.get_eemc_eval_stack(); }
0090   // ---reduced sim node or better----------------------------------------------
0091 
0092   /// what truth showers contributed to this reconstructed jet?
0093   std::set<PHG4Shower*> all_truth_showers(Jet* recojet);
0094 
0095   /// what truth particles contributed to this reconstructed jet?
0096   std::set<PHG4Particle*> all_truth_particles(Jet* recojet);
0097 
0098   /// what truth jets contributed to this reconstructed jet?
0099   std::set<Jet*> all_truth_jets(Jet* recojet);
0100 
0101   /// which truth jet contributed the most energy to this reconstructed jet?
0102   Jet* max_truth_jet_by_energy(Jet* recojet);
0103 
0104   /// what reconstructed jets had contributions from this truth jet?
0105   std::set<Jet*> all_jets_from(Jet* truthjet);
0106 
0107   /// which reconstructed jet had the largest energy contribution from this truth jet?
0108   Jet* best_jet_from(Jet* truthjet);
0109 
0110   /// which reconstructed jet had the largest energy contribution from this truth jet in a unique match?
0111   /// @return pointer to reco jet. And NULL if no unique match
0112   Jet* unique_reco_jet_from_truth(Jet* truthjet);
0113 
0114   /// which truth jet had the largest energy contribution from this reco jet in a unique match?
0115   /// @return pointer to truth jet. And NULL if no unique match
0116   Jet* unique_truth_jet_from_reco(Jet* recojet);
0117 
0118   /// what was the energy contribution to this reconstructed jet from this truth jet?
0119   float get_energy_contribution(Jet* recojet, Jet* truthjet);
0120 
0121   /// what was the energy contribution to this reconstructed jet from a particular source
0122   float get_energy_contribution(Jet* recojet, Jet::SRC src);
0123 
0124   void set_track_nodename(const std::string& name);
0125 
0126   // ---full sim node required--------------------------------------------------
0127 
0128   /// which truth hits contributed to this reconstructed jet?
0129   std::set<PHG4Hit*> all_truth_hits(Jet* recojet);
0130 
0131  private:
0132   void get_node_pointers(PHCompositeNode* topNode);
0133 
0134   JetTruthEval _jettrutheval;
0135   std::string _recojetname;
0136   std::string _truthjetname;
0137 
0138   JetContainer* _recojets = nullptr;
0139   JetContainer* _truthjets = nullptr;
0140 
0141   SvtxTrackMap* _trackmap = nullptr;
0142   RawTowerContainer* _cemctowers = nullptr;
0143   RawClusterContainer* _cemcclusters = nullptr;
0144   RawTowerContainer* _hcalintowers = nullptr;
0145   RawClusterContainer* _hcalinclusters = nullptr;
0146   RawTowerContainer* _hcalouttowers = nullptr;
0147   RawClusterContainer* _hcaloutclusters = nullptr;
0148   RawTowerContainer* _femctowers = nullptr;
0149   RawClusterContainer* _femcclusters = nullptr;
0150   RawTowerContainer* _fhcaltowers = nullptr;
0151   RawClusterContainer* _fhcalclusters = nullptr;
0152   RawTowerContainer* _eemctowers = nullptr;
0153   RawClusterContainer* _eemcclusters = nullptr;
0154 
0155   bool _strict = false;
0156   int _verbosity = 1;
0157   unsigned int _errors = 0;
0158 
0159   bool _do_cache = true;
0160   std::map<Jet*, std::set<PHG4Shower*> > _cache_all_truth_showers;
0161   std::map<Jet*, std::set<PHG4Particle*> > _cache_all_truth_particles;
0162   std::map<Jet*, std::set<Jet*> > _cache_all_truth_jets;
0163   std::map<Jet*, Jet*> _cache_max_truth_jet_by_energy;
0164   std::map<Jet*, std::set<Jet*> > _cache_all_jets_from;
0165   std::map<Jet*, Jet*> _cache_best_jet_from;
0166   std::map<std::pair<Jet*, Jet*>, float> _cache_get_energy_contribution;
0167   std::map<std::pair<Jet*, Jet::SRC>, float> _cache_get_energy_contribution_src;  /// used in get_energy_contribution (Jet* recojet, Jet::SRC src);
0168   std::map<Jet*, std::set<PHG4Hit*> > _cache_all_truth_hits;
0169   std::string m_TrackNodeName = "SvtxTrackMap";
0170 };
0171 
0172 #endif  // G4EVAL_JETRECOEVAL_H