Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef SiStripPedestals_h
0002 #define SiStripPedestals_h
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include <vector>
0007 #include <map>
0008 #include <iostream>
0009 
0010 // #include "CondFormats/SiStripObjects/interface/SiStripBaseObject.h"
0011 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
0012 #include <cstdint>
0013 
0014 /**
0015  * Stores the pedestal of every strip. <br>
0016  * Encodes the information in a vector<char> and uses a vector<DetRegistry> to
0017  * connect each range of values to the corresponding detId. <br>
0018  * The DetRegistry struct contains the detId and two uint32_t giving the index
0019  * of begin and end of the corresponding range in the vector<char>. <br>
0020  * Has methods to return the pedestal of a given strip of of all the strips. <br>
0021  *
0022  * The printSummary method uses SiStripDetSummary. See description therein. <br>
0023  * The printDebug method prints the pedestal value for every strip of every detId. <br>
0024  */
0025 
0026 // class SiStripPedestals : public SiStripBaseObject
0027 class SiStripPedestals {
0028 public:
0029   /*
0030     struct DecodingStructure{  
0031     unsigned int lth :6;
0032     unsigned int hth :6;
0033     unsigned int ped :10;
0034     };*/
0035 
0036   struct DetRegistry {
0037     uint32_t detid;
0038     uint32_t ibegin;
0039     uint32_t iend;
0040 
0041     COND_SERIALIZABLE;
0042   };
0043 
0044   class StrictWeakOrdering {
0045   public:
0046     bool operator()(const DetRegistry& p, const uint32_t& i) const { return p.detid < i; }
0047   };
0048 
0049   typedef std::vector<char> Container;
0050   typedef std::vector<char>::const_iterator ContainerIterator;
0051   typedef std::pair<ContainerIterator, ContainerIterator> Range;
0052   typedef std::vector<DetRegistry> Registry;
0053   typedef Registry::const_iterator RegistryIterator;
0054   typedef std::vector<uint16_t> InputVector;
0055 
0056   SiStripPedestals(){};
0057   ~SiStripPedestals(){};
0058 
0059   //bool  put(const uint32_t& detID,Range input);
0060   bool put(const uint32_t& detID, InputVector& input);
0061   const Range getRange(const uint32_t& detID) const;
0062   void getDetIds(std::vector<uint32_t>& DetIds_) const;
0063 
0064   ContainerIterator getDataVectorBegin() const { return v_pedestals.begin(); }
0065   ContainerIterator getDataVectorEnd() const { return v_pedestals.end(); }
0066   RegistryIterator getRegistryVectorBegin() const { return indexes.begin(); }
0067   RegistryIterator getRegistryVectorEnd() const { return indexes.end(); }
0068 
0069   void setData(float ped, InputVector& vped);
0070   float getPed(const uint16_t& strip, const Range& range) const;
0071   void allPeds(std::vector<int>& pefs, const Range& range) const;
0072 
0073   /// Prints mean pedestal value divided for subdet, layer and mono/stereo.
0074   void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
0075   /// Prints all pedestals.
0076   void printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
0077 
0078 private:
0079   void encode(InputVector& Vi, std::vector<unsigned char>& Vo_CHAR);
0080   uint16_t decode(const uint16_t& strip, const Range& range) const;
0081   inline uint16_t get10bits(const uint8_t*& ptr, int8_t skip) const;
0082 
0083   Container v_pedestals;  //@@@ blob streaming doesn't work with uint16_t and with SiStripData::Data
0084   Registry indexes;
0085 
0086   COND_SERIALIZABLE;
0087 };
0088 
0089 #endif