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
0031
0032
0033
0034 RawClusterDefs::keytype get_id() const override { return clusterid; }
0035
0036 float get_energy() const override { return _energy; }
0037
0038 size_t getNTowers() const override { return towermap.size(); }
0039 RawCluster::TowerConstRange get_towers() const override { return make_pair(towermap.begin(), towermap.end()); }
0040
0041 const TowerMap& get_towermap() const override { return towermap; }
0042
0043
0044 CLHEP::Hep3Vector get_position() const override
0045 {
0046 return CLHEP::Hep3Vector(get_x(), get_y(), get_z());
0047 }
0048
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
0054
0055
0056
0057
0058
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
0063
0064 float get_ecore() const override { return get_property_float(prop_ecore); }
0065
0066 float get_chi2() const override { return get_property_float(prop_chi2); }
0067
0068 float get_prob() const override { return get_property_float(prop_prob); }
0069
0070 float get_merged_cluster_prob() const override { return get_property_float(prop_merged_cluster_prob); }
0071
0072 float get_et_iso() const override { return get_property_float(prop_et_iso_calotower_R03); }
0073
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;
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 void set_id(const RawClusterDefs::keytype id) override { clusterid = id; }
0091
0092 void addTower(const RawClusterDefs::keytype twrid, const float etower) override;
0093
0094 void set_energy(const float energy) override { _energy = energy; }
0095
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
0101
0102 void set_ecore(const float ecore) override { set_property(prop_ecore, ecore); }
0103
0104 void set_chi2(const float chi2) override { set_property(prop_chi2, chi2); }
0105
0106 void set_prob(const float prob) override { set_property(prop_prob, prob); }
0107
0108 void set_merged_cluster_prob(const float probmergedcluster) override { set_property(prop_merged_cluster_prob, probmergedcluster); }
0109
0110 void set_et_iso(const float e) override { set_property(prop_et_iso_calotower_R03, e); }
0111
0112 void set_et_iso(const float et_iso, const int radiusx10, bool subtracted, bool clusterTower) override;
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
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:
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
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
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
0171 prop_map_t prop_map;
0172
0173
0174
0175
0176 protected:
0177
0178 RawClusterDefs::keytype clusterid{0};
0179
0180 float _energy{std::numeric_limits<float>::signaling_NaN()};
0181
0182 TowerMap towermap;
0183
0184
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