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