CMS 3D CMS Logo

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