Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:11:55

0001 #ifndef DQM_SiStripMonitorHardware_SiStripSpyUtilities_H
0002 #define DQM_SiStripMonitorHardware_SiStripSpyUtilities_H
0003 
0004 // Standard includes.
0005 //#include <utility>
0006 #include <string>
0007 
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 
0011 #include "DataFormats/Common/interface/DetSetVector.h"
0012 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
0013 
0014 // Other classes
0015 class EventSetup;
0016 
0017 namespace sistrip {
0018 
0019   namespace SpyUtilities {
0020     struct Frame {
0021       uint32_t detId;
0022       uint16_t digitalLow;
0023       uint16_t digitalHigh;
0024       uint16_t firstHeaderBit;
0025       uint16_t firstTrailerBit;
0026       float baseline;
0027       std::pair<bool, bool> apvErrorBit;
0028       std::pair<uint8_t, uint8_t> apvAddress;
0029     };
0030 
0031     struct FrameQuality {
0032       uint16_t minDigiRange;
0033       uint16_t maxDigiRange;
0034       uint16_t minZeroLight;
0035       uint16_t maxZeroLight;
0036       uint16_t minTickHeight;
0037       uint16_t maxTickHeight;
0038     };
0039 
0040     //fill variables from frame
0041     const Frame extractFrameInfo(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis,
0042                                  bool aPrintDebug = false);
0043 
0044     void getMajorityHeader(const edm::DetSetVector<SiStripRawDigi>* aInputDigis,
0045                            uint16_t& firstHeaderBit,
0046                            bool printResult = true);
0047 
0048     //check frame is valid
0049     const bool isValid(const Frame& aFrame, const FrameQuality& aQuality, const uint16_t aExpectedPos);
0050 
0051     //extract range, threshold and apvAddress
0052     const uint16_t range(const Frame& aFrame);
0053 
0054     const uint16_t threshold(const Frame& aFrame);
0055 
0056     const uint8_t extractAPVaddress(const Frame& aFrame);
0057 
0058     //find position of the first header and trailer bit
0059     const uint16_t findHeaderBits(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis,
0060                                   const uint16_t threshold);
0061 
0062     const uint16_t findTrailerBits(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis,
0063                                    const uint16_t threshold);
0064 
0065     //find both APV addresses and error bits
0066     const std::pair<bool, bool> findAPVErrorBits(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis,
0067                                                  const uint16_t threshold,
0068                                                  const uint16_t aFirstBits);
0069 
0070     const std::pair<uint8_t, uint8_t> findAPVAddresses(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis,
0071                                                        const uint16_t threshold,
0072                                                        const uint16_t aFirstBits);
0073 
0074     std::string print(const Frame& aFrame, std::string aErr);
0075 
0076     void fedIndex(uint32_t aFedIndex, uint16_t& aFedId, uint16_t& aFedChannel);
0077 
0078     std::pair<uint16_t, uint32_t> findMajorityValue(std::vector<uint16_t>& values, const uint16_t aFedId = 0);
0079 
0080     void fillFEDMajorities(const std::map<uint32_t, uint32_t>& channelValues,
0081                            std::vector<uint32_t>& fedMajoritiesToFill);
0082 
0083   }  // namespace SpyUtilities
0084 }  // namespace sistrip
0085 
0086 #endif  // DQM_SiStripMonitorHardware_SiStripSpyUtilities_H