Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:17:58

0001 // $Id: PHG4DSTReader.h,v 1.7 2015/02/27 23:42:23 jinhuang Exp $
0002 
0003 /*!
0004  * \file PHG4DSTReader.h
0005  * \brief
0006  * \author Jin Huang <jhuang@bnl.gov>
0007  * \version $Revision: 1.7 $
0008  * \date $Date: 2015/02/27 23:42:23 $
0009  */
0010 #ifndef G4EVAL_PHG4DSTREADER_H
0011 #define G4EVAL_PHG4DSTREADER_H
0012 
0013 #include <fun4all/SubsysReco.h>
0014 
0015 #include <boost/smart_ptr.hpp>
0016 
0017 #include <set>
0018 #include <string>
0019 #include <vector>
0020 
0021 class PHCompositeNode;
0022 
0023 class PHG4Particle;
0024 
0025 class TClonesArray;
0026 class TTree;
0027 
0028 /*!
0029  * \brief PHG4DSTReader save information from DST to an evaluator, which could include hit. particle, vertex, towers and jet (to be activated)
0030  */
0031 
0032 class PHG4DSTReader : public SubsysReco
0033 {
0034  public:
0035   PHG4DSTReader(const std::string &filename);
0036   ~PHG4DSTReader() override;
0037 
0038   //! full initialization
0039   int Init(PHCompositeNode *) override;
0040 
0041   //! event processing method
0042   int process_event(PHCompositeNode *) override;
0043 
0044   //! end of run method
0045   int End(PHCompositeNode *) override;
0046 
0047   void
0048   AddNode(const std::string &name)
0049   {
0050     _node_postfix.push_back(name);
0051   }
0052 
0053   void
0054   AddHit(const std::string &name)
0055   {
0056     _node_postfix.push_back(name);
0057   }
0058 
0059   void
0060   AddTower(const std::string &name)
0061   {
0062     _tower_postfix.push_back(name);
0063   }
0064 
0065   void
0066   AddJet(const std::string &name)
0067   {
0068     _jet_postfix.push_back(name);
0069   }
0070 
0071   //! load all particle in truth info module?
0072   //! size could be very large, e.g. showers
0073   void
0074   set_load_all_particle(bool b)
0075   {
0076     _load_all_particle = b;
0077   }
0078 
0079   //! load all particle that produced a saved hit
0080   void
0081   set_load_active_particle(bool b)
0082   {
0083     _load_active_particle = b;
0084   }
0085 
0086   //! Switch for saving any particles at all
0087   void
0088   set_save_particle(bool b)
0089   {
0090     _save_particle = b;
0091   }
0092 
0093   //! Switch for vertex
0094   void
0095   set_save_vertex(bool b)
0096   {
0097     _save_vertex = b;
0098   }
0099 
0100   //! zero suppression for all calorimeters
0101   double
0102   get_tower_zero_sup()
0103   {
0104     return _save_particle;
0105   }
0106 
0107   //! zero suppression for all calorimeters
0108   void
0109   set_tower_zero_sup(double b)
0110   {
0111     _tower_zero_sup = b;
0112   }
0113 
0114  protected:
0115   std::vector<std::string> _node_postfix;
0116   std::vector<std::string> _tower_postfix;
0117   std::vector<std::string> _jet_postfix;
0118   //  std::vector<std::string> _node_name;
0119   int nblocks = 0;
0120 
0121   typedef boost::shared_ptr<TClonesArray> arr_ptr;
0122 
0123   struct record
0124   {
0125     unsigned int _cnt;
0126     std::string _name;
0127     arr_ptr _arr;
0128     TClonesArray *_arr_ptr;
0129 
0130     enum enu_type
0131     {
0132       typ_hit,
0133       typ_part,
0134       typ_vertex,
0135       typ_tower,
0136       typ_jets
0137     };
0138     enu_type _type;
0139   };
0140   typedef std::vector<record> records_t;
0141   records_t _records;
0142 
0143   int _event = 0;
0144 
0145   std::string _out_file_name;
0146 
0147   //  TFile * _file;
0148   TTree *_T = nullptr;
0149 
0150   //! master switch to save particles
0151   bool _save_particle = true;
0152 
0153   //! load all particle in truth info module?
0154   bool _load_all_particle = true;
0155 
0156   //! load all particle that produced a saved hit
0157   bool _load_active_particle = true;
0158 
0159   typedef std::set<int> PartSet_t;
0160   PartSet_t _particle_set;
0161   PartSet_t _vertex_set;
0162 
0163   //! save vertex for particles?
0164   bool _save_vertex = true;
0165 
0166   //! zero suppression for all calorimeters
0167   double _tower_zero_sup = 0.;
0168 
0169   //! add a particle and associated vertex if _save_vertex
0170   void
0171   add_particle(record &rec, PHG4Particle *part);
0172 
0173   void
0174   build_tree();
0175 };
0176 
0177 #endif /* G4EVAL_PHG4DSTREADER_H */