LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MicroBooNEDrawer_tool.cc
Go to the documentation of this file.
1 
9 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h"
10 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h"
12 
15 
16 #include "TPolyLine3D.h"
17 
18 namespace evd_tool {
19 
21  public:
22  explicit MicroBooNEDrawer(const fhicl::ParameterSet& pset);
23 
24  void DetOutline3D(evdb::View3D* view) override;
25 
27 
28  private:
29  void configure(const fhicl::ParameterSet& pset);
31  double* coordsLo,
32  double* coordsHi,
33  int color = kGray,
34  int width = 1,
35  int style = 1);
36  void DrawGrids(evdb::View3D* view,
37  double* coordsLo,
38  double* coordsHi,
39  int color = kGray,
40  int width = 1,
41  int style = 1);
42  void DrawAxes(evdb::View3D* view,
43  double* coordsLo,
44  double* coordsHi,
45  int color = kGray,
46  int width = 1,
47  int style = 1);
48  void DrawBadChannels(evdb::View3D* view, double* coords, int color, int width, int style);
49 
50  // Member variables from the fhicl file
51  bool fThreeWindow;
52  bool fDrawGrid;
53  bool fDrawAxes;
55  };
56 
57  //----------------------------------------------------------------------
58  // Constructor.
60  {
61  configure(pset);
62  }
63 
65  {
66  // Start by recovering the parameters
67  fThreeWindow = pset.get<bool>("DrawThreeWindow", true);
68  fDrawGrid = pset.get<bool>("DrawGrid", true);
69  fDrawAxes = pset.get<bool>("DrawAxes", true);
70  fDrawBadChannels = pset.get<bool>("DrawBadChannels", true);
71 
72  return;
73  }
74 
75  //......................................................................
77  {
79 
80  // If requested, draw the outer three window volume first
81  if (fThreeWindow) {
82  double threeWinCoordsLo[] = {-2. * geo->DetHalfWidth(), -geo->DetHalfHeight(), 0.};
83  double threeWinCoordsHi[] = {
84  4. * geo->DetHalfWidth(), geo->DetHalfHeight(), geo->DetLength()};
85 
86  DrawRectangularBox(view, threeWinCoordsLo, threeWinCoordsHi, kGray);
87  }
88 
89  // Now draw the standard volume
90  double coordsLo[] = {0., -geo->DetHalfHeight(), 0.};
91  double coordsHi[] = {2. * geo->DetHalfWidth(), geo->DetHalfHeight(), geo->DetLength()};
92 
93  DrawRectangularBox(view, coordsLo, coordsHi, kRed, 2, 1);
94 
95  // It could be that we don't want to see the grids
96  if (fDrawGrid) DrawGrids(view, coordsLo, coordsHi, kGray + 2, 1, 1);
97 
98  if (fDrawAxes) DrawAxes(view, coordsLo, coordsHi, kBlue, 1, 1);
99 
100  if (fDrawBadChannels) DrawBadChannels(view, coordsHi, kGray, 1, 1);
101 
102  return;
103  }
104 
106  double* coordsLo,
107  double* coordsHi,
108  int color,
109  int width,
110  int style)
111  {
112  TPolyLine3D& top = view->AddPolyLine3D(5, color, width, style);
113  top.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
114  top.SetPoint(1, coordsHi[0], coordsHi[1], coordsLo[2]);
115  top.SetPoint(2, coordsHi[0], coordsHi[1], coordsHi[2]);
116  top.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
117  top.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
118 
119  TPolyLine3D& side = view->AddPolyLine3D(5, color, width, style);
120  side.SetPoint(0, coordsHi[0], coordsHi[1], coordsLo[2]);
121  side.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
122  side.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
123  side.SetPoint(3, coordsHi[0], coordsHi[1], coordsHi[2]);
124  side.SetPoint(4, coordsHi[0], coordsHi[1], coordsLo[2]);
125 
126  TPolyLine3D& side2 = view->AddPolyLine3D(5, color, width, style);
127  side2.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
128  side2.SetPoint(1, coordsLo[0], coordsLo[1], coordsLo[2]);
129  side2.SetPoint(2, coordsLo[0], coordsLo[1], coordsHi[2]);
130  side2.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
131  side2.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
132 
133  TPolyLine3D& bottom = view->AddPolyLine3D(5, color, width, style);
134  bottom.SetPoint(0, coordsLo[0], coordsLo[1], coordsLo[2]);
135  bottom.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
136  bottom.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
137  bottom.SetPoint(3, coordsLo[0], coordsLo[1], coordsHi[2]);
138  bottom.SetPoint(4, coordsLo[0], coordsLo[1], coordsLo[2]);
139 
140  return;
141  }
142 
144  double* coordsLo,
145  double* coordsHi,
146  int color,
147  int width,
148  int style)
149  {
150  double z = coordsLo[2];
151  // Grid running along x and y at constant z
152  for (;;) {
153  TPolyLine3D& gridt = view->AddPolyLine3D(2, color, style, width);
154  gridt.SetPoint(0, coordsLo[0], coordsLo[1], z);
155  gridt.SetPoint(1, coordsHi[0], coordsLo[1], z);
156 
157  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
158  grids.SetPoint(0, coordsHi[0], coordsLo[1], z);
159  grids.SetPoint(1, coordsHi[0], coordsHi[1], z);
160 
161  z += 10.0;
162  if (z > coordsHi[2]) break;
163  }
164 
165  // Grid running along z at constant x
166  double x = 0.0;
167  for (;;) {
168  TPolyLine3D& gridt = view->AddPolyLine3D(2, color, style, width);
169  gridt.SetPoint(0, x, coordsLo[1], coordsLo[2]);
170  gridt.SetPoint(1, x, coordsLo[1], coordsHi[2]);
171  x += 10.0;
172  if (x > coordsHi[0]) break;
173  }
174 
175  // Grid running along z at constant y
176  double y = 0.0;
177  for (;;) {
178  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
179  grids.SetPoint(0, coordsHi[0], y, coordsLo[2]);
180  grids.SetPoint(1, coordsHi[0], y, coordsHi[2]);
181  y += 10.0;
182  if (y > coordsHi[1]) break;
183  }
184  y = -10.0;
185  for (;;) {
186  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
187  grids.SetPoint(0, coordsHi[0], y, coordsLo[2]);
188  grids.SetPoint(1, coordsHi[0], y, coordsHi[2]);
189  y -= 10.0;
190  if (y < coordsLo[1]) break;
191  }
192 
193  return;
194  }
195 
197  double* coordsLo,
198  double* coordsHi,
199  int color,
200  int width,
201  int style)
202  {
203 
204  // Indicate coordinate system
205  double x0 = -0.20; // Center location of the key
206  double y0 = 1.10 * coordsLo[1]; // Center location of the key
207  double z0 = -0.10 * coordsHi[2]; // Center location of the key
208  double sz = 0.20 * coordsHi[2]; // Scale size of the key in z direction
209 
210  TPolyLine3D& xaxis = view->AddPolyLine3D(2, color, style, width);
211  TPolyLine3D& yaxis = view->AddPolyLine3D(2, color, style, width);
212  TPolyLine3D& zaxis = view->AddPolyLine3D(2, color, style, width);
213  xaxis.SetPoint(0, x0, y0, z0);
214  xaxis.SetPoint(1, sz + x0, y0, z0);
215 
216  yaxis.SetPoint(0, x0, y0, z0);
217  yaxis.SetPoint(1, x0, y0 + sz, z0);
218 
219  zaxis.SetPoint(0, x0, y0, z0);
220  zaxis.SetPoint(1, x0, y0, z0 + sz);
221 
222  TPolyLine3D& xpoint = view->AddPolyLine3D(3, color, style, width);
223  TPolyLine3D& ypoint = view->AddPolyLine3D(3, color, style, width);
224  TPolyLine3D& zpoint = view->AddPolyLine3D(3, color, style, width);
225 
226  xpoint.SetPoint(0, 0.95 * sz + x0, y0, z0 - 0.05 * sz);
227  xpoint.SetPoint(1, 1.00 * sz + x0, y0, z0);
228  xpoint.SetPoint(2, 0.95 * sz + x0, y0, z0 + 0.05 * sz);
229 
230  ypoint.SetPoint(0, x0, 0.95 * sz + y0, z0 - 0.05 * sz);
231  ypoint.SetPoint(1, x0, 1.00 * sz + y0, z0);
232  ypoint.SetPoint(2, x0, 0.95 * sz + y0, z0 + 0.05 * sz);
233 
234  zpoint.SetPoint(0, x0 - 0.05 * sz, y0, 0.95 * sz + z0);
235  zpoint.SetPoint(1, x0 + 0.00 * sz, y0, 1.00 * sz + z0);
236  zpoint.SetPoint(2, x0 + 0.05 * sz, y0, 0.95 * sz + z0);
237 
238  TPolyLine3D& zleg = view->AddPolyLine3D(4, color, style, width);
239  zleg.SetPoint(0, x0 - 0.05 * sz, y0 + 0.05 * sz, z0 + 1.05 * sz);
240  zleg.SetPoint(1, x0 + 0.05 * sz, y0 + 0.05 * sz, z0 + 1.05 * sz);
241  zleg.SetPoint(2, x0 - 0.05 * sz, y0 - 0.05 * sz, z0 + 1.05 * sz);
242  zleg.SetPoint(3, x0 + 0.05 * sz, y0 - 0.05 * sz, z0 + 1.05 * sz);
243 
244  TPolyLine3D& yleg = view->AddPolyLine3D(5, color, style, width);
245  yleg.SetPoint(0, x0 - 0.05 * sz, y0 + 1.15 * sz, z0);
246  yleg.SetPoint(1, x0 + 0.00 * sz, y0 + 1.10 * sz, z0);
247  yleg.SetPoint(2, x0 + 0.00 * sz, y0 + 1.05 * sz, z0);
248  yleg.SetPoint(3, x0 + 0.00 * sz, y0 + 1.10 * sz, z0);
249  yleg.SetPoint(4, x0 + 0.05 * sz, y0 + 1.15 * sz, z0);
250 
251  TPolyLine3D& xleg = view->AddPolyLine3D(7, color, style, width);
252  xleg.SetPoint(0, x0 + 1.05 * sz, y0 + 0.05 * sz, z0 - 0.05 * sz);
253  xleg.SetPoint(1, x0 + 1.05 * sz, y0 + 0.00 * sz, z0 - 0.00 * sz);
254  xleg.SetPoint(2, x0 + 1.05 * sz, y0 + 0.05 * sz, z0 + 0.05 * sz);
255  xleg.SetPoint(3, x0 + 1.05 * sz, y0 + 0.00 * sz, z0 - 0.00 * sz);
256  xleg.SetPoint(4, x0 + 1.05 * sz, y0 - 0.05 * sz, z0 - 0.05 * sz);
257  xleg.SetPoint(5, x0 + 1.05 * sz, y0 + 0.00 * sz, z0 - 0.00 * sz);
258  xleg.SetPoint(6, x0 + 1.05 * sz, y0 - 0.05 * sz, z0 + 0.05 * sz);
259 
260  return;
261  }
262 
264  double* coords,
265  int color,
266  int width,
267  int style)
268  {
271 
272  lariov::ChannelStatusProvider const& channelStatus =
274 
275  // We want to translate the wire position to the opposite side of the TPC...
276  for (size_t viewNo = 0; viewNo < geo->Nviews(); viewNo++) {
277  geo::PlaneID const planeID(rawOpt->fCryostat, rawOpt->fTPC, viewNo);
278  for (size_t wireNo = 0; wireNo < geo->Nwires(planeID); wireNo++) {
279  geo::WireID wireID = geo::WireID(planeID, wireNo);
280 
281  raw::ChannelID_t channel = geo->PlaneWireToChannel(wireID);
282 
283  if (channelStatus.IsBad(channel)) {
284  const geo::WireGeo* wireGeo = geo->WirePtr(wireID);
285 
286  auto const wireStart = wireGeo->GetStart();
287  auto const wireEnd = wireGeo->GetEnd();
288 
289  TPolyLine3D& pl = view->AddPolyLine3D(2, color, style, width);
290  pl.SetPoint(0, coords[0] - 0.5, wireStart.Y(), wireStart.Z());
291  pl.SetPoint(1, coords[0] - 0.5, wireEnd.Y(), wireEnd.Z());
292  }
293  }
294  }
295 
296  return;
297  }
298 
300 }
Float_t x
Definition: compare.C:6
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:114
bool fDrawAxes
true to draw coordinate axes
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
void DrawGrids(evdb::View3D *view, double *coordsLo, double *coordsHi, int color=kGray, int width=1, int style=1)
unsigned int fTPC
TPC number to draw, typically set by TWQProjectionView.
bool fDrawBadChannels
true to draw bad channels
Float_t y
Definition: compare.C:6
Length_t DetHalfWidth(TPCID const &tpcid=tpc_zero) const
Returns the half width of the active volume of the specified TPC.
Double_t z
Definition: plot.C:276
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
void DrawAxes(evdb::View3D *view, double *coordsLo, double *coordsHi, int color=kGray, int width=1, int style=1)
Point_t GetStart() const
Returns the world coordinate of one end of the wire [cm].
Definition: WireGeo.h:226
Point_t GetEnd() const
Returns the world coordinate of one end of the wire [cm].
Definition: WireGeo.h:231
TGaxis * xaxis
Definition: plot_hist.C:61
Length_t DetLength(TPCID const &tpcid=tpc_zero) const
Returns the length of the active volume of the specified TPC.
TPolyLine3D & AddPolyLine3D(int n, int c, int w, int s)
Definition: View3D.cxx:105
void DetOutline3D(evdb::View3D *view) override
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
unsigned int fCryostat
Cryostat number to draw, typically set by TWQProjectionView.
MicroBooNEDrawer(const fhicl::ParameterSet &pset)
T get(std::string const &key) const
Definition: ParameterSet.h:314
bool fThreeWindow
true to draw rectangular box representing 3 windows
void configure(const fhicl::ParameterSet &pset)
void DrawBadChannels(evdb::View3D *view, double *coords, int color, int width, int style)
std::size_t color(std::string const &procname)
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
void DrawRectangularBox(evdb::View3D *view, double *coordsLo, double *coordsHi, int color=kGray, int width=1, int style=1)
unsigned int Nwires(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
Length_t DetHalfHeight(TPCID const &tpcid=tpc_zero) const
Returns the half height of the active volume of the specified TPC.
A collection of 3D drawable objects.
unsigned int Nviews() const
Returns the number of views (different wire orientations)
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
bool fDrawGrid
true to draw backing grid
WireGeo const * WirePtr(WireID const &wireid) const
Returns the specified wire.
This is the interface class for drawing 3D detector geometries.
Namespace collecting geometry-related classes utilities.
art framework interface to geometry description