CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

CastorDbService Class Reference

#include <CastorDbService.h>

List of all members.

Public Member Functions

 CastorDbService (const edm::ParameterSet &)
const CastorCalibrationsgetCastorCalibrations (const HcalGenericDetId &fId) const
const CastorCalibrationWidthsgetCastorCalibrationWidths (const HcalGenericDetId &fId) const
const CastorChannelStatusgetCastorChannelStatus (const HcalGenericDetId &fId) const
const CastorQIECodergetCastorCoder (const HcalGenericDetId &fId) const
const CastorElectronicsMapgetCastorMapping () const
const CastorQIEShapegetCastorShape () const
const CastorGaingetGain (const HcalGenericDetId &fId) const
const CastorGainWidthgetGainWidth (const HcalGenericDetId &fId) const
const CastorPedestalgetPedestal (const HcalGenericDetId &fId) const
const CastorPedestalWidthgetPedestalWidth (const HcalGenericDetId &fId) const
void setData (const CastorGains *fItem)
void setData (const CastorPedestals *fItem)
void setData (const CastorChannelQuality *fItem)
void setData (const CastorGainWidths *fItem)
void setData (const CastorPedestalWidths *fItem)
void setData (const CastorElectronicsMap *fItem)
void setData (const CastorQIEData *fItem)

Private Member Functions

void buildCalibrations ()
void buildCalibWidths ()
bool makeCastorCalibration (const HcalGenericDetId &fId, CastorCalibrations *fObject, bool pedestalInADC) const
bool makeCastorCalibrationWidth (const HcalGenericDetId &fId, CastorCalibrationWidths *fObject, bool pedestalInADC) const

Private Attributes

CastorCalibrationsSet mCalibSet
CastorCalibrationWidthsSet mCalibWidthSet
const CastorChannelQualitymChannelQuality
const CastorElectronicsMapmElectronicsMap
const CastorGainsmGains
const CastorGainWidthsmGainWidths
const CastorPedestalsmPedestals
const CastorPedestalWidthsmPedestalWidths
const CastorQIEDatamQIEData
QieShapemQieShapeCache

Detailed Description

Definition at line 28 of file CastorDbService.h.


Constructor & Destructor Documentation

CastorDbService::CastorDbService ( const edm::ParameterSet cfg)

Definition at line 17 of file CastorDbService.cc.


Member Function Documentation

void CastorDbService::buildCalibrations ( ) [private]

Definition at line 60 of file CastorDbService.cc.

References CastorCalibrationsSet::clear(), CastorCondObjectContainer< Item >::getAllChannels(), CastorPedestals::isADC(), makeCastorCalibration(), mCalibSet, mGains, mPedestals, mQIEData, convertSQLiteXML::ok, CastorCalibrationsSet::setCalibrations(), and CastorCalibrationsSet::sort().

Referenced by setData().

                                        {
  // we use the set of ids for pedestals as the master list
  if ((!mPedestals) || (!mGains) || (!mQIEData) ) return;
  std::vector<DetId> ids=mPedestals->getAllChannels();
  bool pedsInADC = mPedestals->isADC();
  // clear the calibrations set
  mCalibSet.clear();
  // loop!
  CastorCalibrations tool;

  //  std::cout << " length of id-vector: " << ids.size() << std::endl;
  for (std::vector<DetId>::const_iterator id=ids.begin(); id!=ids.end(); ++id) {
    // make
    bool ok=makeCastorCalibration(*id,&tool,pedsInADC);
    // store
    if (ok) mCalibSet.setCalibrations(*id,tool);
    //    std::cout << "Castor calibrations built... detid no. " << HcalGenericDetId(*id) << std::endl;
  }
  mCalibSet.sort();
}
void CastorDbService::buildCalibWidths ( ) [private]

Definition at line 81 of file CastorDbService.cc.

References CastorCalibrationWidthsSet::clear(), CastorCondObjectContainer< Item >::getAllChannels(), CastorPedestalWidths::isADC(), makeCastorCalibrationWidth(), mCalibWidthSet, mGainWidths, mPedestalWidths, mQIEData, convertSQLiteXML::ok, CastorCalibrationWidthsSet::setCalibrationWidths(), and CastorCalibrationWidthsSet::sort().

Referenced by setData().

                                       {
  // we use the set of ids for pedestal widths as the master list
  if ((!mPedestalWidths) || (!mGainWidths) || (!mQIEData) ) return;

  std::vector<DetId> ids=mPedestalWidths->getAllChannels();
  bool pedsInADC = mPedestalWidths->isADC();
  // clear the calibrations set
  mCalibWidthSet.clear();
  // loop!
  CastorCalibrationWidths tool;

  //  std::cout << " length of id-vector: " << ids.size() << std::endl;
  for (std::vector<DetId>::const_iterator id=ids.begin(); id!=ids.end(); ++id) {
    // make
    bool ok=makeCastorCalibrationWidth(*id,&tool,pedsInADC);
    // store
    if (ok) mCalibWidthSet.setCalibrationWidths(*id,tool);
    //    std::cout << "Castor calibrations built... detid no. " << HcalGenericDetId(*id) << std::endl;
  }
  mCalibWidthSet.sort();
}
const CastorCalibrations& CastorDbService::getCastorCalibrations ( const HcalGenericDetId fId) const [inline]

Definition at line 32 of file CastorDbService.h.

References CastorCalibrationsSet::getCalibrations(), and mCalibSet.

Referenced by CastorPSMonitor::processEvent().

  { return mCalibSet.getCalibrations(fId); }
const CastorCalibrationWidths& CastorDbService::getCastorCalibrationWidths ( const HcalGenericDetId fId) const [inline]
const CastorChannelStatus * CastorDbService::getCastorChannelStatus ( const HcalGenericDetId fId) const

Definition at line 183 of file CastorDbService.cc.

References CastorCondObjectContainer< Item >::getValues(), and mChannelQuality.

{
  return mChannelQuality->getValues (fId);
}
const CastorQIECoder * CastorDbService::getCastorCoder ( const HcalGenericDetId fId) const
const CastorElectronicsMap * CastorDbService::getCastorMapping ( ) const

Definition at line 179 of file CastorDbService.cc.

References mElectronicsMap.

                                                                     {
  return mElectronicsMap;
}
const CastorQIEShape * CastorDbService::getCastorShape ( ) const
const CastorGain * CastorDbService::getGain ( const HcalGenericDetId fId) const

Definition at line 151 of file CastorDbService.cc.

References CastorCondObjectContainer< Item >::getValues(), and mGains.

Referenced by CastorSimParameters::fCtoGeV(), and makeCastorCalibration().

                                                                             {
  if (mGains) {
    return mGains->getValues(fId);
  }
  return 0;
}
const CastorGainWidth * CastorDbService::getGainWidth ( const HcalGenericDetId fId) const

Definition at line 158 of file CastorDbService.cc.

References CastorCondObjectContainer< Item >::getValues(), and mGainWidths.

Referenced by CastorSimParameters::fCtoGeV(), and makeCastorCalibrationWidth().

                                                                                         {
  if (mGainWidths) {
    return mGainWidths->getValues (fId);
  }
  return 0;
}
const CastorPedestal * CastorDbService::getPedestal ( const HcalGenericDetId fId) const
const CastorPedestalWidth * CastorDbService::getPedestalWidth ( const HcalGenericDetId fId) const
bool CastorDbService::makeCastorCalibration ( const HcalGenericDetId fId,
CastorCalibrations fObject,
bool  pedestalInADC 
) const [private]

Definition at line 28 of file CastorDbService.cc.

References CastorQIECoder::charge(), getCastorCoder(), getCastorShape(), getGain(), getPedestal(), CastorPedestal::getValues(), CastorGain::getValues(), i, and x.

Referenced by buildCalibrations().

                                                                                                                               {
  if (fObject) {
    const CastorPedestal* pedestal = getPedestal (fId);
    const CastorGain* gain = getGain (fId);

    if (pedestalInADC) {
      const CastorQIEShape* shape=getCastorShape();
      const CastorQIECoder* coder=getCastorCoder(fId);
      if (pedestal && gain && shape && coder ) {
        float pedTrue[4];
        for (int i=0; i<4; i++) {
          float x=pedestal->getValues()[i];
          int x1=(int)std::floor(x);
          int x2=(int)std::floor(x+1);
          // y = (y2-y1)/(x2-x1) * (x - x1) + y1  [note: x2-x1=1]
          float y2=coder->charge(*shape,x2,i);
          float y1=coder->charge(*shape,x1,i);
          pedTrue[i]=(y2-y1)*(x-x1)+y1;
        }
        *fObject = CastorCalibrations (gain->getValues (), pedTrue );
        return true; 
      }
    } else {
      if (pedestal && gain ) {
        *fObject = CastorCalibrations (gain->getValues (), pedestal->getValues () );
        return true;
      }
    }
  }
  return false;
}
bool CastorDbService::makeCastorCalibrationWidth ( const HcalGenericDetId fId,
CastorCalibrationWidths fObject,
bool  pedestalInADC 
) const [private]

Definition at line 103 of file CastorDbService.cc.

References CastorQIECoder::charge(), getCastorCoder(), getCastorShape(), getGainWidth(), getPedestalWidth(), CastorGainWidth::getValues(), CastorPedestalWidth::getWidth(), i, and x.

Referenced by buildCalibWidths().

                                                                                                          {
  if (fObject) {
    const CastorPedestalWidth* pedestalwidth = getPedestalWidth (fId);
    const CastorGainWidth* gainwidth = getGainWidth (fId);
    if (pedestalInADC) {
      const CastorQIEShape* shape=getCastorShape();
      const CastorQIECoder* coder=getCastorCoder(fId);
      if (pedestalwidth && gainwidth && shape && coder) {
        float pedTrueWidth[4];
        for (int i=0; i<4; i++) {
          float x=pedestalwidth->getWidth(i);
          // assume QIE is linear in low range and use x1=0 and x2=1
          // y = (y2-y1) * (x) [do not add any constant, only scale!]
          float y2=coder->charge(*shape,1,i);
          float y1=coder->charge(*shape,0,i);
          pedTrueWidth[i]=(y2-y1)*x;
        }
        *fObject = CastorCalibrationWidths (gainwidth->getValues (), pedTrueWidth);
        return true; 
      } 
    } else {
      if (pedestalwidth && gainwidth) {
        float pedestalWidth [4];
        for (int i = 0; i < 4; i++) pedestalWidth [i] = pedestalwidth->getWidth (i);
        *fObject = CastorCalibrationWidths (gainwidth->getValues (), pedestalWidth);
        return true;
      }      
    }
  }
  return false;
}  
void CastorDbService::setData ( const CastorChannelQuality fItem) [inline]

Definition at line 51 of file CastorDbService.h.

References mChannelQuality.

{mChannelQuality = fItem;}
void CastorDbService::setData ( const CastorElectronicsMap fItem) [inline]

Definition at line 52 of file CastorDbService.h.

References mElectronicsMap.

{mElectronicsMap = fItem;}
void CastorDbService::setData ( const CastorGains fItem) [inline]

Definition at line 48 of file CastorDbService.h.

References buildCalibrations(), and mGains.

{mGains = fItem; buildCalibrations(); }
void CastorDbService::setData ( const CastorQIEData fItem) [inline]

Definition at line 50 of file CastorDbService.h.

References mQIEData.

{mQIEData = fItem; }
void CastorDbService::setData ( const CastorPedestals fItem) [inline]

Definition at line 46 of file CastorDbService.h.

References buildCalibrations(), and mPedestals.

void CastorDbService::setData ( const CastorPedestalWidths fItem) [inline]

Definition at line 47 of file CastorDbService.h.

References buildCalibWidths(), and mPedestalWidths.

void CastorDbService::setData ( const CastorGainWidths fItem) [inline]

Definition at line 49 of file CastorDbService.h.

References mGainWidths.

{mGainWidths = fItem; }

Member Data Documentation

Definition at line 69 of file CastorDbService.h.

Referenced by buildCalibrations(), and getCastorCalibrations().

Definition at line 70 of file CastorDbService.h.

Referenced by buildCalibWidths(), and getCastorCalibrationWidths().

Definition at line 67 of file CastorDbService.h.

Referenced by getCastorChannelStatus(), and setData().

Definition at line 68 of file CastorDbService.h.

Referenced by getCastorMapping(), and setData().

Definition at line 64 of file CastorDbService.h.

Referenced by buildCalibrations(), getGain(), and setData().

Definition at line 65 of file CastorDbService.h.

Referenced by buildCalibWidths(), getGainWidth(), and setData().

Definition at line 62 of file CastorDbService.h.

Referenced by buildCalibrations(), getPedestal(), and setData().

Definition at line 63 of file CastorDbService.h.

Referenced by buildCalibWidths(), getPedestalWidth(), and setData().

Definition at line 61 of file CastorDbService.h.