CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DataFormats/SiPixelDigi/interface/SiPixelCalibDigi.h

Go to the documentation of this file.
00001 #ifndef DATAFORMATS_SIPIXELCALIBDIGI_SIPIXELCALIBDIGI_H
00002 #define DATAFORMATS_SIPIXELCALIBDIGI_SIPIXELCALIBDIGI_H
00003 
00004 #include <utility>
00005 #include <vector>
00006 #include <iostream>
00007 #include "boost/cstdint.hpp"
00008 
00009 class SiPixelCalibDigi {
00010  public:
00011 
00012   SiPixelCalibDigi(int packed_value,uint16_t row, uint16_t col):m_data(packed_value),m_row_and_column(row,col) {reset();}
00013     SiPixelCalibDigi(int packed_value):m_data(packed_value),m_row_and_column(0,0){reset();}
00014     SiPixelCalibDigi():m_data(0),m_row_and_column(0,0){;}
00015     virtual ~SiPixelCalibDigi(){;}
00016 
00017   void init( uint16_t row, uint16_t col, uint16_t npoints);
00018   void reset();
00019   void fill(uint32_t ipoint, uint32_t adcval);
00020   void setrowcol(uint16_t row, uint16_t col);
00021 
00022   // analysis methods:
00023   uint32_t getnpoints() const {return m_data.size();} // returns the number of calibration points
00024   uint32_t getsum(uint32_t ipoint) const { return m_data[ipoint].adccountsum;}// returns the sum of adc counts for the collected events at point ipoint
00025   uint32_t getsumsquares(uint32_t ipoint)const { return m_data[ipoint].adccountsumsq;}// returns the sum of the squares of adc counts for the collected events at point ipoint
00026   uint32_t getnentries(uint32_t ipoint) const { return m_data[ipoint].nentries;}// returns the number of entries made for calibration point ipoint
00027   std::vector<uint32_t> getsum() const;// returns the sum of adc counts for the collected events for all points
00028   std::vector<uint32_t> getsumsquares() const;// returns the sum of the squares of adc counts 
00029   std::vector<uint8_t> getnentries() const  ;// returns the number of entries made 
00030   uint16_t row() const {return m_row_and_column.first;}
00031   uint16_t col() const {return m_row_and_column.second;}
00032   std::pair<uint16_t,uint16_t> row_and_col() const {return m_row_and_column;}
00033   
00034  struct datacontainer{
00035    datacontainer():nentries(0),adccountsum(0),adccountsumsq(0) { }
00036    uint8_t nentries;// the number of entries per VCAL point
00037    uint32_t adccountsum;// the sum of the ADC counts
00038    uint32_t adccountsumsq;// the sum of the square value of the ADC counts
00039   };
00040 
00041  private:
00042 
00043   // this is were the data is stored
00044   std::vector<datacontainer> m_data;
00045   std::pair<uint16_t,uint16_t>  m_row_and_column;//the row and column number of this particular pixel
00046 }; 
00047  
00048 inline bool operator <( const SiPixelCalibDigi & one, const SiPixelCalibDigi & other){
00049   return one.getnpoints() < other.getnpoints();
00050 }
00051 
00052 inline std::ostream & operator<<(std::ostream & output, const SiPixelCalibDigi & digi) {
00053 /*   std::ostream result; */
00054 /*   result << "this SiPixelCalibDigi object contains: " << m_nentries.size() << " and represents pixel (row,col) (" << m_row_and_column.first << ","<< m_row_and_colum.second <<") \n"; */
00055 /*   for(int iter=0; iter<m_nentries.size(); ++iter) */
00056 /*     result << "calib point " << iter << ", nentries " << m_nentries[iter] << ", sum " << m_adccountsum[iter] << ", sum of squares " << m_adccountsumsq[iter] <<".\n"; */
00057 /*   return output << result; */
00058   return output << "this pixel (row " << digi.row() << ", col " << digi.col() << " has " << digi.getnpoints() << " calibration points."; 
00059 }
00060 
00061 
00062 #endif