Classes | Macros | Typedefs | Functions | Variables
test_GeometryDune.cxx File Reference
#include "larcore/Geometry/Geometry.h"
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include "dunecore/ArtSupport/ArtServiceHelper.h"
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "larcorealg/Geometry/Exceptions.h"

Go to the source code of this file.

Classes

struct  SpacePoint
 

Macros

#define test_GeometryDune_CXX
 

Typedefs

typedef readout::TPCsetID APAID
 
typedef unsigned int Index
 
template<class T >
using Vector = vector< T >
 
template<class T >
using TwoVector = Vector< Vector< T >>
 
template<class T >
using ThreeVector = Vector< TwoVector< T >>
 

Functions

template<class T , class V >
void resize (Vector< T > &vec1, Index n1, const V &val)
 
template<class T , class V >
void resize (TwoVector< T > &vec2, Index n1, Index n2, const V &val)
 
template<class T , class V >
void resize (ThreeVector< T > &vec3, Index n1, Index n2, Index n3, const V &val)
 
void setExpectedValues (ExpectedValues &ev)
 
void setExpectedValuesSpacePoints (Geometry *)
 
int test_GeometryDune (const ExpectedValues &ev, bool dorop, Index maxchanprint, bool useExistingFcl)
 
int main (int argc, const char *argv[])
 

Variables

const Index InvalidIndex = std::numeric_limits<Index>::max()
 

Macro Definition Documentation

#define test_GeometryDune_CXX

Definition at line 4 of file test_GeometryDune.cxx.

Typedef Documentation

Definition at line 48 of file test_GeometryDune.cxx.

typedef unsigned int Index

Definition at line 55 of file test_GeometryDune.cxx.

template<class T >
using ThreeVector = Vector<TwoVector<T>>

Definition at line 65 of file test_GeometryDune.cxx.

template<class T >
using TwoVector = Vector<Vector<T>>

Definition at line 62 of file test_GeometryDune.cxx.

template<class T >
using Vector = vector<T>

Definition at line 59 of file test_GeometryDune.cxx.

Function Documentation

int main ( int  argc,
const char *  argv[] 
)

Definition at line 541 of file test_GeometryDune.cxx.

541  {
542  ExpectedValues ev;
543  setExpectedValues(ev);
544  bool dorop = true;
545  Index maxchanprint = 10;
546  bool useExistingFcl = false;
547  if ( argc > 1 ) {
548  string sarg = argv[1];
549  if ( sarg == "-h" ) {
550  cout << argv[0] << ": . [dorop] [maxchan] [usefcl]" << endl;
551  cout << argv[0] << ": [ChannelMapClass] [dorop] [maxchan] [usefcl]" << endl;
552  cout << argv[0] << ": [Geometry/ChannelMapClass/sorter] [dorop] [maxchan] [usefcl]" << endl;
553  cout << " dorop: If true ROP mapping methods are tested [true]" << endl;
554  cout << " maxchan: Max # channels displayed for each ROP [10]" << endl;
555  cout << " usefcl: Take top-level fcl from current directory [false]" << endl;
556  return 0;
557  }
558  string::size_type ipos = sarg.find("/");
559  if ( ipos == string ::npos ) {
560  if ( sarg != "." ) ev.chanmap = sarg;
561  } else {
562  ev.gname = sarg.substr(0, ipos);
563  string::size_type jpos = sarg.find("/", ipos+1);
564  if ( jpos == string::npos ) {
565  ev.chanmap = sarg.substr(ipos+1);
566  } else {
567  ev.chanmap = sarg.substr(ipos+1, jpos-ipos-1);
568  ev.sorter = sarg.substr(jpos+1);
569  }
570  }
571  }
572  if ( argc > 2 ) {
573  string sarg = argv[2];
574  dorop = sarg == "1" || sarg == "true" || sarg == ".";
575  }
576  if ( argc > 3 ) {
577  istringstream ssarg(argv[3]);
578  ssarg >> maxchanprint;
579  }
580  if ( argc > 4 ) {
581  string sarg = argv[4];
582  useExistingFcl = sarg == "1" || sarg == "true";
583  }
584  test_GeometryDune(ev, dorop, maxchanprint, useExistingFcl);
585  cout << "Tests concluded." << endl;
586  return 0;
587 }
unsigned int Index
void setExpectedValues(ExpectedValues &ev)
int test_GeometryDune(const ExpectedValues &ev, bool dorop, Index maxchanprint, bool useExistingFcl)
QTextStream & endl(QTextStream &s)
template<class T , class V >
void resize ( Vector< T > &  vec1,
Index  n1,
const V &  val 
)

Definition at line 68 of file test_GeometryDune.cxx.

68  {
69  vec1.resize(n1, val);
70 }
template<class T , class V >
void resize ( TwoVector< T > &  vec2,
Index  n1,
Index  n2,
const V &  val 
)

Definition at line 73 of file test_GeometryDune.cxx.

73  {
74  vec2.resize(n1);
75  for ( Vector<T>& vec1 : vec2 ) {
76  vec1.resize(n2, val);
77  }
78 }
template<class T , class V >
void resize ( ThreeVector< T > &  vec3,
Index  n1,
Index  n2,
Index  n3,
const V &  val 
)

Definition at line 81 of file test_GeometryDune.cxx.

81  {
82  vec3.resize(n1);
83  for ( TwoVector<T>& vec2 : vec3 ) {
84  vec2.resize(n2);
85  for ( Vector<T>& vec1 : vec2 ) {
86  vec1.resize(n3, val);
87  }
88  }
89 }
void setExpectedValues ( ExpectedValues &  ev)

Definition at line 14 of file test_GeometryDune10kt.cxx.

14  {
15  ev.gname ="dune10kt_workspace_geo";
16  ev.fullname = "dune10kt_v1_workspace";
17  // Geometry counts.
18  ev.ncry = 1;
19  ev.ntpc = 8;
20  ev.npla = 3;
21  ev.napa = 4;
22  ev.nrop = 4;
23  // Signal type and view for each TPC plane.
24  resize(ev.sigType, ev.ncry, ev.ntpc, ev.npla, geo::kMysteryType);
25  resize(ev.view, 1, 8, 3, geo::kUnknown);
26  for ( Index icry=0; icry<ev.ncry; ++icry ) {
27  for ( Index itpc=0; itpc<ev.ntpc; ++itpc ) {
28  for ( Index ipla=0; ipla<ev.npla; ++ipla ) {
29  ev.sigType[icry][itpc][ipla] = (ipla < 2) ? geo::kInduction : geo::kCollection;
30  }
31  ev.view[icry][itpc][0] = geo::kU;
32  ev.view[icry][itpc][1] = geo::kV;
33  ev.view[icry][itpc][2] = geo::kZ;
34  }
35  }
36  // Wire count for each TPC plane.
37  resize(ev.nwirPerPlane, ev.ntpc, ev.npla, 0);
38  ev.nwirPerPlane[0][0] = 1149;
39  ev.nwirPerPlane[0][1] = 1148;
40  ev.nwirPerPlane[0][2] = 480;
41  for ( Index itpc=1; itpc<ev.ntpc; ++itpc ) {
42  for ( Index ipla=0; ipla<ev.npla; ++ipla ) ev.nwirPerPlane[itpc][ipla] = ev.nwirPerPlane[0][ipla];
43  }
44  // Channel count per ROP.
45  resize(ev.nchaPerRop, ev.nrop, 0);
46  ev.nchaPerRop[0] = 800;
47  ev.nchaPerRop[1] = 800;
48  ev.nchaPerRop[2] = 480;
49  ev.nchaPerRop[3] = 480;
50  for ( Index irop=0; irop<ev.nrop; ++irop ) ev.nchaPerApa += ev.nchaPerRop[irop];
51  ev.nchatot = ev.napa*ev.nchaPerApa;
52  resize(ev.chacry, ev.nchatot, InvalidIndex);
53  resize(ev.chaapa, ev.nchatot, InvalidIndex);
54  resize(ev.charop, ev.nchatot, InvalidIndex);
55  Index icha = 0;
56  for ( Index icry=0; icry<ev.ncry; ++icry ) {
57  for ( Index iapa=0; iapa<ev.napa; ++iapa ) {
58  for ( Index irop=0; irop<ev.nrop; ++irop ) {
59  for ( Index kcha=0; kcha<ev.nchaPerRop[irop]; ++kcha ) {
60  ev.chacry[icha] = icry;
61  ev.chaapa[icha] = iapa;
62  ev.charop[icha] = irop;
63  ++icha;
64  }
65  }
66  }
67  }
68  resize(ev.firstchan, ev.ncry, ev.napa, ev.nrop, raw::InvalidChannelID);
69  Index chan = 0;
70  for ( Index icry=0; icry<ev.ncry; ++icry ) {
71  for ( Index iapa=0; iapa<ev.napa; ++iapa ) {
72  for ( Index irop=0; irop<ev.nrop; ++irop ) {
73  ev.firstchan[icry][iapa][irop] = chan;
74  chan += ev.nchaPerRop[irop];
75  }
76  }
77  }
78  // Space points.
79  #include "setWorkspaceSpacePoints.dat"
80  // Optical detectors.
81  ev.nopdet = 10*ev.napa;
82  ev.nopdetcha.resize(ev.nopdet, 1);
83  ev.nopcha = ev.nopdet;
84  resize(ev.opdetcha, ev.nopdet, 1, 0);
85  for ( Index iopt=0; iopt<ev.nopdet; ++iopt ) {
86  Index icha = iopt;
87  for ( Index ioch=0; ioch<ev.nopdetcha[iopt]; ++ ioch ) {
88  ev.opdetcha[iopt][ioch] = icha++;
89  }
90  }
91 }
Who knows?
Definition: geo_types.h:147
Planes which measure V.
Definition: geo_types.h:130
Unknown view.
Definition: geo_types.h:136
Planes which measure Z direction.
Definition: geo_types.h:132
unsigned int Index
void resize(Vector< T > &vec1, Index n1, const V &val)
const Index InvalidIndex
Planes which measure U.
Definition: geo_types.h:129
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
Signal from induction planes.
Definition: geo_types.h:145
Signal from collection planes.
Definition: geo_types.h:146
void setExpectedValuesSpacePoints ( Geometry )

Definition at line 95 of file test_GeometryDune10kt.cxx.

95  {
96  const string myname = "setExpectedValuesSpacePoints: ";
97  string ofname = "setExpectedValuesSpacePoints.dat";
98  cout << myname << "Writing " << ofname << endl;
99  const CryostatGeo& crygeo = pgeo->Cryostat(0);
100  double origin[3] = {0.0};
101  double crypos[3] = {0.0};
102  crygeo.LocalToWorld(origin, crypos);
103  double cxlo = crypos[0] - crygeo.HalfWidth();
104  double cxhi = crypos[0] + crygeo.HalfWidth();
105  double cylo = crypos[1] - crygeo.HalfHeight();
106  double cyhi = crypos[1] + crygeo.HalfHeight();
107  double czlo = crypos[2] - 0.5*crygeo.Length();
108  double czhi = crypos[2] + 0.5*crygeo.Length();
109  cout << "Cryostat limits: "
110  << "(" << cxlo << ", " << cylo << ", " << czlo << "), "
111  << "(" << cxhi << ", " << cyhi << ", " << czhi << ")" << endl;
112  vector<double> zfs = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7 };
113  vector<double> yfs = {0.2, 0.5, 0.8};
114  vector<double> xfs = {0.2, 0.3, 0.6 };
115  ofstream fout(ofname.c_str());
116  for ( double zf : zfs ) {
117  double z = czlo + zf*(czhi-czlo);
118  for ( double yf : yfs ) {
119  double y = cylo + yf*(cyhi-cylo);
120  for ( double xf : xfs ) {
121  double x = cxlo + xf*(cxhi-cxlo);
122  double xyz[3] = {x, y, z};
123  cout << " (" << x << ", " << y << ", " << z << ")" << endl;
124  TPCID tpcid = pgeo->FindTPCAtPosition(xyz);
125  unsigned int itpc = tpcid.TPC;
126  if ( itpc == TPCID::InvalidID ) continue;
127  const TPCGeo& tpcgeo = pgeo->TPC(tpcid);
128  unsigned int npla = tpcgeo.Nplanes();
129  fout << " ev.posXyz.push_back(SpacePoint(" << x << ", " << y << ", " << z << "));" << endl;
130  for ( unsigned int ipla=0; ipla<npla; ++ipla ) {
131  PlaneID plaid(tpcid, ipla);
132  double xwire = pgeo->WireCoordinate(x, y, plaid);
133  fout << " ev.posTpc.push_back(" << itpc << ");" << endl;
134  fout << " ev.posPla.push_back(" << ipla << ");" << endl;
135  fout << " ev.posWco.push_back(" << xwire << ");" << endl;
136  } // end loop over planes
137  } // end loop over x
138  } // end loop over y
139  } // end loop over z
140 }
unsigned int Nplanes() const
Number of planes in this tpc.
Definition: TPCGeo.h:165
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Geometry information for a single TPC.
Definition: TPCGeo.h:38
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
double HalfWidth() const
Half width of the cryostat [cm].
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
double HalfHeight() const
Half height of the cryostat [cm].
void LocalToWorld(const double *cryo, double *world) const
Transform point from local cryostat frame to world frame.
Definition: CryostatGeo.h:387
list x
Definition: train.py:276
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
double Length() const
Length of the cryostat [cm].
Definition: CryostatGeo.h:107
QTextStream & endl(QTextStream &s)
int test_GeometryDune ( const ExpectedValues &  ev,
bool  dorop,
Index  maxchanprint,
bool  useExistingFcl 
)

Definition at line 204 of file test_GeometryDune.cxx.

205  {
206  const string myname = "test_GeometryDune: ";
207  cout << myname << "Starting test" << endl;
208 #ifdef NDEBUG
209  cout << myname << "NDEBUG must be off." << endl;
210  abort();
211 #endif
212  string line = "-----------------------------";
213 
214  cout << myname << line << endl;
215  cout << myname << " Geometry: " << ev.gname << endl;
216  cout << myname << "Channel map: " << ev.chanmap << endl;
217  cout << myname << " Sorter: " << ev.sorter << endl;
218  cout << myname << " Do ROP: " << dorop << endl;
219 
220  cout << myname << line << endl;
221  cout << myname << "Create configuration." << endl;
222  if (useExistingFcl) {
223  ArtServiceHelper::load_services("test_GeometryDune.fcl",
225  } else {
226  std::stringstream config;
227  config << "#include \"geometry_dune.fcl\"" << endl;
228  config << "services.Geometry: @local::" << ev.gname << endl;
229  config << "services.ExptGeoHelperInterface: @local::dune_geometry_helper" << endl;
230  if ( ev.chanmap.size() ) {
231  config << "services.ExptGeoHelperInterface.ChannelMapClass: " << ev.chanmap << endl;
232  }
233  //config << "services.ExptGeoHelperInterface.GeoSorterClass: " << ev.sorter << endl;
235  }
236 
237  cout << myname << line << endl;
238  cout << myname << "Get Geometry service." << endl;
240 
241  cout << myname << line << endl;
242  check("Default wiggle", pgeo->DefaultWiggle());
243  check("Geometry name", pgeo->DetectorName(), ev.fullname);
244  cout << myname << "ROOT name: " << pgeo->ROOTFile() << endl;
245  cout << myname << "GDML name: " << pgeo->GDMLFile() << endl;
246 
247  cout << myname << line << endl;
248  double xlo, ylo, zlo;
249  double xhi, yhi, zhi;
250  cout << myname << "World box" << endl;
251  pgeo->WorldBox(&xlo, &ylo, &zlo, &xhi, &yhi, &zhi);
252  check(" xlo", xlo);
253  check(" ylo", ylo);
254  check(" zlo", zlo);
255  check(" xhi", xhi);
256  check(" yhi", yhi);
257  check(" zhi", zhi);
258 
259  cout << myname << line << endl;
260  check("SurfaceY", pgeo->SurfaceY());
261 
262  cout << myname << line << endl;
263  if ( 0 ) check("GetWorldVolumeName", pgeo->GetWorldVolumeName());
264  if ( 0 ) check("TotalMass", pgeo->TotalMass());
265 
266  cout << myname << line << endl;
267  check("CryostatHalfWidth", pgeo->CryostatHalfWidth());
268  check("CryostatHalfHeight", pgeo->CryostatHalfHeight());
269  check("CryostatLength", pgeo->CryostatLength());
270  //check("", pgeo->());
271 
272  cout << myname << line << endl;
273  Index ncry = pgeo->Ncryostats();
274  check("Ncryostats", ncry, ev.ncry);
275  check("MaxTPCs", pgeo->MaxTPCs(), ev.ntpc);
276  check("MaxPlanes", pgeo->MaxPlanes(), ev.npla);
277  check("TotalNTPC", pgeo->TotalNTPC(), ev.ntpc);
278  check("Nviews", pgeo->Nviews(), ev.npla);
279  check("Nchannels", pgeo->Nchannels(), ev.nchatot);
280 
281  cout << myname << line << endl;
282  cout << "Check TPC wire plane counts." << endl;
283  for ( Index icry=0; icry<ncry; ++icry ) {
284  Index ntpc = pgeo->NTPC(icry);
285  cout << " Cryostat " << icry << " has " << ntpc << " TPCs" << endl;
286  for ( Index itpc=0; itpc<ntpc; ++itpc ) {
287  Index npla = pgeo->Nplanes(itpc, icry);
288  cout << " TPC " << itpc << " has " << npla << " planes" << endl;
289  assert( npla == 3 );
290  for ( Index ipla=0; ipla<npla; ++ipla ) {
291  Index nwir = pgeo->Nwires(ipla, itpc, icry);
292  Index ich1 = pgeo->Nchannels();
293  Index ich2 = 0;
294  for ( Index iwir=0; iwir<nwir; ++iwir ) {
295  Index ich = pgeo->PlaneWireToChannel(ipla, iwir, itpc, icry);
296  if ( ich < ich1 ) ich1 = ich;
297  if ( ich > ich2 ) ich2 = ich;
298  }
299  cout << " Plane " << ipla << " has " << setw(4) << nwir << " wires"
300  << " readout on channels [" << ich1 << ", " << ich2 << "]"
301  << endl;
302  assert( nwir == ev.nwirPerPlane[itpc][ipla] );
303  }
304  }
305  }
306 
307  cout << myname << line << endl;
308  cout << "Check wire planes." << endl;
309  const double piOver2 = 0.5*acos(-1.0);
310  for ( PlaneID plaid : pgeo->IteratePlaneIDs() ) {
311  const geo::PlaneGeo& gpla = pgeo->Plane(plaid);
312  cout << " Plane " << plaid << endl;
313  cout << " Signal type: " << pgeo->SignalType(plaid) << endl;
314  cout << " View: " << pgeo->View(plaid) << endl;
315  cout << " Wire angle: " << gpla.ThetaZ() - piOver2 << endl;
316  assert( pgeo->SignalType(plaid) == ev.sigType[plaid.Cryostat][plaid.TPC][plaid.Plane] );
317  assert( pgeo->View(plaid) == ev.view[plaid.Cryostat][plaid.TPC][plaid.Plane] );
318  }
319 
320  cout << myname << line << endl;
321  cout << "Check channel-wire mapping." << endl;
322  Index itpc1Last = TPCID::InvalidID;
323  Index ipla1Last = WireID::InvalidID;
324  Index nprint = 0;
325  TwoVector<Index> lastwire;
326  resize(lastwire, ev.ntpc, ev.npla, 0);
327  for ( Index itpc=0; itpc<ev.ntpc; ++itpc )
328  for ( Index ipla=0; ipla<ev.npla; ++ipla )
329  lastwire[itpc][ipla] = 0;
330  for ( Index icha=0; icha<ev.nchatot; ++icha ) {
331  vector<WireID> wirids = pgeo->ChannelToWire(icha);
332  assert( wirids.size() > 0 );
333  WireID wirid1 = wirids[0];
334  Index itpc1 = wirid1.TPC;
335  Index iapa1 = itpc1/2;
336  Index ipla1 = wirid1.Plane;
337  if ( itpc1 != itpc1Last || ipla1 != ipla1Last ) nprint = 0;
338  itpc1Last = itpc1;
339  ipla1Last = ipla1;
340  bool print = nprint < maxchanprint;
341  if ( print ) ++nprint;
342  if ( print ) cout << " Channel " << setw(4) << icha << " has " << wirids.size() << " wires:";
343  ostringstream sposs;
344  sposs.precision(2);
345  for ( WireID wirid : wirids ) {
346  Index itpc = wirid.TPC;
347  Index iapa = itpc/2;
348  Index ipla = wirid.Plane;
349  Index iwir = wirid.Wire;
350  if ( print ) cout << " " << itpc << "-" << ipla << "-" << setw(3) << iwir;
351  if ( iwir > lastwire[itpc][ipla] ) lastwire[itpc][ipla] = iwir;
352  assert( iapa == iapa1 );
353  assert( ipla == ipla1 );
354  checkval("\nPlaneWireToChannel", pgeo->PlaneWireToChannel(wirid), icha );
355  assert( pgeo->SignalType(icha) == ev.sigType[wirid.Cryostat][wirid.TPC][wirid.Plane] );
356  checkval("View", pgeo->View(icha), ev.view[wirid.Cryostat][wirid.TPC][wirid.Plane]);
357  const WireGeo* pwg = pgeo->WirePtr(wirid);
358  TVector3 p1 = pwg->GetStart();
359  TVector3 p2 = pwg->GetEnd();
360  if ( sposs.str().size() ) sposs << ", ";
361  sposs << "(" << setw(7) << std::fixed << p1.x() << ", "
362  << setw(7) << std::fixed << p1.y() << ", "
363  << setw(7) << std::fixed << p1.z() << ") - ";
364  sposs << "(" << setw(7) << std::fixed << p2.x() << ", "
365  << setw(7) << std::fixed << p2.y() << ", "
366  << setw(7) << std::fixed << p2.z() << ")";
367  }
368  if ( print ) cout << " " << sposs.str() << endl;
369  }
370  for ( Index itpc=0; itpc<ev.ntpc; ++itpc ) {
371  for ( Index ipla=0; ipla<ev.npla; ++ipla ) {
372  Index nwir = lastwire[itpc][ipla] + 1;
373  cout << " TPC-plane " << itpc << "-" << ipla << " has " << setw(3) << nwir << " wires" << endl;
374  assert( nwir == ev.nwirPerPlane[itpc][ipla] );
375  }
376  }
377 
378  if ( dorop ) {
379  cout << myname << line << endl;
380  cout << "Check ROP counts and channels." << endl;
381  check("MaxROPs", pgeo->MaxROPs(), ev.nrop);
382  Index icry = 0;
383  for ( CryostatID cryid: pgeo->IterateCryostatIDs() ) {
384  Index napa = pgeo->NTPCsets(cryid);
385  cout << " Cryostat " << icry << " has " << napa << " APAs" << endl;
386  assert( napa == ev.napa );
387  for ( Index iapa=0; iapa<napa; ++iapa ) {
388  APAID apaid(cryid, iapa);
389  Index nrop = pgeo->NROPs(apaid);
390  cout << " APA " << iapa << " has " << nrop << " ROPs" << endl;
391  assert( nrop == ev.nrop );
392  for ( Index irop=0; irop<nrop; ++irop ) {
393  ROPID ropid(apaid, irop);
394  Index ncha = pgeo->Nchannels(ropid);
395  Index icha1 = pgeo->FirstChannelInROP(ropid);
396  Index icha2 = icha1 + ncha - 1;
397  cout << " ROP " << irop << " has " << ncha << " channels: ["
398  << icha1 << ", " << icha2 << "]" << endl;
399  assert( ncha == ev.nchaPerRop[irop] );
400  assert( icha1 == ev.firstchan[icry][iapa][irop] );
401  }
402  }
403  ++icry;
404  }
405  assert( icry == ncry );
406  cout << myname << line << endl;
407  cout << "Check channel-ROP mapping." << endl;
408  icry = 0;
409  for ( Index icha=0; icha<ev.nchatot; ++icha ) {
410  ROPID ropid = pgeo->ChannelToROP(icha);
411  Index icry = ropid.Cryostat;
412  Index iapa = ropid.TPCset;
413  Index irop = ropid.ROP;
414  assert( icry == ev.chacry[icha] );
415  assert( iapa == ev.chaapa[icha] );
416  assert( irop == ev.charop[icha] );
417  }
418  cout << myname << line << endl;
419  cout << "Check ROP-TPC mapping." << endl;
420  for ( CryostatID cryid: pgeo->IterateCryostatIDs() ) {
421  Index napa = pgeo->NTPCsets(cryid);
422  cout << " Cryostat " << icry << " has " << napa << " APAs" << endl;
423  assert( napa == ev.napa );
424  for ( Index iapa=0; iapa<napa; ++iapa ) {
425  APAID apaid(cryid, iapa);
426  Index nrop = pgeo->NROPs(apaid);
427  cout << " APA " << iapa << " has " << nrop << " ROPs" << endl;
428  assert( nrop == ev.nrop );
429  for ( Index irop=0; irop<nrop; ++irop ) {
430  ROPID ropid(apaid, irop);
431  std::vector<geo::TPCID> rtpcs = pgeo->ROPtoTPCs(ropid);
432  Index nrtpc = rtpcs.size();
433  assert( nrtpc > 0 );
434  cout << " ROP " << irop << " TPCs:";
435  for ( Index irtpc=0; irtpc<nrtpc; ++irtpc ) {
436  assert(rtpcs[irtpc].Cryostat == icry);
437  cout << (irtpc > 0 ? "," : "") << " " << rtpcs[irtpc].TPC;
438  }
439  cout << endl;
440  }
441  }
442  }
443  } else {
444  cout << myname << line << endl;
445  cout << "Skipped APA and ROP tests." << endl;
446  } // end dorop
447 
448  cout << myname << line << endl;
449  Index nspt = ev.posXyz.size();
450  if ( nspt == 0 ) {
451  cout << myname << "No space points found." << endl;
452  cout << myname << "Creating space points." << endl;
454  } else {
455  cout << myname << "Check " << nspt << " space points." << endl;
456  assert( ev.posPla.size() == ev.posTpc.size() );
457  assert( ev.posWco.size() == ev.posTpc.size() );
458  Index ires = 0;
459  int w = 9;
460  for ( Index ispt=0; ispt<nspt; ++ispt ) {
461  double x = ev.posXyz[ispt].x;
462  double y = ev.posXyz[ispt].y;
463  double z = ev.posXyz[ispt].z;
464  double xyz[3] = {x, y, z};
465  TPCID tpcid = pgeo->FindTPCAtPosition(xyz);
466  cout << " (" << setw(w) << x << "," << setw(w) << y << "," << setw(w) << z << "): " << tpcid << endl;
467  assert( tpcid.Cryostat != CryostatID::InvalidID );
468  unsigned int itpc = tpcid.TPC;
469  assert( itpc != TPCID::InvalidID );
470  const TPCGeo& tpcgeo = pgeo->TPC(tpcid);
471  unsigned int npla = tpcgeo.Nplanes();
472  assert( npla == ev.npla );
473  assert( npla > 0 );
474  for ( unsigned int ipla=0; ipla<npla; ++ipla ) {
475  assert( ires < ev.posTpc.size() );
476  PlaneID plaid(tpcid, ipla);
477  WireID wirid;
478  try { wirid = pgeo->NearestWireID(xyz, plaid); }
479  catch (geo::InvalidWireError const& e) {
480  if (!e.hasSuggestedWire()) throw;
481  cerr << "ERROR (non-fatal):\n" << e;
482  wirid = e.suggestedWireID();
483  }
484  double xwire = pgeo->WireCoordinate(x, y, plaid);
485  cout << " TPC " << setw(2) << itpc << " plane " << ipla
486  << " nearest wire is " << setw(3) << wirid.Wire
487  << " and coordinate is " << xwire << endl;
488  assert( itpc == ev.posTpc[ires] );
489  assert( ipla == ev.posPla[ires] );
490  checkfloat(xwire, ev.posWco[ires], 2.e-4);
491  ++ires;
492  } // end loop over planes
493  } // end loop over space points
494  cout << " # checked planes: " << ires << endl;
495  }
496  // Optical detectors.
497  bool dophot = true;
498  bool doAssert = true; // Flag to turn off assertions while testing the test
499  if ( dophot ) {
500  Index nopt = pgeo->NOpDets();
501  check("# Optical detectors expected", nopt, ev.nopdet, true, doAssert);
502  Index nopchaReadout = ev.nopcha;
503  Index nopchaHardware = ev.nopchaHardware ? ev.nopchaHardware : nopchaReadout;
504  cout << " Expected optical readout channel count: " << nopchaReadout << endl;
505  cout << "Expected optical hardware channel count: " << nopchaHardware << endl;
506  cout << " Geometry optical channel count: " << pgeo->NOpChannels() << endl;
507  check("# Optical channels", pgeo->NOpChannels(), nopchaHardware, true, doAssert);
508  cout << "Per-detector optical channel counts:" << endl;
509  assert( ev.nopdetcha.size() == nopt );
510  bool doAssert = true; // True enable assertions in the indvidual channel checks.
511  for ( Index iopt=0; iopt<nopt; ++iopt ) {
512  ostringstream sslab;
513  sslab << " # channels for optical detector " << iopt;
514  //bool print = iopt < maxchanprint;
515  check(sslab.str(), pgeo->NOpHardwareChannels(iopt), ev.nopdetcha[iopt], true, doAssert);
516  }
517  assert(doAssert);
518  cout << " Opdet channels:" << endl;
519  for ( Index iopt=0; iopt<nopt; ++iopt ) {
520  Index noch = pgeo->NOpHardwareChannels(iopt);
521  for ( Index ioch=0; ioch<noch; ++ioch ) {
522  ostringstream sslab;
523  sslab << " Det " << iopt << ", chan " << ioch;
524  Index icha = pgeo->OpChannel(iopt, ioch);
525  check(sslab.str() + " (channel)", icha, ev.opdetcha[iopt][ioch], true, doAssert);
526  if ( nopchaHardware == nopchaReadout ) {
527  check(sslab.str() + " (OpDet)", pgeo->OpDetFromOpChannel(icha), iopt, true, doAssert);
528  }
529  check(sslab.str() + " (HardwareChannel)", pgeo->HardwareChannelFromOpChannel(icha), ioch, true, doAssert);
530  }
531  }
532  }
533 
534  cout << myname << line << endl;
535  cout << myname << "Done." << endl;
536  return 0;
537 }
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
void GetStart(double *xyz) const
Definition: WireGeo.h:157
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const
Returns a list of ID of TPCs the specified ROP spans.
geo::Length_t CryostatHalfHeight(geo::CryostatID const &cid) const
Returns the height of the cryostat (y direction)
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
unsigned int TotalNTPC() const
Returns the total number of TPCs in the detector.
unsigned int Nplanes() const
Number of planes in this tpc.
Definition: TPCGeo.h:165
void WorldBox(double *xlo, double *xhi, double *ylo, double *yhi, double *zlo, double *zhi) const
Fills the arguments with the boundaries of the world.
static constexpr FileOnPath_t FileOnPath
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Geometry information for a single TPC.
Definition: TPCGeo.h:38
unsigned int MaxROPs() const
Returns the largest number of ROPs a TPC set in the detector has.
void setExpectedValuesSpacePoints(Geometry *)
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
const std::string GetWorldVolumeName() const
Return the name of the world volume (needed by Geant4 simulation)
unsigned int NOpHardwareChannels(int opDet) const
unsigned int NTPCsets(readout::CryostatID const &cryoid) const
Returns the total number of TPC sets in the specified cryostat.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
unsigned int Index
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
void resize(Vector< T > &vec1, Index n1, const V &val)
static void load_services(std::string const &config)
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
bool check(const std::vector< std::vector< float > > &outputs)
std::string ROOTFile() const
Returns the full directory path to the geometry file source.
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
double ThetaZ() const
Angle of the wires from positive z axis; .
Definition: PlaneGeo.cxx:726
double TotalMass() const
Returns the total mass [kg] of the specified volume (default: world).
IteratorBox< plane_id_iterator,&GeometryCore::begin_plane_id,&GeometryCore::end_plane_id > IteratePlaneIDs() const
Enables ranged-for loops on all plane IDs of the detector.
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
std::string GDMLFile() const
Returns the full directory path to the GDML file source.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
const double e
ROPID_t ROP
Index of the readout plane within its TPC set.
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
static Config * config
Definition: config.cpp:1054
raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const
Returns the ID of the first channel in the specified readout plane.
unsigned int HardwareChannelFromOpChannel(int opChannel) const
Convert unique channel to hardware channel.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
geo::Length_t SurfaceY() const
The position of the detector respect to earth surface.
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
double DefaultWiggle() const
Returns the tolerance used in looking for positions.
Class identifying a set of planes sharing readout channels.
unsigned int NOpDets() const
Number of OpDets in the whole detector.
TPCsetID_t TPCset
Index of the TPC set within its cryostat.
Definition: readout_types.h:90
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
unsigned int OpChannel(int detNum, int hardwareChannel) const
Convert detector number and hardware channel to unique channel.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
geo::Length_t CryostatHalfWidth(geo::CryostatID const &cid) const
Returns the half width of the cryostat (x direction)
IteratorBox< cryostat_id_iterator,&GeometryCore::begin_cryostat_id,&GeometryCore::end_cryostat_id > IterateCryostatIDs() const
Enables ranged-for loops on all cryostat IDs of the detector.
void line(double t, double *p, double &x, double &y, double &z)
Exception thrown on invalid wire number.
Definition: Exceptions.h:42
geo::Length_t CryostatLength(geo::CryostatID const &cid) const
Returns the length of the cryostat (z direction)
geo::WireID NearestWireID(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
list x
Definition: train.py:276
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
unsigned int NROPs(readout::TPCsetID const &tpcsetid) const
Returns the total number of ROP in the specified TPC set.
unsigned int Nviews() const
Returns the number of views (different wire orientations)
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
bool hasSuggestedWire() const
Returns whether we known a better wire number.
Definition: Exceptions.h:114
unsigned int MaxTPCs() const
Returns the largest number of TPCs a cryostat in the detector has.
QTextStream & endl(QTextStream &s)
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
WireGeo const * WirePtr(geo::WireID const &wireid) const
Returns the specified wire.

Variable Documentation

const Index InvalidIndex = std::numeric_limits<Index>::max()

Definition at line 56 of file test_GeometryDune.cxx.