CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorPedestalWidth.cc
Go to the documentation of this file.
1 
11 #include <math.h>
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 }
26 
28  for (int i = 16; --i >= 0; *(&mSigma00 + i) = 0) {}
29 }
30 
31 float CastorPedestalWidth::getWidth (int fCapId) const {
32  return sqrt (*(getValues () + offset (fCapId, fCapId)));
33 }
34 
35 float CastorPedestalWidth::getSigma (int fCapId1, int fCapId2) const {
36  return *(getValues () + offset (fCapId1, fCapId2));
37 }
38 
39 void CastorPedestalWidth::setSigma (int fCapId1, int fCapId2, float fSigma) {
40  *(&mSigma00 + offset (fCapId1, fCapId2)) = fSigma;
41 }
42 
43 // produces pedestal noise in assumption of near correlations and small variations
44 void CastorPedestalWidth::makeNoise (unsigned fFrames, const double* fGauss, double* fNoise) const {
45  double s_xx_mean = (getSigma (0,0) + getSigma (1,1) + getSigma (2,2) + getSigma (3,3)) / 4;
46  double s_xy_mean = (getSigma (1,0) + getSigma (2,1) + getSigma (3,2) + getSigma (3,0)) / 4;
47  double sigma = sqrt (0.5 * (s_xx_mean + sqrt (s_xx_mean*s_xx_mean - 2*s_xy_mean*s_xy_mean)));
48  double corr = sigma == 0 ? 0 : 0.5*s_xy_mean / sigma;
49  for (unsigned i = 0; i < fFrames; i++) {
50  fNoise [i] = fGauss[i]*sigma;
51  if (i > 0) fNoise [i] += fGauss[i-1]*corr;
52  if (i < fFrames-1) fNoise [i] += fGauss[i+1]*corr;
53  }
54 }
int i
Definition: DBlmapReader.cc:9
void setSigma(int fCapId1, int fCapId2, float fSigma)
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
void makeNoise(unsigned fFrames, const double *fGauss, double *fNoise) const
T sqrt(T t)
Definition: SSEVec.h:18
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
JetCorrectorParameters corr
Definition: classes.h:5
const float * getValues() const
get value for all capId = 0..3, 10 values in total