CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelUtils.cc
Go to the documentation of this file.
1 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
3 #else
4 #include "SiPixelUtils.h"
5 #endif
6 
7 #include <cmath>
8 
9 namespace SiPixelUtils {
10 
11  //-----------------------------------------------------------------------------
15  //-----------------------------------------------------------------------------
17  int q_f,
18  int q_l,
19  float upper_edge_first_pix,
20  float lower_edge_last_pix,
21  float lorentz_shift,
22  float theThickness, //detector thickness
23  float cot_angle,
24  float pitch,
25  bool first_is_big,
26  bool last_is_big,
27  float eff_charge_cut_low,
28  float eff_charge_cut_high,
29  float size_cut
30  ) {
31  float geom_center = 0.5f * (upper_edge_first_pix + lower_edge_last_pix);
32 
33  //--- The case of only one pixel in this projection is separate. Note that
34  //--- here first_pix == last_pix, so the average of the two is still the
35  //--- center of the pixel.
36  if (size == 1) {
37  return geom_center;
38  }
39 
40  //--- Width of the clusters minus the edge (first and last) pixels.
41  //--- In the note, they are denoted x_F and x_L (and y_F and y_L)
42  float w_inner = lower_edge_last_pix - upper_edge_first_pix; // in cm
43 
44  //--- Predicted charge width from geometry
45  float w_pred = theThickness * cot_angle // geometric correction (in cm)
46  - lorentz_shift; // (in cm) &&& check fpix!
47 
48  //--- Total length of the two edge pixels (first+last)
49  float sum_of_edge = 2.0f;
50  if (first_is_big)
51  sum_of_edge += 1.0f;
52  if (last_is_big)
53  sum_of_edge += 1.0f;
54 
55  //--- The `effective' charge width -- particle's path in first and last pixels only
56  float w_eff = std::abs(w_pred) - w_inner;
57 
58  //--- If the observed charge width is inconsistent with the expectations
59  //--- based on the track, do *not* use w_pred-w_innner. Instead, replace
60  //--- it with an *average* effective charge width, which is the average
61  //--- length of the edge pixels.
62  //
63  // bool usedEdgeAlgo = false;
64  if ((size >= size_cut) || ((w_eff / pitch < eff_charge_cut_low) | (w_eff / pitch > eff_charge_cut_high))) {
65  w_eff = pitch * 0.5f * sum_of_edge; // ave. length of edge pixels (first+last) (cm)
66  // usedEdgeAlgo = true;
67  }
68 
69  //--- Finally, compute the position in this projection
70  float q_diff = q_l - q_f;
71  float q_sum = q_l + q_f;
72 
73  //--- Temporary fix for clusters with both first and last pixel with charge = 0
74  if (q_sum == 0)
75  q_sum = 1.0f;
76 
77  float hit_pos = geom_center + 0.5f * (q_diff / q_sum) * w_eff;
78 
79  return hit_pos;
80  }
81 
83  int size,
84  int q_f,
85  int q_l,
86  int q_f_b,
87  int q_l_b,
88  float upper_edge_first_pix,
89  float lower_edge_last_pix,
90  float lorentz_shift,
91  float theThickness, //detector thickness
92  float cot_angle,
93  float pitch,
94  bool first_is_big,
95  bool last_is_big,
96  float eff_charge_cut_low,
97  float eff_charge_cut_high,
98  float size_cut
99  ) {
100  const auto geom_center = 0.5f * (upper_edge_first_pix + lower_edge_last_pix);
101 
102  //--- The case of only one pixel in this projection is separate. Note that
103  //--- here first_pix == last_pix, so the average of the two is still the
104  //--- center of the pixel.
105 
106  //--- Width of the clusters minus the edge (first and last) pixels.
107  //--- In the note, they are denoted x_F and x_L (and y_F and y_L)
108  const auto w_inner = lower_edge_last_pix - upper_edge_first_pix; // in cm
109 
110  //--- Predicted charge width from geometry
111  const auto w_pred = theThickness * cot_angle // geometric correction (in cm)
112  - lorentz_shift; // (in cm) &&& check fpix!
113 
114  //--- Total length of the two edge pixels (first+last)
115  auto sum_of_edge = 2.0f;
116  if (first_is_big)
117  sum_of_edge += 1.0f;
118  if (last_is_big)
119  sum_of_edge += 1.0f;
120 
121  //--- The `effective' charge width -- particle's path in first and last pixels only
122  auto w_eff = std::abs(w_pred) - std::abs(w_inner);
123 
124  //--- If the observed charge width is inconsistent with the expectations
125  //--- based on the track, do *not* use w_pred-w_innner. Instead, replace
126  //--- it with an *average* effective charge width, which is the average
127  //--- length of the edge pixels.
128  //
129  // bool usedEdgeAlgo = false;
130  //Modified cut to make use of the w_eff in the bricked geometry
131  if (size >= size_cut) {
132  w_eff = pitch * 0.5f * sum_of_edge; // ave. length of edge pixels (first+last) (cm)
133  // usedEdgeAlgo = true;
134  }
135 
136  //--- Finally, compute the position in this projection
137  const auto q_diff = q_l - q_f;
138  auto q_sum = q_l + q_f;
139  const auto q_b_corr = q_l_b + q_f_b;
140 
141  //--- Temporary fix for clusters with both first and last pixel with charge = 0
142  if (q_sum == 0)
143  q_sum = 1.0f;
144 
145  float hit_pos =
146  geom_center + 0.5f * (q_diff / q_sum) * w_eff + 0.5f * (q_b_corr / q_sum) * w_eff; //bricked correction
147 
148  return hit_pos;
149  }
150 } // namespace SiPixelUtils
float generic_position_formula_y_bricked(int size, int q_f, int q_l, int q_f_b, int q_l_b, float upper_edge_first_pix, float lower_edge_last_pix, float lorentz_shift, float theThickness, float cot_angle, float pitch, bool first_is_big, bool last_is_big, float eff_charge_cut_low, float eff_charge_cut_high, float size_cut)
Definition: SiPixelUtils.cc:82
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float generic_position_formula(int size, int q_f, int q_l, float upper_edge_first_pix, float lower_edge_last_pix, float lorentz_shift, float theThickness, float cot_angle, float pitch, bool first_is_big, bool last_is_big, float eff_charge_cut_low, float eff_charge_cut_high, float size_cut)
Definition: SiPixelUtils.cc:16
tuple size
Write out results.