17 #include "dqm_core/exceptions.h"
18 #include "dqm_core/AlgorithmConfig.h"
19 #include "dqm_core/AlgorithmManager.h"
20 #include "dqm_core/Result.h"
38 : m_name(
"MDTADCspectrum")
62 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
64 if (
hist->GetDimension() >= 2 ){
65 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension >= 2 " );
68 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
82 catch ( dqm_core::Exception & ex ) {
83 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
89 ref =
static_cast<const TH1*
>(
config.getReference() );
91 catch ( dqm_core::Exception & ex ) {
92 throw dqm_core::BadRefHist(ERS_HERE,
name,
" Could not retreive reference");
94 if (
hist->GetDimension() !=
ref->GetDimension() ) {
95 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Reference VS histo: Different dimension!" );
99 if (
hist->GetEntries() < minstat ) {
100 ERS_INFO(
"Histogram does not satisfy MinStat requirement " <<
hist->GetName());
102 result->tags_[
"InsufficientEntries"] =
hist->GetEntries();
105 ERS_DEBUG(1,
"Statistics: "<<
hist->GetEntries()<<
" entries ");
110 Double_t n_min_50_ref=0;
112 Double_t
N =
hist->GetEntries();
113 Double_t N_ref =
ref ->GetEntries();
119 n_min_50 +=
hist->GetBinContent(
i);
120 if(
i>
hist->GetNbinsX()){
121 ERS_INFO(
"bin limit!"<<
i);
132 n_min_50_ref +=
ref->GetBinContent(
i);
133 if(
i>
ref->GetNbinsX()){
134 ERS_INFO(
"bin limit!"<<
i);
143 Double_t sigma_hist = -1;
144 Double_t sigma_ref = -1;
149 if(
N == 0 && N_ref == 0) {
150 ERS_INFO(
"null N entries found");
152 result->tags_[
"ERROR_null_entries_found"] = -999.;
157 if(
N !=0 && N_ref !=0){
159 f_r = n_min_50_ref/N_ref;
161 if(
f*f_r == 0 || (1-
f)<0 || (1-f_r)<0 ){
162 ERS_DEBUG(1,
"*) f = "<<
f<<
" f_r = "<<f_r);
164 result->tags_[
"ERROR_problem_in_fraction_computation"] = -999.;
165 result->tags_[
"n_min_50/N"] =
f;
166 result->tags_[
"n_min_50_ref/N_ref"] = f_r;
173 sigma_hist= std::sqrt(
f*(1-
f)/
N);
174 sigma_ref= std::sqrt(f_r*(1-f_r)/N_ref);
178 sigma =
F*std::sqrt((sigma_hist/
f)*(sigma_hist/
f)+(sigma_ref/f_r)*(sigma_ref/f_r));
187 result->tags_[
"00-Pedestal_fraction"] =
f;
188 result->tags_[
"1-Pedestal_over_Ped_ref"] = (1-
F);
191 if(
f<= greenTh || (
f>greenTh && f_r>greenTh)) {
194 else if(
f>redTh && f_r<greenTh ) {
195 result->tags_[
"Difference_against_Ref-Pedestal_fraction_Ref"] = f_r;
199 result->status_ = dqm_core::Result::Yellow;
212 message +=
"Description: Checks if the ratio of hits under treshold is below the limits\n";
213 message +=
" Comparison with reference is performed \n";
214 message +=
"Mandatory Parameters: Green/Red Threshold: Limits: warning: ratio limits \n";
216 message +=
"Optional Parameters: MinStat = Minimum histogram statistics needed to perform Algorithm\n";
217 message +=
" thresh = ADC cut on pedestal N counts (def 50)\n";