CMS 3D CMS Logo

CTPPSPixelSimTopology.h
Go to the documentation of this file.
1 #ifndef Geometry_VeryForwardGeometry_CTPPSPixelSimTopology_h
2 #define Geometry_VeryForwardGeometry_CTPPSPixelSimTopology_h
3 
4 #include <cmath>
6 
8 public:
9  /* simX and simY are the coordinates as in the simulation:
10  _________
11  | |
12  | | y
13  |_________|
14 
15  x
16  */
17  class PixelInfo {
18  public:
19  PixelInfo(double lower_simX_border,
20  double higher_simX_border,
21  double lower_simY_border,
22  double higher_simY_border,
23  double eff_factor,
24  unsigned short pixel_row_no,
25  unsigned short pixel_col_no)
26  : lower_simX_border_(lower_simX_border),
27  higher_simX_border_(higher_simX_border),
28  lower_simY_border_(lower_simY_border),
29  higher_simY_border_(higher_simY_border),
30  eff_factor_(eff_factor),
31  pixel_row_no_(pixel_row_no),
32  pixel_col_no_(pixel_col_no),
33  pixel_index_(pixel_col_no * CTPPSPixelTopology::no_of_pixels_simX_ + pixel_row_no) {}
34 
35  inline double higherSimXBorder() const { return higher_simX_border_; }
36  inline double lowerSimXBorder() const { return lower_simX_border_; }
37  inline double higherSimYBorder() const { return higher_simY_border_; }
38  inline double lowerSimYBorder() const { return lower_simY_border_; }
39  inline double effFactor() const { return eff_factor_; }
40  inline unsigned short pixelRowNo() const { return pixel_row_no_; }
41  inline unsigned short pixelColNo() const { return pixel_col_no_; }
42  inline unsigned short pixelIndex() const { return pixel_index_; }
43 
44  private:
49  double eff_factor_;
50  unsigned short pixel_row_no_;
51  unsigned short pixel_col_no_;
52  unsigned short pixel_index_;
53  };
54 
55 public:
58 
59  PixelInfo getPixelsInvolved(double x, double y, double sigma, double& hit_pos_x, double& hit_pos_y) const;
60 
61  inline void pixelRange(unsigned int arow,
62  unsigned int acol,
63  double& lower_x,
64  double& higher_x,
65  double& lower_y,
66  double& higher_y) const {
67  // x and y in the system of Geant4 SIMULATION
68  arow = (2 * ROCSizeInX - 1) - arow;
69  if (arow > (2 * ROCSizeInX - 1) || acol > (3 * ROCSizeInY - 1))
70  throw cms::Exception("CTPPSPixelSimTopology") << "rows or columns exceeding limits";
71 
72  // rows (x segmentation)
73  if (arow == 0) {
74  lower_x = dead_edge_width_ - phys_active_edge_dist_; // 50 um
75  higher_x = dead_edge_width_ + pitch_simX_; // 300 um
76  } else if (arow <= (ROCSizeInX - 2)) {
77  lower_x = dead_edge_width_ + arow * pitch_simX_;
78  higher_x = dead_edge_width_ + (arow + 1) * pitch_simX_;
79  } else if (arow == (ROCSizeInX - 1)) {
80  lower_x = dead_edge_width_ + arow * pitch_simX_;
81  higher_x = dead_edge_width_ + (arow + 2) * pitch_simX_;
82  } else if (arow == ROCSizeInX) {
83  lower_x = dead_edge_width_ + (arow + 1) * pitch_simX_;
84  higher_x = dead_edge_width_ + (arow + 3) * pitch_simX_;
85  } else if (arow <= (2 * ROCSizeInX - 2)) {
86  lower_x = dead_edge_width_ + (arow + 2) * pitch_simX_;
87  higher_x = dead_edge_width_ + (arow + 3) * pitch_simX_;
88  } else if (arow == (2 * ROCSizeInX - 1)) {
89  lower_x = dead_edge_width_ + (arow + 2) * pitch_simX_;
90  higher_x = dead_edge_width_ + (arow + 3) * pitch_simX_ + phys_active_edge_dist_;
91  }
92 
93  // columns (y segmentation)
94  if (acol == 0) {
95  lower_y = dead_edge_width_ - phys_active_edge_dist_; // 50 um
96  higher_y = dead_edge_width_ + pitch_simY_; // 350 um
97  } else if (acol <= (ROCSizeInY - 2)) {
98  lower_y = dead_edge_width_ + acol * pitch_simY_;
99  higher_y = dead_edge_width_ + (acol + 1) * pitch_simY_;
100  } else if (acol == (ROCSizeInY - 1)) {
101  lower_y = dead_edge_width_ + acol * pitch_simY_;
102  higher_y = dead_edge_width_ + (acol + 2) * pitch_simY_;
103  } else if (acol == ROCSizeInY) {
104  lower_y = dead_edge_width_ + (acol + 1) * pitch_simY_;
105  higher_y = dead_edge_width_ + (acol + 3) * pitch_simY_;
106  } else if (acol <= (2 * ROCSizeInY - 2)) {
107  lower_y = dead_edge_width_ + (acol + 2) * pitch_simY_;
108  higher_y = dead_edge_width_ + (acol + 3) * pitch_simY_;
109  } else if (acol == (2 * ROCSizeInY - 1)) {
110  lower_y = dead_edge_width_ + (acol + 2) * pitch_simY_;
111  higher_y = dead_edge_width_ + (acol + 4) * pitch_simY_;
112  } else if (acol == (2 * ROCSizeInY)) {
113  lower_y = dead_edge_width_ + (acol + 3) * pitch_simY_;
114  higher_y = dead_edge_width_ + (acol + 5) * pitch_simY_;
115  } else if (acol <= (3 * ROCSizeInY - 2)) {
116  lower_y = dead_edge_width_ + (acol + 4) * pitch_simY_;
117  higher_y = dead_edge_width_ + (acol + 5) * pitch_simY_;
118  } else if (acol == (3 * ROCSizeInY - 1)) {
119  lower_y = dead_edge_width_ + (acol + 4) * pitch_simY_;
120  higher_y = dead_edge_width_ + (acol + 5) * pitch_simY_ + phys_active_edge_dist_;
121  }
122 
123  lower_x = lower_x - simX_width_ / 2.;
124  lower_y = lower_y - simY_width_ / 2.;
125  higher_x = higher_x - simX_width_ / 2.;
126  higher_y = higher_y - simY_width_ / 2.;
127  }
128 
129 private:
132 
133  inline double activeEdgeFactor(double x, double y) const {
134  const double inv_sigma = 1. / active_edge_sigma_; // precaching
135  const double topEdgeFactor = std::erf(-distanceFromTopActiveEdge(x, y) * inv_sigma) * 0.5 + 0.5;
136  const double bottomEdgeFactor = std::erf(-distanceFromBottomActiveEdge(x, y) * inv_sigma) * 0.5 + 0.5;
137  const double rightEdgeFactor = std::erf(-distanceFromRightActiveEdge(x, y) * inv_sigma) * 0.5 + 0.5;
138  const double leftEdgeFactor = std::erf(-distanceFromLeftActiveEdge(x, y) * inv_sigma) * 0.5 + 0.5;
139 
140  const double aEF = topEdgeFactor * bottomEdgeFactor * rightEdgeFactor * leftEdgeFactor;
141 
142  if (aEF > 1.)
143  throw cms::Exception("CTPPSPixelSimTopology") << " active edge factor > 1";
144 
145  return aEF;
146  }
147 
148  inline double distanceFromTopActiveEdge(double x, double y) const { return (y - active_edge_y_); }
149  inline double distanceFromBottomActiveEdge(double x, double y) const { return (-y - active_edge_y_); }
150  inline double distanceFromRightActiveEdge(double x, double y) const { return (x - active_edge_x_); }
151  inline double distanceFromLeftActiveEdge(double x, double y) const { return (-x - active_edge_x_); }
152 
153  inline unsigned int row(double x) const {
154  // x in the G4 simulation system
155  x = x + simX_width_ / 2.;
156 
157  // now x in the system centered in the bottom left corner of the sensor (sensor view, rocs behind)
158  if (x < 0. || x > simX_width_)
159  throw cms::Exception("CTPPSPixelSimTopology") << "out of reference frame";
160 
161  // rows (x segmentation)
162  unsigned int arow;
163  if (x <= (dead_edge_width_ + pitch_simX_))
164  arow = 0;
165  else if (x <= (dead_edge_width_ + (ROCSizeInX - 1) * pitch_simX_))
166  arow = int((x - dead_edge_width_ - pitch_simX_) / pitch_simX_) + 1;
167  else if (x <= (dead_edge_width_ + (ROCSizeInX + 1) * pitch_simX_))
168  arow = (ROCSizeInX - 1);
169  else if (x <= (dead_edge_width_ + (ROCSizeInX + 3) * pitch_simX_))
170  arow = ROCSizeInX;
171  else if (x <= (dead_edge_width_ + (2 * ROCSizeInX + 2) * pitch_simX_))
172  arow = int((x - dead_edge_width_ - pitch_simX_) / pitch_simX_) - 1;
173  else
174  arow = (2 * ROCSizeInX - 1);
175 
176  arow = (2 * ROCSizeInX - 1) - arow;
177  if (arow > (2 * ROCSizeInX - 1))
178  throw cms::Exception("CTPPSPixelSimTopology") << "row number exceeding limit";
179 
180  return arow;
181  }
182 
183  inline unsigned int col(double y) const {
184  // y in the G4 simulation system
185  unsigned int column;
186 
187  // columns (y segmentation)
188  // now y in the system centered in the bottom left corner of the sensor (sensor view, rocs behind)
189  y = y + simY_width_ / 2.;
190  if (y < 0. || y > simY_width_)
191  throw cms::Exception("CTPPSPixelSimTopology") << " out of reference frame";
192 
193  if (y <= (dead_edge_width_ + pitch_simY_))
194  column = 0;
195  else if (y <= (dead_edge_width_ + (ROCSizeInY - 1) * pitch_simY_))
196  column = int((y - dead_edge_width_ - pitch_simY_) / pitch_simY_) + 1;
197  else if (y <= (dead_edge_width_ + (ROCSizeInY + 1) * pitch_simY_))
198  column = ROCSizeInY - 1;
199  else if (y <= (dead_edge_width_ + (ROCSizeInY + 3) * pitch_simY_))
200  column = ROCSizeInY;
201  else if (y <= (dead_edge_width_ + (2 * ROCSizeInY + 1) * pitch_simY_))
202  column = int((y - dead_edge_width_ - pitch_simY_) / pitch_simY_) - 1;
203  else if (y <= (dead_edge_width_ + (2 * ROCSizeInY + 3) * pitch_simY_))
204  column = 2 * ROCSizeInY - 1;
205  else if (y <= (dead_edge_width_ + (2 * ROCSizeInY + 5) * pitch_simY_))
206  column = 2 * ROCSizeInY;
207  else if (y <= (dead_edge_width_ + (3 * ROCSizeInY + 3) * pitch_simY_))
208  column = int((y - dead_edge_width_ - pitch_simY_) / pitch_simY_) - 3;
209  else
210  column = (3 * ROCSizeInY - 1);
211 
212  return column;
213  }
214 
215  inline void rowCol2Index(unsigned int arow, unsigned int acol, unsigned int& index) const {
216  index = acol * no_of_pixels_simX_ + arow;
217  }
218 
219  inline void index2RowCol(unsigned int& arow, unsigned int& acol, unsigned int index) const {
220  acol = index / no_of_pixels_simX_;
221  arow = index % no_of_pixels_simX_;
222  }
223 };
224 
225 #endif
DDAxes::y
CTPPSPixelTopology::simX_width_
static constexpr double simX_width_
Definition: CTPPSPixelTopology.h:21
CTPPSPixelSimTopology::PixelInfo::eff_factor_
double eff_factor_
Definition: CTPPSPixelSimTopology.h:49
CTPPSPixelSimTopology::PixelInfo::lower_simY_border_
double lower_simY_border_
Definition: CTPPSPixelSimTopology.h:47
CTPPSPixelTopology::pitch_simY_
static constexpr double pitch_simY_
Definition: CTPPSPixelTopology.h:15
CTPPSPixelSimTopology::activeEdgeFactor
double activeEdgeFactor(double x, double y) const
Definition: CTPPSPixelSimTopology.h:133
CTPPSPixelSimTopology::PixelInfo::lower_simX_border_
double lower_simX_border_
Definition: CTPPSPixelSimTopology.h:45
CTPPSPixelTopology::simY_width_
static constexpr double simY_width_
Definition: CTPPSPixelTopology.h:22
CTPPSPixelSimTopology::PixelInfo::pixelIndex
unsigned short pixelIndex() const
Definition: CTPPSPixelSimTopology.h:42
CTPPSPixelSimTopology::PixelInfo::PixelInfo
PixelInfo(double lower_simX_border, double higher_simX_border, double lower_simY_border, double higher_simY_border, double eff_factor, unsigned short pixel_row_no, unsigned short pixel_col_no)
Definition: CTPPSPixelSimTopology.h:19
CTPPSPixelTopology
Geometrical and topological information on RPix silicon detector. Uses coordinate a frame with origin...
Definition: CTPPSPixelTopology.h:10
CTPPSPixelSimTopology::active_edge_x_
double active_edge_x_
Definition: CTPPSPixelSimTopology.h:130
DDAxes::x
CTPPSPixelSimTopology::distanceFromTopActiveEdge
double distanceFromTopActiveEdge(double x, double y) const
Definition: CTPPSPixelSimTopology.h:148
CTPPSPixelSimTopology::PixelInfo::higher_simY_border_
double higher_simY_border_
Definition: CTPPSPixelSimTopology.h:48
CTPPSPixelSimTopology::PixelInfo::higher_simX_border_
double higher_simX_border_
Definition: CTPPSPixelSimTopology.h:46
CTPPSPixelSimTopology::PixelInfo::lowerSimYBorder
double lowerSimYBorder() const
Definition: CTPPSPixelSimTopology.h:38
CTPPSPixelTopology.h
CTPPSPixelSimTopology::distanceFromBottomActiveEdge
double distanceFromBottomActiveEdge(double x, double y) const
Definition: CTPPSPixelSimTopology.h:149
CTPPSPixelSimTopology::PixelInfo::higherSimYBorder
double higherSimYBorder() const
Definition: CTPPSPixelSimTopology.h:37
CTPPSPixelSimTopology::CTPPSPixelSimTopology
CTPPSPixelSimTopology()
Definition: CTPPSPixelSimTopology.cc:3
CTPPSPixelSimTopology::~CTPPSPixelSimTopology
~CTPPSPixelSimTopology()
Definition: CTPPSPixelSimTopology.h:57
CTPPSPixelTopology::pitch_simX_
static constexpr double pitch_simX_
Definition: CTPPSPixelTopology.h:16
CTPPSPixelSimTopology::PixelInfo::higherSimXBorder
double higherSimXBorder() const
Definition: CTPPSPixelSimTopology.h:35
CTPPSPixelSimTopology::active_edge_y_
double active_edge_y_
Definition: CTPPSPixelSimTopology.h:131
CTPPSPixelSimTopology::PixelInfo::pixelColNo
unsigned short pixelColNo() const
Definition: CTPPSPixelSimTopology.h:41
CTPPSPixelSimTopology::rowCol2Index
void rowCol2Index(unsigned int arow, unsigned int acol, unsigned int &index) const
Definition: CTPPSPixelSimTopology.h:215
createfilelist.int
int
Definition: createfilelist.py:10
CTPPSPixelSimTopology::distanceFromLeftActiveEdge
double distanceFromLeftActiveEdge(double x, double y) const
Definition: CTPPSPixelSimTopology.h:151
CTPPSPixelSimTopology::PixelInfo::pixel_index_
unsigned short pixel_index_
Definition: CTPPSPixelSimTopology.h:52
CTPPSPixelSimTopology::pixelRange
void pixelRange(unsigned int arow, unsigned int acol, double &lower_x, double &higher_x, double &lower_y, double &higher_y) const
Definition: CTPPSPixelSimTopology.h:61
CTPPSPixelSimTopology::index2RowCol
void index2RowCol(unsigned int &arow, unsigned int &acol, unsigned int index) const
Definition: CTPPSPixelSimTopology.h:219
CTPPSPixelSimTopology::PixelInfo
Definition: CTPPSPixelSimTopology.h:17
CTPPSPixelTopology::active_edge_sigma_
static constexpr double active_edge_sigma_
Definition: CTPPSPixelTopology.h:24
CTPPSPixelSimTopology::col
unsigned int col(double y) const
Definition: CTPPSPixelSimTopology.h:183
CTPPSPixelSimTopology
Definition: CTPPSPixelSimTopology.h:7
CTPPSPixelSimTopology::PixelInfo::pixelRowNo
unsigned short pixelRowNo() const
Definition: CTPPSPixelSimTopology.h:40
Exception
Definition: hltDiff.cc:246
CTPPSPixelTopology::phys_active_edge_dist_
static constexpr double phys_active_edge_dist_
Definition: CTPPSPixelTopology.h:25
CTPPSPixelSimTopology::PixelInfo::pixel_col_no_
unsigned short pixel_col_no_
Definition: CTPPSPixelSimTopology.h:51
CTPPSPixelSimTopology::row
unsigned int row(double x) const
Definition: CTPPSPixelSimTopology.h:153
CTPPSPixelSimTopology::PixelInfo::effFactor
double effFactor() const
Definition: CTPPSPixelSimTopology.h:39
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
CTPPSPixelTopology::dead_edge_width_
static constexpr double dead_edge_width_
Definition: CTPPSPixelTopology.h:23
CTPPSPixelSimTopology::PixelInfo::lowerSimXBorder
double lowerSimXBorder() const
Definition: CTPPSPixelSimTopology.h:36
cms::Exception
Definition: Exception.h:70
CTPPSPixelSimTopology::PixelInfo::pixel_row_no_
unsigned short pixel_row_no_
Definition: CTPPSPixelSimTopology.h:50
CTPPSPixelSimTopology::getPixelsInvolved
PixelInfo getPixelsInvolved(double x, double y, double sigma, double &hit_pos_x, double &hit_pos_y) const
Definition: CTPPSPixelSimTopology.cc:8
CTPPSPixelTopology::no_of_pixels_simX_
static constexpr unsigned short no_of_pixels_simX_
Definition: CTPPSPixelTopology.h:18
CTPPSPixelSimTopology::distanceFromRightActiveEdge
double distanceFromRightActiveEdge(double x, double y) const
Definition: CTPPSPixelSimTopology.h:150