LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ICARUSDrawer_tool.cc
Go to the documentation of this file.
1 
8 
12 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h"
13 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h"
15 
16 #include "TPolyLine3D.h"
17 
18 namespace evd_tool {
19 
21  public:
22  explicit ICARUSDrawer(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  bool verticalGrid,
40  int color = kGray,
41  int width = 1,
42  int style = 1);
43  void DrawAxes(evdb::View3D* view,
44  double* coordsLo,
45  double* coordsHi,
46  int color = kGray,
47  int width = 1,
48  int style = 1);
49  void DrawBadChannels(evdb::View3D* view, double* coords, int color, int width, int style);
50 
51  // Member variables from the fhicl file
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  fDrawGrid = pset.get<bool>("DrawGrid", true);
68  fDrawAxes = pset.get<bool>("DrawAxes", true);
69  fDrawBadChannels = pset.get<bool>("DrawBadChannels", true);
70 
71  return;
72  }
73 
74  //......................................................................
76  {
78 
79  bool axesNotDrawn(true);
80 
81  double xl, xu, yl, yu, zl, zu;
82 
83  geo->WorldBox(&xl, &xu, &yl, &yu, &zl, &zu);
84 
85  std::cout << "--- building ICARUS 3D display, low coord: " << xl << ", " << yl << ", " << zl
86  << ", hi coord: " << xu << ", " << yu << ", " << zu << std::endl;
87 
88  // Loop over the number of cryostats
89  for (auto const& cryoGeo : geo->Iterate<geo::CryostatGeo>()) {
90  double cryoCoordsLo[] = {cryoGeo.MinX(), cryoGeo.MinY(), cryoGeo.MinZ()};
91  double cryoCoordsHi[] = {cryoGeo.MaxX(), cryoGeo.MaxY(), cryoGeo.MaxZ()};
92 
93  std::cout << " - cryostat: " << cryoGeo.ID() << ", low coord: " << cryoCoordsLo[0] << ", "
94  << cryoCoordsLo[1] << ", " << cryoCoordsLo[2] << ", hi coord: " << cryoCoordsHi[0]
95  << ", " << cryoCoordsHi[1] << ", " << cryoCoordsHi[2] << std::endl;
96 
97  DrawRectangularBox(view, cryoCoordsLo, cryoCoordsHi, kWhite, 2, 1);
98 
99  if (fDrawAxes && axesNotDrawn) {
100  DrawAxes(view, cryoCoordsLo, cryoCoordsHi, kBlue, 1, 1);
101  axesNotDrawn = true;
102  }
103 
104  // Now draw the TPC's associated to this cryostat
105  for (size_t tpcIdx = 0; tpcIdx < cryoGeo.NTPC(); tpcIdx++) {
106  const geo::TPCGeo& tpcGeo = cryoGeo.TPC(tpcIdx);
107 
108  // Find the center of the current TPC
109  auto const tpcCenter = tpcGeo.GetCenter();
110 
111  // Now draw the standard volume
112  double coordsLo[] = {tpcCenter.X() - tpcGeo.HalfWidth(),
113  tpcCenter.Y() - tpcGeo.HalfHeight(),
114  tpcCenter.Z() - 0.5 * tpcGeo.Length()};
115  double coordsHi[] = {tpcCenter.X() + tpcGeo.HalfWidth(),
116  tpcCenter.Y() + tpcGeo.HalfHeight(),
117  tpcCenter.Z() + 0.5 * tpcGeo.Length()};
118 
119  std::cout << " - TPC: " << tpcGeo.ID() << ", low coord: " << coordsLo[0] << ", "
120  << coordsLo[1] << ", " << coordsLo[2] << ", hi coord: " << coordsHi[0] << ", "
121  << coordsHi[1] << ", " << coordsHi[2] << std::endl;
122 
123  DrawRectangularBox(view, coordsLo, coordsHi, kRed, 2, 1);
124 
125  // It could be that we don't want to see the grids
126  if (fDrawGrid) DrawGrids(view, coordsLo, coordsHi, tpcIdx > 0, kGray + 2, 1, 1);
127 
128  if (fDrawBadChannels) DrawBadChannels(view, coordsHi, kGray, 1, 1);
129  }
130  }
131 
132  return;
133  }
134 
136  double* coordsLo,
137  double* coordsHi,
138  int color,
139  int width,
140  int style)
141  {
142  TPolyLine3D& top = view->AddPolyLine3D(5, color, width, style);
143  top.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
144  top.SetPoint(1, coordsHi[0], coordsHi[1], coordsLo[2]);
145  top.SetPoint(2, coordsHi[0], coordsHi[1], coordsHi[2]);
146  top.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
147  top.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
148 
149  TPolyLine3D& side = view->AddPolyLine3D(5, color, width, style);
150  side.SetPoint(0, coordsHi[0], coordsHi[1], coordsLo[2]);
151  side.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
152  side.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
153  side.SetPoint(3, coordsHi[0], coordsHi[1], coordsHi[2]);
154  side.SetPoint(4, coordsHi[0], coordsHi[1], coordsLo[2]);
155 
156  TPolyLine3D& side2 = view->AddPolyLine3D(5, color, width, style);
157  side2.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
158  side2.SetPoint(1, coordsLo[0], coordsLo[1], coordsLo[2]);
159  side2.SetPoint(2, coordsLo[0], coordsLo[1], coordsHi[2]);
160  side2.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
161  side2.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
162 
163  TPolyLine3D& bottom = view->AddPolyLine3D(5, color, width, style);
164  bottom.SetPoint(0, coordsLo[0], coordsLo[1], coordsLo[2]);
165  bottom.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
166  bottom.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
167  bottom.SetPoint(3, coordsLo[0], coordsLo[1], coordsHi[2]);
168  bottom.SetPoint(4, coordsLo[0], coordsLo[1], coordsLo[2]);
169 
170  return;
171  }
172 
174  double* coordsLo,
175  double* coordsHi,
176  bool verticalGrid,
177  int color,
178  int width,
179  int style)
180  {
181  double z = coordsLo[2];
182  // Grid running along x and y at constant z
183  while (1) {
184  TPolyLine3D& gridt = view->AddPolyLine3D(2, color, style, width);
185  gridt.SetPoint(0, coordsLo[0], coordsLo[1], z);
186  gridt.SetPoint(1, coordsHi[0], coordsLo[1], z);
187 
188  if (verticalGrid) {
189  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
190  grids.SetPoint(0, coordsHi[0], coordsLo[1], z);
191  grids.SetPoint(1, coordsHi[0], coordsHi[1], z);
192  }
193 
194  z += 10.0;
195  if (z > coordsHi[2]) break;
196  }
197 
198  // Grid running along z at constant x
199  double x = coordsLo[0];
200  while (1) {
201  TPolyLine3D& gridt = view->AddPolyLine3D(2, color, style, width);
202  gridt.SetPoint(0, x, coordsLo[1], coordsLo[2]);
203  gridt.SetPoint(1, x, coordsLo[1], coordsHi[2]);
204  x += 10.0;
205  if (x > coordsHi[0]) break;
206  }
207 
208  // Grid running along z at constant y
209  if (verticalGrid) {
210  double y = coordsLo[1];
211  while (1) {
212  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
213  grids.SetPoint(0, coordsHi[0], y, coordsLo[2]);
214  grids.SetPoint(1, coordsHi[0], y, coordsHi[2]);
215  y += 10.0;
216  if (y > coordsHi[1]) break;
217  }
218  }
219 
220  return;
221  }
222 
224  double* coordsLo,
225  double* coordsHi,
226  int color,
227  int width,
228  int style)
229  {
230 
231  // Indicate coordinate system
232  double x0 = -0.20; // Center location of the key
233  double y0 = 1.10 * coordsLo[1]; // Center location of the key
234  double z0 = -0.10 * coordsHi[2]; // Center location of the key
235  double sz = 0.20 * coordsHi[2]; // Scale size of the key in z direction
236 
237  TPolyLine3D& xaxis = view->AddPolyLine3D(2, color, style, width);
238  TPolyLine3D& yaxis = view->AddPolyLine3D(2, color, style, width);
239  TPolyLine3D& zaxis = view->AddPolyLine3D(2, color, style, width);
240  xaxis.SetPoint(0, x0, y0, z0);
241  xaxis.SetPoint(1, sz + x0, y0, z0);
242 
243  yaxis.SetPoint(0, x0, y0, z0);
244  yaxis.SetPoint(1, x0, y0 + sz, z0);
245 
246  zaxis.SetPoint(0, x0, y0, z0);
247  zaxis.SetPoint(1, x0, y0, z0 + sz);
248 
249  TPolyLine3D& xpoint = view->AddPolyLine3D(3, color, style, width);
250  TPolyLine3D& ypoint = view->AddPolyLine3D(3, color, style, width);
251  TPolyLine3D& zpoint = view->AddPolyLine3D(3, color, style, width);
252 
253  xpoint.SetPoint(0, 0.95 * sz + x0, y0, z0 - 0.05 * sz);
254  xpoint.SetPoint(1, 1.00 * sz + x0, y0, z0);
255  xpoint.SetPoint(2, 0.95 * sz + x0, y0, z0 + 0.05 * sz);
256 
257  ypoint.SetPoint(0, x0, 0.95 * sz + y0, z0 - 0.05 * sz);
258  ypoint.SetPoint(1, x0, 1.00 * sz + y0, z0);
259  ypoint.SetPoint(2, x0, 0.95 * sz + y0, z0 + 0.05 * sz);
260 
261  zpoint.SetPoint(0, x0 - 0.05 * sz, y0, 0.95 * sz + z0);
262  zpoint.SetPoint(1, x0 + 0.00 * sz, y0, 1.00 * sz + z0);
263  zpoint.SetPoint(2, x0 + 0.05 * sz, y0, 0.95 * sz + z0);
264 
265  TPolyLine3D& zleg = view->AddPolyLine3D(4, color, style, width);
266  zleg.SetPoint(0, x0 - 0.05 * sz, y0 + 0.05 * sz, z0 + 1.05 * sz);
267  zleg.SetPoint(1, x0 + 0.05 * sz, y0 + 0.05 * sz, z0 + 1.05 * sz);
268  zleg.SetPoint(2, x0 - 0.05 * sz, y0 - 0.05 * sz, z0 + 1.05 * sz);
269  zleg.SetPoint(3, x0 + 0.05 * sz, y0 - 0.05 * sz, z0 + 1.05 * sz);
270 
271  TPolyLine3D& yleg = view->AddPolyLine3D(5, color, style, width);
272  yleg.SetPoint(0, x0 - 0.05 * sz, y0 + 1.15 * sz, z0);
273  yleg.SetPoint(1, x0 + 0.00 * sz, y0 + 1.10 * sz, z0);
274  yleg.SetPoint(2, x0 + 0.00 * sz, y0 + 1.05 * sz, z0);
275  yleg.SetPoint(3, x0 + 0.00 * sz, y0 + 1.10 * sz, z0);
276  yleg.SetPoint(4, x0 + 0.05 * sz, y0 + 1.15 * sz, z0);
277 
278  TPolyLine3D& xleg = view->AddPolyLine3D(7, color, style, width);
279  xleg.SetPoint(0, x0 + 1.05 * sz, y0 + 0.05 * sz, z0 - 0.05 * sz);
280  xleg.SetPoint(1, x0 + 1.05 * sz, y0 + 0.00 * sz, z0 - 0.00 * sz);
281  xleg.SetPoint(2, x0 + 1.05 * sz, y0 + 0.05 * sz, z0 + 0.05 * sz);
282  xleg.SetPoint(3, x0 + 1.05 * sz, y0 + 0.00 * sz, z0 - 0.00 * sz);
283  xleg.SetPoint(4, x0 + 1.05 * sz, y0 - 0.05 * sz, z0 - 0.05 * sz);
284  xleg.SetPoint(5, x0 + 1.05 * sz, y0 + 0.00 * sz, z0 - 0.00 * sz);
285  xleg.SetPoint(6, x0 + 1.05 * sz, y0 - 0.05 * sz, z0 + 0.05 * sz);
286 
287  return;
288  }
289 
291  double* coords,
292  int color,
293  int width,
294  int style)
295  {
298 
299  lariov::ChannelStatusProvider const& channelStatus =
301 
302  // We want to translate the wire position to the opposite side of the TPC...
303  for (size_t viewNo = 0; viewNo < geo->Nviews(); viewNo++) {
304  geo::PlaneID const planeID(rawOpt->fCryostat, rawOpt->fTPC, viewNo);
305  for (size_t wireNo = 0; wireNo < geo->Nwires(planeID); wireNo++) {
306  geo::WireID wireID = geo::WireID(planeID, wireNo);
307 
308  raw::ChannelID_t channel = geo->PlaneWireToChannel(wireID);
309 
310  if (channelStatus.IsBad(channel)) {
311  const geo::WireGeo* wireGeo = geo->WirePtr(wireID);
312 
313  auto const wireStart = wireGeo->GetStart();
314  auto const wireEnd = wireGeo->GetEnd();
315 
316  TPolyLine3D& pl = view->AddPolyLine3D(2, color, style, width);
317  pl.SetPoint(0, coords[0] - 0.5, wireStart.Y(), wireStart.Z());
318  pl.SetPoint(1, coords[0] - 0.5, wireEnd.Y(), wireEnd.Z());
319  }
320  }
321  }
322 
323  return;
324  }
325 
327 }
Float_t x
Definition: compare.C:6
geo::TPCID const & ID() const
Returns the identifier of this TPC.
Definition: TPCGeo.h:270
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:541
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:114
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
unsigned int fTPC
TPC number to draw, typically set by TWQProjectionView.
void WorldBox(double *xlo, double *xhi, double *ylo, double *yhi, double *zlo, double *zhi) const
Fills the arguments with the boundaries of the world.
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
Geometry information for a single TPC.
Definition: TPCGeo.h:36
bool fDrawBadChannels
true to draw bad channels
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
bool fDrawAxes
true to draw coordinate axes
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
double Length() const
Length is associated with z coordinate [cm].
Definition: TPCGeo.h:104
TPolyLine3D & AddPolyLine3D(int n, int c, int w, int s)
Definition: View3D.cxx:105
Point_t GetCenter() const
Returns the center of the TPC volume in world coordinates [cm].
Definition: TPCGeo.h:247
void DrawGrids(evdb::View3D *view, double *coordsLo, double *coordsHi, bool verticalGrid, int color=kGray, int width=1, int style=1)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void DrawRectangularBox(evdb::View3D *view, double *coordsLo, double *coordsHi, int color=kGray, int width=1, int style=1)
void DrawBadChannels(evdb::View3D *view, double *coords, int color, int width, int style)
unsigned int fCryostat
Cryostat number to draw, typically set by TWQProjectionView.
T get(std::string const &key) const
Definition: ParameterSet.h:314
void configure(const fhicl::ParameterSet &pset)
bool fDrawGrid
true to draw backing grid
double HalfHeight() const
Height is associated with y coordinate [cm].
Definition: TPCGeo.h:100
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 DrawAxes(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.
void DetOutline3D(evdb::View3D *view) override
A collection of 3D drawable objects.
ICARUSDrawer(const fhicl::ParameterSet &pset)
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
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
double HalfWidth() const
Width is associated with x coordinate [cm].
Definition: TPCGeo.h:96