103 #ifndef AdcChannelMetric_H 104 #define AdcChannelMetric_H 115 class ChannelStatusProvider;
138 void initialize(
bool force =
false);
153 Name& metricUnits,
double& metricWeight)
const;
236 if ( weight <= 0.0 )
return;
237 ++weightedEventCount;
238 if ( weightSum == 0 || val < minval ) minval =
val;
239 if ( weightSum == 0 || val > maxval ) maxval =
val;
242 sumsq += weight*val*
val;
244 double neff()
const {
return weightFlag ? weightSum : weightedEventCount; }
245 double mean()
const {
return weightSum ? sum/weightSum : 0.0; }
246 double dmean()
const {
return weightSum > 0.0 ? sdev()/sqrt(neff()) : 0.0; }
247 double meansq()
const {
return weightSum ? sumsq/weightSum : 0.0; }
249 return sqrt(meansq());
252 if ( weightSum <= 0.0 )
return 0.0;
253 double rmsVal =
rms();
254 double rmsVar = meansq() + rmsVal*(rmsVal - 2.0*
mean());
255 return rmsVar > 0.0 ? sqrt(rmsVar/neff()) : 0.0;
258 double valm =
mean();
259 double arg = meansq() - valm*valm;
260 return arg > 0 ? sqrt(arg) : 0.0;
263 double range()
const {
return maxval - minval; }
266 const std::set<Name> sumVals =
267 {
"weightFlag",
"eventCount",
"weightedEventCount",
"weightSum",
268 "mean",
"rms",
"sdev",
"min",
"max",
"dmean",
"drms",
269 "center",
"range",
"halfRange"};
270 return sumVals.find(vnam) != sumVals.end();
274 if ( vnam ==
"weightFlag" )
return weightFlag;
275 if ( vnam ==
"weightedEventCount" )
return weightedEventCount;
276 if ( vnam ==
"eventCount" )
return eventCount;
277 if ( vnam ==
"weightSum" )
return weightSum;
278 if ( vnam ==
"mean" )
return mean();
279 if ( vnam ==
"rms" )
return rms();
280 if ( vnam ==
"sdev" )
return sdev();
281 if ( vnam ==
"min" )
return minval;
282 if ( vnam ==
"max" )
return maxval;
283 if ( vnam ==
"center" )
return center();
284 if ( vnam ==
"range" )
return range();
285 if ( vnam ==
"halfRange" )
return 0.5*range();
286 if ( vnam ==
"dmean" )
return dmean();
287 if ( vnam ==
"drms" )
return drms();
321 float metricMax =100;
343 Name ofname,
Name ofrname,
bool useErrors)
const;
356 void evaluateFormulas()
const;
void setValue(double a_value)
const FloatArrayTool * m_pPedestalReference
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
std::map< IndexRange, MetricSummaryVector > MetricSummaryMap
const AdcChannelStringTool * m_adcStringBuilder
Index m_ChannelLineModulus
NameVector m_ChannelRanges
const lariov::ChannelStatusProvider * m_pChannelStatusProvider
std::vector< MetricSummary > MetricSummaryVector
std::vector< Name > NameVector
void setError(double a_error)
IndexVector m_ChannelCounts
std::vector< Index > IndexVector
NameVector m_MetadataFlags
Class providing information about the quality of channels.
static constexpr double ps
IndexVector m_ChannelLinePattern
Filters for channels, events, etc.
std::shared_ptr< State > StatePtr
double getValue(Name vnam) const
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
static bool isValueName(Name vnam)
std::vector< IndexRange > IndexRangeVector
IndexVector channelStatuses
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
bool operator<(const Metric &rhs) const
IndexVector m_ChannelLinePatternSolid
Event finding and building.
std::map< Index, Metric > MetricMap
void add(double val, double weight)