CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HFQIE10Info.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_HCALRECHIT_HFQIE10INFO_H
2 #define DATAFORMATS_HCALRECHIT_HFQIE10INFO_H
3 
4 #include <limits>
5 
8 
15 class HFQIE10Info {
16 public:
19 
20  static const unsigned N_RAW_MAX = 5;
22 
23  constexpr HFQIE10Info()
24  : charge_(0.f),
25  energy_(0.f),
26  timeRising_(0.f),
27  timeFalling_(-1.f),
29  nRaw_(0),
30  soi_(0) {}
31 
32  // Argument "soi" provides the index of the sample of interest
33  // in the "rawData" array
34  constexpr HFQIE10Info(const HcalDetId& id,
35  float charge,
36  float energy,
37  float timeRising,
38  float timeFalling,
39  const raw_type* rawData,
40  unsigned nData,
41  unsigned soi)
42  : id_(id),
43  charge_(charge),
44  energy_(energy),
45  timeRising_(timeRising),
46  timeFalling_(timeFalling),
48  nRaw_(std::min(nData, N_RAW_MAX)),
49  soi_(0) {
50  if (nData) {
51  unsigned tbegin = 0;
52  if (soi >= nData) {
53  // No SOI in the data. This situation is not normal
54  // but can not be addressed in this code.
55  if (nData > nRaw_)
56  tbegin = nData - nRaw_;
57  soi_ = nRaw_;
58  } else {
59  if (nData > nRaw_) {
60  // Want to keep at least 2 presamples
61  if (soi > 2U) {
62  tbegin = soi - 2U;
63  if (tbegin + nRaw_ > nData)
64  tbegin = nData - nRaw_;
65  }
66  }
67  soi_ = soi - tbegin;
68  }
69 
70  raw_type* to = &raw_[0];
71  const raw_type* from = rawData + tbegin;
72  for (unsigned i = 0; i < nRaw_; ++i)
73  *to++ = *from++;
74  }
75  }
76 
77  constexpr HcalDetId id() const { return id_; }
78 
79  constexpr float charge() const { return charge_; }
80  constexpr float energy() const { return energy_; }
81  constexpr float timeRising() const { return timeRising_; }
82  constexpr float timeFalling() const { return timeFalling_; }
83  constexpr unsigned nRaw() const { return nRaw_; }
84  constexpr unsigned soi() const { return soi_; }
85  constexpr raw_type getRaw(const unsigned which) const { return which >= nRaw_ ? INVALID_RAW : raw_[which]; }
86 
87  // Check whether the "ok" flag is set in the dataframe.
88  //
89  // If "checkAllTimeSlices" is "true" or if the raw data
90  // does not contain the "sample of interest" time slice,
91  // we are going to check all time slices. Otherwise only
92  // the "sample of interest" time slice is checked.
93  //
94  bool isDataframeOK(bool checkAllTimeSlices = false) const {
95  bool hardwareOK = true;
96  if (soi_ >= nRaw_ || checkAllTimeSlices)
97  for (unsigned i = 0; i < nRaw_ && hardwareOK; ++i) {
99  hardwareOK = s.ok();
100  }
101  else {
103  hardwareOK = s.ok();
104  }
105  return hardwareOK;
106  }
107 
108 private:
110 
111  float charge_;
112  float energy_;
113  float timeRising_;
116  uint8_t nRaw_;
117  uint8_t soi_;
118 };
119 
120 #endif // DATAFORMATS_HCALRECHIT_HFQIE10INFO_H
def which
Definition: eostools.py:336
float timeFalling_
Definition: HFQIE10Info.h:114
bool isDataframeOK(bool checkAllTimeSlices=false) const
Definition: HFQIE10Info.h:94
constexpr unsigned nRaw() const
Definition: HFQIE10Info.h:83
static const raw_type INVALID_RAW
Definition: HFQIE10Info.h:21
constexpr raw_type getRaw(const unsigned which) const
Definition: HFQIE10Info.h:85
HcalDetId id_
Definition: HFQIE10Info.h:109
constexpr unsigned soi() const
Definition: HFQIE10Info.h:84
constexpr HFQIE10Info(const HcalDetId &id, float charge, float energy, float timeRising, float timeFalling, const raw_type *rawData, unsigned nData, unsigned soi)
Definition: HFQIE10Info.h:34
constexpr float timeRising() const
Definition: HFQIE10Info.h:81
QIE10DataFrame::Sample::wide_type raw_type
Definition: HFQIE10Info.h:18
float timeRising_
Definition: HFQIE10Info.h:113
raw_type raw_[N_RAW_MAX]
Definition: HFQIE10Info.h:115
uint8_t soi_
Definition: HFQIE10Info.h:117
constexpr float charge() const
Definition: HFQIE10Info.h:79
constexpr float energy() const
Definition: HFQIE10Info.h:80
constexpr bool ok() const
static const unsigned N_RAW_MAX
Definition: HFQIE10Info.h:20
constexpr HFQIE10Info()
Definition: HFQIE10Info.h:23
constexpr HcalDetId id() const
Definition: HFQIE10Info.h:77
float charge_
Definition: HFQIE10Info.h:111
HcalDetId key_type
Definition: HFQIE10Info.h:17
constexpr float timeFalling() const
Definition: HFQIE10Info.h:82
uint8_t nRaw_
Definition: HFQIE10Info.h:116
float energy_
Definition: HFQIE10Info.h:112