#include <CnrGroupWeighted.h>
Definition at line 38 of file CnrGroupWeighted.h.
Definition at line 20 of file CnrGroupWeighted_tool.cc.
25 const string myname =
"CnrGroupWeighted::ctor: ";
30 else cout << myname <<
"WARNING: Ignoring invalid option: " << sopt <<
endl;
33 string crtName =
"channelGroups";
38 if ( pcrt !=
nullptr ) grp = pcrt->
get(sgrp);
43 cout << myname <<
"WARNING: Unable to find range group " << sgrp <<
endl;
53 cout << myname <<
" Groups: [";
55 for (
Name nam : m_Groups ) {
56 if ( count && count%10 == 0 ) cout <<
"\n ";
57 if ( count++ ) cout <<
", ";
61 cout << myname <<
" Options: [";
63 for (
Name nam : m_Options ) {
64 if ( count++ ) cout <<
", ";
68 cout << myname <<
"Using " << (
m_useMedian ?
"median" :
"mean") <<
" correction." << endl;
69 cout << myname <<
"Using " << (
m_dropSignal ?
"all" :
"non-signal") <<
" samples." << endl;
70 cout << myname << (
m_requireGoodChannel ?
"R" :
"Not r") <<
"equiring good channel status." << endl;
71 cout << myname <<
" Group #chan" <<
endl;
72 for (
const auto& ient :
m_chg ) {
73 cout << myname <<
setw(10) << ient.first <<
setw(8) << ient.second.size() <<
endl;
ChannelGroupService::Name Name
bool m_requireGoodChannel
static constexpr double ps
Q_EXPORT QTSManip setw(int w)
void getIndices(IndexVector &idxs) const
QTextStream & endl(QTextStream &s)
CnrGroupWeighted::~CnrGroupWeighted |
( |
| ) |
|
|
overridedefault |
Definition at line 136 of file CnrGroupWeighted_tool.cc.
138 const string myname =
"CnrGroupWeighted::getCorrection: ";
140 std::vector<FloatVector> wsamples;
142 if ( wts.count(ich) == 0 )
continue;
143 float wt = wts.find(ich)->second;
144 auto iacd = acds.find(ich);
145 if ( iacd == acds.end() )
continue;
148 if ( acd.
samples.size() > nsam ) {
150 wsamples.resize(nsam);
152 for (
size_t isam=0; isam<acd.
samples.size(); ++isam ) {
154 if ( wt == 0 )
continue;
155 wsamples[isam].push_back(acd.
samples[isam]/wt);
158 std::vector<float> correction(nsam, 0.0);
160 for (
Index isam=0; isam<nsam; ++isam ) {
161 size_t nval = wsamples[isam].size();
162 if ( nval < 2 )
continue;
164 std::sort(wsamples[isam].
begin(), wsamples[isam].
end());
165 if ( nval%2 == 0 ) correction[isam] = 0.5 * (wsamples[isam][nval/2-1] + wsamples[isam][nval/2]);
166 else correction[isam] = wsamples[isam][nval/2];
169 for (
float val : wsamples[isam] ) sum +=
val;
170 correction[isam] = sum/
float(wsamples[isam].
size());
174 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...
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
bool m_requireGoodChannel
Index channelStatus() const
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
QTextStream & endl(QTextStream &s)
Definition at line 110 of file CnrGroupWeighted_tool.cc.
112 const string myname =
"CnrGroupWeighted::getWeights: ";
117 auto iacd = acds.find(ich);
118 if ( iacd == acds.end() )
continue;
124 cout << myname <<
"WARNING: Channel " << ich <<
" does not have attribute "
float getAttribute(Name mname, float def=0.0) const
bool hasAttribute(Name mname, float def=0.0) const
QTextStream & endl(QTextStream &s)
Reimplemented from AdcChannelTool.
Definition at line 80 of file CnrGroupWeighted_tool.cc.
81 const string myname =
"CnrGroupWeighted::updateMap: ";
83 if ( acds.size() == 0 ) {
84 std::cout << myname <<
"WARNING: No channels found." <<
std::endl;
92 std::vector<float> correction =
getCorrection(channels, acds, wts);
93 for (
Index ich : channels) {
94 auto iacd = acds.find(ich);
95 if ( iacd == acds.end() )
continue;
97 if ( acd.
samples.size() == 0 )
continue;
98 if ( acd.
samples.size() > correction.size() ) correction.resize(acd.
samples.size(), 0.);
99 for (
size_t isam=0; isam<acd.
samples.size(); ++isam) {
100 acd.
samples[isam] -= wts[ich]*correction[isam];
FloatVector getCorrection(const IndexVector &channels, const AdcChannelDataMap &acds, const FloatMap &wts) const
DataMap & setStatus(int stat)
void getWeights(const IndexVector &channels, const AdcChannelDataMap &acds, FloatMap &wts) const
std::map< Index, float > FloatMap
QTextStream & endl(QTextStream &s)
bool CnrGroupWeighted::m_dropSignal =true |
|
private |
int CnrGroupWeighted::m_LogLevel |
|
private |
bool CnrGroupWeighted::m_requireGoodChannel =true |
|
private |
bool CnrGroupWeighted::m_useMedian =false |
|
private |
Name CnrGroupWeighted::m_Weight |
|
private |
The documentation for this class was generated from the following files: