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