Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:55

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef G4DETECTORS_PHG4CELLV1_H
0004 #define G4DETECTORS_PHG4CELLV1_H
0005 
0006 #include "PHG4Cell.h"
0007 #include "PHG4CellDefs.h"
0008 
0009 #include <g4main/PHG4HitDefs.h>  // for keytype
0010 
0011 #include <cstdint>
0012 #include <iostream>
0013 #include <map>
0014 #include <type_traits>  // for __decay_and_strip<>::__type
0015 #include <utility>      // for make_pair
0016 
0017 class PHG4Cellv1 : public PHG4Cell
0018 {
0019  public:
0020   PHG4Cellv1() {}
0021   explicit PHG4Cellv1(const PHG4CellDefs::keytype g4cellid);
0022   ~PHG4Cellv1() override;
0023 
0024   void identify(std::ostream& os = std::cout) const override;
0025   void Reset() override;
0026 
0027   void set_cellid(const PHG4CellDefs::keytype i) override { cellid = i; }
0028 
0029   PHG4CellDefs::keytype get_cellid() const override { return cellid; }
0030   bool has_binning(const PHG4CellDefs::CellBinning binning) const override;
0031   short int get_detid() const override;
0032 
0033   using PHG4Cell::add_edep;
0034 
0035   void add_edep(const PHG4HitDefs::keytype g4hitid, const float edep) override;
0036   void add_shower_edep(const int g4showerid, const float edep) override;
0037 
0038   EdepConstRange get_g4hits() override
0039   {
0040     return std::make_pair(hitedeps.begin(), hitedeps.end());
0041   }
0042 
0043   ShowerEdepConstRange get_g4showers() override
0044   {
0045     return std::make_pair(showeredeps.begin(), showeredeps.end());
0046   }
0047 
0048   void add_edep(const float f) override { add_property(prop_edep, f); }
0049   double get_edep() const override { return get_property_float(prop_edep); }
0050 
0051   void add_eion(const float f) override { add_property(prop_eion, f); }
0052   double get_eion() const override { return get_property_float(prop_eion); }
0053 
0054   void add_light_yield(const float f) override { add_property(prop_light_yield, f); }
0055   float get_light_yield() const override { return get_property_float(prop_light_yield); }
0056 
0057   void add_raw_light_yield(const float f) override { add_property(prop_raw_light_yield, f); }
0058   float get_raw_light_yield() const override { return get_property_float(prop_raw_light_yield); }
0059 
0060   void set_chip_index(const int i) override { set_property(prop_chip_index, i); }
0061   int get_chip_index() const override { return get_property_int(prop_chip_index); }
0062 
0063   void set_half_stave_index(const int i) override { set_property(prop_half_stave_index, i); }
0064   int get_half_stave_index() const override { return get_property_int(prop_half_stave_index); }
0065 
0066   void set_ladder_phi_index(const int i) override { set_property(prop_ladder_phi_index, i); }
0067   int get_ladder_phi_index() const override { return get_property_int(prop_ladder_phi_index); }
0068 
0069   void set_ladder_z_index(const int i) override { set_property(prop_ladder_z_index, i); }
0070   int get_ladder_z_index() const override { return get_property_int(prop_ladder_z_index); }
0071 
0072   void set_module_index(const int i) override { set_property(prop_module_index, i); }
0073   int get_module_index() const override { return get_property_int(prop_module_index); }
0074 
0075   void set_phibin(const int i) override { set_property(prop_phibin, i); }
0076   int get_phibin() const override { return get_property_int(prop_phibin); }
0077 
0078   void set_pixel_index(const int i) override { set_property(prop_pixel_index, i); }
0079   int get_pixel_index() const override { return get_property_int(prop_pixel_index); }
0080 
0081   void set_stave_index(const int i) override { set_property(prop_stave_index, i); }
0082   int get_stave_index() const override { return get_property_int(prop_stave_index); }
0083 
0084   void set_zbin(const int i) override { set_property(prop_zbin, i); }
0085   int get_zbin() const override { return get_property_int(prop_zbin); }
0086 
0087   void print() const override;
0088 
0089   bool has_property(const PROPERTY prop_id) const override;
0090   float get_property_float(const PROPERTY prop_id) const override;
0091   int get_property_int(const PROPERTY prop_id) const override;
0092   unsigned int get_property_uint(const PROPERTY prop_id) const override;
0093   void add_property(const PROPERTY prop_id, const float value);
0094   void add_property(const PROPERTY prop_id, const int value);
0095   void add_property(const PROPERTY prop_id, const unsigned int value);
0096   void set_property(const PROPERTY prop_id, const float value) override;
0097   void set_property(const PROPERTY prop_id, const int value) override;
0098   void set_property(const PROPERTY prop_id, const unsigned int value) override;
0099 
0100  protected:
0101   unsigned int get_property_nocheck(const PROPERTY prop_id) const override;
0102   void set_property_nocheck(const PROPERTY prop_id, const unsigned int ui) override { prop_map[prop_id] = ui; }
0103 
0104   PHG4CellDefs::keytype cellid = ~0x0;
0105   EdepMap hitedeps;
0106   ShowerEdepMap showeredeps;
0107 
0108   //! storage types for additional property
0109   typedef uint8_t prop_id_t;
0110   typedef uint32_t prop_storage_t;
0111   typedef std::map<prop_id_t, prop_storage_t> prop_map_t;
0112 
0113   //! convert between 32bit inputs and storage type prop_storage_t
0114   union u_property
0115   {
0116     float fdata;
0117     int32_t idata;
0118     uint32_t uidata;
0119 
0120     u_property(int32_t in)
0121       : idata(in)
0122     {
0123     }
0124     u_property(uint32_t in)
0125       : uidata(in)
0126     {
0127     }
0128     u_property(float in)
0129       : fdata(in)
0130     {
0131     }
0132     u_property()
0133       : uidata(0)
0134     {
0135     }
0136 
0137     prop_storage_t get_storage() const { return uidata; }
0138   };
0139 
0140   //! container for additional property
0141   prop_map_t prop_map;
0142 
0143   ClassDefOverride(PHG4Cellv1, 3)
0144 };
0145 
0146 #endif