CMS 3D CMS Logo

HBHEChannelGroups.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_HBHEChannelGroups_h_
2 #define CondFormats_HcalObjects_HBHEChannelGroups_h_
3 
5 
6 #include "boost/serialization/access.hpp"
7 #include "boost/serialization/vector.hpp"
8 
10 #include <cstdint>
11 
13 public:
14  inline HBHEChannelGroups() : group_(HBHELinearMap::ChannelCount, 0U) {}
15 
16  //
17  // Main constructor. It is expected that "len" equals
18  // HBHELinearMap::ChannelCount and that every element of "data"
19  // indicates to which group that particular channel should belong.
20  //
21  inline HBHEChannelGroups(const unsigned* data, const unsigned len) : group_(data, data + len) {
22  if (!validate())
23  throw cms::Exception("In HBHEChannelGroups constructor: invalid input data");
24  }
25 
26  //
27  // Set the group number for the given HBHE linear channel number.
28  // Linear channel numbers are calculated by HBHELinearMap.
29  //
30  inline void setGroup(const unsigned linearChannel, const unsigned groupNum) { group_.at(linearChannel) = groupNum; }
31 
32  // Inspectors
33  inline unsigned size() const { return group_.size(); }
34 
35  inline const uint32_t* groupData() const { return group_.empty() ? nullptr : &group_[0]; }
36 
37  inline unsigned getGroup(const unsigned linearChannel) const { return group_.at(linearChannel); }
38 
39  inline unsigned largestGroupNumber() const {
40  unsigned lg = 0;
41  const unsigned sz = group_.size();
42  const uint32_t* dat = sz ? &group_[0] : nullptr;
43  for (unsigned i = 0; i < sz; ++i)
44  if (dat[i] > lg)
45  lg = dat[i];
46  return lg;
47  }
48 
49  // Comparators
50  inline bool operator==(const HBHEChannelGroups& r) const { return group_ == r.group_; }
51 
52  inline bool operator!=(const HBHEChannelGroups& r) const { return !(*this == r); }
53 
54 private:
55  std::vector<uint32_t> group_;
56 
57  inline bool validate() const { return group_.size() == HBHELinearMap::ChannelCount; }
58 
60 
61  template <class Archive>
62  inline void save(Archive& ar, const unsigned /* version */) const {
63  if (!validate())
64  throw cms::Exception("In HBHEChannelGroups::save: invalid data");
65  ar& group_;
66  }
67 
68  template <class Archive>
69  inline void load(Archive& ar, const unsigned /* version */) {
70  ar& group_;
71  if (!validate())
72  throw cms::Exception("In HBHEChannelGroups::load: invalid data");
73  }
74 
75  BOOST_SERIALIZATION_SPLIT_MEMBER()
76 };
77 
78 BOOST_CLASS_VERSION(HBHEChannelGroups, 1)
79 
80 #endif // CondFormats_HcalObjects_HBHEChannelGroups_h_
HBHEChannelGroups::HBHEChannelGroups
HBHEChannelGroups()
Definition: HBHEChannelGroups.h:14
HBHEChannelGroups
Definition: HBHEChannelGroups.h:12
HBHEChannelGroups::group_
std::vector< uint32_t > group_
Definition: HBHEChannelGroups.h:55
mps_fire.i
i
Definition: mps_fire.py:428
HBHELinearMap::ChannelCount
Definition: HBHELinearMap.h:18
HBHEChannelGroups::setGroup
void setGroup(const unsigned linearChannel, const unsigned groupNum)
Definition: HBHEChannelGroups.h:30
HBHEChannelGroups::load
void load(Archive &ar, const unsigned)
Definition: HBHEChannelGroups.h:69
HBHEChannelGroups::operator!=
bool operator!=(const HBHEChannelGroups &r) const
Definition: HBHEChannelGroups.h:52
HBHEChannelGroups::save
void save(Archive &ar, const unsigned) const
Definition: HBHEChannelGroups.h:62
HBHELinearMap.h
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
HBHEChannelGroups::size
unsigned size() const
Definition: HBHEChannelGroups.h:33
HBHEChannelGroups::access
friend class boost::serialization::access
Definition: HBHEChannelGroups.h:59
HBHELinearMap
Definition: HBHELinearMap.h:16
HBHEChannelGroups::operator==
bool operator==(const HBHEChannelGroups &r) const
Definition: HBHEChannelGroups.h:50
HBHEChannelGroups::getGroup
unsigned getGroup(const unsigned linearChannel) const
Definition: HBHEChannelGroups.h:37
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HBHEChannelGroups::HBHEChannelGroups
HBHEChannelGroups(const unsigned *data, const unsigned len)
Definition: HBHEChannelGroups.h:21
Exception
Definition: hltDiff.cc:246
Exception.h
HBHEChannelGroups::groupData
const uint32_t * groupData() const
Definition: HBHEChannelGroups.h:35
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
HBHEChannelGroups::validate
bool validate() const
Definition: HBHEChannelGroups.h:57
HBHEChannelGroups::largestGroupNumber
unsigned largestGroupNumber() const
Definition: HBHEChannelGroups.h:39