CMS 3D CMS Logo

CastorPedestalWidth.cc
Go to the documentation of this file.
1 
11 #include <cmath>
12 #include <iostream>
13 
15 
16 namespace {
17  int offset(int fCapId1, int fCapId2) {
18  // static int offsets [4] = {0, 1, 3, 6};
19  // if (fCapId1 < fCapId2) { // swap
20  // int tmp = fCapId1; fCapId1 = fCapId2; fCapId2 = tmp;
21  // }
22  // return offsets [fCapId1] + fCapId2;
23  return fCapId1 * 4 + fCapId2;
24  }
25 } // namespace
26 
28  for (int i = 16; --i >= 0; *(&mSigma00 + i) = 0) {
29  }
30 }
31 
32 float CastorPedestalWidth::getWidth(int fCapId) const { return sqrt(*(getValues() + offset(fCapId, fCapId))); }
33 
34 float CastorPedestalWidth::getSigma(int fCapId1, int fCapId2) const {
35  return *(getValues() + offset(fCapId1, fCapId2));
36 }
37 
38 void CastorPedestalWidth::setSigma(int fCapId1, int fCapId2, float fSigma) {
39  *(&mSigma00 + offset(fCapId1, fCapId2)) = fSigma;
40 }
41 
42 // produces pedestal noise in assumption of near correlations and small variations
43 void CastorPedestalWidth::makeNoise(unsigned fFrames, const double* fGauss, double* fNoise) const {
44  double s_xx_mean = (getSigma(0, 0) + getSigma(1, 1) + getSigma(2, 2) + getSigma(3, 3)) / 4;
45  double s_xy_mean = (getSigma(1, 0) + getSigma(2, 1) + getSigma(3, 2) + getSigma(3, 0)) / 4;
46  double sigma = sqrt(0.5 * (s_xx_mean + sqrt(s_xx_mean * s_xx_mean - 2 * s_xy_mean * s_xy_mean)));
47  double corr = sigma == 0 ? 0 : 0.5 * s_xy_mean / sigma;
48  for (unsigned i = 0; i < fFrames; i++) {
49  fNoise[i] = fGauss[i] * sigma;
50  if (i > 0)
51  fNoise[i] += fGauss[i - 1] * corr;
52  if (i < fFrames - 1)
53  fNoise[i] += fGauss[i + 1] * corr;
54  }
55 }
mps_fire.i
i
Definition: mps_fire.py:428
CastorPedestalWidth::CastorPedestalWidth
CastorPedestalWidth(int fId=0)
Definition: CastorPedestalWidth.cc:27
CastorPedestalWidth::getWidth
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
Definition: CastorPedestalWidth.cc:32
CastorPedestalWidth.h
CastorPedestalWidth::mSigma00
float mSigma00
Definition: CastorPedestalWidth.h:38
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CastorPedestalWidth::makeNoise
void makeNoise(unsigned fFrames, const double *fGauss, double *fNoise) const
Definition: CastorPedestalWidth.cc:43
CastorPedestalWidth::getValues
const float * getValues() const
get value for all capId = 0..3, 10 values in total
Definition: CastorPedestalWidth.h:19
CastorPedestalWidth::getSigma
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
Definition: CastorPedestalWidth.cc:34
CastorPedestalWidth::setSigma
void setSigma(int fCapId1, int fCapId2, float fSigma)
Definition: CastorPedestalWidth.cc:38
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82