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

#include <DivideBin.h>

Inheritance diagram for dqm_algorithms::DivideBin:
Collaboration diagram for dqm_algorithms::DivideBin:

Public Member Functions

 DivideBin ()
DivideBinclone ()
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 DivideBin.h.

Constructor & Destructor Documentation

◆ DivideBin()

dqm_algorithms::DivideBin::DivideBin ( )

Definition at line 21 of file DivideBin.cxx.

23{
24 dqm_core::AlgorithmManager::instance().registerAlgorithm("DivideBin", this);
25}

Member Function Documentation

◆ clone()

dqm_algorithms::DivideBin * dqm_algorithms::DivideBin::clone ( )

Definition at line 28 of file DivideBin.cxx.

29{
30
31 return new DivideBin();
32}

◆ execute()

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

Definition at line 36 of file DivideBin.cxx.

39{
40 const TH1 * histogram;
41
42 if( object.IsA()->InheritsFrom( "TH1" ) ) {
43 histogram = static_cast<const TH1*>(&object);
44 if (histogram->GetDimension() > 2 ){
45 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
46 }
47 } else {
48 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
49 }
50
51
52 double gthresho;
53 double rthresho;
54 int xbin_num;
55 int xbin_denom;
56 try {
57 xbin_num = (int)dqm_algorithms::tools::GetFirstFromMap( "TestBin", config.getParameters());
58 xbin_denom = (int)dqm_algorithms::tools::GetFirstFromMap( "RefBin", config.getParameters());
59 }
60 catch ( dqm_core::Exception & ex ) {
61 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
62 }
63
64 try {
65 gthresho = dqm_algorithms::tools::GetFromMap( "Threshold", config.getGreenThresholds() );
66 rthresho = dqm_algorithms::tools::GetFromMap( "Threshold", config.getRedThresholds() );
67 }
68 catch ( dqm_core::Exception & ex ) {
69 throw dqm_core::BadConfig(ERS_HERE,name,"Parameter: 'Threshold' is mandatory, cannot continue");
70
71 }
72
73 const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
74
75 const double minrefentries = dqm_algorithms::tools::GetFirstFromMap( "MinRefEntries", config.getParameters(), 1 );
76
77 if (histogram->GetEntries() < minstat ) {
78 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
79 result->tags_["InsufficientEntries"] = histogram->GetEntries();
80 return result;
81 }
82
83 // Get the denominator
84 double hdenom = histogram->GetBinContent(xbin_denom);
85
86 if ( minrefentries > 0 && hdenom < minrefentries) {
87 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
88 result->tags_["InsufficientRefEntries"] = hdenom;
89 return result;
90 }
91
92 // Get the numerator
93 double hnum = histogram -> GetBinContent(xbin_num);
94
95 double value = hnum/hdenom;
96
97 dqm_core::Result* result = new dqm_core::Result();
98 result->tags_["BinRatio"] = value;
99
100if (rthresho < gthresho){
101 if ( value >= gthresho ) {
102 result->status_ = dqm_core::Result::Green;
103 } else if ( value < rthresho ) {
104 result->status_ = dqm_core::Result::Red;
105 } else {
106 result->status_ = dqm_core::Result::Yellow;
107 }
108} else {
109 if ( value <= gthresho ) {
110 result->status_ = dqm_core::Result::Green;
111 } else if ( value > rthresho ) {
112 result->status_ = dqm_core::Result::Red;
113 } else {
114 result->status_ = dqm_core::Result::Yellow;
115 }
116}
117
118 return result;
119}
std::string histogram
Definition chains.cxx:52
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)
#define IsA
Declare the TObject style functions.

◆ printDescription()

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

Definition at line 122 of file DivideBin.cxx.

122 {
123 out<<"DivideBin : Performs the division of a particular bin by the total entries in that histogram "<< std::endl;
124 out<<"Optional Parameter : MinStat : Minimum histogram statistics needed to perform Algorithm"<< std::endl;
125 out<<"Optional Parameter : MinRefEntries : Minimum number of entries in reference bin needed to perform Algorithm"<< std::endl;
126 out<<"Mandatory parameter: TestBin: Index of the bin in x that should be tested\n"<< std::endl;
127 out<<"Mandatory parameter: RefBin: Index of the bin in x that should be used as a reference\n"<< std::endl;
128
129}

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