Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CondFormats_SiPixelObjects_SiPixelGainCalibration_h
0002 #define CondFormats_SiPixelObjects_SiPixelGainCalibration_h
0003 // -*- C++ -*-
0004 //
0005 // Package:    SiPixelObjects
0006 // Class:      SiPixelGainCalibration
0007 //
0008 /**\class SiPixelGainCalibration SiPixelGainCalibration.h CondFormats/SiPixelObjects/src/SiPixelGainCalibration.cc
0009 
0010  Description: Gain calibration object for the Silicon Pixel detector.  Store gain/pedestal information at pixel granularity
0011 
0012  Implementation:
0013      <Notes on implementation>
0014 */
0015 //
0016 // Original Author:  Vincenzo Chiochia
0017 //         Created:  Tue 8 12:31:25 CEST 2007
0018 //         Modified: Evan Friis
0019 // $Id: SiPixelGainCalibration.h,v 1.8 2009/02/10 17:25:42 rougny Exp $
0020 //
0021 //
0022 #include "CondFormats/Serialization/interface/Serializable.h"
0023 
0024 #include <vector>
0025 #include <map>
0026 #include <iostream>
0027 #include <cstdint>
0028 
0029 class SiPixelGainCalibration {
0030 public:
0031   struct DecodingStructure {
0032     unsigned int gain : 8;
0033     unsigned int ped : 8;
0034   };
0035 
0036   struct DetRegistry {
0037     uint32_t detid;
0038     uint32_t ibegin;
0039     uint32_t iend;
0040     int ncols;
0041 
0042     COND_SERIALIZABLE;
0043   };
0044 
0045   class StrictWeakOrdering {
0046   public:
0047     bool operator()(const DetRegistry& p, const uint32_t& i) const { return p.detid < i; }
0048   };
0049 
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 
0055   // Constructors
0056   SiPixelGainCalibration();
0057   SiPixelGainCalibration(float minPed, float maxPed, float minGain, float maxGain);
0058   ~SiPixelGainCalibration() {}
0059 
0060   void initialize() {}
0061 
0062   bool put(const uint32_t& detID, Range input, const int& nCols);
0063   const Range getRange(const uint32_t& detID) const;
0064   void getDetIds(std::vector<uint32_t>& DetIds_) const;
0065   const int getNCols(const uint32_t& detID) const;
0066   const std::pair<const Range, const int> getRangeAndNCols(const uint32_t& detID) const;
0067 
0068   unsigned int getNumberOfRowsToAverageOver() const { return numberOfRowsToAverageOver_; }
0069   double getGainLow() const { return minGain_; }
0070   double getGainHigh() const { return maxGain_; }
0071   double getPedLow() const { return minPed_; }
0072   double getPedHigh() const { return maxPed_; }
0073 
0074   // Set and get public methods
0075   void setData(
0076       float ped, float gain, std::vector<char>& vped, bool thisPixelIsDead = false, bool thisPixelIsNoisy = false);
0077 
0078   void setDeadPixel(std::vector<char>& vped) { setData(0, 0, /*dummy values, not used*/ vped, true, false); }
0079   void setNoisyPixel(std::vector<char>& vped) { setData(0, 0, /*dummy values, not used*/ vped, false, true); }
0080 
0081   float getPed(const int& col, const int& row, const Range& range, const int& nCols, bool& isDead, bool& isNoisy) const;
0082   float getGain(const int& col, const int& row, const Range& range, const int& nCols, bool& isDead, bool& isNoisy) const;
0083 
0084 private:
0085   float encodeGain(const float& gain);
0086   float encodePed(const float& ped);
0087   float decodeGain(unsigned int gain) const;
0088   float decodePed(unsigned int ped) const;
0089 
0090   std::vector<char> v_pedestals;  //@@@ blob streaming doesn't work with uint16_t and with classes
0091   std::vector<DetRegistry> indexes;
0092   float minPed_, maxPed_, minGain_, maxGain_;
0093 
0094   //THIS WILL BE HARDCODED TO 1 (no averaging) DON'T CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING!
0095   unsigned int numberOfRowsToAverageOver_;
0096 
0097   unsigned int nBinsToUseForEncoding_;
0098   unsigned int deadFlag_;
0099   unsigned int noisyFlag_;
0100 
0101   COND_SERIALIZABLE;
0102 };
0103 
0104 #endif