CMS 3D CMS Logo

HcalFiberPattern.cc
Go to the documentation of this file.
3 
4 static inline int setIf(const std::string& name, const std::map<std::string, std::string>& params) {
5  std::map<std::string, std::string>::const_iterator j = params.find(name);
6  if (j == params.end())
7  throw cms::Exception("InvalidFormat") << "Missing parameter '" << name << "'";
8  else
9  return strtol(j->second.c_str(), nullptr, 0);
10 }
11 
12 HcalFiberPattern::HcalFiberPattern(const std::map<std::string, std::string>& params, const std::vector<uint32_t>& data)
13  : pattern_(data) {
14  crate_ = setIf("CRATE", params);
15  slot_ = setIf("SLOT", params);
16  fiber_ = setIf("FIBER", params);
17  dcc_ = setIf("DCC", params);
18  spigot_ = setIf("SPIGOT", params);
19  tb_ = setIf("TOPBOTTOM", params);
20 }
21 
23  uint32_t w1 = pattern_[bc * 2]; // lsw
24  uint32_t w2 = pattern_[bc * 2 + 1]; // msw
25 
26  int adc = 0, capid = 0;
27  bool dv = (w1 & 0x10000) != 0;
28  bool er = (w1 & 0x20000) != 0;
29 
30  switch (fc) {
31  case (0):
32  adc = (w2 & 0xFE00) >> 9;
33  capid = (w1 & 0x0180) >> 7;
34  break;
35  case (1):
36  adc = (w2 & 0xFE) >> 1;
37  capid = (w1 & 0x0060) >> 5;
38  break;
39  case (2):
40  adc = (w1 & 0xFE00) >> 9;
41  capid = (w1 & 0x0018) >> 3;
42  break;
43  default:
44  break;
45  }
46  return HcalQIESample(adc, capid, fiber_, fc, dv, er);
47 }
48 
49 std::vector<HcalQIESample> HcalFiberPattern::getSamples(int bunch, int npresamples, int nsamples, int fiberChan) {
50  if (bunch < npresamples)
51  throw cms::Exception("InvalidArgument")
52  << "Asked for " << npresamples << " presamples with event at bunch " << bunch;
53  if (nsamples - npresamples + bunch >= (int)(pattern_.size() / 2))
54  throw cms::Exception("InvalidArgument")
55  << "Asked for " << nsamples << " with event at " << bunch << " and " << npresamples << " presamples, but only "
56  << pattern_.size() / 2 << " bunches are available";
57 
58  std::vector<HcalQIESample> retval;
59  retval.reserve(nsamples);
60 
61  for (int i = 0; i < nsamples; i++) {
62  int bc = bunch + i - npresamples;
63  retval.push_back(unpack(bc, fiberChan));
64  }
65  return retval;
66 }
67 
69  HcalElectronicsId retval(fiberChan, fiber_, spigot_, dcc_);
70  retval.setHTR(crate_, slot_, tb_);
71  return retval;
72 }
constexpr void setHTR(int crate, int slot, int tb)
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
HcalFiberPattern(const std::map< std::string, std::string > &params, const std::vector< uint32_t > &data)
weight_default_t w1[2000]
Definition: w1.h:9
HcalElectronicsId getId(int fiberChan)
std::vector< uint32_t > pattern_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::vector< HcalQIESample > getSamples(int bunch, int npresamples, int nsamples, int fiberChan)
HcalQIESample unpack(int bc, int fc)
static int setIf(const std::string &name, const std::map< std::string, std::string > &params)
Readout chain identification for Hcal.
uint16_t *__restrict__ uint16_t const *__restrict__ adc