60{
63
64 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
66 if (
hist->GetDimension() >= 2 ){
67 throw dqm_core::BadConfig( ERS_HERE, name, "dimension >= 2 " );
68 }
69 } else {
70 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
71 }
72
73
74 double minstat;
75 double n_sigma;
76 double greenTh;
77 double redTh;
78 try {
83 }
84 catch ( dqm_core::Exception & ex ) {
85 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
86 }
87
88 double cluster_size=greenTh;
89
90
91
92 try {
93 ref =
static_cast<TH1*
>(
config.getReference() );
94 }
95 catch ( dqm_core::Exception & ex ) {
96 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retrieve reference");
97 }
98 if (
hist->GetDimension() !=
ref->GetDimension() ) {
99 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different dimension!" );
100 }
101 if (
hist->GetNbinsX() !=
ref->GetNbinsX() ) {
102 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different bin number in X axis!" );
103 }
104
105
106 if (
hist->GetEntries() < minstat ) {
107 ERS_INFO(
"Histogram does not satisfy MinStat requirement " <<
hist->GetName());
108 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
109 result->tags_[
"InsufficientEntries"] =
hist->GetEntries();
111 }
112 ERS_DEBUG(1,
"Statistics: "<<
hist->GetEntries()<<
" entries ");
113
114
115
117 double N_ref;
118
119 N=
hist->GetEntries();
120 N_ref=
ref->GetEntries();
121
122 if(N == 0){
123 ERS_INFO(
"Histogram has no entries" <<
hist->GetName());
124 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
125 result->tags_[
"InsufficientEntries"] =
hist->GetEntries();
127 };
128
129 if(N_ref == 0){
130 ERS_INFO(
"Reference histogram has no entries" <<
hist->GetName());
131 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
132 result->tags_[
"InsufficientRefEntries"] =
ref->GetEntries();
134 };
135
136
137
140
141
142
144 int j=1;
145 std::vector<double>
diff;
146
147 for(j=1;j<=
hist->GetNbinsX();j++){
148 diff.push_back(
hist->GetBinContent(j)-
ref->GetBinContent(j));
149 };
150
151
152
153
154
155
156
157
159 bool cluster_open=false;
160 std::pair<int,int> bin_start_end;
161 std::pair<int , std::pair<int,int> > cluster_size_binStart_binEnd;
162 std::vector< std::pair< int , std::pair< int, int> > >
clusters;
163 int size=0;
164
165 for(i=0;
i<
diff.size();
i++){
166 if(std::abs(
diff[i])>n_sigma*std::sqrt(
hist->GetBinContent(i+1)+
ref->GetBinContent(i+1)*norm)){
167 if(cluster_open){
168 if(i!=0){
170 size++;
171 } else {
172 if(size>=cluster_size){
173 bin_start_end.second=
i;
174 cluster_size_binStart_binEnd.first=size;
175 cluster_size_binStart_binEnd.second=bin_start_end;
176 clusters.push_back(cluster_size_binStart_binEnd);
177 };
178 cluster_open=false;
179 };
180 } else {
181 ERS_INFO("Cluster searching fail");
182 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
185 };
186 };
187
188 if(!cluster_open){
189 cluster_open=true;
190 size=0;
191 bin_start_end.first=
i+1;
192 size++;
193 };
194 };
195
196 if(std::abs(
diff[i])<=n_sigma*std::sqrt(
hist->GetBinContent(i+1)+
ref->GetBinContent(i+1)*norm)){
197 if(cluster_open){
198 if(size>=cluster_size){
199 bin_start_end.second=
i;
200 cluster_size_binStart_binEnd.first=size;
201 cluster_size_binStart_binEnd.second=bin_start_end;
202 clusters.push_back(cluster_size_binStart_binEnd);
203 };
204 cluster_open=false;
205 };
206 };
207 if(i==
diff.size()-1){
208 if(cluster_open){
209 if(size>=cluster_size){
210 bin_start_end.second=
i+1;
211 cluster_size_binStart_binEnd.first=size;
212 cluster_size_binStart_binEnd.second=bin_start_end;
213 clusters.push_back(cluster_size_binStart_binEnd);
214 };
215 cluster_open=false;
216 };
217 };
218 };
219
220
221
222
223 dqm_core::Result*
result =
new dqm_core::Result();
225
226 std::string Cluster="Cluster_";
228 std::string
Size=
"_info_1_size";
229 std::string start_at_bin="_info_2_start_at_bin";
230 std::string finish_at_bin="_info_3_finish_at_bin";
231 std::string message1;
232 std::string message2;
233 std::string message3;
234
236 if((i+1)<10){
237 sprintf(num,"0%u",(i+1));
238 };
239
240 if((i+1)>=10){
241 sprintf(num,"%u",(i+1));
242 };
243
244 message1 = Cluster + (std::string) num + Size;
245 message2 = Cluster + (std::string) num + start_at_bin;
246 message3 = Cluster + (std::string) num + finish_at_bin;
247
251 };
252
253
257 if(clusters[i].first<redTh)
flag++;
258 if(clusters[i].first>=redTh)
flag+=2;
259 };
260
261
262 if (flag<1) {
263 result->status_ = dqm_core::Result::Green;
264 ERS_DEBUG(1,"Green");
265 } else if ( flag>=1 && flag<2 ) {
266 result->status_ = dqm_core::Result::Yellow;
267 ERS_DEBUG(1,"Yellow");
268 } else if (flag>=2) {
269 result->status_ = dqm_core::Result::Red;
270 ERS_DEBUG(1,"Red");
271 }
272
274}
const boost::regex ref(r_ef)
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
#define IsA
Declare the TObject style functions.