Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:11

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef G4MAIN_PHG4SHOWERV1_H
0004 #define G4MAIN_PHG4SHOWERV1_H
0005 
0006 #include "PHG4Shower.h"
0007 
0008 #include "PHG4HitDefs.h"
0009 
0010 #include <cstddef>  // for size_t
0011 #include <iostream>
0012 #include <map>
0013 #include <set>
0014 
0015 class PHG4Showerv1 : public PHG4Shower
0016 {
0017  public:
0018   PHG4Showerv1();
0019   ~PHG4Showerv1() override {}
0020 
0021   // PHObject virtual overloads
0022 
0023   void identify(std::ostream& os = std::cout) const override;
0024   PHG4Shower* CloneMe() const override { return (new PHG4Showerv1(*this)); }
0025   void Reset() override { *this = PHG4Showerv1(); }
0026   int isValid() const override;
0027 
0028   // shower info
0029 
0030   int get_id() const override { return _id; }
0031   void set_id(int id) override { _id = id; }
0032 
0033   int get_parent_particle_id() const override { return _parent_particle_id; }
0034   void set_parent_particle_id(int parent_particle_id) override { _parent_particle_id = parent_particle_id; }
0035 
0036   int get_parent_shower_id() const override { return _parent_shower_id; }
0037   void set_parent_shower_id(int parent_shower_id) override { _parent_shower_id = parent_shower_id; }
0038 
0039   float get_x() const override { return _pos[0]; }
0040   void set_x(float x) override { _pos[0] = x; }
0041 
0042   float get_y() const override { return _pos[1]; }
0043   void set_y(float y) override { _pos[1] = y; }
0044 
0045   float get_z() const override { return _pos[2]; }
0046   void set_z(float z) override { _pos[2] = z; }
0047 
0048   float get_position(unsigned int coor) const override { return _pos[coor]; }
0049   void set_position(unsigned int coor, float xi) override { _pos[coor] = xi; }
0050 
0051   float get_covar(unsigned int i, unsigned int j) const override;
0052   void set_covar(unsigned int i, unsigned int j, float entry) override;
0053 
0054   unsigned int get_nhits(int volume) const override;
0055   void set_nhits(int volume, unsigned int nhits) override { _nhits[volume] = nhits; }
0056 
0057   double get_edep() const override;
0058   float get_edep(int volume) const override;
0059   void set_edep(int volume, float edep) override { _edep[volume] = edep; }
0060 
0061   double get_eion() const override;
0062   float get_eion(int volume) const override;
0063   void set_eion(int volume, float eion) override { _eion[volume] = eion; }
0064 
0065   float get_light_yield(int volume) const override;
0066   void set_light_yield(int volume, float light_yield) override { _light_yield[volume] = light_yield; }
0067 
0068   float get_eh_ratio(int volume) const override;
0069   void set_eh_ratio(int volume, float eh_ratio) override { _eh_ratio[volume] = eh_ratio; }
0070 
0071   // container methods for ids
0072   bool empty_g4particle_id() const override { return _g4particle_ids.empty(); }
0073   size_t size_g4particle_id() const override { return _g4particle_ids.size(); }
0074   void add_g4particle_id(int id) override { _g4particle_ids.insert(id); }
0075   PHG4Shower::ParticleIdIter begin_g4particle_id() override { return _g4particle_ids.begin(); }
0076   PHG4Shower::ParticleIdConstIter begin_g4particle_id() const override { return _g4particle_ids.begin(); }
0077   PHG4Shower::ParticleIdIter end_g4particle_id() override { return _g4particle_ids.end(); }
0078   PHG4Shower::ParticleIdConstIter end_g4particle_id() const override { return _g4particle_ids.end(); }
0079   size_t remove_g4particle_id(int id) override { return _g4particle_ids.erase(id); }
0080   void clear_g4particle_id() override { return _g4particle_ids.clear(); }
0081   const ParticleIdSet& g4particle_ids() const override { return _g4particle_ids; }
0082 
0083   bool empty_g4vertex_id() const override { return _g4vertex_ids.empty(); }
0084   size_t size_g4vertex_id() const override { return _g4vertex_ids.size(); }
0085   void add_g4vertex_id(int id) override { _g4vertex_ids.insert(id); }
0086   PHG4Shower::VertexIdIter begin_g4vertex_id() override { return _g4vertex_ids.begin(); }
0087   PHG4Shower::VertexIdConstIter begin_g4vertex_id() const override { return _g4vertex_ids.begin(); }
0088   PHG4Shower::VertexIdIter end_g4vertex_id() override { return _g4vertex_ids.end(); }
0089   PHG4Shower::VertexIdConstIter end_g4vertex_id() const override { return _g4vertex_ids.end(); }
0090   size_t remove_g4vertex_id(int id) override { return _g4vertex_ids.erase(id); }
0091   void clear_g4vertex_id() override { return _g4vertex_ids.clear(); }
0092   const VertexIdSet& g4vertex_ids() const override { return _g4vertex_ids; }
0093 
0094   bool empty_g4hit_id() const override { return _g4hit_ids.empty(); }
0095   size_t size_g4hit_id() const override { return _g4hit_ids.size(); }
0096   void add_g4hit_id(int volume, PHG4HitDefs::keytype id) override { _g4hit_ids[volume].insert(id); }
0097   PHG4Shower::HitIdIter begin_g4hit_id() override { return _g4hit_ids.begin(); }
0098   PHG4Shower::HitIdConstIter begin_g4hit_id() const override { return _g4hit_ids.begin(); }
0099   PHG4Shower::HitIdIter find_g4hit_id(int volume) override { return _g4hit_ids.find(volume); }
0100   PHG4Shower::HitIdConstIter find_g4hit_id(int volume) const override { return _g4hit_ids.find(volume); }
0101   PHG4Shower::HitIdIter end_g4hit_id() override { return _g4hit_ids.end(); }
0102   PHG4Shower::HitIdConstIter end_g4hit_id() const override { return _g4hit_ids.end(); }
0103   size_t remove_g4hit_id(int volume, PHG4HitDefs::keytype id) override { return _g4hit_ids[volume].erase(id); }
0104   size_t remove_g4hit_volume(int volume) override { return _g4hit_ids.erase(volume); }
0105   void clear_g4hit_id() override { return _g4hit_ids.clear(); }
0106   const HitIdMap& g4hit_ids() const override { return _g4hit_ids; }
0107 
0108  private:
0109   unsigned int covar_index(unsigned int i, unsigned int j) const;
0110 
0111   int _id;                             //< unique identifier within container
0112   int _parent_particle_id;             //< association of shower to parent particle id
0113   int _parent_shower_id;               //< association of shower to parent shower id
0114   float _pos[3];                       //< mean position of the shower hits
0115   float _covar[6];                     //< covariance of shower hits
0116   std::map<int, unsigned int> _nhits;  //< number of hits in different volumes
0117   std::map<int, float> _edep;          //< energy deposit in different volumes
0118   std::map<int, float> _eion;          //< ionization energy in different volumes
0119   std::map<int, float> _light_yield;   //< light yield in different volumes
0120   std::map<int, float> _eh_ratio;      //< electron/hadron ratio of energy in different volumes
0121 
0122   // these containers are cleared during dst reduction, but are available in full dsts
0123   ParticleIdSet _g4particle_ids;  //< contained secondary particle ids
0124   VertexIdSet _g4vertex_ids;      //< contained secondary vertex ids
0125   HitIdMap _g4hit_ids;            //< contained hit ids
0126 
0127   ClassDefOverride(PHG4Showerv1, 1);
0128 };
0129 
0130 #endif