All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MicroBooNEDrawer_tool.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file MicroBooNEDrawer.cc
3 /// \author T. Usher
4 ////////////////////////////////////////////////////////////////////////
5 
11 #include "nuevdb/EventDisplayBase/View3D.h"
12 
13 #include "art/Framework/Services/Registry/ServiceHandle.h"
14 #include "art/Utilities/ToolMacros.h"
15 
16 #include "TPolyLine3D.h"
17 
18 namespace evd_tool
19 {
20 
22 {
23 public:
24  explicit MicroBooNEDrawer(const fhicl::ParameterSet& pset);
25 
26  void DetOutline3D(evdb::View3D* view) override;
27 
29 
30 private:
31  void configure(const fhicl::ParameterSet& pset);
32  void DrawRectangularBox(evdb::View3D* view, double* coordsLo, double* coordsHi, int color=kGray, int width = 1, int style = 1);
33  void DrawGrids(evdb::View3D* view, double* coordsLo, double* coordsHi, int color=kGray, int width = 1, int style = 1);
34  void DrawAxes(evdb::View3D* view, double* coordsLo, double* coordsHi, int color=kGray, int width = 1, int style = 1);
35  void DrawBadChannels(evdb::View3D* view, double* coords, int color, int width, int style);
36 
37  // Member variables from the fhicl file
38  bool fThreeWindow; ///< true to draw rectangular box representing 3 windows
39  bool fDrawGrid; ///< true to draw backing grid
40  bool fDrawAxes; ///< true to draw coordinate axes
41  bool fDrawBadChannels; ///< true to draw bad channels
42 };
43 
44 //----------------------------------------------------------------------
45 // Constructor.
46 MicroBooNEDrawer::MicroBooNEDrawer(const fhicl::ParameterSet& pset)
47 {
48  configure(pset);
49 }
50 
51 void MicroBooNEDrawer::configure(const fhicl::ParameterSet& pset)
52 {
53  // Start by recovering the parameters
54  fThreeWindow = pset.get< bool >("DrawThreeWindow", true);
55  fDrawGrid = pset.get< bool >("DrawGrid", true);
56  fDrawAxes = pset.get< bool >("DrawAxes", true);
57  fDrawBadChannels = pset.get< bool >("DrawBadChannels", true);
58 
59  return;
60 }
61 
62 //......................................................................
63 void MicroBooNEDrawer::DetOutline3D(evdb::View3D* view)
64 {
65  art::ServiceHandle<geo::Geometry const> geo;
66 
67  // If requested, draw the outer three window volume first
68  if (fThreeWindow)
69  {
70  double threeWinCoordsLo[] = {-2.*geo->DetHalfWidth(), -geo->DetHalfHeight(), 0.};
71  double threeWinCoordsHi[] = { 4.*geo->DetHalfWidth(), geo->DetHalfHeight(), geo->DetLength()};
72 
73  DrawRectangularBox(view, threeWinCoordsLo, threeWinCoordsHi, kGray);
74  }
75 
76  // Now draw the standard volume
77  double coordsLo[] = { 0., -geo->DetHalfHeight(), 0.};
78  double coordsHi[] = {2.*geo->DetHalfWidth(), geo->DetHalfHeight(), geo->DetLength()};
79 
80  DrawRectangularBox(view, coordsLo, coordsHi, kRed, 2, 1);
81 
82  // It could be that we don't want to see the grids
83  if (fDrawGrid) DrawGrids(view, coordsLo, coordsHi, kGray+2, 1, 1);
84 
85  if (fDrawAxes) DrawAxes(view, coordsLo, coordsHi, kBlue, 1, 1);
86 
87  if (fDrawBadChannels) DrawBadChannels(view, coordsHi, kGray, 1, 1);
88 
89  return;
90 }
91 
92 void MicroBooNEDrawer::DrawRectangularBox(evdb::View3D* view, double* coordsLo, double* coordsHi, int color, int width, int style)
93 {
94  TPolyLine3D& top = view->AddPolyLine3D(5, color, width, style);
95  top.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
96  top.SetPoint(1, coordsHi[0], coordsHi[1], coordsLo[2]);
97  top.SetPoint(2, coordsHi[0], coordsHi[1], coordsHi[2]);
98  top.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
99  top.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
100 
101  TPolyLine3D& side = view->AddPolyLine3D(5, color, width, style);
102  side.SetPoint(0, coordsHi[0], coordsHi[1], coordsLo[2]);
103  side.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
104  side.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
105  side.SetPoint(3, coordsHi[0], coordsHi[1], coordsHi[2]);
106  side.SetPoint(4, coordsHi[0], coordsHi[1], coordsLo[2]);
107 
108  TPolyLine3D& side2 = view->AddPolyLine3D(5, color, width, style);
109  side2.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
110  side2.SetPoint(1, coordsLo[0], coordsLo[1], coordsLo[2]);
111  side2.SetPoint(2, coordsLo[0], coordsLo[1], coordsHi[2]);
112  side2.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
113  side2.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
114 
115  TPolyLine3D& bottom = view->AddPolyLine3D(5, color, width, style);
116  bottom.SetPoint(0, coordsLo[0], coordsLo[1], coordsLo[2]);
117  bottom.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
118  bottom.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
119  bottom.SetPoint(3, coordsLo[0], coordsLo[1], coordsHi[2]);
120  bottom.SetPoint(4, coordsLo[0], coordsLo[1], coordsLo[2]);
121 
122  return;
123 }
124 
125 void MicroBooNEDrawer::DrawGrids(evdb::View3D* view, double* coordsLo, double* coordsHi, int color, int width, int style)
126 {
127  double z = coordsLo[2];
128  // Grid running along x and y at constant z
129  for (;;) {
130  TPolyLine3D& gridt = view->AddPolyLine3D(2, color, style, width);
131  gridt.SetPoint(0, coordsLo[0], coordsLo[1], z);
132  gridt.SetPoint(1, coordsHi[0], coordsLo[1], z);
133 
134  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
135  grids.SetPoint(0, coordsHi[0], coordsLo[1], z);
136  grids.SetPoint(1, coordsHi[0], coordsHi[1], z);
137 
138  z += 10.0;
139  if (z>coordsHi[2]) break;
140  }
141 
142  // Grid running along z at constant x
143  double x = 0.0;
144  for (;;) {
145  TPolyLine3D& gridt = view->AddPolyLine3D(2, color, style, width);
146  gridt.SetPoint(0, x, coordsLo[1], coordsLo[2]);
147  gridt.SetPoint(1, x, coordsLo[1], coordsHi[2]);
148  x += 10.0;
149  if (x>coordsHi[0]) break;
150  }
151 
152  // Grid running along z at constant y
153  double y = 0.0;
154  for (;;) {
155  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
156  grids.SetPoint(0, coordsHi[0], y, coordsLo[2]);
157  grids.SetPoint(1, coordsHi[0], y, coordsHi[2]);
158  y += 10.0;
159  if (y>coordsHi[1]) break;
160  }
161  y = -10.0;
162  for (;;) {
163  TPolyLine3D& grids = view->AddPolyLine3D(2, color, style, width);
164  grids.SetPoint(0, coordsHi[0], y, coordsLo[2]);
165  grids.SetPoint(1, coordsHi[0], y, coordsHi[2]);
166  y -= 10.0;
167  if (y<coordsLo[1]) break;
168  }
169 
170  return;
171 }
172 
173 void MicroBooNEDrawer::DrawAxes(evdb::View3D* view, double* coordsLo, double* coordsHi, int color, int width, int style)
174 {
175 
176  // Indicate coordinate system
177  double x0 = -0.20; // Center location of the key
178  double y0 = 1.10*coordsLo[1]; // Center location of the key
179  double z0 = -0.10*coordsHi[2]; // Center location of the key
180  double sz = 0.20*coordsHi[2]; // Scale size of the key in z direction
181 
182  TPolyLine3D& xaxis = view->AddPolyLine3D(2, color, style, width);
183  TPolyLine3D& yaxis = view->AddPolyLine3D(2, color, style, width);
184  TPolyLine3D& zaxis = view->AddPolyLine3D(2, color, style, width);
185  xaxis.SetPoint(0, x0, y0, z0);
186  xaxis.SetPoint(1, sz+x0, y0, z0);
187 
188  yaxis.SetPoint(0, x0, y0, z0);
189  yaxis.SetPoint(1, x0, y0+sz, z0);
190 
191  zaxis.SetPoint(0, x0, y0, z0);
192  zaxis.SetPoint(1, x0, y0, z0+sz);
193 
194  TPolyLine3D& xpoint = view->AddPolyLine3D(3, color, style, width);
195  TPolyLine3D& ypoint = view->AddPolyLine3D(3, color, style, width);
196  TPolyLine3D& zpoint = view->AddPolyLine3D(3, color, style, width);
197 
198  xpoint.SetPoint(0, 0.95*sz+x0, y0, z0-0.05*sz);
199  xpoint.SetPoint(1, 1.00*sz+x0, y0, z0);
200  xpoint.SetPoint(2, 0.95*sz+x0, y0, z0+0.05*sz);
201 
202  ypoint.SetPoint(0, x0, 0.95*sz+y0, z0-0.05*sz);
203  ypoint.SetPoint(1, x0, 1.00*sz+y0, z0);
204  ypoint.SetPoint(2, x0, 0.95*sz+y0, z0+0.05*sz);
205 
206  zpoint.SetPoint(0, x0-0.05*sz, y0, 0.95*sz+z0);
207  zpoint.SetPoint(1, x0+0.00*sz, y0, 1.00*sz+z0);
208  zpoint.SetPoint(2, x0+0.05*sz, y0, 0.95*sz+z0);
209 
210  TPolyLine3D& zleg = view->AddPolyLine3D(4, color, style, width);
211  zleg.SetPoint(0, x0-0.05*sz, y0+0.05*sz, z0+1.05*sz);
212  zleg.SetPoint(1, x0+0.05*sz, y0+0.05*sz, z0+1.05*sz);
213  zleg.SetPoint(2, x0-0.05*sz, y0-0.05*sz, z0+1.05*sz);
214  zleg.SetPoint(3, x0+0.05*sz, y0-0.05*sz, z0+1.05*sz);
215 
216  TPolyLine3D& yleg = view->AddPolyLine3D(5, color, style, width);
217  yleg.SetPoint(0, x0-0.05*sz, y0+1.15*sz, z0);
218  yleg.SetPoint(1, x0+0.00*sz, y0+1.10*sz, z0);
219  yleg.SetPoint(2, x0+0.00*sz, y0+1.05*sz, z0);
220  yleg.SetPoint(3, x0+0.00*sz, y0+1.10*sz, z0);
221  yleg.SetPoint(4, x0+0.05*sz, y0+1.15*sz, z0);
222 
223  TPolyLine3D& xleg = view->AddPolyLine3D(7, color, style, width);
224  xleg.SetPoint(0, x0+1.05*sz, y0+0.05*sz, z0-0.05*sz);
225  xleg.SetPoint(1, x0+1.05*sz, y0+0.00*sz, z0-0.00*sz);
226  xleg.SetPoint(2, x0+1.05*sz, y0+0.05*sz, z0+0.05*sz);
227  xleg.SetPoint(3, x0+1.05*sz, y0+0.00*sz, z0-0.00*sz);
228  xleg.SetPoint(4, x0+1.05*sz, y0-0.05*sz, z0-0.05*sz);
229  xleg.SetPoint(5, x0+1.05*sz, y0+0.00*sz, z0-0.00*sz);
230  xleg.SetPoint(6, x0+1.05*sz, y0-0.05*sz, z0+0.05*sz);
231 
232  return;
233 }
234 
235 void MicroBooNEDrawer::DrawBadChannels(evdb::View3D* view, double* coords, int color, int width, int style)
236 {
237  art::ServiceHandle<geo::Geometry const> geo;
238  art::ServiceHandle<evd::RawDrawingOptions const> rawOpt;
239 
240  lariov::ChannelStatusProvider const& channelStatus
241  = art::ServiceHandle<lariov::ChannelStatusService const>()->GetProvider();
242 
243  // We want to translate the wire position to the opposite side of the TPC...
244  for(size_t viewNo = 0; viewNo < geo->Nviews(); viewNo++)
245  {
246  for(size_t wireNo = 0; wireNo < geo->Nwires(viewNo); wireNo++)
247  {
248  geo::WireID wireID = geo::WireID(rawOpt->fCryostat, rawOpt->fTPC, viewNo, wireNo);
249 
250  raw::ChannelID_t channel = geo->PlaneWireToChannel(wireID);
251 
252  if (channelStatus.IsBad(channel))
253  {
254  const geo::WireGeo* wireGeo = geo->WirePtr(wireID);
255 
256  double wireStart[3];
257  double wireEnd[3];
258 
259  wireGeo->GetStart(wireStart);
260  wireGeo->GetEnd(wireEnd);
261 
262  TPolyLine3D& pl = view->AddPolyLine3D(2, color, style, width);
263  pl.SetPoint(0, coords[0]-0.5, wireStart[1], wireStart[2]);
264  pl.SetPoint(1, coords[0]-0.5, wireEnd[1], wireEnd[2]);
265  }
266  }
267  }
268 
269  return;
270 }
271 
272 
273 DEFINE_ART_CLASS_TOOL(MicroBooNEDrawer)
274 }
void GetStart(double *xyz) const
Definition: WireGeo.h:157
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
process_name opflash particleana ie ie ie z
bool fDrawAxes
true to draw coordinate axes
walls no bottom
Definition: selectors.fcl:105
void DrawGrids(evdb::View3D *view, double *coordsLo, double *coordsHi, int color=kGray, int width=1, int style=1)
process_name opflash particleana ie x
virtual bool IsBad(raw::ChannelID_t channel) const =0
Returns whether the specified channel is bad in the current run.
bool fDrawBadChannels
true to draw bad channels
void DrawAxes(evdb::View3D *view, double *coordsLo, double *coordsHi, int color=kGray, int width=1, int style=1)
def style
Definition: util.py:237
walls no top
Definition: selectors.fcl:105
void DetOutline3D(evdb::View3D *view) override
process_name opflash particleana ie ie y
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
MicroBooNEDrawer(const fhicl::ParameterSet &pset)
bool fThreeWindow
true to draw rectangular box representing 3 windows
Class providing information about the quality of channels.
void configure(const fhicl::ParameterSet &pset)
void DrawBadChannels(evdb::View3D *view, double *coords, int color, int width, int style)
void GetEnd(double *xyz) const
Definition: WireGeo.h:163
void DrawRectangularBox(evdb::View3D *view, double *coordsLo, double *coordsHi, int color=kGray, int width=1, int style=1)
Interface for experiment-specific channel quality info provider.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
Interface for experiment-specific service for channel quality info.
bool fDrawGrid
true to draw backing grid
This is the interface class for drawing 3D detector geometries.
art framework interface to geometry description