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

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

955 {
957  int first = 1;
959  int ncx = h->GetXaxis()->GetNbins();
960  double sum = 0; int bin_low, bin_hi;
961  for (unsigned i = 1; i <= numNeighbors_; ++i)
962  {
964  bin_low = bin-i; bin_hi = bin+i;
967  while (bin_low < first) // shift bin by +ncx
968  bin_low = ncx + bin_low;
969  while (bin_hi > ncx) // shift bin by -ncx
970  bin_hi = bin_hi - ncx;
971  sum += h->GetBinContent(bin_low) + h->GetBinContent(bin_hi);
972  }
974  return sum/(numNeighbors_ * 2);
975 }
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 858 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.

859 {
860  badChannels_.clear();
861  if (!me)
862  return -1;
863  if (!me->getRootObject())
864  return -1;
865  TH1* h=nullptr;//initialize histogram pointer
866 
867  if (verbose_>1)
868  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
869  << me-> getFullname() << "\n";
870 
871  int nbins=0;
872  //-- TH1F
874  {
875  nbins = me->getTH1F()->GetXaxis()->GetNbins();
876  h = me->getTH1F(); // access Test histo
877  }
878  //-- TH1S
879  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
880  {
881  nbins = me->getTH1S()->GetXaxis()->GetNbins();
882  h = me->getTH1S(); // access Test histo
883  }
884  //-- TH1D
885  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
886  {
887  nbins = me->getTH1D()->GetXaxis()->GetNbins();
888  h = me->getTH1D(); // access Test histo
889  }
890  //-- TH2
891  else if (me->kind()==MonitorElement::DQM_KIND_TH2F)
892  {
893  nbins = me->getTH2F()->GetXaxis()->GetNbins() *
894  me->getTH2F()->GetYaxis()->GetNbins();
895  h = me->getTH2F(); // access Test histo
896  }
897  //-- TH2
898  else if (me->kind()==MonitorElement::DQM_KIND_TH2S)
899  {
900  nbins = me->getTH2S()->GetXaxis()->GetNbins() *
901  me->getTH2S()->GetYaxis()->GetNbins();
902  h = me->getTH2S(); // access Test histo
903  }
904  //-- TH2
905  else if (me->kind()==MonitorElement::DQM_KIND_TH2D)
906  {
907  nbins = me->getTH2D()->GetXaxis()->GetNbins() *
908  me->getTH2D()->GetYaxis()->GetNbins();
909  h = me->getTH2D(); // access Test histo
910  }
911  else
912  {
913  if (verbose_>0)
914  std::cout << "QTest:NoisyChannel"
915  << " ME " << me->getFullname()
916  << " does not contain TH1F/TH1S/TH1D or TH2F/TH2S/TH2D, exiting\n";
917  return -1;
918  }
919 
920  //-- QUALITY TEST itself
921 
922  if ( !rangeInitialized_ || !h->GetXaxis() )
923  return 1; // all channels are accepted if tolerance has not been set
924 
925  // do NOT use underflow bin
926  int first = 1;
927  // do NOT use overflow bin
928  int last = nbins;
929  // bins outside Y-range
930  int fail = 0;
931  int bin;
932  for (bin = first; bin <= last; ++bin)
933  {
934  double contents = h->GetBinContent(bin);
935  double average = getAverage(bin, h);
936  bool failure = false;
937  if (average != 0)
938  failure = (((contents-average)/TMath::Abs(average)) > tolerance_);
939 
940  if (failure)
941  {
942  ++fail;
943  DQMChannel chan(bin, 0, 0, contents, h->GetBinError(bin));
944  badChannels_.push_back(chan);
945  }
946  }
947 
948  // return fraction of bins that passed test
949  return 1.*(nbins - fail)/nbins;
950 }
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:954
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.