ATLAS Offline Software
Loading...
Searching...
No Matches
dqm_algorithms::MDTPercentUnderThresh Class Reference

#include <MDTPercentUnderThresh.h>

Inheritance diagram for dqm_algorithms::MDTPercentUnderThresh:
Collaboration diagram for dqm_algorithms::MDTPercentUnderThresh:

Public Member Functions

 MDTPercentUnderThresh ()
virtual ~MDTPercentUnderThresh ()
virtual dqm_core::Algorithm * clone ()
virtual dqm_core::Result * execute (const std::string &name, const TObject &data, const dqm_core::AlgorithmConfig &config)
virtual void printDescription (std::ostream &out)

Private Attributes

std::string m_name

Detailed Description

Definition at line 16 of file MDTPercentUnderThresh.h.

Constructor & Destructor Documentation

◆ MDTPercentUnderThresh()

dqm_algorithms::MDTPercentUnderThresh::MDTPercentUnderThresh ( )

Definition at line 37 of file MDTPercentUnderThresh.cxx.

38 : m_name("MDTpercent_under_thresh")
39{
40 dqm_core::AlgorithmManager::instance().registerAlgorithm( m_name, this );
41}

◆ ~MDTPercentUnderThresh()

dqm_algorithms::MDTPercentUnderThresh::~MDTPercentUnderThresh ( )
virtual

Definition at line 44 of file MDTPercentUnderThresh.cxx.

45{
46}

Member Function Documentation

◆ clone()

dqm_core::Algorithm * dqm_algorithms::MDTPercentUnderThresh::clone ( )
virtual

Definition at line 50 of file MDTPercentUnderThresh.cxx.

◆ execute()

dqm_core::Result * dqm_algorithms::MDTPercentUnderThresh::execute ( const std::string & name,
const TObject & data,
const dqm_core::AlgorithmConfig & config )
virtual

Definition at line 57 of file MDTPercentUnderThresh.cxx.

58{
59 const TH1 * hist;
60
61 if( object.IsA()->InheritsFrom( "TH1" ) ) {
62 hist = static_cast<const TH1*>(&object);
63 if (hist->GetDimension() >= 2 ){
64 throw dqm_core::BadConfig( ERS_HERE, name, "dimension >= 2 " );
65 }
66 } else {
67 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
68 }
69
70 //Get Parameters and Thresholds
71 double minstat;
72 double thresh;
73 double greenTh;
74 double redTh;
75 try {
76 thresh = dqm_algorithms::tools::GetFirstFromMap( "Thresh", config.getParameters());
77 minstat = dqm_algorithms::tools::GetFirstFromMap("MinStat", config.getParameters(), 0);
78 redTh = dqm_algorithms::tools::GetFromMap( "Percent", config.getRedThresholds());
79 greenTh = dqm_algorithms::tools::GetFromMap( "Percent", config.getGreenThresholds() );
80 }
81 catch ( dqm_core::Exception & ex ) {
82 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
83 }
84
85 //Check of statistics
86 if (hist->GetEntries() < minstat ) {
87 ERS_INFO("Histogram does not satisfy MinStat requirement " <<hist->GetName());
88 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
89 result->tags_["InsufficientEntries"] = hist->GetEntries();
90 return result;
91 }
92 ERS_DEBUG(1,"Statistics: "<< hist->GetEntries()<< " entries ");
93
94 //Algo
95
96 Double_t hit_under_th=0;
97
98 Double_t N = hist->GetEntries();
99
100 if(N == 0) {
101 dqm_core::Result* result = new dqm_core::Result();
102 result->tags_["Empty_Histogram_found_N_Entries"] = N;
103 result->status_ = dqm_core::Result::Undefined;
104 return result;
105 };
106
107 int i=0;
108
109 do{
110 i++;
111 if(i>hist->GetNbinsX()){
112 dqm_core::Result* result = new dqm_core::Result();
113 result->tags_["Config_error_maximum_bin_exceed_looking_for_bin_number"] = i;
114 result->status_ = dqm_core::Result::Undefined;
115 return result;
116 };
117 hit_under_th += hist->GetBinContent(i);
118 }while(hist->GetBinCenter(i)<thresh);
119
120 double percent = 100 - 100*((double) hit_under_th)/((double) N);
121
122 //Result
123
124 dqm_core::Result* result = new dqm_core::Result();
125 result->tags_["Entries_above_thresh(%)"] = percent;
126
127 if( percent >= greenTh ) {
128 result->status_ = dqm_core::Result::Green;
129 }
130 else if( percent <greenTh && percent>redTh ) {
131 result->status_ = dqm_core::Result::Yellow;
132 }
133 else {
134 result->status_ = dqm_core::Result::Red;
135 }
136
137 // Return the result
138 return result;
139}
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::MDTPercentUnderThresh::printDescription ( std::ostream & out)
virtual

Definition at line 143 of file MDTPercentUnderThresh.cxx.

143 {
144 std::string message;
145 message += "\n";
146 message += "Algorithm: \"" + m_name + "\"\n";
147 message += "Description: Compute the percent of entries above a threshold and and compare it with user defined green and red Threshold\n";
148 message += "Mandatory Parameters: Green/Red Threshold: Percent: Percent of the entries above threshold requested";
149 message += "Optional Parameters: MinStat = Minimum histogram statistics needed to perform Algorithm\n";
150 message += " thresh = threshold\n";
151 message += "\n";
152
153 out << message;
154}

Member Data Documentation

◆ m_name

std::string dqm_algorithms::MDTPercentUnderThresh::m_name
private

Definition at line 28 of file MDTPercentUnderThresh.h.


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