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.
template<class T >
static bool getBinStatistics (const T *histo, const int ix, const int iy, float &num, float &mean, float &rms)
 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.
template<class T >
static void printBadChannels (const MonitorElement *me, const T *hi, bool positive_only=false)
 Print the bad channels.

Private Member Functions

 UtilsClient ()
 ~UtilsClient ()

Detailed Description

Utilities for Ecal Monitor Client.

Definition at line 23 of file UtilsClient.h.


Constructor & Destructor Documentation

UtilsClient::UtilsClient ( ) [inline, private]

Definition at line 220 of file UtilsClient.h.

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

Definition at line 221 of file UtilsClient.h.

{}; // Hidden to force static use

Member Function Documentation

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

Returns true if the bin quality is good or masked.

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

Definition at line 153 of file UtilsClient.h.

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;
  }
template<class T >
template< class T > static bool UtilsClient::getBinStatistics ( const T histo,
const int  ix,
const int  iy,
float &  num,
float &  mean,
float &  rms 
) [inline, 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 133 of file UtilsClient.h.

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.;
    float n_min_bin = 1.;

    if ( histo ) {
      num = histo->GetBinEntries(histo->GetBin(ix, iy));
      if ( num >= n_min_bin ) {
        mean = histo->GetBinContent(ix, iy);
        rms  = histo->GetBinError(ix, iy);
        return true;
      }
    }
    return false;
  }
static bool UtilsClient::getBinStatus ( const MonitorElement me,
const int  ix,
const int  iy 
) [inline, static]

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

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

Definition at line 171 of file UtilsClient.h.

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;
  }
static int UtilsClient::getFirstNonEmptyChannel ( const TProfile2D *  histo) [inline, static]

Find the first non empty bin.

static int getFirstNonEmptyChannel( const TProfile2D* histo )

Parameters:
histoinput ROOT histogram

Definition at line 206 of file UtilsClient.h.

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 >
template< class T > static 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 33 of file UtilsClient.h.

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

                                                                                                {
    if( me ) {
      // std::cout << "Found '" << me->getName() <<"'" << std::endl;
      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;
  }
static void UtilsClient::maskBinContent ( const MonitorElement me,
const int  ix,
const int  iy 
) [inline, 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 189 of file UtilsClient.h.

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);
      }
    }
  }
template<class T >
template< class T > static void UtilsClient::printBadChannels ( const MonitorElement me,
const T hi,
bool  positive_only = false 
) [inline, static]

Print the bad channels.

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

Definition at line 67 of file UtilsClient.h.

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*>(const_cast<T*>(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;
  }