14 #include "dqm_core/exceptions.h"
16 #include "dqm_core/AlgorithmManager.h"
17 #include "dqm_core/AlgorithmConfig.h"
18 #include "dqm_core/Result.h"
35 message +=
"Description: Extracts bin contents from a TProfile, TH1, TH2 object without performing\n";
36 message +=
" any assessment; the status is always \"Undefined\"\n";
37 message +=
"Optional Parameter: UnMask_All Default = -1\n";
38 message +=
" <0: Only unmask bins when Mask_## = 0\n";
39 message +=
" >=0: Unmask all bins and only mask bins when Mask_## = 1\n";
40 message +=
" # >= 0: Maximum number of bins printed is #\n";
41 message +=
" This setting is combined so that large bin lists do not occur accidentaly.\n";
42 message +=
"Optional Parameter: UseValue: Default = 0\n";
43 message +=
" 0: Print all unmasked bins\n";
44 message +=
" 1: Print bin contents >= Value\n";
45 message +=
" >1: Print bin contents > Value\n";
46 message +=
" -1: Print bin contents <= Value\n";
47 message +=
" <-1: Print bin contents < Value\n";
48 message +=
"Optional Parameter: Value:\n";
49 message +=
"Optional Parameter: UseMaskValue: Default = 0\n";
50 message +=
" 0: Mask no bins\n";
51 message +=
" 1: Change Mask for all >= MaskValue\n";
52 message +=
" >1: Change Mask for all > Mask Value\n";
53 message +=
" -1: Change Mask for all <= MaskValue\n";
54 message +=
" <-1: Change Mask for all < Mask Value\n";
55 message +=
" NOTE: The same boundaries apply to the mask\n";
56 message +=
"Optional Parameter: MaskValue:\n";
57 message +=
" Example of Printing values from 0. <= x <= 1.\n";
59 message +=
" Value = 0. ## x >= 0.\n";
60 message +=
" UseMaskValue = 2\n";
61 message +=
" MaskValue = 1. ## x <= 1.\n";
62 message +=
" Example of Printing values outside of the range above\n";
65 message +=
" ## By Value Only: x > 1.0\n";
66 message +=
" UseMaskValue = -2\n";
68 message +=
" ## Including Mask: x < 0.0\n";
69 message +=
"Optional Parameter: TypeValue: Default = 0\n";
70 message +=
" 0: Value is compared to total entries in bin\n";
71 message +=
" 1: Value is compared to fraction of entries in histogram appearing in bin\n";
72 message +=
" This also determines how the bin contents will be listed if published.\n";
73 message +=
"1D Histogram Configuration:\n";
74 message +=
"Optional Parameters: Mask_#\n";
77 message +=
" Example of Printing all but the first bin\n";
78 message +=
" ***In algorithm declaration\n";
81 message +=
"2D Histogram Configuration:\n";
82 message +=
"Optional Parameters: Mask_#_#\n";
85 message +=
" Example of masking the X = 1, Y = 2 bin:\n";
86 message +=
" ***In algorithm declaration\n";
90 message +=
"Optional Parameters: PrintError\n";
91 message +=
" 1: Print Corresponding Bin Error\n";
138 if (!
data.IsA()->InheritsFrom(
"TH1")) {
139 throw dqm_core::BadConfig(ERS_HERE,
name,
"does not inherit from TH1");
141 const TH1*
h =
static_cast<const TH1*
>(&
data);
142 if (
h->GetDimension() > 2) {
143 throw dqm_core::BadConfig(ERS_HERE,
name,
"dimension > 2 ");
158 if (
h->GetDimension() == 1) {
162 std::vector<bool> Mask;
166 double h_entries =
h->GetEntries();
171 double bincon =
h->GetBinContent(
bin + 1);
172 double ebincon =
h->GetBinError(
bin + 1);
176 bool do_printbin =
false;
182 ) do_printbin =
true;
187 ) do_printbin = ! do_printbin;
193 double binvalX =
h->GetXaxis()->GetBinCenter(
bin + 1);
194 std::string binname = Form(
"%s_Bin(%u | %.*e)",
name.c_str(),
bin, 2, binvalX);
195 std::string sigbinname = Form(
"%s_EBin(%u | %.*e)",
name.c_str(),
bin, 2, binvalX);
201 result->tags_[binname.c_str()] = (bincon / h_entries);
202 if (Error ==1 )
result->tags_[sigbinname.c_str()] = ebincon ;
204 result->tags_[binname.c_str()] = bincon;
205 if (Error ==1 )
result->tags_[sigbinname.c_str()] = ebincon ;
216 if (
h->GetDimension() == 2) {
221 std::vector< std::vector<bool> > Mask;
225 double h_entries =
h->GetEntries();
231 double bincon =
h->GetBinContent(
binX + 1,
binY + 1);
232 double ebincon =
h->GetBinError(
binX + 1,
binY + 1);
234 bool do_printbin =
false;
240 ) do_printbin =
true;
245 ) do_printbin = ! do_printbin;
250 double binvalX =
h->GetXaxis()->GetBinCenter(
binX + 1);
251 double binvalY =
h->GetYaxis()->GetBinCenter(
binY + 1);
252 std::string binname = Form(
"%s_Bin((%u,%u) | %.*e,%.*e)",
name.c_str(),
binX,
binY, 2, binvalX, 2, binvalY);
253 std::string sigbinname = Form(
"%s_EBin((%u,%u) | %.*e,%.*e)",
name.c_str(),
binX,
binY, 2, binvalX, 2, binvalY);
255 result->tags_[binname.c_str()] = (bincon / h_entries);
256 result->tags_[sigbinname.c_str()] = ebincon;
259 result->tags_[binname.c_str()] = bincon;
260 result->tags_[sigbinname.c_str()] = ebincon;
271 std::string pub_excess = Form(
"%s_PROBLEM_Publishable_UnPrinted",
name.c_str());
285 std::map<std::string, double>::const_iterator
it =
params.find(
"UseValue");
287 return((
int)
it->second);
295 std::map<std::string, double>::const_iterator
it =
params.find(
"TypeValue");
297 return((
int)
it->second);
305 std::map<std::string, double>::const_iterator
it =
params.find(
"Value");
315 std::map<std::string, double>::const_iterator
it =
params.find(
"UseMaskValue");
317 return((
int)
it->second);
325 std::map<std::string, double>::const_iterator
it =
params.find(
"MaskValue");
335 std::map<std::string, double>::const_iterator mask_map_bin;
338 bool default_Mask =
true;
341 mask_map_bin =
params.find(
"UnMask_All");
342 if ( mask_map_bin !=
params.end() ) {
343 if(mask_map_bin->second > 0.5) {
345 default_Mask =
false;
348 std::vector<bool> Mask(
m_NbinsX, default_Mask);
352 std::string mask_bin = Form(
"Mask_%d",
bin + 1);
353 mask_map_bin =
params.find(mask_bin.c_str());
354 if ( mask_map_bin !=
params.end() ) {
355 if(mask_map_bin->second > 0.5) Mask[
bin] =
true;
356 else Mask[
bin] =
false;
365 std::map<std::string, double>::const_iterator mask_map_bin;
368 bool default_Mask =
true;
371 mask_map_bin =
params.find(
"UnMask_All");
372 if ( mask_map_bin !=
params.end() ) {
373 if(mask_map_bin->second > 0.5) {
375 default_Mask =
false;
378 std::vector< std::vector<bool> > Mask(
m_NbinsX, std::vector<bool>(
m_NbinsY, default_Mask));
383 std::string mask_bin = Form(
"Mask_%d_%d",
binX + 1,
binY + 1);
384 mask_map_bin =
params.find(mask_bin.c_str());
385 if ( mask_map_bin !=
params.end() ) {
386 if(mask_map_bin->second > 0.5) Mask[
binX][
binY] =
true;