CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DQM/RPCMonitorClient/interface/RPCLinkSynchroStat.h

Go to the documentation of this file.
00001 #ifndef DQM_RPCMonitorClient_RPCLinkSynchroStat_H
00002 #define DQM_RPCMonitorClient_RPCLinkSynchroStat_H
00003 
00004 #include <map>
00005 #include <cmath>
00006 #include <vector>
00007 #include "CondFormats/RPCObjects/interface/LinkBoardElectronicIndex.h"
00008 #include "DataFormats/RPCDigi/interface/RPCRawSynchro.h"
00009 
00010 class RPCReadOutMapping;
00011 
00012 class RPCLinkSynchroStat {
00013 public:
00014 
00015   RPCLinkSynchroStat(bool useFirstHitOnly);
00016 
00017   virtual ~RPCLinkSynchroStat(){}
00018 
00019   void init(const RPCReadOutMapping* theCabling, bool addChamberInfo);
00020 
00021   void add(const RPCRawSynchro::ProdItem & counts, std::vector<LinkBoardElectronicIndex> & problems);
00022 
00023   void add(const std::string & lbName, const unsigned int *hits);
00024 
00025   std::string dumpDelays();
00026 
00027 protected:
00028 
00029   class LinkBoard {
00030   public:
00031     LinkBoard(const std::string & n) : theName(n) {}
00032     const std::string & name() const { return theName; }
00033     typedef std::pair<std::string,std::string> ChamberAndPartition;
00034     int add(const ChamberAndPartition & part);
00035     int add(const LinkBoardElectronicIndex & ele);
00036     const std::vector<LinkBoardElectronicIndex> & paths() const { return theElePaths; } 
00037     const std::vector<ChamberAndPartition> & chamberAndPartitions() const { return theChamberAndPartitions; }
00038     bool operator<(const LinkBoard &o) const {return theName < o.theName; }
00039     bool operator==(const LinkBoard &o) const { return (theName == o.theName); }
00040   private:
00041     std::string theName;
00042     std::vector<ChamberAndPartition> theChamberAndPartitions;
00043     std::vector<LinkBoardElectronicIndex> theElePaths;
00044   };
00045 
00046   class SynchroCounts {
00047   public:
00048     SynchroCounts() : theCounts(std::vector<unsigned int>(8,0)) {}
00049     SynchroCounts(const unsigned int *hits) : theCounts(std::vector<unsigned int>(hits,hits+8)) {}
00050     
00051     void increment(unsigned int bxDiff);
00052     void set(unsigned int bxDiff);
00053     unsigned int firstHit() const;
00054 
00055     double rms() const;
00056     double mean() const;
00057     unsigned int sum() const { return mom0(); }
00058 
00059     std::string print() const;
00060     const std::vector<unsigned int> & counts() const { return theCounts; }
00061     bool operator==(const SynchroCounts &) const;
00062     SynchroCounts & operator+=(const SynchroCounts &rhs);
00063   private:
00064     unsigned int  mom0() const;
00065     double mom1() const;
00066     std::vector<unsigned int> theCounts;
00067   };
00068 
00069   typedef std::pair<LinkBoard, SynchroCounts> BoardAndCounts;
00070   struct LessLinkName { bool operator()(const BoardAndCounts & o1, const BoardAndCounts & o2); };
00071   struct LessCountSum { bool operator()(const BoardAndCounts & o1, const BoardAndCounts & o2); };
00072   struct ShortLinkInfo{ unsigned int idx; std::vector<unsigned int> hit_paths; SynchroCounts counts; };
00073 
00074   bool theUseFirstHitOnly;
00075 
00076   static const unsigned int MAXDCCINDEX=2;
00077   static const unsigned int DCCINDEXSHIFT=790;
00078   static const unsigned int MAXRBCINDEX=35;
00079   static const unsigned int MAXLINKINDEX=17;
00080   static const unsigned int MAXLBINDEX=2; 
00081   unsigned int theLinkStatNavi[MAXDCCINDEX+1][MAXRBCINDEX+1][MAXLINKINDEX+1][MAXLBINDEX+1];
00082   std::vector<BoardAndCounts> theLinkStatMap;
00083   
00084   friend class RPCLinkSynchroHistoMaker;
00085 };
00086 #endif