CMS 3D CMS Logo

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