Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:34

0001 #ifndef CondFormats_SiPixelObjects_SiPixelGainCalibrationOffline_h
0002 #define CondFormats_SiPixelObjects_SiPixelGainCalibrationOffline_h
0003 // -*- C++ -*-
0004 //
0005 // Package:    SiPixelObjects
0006 // Class:      SiPixelGainCalibrationOffline
0007 //
0008 /**\class SiPixelGainCalibrationOffline SiPixelGainCalibrationOffline.h CondFormats/SiPixelObjects/src/SiPixelGainCalibrationOffline.cc
0009 
0010  Description: Gain calibration object for the Silicon Pixel detector.  Stores pedestal at pixel granularity, gain at column granularity.
0011 
0012  Implementation:
0013      <Notes on implementation>
0014 */
0015 //
0016 // Original Author:  Vincenzo Chiochia
0017 //         Modified: Evan Friis
0018 //         Created:  Tue 8 12:31:25 CEST 2007
0019 // $Id: SiPixelGainCalibrationOffline.h,v 1.5 2009/02/10 17:26:50 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 SiPixelGainCalibrationOffline {
0030 public:
0031   struct DecodingStructure {
0032     unsigned int datum : 8;
0033   };
0034 
0035   struct DetRegistry {
0036     uint32_t detid;
0037     uint32_t ibegin;
0038     uint32_t iend;
0039     int ncols;
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>::const_iterator ContainerIterator;
0050   typedef std::pair<ContainerIterator, ContainerIterator> Range;
0051   typedef std::vector<DetRegistry> Registry;
0052   typedef Registry::const_iterator RegistryIterator;
0053 
0054   // Constructors
0055   SiPixelGainCalibrationOffline();
0056   SiPixelGainCalibrationOffline(float minPed, float maxPed, float minGain, float maxGain);
0057   ~SiPixelGainCalibrationOffline() {}
0058 
0059   void initialize() {}
0060 
0061   bool put(const uint32_t& detID, Range input, const int& nCols);
0062   const Range getRange(const uint32_t& detID) const;
0063   void getDetIds(std::vector<uint32_t>& DetIds_) const;
0064   const int getNCols(const uint32_t& detID) const;
0065   const std::pair<const Range, const int> getRangeAndNCols(const uint32_t& detID) const;
0066 
0067   // Set and get public methods
0068   void setDataGain(float gain,
0069                    const int& nRows,
0070                    std::vector<char>& vped,
0071                    bool thisColumnIsDead = false,
0072                    bool thisColumnIsNoisy = false);
0073   void setDataPedestal(float pedestal,
0074                        std::vector<char>& vped,
0075                        bool thisPixelIsDead = false,
0076                        bool thisPixelIsNoisy = false);
0077 
0078   unsigned int getNumberOfRowsToAverageOver() const { return numberOfRowsToAverageOver_; }
0079   double getGainLow() const { return minGain_; }
0080   double getGainHigh() const { return maxGain_; }
0081   double getPedLow() const { return minPed_; }
0082   double getPedHigh() const { return maxPed_; }
0083 
0084   // Set dead pixels
0085   void setDeadPixel(std::vector<char>& vped) { setDataPedestal(0 /*dummy value, not used*/, vped, true); }
0086   void setDeadColumn(const int& nRows, std::vector<char>& vped) {
0087     setDataGain(0 /*dummy value, not used*/, nRows, vped, true);
0088   }
0089 
0090   // Set noisy pixels
0091   void setNoisyPixel(std::vector<char>& vped) { setDataPedestal(0 /*dummy value, not used*/, vped, false, true); }
0092   void setNoisyColumn(const int& nRows, std::vector<char>& vped) {
0093     setDataGain(0 /*dummy value, not used*/, nRows, vped, false, true);
0094   }
0095 
0096   // these methods SHOULD NEVER BE ACESSED BY THE USER - use the services in CondTools/SiPixel!!!!
0097   float getPed(const int& col, const int& row, const Range& range, const int& nCols, bool& isDead, bool& isNoisy) const;
0098   float getGain(const int& col,
0099                 const int& row,
0100                 const Range& range,
0101                 const int& nCols,
0102                 bool& isDeadColumn,
0103                 bool& isNoisyColumn) const;
0104 
0105 private:
0106   float encodeGain(const float& gain);
0107   float encodePed(const float& ped);
0108   float decodeGain(unsigned int gain) const;
0109   float decodePed(unsigned int ped) const;
0110 
0111   std::vector<char> v_pedestals;  //@@@ blob streaming doesn't work with uint16_t and with classes
0112   std::vector<DetRegistry> indexes;
0113   float minPed_, maxPed_, minGain_, maxGain_;
0114 
0115   //THIS WILL BE HARDCODED TO 80 (all rows in a ROC) DON'T CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING!
0116   unsigned int numberOfRowsToAverageOver_;
0117 
0118   unsigned int nBinsToUseForEncoding_;
0119   unsigned int deadFlag_;
0120   unsigned int noisyFlag_;
0121 
0122   COND_SERIALIZABLE;
0123 };
0124 
0125 #endif