Back to home page

sPhenix code displayed by LXR

 
 

    


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

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