ATLAS Offline Software
SkewnessTest.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 <TH1.h>
13 #include <TF1.h>
14 #include <TClass.h>
15 #include <ers/ers.h>
16 #include <cmath>
17 
18 
19 #include <dqm_core/AlgorithmManager.h>
20 
21 namespace
22 {
23  dqm_algorithms::SkewnessTest skweness_GreaterThan( "GreaterThan" );
24  dqm_algorithms::SkewnessTest skewness_LessThan( "LessThan" );
25  dqm_algorithms::SkewnessTest skewness_GreaterThanAbs( "GreaterThanAbs" );
26  dqm_algorithms::SkewnessTest skewness_LessThanAbs( "LessThanAbs" );
27 }
28 
29 
31  : m_name( name )
32 {
33  dqm_core::AlgorithmManager::instance().registerAlgorithm("SkewnessTest_"+name,this);
34 }
35 
38 {
39  return new SkewnessTest( m_name );
40 }
41 
42 
45  const TObject & object,
46  const dqm_core::AlgorithmConfig & config )
47 {
48  const TH1 * histogram;
49 
50  if( object.IsA()->InheritsFrom( "TH1" ) ) {
51  histogram = static_cast<const TH1*>(&object);
52  } else {
53  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
54  }
55 
56  const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
57 
58  if (histogram->GetEffectiveEntries() < minstat ) {
60  result->tags_["InsufficientEffectiveEntries"] = histogram->GetEffectiveEntries();
61  return result;
62  }
63 
64  double gthreshold;
65  double rthreshold;
66 
67  const int axis = (int) dqm_algorithms::tools::GetFirstFromMap( "Axis", config.getParameters(), 1);
68 
69  try {
70  rthreshold = dqm_algorithms::tools::GetFromMap( "S", config.getRedThresholds() );
71  gthreshold = dqm_algorithms::tools::GetFromMap( "S", config.getGreenThresholds() );
72  }
73  catch ( dqm_core::Exception & ex ) {
74  throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
75  }
76  ERS_DEBUG(1,"Axis for skewness calculation:"<<axis);
77 
78  Double_t skewness = histogram->GetSkewness( axis );
79  Double_t skewness_e = histogram->GetSkewness( axis + 10 );
80 
82  ERS_DEBUG(1,"Skewness = "<<skewness<<" +- "<<skewness_e);
83  result->tags_["Skewness"] = skewness;
84  result->tags_["ApproxStandardError"]=skewness_e;
85 
86  if ( CompareSkewnessTest( m_name , skewness ,gthreshold) ) {
88  } else if ( CompareSkewnessTest( m_name, skewness, rthreshold) ) {
89  result->status_ = dqm_core::Result::Yellow;
90  } else {
91  result->status_ = dqm_core::Result::Red;
92  }
93 
94  return result;
95 
96 }
97 
98 bool
100 
101  if (type == "GreaterThan") return (value > threshold);
102  if (type == "LessThan") return (value < threshold);
103  if (type == "GreaterThanAbs") return ( std::abs(value) > threshold );
104  if (type == "LessThanAbs") return ( std::abs(value) < threshold);
105  return 0;
106 }
107 
108 
109 void
111 {
112  out<<"SkewnessTest_"+m_name+" : Checks if the Skewness of the distribution is "+m_name+" threshold value\n"<<std::endl;
113 
114  out<<"Mandatory Green/Red Threshold: S: Value of Skewness"<<std::endl;
115 
116  out<<"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
117  out<<"Optional Parameter: Axis: Axis along which compute Skewness: 1=X, 2=Y, 3=Z"<<std::endl;
118 
119 }
120 
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
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
yodamerge_tmp.axis
list axis
Definition: yodamerge_tmp.py:241
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
athena.value
value
Definition: athena.py:124
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
SkewnessTest.h
dqm_algorithms::SkewnessTest::execute
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
Definition: SkewnessTest.cxx:44
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
python.handimod.Green
int Green
Definition: handimod.py:524
python.handimod.Red
Red
Definition: handimod.py:551
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
threshold
Definition: chainparser.cxx:74
dqm_algorithms::SkewnessTest::printDescription
void printDescription(std::ostream &out)
Definition: SkewnessTest.cxx:110
dqm_algorithms::SkewnessTest::SkewnessTest
SkewnessTest(const std::string &name)
Definition: SkewnessTest.cxx:30
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
dqm_algorithms::SkewnessTest::clone
SkewnessTest * clone()
Definition: SkewnessTest.cxx:37
AlgorithmHelper.h
dqm_algorithms::tools::GetFromMap
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
Definition: AlgorithmHelper.h:114
pickleTool.object
object
Definition: pickleTool.py:30
dqm_algorithms::SkewnessTest::CompareSkewnessTest
bool CompareSkewnessTest(const std::string &type, double value, double threshold)
Definition: SkewnessTest.cxx:99
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
dqm_algorithms::SkewnessTest
Definition: SkewnessTest.h:19
histogram
std::string histogram
Definition: chains.cxx:52