59{
62
63 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
65 if (
hist->GetDimension() >= 2 ){
66 throw dqm_core::BadConfig( ERS_HERE, name, "dimension >= 2 " );
67 }
68 } else {
69 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
70 }
71
72
73 double minstat;
75 double greenTh;
76 double redTh;
77 double max_shift;
78 try {
84 }
85 catch ( dqm_core::Exception & ex ) {
86 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
87 }
88
89
90
91 try {
92 ref =
static_cast<const TH1*
>(
config.getReference() );
93 }
94 catch ( dqm_core::Exception & ex ) {
95 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
96 }
97 if (
hist->GetDimension() !=
ref->GetDimension() ) {
98 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different dimension!" );
99 }
100
101
102 if (
hist->GetEntries() < minstat ) {
103 ERS_INFO(
"Histogram does not satisfy MinStat requirement " <<
hist->GetName());
104 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
105 result->tags_[
"InsufficientEntries"] =
hist->GetEntries();
107 }
108 ERS_DEBUG(1,
"Statistics: "<<
hist->GetEntries()<<
" entries ");
109
110
111
112 Double_t chi2_per_NDF=999999999;
113
114 TF1* fit_ref = (TF1*)
ref->GetFunction(
"TimeSpectrum");
115 TF1* fit_hist= (TF1*)
hist->GetFunction(
"TimeSpectrum");
116
117 if(fit_ref == 0){
118 ERS_INFO(
"Missing reference fit for "<<
hist->GetName());
119 dqm_core::Result*
result =
new dqm_core::Result();
120 result->tags_[
"Fit_parameter_NOT_found"] = -999.;
121 result->status_ = dqm_core::Result::Undefined;
123 };
124 if(fit_hist == 0){
125 ERS_INFO(
"Missing fit for "<<
hist->GetName());
126 dqm_core::Result*
result =
new dqm_core::Result();
127 result->tags_[
"Fit_parameter_NOT_found"] = -999.;
128 result->status_ = dqm_core::Result::Undefined;
130 };
131
132 if(fit_hist->GetNDF() !=0) chi2_per_NDF = (fit_hist->GetChisquare())/(fit_hist->GetNDF());
133
134
135 if (chi2_per_NDF >
chi2 &&
chi2>0) {
136 ERS_INFO(
"Histogram does not satisfy chi_square/NDF requirement: " <<
hist->GetName());
137 dqm_core::Result*
result =
new dqm_core::Result();
138 result->tags_[
"Chi2_over_threshold"] = chi2_per_NDF;
139 result->status_ = dqm_core::Result::Undefined;
141 }
142
143 if(fit_hist->GetNDF() == 0){
144 ERS_INFO(
"NDF not available for histogram " <<
hist->GetName());
145 dqm_core::Result*
result =
new dqm_core::Result();
146 result->tags_[
"Fit_parameter_NDF"] = 0;
147 result->status_ = dqm_core::Result::Undefined;
149 };
150
151 Double_t t0_ref=0;
152 Double_t t0_err_ref=0;
153 Double_t tmax_ref=0;
154 Double_t tmax_err_ref=0;
155
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);
160
161 if (t0_err_ref<1.) {
162 t0_err_ref =1.;
163 }
164 if (tmax_err_ref<2.) {
165 tmax_err_ref =2.;
166 }
167
169 Double_t t0_err=0;
170 Double_t tmax=0;
171 Double_t tmax_err=0;
172
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);
177
178 if (t0_err<1.) {
179 t0_err =1.;
180 }
181 if (tmax_err<2.) {
182 tmax_err =2.;
183 }
184
185 Double_t
Dt0=std::abs(
t0-t0_ref);
186 Double_t Dtd=std::abs(tmax-
t0-tmax_ref+t0_ref);
187
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);
191
192 if( sigma_Dt0 ==0 || sigma_Dtmax==0 ){
193 ERS_DEBUG(1,"ERROR: fit parameter errors not found!");
194 dqm_core::Result*
result =
new dqm_core::Result();
195 result->tags_[
"Fit_parameter_NOT_found"] = -999.;
196 result->status_ = dqm_core::Result::Undefined;
198 };
199
200
201
202
203 dqm_core::Result*
result =
new dqm_core::Result();
205
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);
209
210 int flag_count=0;
211
212 if( Dtd*0.78125>max_shift ){
213 flag_count+=1000;
214 result->tags_[
"05-ERROR_(td-td_Ref)"] = Dtd;
215 };
216
217 if(Dt0>redTh*sigma_Dt0){
218 flag_count+=3;
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){
222 flag_count+=1;
223 result->tags_[
"07-ERROR_(t0-t0_Ref)"] =
Dt0;
224 result->tags_[
"08-ERROR_sigma(t0-t0_Ref)"] = sigma_Dt0;
225 };
226
227
228 if(Dtd>redTh*sigma_Dtd){
229 flag_count+=3;
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){
233 flag_count+=1;
234 result->tags_[
"05-ERROR_(td-td_Ref)"] = Dtd;
235 result->tags_[
"06-ERROR_sigma(td-td_Ref)"] = sigma_Dtd;
236 };
237
238
239 if (flag_count>2) {
240 result->status_ = dqm_core::Result::Red;
241 ERS_DEBUG(1,"Red");
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) {
246 result->status_ = dqm_core::Result::Green;
247 ERS_DEBUG(1,"Green");
248 }
250}
const boost::regex ref(r_ef)
double chi2(TH1 *h0, TH1 *h1)
#define IsA
Declare the TObject style functions.