CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType > Class Template Reference

#include <SiPixelGainCalibrationServiceBase.h>

Inheritance diagram for SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >:
SiPixelGainCalibrationServiceBase

List of all members.

Public Member Functions

std::vector< uint32_t > getDetIds ()
virtual float getGain (const uint32_t &detID, const int &col, const int &row)=0
double getGainHigh ()
double getGainLow ()
virtual float getPedestal (const uint32_t &detID, const int &col, const int &row)=0
double getPedHigh ()
double getPedLow ()
virtual bool isDead (const uint32_t &detID, const int &col, const int &row)=0
virtual bool isDeadColumn (const uint32_t &detID, const int &col, const int &row)=0
virtual bool isNoisy (const uint32_t &detID, const int &col, const int &row)=0
virtual bool isNoisyColumn (const uint32_t &detID, const int &col, const int &row)=0
void setESObjects (const edm::EventSetup &es)
 SiPixelGainCalibrationServicePayloadGetter (const edm::ParameterSet &conf)
virtual ~SiPixelGainCalibrationServicePayloadGetter ()

Protected Member Functions

float getGainByColumn (const uint32_t &detID, const int &col, const int &row, bool &isDeadColumn, bool &isNoisyColumn)
float getGainByPixel (const uint32_t &detID, const int &col, const int &row, bool &isDeadPixel, bool &isNoisyPixel)
float getPedestalByColumn (const uint32_t &detID, const int &col, const int &row, bool &isDeadColumn, bool &isNoisyColumn)
float getPedestalByPixel (const uint32_t &detID, const int &col, const int &row, bool &isDeadPixel, bool &isNoisyPixel)
void throwExepctionForBadRead (std::string payload, const uint32_t &detID, const int &col, const int &row, double value=-1) const

Private Attributes

edm::ParameterSet conf_
bool ESetupInit_
double gainHigh_
double gainLow_
int numberOfRowsAveragedOver_
int old_cols
uint32_t old_detID
thePayloadObject::Range old_range
int oldAveragedBlockDataGain_
int oldAveragedBlockDataPed_
int oldColumnIndexGain_
int oldColumnIndexPed_
float oldColumnValueGain_
float oldColumnValuePed_
bool oldThisColumnIsDeadGain_
bool oldThisColumnIsDeadPed_
bool oldThisColumnIsNoisyGain_
bool oldThisColumnIsNoisyPed_
edm::ESHandle< thePayloadObject > ped
double pedHigh_
double pedLow_

Detailed Description

template<class thePayloadObject, class theDBRecordType>
class SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >

Definition at line 48 of file SiPixelGainCalibrationServiceBase.h.


Constructor & Destructor Documentation

template<class thePayloadObject , class theDBRecordType >
SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::SiPixelGainCalibrationServicePayloadGetter ( const edm::ParameterSet conf) [explicit]

Definition at line 115 of file SiPixelGainCalibrationServiceBase.h.

References SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::old_detID, SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldAveragedBlockDataGain_, SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldAveragedBlockDataPed_, SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldColumnIndexGain_, SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldColumnIndexPed_, SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldColumnValueGain_, SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldColumnValuePed_, SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldThisColumnIsDeadGain_, SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldThisColumnIsDeadPed_, SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldThisColumnIsNoisyGain_, and SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldThisColumnIsNoisyPed_.

                                                                                                                                                   :
  conf_(conf),
  ESetupInit_(false)
{

  edm::LogInfo("SiPixelGainCalibrationServicePayloadGetter")  << "[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]";
  // Initialize cache variables
  old_detID             = 0;
  oldColumnIndexGain_   = -1;
  oldColumnIndexPed_    = -1;
  oldColumnValueGain_   = 0.;
  oldColumnValuePed_    = 0.; 

  oldAveragedBlockDataGain_ = -1;
  oldAveragedBlockDataPed_  = -1;
  oldThisColumnIsDeadGain_ = false;
  oldThisColumnIsDeadPed_  = false;
  oldThisColumnIsNoisyGain_ = false;
  oldThisColumnIsNoisyPed_  = false;

}
template<class thePayloadObject, class theDBRecordType>
virtual SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::~SiPixelGainCalibrationServicePayloadGetter ( ) [inline, virtual]

Definition at line 52 of file SiPixelGainCalibrationServiceBase.h.

{};

Member Function Documentation

template<class thePayloadObject , class theDBRecordType >
std::vector< uint32_t > SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getDetIds ( ) [virtual]

Implements SiPixelGainCalibrationServiceBase.

Definition at line 147 of file SiPixelGainCalibrationServiceBase.h.

                                                                                                            {

  std::vector<uint32_t> vdetId_;  
  ped->getDetIds(vdetId_);
  return vdetId_;

}
template<class thePayloadObject, class theDBRecordType>
virtual float SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getGain ( const uint32_t &  detID,
const int &  col,
const int &  row 
) [pure virtual]
template<class thePayloadObject , class theDBRecordType >
float SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getGainByColumn ( const uint32_t &  detID,
const int &  col,
const int &  row,
bool &  isDeadColumn,
bool &  isNoisyColumn 
) [protected]

Definition at line 254 of file SiPixelGainCalibrationServiceBase.h.

References Exception.

                                                                                                                                                                                                 {
  if(ESetupInit_) {
    //&&&&&&&&&&&&&&&&&&&&
    //Access from DB
    //&&&&&&&&&&&&&&&&&&&&
    bool inTheSameAveragedDataBlock = false;
    if ( row / numberOfRowsAveragedOver_ == oldAveragedBlockDataGain_ )
       inTheSameAveragedDataBlock = true;

    if (detID != old_detID){
      old_detID=detID;
      std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
      old_range = rangeAndNCols.first;
      old_cols  = rangeAndNCols.second;
    }
    else if (col == oldColumnIndexGain_ && inTheSameAveragedDataBlock) // same DetID, same column
    {
       isDeadColumn = oldThisColumnIsDeadGain_;
       isDeadColumn = oldThisColumnIsNoisyGain_;
       return oldColumnValueGain_;
    }

    oldColumnIndexGain_       = col;
    oldAveragedBlockDataGain_ = row / numberOfRowsAveragedOver_;
    oldColumnValueGain_       = ped->getGain(col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
    oldThisColumnIsDeadGain_  = isDeadColumn;
    oldThisColumnIsNoisyGain_  = isNoisyColumn;

    return oldColumnValueGain_;

  } else throw cms::Exception("NullPointer")
    << "[SiPixelGainCalibrationServicePayloadGetter::getGainByColumn] SiPixelGainCalibrationRcd not initialized ";
}
template<class thePayloadObject , class theDBRecordType >
float SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getGainByPixel ( const uint32_t &  detID,
const int &  col,
const int &  row,
bool &  isDeadPixel,
bool &  isNoisyPixel 
) [protected]

Definition at line 199 of file SiPixelGainCalibrationServiceBase.h.

References Exception.

                                                                                                                                                                                    {
  if(ESetupInit_) {
    //&&&&&&&&&&&&&&&&&&&&
    //Access from DB
    //&&&&&&&&&&&&&&&&&&&&
    if (detID != old_detID){
      old_detID=detID;
      std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
      old_range = rangeAndNCols.first;
      old_cols  = rangeAndNCols.second;
    }
    return ped->getGain(col, row, old_range, old_cols, isDead, isNoisy);
  } else throw cms::Exception("NullPointer")
    << "[SiPixelGainCalibrationServicePayloadGetter::getGainByPixel] SiPixelGainCalibrationRcd not initialized ";
}
template<class thePayloadObject , class theDBRecordType >
double SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getGainHigh ( ) [virtual]

Implements SiPixelGainCalibrationServiceBase.

Definition at line 162 of file SiPixelGainCalibrationServiceBase.h.

                                                                                                 {
  double gainHigh_ = ped->getGainHigh();
  return gainHigh_;
}
template<class thePayloadObject , class theDBRecordType >
double SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getGainLow ( ) [virtual]

Implements SiPixelGainCalibrationServiceBase.

Definition at line 156 of file SiPixelGainCalibrationServiceBase.h.

                                                                                                {
  double gainLow_ = ped->getGainLow();
  return gainLow_;
}
template<class thePayloadObject, class theDBRecordType>
virtual float SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getPedestal ( const uint32_t &  detID,
const int &  col,
const int &  row 
) [pure virtual]
template<class thePayloadObject , class theDBRecordType >
float SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getPedestalByColumn ( const uint32_t &  detID,
const int &  col,
const int &  row,
bool &  isDeadColumn,
bool &  isNoisyColumn 
) [protected]

Definition at line 217 of file SiPixelGainCalibrationServiceBase.h.

References Exception.

                                                                                                                                                                                                     { 
  if(ESetupInit_) {
    //&&&&&&&&&&&&&&&&&&&&
    //Access from DB
    //&&&&&&&&&&&&&&&&&&&&
      // see if we are in the same averaged data block
      bool inTheSameAveragedDataBlock = false;
      if ( row / numberOfRowsAveragedOver_ == oldAveragedBlockDataPed_ )
         inTheSameAveragedDataBlock = true;

      if (detID != old_detID){
        old_detID=detID;
        std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
        old_range = rangeAndNCols.first;
        old_cols  = rangeAndNCols.second;
      } 
      else if (col == oldColumnIndexPed_ && inTheSameAveragedDataBlock) // same DetID, same column, same data block
      {
         isDeadColumn = oldThisColumnIsDeadPed_;
         isNoisyColumn = oldThisColumnIsNoisyPed_;
         return oldColumnValuePed_;
      } 

      oldColumnIndexPed_       = col;
      oldAveragedBlockDataPed_ = row / numberOfRowsAveragedOver_;
      oldColumnValuePed_       = ped->getPed(col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
      oldThisColumnIsDeadPed_  = isDeadColumn;
      oldThisColumnIsNoisyPed_  = isNoisyColumn;

      return oldColumnValuePed_;

  } else throw cms::Exception("NullPointer")
    << "[SiPixelGainCalibrationServicePayloadGetter::getPedestalByColumn] SiPixelGainCalibrationRcd not initialized ";
}
template<class thePayloadObject , class theDBRecordType >
float SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getPedestalByPixel ( const uint32_t &  detID,
const int &  col,
const int &  row,
bool &  isDeadPixel,
bool &  isNoisyPixel 
) [protected]

Definition at line 180 of file SiPixelGainCalibrationServiceBase.h.

References Exception.

                                                                                                                                                                                        { 
  if(ESetupInit_) {
    //&&&&&&&&&&&&&&&&&&&&
    //Access from DB
    //&&&&&&&&&&&&&&&&&&&&
      if (detID != old_detID){
        old_detID=detID;
        std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
        old_range = rangeAndNCols.first;
        old_cols  = rangeAndNCols.second;
      }
      //std::cout<<" Pedestal "<<ped->getPed(col, row, old_range, old_cols)<<std::endl;
      return  ped->getPed(col, row, old_range, old_cols, isDead, isNoisy);
  } else throw cms::Exception("NullPointer")
    << "[SiPixelGainCalibrationServicePayloadGetter::getPedestalByPixel] SiPixelGainCalibrationRcd not initialized ";
}
template<class thePayloadObject , class theDBRecordType >
double SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getPedHigh ( ) [virtual]

Implements SiPixelGainCalibrationServiceBase.

Definition at line 174 of file SiPixelGainCalibrationServiceBase.h.

                                                                                                {
  double pedHigh_ = ped->getPedHigh();
  return pedHigh_;
}
template<class thePayloadObject , class theDBRecordType >
double SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::getPedLow ( ) [virtual]

Implements SiPixelGainCalibrationServiceBase.

Definition at line 168 of file SiPixelGainCalibrationServiceBase.h.

                                                                                               {
  double pedLow_ = ped->getPedLow();
  return pedLow_;
}
template<class thePayloadObject, class theDBRecordType>
virtual bool SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::isDead ( const uint32_t &  detID,
const int &  col,
const int &  row 
) [pure virtual]
template<class thePayloadObject, class theDBRecordType>
virtual bool SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::isDeadColumn ( const uint32_t &  detID,
const int &  col,
const int &  row 
) [pure virtual]
template<class thePayloadObject, class theDBRecordType>
virtual bool SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::isNoisy ( const uint32_t &  detID,
const int &  col,
const int &  row 
) [pure virtual]
template<class thePayloadObject, class theDBRecordType>
virtual bool SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::isNoisyColumn ( const uint32_t &  detID,
const int &  col,
const int &  row 
) [pure virtual]
template<class thePayloadObject , class theDBRecordType >
void SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::setESObjects ( const edm::EventSetup es) [virtual]

Implements SiPixelGainCalibrationServiceBase.

Definition at line 138 of file SiPixelGainCalibrationServiceBase.h.

References edm::EventSetup::get().

                                                                                                                         {

    es.get<theDBRecordType>().get(ped);
    numberOfRowsAveragedOver_ = ped->getNumberOfRowsToAverageOver();
    ESetupInit_ = true;

}
template<class thePayloadObject , class theDBRecordType >
void SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::throwExepctionForBadRead ( std::string  payload,
const uint32_t &  detID,
const int &  col,
const int &  row,
double  value = -1 
) const [protected]

Definition at line 289 of file SiPixelGainCalibrationServiceBase.h.

References dtNoiseDBValidation_cfg::cerr.

{
   std::cerr << "[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]"
      << "[SiPixelGainCalibrationServicePayloadGetter] ERROR - Slow down, speed racer! You have tried to read the ped/gain on a pixel that is flagged as dead/noisy. For payload: " << payload << "  DETID: " 
      << detID << " col: " << col << " row: " << row << ". You must check if the pixel is dead/noisy before asking for the ped/gain value, otherwise you will get corrupt data! value: " << value << std::endl;

   // really yell if this occurs

   edm::LogError("SiPixelGainCalibrationService") << "[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]"
      << "[SiPixelGainCalibrationServicePayloadGetter] ERROR - Slow down, speed racer! You have tried to read the ped/gain on a pixel that is flagged as dead/noisy. For payload: " << payload << "  DETID: " 
      << detID << " col: " << col << " row: " << row << ". You must check if the pixel is dead/noisy before asking for the ped/gain value, otherwise you will get corrupt data! value: " << value << std::endl;
}

Member Data Documentation

template<class thePayloadObject, class theDBRecordType>
edm::ParameterSet SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::conf_ [private]

Definition at line 85 of file SiPixelGainCalibrationServiceBase.h.

template<class thePayloadObject, class theDBRecordType>
bool SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::ESetupInit_ [private]

Definition at line 86 of file SiPixelGainCalibrationServiceBase.h.

template<class thePayloadObject, class theDBRecordType>
double SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::gainHigh_ [private]

Definition at line 90 of file SiPixelGainCalibrationServiceBase.h.

template<class thePayloadObject, class theDBRecordType>
double SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::gainLow_ [private]

Definition at line 89 of file SiPixelGainCalibrationServiceBase.h.

template<class thePayloadObject, class theDBRecordType>
int SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::numberOfRowsAveragedOver_ [private]

Definition at line 88 of file SiPixelGainCalibrationServiceBase.h.

template<class thePayloadObject, class theDBRecordType>
int SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::old_cols [private]

Definition at line 95 of file SiPixelGainCalibrationServiceBase.h.

template<class thePayloadObject, class theDBRecordType>
uint32_t SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::old_detID [private]
template<class thePayloadObject, class theDBRecordType>
thePayloadObject::Range SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::old_range [private]

Definition at line 111 of file SiPixelGainCalibrationServiceBase.h.

template<class thePayloadObject, class theDBRecordType>
int SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldAveragedBlockDataGain_ [private]
template<class thePayloadObject, class theDBRecordType>
int SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldAveragedBlockDataPed_ [private]
template<class thePayloadObject, class theDBRecordType>
int SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldColumnIndexGain_ [private]
template<class thePayloadObject, class theDBRecordType>
int SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldColumnIndexPed_ [private]
template<class thePayloadObject, class theDBRecordType>
float SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldColumnValueGain_ [private]
template<class thePayloadObject, class theDBRecordType>
float SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldColumnValuePed_ [private]
template<class thePayloadObject, class theDBRecordType>
bool SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldThisColumnIsDeadGain_ [private]
template<class thePayloadObject, class theDBRecordType>
bool SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldThisColumnIsDeadPed_ [private]
template<class thePayloadObject, class theDBRecordType>
bool SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldThisColumnIsNoisyGain_ [private]
template<class thePayloadObject, class theDBRecordType>
bool SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::oldThisColumnIsNoisyPed_ [private]
template<class thePayloadObject, class theDBRecordType>
edm::ESHandle<thePayloadObject> SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::ped [private]

Definition at line 87 of file SiPixelGainCalibrationServiceBase.h.

template<class thePayloadObject, class theDBRecordType>
double SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::pedHigh_ [private]

Definition at line 92 of file SiPixelGainCalibrationServiceBase.h.

template<class thePayloadObject, class theDBRecordType>
double SiPixelGainCalibrationServicePayloadGetter< thePayloadObject, theDBRecordType >::pedLow_ [private]

Definition at line 91 of file SiPixelGainCalibrationServiceBase.h.