21 : m_LogLevel(ps.
get<
int>(
"LogLevel")),
24 const string myname =
"CnrByGroup::ctor: ";
29 else cout << myname <<
"WARNING: Ignoring invalid option: " << sopt <<
endl;
32 string crtName =
"channelGroups";
37 if ( pcrt !=
nullptr ) grp = pcrt->
get(sgrp);
42 cout << myname <<
"WARNING: Unable to find range group " << sgrp <<
endl;
51 cout << myname <<
" Groups: [";
53 for (
Name nam : m_Groups ) {
54 if ( count && count%10 == 0 ) cout <<
"\n ";
55 if ( count++ ) cout <<
", ";
59 cout << myname <<
" Options: [";
61 for (
Name nam : m_Options ) {
62 if ( count++ ) cout <<
", ";
66 cout << myname <<
"Using " << (
m_useMedian ?
"median" :
"mean") <<
" correction." << endl;
67 cout << myname <<
"Using " << (
m_dropSignal ?
"all" :
"non-signal") <<
" samples." << endl;
68 cout << myname << (
m_requireGoodChannel ?
"R" :
"Not r") <<
"equiring good channel status." << endl;
69 cout << myname <<
" Group #chan" <<
endl;
70 for (
const auto& ient :
m_chg ) {
71 cout << myname <<
setw(10) << ient.first <<
setw(8) << ient.second.size() <<
endl;
79 const string myname =
"CnrByGroup::updateMap: ";
81 if ( acds.size() == 0 ) {
82 std::cout << myname <<
"WARNING: No channels found." <<
std::endl;
87 std::vector<float> correction =
getCorrection(channels, acds);
88 for (
Index ich : channels) {
89 auto iacd = acds.find(ich);
90 if ( iacd == acds.end() )
continue;
92 if ( acd.
samples.size() == 0 )
continue;
93 if ( acd.
samples.size() > correction.size() ) correction.resize(acd.
samples.size(), 0.);
94 for (
size_t isam=0; isam<acd.
samples.size(); ++isam) {
95 acd.
samples[isam] -= correction[isam];
106 const string myname =
"CnrByGroup::getCorrection: ";
108 std::vector<FloatVector> samples;
109 for (
Index ich : channels ) {
110 auto iacd = acds.find(ich);
111 if ( iacd == acds.end() )
continue;
114 if ( acd.
samples.size() > nsam ) {
116 samples.resize(nsam);
118 for (
size_t isam=0; isam<acd.
samples.size(); ++isam ) {
120 samples[isam].push_back(acd.
samples[isam]);
123 std::vector<float> correction(nsam, 0.0);
125 for (
Index isam=0; isam<nsam; ++isam ) {
126 size_t nval = samples[isam].size();
127 if ( nval < 2 )
continue;
129 std::sort(samples[isam].
begin(), samples[isam].
end());
130 if ( nval%2 == 0 ) correction[isam] = 0.5 * (samples[isam][nval/2-1] + samples[isam][nval/2]);
131 else correction[isam] = samples[isam][nval/2];
134 for (
float val : samples[isam] ) sum +=
val;
135 correction[isam] = sum/
float(samples[isam].
size());
139 if (
m_LogLevel >= 2 ) cout << myname <<
"Correcting " << nsamCor <<
"/" << nsam <<
" samples." <<
endl;
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
DataMap & setStatus(int stat)
CnrByGroup(fhicl::ParameterSet const &ps)
FloatVector getCorrection(const IndexVector &channels, const AdcChannelDataMap &acds) const
std::vector< Index > IndexVector
std::vector< float > FloatVector
DataMap updateMap(AdcChannelDataMap &acds) const override
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
static constexpr double ps
Q_EXPORT QTSManip setw(int w)
Index channelStatus() const
bool m_requireGoodChannel
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
auto const & get(AssnsNode< L, R, D > const &r)
void getIndices(IndexVector &idxs) const
std::vector< Name > NameVector
QTextStream & endl(QTextStream &s)