CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions | Private Member Functions
UtilsClient Class Reference

Utilities for Ecal Monitor Client. More...

#include <UtilsClient.h>

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. More...
 
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. More...
 
static bool getBinStatus (const MonitorElement *me, const int ix, const int iy)
 Returns true if the bin status is red/dark red. More...
 
static int getFirstNonEmptyChannel (const TProfile2D *histo)
 Find the first non empty bin. More...
 
template<class T >
static T getHisto (const MonitorElement *me, bool clone=false, T ret=0)
 Returns the histogram contained by the Monitor Element. More...
 
static void maskBinContent (const MonitorElement *me, const int ix, const int iy)
 Mask the bin content. More...
 
template<class T >
static void printBadChannels (const MonitorElement *me, const T *hi, bool positive_only=false)
 Print the bad channels. More...
 

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 ( )
inlineprivate

Definition at line 220 of file UtilsClient.h.

220 {}; // Hidden to force static use
UtilsClient::~UtilsClient ( )
inlineprivate

Definition at line 221 of file UtilsClient.h.

221 {}; // Hidden to force static use

Member Function Documentation

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

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().

153  {
154  if ( me ) {
155  float val = me->getBinContent(ix, iy);
156  // 0/3 = red/dark red
157  // 1/4 = green/dark green
158  // 2/5 = yellow/dark yellow
159  // 6 = unknown
160  if ( val == 0. || val == 2 || val == 6 ) return false;
161  if ( val == 1. || val == 3 || val == 4 || val == 5 ) return true;
162  }
163  return false;
164  }
double getBinContent(int binx) const
get content of bin (1-D)
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 
)
inlinestatic

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 EBSummaryClient::analyze(), EESummaryClient::analyze(), EELedClient::analyze(), EBLaserClient::analyze(), EBTimingClient::analyze(), EETimingClient::analyze(), EELaserClient::analyze(), EEPedestalClient::analyze(), EEPedestalOnlineClient::analyze(), EETestPulseClient::analyze(), EBPedestalOnlineClient::analyze(), EBPedestalClient::analyze(), and EBTestPulseClient::analyze().

133  {
134  num = -1.; mean = -1.; rms = -1.;
135  float n_min_bin = 1.;
136 
137  if ( histo ) {
138  num = histo->GetBinEntries(histo->GetBin(ix, iy));
139  if ( num >= n_min_bin ) {
140  mean = histo->GetBinContent(ix, iy);
141  rms = histo->GetBinError(ix, iy);
142  return true;
143  }
144  }
145  return false;
146  }
tuple histo
Definition: trackerHits.py:12
long long int num
Definition: procUtils.cc:71
static bool UtilsClient::getBinStatus ( const MonitorElement me,
const int  ix,
const int  iy 
)
inlinestatic

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().

171  {
172  if ( me ) {
173  float val = me->getBinContent(ix, iy);
174  // 0/3 = red/dark red
175  // 1/4 = green/dark green
176  // 2/5 = yellow/dark yellow
177  // 6 = unknown
178  if ( val == 0. || val == 3 ) return true;
179  return false;
180  }
181  return false;
182  }
double getBinContent(int binx) const
get content of bin (1-D)
static int UtilsClient::getFirstNonEmptyChannel ( const TProfile2D *  histo)
inlinestatic

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 EBLaserClient::analyze(), EELedClient::analyze(), EELaserClient::analyze(), EBTestPulseClient::analyze(), and EETestPulseClient::analyze().

206  {
207  if ( histo ) {
208  int ichannel = 1;
209  while ( ichannel <= histo->GetNbinsX() ) {
210  double counts = histo->GetBinContent(ichannel, 1);
211  if ( counts > 0 ) return( ichannel );
212  ichannel++;
213  }
214  }
215  return( 1 );
216  }
tuple histo
Definition: trackerHits.py:12
template<class T >
template< class T > static T UtilsClient::getHisto ( const MonitorElement me,
bool  clone = false,
ret = 0 
)
inlinestatic

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.

33  {
34  if( me ) {
35  // std::cout << "Found '" << me->getName() <<"'" << std::endl;
36  TObject* ob = const_cast<MonitorElement*>(me)->getRootObject();
37  if( ob ) {
38  if( clone ) {
39  if( ret ) {
40  delete ret;
41  }
42  std::string s = "ME " + me->getName();
43  ret = dynamic_cast<T>(ob->Clone(s.c_str()));
44  if( ret ) {
45  ret->SetDirectory(0);
46  }
47  } else {
48  ret = dynamic_cast<T>(ob);
49  }
50  } else {
51  ret = 0;
52  }
53  } else {
54  if( !clone ) {
55  ret = 0;
56  }
57  }
58  return ret;
59  }
const std::string & getName(void) const
get name of ME
T * clone(const T *tp)
Definition: Ptr.h:42
string s
Definition: asciidump.py:422
static void UtilsClient::maskBinContent ( const MonitorElement me,
const int  ix,
const int  iy 
)
inlinestatic

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 EBSummaryClient::analyze(), EESummaryClient::analyze(), EBLaserClient::analyze(), EELaserClient::analyze(), EELedClient::analyze(), EBTimingClient::analyze(), EETimingClient::analyze(), EBPedestalOnlineClient::analyze(), EEIntegrityClient::analyze(), EEPedestalClient::analyze(), EBPedestalClient::analyze(), EBTestPulseClient::analyze(), EETestPulseClient::analyze(), EBIntegrityClient::analyze(), and EEPedestalOnlineClient::analyze().

189  {
190  if ( me ) {
191  float val = me->getBinContent(ix, iy);
192  // 0/3 = red/dark red
193  // 1/4 = green/dark green
194  // 2/5 = yellow/dark yellow
195  // 6 = unknown
196  if ( val >= 0. && val <= 2. ) {
197  const_cast<MonitorElement*>(me)->setBinContent(ix, iy, val+3);
198  }
199  }
200  }
double getBinContent(int binx) const
get content of bin (1-D)
template<class T >
template< class T > static void UtilsClient::printBadChannels ( const MonitorElement me,
const T *  hi,
bool  positive_only = false 
)
inlinestatic

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.

67  {
68  if ( ! me ) {
69  std::cout << "printBadChannels() failed, NULL pointer to MonitorElement !"
70  << std::endl;
71  return;
72  }
73  if ( ! hi ) {
74  std::cout << "printBadChannels() failed, NULL pointer to ROOT histogram !"
75  << std::endl;
76  return;
77  }
78  bool title = false;
79  TProfile2D* hj = dynamic_cast<TProfile2D*>(const_cast<T*>(hi));
80  int kx = -1;
81  int ky = -1;
82  for ( int ix = 1; ix <= me->getNbinsX(); ix++ ) {
83  int jx = ix * hi->GetNbinsX() / me->getNbinsX();
84  if ( jx == kx ) continue;
85  kx = jx;
86  for ( int iy = 1; iy <= me->getNbinsY(); iy++ ) {
87  int jy = iy * hi->GetNbinsY() / me->getNbinsY();
88  if ( jy == ky ) continue;
89  ky = jy;
90  if ( positive_only ) {
91  if ( hi->GetBinContent(hi->GetBin(jx, jy)) <= 0 ) continue;
92  } else {
93  float val = me->getBinContent( ix, iy );
94  // 0/3 = red/dark red
95  // 1/4 = green/dark green
96  // 2/5 = yellow/dark yellow
97  // 6 = unknown
98  if ( val == 6 ) continue;
99  if ( int(val) % 3 != 0 ) continue;
100  }
101  if ( ! title ) {
102  std::cout << " Channels failing \"" << me->getName() << "\""
103  << " (" << hi->GetName() << ") "
104  << std::endl << std::endl;
105  title = true;
106  }
107  std::cout << " ("
108  << hi->GetXaxis()->GetBinUpEdge(jx)
109  << ", "
110  << hi->GetYaxis()->GetBinUpEdge(jy);
111  if ( hj )
112  std::cout << ", "
113  << hj->GetBinEntries(hj->GetBin(jx, jy));
114  std::cout << ") = "
115  << hi->GetBinContent(hi->GetBin(jx, jy))
116  << " +- "
117  << hi->GetBinError(hi->GetBin(jx, jy))
118  << std::endl;
119  }
120  }
121  if ( title ) std::cout << std::endl;
122  return;
123  }
const std::string & getName(void) const
get name of ME
int getNbinsY(void) const
get # of bins in Y-axis
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
tuple cout
Definition: gather_cfg.py:41