Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-28 04:15:52

0001 #ifndef CondFormats_SiPixelObjects_SiPixelGainCalibrationForHLT_h
0002 #define CondFormats_SiPixelObjects_SiPixelGainCalibrationForHLT_h
0003 // -*- C++ -*-
0004 //
0005 // Package:    SiPixelObjects
0006 // Class:      SiPixelGainCalibrationForHLT
0007 //
0008 /**\class SiPixelGainCalibrationForHLT SiPixelGainCalibrationForHLT.h CondFormats/SiPixelObjects/src/SiPixelGainCalibrationForHLT.cc
0009 
0010  Description: Gain calibration object for the Silicon Pixel detector for use at HLT.  Stores only average gain and average pedestal per column.
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: SiPixelGainCalibrationForHLT.h,v 1.5 2009/02/10 17:25:58 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 SiPixelGainCalibrationForHLT {
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   SiPixelGainCalibrationForHLT();
0057   SiPixelGainCalibrationForHLT(float minPed, float maxPed, float minGain, float maxGain);
0058   ~SiPixelGainCalibrationForHLT() {}
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   float getGainLow() const { return minGain_; }
0070   float getGainHigh() const { return maxGain_; }
0071   float getPedLow() const { return minPed_; }
0072   float getPedHigh() const { return maxPed_; }
0073 
0074   std::vector<char> const& data() const { return v_pedestals; }
0075   std::vector<DetRegistry> const& getIndexes() const { return indexes; }
0076 
0077   // Set and get public methods
0078   void setData(
0079       float ped, float gain, std::vector<char>& vped, bool thisColumnIsDead = false, bool thisColumnIsNoisy = false);
0080   void setDeadColumn(const int& nRows, std::vector<char>& vped) {
0081     setData(0, 0 /*dummy values, not used*/, vped, true, false);
0082   }
0083   void setNoisyColumn(const int& nRows, std::vector<char>& vped) {
0084     setData(0, 0 /*dummy values, not used*/, vped, false, true);
0085   }
0086 
0087   std::pair<float, float> getPedAndGain(const int& col,
0088                                         const int& row,
0089                                         const Range& range,
0090                                         const int& nCols,
0091                                         bool& isDeadColumn,
0092                                         bool& isNoisyColumn) const;
0093 
0094   float getPed(const int& col,
0095                const int& row,
0096                const Range& range,
0097                const int& nCols,
0098                bool& isDeadColumn,
0099                bool& isNoisyColumn) const;
0100   float getGain(const int& col,
0101                 const int& row,
0102                 const Range& range,
0103                 const int& nCols,
0104                 bool& isDeadColumn,
0105                 bool& isNoisyColumn) const;
0106 
0107 private:
0108   float encodeGain(const float& gain);
0109   float encodePed(const float& ped);
0110   float decodeGain(unsigned int gain) const { return float(gain) * gainPrecision + minGain_; }
0111   float decodePed(unsigned int ped) const { return float(ped) * pedPrecision + minPed_; }
0112 
0113   std::vector<char> v_pedestals;  //@@@ blob streaming doesn't work with uint16_t and with classes
0114   std::vector<DetRegistry> indexes;
0115   float minPed_, maxPed_, minGain_, maxGain_;
0116 
0117   float pedPrecision, gainPrecision;
0118 
0119   //THIS WILL BE HARDCODED TO 80 (all rows in a ROC) DON'T CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING!
0120   unsigned int numberOfRowsToAverageOver_;
0121 
0122   unsigned int nBinsToUseForEncoding_;
0123   unsigned int deadFlag_;
0124   unsigned int noisyFlag_;
0125 
0126   COND_SERIALIZABLE;
0127 };
0128 
0129 #endif