File indexing completed on 2024-04-06 12:04:53
0001 #ifndef DataFormats_PatCandidates_HcalDepthEnergyFractions_h
0002 #define DataFormats_PatCandidates_HcalDepthEnergyFractions_h
0003
0004 #include <vector>
0005 #include <cstdint>
0006
0007 namespace pat {
0008
0009
0010
0011
0012 class HcalDepthEnergyFractions {
0013 private:
0014
0015 std::vector<float> fractions_;
0016
0017 std::vector<uint8_t> fractionsI_;
0018
0019 public:
0020 explicit HcalDepthEnergyFractions(const std::vector<float>& v) : fractions_(v), fractionsI_() { initUint8Vector(); }
0021 HcalDepthEnergyFractions() : fractions_(), fractionsI_() {}
0022
0023
0024 void initUint8Vector() {
0025 fractionsI_.clear();
0026 for (auto frac : fractions_)
0027 fractionsI_.push_back((uint8_t)(frac * 200.));
0028 }
0029
0030
0031 void initFloatVector() {
0032 fractions_.clear();
0033 for (auto fracI : fractionsI_)
0034 fractions_.push_back(float(fracI) / 200.);
0035 }
0036
0037
0038 void reset(std::vector<float> v) {
0039 fractions_ = v;
0040 initUint8Vector();
0041 }
0042
0043
0044 const std::vector<float>& fractions() const { return fractions_; }
0045
0046
0047 float fraction(unsigned int i) const {
0048 if (i < fractions_.size())
0049 return fractions_[i];
0050 else
0051 return -1.;
0052 }
0053
0054
0055 const std::vector<uint8_t>& fractionsI() const { return fractionsI_; }
0056
0057
0058 int fractionI(unsigned int i) const {
0059 if (i < fractionsI_.size())
0060 return int(fractionsI_[i]);
0061 else
0062 return -1;
0063 }
0064 };
0065
0066 }
0067
0068 #endif