Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:38

0001 #ifndef SiStripDetVOff_h
0002 #define SiStripDetVOff_h
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include <vector>
0007 #include <map>
0008 #include <iostream>
0009 #include <string>
0010 #include <cstdint>
0011 
0012 class TrackerTopology;
0013 
0014 /**
0015  * This class stores the information if the HV or LV of a detId were off. <br>
0016  * Internally it uses two bits to store the information about HV and LV. It saves a uint32_t
0017  * containing the detId number and these additional bits, which are stored in the first
0018  * position. This is realized by the put method using a bit shift so that the actual
0019  * number written in the database is: detId|HV|LV. <br>
0020  * The getDetIds method builds and returns a vector with detIds, removing the additional bits.
0021  * It has three methods to extract the information: <br>
0022  * - IsModuleVOff returning the true if any of HV or LV is off
0023  * - IsModuleHVOff/IsModuleLVOff returning true if the corresponding value is off.
0024  *
0025  * The printSummary method uses SiStripDetSummary to print both LV off and HV off summaries.
0026  * See description of the SiStripDetSummary class therein. <br>
0027  * The printDebug method prints the status of HV and LV for all DetIds that have at least
0028  * one of the two off.
0029  */
0030 
0031 class SiStripDetVOff {
0032 public:
0033   typedef std::vector<uint32_t>::iterator vOffIterator;
0034   typedef std::vector<uint32_t>::const_iterator constVoffIterator;
0035   typedef std::vector<int>::const_iterator constVboolIterator;
0036 
0037   // Bitmasks used to retrieve LV and HV information
0038   static const short LVmask = 0x1;                  // <--- 01
0039   static const unsigned int LVonMask = 0xFFFFFFFE;  // <--- the last 4 bits are 1110. All the other bits are 1.
0040   static const short HVmask = 0x2;                  // <--- 10
0041   static const unsigned int HVonMask = 0xFFFFFFFD;  // <--- the last 4 bits are 1101. All the other bits are 1.
0042   static const unsigned int allOnMask = 0x03;       // <--- 2 bits are 11.
0043   static const unsigned int eightBitMask = 0xFFFFFFFF;
0044   static const short bitShift = 2;
0045 
0046   SiStripDetVOff() {}
0047   ~SiStripDetVOff() {}
0048   SiStripDetVOff(const SiStripDetVOff& toCopy) { toCopy.getVoff(v_Voff); }
0049 
0050   /// Needed by the copy constructor
0051   void getVoff(std::vector<uint32_t>& vOff_) const { vOff_ = v_Voff; }
0052 
0053   /// Insert information for a single detId
0054   bool put(const uint32_t DetId, const int HVoff, const int LVoff);
0055 
0056   /// Insert information for a vector of detIds
0057   bool put(std::vector<uint32_t>& DetId, std::vector<int>& HVoff, std::vector<int>& LVoff);
0058 
0059   bool operator==(const SiStripDetVOff& d) const { return d.v_Voff == v_Voff; }
0060 
0061   void getDetIds(std::vector<uint32_t>& DetIds_) const;
0062 
0063   /// Returns true if either HV or LV are off
0064   bool IsModuleVOff(const uint32_t DetID) const;
0065 
0066   bool IsModuleHVOff(const uint32_t DetID) const;
0067 
0068   bool IsModuleLVOff(const uint32_t DetID) const;
0069 
0070   void printDebug(std::stringstream& ss, const TrackerTopology*) const;
0071   void printSummary(std::stringstream& ss, const TrackerTopology*) const;
0072 
0073   /// Returns the total number of modules with LV off
0074   int getLVoffCounts() const;
0075   /// Returns the total number of modules with HV off
0076   int getHVoffCounts() const;
0077 
0078   /// Changes the bits in the stored value according to on/off voltages
0079   void setBits(uint32_t& enDetId, const int HVoff, const int LVoff);
0080 
0081 private:
0082   std::vector<uint32_t> v_Voff;
0083 
0084   COND_SERIALIZABLE;
0085 };
0086 
0087 #endif