ATLAS Offline Software
Loading...
Searching...
No Matches
dqm_algorithms::BinsFilledOutRange Struct Reference

#include <BinsFilledOutRange.h>

Inheritance diagram for dqm_algorithms::BinsFilledOutRange:
Collaboration diagram for dqm_algorithms::BinsFilledOutRange:

Public Member Functions

 BinsFilledOutRange ()
 ~BinsFilledOutRange ()
BinsFilledOutRangeclone ()
dqm_core::Result * execute (const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
void printDescription (std::ostream &out)

Detailed Description

Definition at line 18 of file BinsFilledOutRange.h.

Constructor & Destructor Documentation

◆ BinsFilledOutRange()

dqm_algorithms::BinsFilledOutRange::BinsFilledOutRange ( )

Definition at line 24 of file BinsFilledOutRange.cxx.

25{
26 dqm_core::AlgorithmManager::instance().registerAlgorithm( "BinsFilledOutRange", this );
27}

◆ ~BinsFilledOutRange()

dqm_algorithms::BinsFilledOutRange::~BinsFilledOutRange ( )

Definition at line 29 of file BinsFilledOutRange.cxx.

30{
31}

Member Function Documentation

◆ clone()

dqm_algorithms::BinsFilledOutRange * dqm_algorithms::BinsFilledOutRange::clone ( )

Definition at line 34 of file BinsFilledOutRange.cxx.

◆ execute()

dqm_core::Result * dqm_algorithms::BinsFilledOutRange::execute ( const std::string & name,
const TObject & object,
const dqm_core::AlgorithmConfig & config )

Definition at line 41 of file BinsFilledOutRange.cxx.

44{
45 const TH1 * histogram;
46
47 if(object.IsA()->InheritsFrom( "TH1" )) {
48 histogram = static_cast<const TH1*>(&object);
49 if (histogram->GetDimension() > 1 ){
50 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 1 " );
51 }
52 } else {
53 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1");
54 }
55
56
57 const bool publish = (bool) dqm_algorithms::tools::GetFirstFromMap( "PublishBins", config.getParameters(), 0);
58 const int maxpublish = (int) dqm_algorithms::tools::GetFirstFromMap( "MaxPublish", config.getParameters(), 20);
59 const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
60 if (histogram->GetEntries() < minstat ) {
61 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
62 result->tags_["InsufficientEntries"] = histogram->GetEntries();
63 return result;
64 }
65
66 double gthreshold;
67 double rthreshold;
68 try {
69 rthreshold = dqm_algorithms::tools::GetFromMap( "NBins", config.getRedThresholds() );
70 gthreshold = dqm_algorithms::tools::GetFromMap( "NBins", config.getGreenThresholds() );
71 }
72 catch( dqm_core::Exception & ex ) {
73 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
74 }
75
76
77 int count = 0;
78 std::vector<int> range=dqm_algorithms::tools::GetBinRange(histogram, config.getParameters());
79 int nbins=histogram->GetNbinsX();
80 dqm_core::Result* result = new dqm_core::Result();
81 TH1* resulthisto;
82 if (histogram->InheritsFrom("TH2")) {
83 resulthisto=(TH1*)(histogram->Clone());
84 } else if (histogram->InheritsFrom("TH1")) {
85 resulthisto=(TH1*)(histogram->Clone());
86 } else {
87 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
88 }
89
90 resulthisto->Reset();
91
92 for ( int i = 1; i < range[0]; ++i ) {
93 double content = histogram -> GetBinContent(i);
94 if ( content !=0 ) {
95 ++count;
96 resulthisto->SetBinContent(i,content);
97 if (publish && count<maxpublish) {
99 }
100 }
101 }
102 for ( int j = range[1]; j <= nbins; ++j ) {
103 double content= histogram -> GetBinContent(j);
104 if ( content != 0 ) {
105 ++count;
106 resulthisto->SetBinContent(j,content);
107 if (publish && count<maxpublish) {
109 }
110 }
111 }
112
113 ERS_DEBUG(1,"Number of bins with content != 0 is " << count );
114 ERS_DEBUG(1,"Green threshold: "<< gthreshold << " bin(s); Red threshold : " << rthreshold << " bin(s) ");
115
116
117 result->tags_["NBins"] = count;
118 result->object_ = boost::shared_ptr<TObject>(resulthisto);
119
120 if (gthreshold > rthreshold) {
121 if ( count >= gthreshold ) {
122 result->status_ = dqm_core::Result::Green;
123 } else if ( count > rthreshold ) {
124 result->status_ = dqm_core::Result::Yellow;
125 } else {
126 result->status_ = dqm_core::Result::Red;
127 }
128 } else {
129 if ( count <= gthreshold ) {
130 result->status_ = dqm_core::Result::Green;
131 } else if ( count < rthreshold ) {
132 result->status_ = dqm_core::Result::Yellow;
133 } else {
134 result->status_ = dqm_core::Result::Red;
135 }
136 }
137
138 return result;
139}
std::string histogram
Definition chains.cxx:52
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
std::vector< int > GetBinRange(const TH1 *histogram, const std::map< std::string, double > &params)
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
void PublishBin(const TH1 *histogram, int xbin, int ybin, double content, dqm_core::Result *result)
str content
Definition grepfile.py:56
setBGCode setTAP setLVL2ErrorBits bool
#define IsA
Declare the TObject style functions.

◆ printDescription()

void dqm_algorithms::BinsFilledOutRange::printDescription ( std::ostream & out)

Definition at line 141 of file BinsFilledOutRange.cxx.

142{
143 out<<"Bins_Filled_OutsideRange: Checks for number of non-empty bins outside bin range\n"<<std::endl;
144
145 out<<"Mandatory Parameter: xmin: minimum x range"<<std::endl;
146 out<<"Mandatory Parameter: xmax: maximum x range"<<std::endl;
147 out<<"Mandatory Green/Red Threshold: NBins: Number of non-empty bins to give Green/Red result\n"<<std::endl;
148
149 out<<"Optional Parameter: PublishBins: Save bins which are different from average in Result (set to 1)"<<std::endl;
150 out<<"Optional Parameter: MaxPublish: Max number of bins to save (default 20)"<<std::endl;
151 out<<"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
152}

The documentation for this struct was generated from the following files: