Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef G4EVAL_JETTRUTHEVAL_H
0002 #define G4EVAL_JETTRUTHEVAL_H
0003 
0004 #include "CaloEvalStack.h"
0005 #include "SvtxEvalStack.h"
0006 
0007 #include <map>
0008 #include <set>
0009 #include <string>
0010 
0011 class Jet;
0012 class JetContainer;
0013 
0014 class PHCompositeNode;
0015 
0016 class PHG4Hit;
0017 class PHG4Particle;
0018 class PHG4Shower;
0019 class PHG4TruthInfoContainer;
0020 
0021 class JetTruthEval
0022 {
0023  public:
0024   /// example truthjetname: AntiKt_Truth_r03
0025   JetTruthEval(PHCompositeNode* topNode,
0026                const std::string& truthjetname);
0027   virtual ~JetTruthEval();
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)
0034   {
0035     _do_cache = do_cache;
0036     _svtxevalstack.do_caching(do_cache);
0037     _cemcevalstack.do_caching(do_cache);
0038     _hcalinevalstack.do_caching(do_cache);
0039     _hcaloutevalstack.do_caching(do_cache);
0040     _femcevalstack.do_caching(do_cache);
0041     _fhcalevalstack.do_caching(do_cache);
0042     _eemcevalstack.do_caching(do_cache);
0043   }
0044 
0045   /// strict mode will assert when an error is detected
0046   /// non-strict mode will notice and report at the End()
0047   void set_strict(bool strict)
0048   {
0049     _strict = strict;
0050     _svtxevalstack.set_strict(strict);
0051     _cemcevalstack.set_strict(strict);
0052     _hcalinevalstack.set_strict(strict);
0053     _hcaloutevalstack.set_strict(strict);
0054     _femcevalstack.set_strict(strict);
0055     _fhcalevalstack.set_strict(strict);
0056     _eemcevalstack.set_strict(strict);
0057   }
0058 
0059   /// get a count of the errors discovered thus far
0060   unsigned int get_errors()
0061   {
0062     return _errors + _svtxevalstack.get_errors() + _cemcevalstack.get_errors() + _hcalinevalstack.get_errors() + _hcaloutevalstack.get_errors() + _femcevalstack.get_errors() + _fhcalevalstack.get_errors() + _eemcevalstack.get_errors();
0063   }
0064 
0065   /// adjust the messaging from the evalutaion module
0066   void set_verbosity(int verbosity)
0067   {
0068     _verbosity = verbosity;
0069     _svtxevalstack.set_verbosity(verbosity);
0070     _cemcevalstack.set_verbosity(verbosity);
0071     _hcalinevalstack.set_verbosity(verbosity);
0072     _hcaloutevalstack.set_verbosity(verbosity);
0073     _femcevalstack.set_verbosity(verbosity);
0074     _fhcalevalstack.set_verbosity(verbosity);
0075     _eemcevalstack.set_verbosity(verbosity);
0076   }
0077 
0078   // set track node name
0079   void set_track_nodename(const std::string& name)
0080   {
0081     _svtxevalstack.set_track_nodename(name);
0082   }
0083 
0084   /// get a copy of the lower level eval and its memory cache
0085   SvtxEvalStack* get_svtx_eval_stack() { return &_svtxevalstack; }
0086 
0087   /// get a copy of the lower level eval and its memory cache
0088   CaloEvalStack* get_cemc_eval_stack() { return &_cemcevalstack; }
0089 
0090   /// get a copy of the lower level eval and its memory cache
0091   CaloEvalStack* get_hcalin_eval_stack() { return &_hcalinevalstack; }
0092 
0093   /// get a copy of the lower level eval and its memory cache
0094   CaloEvalStack* get_hcalout_eval_stack() { return &_hcaloutevalstack; }
0095 
0096   /// get a copy of the lower level eval and its memory cache
0097   CaloEvalStack* get_femc_eval_stack() { return &_femcevalstack; }
0098 
0099   /// get a copy of the lower level eval and its memory cache
0100   CaloEvalStack* get_fhcal_eval_stack() { return &_fhcalevalstack; }
0101 
0102   /// get a copy of the lower level eval and its memory cache
0103   CaloEvalStack* get_eemc_eval_stack() { return &_eemcevalstack; }
0104 
0105   // ---reduced sim node or better----------------------------------------------
0106 
0107   /// which truth jet in the specified node contains this truth particle?
0108   Jet* get_truth_jet(PHG4Particle* truthparticle);
0109 
0110   /// which truth particle contributed to this truth jet?
0111   std::set<PHG4Particle*> all_truth_particles(Jet* truthjet);
0112 
0113   /// which showers were left by particles contributing to this truth jet?
0114   std::set<PHG4Shower*> all_truth_showers(Jet* truthjet);
0115 
0116   // ---full sim node required--------------------------------------------------
0117 
0118   /// which truth hits were left by particles contributing to this truth jet?
0119   std::set<PHG4Hit*> all_truth_hits(Jet* truthjet);
0120 
0121  private:
0122   void get_node_pointers(PHCompositeNode* topNode);
0123 
0124   std::string _truthjetname;
0125   SvtxEvalStack _svtxevalstack;
0126   CaloEvalStack _cemcevalstack;
0127   CaloEvalStack _hcalinevalstack;
0128   CaloEvalStack _hcaloutevalstack;
0129   CaloEvalStack _femcevalstack;
0130   CaloEvalStack _fhcalevalstack;
0131   CaloEvalStack _eemcevalstack;
0132 
0133   PHG4TruthInfoContainer* _truthinfo = nullptr;
0134   JetContainer* _truthjets = nullptr;
0135 
0136   bool _strict = false;
0137   int _verbosity = 1;
0138   unsigned int _errors = 0;
0139 
0140   bool _do_cache = true;
0141   std::map<Jet*, std::set<PHG4Particle*> > _cache_all_truth_particles;
0142   std::map<Jet*, std::set<PHG4Shower*> > _cache_all_truth_showers;
0143   std::map<Jet*, std::set<PHG4Hit*> > _cache_all_truth_hits;
0144   std::map<PHG4Particle*, Jet*> _cache_get_truth_jet;
0145 };
0146 
0147 #endif  // JETTRUTHEVAL_H__