124 const string myname =
"ExpTailRemover::update: ";
129 Index nsam = samples.size();
141 cout << myname <<
"WARNING: Data for channel " << acd.
channel() <<
" has " 142 << ( nsam==0 ?
"no" :
"too few" ) <<
" ticks." <<
endl;
146 if (
m_LogLevel >= 2 ) cout << myname <<
"Correcting run " << acd.
run() <<
" event " << acd.
event()
150 bool checkSignal =
true;
151 bool findSignal =
false;
155 if ( acd.
signal.size() < nsam ) {
156 cout << myname <<
"WARNING: Data is missing signal flags--padding from " << acd.
signal.size()
157 <<
" to " << nsam <<
" samples." <<
endl;
161 cout << myname <<
"WARNING: Signal-finding tool is missing. Using all signals." <<
endl;
174 while ( niter < maxiter ) {
180 cout << myname <<
"WARNING: Signal-finding failed for event " << acd.
event()
184 if ( acd.
signal == signalLast ) {
185 if (
m_LogLevel >=3 ) cout << myname <<
"Signal is unchanged. Exiting loop." <<
endl;
193 sta.setDataZero(nsam);
195 copy(sta.signal().begin(), sta.signal().end(), ctau.begin());
197 sta.setPedestal(1.0);
198 sta.setDataZero(nsam);
200 copy(sta.signal().begin(), sta.signal().end(), cped.begin());
201 sta.setPedestal(0.0);
202 sta.setData(samples);
204 copy(sta.signal().begin(), sta.signal().end(), cdat.begin());
213 for (
Index isam=0; isam<nsam; ++isam ) {
214 if ( checkSignal && isam < acd.
signal.size() && acd.
signal[isam] )
continue;
215 double cd = cdat[isam];
216 double ct = ctau[isam];
217 double cp = cped[isam];
227 double den = ktt*kpp - ktp*ktp;
230 cout << myname <<
"WARNING: Unable to invert K-matrix with " 231 << nsamKeep <<
" of " << nsam <<
" samples--stopping iteration for channel " 236 double deninv = 1.0/den;
237 tau = deninv*(kdp*ktp-kdt*kpp);
238 ped = deninv*(kdt*ktp-kdp*ktt);
239 double chsq = kdd + ktt*tau*tau + kpp*ped*ped + 2.0*(kdt*tau + kdp*ped + ktp*tau*ped);
241 if ( nsamKeep > 2 && chsq > 0.0 ) {
242 noise = sqrt(chsq/(nsamKeep-2));
244 if (
m_LogLevel >= 3 ) cout << myname <<
"Iteration " << niter <<
": ped, tau, noise: " 245 << ped <<
", " << tau <<
", " << noise
246 <<
" (" << nsamKeep <<
" samples)." <<
endl;
250 sta.setPedestal(ped);
251 sta.setData(samples);
259 cout << myname <<
"Iteration count: " << niter <<
endl;
260 cout << myname <<
"Final ped, tau: " << ped <<
", " << tau <<
endl;
270 ret.
setInt(
"uscNsamFit", nsamKeep);
271 ret.
setInt(
"uscNiteration", niter);
Index m_SignalIterationLimit
void setFloat(Name name, float val)
DataMap & setStatus(int stat)
AdcChannelTool * m_pSignalTool
std::vector< bool > m_checkChannels
void setInt(Name name, int val)
std::vector< double > DoubleVector
Index channelStatus() const
std::vector< bool > AdcFilterVector
std::vector< AdcSignal > AdcSignalVector
QTextStream & endl(QTextStream &s)