ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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::Resultexecute (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.

40 {
41  return new TRTCheckPeakSimple(*this);
42 }

◆ 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());
62  result->tags_["InsufficientEntries"] = histogram->GetEntries();
63  return result;
64  }
65 
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  wmean = sum / integral; // make sure that integer division does not truncate decimal of mean
91 
92  //find the most probable value (peak)
93  float maxbinsum = 0;
94  float binsum = 0;
95  float peakbin = 0;
96  float peakpos = 0;
97 
98  for (int i = xmin + 1; i <= xmax - 1; i++) {
99  binsum = histogram->GetBinContent(i - 1) + histogram->GetBinContent(i) + histogram->GetBinContent(i + 1);
100  if (binsum > maxbinsum) {
101  maxbinsum = binsum;
102  if (maxbinsum != 0) {
103  peakbin = ((i - 1) * histogram->GetBinContent(i - 1) + i * histogram->GetBinContent(i) + (i + 1) * histogram->GetBinContent(i + 1)) / maxbinsum;
104  peakpos = (histogram->GetBinCenter(i - 1) * histogram->GetBinContent(i - 1) + histogram->GetBinCenter(i) * histogram->GetBinContent(i) + histogram->GetBinCenter(i + 1) * histogram->GetBinContent(i + 1)) / maxbinsum;
105  } else {
106  peakbin = 0;
107  peakpos = 0;
108  }
109  }
110  }
111 
112  result->tags_["Weighted_mean"] = wmean;
113  result->tags_["PeakBin"] = peakbin;
114  result->tags_["PeakPosition"] = peakpos;
115 
116  if (peakpos >= gthreshold) result->status_ = dqm_core::Result::Green;
117  else if (peakpos > rthreshold) result->status_ = dqm_core::Result::Yellow;
118  else result->status_ = dqm_core::Result::Red;
119  return result;
120 }

◆ printDescription()

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

Definition at line 122 of file TRTCheckPeakSimple.cxx.

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

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:
dqm_algorithms::tools::GetBinRange
std::vector< int > GetBinRange(const TH1 *histogram, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:380
Undefined
@ Undefined
Definition: MaterialTypes.h:8
get_generator_info.result
result
Definition: get_generator_info.py:21
IsA
#define IsA
Declare the TObject style functions.
Definition: xAODTEventBranch.h:59
integral
double integral(TH1 *h)
Definition: computils.cxx:58
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
dqm_algorithms::TRTCheckPeakSimple::m_name
std::string m_name
Definition: TRTCheckPeakSimple.h:32
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
lumiFormat.i
int i
Definition: lumiFormat.py:85
xmin
double xmin
Definition: listroot.cxx:60
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.handimod.Green
int Green
Definition: handimod.py:524
python.handimod.Red
Red
Definition: handimod.py:551
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
dqm_algorithms::TRTCheckPeakSimple::TRTCheckPeakSimple
TRTCheckPeakSimple()
Definition: TRTCheckPeakSimple.cxx:30
xmax
double xmax
Definition: listroot.cxx:61
dqm_algorithms::tools::GetFromMap
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
Definition: AlgorithmHelper.h:114
pickleTool.object
object
Definition: pickleTool.py:30
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
histogram
std::string histogram
Definition: chains.cxx:52