CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Protected Attributes

ContentsXRange Class Reference

#include <QTest.h>

Inheritance diagram for ContentsXRange:
SimpleTest QCriterion

List of all members.

Public Member Functions

 ContentsXRange (const std::string &name)
float runTest (const MonitorElement *me)
virtual void setAllowedXRange (double xmin, double xmax)
 set allowed range in X-axis (default values: histogram's X-range)

Static Public Member Functions

static std::string getAlgoName (void)

Protected Attributes

bool rangeInitialized_
double xmax_
double xmin_

Detailed Description

Definition at line 223 of file QTest.h.


Constructor & Destructor Documentation

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

Member Function Documentation

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

Reimplemented from QCriterion.

Definition at line 477 of file QTest.cc.

References newFWLiteAna::bin, cmsMakeMELists::contents, gather_cfg::cout, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, cmsPerfPublish::fail(), first, MonitorElement::getFullname(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), h, MonitorElement::kind(), prof2calltree::last, and x.

{
  badChannels_.clear();

  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";
  // -- TH1F
  if (me->kind()==MonitorElement::DQM_KIND_TH1F ) 
  {
    h = me->getTH1F();
  } 
  // -- TH1S
  else if ( me->kind()==MonitorElement::DQM_KIND_TH1S ) 
  {
    h = me->getTH1S();
  } 
  // -- TH1D
  else if ( me->kind()==MonitorElement::DQM_KIND_TH1D ) 
  {
    h = me->getTH1D();
  } 
  else 
  {
    if (verbose_>0) std::cout << "QTest:ContentsXRange"
         << " ME " << me->getFullname() 
         << " does not contain TH1F/TH1S/TH1D, exiting\n"; 
    return -1;
  } 

  if (!rangeInitialized_)
  {
    if ( h->GetXaxis() ) 
      setAllowedXRange(h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
    else 
      return -1;
  }
  int ncx = h->GetXaxis()->GetNbins();
  // use underflow bin
  int first = 0; // 1
  // use overflow bin
  int last  = ncx+1; // ncx
  // all entries
  double sum = 0;
  // entries outside X-range
  double fail = 0;
  int bin;
  for (bin = first; bin <= last; ++bin)
  {
    double contents = h->GetBinContent(bin);
    double x = h->GetBinCenter(bin);
    sum += contents;
    if (x < xmin_ || x > xmax_)fail += contents;
  }

  if (sum==0) return 1;
  // return fraction of entries within allowed X-range
  return (sum - fail)/sum; 

}
virtual void ContentsXRange::setAllowedXRange ( double  xmin,
double  xmax 
) [inline, virtual]

set allowed range in X-axis (default values: histogram's X-range)

Definition at line 235 of file QTest.h.

References rangeInitialized_, xmax_, and xmin_.

Referenced by createXRangeTest(), and QTestConfigure::EnableXRangeTest().

  { 
    xmin_ = xmin; xmax_ = xmax; 
    rangeInitialized_ = true; 
  }

Member Data Documentation

Definition at line 243 of file QTest.h.

Referenced by ContentsXRange(), and setAllowedXRange().

double ContentsXRange::xmax_ [protected]

Definition at line 242 of file QTest.h.

Referenced by setAllowedXRange().

double ContentsXRange::xmin_ [protected]

Definition at line 242 of file QTest.h.

Referenced by setAllowedXRange().