ATLAS Offline Software
BasicStatCheck.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include <dqm_core/AlgorithmConfig.h>
12 #include <ers/ers.h>
13 #include <TH1.h>
14 #include <TF1.h>
15 #include <TClass.h>
16 
17 
18 #include <dqm_core/AlgorithmManager.h>
19 
20 namespace
21 {
24 }
25 
26 
28  : m_name( name )
29 {
30  dqm_core::AlgorithmManager::instance().registerAlgorithm("CheckHisto_"+name, this);
31 }
32 
35 {
36 
37  return new BasicStatCheck( m_name );
38 }
39 
40 
43  const TObject & object,
44  const dqm_core::AlgorithmConfig & config )
45 {
46  const TH1 * histogram;
47 
48  if( object.IsA()->InheritsFrom( "TH1" ) ) {
49  histogram = static_cast<const TH1*>(&object);
50  if (histogram->GetDimension() > 2 ){
51  throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
52  }
53  } else {
54  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
55  }
56 
57  const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
58  const double subtractfromxmean = dqm_algorithms::tools::GetFirstFromMap( "SubtractFromXMean", config.getParameters(), 0);
59  const double subtractfromymean = dqm_algorithms::tools::GetFirstFromMap( "SubtractFromYMean", config.getParameters(), 0);
60  const unsigned int publishType = static_cast<unsigned int>(dqm_algorithms::tools::GetFirstFromMap( "PublishType", config.getParameters(), 3));
61 
62  if (histogram->GetEntries() < minstat ) {
64  result->tags_["InsufficientEntries"] = histogram->GetEntries();
65  return result;
66  }
67 
68 
69  std::vector<int> range=dqm_algorithms::tools::GetBinRange(histogram, config.getParameters());
70  const_cast<TAxis*>(histogram->GetXaxis())->SetRange(range[0], range[1]);
71  const_cast<TAxis*>(histogram->GetYaxis())->SetRange(range[2], range[3]);
72 
73  std::map<std::string, double> params;
74  if (m_name == "Mean") {
75  params["XMean"]=histogram->GetMean(1) - subtractfromxmean;
76  params["YMean"]=histogram->GetMean(2) - subtractfromymean;
77  ERS_DEBUG(1,"XMean Value " <<histogram->GetMean(1)<<" YMean Value " <<histogram->GetMean(2));
78  } else if (m_name == "RMS" ) {
79  params["XRMS"]=histogram->GetRMS(1);
80  params["YRMS"]=histogram->GetRMS(2);
81  ERS_DEBUG(1,"XRMS Value " <<histogram->GetRMS(1)<<" YRMS Value "<<histogram->GetRMS(2));
82  }else {
83  return new dqm_core::Result();
84  }
85 
87 
88  try {
89  result = dqm_algorithms::tools::MakeComparisons(params, config.getGreenThresholds(), config.getRedThresholds() );
90  }
91  catch ( dqm_core::Exception & ex ) {
92  throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
93  }
94 
95  if (m_name == "Mean") {
96  if (publishType & 0x01) result->tags_["XMean"] = params["XMean"];
97  if (publishType & 0x02) result->tags_["YMean"] = params["YMean"];
98  } else if (m_name == "RMS") {
99  if (publishType & 0x01) result->tags_["XRMS"] = params["XRMS"];
100  if (publishType & 0x02) result->tags_["YRMS"] = params["YRMS"];
101  }
102 
103  return result;
104 }
105 
106 void
108 {
109  if (m_name == "Mean") {
110  out<<"CheckHisto_Mean: Checks that X and Y Mean of histo are within specified thresholds\n"<<std::endl;
111  out<<"Green/Red Threshold: XMean or AbsXMean: X Mean value to give Green/Red result; AbsXMean checks the absolute value"<<std::endl;
112  out<<"Green/Red Threshold: YMean or AbsYMean: Y Mean value to give Green/Red result; AbsYMean checks the absolute value\n"<<std::endl;
113  }else if (m_name == "RMS"){
114  out<<"CheckHisto_RMS: Checks that X and Y RMS of histo are within specified thresholds\n"<<std::endl;
115  out<<"Green/Red Threshold: XRMS: X RMS value to give Green/Red result"<<std::endl;
116  out<<"Green/Red Threshold: YRMS: Y RMS value to give Green/Red result\n"<<std::endl;
117  }
118  out<<"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
119  out<<"Optional Parameter: xmin: minimum x range"<<std::endl;
120  out<<"Optional Parameter: xmax: maximum x range"<<std::endl;
121  out<<"Optional Parameter: ymin: minimum y range"<<std::endl;
122  out<<"Optional Parameter: ymax: maximum y range"<<std::endl;
123  out<<"Optional Parameter: SubtractFromXMean: value subtracted from XMean before test is applied: allows using AbsXMean for non-zero expected mean"<<std::endl;
124  out<<"Optional Parameter: SubtractFromYMean: value subtracted from YMean before test is applied: allows using AbsYMean for non-zero expected mean"<<std::endl;
125  out<<"Optional Parameter: PublishType: 0 = publish no results, 1 = publish X result, 2 = publish Y result, 3 = publish both results (default)."<<std::endl;
126 }
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
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
dqm_algorithms::BasicStatCheck
Definition: BasicStatCheck.h:22
dqm_algorithms::BasicStatCheck::clone
BasicStatCheck * clone()
Definition: BasicStatCheck.cxx:34
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
dqm_algorithms::BasicStatCheck::printDescription
void printDescription(std::ostream &out)
Definition: BasicStatCheck.cxx:107
BasicStatCheck.h
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
dqm_algorithms::tools::MakeComparisons
dqm_core::Result * MakeComparisons(const std::map< std::string, double > &algparams, const std::map< std::string, double > &gthreshold, const std::map< std::string, double > &rthreshold)
Definition: AlgorithmHelper.cxx:60
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
DiTauMassTools::HistInfo::RMS
@ RMS
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
dqm_algorithms::BasicStatCheck::execute
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
Definition: BasicStatCheck.cxx:42
AlgorithmHelper.h
pickleTool.object
object
Definition: pickleTool.py:30
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
LArMonTransforms.Mean
def Mean(inputs)
Definition: LArMonTransforms.py:438
histogram
std::string histogram
Definition: chains.cxx:52
dqm_algorithms::BasicStatCheck::BasicStatCheck
BasicStatCheck(const std::string &name)
Definition: BasicStatCheck.cxx:27