CMS 3D CMS Logo

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