ATLAS Offline Software
Loading...
Searching...
No Matches
BasicGraphCheck.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9#include <dqm_core/AlgorithmConfig.h>
12#include <TGraph.h>
13#include <TClass.h>
14#include <ers/ers.h>
15
16#include <dqm_core/AlgorithmManager.h>
17
18namespace
19{
20 dqm_algorithms::BasicGraphCheck GraphFilling( "Graph_Not_Empty" );
21 dqm_algorithms::BasicGraphCheck GraphEmpty( "Graph_Empty" );
22
23}
24
25
27 : m_name( name )
28{
29 dqm_core::AlgorithmManager::instance().registerAlgorithm(name, this);
30}
31
38
39
40dqm_core::Result *
41dqm_algorithms::BasicGraphCheck::execute( const std::string & name ,
42 const TObject & object,
43 const dqm_core::AlgorithmConfig & config)
44{
45 const TGraph * graph;
46
47 if( object.IsA()->InheritsFrom( "TGraph" ) ) {
48 graph = static_cast<const TGraph*>(&object);
49 } else {
50 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TGraph" );
51 }
52
53 double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1 );
54
55 if (graph->GetN() < minstat ) {
56 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
57 result->tags_["InsufficientN"] = graph->GetN();
58 return result;
59 }
60
61 if (m_name == "Graph_Not_Empty") {
62 if (graph->GetN() != 0) {
63 ERS_DEBUG(1, "Graph " <<graph->GetName()<<" is Not Empty");
64 return new dqm_core::Result(dqm_core::Result::Green);
65 }else {
66 ERS_DEBUG(1, "Graph " <<graph->GetName()<<" is Empty");
67 return new dqm_core::Result(dqm_core::Result::Red);
68 }
69 } else if (m_name == "Graph_Empty") {
70 if (graph->GetN() == 0) {
71 ERS_DEBUG(1, "Graph " <<graph->GetName()<<" is Empty");
72 return new dqm_core::Result(dqm_core::Result::Green);
73 }else {
74 ERS_DEBUG(1, "Graph " <<graph->GetName()<<" is Not Empty");
75 return new dqm_core::Result(dqm_core::Result::Red);
76 }
77 } else {
78 return new dqm_core::Result();
79 }
80
81
82}
83
84void
86{
87 if ( m_name == "Graph_Not_Empty"){
88 out<<"Graph_Not_Empty: Checks that graph is not empty\n"<<std::endl;
89 } else if ( m_name == "Graph_Empty"){
90 out<<"Graph_Empty: Checks that graph is empty\n"<<std::endl;
91 }
92
93 out<<"Optional Parameter: MinStat: Minimum graph statistics needed to perform Algorithm\n"<<std::endl;
94}
95
file declares the dqm_core::BasicGraphCheck class.
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
BasicGraphCheck(const std::string &name)
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
void printDescription(std::ostream &out)
#define IsA
Declare the TObject style functions.