CMS 3D CMS Logo

SiPixelCPEGenericDBErrorParametrization.cc
Go to the documentation of this file.
3 #include <iostream>
4 #include <cmath>
5 
6 const float math_pi = 3.14159265;
7 
8 //These are the bin parameters -- they determine the width of the bins
9 //998, 999 refer to bins where the 0 should always be returned
10 const float SiPixelCPEGenericDBErrorParametrization::bx_a_min[3] = {1.525, 1.475, 1.425};
11 const float SiPixelCPEGenericDBErrorParametrization::bx_a_max[3] = {1.725, 1.675, 1.625};
12 
13 const float SiPixelCPEGenericDBErrorParametrization::fx_a_min[2] = {0.165, 0.185};
14 const float SiPixelCPEGenericDBErrorParametrization::fx_a_max[2] = {0.285, 0.465};
15 const float SiPixelCPEGenericDBErrorParametrization::fx_b_min[2] = {998, 998};
16 const float SiPixelCPEGenericDBErrorParametrization::fx_b_max[2] = {999, 999};
17 
19  1.47078, 1.47078, 1.47078, 1.47078, 1.47078, 1.47078};
21  1.67078, 1.67078, 1.67078, 1.67078, 1.67078, 1.67078};
22 const float SiPixelCPEGenericDBErrorParametrization::by_b_min[6] = {0.05, 0.15, 0.70, 0.95, 1.15, 1.20};
23 const float SiPixelCPEGenericDBErrorParametrization::by_b_max[6] = {0.50, 0.90, 1.05, 1.15, 1.20, 1.40};
24 
25 const float SiPixelCPEGenericDBErrorParametrization::fy_a_min[2] = {998, 998};
26 const float SiPixelCPEGenericDBErrorParametrization::fy_a_max[2] = {999, 999};
27 const float SiPixelCPEGenericDBErrorParametrization::fy_b_min[2] = {0.31, 0.31};
28 const float SiPixelCPEGenericDBErrorParametrization::fy_b_max[2] = {0.39, 0.39};
29 
30 //Constants based on subpart
31 const float SiPixelCPEGenericDBErrorParametrization::errors_big_pix[4] = {0.0070, 0.0030, 0.0068, 0.0040};
32 const int SiPixelCPEGenericDBErrorParametrization::size_max[4] = {5, 2, 0, 0};
33 
34 //Garbage is set to hold a place for bx_b, though we don't parametrize it the same way
35 const float garbage[1] = {-9999.99};
36 
37 const float* SiPixelCPEGenericDBErrorParametrization::a_min[4] = {by_a_min, bx_a_min, fy_a_min, fx_a_min};
38 const float* SiPixelCPEGenericDBErrorParametrization::a_max[4] = {by_a_max, bx_a_max, fy_a_max, fx_a_max};
39 const float* SiPixelCPEGenericDBErrorParametrization::b_min[4] = {by_b_min, garbage, fy_b_min, fx_b_min};
40 const float* SiPixelCPEGenericDBErrorParametrization::b_max[4] = {by_b_max, garbage, fy_b_max, fx_b_max};
41 
42 //Bin Sizes
43 const int SiPixelCPEGenericDBErrorParametrization::part_bin_size[4] = {0, 240, 360, 380};
44 const int SiPixelCPEGenericDBErrorParametrization::size_bin_size[4] = {40, 40, 40, 40};
46 const int SiPixelCPEGenericDBErrorParametrization::beta_bin_size[4] = {1, 10, 1, 10};
47 
49 
51 
54 }
55 
56 //The function which is called to return errX and errY. Used in CPEs.
58  GeomDetType::SubDetector pixelPart,
59  int sizex,
60  int sizey,
61  float alpha,
62  float beta,
63  bool bigInX,
64  bool bigInY) {
65  std::pair<float, float> element;
66  std::pair<float, float> errors;
67 
68  if (!GeomDetEnumerators::isTrackerPixel(pixelPart))
69  throw cms::Exception("PixelCPEGenericDBErrorParametrization::getError") << "Non-pixel detector type !!!";
70  if (GeomDetEnumerators::isBarrel(pixelPart)) {
71  element = std::pair<float, float>(index(1, sizex, alpha, beta, bigInX), //1 -- Bx
72  index(0, sizey, alpha, beta, bigInY)); //0 -- By
73  } else {
74  element = std::pair<float, float>(index(3, sizex, alpha, beta, bigInX), //3 -- Fx
75  index(2, sizey, alpha, beta, bigInY)); //2 -- Fy
76  }
77 
78  if (bigInX && sizex == 1)
79  errors.first = element.first;
80  else
81  errors.first = parmErrors->errors()[(int)element.first].sigma;
82  if (bigInY && sizey == 1)
83  errors.second = element.second;
84  else
85  errors.second = parmErrors->errors()[(int)element.second].sigma;
86 
87  return errors;
88 }
89 
90 //The function which is called to return errX and errY. Used outside CPEs with access to ES.
92  GeomDetType::SubDetector pixelPart, int sizex, int sizey, float alpha, float beta, bool bigInX, bool bigInY) {
93  std::pair<float, float> element;
94  std::pair<float, float> errors;
95 
96  if (!GeomDetEnumerators::isTrackerPixel(pixelPart))
97  throw cms::Exception("PixelCPEGenericDBErrorParametrization::getError") << "Non-pixel detector type !!!";
98  if (GeomDetEnumerators::isBarrel(pixelPart)) {
99  element = std::pair<float, float>(index(1, sizex, alpha, beta, bigInX), //1 -- Bx
100  index(0, sizey, alpha, beta, bigInY)); //0 -- By
101  } else {
102  element = std::pair<float, float>(index(3, sizex, alpha, beta, bigInX), //3 -- Fx
103  index(2, sizey, alpha, beta, bigInY)); //2 -- Fy
104  }
105 
106  if (bigInX && sizex == 1)
107  errors.first = element.first;
108  else
109  errors.first = errorsH->errors()[(int)element.first].sigma;
110  if (bigInY && sizey == 1)
111  errors.second = element.second;
112  else
113  errors.second = errorsH->errors()[(int)element.second].sigma;
114 
115  return errors;
116 }
117 
118 float SiPixelCPEGenericDBErrorParametrization::index(int ind_subpart, int size, float alpha, float beta, bool big) {
119  //This is a check for big pixels. If it passes, the code returns a given error and the function ends.
120  if (big && size == 1)
121  return errors_big_pix[ind_subpart];
122 
123  int ind_size = std::min(size - 1, size_max[ind_subpart]);
124 
125  float alpha_rad = -999.9;
126  float betap_rad = -999.9;
127 
128  int ind_alpha = -99;
129  int ind_beta = -99;
130 
131  float binw_a = -999.9;
132  float binw_b = -999.9;
133  int maxbin_a = -99;
134  int maxbin_b = -99;
135 
136  betap_rad = fabs(math_pi / 2.0 - beta);
137  //We must take into account that Fx(subpart=3) has different alpha parametrization
138  if (ind_subpart == 3)
139  alpha_rad = fabs(math_pi / 2.0 - alpha);
140  else
141  alpha_rad = fabs(alpha);
142 
143  //Sets the correct binning for alpha and beta based on whether in x or y
144  if (ind_subpart == 0 || ind_subpart == 2) {
145  binw_a = (a_max[ind_subpart][ind_size] - a_min[ind_subpart][ind_size]) / 2.0;
146  binw_b = (b_max[ind_subpart][ind_size] - b_min[ind_subpart][ind_size]) / 8.0;
147  maxbin_a = 3;
148  maxbin_b = 9;
149  } else {
150  binw_a = (a_max[ind_subpart][ind_size] - a_min[ind_subpart][ind_size]) / 8.0;
151  binw_b = (b_max[ind_subpart][ind_size] - b_min[ind_subpart][ind_size]) / 2.0;
152  maxbin_a = 3;
153  maxbin_b = 9;
154  }
155 
156  //Binning for alpha
157  if (alpha_rad < a_min[ind_subpart][ind_size])
158  ind_alpha = 0;
159  else if (alpha_rad >= a_max[ind_subpart][ind_size])
160  ind_alpha = maxbin_a;
161  else
162  ind_alpha = 1 + (int)((alpha_rad - a_min[ind_subpart][ind_size]) / binw_a);
163 
164  //Binning for beta -- we need to account for Bx(subpart=1) having uneven binning
165  if (ind_subpart == 1) {
166  if (betap_rad <= 0.7)
167  ind_beta = 0;
168  else if (0.7 < betap_rad && betap_rad <= 1.0)
169  ind_beta = 1;
170  else if (1.0 < betap_rad && betap_rad <= 1.2)
171  ind_beta = 2;
172  else if (1.2 <= betap_rad)
173  ind_beta = 3;
174  } else if (betap_rad < b_min[ind_subpart][ind_size])
175  ind_beta = 0;
176  else if (betap_rad >= b_max[ind_subpart][ind_size])
177  ind_beta = maxbin_b;
178  else
179  ind_beta = 1 + (int)((betap_rad - b_min[ind_subpart][ind_size]) / binw_b);
180 
181  //Index to be used to find error in database
182  int index = part_bin_size[ind_subpart] + size_bin_size[ind_subpart] * ind_size +
183  alpha_bin_size[ind_subpart] * ind_alpha + beta_bin_size[ind_subpart] * ind_beta;
184 
185  return index;
186 }
SiPixelCPEGenericDBErrorParametrization::a_max
static const float * a_max[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:67
SiPixelCPEGenericDBErrorParametrization::fy_a_max
static const float fy_a_max[2]
Definition: SiPixelCPEGenericDBErrorParametrization.h:54
SiPixelCPEGenericDBErrorParametrization::fx_a_min
static const float fx_a_min[2]
Definition: SiPixelCPEGenericDBErrorParametrization.h:43
GeomDetEnumerators::SubDetector
SubDetector
Definition: GeomDetEnumerators.h:10
SiPixelCPEGenericErrorParm
Definition: SiPixelCPEGenericErrorParm.h:15
SiPixelCPEGenericErrorParmRcd
Definition: SiPixelCPEGenericErrorParmRcd.h:24
SiPixelCPEGenericDBErrorParametrization::fx_a_max
static const float fx_a_max[2]
Definition: SiPixelCPEGenericDBErrorParametrization.h:44
SiPixelCPEGenericDBErrorParametrization::fy_b_max
static const float fy_b_max[2]
Definition: SiPixelCPEGenericDBErrorParametrization.h:56
min
T min(T a, T b)
Definition: MathUtil.h:58
HLT_FULL_cff.beta
beta
Definition: HLT_FULL_cff.py:8651
SiPixelCPEGenericDBErrorParametrization::a_min
static const float * a_min[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:66
SiPixelCPEGenericDBErrorParametrization::bx_a_max
static const float bx_a_max[3]
Definition: SiPixelCPEGenericDBErrorParametrization.h:41
SiPixelCPEGenericDBErrorParametrization.h
SiPixelCPEGenericDBErrorParametrization::fy_a_min
static const float fy_a_min[2]
Definition: SiPixelCPEGenericDBErrorParametrization.h:53
if
if(0==first)
Definition: CAHitNtupletGeneratorKernelsImpl.h:58
alpha
float alpha
Definition: AMPTWrapper.h:105
SiPixelCPEGenericDBErrorParametrization::~SiPixelCPEGenericDBErrorParametrization
~SiPixelCPEGenericDBErrorParametrization()
Definition: SiPixelCPEGenericDBErrorParametrization.cc:50
SiPixelCPEGenericDBErrorParametrization::SiPixelCPEGenericDBErrorParametrization
SiPixelCPEGenericDBErrorParametrization()
Definition: SiPixelCPEGenericDBErrorParametrization.cc:48
SiPixelCPEGenericDBErrorParametrization::part_bin_size
static const int part_bin_size[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:61
SiPixelCPEGenericDBErrorParametrization::by_b_min
static const float by_b_min[6]
Definition: SiPixelCPEGenericDBErrorParametrization.h:50
SiPixelCPEGenericDBErrorParametrization::setDBAccess
void setDBAccess(const edm::EventSetup &es)
Definition: SiPixelCPEGenericDBErrorParametrization.cc:52
SiPixelCPEGenericErrorParm::errors
DbVector & errors()
Accessors for the vectors – non-const version.
Definition: SiPixelCPEGenericErrorParm.h:55
SiPixelCPEGenericDBErrorParametrization::fy_b_min
static const float fy_b_min[2]
Definition: SiPixelCPEGenericDBErrorParametrization.h:55
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
errors
Definition: errors.py:1
SiPixelCPEGenericDBErrorParametrization::size_bin_size
static const int size_bin_size[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:62
SiPixelCPEGenericDBErrorParametrization::by_a_max
static const float by_a_max[6]
Definition: SiPixelCPEGenericDBErrorParametrization.h:49
SiPixelCPEGenericDBErrorParametrization::by_a_min
static const float by_a_min[6]
Definition: SiPixelCPEGenericDBErrorParametrization.h:48
SiPixelCPEGenericDBErrorParametrization::alpha_bin_size
static const int alpha_bin_size[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:63
SiPixelCPEGenericDBErrorParametrization::errors_big_pix
static const float errors_big_pix[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:58
SiPixelCPEGenericDBErrorParametrization::index
float index(int ind_subpart, int size, float alpha, float beta, bool big)
Definition: SiPixelCPEGenericDBErrorParametrization.cc:118
SiPixelCPEGenericDBErrorParametrization::by_b_max
static const float by_b_max[6]
Definition: SiPixelCPEGenericDBErrorParametrization.h:51
SiPixelCPEGenericDBErrorParametrization::b_max
static const float * b_max[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:69
createfilelist.int
int
Definition: createfilelist.py:10
GeomDetEnumerators::isTrackerPixel
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
Definition: GeomDetEnumerators.cc:68
SiPixelCPEGenericDBErrorParametrization::bx_a_min
static const float bx_a_min[3]
Definition: SiPixelCPEGenericDBErrorParametrization.h:40
GeomDetEnumerators::isBarrel
bool isBarrel(GeomDetEnumerators::SubDetector m)
Definition: GeomDetEnumerators.cc:57
SiPixelCPEGenericDBErrorParametrization::size_max
static const int size_max[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:59
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
garbage
const float garbage[1]
Definition: SiPixelCPEGenericDBErrorParametrization.cc:35
Exception
Definition: hltDiff.cc:245
SiPixelCPEGenericErrorParmRcd.h
big
Definition: big.h:8
math_pi
const float math_pi
Definition: SiPixelCPEGenericDBErrorParametrization.cc:6
SiPixelCPEGenericDBErrorParametrization::getError
std::pair< float, float > getError(const SiPixelCPEGenericErrorParm *parmErrors, GeomDetType::SubDetector pixelPart, int sizex, int sizey, float alpha, float beta, bool bigInX=false, bool bigInY=false)
Definition: SiPixelCPEGenericDBErrorParametrization.cc:57
SiPixelCPEGenericDBErrorParametrization::b_min
static const float * b_min[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:68
SiPixelCPEGenericDBErrorParametrization::fx_b_max
static const float fx_b_max[2]
Definition: SiPixelCPEGenericDBErrorParametrization.h:46
SiPixelCPEGenericDBErrorParametrization::errorsH
edm::ESHandle< SiPixelCPEGenericErrorParm > errorsH
Definition: SiPixelCPEGenericDBErrorParametrization.h:38
SiPixelCPEGenericDBErrorParametrization::fx_b_min
static const float fx_b_min[2]
Definition: SiPixelCPEGenericDBErrorParametrization.h:45
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
SiPixelCPEGenericDBErrorParametrization::beta_bin_size
static const int beta_bin_size[4]
Definition: SiPixelCPEGenericDBErrorParametrization.h:64
debug_messages_cfi.errors
errors
Definition: debug_messages_cfi.py:54