55{
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
74
76
77 std::vector<std::string> hotRows;
78 std::vector<std::string> hotCols;
79 std::vector<std::pair<std::string,std::string>> hotBins;
80
82
84 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
87 }
88
89 double bin_threshold;
90 double gthreshold;
91 double rthreshold;
92 try {
96 }
97 catch ( dqm_core::Exception & ex ) {
98 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
99 }
100
101
104 dqm_core::Result*
result =
new dqm_core::Result();
105 TH1* resulthisto;
108 }
else if (
histogram->InheritsFrom(
"TH1")) {
110 } else {
111 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
112 }
113
114 resulthisto->Reset();
115 if(
m_name.find(
"Median")!=std::string::npos){
116 std::vector<double> bin_vals;
117 for (
int i = range[0];
i <=
range[1]; ++
i ) {
118 for (
int j = range[2];
j <=
range[3]; ++
j ) {
119 if(
histogram -> GetBinContent(i,j) > 0) bin_vals . push_back(
histogram -> GetBinContent(i,j) );
120 }
121 }
122 std::sort(bin_vals.begin(), bin_vals.end());
123 unsigned bin_vals_size = bin_vals.size();
125 if(bin_vals_size%2==0 && bin_vals_size>1)
median = (bin_vals.at(bin_vals_size/2-1)+bin_vals.at(bin_vals_size/2))/2;
126 else if(bin_vals_size%2==1 && bin_vals_size>1)
median = bin_vals.at(bin_vals_size/2-1);
127 else if(bin_vals_size==1)
median = bin_vals.at(0);
128
131 bin_threshold=
median*bin_threshold;
132
133 bin_threshold = std::max(bin_threshold, min_bin_threshold);
134 if(max_bin_threshold > -1 ) bin_threshold = std::min(bin_threshold, max_bin_threshold);
135
136 result->tags_[
"Effective_BinThreshold"] = bin_threshold;
137 }
138
139
142 std::pair<bool,bool> skipBin;
143 std::pair<const char*, const char*> binLabel;
144
145 for (
int i = range[0];
i <=
range[1]; ++
i ) {
147 binLabel.first = nullptr;
148 binLabel.second = nullptr;
149
150 if ( !hotCols.empty() ) {
151 for (const auto& col : hotCols){
152
153
154 binLabel.first =
histogram->GetXaxis()->GetBinLabel(i);
155 if ( std::to_string(i)==col || TString(binLabel.first).Contains(TRegexp((col).c_str(),
true)) )
skipCol =
true;
156 }
157 }
158
160
161
163
165
166 for (
int j = range[2];
j <=
range[3]; ++
j ) {
168 binLabel.first = nullptr;
169 binLabel.second = nullptr;
170
171 if ( !hotRows.empty() ) {
172 for (const auto& row : hotRows){
173
174
175 binLabel.second =
histogram->GetYaxis()->GetBinLabel(j);
176 if ( std::to_string(j)==row || TString(binLabel.second).Contains(TRegexp((row).c_str(),
true)) )
skipRow =
true;
177 }
178 }
179
181
182 skipBin.first = false;
183 skipBin.second = false;
184 binLabel.first = nullptr;
185 binLabel.second = nullptr;
186
187 if ( !hotBins.empty() ) {
188 for (const auto& bin : hotBins){
189
190
191 binLabel.first =
histogram->GetXaxis()->GetBinLabel(i);
192 if ( std::to_string(i)==
bin.first || TString(binLabel.first).Contains(TRegexp((
bin.first).c_str(),
true)) ) skipBin.first =
true;
193
194
195 binLabel.second =
histogram->GetYaxis()->GetBinLabel(j);
196 if ( std::to_string(j)==
bin.second || TString(binLabel.second).Contains(TRegexp((
bin.second).c_str(),
true)) ) skipBin.second =
true;
197 }
198 }
199
200 if (skipBin.first && skipBin.second) continue;
201
202
204
206
210 resulthisto->SetBinContent(i,j,content);
211 if (publish &&
count< maxpublish){
213 }
214 }
215 }
216 }
217
218 ERS_DEBUG(1,
"Number of bins " <<
m_name <<
" treshold of " << bin_threshold <<
" is " <<
count );
219 ERS_DEBUG(1,"Green threshold: "<< gthreshold << " bin(s); Red threshold : " << rthreshold << " bin(s) ");
220
222 if(TotalBins > -10){
225 if(
m_name.find(
"LessThan")!=std::string::npos)
result->tags_[
"NBins_%"] = 100.*effectiveCount/TotalBins;
226 else result->tags_[
"NBins_%"] = 100.*
count/TotalBins;
227 }
228
230 result->object_ = boost::shared_ptr<TObject>(resulthisto);
231 if (gthreshold > rthreshold) {
232 if (
count >= gthreshold ) {
233 result->status_ = dqm_core::Result::Green;
234 }
else if (
count > rthreshold ) {
235 result->status_ = dqm_core::Result::Yellow;
236 } else {
237 result->status_ = dqm_core::Result::Red;
238 }
239 } else {
240 if (
count <= gthreshold ) {
241 result->status_ = dqm_core::Result::Green;
242 }
else if (
count < rthreshold ) {
243 result->status_ = dqm_core::Result::Yellow;
244 } else {
245 result->status_ = dqm_core::Result::Red;
246 }
247 }
248
250
251}
static const uint32_t skipRow
static const uint32_t skipCol
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
float median(std::vector< float > &Vec)
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
setBGCode setTAP setLVL2ErrorBits bool
void parseIgnoreList(const std::string &bins, std::vector< std::string > &ignoredRows, std::vector< std::string > &ignoredCols, std::vector< std::pair< std::string, std::string > > &ignoredBins)
bool CompareBinThreshold(const std::string &objname, double bincontent, double threshold)
#define IsA
Declare the TObject style functions.