9 quality_cache_id(-1), noise_cache_id(-1), pedestal_cache_id(-1),
10 ForceNoRestore_(conf.getParameter<bool>(
"ForceNoRestore")),
11 SelfSelectRestoreAlgo_(conf.getParameter<bool>(
"SelfSelectRestoreAlgo")),
12 InspectAlgo_(conf.getParameter<std::string>(
"APVInspectMode")),
13 RestoreAlgo_(conf.getParameter<std::string>(
"APVRestoreMode")),
14 useRealMeanCM_(conf.getParameter<bool>(
"useRealMeanCM")),
15 fraction_(conf.getParameter<double>(
"Fraction")),
16 deviation_(conf.getParameter<uint32_t>(
"Deviation")),
17 restoreThreshold_(conf.getParameter<double>(
"restoreThreshold")),
18 DeltaCMThreshold_(conf.getParameter<uint32_t>(
"DeltaCMThreshold")),
19 nSigmaNoiseDerTh_(conf.getParameter<uint32_t>(
"nSigmaNoiseDerTh")),
20 consecThreshold_(conf.getParameter<uint32_t>(
"consecThreshold")),
21 hitStripThreshold_(conf.getParameter<uint32_t>(
"hitStripThreshold")),
22 nSmooth_(conf.getParameter<uint32_t>(
"nSmooth")),
23 minStripsToFit_(conf.getParameter<uint32_t>(
"minStripsToFit")),
24 distortionThreshold_(conf.getParameter<uint32_t>(
"distortionThreshold")),
25 CutToAvoidSignal_(conf.getParameter<double>(
"CutToAvoidSignal")),
26 nSaturatedStrip_(conf.getParameter<uint32_t>(
"nSaturatedStrip")),
27 ApplyBaselineCleaner_(conf.getParameter<bool>(
"ApplyBaselineCleaner")),
28 slopeX_(conf.getParameter<int32_t>(
"slopeX")),
29 slopeY_(conf.getParameter<int32_t>(
"slopeY")),
30 CleaningSequence_(conf.getParameter<uint32_t>(
"CleaningSequence")),
31 ApplyBaselineRejection_(conf.getParameter<bool>(
"ApplyBaselineRejection")),
32 MeanCM_(conf.getParameter<int32_t>(
"MeanCM")),
33 filteredBaselineMax_(conf.getParameter<double>(
"filteredBaselineMax")),
34 filteredBaselineDerivativeSumSquare_(conf.getParameter<double>(
"filteredBaselineDerivativeSumSquare"))
72 int16_t
SiStripAPVRestorer::InspectAndRestore(
const uint32_t& detId,
const uint16_t& firstAPV, std::vector<int16_t>& rawDigisPedSubtracted, std::vector<int16_t>& processedRawDigi,
const std::vector< std::pair<short,float> >& vmedians ){
73 int16_t nAPVFlagged = this->
inspect(detId, firstAPV, rawDigisPedSubtracted, vmedians);
74 this->
restore(firstAPV, processedRawDigi);
79 int16_t
SiStripAPVRestorer::inspect(
const uint32_t& detId,
const uint16_t& firstAPV, std::vector<int16_t>& digis,
const std::vector< std::pair<short,float> >& vmedians) {
95 for(
size_t i=0;
i< vmedians.size(); ++
i){
96 short APV = vmedians[
i].first;
105 throw cms::Exception(
"Unregistered Inspect Algorithm") <<
"SiStripAPVRestorer possibilities: (Null), (AbnormalBaseline),(BaselineFollower)";
114 for( uint16_t
APV=firstAPV;
APV< digis.size()/128 + firstAPV; ++
APV){
117 if ( algoToUse !=
""){
120 if(algoToUse==
"Flat"){
122 }
else if(algoToUse==
"BaselineFollower"){
125 throw cms::Exception(
"Unregistered Restore Algorithm") <<
"SiStripAPVRestorer possibilities: (Flat), (BaselineFollower)";
142 std::vector<T> singleAPVdigi;
143 int16_t nAPVflagged = 0;
145 CMMap::iterator itCMMap;
148 for(uint16_t
APV=firstAPV ;
APV< digis.size()/128 + firstAPV; ++
APV){
151 smoothedmap.erase(smoothedmap.begin(), smoothedmap.end());
157 singleAPVdigi.clear();
158 for(int16_t
strip = (APV-firstAPV)*128;
strip < (APV-firstAPV+1)*128; ++
strip){
159 singleAPVdigi.push_back(digis[
strip]);
186 std::vector<T> singleAPVdigi;
187 singleAPVdigi.clear();
190 int16_t nAPVflagged = 0;
192 CMMap::iterator itCMMap;
195 for(uint16_t
APV=firstAPV ;
APV< digis.size()/128 + firstAPV; ++
APV){
201 singleAPVdigi.clear();
203 uint16_t nSatStrip =0;
204 for(int16_t
strip = (APV-firstAPV)*128;
strip < (APV-firstAPV+1)*128; ++
strip){
205 singleAPVdigi.push_back(digis[
strip]);
206 if(digis[strip] >=1023) ++nSatStrip;
229 typename std::vector<T>::iterator fs;
231 int16_t nAPVflagged=0;
233 CMMap::iterator itCMMap;
237 int devCount = 0, qualityCount = 0, minstrip = 0;
238 for(uint16_t
APV=firstAPV ;
APV< digis.size()/128 + firstAPV; ++
APV){
243 for (uint16_t istrip=APV*128; istrip<(APV+1)*128; ++istrip){
244 fs = digis.begin() + istrip-firstAPV*128;
249 minstrip =
std::min((
int) *fs, minstrip);
254 if( devCount >
fraction_ * qualityCount ) {
273 typename std::vector<T>::iterator fs;
275 int16_t nAPVflagged = 0;
277 for(uint16_t
APV=firstAPV ;
APV< digis.size()/128 + firstAPV; ++
APV){
280 int zeroCount = 0, qualityCount = 0;
281 for (uint16_t istrip=APV*128; istrip<(APV+1)*128; ++istrip){
282 fs = digis.begin() + istrip-firstAPV*128;
285 if ( (
int) *fs < 1 ) zeroCount++;
311 std::vector<int16_t> baseline;
313 baseline.insert(baseline.begin(),128, 0);
321 std::map<uint16_t, DigiMap >::iterator itSmootedMap =
SmoothedMaps_.find(APVn);
326 std::vector<int16_t> singleAPVdigi;
327 singleAPVdigi.clear();
328 for(int16_t
strip = (APVn-firstAPV)*128;
strip < (APVn-firstAPV+1)*128; ++
strip) singleAPVdigi.push_back(digis[
strip]);
340 for(int16_t itStrip= 0 ; itStrip< 128; ++itStrip){
341 digis[(APVn-firstAPV)*128+itStrip] -= baseline[itStrip] - median;
355 std::vector<int16_t> baseline;
357 baseline.insert(baseline.begin(),128, 150);
358 baseline[0]=0; baseline[127]=0;
361 for(int16_t itStrip= 0 ; itStrip< 128; ++itStrip){
362 digis[(APVn-firstAPV)*128+itStrip] = baseline[itStrip];
379 consecpoints.erase(consecpoints.begin(), consecpoints.end());
380 smoothedpoints.erase(smoothedpoints.begin(), smoothedpoints.end());
384 std::vector<float> adcsLocalMinSubtracted;
385 adcsLocalMinSubtracted.clear();
386 adcsLocalMinSubtracted.insert(adcsLocalMinSubtracted.begin(), 128,0);
387 for(uint32_t istrip=0; istrip<128; ++istrip) {
388 float localmin = 999.9;
390 float nextvalue = adcs[jstrip];
391 if(nextvalue < localmin) localmin=nextvalue;
393 adcsLocalMinSubtracted[istrip] = adcs[istrip] - localmin;
398 std::vector<uint16_t> nConsStrip;
402 uint16_t consecStrips=0;
403 for(uint32_t istrip=0; istrip<128; ++istrip) {
404 int16_t
adc = adcs[istrip];
408 consecpoints.insert(consecpoints.end(), std::pair<uint16_t, int16_t >(istrip,
adc));
410 }
else if (consecStrips >0){
411 nConsStrip.push_back(consecStrips);
417 if(consecStrips >0) nConsStrip.push_back(consecStrips);
420 itConsecpoints = consecpoints.begin();
421 float MinSmoothValue=20000., MaxSmoothValue=0.;
422 for(std::vector<uint16_t>::iterator itnConsStrip = nConsStrip.begin(); itnConsStrip < nConsStrip.end(); ++itnConsStrip){
424 consecStrips = *itnConsStrip;
427 uint16_t nFirstStrip = itConsecpoints->first;
429 float smoothValue = 0.0;
431 for(uint16_t
n =0;
n < consecStrips-2; ++
n){
432 smoothValue += itConsecpoints->second;
434 smoothValue /= (float)stripCount;
435 nLastStrip = nFirstStrip + stripCount -1;
436 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nFirstStrip, smoothValue));
437 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nLastStrip, smoothValue));
438 if(smoothValue > MaxSmoothValue) MaxSmoothValue = smoothValue;
439 if(smoothValue < MinSmoothValue) MinSmoothValue = smoothValue;
440 nFirstStrip = nLastStrip+1;
452 smoothValue /= (float)(stripCount);
453 nLastStrip = nFirstStrip + stripCount -1;
454 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nFirstStrip, smoothValue));
455 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nLastStrip, smoothValue));
456 if(smoothValue > MaxSmoothValue) MaxSmoothValue = smoothValue;
457 if(smoothValue < MinSmoothValue) MinSmoothValue = smoothValue;
460 for(
int n =0;
n< consecStrips ; ++
n) ++itConsecpoints;
498 if(smoothedpoints.size() < 3)
return;
499 DigiMapIter itSmoothedpoints, itSmoothedpointsNext, itSmoothedpointsNextNext, itSmoothedpointsBegin, itSmoothedpointsEnd;
501 itSmoothedpoints=smoothedpoints.begin();
502 while (smoothedpoints.size() > 3 && itSmoothedpoints != --(--(smoothedpoints.end()))) {
504 itSmoothedpointsNext = itSmoothedpoints;
505 ++itSmoothedpointsNext;
506 itSmoothedpointsNextNext = itSmoothedpointsNext;
507 ++itSmoothedpointsNextNext;
508 float adc1 = itSmoothedpoints->second;
509 float adc2 = itSmoothedpointsNext->second;
510 float adc3 = itSmoothedpointsNextNext->second;
513 smoothedpoints.erase(itSmoothedpointsNext);
527 DigiMapIter itSmoothedpoints, itSmoothedpointsNext, itSmoothedpointsBegin, itSmoothedpointsEnd;
528 if(smoothedpoints.size() >= 2){
530 itSmoothedpointsBegin = smoothedpoints.begin();
531 itSmoothedpointsEnd = --(smoothedpoints.end());
532 for(itSmoothedpoints = itSmoothedpointsBegin; itSmoothedpoints != itSmoothedpointsEnd; ++itSmoothedpoints){
533 itSmoothedpointsNext = itSmoothedpoints;
534 ++itSmoothedpointsNext;
535 float strip1 = itSmoothedpoints->first;
536 float strip2 = itSmoothedpointsNext->first;
537 float adc1 = itSmoothedpoints->second;
538 float adc2 = itSmoothedpointsNext->second;
539 float m = (adc2 -adc1)/(strip2 -strip1);
544 float strip = itStrip + strip1;
545 while(strip < strip2){
548 if( adc < (adc1 + m * itStrip - 2 * (
float)
noiseHandle->getNoiseFast(strip+APVn*128,detNoiseRange))){
550 smoothedpoints.insert(itSmoothedpointsNext, std::pair<uint16_t, int16_t >(strip,adc));
552 ++itSmoothedpointsNext;
553 itSmoothedpointsEnd = --(smoothedpoints.end());
565 itSmoothedpointsBegin = smoothedpoints.begin();
566 itSmoothedpointsEnd = --(smoothedpoints.end());
567 uint16_t firstStripFlat = itSmoothedpointsBegin->first;
568 uint16_t lastStripFlat = itSmoothedpointsEnd->first;
569 int16_t firstStripFlatADC= itSmoothedpointsBegin->second;
570 int16_t lastStripFlatADC= itSmoothedpointsEnd->second;
572 itSmoothedpoints = itSmoothedpointsBegin;
573 if(firstStripFlat >3){
575 while(strip < firstStripFlat){
577 if( adc < ( firstStripFlatADC - 2 * (
float)
noiseHandle->getNoiseFast(strip+APVn*128,detNoiseRange))){
578 smoothedpoints.insert(itSmoothedpoints, std::pair<uint16_t, int16_t >(strip,adc));
585 itSmoothedpoints = itSmoothedpointsEnd;
586 if(lastStripFlat <125){
587 float strip = lastStripFlat+1;
590 if( adc < ( lastStripFlatADC - 2 * (
float)
noiseHandle->getNoiseFast(strip+APVn*128,detNoiseRange))){
591 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(
strip,
adc));
603 if(smoothedpoints.size() < 4)
return;
604 DigiMapIter itSmoothedpoints, itSmoothedpointsNext, itSmoothedpointsBegin, itSmoothedpointsEnd;
605 itSmoothedpoints=smoothedpoints.begin();
606 while (smoothedpoints.size() >2 && itSmoothedpoints != --(smoothedpoints.end()) ) {
609 itSmoothedpointsNext = itSmoothedpoints;
610 ++itSmoothedpointsNext;
611 float strip1 = itSmoothedpoints->first;
612 float strip2 = itSmoothedpointsNext->first;
613 float adc1 = itSmoothedpoints->second;
614 float adc2 = itSmoothedpointsNext->second;
615 float m = (adc2 -adc1)/(strip2 -strip1);
618 smoothedpoints.erase(itSmoothedpointsNext);
621 if(itSmoothedpoints==smoothedpoints.begin()) smoothedpoints.erase(itSmoothedpoints++);
623 else smoothedpoints.erase(itSmoothedpoints--);
639 baseline.insert(baseline.begin(),128, median);
641 baseline.insert(baseline.begin(),128, 0);
643 DigiMapIter itSmoothedpointsBegin, itSmoothedpointsEnd;
644 itSmoothedpointsBegin = smoothedpoints.begin();
645 itSmoothedpointsEnd = --(smoothedpoints.end());
648 uint16_t firstStripFlat = itSmoothedpointsBegin->first;
649 uint16_t lastStripFlat = itSmoothedpointsEnd->first;
650 int16_t firstStripFlatADC= itSmoothedpointsBegin->second;
651 int16_t lastStripFlatADC= itSmoothedpointsEnd->second;
654 baseline.erase(baseline.begin(), baseline.begin()+firstStripFlat);
655 baseline.insert(baseline.begin(), firstStripFlat, firstStripFlatADC);
657 baseline.erase(baseline.begin()+lastStripFlat, baseline.end());
658 baseline.insert(baseline.end(), 128 - lastStripFlat, lastStripFlatADC);
662 for(itSmoothedpoints = itSmoothedpointsBegin; itSmoothedpoints != itSmoothedpointsEnd; ++itSmoothedpoints){
663 DigiMapIter itSmoothedpointsNext = itSmoothedpoints;
664 ++itSmoothedpointsNext;
665 float strip1 = itSmoothedpoints->first;
666 float strip2 = itSmoothedpointsNext->first;
667 float adc1 = itSmoothedpoints->second;
668 float adc2 = itSmoothedpointsNext->second;
670 baseline[strip1] = adc1;
671 baseline[strip2] = adc2;
672 float m = (adc2 -adc1)/(strip2 -strip1);
673 uint16_t itStrip = strip1 +1;
674 float stripadc = adc1 +
m;
675 while(itStrip < strip2){
676 baseline[itStrip] = stripadc;
709 static const size_t savitzky_golay_n_l_r = 16;
710 static const float savitzky_golay_coefficient
711 [2 * savitzky_golay_n_l_r + 1][2 * savitzky_golay_n_l_r + 1] = {
712 { 0.422085, 0.325077, 0.23839, 0.162023, 0.0959752, 0.0402477,
713 -0.00515996, -0.0402477, -0.0650155, -0.0794634, -0.0835913,
714 -0.0773994, -0.0608875, -0.0340557, 0.00309598, 0.0505676,
716 { 0.315789, 0.254902, 0.19969, 0.150155, 0.106295, 0.0681115,
717 0.0356037, 0.00877193, -0.0123839, -0.0278638, -0.0376677,
718 -0.0417957, -0.0402477, -0.0330237, -0.0201238, -0.00154799,
719 0.0227038, 0.0526316 },
720 { 0.234586, 0.198496, 0.165207, 0.134719, 0.107032, 0.0821465,
721 0.0600619, 0.0407784, 0.024296, 0.0106148, -0.000265369,
722 -0.00834439, -0.0136223, -0.0160991, -0.0157747, -0.0126493,
723 -0.00672269, 0.00200501, 0.0135338 },
724 { 0.172078, 0.153076, 0.135099, 0.118148, 0.102221, 0.0873206,
725 0.073445, 0.0605947, 0.0487697, 0.0379699, 0.0281955,
726 0.0194463, 0.0117225, 0.00502392, -0.000649351, -0.00529733,
727 -0.00892003, -0.0115174, -0.0130895, -0.0136364 },
728 { 0.123659, 0.116431, 0.109144, 0.101798, 0.0943921, 0.0869268,
729 0.0794021, 0.0718179, 0.0641743, 0.0564712, 0.0487087,
730 0.0408868, 0.0330054, 0.0250646, 0.0170644, 0.00900473,
731 0.000885613, -0.00729294, -0.0155309, -0.0238283,
733 { 0.0859684, 0.0868154, 0.0869565, 0.0863919, 0.0851214,
734 0.0831451, 0.080463, 0.0770751, 0.0729814, 0.0681818,
735 0.0626765, 0.0564653, 0.0495483, 0.0419255, 0.0335968,
736 0.0245624, 0.0148221, 0.00437606, -0.00677583, -0.0186335,
737 -0.0311971, -0.0444664 },
738 { 0.0565217, 0.0628458, 0.0680971, 0.0722756, 0.0753811,
739 0.0774139, 0.0783738, 0.0782609, 0.0770751, 0.0748165,
740 0.071485, 0.0670807, 0.0616036, 0.0550536, 0.0474308,
741 0.0387352, 0.0289667, 0.0181254, 0.00621118, -0.00677583,
742 -0.0208357, -0.0359684, -0.0521739 },
743 { 0.0334615, 0.0434281, 0.0521329, 0.0595759, 0.0657571,
744 0.0706765, 0.0743341, 0.07673, 0.0778641, 0.0777364,
745 0.0763469, 0.0736957, 0.0697826, 0.0646078, 0.0581712,
746 0.0504728, 0.0415126, 0.0312907, 0.0198069, 0.00706142,
747 -0.00694588, -0.022215, -0.0387458, -0.0565385 },
748 { 0.0153846, 0.0276923, 0.0386622, 0.0482943, 0.0565886,
749 0.0635452, 0.0691639, 0.0734448, 0.076388, 0.0779933,
750 0.0782609, 0.0771906, 0.0747826, 0.0710368, 0.0659532,
751 0.0595318, 0.0517726, 0.0426756, 0.0322408, 0.0204682,
752 0.00735786, -0.0070903, -0.0228763, -0.04, -0.0584615 },
753 { 0.001221, 0.0149451, 0.027326, 0.0383639, 0.0480586,
754 0.0564103, 0.0634188, 0.0690842, 0.0734066, 0.0763858,
755 0.078022, 0.078315, 0.077265, 0.0748718, 0.0711355,
756 0.0660562, 0.0596337, 0.0518681, 0.0427595, 0.0323077,
757 0.0205128, 0.00737485, -0.00710623, -0.0229304, -0.0400977,
759 { -0.00985222, 0.00463138, 0.0178098, 0.029683, 0.0402509,
760 0.0495137, 0.0574713, 0.0641236, 0.0694708, 0.0735127,
761 0.0762494, 0.0776809, 0.0778073, 0.0766284, 0.0741442,
762 0.0703549, 0.0652604, 0.0588607, 0.0511557, 0.0421456,
763 0.0318302, 0.0202097, 0.0072839, -0.00694708, -0.0224833,
764 -0.0393247, -0.0574713 },
765 { -0.0184729, -0.00369458, 0.00984169, 0.0221359, 0.0331881,
766 0.0429982, 0.0515662, 0.0588923, 0.0649762, 0.0698181,
767 0.073418, 0.0757758, 0.0768915, 0.0767652, 0.0753968,
768 0.0727864, 0.0689339, 0.0638394, 0.0575028, 0.0499242,
769 0.0411035, 0.0310408, 0.019736, 0.00718917, -0.00659972,
770 -0.0216307, -0.0379037, -0.0554187 },
771 { -0.025139, -0.0103925, 0.00318873, 0.0156046, 0.0268552,
772 0.0369405, 0.0458605, 0.0536151, 0.0602045, 0.0656285,
773 0.0698872, 0.0729806, 0.0749086, 0.0756714, 0.0752688,
774 0.0737009, 0.0709677, 0.0670692, 0.0620054, 0.0557763,
775 0.0483818, 0.039822, 0.0300969, 0.0192065, 0.0071508,
776 -0.00607024, -0.0204566, -0.0360083, -0.0527253 },
777 { -0.0302419, -0.0157536, -0.00234785, 0.00997537, 0.021216,
778 0.0313741, 0.0404497, 0.0484427, 0.0553532, 0.0611811,
779 0.0659264, 0.0695892, 0.0721695, 0.0736672, 0.0740823,
780 0.0734149, 0.0716649, 0.0688324, 0.0649174, 0.0599198,
781 0.0538396, 0.0466769, 0.0384316, 0.0291038, 0.0186934,
782 0.00720046, -0.00537502, -0.0190331, -0.0337736,
784 { -0.0340909, -0.0200147, -0.006937, 0.00514208, 0.0162226,
785 0.0263045, 0.0353878, 0.0434725, 0.0505587, 0.0566463,
786 0.0617353, 0.0658257, 0.0689175, 0.0710107, 0.0721054,
787 0.0722014, 0.0712989, 0.0693978, 0.0664981, 0.0625999,
788 0.057703, 0.0518076, 0.0449135, 0.0370209, 0.0281297,
789 0.01824, 0.0073516, -0.00453534, -0.0174209, -0.031305,
791 { -0.0369318, -0.0233688, -0.0107221, 0.00100806, 0.0118218,
792 0.0217192, 0.0307001, 0.0387647, 0.0459128, 0.0521444,
793 0.0574597, 0.0618585, 0.0653409, 0.0679069, 0.0695565,
794 0.0702896, 0.0701063, 0.0690066, 0.0669905, 0.0640579,
795 0.0602089, 0.0554435, 0.0497617, 0.0431635, 0.0356488,
796 0.0272177, 0.0178702, 0.0076063, -0.00357405, -0.0156708,
797 -0.028684, -0.0426136 },
798 { -0.038961, -0.025974, -0.0138249, -0.00251362, 0.00795978,
799 0.0175953, 0.026393, 0.0343527, 0.0414747, 0.0477587,
800 0.0532049, 0.0578132, 0.0615836, 0.0645161, 0.0666108,
801 0.0678676, 0.0682866, 0.0678676, 0.0666108, 0.0645161,
802 0.0615836, 0.0578132, 0.0532049, 0.0477587, 0.0414747,
803 0.0343527, 0.026393, 0.0175953, 0.00795978, -0.00251362,
804 -0.0138249, -0.025974, -0.038961 },
805 { -0.0426136, -0.028684, -0.0156708, -0.00357405, 0.0076063,
806 0.0178702, 0.0272177, 0.0356488, 0.0431635, 0.0497617,
807 0.0554435, 0.0602089, 0.0640579, 0.0669905, 0.0690066,
808 0.0701063, 0.0702896, 0.0695565, 0.0679069, 0.0653409,
809 0.0618585, 0.0574597, 0.0521444, 0.0459128, 0.0387647,
810 0.0307001, 0.0217192, 0.0118218, 0.00100806, -0.0107221,
811 -0.0233688, -0.0369318 },
812 { -0.0461877, -0.031305, -0.0174209, -0.00453534, 0.0073516,
813 0.01824, 0.0281297, 0.0370209, 0.0449135, 0.0518076,
814 0.057703, 0.0625999, 0.0664981, 0.0693978, 0.0712989,
815 0.0722014, 0.0721054, 0.0710107, 0.0689175, 0.0658257,
816 0.0617353, 0.0566463, 0.0505587, 0.0434725, 0.0353878,
817 0.0263045, 0.0162226, 0.00514208, -0.006937, -0.0200147,
819 { -0.0495968, -0.0337736, -0.0190331, -0.00537502, 0.00720046,
820 0.0186934, 0.0291038, 0.0384316, 0.0466769, 0.0538396,
821 0.0599198, 0.0649174, 0.0688324, 0.0716649, 0.0734149,
822 0.0740823, 0.0736672, 0.0721695, 0.0695892, 0.0659264,
823 0.0611811, 0.0553532, 0.0484427, 0.0404497, 0.0313741,
824 0.021216, 0.00997537, -0.00234785, -0.0157536, -0.0302419 },
825 { -0.0527253, -0.0360083, -0.0204566, -0.00607024, 0.0071508,
826 0.0192065, 0.0300969, 0.039822, 0.0483818, 0.0557763,
827 0.0620054, 0.0670692, 0.0709677, 0.0737009, 0.0752688,
828 0.0756714, 0.0749086, 0.0729806, 0.0698872, 0.0656285,
829 0.0602045, 0.0536151, 0.0458605, 0.0369405, 0.0268552,
830 0.0156046, 0.00318873, -0.0103925, -0.025139 },
831 { -0.0554187, -0.0379037, -0.0216307, -0.00659972, 0.00718917,
832 0.019736, 0.0310408, 0.0411035, 0.0499242, 0.0575028,
833 0.0638394, 0.0689339, 0.0727864, 0.0753968, 0.0767652,
834 0.0768915, 0.0757758, 0.073418, 0.0698181, 0.0649762,
835 0.0588923, 0.0515662, 0.0429982, 0.0331881, 0.0221359,
836 0.00984169, -0.00369458, -0.0184729 },
837 { -0.0574713, -0.0393247, -0.0224833, -0.00694708, 0.0072839,
838 0.0202097, 0.0318302, 0.0421456, 0.0511557, 0.0588607,
839 0.0652604, 0.0703549, 0.0741442, 0.0766284, 0.0778073,
840 0.0776809, 0.0762494, 0.0735127, 0.0694708, 0.0641236,
841 0.0574713, 0.0495137, 0.0402509, 0.029683, 0.0178098,
842 0.00463138, -0.00985222 },
843 { -0.0586081, -0.0400977, -0.0229304, -0.00710623, 0.00737485,
844 0.0205128, 0.0323077, 0.0427595, 0.0518681, 0.0596337,
845 0.0660562, 0.0711355, 0.0748718, 0.077265, 0.078315,
846 0.078022, 0.0763858, 0.0734066, 0.0690842, 0.0634188,
847 0.0564103, 0.0480586, 0.0383639, 0.027326, 0.0149451,
849 { -0.0584615, -0.04, -0.0228763, -0.0070903, 0.00735786,
850 0.0204682, 0.0322408, 0.0426756, 0.0517726, 0.0595318,
851 0.0659532, 0.0710368, 0.0747826, 0.0771906, 0.0782609,
852 0.0779933, 0.076388, 0.0734448, 0.0691639, 0.0635452,
853 0.0565886, 0.0482943, 0.0386622, 0.0276923, 0.0153846 },
854 { -0.0565385, -0.0387458, -0.022215, -0.00694588, 0.00706142,
855 0.0198069, 0.0312907, 0.0415126, 0.0504728, 0.0581712,
856 0.0646078, 0.0697826, 0.0736957, 0.0763469, 0.0777364,
857 0.0778641, 0.07673, 0.0743341, 0.0706765, 0.0657571,
858 0.0595759, 0.0521329, 0.0434281, 0.0334615 },
859 { -0.0521739, -0.0359684, -0.0208357, -0.00677583, 0.00621118,
860 0.0181254, 0.0289667, 0.0387352, 0.0474308, 0.0550536,
861 0.0616036, 0.0670807, 0.071485, 0.0748165, 0.0770751,
862 0.0782609, 0.0783738, 0.0774139, 0.0753811, 0.0722756,
863 0.0680971, 0.0628458, 0.0565217 },
864 { -0.0444664, -0.0311971, -0.0186335, -0.00677583, 0.00437606,
865 0.0148221, 0.0245624, 0.0335968, 0.0419255, 0.0495483,
866 0.0564653, 0.0626765, 0.0681818, 0.0729814, 0.0770751,
867 0.080463, 0.0831451, 0.0851214, 0.0863919, 0.0869565,
868 0.0868154, 0.0859684 },
869 { -0.0321852, -0.0238283, -0.0155309, -0.00729294, 0.000885613,
870 0.00900473, 0.0170644, 0.0250646, 0.0330054, 0.0408868,
871 0.0487087, 0.0564712, 0.0641743, 0.0718179, 0.0794021,
872 0.0869268, 0.0943921, 0.101798, 0.109144, 0.116431,
874 { -0.0136364, -0.0130895, -0.0115174, -0.00892003, -0.00529733,
875 -0.000649351, 0.00502392, 0.0117225, 0.0194463, 0.0281955,
876 0.0379699, 0.0487697, 0.0605947, 0.073445, 0.0873206,
877 0.102221, 0.118148, 0.135099, 0.153076, 0.172078 },
878 { 0.0135338, 0.00200501, -0.00672269, -0.0126493, -0.0157747,
879 -0.0160991, -0.0136223, -0.00834439, -0.000265369, 0.0106148,
880 0.024296, 0.0407784, 0.0600619, 0.0821465, 0.107032,
881 0.134719, 0.165207, 0.198496, 0.234586 },
882 { 0.0526316, 0.0227038, -0.00154799, -0.0201238, -0.0330237,
883 -0.0402477, -0.0417957, -0.0376677, -0.0278638, -0.0123839,
884 0.00877193, 0.0356037, 0.0681115, 0.106295, 0.150155,
885 0.19969, 0.254902, 0.315789 },
886 { 0.108359, 0.0505676, 0.00309598, -0.0340557, -0.0608875,
887 -0.0773994, -0.0835913, -0.0794634, -0.0650155, -0.0402477,
888 -0.00515996, 0.0402477, 0.0959752, 0.162023, 0.23839,
892 float filtered_baseline[128];
893 float filtered_baseline_derivative[127];
896 memset(filtered_baseline, 0, 128 *
sizeof(
float));
899 for (
size_t i = 0;
i < savitzky_golay_n_l_r;
i++) {
900 for (
size_t j = 0;
j < savitzky_golay_n_l_r + 1 +
i;
j++) {
901 filtered_baseline[
i] +=
902 savitzky_golay_coefficient[
i][
j] * baseline[
j];
908 for (
size_t i = savitzky_golay_n_l_r;
909 i < 128 - savitzky_golay_n_l_r;
i++) {
910 filtered_baseline[
i] =
911 savitzky_golay_coefficient
912 [savitzky_golay_n_l_r][savitzky_golay_n_l_r] * baseline[
i];
913 for (
size_t j = 0;
j < savitzky_golay_n_l_r;
j++) {
914 filtered_baseline[
i] +=
915 savitzky_golay_coefficient[savitzky_golay_n_l_r][
j] *
916 (baseline[
i +
j - savitzky_golay_n_l_r] +
917 baseline[
i -
j + savitzky_golay_n_l_r]);
922 for (
size_t j = 0;
j < 2 * savitzky_golay_n_l_r + 1;
j++) {
924 savitzky_golay_coefficient[savitzky_golay_n_l_r][
j] *
925 baseline[
i +
j - savitzky_golay_n_l_r];
932 for (
size_t i = 128 - savitzky_golay_n_l_r;
i < 128;
i++) {
933 for (
size_t j = 0;
j < 128 -
i + savitzky_golay_n_l_r;
j++) {
934 filtered_baseline[
i] +=
935 savitzky_golay_coefficient
936 [2 * savitzky_golay_n_l_r +
i + 1 - 128][
j] *
937 baseline[
i +
j - savitzky_golay_n_l_r];
943 for (
size_t i = 0;
i < 127;
i++) {
944 filtered_baseline_derivative[
i] =
945 filtered_baseline[
i + 1] - filtered_baseline[
i];
951 double filtered_baseline_max = 0;
952 double filtered_baseline_derivative_sum_square = 0;
954 for (
size_t i = 0;
i < 128;
i++) {
955 const double d = filtered_baseline[
i] - baseline[
i];
957 filtered_baseline_max =
959 static_cast<double>(fabs(d)));
961 for (
size_t i = 0;
i < 127;
i++) {
962 filtered_baseline_derivative_sum_square +=
963 filtered_baseline_derivative[
i] *
964 filtered_baseline_derivative[
i];
968 std::cerr << __FILE__ <<
':' << __LINE__ <<
": "
969 << filtered_baseline_max <<
' '
970 << filtered_baseline_derivative_sum_square << std::endl;
988 iEvent.
getByLabel(
"siStripDigis",
"VirginRaw", input);
1005 rawDigis = input.
begin(); rawDigis != input.
end(); rawDigis++) {
1007 std::vector<float> MeanCMDetSet;
1008 MeanCMDetSet.clear();
1010 for(uint16_t
APV = 0;
APV < rawDigis->size()/128; ++
APV){
1015 if(ped < MinPed) MinPed = ped;
1017 if(MinPed>128) MinPed=128;
1018 MeanCMDetSet.push_back(MinPed);
1021 MeanCMmap_.insert(std::pair<uint32_t, std::vector<float> >(rawDigis->id,MeanCMDetSet));
1032 std::vector<float> MeanCMNValue;
1034 for(itInput = Input.
begin(); itInput != Input.
end(); ++itInput){
1035 detId = itInput->id;
1036 MeanCMNValue.clear();
1037 for(itCM = itInput->
begin(); itCM != itInput->
end(); ++itCM) MeanCMNValue.push_back(itCM->adc());
1038 MeanCMmap_.insert(std::pair<uint32_t, std::vector<float> >(detId,MeanCMNValue));
int adc(sample_type sample)
get the ADC sample (12 bits)
int16_t AbnormalBaselineInspect(const uint16_t &, std::vector< T > &)
int16_t BaselineFollowerInspect(const uint16_t &, std::vector< T > &)
void CreateCMMapRealPed(const edm::DetSetVector< SiStripRawDigi > &)
uint32_t nSaturatedStrip_
void restore(const uint16_t &, std::vector< int16_t > &)
void init(const edm::EventSetup &es)
std::vector< bool > & GetAPVFlags()
bool FlatRegionsFinder(const std::vector< int16_t > &, DigiMap &, const uint16_t &)
void LoadMeanCMMap(const edm::Event &)
bool ApplyBaselineRejection_
uint32_t pedestal_cache_id
std::map< uint16_t, int16_t > DigiMap
double filteredBaselineDerivativeSumSquare_
std::pair< ContainerIterator, ContainerIterator > Range
uint32_t nSigmaNoiseDerTh_
uint32_t quality_cache_id
edm::ESHandle< SiStripPedestals > pedestalHandle
void Cleaner_MonotonyChecker(DigiMap &)
std::map< uint16_t, DigiMap > SmoothedMaps_
std::map< uint16_t, int16_t >::iterator DigiMapIter
std::vector< std::string > apvFlags_
void BaselineFollowerRestore(const uint16_t &, const uint16_t &, const float &, std::vector< int16_t > &)
bool CheckBaseline(const std::vector< int16_t > &) const
edm::ESHandle< SiStripQuality > qualityHandle
void BaselineFollower(DigiMap &, std::vector< int16_t > &, const float &)
const T & max(const T &a, const T &b)
int16_t InspectAndRestore(const uint32_t &, const uint16_t &, std::vector< int16_t > &, std::vector< int16_t > &, const std::vector< std::pair< short, float > > &)
double filteredBaselineMax_
uint32_t CleaningSequence_
int16_t NullInspect(const uint16_t &, std::vector< T > &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
iterator end()
Return the off-the-end iterator.
int16_t BaselineAndSaturationInspect(const uint16_t &, std::vector< T > &)
void FlatRestore(const uint16_t &, const uint16_t &, std::vector< int16_t > &)
bool SelfSelectRestoreAlgo_
uint32_t consecThreshold_
void Cleaner_HighSlopeChecker(DigiMap &)
std::vector< bool > apvFlagsBoolOverride_
edm::ESHandle< SiStripNoises > noiseHandle
int16_t inspect(const uint32_t &, const uint16_t &, std::vector< int16_t > &, const std::vector< std::pair< short, float > > &)
uint32_t DeltaCMThreshold_
void BaselineCleaner(const std::vector< int16_t > &, DigiMap &, const uint16_t &)
std::vector< bool > badAPVs_
bool ApplyBaselineCleaner_
std::vector< bool > apvFlagsBool_
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< float > median_
uint32_t distortionThreshold_
void CreateCMMapCMstored(const edm::DetSetVector< SiStripProcessedRawDigi > &)
iterator begin()
Return an iterator to the first DetSet.
uint32_t hitStripThreshold_
void Cleaner_LocalMinimumAdder(const std::vector< int16_t > &, DigiMap &, const uint16_t &)
std::pair< ContainerIterator, ContainerIterator > Range
collection_type::const_iterator const_iterator
collection_type::const_iterator const_iterator
SiStripAPVRestorer(const edm::ParameterSet &conf)