CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DQM/EcalCommon/interface/UtilsClient.h

Go to the documentation of this file.
00001 #ifndef UtilsClient_H
00002 #define UtilsClient_H
00003 
00016 #include "DQMServices/Core/interface/MonitorElement.h"
00017 #include "TObject.h"
00018 
00019 class TH1;
00020 class TProfile;
00021 class TProfile2D;
00022 class TClass;
00023 
00024 class UtilsClient {
00025 
00026  public:
00027 
00034   template<class T> static T getHisto( const MonitorElement* me, bool clone = false, T ret = 0);
00035 
00042   static void printBadChannels( const MonitorElement* me, TH1* hi, bool positive_only = false );
00043 
00052   static bool getBinStatistics( TH1* histo, const int ix, const int iy, float& num, float& mean, float& rms, float minEntries = 1. );
00053 
00059   static bool getBinQuality( const MonitorElement* me, const int ix, const int iy );
00060 
00066   static bool getBinStatus( const MonitorElement* me, const int ix, const int iy );
00067 
00073   static void maskBinContent( const MonitorElement* me, const int ix, const int iy );
00074 
00079   static int getFirstNonEmptyChannel( const TProfile2D* histo );
00080 
00081  private:
00082 
00083   UtilsClient() {}; // Hidden to force static use
00084   ~UtilsClient() {}; // Hidden to force static use
00085 
00086 };
00087 
00088 template<class T>
00089 inline
00090 T
00091 UtilsClient::getHisto( const MonitorElement* me, bool clone, T ret)
00092 {
00093   if( me ) {
00094     TObject* ob = const_cast<MonitorElement*>(me)->getRootObject();
00095     if( ob ) { 
00096       if( clone ) {
00097         if( ret ) {
00098           delete ret;
00099         }
00100         std::string s = "ME " + me->getName();
00101         ret = dynamic_cast<T>(ob->Clone(s.c_str())); 
00102         if( ret ) {
00103           ret->SetDirectory(0);
00104         }
00105       } else {
00106         ret = dynamic_cast<T>(ob); 
00107       }
00108     } else {
00109       ret = 0;
00110     }
00111   } else {
00112     if( !clone ) {
00113       ret = 0;
00114     }
00115   }
00116   return ret;
00117 }
00118 
00119 #endif