ATLAS Offline Software
KurtosisTest.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 #include <dqm_core/AlgorithmManager.h>
19 
20 namespace
21 {
22  dqm_algorithms::KurtosisTest kurtosis_GreaterThan( "GreaterThan" );
23  dqm_algorithms::KurtosisTest kurtosis_LessThan( "LessThan" );
24  dqm_algorithms::KurtosisTest kurtosis_GreaterThanAbs( "GreaterThanAbs" );// Ok, for Kurtosis this is not so much sense (K<0 and K>0 indicate really different things), but just for completeness
25  dqm_algorithms::KurtosisTest kurtosis_LessThanAbs( "LessThanAbs" ); // Kurtosis( normal(0,1) ) =0
26 }
27 
28 //NB. Following ROOT definition This is the excess kurtosis, i.e. fourth standarized momentum -3. K(N(0,1))=0
30  : m_name( name )
31 {
32  dqm_core::AlgorithmManager::instance().registerAlgorithm("KurtosisTest_"+name,this);
33 }
34 
37 {
38  return new KurtosisTest( m_name );
39 }
40 
41 
44  const TObject & object,
45  const dqm_core::AlgorithmConfig & config )
46 {
47  const TH1 * histogram;
48 
49  if( object.IsA()->InheritsFrom( "TH1" ) ) {
50  histogram = static_cast<const TH1*>(&object);
51  } else {
52  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
53  }
54 
55  const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
56 
57  if (histogram->GetEffectiveEntries() < minstat ) {
59  result->tags_["InsufficientEffectiveEntries"] = histogram->GetEffectiveEntries();
60  return result;
61  }
62 
63  double gthreshold;
64  double rthreshold;
65 
66  int axis = (int) dqm_algorithms::tools::GetFirstFromMap( "Axis", config.getParameters(), 1);
67 
68  try {
69  rthreshold = dqm_algorithms::tools::GetFromMap( "K", config.getRedThresholds() );
70  gthreshold = dqm_algorithms::tools::GetFromMap( "K", config.getGreenThresholds() );
71  }
72  catch ( dqm_core::Exception & ex ) {
73  throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
74  }
75  ERS_DEBUG(1,"Axis for kurtosis calculation:"<<axis);
76 
77  Double_t kurtosis = histogram->GetKurtosis( axis );
78  Double_t kurtosis_e = histogram->GetKurtosis( axis + 10 );
79 
81  ERS_DEBUG(1,"Kurtosis = "<<kurtosis<<" +- "<<kurtosis_e);
82  result->tags_["Kurtosis"] = kurtosis;
83  result->tags_["ApproxStandardError"]=kurtosis_e;
84 
85  if ( CompareKurtosisTest( m_name , kurtosis ,gthreshold) ) {
87  } else if ( CompareKurtosisTest( m_name, kurtosis, rthreshold) ) {
88  result->status_ = dqm_core::Result::Yellow;
89  } else {
90  result->status_ = dqm_core::Result::Red;
91  }
92 
93  return result;
94 
95 }
96 
97 bool
99 
100  if (type == "GreaterThan") return (value > threshold);
101  if (type == "LessThan") return (value < threshold);
102  if (type == "GreaterThanAbs") return ( std::abs(value) > threshold );
103  if (type == "LessThanAbs") return ( std::abs(value) < threshold);
104  return 0;
105 }
106 
107 
108 void
110 {
111  out<<"KurtosisTest_"+m_name+" : Checks if the Excess Kurtosis of the distribution is "+m_name+" threshold value\n"<<std::endl;
112 
113  out<<"Mandatory Green/Red Threshold: K: Value of Kurtosis"<<std::endl;
114 
115  out<<"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
116  out<<"Optional Parameter: Axis: Axis along which compute Kurtosis: 1=X, 2=Y, 3=Z"<<std::endl;
117 
118 }
119 
KurtosisTest.h
dqm_algorithms::KurtosisTest
Definition: KurtosisTest.h:19
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
dqm_algorithms::KurtosisTest::CompareKurtosisTest
bool CompareKurtosisTest(const std::string &type, double value, double threshold)
Definition: KurtosisTest.cxx:98
yodamerge_tmp.axis
list axis
Definition: yodamerge_tmp.py:241
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
athena.value
value
Definition: athena.py:122
dqm_algorithms::KurtosisTest::printDescription
void printDescription(std::ostream &out)
Definition: KurtosisTest.cxx:109
dqm_algorithms::KurtosisTest::KurtosisTest
KurtosisTest(const std::string &name)
Definition: KurtosisTest.cxx:29
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
dqm_algorithms::KurtosisTest::execute
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
Definition: KurtosisTest.cxx:43
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:195
threshold
Definition: chainparser.cxx:74
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TH1
Definition: rootspy.cxx:268
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::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
dqm_algorithms::KurtosisTest::clone
KurtosisTest * clone()
Definition: KurtosisTest.cxx:36
histogram
std::string histogram
Definition: chains.cxx:52