Classes | Enumerations | Functions
geo.h File Reference

Supply basic geometry functions. More...

Go to the source code of this file.

Classes

struct  rect
 

Enumerations

enum  noe_view_t { kX, kY, kXorY }
 

Functions

int pixx_from_pixy (const int y)
 
void setboxes ()
 
void setfd ()
 
int total_x_pixels (const int pixels_x)
 
int total_y_pixels (const int pixels_y)
 
int scintpix_from_pixx (const int x)
 
int det_to_screen_y (const int plane, const int cell)
 
int det_to_screen_x (const int plane)
 
std::pair< int, intcppoint_to_screen (const cppoint &tp)
 
int screen_to_plane (const noe_view_t view, const int x)
 
int screen_to_plane_unbounded (const noe_view_t view, const int x)
 
int screen_to_cell (const noe_view_t view, const int x, const int y)
 
int screen_to_cell_unbounded (const noe_view_t view, const int x, const int y)
 

Detailed Description

Supply basic geometry functions.

Author
messi.nosp@m.er@i.nosp@m.ndian.nosp@m.a.ed.nosp@m.u
Version

Definition in file geo.h.

Enumeration Type Documentation

enum noe_view_t
Enumerator
kX 
kY 
kXorY 

Definition at line 1 of file geo.h.

1 { kX, kY, kXorY };
Definition: geo.h:1
Definition: geo.h:1
Definition: geo.h:1

Function Documentation

std::pair<int, int> cppoint_to_screen ( const cppoint tp)

Definition at line 139 of file geo.cxx.

References cppoint::cell, det_to_screen_x(), det_to_screen_y(), cppoint::fcell, cppoint::fplane, pixx, pixy, and cppoint::plane.

Referenced by draw_track_in_one_view(), draw_vertex_in_one_view(), and rect::xmax().

140 {
141  return std::pair<int, int>(
142  det_to_screen_x(tp.plane) + (0.5 + tp.fplane)*pixx/2,
143  det_to_screen_y(tp.plane, tp.cell) + (0.5 - tp.fcell )*pixy
144  );
145 }
int pixy
Definition: geo.cxx:24
float fcell
Definition: event.h:16
int pixx
Definition: geo.cxx:24
uint16_t plane
Definition: event.h:11
float fplane
Definition: event.h:16
int det_to_screen_y(const int plane, const int cell)
Definition: geo.cxx:119
int det_to_screen_x(const int plane)
Definition: geo.cxx:100
uint16_t cell
Definition: event.h:11
int det_to_screen_x ( const int  plane)

Definition at line 100 of file geo.cxx.

References first_mucatcher, pixx, and screenxoffset.

Referenced by cppoint_to_screen(), dozooming(), draw_hit(), and rect::xmax().

101 {
102  const bool xview = plane%2 == 1;
103  return 1 + // Don't overdraw the border
104  pixx*((plane
105 
106  // space out the muon catcher planes so they are twice as far
107  // apart as normal. This is very close to right, since the depth
108  // of (two scintillator planes + one steel plane + air gaps) is
109  // within 10% of the depth of two scintillator planes.
111 
112  // stagger x and y planes
113  + xview*pixx/2
114 
115  - screenxoffset;
116 }
int pixx
Definition: geo.cxx:24
int first_mucatcher
Definition: geo.cxx:21
int screenxoffset
Definition: geo.cxx:98
int det_to_screen_y ( const int  plane,
const int  cell 
)

Definition at line 119 of file geo.cxx.

References getBrightness::cell, first_mucatcher, ncells_perplane, pixy, screenyoffset_xview, and screenyoffset_yview.

Referenced by cppoint_to_screen(), dozooming(), draw_hit(), and rect::xmax().

120 {
121  const bool xview = plane%2 == 1;
122 
123  // In each view, every other plane is offset by half a cell width
124  const bool celldown = !((plane/2)%2 ^ (plane%2));
125 
126  return + pixy*(ncells_perplane-cell) // cells numbered from the bottom
127 
128  - (pixy-1)
129 
130  // Physical stagger of planes in each view, but not in the muon
131  // catcher, which is a better approximation to the current MC
132  // geometry and plausible from visual inspection of the real
133  // muon catcher.
134  + (plane < first_mucatcher)*celldown*pixy/2
135 
137 }
int pixy
Definition: geo.cxx:24
int first_mucatcher
Definition: geo.cxx:21
int screenyoffset_xview
Definition: geo.cxx:98
int ncells_perplane
Definition: geo.cxx:22
int screenyoffset_yview
Definition: geo.cxx:98
int pixx_from_pixy ( const int  y)

Definition at line 51 of file geo.cxx.

References celldepth, ExtruGlueThick, ExtruWidth, and makeTrainCVSamples::int.

Referenced by dozooming(), and rect::xmax().

52 {
53  const double meancellwidth = (2*ExtruWidth+ExtruGlueThick)/32;
54 
55  // Comes out to 3.36, giving pixel ratios 3:1, 2:7, 3:10, 4:13, 5:17, etc.
56  const double planepix_per_cellpix = 2*celldepth/meancellwidth;
57 
58  return int(y*planepix_per_cellpix + 0.5);
59 }
static const double ExtruWidth
Definition: geo.cxx:40
static const double ExtruGlueThick
Definition: geo.cxx:41
static const double celldepth
Definition: geo.cxx:46
int scintpix_from_pixx ( const int  x)

Definition at line 61 of file geo.cxx.

References celldepth, ExtruDepth, ExtruWallThick, and makeTrainCVSamples::int.

Referenced by draw_hit(), and rect::xmax().

62 {
63  const double scintdepth = ExtruDepth - 2*ExtruWallThick;
64  return int(x * scintdepth/(2*celldepth) + 0.5);
65 }
static const double ExtruWallThick
Definition: geo.cxx:32
static const double celldepth
Definition: geo.cxx:46
static const double ExtruDepth
Definition: geo.cxx:31
int screen_to_cell ( const noe_view_t  view,
const int  x,
const int  y 
)

Definition at line 229 of file geo.cxx.

References plot_validation_datamc::c, first_mucatcher, kY, ncells_perplane, NDAPDHVSetting::plane, screen_to_cell_unbounded(), and screen_to_plane().

Referenced by screen_to_activecell(), and rect::xmax().

230 {
231  const int c = screen_to_cell_unbounded(view, x, y);
232  const int plane = screen_to_plane(view, x);
233  if(c < 0) return -1;
234  if(c >= ncells_perplane) return -1;
235  if(plane >= first_mucatcher && view == kY && c >= 2*ncells_perplane/3) return -1;
236  return c;
237 }
int first_mucatcher
Definition: geo.cxx:21
const Var kY([](const caf::SRProxy *sr){float tmp=0.f;if(sr->mc.nu.empty()) return tmp;tmp=sr->mc.nu[0].y;return tmp;})
int ncells_perplane
Definition: geo.cxx:22
int screen_to_cell_unbounded(const noe_view_t view, const int x, const int y)
Definition: geo.cxx:215
int screen_to_plane(const noe_view_t view, const int x)
Definition: geo.cxx:207
int screen_to_cell_unbounded ( const noe_view_t  view,
const int  x,
const int  y 
)

Definition at line 215 of file geo.cxx.

References first_mucatcher, kX, ncells_perplane, pixy, NDAPDHVSetting::plane, screen_to_plane(), screenyoffset_xview, and screenyoffset_yview.

Referenced by dozooming(), screen_to_cell(), and rect::xmax().

216 {
217  // Where y would be if not offset. Do not pass into functions.
218  const int unoffsety = y + (view == kX?screenyoffset_xview:screenyoffset_yview);
219 
220  const int plane = screen_to_plane(view, x);
221 
222  // See comments in det_to_screen_y() on the muon catcher.
223  const bool celldown = (plane < first_mucatcher) && !((plane/2)%2 ^ (plane%2));
224  const int effy = unoffsety - celldown*(pixy/2) - 2;
225 
226  return ncells_perplane - effy/pixy - 1;
227 }
int pixy
Definition: geo.cxx:24
int first_mucatcher
Definition: geo.cxx:21
int screenyoffset_xview
Definition: geo.cxx:98
int ncells_perplane
Definition: geo.cxx:22
int screenyoffset_yview
Definition: geo.cxx:98
Definition: geo.h:1
int screen_to_plane(const noe_view_t view, const int x)
Definition: geo.cxx:207
int screen_to_plane ( const noe_view_t  view,
const int  x 
)

Definition at line 207 of file geo.cxx.

References kX, nplanes, and screen_to_plane_unbounded().

Referenced by screen_to_activecell(), screen_to_cell(), screen_to_cell_unbounded(), update_active_indices(), and rect::xmax().

208 {
209  const int p = screen_to_plane_unbounded(view, x);
210  if(p < (view == kX?1:0)) return -1;
211  if(p >= nplanes) return -1;
212  return p;
213 }
const char * p
Definition: xmltok.h:285
int nplanes
Definition: geo.cxx:23
Definition: geo.h:1
int screen_to_plane_unbounded(const noe_view_t view, const int x)
Definition: geo.cxx:182
int screen_to_plane_unbounded ( const noe_view_t  view,
const int  x 
)

Definition at line 182 of file geo.cxx.

References first_mucatcher, kX, kY, pixx, and screenxoffset.

Referenced by dozooming(), screen_to_plane(), and rect::xmax().

183 {
184  // Where x would be if not offset
185  const int unoffsetx = x + screenxoffset;
186 
187  // The number of the first muon catcher plane counting only planes
188  // in one view.
189  const int halfmucatch = (first_mucatcher)/2 + (view == kY);
190 
191  // Account for the plane stagger and border width.
192  const int effx = unoffsetx - 2 -
193  (unoffsetx-2 >= halfmucatch*pixx)*(pixx/2);
194 
195  // Half the plane number, as long as we're not in the muon catcher
196  int halfp = view == kX? (effx-pixx/2)/pixx
197  :( effx )/pixx;
198 
199  // Fix up the case of being in the muon catcher
200  if(halfp > halfmucatch) halfp = halfmucatch +
201  (halfp - halfmucatch)/2;
202 
203  // The plane number, except it might be out of range
204  return halfp*2 + (view == kX);
205 }
int pixx
Definition: geo.cxx:24
int first_mucatcher
Definition: geo.cxx:21
int screenxoffset
Definition: geo.cxx:98
const Var kY([](const caf::SRProxy *sr){float tmp=0.f;if(sr->mc.nu.empty()) return tmp;tmp=sr->mc.nu[0].y;return tmp;})
Definition: geo.h:1
void setboxes ( )

Definition at line 149 of file geo.cxx.

References first_mucatcher, kX, kY, ncells_perplane, nplanes, pixx, pixy, screenxoffset, screenyoffset_xview, screenyoffset_yview, total_x_pixels(), total_y_pixels(), rect::xmin, rect::xsize, rect::ymin, and rect::ysize.

Referenced by draw_background(), setfd(), setup(), and rect::xmax().

150 {
151  const int ybox = total_y_pixels(pixy);
152  const int xbox = total_x_pixels(pixx);
153 
154  const int xboxnomu = pixx*(first_mucatcher/2) + pixy/2 /* cell stagger */;
155 
156  // muon catcher is 1/3 empty. Do not include cell stagger here since we want
157  // the extra half cells to be inside the active box.
158  const int yboxnomu = (ncells_perplane/3)*pixy;
159 
160  screenview[kX].xmin = -screenxoffset + pixx/2 /* plane stagger */;
162  screenview[kX].xsize = xbox;
163  screenview[kX].ysize = ybox;
164 
165  const bool hasmucatch = first_mucatcher < nplanes;
166 
167  // In the x view the blank spaces are to the left of the hits, but in
168  // the y view, they are to the right, but I don't want the box to include them.
169  const int hacky_subtraction_for_y_mucatch = hasmucatch * pixx;
170 
173  screenview[kY].xsize = xbox-hacky_subtraction_for_y_mucatch;
174  screenview[kY].ysize = ybox;
175 
176  screenmu.xmin = -screenxoffset + 1 + xboxnomu;
178  screenmu.xsize = xbox-xboxnomu-hacky_subtraction_for_y_mucatch-1;
179  screenmu.ysize = yboxnomu;
180 }
int pixy
Definition: geo.cxx:24
int pixx
Definition: geo.cxx:24
int xmin
Definition: geo.h:4
int first_mucatcher
Definition: geo.cxx:21
int xsize
Definition: geo.h:5
int ymin
Definition: geo.h:4
int screenyoffset_xview
Definition: geo.cxx:98
int screenxoffset
Definition: geo.cxx:98
const Var kY([](const caf::SRProxy *sr){float tmp=0.f;if(sr->mc.nu.empty()) return tmp;tmp=sr->mc.nu[0].y;return tmp;})
rect screenview[kXorY]
Definition: geo.cxx:29
int ncells_perplane
Definition: geo.cxx:22
int screenyoffset_yview
Definition: geo.cxx:98
int nplanes
Definition: geo.cxx:23
int total_y_pixels(const int pixels_y)
Definition: geo.cxx:74
rect screenmu
Definition: geo.cxx:29
int ysize
Definition: geo.h:5
Definition: geo.h:1
int total_x_pixels(const int pixels_x)
Definition: geo.cxx:67
void setfd ( )

Definition at line 80 of file geo.cxx.

References FDfirst_mucatcher, FDncells_perplane, FDnplanes_perview, FDpixx, FDpixy, first_mucatcher, isfd, ncells_perplane, nplanes, nplanes_perview, pixx, pixy, and setboxes().

Referenced by draw_event(), and rect::xmax().

81 {
82  isfd = true;
83 
87 
89 
90  pixx = FDpixx;
91  pixy = FDpixy;
92 
93  setboxes();
94 }
int pixy
Definition: geo.cxx:24
void setboxes()
Definition: geo.cxx:149
int pixx
Definition: geo.cxx:24
int nplanes_perview
Definition: geo.cxx:20
int first_mucatcher
Definition: geo.cxx:21
static const int FDncells_perplane
Definition: geo.cxx:12
int FDpixy
Definition: geo.cxx:14
int ncells_perplane
Definition: geo.cxx:22
int nplanes
Definition: geo.cxx:23
static const int FDfirst_mucatcher
Definition: geo.cxx:11
int FDpixx
Definition: geo.cxx:14
static const int FDnplanes_perview
Definition: geo.cxx:10
bool isfd
Definition: geo.cxx:18
int total_x_pixels ( const int  pixels_x)

Definition at line 67 of file geo.cxx.

References first_mucatcher, nplanes, and nplanes_perview.

Referenced by setboxes(), and rect::xmax().

68 {
69  return pixels_x*(nplanes_perview +
71  nplanes_perview - first_mucatcher/2: 0)) + 1;
72 }
int nplanes_perview
Definition: geo.cxx:20
int first_mucatcher
Definition: geo.cxx:21
int nplanes
Definition: geo.cxx:23
int total_y_pixels ( const int  pixels_y)

Definition at line 74 of file geo.cxx.

References ncells_perplane.

Referenced by setboxes(), and rect::xmax().

75 {
76  return ncells_perplane*pixels_y
77  + pixels_y/2 /* cell stagger */ + 1 /* border */;
78 }
int ncells_perplane
Definition: geo.cxx:22