CMS 3D CMS Logo

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