ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
dqm_algorithms::Chi2Test_Chi2 Struct Reference

#include <Chi2Test_Chi2.h>

Inheritance diagram for dqm_algorithms::Chi2Test_Chi2:
Collaboration diagram for dqm_algorithms::Chi2Test_Chi2:

Public Member Functions

 Chi2Test_Chi2 ()
 
Chi2Testclone ()
 
dqm_core::Resultexecute (const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
 
void printDescription (std::ostream &out)
 

Private Attributes

std::string m_name
 
std::string m_option
 

Detailed Description

Definition at line 16 of file Chi2Test_Chi2.h.

Constructor & Destructor Documentation

◆ Chi2Test_Chi2()

dqm_algorithms::Chi2Test_Chi2::Chi2Test_Chi2 ( )
inline

Definition at line 18 of file Chi2Test_Chi2.h.

18 : Chi2Test("Chi2") {};

Member Function Documentation

◆ clone()

dqm_algorithms::Chi2Test * dqm_algorithms::Chi2Test::clone ( )
inherited

Definition at line 34 of file Chi2Test.cxx.

35 {
36  return new Chi2Test( m_name );
37 }

◆ execute()

dqm_core::Result * dqm_algorithms::Chi2Test::execute ( const std::string &  name,
const TObject &  object,
const dqm_core::AlgorithmConfig &  config 
)
inherited

Definition at line 41 of file Chi2Test.cxx.

44 {
45  const TH1* histogram = 0;
46  const TEfficiency* efficiency = 0;
47  TH1* passed_histogram = 0;
48  TH1* total_histogram = 0;
49 
50  if(object.IsA()->InheritsFrom( "TH1" )) {
51  histogram = static_cast<const TH1*>( &object );
52  if (histogram->GetDimension() > 2 ){
53  throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
54  }
55  } else if(object.IsA()->InheritsFrom( "TEfficiency" )) {
56  // get the histograms from TEfficiency object to perform Chi2Test
57  efficiency = static_cast<const TEfficiency*>( &object);
58  if (efficiency->GetDimension() > 2 ){
59  throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
60  }
61 
62  passed_histogram = efficiency->GetCopyPassedHisto();
63  total_histogram = efficiency->GetCopyTotalHisto();
64  passed_histogram->Divide(total_histogram);
65 
66  } else {
67  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1 or TEfficiency");
68  }
69 
70  const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
71  double current_stat = 0;
72 
73  if(object.IsA()->InheritsFrom( "TH1" )) {
74  current_stat = histogram->GetEntries();
75  } else if(object.IsA()->InheritsFrom( "TEfficiency" )){
76  current_stat = total_histogram->GetEntries();
77  }
78 
79  if(current_stat < minstat ) {
81  result->tags_["InsufficientEntries"] = current_stat;
82  return result;
83  }
84 
85  TH1 * refhist = 0;
86  TH1 * ref_total_hist;
87  TEfficiency * refeff;
88  double gthresho;
89  double rthresho;
90  std::string option;
91  std::string thresholdname="P";
92  if (m_name == "Chi2_per_NDF") {
93  option="Chi2/ndfUU";
94  thresholdname="Chi2_per_NDF";
95  }else if (m_name == "Prob" ) {
96  option="UU";
97  }else if (m_name == "ProbUW") {
98  option="UW";
99  }else if (m_name == "ProbWW") {
100  option="WW";
101  } else if (m_name == "Chi2") {
102  option="CHI2UU";
103  thresholdname="Chi2";
104  } else {
105  throw dqm_core::BadConfig( ERS_HERE, "None", m_name );
106  }
107  try {
108  gthresho = dqm_algorithms::tools::GetFromMap( thresholdname, config.getGreenThresholds() );
109  rthresho = dqm_algorithms::tools::GetFromMap( thresholdname, config.getRedThresholds() );
110  }
111  catch ( dqm_core::Exception & ex ) {
112  throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
113 
114  }
115 
116  if(object.IsA()->InheritsFrom( "TH1" )) {
117  try {
118  refhist = dynamic_cast<TH1 *>( config.getReference() );
119  }
120  catch ( dqm_core::Exception & ex ) {
121  throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
122  }
123  } else if(object.IsA()->InheritsFrom( "TEfficiency" )){
124  try {
125  refeff = dynamic_cast<TEfficiency *>( config.getReference() );
126  }
127  catch ( dqm_core::Exception & ex ) {
128  throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
129  }
130 
131  refhist = refeff->GetCopyPassedHisto();
132  ref_total_hist = refeff->GetCopyTotalHisto();
133  refhist->Divide(ref_total_hist);
134  }
135 
136  if (!refhist) { throw dqm_core::BadRefHist(ERS_HERE,name,"Bad reference type"); }
137 
138  double value = 0;
139  if(object.IsA()->InheritsFrom( "TH1" )) {
140 
141  if (histogram->GetDimension() != refhist->GetDimension() ) {
142  throw dqm_core::BadRefHist( ERS_HERE, "Dimension", name );
143  }
144 
145  if ((histogram->GetNbinsX() != refhist->GetNbinsX()) || (histogram->GetNbinsY() != refhist->GetNbinsY())) {
146  throw dqm_core::BadRefHist( ERS_HERE, "number of bins", name );
147  }
148 
149  value = histogram->Chi2Test( refhist, option.c_str() );
150 
151  } else if(object.IsA()->InheritsFrom( "TEfficiency" )){
152 
153  if (passed_histogram->GetDimension() != refhist->GetDimension() ) {
154  throw dqm_core::BadRefHist( ERS_HERE, "Dimension", name );
155  }
156 
157  if ((passed_histogram->GetNbinsX() != refhist->GetNbinsX()) || (passed_histogram->GetNbinsY() != refhist->GetNbinsY())) {
158  throw dqm_core::BadRefHist( ERS_HERE, "number of bins", name );
159  }
160 
161  value = passed_histogram->Chi2Test( refhist, option.c_str() );
162  }
163 
164  ERS_DEBUG(1,"Green threshold: "<< gthresho << "; Red threshold: " << rthresho );
165  ERS_DEBUG(1,"Chi2 Test with Option " << option << " is " << value );
166 
168  result->tags_[thresholdname] = value;
169 
170  if (thresholdname == "P") {//Checking against a probability
171  if ( value >= gthresho ) {
172  result->status_ = dqm_core::Result::Green;
173  } else if ( value > rthresho ) {
174  result->status_ = dqm_core::Result::Yellow;
175  } else {
176  result->status_ = dqm_core::Result::Red;
177  }
178  } else {//checking against Chi2 value
179  if ( value <= gthresho ) {
180  result->status_ = dqm_core::Result::Green;
181  } else if ( value < rthresho ) {
182  result->status_ = dqm_core::Result::Yellow;
183  } else {
184  result->status_ = dqm_core::Result::Red;
185  }
186 
187  }
188 
189  ERS_DEBUG(2,"Result: "<<*result);
190  return result;
191 
192 }

◆ printDescription()

void dqm_algorithms::Chi2Test::printDescription ( std::ostream &  out)
inherited

Definition at line 194 of file Chi2Test.cxx.

195 {
196  m_option="UU";
197  std::string thresholdname = "P";
198  if (m_name == "Chi2_per_NDF") {
199  m_option="Chi2/ndf";
200  thresholdname="Chi2_per_NDF";
201  }else if (m_name == "Prob") {
202  m_option="UU";
203  }else if (m_name == "ProbUW") {
204  m_option="UW";
205  }else if (m_name == "ProbWW") {
206  m_option="WW";
207  }else if (m_name == "Chi2") {
208  m_option="CHI2";
209  thresholdname="Chi2";
210  }
211 
212  out<<"Chi2Test_"+ m_name+": Gives back "+thresholdname+" after performing Chi2 test on histogram against referece histogram with option: "<<m_option<<" (see TH1::GetChi2Test)"<<std::endl;
213 
214 
215  out<<"Mandatory Green/Red Threshold: "+ thresholdname+" : "+thresholdname+" to give Green/Red result\n"<<std::endl;
216 
217  out<<"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm\n"<<std::endl;
218 
219 }

Member Data Documentation

◆ m_name

std::string dqm_algorithms::Chi2Test::m_name
privateinherited

Definition at line 27 of file Chi2Test.h.

◆ m_option

std::string dqm_algorithms::Chi2Test::m_option
privateinherited

Definition at line 28 of file Chi2Test.h.


The documentation for this struct was generated from the following file:
dqm_algorithms::Chi2Test::Chi2Test
Chi2Test(const std::string &name)
Definition: Chi2Test.cxx:27
dqm_algorithms::Chi2Test::m_option
std::string m_option
Definition: Chi2Test.h:28
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
athena.value
value
Definition: athena.py:124
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
efficiency
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:128
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
python.handimod.Green
int Green
Definition: handimod.py:524
dqm_algorithms::Chi2Test::m_name
std::string m_name
Definition: Chi2Test.h:27
python.handimod.Red
Red
Definition: handimod.py:551
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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
histogram
std::string histogram
Definition: chains.cxx:52