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

#include <TRTCheckPeakSimple.h>

Inheritance diagram for dqm_algorithms::TRTCheckPeakSimple:
Collaboration diagram for dqm_algorithms::TRTCheckPeakSimple:

Public Member Functions

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

Private Attributes

std::string m_name

Detailed Description

Definition at line 20 of file TRTCheckPeakSimple.h.

Constructor & Destructor Documentation

◆ TRTCheckPeakSimple()

dqm_algorithms::TRTCheckPeakSimple::TRTCheckPeakSimple ( )

Definition at line 30 of file TRTCheckPeakSimple.cxx.

30 : m_name("TRTCheckPeakSimple")
31{
32 dqm_core::AlgorithmManager::instance().registerAlgorithm(m_name, this);
33}

◆ ~TRTCheckPeakSimple()

dqm_algorithms::TRTCheckPeakSimple::~TRTCheckPeakSimple ( )
virtual

Definition at line 35 of file TRTCheckPeakSimple.cxx.

36{
37}

Member Function Documentation

◆ clone()

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

Definition at line 39 of file TRTCheckPeakSimple.cxx.

◆ execute()

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

Definition at line 45 of file TRTCheckPeakSimple.cxx.

46{
47 const TH1 *histogram;
48
49 if (object.IsA()->InheritsFrom("TH1")) {
50 histogram = static_cast<const TH1*>(&object);
51 if (histogram->GetDimension() > 2) {
52 throw dqm_core::BadConfig(ERS_HERE, name, "dimension > 2 ");
53 }
54 } else {
55 throw dqm_core::BadConfig(ERS_HERE, name, "does not inherit from TH1");
56 }
57 const double minstat = dqm_algorithms::tools::GetFirstFromMap("MinStat", config.getParameters(), -1);
58
59 if (histogram->GetEntries() < minstat) {
60 // ERS_INFO("Histogram does not satisfy MinStat requirement " << histogram->GetName());
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 dqm_core::Result *result = new dqm_core::Result();
67
68 if (histogram->Integral() == 0 && histogram->GetEntries() > 0) {
69 ERS_DEBUG(1, "Histogram " << histogram->GetName() << " is filled with zeroes!");
70 result->status_ = dqm_core::Result::Red;
71 result->tags_["Integral"] = histogram->Integral();
72 return result;
73 }
74
75
76 const double gthreshold = dqm_algorithms::tools::GetFromMap("PeakPosition", config.getGreenThresholds());
77 const double rthreshold = dqm_algorithms::tools::GetFromMap("PeakPosition", config.getRedThresholds());
78 const std::vector<int> range = dqm_algorithms::tools::GetBinRange(histogram, config.getParameters());
79 const int xmin = range[0];
80 const int xmax = range[1];
81
82 //compute the weighted mean
83 float wmean = 0;
84 float sum = 0;
85 float integral = 0;
86 for (int i = xmin; i <= xmax; i++) {
87 integral += histogram->GetBinContent(i);
88 sum += i * (histogram->GetBinContent(i));
89 }
90 if (integral != 0) {
91 wmean = sum / integral; // make sure that integer division does not truncate decimal of mean
92 }
93
94 //find the most probable value (peak)
95 float maxbinsum = 0;
96 float binsum = 0;
97 float peakbin = 0;
98 float peakpos = 0;
99
100 for (int i = xmin + 1; i <= xmax - 1; i++) {
101 binsum = histogram->GetBinContent(i - 1) + histogram->GetBinContent(i) + histogram->GetBinContent(i + 1);
102 if (binsum > maxbinsum) {
103 maxbinsum = binsum;
104 if (maxbinsum != 0) {
105 peakbin = ((i - 1) * histogram->GetBinContent(i - 1) + i * histogram->GetBinContent(i) + (i + 1) * histogram->GetBinContent(i + 1)) / maxbinsum;
106 peakpos = (histogram->GetBinCenter(i - 1) * histogram->GetBinContent(i - 1) + histogram->GetBinCenter(i) * histogram->GetBinContent(i) + histogram->GetBinCenter(i + 1) * histogram->GetBinContent(i + 1)) / maxbinsum;
107 } else {
108 peakbin = 0;
109 peakpos = 0;
110 }
111 }
112 }
113
114 result->tags_["Weighted_mean"] = wmean;
115 result->tags_["PeakBin"] = peakbin;
116 result->tags_["PeakPosition"] = peakpos;
117
118 if (peakpos >= gthreshold) result->status_ = dqm_core::Result::Green;
119 else if (peakpos > rthreshold) result->status_ = dqm_core::Result::Yellow;
120 else result->status_ = dqm_core::Result::Red;
121 return result;
122}
std::string histogram
Definition chains.cxx:52
double integral(TH1 *h)
Definition computils.cxx:59
double xmax
Definition listroot.cxx:61
double xmin
Definition listroot.cxx:60
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)
#define IsA
Declare the TObject style functions.

◆ printDescription()

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

Definition at line 124 of file TRTCheckPeakSimple.cxx.

125{
126 out << m_name << ": Checks on the most probable value (peak) in the histogram." << std::endl;
127}

Member Data Documentation

◆ m_name

std::string dqm_algorithms::TRTCheckPeakSimple::m_name
private

Definition at line 32 of file TRTCheckPeakSimple.h.


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