CMS 3D CMS Logo

Static Public Member Functions | Private Member Functions

UtilsClient Class Reference

Utilities for Ecal Monitor Client. More...

#include <UtilsClient.h>

List of all members.

Static Public Member Functions

static bool getBinQuality (const MonitorElement *me, const int ix, const int iy)
 Returns true if the bin quality is good or masked.
static bool getBinStatistics (TH1 *histo, const int ix, const int iy, float &num, float &mean, float &rms, float minEntries=1.)
 Returns true if the bin contains good statistical data.
static bool getBinStatus (const MonitorElement *me, const int ix, const int iy)
 Returns true if the bin status is red/dark red.
static int getFirstNonEmptyChannel (const TProfile2D *histo)
 Find the first non empty bin.
template<class T >
static T getHisto (const MonitorElement *me, bool clone=false, T ret=0)
 Returns the histogram contained by the Monitor Element.
static void maskBinContent (const MonitorElement *me, const int ix, const int iy)
 Mask the bin content.
static void printBadChannels (const MonitorElement *me, TH1 *hi, bool positive_only=false)
 Print the bad channels.

Private Member Functions

 UtilsClient ()
 ~UtilsClient ()

Detailed Description

Utilities for Ecal Monitor Client.

Definition at line 24 of file UtilsClient.h.


Constructor & Destructor Documentation

UtilsClient::UtilsClient ( ) [inline, private]

Definition at line 83 of file UtilsClient.h.

{}; // Hidden to force static use
UtilsClient::~UtilsClient ( ) [inline, private]

Definition at line 84 of file UtilsClient.h.

{}; // Hidden to force static use

Member Function Documentation

bool UtilsClient::getBinQuality ( const MonitorElement me,
const int  ix,
const int  iy 
) [static]

Returns true if the bin quality is good or masked.

Parameters:
meinput histogram
(ix,iy)input histogram's bins

Definition at line 201 of file UtilsClient.cc.

References MonitorElement::getBinContent().

{
  if ( me ) {
    float val = me->getBinContent(ix, iy);
    //  0/3 = red/dark red
    //  1/4 = green/dark green
    //  2/5 = yellow/dark yellow
    //  6   = unknown
    if ( val == 0. || val == 2 || val == 6 ) return false;
    if ( val == 1. || val == 3 || val == 4 || val == 5 ) return true;
  }
  return false;
}
bool UtilsClient::getBinStatistics ( TH1 *  histo,
const int  ix,
const int  iy,
float &  num,
float &  mean,
float &  rms,
float  minEntries = 1. 
) [static]

Returns true if the bin contains good statistical data.

Parameters:
histoinput ROOT histogram
(ix,iy)input histogram's bin
numbin's entries
meanbins' mean
rmsbin's rms

Definition at line 74 of file UtilsClient.cc.

References newFWLiteAna::bin, timingPdfMaker::histo, NULL, connectstrParser::o, AlCaHLTBitMon_ParallelJobs::p, p2, and mathSSE::sqrt().

Referenced by EEPedestalClient::analyze(), EETimingClient::analyze(), EESummaryClient::analyze(), EBTimingClient::analyze(), EELaserClient::analyze(), EETestPulseClient::analyze(), EEPedestalOnlineClient::analyze(), EBSummaryClient::analyze(), EBLaserClient::analyze(), EBTestPulseClient::analyze(), EELedClient::analyze(), EBPedestalClient::analyze(), and EBPedestalOnlineClient::analyze().

{
  num  = -1.; mean = -1.; rms  = -1.;

  if ( !histo ) return false;
 
  // TProfile2D does not inherit from TProfile; need two pointers
 
  TProfile *p = NULL;
  TProfile2D *p2 = NULL;
 
  int bin = histo->GetBin(ix, iy);
  char o;
 
  TClass *cl = histo->IsA();
  if( cl == TClass::GetClass("TProfile") ){
    p = dynamic_cast<TProfile *>(histo);
    num = p->GetBinEntries(bin);
    o = *( p->GetErrorOption() );
  }else if( cl == TClass::GetClass("TProfile2D") ){
    p2 = dynamic_cast<TProfile2D *>(histo);
    num = p2->GetBinEntries(bin);
    o = *( p2->GetErrorOption() );
  }else
    return false;
 
  if ( num < minEntries ) return false;
 
  mean = histo->GetBinContent(ix, iy);
  if( o == 's' )
    rms  = histo->GetBinError(ix, iy);
  else if( o == '\0' )
    rms = histo->GetBinError(ix, iy) * std::sqrt( num );
  // currently not compatible with other error options!!
 
  return true;
}
bool UtilsClient::getBinStatus ( const MonitorElement me,
const int  ix,
const int  iy 
) [static]

Returns true if the bin status is red/dark red.

Parameters:
meinput histogram
(ix,iy)input histogram's bins

Definition at line 216 of file UtilsClient.cc.

References MonitorElement::getBinContent().

{
  if ( me ) {
    float val = me->getBinContent(ix, iy);
    //  0/3 = red/dark red
    //  1/4 = green/dark green
    //  2/5 = yellow/dark yellow
    //  6   = unknown
    if ( val == 0. || val == 3 ) return true;
    return false;
  }
  return false;
}
int UtilsClient::getFirstNonEmptyChannel ( const TProfile2D *  histo) [static]

Find the first non empty bin.

static int getFirstNonEmptyChannel( const TProfile2D* histo )

Parameters:
histoinput ROOT histogram

Definition at line 246 of file UtilsClient.cc.

Referenced by EELaserClient::analyze(), EETestPulseClient::analyze(), EBLaserClient::analyze(), EBTestPulseClient::analyze(), and EELedClient::analyze().

{
  if ( histo ) {
    int ichannel = 1;
    while ( ichannel <= histo->GetNbinsX() ) {
      double counts = histo->GetBinContent(ichannel, 1);
      if ( counts > 0 ) return( ichannel );
      ichannel++;
    }
  }
  return( 1 );
}
template<class T >
T UtilsClient::getHisto ( const MonitorElement me,
bool  clone = false,
T  ret = 0 
) [inline, static]

Returns the histogram contained by the Monitor Element.

Parameters:
meMonitor Element
clone(boolean) if true clone the histogram
retin case of clonation delete the histogram first

Definition at line 91 of file UtilsClient.h.

References MonitorElement::getName(), runTheMatrix::ret, and asciidump::s.

{
  if( me ) {
    TObject* ob = const_cast<MonitorElement*>(me)->getRootObject();
    if( ob ) { 
      if( clone ) {
        if( ret ) {
          delete ret;
        }
        std::string s = "ME " + me->getName();
        ret = dynamic_cast<T>(ob->Clone(s.c_str())); 
        if( ret ) {
          ret->SetDirectory(0);
        }
      } else {
        ret = dynamic_cast<T>(ob); 
      }
    } else {
      ret = 0;
    }
  } else {
    if( !clone ) {
      ret = 0;
    }
  }
  return ret;
}
void UtilsClient::maskBinContent ( const MonitorElement me,
const int  ix,
const int  iy 
) [static]

Mask the bin content.

static void maskBinContent( const MonitorElement* me, const int ix, const int iy )

Parameters:
histoinput histogram
(ix,iy)input histogram's bins

Definition at line 231 of file UtilsClient.cc.

References MonitorElement::getBinContent().

Referenced by EETimingClient::analyze(), EEPedestalClient::analyze(), EESummaryClient::analyze(), EELaserClient::analyze(), EBTimingClient::analyze(), EEIntegrityClient::analyze(), EETestPulseClient::analyze(), EEPedestalOnlineClient::analyze(), EBSummaryClient::analyze(), EELedClient::analyze(), EBTestPulseClient::analyze(), EBLaserClient::analyze(), EBPedestalOnlineClient::analyze(), EBPedestalClient::analyze(), and EBIntegrityClient::analyze().

{
  if ( me ) {
    float val = me->getBinContent(ix, iy);
    //  0/3 = red/dark red
    //  1/4 = green/dark green
    //  2/5 = yellow/dark yellow
    //  6   = unknown
    if ( val >= 0. && val <= 2. ) {
      const_cast<MonitorElement*>(me)->setBinContent(ix, iy, val+3);
    }
  }
}
void UtilsClient::printBadChannels ( const MonitorElement me,
TH1 *  hi,
bool  positive_only = false 
) [static]

Print the bad channels.

Parameters:
memonitor element
hihistogram
positive_onlyenable logging of channels with positive content, only

Definition at line 14 of file UtilsClient.cc.

References gather_cfg::cout, MonitorElement::getBinContent(), MonitorElement::getName(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), and indexGen::title.

{
  if ( ! me ) {
    std::cout << "printBadChannels() failed, NULL pointer to MonitorElement !"
              << std::endl;
    return;
  }
  if ( ! hi ) {
    std::cout << "printBadChannels() failed, NULL pointer to ROOT histogram !"
              << std::endl;
    return;
  }
  bool title = false;
  TProfile2D* hj = dynamic_cast<TProfile2D*>(hi);
  int kx = -1;
  int ky = -1;
  for ( int ix = 1; ix <= me->getNbinsX(); ix++ ) {
    int jx = ix * hi->GetNbinsX() / me->getNbinsX();
    if ( jx == kx ) continue;
    kx = jx;
    for ( int iy = 1; iy <= me->getNbinsY(); iy++ ) {
      int jy = iy * hi->GetNbinsY() / me->getNbinsY();
      if ( jy == ky ) continue;
      ky = jy;
      if ( positive_only ) {
        if ( hi->GetBinContent(hi->GetBin(jx, jy)) <= 0 ) continue;
      } else {
        float val = me->getBinContent( ix, iy );
        //  0/3 = red/dark red
        //  1/4 = green/dark green
        //  2/5 = yellow/dark yellow
        //  6   = unknown
        if ( val == 6 ) continue;
        if ( int(val) % 3 != 0 ) continue;
      }
      if ( ! title ) {
        std::cout << " Channels failing \"" << me->getName() << "\""
                  << " (" << hi->GetName() << ") "
                  << std::endl << std::endl;
        title = true;
      }
      std::cout << " ("
                << hi->GetXaxis()->GetBinUpEdge(jx)
                << ", "
                << hi->GetYaxis()->GetBinUpEdge(jy);
      if ( hj )
        std::cout << ", "
                  << hj->GetBinEntries(hj->GetBin(jx, jy));
      std::cout << ") = "
                << hi->GetBinContent(hi->GetBin(jx, jy))
                << " +- "
                << hi->GetBinError(hi->GetBin(jx, jy))
                << std::endl;
    }
  }
  if ( title ) std::cout << std::endl;
  return;
}