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

Definition at line 16 of file CastorDbService.cc.

17  : mPedestals(nullptr),
18  mPedestalWidths(nullptr),
19  mGains(nullptr),
20  mGainWidths(nullptr),
21  mQIEData(nullptr),
22  mChannelQuality(nullptr),
23  mElectronicsMap(nullptr) {}

Member Function Documentation

◆ buildCalibrations()

void CastorDbService::buildCalibrations ( )

Definition at line 59 of file CastorDbService.cc.

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

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

◆ buildCalibWidths()

void CastorDbService::buildCalibWidths ( )

Definition at line 82 of file CastorDbService.cc.

82  {
83  // we use the set of ids for pedestal widths as the master list
84  if ((!mPedestalWidths) || (!mGainWidths) || (!mQIEData))
85  return;
86 
87  std::vector<DetId> ids = mPedestalWidths->getAllChannels();
88  bool pedsInADC = mPedestalWidths->isADC();
89  // clear the calibrations set
91  // loop!
93 
94  // std::cout << " length of id-vector: " << ids.size() << std::endl;
95  for (std::vector<DetId>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
96  // make
97  bool ok = makeCastorCalibrationWidth(*id, &tool, pedsInADC);
98  // store
99  if (ok)
101  // std::cout << "Castor calibrations built... detid no. " << HcalGenericDetId(*id) << std::endl;
102  }
104 }

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

◆ getCastorCalibrations()

const CastorCalibrations& CastorDbService::getCastorCalibrations ( const HcalGenericDetId fId) const
inline

Definition at line 32 of file CastorDbService.h.

32  {
33  return mCalibSet.getCalibrations(fId);
34  }

References CastorCalibrationsSet::getCalibrations(), and mCalibSet.

◆ getCastorCalibrationWidths()

const CastorCalibrationWidths& CastorDbService::getCastorCalibrationWidths ( const HcalGenericDetId fId) const
inline

Definition at line 35 of file CastorDbService.h.

35  {
37  }

References CastorCalibrationWidthsSet::getCalibrationWidths(), and mCalibWidthSet.

◆ getCastorChannelStatus()

const CastorChannelStatus * CastorDbService::getCastorChannelStatus ( const HcalGenericDetId fId) const

Definition at line 185 of file CastorDbService.cc.

185  {
186  return mChannelQuality->getValues(fId);
187 }

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

◆ getCastorCoder()

const CastorQIECoder * CastorDbService::getCastorCoder ( const HcalGenericDetId fId) const

Definition at line 169 of file CastorDbService.cc.

169  {
170  if (mQIEData) {
171  return mQIEData->getCoder(fId);
172  }
173  return nullptr;
174 }

References CastorQIEData::getCoder(), and mQIEData.

Referenced by CastorCoderFactory::coder(), makeCastorCalibration(), and makeCastorCalibrationWidth().

◆ getCastorMapping()

const CastorElectronicsMap * CastorDbService::getCastorMapping ( ) const

Definition at line 183 of file CastorDbService.cc.

183 { return mElectronicsMap; }

References mElectronicsMap.

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

◆ getCastorShape()

const CastorQIEShape * CastorDbService::getCastorShape ( ) const

Definition at line 176 of file CastorDbService.cc.

176  {
177  if (mQIEData) {
178  return &mQIEData->getShape();
179  }
180  return nullptr;
181 }

References CastorQIEData::getShape(), and mQIEData.

Referenced by CastorCoderFactory::coder(), makeCastorCalibration(), and makeCastorCalibrationWidth().

◆ getGain()

const CastorGain * CastorDbService::getGain ( const HcalGenericDetId fId) const

Definition at line 155 of file CastorDbService.cc.

155  {
156  if (mGains) {
157  return mGains->getValues(fId);
158  }
159  return nullptr;
160 }

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

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

◆ getGainWidth()

const CastorGainWidth * CastorDbService::getGainWidth ( const HcalGenericDetId fId) const

Definition at line 162 of file CastorDbService.cc.

162  {
163  if (mGainWidths) {
164  return mGainWidths->getValues(fId);
165  }
166  return nullptr;
167 }

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

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

◆ getPedestal()

const CastorPedestal * CastorDbService::getPedestal ( const HcalGenericDetId fId) const

Definition at line 141 of file CastorDbService.cc.

141  {
142  if (mPedestals) {
143  return mPedestals->getValues(fId);
144  }
145  return nullptr;
146 }

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

Referenced by CastorAmplifier::amplify(), and makeCastorCalibration().

◆ getPedestalWidth()

const CastorPedestalWidth * CastorDbService::getPedestalWidth ( const HcalGenericDetId fId) const

Definition at line 148 of file CastorDbService.cc.

148  {
149  if (mPedestalWidths) {
150  return mPedestalWidths->getValues(fId);
151  }
152  return nullptr;
153 }

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

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

◆ makeCastorCalibration()

bool CastorDbService::makeCastorCalibration ( const HcalGenericDetId fId,
CastorCalibrations fObject,
bool  pedestalInADC 
) const
private

Definition at line 25 of file CastorDbService.cc.

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 }

References CastorQIECoder::charge(), PedestalClient_cfi::gain, getCastorCoder(), getCastorShape(), getGain(), getPedestal(), mps_fire::i, createfilelist::int, EcalCondDBWriter_cfi::pedestal, x, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, testProducerWithPsetDescEmpty_cfi::y1, and testProducerWithPsetDescEmpty_cfi::y2.

Referenced by buildCalibrations().

◆ makeCastorCalibrationWidth()

bool CastorDbService::makeCastorCalibrationWidth ( const HcalGenericDetId fId,
CastorCalibrationWidths fObject,
bool  pedestalInADC 
) const
private

Definition at line 106 of file CastorDbService.cc.

108  {
109  if (fObject) {
110  const CastorPedestalWidth* pedestalwidth = getPedestalWidth(fId);
111  const CastorGainWidth* gainwidth = getGainWidth(fId);
112  if (pedestalInADC) {
113  const CastorQIEShape* shape = getCastorShape();
114  const CastorQIECoder* coder = getCastorCoder(fId);
115  if (pedestalwidth && gainwidth && shape && coder) {
116  float pedTrueWidth[4];
117  for (int i = 0; i < 4; i++) {
118  float x = pedestalwidth->getWidth(i);
119  // assume QIE is linear in low range and use x1=0 and x2=1
120  // y = (y2-y1) * (x) [do not add any constant, only scale!]
121  float y2 = coder->charge(*shape, 1, i);
122  float y1 = coder->charge(*shape, 0, i);
123  pedTrueWidth[i] = (y2 - y1) * x;
124  }
125  *fObject = CastorCalibrationWidths(gainwidth->getValues(), pedTrueWidth);
126  return true;
127  }
128  } else {
129  if (pedestalwidth && gainwidth) {
130  float pedestalWidth[4];
131  for (int i = 0; i < 4; i++)
132  pedestalWidth[i] = pedestalwidth->getWidth(i);
133  *fObject = CastorCalibrationWidths(gainwidth->getValues(), pedestalWidth);
134  return true;
135  }
136  }
137  }
138  return false;
139 }

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

Referenced by buildCalibWidths().

◆ setData() [1/7]

void CastorDbService::setData ( const CastorChannelQuality fItem)
inline

Definition at line 53 of file CastorDbService.h.

53 { mChannelQuality = fItem; }

References mChannelQuality.

◆ setData() [2/7]

void CastorDbService::setData ( const CastorElectronicsMap fItem)
inline

Definition at line 54 of file CastorDbService.h.

54 { mElectronicsMap = fItem; }

References mElectronicsMap.

◆ setData() [3/7]

void CastorDbService::setData ( const CastorGains fItem)
inline

Definition at line 50 of file CastorDbService.h.

50 { mGains = fItem; }

References mGains.

◆ setData() [4/7]

void CastorDbService::setData ( const CastorGainWidths fItem)
inline

Definition at line 51 of file CastorDbService.h.

51 { mGainWidths = fItem; }

References mGainWidths.

◆ setData() [5/7]

void CastorDbService::setData ( const CastorPedestals fItem)
inline

Definition at line 48 of file CastorDbService.h.

48 { mPedestals = fItem; }

References mPedestals.

◆ setData() [6/7]

void CastorDbService::setData ( const CastorPedestalWidths fItem)
inline

Definition at line 49 of file CastorDbService.h.

49 { mPedestalWidths = fItem; }

References mPedestalWidths.

◆ setData() [7/7]

void CastorDbService::setData ( const CastorQIEData fItem)
inline

Definition at line 52 of file CastorDbService.h.

52 { mQIEData = fItem; }

References mQIEData.

Member Data Documentation

◆ mCalibSet

CastorCalibrationsSet CastorDbService::mCalibSet
private

Definition at line 71 of file CastorDbService.h.

Referenced by buildCalibrations(), and getCastorCalibrations().

◆ mCalibWidthSet

CastorCalibrationWidthsSet CastorDbService::mCalibWidthSet
private

Definition at line 72 of file CastorDbService.h.

Referenced by buildCalibWidths(), and getCastorCalibrationWidths().

◆ mChannelQuality

const CastorChannelQuality* CastorDbService::mChannelQuality
private

Definition at line 69 of file CastorDbService.h.

Referenced by getCastorChannelStatus(), and setData().

◆ mElectronicsMap

const CastorElectronicsMap* CastorDbService::mElectronicsMap
private

Definition at line 70 of file CastorDbService.h.

Referenced by getCastorMapping(), and setData().

◆ mGains

const CastorGains* CastorDbService::mGains
private

Definition at line 66 of file CastorDbService.h.

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

◆ mGainWidths

const CastorGainWidths* CastorDbService::mGainWidths
private

Definition at line 67 of file CastorDbService.h.

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

◆ mPedestals

const CastorPedestals* CastorDbService::mPedestals
private

Definition at line 64 of file CastorDbService.h.

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

◆ mPedestalWidths

const CastorPedestalWidths* CastorDbService::mPedestalWidths
private

Definition at line 65 of file CastorDbService.h.

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

◆ mQIEData

const CastorQIEData* CastorDbService::mQIEData
private
CastorDbService::mChannelQuality
const CastorChannelQuality * mChannelQuality
Definition: CastorDbService.h:69
CastorCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: CastorCondObjectContainer.h:65
mps_fire.i
i
Definition: mps_fire.py:428
CastorDbService::mPedestals
const CastorPedestals * mPedestals
Definition: CastorDbService.h:64
CastorDbService::makeCastorCalibration
bool makeCastorCalibration(const HcalGenericDetId &fId, CastorCalibrations *fObject, bool pedestalInADC) const
Definition: CastorDbService.cc:25
CastorCalibrationsSet::clear
void clear()
Definition: CastorCalibrationsSet.cc:38
CastorDbService::mCalibSet
CastorCalibrationsSet mCalibSet
Definition: CastorDbService.h:71
CastorDbService::getPedestalWidth
const CastorPedestalWidth * getPedestalWidth(const HcalGenericDetId &fId) const
Definition: CastorDbService.cc:148
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
CastorCalibrationWidthsSet::setCalibrationWidths
void setCalibrationWidths(const DetId id, const CastorCalibrationWidths &ca)
Definition: CastorCalibrationWidthsSet.cc:23
CastorPedestals::isADC
bool isADC() const
Definition: CastorPedestals.h:25
CastorDbService::mGainWidths
const CastorGainWidths * mGainWidths
Definition: CastorDbService.h:67
CastorCalibrationsSet::setCalibrations
void setCalibrations(const DetId id, const CastorCalibrations &ca)
Definition: CastorCalibrationsSet.cc:21
CastorDbService::getCastorCoder
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const
Definition: CastorDbService.cc:169
DDAxes::x
CastorCalibrationsSet::sort
void sort()
Definition: CastorCalibrationsSet.cc:32
CastorPedestal
Definition: CastorPedestal.h:16
CastorPedestalWidth
Definition: CastorPedestalWidth.h:16
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
CastorPedestalWidth::getWidth
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
Definition: CastorPedestalWidth.cc:32
CastorCondObjectContainer::getAllChannels
std::vector< DetId > getAllChannels() const
Definition: CastorCondObjectContainer.h:119
CastorDbService::getPedestal
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
Definition: CastorDbService.cc:141
CastorCalibrations
Definition: CastorCalibrations.h:9
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
CastorDbService::mCalibWidthSet
CastorCalibrationWidthsSet mCalibWidthSet
Definition: CastorDbService.h:72
CastorDbService::mPedestalWidths
const CastorPedestalWidths * mPedestalWidths
Definition: CastorDbService.h:65
CastorCalibrationWidthsSet::clear
void clear()
Definition: CastorCalibrationWidthsSet.cc:39
CastorDbService::getGainWidth
const CastorGainWidth * getGainWidth(const HcalGenericDetId &fId) const
Definition: CastorDbService.cc:162
CastorCalibrationWidthsSet::sort
void sort()
Definition: CastorCalibrationWidthsSet.cc:33
CastorPedestalWidths::isADC
bool isADC() const
Definition: CastorPedestalWidths.h:25
CastorGainWidth
Definition: CastorGainWidth.h:12
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
CastorGainWidth::getValues
const float * getValues() const
get value for all capId = 0..3
Definition: CastorGainWidth.h:15
CastorDbService::getCastorShape
const CastorQIEShape * getCastorShape() const
Definition: CastorDbService.cc:176
CastorCalibrationsSet::getCalibrations
const CastorCalibrations & getCalibrations(const DetId id) const
Definition: CastorCalibrationsSet.cc:8
CastorQIECoder::charge
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: CastorQIECoder.cc:17
createfilelist.int
int
Definition: createfilelist.py:10
CastorQIEData::getCoder
const CastorQIECoder * getCoder(DetId fId) const
get QIE parameters
Definition: CastorQIEData.h:37
CastorGain
Definition: CastorGain.h:13
EcalCondDBWriter_cfi.pedestal
pedestal
Definition: EcalCondDBWriter_cfi.py:49
CastorDbService::getGain
const CastorGain * getGain(const HcalGenericDetId &fId) const
Definition: CastorDbService.cc:155
CastorDbService::makeCastorCalibrationWidth
bool makeCastorCalibrationWidth(const HcalGenericDetId &fId, CastorCalibrationWidths *fObject, bool pedestalInADC) const
Definition: CastorDbService.cc:106
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
CastorDbService::mQIEData
const CastorQIEData * mQIEData
Definition: CastorDbService.h:68
CastorDbService::mGains
const CastorGains * mGains
Definition: CastorDbService.h:66
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
CastorCalibrationWidthsSet::getCalibrationWidths
const CastorCalibrationWidths & getCalibrationWidths(const DetId id) const
Definition: CastorCalibrationWidthsSet.cc:9
CastorDbService::mElectronicsMap
const CastorElectronicsMap * mElectronicsMap
Definition: CastorDbService.h:70
CastorQIECoder
Definition: CastorQIECoder.h:21
CastorCalibrationWidths
Definition: CastorCalibrationWidths.h:9
CastorQIEShape
Definition: CastorQIEShape.h:14
CastorQIEData::getShape
const CastorQIEShape & getShape() const
get basic shape
Definition: CastorQIEData.h:35