test_GeometryProtoDune.cxx
Go to the documentation of this file.
1 // test_GeometryProtoDune.cxx
2 
3 // David Adams
4 // November 2016
5 //
6 // Test the protoDune geometry including channel mapping.
7 
8 #include "test_GeometryDune.cxx"
9 
10 //**********************************************************************
11 
12 // Set expected values.
13 
14 void setExpectedValues(ExpectedValues& ev) {
15  ev.gname = "protodune_geo";
16  ev.fullname = "protodunev7";
17  // Geometry counts.
18  ev.ncry = 1;
19  ev.ntpc = 12;
20  ev.npla = 3;
21  ev.napa = ev.ntpc/2;
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, ev.ncry, ev.ntpc, ev.npla, 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] = 1148;
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 "setProtoDuneSpacePoints.dat"
80  // Optical detectors.
81  // ... # detectors Modified for 2 ARAPUCAS
82  ev.nopdet = 10*ev.napa - 2 + 2*16;
83  // ... # channels in each detector
84  ev.nopdetcha.resize(ev.nopdet, 4);
85  for ( Index icha=29; icha<=60; ++icha ) ev.nopdetcha[icha] = 1;
86  // ... First channel in each detector
87  vector<Index> firstChan = {
88  144, 148, 152, 156, 160, 164, 168, 172, 176, 180,
89  240, 244, 248, 252, 256, 260, 276, 280, 284, 216,
90  220, 224, 228, 192, 232, 196, 200, 236, 204, 264,
91  264, 265, 265, 266, 266, 267, 267, 268, 269, 270,
92  271, 272, 273, 274, 275, 132, 132, 133, 133, 134,
93  134, 135, 135, 136, 137, 138, 139, 140, 141, 142,
94  143, 0, 4, 8, 12, 16, 20, 24, 28, 32,
95  36, 48, 52, 56, 60, 64, 68, 72, 76, 80,
96  84, 96, 100, 104, 108, 112, 116, 120, 124, 128
97  };
98  ev.opdetcha.resize(ev.nopdet);
99  Index ncha = 0;
100  // ... Channels in each detector
101  for ( Index iodt=0; iodt<ev.nopdet; ++iodt ) {
102  ev.opdetcha[iodt].resize(ev.nopdetcha[iodt]);
103  icha = firstChan[iodt];
104  for ( Index ioch=0; ioch<ev.nopdetcha[iodt]; ++ioch ) {
105  ev.opdetcha[iodt][ioch] = icha++;
106  ++ncha;
107  }
108  }
109  ev.nopchaHardware = ncha;
110  ev.nopcha = ncha - 8;
111 }
112 
113 //**********************************************************************
114 
116  const string myname = "setExpectedValuesSpacePoints: ";
117  string ofname = "setExpectedValuesSpacePoints.dat";
118  cout << myname << "Writing " << ofname << endl;
119  const CryostatGeo& crygeo = pgeo->Cryostat(0);
120  double origin[3] = {0.0};
121  double crypos[3] = {0.0};
122  crygeo.LocalToWorld(origin, crypos);
123  double cxlo = crypos[0] - crygeo.HalfWidth();
124  double cxhi = crypos[0] + crygeo.HalfWidth();
125  double cylo = crypos[1] - crygeo.HalfHeight();
126  double cyhi = crypos[1] + crygeo.HalfHeight();
127  double czlo = crypos[2] - 0.5*crygeo.Length();
128  double czhi = crypos[2] + 0.5*crygeo.Length();
129  cout << "Cryostat limits: "
130  << "(" << cxlo << ", " << cylo << ", " << czlo << "), "
131  << "(" << cxhi << ", " << cyhi << ", " << czhi << ")" << endl;
132  vector<double> zfs = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7 };
133  vector<double> yfs = {0.2, 0.5, 0.8};
134  vector<double> xfs = {0.2, 0.3, 0.6 };
135  ofstream fout(ofname.c_str());
136  for ( double zf : zfs ) {
137  double z = czlo + zf*(czhi-czlo);
138  for ( double yf : yfs ) {
139  double y = cylo + yf*(cyhi-cylo);
140  for ( double xf : xfs ) {
141  double x = cxlo + xf*(cxhi-cxlo);
142  double xyz[3] = {x, y, z};
143  cout << " (" << x << ", " << y << ", " << z << ")" << endl;
144  TPCID tpcid = pgeo->FindTPCAtPosition(xyz);
145  unsigned int itpc = tpcid.TPC;
146  if ( itpc == TPCID::InvalidID ) continue;
147  const TPCGeo& tpcgeo = pgeo->TPC(tpcid);
148  unsigned int npla = tpcgeo.Nplanes();
149  fout << " ev.posXyz.push_back(SpacePoint(" << x << ", " << y << ", " << z << "));" << endl;
150  for ( unsigned int ipla=0; ipla<npla; ++ipla ) {
151  PlaneID plaid(tpcid, ipla);
152  double xwire = pgeo->WireCoordinate(x, y, plaid);
153  fout << " ev.posTpc.push_back(" << itpc << ");" << endl;
154  fout << " ev.posPla.push_back(" << ipla << ");" << endl;
155  fout << " ev.posWco.push_back(" << xwire << ");" << endl;
156  } // end loop over planes
157  } // end loop over x
158  } // end loop over y
159  } // end loop over z
160 }
161 
162 //**********************************************************************
163 
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
Who knows?
Definition: geo_types.h:147
Planes which measure V.
Definition: geo_types.h:130
Unknown view.
Definition: geo_types.h:136
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
Planes which measure Z direction.
Definition: geo_types.h:132
unsigned int Index
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
void resize(Vector< T > &vec1, Index n1, const V &val)
void setExpectedValuesSpacePoints(Geometry *pgeo)
void setExpectedValues(ExpectedValues &ev)
const Index InvalidIndex
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
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
double HalfWidth() const
Half width of the cryostat [cm].
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
The geometry of one entire detector, as served by art.
Definition: Geometry.h:196
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
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
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)
Signal from collection planes.
Definition: geo_types.h:146