CMS 3D CMS Logo

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