CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

NoisyChannel Class Reference

Check if any channels are noisy compared to neighboring ones. More...

#include <QTest.h>

Inheritance diagram for NoisyChannel:
SimpleTest QCriterion

List of all members.

Public Member Functions

 NoisyChannel (const std::string &name)
float runTest (const MonitorElement *me)
void setNumNeighbors (unsigned n)
void setTolerance (float percentage)

Static Public Member Functions

static std::string getAlgoName (void)

Protected Member Functions

double getAverage (int bin, const TH1 *h) const

Protected Attributes

unsigned numNeighbors_
bool rangeInitialized_
float tolerance_

Detailed Description

Check if any channels are noisy compared to neighboring ones.

Definition at line 302 of file QTest.h.


Constructor & Destructor Documentation

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

Member Function Documentation

static std::string NoisyChannel::getAlgoName ( void  ) [inline, static]
double NoisyChannel::getAverage ( int  bin,
const TH1 *  h 
) const [protected]

get average for bin under consideration (see description of method setNumNeighbors)

do NOT use underflow bin

do NOT use overflow bin

use symmetric-to-bin bins to calculate average

check if need to consider bins on other side of spectrum (ie. if bins below 1 or above ncx)

average is sum over the # of bins used

Definition at line 843 of file QTest.cc.

References first, and i.

{
  int first = 1;
  int ncx  = h->GetXaxis()->GetNbins();
  double sum = 0; int bin_low, bin_hi;
  for (unsigned i = 1; i <= numNeighbors_; ++i)
  {
    bin_low = bin-i;  bin_hi = bin+i;
    while (bin_low < first) // shift bin by +ncx
      bin_low = ncx + bin_low;
    while (bin_hi > ncx) // shift bin by -ncx
      bin_hi = bin_hi - ncx;
      sum += h->GetBinContent(bin_low) + h->GetBinContent(bin_hi);
  }
  return sum/(numNeighbors_ * 2);
}
float NoisyChannel::runTest ( const MonitorElement me) [virtual]

Reimplemented from QCriterion.

Definition at line 747 of file QTest.cc.

References PDRates::average, newFWLiteAna::bin, relmon_rootfiles_spy::contents, gather_cfg::cout, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, MonitorElement::DQM_KIND_TH2D, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH2S, cmsPerfPublish::fail(), first, MonitorElement::getFullname(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), MonitorElement::getTH2D(), MonitorElement::getTH2F(), MonitorElement::getTH2S(), h, MonitorElement::kind(), prof2calltree::last, and pileupCalc::nbins.

{
  badChannels_.clear();
  if (!me) 
    return -1;
  if (!me->getRootObject()) 
    return -1; 
  TH1* h=0;//initialize histogram pointer

  if (verbose_>1) 
    std::cout << "QTest:" << getAlgoName() << "::runTest called on " 
              << me-> getFullname() << "\n";

  int nbins=0;
  //-- TH1F
  if (me->kind()==MonitorElement::DQM_KIND_TH1F)
  { 
    nbins = me->getTH1F()->GetXaxis()->GetNbins(); 
    h  = me->getTH1F(); // access Test histo
  } 
  //-- TH1S
  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
  { 
    nbins = me->getTH1S()->GetXaxis()->GetNbins(); 
    h  = me->getTH1S(); // access Test histo
  } 
  //-- TH1D
  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
  { 
    nbins = me->getTH1D()->GetXaxis()->GetNbins(); 
    h  = me->getTH1D(); // access Test histo
  } 
  //-- TH2
  else if (me->kind()==MonitorElement::DQM_KIND_TH2F)
  { 
    nbins = me->getTH2F()->GetXaxis()->GetNbins() *
            me->getTH2F()->GetYaxis()->GetNbins();
    h  = me->getTH2F(); // access Test histo
  } 
  //-- TH2
  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
  { 
    nbins = me->getTH2S()->GetXaxis()->GetNbins() *
            me->getTH2S()->GetYaxis()->GetNbins();
    h  = me->getTH2S(); // access Test histo
  } 
  //-- TH2
  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
  { 
    nbins = me->getTH2D()->GetXaxis()->GetNbins() *
            me->getTH2D()->GetYaxis()->GetNbins();
    h  = me->getTH2D(); // access Test histo
  } 
  else 
  {  
    if (verbose_>0) 
      std::cout << "QTest:NoisyChannel"
        << " ME " << me->getFullname() 
        << " does not contain TH1F/TH1S/TH1D or TH2F/TH2S/TH2D, exiting\n"; 
    return -1;
  }

  //--  QUALITY TEST itself 

  if ( !rangeInitialized_ || !h->GetXaxis() ) 
    return 1; // all channels are accepted if tolerance has not been set

  // do NOT use underflow bin
  int first = 1;
  // do NOT use overflow bin
  int last  = nbins;
  // bins outside Y-range
  int fail = 0;
  int bin;
  for (bin = first; bin <= last; ++bin)
  {
    double contents = h->GetBinContent(bin);
    double average = getAverage(bin, h);
    bool failure = false;
    if (average != 0)
       failure = (((contents-average)/TMath::Abs(average)) > tolerance_);

    if (failure)
    {
      ++fail;
      DQMChannel chan(bin, 0, 0, contents, h->GetBinError(bin));
      badChannels_.push_back(chan);
    }
  }

  // return fraction of bins that passed test
  return 1.*(nbins - fail)/nbins;
}
void NoisyChannel::setNumNeighbors ( unsigned  n) [inline]

set # of neighboring channels for calculating average to be used for comparison with channel under consideration; use 1 for considering bin+1 and bin-1 (default), use 2 for considering bin+1,bin-1, bin+2,bin-2, etc; Will use rollover when bin+i or bin-i is beyond histogram limits (e.g. for histogram with N bins, bin N+1 corresponds to bin 1, and bin -1 corresponds to bin N)

Definition at line 321 of file QTest.h.

References n, and numNeighbors_.

Referenced by QTestConfigure::EnableNoisyChannelTest().

{ if (n > 0) numNeighbors_ = n; }
void NoisyChannel::setTolerance ( float  percentage) [inline]

set (percentage) tolerance for considering a channel noisy; eg. if tolerance = 20%, a channel will be noisy if (contents-average)/|average| > 20%; average is calculated from neighboring channels (also see method setNumNeighbors)

Definition at line 327 of file QTest.h.

References rangeInitialized_, and tolerance_.

Referenced by QTestConfigure::EnableNoisyChannelTest().

  {
    if (percentage >=0)
    {
      tolerance_ = percentage;
      rangeInitialized_ = true;
    }
  }

Member Data Documentation

unsigned NoisyChannel::numNeighbors_ [protected]

Definition at line 342 of file QTest.h.

Referenced by NoisyChannel(), and setNumNeighbors().

Definition at line 344 of file QTest.h.

Referenced by NoisyChannel(), and setTolerance().

float NoisyChannel::tolerance_ [protected]

Definition at line 341 of file QTest.h.

Referenced by setTolerance().