CMS 3D CMS Logo

HcalZSAlgoRealistic.cc
Go to the documentation of this file.
2 #include <iostream>
3 
5  bool use1ts,
6  int levelHB,
7  int levelHE,
8  int levelHO,
9  int levelHF,
10  std::pair<int, int> HBsearchTS,
11  std::pair<int, int> HEsearchTS,
12  std::pair<int, int> HOsearchTS,
13  std::pair<int, int> HFsearchTS)
15  use1ts_(use1ts),
16  thresholdHB_(levelHB),
17  thresholdHE_(levelHE),
18  thresholdHO_(levelHO),
19  thresholdHF_(levelHF),
20  HBsearchTS_(HBsearchTS),
21  HEsearchTS_(HEsearchTS),
22  HOsearchTS_(HOsearchTS),
23  HFsearchTS_(HFsearchTS) {
24  usingDBvalues = false;
25 }
26 
28  bool use1ts,
29  std::pair<int, int> HBsearchTS,
30  std::pair<int, int> HEsearchTS,
31  std::pair<int, int> HOsearchTS,
32  std::pair<int, int> HFsearchTS)
34  use1ts_(use1ts),
35  HBsearchTS_(HBsearchTS),
36  HEsearchTS_(HEsearchTS),
37  HOsearchTS_(HOsearchTS),
38  HFsearchTS_(HFsearchTS) {
39  thresholdHB_ = -1;
40  thresholdHE_ = -1;
41  thresholdHO_ = -1;
42  thresholdHF_ = -1;
43  usingDBvalues = true;
44 }
45 
46 template <class Digi>
47 bool HcalZSAlgoRealistic::keepMe(const Digi &inp, int start, int finish, int threshold, uint32_t zsmask) const {
48  if ((usingDBvalues) && (threshold < 0) && (m_dbService != nullptr)) {
49  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
50  }
51 
52  // determine the sum of 2 timeslices
53  for (int i = start; i < finish; i++) {
54  if ((zsmask & (1 << i)) != 0)
55  continue;
56  if ((inp[i].adc() + inp[i + 1].adc()) >= threshold)
57  return true;
58  }
59  return false;
60 }
61 
62 // zs mask not used for QIE10,11
63 
64 template <>
65 bool HcalZSAlgoRealistic::keepMe<QIE10DataFrame>(
66  const QIE10DataFrame &inp, int start, int finish, int threshold, uint32_t zsmask) const {
67  if ((usingDBvalues) && (threshold < 0) && (m_dbService != nullptr)) {
68  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
69  }
70 
71  // determine the sum of 2 timeslices
72  for (int i = start; i < finish; i++) {
73  if ((inp[i].adc() + inp[i + 1].adc()) >= threshold)
74  return true;
75  }
76  return false;
77 }
78 
79 template <>
80 bool HcalZSAlgoRealistic::keepMe<QIE11DataFrame>(
81  const QIE11DataFrame &inp, int start, int finish, int threshold, uint32_t zsmask) const {
82  if ((usingDBvalues) && (threshold < 0) && (m_dbService != nullptr)) {
83  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
84  }
85 
86  // sum of 2 timeslices or just single one
87  for (int i = start; i < finish; i++) {
88  int sum = inp[i].adc();
89  if (!use1ts_)
90  sum += inp[i + 1].adc();
91  if (sum >= threshold)
92  return true;
93  }
94  return false;
95 }
96 
98  if (digi.id().subdet() == HcalBarrel) {
99  int start = std::max(0, HBsearchTS_.first);
100  int finish = std::min(digi.size() - 1, HBsearchTS_.second);
101  return keepMe(digi, start, finish, thresholdHB_, digi.zsCrossingMask());
102  } else {
103  int start = std::max(0, HEsearchTS_.first);
104  int finish = std::min(digi.size() - 1, HEsearchTS_.second);
105  return keepMe(digi, start, finish, thresholdHE_, digi.zsCrossingMask());
106  }
107 }
108 
110  int start = std::max(0, HOsearchTS_.first);
111  int finish = std::min(digi.size() - 1, HOsearchTS_.second);
112  return keepMe(digi, start, finish, thresholdHO_, digi.zsCrossingMask());
113 }
114 
116  int start = std::max(0, HFsearchTS_.first);
117  int finish = std::min(digi.size() - 1, HFsearchTS_.second);
118  return keepMe(digi, start, finish, thresholdHF_, digi.zsCrossingMask());
119 }
120 
122  int start = std::max(0, HFsearchTS_.first);
123  int finish = std::min((int)digi.samples() - 1, HFsearchTS_.second);
124  return keepMe(digi, start, finish, thresholdHF_, 0);
125 }
126 
128  HcalDetId hid(digi.id());
129  if (hid.subdet() == HcalBarrel) {
130  int start = std::max(0, HBsearchTS_.first);
131  int finish = std::min(digi.samples() - 1, HBsearchTS_.second);
132  return keepMe(digi, start, finish, thresholdHB_, 0);
133  } else {
134  int start = std::max(0, HEsearchTS_.first);
135  int finish = std::min(digi.samples() - 1, HEsearchTS_.second);
136  return keepMe(digi, start, finish, thresholdHE_, 0);
137  }
138 }
const HcalDbService * m_dbService
bool keepMe(const Digi &inp, int start, int finish, int threshold, uint32_t zsmask) const
Definition: start.py:1
constexpr uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HFDataFrame.h:35
const HcalZSThreshold * getHcalZSThreshold(const HcalGenericDetId &fId) const
constexpr edm::DataFrame::id_type id() const
bool shouldKeep(const HBHEDataFrame &digi) const override
constexpr uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HODataFrame.h:35
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
std::pair< int, int > HOsearchTS_
std::pair< int, int > HBsearchTS_
constexpr uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HBHEDataFrame.h:35
constexpr int size() const
total number of samples in the digi
Definition: HFDataFrame.h:27
constexpr const HcalDetId & id() const
Definition: HBHEDataFrame.h:23
constexpr int samples() const
total number of samples in the digi
std::pair< int, int > HFsearchTS_
HcalZSAlgoRealistic(bool markAndPass, bool use1ts, std::pair< int, int > HBsearchTS, std::pair< int, int > HEsearchTS, std::pair< int, int > HOsearchTS, std::pair< int, int > HFsearchTS)
constexpr int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
std::pair< int, int > HEsearchTS_
constexpr int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:27
constexpr int samples() const
total number of samples in the digi
uint16_t *__restrict__ uint16_t const *__restrict__ adc