CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HFRecHitAuxSetter.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <type_traits>
3 
5 
8 
10  const unsigned anodeStates[2],
11  const unsigned u_soiPhase,
12  HFRecHit* rechit) {
13  using namespace CaloRecHitAuxSetter;
14 
15  const int wantedPhase = u_soiPhase < 2U ? u_soiPhase : 2U;
16 
17  for (unsigned ianode = 0; ianode < 2; ++ianode) {
18  uint32_t aux = 0;
19  const HFQIE10Info* anodeInfo = prehit.getHFQIE10Info(ianode);
20  if (anodeInfo) {
21  const int nRaw = anodeInfo->nRaw();
22  const int soiStored = anodeInfo->soi();
23  if (soiStored < nRaw) {
24  // SOI is in the raw data. Figure out a good
25  // way to map ADCs into the three bytes available.
26  int shift = 0;
27  int nStore = nRaw;
28  if (nRaw > 3) {
29  nStore = 3;
30  if (soiStored > wantedPhase)
31  shift = soiStored - wantedPhase;
32  if (shift + nStore > nRaw)
33  shift = nRaw - nStore;
34  }
35 
36  // Fill out the ADC fields
37  for (int iadc = 0; iadc < nStore; ++iadc) {
38  const int istored = iadc + shift;
39  const QIE10DataFrame::Sample ts(anodeInfo->getRaw(istored));
40  setField(&aux, 0xff, iadc * 8, ts.adc());
41  if (istored == soiStored)
42  setField(&aux, MASK_CAPID, OFF_CAPID, ts.capid());
43  }
44  setField(&aux, MASK_SOI, OFF_SOI, soiStored - shift);
45  } else
46  setField(&aux, MASK_SOI, OFF_SOI, 3U);
47  }
48 
49  // Remember anode status
50  static_assert(HFAnodeStatus::N_POSSIBLE_STATES <= MASK_STATUS + 1,
51  "Possible states enum must fit into the bit field");
52  setField(&aux, MASK_STATUS, OFF_STATUS, anodeStates[ianode]);
53 
54  // Fill the aux field in the rechit
55  if (ianode)
56  rechit->setAuxHF(aux);
57  else
58  rechit->setAux(aux);
59  }
60 }
constexpr void setField(uint32_t *u, const unsigned mask, const unsigned offset, const unsigned value)
static const unsigned OFF_CAPID
constexpr unsigned nRaw() const
Definition: HFQIE10Info.h:83
constexpr raw_type getRaw(const unsigned which) const
Definition: HFQIE10Info.h:85
static const unsigned OFF_STATUS
constexpr void setAuxHF(const uint32_t u)
Definition: HFRecHit.h:28
static const unsigned MASK_STATUS
constexpr unsigned soi() const
Definition: HFQIE10Info.h:84
static const unsigned OFF_SOI
static const unsigned MASK_CAPID
static const unsigned MASK_SOI
static void setAux(const HFPreRecHit &prehit, const unsigned anodeStates[2], unsigned soiPhase, HFRecHit *rechit)
static unsigned int const shift
constexpr HFQIE10Info const * getHFQIE10Info(unsigned index) const
Definition: HFPreRecHit.h:39
constexpr void setAux(uint32_t value)
Definition: CaloRecHit.h:49