3 #ifndef test_WireSelector_CXX 4 #define test_WireSelector_CXX 30 #include "../WireSelector.h" 42 using std::istringstream;
43 using std::ostringstream;
65 <<
setw(
w) << std::fixed << xyz.x()
67 <<
setw(
w) << std::fixed << xyz.y()
69 <<
setw(
w) << std::fixed << xyz.z()
78 <<
setw(
w) << std::fixed << dat.
x 80 <<
setw(
w) << std::fixed << dat.
y 82 <<
setw(
w) << std::fixed << dat.
z 96 int test_WireSelector(
string gname,
double wireAngle,
double minDrift,
unsigned int nShow,
int sigopt) {
97 const string myname =
"test_WireSelector: ";
98 cout << myname <<
"Starting test" <<
endl;
100 cout << myname <<
"NDEBUG must be off." <<
endl;
103 string line =
"-----------------------------";
105 cout << myname << line <<
endl;
106 cout << myname <<
" Geometry: " << gname <<
endl;
109 if ( wireAngle == 100 ) view =
geo::kU;
110 if ( wireAngle == 101 ) view =
geo::kV;
111 if ( wireAngle == 102 ) view =
geo::kZ;
112 bool useView = wireAngle >= 100;
114 cout << myname << line <<
endl;
115 cout << myname <<
"Create configuration." <<
endl;
116 bool useExistingFcl =
false;
117 if (useExistingFcl) {
123 config <<
"#include \"geometry_dune.fcl\"" <<
endl;
124 config <<
"services.Geometry: @local::" + gname <<
endl;
125 config <<
"services.ExptGeoHelperInterface: @local::dune_geometry_helper" <<
endl;
131 cout << myname << line <<
endl;
132 cout << myname <<
"Input arguments:" <<
endl;
133 cout << myname <<
" gname: " << gname <<
endl;
134 cout << myname <<
" wireAngle: " << wireAngle <<
endl;
135 cout << myname <<
" minDrift: " << minDrift <<
endl;
136 cout << myname <<
" nShow: " << nShow <<
endl;
137 cout << myname <<
" sigopt: " << sigopt <<
endl;
139 cout << myname << line <<
endl;
140 cout << myname <<
"Construct selector." <<
endl;
144 cout << myname <<
" Selecting view " << view <<
endl;
148 cout << myname <<
" Selecting wire angle " << wireAngle <<
endl;
151 if ( minDrift > 0.0 ) {
152 cout << myname <<
" Selecting min drift " << minDrift <<
" cm" <<
endl;
157 cout << myname << line <<
endl;
158 cout << myname <<
"Selector properties:" <<
endl;
160 cout << myname <<
" View: " << ws.
view() <<
endl;
163 cout << myname <<
" Drift min: " << ws.
driftMin() <<
endl;
164 cout << myname <<
" # planes: " << ws.
planeIDs().size() <<
endl;
166 cout << myname << line <<
endl;
167 cout << myname <<
"Geometry properties:" <<
endl;
169 cout << myname <<
" # channels: " << ncha <<
endl;
170 const double piOver2 = 0.5*acos(-1.0);
174 double thtx = gpla.
ThetaZ() - piOver2;
178 cout << myname <<
pid 179 <<
" view=" << gpla.
View()
182 <<
" drift distance =" << driftSize <<
" cm" 186 cout << myname <<
" Wire direction: " <<
toString(wdir) <<
endl;
187 cout << myname <<
" Normal direction: " <<
toString(ndir) <<
endl;
192 bool usePlane = useView ? gpla.
View() == view : fabs(thtx - wireAngle)<0.001;
193 if ( ! usePlane )
continue;
195 for (
Index iwir=0; iwir<=nwir; ++iwir ) {
196 bool showWire = iwir < nShow;
197 bool endPlane = iwir == nwir;
198 bool endBlock = endPlane;
203 TVector3 xyzWire = pgwir->
GetCenter<TVector3>();
204 TVector3 xyz1 = pgwir->
GetStart<TVector3>();
205 TVector3 xyz2 = pgwir->
GetEnd<TVector3>();
207 wout << myname <<
setw(12) << iwir <<
" [" <<
setw(4) << icha <<
"] " <<
toString(xyzWire);
208 xyzWire.RotateX(thtx);
209 wout <<
" --> " <<
toString(xyzWire) <<
"\n";
212 wout <<
" --> " <<
toString(xyz1) <<
"\n";
215 wout <<
" --> " <<
toString(xyz2) <<
"\n";
216 assert( icha < ncha );
217 if ( icha1 == ncha ) {
220 wireText = showWire ? wout.str() :
"";
221 }
else if ( icha == icha2 + 1 ) {
223 if ( showWire ) wireText += wout.str();
229 cout << myname <<
" [" << icha1 <<
", " << icha2 <<
"]" <<
endl;
238 wireText = showWire ? wout.str() :
"";
241 assert( icha1 == ncha );
242 assert( icha2 == ncha );
246 cout << myname << line <<
endl;
247 cout << myname <<
"Check geometry: " << gname <<
endl;
250 cout << myname << line <<
endl;
251 cout << myname <<
"Check data" <<
endl;
254 cout << myname <<
" Expected wire count: " << nwirSel <<
endl;
255 cout << myname <<
" Reported wire count: " << ws.
data().size() <<
endl;
256 cout << myname <<
" Mapped wire count: " << ws.
dataMap().size() <<
endl;
258 assert( ws.
data().size() == nwirSel );
259 assert( ws.
dataMap().size() == nwirSel );
260 assert( wsum.
size() == nwirSel );
263 cout << myname << line <<
endl;
264 cout << myname <<
"Build ADC data." <<
endl;
265 vector<vector<float>> adcdata(ncha);
267 cout << myname <<
" Strumming selected wires." <<
endl;
269 float dx = (wsum.
xmax-wsum.
xmin)/nwir;
270 float xval = wsum.
xmin + 0.5*dx;
271 for (
Index iwir=0; iwir<nwir; ++iwir ) {
273 adcdata[dat.
channel].push_back(xval);
276 }
else if ( sigopt == 1 ) {
277 cout << myname <<
" Strumming channels." <<
endl;
278 float dx = (wsum.
xmax-wsum.
xmin)/ncha;
279 float xval = wsum.
xmin + 0.5*dx;
280 for (
Index icha=0; icha<ncha; ++icha ) {
281 adcdata[icha].push_back(xval);
287 cout << myname << line <<
endl;
288 cout << myname <<
"Build signal data." <<
endl;
291 for (
Index icha=0; icha<ncha; ++icha ) {
293 auto range = ws.
dataMap().equal_range(icha);
294 for (
auto ient=range.first; ient!=range.second; ++ient ) {
296 float zsig = pdat->
z;
298 for (
float xsig : adcdata[icha] ) {
300 xsigs.push_back(xsig);
301 zsigs.push_back(zsig);
306 TGraph gsigxz(nsig, &zsigs[0], &xsigs[0]);
307 TGraph gsigzx(nsig, &xsigs[0], &zsigs[0]);
308 cout << myname <<
" # signals: " << nsig <<
endl;
309 Index nShowSig = nShow < nsig ? nShow : nsig;
310 for (
Index isig=0; isig<nShowSig; ++isig ) {
313 sout << myname <<
setw(10) << std::fixed << xsigs[isig] <<
"," <<
setw(9) << std::fixed << zsigs[isig];
314 cout << sout.str() <<
endl;
317 bool drawWires =
true;
319 double ticklen = 0.015;
324 double xpmin = wsum.
xmin;
325 double xpmax = wsum.
xmin;
326 if ( gname ==
"protodune_geo" ) {
331 ssttl << gname <<
" ";
333 ssttl <<
"view=" << view;
337 if ( minDrift > 0.0 ) {
338 ssttl <<
", TPCs with drift > " <<
std::setprecision(0) << std::fixed << minDrift <<
" cm";
340 string sttlxz = ssttl.str() +
"; z [cm]; x [cm]";
341 string sttlzx = ssttl.str() +
"; x [cm]; z [cm]";
342 TH2* phaxz =
new TH2F(
"phaxz", sttlxz.c_str(), 1, wsum.
zmin-
b, wsum.
zmax+
b, 1, xpmin, xpmax);
343 TH2* phazx =
new TH2F(
"phazx", sttlzx.c_str(), 1, xpmin, xpmax, 1, wsum.
zmin-
b, wsum.
zmax+
b);
348 gxz.SetMarkerColor(lc.
red());
349 gzx.SetMarkerColor(lc.
red());
352 gxzd.SetMarkerColor(lc.
green());
353 gzxd.SetMarkerColor(lc.
green());
356 padxz.
add(&gxz,
"P");
357 padxz.
add(&gxzd,
"P");
358 if ( sigopt ) padxz.
add(&gsigxz,
"P");
361 padxz.
print(
"test_WireSelector_xz.png");
364 padzx.
add(&gzx,
"P");
365 padzx.
add(&gzxd,
"P");
366 if ( sigopt ) padzx.
add(&gsigzx,
"P");
369 padzx.
print(
"test_WireSelector_zx.png");
372 cout << myname << line <<
endl;
373 cout << myname <<
"Done." <<
endl;
380 string gname =
"protodune_geo";
382 double minDrift = 0.0;
383 unsigned int nShow = 0;
386 string sarg = argv[1];
387 if ( sarg ==
"-h" ) {
388 cout <<
"Usage: " << argv[0] <<
" [gname] [thtx] [minDrift] [nShow] [sigopt]" <<
endl;
389 cout <<
" gname: Geometry name, e.g. protodune_geo" <<
endl;
390 cout <<
" thtx: Wire angle, e.g. 0 for vertical" <<
endl;
391 cout <<
" >= 100 means use view thtx-100, e.g. 2 for kZ" <<
endl;
392 cout <<
" minDrift: select TPC with drift > midDrift cm" <<
endl;
393 cout <<
" nShow: # wires, signals to print" <<
endl;
394 cout <<
" sigopt: Option to add signals to the displays" <<
endl;
395 cout <<
" 0 for no signal" <<
endl;
396 cout <<
" 1 for strum of detector channels" <<
endl;
397 cout <<
" 2 for strum of selected wires" <<
endl;
402 istringstream ssarg(argv[2]);
405 istringstream ssarg(argv[3]);
408 istringstream ssarg(argv[4]);
411 istringstream ssarg(argv[5]);
419 cout <<
"Tests concluded." <<
endl;
void GetStart(double *xyz) const
double wireAngleTolerance() const
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
const WireInfoMap & dataMap() const
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
int add(unsigned int ipad, TObject *pobj, std::string sopt="", bool replace=false)
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::vector< float > xWire
const PlaneIDVector & planeIDs() const
static constexpr FileOnPath_t FileOnPath
The data type to uniquely identify a Plane.
Geometry information for a single TPC.
const WireInfoVector & data() const
Class identifying a set of TPC sharing readout channels.
Planes which measure Z direction.
Geometry information for a single cryostat.
Vector GetNormalDirection() const
Returns the direction normal to the plane.
const GeometryCore * geometry() const
static void load_services(std::string const &config)
Q_EXPORT QTSManip setprecision(int p)
art framework interface to geometry description
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; .
void selectView(View view)
void selectWireAngle(double wireAngle, double tol=0.001)
View_t View() const
Which coordinate does this plane measure.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
enum geo::_plane_sigtype SigType_t
int test_WireSelector(string gname, double wireAngle, double minDrift, unsigned int nShow, int sigopt)
int setTickLength(double len)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
void selectDrift(double dmin, double dmax=1.e20)
int addAxis(bool flag=true)
std::vector< float > zWire
The geometry of one entire detector, as served by art.
string toString(const TVector3 &xyz, int w=9)
Q_EXPORT QTSManip setw(int w)
const WireSummary & fillWireSummary()
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
int main(int argc, const char *argv[])
const WireInfoVector & fillData()
std::vector< float > xCathode
void GetEnd(double *xyz) const
double ActiveWidth() const
Width (associated with x coordinate) of active TPC volume [cm].
void line(double t, double *p, double &x, double &y, double &z)
unsigned int Nwires() const
Number of wires in this plane.
detail::Node< FrameID, bool > PlaneID
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
const WireInfoMap & fillDataMap()
int print(std::string fname, std::string spat="{,}")
QTextStream & endl(QTextStream &s)
Vector GetWireDirection() const
Returns the direction of the wires.
WireGeo const * WirePtr(geo::WireID const &wireid) const
Returns the specified wire.