13 if (noiseWatcher_.check(es)) {
16 if (thresholdWatcher_.check(es)) {
17 threshold_ = &es.
getData(thresholdToken_);
23 constexpr uint8_t zeroTh = 0;
24 constexpr uint8_t lowTh = 1;
25 constexpr uint8_t highTh = 2;
36 constexpr
bool isDigiValid(Payload
const&
data, uint16_t FEDalgorithm) {
39 switch (FEDalgorithm) {
51 || ((
data.stat >= lowTh)
52 && (
data.statMaxNeigh >= lowTh)) ||
54 && (((
data.statPrev >= highTh)
55 && (
data.statNext >= highTh)) ||
56 ((
data.statPrev >= highTh)
57 && (
data.statNext >= lowTh)
58 && (
data.statNext2 >= lowTh)) ||
59 ((
data.statNext >= highTh)
60 && (
data.statPrev >= lowTh)
61 && (
data.statPrev2 >= lowTh)) ||
62 ((
data.statNext >= lowTh)
63 && (
data.statNext2 >= lowTh)
64 && (
data.statPrev >= lowTh) && (
data.statPrev2 >= lowTh)))));
76 std::vector<SiStripDigi>& selectedSignal,
82 std::vector<SiStripDigi>& selectedSignal,
86 int inSize =
in.size();
91 selectedSignal.clear();
92 selectedSignal.reserve(inSize);
96 for (
int i = 0;
i < inSize;
i++) {
99 auto ladc =
in[
i].adc();
104 auto highThresh =
static_cast<int16_t
>(
thresholds.getHth() *
noise.getNoiseFast(
strip, detNoiseRange) + 0.5f);
105 auto lowThresh =
static_cast<int16_t
>(
thresholds.getLth() *
noise.getNoiseFast(
strip, detNoiseRange) + 0.5f);
108 assert(lowThresh <= highThresh);
111 if (ladc >= lowThresh)
113 if (ladc >= highThresh)
117 for (
int i = 0;
i < inSize;
i++) {
121 ldata.stat =
stat[
i];
122 ldata.statPrev = zeroTh;
123 ldata.statNext = zeroTh;
124 ldata.statPrev2 = zeroTh;
125 ldata.statNext2 = zeroTh;
127 if (((
strip) % 128) == 127) {
128 ldata.statNext = zeroTh;
130 ldata.statNext =
stat[
i + 1];
131 if (((
strip) % 128) == 126) {
132 ldata.statNext2 = zeroTh;
134 ldata.statNext2 =
stat[
i + 2];
138 if (((
strip) % 128) == 0) {
139 ldata.statPrev = zeroTh;
141 ldata.statPrev =
stat[
i - 1];
142 if (((
strip) % 128) == 1) {
143 ldata.statPrev2 = zeroTh;
145 ldata.statPrev2 =
stat[
i - 2];
149 ldata.statMaxNeigh =
std::max(ldata.statPrev, ldata.statNext);
151 if (isDigiValid(ldata, theFEDalgorithm)) {
158 const uint32_t detID =
out.id;
161 #ifdef DEBUG_SiStripZeroSuppression_ 164 <<
"[SiStripFedZeroSuppression::suppress] Zero suppression on edm::DetSet<SiStripRawDigi>: detID " << detID
165 <<
" size = " <<
in.data.size();
168 for (; in_iter !=
in.data.end(); in_iter++) {
169 const uint32_t
strip = (uint32_t)(in_iter -
in.data.begin());
171 #ifdef DEBUG_SiStripZeroSuppression_ 173 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] detID= " << detID
174 <<
" strip= " <<
strip <<
" adc= " << in_iter->adc();
176 adc = in_iter->adc();
179 theFEDlowThresh =
static_cast<int16_t
>(
thresholds.getLth() *
noise_->getNoiseFast(
strip, detNoiseRange) + 0.5);
180 theFEDhighThresh =
static_cast<int16_t
>(
thresholds.getHth() *
noise_->getNoiseFast(
strip, detNoiseRange) + 0.5);
190 if (
strip % 128 == 127) {
192 theNextFEDlowThresh = 9999;
193 theNextFEDhighThresh = 9999;
195 adcNext = (in_iter + 1)->
adc();
197 theNextFEDlowThresh =
198 static_cast<int16_t
>(thresholds_1.
getLth() *
noise_->getNoiseFast(
strip + 1, detNoiseRange) + 0.5);
199 theNextFEDhighThresh =
200 static_cast<int16_t
>(thresholds_1.
getHth() *
noise_->getNoiseFast(
strip + 1, detNoiseRange) + 0.5);
206 if (
strip % 128 == 0) {
208 thePrevFEDlowThresh = 9999;
209 thePrevFEDhighThresh = 9999;
211 adcPrev = (in_iter - 1)->
adc();
213 thePrevFEDlowThresh =
214 static_cast<int16_t
>(thresholds_1.
getLth() *
noise_->getNoiseFast(
strip - 1, detNoiseRange) + 0.5);
215 thePrevFEDhighThresh =
216 static_cast<int16_t
>(thresholds_1.
getHth() *
noise_->getNoiseFast(
strip - 1, detNoiseRange) + 0.5);
218 if (adcNext < adcPrev) {
219 adcMaxNeigh = adcPrev;
220 theNeighFEDlowThresh = thePrevFEDlowThresh;
221 theNeighFEDhighThresh = thePrevFEDhighThresh;
223 adcMaxNeigh = adcNext;
224 theNeighFEDlowThresh = theNextFEDlowThresh;
225 theNeighFEDhighThresh = theNextFEDhighThresh;
231 thePrev2FEDlowThresh = 1;
232 theNext2FEDlowThresh = 1;
233 if (
strip % 128 >= 126) {
235 theNext2FEDlowThresh = 9999;
236 }
else if (
strip % 128 < 126) {
237 adcNext2 = (in_iter + 2)->
adc();
238 theNext2FEDlowThresh =
static_cast<int16_t
>(
239 threshold_->getData(
strip + 2, detThRange).getLth() *
noise_->getNoiseFast(
strip + 2, detNoiseRange) + 0.5);
241 if (
strip % 128 <= 1) {
243 thePrev2FEDlowThresh = 9999;
244 }
else if (
strip % 128 > 1) {
245 adcPrev2 = (in_iter - 2)->
adc();
246 thePrev2FEDlowThresh =
static_cast<int16_t
>(
247 threshold_->getData(
strip - 2, detThRange).getLth() *
noise_->getNoiseFast(
strip - 2, detNoiseRange) + 0.5);
259 if (highThr_.size() !=
size) {
260 highThr_.resize(
size);
261 lowThr_.resize(
size);
262 noises_.resize(
size);
263 highThrSN_.resize(
size);
264 lowThrSN_.resize(
size);
267 noise_->allNoises(noises_, detNoiseRange);
268 threshold_->allThresholds(lowThrSN_, highThrSN_, detThRange);
273 highThr_[
strip] =
static_cast<int16_t
>(highThrSN_[
strip] *
noise + 0.5 + 1
e-6);
274 lowThr_[
strip] =
static_cast<int16_t
>(lowThrSN_[
strip] *
noise + 0.5 + 1
e-6);
285 const uint32_t detID =
out.id;
287 #ifdef DEBUG_SiStripZeroSuppression_ 290 <<
"[SiStripFedZeroSuppression::suppress] Zero suppression on std::vector<int16_t>: detID " << detID
291 <<
" size = " <<
in.size();
294 fillThresholds_(detID,
size + firstAPV * 128);
296 std::vector<int16_t>::const_iterator in_iter =
in.begin();
297 uint16_t
strip = firstAPV * 128;
299 size_t strip_mod_128 =
strip & 127;
300 #ifdef DEBUG_SiStripZeroSuppression_ 302 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] detID= " << detID
303 <<
" strip= " <<
strip <<
" adc= " << *in_iter;
307 theFEDlowThresh = lowThr_[
strip];
308 theFEDhighThresh = highThr_[
strip];
321 if (strip_mod_128 == 127) {
323 theNextFEDlowThresh = 9999;
324 theNextFEDhighThresh = 9999;
326 adcNext = *(in_iter + 1);
327 theNextFEDlowThresh = lowThr_[
strip + 1];
328 theNextFEDhighThresh = highThr_[
strip + 1];
335 if (strip_mod_128 == 0) {
337 thePrevFEDlowThresh = 9999;
338 thePrevFEDhighThresh = 9999;
340 adcPrev = *(in_iter - 1);
341 thePrevFEDlowThresh = lowThr_[
strip - 1];
342 thePrevFEDhighThresh = highThr_[
strip - 1];
345 if (adcNext < adcPrev) {
346 adcMaxNeigh = adcPrev;
347 theNeighFEDlowThresh = thePrevFEDlowThresh;
348 theNeighFEDhighThresh = thePrevFEDhighThresh;
350 adcMaxNeigh = adcNext;
351 theNeighFEDlowThresh = theNextFEDlowThresh;
352 theNeighFEDhighThresh = theNextFEDhighThresh;
360 if (strip_mod_128 >= 126) {
362 theNext2FEDlowThresh = 9999;
365 adcNext2 = *(in_iter + 2);
366 theNext2FEDlowThresh = lowThr_[
strip + 2];
368 if (strip_mod_128 <= 1) {
370 thePrev2FEDlowThresh = 9999;
373 adcPrev2 = *(in_iter - 2);
374 thePrev2FEDlowThresh = lowThr_[
strip - 2];
378 if (isAValidDigi()) {
379 #ifdef DEBUG_SiStripZeroSuppression_ 382 <<
"[SiStripFedZeroSuppression::suppress] DetId " <<
out.id <<
" strip " <<
strip <<
" adc " << *in_iter
383 <<
" digiCollection size " <<
out.data.size();
392 #ifdef DEBUG_SiStripZeroSuppression_ 395 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] " 396 <<
"\n\t adc " <<
adc <<
"\n\t adcPrev " << adcPrev <<
"\n\t adcNext " << adcNext
397 <<
"\n\t adcMaxNeigh " << adcMaxNeigh <<
"\n\t adcPrev2 " << adcPrev2
398 <<
"\n\t adcNext2 " << adcNext2 << std::endl;
400 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] " 401 <<
"\n\t theFEDlowThresh " << theFEDlowThresh <<
"\n\t theFEDhighThresh " 402 << theFEDhighThresh <<
"\n\t thePrevFEDlowThresh " << thePrevFEDlowThresh
403 <<
"\n\t thePrevFEDhighThresh " << thePrevFEDhighThresh
404 <<
"\n\t theNextFEDlowThresh " << theNextFEDlowThresh
405 <<
"\n\t theNextFEDhighThresh " << theNextFEDhighThresh
406 <<
"\n\t theNeighFEDlowThresh " << theNeighFEDlowThresh
407 <<
"\n\t theNeighFEDhighThresh " << theNeighFEDhighThresh
408 <<
"\n\t thePrev2FEDlowThresh " << thePrev2FEDlowThresh
409 <<
"\n\t theNext2FEDlowThresh " << theNext2FEDlowThresh << std::endl;
414 switch (theFEDalgorithm) {
419 accept = (
adc >= theFEDhighThresh || (
adc >= theFEDlowThresh && adcMaxNeigh >= theNeighFEDlowThresh));
422 accept = (
adc >= theFEDhighThresh || (
adc >= theFEDlowThresh && adcMaxNeigh >= theNeighFEDhighThresh));
426 ((
adc >= theFEDhighThresh)
427 || ((
adc >= theFEDlowThresh)
428 && (adcMaxNeigh >= theNeighFEDlowThresh)) ||
429 ((
adc < theFEDlowThresh)
430 && (((adcPrev >= thePrevFEDhighThresh)
431 && (adcNext >= theNextFEDhighThresh)) ||
432 ((adcPrev >= thePrevFEDhighThresh)
433 && (adcNext >= theNextFEDlowThresh)
434 && (adcNext2 >= theNext2FEDlowThresh)) ||
435 ((adcNext >= theNextFEDhighThresh)
436 && (adcPrev >= thePrevFEDlowThresh)
437 && (adcPrev2 >= thePrev2FEDlowThresh)) ||
438 ((adcNext >= theNextFEDlowThresh)
439 && (adcNext2 >= theNext2FEDlowThresh)
440 && (adcPrev >= thePrevFEDlowThresh) && (adcPrev2 >= thePrev2FEDlowThresh)))));
void init(const edm::EventSetup &es)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
std::pair< ContainerIterator, ContainerIterator > Range
void suppress(const std::vector< SiStripDigi > &in, std::vector< SiStripDigi > &selectedSignal, uint32_t detId, const SiStripNoises &, const SiStripThreshold &)
char data[epos_bytes_allocation]
std::pair< ContainerIterator, ContainerIterator > Range
collection_type::const_iterator const_iterator
void fillThresholds_(const uint32_t detID, size_t size)
uint16_t *__restrict__ uint16_t const *__restrict__ adc