CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
18 const float SiPixelCPEGenericDBErrorParametrization::by_a_min[6] = {1.47078, 1.47078, 1.47078, 1.47078, 1.47078, 1.47078};
19 const float SiPixelCPEGenericDBErrorParametrization::by_a_max[6] = {1.67078, 1.67078, 1.67078, 1.67078, 1.67078, 1.67078};
20 const float SiPixelCPEGenericDBErrorParametrization::by_b_min[6] = {0.05, 0.15, 0.70, 0.95, 1.15, 1.20};
21 const float SiPixelCPEGenericDBErrorParametrization::by_b_max[6] = {0.50, 0.90, 1.05, 1.15, 1.20, 1.40};
22 
23 const float SiPixelCPEGenericDBErrorParametrization::fy_a_min[2] = {998, 998};
24 const float SiPixelCPEGenericDBErrorParametrization::fy_a_max[2] = {999, 999};
25 const float SiPixelCPEGenericDBErrorParametrization::fy_b_min[2] = {0.31, 0.31};
26 const float SiPixelCPEGenericDBErrorParametrization::fy_b_max[2] = {0.39, 0.39};
27 
28 //Constants based on subpart
29 const float SiPixelCPEGenericDBErrorParametrization::errors_big_pix[4] = {0.0070, 0.0030, 0.0068, 0.0040};
30 const int SiPixelCPEGenericDBErrorParametrization::size_max[4] = {5, 2, 0, 0};
31 
32 //Garbage is set to hold a place for bx_b, though we don't parametrize it the same way
33 const float garbage[1] = {-9999.99};
34 
35 const float* SiPixelCPEGenericDBErrorParametrization::a_min[4] = {by_a_min, bx_a_min, fy_a_min, fx_a_min};
36 const float* SiPixelCPEGenericDBErrorParametrization::a_max[4] = {by_a_max, bx_a_max, fy_a_max, fx_a_max};
37 const float* SiPixelCPEGenericDBErrorParametrization::b_min[4] = {by_b_min, garbage, fy_b_min, fx_b_min};
38 const float* SiPixelCPEGenericDBErrorParametrization::b_max[4] = {by_b_max, garbage, fy_b_max, fx_b_max};
39 
40 //Bin Sizes
41 const int SiPixelCPEGenericDBErrorParametrization::part_bin_size[4] = { 0, 240, 360, 380};
42 const int SiPixelCPEGenericDBErrorParametrization::size_bin_size[4] = {40, 40, 40, 40};
44 const int SiPixelCPEGenericDBErrorParametrization::beta_bin_size[4] = { 1, 10, 1, 10};
45 
47 
49 
51 {
53 }
54 
55 //The function which is called to return errX and errY. Used in CPEs.
57  GeomDetType::SubDetector pixelPart,
58  int sizex, int sizey,
59  float alpha, float beta,
60  bool bigInX, bool bigInY)
61 {
62  std::pair<float,float> element;
63  std::pair<float,float> errors;
64 
65  switch (pixelPart)
66  {
68  element = std::pair<float,float>(index(1, sizex, alpha, beta, bigInX), //1 -- Bx
69  index(0, sizey, alpha, beta, bigInY)); //0 -- By
70  break;
72  element = std::pair<float,float>(index(3, sizex, alpha, beta, bigInX), //3 -- Fx
73  index(2, sizey, alpha, beta, bigInY)); //2 -- Fy
74  break;
75  default:
76  throw cms::Exception("PixelCPEGenericDBErrorParametrization::getError")
77  << "Non-pixel detector type !!!" ;
78  }
79 
80  if (bigInX && sizex == 1) errors.first = element.first;
81  else errors.first = parmErrors->errors()[(int)element.first].sigma;
82  if (bigInY && sizey == 1) errors.second = element.second;
83  else errors.second = parmErrors->errors()[(int)element.second].sigma;
84 
85  return errors;
86 }
87 
88 //The function which is called to return errX and errY. Used outside CPEs with access to ES.
90  int sizex, int sizey,
91  float alpha, float beta,
92  bool bigInX, bool bigInY)
93 {
94  std::pair<float,float> element;
95  std::pair<float,float> errors;
96 
97  switch (pixelPart)
98  {
100  element = std::pair<float,float>(index(1, sizex, alpha, beta, bigInX), //1 -- Bx
101  index(0, sizey, alpha, beta, bigInY)); //0 -- By
102  break;
104  element = std::pair<float,float>(index(3, sizex, alpha, beta, bigInX), //3 -- Fx
105  index(2, sizey, alpha, beta, bigInY)); //2 -- Fy
106  break;
107  default:
108  throw cms::Exception("PixelCPEGenericDBErrorParametrization::getError")
109  << "Non-pixel detector type !!!" ;
110  }
111 
112  if (bigInX && sizex == 1) errors.first = element.first;
113  else errors.first = errorsH->errors()[(int)element.first].sigma;
114  if (bigInY && sizey == 1) errors.second = element.second;
115  else errors.second = errorsH->errors()[(int)element.second].sigma;
116 
117  return errors;
118 }
119 
120 
121 
122 float SiPixelCPEGenericDBErrorParametrization::index(int ind_subpart, int size, float alpha, float beta, bool big)
123 {
124  //This is a check for big pixels. If it passes, the code returns a given error and the function ends.
125  if ( big && size == 1) return errors_big_pix[ind_subpart];
126 
127  int ind_size = std::min(size - 1, size_max[ind_subpart]);
128 
129  float alpha_rad = -999.9;
130  float betap_rad = -999.9;
131 
132  int ind_alpha = -99;
133  int ind_beta = -99;
134 
135  float binw_a = -999.9;
136  float binw_b = -999.9;
137  int maxbin_a = -99;
138  int maxbin_b = -99;
139 
140  betap_rad = fabs(math_pi/2.0 - beta);
141  //We must take into account that Fx(subpart=3) has different alpha parametrization
142  if(ind_subpart == 3) alpha_rad = fabs(math_pi/2.0 - alpha);
143  else alpha_rad = fabs(alpha);
144 
145  //Sets the correct binning for alpha and beta based on whether in x or y
146  if(ind_subpart == 0||ind_subpart == 2)
147  {
148  binw_a = (a_max[ind_subpart][ind_size] - a_min[ind_subpart][ind_size])/2.0;
149  binw_b = (b_max[ind_subpart][ind_size] - b_min[ind_subpart][ind_size])/8.0;
150  maxbin_a = 3;
151  maxbin_b = 9;
152  }
153  else
154  {
155  binw_a = (a_max[ind_subpart][ind_size] - a_min[ind_subpart][ind_size])/8.0;
156  binw_b = (b_max[ind_subpart][ind_size] - b_min[ind_subpart][ind_size])/2.0;
157  maxbin_a = 3;
158  maxbin_b = 9;
159  }
160 
161  //Binning for alpha
162  if ( alpha_rad < a_min[ind_subpart][ind_size]) ind_alpha = 0;
163  else if ( alpha_rad >= a_max[ind_subpart][ind_size]) ind_alpha = maxbin_a;
164  else ind_alpha = 1 + (int)((alpha_rad - a_min[ind_subpart][ind_size])/binw_a);
165 
166  //Binning for beta -- we need to account for Bx(subpart=1) having uneven binning
167  if(ind_subpart == 1)
168  {
169  if ( betap_rad <= 0.7 ) ind_beta = 0;
170  else if ( 0.7 < betap_rad && betap_rad <= 1.0 ) ind_beta = 1;
171  else if ( 1.0 < betap_rad && betap_rad <= 1.2 ) ind_beta = 2;
172  else if ( 1.2 <= betap_rad ) ind_beta = 3;
173  }
174  else if ( betap_rad < b_min[ind_subpart][ind_size]) ind_beta = 0;
175  else if ( betap_rad >= b_max[ind_subpart][ind_size]) ind_beta = maxbin_b;
176  else ind_beta = 1 + (int)((betap_rad - b_min[ind_subpart][ind_size])/binw_b);
177 
178  //Index to be used to find error in database
179  int index = part_bin_size[ind_subpart] + size_bin_size[ind_subpart] * ind_size + alpha_bin_size[ind_subpart] * ind_alpha + beta_bin_size[ind_subpart] * ind_beta;
180 
181  return index;
182 }
const double beta
float alpha
Definition: AMPTWrapper.h:95
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)
float index(int ind_subpart, int size, float alpha, float beta, bool big)
DbVector & errors()
Accessors for the vectors – non-const version.
const T & get() const
Definition: EventSetup.h:55
if(dp >Float(M_PI)) dp-
Definition: big.h:6
edm::ESHandle< SiPixelCPEGenericErrorParm > errorsH
tuple size
Write out results.