CMS 3D CMS Logo

PPSPixelTopology.cc
Go to the documentation of this file.
2 
3 // Constructors
4 
6  : runType_(""),
7  pitch_simY_(0.),
8  pitch_simX_(0.),
9  thickness_(0.),
10  no_of_pixels_simX_(0.),
11  no_of_pixels_simY_(0.),
12  no_of_pixels_(0.),
13  simX_width_(0.),
14  simY_width_(0.),
15  dead_edge_width_(0.),
16  active_edge_sigma_(0.),
17  phys_active_edge_dist_(0.),
18  active_edge_x_(0.),
19  active_edge_y_(0.) {}
20 
21 // Destructor
23 
24 unsigned short PPSPixelTopology::pixelIndex(PixelInfo pI) const {
25  return no_of_pixels_simX_ * pI.pixelColNo() + pI.pixelRowNo();
26 }
27 
28 bool PPSPixelTopology::isPixelHit(float xLocalCoordinate, float yLocalCoordinate, bool is3x2 = true) const {
29  // check hit fiducial boundaries
30  const double xModuleSize = 2 * ((no_of_pixels_simX_ / 2. + 1) * pitch_simX_ + dead_edge_width_);
31  if (xLocalCoordinate < -xModuleSize / 2. || xLocalCoordinate > xModuleSize / 2.)
32  return false;
33 
34  const double yModuleSize = (no_of_pixels_simY_ + 4.) * pitch_simY_ + 2. * dead_edge_width_;
35  const double y2x2top = no_of_pixels_simY_ / 6. * pitch_simY_ + dead_edge_width_;
36  if (is3x2 && (yLocalCoordinate < -yModuleSize / 2. || yLocalCoordinate > yModuleSize / 2.))
37  return false;
38  if (!is3x2 && (runType_ == "Run2") && (yLocalCoordinate < -yModuleSize / 2. || yLocalCoordinate > y2x2top))
39  return false;
40  if (!is3x2 && (runType_ == "Run3") && (yLocalCoordinate < -yModuleSize / 2. || yLocalCoordinate > yModuleSize / 2.))
41  return false;
42 
43  return true;
44 }
45 
47  double x, double y, double sigma, double& hit_pos_x, double& hit_pos_y) const {
48  //hit position wrt the bottom left corner of the sensor (-8.3, -12.2) in sensor view, rocs behind
49  hit_pos_x = x + simX_width_ / 2.;
50  hit_pos_y = y + simY_width_ / 2.;
51  if (!(hit_pos_x * hit_pos_y > 0))
52  throw cms::Exception("PPSPixelTopology") << "pixel out of reference frame";
53 
54  double hit_factor = activeEdgeFactor(x, y);
55 
56  unsigned int interested_row = row(x);
57  unsigned int interested_col = col(y);
58  double low_pixel_range_x, high_pixel_range_x, low_pixel_range_y, high_pixel_range_y;
59  pixelRange(
60  interested_row, interested_col, low_pixel_range_x, high_pixel_range_x, low_pixel_range_y, high_pixel_range_y);
61 
62  return PPSPixelTopology::PixelInfo(low_pixel_range_x,
63  high_pixel_range_x,
64  low_pixel_range_y,
65  high_pixel_range_y,
66  hit_factor,
67  interested_row,
68  interested_col);
69 }
70 
72  unsigned int arow, unsigned int acol, double& lower_x, double& higher_x, double& lower_y, double& higher_y) const {
73  // x and y in the system of Geant4 SIMULATION
74  arow = (2 * rpixValues::ROCSizeInX - 1) - arow;
75  if (arow > (2 * rpixValues::ROCSizeInX - 1) || acol > (3 * rpixValues::ROCSizeInY - 1))
76  throw cms::Exception("PPSPixelTopology") << "pixel rows or columns exceeding limits";
77 
78  // rows (x segmentation)
79  if (arow == 0) {
80  lower_x = dead_edge_width_ - phys_active_edge_dist_; // 50 um
81  higher_x = dead_edge_width_ + pitch_simX_; // 300 um
82  } else if (arow <= (rpixValues::ROCSizeInX - 2)) {
83  lower_x = dead_edge_width_ + arow * pitch_simX_;
84  higher_x = dead_edge_width_ + (arow + 1) * pitch_simX_;
85  } else if (arow == (rpixValues::ROCSizeInX - 1)) {
86  lower_x = dead_edge_width_ + arow * pitch_simX_;
87  higher_x = dead_edge_width_ + (arow + 2) * pitch_simX_;
88  } else if (arow == rpixValues::ROCSizeInX) {
89  lower_x = dead_edge_width_ + (arow + 1) * pitch_simX_;
90  higher_x = dead_edge_width_ + (arow + 3) * pitch_simX_;
91  } else if (arow <= (2 * rpixValues::ROCSizeInX - 2)) {
92  lower_x = dead_edge_width_ + (arow + 2) * pitch_simX_;
93  higher_x = dead_edge_width_ + (arow + 3) * pitch_simX_;
94  } else if (arow == (2 * rpixValues::ROCSizeInX - 1)) {
95  lower_x = dead_edge_width_ + (arow + 2) * pitch_simX_;
96  higher_x = dead_edge_width_ + (arow + 3) * pitch_simX_ + phys_active_edge_dist_;
97  }
98  // columns (y segmentation)
99  if (acol == 0) {
100  lower_y = dead_edge_width_ - phys_active_edge_dist_; // 50 um
101  higher_y = dead_edge_width_ + pitch_simY_; // 350 um
102  } else if (acol <= (rpixValues::ROCSizeInY - 2)) {
103  lower_y = dead_edge_width_ + acol * pitch_simY_;
104  higher_y = dead_edge_width_ + (acol + 1) * pitch_simY_;
105  } else if (acol == (rpixValues::ROCSizeInY - 1)) {
106  lower_y = dead_edge_width_ + acol * pitch_simY_;
107  higher_y = dead_edge_width_ + (acol + 2) * pitch_simY_;
108  } else if (acol == rpixValues::ROCSizeInY) {
109  lower_y = dead_edge_width_ + (acol + 1) * pitch_simY_;
110  higher_y = dead_edge_width_ + (acol + 3) * pitch_simY_;
111  } else if (acol <= (2 * rpixValues::ROCSizeInY - 2)) {
112  lower_y = dead_edge_width_ + (acol + 2) * pitch_simY_;
113  higher_y = dead_edge_width_ + (acol + 3) * pitch_simY_;
114  } else if (acol == (2 * rpixValues::ROCSizeInY - 1)) {
115  lower_y = dead_edge_width_ + (acol + 2) * pitch_simY_;
116  higher_y = dead_edge_width_ + (acol + 4) * pitch_simY_;
117  } else if (acol == (2 * rpixValues::ROCSizeInY)) {
118  lower_y = dead_edge_width_ + (acol + 3) * pitch_simY_;
119  higher_y = dead_edge_width_ + (acol + 5) * pitch_simY_;
120  } else if (acol <= (3 * rpixValues::ROCSizeInY - 2)) {
121  lower_y = dead_edge_width_ + (acol + 4) * pitch_simY_;
122  higher_y = dead_edge_width_ + (acol + 5) * pitch_simY_;
123  } else if (acol == (3 * rpixValues::ROCSizeInY - 1)) {
124  lower_y = dead_edge_width_ + (acol + 4) * pitch_simY_;
125  higher_y = dead_edge_width_ + (acol + 5) * pitch_simY_ + phys_active_edge_dist_;
126  }
127 
128  lower_x = lower_x - simX_width_ / 2.;
129  lower_y = lower_y - simY_width_ / 2.;
130  higher_x = higher_x - simX_width_ / 2.;
131  higher_y = higher_y - simY_width_ / 2.;
132 }
133 
134 double PPSPixelTopology::activeEdgeFactor(double x, double y) const {
135  const double inv_sigma = 1. / active_edge_sigma_; // precaching
136  const double topEdgeFactor = std::erf(-distanceFromTopActiveEdge(x, y) * inv_sigma) * 0.5 + 0.5;
137  const double bottomEdgeFactor = std::erf(-distanceFromBottomActiveEdge(x, y) * inv_sigma) * 0.5 + 0.5;
138  const double rightEdgeFactor = std::erf(-distanceFromRightActiveEdge(x, y) * inv_sigma) * 0.5 + 0.5;
139  const double leftEdgeFactor = std::erf(-distanceFromLeftActiveEdge(x, y) * inv_sigma) * 0.5 + 0.5;
140 
141  const double aEF = topEdgeFactor * bottomEdgeFactor * rightEdgeFactor * leftEdgeFactor;
142 
143  if (aEF > 1.)
144  throw cms::Exception("PPSPixelTopology") << " pixel active edge factor > 1";
145 
146  return aEF;
147 }
148 
149 double PPSPixelTopology::distanceFromTopActiveEdge(double x, double y) const { return (y - active_edge_y_); }
150 double PPSPixelTopology::distanceFromBottomActiveEdge(double x, double y) const { return (-y - active_edge_y_); }
151 double PPSPixelTopology::distanceFromRightActiveEdge(double x, double y) const { return (x - active_edge_x_); }
152 double PPSPixelTopology::distanceFromLeftActiveEdge(double x, double y) const { return (-x - active_edge_x_); }
153 
154 unsigned int PPSPixelTopology::row(double x) const {
155  // x in the G4 simulation system
156  x = x + simX_width_ / 2.;
157 
158  // now x in the system centered in the bottom left corner of the sensor (sensor view, rocs behind)
159  if (x < 0. || x > simX_width_)
160  throw cms::Exception("PPSPixelTopology") << " pixel out of reference frame";
161 
162  // rows (x segmentation)
163  unsigned int arow;
164  if (x <= (dead_edge_width_ + pitch_simX_))
165  arow = 0;
166  else if (x <= (dead_edge_width_ + (rpixValues::ROCSizeInX - 1) * pitch_simX_))
167  arow = int((x - dead_edge_width_ - pitch_simX_) / pitch_simX_) + 1;
168  else if (x <= (dead_edge_width_ + (rpixValues::ROCSizeInX + 1) * pitch_simX_))
169  arow = (rpixValues::ROCSizeInX - 1);
170  else if (x <= (dead_edge_width_ + (rpixValues::ROCSizeInX + 3) * pitch_simX_))
171  arow = rpixValues::ROCSizeInX;
172  else if (x <= (dead_edge_width_ + (2 * rpixValues::ROCSizeInX + 2) * pitch_simX_))
173  arow = int((x - dead_edge_width_ - pitch_simX_) / pitch_simX_) - 1;
174  else
175  arow = (2 * rpixValues::ROCSizeInX - 1);
176 
177  arow = (2 * rpixValues::ROCSizeInX - 1) - arow;
178  if (arow > (2 * rpixValues::ROCSizeInX - 1))
179  throw cms::Exception("PPSPixelTopology") << " pixel row number exceeding limit";
180 
181  return arow;
182 }
183 
184 unsigned int PPSPixelTopology::col(double y) const {
185  // y in the G4 simulation system
186  unsigned int column;
187 
188  // columns (y segmentation)
189  // now y in the system centered in the bottom left corner of the sensor (sensor view, rocs behind)
190  y = y + simY_width_ / 2.;
191  if (y < 0. || y > simY_width_)
192  throw cms::Exception("PPSPixelTopology") << "pixel out of reference frame";
193 
194  if (y <= (dead_edge_width_ + pitch_simY_))
195  column = 0;
196  else if (y <= (dead_edge_width_ + (rpixValues::ROCSizeInY - 1) * pitch_simY_))
197  column = int((y - dead_edge_width_ - pitch_simY_) / pitch_simY_) + 1;
198  else if (y <= (dead_edge_width_ + (rpixValues::ROCSizeInY + 1) * pitch_simY_))
199  column = rpixValues::ROCSizeInY - 1;
200  else if (y <= (dead_edge_width_ + (rpixValues::ROCSizeInY + 3) * pitch_simY_))
201  column = rpixValues::ROCSizeInY;
202  else if (y <= (dead_edge_width_ + (2 * rpixValues::ROCSizeInY + 1) * pitch_simY_))
203  column = int((y - dead_edge_width_ - pitch_simY_) / pitch_simY_) - 1;
204  else if (y <= (dead_edge_width_ + (2 * rpixValues::ROCSizeInY + 3) * pitch_simY_))
205  column = 2 * rpixValues::ROCSizeInY - 1;
206  else if (y <= (dead_edge_width_ + (2 * rpixValues::ROCSizeInY + 5) * pitch_simY_))
207  column = 2 * rpixValues::ROCSizeInY;
208  else if (y <= (dead_edge_width_ + (3 * rpixValues::ROCSizeInY + 3) * pitch_simY_))
209  column = int((y - dead_edge_width_ - pitch_simY_) / pitch_simY_) - 3;
210  else
211  column = (3 * rpixValues::ROCSizeInY - 1);
212 
213  return column;
214 }
215 
216 void PPSPixelTopology::rowCol2Index(unsigned int arow, unsigned int acol, unsigned int& index) const {
217  index = acol * no_of_pixels_simX_ + arow;
218 }
219 
220 void PPSPixelTopology::index2RowCol(unsigned int& arow, unsigned int& acol, unsigned int index) const {
221  acol = index / no_of_pixels_simX_;
222  arow = index % no_of_pixels_simX_;
223 }
224 
225 // Getters
226 
228 double PPSPixelTopology::getPitchSimY() const { return pitch_simY_; }
229 double PPSPixelTopology::getPitchSimX() const { return pitch_simX_; }
230 double PPSPixelTopology::getThickness() const { return thickness_; }
231 unsigned short PPSPixelTopology::getNoPixelsSimX() const { return no_of_pixels_simX_; }
232 unsigned short PPSPixelTopology::getNoPixelsSimY() const { return no_of_pixels_simY_; }
233 unsigned short PPSPixelTopology::getNoPixels() const { return no_of_pixels_; }
234 double PPSPixelTopology::getSimXWidth() const { return simX_width_; }
235 double PPSPixelTopology::getSimYWidth() const { return simY_width_; }
241 
242 // Setters
243 
245 void PPSPixelTopology::setPitchSimY(double psy) { pitch_simY_ = psy; }
246 void PPSPixelTopology::setPitchSimX(double psx) { pitch_simX_ = psx; }
247 void PPSPixelTopology::setThickness(double tss) { thickness_ = tss; }
248 void PPSPixelTopology::setNoPixelsSimX(unsigned short npx) { no_of_pixels_simX_ = npx; }
249 void PPSPixelTopology::setNoPixelsSimY(unsigned short npy) { no_of_pixels_simY_ = npy; }
251 void PPSPixelTopology::setSimXWidth(double sxw) { simX_width_ = sxw; }
252 void PPSPixelTopology::setSimYWidth(double syw) { simY_width_ = syw; }
258 
259 void PPSPixelTopology::printInfo(std::stringstream& s) {
260  s << "\n PPS Topology parameters : \n"
261  << "\n runType_ = " << runType_ << "\n pitch_simY_ = " << pitch_simY_ << "\n pitch_simX_ = " << pitch_simX_
262  << "\n thickness_ = " << thickness_ << "\n no_of_pixels_simX_ " << no_of_pixels_simX_
263  << "\n no_of_pixels_simY_ " << no_of_pixels_simY_ << "\n no_of_pixels_ " << no_of_pixels_ << "\n simX_width_ "
264  << simX_width_ << "\n simY_width_ " << simY_width_ << "\n dead_edge_width_ " << dead_edge_width_
265  << "\n active_edge_sigma_ " << active_edge_sigma_ << "\n phys_active_edge_dist_ " << phys_active_edge_dist_
266 
267  << "\n active_edge_x_ " << active_edge_x_ << "\n active_edge_y_ " << active_edge_y_
268 
269  << std::endl;
270 }
271 
272 std::ostream& operator<<(std::ostream& os, PPSPixelTopology info) {
273  std::stringstream ss;
274  info.printInfo(ss);
275  os << ss.str();
276  return os;
277 }
double distanceFromBottomActiveEdge(double x, double y) const
void setPitchSimY(double psy)
void setThickness(double tss)
unsigned short pixelColNo() const
static const TGPicture * info(bool iBackgroundIsBlack)
unsigned int col(double y) const
double distanceFromTopActiveEdge(double x, double y) const
double getPitchSimY() const
void setActiveEdgeY(double aey)
double distanceFromRightActiveEdge(double x, double y) const
double getPitchSimX() const
double getDeadEdgeWidth() const
double getActiveEdgeX() const
unsigned int row(double x) const
double getActiveEdgeSigma() const
bool isPixelHit(float xLocalCoordinate, float yLocalCoordinate, bool is3x2) const
unsigned short no_of_pixels_simX_
void setActiveEdgeX(double aex)
void setDeadEdgeWidth(double dew)
void setPitchSimX(double psx)
int np
Definition: AMPTWrapper.h:43
double activeEdgeFactor(double x, double y) const
double getSimXWidth() const
void setSimYWidth(double syw)
void setRunType(std::string rt)
unsigned short getNoPixels() const
double distanceFromLeftActiveEdge(double x, double y) const
unsigned short getNoPixelsSimY() const
std::ostream & operator<<(std::ostream &os, PPSPixelTopology info)
void pixelRange(unsigned int arow, unsigned int acol, double &lower_x, double &higher_x, double &lower_y, double &higher_y) const
unsigned short pixelRowNo() const
void index2RowCol(unsigned int &arow, unsigned int &acol, unsigned int index) const
unsigned short pixelIndex(PixelInfo pI) const
void setNoPixelsSimY(unsigned short npy)
void setSimXWidth(double sxw)
void printInfo(std::stringstream &s)
double getActiveEdgeY() const
std::string runType_
void setPhysActiveEdgeDist(double pae)
PixelInfo getPixelsInvolved(double x, double y, double sigma, double &hit_pos_x, double &hit_pos_y) const
void setNoPixelsSimX(unsigned short npx)
void rowCol2Index(unsigned int arow, unsigned int acol, unsigned int &index) const
float x
double getSimYWidth() const
std::string getRunType() const
void setNoPixels(unsigned short np)
unsigned short getNoPixelsSimX() const
unsigned short no_of_pixels_simY_
double getPhysActiveEdgeDist() const
unsigned short no_of_pixels_
void setActiveEdgeSigma(double aes)
constexpr int ROCSizeInX
double getThickness() const
constexpr int ROCSizeInY