Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:21

0001 #ifndef CALOBASE_RAWCLUSTERV1_H
0002 #define CALOBASE_RAWCLUSTERV1_H
0003 
0004 #include "RawCluster.h"
0005 #include "RawClusterDefs.h"
0006 
0007 #include <CLHEP/Vector/ThreeVector.h>
0008 
0009 #include <cmath>
0010 #include <cstddef>
0011 #include <cstdint>
0012 #include <iostream>
0013 #include <limits>
0014 #include <map>
0015 #include <utility>
0016 
0017 class PHObject;
0018 
0019 class RawClusterv1 : public RawCluster
0020 {
0021  public:
0022   RawClusterv1() = default;
0023   ~RawClusterv1() override {}
0024 
0025   void Reset() override;
0026   PHObject* CloneMe() const override { return new RawClusterv1(*this); }
0027   int isValid() const override { return towermap.size() > 0; }
0028   void identify(std::ostream& os = std::cout) const override;
0029 
0030   /** @defgroup getters
0031    *  @{
0032    */
0033   //! cluster ID
0034   RawClusterDefs::keytype get_id() const override { return clusterid; }
0035   //! total energy
0036   float get_energy() const override { return _energy; }
0037   //! Tower operations
0038   size_t getNTowers() const override { return towermap.size(); }
0039   RawCluster::TowerConstRange get_towers() const override { return make_pair(towermap.begin(), towermap.end()); }
0040   //! return tower map for c++11 range-based for-loop
0041   const TowerMap& get_towermap() const override { return towermap; }
0042   //
0043   //! cluster position in 3D
0044   CLHEP::Hep3Vector get_position() const override
0045   {
0046     return CLHEP::Hep3Vector(get_x(), get_y(), get_z());
0047   }
0048   //!  access to intrinsic cylindrical coordinate system
0049   float get_phi() const override { return _phi; }
0050   float get_r() const override { return _r; }
0051   float get_z() const override { return _z; }
0052   //
0053   //  //! convert cluster location to psuedo-rapidity given a user chosen z-location
0054   //  virtual float get_eta(const float z) const;
0055   //  //! convert cluster E_T given a user chosen z-location
0056   //  virtual float get_et(const float z) const;
0057   //
0058   //! access Cartesian coordinate system
0059   float get_x() const override { return get_r() * std::cos(get_phi()); }
0060   float get_y() const override { return get_r() * std::sin(get_phi()); }
0061   //
0062   //! access additional optional properties
0063   //! cluster core energy for EM shower
0064   float get_ecore() const override { return get_property_float(prop_ecore); }
0065   //! reduced chi2 for EM shower
0066   float get_chi2() const override { return get_property_float(prop_chi2); }
0067   //! cluster template probability for EM shower
0068   float get_prob() const override { return get_property_float(prop_prob); }
0069   //! cluster template merged pi0 cluster probability for EM shower
0070   float get_merged_cluster_prob() const override { return get_property_float(prop_merged_cluster_prob); }
0071   //! isolation ET default
0072   float get_et_iso() const override { return get_property_float(prop_et_iso_calotower_R03); }
0073   //! isolation ET the radius and hueristic can be specified
0074   float get_et_iso(const int radiusx10, bool subtracted, bool clusterTower) const override;
0075 
0076   std::vector<float> get_shower_shapes(float tower_thresh) const override;
0077   std::pair<int,int> get_lead_tower() const override; // eta,phi of leading tower in cluster
0078 
0079   //  //! truth cluster's PHG4Particle ID
0080   //  virtual int get_truth_track_ID() const override { return get_property_int(prop_truth_track_ID); }
0081   //  //! truth cluster's PHG4Particle flavor
0082   //  virtual int get_truth_flavor() const override { return get_property_int(prop_truth_flavor); }
0083   //
0084   /** @} */  // end of getters
0085 
0086   /** @defgroup setters
0087    *  @{
0088    */
0089   //! cluster ID
0090   void set_id(const RawClusterDefs::keytype id) override { clusterid = id; }
0091   //! Tower operations
0092   void addTower(const RawClusterDefs::keytype twrid, const float etower) override;
0093   //! total energy
0094   void set_energy(const float energy) override { _energy = energy; }
0095   //!  access to intrinsic cylindrical coordinate system
0096   void set_phi(const float phi) override { _phi = phi; }
0097   void set_z(const float z) override { _z = z; }
0098   void set_r(const float r) override { _r = r; }
0099   //
0100   //! access additional optional properties
0101   //! cluster core energy for EM shower
0102   void set_ecore(const float ecore) override { set_property(prop_ecore, ecore); }
0103   //! reduced chi2 for EM shower
0104   void set_chi2(const float chi2) override { set_property(prop_chi2, chi2); }
0105   //! cluster template probability for EM shower
0106   void set_prob(const float prob) override { set_property(prop_prob, prob); }
0107   //! cluster template merged pi0 cluster probability for EM shower
0108   void set_merged_cluster_prob(const float probmergedcluster) override { set_property(prop_merged_cluster_prob, probmergedcluster); }
0109   //! isolation ET default
0110   void set_et_iso(const float e) override { set_property(prop_et_iso_calotower_R03, e); }
0111   //! isolation ET the radius and hueristic can be specified
0112   void set_et_iso(const float et_iso, const int radiusx10, bool subtracted, bool clusterTower) override;
0113   //  //! truth cluster's PHG4Particle ID
0114   //  virtual void set_truth_track_ID(const int i) override { set_property(prop_truth_track_ID, i); }
0115   //  //! truth cluster's PHG4Particle flavor
0116   //  virtual void set_truth_flavor(const int f) override { set_property(prop_truth_flavor, f); }
0117   //
0118   /*
0119    *
0120    * @} */
0121   // end of setters
0122 
0123   /** @defgroup property_map property map definitions
0124    *  @{
0125    */
0126  public:
0127   bool has_property(const PROPERTY prop_id) const override;
0128   float get_property_float(const PROPERTY prop_id) const override;
0129   int get_property_int(const PROPERTY prop_id) const override;
0130   unsigned int get_property_uint(const PROPERTY prop_id) const override;
0131   void set_property(const PROPERTY prop_id, const float value) override;
0132   void set_property(const PROPERTY prop_id, const int value) override;
0133   void set_property(const PROPERTY prop_id, const unsigned int value) override;
0134 
0135  protected:  // protected is declared twice !?
0136   unsigned int get_property_nocheck(const PROPERTY prop_id) const;
0137   void set_property_nocheck(const PROPERTY prop_id, const unsigned int ui) { prop_map[prop_id] = ui; }
0138   //! storage types for additional property
0139   typedef uint8_t prop_id_t;
0140   typedef uint32_t prop_storage_t;
0141   typedef std::map<prop_id_t, prop_storage_t> prop_map_t;
0142 
0143   //! convert between 32bit inputs and storage type prop_storage_t
0144   union u_property
0145   {
0146     float fdata;
0147     int32_t idata;
0148     uint32_t uidata;
0149 
0150     u_property(int32_t in)
0151       : idata(in)
0152     {
0153     }
0154     u_property(uint32_t in)
0155       : uidata(in)
0156     {
0157     }
0158     u_property(float in)
0159       : fdata(in)
0160     {
0161     }
0162     u_property()
0163       : uidata(0)
0164     {
0165     }
0166 
0167     prop_storage_t get_storage() const { return uidata; }
0168   };
0169 
0170   //! container for additional property
0171   prop_map_t prop_map;
0172 
0173   /** @} */  // end of property map definitions
0174 
0175   //
0176  protected:
0177   //! cluster ID
0178   RawClusterDefs::keytype clusterid{0};
0179   //! total energy
0180   float _energy{std::numeric_limits<float>::signaling_NaN()};
0181   //! Tower operations
0182   TowerMap towermap;
0183 
0184   //! location of cluster in cylindrical coordinate
0185   float _r{std::numeric_limits<float>::signaling_NaN()};
0186   float _phi{std::numeric_limits<float>::signaling_NaN()};
0187   float _z{std::numeric_limits<float>::signaling_NaN()};
0188 
0189   ClassDefOverride(RawClusterv1, 3)
0190 };
0191 
0192 #endif