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

#include <CheckMean.h>

Inheritance diagram for dqm_algorithms::CheckMean:
Collaboration diagram for dqm_algorithms::CheckMean:

Public Member Functions

 CheckMean ()
virtual ~CheckMean ()
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)

Protected Member Functions

virtual double getWarningLimit (const dqm_core::AlgorithmConfig &config, std::string limitName)
virtual double getErrorLimit (const dqm_core::AlgorithmConfig &config, std::string limitName)

Protected Attributes

std::string m_name
std::string m_limitName

Detailed Description

Definition at line 16 of file CheckMean.h.

Constructor & Destructor Documentation

◆ CheckMean()

dqm_algorithms::CheckMean::CheckMean ( )

Definition at line 30 of file CheckMean.cxx.

32 : m_name("AlgCheckMean")
33 , m_limitName("chi2")
34{
35 dqm_core::AlgorithmManager::instance().registerAlgorithm( m_name, this );
36}

◆ ~CheckMean()

dqm_algorithms::CheckMean::~CheckMean ( )
virtual

Definition at line 39 of file CheckMean.cxx.

41{
42}

Member Function Documentation

◆ clone()

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

Definition at line 46 of file CheckMean.cxx.

48{
49 return new CheckMean(*this);
50}

◆ execute()

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

Definition at line 54 of file CheckMean.cxx.

56{
57 dqm_core::Result::Status status(dqm_core::Result::Undefined);
58
59 // Cast to the type of TObject to assess
60 const TH1* h = dynamic_cast<const TH1*>( &data );
61 if( h == 0 ) {
62 throw dqm_core::BadConfig( ERS_HERE, name, "Cannot cast data to type TH1" );
63 }
64
65 const TH1* ref = dynamic_cast<const TH1*>( config.getReference() );
66 if( ref == 0 ) {
67 throw dqm_core::BadConfig( ERS_HERE, name, "Cannot obtain reference of type TH1" );
68 }
69
70 // Perform the check
71 const double mean_data = h->GetMean();
72 const double mean_ref = ref->GetMean();
73
74 const double mean_data_err = h->GetMeanError();
75 const double mean_ref_err = ref->GetMeanError();
76
77 const double chi2_warn = getWarningLimit( config, m_limitName );
78 const double chi2_err = getErrorLimit( config, m_limitName );
79
80 const double s = ( mean_data - mean_ref );
81 const double s2 = s*s;
82 const double e2 = mean_data_err*mean_data_err + mean_ref_err*mean_ref_err;
83
84 const double chi2 = s2/e2;
85
86 //out << "mean_data = " << mean_data << "\n";
87 //out << "mean_ref = " << mean_ref << "\n";
88 //out << "mean_data_err = " << mean_data_err << "\n";
89 //out << "mean_ref_err = " << mean_ref_err << "\n";
90 //out << "chi2 = " << chi2 << "\n";
91
92 if( chi2 < chi2_warn ) {
93 status = dqm_core::Result::Green;
94 }
95 else if( chi2 < chi2_err ) {
96 status = dqm_core::Result::Yellow;
97 }
98 else {
99 status = dqm_core::Result::Red;
100 }
101
102 // Return the result
103 return new dqm_core::Result( status );
104}
const boost::regex ref(r_ef)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual double getWarningLimit(const dqm_core::AlgorithmConfig &config, std::string limitName)
virtual double getErrorLimit(const dqm_core::AlgorithmConfig &config, std::string limitName)
double chi2(TH1 *h0, TH1 *h1)
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
status
Definition merge.py:16

◆ getErrorLimit()

double dqm_algorithms::CheckMean::getErrorLimit ( const dqm_core::AlgorithmConfig & config,
std::string limitName )
protectedvirtual

Definition at line 145 of file CheckMean.cxx.

147{
148 std::map<std::string,double> rdmap = config.getRedThresholds();
149 std::map<std::string,double>::const_iterator i = rdmap.find( limitName );
150 if( i == rdmap.end() ) {
151 throw dqm_core::BadConfig( ERS_HERE, std::move(limitName), "Cannot find red threshold" );
152 }
153
154 return i->second;
155}

◆ getWarningLimit()

double dqm_algorithms::CheckMean::getWarningLimit ( const dqm_core::AlgorithmConfig & config,
std::string limitName )
protectedvirtual

Definition at line 131 of file CheckMean.cxx.

133{
134 std::map<std::string,double> grmap = config.getGreenThresholds();
135 std::map<std::string,double>::const_iterator i = grmap.find( limitName );
136 if( i == grmap.end() ) {
137 throw dqm_core::BadConfig( ERS_HERE, std::move(limitName), "Cannot find green threshold" );
138 }
139
140 return i->second;
141}

◆ printDescription()

void dqm_algorithms::CheckMean::printDescription ( std::ostream & out)
virtual

Definition at line 108 of file CheckMean.cxx.

110{
111 std::string message;
112 message += "\n";
113 message += "Algorithm: \"" + m_name + "\"\n";
114 message += "Description: Checks the mean of a TH1 against the mean of a reference TH1\n";
115 message += " by assessing a chi2 defined by the two means and their errors\n";
116 message += "Parameters: none\n";
117 message += "Limits:\n";
118 message += " \"" + m_limitName + "\" : generate warnings on the chi2 value\n";
119 message += "\n";
120
121 out << message;
122}

Member Data Documentation

◆ m_limitName

std::string dqm_algorithms::CheckMean::m_limitName
protected

Definition at line 34 of file CheckMean.h.

◆ m_name

std::string dqm_algorithms::CheckMean::m_name
protected

Definition at line 33 of file CheckMean.h.


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