CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Comp2RefChi2 Class Reference

#include <QTest.h>

Inheritance diagram for Comp2RefChi2:
SimpleTest QCriterion

Public Member Functions

 Comp2RefChi2 (const std::string &name)
 
float runTest (const MonitorElement *me)
 
- Public Member Functions inherited from SimpleTest
virtual std::vector< DQMChannelgetBadChannels (void) const
 get vector of channels that failed test (not always relevant!) More...
 
void setMinimumEntries (unsigned n)
 set minimum # of entries needed More...
 
 SimpleTest (const std::string &name, bool keepBadChannels=false)
 
- Public Member Functions inherited from QCriterion
std::string algoName (void) const
 get algorithm name More...
 
std::string getMessage (void) const
 get message attached to test More...
 
std::string getName (void) const
 get name of quality test More...
 
int getStatus (void) const
 (class should be created by DQMStore class) More...
 
void setErrorProb (float prob)
 
void setWarningProb (float prob)
 set probability limit for warning and error (default: 90% and 50%) More...
 

Static Public Member Functions

static std::string getAlgoName (void)
 

Protected Member Functions

void setMessage (void)
 set status & message after test has run More...
 
- Protected Member Functions inherited from QCriterion
void init (void)
 initialize values More...
 
 QCriterion (std::string qtname)
 
float runTest (const MonitorElement *me, QReport &qr, DQMNet::QValue &qv)
 
void setAlgoName (std::string name)
 set algorithm name More...
 
void setVerbose (int verbose)
 probability limits for warnings, errors More...
 
virtual ~QCriterion (void)
 

Protected Attributes

double chi2_
 
int Ndof_
 
- Protected Attributes inherited from SimpleTest
std::vector< DQMChannelbadChannels_
 
bool keepBadChannels_
 
unsigned minEntries_
 
- Protected Attributes inherited from QCriterion
std::string algoName_
 name of quality test More...
 
float errorProb_
 
std::string message_
 quality test status More...
 
float prob_
 name of algorithm More...
 
std::string qtname_
 
int status_
 
int verbose_
 
float warningProb_
 message attached to test More...
 

Detailed Description

Definition at line 184 of file QTest.h.

Constructor & Destructor Documentation

Comp2RefChi2::Comp2RefChi2 ( const std::string &  name)
inline

Definition at line 187 of file QTest.h.

References QCriterion::setAlgoName().

187  :SimpleTest(name)
188  {
190  }
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:78
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:138
static std::string getAlgoName(void)
Definition: QTest.h:191

Member Function Documentation

static std::string Comp2RefChi2::getAlgoName ( void  )
inlinestatic

Definition at line 191 of file QTest.h.

References QCriterion::runTest().

Referenced by QTestConfigure::EnableComp2RefChi2Test(), QTestConfigure::enableTests(), and QTestParameterNames::QTestParameterNames().

191 { return "Comp2RefChi2"; }
float Comp2RefChi2::runTest ( const MonitorElement me)
virtual

Reimplemented from QCriterion.

Definition at line 173 of file QTest.cc.

References vertices_cff::chi2, pfSecondaryVertexTagInfos_cfi::constraint, gather_cfg::cout, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::getRefRootObject(), MonitorElement::getRefTH1D(), MonitorElement::getRefTH1F(), MonitorElement::getRefTH1S(), MonitorElement::getRefTProfile(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), MonitorElement::getTProfile(), mps_fire::i, MonitorElement::kind(), ndof, combinedConstraintHelpers::sum2(), and groupFilesInBlocks::temp.

174 {
175  if (!me)
176  return -1;
177  if (!me->getRootObject() || !me->getRefRootObject())
178  return -1;
179  TH1* h=nullptr;
180  TH1* ref_=nullptr;
181 
182  if (verbose_>1)
183  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
184  << me-> getFullname() << "\n";
185  //-- TH1F
187  {
188  h = me->getTH1F(); // access Test histo
189  ref_ = me->getRefTH1F(); //access Ref histo
190  }
191  //-- TH1S
192  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
193  {
194  h = me->getTH1S(); // access Test histo
195  ref_ = me->getRefTH1S(); //access Ref histo
196  }
197  //-- TH1D
198  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
199  {
200  h = me->getTH1D(); // access Test histo
201  ref_ = me->getRefTH1D(); //access Ref histo
202  }
203  //-- TProfile
204  else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE)
205  {
206  h = me->getTProfile(); // access Test histo
207  ref_ = me->getRefTProfile(); //access Ref histo
208  }
209  else
210  {
211  if (verbose_>0)
212  std::cout << "QTest::Comp2RefChi2"
213  << " ME does not contain TH1F/TH1S/TH1D/TProfile, exiting\n";
214  return -1;
215  }
216 
217  //-- isInvalid ? - Check consistency in number of channels
218  int ncx1 = h->GetXaxis()->GetNbins();
219  int ncx2 = ref_->GetXaxis()->GetNbins();
220  if ( ncx1 != ncx2)
221  {
222  if (verbose_>0)
223  std::cout << "QTest:Comp2RefChi2"
224  << " different number of channels! ("
225  << ncx1 << ", " << ncx2 << "), exiting\n";
226  return -1;
227  }
228 
229  //-- QUALITY TEST itself
230  //reset Results
231  Ndof_ = 0; chi2_ = -1.; ncx1 = ncx2 = -1;
232 
233  int i, i_start, i_end;
234  double chi2 = 0.; int ndof = 0; int constraint = 0;
235 
236  i_start = 1;
237  i_end = ncx1;
238  // if (fXaxis.TestBit(TAxis::kAxisRange)) {
239  i_start = h->GetXaxis()->GetFirst();
240  i_end = h->GetXaxis()->GetLast();
241  // }
242  ndof = i_end-i_start+1-constraint;
243 
244  //Compute the normalisation factor
245  double sum1=0, sum2=0;
246  for (i=i_start; i<=i_end; i++)
247  {
248  sum1 += h->GetBinContent(i);
249  sum2 += ref_->GetBinContent(i);
250  }
251 
252  //check that the histograms are not empty
253  if (sum1 == 0)
254  {
255  if (verbose_>0)
256  std::cout << "QTest:Comp2RefChi2"
257  << " Test Histogram " << h->GetName()
258  << " is empty, exiting\n";
259  return -1;
260  }
261  if (sum2 == 0)
262  {
263  if (verbose_>0)
264  std::cout << "QTest:Comp2RefChi2"
265  << " Ref Histogram " << ref_->GetName()
266  << " is empty, exiting\n";
267  return -1;
268  }
269 
270  double bin1, bin2, err1, err2, temp;
271  for (i=i_start; i<=i_end; i++)
272  {
273  bin1 = h->GetBinContent(i)/sum1;
274  bin2 = ref_->GetBinContent(i)/sum2;
275  if (bin1 ==0 && bin2==0)
276  {
277  --ndof; //no data means one less degree of freedom
278  }
279  else
280  {
281  temp = bin1-bin2;
282  err1=h->GetBinError(i); err2=ref_->GetBinError(i);
283  if (err1 == 0 && err2 == 0)
284  {
285  if (verbose_>0)
286  std::cout << "QTest:Comp2RefChi2"
287  << " bins with non-zero content and zero error, exiting\n";
288  return -1;
289  }
290  err1*=err1 ; err2*=err2;
291  err1/=sum1*sum1 ; err2/=sum2*sum2;
292  chi2 +=temp*temp/(err1+err2);
293  }
294  }
295  chi2_ = chi2; Ndof_ = ndof;
296  return TMath::Prob(0.5*chi2, int(0.5*ndof));
297 }
TH1F * getRefTH1F(void) const
TH1S * getTH1S(void) const
int verbose_
Definition: QTest.h:118
TH1D * getTH1D(void) const
int Ndof_
Definition: QTest.h:207
Kind kind(void) const
Get the type of the monitor element.
TObject * getRootObject(void) const
TH1F * getTH1F(void) const
TProfile * getRefTProfile(void) const
static std::string getAlgoName(void)
Definition: QTest.h:191
TProfile * getTProfile(void) const
double chi2_
Definition: QTest.h:207
TObject * getRefRootObject(void) const
TH1S * getRefTH1S(void) const
TH1D * getRefTH1D(void) const
void Comp2RefChi2::setMessage ( void  )
inlineprotectedvirtual

set status & message after test has run

Reimplemented from SimpleTest.

Definition at line 196 of file QTest.h.

References QCriterion::errorProb_, python.rootplot.argparse::message, QCriterion::message_, and QCriterion::warningProb_.

197  {
198  std::ostringstream message;
199  message << "chi2/Ndof = " << chi2_ << "/" << Ndof_
200  << ", minimum needed statistics = " << minEntries_
201  << " warning threshold = " << this->warningProb_
202  << " error threshold = " << this->errorProb_;
203  message_ = message.str();
204  }
int Ndof_
Definition: QTest.h:207
float errorProb_
Definition: QTest.h:116
std::string message_
quality test status
Definition: QTest.h:115
unsigned minEntries_
Definition: QTest.h:159
double chi2_
Definition: QTest.h:207
float warningProb_
message attached to test
Definition: QTest.h:116

Member Data Documentation

double Comp2RefChi2::chi2_
protected

Definition at line 207 of file QTest.h.

int Comp2RefChi2::Ndof_
protected

Definition at line 207 of file QTest.h.