CMS 3D CMS Logo

HBHERecHitAuxSetter.h
Go to the documentation of this file.
1 #ifndef DataFormats_HcalRecHit_HBHERecHitAuxSetter_h_
2 #define DataFormats_HcalRecHit_HBHERecHitAuxSetter_h_
3 
7 
8 //
9 // Set rechit "auxiliary words" for the Phase 1 HBHE reco.
10 //
11 // The standars CaloRecHit "aux" word contains ADC values 0-3.
12 //
13 // The "auxHBHE" word of HBHERecHit contains ADC values 4-7.
14 //
15 // The "auxPhase1" word of HBHERecHit contains ADC values 8-9
16 // and other info, as specified by the masks and offsets below.
17 //
19 {
20  static const unsigned MASK_ADC = 0xffff;
21  static const unsigned OFF_ADC = 0;
22 
23  // How many ADC values are actually stored
24  static const unsigned MASK_NSAMPLES = 0xf;
25  static const unsigned OFF_NSAMPLES = 16;
26 
27  // Which ADC corresponds to the sample of interest.
28  static const unsigned MASK_SOI = 0xf;
29  static const unsigned OFF_SOI = 20;
30 
31  // CAPID for the sample of interest.
32  static const unsigned MASK_CAPID = 0x3;
33  static const unsigned OFF_CAPID = 24;
34 
35  // Various status bits (pack bools from HBHEChannelInfo)
36  static const unsigned OFF_TDC_TIME = 26;
37  static const unsigned OFF_DROPPED = 27;
38  static const unsigned OFF_LINK_ERR = 28;
39  static const unsigned OFF_CAPID_ERR = 29;
40 
41  // Flag identifying combined "Plan 1" rechits
42  static const unsigned OFF_COMBINED = 30;
43 
44  // Main function for setting the aux words.
45  constexpr static void setAux(const HBHEChannelInfo& info,
46  HBHERecHit* rechit);
47 };
48 
50  HBHERecHit* rechit)
51 {
52  using namespace CaloRecHitAuxSetter;
53 
54  uint32_t aux = 0, auxHBHE = 0, auxPhase1 = 0;
55 
56  // Pack ADC values
57  unsigned nSamples = info.nSamples();
58  if (nSamples > 10)
59  nSamples = 10;
60  for (unsigned i=0; i<4 && i<nSamples; ++i)
61  setField(&aux, 0xff, i*8, info.tsAdc(i));
62  for (unsigned i=4; i<8 && i<nSamples; ++i)
63  setField(&auxHBHE, 0xff, (i-4)*8, info.tsAdc(i));
64  for (unsigned i=8; i<nSamples; ++i)
65  setField(&auxPhase1, 0xff, (i-8)*8, info.tsAdc(i));
66 
67  // Pack other fields
68  setField(&auxPhase1, MASK_NSAMPLES, OFF_NSAMPLES, nSamples);
69  unsigned soi = info.soi();
70  if (soi > 10)
71  soi = 10;
72  setField(&auxPhase1, MASK_SOI, OFF_SOI, soi);
73  setField(&auxPhase1, MASK_CAPID, OFF_CAPID, info.capid());
74 
75  // Pack status bits
76  setBit(&auxPhase1, OFF_TDC_TIME, info.hasTimeInfo());
77  setBit(&auxPhase1, OFF_DROPPED, info.isDropped());
78  setBit(&auxPhase1, OFF_LINK_ERR, info.hasLinkError());
79  setBit(&auxPhase1, OFF_CAPID_ERR, info.hasCapidError());
80 
81  // Copy the aux words into the rechit
82  rechit->setAux(aux);
83  rechit->setAuxHBHE(auxHBHE);
84  rechit->setAuxPhase1(auxPhase1);
85 }
86 
87 #endif // DataFormats_HcalRecHit_HBHERecHitAuxSetter_h_
static const TGPicture * info(bool iBackgroundIsBlack)
static const unsigned MASK_NSAMPLES
constexpr void setField(uint32_t *u, const unsigned mask, const unsigned offset, const unsigned value)
bool hasTimeInfo() const
static const unsigned OFF_SOI
static const unsigned MASK_CAPID
unsigned soi() const
static const unsigned OFF_NSAMPLES
static const unsigned OFF_DROPPED
static const unsigned OFF_CAPID
static const unsigned OFF_TDC_TIME
static const unsigned OFF_CAPID_ERR
static const unsigned OFF_LINK_ERR
static const unsigned OFF_ADC
static const unsigned MASK_ADC
static const unsigned MASK_SOI
void setAuxHBHE(const uint32_t aux)
Definition: HBHERecHit.h:53
constexpr size_t nSamples
void setBit(int &_bitArray, unsigned _iBit)
static void setAux(const HBHEChannelInfo &info, HBHERecHit *rechit)
bool hasLinkError() const
static const unsigned OFF_COMBINED
bool isDropped() const
constexpr void setAux(uint32_t value)
Definition: CaloRecHit.h:51
unsigned nSamples() const
int capid() const
uint8_t tsAdc(const unsigned ts) const
void setAuxPhase1(const uint32_t aux)
Definition: HBHERecHit.h:56
bool hasCapidError() const
#define constexpr