CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Protected Attributes

MeanWithinExpected Class Reference

Algorithm for testing if histogram's mean value is near expected value. More...

#include <QTest.h>

Inheritance diagram for MeanWithinExpected:
SimpleTest QCriterion

List of all members.

Public Member Functions

 MeanWithinExpected (const std::string &name)
float runTest (const MonitorElement *me)
void setExpectedMean (double mean)
void useRange (double xmin, double xmax)
void useRMS (void)
void useSigma (double expectedSigma)

Static Public Member Functions

static std::string getAlgoName (void)

Protected Attributes

double expMean_
double sigma_
bool useRange_
bool useRMS_
bool useSigma_
double xmax_
double xmin_

Detailed Description

Algorithm for testing if histogram's mean value is near expected value.

Definition at line 391 of file QTest.h.


Constructor & Destructor Documentation

MeanWithinExpected::MeanWithinExpected ( const std::string &  name) [inline]

Definition at line 394 of file QTest.h.

References getAlgoName(), and QCriterion::setAlgoName().


Member Function Documentation

static std::string MeanWithinExpected::getAlgoName ( void  ) [inline, static]
float MeanWithinExpected::runTest ( const MonitorElement me) [virtual]

Reimplemented from QCriterion.

Definition at line 1147 of file QTest.cc.

References gather_cfg::cout, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, MonitorElement::getEntries(), MonitorElement::getFullname(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), h, MonitorElement::kind(), and plotscripts::mean().

{
  if (!me) 
    return -1;
  if (!me->getRootObject()) 
    return -1;
  TH1* h=0;
   
  if (verbose_>1) 
    std::cout << "QTest:" << getAlgoName() << "::runTest called on " 
              << me-> getFullname() << "\n";

  if (minEntries_ != 0 && me->getEntries() < minEntries_) return -1;

  if (me->kind()==MonitorElement::DQM_KIND_TH1F) 
  { 
    h = me->getTH1F(); //access Test histo
  }
  else if (me->kind()==MonitorElement::DQM_KIND_TH1S) 
  { 
    h = me->getTH1S(); //access Test histo
  }
  else if (me->kind()==MonitorElement::DQM_KIND_TH1D) 
  { 
    h = me->getTH1D(); //access Test histo
  }
  else {
    if (verbose_>0) 
      std::cout << "QTest:MeanWithinExpected"
                << " ME " << me->getFullname() 
                << " does not contain TH1F/TH1S/TH1D, exiting\n"; 
    return -1;
  } 
 
  
  if (useRange_) {
    double mean = h->GetMean();
    if (mean <= xmax_ && mean >= xmin_) 
      return 1;
    else
      return 0;
  }
  else if (useSigma_) 
  {
    if (sigma_ != 0.) 
    {
      double chi = (h->GetMean() - expMean_)/sigma_;
      return TMath::Prob(chi*chi, 1);
    }
    else
    {
      if (verbose_>0) 
        std::cout << "QTest:MeanWithinExpected"
                  << " Error, sigma_ is zero, exiting\n";
      return 0;
    }
  }
  else if (useRMS_) 
  {
    if (h->GetRMS() != 0.) 
    {
      double chi = (h->GetMean() - expMean_)/h->GetRMS();
      return TMath::Prob(chi*chi, 1);
    }
    else
    {
      if (verbose_>0) 
        std::cout << "QTest:MeanWithinExpected"
                  << " Error, RMS is zero, exiting\n";
      return 0;
    }
  }
  else 
    if (verbose_>0) 
      std::cout << "QTest:MeanWithinExpected"
                << " Error, neither Range, nor Sigma, nor RMS, exiting\n";
    return -1; 
}
void MeanWithinExpected::setExpectedMean ( double  mean) [inline]

Definition at line 401 of file QTest.h.

References expMean_, and plotscripts::mean().

Referenced by createMeanValueTest(), and QTestConfigure::EnableMeanWithinExpectedTest().

{ expMean_ = mean; }
void MeanWithinExpected::useRange ( double  xmin,
double  xmax 
)

Definition at line 1226 of file QTest.cc.

References gather_cfg::cout.

Referenced by QTestConfigure::EnableMeanWithinExpectedTest().

{
    useRange_ = true;
    useSigma_ = useRMS_ = false;
    xmin_ = xmin; xmax_ = xmax;
    if (xmin_ > xmax_)  
      if (verbose_>0) 
        std::cout << "QTest:MeanWithinExpected"
                  << " Illogical range: (" << xmin_ << ", " << xmax_ << "\n";
}
void MeanWithinExpected::useRMS ( void  )

Definition at line 1247 of file QTest.cc.

Referenced by createMeanValueTest(), and QTestConfigure::EnableMeanWithinExpectedTest().

{
  useRMS_ = true;
  useSigma_ = useRange_ = false;
}
void MeanWithinExpected::useSigma ( double  expectedSigma)

Definition at line 1236 of file QTest.cc.

References gather_cfg::cout.

Referenced by createMeanValueTest(), and QTestConfigure::EnableMeanWithinExpectedTest().

{
  useSigma_ = true;
  useRMS_ = useRange_ = false;
  sigma_ = expectedSigma;
  if (sigma_ == 0) 
    if (verbose_>0) 
      std::cout << "QTest:MeanWithinExpected"
                << " Expected sigma = " << sigma_ << "\n";
}

Member Data Documentation

double MeanWithinExpected::expMean_ [protected]

Definition at line 411 of file QTest.h.

Referenced by setExpectedMean().

double MeanWithinExpected::sigma_ [protected]

Definition at line 410 of file QTest.h.

Definition at line 409 of file QTest.h.

bool MeanWithinExpected::useRMS_ [protected]

Definition at line 407 of file QTest.h.

Definition at line 408 of file QTest.h.

double MeanWithinExpected::xmax_ [protected]

Definition at line 412 of file QTest.h.

double MeanWithinExpected::xmin_ [protected]

Definition at line 412 of file QTest.h.