ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
dqm_algorithms
src
MUCTPISLAnyHit.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/MUCTPISLAnyHit.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::MUCTPISLAnyHit
staticInstance
;
26
27
28
namespace
dqm_algorithms
{
29
30
// *********************************************************************
31
// Public Methods
32
// *********************************************************************
33
34
MUCTPISLAnyHit::MUCTPISLAnyHit
()
35
:
m_name
(
"MUCTPISLAnyHit"
)
36
{
37
dqm_core::AlgorithmManager::instance().registerAlgorithm(
m_name
,
this
);
38
}
39
40
dqm_core::Algorithm*
41
MUCTPISLAnyHit::clone
()
42
{
43
return
new
MUCTPISLAnyHit
(*
this
);
44
}
45
46
47
dqm_core::Result*
48
MUCTPISLAnyHit::execute
(
const
std::string& name,
const
TObject&
object
,
const
dqm_core::AlgorithmConfig& config)
49
{
50
using namespace
std
;
51
52
const
TH2 *hist{};
53
54
//ensure that input histo is 2D
55
if
(
object
.
IsA
()->InheritsFrom(
"TH2"
) ) {
56
hist =
static_cast<
const
TH2 *
>
(&object);
57
if
(hist->GetDimension() != 2 ){
58
throw
dqm_core::BadConfig( ERS_HERE, name,
"dimension != 2 "
);
59
}
60
}
else
{
61
throw
dqm_core::BadConfig( ERS_HERE, name,
"does not inherit from TH2"
);
62
}
63
64
//Get Parameters and Thresholds
65
double
thresh=0.1;
66
67
try
{
68
thresh =
dqm_algorithms::tools::GetFirstFromMap
(
"thresh"
, config.getParameters(), 0.1);
69
}
70
catch
( dqm_core::Exception & ex ) {
71
throw
dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
72
}
73
74
//Algo
75
76
//project our 2D histogram to 1D (on the y-axis), thus summing up along x
77
TH1* projection = hist->ProjectionY();
78
79
dqm_core::Result* result =
new
dqm_core::Result();
80
std::map<std::string,double>
tags
;
//defined in https://gitlab.cern.ch/atlas-tdaq-software/dqm_core/-/blob/master/dqm_core/Result.h
81
82
//assume all good, until find a bad one
83
result->status_ = dqm_core::Result::Green;
84
uint
howmanybad=0;
85
86
for
(
int
iBin=1;iBin<=projection->GetNbinsX();iBin++)
//foreach bin of the projection (0=underflow)
87
{
88
if
( projection->GetBinContent(iBin) < thresh )
//if bin content less than algorithm threshold => bad
89
{
90
result->status_ = dqm_core::Result::Yellow;
91
howmanybad++;
92
}
93
}
94
tags
[
"howmanybad"
] = howmanybad;
95
96
//set the result tags
97
result->tags_ = std::move(
tags
);
98
99
// Return the result
100
return
result;
101
}
102
103
104
void
105
MUCTPISLAnyHit::printDescription
(std::ostream& out){
106
std::string message;
107
message +=
"\n"
;
108
message +=
"Algorithm: \""
+
m_name
+
"\"\n"
;
109
message +=
"Description: Makes the ProjectionY of the 2D input histo. If any bin content is below the given threshold => warning.\n"
;
110
message +=
"Optional Parameters: thresh = if any bin content in the ProjectionY is below this value => warning\n"
;
111
out << message;
112
}
113
114
}
// namespace dqm_algorithms
AlgorithmHelper.h
staticInstance
static dqm_algorithms::AveragePrint staticInstance
Definition
AveragePrint.cxx:19
uint
unsigned int uint
Definition
LArOFPhaseFill.cxx:19
MUCTPISLAnyHit.h
dqm_algorithms::MUCTPISLAnyHit
Definition
MUCTPISLAnyHit.h:15
dqm_algorithms::MUCTPISLAnyHit::execute
virtual dqm_core::Result * execute(const std::string &name, const TObject &data, const dqm_core::AlgorithmConfig &config)
Definition
MUCTPISLAnyHit.cxx:48
dqm_algorithms::MUCTPISLAnyHit::MUCTPISLAnyHit
MUCTPISLAnyHit()
Definition
MUCTPISLAnyHit.cxx:34
dqm_algorithms::MUCTPISLAnyHit::clone
virtual dqm_core::Algorithm * clone()
Definition
MUCTPISLAnyHit.cxx:41
dqm_algorithms::MUCTPISLAnyHit::m_name
std::string m_name
Definition
MUCTPISLAnyHit.h:27
dqm_algorithms::MUCTPISLAnyHit::printDescription
virtual void printDescription(std::ostream &out)
Definition
MUCTPISLAnyHit.cxx:105
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.
IsA
#define IsA
Declare the TObject style functions.
Definition
xAODTEventBranch.h:59
Generated on
for ATLAS Offline Software by
1.17.0