CMS 3D CMS Logo

CSCDQM_HistoDef.h

Go to the documentation of this file.
00001 /*
00002  * =====================================================================================
00003  *
00004  *       Filename:  HistoDef.h
00005  *
00006  *    Description:  Histo Type Classes that are being used by EventProcessor
00007  *    to request histograms. 
00008  *
00009  *        Version:  1.0
00010  *        Created:  10/03/2008 11:54:31 AM
00011  *       Revision:  none
00012  *       Compiler:  gcc
00013  *
00014  *         Author:  Valdas Rapsevicius (VR), Valdas.Rapsevicius@cern.ch
00015  *        Company:  CERN, CH
00016  *
00017  * =====================================================================================
00018  */
00019 
00020 #ifndef CSCDQM_HistoDef_H
00021 #define CSCDQM_HistoDef_H 
00022 
00023 #include <string>
00024 #include <iostream>  
00025 
00026 #include "DQM/CSCMonitorModule/interface/CSCDQM_Utility.h"
00027 #include "DQM/CSCMonitorModule/interface/CSCDQM_Logger.h"
00028 
00029 namespace cscdqm {
00030 
00032   typedef char* HistoName; 
00033 
00035   typedef unsigned int HistoId; 
00036 
00038   typedef unsigned int HwId; 
00039 
00040   namespace h {
00042     const HistoName HISTO_SKIP = "0";
00043   }
00044 
00046   static const char PATH_DDU[]     = "DDU_%02d";
00047 
00049   static const char PATH_CSC[]     = "CSC_%03d_%02d";
00050 
00051   static const TPRegexp REGEXP_ONDEMAND("^.*%d.*$");
00052 
00053   #include "DQM/CSCMonitorModule/interface/CSCDQM_HistoNames.h"
00054 
00059   class HistoDef {
00060 
00061     private:
00062 
00064       HistoId id;
00065 
00066     public:
00067 
00073       HistoDef(const HistoId p_id) : id(p_id) { }
00074       
00079       const HistoId getId() const { return id; }
00080 
00085       const HistoName&  getHistoName() const { return h::names[id]; }
00086 
00093       virtual const std::string getName() const { return getHistoName(); }
00094 
00100       const std::string getFullPath() const {
00101         std::string path(getPath());
00102         path.append("/");
00103         path.append(getName());
00104         return path;
00105       }
00106 
00112       const bool operator== (const HistoDef& t) const {
00113         if (getId()      != t.getId())      return false;
00114         if (getDDUId()   != t.getDDUId())   return false;
00115         if (getCrateId() != t.getCrateId()) return false;
00116         if (getDMBId()   != t.getDMBId())   return false;
00117         if (getAddId()   != t.getAddId())   return false;
00118         return true;
00119       }
00120 
00126       const HistoDef& operator= (const HistoDef& t) {
00127         id  = t.getId();
00128         return *this;
00129       }
00130 
00136       const bool operator< (const HistoDef& t) const {
00137         if (getId()      < t.getId())       return true; 
00138         if (getDDUId()   < t.getDDUId())    return true;
00139         if (getCrateId() < t.getCrateId())  return true;
00140         if (getDMBId()   < t.getDMBId())    return true;
00141         if (getAddId()   < t.getAddId())    return true;
00142         return false;
00143       }
00144 
00151       friend std::ostream& operator<<(std::ostream& out, const HistoDef& t) {
00152         return out << t.getFullPath();
00153       }
00154 
00159       virtual const std::string getPath() const { return ""; }
00160 
00165       virtual const HwId getCrateId() const { return  0; }
00166 
00171       virtual const HwId getDMBId() const { return  0; }
00172 
00178       virtual const HwId getAddId() const { return  0; }
00179 
00184       virtual const HwId getDDUId() const { return  0; }
00185 
00191       virtual const std::string processTitle(const std::string& p_title) const {
00192         return p_title;
00193       }
00194 
00201       static const bool getHistoIdByName(const std::string& p_name, HistoId& p_id) {
00202         for (HistoId i = 0; i < h::namesSize; i++) {
00203           if (p_name.compare(h::names[i]) == 0) {
00204             p_id = i;
00205             return true;
00206           }
00207         }
00208         return false;
00209       }
00210 
00217       static const std::string processName(const HistoName& p_name, const HwId p_id) {
00218         if (Utility::regexMatch(REGEXP_ONDEMAND, p_name)) {
00219           return Form(p_name, p_id);
00220         }
00221         return p_name;
00222       }
00223 
00224   };
00225 
00230   class EMUHistoDef : public HistoDef {
00231 
00232     public:
00233 
00239       EMUHistoDef(const HistoId p_id) : HistoDef(p_id) { }
00240 
00241   };
00242 
00247   class DDUHistoDef : public HistoDef {
00248 
00249     private:
00250 
00251       HwId dduId;
00252 
00253     public:
00254 
00261       DDUHistoDef(const HistoId p_id, const HwId p_dduId) : HistoDef(p_id), dduId(p_dduId) { }
00262       const HwId getDDUId() const { return dduId; }
00263       const std::string getPath() const { return getPath(dduId); }
00264 
00270       static const std::string getPath(const HwId p_dduId) { 
00271         return Form(PATH_DDU, p_dduId); 
00272       }
00273 
00280       const DDUHistoDef& operator= (const DDUHistoDef& t) {
00281         HistoDef *h1 = const_cast<DDUHistoDef*>(this);
00282         const HistoDef *h2 = &t;
00283         *h1 = *h2;
00284         dduId   = t.getDDUId();
00285         return *this;
00286       }
00287 
00288       const std::string processTitle(const std::string& p_title) const {
00289         return processName(const_cast<HistoName>(p_title.c_str()), getDDUId());
00290       }
00291 
00292   };
00293 
00298   class CSCHistoDef : public HistoDef {
00299 
00300     private:
00301 
00303       HwId crateId;
00305       HwId dmbId;
00307       HwId addId;
00308 
00309     public:
00310 
00320       CSCHistoDef(const HistoId p_id, const HwId p_crateId, const HwId p_dmbId, const HwId p_addId = 0) : 
00321         HistoDef(p_id), crateId(p_crateId), dmbId(p_dmbId), addId(p_addId) { }
00322 
00323       const HwId getCrateId() const { return crateId; }
00324       const HwId getDMBId()   const { return dmbId; }
00325       const HwId getAddId()   const { return addId; }
00326       const std::string getName() const { return processName(getHistoName(), getAddId()); }
00327       const std::string getPath() const { return getPath(crateId, dmbId); }
00328 
00335       static const std::string getPath(const HwId p_crateId, const HwId p_dmbId) { 
00336         return Form(PATH_CSC, p_crateId, p_dmbId); 
00337       }
00338 
00345       const CSCHistoDef& operator= (const CSCHistoDef& t) {
00346         HistoDef *h1 = const_cast<CSCHistoDef*>(this);
00347         const HistoDef *h2 = &t;
00348         *h1 = *h2;
00349         crateId = t.getCrateId();
00350         dmbId   = t.getDMBId();
00351         addId   = t.getAddId();
00352         return *this;
00353       }
00354 
00355       const std::string processTitle(const std::string& p_title) const {
00356         return processName(const_cast<HistoName>(p_title.c_str()), getAddId());
00357       }
00358 
00359 
00360   };
00361 
00366   class ParHistoDef : public HistoDef {
00367 
00368     public:
00369 
00373       HistoName name;
00374 
00380       ParHistoDef(const HistoName p_name) : HistoDef(Utility::fastHash(p_name)), name(p_name) { }
00381 
00387       ParHistoDef(const HistoId p_id) : HistoDef(p_id) {
00388         name = HistoDef::getHistoName();
00389       }
00390 
00391       const HistoName&  getHistoName() const { return name; }
00392 
00393   };
00394 
00395   static const std::type_info& EMUHistoDefT = typeid(cscdqm::EMUHistoDef);
00396   static const std::type_info& DDUHistoDefT = typeid(cscdqm::DDUHistoDef);
00397   static const std::type_info& CSCHistoDefT = typeid(cscdqm::CSCHistoDef);
00398   static const std::type_info& ParHistoDefT = typeid(cscdqm::ParHistoDef);
00399 
00400 }
00401 
00402 #endif
00403 

Generated on Tue Jun 9 17:32:32 2009 for CMSSW by  doxygen 1.5.4