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 suppress(in, selectedSignal, detID, noiseHandle, thresholdHandle);
34 int inSize = in.size();
39 selectedSignal.clear();
40 selectedSignal.reserve(inSize);
41 for (i = 0; i < inSize; i++) {
43 const uint32_t strip = (uint32_t) in[i].strip();
48 theFEDlowThresh =
static_cast<int16_t
>(thresholds.
getLth()*noiseHandle->getNoiseFast(strip,detNoiseRange)+0.5);
49 theFEDhighThresh =
static_cast<int16_t
>(thresholds.
getHth()*noiseHandle->getNoiseFast(strip,detNoiseRange)+0.5);
62 theNextFEDlowThresh = theFEDlowThresh;
63 theNext2FEDlowThresh = theFEDlowThresh;
64 thePrevFEDlowThresh = theFEDlowThresh;
65 thePrev2FEDlowThresh = theFEDlowThresh;
66 theNeighFEDlowThresh = theFEDlowThresh;
68 theNextFEDhighThresh = theFEDhighThresh;
69 thePrevFEDhighThresh = theFEDhighThresh;
70 theNeighFEDhighThresh = theFEDhighThresh;
72 if ( ((strip)%128) == 127){
74 theNextFEDlowThresh = 9999;
75 theNextFEDhighThresh = 9999;
76 }
else if (i + 1 < inSize && in[i+1].strip() == strip + 1) {
77 adcNext = in[i+1].adc();
79 theNextFEDlowThresh =
static_cast<int16_t
>(thresholds_1.
getLth()*noiseHandle->getNoiseFast(strip+1,detNoiseRange)+0.5);
80 theNextFEDhighThresh =
static_cast<int16_t
>(thresholds_1.
getHth()*noiseHandle->getNoiseFast(strip+1,detNoiseRange)+0.5);
81 if ( ((strip)%128) == 126){
83 theNext2FEDlowThresh = 9999;
84 }
else if (i + 2 < inSize && in[i+2].strip() == strip + 2) {
85 adcNext2 = in[i+2].adc();
86 theNext2FEDlowThresh =
static_cast<int16_t
>(thresholdHandle->getData(strip+2,detThRange).getLth()*noiseHandle->getNoiseFast(strip+2,detNoiseRange)+0.5);
90 if ( ((strip)%128) == 0){
92 thePrevFEDlowThresh = 9999;
93 thePrevFEDhighThresh = 9999;
94 }
else if (i - 1 >= 0 && in[i-1].strip() == strip - 1) {
95 adcPrev = in[i-1].adc();
97 thePrevFEDlowThresh =
static_cast<int16_t
>(thresholds_1.
getLth()*noiseHandle->getNoiseFast(strip-1,detNoiseRange)+0.5);
98 thePrevFEDhighThresh =
static_cast<int16_t
>(thresholds_1.
getHth()*noiseHandle->getNoiseFast(strip-1,detNoiseRange)+0.5);
99 if ( ((strip)%128) == 1){
101 thePrev2FEDlowThresh = 9999;
102 }
else if (i - 2 >= 0 && in[i-2].strip() == strip - 2) {
103 adcPrev2 = in[i-2].adc();
104 thePrev2FEDlowThresh =
static_cast<int16_t
>(thresholdHandle->getData(strip-2,detThRange).getLth()*noiseHandle->getNoiseFast(strip-2,detNoiseRange)+0.5);
108 if ( adcNext <= adcPrev){
109 adcMaxNeigh = adcPrev;
110 theNeighFEDlowThresh = thePrevFEDlowThresh;
111 theNeighFEDhighThresh = thePrevFEDhighThresh;
113 adcMaxNeigh = adcNext;
114 theNeighFEDlowThresh = theNextFEDlowThresh;
115 theNeighFEDhighThresh = theNextFEDhighThresh;
126 const uint32_t detID = out.
id;
129 #ifdef DEBUG_SiStripZeroSuppression_
131 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] Zero suppression on edm::DetSet<SiStripRawDigi>: detID " << detID <<
" size = " << in.
data.size();
134 for (;in_iter!=in.
data.end();in_iter++){
136 const uint32_t strip = (uint32_t) (in_iter-in.
data.begin());
138 #ifdef DEBUG_SiStripZeroSuppression_
140 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] detID= " << detID <<
" strip= " << strip <<
" adc= " << in_iter->adc();
142 adc = in_iter->adc();
145 theFEDlowThresh =
static_cast<int16_t
>(thresholds.
getLth()*noiseHandle->getNoiseFast(strip,detNoiseRange)+0.5);
146 theFEDhighThresh =
static_cast<int16_t
>(thresholds.
getHth()*noiseHandle->getNoiseFast(strip,detNoiseRange)+0.5);
156 if ( strip%128 == 127 ) {
158 theNextFEDlowThresh = 9999;
159 theNextFEDhighThresh = 9999;
162 adcNext = (in_iter+1)->
adc();
164 theNextFEDlowThresh =
static_cast<int16_t
>(thresholds_1.
getLth()*noiseHandle->getNoiseFast(strip+1,detNoiseRange)+0.5);
165 theNextFEDhighThresh =
static_cast<int16_t
>(thresholds_1.
getHth()*noiseHandle->getNoiseFast(strip+1,detNoiseRange)+0.5);
171 if ( strip%128 == 0 ) {
173 thePrevFEDlowThresh = 9999;
174 thePrevFEDhighThresh = 9999;
177 adcPrev = (in_iter-1)->
adc();
179 thePrevFEDlowThresh =
static_cast<int16_t
>(thresholds_1.
getLth()*noiseHandle->getNoiseFast(strip-1,detNoiseRange)+0.5);
180 thePrevFEDhighThresh =
static_cast<int16_t
>(thresholds_1.
getHth()*noiseHandle->getNoiseFast(strip-1,detNoiseRange)+0.5);
182 if ( adcNext < adcPrev){
183 adcMaxNeigh = adcPrev;
184 theNeighFEDlowThresh = thePrevFEDlowThresh;
185 theNeighFEDhighThresh = thePrevFEDhighThresh;
187 adcMaxNeigh = adcNext;
188 theNeighFEDlowThresh = theNextFEDlowThresh;
189 theNeighFEDhighThresh = theNextFEDhighThresh;
195 thePrev2FEDlowThresh = 1;
196 theNext2FEDlowThresh = 1;
197 if ( strip%128 >= 126 ) {
199 theNext2FEDlowThresh = 9999;
201 else if ( strip%128 < 126 ) {
202 adcNext2 = (in_iter+2)->
adc();
203 theNext2FEDlowThresh =
static_cast<int16_t
>(thresholdHandle->getData(strip+2,detThRange).getLth()*noiseHandle->getNoiseFast(strip+2,detNoiseRange)+0.5);
205 if ( strip%128 <= 1 ) {
207 thePrev2FEDlowThresh = 9999;
209 else if ( strip%128 > 1 ) {
210 adcPrev2 = (in_iter-2)->
adc();
211 thePrev2FEDlowThresh =
static_cast<int16_t
>(thresholdHandle->getData(strip-2,detThRange).getLth()*noiseHandle->getNoiseFast(strip-2,detNoiseRange)+0.5);
223 if (highThr_.size() !=
size) {
224 highThr_.resize(size);
225 lowThr_.resize(size);
226 noises_.resize(size);
227 highThrSN_.resize(size);
228 lowThrSN_.resize(size);
231 noiseHandle->allNoises(noises_, detNoiseRange);
232 thresholdHandle->allThresholds(lowThrSN_, highThrSN_, detThRange);
233 for (
size_t strip = 0; strip <
size; ++strip) {
234 float noise = noises_[strip];
237 highThr_[strip] =
static_cast<int16_t
>(highThrSN_[strip]*noise+0.5+1
e-6);
238 lowThr_[strip] =
static_cast<int16_t
>( lowThrSN_[strip]*noise+0.5+1
e-6);
249 const uint32_t detID = out.
id;
250 size_t size = in.size();
251 #ifdef DEBUG_SiStripZeroSuppression_
253 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] Zero suppression on std::vector<int16_t>: detID " << detID <<
" size = " << in.size();
256 fillThresholds_(detID, size+firstAPV*128);
259 std::vector<int16_t>::const_iterator in_iter=in.begin();
260 uint16_t strip = firstAPV*128;
261 for (; strip < size+firstAPV*128; ++strip, ++in_iter){
263 size_t strip_mod_128 = strip & 127;
264 #ifdef DEBUG_SiStripZeroSuppression_
266 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] detID= " << detID <<
" strip= " << strip <<
" adc= " << *in_iter;
270 theFEDlowThresh = lowThr_[strip];
271 theFEDhighThresh = highThr_[strip];
284 if ( strip_mod_128 == 127 ) {
286 theNextFEDlowThresh = 9999;
287 theNextFEDhighThresh = 9999;
289 adcNext = *(in_iter+1);
290 theNextFEDlowThresh = lowThr_[strip+1];
291 theNextFEDhighThresh = highThr_[strip+1];
298 if ( strip_mod_128 == 0 ) {
300 thePrevFEDlowThresh = 9999;
301 thePrevFEDhighThresh = 9999;
303 adcPrev = *(in_iter-1);
304 thePrevFEDlowThresh = lowThr_[strip-1];
305 thePrevFEDhighThresh = highThr_[strip-1];
308 if ( adcNext < adcPrev){
309 adcMaxNeigh = adcPrev;
310 theNeighFEDlowThresh = thePrevFEDlowThresh;
311 theNeighFEDhighThresh = thePrevFEDhighThresh;
313 adcMaxNeigh = adcNext;
314 theNeighFEDlowThresh = theNextFEDlowThresh;
315 theNeighFEDhighThresh = theNextFEDhighThresh;
323 if ( strip_mod_128 >=126 ) {
325 theNext2FEDlowThresh = 9999;
328 adcNext2 = *(in_iter+2);
329 theNext2FEDlowThresh = lowThr_[strip+2];
331 if ( strip_mod_128 <= 1 ) {
333 thePrev2FEDlowThresh = 9999;
336 adcPrev2 = *(in_iter-2);
337 thePrev2FEDlowThresh = lowThr_[strip-2];;
341 #ifdef DEBUG_SiStripZeroSuppression_
343 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] DetId " << out.
id <<
" strip " << strip <<
" adc " << *in_iter <<
" digiCollection size " << out.
data.size() ;
355 #ifdef DEBUG_SiStripZeroSuppression_
360 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] "
361 <<
"\n\t adc " <<
adc
362 <<
"\n\t adcPrev " << adcPrev
363 <<
"\n\t adcNext " << adcNext
364 <<
"\n\t adcMaxNeigh " << adcMaxNeigh
365 <<
"\n\t adcPrev2 " << adcPrev2
366 <<
"\n\t adcNext2 " << adcNext2
369 LogTrace(
"SiStripZeroSuppression") <<
"[SiStripFedZeroSuppression::suppress] "
370 <<
"\n\t theFEDlowThresh " << theFEDlowThresh
371 <<
"\n\t theFEDhighThresh " << theFEDhighThresh
372 <<
"\n\t thePrevFEDlowThresh " << thePrevFEDlowThresh
373 <<
"\n\t thePrevFEDhighThresh " << thePrevFEDhighThresh
374 <<
"\n\t theNextFEDlowThresh " << theNextFEDlowThresh
375 <<
"\n\t theNextFEDhighThresh " << theNextFEDhighThresh
376 <<
"\n\t theNeighFEDlowThresh " << theNeighFEDlowThresh
377 <<
"\n\t theNeighFEDhighThresh " << theNeighFEDhighThresh
378 <<
"\n\t thePrev2FEDlowThresh " << thePrev2FEDlowThresh
379 <<
"\n\t theNext2FEDlowThresh " << theNext2FEDlowThresh
385 switch (theFEDalgorithm) {
387 accept = (
adc >= theFEDlowThresh);
390 accept = (
adc >= theFEDhighThresh || (
adc >= theFEDlowThresh &&
391 adcMaxNeigh >= theNeighFEDlowThresh));
394 accept = (
adc >= theFEDhighThresh || (
adc >= theFEDlowThresh &&
395 adcMaxNeigh >= theNeighFEDhighThresh));
399 (
adc >= theFEDhighThresh)
402 (
adc >= theFEDlowThresh)
404 (adcMaxNeigh >= theNeighFEDlowThresh)
408 (
adc < theFEDlowThresh)
412 (adcPrev >= thePrevFEDhighThresh)
414 (adcNext >= theNextFEDhighThresh)
418 (adcPrev >= thePrevFEDhighThresh)
420 (adcNext >= theNextFEDlowThresh)
422 (adcNext2 >= theNext2FEDlowThresh)
426 (adcNext >= theNextFEDhighThresh)
428 (adcPrev >= thePrevFEDlowThresh)
430 (adcPrev2 >= thePrev2FEDlowThresh)
434 (adcNext >= theNextFEDlowThresh)
436 (adcNext2 >= theNext2FEDlowThresh)
438 (adcPrev >= thePrevFEDlowThresh)
440 (adcPrev2 >= thePrev2FEDlowThresh)
int adc(sample_type sample)
get the ADC sample (12 bits)
void init(const edm::EventSetup &es)
void push_back(const T &t)
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
void suppress(const std::vector< SiStripDigi > &, std::vector< SiStripDigi > &, const uint32_t &, edm::ESHandle< SiStripNoises > &, edm::ESHandle< SiStripThreshold > &)
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
std::pair< ContainerIterator, ContainerIterator > Range
std::pair< ContainerIterator, ContainerIterator > Range
collection_type::const_iterator const_iterator
void fillThresholds_(const uint32_t detID, size_t size)
tuple size
Write out results.