43{
44
46 TH1 * refhist;
47
48
49 double gthresho;
50 double rthresho;
51
52
54 if(
object.
IsA()->InheritsFrom(
"TProfile" ))
56
57
58 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
61 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
62 }
63 } else {
64 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
65 }
66
67 try {
68 refhist =
static_cast<TH1 *
>(
config.getReference() );
69 }
70 catch ( dqm_core::Exception & ex ) {
71 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
72 }
73
74 if (
histogram->GetDimension() != refhist->GetDimension() ) {
75 throw dqm_core::BadRefHist( ERS_HERE, name, "Dimension" );
76 }
77
78 if ((
histogram->GetNbinsX() != refhist->GetNbinsX()) || (
histogram->GetNbinsY() != refhist->GetNbinsY())) {
79 throw dqm_core::BadRefHist( ERS_HERE, name, "number of bins" );
80 }
81
82
83
84 std::string
thresh=
"ChiSqPerNdof";
85 try {
88 }
89 catch ( dqm_core::Exception & ex ) {
90 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
91 }
92
93
95
96
99 if(profile){
101 prof_ref = (
TProfile*)refhist->Clone();
102 }
103
104
105
106 if(!profile)
107 {
111 }
112
113
114
115 int numchi = 0;
116
117
118 double significance = 0;
119
120
122
123
125
126 double uncert1 =
histogram->GetBinError(i);
127 double uncert2 =
reference->GetBinError(i);
128 double uncert = std::sqrt(uncert1*uncert1 + uncert2*uncert2);
129
130 bool badbin = 0;
131
132
133
134 if(profile)
135 badbin = prof_hist->GetBinEntries(i)<2 || prof_ref->GetBinEntries(i)<2;
136
137
138
139
140
141 if(!profile)
143
144 if(uncert !=0 && badbin ==0){
145 numchi++;
146 significance += (
diff/uncert)*(
diff/uncert);
147 }
148 }
149
150 dqm_core::Result*
result =
new dqm_core::Result();
151
152 std::string
out =
"ChiSqPerBin";
153 std::string out1="ChiSqTotal";
154 std::string out2="ChiSqUsedBins";
155
156 if(numchi>0)
157 {
158 double value = significance/numchi;
160 result->tags_[out1] = significance;
161 result->tags_[out2] = numchi;
162 if ( value <= gthresho ) {
163 result->status_ = dqm_core::Result::Green;
164 } else if ( value < rthresho ) {
165 result->status_ = dqm_core::Result::Yellow;
166 } else {
167 result->status_ = dqm_core::Result::Red;
168 }
169 } else {
173 result->status_ = dqm_core::Result::Undefined;
174 }
175
176
177
181 result->tags_[
"EntriesReference"] = refhist->GetEntries();
182 result->tags_[
"MeanReference"] = refhist->GetMean();
183 result->tags_[
"RMSReference"] = refhist->GetRMS();
184
186}
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
TProfile(*args, **kwargs)
#define IsA
Declare the TObject style functions.