13 if (noiseWatcher_.check(es)) {
16 if (thresholdWatcher_.check(es)) {
17 threshold_ = &es.
getData(thresholdToken_);
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 selectedSignal.clear();
87 size_t inSize =
in.size();
96 selectedSignal.reserve(inSize);
100 for (
size_t i = 0;
i < inSize;
i++) {
103 auto ladc =
in[
i].adc();
108 auto highThresh =
static_cast<int16_t
>(
thresholds.getHth() *
noise.getNoiseFast(
strip, detNoiseRange) + 0.5f);
109 auto lowThresh =
static_cast<int16_t
>(
thresholds.getLth() *
noise.getNoiseFast(
strip, detNoiseRange) + 0.5f);
112 assert(lowThresh <= highThresh);
115 if (ladc >= lowThresh)
117 if (ladc >= highThresh)
121 for (
size_t i = 0;
i < inSize;
i++) {
125 ldata.stat =
stat[
i];
126 ldata.statPrev = zeroTh;
127 ldata.statNext = zeroTh;
128 ldata.statPrev2 = zeroTh;
129 ldata.statNext2 = zeroTh;
131 if (((
strip) % 128) == 127) {
132 ldata.statNext = zeroTh;
134 ldata.statNext =
stat[
i + 1];
135 if (((
strip) % 128) == 126) {
136 ldata.statNext2 = zeroTh;
138 ldata.statNext2 =
stat[
i + 2];
142 if (((
strip) % 128) == 0) {
143 ldata.statPrev = zeroTh;
145 ldata.statPrev =
stat[
i - 1];
146 if (((
strip) % 128) == 1) {
147 ldata.statPrev2 = zeroTh;
149 ldata.statPrev2 =
stat[
i - 2];
153 ldata.statMaxNeigh =
std::max(ldata.statPrev, ldata.statNext);
155 if (isDigiValid(ldata, theFEDalgorithm)) {
162 const uint32_t detID =
out.id;
165 #ifdef DEBUG_SiStripZeroSuppression_ 168 <<
"[SiStripFedZeroSuppression::suppress] Zero suppression on edm::DetSet<SiStripRawDigi>: detID " << detID
169 <<
" size = " <<
in.data.size();
172 for (; in_iter !=
in.data.end(); in_iter++) {
173 const uint32_t
strip = (uint32_t)(in_iter -
in.data.begin());
175 #ifdef DEBUG_SiStripZeroSuppression_ 177 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] detID= " << detID
178 <<
" strip= " <<
strip <<
" adc= " << in_iter->adc();
180 adc = in_iter->adc();
183 theFEDlowThresh =
static_cast<int16_t
>(
thresholds.getLth() *
noise_->getNoiseFast(
strip, detNoiseRange) + 0.5);
184 theFEDhighThresh =
static_cast<int16_t
>(
thresholds.getHth() *
noise_->getNoiseFast(
strip, detNoiseRange) + 0.5);
194 if (
strip % 128 == 127) {
196 theNextFEDlowThresh = 9999;
197 theNextFEDhighThresh = 9999;
199 adcNext = (in_iter + 1)->
adc();
201 theNextFEDlowThresh =
202 static_cast<int16_t
>(thresholds_1.
getLth() *
noise_->getNoiseFast(
strip + 1, detNoiseRange) + 0.5);
203 theNextFEDhighThresh =
204 static_cast<int16_t
>(thresholds_1.
getHth() *
noise_->getNoiseFast(
strip + 1, detNoiseRange) + 0.5);
210 if (
strip % 128 == 0) {
212 thePrevFEDlowThresh = 9999;
213 thePrevFEDhighThresh = 9999;
215 adcPrev = (in_iter - 1)->
adc();
217 thePrevFEDlowThresh =
218 static_cast<int16_t
>(thresholds_1.
getLth() *
noise_->getNoiseFast(
strip - 1, detNoiseRange) + 0.5);
219 thePrevFEDhighThresh =
220 static_cast<int16_t
>(thresholds_1.
getHth() *
noise_->getNoiseFast(
strip - 1, detNoiseRange) + 0.5);
222 if (adcNext < adcPrev) {
223 adcMaxNeigh = adcPrev;
224 theNeighFEDlowThresh = thePrevFEDlowThresh;
225 theNeighFEDhighThresh = thePrevFEDhighThresh;
227 adcMaxNeigh = adcNext;
228 theNeighFEDlowThresh = theNextFEDlowThresh;
229 theNeighFEDhighThresh = theNextFEDhighThresh;
235 thePrev2FEDlowThresh = 1;
236 theNext2FEDlowThresh = 1;
237 if (
strip % 128 >= 126) {
239 theNext2FEDlowThresh = 9999;
240 }
else if (
strip % 128 < 126) {
241 adcNext2 = (in_iter + 2)->
adc();
242 theNext2FEDlowThresh =
static_cast<int16_t
>(
243 threshold_->getData(
strip + 2, detThRange).getLth() *
noise_->getNoiseFast(
strip + 2, detNoiseRange) + 0.5);
245 if (
strip % 128 <= 1) {
247 thePrev2FEDlowThresh = 9999;
248 }
else if (
strip % 128 > 1) {
249 adcPrev2 = (in_iter - 2)->
adc();
250 thePrev2FEDlowThresh =
static_cast<int16_t
>(
251 threshold_->getData(
strip - 2, detThRange).getLth() *
noise_->getNoiseFast(
strip - 2, detNoiseRange) + 0.5);
263 if (highThr_.size() != size) {
264 highThr_.resize(size);
265 lowThr_.resize(size);
266 noises_.resize(size);
267 highThrSN_.resize(size);
268 lowThrSN_.resize(size);
271 noise_->allNoises(noises_, detNoiseRange);
272 threshold_->allThresholds(lowThrSN_, highThrSN_, detThRange);
277 highThr_[
strip] =
static_cast<int16_t
>(highThrSN_[
strip] *
noise + 0.5 + 1
e-6);
278 lowThr_[
strip] =
static_cast<int16_t
>(lowThrSN_[
strip] *
noise + 0.5 + 1
e-6);
289 const uint32_t detID =
out.id;
290 size_t size =
in.size();
291 #ifdef DEBUG_SiStripZeroSuppression_ 294 <<
"[SiStripFedZeroSuppression::suppress] Zero suppression on std::vector<int16_t>: detID " << detID
295 <<
" size = " <<
in.size();
298 fillThresholds_(detID, size + firstAPV * 128);
300 std::vector<int16_t>::const_iterator in_iter =
in.begin();
301 uint16_t
strip = firstAPV * 128;
302 for (;
strip < size + firstAPV * 128; ++
strip, ++in_iter) {
303 size_t strip_mod_128 =
strip & 127;
304 #ifdef DEBUG_SiStripZeroSuppression_ 306 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] detID= " << detID
307 <<
" strip= " <<
strip <<
" adc= " << *in_iter;
311 theFEDlowThresh = lowThr_[
strip];
312 theFEDhighThresh = highThr_[
strip];
325 if (strip_mod_128 == 127) {
327 theNextFEDlowThresh = 9999;
328 theNextFEDhighThresh = 9999;
330 adcNext = *(in_iter + 1);
331 theNextFEDlowThresh = lowThr_[
strip + 1];
332 theNextFEDhighThresh = highThr_[
strip + 1];
339 if (strip_mod_128 == 0) {
341 thePrevFEDlowThresh = 9999;
342 thePrevFEDhighThresh = 9999;
344 adcPrev = *(in_iter - 1);
345 thePrevFEDlowThresh = lowThr_[
strip - 1];
346 thePrevFEDhighThresh = highThr_[
strip - 1];
349 if (adcNext < adcPrev) {
350 adcMaxNeigh = adcPrev;
351 theNeighFEDlowThresh = thePrevFEDlowThresh;
352 theNeighFEDhighThresh = thePrevFEDhighThresh;
354 adcMaxNeigh = adcNext;
355 theNeighFEDlowThresh = theNextFEDlowThresh;
356 theNeighFEDhighThresh = theNextFEDhighThresh;
364 if (strip_mod_128 >= 126) {
366 theNext2FEDlowThresh = 9999;
369 adcNext2 = *(in_iter + 2);
370 theNext2FEDlowThresh = lowThr_[
strip + 2];
372 if (strip_mod_128 <= 1) {
374 thePrev2FEDlowThresh = 9999;
377 adcPrev2 = *(in_iter - 2);
378 thePrev2FEDlowThresh = lowThr_[
strip - 2];
382 if (isAValidDigi()) {
383 #ifdef DEBUG_SiStripZeroSuppression_ 386 <<
"[SiStripFedZeroSuppression::suppress] DetId " <<
out.id <<
" strip " <<
strip <<
" adc " << *in_iter
387 <<
" digiCollection size " <<
out.data.size();
396 #ifdef DEBUG_SiStripZeroSuppression_ 399 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] " 400 <<
"\n\t adc " <<
adc <<
"\n\t adcPrev " << adcPrev <<
"\n\t adcNext " << adcNext
401 <<
"\n\t adcMaxNeigh " << adcMaxNeigh <<
"\n\t adcPrev2 " << adcPrev2
402 <<
"\n\t adcNext2 " << adcNext2 << std::endl;
404 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] " 405 <<
"\n\t theFEDlowThresh " << theFEDlowThresh <<
"\n\t theFEDhighThresh " 406 << theFEDhighThresh <<
"\n\t thePrevFEDlowThresh " << thePrevFEDlowThresh
407 <<
"\n\t thePrevFEDhighThresh " << thePrevFEDhighThresh
408 <<
"\n\t theNextFEDlowThresh " << theNextFEDlowThresh
409 <<
"\n\t theNextFEDhighThresh " << theNextFEDhighThresh
410 <<
"\n\t theNeighFEDlowThresh " << theNeighFEDlowThresh
411 <<
"\n\t theNeighFEDhighThresh " << theNeighFEDhighThresh
412 <<
"\n\t thePrev2FEDlowThresh " << thePrev2FEDlowThresh
413 <<
"\n\t theNext2FEDlowThresh " << theNext2FEDlowThresh << std::endl;
418 switch (theFEDalgorithm) {
423 accept = (
adc >= theFEDhighThresh || (
adc >= theFEDlowThresh && adcMaxNeigh >= theNeighFEDlowThresh));
426 accept = (
adc >= theFEDhighThresh || (
adc >= theFEDlowThresh && adcMaxNeigh >= theNeighFEDhighThresh));
430 ((
adc >= theFEDhighThresh)
431 || ((
adc >= theFEDlowThresh)
432 && (adcMaxNeigh >= theNeighFEDlowThresh)) ||
433 ((
adc < theFEDlowThresh)
434 && (((adcPrev >= thePrevFEDhighThresh)
435 && (adcNext >= theNextFEDhighThresh)) ||
436 ((adcPrev >= thePrevFEDhighThresh)
437 && (adcNext >= theNextFEDlowThresh)
438 && (adcNext2 >= theNext2FEDlowThresh)) ||
439 ((adcNext >= theNextFEDhighThresh)
440 && (adcPrev >= thePrevFEDlowThresh)
441 && (adcPrev2 >= thePrev2FEDlowThresh)) ||
442 ((adcNext >= theNextFEDlowThresh)
443 && (adcNext2 >= theNext2FEDlowThresh)
444 && (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