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

#include <MDTChi2.h>

Inheritance diagram for dqm_algorithms::MDTChi2:
Collaboration diagram for dqm_algorithms::MDTChi2:

Public Member Functions

 MDTChi2 ()
 
virtual ~MDTChi2 ()
 
virtual dqm_core::Algorithm * clone ()
 
virtual dqm_core::Resultexecute (const std::string &name, const TObject &object, const dqm_core::AlgorithmConfig &config)
 
virtual void printDescription (std::ostream &out)
 

Private Attributes

std::string m_name
 

Detailed Description

Definition at line 17 of file MDTChi2.h.

Constructor & Destructor Documentation

◆ MDTChi2()

dqm_algorithms::MDTChi2::MDTChi2 ( )

Definition at line 38 of file MDTChi2.cxx.

39  : m_name("MDTchi2")
40 {
41  dqm_core::AlgorithmManager::instance().registerAlgorithm( m_name, this );
42 }

◆ ~MDTChi2()

dqm_algorithms::MDTChi2::~MDTChi2 ( )
virtual

Definition at line 45 of file MDTChi2.cxx.

46 {
47 }

Member Function Documentation

◆ clone()

dqm_core::Algorithm * dqm_algorithms::MDTChi2::clone ( )
virtual

Definition at line 51 of file MDTChi2.cxx.

52 {
53  return new MDTChi2(*this);
54 }

◆ execute()

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

Definition at line 58 of file MDTChi2.cxx.

59 {
60  const TH1 * hist;
61  const TH1 * ref;
62 
63  if( object.IsA()->InheritsFrom( "TH1" ) ) {
64  hist = static_cast<const TH1*>(&object);
65  if (hist->GetDimension() >= 2 ){
66  throw dqm_core::BadConfig( ERS_HERE, name, "dimension >= 2 " );
67  }
68  } else {
69  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
70  }
71 
72  //Get Parameters and Thresholds
73  double minstat;
74  double greenTh;
75  double redTh;
76  try {
77  minstat = dqm_algorithms::tools::GetFirstFromMap("MinStat", config.getParameters(), 50);
78  redTh = dqm_algorithms::tools::GetFromMap( "Limits", config.getRedThresholds());
79  greenTh = dqm_algorithms::tools::GetFromMap( "Limits", config.getGreenThresholds() );
80  }
81  catch ( dqm_core::Exception & ex ) {
82  throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
83  }
84 
85  //Get Reference Histo
86 
87  try {
88  ref = static_cast<const TH1*>( config.getReference() );
89  }
90  catch ( dqm_core::Exception & ex ) {
91  throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
92  }
93  if (hist->GetDimension() != ref->GetDimension() ) {
94  throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different dimension!" );
95  }
96  if (hist->GetNbinsX() != ref->GetNbinsX() ) {
97  throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different bin numbre in X axis!" );
98  }
99 
100  //Check of statistics
101  if (hist->GetEntries() < minstat ) {
102  ERS_INFO("Histogram does not satisfy MinStat requirement " <<hist->GetName());
104  result->tags_["InsufficientEntries"] = hist->GetEntries();
105  return result;
106  }
107  ERS_DEBUG(1,"Statistics: "<< hist->GetEntries()<< " entries ");
108 
109 
110  //Algo
111 
112  int i = 0;
113  int count = 1;
114  Double_t n = 0;
115  Double_t n_ref = 0;
116  Double_t chi2 = 0;
117  int max_bin = hist -> GetNbinsX();
118  Double_t N = hist -> GetEntries();
119  Double_t N_ref = ref -> GetEntries();
120 
121  if(N == 0){
122  ERS_INFO("Histogram has no entries" <<hist->GetName());
124  result->tags_["InsufficientEntries"] = hist->GetEntries();
125  return result;
126  };
127 
128  if(N_ref == 0){
129  ERS_INFO("Reference histogram has no entries" <<hist->GetName());
131  result->tags_["InsufficientRefEntries"] = ref->GetEntries();
132  return result;
133  };
134 
135  double norm=1;
136  double norm_ref=1;
137 
138  if(N != 0) norm=1/N;
139  if(N_ref != 0) norm_ref=1/N_ref;
140 
141  for(i=1;i<=max_bin;i++){
142  n = hist->GetBinContent(i);
143  n_ref = ref->GetBinContent(i);
144  if( n != 0 || n_ref != 0) chi2+=(n*norm-n_ref*norm_ref)*(n*norm-n_ref*norm_ref)/(n*norm*norm+n_ref*norm_ref*norm_ref);
145  if( n == 0 && n_ref == 0) count++;
146  };
147 
148  Double_t prob=0;
149  prob=TMath::Prob(chi2,(max_bin-count));
150 
151 
152  //Result
153 
155  result->tags_["chi2_prob"] = prob;
156 
157  if (prob>greenTh) {
158  result->status_ = dqm_core::Result::Green;
159  ERS_DEBUG(1,"Green");
160  } else if ( prob<=greenTh && prob>redTh ) {
161  result->status_ = dqm_core::Result::Yellow;
162  ERS_DEBUG(1,"Yellow");
163  } else if (prob<=redTh) {
164  result->status_ = dqm_core::Result::Red;
165  ERS_DEBUG(1,"Red");
166  }
167  return result;
168 }

◆ printDescription()

void dqm_algorithms::MDTChi2::printDescription ( std::ostream &  out)
virtual

Definition at line 172 of file MDTChi2.cxx.

173 {
174  std::string message;
175  message += "\n";
176  message += "Algorithm: \"" + m_name + "\"\n";
177  message += "Description: Perform a chi square check between input istogram and reference\n";
178  message += "Mandatory Green/Red Threshold: Limits: chi square probability limits\n";
179  message += "Optional Parameters: MinStat = Minimum histogram statistics needed to perform Algorithm\n";
180  message += "\n";
181 
182  out << message;
183 }

Member Data Documentation

◆ m_name

std::string dqm_algorithms::MDTChi2::m_name
private

Definition at line 30 of file MDTChi2.h.


The documentation for this class was generated from the following files:
PlotCalibFromCool.norm
norm
Definition: PlotCalibFromCool.py:100
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
plotmaker.hist
hist
Definition: plotmaker.py:148
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
covarianceTool.prob
prob
Definition: covarianceTool.py:678
ReweightUtils.message
message
Definition: ReweightUtils.py:15
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:523
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
ref
const boost::regex ref(r_ef)
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::MDTChi2::MDTChi2
MDTChi2()
Definition: MDTChi2.cxx:38
dqm_algorithms::MDTChi2::m_name
std::string m_name
Definition: MDTChi2.h:30