ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
dqm_algorithms
src
CTP_AllBinsAreEmptyExceptZero.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
dqm_algorithms/CTP_AllBinsAreEmptyExceptZero.h
"
6
7
#include <cmath>
8
#include <iostream>
9
#include <map>
10
#include <vector>
11
#include <string>
12
13
#include <TClass.h>
14
#include <TH1.h>
15
#include <TH2.h>
16
17
#include "dqm_core/exceptions.h"
18
#include "dqm_core/AlgorithmConfig.h"
19
#include "dqm_core/AlgorithmManager.h"
20
#include "dqm_core/Result.h"
21
#include "
dqm_algorithms/tools/AlgorithmHelper.h
"
22
#include "ers/ers.h"
23
24
25
static
dqm_algorithms::CTP_AllBinsAreEmptyExceptZero
staticInstance
;
26
27
28
namespace
dqm_algorithms
{
29
30
// *********************************************************************
31
// Public Methods
32
// *********************************************************************
33
34
CTP_AllBinsAreEmptyExceptZero::CTP_AllBinsAreEmptyExceptZero
()
35
:
m_name
(
"CTP_AllBinsAreEmptyExceptZero"
)
36
{
37
dqm_core::AlgorithmManager::instance().registerAlgorithm(
m_name
,
this
);
38
}
39
40
dqm_core::Algorithm*
41
CTP_AllBinsAreEmptyExceptZero::clone
()
42
{
43
return
new
CTP_AllBinsAreEmptyExceptZero
(*
this
);
44
}
45
46
47
dqm_core::Result*
48
CTP_AllBinsAreEmptyExceptZero::execute
(
const
std::string& name,
const
TObject&
object
,
const
dqm_core::AlgorithmConfig& config)
49
{
50
using namespace
std
;
51
52
const
TH1 *hist{};
53
54
if
(
object
.
IsA
()->InheritsFrom(
"TH1"
)) {
55
hist =
static_cast<
const
TH1*
>
( &object );
56
if
(hist->GetDimension() > 1 ){
57
throw
dqm_core::BadConfig( ERS_HERE, name,
"dimension > 1 "
);
58
}
59
}
else
{
60
throw
dqm_core::BadConfig( ERS_HERE, name,
"does not inherit from TH1"
);
61
}
62
63
//Get Parameters and Thresholds
64
double
threshold
= 0;
65
66
try
{
67
threshold
=
dqm_algorithms::tools::GetFirstFromMap
(
"threshold"
, config.getParameters(), 0);
68
}
69
catch
( dqm_core::Exception & ex ) {
70
throw
dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
71
}
72
73
//Algo
74
dqm_core::Result* result =
new
dqm_core::Result();
75
std::map<std::string,double>
tags
;
//defined in https://gitlab.cern.ch/atlas-tdaq-software/dqm_core/-/blob/master/dqm_core/Result.h
76
77
//assume all good, until find a bad one
78
result->status_ = dqm_core::Result::Green;
79
int
nbinsx = hist->GetXaxis()->GetNbins();
80
int
badBins = 0;
81
82
for
(
int
iBin = 1; iBin <= nbinsx-1; ++iBin)
//foreach bin of the projection (0=underflow)
83
{
84
// If bin content is nonzero, and 0 does not lie in between bin edges
85
if
( hist->GetBinContent(iBin) >
threshold
&& hist->GetBinLowEdge(iBin) * hist->GetBinLowEdge(iBin+1) > 0 )
86
{
87
result->status_ = dqm_core::Result::Red;
88
++ badBins;
89
}
90
}
91
tags
[
"# Bad bins"
] = badBins;
92
93
//set the result tags
94
result->tags_ = std::move(
tags
);
95
96
// Return the result
97
return
result;
98
}
99
100
101
void
102
CTP_AllBinsAreEmptyExceptZero::printDescription
(std::ostream& out){
103
std::string message;
104
message +=
"\n"
;
105
message +=
"Algorithm: \""
+
m_name
+
"\"\n"
;
106
message +=
"Description: Check that the only non-empty bin is the one centered in zero.\n"
;
107
out << message;
108
}
109
110
}
// namespace dqm_algorithms
AlgorithmHelper.h
staticInstance
static dqm_algorithms::AveragePrint staticInstance
Definition
AveragePrint.cxx:19
CTP_AllBinsAreEmptyExceptZero.h
dqm_algorithms::CTP_AllBinsAreEmptyExceptZero
Definition
CTP_AllBinsAreEmptyExceptZero.h:15
dqm_algorithms::CTP_AllBinsAreEmptyExceptZero::printDescription
virtual void printDescription(std::ostream &out)
Definition
CTP_AllBinsAreEmptyExceptZero.cxx:102
dqm_algorithms::CTP_AllBinsAreEmptyExceptZero::clone
virtual dqm_core::Algorithm * clone() override
Definition
CTP_AllBinsAreEmptyExceptZero.cxx:41
dqm_algorithms::CTP_AllBinsAreEmptyExceptZero::CTP_AllBinsAreEmptyExceptZero
CTP_AllBinsAreEmptyExceptZero()
Definition
CTP_AllBinsAreEmptyExceptZero.cxx:34
dqm_algorithms::CTP_AllBinsAreEmptyExceptZero::execute
virtual dqm_core::Result * execute(const std::string &name, const TObject &data, const dqm_core::AlgorithmConfig &config) override
Definition
CTP_AllBinsAreEmptyExceptZero.cxx:48
dqm_algorithms::CTP_AllBinsAreEmptyExceptZero::m_name
std::string m_name
Definition
CTP_AllBinsAreEmptyExceptZero.h:27
tags
std::vector< std::string > tags
Definition
hcg.cxx:107
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string ¶mName, const std::map< std::string, double > ¶ms)
Definition
AlgorithmHelper.cxx:346
dqm_algorithms
Definition
AddReference.h:17
std
STL namespace.
threshold
Definition
chainparser.cxx:74
IsA
#define IsA
Declare the TObject style functions.
Definition
xAODTEventBranch.h:59
Generated on
for ATLAS Offline Software by
1.17.0