File indexing completed on 2025-12-17 09:19:53
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(const RawCluster& cluster);
0024 ~RawClusterv1() override = default;
0025
0026 void Reset() override;
0027 PHObject* CloneMe() const override { return new RawClusterv1(*this); }
0028 int isValid() const override { return towermap.size() > 0; }
0029 void identify(std::ostream& os = std::cout) const override;
0030
0031
0032
0033
0034
0035 RawClusterDefs::keytype get_id() const override { return clusterid; }
0036
0037 float get_energy() const override { return _energy; }
0038
0039 size_t getNTowers() const override { return towermap.size(); }
0040 RawCluster::TowerConstRange get_towers() const override { return make_pair(towermap.begin(), towermap.end()); }
0041
0042 const TowerMap& get_towermap() const override { return towermap; }
0043
0044
0045 CLHEP::Hep3Vector get_position() const override
0046 {
0047 return CLHEP::Hep3Vector(get_x(), get_y(), get_z());
0048 }
0049
0050 float get_phi() const override { return _phi; }
0051 float get_r() const override { return _r; }
0052 float get_z() const override { return _z; }
0053
0054
0055
0056
0057
0058
0059
0060 float get_x() const override { return get_r() * std::cos(get_phi()); }
0061 float get_y() const override { return get_r() * std::sin(get_phi()); }
0062
0063
0064
0065 float get_ecore() const override { return get_property_float(prop_ecore); }
0066
0067 float get_chi2() const override { return get_property_float(prop_chi2); }
0068
0069 float get_prob() const override { return get_property_float(prop_prob); }
0070
0071 float get_merged_cluster_prob() const override { return get_property_float(prop_merged_cluster_prob); }
0072
0073 float get_et_iso() const override { return get_property_float(prop_et_iso_calotower_R03); }
0074
0075 float get_et_iso(const int radiusx10, bool subtracted, bool clusterTower) const override;
0076
0077
0078 float x_tower_raw() const override { return get_property_float(prop_tower_x_raw); }
0079 float y_tower_raw() const override { return get_property_float(prop_tower_y_raw); }
0080 float x_tower_corr() const override { return get_property_float(prop_tower_x_corr); }
0081 float y_tower_corr() const override { return get_property_float(prop_tower_y_corr); }
0082
0083
0084 float mean_time() const override { return get_property_float(prop_tower_t_mean); }
0085
0086
0087 float alpha_mech_phi() const { return get_property_float(prop_incidence_alpha_phi); }
0088 float alpha_mech_eta() const { return get_property_float(prop_incidence_alpha_eta); }
0089
0090 std::vector<float> get_shower_shapes(float tower_thresh) const override;
0091 std::pair<int, int> get_lead_tower() const override;
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 void set_id(const RawClusterDefs::keytype id) override { clusterid = id; }
0105
0106 void addTower(const RawClusterDefs::keytype twrid, const float etower) override;
0107
0108 void set_energy(const float energy) override { _energy = energy; }
0109
0110 void set_phi(const float phi) override { _phi = phi; }
0111 void set_z(const float z) override { _z = z; }
0112 void set_r(const float r) override { _r = r; }
0113
0114
0115
0116 void set_ecore(const float ecore) override { set_property(prop_ecore, ecore); }
0117
0118 void set_chi2(const float chi2) override { set_property(prop_chi2, chi2); }
0119
0120 void set_prob(const float prob) override { set_property(prop_prob, prob); }
0121
0122 void set_merged_cluster_prob(const float probmergedcluster) override { set_property(prop_merged_cluster_prob, probmergedcluster); }
0123
0124 void set_et_iso(const float e) override { set_property(prop_et_iso_calotower_R03, e); }
0125
0126 void set_et_iso(const float et_iso, const int radiusx10, bool subtracted, bool clusterTower) override;
0127
0128
0129 void set_tower_cog(float xr, float yr, float xc, float yc) override
0130 {
0131 set_property(prop_tower_x_raw, xr);
0132 set_property(prop_tower_y_raw, yr);
0133 set_property(prop_tower_x_corr, xc);
0134 set_property(prop_tower_y_corr, yc);
0135 }
0136
0137
0138 void set_mean_time(float t) override
0139 {
0140 set_property(prop_tower_t_mean, t);
0141 }
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155 public:
0156 bool has_property(const PROPERTY prop_id) const override;
0157 float get_property_float(const PROPERTY prop_id) const override;
0158 int get_property_int(const PROPERTY prop_id) const override;
0159 unsigned int get_property_uint(const PROPERTY prop_id) const override;
0160 void set_property(const PROPERTY prop_id, const float value) override;
0161 void set_property(const PROPERTY prop_id, const int value) override;
0162 void set_property(const PROPERTY prop_id, const unsigned int value) override;
0163
0164 protected:
0165 unsigned int get_property_nocheck(const PROPERTY prop_id) const;
0166 void set_property_nocheck(const PROPERTY prop_id, const unsigned int ui) { prop_map[prop_id] = ui; }
0167
0168 typedef uint8_t prop_id_t;
0169 typedef uint32_t prop_storage_t;
0170 typedef std::map<prop_id_t, prop_storage_t> prop_map_t;
0171
0172
0173 union u_property
0174 {
0175 float fdata;
0176 int32_t idata;
0177 uint32_t uidata;
0178
0179 u_property(int32_t in)
0180 : idata(in)
0181 {
0182 }
0183 u_property(uint32_t in)
0184 : uidata(in)
0185 {
0186 }
0187 u_property(float in)
0188 : fdata(in)
0189 {
0190 }
0191 u_property()
0192 : uidata(0)
0193 {
0194 }
0195
0196 prop_storage_t get_storage() const { return uidata; }
0197 };
0198
0199
0200 prop_map_t prop_map;
0201
0202
0203
0204 private:
0205 void copy_property_from_cluster(const RawCluster& source, const PROPERTY prop_id);
0206
0207
0208 protected:
0209
0210 RawClusterDefs::keytype clusterid{0};
0211
0212 float _energy{std::numeric_limits<float>::quiet_NaN()};
0213
0214 TowerMap towermap;
0215
0216
0217 float _r{std::numeric_limits<float>::quiet_NaN()};
0218 float _phi{std::numeric_limits<float>::quiet_NaN()};
0219 float _z{std::numeric_limits<float>::quiet_NaN()};
0220
0221 ClassDefOverride(RawClusterv1, 3)
0222 };
0223
0224 #endif