CMS 3D CMS Logo

ContentsXRange Class Reference

#include <DQMServices/Core/interface/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 (float xmin, float xmax)
 set allowed range in X-axis (default values: histogram's X-range)

Static Public Member Functions

static std::string getAlgoName (void)

Protected Member Functions

void setMessage (void)
 set status & message after test has run

Protected Attributes

bool rangeInitialized_
 init-flag for xmin_, xmax_
float xmax_
float xmin_
 allowed range in X-axis


Detailed Description

Definition at line 288 of file QTest.h.


Constructor & Destructor Documentation

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

Definition at line 291 of file QTest.h.

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

00291                                         : SimpleTest(name)
00292   {
00293       rangeInitialized_ = false;
00294       setAlgoName(getAlgoName());
00295   }


Member Function Documentation

static std::string ContentsXRange::getAlgoName ( void   )  [inline, static]

Definition at line 303 of file QTest.h.

Referenced by ContentsXRange(), createXRangeTest(), QTestConfigure::enableTests(), QTestConfigure::EnableXRangeTest(), and QTestParameterNames::QTestParameterNames().

00304   { return "ContentsXRange"; }

float ContentsXRange::runTest ( const MonitorElement me  )  [virtual]

Reimplemented from QCriterion.

Definition at line 391 of file QTest.cc.

References SimpleTest::badChannels_, GenMuonPlsPt100GeV_cfg::cout, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, lat::endl(), cmsPerfPublish::fail(), first, MonitorElement::getFullname(), MonitorElement::getRootObject(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), h, MonitorElement::kind(), prof2calltree::last, rangeInitialized_, setAllowedXRange(), sum(), x, and xmax_.

00392 {
00393 
00394  badChannels_.clear();
00395 
00396  if (!me) return -1;
00397  if (!me->getRootObject()) return -1;
00398  TH1* h=0; 
00399 
00400  if (me->kind()==MonitorElement::DQM_KIND_TH1F ) {
00401    h = me->getTH1F();
00402  } 
00403  else if ( me->kind()==MonitorElement::DQM_KIND_TH1S ) {
00404    h = me->getTH1S();
00405  } 
00406  else {
00407      std::cout<< "ContentsXRange ERROR: ME " << me->getFullname() << " does not contain TH1F/TH1S" << std::endl; 
00408      return -1;
00409  } 
00410 
00411  if (!rangeInitialized_)
00412  {
00413   if ( h->GetXaxis() ) setAllowedXRange(h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
00414   else return -1;
00415  }
00416  Int_t ncx = h->GetXaxis()->GetNbins();
00417  // use underflow bin
00418  Int_t first = 0; // 1
00419  // use overflow bin
00420  Int_t last  = ncx+1; // ncx
00421  // all entries
00422  Double_t sum = 0;
00423  // entries outside X-range
00424  Double_t fail = 0;
00425  Int_t bin;
00426  for (bin = first; bin <= last; ++bin)
00427  {
00428   Double_t contents = h->GetBinContent(bin);
00429   float x = h->GetBinCenter(bin);
00430   sum += contents;
00431   if (x < xmin_ || x > xmax_)fail += contents;
00432  }
00433 
00434    if(sum==0) return 1;
00435   // return fraction of entries within allowed X-range
00436   return (sum - fail)/sum; 
00437 
00438 }

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

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

Definition at line 298 of file QTest.h.

References rangeInitialized_, xmax_, and xmin_.

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

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

void ContentsXRange::setMessage ( void   )  [inline, protected, virtual]

set status & message after test has run

Reimplemented from SimpleTest.

Definition at line 307 of file QTest.h.

References QCriterion::algoName_, QCriterion::message_, QCriterion::prob_, and QCriterion::qtname_.

00307                         {
00308     std::ostringstream message;
00309     message << " Test " << qtname_ << " (" << algoName_
00310             << "): Entry fraction within X range = " << prob_;
00311     message_ = message.str();
00312     }


Member Data Documentation

bool ContentsXRange::rangeInitialized_ [protected]

init-flag for xmin_, xmax_

Definition at line 317 of file QTest.h.

Referenced by ContentsXRange(), runTest(), and setAllowedXRange().

float ContentsXRange::xmax_ [protected]

Definition at line 315 of file QTest.h.

Referenced by runTest(), and setAllowedXRange().

float ContentsXRange::xmin_ [protected]

allowed range in X-axis

Definition at line 315 of file QTest.h.

Referenced by setAllowedXRange().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:16:47 2009 for CMSSW by  doxygen 1.5.4