CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Protected Attributes

ContentsYRange Class Reference

#include <QTest.h>

Inheritance diagram for ContentsYRange:
SimpleTest QCriterion

List of all members.

Public Member Functions

 ContentsYRange (const std::string &name)
float runTest (const MonitorElement *me)
virtual void setAllowedYRange (double ymin, double ymax)
void setUseEmptyBins (unsigned int useEmptyBins)

Static Public Member Functions

static std::string getAlgoName (void)

Protected Attributes

bool rangeInitialized_
unsigned int useEmptyBins_
double ymax_
double ymin_

Detailed Description

Definition at line 249 of file QTest.h.


Constructor & Destructor Documentation

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

Definition at line 252 of file QTest.h.

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


Member Function Documentation

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

Standard test !

AS quality test !!!

end of AS quality tests

Reimplemented from QCriterion.

Definition at line 547 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(), and prof2calltree::last.

{
  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";

  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:ContentsYRange" 
                << " ME " << me->getFullname() 
                << " does not contain TH1F/TH1S/TH1D, exiting\n"; 
    return -1;
  } 

  if (!rangeInitialized_ || !h->GetXaxis()) return 1; // all bins are accepted if no initialization
  int ncx = h->GetXaxis()->GetNbins();
  // do NOT use underflow bin
  int first = 1;
  // do NOT use overflow bin
  int last  = ncx;
  // bins outside Y-range
  int fail = 0;
  int bin;
  
  if (useEmptyBins_)
  {
    for (bin = first; bin <= last; ++bin)
    {
      double contents = h->GetBinContent(bin);
      bool failure = false;
      failure = (contents < ymin_ || contents > ymax_); // allowed y-range: [ymin_, ymax_]
      if (failure) 
      { 
        DQMChannel chan(bin, 0, 0, contents, h->GetBinError(bin));
        badChannels_.push_back(chan);
        ++fail;
      }
    }
    // return fraction of bins that passed test
    return 1.*(ncx - fail)/ncx;
  }
  else 
  {
    for (bin = first; bin <= last; ++bin)
    {
      double contents = h->GetBinContent(bin);
      bool failure = false;
      if (contents) failure = (contents < ymin_ || contents > ymax_); // allowed y-range: [ymin_, ymax_]
      if (failure) ++fail;
    }
    // return fraction of bins that passed test
    return 1.*(ncx - fail)/ncx;
  } 
}
virtual void ContentsYRange::setAllowedYRange ( double  ymin,
double  ymax 
) [inline, virtual]
void ContentsYRange::setUseEmptyBins ( unsigned int  useEmptyBins) [inline]

Definition at line 260 of file QTest.h.

References useEmptyBins_.

Referenced by QTestConfigure::EnableYRangeTest().

{ useEmptyBins_ = useEmptyBins; }

Member Data Documentation

Definition at line 269 of file QTest.h.

Referenced by ContentsYRange(), and setAllowedYRange().

unsigned int ContentsYRange::useEmptyBins_ [protected]

Definition at line 270 of file QTest.h.

Referenced by setUseEmptyBins().

double ContentsYRange::ymax_ [protected]

Definition at line 268 of file QTest.h.

Referenced by setAllowedYRange().

double ContentsYRange::ymin_ [protected]

Definition at line 268 of file QTest.h.

Referenced by setAllowedYRange().