17 const string myname =
"InterpolatingAdcMitigationService::ctor: ";
30 const string myname =
"InterpolatingAdcMitigationService:update: ";
32 cout << myname <<
"Entering..." <<
endl;
33 cout << myname <<
" Channel: " << data.
channel() <<
endl;
34 cout << myname <<
"Input vector size: " << data.
samples.size() <<
endl;
38 unsigned int isigFirst = sigs.size();
41 unsigned int nupdated = 0;
43 for (
unsigned int isig=0; isig<sigs.size(); ++isig ) {
45 unsigned int isLast = isig == sigs.size()-1;
54 if ( isBad && isigFirst > isig ) isigFirst = isig;
58 bool endBadSequence =
false;
59 unsigned int isigLast = 0;
60 if ( !isBad && isigFirst < isig ) {
61 endBadSequence =
true;
64 if ( isLast && isBad ) {
65 endBadSequence =
true;
69 if ( endBadSequence ) {
70 unsigned int nsig = isigLast - isigFirst + 1;
71 bool tooMany = useMax && nsig > maxsig;
73 cout << myname <<
" Updating at sample " << isig <<
":" 74 <<
" range=[" << isigFirst <<
"," << isigLast <<
"]," 75 <<
" tooMany=" << tooMany <<
", isLast=" << isLast <<
endl;
78 if ( tooMany || isigFirst == 0 || isLast ) {
80 for (
unsigned isig=isigFirst; isig<=isigLast; ++isig ) {
88 unsigned int isig1 = isigFirst - 1;
89 unsigned int isig2 = isigLast + 1;
90 double sig1 = sigs[isig1];
91 double sig2 = sigs[isigLast+1];
92 double fac = 1.0/(isig2 - isig1);
93 double a = fac*(sig2 - sig1);
94 double b = fac*(isig2*sig1 - isig1*sig2);
95 for (
unsigned isig=isigFirst; isig<=isigLast; ++isig ) {
96 sigs[isig] = a*isig +
b;
101 isigFirst = sigs.size();
105 <<
": # updated/total = " << nupdated <<
"/" << sigs.size() <<
endl;
113 out << prefix <<
"InterpolatingAdcMitigationService:" <<
endl;
std::vector< AdcFlag > AdcFlagVector
const AdcFlag AdcUnderflow
const AdcFlag AdcSetFixed
int update(AdcChannelData &data) const
const AdcFlag AdcOverflow
T get(std::string const &key) const
int m_MaxConsecutiveSamples
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const
const AdcFlag AdcInterpolated
std::optional< T > get_if_present(std::string const &key) const
std::vector< AdcSignal > AdcSignalVector
InterpolatingAdcMitigationService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)
QTextStream & endl(QTextStream &s)
#define DEFINE_ART_SERVICE_INTERFACE_IMPL(svc, iface)