CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DQM/SiStripMonitorHardware/interface/SiStripSpyUtilities.h

Go to the documentation of this file.
00001 #ifndef DQM_SiStripMonitorHardware_SiStripSpyUtilities_H
00002 #define DQM_SiStripMonitorHardware_SiStripSpyUtilities_H
00003 
00004 
00005 // Standard includes.
00006 //#include <utility>
00007 #include <string>
00008 
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 #include "FWCore/Framework/interface/ESHandle.h"
00011 
00012 #include "DataFormats/Common/interface/DetSetVector.h"
00013 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
00014 
00015 #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
00016 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00017 #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
00018 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
00019 
00020 // Other classes
00021 class EventSetup;
00022 
00023 namespace sistrip {
00024   
00025   class SpyUtilities
00026   {
00027   public:
00028 
00029     struct Frame {
00030       uint32_t detId;
00031       uint16_t digitalLow;
00032       uint16_t digitalHigh;
00033       uint16_t firstHeaderBit;
00034       uint16_t firstTrailerBit;
00035       float baseline;
00036       std::pair<bool,bool> apvErrorBit;
00037       std::pair<uint8_t,uint8_t> apvAddress;
00038     };
00039 
00040     struct FrameQuality {
00041       uint16_t minDigiRange;
00042       uint16_t maxDigiRange;
00043       uint16_t minZeroLight;
00044       uint16_t maxZeroLight;
00045       uint16_t minTickHeight;
00046       uint16_t maxTickHeight;
00047     };
00048 
00049     SpyUtilities();
00050     ~SpyUtilities();
00051 
00052     //get cabling for an eventSetup: internal counter to see if cabling has changed.
00053     const SiStripFedCabling* getCabling( const edm::EventSetup& ); 
00054     const SiStripDetCabling* getDetCabling( const edm::EventSetup& ); 
00055 
00056     edm::ESHandle<SiStripPedestals> getPedestalHandle(const edm::EventSetup& eventSetup);
00057     edm::ESHandle<SiStripNoises> getNoiseHandle(const edm::EventSetup& eventSetup);
00058     
00059     //fill variables from frame
00060     static const Frame extractFrameInfo(const edm::DetSetVector<SiStripRawDigi>::detset & channelDigis,
00061                                         bool aPrintDebug=false);
00062 
00063     static void getMajorityHeader(const edm::DetSetVector<SiStripRawDigi> * aInputDigis,
00064                                   uint16_t & firstHeaderBit,
00065                                   bool printResult=true);
00066 
00067     //check frame is valid
00068     static const bool isValid(const Frame & aFrame,
00069                               const FrameQuality & aQuality,
00070                               const uint16_t aExpectedPos);
00071 
00072     //extract range, threshold and apvAddress
00073     static const uint16_t range(const Frame & aFrame);
00074 
00075     static const uint16_t threshold(const Frame & aFrame);
00076 
00077     static const uint8_t extractAPVaddress(const Frame & aFrame);
00078 
00079     //find position of the first header and trailer bit
00080     static const uint16_t findHeaderBits(const edm::DetSetVector<SiStripRawDigi>::detset & channelDigis,
00081                                          const uint16_t threshold);
00082 
00083     static const uint16_t findTrailerBits(const edm::DetSetVector<SiStripRawDigi>::detset & channelDigis,
00084                                           const uint16_t threshold);
00085 
00086     //find both APV addresses and error bits
00087     static const std::pair<bool,bool> 
00088       findAPVErrorBits(const edm::DetSetVector<SiStripRawDigi>::detset & channelDigis,
00089                        const uint16_t threshold,
00090                        const uint16_t aFirstBits);
00091 
00092     static const std::pair<uint8_t,uint8_t> 
00093       findAPVAddresses(const edm::DetSetVector<SiStripRawDigi>::detset & channelDigis,
00094                        const uint16_t threshold,
00095                        const uint16_t aFirstBits);
00096 
00097     static std::string print(const Frame & aFrame,
00098                              std::string aErr);
00099 
00100     static void fedIndex(uint32_t   aFedIndex,
00101                          uint16_t & aFedId,
00102                          uint16_t & aFedChannel);
00103 
00104     static std::pair<uint16_t,uint32_t> findMajorityValue(std::vector<uint16_t> & values,
00105                                                           const uint16_t aFedId = 0);
00106 
00107     static void fillFEDMajorities(const std::map<uint32_t,uint32_t>& channelValues, 
00108                                   std::vector<uint32_t> & fedMajoritiesToFill);
00109 
00110   private:
00111     // Cabling
00112     const SiStripFedCabling* cabling_;  
00113     uint32_t cacheId_;                  
00114 
00115     // DetCabling
00116     const SiStripDetCabling* detCabling_;  
00117     uint32_t cacheIdDet_;                  
00118 
00119     //used to see if the pedestals have changed.
00120     uint32_t pedsCacheId_;
00121     edm::ESHandle<SiStripPedestals> pedsHandle_;
00122 
00123     //used to see if the noises have changed.
00124     uint32_t noiseCacheId_;
00125     edm::ESHandle<SiStripNoises> noiseHandle_;
00126 
00127   };
00128     
00129 }
00130 
00131 #endif // DQM_SiStripMonitorHardware_SiStripSpyUtilities_H