CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQM/CSCMonitorModule/interface/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 std::string 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       
00078       virtual ~HistoDef() { }
00079 
00084       const HistoId getId() const { return id; }
00085 
00090       const HistoName&  getHistoName() const { return h::names[id]; }
00091 
00098       virtual const std::string getName() const { return getHistoName(); }
00099 
00105       const std::string getFullPath() const {
00106         std::string path(getPath());
00107         if (path.size() > 0) path.append("/");
00108         path.append(getName());
00109         return path;
00110       }
00111 
00117       const bool operator== (const HistoDef& t) const {
00118         if (getId()      != t.getId())      return false;
00119         if (getDDUId()   != t.getDDUId())   return false;
00120         if (getCrateId() != t.getCrateId()) return false;
00121         if (getDMBId()   != t.getDMBId())   return false;
00122         if (getAddId()   != t.getAddId())   return false;
00123         return true;
00124       }
00125 
00131       const HistoDef& operator= (const HistoDef& t) {
00132         id  = t.getId();
00133         return *this;
00134       }
00135 
00141       const bool operator< (const HistoDef& t) const {
00142         if (getId()      < t.getId())       return true; 
00143         if (getDDUId()   < t.getDDUId())    return true;
00144         if (getCrateId() < t.getCrateId())  return true;
00145         if (getDMBId()   < t.getDMBId())    return true;
00146         if (getAddId()   < t.getAddId())    return true;
00147         return false;
00148       }
00149 
00156       friend std::ostream& operator<<(std::ostream& out, const HistoDef& t) {
00157         return out << t.getFullPath();
00158       }
00159 
00164       virtual const std::string getPath() const { return ""; }
00165 
00170       virtual const HwId getCrateId() const { return  0; }
00171 
00176       virtual const HwId getDMBId() const { return  0; }
00177 
00183       virtual const HwId getAddId() const { return  0; }
00184 
00189       virtual const HwId getDDUId() const { return  0; }
00190 
00196       virtual const std::string processTitle(const std::string& p_title) const {
00197         return p_title;
00198       }
00199 
00206       static const bool getHistoIdByName(const std::string& p_name, HistoId& p_id) {
00207         for (HistoId i = 0; i < h::namesSize; i++) {
00208           if (p_name.compare(h::names[i]) == 0) {
00209             p_id = i;
00210             return true;
00211           }
00212         }
00213         return false;
00214       }
00215 
00221       static const std::string getHistoKeyById(const HistoId& p_id) {
00222         return h::keys[p_id];
00223       }
00224 
00231       static const std::string processName(const HistoName& p_name, const HwId p_id) {
00232         if (Utility::regexMatch(REGEXP_ONDEMAND, p_name)) {
00233           return Form(p_name.c_str(), p_id);
00234         }
00235         return p_name;
00236       }
00237 
00238   };
00239 
00244   class EMUHistoDef : public HistoDef {
00245 
00246     public:
00247 
00253       EMUHistoDef(const HistoId p_id) : HistoDef(p_id) { }
00254 
00255   };
00256 
00261   class DDUHistoDef : public HistoDef {
00262 
00263     private:
00264 
00265       HwId dduId;
00266 
00267     public:
00268 
00275       DDUHistoDef(const HistoId p_id, const HwId p_dduId) : HistoDef(p_id), dduId(p_dduId) { }
00276       const HwId getDDUId() const { return dduId; }
00277       const std::string getPath() const { return getPath(dduId); }
00278 
00284       static const std::string getPath(const HwId p_dduId) { 
00285         return Form(PATH_DDU, p_dduId); 
00286       }
00287 
00294       const DDUHistoDef& operator= (const DDUHistoDef& t) {
00295         HistoDef *h1 = const_cast<DDUHistoDef*>(this);
00296         const HistoDef *h2 = &t;
00297         *h1 = *h2;
00298         dduId   = t.getDDUId();
00299         return *this;
00300       }
00301 
00302       const std::string processTitle(const std::string& p_title) const {
00303         return processName(p_title.c_str(), getDDUId());
00304       }
00305 
00306   };
00307 
00312   class CSCHistoDef : public HistoDef {
00313 
00314     private:
00315 
00317       HwId crateId;
00319       HwId dmbId;
00321       HwId addId;
00322 
00323     public:
00324 
00334       CSCHistoDef(const HistoId p_id, const HwId p_crateId, const HwId p_dmbId, const HwId p_addId = 0) : 
00335         HistoDef(p_id), crateId(p_crateId), dmbId(p_dmbId), addId(p_addId) { }
00336 
00337       const HwId getCrateId() const { return crateId; }
00338       const HwId getDMBId()   const { return dmbId; }
00339       const HwId getAddId()   const { return addId; }
00340       const std::string getName() const { return processName(getHistoName(), getAddId()); }
00341       const std::string getPath() const { return getPath(crateId, dmbId); }
00342 
00349       static const std::string getPath(const HwId p_crateId, const HwId p_dmbId) { 
00350         return Form(PATH_CSC, p_crateId, p_dmbId); 
00351       }
00352 
00359       const CSCHistoDef& operator= (const CSCHistoDef& t) {
00360         HistoDef *h1 = const_cast<CSCHistoDef*>(this);
00361         const HistoDef *h2 = &t;
00362         *h1 = *h2;
00363         crateId = t.getCrateId();
00364         dmbId   = t.getDMBId();
00365         addId   = t.getAddId();
00366         return *this;
00367       }
00368 
00369       const std::string processTitle(const std::string& p_title) const {
00370         return processName(p_title.c_str(), getAddId());
00371       }
00372 
00373 
00374   };
00375 
00380   class ParHistoDef : public HistoDef {
00381 
00382     private:
00383 
00387       HistoName name;
00388 
00389 
00390     public:
00391 
00397       ParHistoDef(const HistoName& p_name) : HistoDef(Utility::fastHash(p_name.c_str())), name(p_name) { }
00398 
00404       ParHistoDef(const HistoId p_id) : HistoDef(p_id) {
00405         name = HistoDef::getHistoName();
00406       }
00407 
00408       const HistoName&  getHistoName() const { return name; }
00409 
00410   };
00411 
00412   static const std::type_info& EMUHistoDefT = typeid(cscdqm::EMUHistoDef);
00413   static const std::type_info& DDUHistoDefT = typeid(cscdqm::DDUHistoDef);
00414   static const std::type_info& CSCHistoDefT = typeid(cscdqm::CSCHistoDef);
00415   static const std::type_info& ParHistoDefT = typeid(cscdqm::ParHistoDef);
00416 
00417 }
00418 
00419 #endif
00420