45{
46 const TH1 * inputgraph;
47
48 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
49 inputgraph =
static_cast<const TH1*
>( &
object );
50
51 } else {
52 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
53 }
54
56
57 if (inputgraph->GetEntries() < minstat ) {
58 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
59 result->tags_[
"InsufficientEntries"] = inputgraph->GetEntries();
61 }
62
63
64
65
66 TH1 * refhist;
67 double gthresho;
68 double rthresho;
69 std::string option;
70
71 std::string thresholdname="Chi2_per_NDF";
72
73 try {
76 }
77 catch ( dqm_core::Exception & ex ) {
78 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
79
80 }
81
82 try {
83 refhist =
static_cast<TH1 *
>(
config.getReference() );
84 }
85 catch ( dqm_core::Exception & ex ) {
86 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
87 }
88
89 if (inputgraph->GetDimension() != refhist->GetDimension() ) {
90 throw dqm_core::BadRefHist( ERS_HERE, "Dimension", name );
91 }
92
93
94
95 if ((inputgraph->GetNbinsX() != refhist->GetNbinsX()) || (inputgraph->GetNbinsY() != refhist->GetNbinsY())) {
96 throw dqm_core::BadRefHist( ERS_HERE, "number of bins", name );
97 }
98
100 double chisq=0;
101 double errsquared{};
102 double inputerr{};
103 double referr{};
105 double refval{};
106
107
108
109 std::vector<int>
range;
110 try{
112 }
113 catch( dqm_core::Exception & ex ) {
114 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
115 }
116
117
118
119 int count_ndf=0;
120
121 for(n=range[0];
n<(
range[1]+1);
n++)
122 { inputerr=inputgraph->GetBinError(n);
123 referr=refhist->GetBinError(n);
124 errsquared= referr*referr+inputerr*inputerr;
125 val=inputgraph->GetBinContent(n);
126 refval=refhist->GetBinContent(n);
127 if (referr >0.00001 && inputerr >0.00001)
128 {chisq=chisq+((
val-refval)*(
val-refval))/errsquared;
129 count_ndf++;
130 }
131 else
132 {
133 }
134
135 }
136
137
138 const double value = (count_ndf > 1) ? (chisq / (count_ndf - 1)) : 0;
139
140 dqm_core::Result*
result =
new dqm_core::Result();
142
143
144
145
146 if ( value <= gthresho ) {
147 result->status_ = dqm_core::Result::Green;
148 } else if ( value < rthresho ) {
149 result->status_ = dqm_core::Result::Yellow;
150 } else {
151 result->status_ = dqm_core::Result::Red;
152 }
153
154 ERS_DEBUG(2,"Result: "<<*result);
155
157
158}
#define IsA
Declare the TObject style functions.