16 if (n_cache_id != noise_cache_id) {
18 noise_cache_id = n_cache_id;
20 if (t_cache_id != threshold_cache_id) {
22 threshold_cache_id = t_cache_id;
27 std::vector<SiStripDigi>& selectedSignal,
29 suppress(in, selectedSignal, detID, noiseHandle, thresholdHandle);
33 std::vector<SiStripDigi>& selectedSignal,
38 int inSize = in.size();
43 selectedSignal.clear();
44 selectedSignal.reserve(inSize);
45 for (i = 0; i < inSize; i++) {
47 const uint32_t
strip = (uint32_t)in[i].
strip();
52 theFEDlowThresh =
static_cast<int16_t
>(thresholds.
getLth() * noiseHandle->
getNoiseFast(strip, detNoiseRange) + 0.5);
54 static_cast<int16_t
>(thresholds.
getHth() * noiseHandle->
getNoiseFast(strip, detNoiseRange) + 0.5);
67 theNextFEDlowThresh = theFEDlowThresh;
68 theNext2FEDlowThresh = theFEDlowThresh;
69 thePrevFEDlowThresh = theFEDlowThresh;
70 thePrev2FEDlowThresh = theFEDlowThresh;
71 theNeighFEDlowThresh = theFEDlowThresh;
73 theNextFEDhighThresh = theFEDhighThresh;
74 thePrevFEDhighThresh = theFEDhighThresh;
75 theNeighFEDhighThresh = theFEDhighThresh;
77 if (((strip) % 128) == 127) {
79 theNextFEDlowThresh = 9999;
80 theNextFEDhighThresh = 9999;
81 }
else if (i + 1 < inSize && in[i + 1].
strip() == strip + 1) {
82 adcNext = in[i + 1].adc();
85 static_cast<int16_t
>(thresholds_1.
getLth() * noiseHandle->
getNoiseFast(strip + 1, detNoiseRange) + 0.5);
86 theNextFEDhighThresh =
87 static_cast<int16_t
>(thresholds_1.
getHth() * noiseHandle->
getNoiseFast(strip + 1, detNoiseRange) + 0.5);
88 if (((strip) % 128) == 126) {
90 theNext2FEDlowThresh = 9999;
91 }
else if (i + 2 < inSize && in[i + 2].
strip() == strip + 2) {
92 adcNext2 = in[i + 2].adc();
93 theNext2FEDlowThresh =
static_cast<int16_t
>(thresholdHandle->
getData(strip + 2, detThRange).
getLth() *
99 if (((strip) % 128) == 0) {
101 thePrevFEDlowThresh = 9999;
102 thePrevFEDhighThresh = 9999;
103 }
else if (i - 1 >= 0 && in[i - 1].
strip() == strip - 1) {
104 adcPrev = in[i - 1].adc();
106 thePrevFEDlowThresh =
107 static_cast<int16_t
>(thresholds_1.
getLth() * noiseHandle->
getNoiseFast(strip - 1, detNoiseRange) + 0.5);
108 thePrevFEDhighThresh =
109 static_cast<int16_t
>(thresholds_1.
getHth() * noiseHandle->
getNoiseFast(strip - 1, detNoiseRange) + 0.5);
110 if (((strip) % 128) == 1) {
112 thePrev2FEDlowThresh = 9999;
113 }
else if (i - 2 >= 0 && in[i - 2].
strip() == strip - 2) {
114 adcPrev2 = in[i - 2].adc();
115 thePrev2FEDlowThresh =
static_cast<int16_t
>(thresholdHandle->
getData(strip - 2, detThRange).
getLth() *
121 if (adcNext <= adcPrev) {
122 adcMaxNeigh = adcPrev;
123 theNeighFEDlowThresh = thePrevFEDlowThresh;
124 theNeighFEDhighThresh = thePrevFEDhighThresh;
126 adcMaxNeigh = adcNext;
127 theNeighFEDlowThresh = theNextFEDlowThresh;
128 theNeighFEDhighThresh = theNextFEDhighThresh;
131 if (isAValidDigi()) {
138 const uint32_t detID = out.
id;
141 #ifdef DEBUG_SiStripZeroSuppression_ 144 <<
"[SiStripFedZeroSuppression::suppress] Zero suppression on edm::DetSet<SiStripRawDigi>: detID " << detID
145 <<
" size = " << in.
data.size();
148 for (; in_iter != in.
data.end(); in_iter++) {
149 const uint32_t
strip = (uint32_t)(in_iter - in.
data.begin());
151 #ifdef DEBUG_SiStripZeroSuppression_ 153 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] detID= " << detID
154 <<
" strip= " << strip <<
" adc= " << in_iter->adc();
156 adc = in_iter->adc();
159 theFEDlowThresh =
static_cast<int16_t
>(thresholds.
getLth() * noiseHandle->getNoiseFast(strip, detNoiseRange) + 0.5);
161 static_cast<int16_t
>(thresholds.
getHth() * noiseHandle->getNoiseFast(strip, detNoiseRange) + 0.5);
171 if (strip % 128 == 127) {
173 theNextFEDlowThresh = 9999;
174 theNextFEDhighThresh = 9999;
176 adcNext = (in_iter + 1)->
adc();
178 theNextFEDlowThresh =
179 static_cast<int16_t
>(thresholds_1.
getLth() * noiseHandle->getNoiseFast(strip + 1, detNoiseRange) + 0.5);
180 theNextFEDhighThresh =
181 static_cast<int16_t
>(thresholds_1.
getHth() * noiseHandle->getNoiseFast(strip + 1, detNoiseRange) + 0.5);
187 if (strip % 128 == 0) {
189 thePrevFEDlowThresh = 9999;
190 thePrevFEDhighThresh = 9999;
192 adcPrev = (in_iter - 1)->
adc();
194 thePrevFEDlowThresh =
195 static_cast<int16_t
>(thresholds_1.
getLth() * noiseHandle->getNoiseFast(strip - 1, detNoiseRange) + 0.5);
196 thePrevFEDhighThresh =
197 static_cast<int16_t
>(thresholds_1.
getHth() * noiseHandle->getNoiseFast(strip - 1, detNoiseRange) + 0.5);
199 if (adcNext < adcPrev) {
200 adcMaxNeigh = adcPrev;
201 theNeighFEDlowThresh = thePrevFEDlowThresh;
202 theNeighFEDhighThresh = thePrevFEDhighThresh;
204 adcMaxNeigh = adcNext;
205 theNeighFEDlowThresh = theNextFEDlowThresh;
206 theNeighFEDhighThresh = theNextFEDhighThresh;
212 thePrev2FEDlowThresh = 1;
213 theNext2FEDlowThresh = 1;
214 if (strip % 128 >= 126) {
216 theNext2FEDlowThresh = 9999;
217 }
else if (strip % 128 < 126) {
218 adcNext2 = (in_iter + 2)->
adc();
219 theNext2FEDlowThresh =
static_cast<int16_t
>(thresholdHandle->getData(strip + 2, detThRange).getLth() *
220 noiseHandle->getNoiseFast(strip + 2, detNoiseRange) +
223 if (strip % 128 <= 1) {
225 thePrev2FEDlowThresh = 9999;
226 }
else if (strip % 128 > 1) {
227 adcPrev2 = (in_iter - 2)->
adc();
228 thePrev2FEDlowThresh =
static_cast<int16_t
>(thresholdHandle->getData(strip - 2, detThRange).getLth() *
229 noiseHandle->getNoiseFast(strip - 2, detNoiseRange) +
242 if (highThr_.size() !=
size) {
243 highThr_.resize(size);
244 lowThr_.resize(size);
245 noises_.resize(size);
246 highThrSN_.resize(size);
247 lowThrSN_.resize(size);
250 noiseHandle->allNoises(noises_, detNoiseRange);
251 thresholdHandle->allThresholds(lowThrSN_, highThrSN_, detThRange);
256 highThr_[
strip] =
static_cast<int16_t
>(highThrSN_[
strip] * noise + 0.5 + 1
e-6);
257 lowThr_[
strip] =
static_cast<int16_t
>(lowThrSN_[
strip] * noise + 0.5 + 1
e-6);
268 const uint32_t detID = out.
id;
269 size_t size = in.size();
270 #ifdef DEBUG_SiStripZeroSuppression_ 273 <<
"[SiStripFedZeroSuppression::suppress] Zero suppression on std::vector<int16_t>: detID " << detID
274 <<
" size = " << in.size();
277 fillThresholds_(detID, size + firstAPV * 128);
279 std::vector<int16_t>::const_iterator in_iter = in.begin();
280 uint16_t
strip = firstAPV * 128;
281 for (; strip < size + firstAPV * 128; ++
strip, ++in_iter) {
282 size_t strip_mod_128 = strip & 127;
283 #ifdef DEBUG_SiStripZeroSuppression_ 285 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] detID= " << detID
286 <<
" strip= " << strip <<
" adc= " << *in_iter;
290 theFEDlowThresh = lowThr_[
strip];
291 theFEDhighThresh = highThr_[
strip];
304 if (strip_mod_128 == 127) {
306 theNextFEDlowThresh = 9999;
307 theNextFEDhighThresh = 9999;
309 adcNext = *(in_iter + 1);
310 theNextFEDlowThresh = lowThr_[strip + 1];
311 theNextFEDhighThresh = highThr_[strip + 1];
318 if (strip_mod_128 == 0) {
320 thePrevFEDlowThresh = 9999;
321 thePrevFEDhighThresh = 9999;
323 adcPrev = *(in_iter - 1);
324 thePrevFEDlowThresh = lowThr_[strip - 1];
325 thePrevFEDhighThresh = highThr_[strip - 1];
328 if (adcNext < adcPrev) {
329 adcMaxNeigh = adcPrev;
330 theNeighFEDlowThresh = thePrevFEDlowThresh;
331 theNeighFEDhighThresh = thePrevFEDhighThresh;
333 adcMaxNeigh = adcNext;
334 theNeighFEDlowThresh = theNextFEDlowThresh;
335 theNeighFEDhighThresh = theNextFEDhighThresh;
343 if (strip_mod_128 >= 126) {
345 theNext2FEDlowThresh = 9999;
348 adcNext2 = *(in_iter + 2);
349 theNext2FEDlowThresh = lowThr_[strip + 2];
351 if (strip_mod_128 <= 1) {
353 thePrev2FEDlowThresh = 9999;
356 adcPrev2 = *(in_iter - 2);
357 thePrev2FEDlowThresh = lowThr_[strip - 2];
361 if (isAValidDigi()) {
362 #ifdef DEBUG_SiStripZeroSuppression_ 365 <<
"[SiStripFedZeroSuppression::suppress] DetId " << out.
id <<
" strip " << strip <<
" adc " << *in_iter
366 <<
" digiCollection size " << out.
data.size();
375 #ifdef DEBUG_SiStripZeroSuppression_ 378 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] " 379 <<
"\n\t adc " <<
adc <<
"\n\t adcPrev " << adcPrev <<
"\n\t adcNext " << adcNext
380 <<
"\n\t adcMaxNeigh " << adcMaxNeigh <<
"\n\t adcPrev2 " << adcPrev2
381 <<
"\n\t adcNext2 " << adcNext2 << std::endl;
383 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] " 384 <<
"\n\t theFEDlowThresh " << theFEDlowThresh <<
"\n\t theFEDhighThresh " 385 << theFEDhighThresh <<
"\n\t thePrevFEDlowThresh " << thePrevFEDlowThresh
386 <<
"\n\t thePrevFEDhighThresh " << thePrevFEDhighThresh
387 <<
"\n\t theNextFEDlowThresh " << theNextFEDlowThresh
388 <<
"\n\t theNextFEDhighThresh " << theNextFEDhighThresh
389 <<
"\n\t theNeighFEDlowThresh " << theNeighFEDlowThresh
390 <<
"\n\t theNeighFEDhighThresh " << theNeighFEDhighThresh
391 <<
"\n\t thePrev2FEDlowThresh " << thePrev2FEDlowThresh
392 <<
"\n\t theNext2FEDlowThresh " << theNext2FEDlowThresh << std::endl;
397 switch (theFEDalgorithm) {
399 accept = (
adc >= theFEDlowThresh);
402 accept = (
adc >= theFEDhighThresh || (
adc >= theFEDlowThresh && adcMaxNeigh >= theNeighFEDlowThresh));
405 accept = (
adc >= theFEDhighThresh || (
adc >= theFEDlowThresh && adcMaxNeigh >= theNeighFEDhighThresh));
409 ((
adc >= theFEDhighThresh)
410 || ((
adc >= theFEDlowThresh)
411 && (adcMaxNeigh >= theNeighFEDlowThresh)) ||
412 ((
adc < theFEDlowThresh)
413 && (((adcPrev >= thePrevFEDhighThresh)
414 && (adcNext >= theNextFEDhighThresh)) ||
415 ((adcPrev >= thePrevFEDhighThresh)
416 && (adcNext >= theNextFEDlowThresh)
417 && (adcNext2 >= theNext2FEDlowThresh)) ||
418 ((adcNext >= theNextFEDhighThresh)
419 && (adcPrev >= thePrevFEDlowThresh)
420 && (adcPrev2 >= thePrev2FEDlowThresh)) ||
421 ((adcNext >= theNextFEDlowThresh)
422 && (adcNext2 >= theNext2FEDlowThresh)
423 && (adcPrev >= thePrevFEDlowThresh) && (adcPrev2 >= thePrev2FEDlowThresh)))));
void init(const edm::EventSetup &es)
void push_back(const T &t)
void suppress(const std::vector< SiStripDigi > &in, std::vector< SiStripDigi > &selectedSignal, uint32_t detId, edm::ESHandle< SiStripNoises > &, edm::ESHandle< SiStripThreshold > &)
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
static float getNoiseFast(const uint16_t &strip, const Range &range)
SiStripThreshold::Data getData(const uint16_t &strip, const Range &range) const
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
std::pair< ContainerIterator, ContainerIterator > Range
const Range getRange(const uint32_t detID) const
std::pair< ContainerIterator, ContainerIterator > Range
collection_type::const_iterator const_iterator
const Range getRange(const uint32_t &detID) const
void fillThresholds_(const uint32_t detID, size_t size)