18 #include "dqm_core/exceptions.h"
19 #include "dqm_core/AlgorithmConfig.h"
20 #include "dqm_core/AlgorithmManager.h"
21 #include "dqm_core/Result.h"
39 : m_name(
"MDTTDCspectrum")
63 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
65 if (
hist->GetDimension() >= 2 ){
66 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension >= 2 " );
69 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
85 catch ( dqm_core::Exception & ex ) {
86 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
92 ref =
static_cast<const TH1*
>(
config.getReference() );
94 catch ( dqm_core::Exception & ex ) {
95 throw dqm_core::BadRefHist(ERS_HERE,
name,
" Could not retreive reference");
97 if (
hist->GetDimension() !=
ref->GetDimension() ) {
98 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Reference VS histo: Different dimension!" );
102 if (
hist->GetEntries() < minstat ) {
103 ERS_INFO(
"Histogram does not satisfy MinStat requirement " <<
hist->GetName());
105 result->tags_[
"InsufficientEntries"] =
hist->GetEntries();
108 ERS_DEBUG(1,
"Statistics: "<<
hist->GetEntries()<<
" entries ");
112 Double_t chi2_per_NDF=999999999;
114 TF1* fit_ref = (TF1*)
ref->GetFunction(
"TimeSpectrum");
115 TF1* fit_hist= (TF1*)
hist->GetFunction(
"TimeSpectrum");
118 ERS_INFO(
"Missing reference fit for "<<
hist->GetName());
120 result->tags_[
"Fit_parameter_NOT_found"] = -999.;
125 ERS_INFO(
"Missing fit for "<<
hist->GetName());
127 result->tags_[
"Fit_parameter_NOT_found"] = -999.;
132 if(fit_hist->GetNDF() !=0) chi2_per_NDF = (fit_hist->GetChisquare())/(fit_hist->GetNDF());
135 if (chi2_per_NDF >
chi2 &&
chi2>0) {
136 ERS_INFO(
"Histogram does not satisfy chi_square/NDF requirement: " <<
hist->GetName());
138 result->tags_[
"Chi2_over_threshold"] = chi2_per_NDF;
143 if(fit_hist->GetNDF() == 0){
144 ERS_INFO(
"NDF not available for histogram " <<
hist->GetName());
146 result->tags_[
"Fit_parameter_NDF"] = 0;
152 Double_t t0_err_ref=0;
154 Double_t tmax_err_ref=0;
156 if(fit_ref !=0) t0_ref = ((fit_ref->GetParameter(4))*0.78125);
157 if(fit_ref !=0) t0_err_ref = ((fit_ref->GetParError(4))*0.78125);
158 if(fit_ref !=0) tmax_ref = ((fit_ref->GetParameter(5))*0.78125);
159 if(fit_ref !=0) tmax_err_ref = ((fit_ref->GetParError(5))*0.78125);
164 if (tmax_err_ref<2.) {
173 if(fit_hist !=0) t0 = ((fit_hist->GetParameter(4))*0.78125);
174 if(fit_hist !=0) t0_err = ((fit_hist->GetParError(4))*0.78125);
175 if(fit_hist !=0) tmax = ((fit_hist->GetParameter(5))*0.78125);
176 if(fit_hist !=0) tmax_err = ((fit_hist->GetParError(5))*0.78125);
185 Double_t
Dt0=std::abs(t0-t0_ref);
186 Double_t Dtd=std::abs(tmax-t0-tmax_ref+t0_ref);
188 Double_t sigma_Dt0=sqrt(t0_err*t0_err+t0_err_ref*t0_err_ref);
189 Double_t sigma_Dtmax=sqrt(tmax_err*tmax_err+tmax_err_ref*tmax_err_ref);
190 Double_t sigma_Dtd= sqrt(tmax_err*tmax_err+t0_err*t0_err+tmax_err_ref*tmax_err_ref+t0_err_ref*t0_err_ref);
192 if( sigma_Dt0 ==0 || sigma_Dtmax==0 ){
193 ERS_DEBUG(1,
"ERROR: fit parameter errors not found!");
195 result->tags_[
"Fit_parameter_NOT_found"] = -999.;
204 result->tags_[
"01-t0(ns)"] = t0;
206 result->tags_[
"02-sigma_t0(ns)"] = t0_err;
207 result->tags_[
"03-t_drift(ns)"] = (tmax-t0);
208 result->tags_[
"04-sigma_t_drift(ns)"] = sqrt(tmax_err*tmax_err+t0_err*t0_err);
212 if( Dtd*0.78125>max_shift ){
214 result->tags_[
"05-ERROR_(td-td_Ref)"] = Dtd;
217 if(
Dt0>redTh*sigma_Dt0){
219 result->tags_[
"07-ERROR_(t0-t0_Ref)"] =
Dt0;
220 result->tags_[
"08-ERROR_sigma(t0-t0_Ref)"] = sigma_Dt0;
221 }
else if(
Dt0>greenTh*sigma_Dt0){
223 result->tags_[
"07-ERROR_(t0-t0_Ref)"] =
Dt0;
224 result->tags_[
"08-ERROR_sigma(t0-t0_Ref)"] = sigma_Dt0;
228 if(Dtd>redTh*sigma_Dtd){
230 result->tags_[
"05-ERROR_(td-td_Ref)"] = Dtd;
231 result->tags_[
"06-ERROR_sigma(td-td_Ref)"] = sigma_Dtd;
232 }
else if(Dtd>greenTh*sigma_Dtd){
234 result->tags_[
"05-ERROR_(td-td_Ref)"] = Dtd;
235 result->tags_[
"06-ERROR_sigma(td-td_Ref)"] = sigma_Dtd;
242 }
else if (flag_count>=1 && flag_count<=2) {
243 result->status_ = dqm_core::Result::Yellow;
244 ERS_DEBUG(1,
"Yellow");
245 }
else if (flag_count<1) {
247 ERS_DEBUG(1,
"Green");
259 message +=
"Description: Check if the histogram t0 tmax and t_drift are compatible with the reference\n";
260 message +=
"Mandatory Parameters: Green/Red Threshold: Limits: warning: number of standard deviation from mean\n";
262 message +=
"Optional Parameters: MinStat = Minimum histogram statistics needed to perform Algorithm\n";
263 message +=
" chi2 = chi square limit for histogram fit\n";
264 message +=
" max_shift = maximum difference between t_drif of the histograns and reference\n";