CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQMServices/Diagnostic/interface/HDQMInspector.h

Go to the documentation of this file.
00001 #ifndef HDQMInspector_h
00002 #define HDQMInspector_h
00003 
00004 //---------------------------------------------------------//
00005 //
00006 //-- extract summary informations from historic DB --
00007 //-- plot summary informations vs run number or vs detID --
00008 //
00009 //---------------------------------------------------------//
00010 //---------------------------------------------------------//
00011 // 
00012 //  12-08-2008 - domenico.giordano@cern.ch 
00013 //  12-06-2008 - anne-catherine.le.bihan@cern.ch 
00014 //
00015 //---------------------------------------------------------//
00016 
00017 #include "vector"
00018 #include "string"
00019 #include "iostream"
00020 #include <fstream>
00021 #include "cmath"
00022 #include "CondCore/Utilities/interface/CondCachedIter.h"
00023 #include "CondFormats/DQMObjects/interface/HDQMSummary.h"
00024 #include "DQMServices/Diagnostic/interface/HDQMInspectorConfigBase.h"
00025 #include "TFile.h"
00026 #include "TGraphErrors.h"
00027 
00028 class HDQMInspector
00029 {
00030  public:  
00031   HDQMInspector():
00032     DBName_(""),
00033     DBTag_(""),
00034     DBauth_(""),
00035     Iterator(0),
00036     iDebug(0),
00037     iDoStat(0),
00038     fSkip99s(false),
00039     fSkip0s(false),
00040     fHDQMInspectorConfig(0x0),
00041     fSep("@")
00042     {
00043     };
00044   
00045   HDQMInspector(const HDQMInspectorConfigBase* InConfig):
00046     DBName_(""),
00047     DBTag_(""),
00048     DBauth_(""),
00049     Iterator(0),
00050     iDebug(0),
00051     iDoStat(0),
00052     fSkip99s(false),
00053     fSkip0s(false),
00054     fHDQMInspectorConfig(InConfig),
00055     fSep("@")
00056     {
00057     };
00058   
00059   virtual ~HDQMInspector() {
00060     delete Iterator;
00061   };
00062   struct DetIdItemList {
00063     unsigned int detid;
00064     std::vector<std::string> items;
00065     std::vector<float> values;
00066   };
00067 
00068   void setDB(const std::string & DBName, const std::string & DBTag, const std::string & DBauth = "");
00069   void createTrend(const std::string ListItems, const std::string CanvasName="", const int logy=0, const std::string Conditions="",
00070                    std::string const& Labels="", const unsigned int firstRun=1, const unsigned int lastRun=0xFFFFFFFE, int const UseYRange = 0, double const& YMin = 999999, double const& YMax = -999999);
00071   void createTrendLastRuns(const std::string ListItems, const std::string CanvasName="",
00072                            const int logy=0, const std::string Conditions="", std::string const& Labels="", const unsigned int nRuns=10, int const UseYRange = 0, double const& YMin = 999999, double const& YMax = -999999); 
00073   void setDebug(int i){iDebug=i;}
00074   void setDoStat(int i){iDoStat=i;}
00075   void setBlackList(std::string const& ListItems);
00076   void setWhiteList(std::string const& ListItems);
00077   std::string readListFromFile(const std::string & listFileName);
00078   void setSkip99s (bool const in) {
00079     fSkip99s = in;
00080     return;
00081   }
00082   void setSkip0s (bool const in) {
00083     fSkip0s = in;
00084     return;
00085   }
00086   void closeFile ()
00087   { 
00088     if( fOutFile ) {
00089       fOutFile->Close();
00090     }
00091   }
00092   double findGraphMax(TGraphErrors*);
00093   double findGraphMin(TGraphErrors*);
00094   void setSeparator(std::string const in) {
00095     fSep = in;
00096     return;
00097   }
00098 
00099   
00100   inline std::vector<unsigned int> getRuns() { return vRun_;}
00101   inline std::vector<float> getSummary()     { return vSummary_;}
00102  
00103   inline std::vector<std::string>  getListItems() { return vlistItems_;}
00104   inline std::vector<unsigned int> getvDetId()    { return vdetId_;}
00105  
00106 private:
00107 
00108   void style();
00109   void plot(size_t& nPads, std::string CanvasName, int logy=0, std::string const& Labels = "", int const UseYRange = 0, double const XMin = 999999, double const YMin = -999999);
00110   void accessDB();
00111   void InitializeIOVList();
00112   bool setRange(unsigned int& firstRun, unsigned int& lastRun);
00113   void setItems(std::string);
00114   size_t unpackItems(std::string& );
00115   void unpackConditions(std::string&, std::vector<DetIdItemList>&);
00116   bool ApplyConditions(std::string&, std::vector<DetIdItemList>&);
00117   bool isListed(unsigned int run, std::vector<unsigned int>& vList);
00118 
00119 
00120   std::string DBName_, DBTag_, DBauth_;
00121   
00122   CondCachedIter<HDQMSummary>* Iterator; 
00123   
00124   std::vector<unsigned int> iovList;
00125   std::vector<unsigned int> blackList;
00126   std::vector<unsigned int> whiteList;
00127   
00128   std::vector<unsigned int> vRun_;
00129   std::vector<float> vSummary_;
00130   std::vector<DetIdItemList> vDetIdItemList_;
00131   std::vector<std::string> vlistItems_;
00132   std::vector<unsigned int> vdetId_;   
00133 
00134   int iDebug;
00135   int iDoStat;
00136   bool fSkip99s;
00137   bool fSkip0s;
00138 
00139   const HDQMInspectorConfigBase* fHDQMInspectorConfig;
00140 
00141   std::string fSep;
00142 
00143 public:
00144   TFile *fOutFile;
00145   
00146 };
00147 
00148 #endif