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...
 
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. 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...
 
static void printBadChannels (const MonitorElement *me, TH1 *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 24 of file UtilsClient.h.

Constructor & Destructor Documentation

UtilsClient::UtilsClient ( )
inlineprivate

Definition at line 83 of file UtilsClient.h.

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

Definition at line 84 of file UtilsClient.h.

84 {}; // 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().

202 {
203  if ( me ) {
204  float val = me->getBinContent(ix, iy);
205  // 0/3 = red/dark red
206  // 1/4 = green/dark green
207  // 2/5 = yellow/dark yellow
208  // 6 = unknown
209  if ( val == 0. || val == 2 || val == 6 ) return false;
210  if ( val == 1. || val == 3 || val == 4 || val == 5 ) return true;
211  }
212  return false;
213 }
double getBinContent(int binx) const
get content of bin (1-D)
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, cl, interpolateCardsSimple::histo, NULL, python.connectstrParser::o, AlCaHLTBitMon_ParallelJobs::p, p2, and mathSSE::sqrt().

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

75 {
76  num = -1.; mean = -1.; rms = -1.;
77 
78  if ( !histo ) return false;
79 
80  // TProfile2D does not inherit from TProfile; need two pointers
81 
82  TProfile *p = NULL;
83  TProfile2D *p2 = NULL;
84 
85  int bin = histo->GetBin(ix, iy);
86  char o;
87 
88  TClass *cl = histo->IsA();
89  if( cl == TClass::GetClass("TProfile") ){
90  p = static_cast<TProfile *>(histo);
91  num = p->GetBinEntries(bin);
92  o = *( p->GetErrorOption() );
93  }else if( cl == TClass::GetClass("TProfile2D") ){
94  p2 = static_cast<TProfile2D *>(histo);
95  num = p2->GetBinEntries(bin);
96  o = *( p2->GetErrorOption() );
97  }else
98  return false;
99 
100  if ( num < minEntries ) return false;
101 
102  mean = histo->GetBinContent(ix, iy);
103  if( o == 's' )
104  rms = histo->GetBinError(ix, iy);
105  else if( o == '\0' )
106  rms = histo->GetBinError(ix, iy) * std::sqrt( num );
107  // currently not compatible with other error options!!
108 
109  return true;
110 }
#define NULL
Definition: scimark2.h:8
T sqrt(T t)
Definition: SSEVec.h:46
double p2[4]
Definition: TauolaWrapper.h:90
float cl
Definition: Combine.cc:71
long long int num
Definition: procUtils.cc:71
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().

217 {
218  if ( me ) {
219  float val = me->getBinContent(ix, iy);
220  // 0/3 = red/dark red
221  // 1/4 = green/dark green
222  // 2/5 = yellow/dark yellow
223  // 6 = unknown
224  if ( val == 0. || val == 3 ) return true;
225  return false;
226  }
227  return false;
228 }
double getBinContent(int binx) const
get content of bin (1-D)
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 EBLaserClient::analyze(), EELedClient::analyze(), EELaserClient::analyze(), EBTestPulseClient::analyze(), and EETestPulseClient::analyze().

247 {
248  if ( histo ) {
249  int ichannel = 1;
250  while ( ichannel <= histo->GetNbinsX() ) {
251  double counts = histo->GetBinContent(ichannel, 1);
252  if ( counts > 0 ) return( ichannel );
253  ichannel++;
254  }
255  }
256  return( 1 );
257 }
template<class T >
T UtilsClient::getHisto ( const MonitorElement me,
bool  clone = false,
T  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 91 of file UtilsClient.h.

References MonitorElement::getName(), run_regression::ret, and alignCSCRings::s.

Referenced by EBSummaryClient::analyze(), EESummaryClient::analyze(), EBStatusFlagsClient::analyze(), EELaserClient::analyze(), EELedClient::analyze(), EEPedestalOnlineClient::analyze(), EEPedestalClient::analyze(), EECosmicClient::analyze(), EETestPulseClient::analyze(), EEIntegrityClient::analyze(), EBIntegrityClient::analyze(), EBTestPulseClient::analyze(), EBPedestalClient::analyze(), EEOccupancyClient::analyze(), EBClusterClient::analyze(), EEClusterClient::analyze(), EETriggerTowerClient::analyze(), and EETimingClient::analyze().

92 {
93  if( me ) {
94  TObject* ob = const_cast<MonitorElement*>(me)->getRootObject();
95  if( ob ) {
96  if( clone ) {
97  if( ret ) {
98  delete ret;
99  }
100  std::string s = "ME " + me->getName();
101  ret = dynamic_cast<T>(ob->Clone(s.c_str()));
102  if( ret ) {
103  ret->SetDirectory(0);
104  }
105  } else {
106  ret = dynamic_cast<T>(ob);
107  }
108  } else {
109  ret = 0;
110  }
111  } else {
112  if( !clone ) {
113  ret = 0;
114  }
115  }
116  return ret;
117 }
const std::string & getName(void) const
get name of ME
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
long double T
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 EBSummaryClient::analyze(), EESummaryClient::analyze(), EBLaserClient::analyze(), EELaserClient::analyze(), EELedClient::analyze(), EBTimingClient::analyze(), EBIntegrityClient::analyze(), EBPedestalOnlineClient::analyze(), EETestPulseClient::analyze(), EBPedestalClient::analyze(), EEPedestalOnlineClient::analyze(), EBTestPulseClient::analyze(), EEIntegrityClient::analyze(), EEPedestalClient::analyze(), and EETimingClient::analyze().

232 {
233  if ( me ) {
234  float val = me->getBinContent(ix, iy);
235  // 0/3 = red/dark red
236  // 1/4 = green/dark green
237  // 2/5 = yellow/dark yellow
238  // 6 = unknown
239  if ( val >= 0. && val <= 2. ) {
240  const_cast<MonitorElement*>(me)->setBinContent(ix, iy, val+3);
241  }
242  }
243 }
double getBinContent(int binx) const
get content of bin (1-D)
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.

15 {
16  if ( ! me ) {
17  std::cout << "printBadChannels() failed, NULL pointer to MonitorElement !"
18  << std::endl;
19  return;
20  }
21  if ( ! hi ) {
22  std::cout << "printBadChannels() failed, NULL pointer to ROOT histogram !"
23  << std::endl;
24  return;
25  }
26  bool title = false;
27  TProfile2D* hj = dynamic_cast<TProfile2D*>(hi);
28  int kx = -1;
29  int ky = -1;
30  for ( int ix = 1; ix <= me->getNbinsX(); ix++ ) {
31  int jx = ix * hi->GetNbinsX() / me->getNbinsX();
32  if ( jx == kx ) continue;
33  kx = jx;
34  for ( int iy = 1; iy <= me->getNbinsY(); iy++ ) {
35  int jy = iy * hi->GetNbinsY() / me->getNbinsY();
36  if ( jy == ky ) continue;
37  ky = jy;
38  if ( positive_only ) {
39  if ( hi->GetBinContent(hi->GetBin(jx, jy)) <= 0 ) continue;
40  } else {
41  float val = me->getBinContent( ix, iy );
42  // 0/3 = red/dark red
43  // 1/4 = green/dark green
44  // 2/5 = yellow/dark yellow
45  // 6 = unknown
46  if ( val == 6 ) continue;
47  if ( int(val) % 3 != 0 ) continue;
48  }
49  if ( ! title ) {
50  std::cout << " Channels failing \"" << me->getName() << "\""
51  << " (" << hi->GetName() << ") "
52  << std::endl << std::endl;
53  title = true;
54  }
55  std::cout << " ("
56  << hi->GetXaxis()->GetBinUpEdge(jx)
57  << ", "
58  << hi->GetYaxis()->GetBinUpEdge(jy);
59  if ( hj )
60  std::cout << ", "
61  << hj->GetBinEntries(hj->GetBin(jx, jy));
62  std::cout << ") = "
63  << hi->GetBinContent(hi->GetBin(jx, jy))
64  << " +- "
65  << hi->GetBinError(hi->GetBin(jx, jy))
66  << std::endl;
67  }
68  }
69  if ( title ) std::cout << std::endl;
70  return;
71 }
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:121