CMS 3D CMS Logo

NoisyChannel Class Reference

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

#include <DQMServices/Core/interface/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)
 run the test (result: fraction of channels not appearing noisy or "hot")
void setNumNeighbors (unsigned n)
 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.
void setTolerance (float percentage)
 set (percentage) tolerance for considering a channel noisy; eg.

Static Public Member Functions

static std::string getAlgoName (void)

Protected Member Functions

Double_t getAverage (int bin, const TH1 *h) const
 get average for bin under consideration (see description of method setNumNeighbors)
void setMessage (void)
 set status & message after test has run

Protected Attributes

TH1 * h
unsigned numNeighbors_
bool rangeInitialized_
float tolerance_


Detailed Description

Check if any channels are noisy compared to neighboring ones.

Definition at line 398 of file QTest.h.


Constructor & Destructor Documentation

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

Definition at line 401 of file QTest.h.

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

00401                                       : SimpleTest(name,true)
00402   {
00403    rangeInitialized_ = false;
00404    numNeighbors_ = 1;
00405    setAlgoName(getAlgoName());
00406   }


Member Function Documentation

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

Definition at line 411 of file QTest.h.

Referenced by QTestConfigure::EnableNoisyChannelTest(), QTestConfigure::enableTests(), NoisyChannel(), and QTestParameterNames::QTestParameterNames().

00412   { return "NoisyChannel"; }

Double_t 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 673 of file QTest.cc.

References first, i, numNeighbors_, and sum().

Referenced by runTest().

00674 {
00676   Int_t first = 1;
00678   Int_t ncx  = h->GetXaxis()->GetNbins();
00679 
00680   Double_t sum = 0; int bin_low, bin_hi;
00681   for (unsigned i = 1; i <= numNeighbors_; ++i)
00682   {
00684     bin_low = bin-i;  bin_hi = bin+i;
00687 
00688     while (bin_low < first) // shift bin by +ncx
00689       bin_low = ncx + bin_low;
00690     while (bin_hi > ncx) // shift bin by -ncx
00691       bin_hi = bin_hi - ncx;
00692   
00693       sum += h->GetBinContent(bin_low) + h->GetBinContent(bin_hi);
00694   }
00695 
00697   return sum/(numNeighbors_ * 2);
00698 }

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

run the test (result: fraction of channels not appearing noisy or "hot")

Reimplemented from QCriterion.

Definition at line 603 of file QTest.cc.

References average(), SimpleTest::badChannels_, GenMuonPlsPt100GeV_cfg::cout, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH2S, lat::endl(), cmsPerfPublish::fail(), first, getAverage(), MonitorElement::getFullname(), MonitorElement::getRootObject(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), MonitorElement::getTH2F(), MonitorElement::getTH2S(), h, MonitorElement::kind(), prof2calltree::last, rangeInitialized_, and tolerance_.

00604  {
00605 
00606  badChannels_.clear();
00607  if (!me) return -1;
00608  if (!me->getRootObject()) return -1; 
00609  h=0;//initialize histogram pointer
00610 
00611  int nbins=0;
00612  //-- TH1F
00613  if (me->kind()==MonitorElement::DQM_KIND_TH1F){ 
00614    nbins = me->getTH1F()->GetXaxis()->GetNbins(); 
00615    h  = me->getTH1F(); // access Test histo
00616  } 
00617  //-- TH1S
00618  else if (me->kind()==MonitorElement::DQM_KIND_TH1S){ 
00619    nbins = me->getTH1S()->GetXaxis()->GetNbins(); 
00620    h  = me->getTH1S(); // access Test histo
00621  } 
00622  //-- TH2
00623  else if (me->kind()==MonitorElement::DQM_KIND_TH2F){ 
00624    nbins = me->getTH2F()->GetXaxis()->GetNbins() *
00625            me->getTH2F()->GetYaxis()->GetNbins();
00626    h  = me->getTH2F(); // access Test histo
00627  } 
00628  //-- TH2
00629  else if (me->kind()==MonitorElement::DQM_KIND_TH2S){ 
00630    nbins = me->getTH2S()->GetXaxis()->GetNbins() *
00631            me->getTH2S()->GetYaxis()->GetNbins();
00632    h  = me->getTH2S(); // access Test histo
00633  } 
00634  else {  
00635    std::cout<< "NoisyChannel ERROR: ME " << me->getFullname() << 
00636    " does not contain TH1F/TH1S or TH2F/TH2S" << std::endl; 
00637    return -1;
00638  }
00639 
00640  //--  QUALITY TEST itself 
00641 
00642  if ( !rangeInitialized_ || !h->GetXaxis() ) return 1; // all channels are accepted if tolerance has not been set
00643 
00644   // do NOT use underflow bin
00645   Int_t first = 1;
00646   // do NOT use overflow bin
00647   Int_t last  = nbins;
00648   // bins outside Y-range
00649   Int_t fail = 0;
00650   Int_t bin;
00651   for (bin = first; bin <= last; ++bin)
00652   {
00653     Double_t contents = h->GetBinContent(bin);
00654     Double_t average = getAverage(bin, h);
00655     bool failure = false;
00656     if (average != 0)
00657       failure = (((contents-average)/TMath::Abs(average)) > tolerance_);
00658 
00659     if (failure)
00660     {
00661       ++fail;
00662       DQMChannel chan(bin, 0, 0, contents, h->GetBinError(bin));
00663       badChannels_.push_back(chan);
00664     }
00665   }
00666 
00667   // return fraction of bins that passed test
00668   return 1.*(nbins - fail)/nbins;
00669  }

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

set status & message after test has run

Reimplemented from SimpleTest.

Definition at line 439 of file QTest.h.

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

00439                          {
00440       std::ostringstream message;
00441       message << " Test " << qtname_ << " (" << algoName_
00442               << "): Fraction of non-noisy channels = " << prob_;
00443       message_ = message.str();
00444     }

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 421 of file QTest.h.

References numNeighbors_.

Referenced by QTestConfigure::EnableNoisyChannelTest().

00421 { 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 427 of file QTest.h.

References rangeInitialized_, and tolerance_.

Referenced by QTestConfigure::EnableNoisyChannelTest().

00428     {
00429       if (percentage >=0)
00430       {
00431         tolerance_ = percentage;
00432         rangeInitialized_ = true;
00433       }
00434     }


Member Data Documentation

TH1* NoisyChannel::h [protected]

Definition at line 446 of file QTest.h.

Referenced by runTest().

unsigned NoisyChannel::numNeighbors_ [protected]

Definition at line 453 of file QTest.h.

Referenced by getAverage(), NoisyChannel(), and setNumNeighbors().

bool NoisyChannel::rangeInitialized_ [protected]

Definition at line 455 of file QTest.h.

Referenced by NoisyChannel(), runTest(), and setTolerance().

float NoisyChannel::tolerance_ [protected]

Definition at line 452 of file QTest.h.

Referenced by runTest(), and setTolerance().


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