25 : m_LogLevel(ps.
get<
int>(
"LogLevel")),
26 m_BinsPerTick(ps.
get<
Index>(
"BinsPerTick")),
27 m_BinsPerWire(ps.
get<
Index>(
"BinsPerWire")),
29 m_ResponseCenter(ps.
get<
Index>(
"ResponseCenter")),
30 m_MinChannel(ps.
get<
Index>(
"MinChannel")),
31 m_MaxChannel(ps.
get<
Index>(
"MaxChannel")) {
32 const string myname =
"Adc2dConvolute::ctor: ";
34 std::ios cout_state(
nullptr);
35 cout_state.copyfmt(std::cout);
36 cout << myname <<
"Parameters:" <<
endl;
40 cout << myname <<
" ResponseVectors: [";
44 if ( first ) first =
false;
46 for (
Index isam=0; isam<vec.size(); ++isam ) {
47 float val = vec[isam];
48 if ( isam != 0 ) cout <<
", ";
49 if ( isam == 0 ) cout <<
"\n" << myname <<
setw(indent) <<
"[";
50 else if ( 10*(isam/10) == isam ) cout <<
"\n" << myname <<
setw(indent) <<
" ";
56 cout << myname <<
setw(indent-2) <<
"]" <<
endl;
66 const string myname =
"Adc2dConvolute::update: ";
68 if ( acds.size() == 0 )
return ret;
71 Index icha1 = acds.begin()->first;
73 Index icha2 = acds.rbegin()->first;
75 ret.
setInt(
"channelMin", icha1);
76 ret.
setInt(
"channelMax", icha2);
77 if ( icha2 < icha1 )
return ret.
setStatus(1);
78 if (
m_LogLevel >= 2 ) cout << myname <<
"Processing run() " << acd0.
run() <<
" event " << acd0.
event()
79 <<
" channel " << icha1 <<
" to " << icha2 <<
endl;
84 bool readSamples = nbint == 0;
85 if ( readSamples ) nbint = 1;
88 ret.
setInt(
"responseVectorCount", nrv);
91 std::map<AdcChannel, AdcSignalVector> inSamples;
92 for (
Index icha=icha1; icha<=icha2; ++icha ) {
93 if ( acds.count(icha) ) inSamples[icha] = acds[icha].samples;
98 for (
Index icha=icha1; icha<=icha2; ++icha ) {
100 cout << myname <<
"Creating samples for channel " << icha <<
endl;
102 if ( acds.count(icha) == 0 ) {
103 cout << myname <<
"Skipping missing output channel " << icha <<
endl;
110 for (
Index irv=0; irv<nrv; ++irv ) {
112 cout << myname <<
" Using Response vector " << irv <<
endl;
115 Index nbinrv = resvec.size();
116 Index dcha = (irv + nbinw/2)/nbinw;
117 Index jbinRight = (irv + nbinw/2)%nbinw;
118 Index jbinLeft = nbinw - jbinRight - 1;
119 using ChannelBin = std::pair<Index, Index>;
121 std::set<ChannelBin> jchbs;
122 if ( icha + dcha <= icha2 ) {
123 jchbs.emplace(icha + dcha, jbinRight);
125 if ( icha >= icha1 + dcha ) {
126 jchbs.emplace(icha - dcha, jbinLeft);
129 for ( ChannelBin jchb : jchbs ) {
130 Index jcha = jchb.first;
131 Index jbin = jchb.second;
133 cout << myname <<
" Filling from channel/bin " << jcha <<
"/" << jbin <<
endl;
135 if ( acds.count(jcha) == 0 ) {
136 cout << myname <<
" Skipping missing input channel " << jcha <<
endl;
140 if ( ! readSamples ) {
142 cout << myname <<
"ERROR: Input channel " << jcha
143 <<
" has an unexpected number of sample bins: " 149 Index nsamj = samsj.size();
151 cout << myname <<
" Skipping empty channel/bin " << jcha <<
"/" << jbin <<
endl;
154 Index nsami = (nsamj-1)/nbint + 1;
155 if ( nsami > samsi.size() ) {
157 cout << myname <<
" Increasing output sample size to " << nsami <<
endl;
159 samsi.resize(nsami, 0.0);
162 for (
Index isami=0; isami<nsami; ++isami ) {
164 cout << myname <<
" Filling output channel " << icha <<
" sample " << isami <<
endl;
166 Index ibint = nbint*isami;
167 float& sami = samsi[isami];
170 Index ibintOff = ibint + jofft;
171 Index jbint1 = ibintOff >= nbinrv ? ibintOff - nbinrv + 1: 0;
172 Index jbint2 = ibintOff < nsamj ? ibintOff + 1 : nsamj;
174 cout << myname <<
" Input channel tick range: (" << jbint1 <<
", " 175 << jbint2 - 1 <<
")" <<
endl;
176 cout << myname <<
" Response vector " << irv <<
" tick range: (" 177 << ibintOff + 1 - jbint2 <<
", " 178 << ibintOff - jbint1 <<
")" <<
endl;
180 for (
Index jbint=jbint1; jbint<jbint2; ++jbint ) {
181 Index ijbinrv = ibintOff - jbint;
182 sami += resvec[ijbinrv]*samsj[jbint];
186 cout << myname <<
" Channel " << icha <<
" sample[" << isami
187 <<
"] = " << sami <<
endl;
193 cout << myname <<
"Sample count for channel " << icha <<
" is " << samsi.size() <<
endl;
197 ret.
setInt(
"nmult", nmult);
DataMap updateMap(AdcChannelDataMap &acd) const override
AdcSignalVectorVector binSamples
DataMap & setStatus(int stat)
ChannelGroupService::Name Name
std::vector< ResponseVector > ResponseVectorVector
Q_EXPORT QTSManip setprecision(int p)
ResponseVectorVector m_ResponseVectors
Adc2dConvolute(fhicl::ParameterSet const &ps)
void setInt(Name name, int val)
std::vector< double > DoubleVector
static constexpr double ps
Q_EXPORT QTSManip setw(int w)
AdcSignalVector ResponseVector
std::vector< AdcSignal > AdcSignalVector
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
Dft::FloatVector FloatVector
auto const & get(AssnsNode< L, R, D > const &r)
QTextStream & endl(QTextStream &s)