Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:21:58

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef G4MAIN_PHG4HIT_H
0004 #define G4MAIN_PHG4HIT_H
0005 
0006 #include "PHG4HitDefs.h"
0007 
0008 #include <phool/PHObject.h>
0009 
0010 #include <iostream>
0011 #include <limits>
0012 #include <string>
0013 #include <utility>
0014 
0015 class PHG4Hit : public PHObject
0016 {
0017  public:
0018   PHG4Hit() {}
0019   ~PHG4Hit() override {}
0020 
0021   void identify(std::ostream &os = std::cout) const override;
0022   void CopyFrom(const PHObject *phobj) override;
0023   friend std::ostream &operator<<(std::ostream &stream, const PHG4Hit *hit);
0024   void Reset() override;
0025 
0026   // The indices here represent the entry and exit points of the particle
0027   virtual float get_x(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0028   virtual float get_y(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0029   virtual float get_z(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0030   virtual float get_px(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0031   virtual float get_py(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0032   virtual float get_pz(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0033   virtual float get_local_x(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0034   virtual float get_local_y(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0035   virtual float get_local_z(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0036   virtual float get_t(const int) const { return std::numeric_limits<float>::quiet_NaN(); }
0037   virtual float get_edep() const { return std::numeric_limits<float>::quiet_NaN(); }
0038   virtual float get_eion() const { return std::numeric_limits<float>::quiet_NaN(); }
0039   virtual float get_light_yield() const { return std::numeric_limits<float>::quiet_NaN(); }
0040   virtual float get_path_length() const { return std::numeric_limits<float>::quiet_NaN(); }
0041   virtual float get_raw_light_yield() const { return std::numeric_limits<float>::quiet_NaN(); }
0042   virtual unsigned int get_layer() const { return std::numeric_limits<unsigned int>::max(); }
0043   virtual PHG4HitDefs::keytype get_hit_id() const { return std::numeric_limits<PHG4HitDefs::keytype>::max(); }
0044   virtual int get_detid() const { return std::numeric_limits<int>::min(); }
0045   virtual int get_shower_id() const { return std::numeric_limits<int>::min(); }
0046   virtual int get_scint_id() const { return std::numeric_limits<int>::min(); }
0047   virtual int get_row() const { return std::numeric_limits<int>::min(); }
0048   virtual int get_sector() const { return std::numeric_limits<int>::min(); }
0049   virtual int get_trkid() const { return std::numeric_limits<int>::min(); }
0050   virtual int get_strip_z_index() const { return std::numeric_limits<int>::min(); }
0051   virtual int get_strip_y_index() const { return std::numeric_limits<int>::min(); }
0052   virtual int get_ladder_z_index() const { return std::numeric_limits<int>::min(); }
0053   virtual int get_ladder_phi_index() const { return std::numeric_limits<int>::min(); }
0054   virtual int get_index_i() const { return std::numeric_limits<int>::min(); }
0055   virtual int get_index_j() const { return std::numeric_limits<int>::min(); }
0056   virtual int get_index_k() const { return std::numeric_limits<int>::min(); }
0057   virtual int get_index_l() const { return std::numeric_limits<int>::min(); }
0058   virtual int get_hit_type() const { return std::numeric_limits<int>::min(); }
0059 
0060   virtual void set_x(const int, const float) { return; }
0061   virtual void set_y(const int, const float) { return; }
0062   virtual void set_z(const int, const float) { return; }
0063   virtual void set_px(const int, const float) { return; }
0064   virtual void set_py(const int, const float) { return; }
0065   virtual void set_pz(const int, const float) { return; }
0066   virtual void set_local_x(const int, const float) { return; }
0067   virtual void set_local_y(const int, const float) { return; }
0068   virtual void set_local_z(const int, const float) { return; }
0069   virtual void set_t(const int, const float) { return; }
0070   virtual void set_edep(const float) { return; }
0071   virtual void set_eion(const float) { return; }
0072   virtual void set_light_yield(const float) { return; }
0073   virtual void set_raw_light_yield(const float) { return; }
0074   virtual void set_path_length(const float) { return; }
0075   virtual void set_layer(const unsigned int) { return; }
0076   virtual void set_hit_id(const PHG4HitDefs::keytype) { return; }
0077   virtual void set_shower_id(const int) { return; }
0078   virtual void set_scint_id(const int) { return; }
0079   virtual void set_row(const int) { return; }
0080   virtual void set_sector(const int) { return; }
0081   virtual void set_trkid(const int) { return; }
0082   virtual void set_strip_z_index(const int) { return; }
0083   virtual void set_strip_y_index(const int) { return; }
0084   virtual void set_ladder_z_index(const int) { return; }
0085   virtual void set_ladder_phi_index(const int) { return; }
0086   virtual void set_index_i(const int) { return; }
0087   virtual void set_index_j(const int) { return; }
0088   virtual void set_index_k(const int) { return; }
0089   virtual void set_index_l(const int) { return; }
0090   virtual void set_hit_type(const int) { return; }
0091 
0092   virtual float get_avg_x() const;
0093   virtual float get_avg_y() const;
0094   virtual float get_avg_z() const;
0095   virtual float get_avg_t() const;
0096 
0097   virtual void print() const { std::cout << "PHG4Hit base class - print() not implemented" << std::endl; }
0098 
0099   //! Procedure to add a new PROPERTY tag:
0100   //! 1.add new tag below with unique value,
0101   //! 2.add a short name to PHG4Hit::get_property_info
0102   enum PROPERTY
0103   {  //
0104 
0105     //-- hit properties: 1 - 10  --
0106     //! ionizing energy loss
0107     prop_eion = 1,
0108 
0109     //! for scintillation detectors, the amount of light produced
0110     prop_light_yield = 2,
0111     scint_gammas = 3,
0112     cerenkov_gammas = 4,
0113     prop_raw_light_yield = 5,
0114 
0115     //-- track properties: 10 - 20  --
0116 
0117     //! momentum
0118     prop_px_0 = 10,
0119     prop_px_1 = 11,
0120     prop_py_0 = 12,
0121     prop_py_1 = 13,
0122     prop_pz_0 = 14,
0123     prop_pz_1 = 15,
0124 
0125     //! pathlength
0126     prop_path_length = 16,
0127 
0128     //! local coordinate
0129     prop_local_x_0 = 20,
0130     prop_local_x_1 = 21,
0131     prop_local_y_0 = 22,
0132     prop_local_y_1 = 23,
0133     prop_local_z_0 = 24,
0134     prop_local_z_1 = 25,
0135 
0136     //-- detector specific IDs: 100+ --
0137 
0138     //! layer ID
0139     prop_layer = 101,
0140     //! scintillator ID
0141     prop_scint_id = 102,
0142     //! row (mother volume or steel plate id)
0143     prop_row = 103,
0144     //! sector
0145     prop_sector = 104,
0146 
0147     //! SVX stuff
0148     prop_strip_z_index = 110,
0149     prop_strip_y_index = 111,
0150     prop_ladder_z_index = 112,
0151     prop_ladder_phi_index = 113,
0152 
0153     // MAPS stuff
0154     prop_stave_index = 114,
0155     prop_half_stave_index = 115,
0156     prop_module_index = 116,
0157     prop_chip_index = 117,
0158 
0159     prop_local_pos_x_0 = 118,
0160     prop_local_pos_y_0 = 119,
0161     prop_local_pos_z_0 = 120,
0162 
0163     //! generic indexes
0164     prop_index_i = 121,
0165     prop_index_j = 122,
0166     prop_index_k = 123,
0167     prop_index_l = 124,
0168 
0169     //! hit type
0170     prop_hit_type = 125,
0171 
0172     prop_local_pos_x_1 = 128,
0173     prop_local_pos_y_1 = 126,
0174     prop_local_pos_z_1 = 127,
0175 
0176     //! max limit in order to fit into 8 bit unsigned number
0177     prop_MAX_NUMBER = std::numeric_limits<unsigned char>::max()
0178   };
0179 
0180   enum PROPERTY_TYPE
0181   {  //
0182     type_int = 1,
0183     type_uint = 2,
0184     type_float = 3,
0185     type_unknown = -1
0186   };
0187 
0188   virtual bool has_property(const PROPERTY /*prop_id*/) const { return false; }
0189   virtual float get_property_float(const PROPERTY /*prop_id*/) const { return std::numeric_limits<float>::quiet_NaN(); }
0190   virtual int get_property_int(const PROPERTY /*prop_id*/) const { return std::numeric_limits<int>::min(); }
0191   virtual unsigned int get_property_uint(const PROPERTY /*prop_id*/) const { return std::numeric_limits<unsigned int>::max(); }
0192   virtual void set_property(const PROPERTY /*prop_id*/, const float /*value*/) { return; }
0193   virtual void set_property(const PROPERTY /*prop_id*/, const int /*value*/) { return; }
0194   virtual void set_property(const PROPERTY /*prop_id*/, const unsigned int /*value*/) { return; }
0195   static std::pair<const std::string, PROPERTY_TYPE> get_property_info(PROPERTY prop_id);
0196   static bool check_property(const PROPERTY prop_id, const PROPERTY_TYPE prop_type);
0197   static std::string get_property_type(const PROPERTY_TYPE prop_type);
0198 
0199  protected:
0200   virtual unsigned int get_property_nocheck(const PROPERTY /*prop_id*/) const { return std::numeric_limits<unsigned int>::max(); }
0201   virtual void set_property_nocheck(const PROPERTY /*prop_id*/, const unsigned int) { return; }
0202   ClassDefOverride(PHG4Hit, 1)
0203 };
0204 
0205 inline float PHG4Hit::get_avg_x() const { return 0.5 * (get_x(0) + get_x(1)); }
0206 inline float PHG4Hit::get_avg_y() const { return 0.5 * (get_y(0) + get_y(1)); }
0207 inline float PHG4Hit::get_avg_z() const { return 0.5 * (get_z(0) + get_z(1)); }
0208 inline float PHG4Hit::get_avg_t() const { return 0.5 * (get_t(0) + get_t(1)); }
0209 
0210 #endif