CMS 3D CMS Logo

SiStripSpyUtilities.h
Go to the documentation of this file.
1 #ifndef DQM_SiStripMonitorHardware_SiStripSpyUtilities_H
2 #define DQM_SiStripMonitorHardware_SiStripSpyUtilities_H
3 
4 // Standard includes.
5 //#include <utility>
6 #include <string>
7 
10 
13 
18 
19 // Other classes
20 class EventSetup;
21 
22 namespace sistrip {
23 
24  class SpyUtilities {
25  public:
26  struct Frame {
27  uint32_t detId;
28  uint16_t digitalLow;
29  uint16_t digitalHigh;
30  uint16_t firstHeaderBit;
31  uint16_t firstTrailerBit;
32  float baseline;
33  std::pair<bool, bool> apvErrorBit;
34  std::pair<uint8_t, uint8_t> apvAddress;
35  };
36 
37  struct FrameQuality {
38  uint16_t minDigiRange;
39  uint16_t maxDigiRange;
40  uint16_t minZeroLight;
41  uint16_t maxZeroLight;
42  uint16_t minTickHeight;
43  uint16_t maxTickHeight;
44  };
45 
46  SpyUtilities();
47  ~SpyUtilities();
48 
49  //get cabling for an eventSetup: internal counter to see if cabling has changed.
52 
55 
56  //fill variables from frame
57  static const Frame extractFrameInfo(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis,
58  bool aPrintDebug = false);
59 
60  static void getMajorityHeader(const edm::DetSetVector<SiStripRawDigi>* aInputDigis,
61  uint16_t& firstHeaderBit,
62  bool printResult = true);
63 
64  //check frame is valid
65  static const bool isValid(const Frame& aFrame, const FrameQuality& aQuality, const uint16_t aExpectedPos);
66 
67  //extract range, threshold and apvAddress
68  static const uint16_t range(const Frame& aFrame);
69 
70  static const uint16_t threshold(const Frame& aFrame);
71 
72  static const uint8_t extractAPVaddress(const Frame& aFrame);
73 
74  //find position of the first header and trailer bit
75  static const uint16_t findHeaderBits(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis,
76  const uint16_t threshold);
77 
78  static const uint16_t findTrailerBits(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis,
79  const uint16_t threshold);
80 
81  //find both APV addresses and error bits
82  static const std::pair<bool, bool> findAPVErrorBits(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis,
83  const uint16_t threshold,
84  const uint16_t aFirstBits);
85 
86  static const std::pair<uint8_t, uint8_t> findAPVAddresses(
88  const uint16_t threshold,
89  const uint16_t aFirstBits);
90 
91  static std::string print(const Frame& aFrame, std::string aErr);
92 
93  static void fedIndex(uint32_t aFedIndex, uint16_t& aFedId, uint16_t& aFedChannel);
94 
95  static std::pair<uint16_t, uint32_t> findMajorityValue(std::vector<uint16_t>& values, const uint16_t aFedId = 0);
96 
97  static void fillFEDMajorities(const std::map<uint32_t, uint32_t>& channelValues,
98  std::vector<uint32_t>& fedMajoritiesToFill);
99 
100  private:
101  // Cabling
103  uint32_t cacheId_;
104 
105  // DetCabling
107  uint32_t cacheIdDet_;
108 
109  //used to see if the pedestals have changed.
110  uint32_t pedsCacheId_;
112 
113  //used to see if the noises have changed.
114  uint32_t noiseCacheId_;
116  };
117 
118 } // namespace sistrip
119 
120 #endif // DQM_SiStripMonitorHardware_SiStripSpyUtilities_H
static void fedIndex(uint32_t aFedIndex, uint16_t &aFedId, uint16_t &aFedChannel)
std::pair< uint8_t, uint8_t > apvAddress
edm::ESHandle< SiStripNoises > noiseHandle_
static const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
edm::ESHandle< SiStripNoises > getNoiseHandle(const edm::EventSetup &eventSetup)
static const std::pair< bool, bool > findAPVErrorBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, const uint16_t aFirstBits)
const SiStripDetCabling * getDetCabling(const edm::EventSetup &)
Updates the det cabling object from the DB.
edm::ESHandle< SiStripPedestals > getPedestalHandle(const edm::EventSetup &eventSetup)
uint32_t cacheIdDet_
DB cache ID used to establish if the cabling has changed during the run.
static const std::pair< uint8_t, uint8_t > findAPVAddresses(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, const uint16_t aFirstBits)
sistrip classes
static const uint16_t findHeaderBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
const SiStripDetCabling * detCabling_
The cabling object.
static void fillFEDMajorities(const std::map< uint32_t, uint32_t > &channelValues, std::vector< uint32_t > &fedMajoritiesToFill)
std::pair< bool, bool > apvErrorBit
static const Frame extractFrameInfo(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
static const uint16_t range(const Frame &aFrame)
static std::pair< uint16_t, uint32_t > findMajorityValue(std::vector< uint16_t > &values, const uint16_t aFedId=0)
static const uint16_t threshold(const Frame &aFrame)
const SiStripFedCabling * cabling_
The cabling object.
const SiStripFedCabling * getCabling(const edm::EventSetup &)
Updates the cabling object from the DB.
static const uint16_t findTrailerBits(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
static void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
edm::ESHandle< SiStripPedestals > pedsHandle_
static std::string print(const Frame &aFrame, std::string aErr)
uint32_t cacheId_
DB cache ID used to establish if the cabling has changed during the run.
static const uint8_t extractAPVaddress(const Frame &aFrame)