10 quality_cache_id(-1), noise_cache_id(-1), pedestal_cache_id(-1),
11 ForceNoRestore_(conf.getParameter<
bool>(
"ForceNoRestore")),
12 SelfSelectRestoreAlgo_(conf.getParameter<
bool>(
"SelfSelectRestoreAlgo")),
13 InspectAlgo_(conf.getParameter<
std::
string>(
"APVInspectMode")),
14 RestoreAlgo_(conf.getParameter<
std::
string>(
"APVRestoreMode")),
15 useRealMeanCM_(conf.getParameter<
bool>(
"useRealMeanCM")),
16 fraction_(conf.getParameter<double>(
"Fraction")),
17 deviation_(conf.getParameter<uint32_t>(
"Deviation")),
18 restoreThreshold_(conf.getParameter<double>(
"restoreThreshold")),
19 DeltaCMThreshold_(conf.getParameter<uint32_t>(
"DeltaCMThreshold")),
20 nSigmaNoiseDerTh_(conf.getParameter<uint32_t>(
"nSigmaNoiseDerTh")),
21 consecThreshold_(conf.getParameter<uint32_t>(
"consecThreshold")),
22 hitStripThreshold_(conf.getParameter<uint32_t>(
"hitStripThreshold")),
23 nSmooth_(conf.getParameter<uint32_t>(
"nSmooth")),
24 minStripsToFit_(conf.getParameter<uint32_t>(
"minStripsToFit")),
25 distortionThreshold_(conf.getParameter<uint32_t>(
"distortionThreshold")),
26 CutToAvoidSignal_(conf.getParameter<double>(
"CutToAvoidSignal")),
27 nSaturatedStrip_(conf.getParameter<uint32_t>(
"nSaturatedStrip")),
28 ApplyBaselineCleaner_(conf.getParameter<
bool>(
"ApplyBaselineCleaner")),
29 slopeX_(conf.getParameter<int32_t>(
"slopeX")),
30 slopeY_(conf.getParameter<int32_t>(
"slopeY")),
31 CleaningSequence_(conf.getParameter<uint32_t>(
"CleaningSequence")),
32 ApplyBaselineRejection_(conf.getParameter<
bool>(
"ApplyBaselineRejection")),
33 MeanCM_(conf.getParameter<int32_t>(
"MeanCM")),
34 filteredBaselineMax_(conf.getParameter<double>(
"filteredBaselineMax")),
35 filteredBaselineDerivativeSumSquare_(conf.getParameter<double>(
"filteredBaselineDerivativeSumSquare"))
73 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 ){
74 int16_t nAPVFlagged = this->
inspect(detId, firstAPV, rawDigisPedSubtracted, vmedians);
75 this->
restore(firstAPV, processedRawDigi);
80 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) {
96 for(
size_t i=0;
i< vmedians.size(); ++
i){
97 short APV = vmedians[
i].first;
106 throw cms::Exception(
"Unregistered Inspect Algorithm") <<
"SiStripAPVRestorer possibilities: (Null), (AbnormalBaseline),(BaselineFollower)";
115 for( uint16_t
APV=firstAPV;
APV< digis.size()/128 + firstAPV; ++
APV){
118 if ( algoToUse !=
""){
121 if(algoToUse==
"Flat"){
123 }
else if(algoToUse==
"BaselineFollower"){
126 throw cms::Exception(
"Unregistered Restore Algorithm") <<
"SiStripAPVRestorer possibilities: (Flat), (BaselineFollower)";
143 std::vector<T> singleAPVdigi;
144 int16_t nAPVflagged = 0;
146 CMMap::iterator itCMMap;
149 for(uint16_t
APV=firstAPV ;
APV< digis.size()/128 + firstAPV; ++
APV){
152 smoothedmap.erase(smoothedmap.begin(), smoothedmap.end());
158 singleAPVdigi.clear();
159 for(int16_t
strip = (APV-firstAPV)*128;
strip < (APV-firstAPV+1)*128; ++
strip){
160 singleAPVdigi.push_back(digis[
strip]);
187 std::vector<T> singleAPVdigi;
188 singleAPVdigi.clear();
191 int16_t nAPVflagged = 0;
193 CMMap::iterator itCMMap;
196 for(uint16_t
APV=firstAPV ;
APV< digis.size()/128 + firstAPV; ++
APV){
202 singleAPVdigi.clear();
204 uint16_t nSatStrip =0;
205 for(int16_t
strip = (APV-firstAPV)*128;
strip < (APV-firstAPV+1)*128; ++
strip){
206 singleAPVdigi.push_back(digis[
strip]);
207 if(digis[strip] >=1023) ++nSatStrip;
230 typename std::vector<T>::iterator fs;
232 int16_t nAPVflagged=0;
234 CMMap::iterator itCMMap;
238 int devCount = 0, qualityCount = 0, minstrip = 0;
239 for(uint16_t
APV=firstAPV ;
APV< digis.size()/128 + firstAPV; ++
APV){
244 for (uint16_t istrip=APV*128; istrip<(APV+1)*128; ++istrip){
245 fs = digis.begin() + istrip-firstAPV*128;
250 minstrip =
std::min((
int) *fs, minstrip);
255 if( devCount >
fraction_ * qualityCount ) {
274 typename std::vector<T>::iterator fs;
276 int16_t nAPVflagged = 0;
278 for(uint16_t
APV=firstAPV ;
APV< digis.size()/128 + firstAPV; ++
APV){
281 int zeroCount = 0, qualityCount = 0;
282 for (uint16_t istrip=APV*128; istrip<(APV+1)*128; ++istrip){
283 fs = digis.begin() + istrip-firstAPV*128;
286 if ( (
int) *fs < 1 ) zeroCount++;
312 std::vector<int16_t> baseline;
314 baseline.insert(baseline.begin(),128, 0);
322 std::map<uint16_t, DigiMap >::iterator itSmootedMap =
SmoothedMaps_.find(APVn);
327 std::vector<int16_t> singleAPVdigi;
328 singleAPVdigi.clear();
329 for(int16_t
strip = (APVn-firstAPV)*128;
strip < (APVn-firstAPV+1)*128; ++
strip) singleAPVdigi.push_back(digis[
strip]);
341 for(int16_t itStrip= 0 ; itStrip< 128; ++itStrip){
342 digis[(APVn-firstAPV)*128+itStrip] -= baseline[itStrip] - median;
356 std::vector<int16_t> baseline;
358 baseline.insert(baseline.begin(),128, 150);
359 baseline[0]=0; baseline[127]=0;
362 for(int16_t itStrip= 0 ; itStrip< 128; ++itStrip){
363 digis[(APVn-firstAPV)*128+itStrip] = baseline[itStrip];
380 consecpoints.erase(consecpoints.begin(), consecpoints.end());
381 smoothedpoints.erase(smoothedpoints.begin(), smoothedpoints.end());
385 std::vector<float> adcsLocalMinSubtracted;
386 adcsLocalMinSubtracted.clear();
387 adcsLocalMinSubtracted.insert(adcsLocalMinSubtracted.begin(), 128,0);
388 for(uint32_t istrip=0; istrip<128; ++istrip) {
389 float localmin = 999.9;
391 float nextvalue = adcs[jstrip];
392 if(nextvalue < localmin) localmin=nextvalue;
394 adcsLocalMinSubtracted[istrip] = adcs[istrip] - localmin;
399 std::vector<uint16_t> nConsStrip;
403 uint16_t consecStrips=0;
404 for(uint32_t istrip=0; istrip<128; ++istrip) {
405 int16_t
adc = adcs[istrip];
409 consecpoints.insert(consecpoints.end(), std::pair<uint16_t, int16_t >(istrip,
adc));
411 }
else if (consecStrips >0){
412 nConsStrip.push_back(consecStrips);
418 if(consecStrips >0) nConsStrip.push_back(consecStrips);
421 itConsecpoints = consecpoints.begin();
422 float MinSmoothValue=20000., MaxSmoothValue=0.;
423 for(std::vector<uint16_t>::iterator itnConsStrip = nConsStrip.begin(); itnConsStrip < nConsStrip.end(); ++itnConsStrip){
425 consecStrips = *itnConsStrip;
428 uint16_t nFirstStrip = itConsecpoints->first;
430 float smoothValue = 0.0;
432 for(uint16_t
n =0;
n < consecStrips-2; ++
n){
433 smoothValue += itConsecpoints->second;
435 smoothValue /= (
float)stripCount;
436 nLastStrip = nFirstStrip + stripCount -1;
437 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nFirstStrip, smoothValue));
438 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nLastStrip, smoothValue));
439 if(smoothValue > MaxSmoothValue) MaxSmoothValue = smoothValue;
440 if(smoothValue < MinSmoothValue) MinSmoothValue = smoothValue;
441 nFirstStrip = nLastStrip+1;
453 smoothValue /= (
float)(stripCount);
454 nLastStrip = nFirstStrip + stripCount -1;
455 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nFirstStrip, smoothValue));
456 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(nLastStrip, smoothValue));
457 if(smoothValue > MaxSmoothValue) MaxSmoothValue = smoothValue;
458 if(smoothValue < MinSmoothValue) MinSmoothValue = smoothValue;
461 for(
int n =0;
n< consecStrips ; ++
n) ++itConsecpoints;
499 if(smoothedpoints.size() < 3)
return;
500 DigiMapIter itSmoothedpoints, itSmoothedpointsNext, itSmoothedpointsNextNext, itSmoothedpointsBegin, itSmoothedpointsEnd;
502 itSmoothedpoints=smoothedpoints.begin();
503 while (smoothedpoints.size() > 3 && itSmoothedpoints != --(--(smoothedpoints.end()))) {
505 itSmoothedpointsNext = itSmoothedpoints;
506 ++itSmoothedpointsNext;
507 itSmoothedpointsNextNext = itSmoothedpointsNext;
508 ++itSmoothedpointsNextNext;
509 float adc1 = itSmoothedpoints->second;
510 float adc2 = itSmoothedpointsNext->second;
511 float adc3 = itSmoothedpointsNextNext->second;
514 smoothedpoints.erase(itSmoothedpointsNext);
528 DigiMapIter itSmoothedpoints, itSmoothedpointsNext, itSmoothedpointsBegin, itSmoothedpointsEnd;
529 if(smoothedpoints.size() >= 2){
531 itSmoothedpointsBegin = smoothedpoints.begin();
532 itSmoothedpointsEnd = --(smoothedpoints.end());
533 for(itSmoothedpoints = itSmoothedpointsBegin; itSmoothedpoints != itSmoothedpointsEnd; ++itSmoothedpoints){
534 itSmoothedpointsNext = itSmoothedpoints;
535 ++itSmoothedpointsNext;
536 float strip1 = itSmoothedpoints->first;
537 float strip2 = itSmoothedpointsNext->first;
538 float adc1 = itSmoothedpoints->second;
539 float adc2 = itSmoothedpointsNext->second;
540 float m = (adc2 -adc1)/(strip2 -strip1);
545 float strip = itStrip + strip1;
546 while(strip < strip2){
551 smoothedpoints.insert(itSmoothedpointsNext, std::pair<uint16_t, int16_t >(strip,adc));
553 ++itSmoothedpointsNext;
554 itSmoothedpointsEnd = --(smoothedpoints.end());
566 itSmoothedpointsBegin = smoothedpoints.begin();
567 itSmoothedpointsEnd = --(smoothedpoints.end());
568 uint16_t firstStripFlat = itSmoothedpointsBegin->first;
569 uint16_t lastStripFlat = itSmoothedpointsEnd->first;
570 int16_t firstStripFlatADC= itSmoothedpointsBegin->second;
571 int16_t lastStripFlatADC= itSmoothedpointsEnd->second;
573 itSmoothedpoints = itSmoothedpointsBegin;
574 if(firstStripFlat >3){
576 while(strip < firstStripFlat){
579 smoothedpoints.insert(itSmoothedpoints, std::pair<uint16_t, int16_t >(strip,adc));
586 itSmoothedpoints = itSmoothedpointsEnd;
587 if(lastStripFlat <125){
588 float strip = lastStripFlat+1;
592 smoothedpoints.insert(smoothedpoints.end(), std::pair<uint16_t, int16_t >(
strip,
adc));
604 if(smoothedpoints.size() < 4)
return;
605 DigiMapIter itSmoothedpoints, itSmoothedpointsNext, itSmoothedpointsBegin, itSmoothedpointsEnd;
606 itSmoothedpoints=smoothedpoints.begin();
607 while (smoothedpoints.size() >2 && itSmoothedpoints != --(smoothedpoints.end()) ) {
610 itSmoothedpointsNext = itSmoothedpoints;
611 ++itSmoothedpointsNext;
612 float strip1 = itSmoothedpoints->first;
613 float strip2 = itSmoothedpointsNext->first;
614 float adc1 = itSmoothedpoints->second;
615 float adc2 = itSmoothedpointsNext->second;
616 float m = (adc2 -adc1)/(strip2 -strip1);
619 smoothedpoints.erase(itSmoothedpointsNext);
622 if(itSmoothedpoints==smoothedpoints.begin()) smoothedpoints.erase(itSmoothedpoints++);
624 else smoothedpoints.erase(itSmoothedpoints--);
640 baseline.insert(baseline.begin(),128,
median);
642 baseline.insert(baseline.begin(),128, 0);
644 DigiMapIter itSmoothedpointsBegin, itSmoothedpointsEnd;
645 itSmoothedpointsBegin = smoothedpoints.begin();
646 itSmoothedpointsEnd = --(smoothedpoints.end());
649 uint16_t firstStripFlat = itSmoothedpointsBegin->first;
650 uint16_t lastStripFlat = itSmoothedpointsEnd->first;
651 int16_t firstStripFlatADC= itSmoothedpointsBegin->second;
652 int16_t lastStripFlatADC= itSmoothedpointsEnd->second;
655 baseline.erase(baseline.begin(), baseline.begin()+firstStripFlat);
656 baseline.insert(baseline.begin(), firstStripFlat, firstStripFlatADC);
658 baseline.erase(baseline.begin()+lastStripFlat, baseline.end());
659 baseline.insert(baseline.end(), 128 - lastStripFlat, lastStripFlatADC);
663 for(itSmoothedpoints = itSmoothedpointsBegin; itSmoothedpoints != itSmoothedpointsEnd; ++itSmoothedpoints){
664 DigiMapIter itSmoothedpointsNext = itSmoothedpoints;
665 ++itSmoothedpointsNext;
666 float strip1 = itSmoothedpoints->first;
667 float strip2 = itSmoothedpointsNext->first;
668 float adc1 = itSmoothedpoints->second;
669 float adc2 = itSmoothedpointsNext->second;
671 baseline[strip1] = adc1;
672 baseline[strip2] = adc2;
673 float m = (adc2 -adc1)/(strip2 -strip1);
674 uint16_t itStrip = strip1 +1;
675 float stripadc = adc1 +
m;
676 while(itStrip < strip2){
677 baseline[itStrip] = stripadc;
710 static const size_t savitzky_golay_n_l_r = 16;
711 static const float savitzky_golay_coefficient
712 [2 * savitzky_golay_n_l_r + 1][2 * savitzky_golay_n_l_r + 1] = {
713 { 0.422085, 0.325077, 0.23839, 0.162023, 0.0959752, 0.0402477,
714 -0.00515996, -0.0402477, -0.0650155, -0.0794634, -0.0835913,
715 -0.0773994, -0.0608875, -0.0340557, 0.00309598, 0.0505676,
717 { 0.315789, 0.254902, 0.19969, 0.150155, 0.106295, 0.0681115,
718 0.0356037, 0.00877193, -0.0123839, -0.0278638, -0.0376677,
719 -0.0417957, -0.0402477, -0.0330237, -0.0201238, -0.00154799,
720 0.0227038, 0.0526316 },
721 { 0.234586, 0.198496, 0.165207, 0.134719, 0.107032, 0.0821465,
722 0.0600619, 0.0407784, 0.024296, 0.0106148, -0.000265369,
723 -0.00834439, -0.0136223, -0.0160991, -0.0157747, -0.0126493,
724 -0.00672269, 0.00200501, 0.0135338 },
725 { 0.172078, 0.153076, 0.135099, 0.118148, 0.102221, 0.0873206,
726 0.073445, 0.0605947, 0.0487697, 0.0379699, 0.0281955,
727 0.0194463, 0.0117225, 0.00502392, -0.000649351, -0.00529733,
728 -0.00892003, -0.0115174, -0.0130895, -0.0136364 },
729 { 0.123659, 0.116431, 0.109144, 0.101798, 0.0943921, 0.0869268,
730 0.0794021, 0.0718179, 0.0641743, 0.0564712, 0.0487087,
731 0.0408868, 0.0330054, 0.0250646, 0.0170644, 0.00900473,
732 0.000885613, -0.00729294, -0.0155309, -0.0238283,
734 { 0.0859684, 0.0868154, 0.0869565, 0.0863919, 0.0851214,
735 0.0831451, 0.080463, 0.0770751, 0.0729814, 0.0681818,
736 0.0626765, 0.0564653, 0.0495483, 0.0419255, 0.0335968,
737 0.0245624, 0.0148221, 0.00437606, -0.00677583, -0.0186335,
738 -0.0311971, -0.0444664 },
739 { 0.0565217, 0.0628458, 0.0680971, 0.0722756, 0.0753811,
740 0.0774139, 0.0783738, 0.0782609, 0.0770751, 0.0748165,
741 0.071485, 0.0670807, 0.0616036, 0.0550536, 0.0474308,
742 0.0387352, 0.0289667, 0.0181254, 0.00621118, -0.00677583,
743 -0.0208357, -0.0359684, -0.0521739 },
744 { 0.0334615, 0.0434281, 0.0521329, 0.0595759, 0.0657571,
745 0.0706765, 0.0743341, 0.07673, 0.0778641, 0.0777364,
746 0.0763469, 0.0736957, 0.0697826, 0.0646078, 0.0581712,
747 0.0504728, 0.0415126, 0.0312907, 0.0198069, 0.00706142,
748 -0.00694588, -0.022215, -0.0387458, -0.0565385 },
749 { 0.0153846, 0.0276923, 0.0386622, 0.0482943, 0.0565886,
750 0.0635452, 0.0691639, 0.0734448, 0.076388, 0.0779933,
751 0.0782609, 0.0771906, 0.0747826, 0.0710368, 0.0659532,
752 0.0595318, 0.0517726, 0.0426756, 0.0322408, 0.0204682,
753 0.00735786, -0.0070903, -0.0228763, -0.04, -0.0584615 },
754 { 0.001221, 0.0149451, 0.027326, 0.0383639, 0.0480586,
755 0.0564103, 0.0634188, 0.0690842, 0.0734066, 0.0763858,
756 0.078022, 0.078315, 0.077265, 0.0748718, 0.0711355,
757 0.0660562, 0.0596337, 0.0518681, 0.0427595, 0.0323077,
758 0.0205128, 0.00737485, -0.00710623, -0.0229304, -0.0400977,
760 { -0.00985222, 0.00463138, 0.0178098, 0.029683, 0.0402509,
761 0.0495137, 0.0574713, 0.0641236, 0.0694708, 0.0735127,
762 0.0762494, 0.0776809, 0.0778073, 0.0766284, 0.0741442,
763 0.0703549, 0.0652604, 0.0588607, 0.0511557, 0.0421456,
764 0.0318302, 0.0202097, 0.0072839, -0.00694708, -0.0224833,
765 -0.0393247, -0.0574713 },
766 { -0.0184729, -0.00369458, 0.00984169, 0.0221359, 0.0331881,
767 0.0429982, 0.0515662, 0.0588923, 0.0649762, 0.0698181,
768 0.073418, 0.0757758, 0.0768915, 0.0767652, 0.0753968,
769 0.0727864, 0.0689339, 0.0638394, 0.0575028, 0.0499242,
770 0.0411035, 0.0310408, 0.019736, 0.00718917, -0.00659972,
771 -0.0216307, -0.0379037, -0.0554187 },
772 { -0.025139, -0.0103925, 0.00318873, 0.0156046, 0.0268552,
773 0.0369405, 0.0458605, 0.0536151, 0.0602045, 0.0656285,
774 0.0698872, 0.0729806, 0.0749086, 0.0756714, 0.0752688,
775 0.0737009, 0.0709677, 0.0670692, 0.0620054, 0.0557763,
776 0.0483818, 0.039822, 0.0300969, 0.0192065, 0.0071508,
777 -0.00607024, -0.0204566, -0.0360083, -0.0527253 },
778 { -0.0302419, -0.0157536, -0.00234785, 0.00997537, 0.021216,
779 0.0313741, 0.0404497, 0.0484427, 0.0553532, 0.0611811,
780 0.0659264, 0.0695892, 0.0721695, 0.0736672, 0.0740823,
781 0.0734149, 0.0716649, 0.0688324, 0.0649174, 0.0599198,
782 0.0538396, 0.0466769, 0.0384316, 0.0291038, 0.0186934,
783 0.00720046, -0.00537502, -0.0190331, -0.0337736,
785 { -0.0340909, -0.0200147, -0.006937, 0.00514208, 0.0162226,
786 0.0263045, 0.0353878, 0.0434725, 0.0505587, 0.0566463,
787 0.0617353, 0.0658257, 0.0689175, 0.0710107, 0.0721054,
788 0.0722014, 0.0712989, 0.0693978, 0.0664981, 0.0625999,
789 0.057703, 0.0518076, 0.0449135, 0.0370209, 0.0281297,
790 0.01824, 0.0073516, -0.00453534, -0.0174209, -0.031305,
792 { -0.0369318, -0.0233688, -0.0107221, 0.00100806, 0.0118218,
793 0.0217192, 0.0307001, 0.0387647, 0.0459128, 0.0521444,
794 0.0574597, 0.0618585, 0.0653409, 0.0679069, 0.0695565,
795 0.0702896, 0.0701063, 0.0690066, 0.0669905, 0.0640579,
796 0.0602089, 0.0554435, 0.0497617, 0.0431635, 0.0356488,
797 0.0272177, 0.0178702, 0.0076063, -0.00357405, -0.0156708,
798 -0.028684, -0.0426136 },
799 { -0.038961, -0.025974, -0.0138249, -0.00251362, 0.00795978,
800 0.0175953, 0.026393, 0.0343527, 0.0414747, 0.0477587,
801 0.0532049, 0.0578132, 0.0615836, 0.0645161, 0.0666108,
802 0.0678676, 0.0682866, 0.0678676, 0.0666108, 0.0645161,
803 0.0615836, 0.0578132, 0.0532049, 0.0477587, 0.0414747,
804 0.0343527, 0.026393, 0.0175953, 0.00795978, -0.00251362,
805 -0.0138249, -0.025974, -0.038961 },
806 { -0.0426136, -0.028684, -0.0156708, -0.00357405, 0.0076063,
807 0.0178702, 0.0272177, 0.0356488, 0.0431635, 0.0497617,
808 0.0554435, 0.0602089, 0.0640579, 0.0669905, 0.0690066,
809 0.0701063, 0.0702896, 0.0695565, 0.0679069, 0.0653409,
810 0.0618585, 0.0574597, 0.0521444, 0.0459128, 0.0387647,
811 0.0307001, 0.0217192, 0.0118218, 0.00100806, -0.0107221,
812 -0.0233688, -0.0369318 },
813 { -0.0461877, -0.031305, -0.0174209, -0.00453534, 0.0073516,
814 0.01824, 0.0281297, 0.0370209, 0.0449135, 0.0518076,
815 0.057703, 0.0625999, 0.0664981, 0.0693978, 0.0712989,
816 0.0722014, 0.0721054, 0.0710107, 0.0689175, 0.0658257,
817 0.0617353, 0.0566463, 0.0505587, 0.0434725, 0.0353878,
818 0.0263045, 0.0162226, 0.00514208, -0.006937, -0.0200147,
820 { -0.0495968, -0.0337736, -0.0190331, -0.00537502, 0.00720046,
821 0.0186934, 0.0291038, 0.0384316, 0.0466769, 0.0538396,
822 0.0599198, 0.0649174, 0.0688324, 0.0716649, 0.0734149,
823 0.0740823, 0.0736672, 0.0721695, 0.0695892, 0.0659264,
824 0.0611811, 0.0553532, 0.0484427, 0.0404497, 0.0313741,
825 0.021216, 0.00997537, -0.00234785, -0.0157536, -0.0302419 },
826 { -0.0527253, -0.0360083, -0.0204566, -0.00607024, 0.0071508,
827 0.0192065, 0.0300969, 0.039822, 0.0483818, 0.0557763,
828 0.0620054, 0.0670692, 0.0709677, 0.0737009, 0.0752688,
829 0.0756714, 0.0749086, 0.0729806, 0.0698872, 0.0656285,
830 0.0602045, 0.0536151, 0.0458605, 0.0369405, 0.0268552,
831 0.0156046, 0.00318873, -0.0103925, -0.025139 },
832 { -0.0554187, -0.0379037, -0.0216307, -0.00659972, 0.00718917,
833 0.019736, 0.0310408, 0.0411035, 0.0499242, 0.0575028,
834 0.0638394, 0.0689339, 0.0727864, 0.0753968, 0.0767652,
835 0.0768915, 0.0757758, 0.073418, 0.0698181, 0.0649762,
836 0.0588923, 0.0515662, 0.0429982, 0.0331881, 0.0221359,
837 0.00984169, -0.00369458, -0.0184729 },
838 { -0.0574713, -0.0393247, -0.0224833, -0.00694708, 0.0072839,
839 0.0202097, 0.0318302, 0.0421456, 0.0511557, 0.0588607,
840 0.0652604, 0.0703549, 0.0741442, 0.0766284, 0.0778073,
841 0.0776809, 0.0762494, 0.0735127, 0.0694708, 0.0641236,
842 0.0574713, 0.0495137, 0.0402509, 0.029683, 0.0178098,
843 0.00463138, -0.00985222 },
844 { -0.0586081, -0.0400977, -0.0229304, -0.00710623, 0.00737485,
845 0.0205128, 0.0323077, 0.0427595, 0.0518681, 0.0596337,
846 0.0660562, 0.0711355, 0.0748718, 0.077265, 0.078315,
847 0.078022, 0.0763858, 0.0734066, 0.0690842, 0.0634188,
848 0.0564103, 0.0480586, 0.0383639, 0.027326, 0.0149451,
850 { -0.0584615, -0.04, -0.0228763, -0.0070903, 0.00735786,
851 0.0204682, 0.0322408, 0.0426756, 0.0517726, 0.0595318,
852 0.0659532, 0.0710368, 0.0747826, 0.0771906, 0.0782609,
853 0.0779933, 0.076388, 0.0734448, 0.0691639, 0.0635452,
854 0.0565886, 0.0482943, 0.0386622, 0.0276923, 0.0153846 },
855 { -0.0565385, -0.0387458, -0.022215, -0.00694588, 0.00706142,
856 0.0198069, 0.0312907, 0.0415126, 0.0504728, 0.0581712,
857 0.0646078, 0.0697826, 0.0736957, 0.0763469, 0.0777364,
858 0.0778641, 0.07673, 0.0743341, 0.0706765, 0.0657571,
859 0.0595759, 0.0521329, 0.0434281, 0.0334615 },
860 { -0.0521739, -0.0359684, -0.0208357, -0.00677583, 0.00621118,
861 0.0181254, 0.0289667, 0.0387352, 0.0474308, 0.0550536,
862 0.0616036, 0.0670807, 0.071485, 0.0748165, 0.0770751,
863 0.0782609, 0.0783738, 0.0774139, 0.0753811, 0.0722756,
864 0.0680971, 0.0628458, 0.0565217 },
865 { -0.0444664, -0.0311971, -0.0186335, -0.00677583, 0.00437606,
866 0.0148221, 0.0245624, 0.0335968, 0.0419255, 0.0495483,
867 0.0564653, 0.0626765, 0.0681818, 0.0729814, 0.0770751,
868 0.080463, 0.0831451, 0.0851214, 0.0863919, 0.0869565,
869 0.0868154, 0.0859684 },
870 { -0.0321852, -0.0238283, -0.0155309, -0.00729294, 0.000885613,
871 0.00900473, 0.0170644, 0.0250646, 0.0330054, 0.0408868,
872 0.0487087, 0.0564712, 0.0641743, 0.0718179, 0.0794021,
873 0.0869268, 0.0943921, 0.101798, 0.109144, 0.116431,
875 { -0.0136364, -0.0130895, -0.0115174, -0.00892003, -0.00529733,
876 -0.000649351, 0.00502392, 0.0117225, 0.0194463, 0.0281955,
877 0.0379699, 0.0487697, 0.0605947, 0.073445, 0.0873206,
878 0.102221, 0.118148, 0.135099, 0.153076, 0.172078 },
879 { 0.0135338, 0.00200501, -0.00672269, -0.0126493, -0.0157747,
880 -0.0160991, -0.0136223, -0.00834439, -0.000265369, 0.0106148,
881 0.024296, 0.0407784, 0.0600619, 0.0821465, 0.107032,
882 0.134719, 0.165207, 0.198496, 0.234586 },
883 { 0.0526316, 0.0227038, -0.00154799, -0.0201238, -0.0330237,
884 -0.0402477, -0.0417957, -0.0376677, -0.0278638, -0.0123839,
885 0.00877193, 0.0356037, 0.0681115, 0.106295, 0.150155,
886 0.19969, 0.254902, 0.315789 },
887 { 0.108359, 0.0505676, 0.00309598, -0.0340557, -0.0608875,
888 -0.0773994, -0.0835913, -0.0794634, -0.0650155, -0.0402477,
889 -0.00515996, 0.0402477, 0.0959752, 0.162023, 0.23839,
893 float filtered_baseline[128];
894 float filtered_baseline_derivative[127];
897 memset(filtered_baseline, 0, 128 *
sizeof(
float));
900 for (
size_t i = 0;
i < savitzky_golay_n_l_r;
i++) {
901 for (
size_t j = 0; j < savitzky_golay_n_l_r + 1 +
i; j++) {
902 filtered_baseline[
i] +=
903 savitzky_golay_coefficient[
i][j] * baseline[j];
909 for (
size_t i = savitzky_golay_n_l_r;
910 i < 128 - savitzky_golay_n_l_r;
i++) {
911 filtered_baseline[
i] =
912 savitzky_golay_coefficient
913 [savitzky_golay_n_l_r][savitzky_golay_n_l_r] * baseline[
i];
914 for (
size_t j = 0; j < savitzky_golay_n_l_r; j++) {
915 filtered_baseline[
i] +=
916 savitzky_golay_coefficient[savitzky_golay_n_l_r][j] *
917 (baseline[
i + j - savitzky_golay_n_l_r] +
918 baseline[
i - j + savitzky_golay_n_l_r]);
923 for (
size_t j = 0; j < 2 * savitzky_golay_n_l_r + 1; j++) {
925 savitzky_golay_coefficient[savitzky_golay_n_l_r][j] *
926 baseline[
i + j - savitzky_golay_n_l_r];
933 for (
size_t i = 128 - savitzky_golay_n_l_r;
i < 128;
i++) {
934 for (
size_t j = 0; j < 128 -
i + savitzky_golay_n_l_r; j++) {
935 filtered_baseline[
i] +=
936 savitzky_golay_coefficient
937 [2 * savitzky_golay_n_l_r +
i + 1 - 128][j] *
938 baseline[
i + j - savitzky_golay_n_l_r];
944 for (
size_t i = 0;
i < 127;
i++) {
945 filtered_baseline_derivative[
i] =
946 filtered_baseline[
i + 1] - filtered_baseline[
i];
952 double filtered_baseline_max = 0;
953 double filtered_baseline_derivative_sum_square = 0;
955 for (
size_t i = 0;
i < 128;
i++) {
956 const double d = filtered_baseline[
i] - baseline[
i];
958 filtered_baseline_max =
960 static_cast<double>(fabs(d)));
962 for (
size_t i = 0;
i < 127;
i++) {
963 filtered_baseline_derivative_sum_square +=
964 filtered_baseline_derivative[
i] *
965 filtered_baseline_derivative[
i];
969 std::cerr << __FILE__ <<
':' << __LINE__ <<
": " 970 << filtered_baseline_max <<
' ' 971 << filtered_baseline_derivative_sum_square << std::endl;
989 iEvent.
getByLabel(
"siStripDigis",
"VirginRaw", input);
1006 rawDigis = input.
begin(); rawDigis != input.
end(); rawDigis++) {
1008 std::vector<float> MeanCMDetSet;
1009 MeanCMDetSet.clear();
1011 for(uint16_t
APV = 0;
APV < rawDigis->size()/128; ++
APV){
1016 if(ped < MinPed) MinPed = ped;
1018 if(MinPed>128) MinPed=128;
1019 MeanCMDetSet.push_back(MinPed);
1022 MeanCMmap_.insert(std::pair<uint32_t, std::vector<float> >(rawDigis->id,MeanCMDetSet));
1033 std::vector<float> MeanCMNValue;
1035 for(itInput = Input.
begin(); itInput != Input.
end(); ++itInput){
1036 detId = itInput->id;
1037 MeanCMNValue.clear();
1038 for(itCM = itInput->
begin(); itCM != itInput->
end(); ++itCM) MeanCMNValue.push_back(itCM->adc());
1039 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 > &)
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
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 IsStripBad(const uint32_t &detid, const short &strip) const
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_
static std::string const input
std::map< uint16_t, int16_t >::iterator DigiMapIter
float getPed(const uint16_t &strip, const Range &range) const
std::vector< std::string > apvFlags_
static float getNoiseFast(const uint16_t &strip, const Range &range)
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 &)
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_
Abs< T >::type abs(const T &t)
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_
const Range getRange(const uint32_t detID) const
const Range getRange(const uint32_t detID) const
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.
const Range getRange(const uint32_t &detID) const
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)