CMS 3D CMS Logo

List of all members | 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

Public Member Functions

 NoisyChannel (const std::string &name)
 
float runTest (const MonitorElement *me)
 
void setNumNeighbors (unsigned n)
 
void setTolerance (float percentage)
 
- Public Member Functions inherited from SimpleTest
virtual std::vector< DQMChannelgetBadChannels (void) const
 get vector of channels that failed test (not always relevant!) More...
 
void setMinimumEntries (unsigned n)
 set minimum # of entries needed More...
 
 SimpleTest (const std::string &name, bool keepBadChannels=false)
 
- Public Member Functions inherited from QCriterion
std::string algoName (void) const
 get algorithm name More...
 
std::string getMessage (void) const
 get message attached to test More...
 
std::string getName (void) const
 get name of quality test More...
 
int getStatus (void) const
 (class should be created by DQMStore class) More...
 
void setErrorProb (float prob)
 
void setWarningProb (float prob)
 set probability limit for warning and error (default: 90% and 50%) More...
 

Static Public Member Functions

static std::string getAlgoName (void)
 

Protected Member Functions

double getAverage (int bin, const TH1 *h) const
 
- Protected Member Functions inherited from SimpleTest
virtual void setMessage (void)
 set status & message after test has run More...
 
- Protected Member Functions inherited from QCriterion
void init (void)
 initialize values More...
 
 QCriterion (std::string qtname)
 
float runTest (const MonitorElement *me, QReport &qr, DQMNet::QValue &qv)
 
void setAlgoName (std::string name)
 set algorithm name More...
 
void setVerbose (int verbose)
 probability limits for warnings, errors More...
 
virtual ~QCriterion (void)
 

Protected Attributes

unsigned numNeighbors_
 
bool rangeInitialized_
 
float tolerance_
 
- Protected Attributes inherited from SimpleTest
std::vector< DQMChannelbadChannels_
 
bool keepBadChannels_
 
unsigned minEntries_
 
- Protected Attributes inherited from QCriterion
std::string algoName_
 name of quality test More...
 
float errorProb_
 
std::string message_
 quality test status More...
 
float prob_
 name of algorithm More...
 
std::string qtname_
 
int status_
 
int verbose_
 
float warningProb_
 message attached to test More...
 

Detailed Description

Check if any channels are noisy compared to neighboring ones.

Definition at line 332 of file QTest.h.

Constructor & Destructor Documentation

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

Definition at line 335 of file QTest.h.

References QCriterion::setAlgoName().

335  : SimpleTest(name,true)
336  {
337  rangeInitialized_ = false;
338  numNeighbors_ = 1;
340  }
static std::string getAlgoName(void)
Definition: QTest.h:341
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:78
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:138
bool rangeInitialized_
Definition: QTest.h:374
unsigned numNeighbors_
Definition: QTest.h:372

Member Function Documentation

static std::string NoisyChannel::getAlgoName ( void  )
inlinestatic

Definition at line 341 of file QTest.h.

References QCriterion::runTest().

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

341 { return "NoisyChannel"; }
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 944 of file QTest.cc.

References plotBeamSpotDB::first, and mps_fire::i.

945 {
947  int first = 1;
949  int ncx = h->GetXaxis()->GetNbins();
950  double sum = 0; int bin_low, bin_hi;
951  for (unsigned i = 1; i <= numNeighbors_; ++i)
952  {
954  bin_low = bin-i; bin_hi = bin+i;
957  while (bin_low < first) // shift bin by +ncx
958  bin_low = ncx + bin_low;
959  while (bin_hi > ncx) // shift bin by -ncx
960  bin_hi = bin_hi - ncx;
961  sum += h->GetBinContent(bin_low) + h->GetBinContent(bin_hi);
962  }
964  return sum/(numNeighbors_ * 2);
965 }
bin
set the eta bin as selection string.
unsigned numNeighbors_
Definition: QTest.h:372
float NoisyChannel::runTest ( const MonitorElement me)
virtual

Reimplemented from QCriterion.

Definition at line 848 of file QTest.cc.

References Abs(), stringResolutionProvider_cfi::bin, officialStyle::chan, 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(), plotBeamSpotDB::first, MonitorElement::getFullname(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), MonitorElement::getTH2D(), MonitorElement::getTH2F(), MonitorElement::getTH2S(), MonitorElement::kind(), plotBeamSpotDB::last, and pileupCalc::nbins.

849 {
850  badChannels_.clear();
851  if (!me)
852  return -1;
853  if (!me->getRootObject())
854  return -1;
855  TH1* h=0;//initialize histogram pointer
856 
857  if (verbose_>1)
858  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
859  << me-> getFullname() << "\n";
860 
861  int nbins=0;
862  //-- TH1F
864  {
865  nbins = me->getTH1F()->GetXaxis()->GetNbins();
866  h = me->getTH1F(); // access Test histo
867  }
868  //-- TH1S
869  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
870  {
871  nbins = me->getTH1S()->GetXaxis()->GetNbins();
872  h = me->getTH1S(); // access Test histo
873  }
874  //-- TH1D
875  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
876  {
877  nbins = me->getTH1D()->GetXaxis()->GetNbins();
878  h = me->getTH1D(); // access Test histo
879  }
880  //-- TH2
881  else if (me->kind()==MonitorElement::DQM_KIND_TH2F)
882  {
883  nbins = me->getTH2F()->GetXaxis()->GetNbins() *
884  me->getTH2F()->GetYaxis()->GetNbins();
885  h = me->getTH2F(); // access Test histo
886  }
887  //-- TH2
888  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
889  {
890  nbins = me->getTH2S()->GetXaxis()->GetNbins() *
891  me->getTH2S()->GetYaxis()->GetNbins();
892  h = me->getTH2S(); // access Test histo
893  }
894  //-- TH2
895  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
896  {
897  nbins = me->getTH2D()->GetXaxis()->GetNbins() *
898  me->getTH2D()->GetYaxis()->GetNbins();
899  h = me->getTH2D(); // access Test histo
900  }
901  else
902  {
903  if (verbose_>0)
904  std::cout << "QTest:NoisyChannel"
905  << " ME " << me->getFullname()
906  << " does not contain TH1F/TH1S/TH1D or TH2F/TH2S/TH2D, exiting\n";
907  return -1;
908  }
909 
910  //-- QUALITY TEST itself
911 
912  if ( !rangeInitialized_ || !h->GetXaxis() )
913  return 1; // all channels are accepted if tolerance has not been set
914 
915  // do NOT use underflow bin
916  int first = 1;
917  // do NOT use overflow bin
918  int last = nbins;
919  // bins outside Y-range
920  int fail = 0;
921  int bin;
922  for (bin = first; bin <= last; ++bin)
923  {
924  double contents = h->GetBinContent(bin);
925  double average = getAverage(bin, h);
926  bool failure = false;
927  if (average != 0)
928  failure = (((contents-average)/TMath::Abs(average)) > tolerance_);
929 
930  if (failure)
931  {
932  ++fail;
933  DQMChannel chan(bin, 0, 0, contents, h->GetBinError(bin));
934  badChannels_.push_back(chan);
935  }
936  }
937 
938  // return fraction of bins that passed test
939  return 1.*(nbins - fail)/nbins;
940 }
TH2S * getTH2S(void) const
TH1S * getTH1S(void) const
static std::string getAlgoName(void)
Definition: QTest.h:341
double getAverage(int bin, const TH1 *h) const
Definition: QTest.cc:944
int verbose_
Definition: QTest.h:118
TH1D * getTH1D(void) const
TH2D * getTH2D(void) const
T Abs(T a)
Definition: MathUtil.h:49
Kind kind(void) const
Get the type of the monitor element.
const std::string getFullname(void) const
get full name of ME including Pathname
bin
set the eta bin as selection string.
TObject * getRootObject(void) const
TH1F * getTH1F(void) const
std::vector< DQMChannel > badChannels_
Definition: QTest.h:160
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
float tolerance_
Definition: QTest.h:371
TH2F * getTH2F(void) const
def fail(errstr="")
bool rangeInitialized_
Definition: QTest.h:374
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 351 of file QTest.h.

References gen::n.

Referenced by QTestConfigure::EnableNoisyChannelTest().

351 { if (n > 0) numNeighbors_ = n; }
unsigned numNeighbors_
Definition: QTest.h:372
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 357 of file QTest.h.

References stringResolutionProvider_cfi::bin.

Referenced by QTestConfigure::EnableNoisyChannelTest().

358  {
359  if (percentage >=0)
360  {
361  tolerance_ = percentage;
362  rangeInitialized_ = true;
363  }
364  }
float tolerance_
Definition: QTest.h:371
bool rangeInitialized_
Definition: QTest.h:374

Member Data Documentation

unsigned NoisyChannel::numNeighbors_
protected

Definition at line 372 of file QTest.h.

bool NoisyChannel::rangeInitialized_
protected

Definition at line 374 of file QTest.h.

float NoisyChannel::tolerance_
protected

Definition at line 371 of file QTest.h.