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 }
w2
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
mps_fire.i
i
Definition: mps_fire.py:428
HcalElectronicsId::setHTR
constexpr void setHTR(int crate, int slot, int tb)
Definition: HcalElectronicsId.h:66
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
HcalFiberPattern::HcalFiberPattern
HcalFiberPattern(const std::map< std::string, std::string > &params, const std::vector< uint32_t > &data)
Definition: HcalFiberPattern.cc:12
HcalFiberPattern::getId
HcalElectronicsId getId(int fiberChan)
Definition: HcalFiberPattern.cc:68
HcalFiberPattern::getSamples
std::vector< HcalQIESample > getSamples(int bunch, int npresamples, int nsamples, int fiberChan)
Definition: HcalFiberPattern.cc:49
HcalFiberPattern::spigot_
int spigot_
Definition: HcalFiberPattern.h:25
HcalFiberPattern::crate_
int crate_
Definition: HcalFiberPattern.h:25
HcalFiberPattern::unpack
HcalQIESample unpack(int bc, int fc)
Definition: HcalFiberPattern.cc:22
HcalQIESample
Definition: HcalQIESample.h:32
HcalFiberPattern::pattern_
std::vector< uint32_t > pattern_
Definition: HcalFiberPattern.h:26
HcalFiberPattern::tb_
int tb_
Definition: HcalFiberPattern.h:25
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
benchmark_cfg.fc
fc
Definition: benchmark_cfg.py:15
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalFiberPattern::dcc_
int dcc_
Definition: HcalFiberPattern.h:25
HcalFiberPattern.h
HcalFiberPattern::slot_
int slot_
Definition: HcalFiberPattern.h:25
HcalFiberPattern::fiber_
int fiber_
Definition: HcalFiberPattern.h:25
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cms::Exception
Definition: Exception.h:70
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
setIf
static int setIf(const std::string &name, const std::map< std::string, std::string > &params)
Definition: HcalFiberPattern.cc:4