Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:18:25

0001 #ifndef G4EVAL_CALOEVALUATOR_H
0002 #define G4EVAL_CALOEVALUATOR_H
0003 
0004 //===============================================
0005 /// \file CaloEvaluator.h
0006 /// \brief Compares reconstructed tracks to truth particles
0007 /// \author Michael P. McCumber (revised sPHENIX version)
0008 //===============================================
0009 
0010 #include <fun4all/SubsysReco.h>
0011 
0012 #include <set>
0013 #include <string>
0014 
0015 class CaloEvalStack;
0016 class PHCompositeNode;
0017 class TFile;
0018 class TNtuple;
0019 class TTree;  // Added by Barak
0020 
0021 /// \class CaloEvaluator
0022 ///
0023 /// \brief Compares reconstructed showers to truth particles
0024 ///
0025 /// Plan: This module will trace the reconstructed clusters back to
0026 /// the greatest contributor Monte Carlo particle and then
0027 /// test one against the other.
0028 ///
0029 class CaloEvaluator : public SubsysReco
0030 {
0031  public:
0032   CaloEvaluator(const std::string &name = "CALOEVALUATOR",
0033                 const std::string &caloname = "CEMC",
0034                 const std::string &filename = "g4eval_cemc.root");
0035   ~CaloEvaluator() override{};
0036 
0037   int Init(PHCompositeNode *topNode) override;
0038   int process_event(PHCompositeNode *topNode) override;
0039   int End(PHCompositeNode *topNode) override;
0040 
0041   // allow user to set the value of the event number
0042   // useful for condor simulation submissions
0043   // must be called after Init()
0044   void set_event(int ievent)
0045   {
0046     _ievent = ievent;
0047   }
0048 
0049   void set_strict(bool b) { _strict = b; }
0050   // funtions to limit the tracing to only part of the event ---------
0051   // and speed up the evaluation
0052 
0053   // when tracing truth showers limit the trace to showers
0054   // that result from truth particles with a particular embed flag set
0055   // useful if you only want to know about that electron you
0056   // embedded into a central hijing event
0057   // (evaluation for truth objects with matching embed flag set unaffected)
0058   void add_truth_tracing_embed_flag(int flag)
0059   {
0060     _truth_trace_embed_flags.insert(flag);
0061   }
0062 
0063   // limit the tracing of truth particles to those above some
0064   // theshold energy. useful for tracing only high energy particles
0065   // and ignoring low energy truth particles from a hijing event
0066   // (evaluation for objects above threshold unaffected)
0067   void set_truth_tracing_energy_threshold(float thresh)
0068   {
0069     _truth_e_threshold = thresh;
0070   }
0071 
0072   // limit the tracing of towers and clusters back to the truth particles
0073   // to only those reconstructed objects above a particular energy
0074   // threshold (evaluation for objects above threshold unaffected)
0075   void set_reco_tracing_energy_threshold(float thresh)
0076   {
0077     _reco_e_threshold = thresh;
0078   }
0079 
0080   // functions to limit the output size ------------------
0081   // will no evaluate or write out these particular ntuples
0082   // mostly intended for size savings, but some time savings will result
0083   void set_do_gpoint_eval(bool b) { _do_gpoint_eval = b; }
0084   void set_do_gshower_eval(bool b) { _do_gshower_eval = b; }
0085   void set_do_tower_eval(bool b) { _do_tower_eval = b; }
0086   void set_do_cluster_eval(bool b) { _do_cluster_eval = b; }
0087   void set_use_towerinfo(bool b) { _use_towerinfo = b; }
0088 
0089  private:
0090   // subroutines
0091   void printInputInfo(PHCompositeNode *topNode);     ///< print out the input object information (debugging upstream components)
0092   void fillOutputNtuples(PHCompositeNode *topNode);  ///< dump the evaluator information into ntuple for external analysis
0093   void printOutputInfo(PHCompositeNode *topNode);    ///< print out the ancestry information for detailed diagnosis
0094 
0095   CaloEvalStack *_caloevalstack = nullptr;
0096   TFile *_tfile = nullptr;
0097   TNtuple *_ntp_cluster = nullptr;
0098   TNtuple *_ntp_gpoint = nullptr;
0099   TNtuple *_ntp_gshower = nullptr;
0100   TNtuple *_ntp_tower = nullptr;
0101   TTree *_tower_debug = nullptr;  // Added by Barak
0102 
0103   unsigned int _ievent = 0;
0104   unsigned int _towerID_debug = 0;
0105   unsigned int m_EvtCounter = 0;
0106 
0107   int _ieta_debug = 0;
0108   int _iphi_debug = 0;
0109 
0110   float _eta_debug = 0.;
0111   float _phi_debug = 0.;
0112   float _e_debug = 0.;
0113   float _x_debug = 0.;
0114   float _y_debug = 0.;
0115   float _z_debug = 0.;
0116   float _truth_e_threshold = 0.;
0117   float _reco_e_threshold = 0.;
0118 
0119   bool _do_cluster_eval = true;
0120   bool _do_gpoint_eval = true;
0121   bool _do_gshower_eval = true;
0122   bool _do_tower_eval = true;
0123   bool _use_towerinfo = false;
0124   bool _strict = false;
0125 
0126   std::string _caloname;
0127   std::string _filename;
0128   std::set<int> _truth_trace_embed_flags;
0129 };
0130 
0131 #endif  // G4EVAL_CALOEVALUATOR_H