CMS 3D CMS Logo

HcalDepthEnergyFractions.h
Go to the documentation of this file.
1 #ifndef DataFormats_PatCandidates_HcalDepthEnergyFractions_h
2 #define DataFormats_PatCandidates_HcalDepthEnergyFractions_h
3 
4 #include <vector>
5 #include <cstdint>
6 
7 namespace pat {
8 
9  //
10  // Hcal depth energy fracrtion struct
11  //
13  private:
14  //do not store
15  std::vector<float> fractions_;
16  //store
17  std::vector<uint8_t> fractionsI_;
18 
19  public:
20  explicit HcalDepthEnergyFractions(const std::vector<float>& v) : fractions_(v), fractionsI_() { initUint8Vector(); }
22 
23  // produce vector of uint8 from vector of float
24  void initUint8Vector() {
25  fractionsI_.clear();
26  for (auto frac : fractions_)
27  fractionsI_.push_back((uint8_t)(frac * 200.));
28  }
29 
30  // produce vector of float from vector of uint8_t
31  void initFloatVector() {
32  fractions_.clear();
33  for (auto fracI : fractionsI_)
34  fractions_.push_back(float(fracI) / 200.);
35  }
36 
37  // reset vectors
38  void reset(std::vector<float> v) {
39  fractions_ = v;
41  }
42 
43  // provide a full vector for each depth
44  const std::vector<float>& fractions() const { return fractions_; }
45 
46  // provide info for individual depth
47  float fraction(unsigned int i) const {
48  if (i < fractions_.size())
49  return fractions_[i];
50  else
51  return -1.;
52  }
53 
54  // provide a full vector (in uint8_t) for each depth
55  const std::vector<uint8_t>& fractionsI() const { return fractionsI_; }
56 
57  // provide info for individual depth (uint8_t)
58  int fractionI(unsigned int i) const {
59  if (i < fractionsI_.size())
60  return int(fractionsI_[i]);
61  else
62  return -1; // physical range 0-200
63  }
64  };
65 
66 } // namespace pat
67 
68 #endif
mps_fire.i
i
Definition: mps_fire.py:355
cropTnPTrees.frac
frac
Definition: cropTnPTrees.py:18
pat::HcalDepthEnergyFractions::fractionsI_
std::vector< uint8_t > fractionsI_
Definition: HcalDepthEnergyFractions.h:17
pat::HcalDepthEnergyFractions::initFloatVector
void initFloatVector()
Definition: HcalDepthEnergyFractions.h:31
findQualityFiles.v
v
Definition: findQualityFiles.py:179
pat::HcalDepthEnergyFractions::reset
void reset(std::vector< float > v)
Definition: HcalDepthEnergyFractions.h:38
pat::HcalDepthEnergyFractions::HcalDepthEnergyFractions
HcalDepthEnergyFractions(const std::vector< float > &v)
Definition: HcalDepthEnergyFractions.h:20
pat::HcalDepthEnergyFractions::fraction
float fraction(unsigned int i) const
Definition: HcalDepthEnergyFractions.h:47
pat::HcalDepthEnergyFractions::fractions
const std::vector< float > & fractions() const
Definition: HcalDepthEnergyFractions.h:44
pat
Definition: HeavyIon.h:7
pat::HcalDepthEnergyFractions::initUint8Vector
void initUint8Vector()
Definition: HcalDepthEnergyFractions.h:24
pat::HcalDepthEnergyFractions::HcalDepthEnergyFractions
HcalDepthEnergyFractions()
Definition: HcalDepthEnergyFractions.h:21
pat::HcalDepthEnergyFractions::fractionsI
const std::vector< uint8_t > & fractionsI() const
Definition: HcalDepthEnergyFractions.h:55
pat::HcalDepthEnergyFractions::fractions_
std::vector< float > fractions_
Definition: HcalDepthEnergyFractions.h:15
pat::HcalDepthEnergyFractions::fractionI
int fractionI(unsigned int i) const
Definition: HcalDepthEnergyFractions.h:58
pat::HcalDepthEnergyFractions
Definition: HcalDepthEnergyFractions.h:12