Classes | Functions | Variables
noe Namespace Reference

Classes

class  noe
 

Functions

 __attribute__ ((unused)) static void add_test_fd_event()
 
static cppoint get_int_plane_and_cell (const double x, const double y, const double z, const geo::View_t view)
 
static void build_cell_lookup_table (art::ServiceHandle< geo::Geometry > &geo)
 
static std::pair< cppoint, cppointcart_to_cp (art::ServiceHandle< geo::Geometry > &geo, const TVector3 &tp)
 

Variables

static vector< vector< float > > xcell_z
 
static vector< vector< float > > ycell_z
 
static vector< float > xplane_z
 
static vector< float > yplane_z
 
static vector< vector< float > > xcell_x
 
static vector< vector< float > > ycell_y
 

Function Documentation

noe::__attribute__ ( (unused)  )

Definition at line 90 of file noe_module.cc.

References hit::adc, noeevent::addhit(), make_syst_table_plots::c, hit::cell, noeevent::nevent, noeevent::nrun, noeevent::nsubrun, hit::plane, hit::tdc, and theevents.

91 {
92  noeevent ev;
93  ev.nevent = 0;
94  ev.nrun = 0;
95  ev.nsubrun = 0;
96 
97  for(unsigned int c = 0; c < 12 * 32; c++){
98  for(unsigned int p = 0; p < 32 * 28; p++){
99  hit thehit;
100  thehit.cell = c;
101  thehit.plane = p;
102  thehit.adc = (c*p)%124;
103  thehit.tdc = ((c*p)%432)*4;
104  ev.addhit(thehit);
105  }
106  }
107  theevents.push_back(ev);
108 }
vector< noeevent > theevents
Definition: noe_module.cc:28
uint32_t nsubrun
Definition: event.h:45
uint16_t plane
Definition: event.h:2
const char * p
Definition: xmltok.h:285
void addhit(const hit &h)
Definition: event.h:83
int32_t tdc
Definition: event.h:5
Definition: event.h:41
uint16_t cell
Definition: event.h:2
uint32_t nevent
Definition: event.h:45
uint32_t nrun
Definition: event.h:45
int16_t adc
Definition: event.h:3
Definition: event.h:1
static void noe::build_cell_lookup_table ( art::ServiceHandle< geo::Geometry > &  geo)
static

Definition at line 201 of file noe_module.cc.

References geo::GeometryBase::CellInfo(), geo::kX, geo::PlaneGeo::Ncells(), geo::GeometryBase::NPlanes(), std_candles::pl, geo::GeometryBase::Plane(), NDAPDHVSetting::plane, push_back(), POTSpillRate::view, ycell_y, ycell_z, and yplane_z.

Referenced by cart_to_cp().

202 {
203  for(unsigned int pl = 0; pl < geo->NPlanes(); pl++){
204  const geo::PlaneGeo * const plane = geo->Plane(pl);
206  vector<float> cell_z, cell_t;
207  for(unsigned int ce = 0; ce < plane->Ncells(); ce++){
208  double cellcenter[3], dum[3];
209  geo->CellInfo(pl, ce, &view, cellcenter, dum);
210  cell_z.push_back(cellcenter[2]);
211  cell_t.push_back(geo::kX?cellcenter[0]:cellcenter[1]);
212  }
213 
214  (view == geo::kX?xcell_z:ycell_z).push_back(cell_z);
215  (view == geo::kX?xcell_x:ycell_y).push_back(cell_t);
216 
217  vector<float> & pz = (view == geo::kX?xplane_z:yplane_z);
218  pz.push_back(cell_z[cell_z.size()/2]);
219  }
220 }
static vector< vector< float > > xcell_z
Definition: noe_module.cc:132
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
static vector< vector< float > > ycell_y
Definition: noe_module.cc:137
Vertical planes which measure X.
Definition: PlaneGeo.h:28
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const PlaneGeo * Plane(unsigned int i) const
static vector< vector< float > > xcell_x
Definition: noe_module.cc:136
void CellInfo(unsigned int ip, unsigned int ic, View_t *view=0, double *pos=0, double *dpos=0) const
Geometry information for a single readout plane.
Definition: PlaneGeo.h:36
base_types push_back(int_type())
static vector< float > xplane_z
Definition: noe_module.cc:134
static vector< float > yplane_z
Definition: noe_module.cc:135
static vector< vector< float > > ycell_z
Definition: noe_module.cc:133
unsigned int NPlanes() const
static std::pair<cppoint, cppoint> noe::cart_to_cp ( art::ServiceHandle< geo::Geometry > &  geo,
const TVector3 &  tp 
)
static

Definition at line 225 of file noe_module.cc.

References build_cell_lookup_table(), geo::GeometryBase::CellInfo(), get_int_plane_and_cell(), geo::kX, and geo::kY.

Referenced by noe::noe::produce().

227 {
228  // With this lookup table (which isn't really a lookup table), finding
229  // track point uses ~15% of the time spent loading events. Probably
230  // could go faster, although that's not too bad.
231  {
232  static int first = true;
233  if(first) build_cell_lookup_table(geo);
234  first = false;
235  }
236 
237  // For each view, first find a plane and cell which is probably the closest
238  // one, or maybe one of the several closest. Then ask the geometry where that
239  // cell is and store the difference in the fractional part of the cppoint.
240  // This is right up to the difference between the mean plane and cell
241  // spacings and the actual spacing near the requested point. For purposes of
242  // the event display, it's fine.
243 
244  // Exact values are not very important
245  const double meanplanesep = 6.6681604;
246  const double meancellsep = 3.9674375;
247 
248  std::pair<cppoint, cppoint> answer;
249  answer.first = get_int_plane_and_cell(tp.X(), tp.Y(), tp.Z(), geo::kX);
250 
251  double cellcenter[3], dum[3];
252  geo::View_t dumv;
253 
254  geo->CellInfo(answer.first.plane, answer.first.cell, &dumv, cellcenter, dum);
255  answer.first.fcell = (tp.X() - cellcenter[0])/meancellsep;
256  answer.first.fplane = (tp.Z() - cellcenter[2])/meanplanesep;
257 
258  // Could optimize this by only checking the nearest two planes to the one
259  // found above, but I bet that geo::CellInfo is the hot spot, not
260  // std::upper_bound.
261  answer.second = get_int_plane_and_cell(tp.X(), tp.Y(), tp.Z(), geo::kY);
262 
263  geo->CellInfo(answer.second.plane, answer.second.cell, &dumv, cellcenter, dum);
264  answer.second.fcell = (tp.Y() - cellcenter[1])/meancellsep;
265  answer.second.fplane = (tp.Z() - cellcenter[2])/meanplanesep;
266 
267  return answer;
268 }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Vertical planes which measure X.
Definition: PlaneGeo.h:28
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
void CellInfo(unsigned int ip, unsigned int ic, View_t *view=0, double *pos=0, double *dpos=0) const
static void build_cell_lookup_table(art::ServiceHandle< geo::Geometry > &geo)
Definition: noe_module.cc:201
static cppoint get_int_plane_and_cell(const double x, const double y, const double z, const geo::View_t view)
Definition: noe_module.cc:141
static cppoint noe::get_int_plane_and_cell ( const double  x,
const double  y,
const double  z,
const geo::View_t  view 
)
static

Definition at line 141 of file noe_module.cc.

References add(), cppoint::cell, stan::math::fabs(), geo::kX, python.hepunit::pi, cppoint::plane, confusionMatrixTree::t, ycell_y, yplane_z, and test::z.

Referenced by cart_to_cp().

143 {
144  cppoint ans;
145 
146  // (1) First the plane
147  {
148  vector<float> & tplane_z = view == geo::kX?xplane_z:yplane_z;
149 
150  const vector<float>::iterator pi
151  = std::upper_bound(tplane_z.begin(), tplane_z.end(), z);
152 
153  const int add = (view == geo::kX);
154 
155  if(pi == tplane_z.end()){
156  // No plane had as big a 'z' as this, so use the last plane.
157  ans.plane = (tplane_z.size()-1) * 2 + add;
158  }
159  else if(pi == tplane_z.begin()){
160  // 'z' was smaller than the first plane, so that's the closest.
161  ans.plane = add;
162  }
163  else{
164  // Check which is closer, the first plane bigger than 'z', or the
165  // previous one.
166  const float thisone = fabs( *pi - z);
167  const float previous = fabs( *(pi - 1) - z);
168  if(thisone < previous) ans.plane = (pi - tplane_z.begin())*2 + add;
169  else ans.plane = (pi - tplane_z.begin())*2 + add - 2;
170  }
171  }
172 
173  // (2) Now find the cell
174  {
175  vector<float> & cells = (view == geo::kX? xcell_x:ycell_y)[ans.plane/2];
176 
177  const float t = (view == geo::kX? x: y);
178  const vector<float>::iterator ci
179  = std::upper_bound(cells.begin(), cells.end(), t);
180 
181  if(ci == cells.end()){
182  // No cell had as big a 't' as this, so use the last cell.
183  ans.cell = cells.size()-1;
184  }
185  else if(ci == cells.begin()){
186  // 't' was smaller than the first cell, so that's the closest.
187  ans.cell = 0;
188  }
189  else{
190  // Check which is closer
191  const float thisone = fabs( *ci - t);
192  const float previous = fabs( *(ci - 1) - t);
193  if(thisone < previous) ans.cell = (ci - cells.begin());
194  else ans.cell = (ci - cells.begin()) - 1;
195  }
196  }
197 
198  return ans;
199 }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
static vector< vector< float > > ycell_y
Definition: noe_module.cc:137
uint16_t plane
Definition: event.h:11
Vertical planes which measure X.
Definition: PlaneGeo.h:28
static vector< vector< float > > xcell_x
Definition: noe_module.cc:136
static vector< float > xplane_z
Definition: noe_module.cc:134
static vector< float > yplane_z
Definition: noe_module.cc:135
z
Definition: test.py:28
Definition: event.h:9
add("abs", expr_type(int_type()), expr_type(int_type()))
uint16_t cell
Definition: event.h:11

Variable Documentation

vector< vector<float> > noe::xcell_x
static

Definition at line 136 of file noe_module.cc.

vector< vector<float> > noe::xcell_z
static

Definition at line 132 of file noe_module.cc.

vector<float> noe::xplane_z
static

Definition at line 134 of file noe_module.cc.

vector< vector<float> > noe::ycell_y
static

Definition at line 137 of file noe_module.cc.

Referenced by build_cell_lookup_table(), and get_int_plane_and_cell().

vector< vector<float> > noe::ycell_z
static

Definition at line 133 of file noe_module.cc.

Referenced by build_cell_lookup_table().

vector<float> noe::yplane_z
static

Definition at line 135 of file noe_module.cc.

Referenced by build_cell_lookup_table(), and get_int_plane_and_cell().