LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
MicroBooNEDrawer_tool.cc
Go to the documentation of this file.
1 
10 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h"
11 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h"
13 
16 
17 #include "TPolyLine3D.h"
18 
19 namespace evd_tool {
20 
22  public:
23  explicit MicroBooNEDrawer(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 color = kGray,
33  int width = 1,
34  int style = 1);
35  void DrawGrids(evdb::View3D* view,
36  double* coordsLo,
37  double* coordsHi,
38  int color = kGray,
39  int width = 1,
40  int style = 1);
41  void DrawAxes(evdb::View3D* view,
42  double* coordsLo,
43  double* coordsHi,
44  int color = kGray,
45  int width = 1,
46  int style = 1);
47  void DrawBadChannels(evdb::View3D* view, double* coords, int color, int width, int style);
48 
49  // Member variables from the fhicl file
50  bool fThreeWindow;
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  fThreeWindow = pset.get<bool>("DrawThreeWindow", true);
67  fDrawGrid = pset.get<bool>("DrawGrid", true);
68  fDrawAxes = pset.get<bool>("DrawAxes", true);
69  fDrawBadChannels = pset.get<bool>("DrawBadChannels", true);
70  }
71 
72  //......................................................................
74  {
75  auto const& tpc = art::ServiceHandle<geo::Geometry const>()->TPC({0, 0});
76 
77  // If requested, draw the outer three window volume first
78  if (fThreeWindow) {
79  double threeWinCoordsLo[] = {-2. * tpc.HalfWidth(), -tpc.HalfHeight(), 0.};
80  double threeWinCoordsHi[] = {4. * tpc.HalfWidth(), tpc.HalfHeight(), tpc.Length()};
81 
82  DrawRectangularBox(view, threeWinCoordsLo, threeWinCoordsHi, kGray);
83  }
84 
85  // Now draw the standard volume
86  double coordsLo[] = {0., -tpc.HalfHeight(), 0.};
87  double coordsHi[] = {2. * tpc.HalfWidth(), tpc.HalfHeight(), tpc.Length()};
88 
89  DrawRectangularBox(view, coordsLo, coordsHi, kRed, 2, 1);
90 
91  // It could be that we don't want to see the grids
92  if (fDrawGrid) DrawGrids(view, coordsLo, coordsHi, kGray + 2, 1, 1);
93 
94  if (fDrawAxes) DrawAxes(view, coordsLo, coordsHi, kBlue, 1, 1);
95 
96  if (fDrawBadChannels) DrawBadChannels(view, coordsHi, kGray, 1, 1);
97  }
98 
100  double* coordsLo,
101  double* coordsHi,
102  int color,
103  int width,
104  int style)
105  {
106  TPolyLine3D& top = view->AddPolyLine3D(5, color, width, style);
107  top.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
108  top.SetPoint(1, coordsHi[0], coordsHi[1], coordsLo[2]);
109  top.SetPoint(2, coordsHi[0], coordsHi[1], coordsHi[2]);
110  top.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
111  top.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
112 
113  TPolyLine3D& side = view->AddPolyLine3D(5, color, width, style);
114  side.SetPoint(0, coordsHi[0], coordsHi[1], coordsLo[2]);
115  side.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
116  side.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
117  side.SetPoint(3, coordsHi[0], coordsHi[1], coordsHi[2]);
118  side.SetPoint(4, coordsHi[0], coordsHi[1], coordsLo[2]);
119 
120  TPolyLine3D& side2 = view->AddPolyLine3D(5, color, width, style);
121  side2.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
122  side2.SetPoint(1, coordsLo[0], coordsLo[1], coordsLo[2]);
123  side2.SetPoint(2, coordsLo[0], coordsLo[1], coordsHi[2]);
124  side2.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
125  side2.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
126 
127  TPolyLine3D& bottom = view->AddPolyLine3D(5, color, width, style);
128  bottom.SetPoint(0, coordsLo[0], coordsLo[1], coordsLo[2]);
129  bottom.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
130  bottom.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
131  bottom.SetPoint(3, coordsLo[0], coordsLo[1], coordsHi[2]);
132  bottom.SetPoint(4, coordsLo[0], coordsLo[1], coordsLo[2]);
133  }
134 
136  double* coordsLo,
137  double* coordsHi,
138  int color,
139  int width,
140  int style)
141  {
142  double z = coordsLo[2];
143  // Grid running along x and y at constant z
144  for (;;) {
145  TPolyLine3D& gridt = view->AddPolyLine3D(2, color, style, width);
146  gridt.SetPoint(0, coordsLo[0], coordsLo[1], z);
147  gridt.SetPoint(1, coordsHi[0], coordsLo[1], z);
148 
149  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
150  grids.SetPoint(0, coordsHi[0], coordsLo[1], z);
151  grids.SetPoint(1, coordsHi[0], coordsHi[1], z);
152 
153  z += 10.0;
154  if (z > coordsHi[2]) break;
155  }
156 
157  // Grid running along z at constant x
158  double x = 0.0;
159  for (;;) {
160  TPolyLine3D& gridt = view->AddPolyLine3D(2, color, style, width);
161  gridt.SetPoint(0, x, coordsLo[1], coordsLo[2]);
162  gridt.SetPoint(1, x, coordsLo[1], coordsHi[2]);
163  x += 10.0;
164  if (x > coordsHi[0]) break;
165  }
166 
167  // Grid running along z at constant y
168  double y = 0.0;
169  for (;;) {
170  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
171  grids.SetPoint(0, coordsHi[0], y, coordsLo[2]);
172  grids.SetPoint(1, coordsHi[0], y, coordsHi[2]);
173  y += 10.0;
174  if (y > coordsHi[1]) break;
175  }
176  y = -10.0;
177 
178  for (;;) {
179  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
180  grids.SetPoint(0, coordsHi[0], y, coordsLo[2]);
181  grids.SetPoint(1, coordsHi[0], y, coordsHi[2]);
182  y -= 10.0;
183  if (y < coordsLo[1]) break;
184  }
185  }
186 
188  double* coordsLo,
189  double* coordsHi,
190  int color,
191  int width,
192  int style)
193  {
194  // Indicate coordinate system
195  double x0 = -0.20; // Center location of the key
196  double y0 = 1.10 * coordsLo[1]; // Center location of the key
197  double z0 = -0.10 * coordsHi[2]; // Center location of the key
198  double sz = 0.20 * coordsHi[2]; // Scale size of the key in z direction
199 
200  TPolyLine3D& xaxis = view->AddPolyLine3D(2, color, style, width);
201  TPolyLine3D& yaxis = view->AddPolyLine3D(2, color, style, width);
202  TPolyLine3D& zaxis = view->AddPolyLine3D(2, color, style, width);
203  xaxis.SetPoint(0, x0, y0, z0);
204  xaxis.SetPoint(1, sz + x0, y0, z0);
205 
206  yaxis.SetPoint(0, x0, y0, z0);
207  yaxis.SetPoint(1, x0, y0 + sz, z0);
208 
209  zaxis.SetPoint(0, x0, y0, z0);
210  zaxis.SetPoint(1, x0, y0, z0 + sz);
211 
212  TPolyLine3D& xpoint = view->AddPolyLine3D(3, color, style, width);
213  TPolyLine3D& ypoint = view->AddPolyLine3D(3, color, style, width);
214  TPolyLine3D& zpoint = view->AddPolyLine3D(3, color, style, width);
215 
216  xpoint.SetPoint(0, 0.95 * sz + x0, y0, z0 - 0.05 * sz);
217  xpoint.SetPoint(1, 1.00 * sz + x0, y0, z0);
218  xpoint.SetPoint(2, 0.95 * sz + x0, y0, z0 + 0.05 * sz);
219 
220  ypoint.SetPoint(0, x0, 0.95 * sz + y0, z0 - 0.05 * sz);
221  ypoint.SetPoint(1, x0, 1.00 * sz + y0, z0);
222  ypoint.SetPoint(2, x0, 0.95 * sz + y0, z0 + 0.05 * sz);
223 
224  zpoint.SetPoint(0, x0 - 0.05 * sz, y0, 0.95 * sz + z0);
225  zpoint.SetPoint(1, x0 + 0.00 * sz, y0, 1.00 * sz + z0);
226  zpoint.SetPoint(2, x0 + 0.05 * sz, y0, 0.95 * sz + z0);
227 
228  TPolyLine3D& zleg = view->AddPolyLine3D(4, color, style, width);
229  zleg.SetPoint(0, x0 - 0.05 * sz, y0 + 0.05 * sz, z0 + 1.05 * sz);
230  zleg.SetPoint(1, x0 + 0.05 * sz, y0 + 0.05 * sz, z0 + 1.05 * sz);
231  zleg.SetPoint(2, x0 - 0.05 * sz, y0 - 0.05 * sz, z0 + 1.05 * sz);
232  zleg.SetPoint(3, x0 + 0.05 * sz, y0 - 0.05 * sz, z0 + 1.05 * sz);
233 
234  TPolyLine3D& yleg = view->AddPolyLine3D(5, color, style, width);
235  yleg.SetPoint(0, x0 - 0.05 * sz, y0 + 1.15 * sz, z0);
236  yleg.SetPoint(1, x0 + 0.00 * sz, y0 + 1.10 * sz, z0);
237  yleg.SetPoint(2, x0 + 0.00 * sz, y0 + 1.05 * sz, z0);
238  yleg.SetPoint(3, x0 + 0.00 * sz, y0 + 1.10 * sz, z0);
239  yleg.SetPoint(4, x0 + 0.05 * sz, y0 + 1.15 * sz, z0);
240 
241  TPolyLine3D& xleg = view->AddPolyLine3D(7, color, style, width);
242  xleg.SetPoint(0, x0 + 1.05 * sz, y0 + 0.05 * sz, z0 - 0.05 * sz);
243  xleg.SetPoint(1, x0 + 1.05 * sz, y0 + 0.00 * sz, z0 - 0.00 * sz);
244  xleg.SetPoint(2, x0 + 1.05 * sz, y0 + 0.05 * sz, z0 + 0.05 * sz);
245  xleg.SetPoint(3, x0 + 1.05 * sz, y0 + 0.00 * sz, z0 - 0.00 * sz);
246  xleg.SetPoint(4, x0 + 1.05 * sz, y0 - 0.05 * sz, z0 - 0.05 * sz);
247  xleg.SetPoint(5, x0 + 1.05 * sz, y0 + 0.00 * sz, z0 - 0.00 * sz);
248  xleg.SetPoint(6, x0 + 1.05 * sz, y0 - 0.05 * sz, z0 + 0.05 * sz);
249  }
250 
252  double* coords,
253  int color,
254  int width,
255  int style)
256  {
258  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout const>()->Get();
259 
260  lariov::ChannelStatusProvider const& channelStatus =
262 
263  // We want to translate the wire position to the opposite side of the TPC...
264  for (size_t viewNo = 0; viewNo < wireReadoutGeom.Nviews(); viewNo++) {
265  geo::PlaneID const planeID(rawOpt->fCryostat, rawOpt->fTPC, viewNo);
266  for (size_t wireNo = 0; wireNo < wireReadoutGeom.Nwires(planeID); wireNo++) {
267  geo::WireID wireID = geo::WireID(planeID, wireNo);
268 
269  raw::ChannelID_t channel = wireReadoutGeom.PlaneWireToChannel(wireID);
270 
271  if (channelStatus.IsBad(channel)) {
272  const geo::WireGeo* wireGeo = wireReadoutGeom.WirePtr(wireID);
273 
274  auto const wireStart = wireGeo->GetStart();
275  auto const wireEnd = wireGeo->GetEnd();
276 
277  TPolyLine3D& pl = view->AddPolyLine3D(2, color, style, width);
278  pl.SetPoint(0, coords[0] - 0.5, wireStart.Y(), wireStart.Z());
279  pl.SetPoint(1, coords[0] - 0.5, wireEnd.Y(), wireEnd.Z());
280  }
281  }
282  }
283  }
284 
286 }
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:112
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
Double_t z
Definition: plot.C:276
The data type to uniquely identify a Plane.
Definition: geo_types.h:364
void DrawAxes(evdb::View3D *view, double *coordsLo, double *coordsHi, int color=kGray, int width=1, int style=1)
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
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
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)
void DrawRectangularBox(evdb::View3D *view, double *coordsLo, double *coordsHi, int color=kGray, int width=1, int style=1)
A collection of 3D drawable objects.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
bool fDrawGrid
true to draw backing grid
This is the interface class for drawing 3D detector geometries.
art framework interface to geometry description