Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:13:14

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