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

#include <CheckBinSpike.h>

Inheritance diagram for dqm_algorithms::CheckBinSpike:
Collaboration diagram for dqm_algorithms::CheckBinSpike:

Public Member Functions

 CheckBinSpike (const std::string &name)
CheckBinSpikeclone ()
dqm_core::Result * execute (const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
void printDescription (std::ostream &out)
void checkBinByBin (const TH1 *hist, float &result, float &detectedBin)

Private Attributes

std::string m_name

Detailed Description

Definition at line 18 of file CheckBinSpike.h.

Constructor & Destructor Documentation

◆ CheckBinSpike()

dqm_algorithms::CheckBinSpike::CheckBinSpike ( const std::string & name)

Definition at line 30 of file CheckBinSpike.cxx.

31 : m_name ( name )
32{
33 dqm_core::AlgorithmManager::instance().registerAlgorithm("CheckBinSpike_" + name, this );
34}

Member Function Documentation

◆ checkBinByBin()

void dqm_algorithms::CheckBinSpike::checkBinByBin ( const TH1 * hist,
float & result,
float & detectedBin )

Definition at line 82 of file CheckBinSpike.cxx.

82 {
83 std::vector<float> values;
84 for ( int ibin=1; ibin<hist->GetNbinsX()+1; ibin++ ){
85 float ref = (hist->GetBinContent(ibin-1) + hist->GetBinContent(ibin+1))*0.5;
86 if ( ibin==1 ) {
87 ref = (hist->GetBinContent(hist->GetNbinsX()) + hist->GetBinContent(ibin+1))*0.5;
88 }
89 if ( ibin==hist->GetNbinsX() ){
90 ref = (hist->GetBinContent(1) + hist->GetBinContent(ibin-1))*0.5;
91 }
92 float test = hist->GetBinContent(ibin);
93 values.push_back(test/ref);
94 }
95 result = *std::max_element(values.begin(),values.end());
96 int bin = std::max_element(values.begin(),values.end()) - values.begin();
97 detectedBin = hist->GetXaxis()->GetBinCenter(bin);
98}
const boost::regex ref(r_ef)

◆ clone()

dqm_algorithms::CheckBinSpike * dqm_algorithms::CheckBinSpike::clone ( )

Definition at line 36 of file CheckBinSpike.cxx.

36 {
37 return new CheckBinSpike(m_name);
38}
CheckBinSpike(const std::string &name)

◆ execute()

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

Definition at line 41 of file CheckBinSpike.cxx.

41 {
42 // Cast to the type of TObject to assess
43 const TH1* h = dynamic_cast<const TH1*>( &data );
44 if( h == 0 ) {
45 throw dqm_core::BadConfig( ERS_HERE, name, "Cannot cast data to type TH1" );
46 }
47 const TH1* ref = dynamic_cast<const TH1*>( config.getReference() );
48 if( ref == 0 ) {
49 throw dqm_core::BadConfig( ERS_HERE, name, "Cannot obtain reference of type TH1" );
50 }
51 double greenThr, redThr;
52
53 std::string thrName="MaxDist";
54
55 try {
56 greenThr = dqm_algorithms::tools::GetFromMap( thrName, config.getGreenThresholds() );
57 redThr = dqm_algorithms::tools::GetFromMap( thrName, config.getRedThresholds() );
58 }
59 catch ( dqm_core::Exception & ex ) {
60 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
61
62 }
63 float bin = 0;
64 float maxValue = 0;
65 checkBinByBin(h, maxValue, bin);
66 std::unique_ptr<dqm_core::Result> result (new dqm_core::Result());
67 result->tags_["MaximumValue"] = maxValue;
68 result->tags_["SpottedBin"] = bin;
69
70 if( maxValue < greenThr ) {
71 result->status_ = dqm_core::Result::Green;
72 }
73 else if( maxValue > redThr ) {
74 result->status_ = dqm_core::Result::Red;
75 }
76 else {
77 result->status_ = dqm_core::Result::Yellow;
78 }
79 return result.release();
80}
#define maxValue(current, test)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
void checkBinByBin(const TH1 *hist, float &result, float &detectedBin)

◆ printDescription()

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

Definition at line 100 of file CheckBinSpike.cxx.

100 {
101 std::string message;
102 message += "\n";
103 message += "Algorithm: \"" + m_name + "\"\n";
104 message += "Description: Checks if the maximum ratio between bins in a TH1F\n";
105 message += " is above a given threshold. Useful for peak detection\n";
106 message += "Parameters: none\n";
107 message += "\n";
108 out << message;
109}

Member Data Documentation

◆ m_name

std::string dqm_algorithms::CheckBinSpike::m_name
private

Definition at line 27 of file CheckBinSpike.h.


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