#include <TRTWeightedAverage.h>
Definition at line 14 of file TRTWeightedAverage.h.
◆ TRTWeightedAverage()
dqm_algorithms::TRTWeightedAverage::TRTWeightedAverage |
( |
| ) |
|
◆ ~TRTWeightedAverage()
dqm_algorithms::TRTWeightedAverage::~TRTWeightedAverage |
( |
| ) |
|
◆ clone()
◆ execute()
dqm_core::Result * dqm_algorithms::TRTWeightedAverage::execute |
( |
const std::string & |
name, |
|
|
const TObject & |
object, |
|
|
const dqm_core::AlgorithmConfig & |
config |
|
) |
| |
Definition at line 35 of file TRTWeightedAverage.cxx.
40 if (
object.
IsA()->InheritsFrom(
"TH1")) {
43 throw dqm_core::BadConfig(ERS_HERE,
name,
"dimension > 1");
46 throw dqm_core::BadConfig(ERS_HERE,
name,
"does not inherit from TH1");
63 if (firstbin>lastbin){
65 result->tags_[
"Range_is_not_correct "] = 1;
71 result->tags_[
"Range_is_not_correct "] = 2;
77 result->tags_[
"Range_is_not_correct "] = 3;
82 refhist =
dynamic_cast<const TH1*
>(
config.getReference() );
84 catch ( dqm_core::Exception & ex ) {
85 throw dqm_core::BadRefHist(ERS_HERE,
name,
" Could not retreive reference");
89 throw dqm_core::BadRefHist(ERS_HERE,
name,
"Reference is not a histogram");
92 if (
histogram->GetDimension() != refhist->GetDimension() ) {
93 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Dimension" );
96 if ((
histogram->GetNbinsX() != refhist->GetNbinsX()) || (
histogram->GetNbinsY() != refhist->GetNbinsY())) {
97 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Non-matching number of bins of reference" );
100 std::map<std::string, double>
results;
104 double sumcontent = 0;
105 double CorrectedMean= 0;
107 for (
int i = firstbin;
i <= lastbin; ++
i) {
109 const double binContent =
histogram->GetBinContent(
i);
110 const double binCenter =
histogram->GetXaxis()->GetBinCenter(
i);
112 sum += binContent*binCenter;
113 sumcontent += binContent;
119 result->tags_[
"Content_is_zero "] = 1;
125 if (correctusingbin1>0){
128 double correctionfactor=bin0/Nentries;
129 CorrectedMean=
mean-(
p0+
p1*correctionfactor);
133 results[
"Abs_Diff"] = std::fabs(
mean-expectedaverage);
134 if (correctusingbin1>0){
135 results[
"Corrected_Weighted_mean"]= CorrectedMean+expectedaverage;
136 results[
"Corrected_Abs_Diff"]=std::fabs(CorrectedMean);
138 results[
"Corrected_Weighted_mean"]=0;
139 results[
"Corrected_Abs_Diff"]=0;
◆ printDescription()
void dqm_algorithms::TRTWeightedAverage::printDescription |
( |
std::ostream & |
out | ) |
|
|
virtual |
Definition at line 144 of file TRTWeightedAverage.cxx.
147 out <<
"TRTWeightedAverage: Calculates weighted average of the bins within the selected bin range. It is also possible to correct these results using the normalized value of the 0th bin. This is helpful for TRT drift time histogram. In the case of the correction algorithm expects the coefficients p0 and p1 such that (weighted_mean-p0-p1*normalized_firtbin_value) is 0 on the average. \n"
148 "Optional parameter: MinStat :\n"
149 "Optional parameter: FirstBin :\n"
150 "Optional parameter: LastBin :\n"
151 "Optional parameter: ExpectedAverage :\n"
152 "Optional parameter: P0 :\n"
153 "Optional parameter: P1 :\n"
154 "Optional parameter: CorrectUsing0Bin :\n"
155 "Returned values: \n"
156 " Weighted_mean: weighted average result for the selected bins. \n"
157 " Abs_Diff: Absolute value of the difference between Weighted_mean and ExpectedAverage, fabs(Weighted_mean-ExpectedAverage) \n"
158 " Corrected_Weighted_mean: Weighted_mean-(p0+p1*normalized_bin_0)+ExpectedAverage , 0 if CorrectUsing0Bin==0 \n"
159 " Corrected_Abs_Diff: fabs(Weighted_mean-(p0+p1*normalized_bin_0)), 0 if CorrectUsing0Bin==0 \n"
The documentation for this struct was generated from the following files:
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")