ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
dqm_algorithms
src
MaximumBin.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
dqm_algorithms/MaximumBin.h
"
6
#include "dqm_core/AlgorithmConfig.h"
7
#include "dqm_core/AlgorithmManager.h"
8
#include "
dqm_algorithms/tools/AlgorithmHelper.h
"
9
#include "TH1.h"
10
11
static
dqm_algorithms::MaximumBin
myInstance
;
12
13
dqm_algorithms::MaximumBin::MaximumBin
()
14
{
15
dqm_core::AlgorithmManager::instance().registerAlgorithm(
"MaximumBin"
,
this
);
16
}
17
18
dqm_algorithms::MaximumBin
*
19
dqm_algorithms::MaximumBin::clone
()
20
{
21
return
new
MaximumBin
();
22
}
23
24
25
dqm_core::Result *
26
dqm_algorithms::MaximumBin::execute
(
const
std::string & name,
27
const
TObject &
object
,
28
const
dqm_core::AlgorithmConfig & config)
29
{
30
// get the histogram
31
const
TH1 *
histogram
;
32
33
if
(
object
.
IsA
()->InheritsFrom(
"TH1"
) ) {
34
histogram
=
static_cast<
const
TH1*
>
(&object);
35
}
else
{
36
throw
dqm_core::BadConfig( ERS_HERE, name,
"does not inherit from TH1"
);
37
}
38
39
int
dim =
histogram
->GetDimension();
40
41
// get the reference maximum bin indices
42
int
refBinX=-1, refBinY=-1, refBinZ=-1;
// bin x,y,z-index to be compared to the maximum bin
43
try
{
44
refBinX = (int)
dqm_algorithms::tools::GetFirstFromMap
(
"RefBinX"
, config.getParameters());
45
if
(dim>1) refBinY = (int)
dqm_algorithms::tools::GetFirstFromMap
(
"RefBinY"
, config.getParameters());
46
if
(dim>2) refBinZ = (int)
dqm_algorithms::tools::GetFirstFromMap
(
"RefBinZ"
, config.getParameters());
47
}
48
catch
( dqm_core::Exception & ex ) {
49
throw
dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
50
}
51
52
// check MinStat
53
const
double
minstat =
dqm_algorithms::tools::GetFirstFromMap
(
"MinStat"
, config.getParameters(), -1);
54
if
(
histogram
->GetEntries() < minstat ) {
55
dqm_core::Result *result =
new
dqm_core::Result(dqm_core::Result::Undefined);
56
result->tags_[
"InsufficientEntries"
] =
histogram
->GetEntries();
57
return
result;
58
}
59
60
// find the maximum bin indices
61
int
maxBinX=-1, maxBinY=-1, maxBinZ=-1;
62
histogram
->GetMaximumBin(maxBinX,maxBinY,maxBinZ);
63
64
// publish the maximum bin indices
65
dqm_core::Result* result =
new
dqm_core::Result();
66
result->tags_[
"MaxBin_xIndex"
] = maxBinX;
67
if
(dim>1) result->tags_[
"MaxBin_yIndex"
] = maxBinY;
68
if
(dim>2) result->tags_[
"MaxBin_zIndex"
] = maxBinZ;
69
70
// check if the conditions are met
71
bool
match
= (maxBinX == refBinX);
72
if
(dim>1)
match
&= (maxBinY == refBinY);
73
if
(dim>2)
match
&= (maxBinZ == refBinZ);
74
75
// set the flag and return the result
76
if
(
match
) result->status_ = dqm_core::Result::Green;
77
else
result->status_ = dqm_core::Result::Red;
78
79
return
result;
80
}
81
82
83
void
dqm_algorithms::MaximumBin::printDescription
(std::ostream& out) {
84
out<<
"MaximumBin : Finds a bin with the maximum content and checks if the bin index matches the expectation"
<< std::endl;
85
out<<
"Mandatory parameter : RefBinX : Bin x-index where the maximum is expected"
<< std::endl;
86
out<<
"Optional parameter : RefBinY : Bin y-index where the maximum is expected"
<< std::endl;
87
out<<
"Optional parameter : RefBinZ : Bin z-index where the maximum is expected"
<< std::endl;
88
out<<
"Optional Parameter : MinStat : Minimum histogram statistics needed to perform Algorithm\n"
<< std::endl;
89
}
90
AlgorithmHelper.h
myInstance
static dqm_algorithms::AutoencoderExampleAlgorithm myInstance
Definition
AutoencoderExampleAlgorithm.cxx:30
MaximumBin.h
histogram
std::string histogram
Definition
chains.cxx:52
dqm_algorithms::MaximumBin
Definition
MaximumBin.h:15
dqm_algorithms::MaximumBin::MaximumBin
MaximumBin()
Definition
MaximumBin.cxx:13
dqm_algorithms::MaximumBin::printDescription
void printDescription(std::ostream &out)
Definition
MaximumBin.cxx:83
dqm_algorithms::MaximumBin::execute
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
Definition
MaximumBin.cxx:26
dqm_algorithms::MaximumBin::clone
MaximumBin * clone()
Definition
MaximumBin.cxx:19
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition
hcg.cxx:359
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string ¶mName, const std::map< std::string, double > ¶ms)
Definition
AlgorithmHelper.cxx:346
IsA
#define IsA
Declare the TObject style functions.
Definition
xAODTEventBranch.h:59
Generated on
for ATLAS Offline Software by
1.17.0