Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-31 22:35:53

0001 #ifndef DQM_RPCMonitorDigi_RPCLinkSynchroStat_H
0002 #define DQM_RPCMonitorDigi_RPCLinkSynchroStat_H
0003 
0004 #include "CondFormats/RPCObjects/interface/LinkBoardElectronicIndex.h"
0005 #include "DataFormats/RPCDigi/interface/RPCRawSynchro.h"
0006 #include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
0007 
0008 #include <cmath>
0009 #include <vector>
0010 
0011 class RPCLinkSynchroStat {
0012 public:
0013   RPCLinkSynchroStat(bool useFirstHitOnly);
0014 
0015   virtual ~RPCLinkSynchroStat() {}
0016 
0017   void init(const RPCReadOutMapping *theCabling, bool addChamberInfo);
0018 
0019   void add(const RPCRawSynchro::ProdItem &counts, std::vector<LinkBoardElectronicIndex> &problems);
0020 
0021   void add(const std::string &lbName, const unsigned int *hits);
0022 
0023   std::string dumpDelays();
0024 
0025 protected:
0026   class LinkBoard {
0027   public:
0028     LinkBoard(const std::string &n) : theName(n) {}
0029     const std::string &name() const { return theName; }
0030     typedef std::pair<std::string, std::string> ChamberAndPartition;
0031     int add(const ChamberAndPartition &part);
0032     int add(const LinkBoardElectronicIndex &ele);
0033     const std::vector<LinkBoardElectronicIndex> &paths() const { return theElePaths; }
0034     const std::vector<ChamberAndPartition> &chamberAndPartitions() const { return theChamberAndPartitions; }
0035     bool operator<(const LinkBoard &o) const { return theName < o.theName; }
0036     bool operator==(const LinkBoard &o) const { return (theName == o.theName); }
0037 
0038   private:
0039     std::string theName;
0040     std::vector<ChamberAndPartition> theChamberAndPartitions;
0041     std::vector<LinkBoardElectronicIndex> theElePaths;
0042   };
0043 
0044   class SynchroCounts {
0045   public:
0046     SynchroCounts() : theCounts(std::vector<unsigned int>(8, 0)) {}
0047     SynchroCounts(const unsigned int *hits) : theCounts(std::vector<unsigned int>(hits, hits + 8)) {}
0048 
0049     void increment(unsigned int bxDiff);
0050     void set(unsigned int bxDiff);
0051     unsigned int firstHit() const;
0052 
0053     double rms() const;
0054     double mean() const;
0055     unsigned int sum() const { return mom0(); }
0056 
0057     std::string print() const;
0058     const std::vector<unsigned int> &counts() const { return theCounts; }
0059     bool operator==(const SynchroCounts &) const;
0060     SynchroCounts &operator+=(const SynchroCounts &rhs);
0061 
0062   private:
0063     unsigned int mom0() const;
0064     double mom1() const;
0065     std::vector<unsigned int> theCounts;
0066   };
0067 
0068   typedef std::pair<LinkBoard, SynchroCounts> BoardAndCounts;
0069   struct LessLinkName {
0070     bool operator()(const BoardAndCounts &o1, const BoardAndCounts &o2);
0071   };
0072   struct LessCountSum {
0073     bool operator()(const BoardAndCounts &o1, const BoardAndCounts &o2);
0074   };
0075   struct ShortLinkInfo {
0076     unsigned int idx;
0077     std::vector<unsigned int> hit_paths;
0078     SynchroCounts counts;
0079   };
0080 
0081   bool theUseFirstHitOnly;
0082 
0083   static const unsigned int MAXDCCINDEX = 2;
0084   static const unsigned int DCCINDEXSHIFT = 790;
0085   static const unsigned int MAXRBCINDEX = 35;
0086   static const unsigned int MAXLINKINDEX = 17;
0087   static const unsigned int MAXLBINDEX = 2;
0088   unsigned int theLinkStatNavi[MAXDCCINDEX + 1][MAXRBCINDEX + 1][MAXLINKINDEX + 1][MAXLBINDEX + 1];
0089   std::vector<BoardAndCounts> theLinkStatMap;
0090 
0091   friend class RPCLinkSynchroHistoMaker;
0092 };
0093 #endif