27 : m_LogLevel(ps.
get<
int>(
"LogLevel")),
28 m_SignalFlag(ps.
get<
Index>(
"SignalFlag")),
29 m_SignalIterationLimit(ps.
get<
Index>(
"SignalIterationLimit")),
30 m_SignalTool(ps.
get<
string>(
"SignalTool")),
31 m_DecayTime(ps.
get<double>(
"DecayTime")) ,
32 m_IncludeChannelRanges(ps.
get<
NameVector>(
"IncludeChannelRanges")),
33 m_ExcludeChannelRanges(ps.
get<
NameVector>(
"ExcludeChannelRanges")),
34 m_useChannelRanges(false),
35 m_pSignalTool(nullptr) {
36 const string myname =
"ExpTailRemover::ctor: ";
39 cout << myname <<
"WARNING: Invalid SignalFlag value " <<
m_SignalFlag 40 <<
" reset to " << signalFlag <<
"." <<
endl;
45 if ( ptm ==
nullptr ) {
46 cout << myname <<
"ERROR: Unable to retrieve tool manager." <<
endl;
50 cout << myname <<
"ERROR: Signal finding tool not found: " <<
m_SignalTool <<
endl;
58 if ( pcrt ==
nullptr ) {
59 cout << myname <<
"ERROR: IndexRangeTool not found: channelRanges" <<
endl;
67 cout << myname <<
"WARNING: Ignoring invalid include channel range " << crn <<
endl;
81 cout << myname <<
"WARNING: Ignoring invalid exclude channel range " << crn <<
endl;
90 cout << myname <<
"Parameters:" <<
endl;
96 cout << myname <<
" IncludeChannelRanges: [";
99 if ( first ) first =
false;
104 cout << myname <<
" ExcludeChannelRanges: [";
107 if ( first ) first =
false;
113 cout << myname <<
"Channel checking enabled for " << nchaCheck <<
" channel" 114 << ( nchaCheck == 1 ?
"" :
"s") <<
"." << endl;
116 cout << myname <<
"Channel checking disabled." <<
endl;
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;
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;
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);
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Index m_SignalIterationLimit
int setData(const FloatVector &inData)
void setFloat(Name name, float val)
DataMap & setStatus(int stat)
DataMap update(AdcChannelData &acd) const override
ExpTailRemover(fhicl::ParameterSet const &ps)
AdcChannelTool * m_pSignalTool
NameVector m_IncludeChannelRanges
int setPedestal(float val)
std::vector< bool > m_checkChannels
std::vector< Name > NameVector
const FloatVector & signal() const
void setInt(Name name, int val)
NameVector m_ExcludeChannelRanges
std::vector< double > DoubleVector
static constexpr double ps
Q_EXPORT QTSManip setw(int w)
Index channelStatus() const
std::vector< bool > AdcFilterVector
std::vector< AdcSignal > AdcSignalVector
auto const & get(AssnsNode< L, R, D > const &r)
QTextStream & endl(QTextStream &s)
int setDataZero(Index nsam)