CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CastorDbService Class Reference

#include <CastorDbService.h>

Public Member Functions

void buildCalibrations ()
 
void buildCalibWidths ()
 
 CastorDbService ()
 
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 CastorPedestals *fItem)
 
void setData (const CastorPedestalWidths *fItem)
 
void setData (const CastorGains *fItem)
 
void setData (const CastorGainWidths *fItem)
 
void setData (const CastorQIEData *fItem)
 
void setData (const CastorChannelQuality *fItem)
 
void setData (const CastorElectronicsMap *fItem)
 

Private Member Functions

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
 

Detailed Description

Definition at line 28 of file CastorDbService.h.

Constructor & Destructor Documentation

CastorDbService::CastorDbService ( )

Definition at line 16 of file CastorDbService.cc.

17  :
18  mPedestals (nullptr),
19  mPedestalWidths (nullptr),
20  mGains (nullptr),
21  mGainWidths (nullptr),
22  mQIEData(nullptr),
23  mChannelQuality(nullptr),
24  mElectronicsMap(nullptr)
25  {}
const CastorQIEData * mQIEData
const CastorPedestals * mPedestals
const CastorGainWidths * mGainWidths
const CastorElectronicsMap * mElectronicsMap
const CastorPedestalWidths * mPedestalWidths
const CastorChannelQuality * mChannelQuality
const CastorGains * mGains

Member Function Documentation

void CastorDbService::buildCalibrations ( )

Definition at line 59 of file CastorDbService.cc.

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

Referenced by setData().

59  {
60  // we use the set of ids for pedestals as the master list
61  if ((!mPedestals) || (!mGains) || (!mQIEData) ) return;
62  std::vector<DetId> ids=mPedestals->getAllChannels();
63  bool pedsInADC = mPedestals->isADC();
64  // clear the calibrations set
65  mCalibSet.clear();
66  // loop!
67  CastorCalibrations tool;
68 
69  // std::cout << " length of id-vector: " << ids.size() << std::endl;
70  for (std::vector<DetId>::const_iterator id=ids.begin(); id!=ids.end(); ++id) {
71  // make
72  bool ok=makeCastorCalibration(*id,&tool,pedsInADC);
73  // store
74  if (ok) mCalibSet.setCalibrations(*id,tool);
75  // std::cout << "Castor calibrations built... detid no. " << HcalGenericDetId(*id) << std::endl;
76  }
77  mCalibSet.sort();
78 }
bool makeCastorCalibration(const HcalGenericDetId &fId, CastorCalibrations *fObject, bool pedestalInADC) const
const CastorQIEData * mQIEData
std::vector< DetId > getAllChannels() const
const CastorPedestals * mPedestals
CastorCalibrationsSet mCalibSet
void setCalibrations(const DetId id, const CastorCalibrations &ca)
bool isADC() const
const CastorGains * mGains
void CastorDbService::buildCalibWidths ( )

Definition at line 80 of file CastorDbService.cc.

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

Referenced by setData().

80  {
81  // we use the set of ids for pedestal widths as the master list
82  if ((!mPedestalWidths) || (!mGainWidths) || (!mQIEData) ) return;
83 
84  std::vector<DetId> ids=mPedestalWidths->getAllChannels();
85  bool pedsInADC = mPedestalWidths->isADC();
86  // clear the calibrations set
88  // loop!
90 
91  // std::cout << " length of id-vector: " << ids.size() << std::endl;
92  for (std::vector<DetId>::const_iterator id=ids.begin(); id!=ids.end(); ++id) {
93  // make
94  bool ok=makeCastorCalibrationWidth(*id,&tool,pedsInADC);
95  // store
96  if (ok) mCalibWidthSet.setCalibrationWidths(*id,tool);
97  // std::cout << "Castor calibrations built... detid no. " << HcalGenericDetId(*id) << std::endl;
98  }
100 }
void setCalibrationWidths(const DetId id, const CastorCalibrationWidths &ca)
const CastorQIEData * mQIEData
std::vector< DetId > getAllChannels() const
const CastorGainWidths * mGainWidths
bool makeCastorCalibrationWidth(const HcalGenericDetId &fId, CastorCalibrationWidths *fObject, bool pedestalInADC) const
const CastorPedestalWidths * mPedestalWidths
CastorCalibrationWidthsSet mCalibWidthSet
const CastorCalibrations& CastorDbService::getCastorCalibrations ( const HcalGenericDetId fId) const
inline

Definition at line 32 of file CastorDbService.h.

References CastorCalibrationsSet::getCalibrations(), and mCalibSet.

Referenced by CastorTTRecord::getEnergy_fC(), CastorSimpleReconstructor::produce(), and RecHitCorrector::produce().

33  { return mCalibSet.getCalibrations(fId); }
const CastorCalibrations & getCalibrations(const DetId id) const
CastorCalibrationsSet mCalibSet
const CastorCalibrationWidths& CastorDbService::getCastorCalibrationWidths ( const HcalGenericDetId fId) const
inline
const CastorChannelStatus * CastorDbService::getCastorChannelStatus ( const HcalGenericDetId fId) const

Definition at line 182 of file CastorDbService.cc.

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

Referenced by getCastorCalibrationWidths().

183 {
184  return mChannelQuality->getValues (fId);
185 }
const Item * getValues(DetId fId, bool throwOnFail=true) const
const CastorChannelQuality * mChannelQuality
const CastorQIECoder * CastorDbService::getCastorCoder ( const HcalGenericDetId fId) const
const CastorElectronicsMap * CastorDbService::getCastorMapping ( ) const

Definition at line 178 of file CastorDbService.cc.

References mElectronicsMap.

Referenced by getCastorCalibrationWidths(), CastorDigiToRaw::produce(), and CastorRawToDigi::produce().

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

Definition at line 150 of file CastorDbService.cc.

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

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

150  {
151  if (mGains) {
152  return mGains->getValues(fId);
153  }
154  return nullptr;
155 }
const Item * getValues(DetId fId, bool throwOnFail=true) const
const CastorGains * mGains
const CastorGainWidth * CastorDbService::getGainWidth ( const HcalGenericDetId fId) const

Definition at line 157 of file CastorDbService.cc.

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

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

157  {
158  if (mGainWidths) {
159  return mGainWidths->getValues (fId);
160  }
161  return nullptr;
162 }
const Item * getValues(DetId fId, bool throwOnFail=true) const
const CastorGainWidths * mGainWidths
const CastorPedestal * CastorDbService::getPedestal ( const HcalGenericDetId fId) const

Definition at line 136 of file CastorDbService.cc.

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

Referenced by CastorAmplifier::amplify(), getCastorCalibrationWidths(), CastorLedAnalysis::LedCastorHists(), and makeCastorCalibration().

136  {
137  if (mPedestals) {
138  return mPedestals->getValues (fId);
139  }
140  return nullptr;
141 }
const CastorPedestals * mPedestals
const Item * getValues(DetId fId, bool throwOnFail=true) const
const CastorPedestalWidth * CastorDbService::getPedestalWidth ( const HcalGenericDetId fId) const

Definition at line 143 of file CastorDbService.cc.

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

Referenced by CastorAmplifier::amplify(), getCastorCalibrationWidths(), and makeCastorCalibrationWidth().

143  {
144  if (mPedestalWidths) {
145  return mPedestalWidths->getValues (fId);
146  }
147  return nullptr;
148 }
const Item * getValues(DetId fId, bool throwOnFail=true) const
const CastorPedestalWidths * mPedestalWidths
bool CastorDbService::makeCastorCalibration ( const HcalGenericDetId fId,
CastorCalibrations fObject,
bool  pedestalInADC 
) const
private

Definition at line 27 of file CastorDbService.cc.

References CastorQIECoder::charge(), muonCSCDigis_cfi::gain, getCastorCoder(), getCastorShape(), getGain(), getPedestal(), CastorGain::getValues(), CastorPedestal::getValues(), mps_fire::i, createfilelist::int, muonCSCDigis_cfi::pedestal, x, globals_cff::x1, and globals_cff::x2.

Referenced by buildCalibrations(), and setData().

27  {
28  if (fObject) {
29  const CastorPedestal* pedestal = getPedestal (fId);
30  const CastorGain* gain = getGain (fId);
31 
32  if (pedestalInADC) {
33  const CastorQIEShape* shape=getCastorShape();
34  const CastorQIECoder* coder=getCastorCoder(fId);
35  if (pedestal && gain && shape && coder ) {
36  float pedTrue[4];
37  for (int i=0; i<4; i++) {
38  float x=pedestal->getValues()[i];
39  int x1=(int)std::floor(x);
40  int x2=(int)std::floor(x+1);
41  // y = (y2-y1)/(x2-x1) * (x - x1) + y1 [note: x2-x1=1]
42  float y2=coder->charge(*shape,x2,i);
43  float y1=coder->charge(*shape,x1,i);
44  pedTrue[i]=(y2-y1)*(x-x1)+y1;
45  }
46  *fObject = CastorCalibrations (gain->getValues (), pedTrue );
47  return true;
48  }
49  } else {
50  if (pedestal && gain ) {
51  *fObject = CastorCalibrations (gain->getValues (), pedestal->getValues () );
52  return true;
53  }
54  }
55  }
56  return false;
57 }
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
const CastorQIEShape * getCastorShape() const
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
const CastorGain * getGain(const HcalGenericDetId &fId) const
const float * getValues() const
get value for all capId = 0..3
const float * getValues() const
get value for all capId = 0..3
Definition: CastorGain.h:17
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const
bool CastorDbService::makeCastorCalibrationWidth ( const HcalGenericDetId fId,
CastorCalibrationWidths fObject,
bool  pedestalInADC 
) const
private

Definition at line 102 of file CastorDbService.cc.

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

Referenced by buildCalibWidths(), and setData().

103  {
104  if (fObject) {
105  const CastorPedestalWidth* pedestalwidth = getPedestalWidth (fId);
106  const CastorGainWidth* gainwidth = getGainWidth (fId);
107  if (pedestalInADC) {
108  const CastorQIEShape* shape=getCastorShape();
109  const CastorQIECoder* coder=getCastorCoder(fId);
110  if (pedestalwidth && gainwidth && shape && coder) {
111  float pedTrueWidth[4];
112  for (int i=0; i<4; i++) {
113  float x=pedestalwidth->getWidth(i);
114  // assume QIE is linear in low range and use x1=0 and x2=1
115  // y = (y2-y1) * (x) [do not add any constant, only scale!]
116  float y2=coder->charge(*shape,1,i);
117  float y1=coder->charge(*shape,0,i);
118  pedTrueWidth[i]=(y2-y1)*x;
119  }
120  *fObject = CastorCalibrationWidths (gainwidth->getValues (), pedTrueWidth);
121  return true;
122  }
123  } else {
124  if (pedestalwidth && gainwidth) {
125  float pedestalWidth [4];
126  for (int i = 0; i < 4; i++) pedestalWidth [i] = pedestalwidth->getWidth (i);
127  *fObject = CastorCalibrationWidths (gainwidth->getValues (), pedestalWidth);
128  return true;
129  }
130  }
131  }
132  return false;
133 }
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
const CastorQIEShape * getCastorShape() const
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
const float * getValues() const
get value for all capId = 0..3
const CastorGainWidth * getGainWidth(const HcalGenericDetId &fId) const
const CastorPedestalWidth * getPedestalWidth(const HcalGenericDetId &fId) const
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const
void CastorDbService::setData ( const CastorPedestals fItem)
inline
void CastorDbService::setData ( const CastorPedestalWidths fItem)
inline

Definition at line 47 of file CastorDbService.h.

References mPedestalWidths.

47 { mPedestalWidths = fItem; }
const CastorPedestalWidths * mPedestalWidths
void CastorDbService::setData ( const CastorGains fItem)
inline

Definition at line 48 of file CastorDbService.h.

References mGains.

48 { mGains = fItem; }
const CastorGains * mGains
void CastorDbService::setData ( const CastorGainWidths fItem)
inline

Definition at line 49 of file CastorDbService.h.

References mGainWidths.

49 {mGainWidths = fItem; }
const CastorGainWidths * mGainWidths
void CastorDbService::setData ( const CastorQIEData fItem)
inline

Definition at line 50 of file CastorDbService.h.

References mQIEData.

50 {mQIEData = fItem; }
const CastorQIEData * mQIEData
void CastorDbService::setData ( const CastorChannelQuality fItem)
inline

Definition at line 51 of file CastorDbService.h.

References mChannelQuality.

51 {mChannelQuality = fItem;}
const CastorChannelQuality * mChannelQuality
void CastorDbService::setData ( const CastorElectronicsMap fItem)
inline

Definition at line 52 of file CastorDbService.h.

References buildCalibrations(), buildCalibWidths(), makeCastorCalibration(), makeCastorCalibrationWidth(), and mElectronicsMap.

52 {mElectronicsMap = fItem;}
const CastorElectronicsMap * mElectronicsMap

Member Data Documentation

CastorCalibrationsSet CastorDbService::mCalibSet
private

Definition at line 69 of file CastorDbService.h.

Referenced by buildCalibrations(), and getCastorCalibrations().

CastorCalibrationWidthsSet CastorDbService::mCalibWidthSet
private

Definition at line 70 of file CastorDbService.h.

Referenced by buildCalibWidths(), and getCastorCalibrationWidths().

const CastorChannelQuality* CastorDbService::mChannelQuality
private

Definition at line 67 of file CastorDbService.h.

Referenced by getCastorChannelStatus(), and setData().

const CastorElectronicsMap* CastorDbService::mElectronicsMap
private

Definition at line 68 of file CastorDbService.h.

Referenced by getCastorMapping(), and setData().

const CastorGains* CastorDbService::mGains
private

Definition at line 64 of file CastorDbService.h.

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

const CastorGainWidths* CastorDbService::mGainWidths
private

Definition at line 65 of file CastorDbService.h.

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

const CastorPedestals* CastorDbService::mPedestals
private

Definition at line 62 of file CastorDbService.h.

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

const CastorPedestalWidths* CastorDbService::mPedestalWidths
private

Definition at line 63 of file CastorDbService.h.

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

const CastorQIEData* CastorDbService::mQIEData
private