RecoBaseDrawer.cxx
Go to the documentation of this file.
1 /// \file RecoBaseDrawer.cxx
2 /// \brief Class to aid in the rendering of RecoBase objects
3 /// \author brebel@fnal.gov
4 /// \version $Id: RecoBaseDrawer.cxx,v 1.3 2010/11/11 22:47:19 p-novaart Exp $
5 #include <cmath>
6 #include <map>
7 #include <stdint.h>
8 
9 #include "TMath.h"
10 #include "TMarker.h"
11 #include "TBox.h"
12 #include "TH1.h"
13 #include "TLine.h"
14 #include "TPolyLine.h"
15 #include "TPolyLine3D.h"
16 #include "TPolyMarker.h"
17 #include "TPolyMarker3D.h"
18 #include "TVector3.h"
19 #include "TText.h"
20 #include "TColor.h"
21 
22 #include "nuevdb/EventDisplayBase/View2D.h"
23 #include "nuevdb/EventDisplayBase/View3D.h"
24 #include "nuevdb/EventDisplayBase/EventHolder.h"
30 #include "EventDisplay/EVD/Style.h"
39 #include "Geometry/GeometryGAr.h"
41 #include "Utilities/AssociationUtil.h"
42 
43 #include "cetlib_except/exception.h"
49 #include "canvas/Persistency/Common/FindMany.h"
51 
52 namespace {
53  // Utility function to make uniform error messages.
54  void writeErrMsg(const char* fcn,
55  cet::exception const& e)
56  {
57  mf::LogWarning("RecoBaseDrawer") << "RecoBaseDrawer::" << fcn
58  << " failed with message:\n"
59  << e;
60  }
61 }
62 
63 namespace gar {
64  namespace evd{
65 
66  //......................................................................
68  {
69  }
70 
71  //......................................................................
73  {
74  }
75 
76  //......................................................................
77  ///
78  /// Render Hit objects on a 2D viewing canvas
79  ///
80  /// @param evt : Event handle to get data objects from
81  /// @param view : Pointer to view to draw on
82  /// @param plane : plane number of view
83  ///
85  evdb::View3D* view)
86  {
89 
90  if(recoOpt->fDrawHits == 0 ||
91  rawOpt->fDrawRawOrReco < 1 ) return;
92 
93  int h = 0;
94  for(auto const& which : recoOpt->fHitLabels) {
95 
96  std::vector<const gar::rec::Hit*> hits;
97  this->GetHits(evt, which, hits);
98 
99  this->DrawHit3D(hits, view, h%evd::kNCOLS);
100  ++h;
101  } // loop on imod folders
102 
103  return;
104  }
105 
106 
107  //......................................................................
108  ///
109  /// Render TPCCluster objects on a 2D viewing canvas
110  ///
111  /// @param evt : Event handle to get data objects from
112  /// @param view : Pointer to view to draw on
113  /// @param plane : plane number of view
114  ///
116  evdb::View3D* view)
117  {
120 
121  if(recoOpt->fDrawTPCClusters == 0 ||
122  rawOpt->fDrawRawOrReco < 1 ) return;
123 
124  int h = 0;
125  for(auto const& which : recoOpt->fTPCClusterLabels) {
126 
127  std::vector<const gar::rec::TPCCluster*> TPCClusters;
128  this->GetTPCClusters(evt, which, TPCClusters);
129 
130  this->DrawTPCCluster3D(TPCClusters, view, h%evd::kNCOLS,
131  recoOpt->fTPCClusterMarker,
132  recoOpt->fTPCClusterMarkerSize);
133  ++h;
134  }
135 
136  return;
137  }
138 
139 
140  //......................................................................
141  ///
142  /// Render Calorimeter Cluster objects on a 2D viewing canvas
143  ///
144  /// @param evt : Event handle to get data objects from
145  /// @param view : Pointer to view to draw on
146  ///
148  evdb::View3D* view)
149  {
152 
153  if(recoOpt->fDrawCaloClusters == 0 ||
154  rawOpt->fDrawRawOrReco < 1 ) return;
155 
156  int h = 0;
157  for(auto const& which : recoOpt->fCaloClusterLabels) {
158 
159  std::vector<const gar::rec::Cluster*> Clusters;
160  this->GetCaloClusters(evt, which, Clusters);
161 
162  //this->DrawCaloCluster3D(Clusters, view, h%evd::kNCOLS);
163  this->DrawCaloCluster3D(Clusters, view, 3); // think about colors. currently just green
164  ++h;
165  }
166 
167  return;
168  }
169 
170 
171  //......................................................................
172  ///
173  /// Render Calorimeter Hit objects on a 2D viewing canvas
174  ///
175  /// @param evt : Event handle to get data objects from
176  /// @param view : Pointer to view to draw on
177  ///
179  evdb::View3D* view)
180  {
183 
184  if(recoOpt->fDrawCaloHits == 0 ||
185  rawOpt->fDrawRawOrReco < 1 ) return;
186 
187  int h = 0;
188  for(auto const& which : recoOpt->fCaloHitLabels) {
189 
190  std::vector<const gar::rec::CaloHit*> CaloHits;
191  this->GetCaloHits(evt, which, CaloHits);
192 
193  this->DrawCaloHit3D(CaloHits, view);
194  ++h;
195  }
196 
197  return;
198  }
199 
201  evdb::View3D* view,
202  int color,
203  int marker,
204  int size )
205  {
207  double xcent = geo->TPCXCent();
208  double ycent = geo->TPCYCent();
209  double zcent = geo->TPCZCent();
210  xcent = 0;
211  ycent = 0;
212  zcent = 0;
213  TPolyMarker3D& pm = view->AddPolyMarker3D(1, color, marker, size);
214  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
215  pm.SetPoint(0, zcent + pos[2], xcent + pos[0], ycent + pos[1] );
216  }
217 
218  void RecoBaseDrawer::DrawHelix3D(const float *trackpar,
219  const float xpar,
220  const float xother,
221  evdb::View3D *view,
222  int color,
223  int width)
224  {
226  double xcent = geo->TPCXCent();
227  double ycent = geo->TPCYCent();
228  double zcent = geo->TPCZCent();
229  xcent = 0;
230  ycent = 0;
231  zcent = 0;
232 
233  float r = 0;
234  if (trackpar[2] != 0) r=1.0/trackpar[2];
235  float si = TMath::Tan(trackpar[4]);
236 
237  float ycc = trackpar[0] + r*TMath::Cos(trackpar[3]);
238  float zcc = trackpar[1] - r*TMath::Sin(trackpar[3]);
239 
240  float dphimax = TMath::Pi();
241  float phi1 = 0;
242  float phi2 = (xother-xpar)*trackpar[2]/si;
243  if (phi2-phi1>dphimax) phi2 = phi1+dphimax;
244  if (phi2-phi1<-dphimax) phi2 = phi1-dphimax;
245  if (phi2-phi1==0) phi2=phi1+0.01;
246 
247  int nptshelix=100;
248  float dphihelix=(phi2-phi1)/((float) nptshelix);
249 
250  TPolyLine3D& tpoly = view->AddPolyLine3D(nptshelix,color,1,1);
251 
252  for (int ipoint=0;ipoint<nptshelix;++ipoint)
253  {
254  float philoc = phi1 + ipoint*dphihelix;
255  float xl = xpar + r*si*(philoc);
256  float yl = ycc - r*TMath::Cos(philoc + trackpar[3]);
257  float zl = zcc + r*TMath::Sin(philoc + trackpar[3]);
258  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
259  tpoly.SetPoint(ipoint,zcent+zl,xcent+xl,ycent+yl);
260  }
261  tpoly.SetLineWidth(width);
262  }
263 
264 
265  void RecoBaseDrawer::DrawArrow3D(const float *startpos,
266  const float *arrowvec,
267  evdb::View3D* view,
268  int color,
269  float lengthscale)
270  {
272  double xcent = geo->TPCXCent();
273  double ycent = geo->TPCYCent();
274  double zcent = geo->TPCZCent();
275  xcent = 0;
276  ycent = 0;
277  zcent = 0;
278  TVector3 cent(xcent,ycent,zcent);
279 
280  TPolyLine3D& tpoly = view->AddPolyLine3D(5,color,1,1);
281  TVector3 spv(startpos);
282  TVector3 spcv = startpos + cent;
283  TVector3 av(arrowvec);
284  TVector3 endpos = spcv + lengthscale*av;
285 
286  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
287  tpoly.SetPoint(0,spcv.Z(),spcv.X(),spcv.Y());
288  tpoly.SetPoint(1,endpos.Z(),endpos.X(),endpos.Y());
289 
290  TVector3 xhat(1,0,0);
291  TVector3 yhat(0,1,0);
292  TVector3 zhat(0,0,1);
293 
294  TVector3 perp1 = av.Cross(xhat);
295  if (perp1.Mag() == 0)
296  {
297  perp1 = av.Cross(yhat);
298  }
299  if (perp1.Mag() == 0)
300  {
301  perp1 = av.Cross(zhat);
302  }
303  if (perp1.Mag() == 0)
304  {
305  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
306  tpoly.SetPoint(2,endpos.Z(),endpos.X(),endpos.Y());
307  tpoly.SetPoint(3,endpos.Z(),endpos.X(),endpos.Y());
308  tpoly.SetPoint(4,endpos.Z(),endpos.X(),endpos.Y());
309  return;
310  }
311  perp1 = perp1*(1.0/perp1.Mag());
312 
313  TVector3 arpd1 = endpos -lengthscale*0.1*av + perp1*lengthscale*0.1*av.Mag();
314  TVector3 arpd2 = endpos -lengthscale*0.1*av - perp1*lengthscale*0.1*av.Mag();
315  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
316  tpoly.SetPoint(2,arpd1.Z(),arpd1.X(),arpd1.Y());
317  tpoly.SetPoint(3,endpos.Z(),endpos.X(),endpos.Y());
318  tpoly.SetPoint(4,arpd2.Z(),arpd2.X(),arpd2.Y());
319  }
320 
321  //......................................................................
322  void RecoBaseDrawer::DrawHit3D(std::vector<const gar::rec::Hit*> const& hits,
323  evdb::View3D * view,
324  int color,
325  int /*marker*/,
326  int /*size*/)
327  {
328  //auto const* detp = gar::providerFrom<detinfo::DetectorPropertiesService>();
329 
331  double xcent = geo->TPCXCent();
332  double ycent = geo->TPCYCent();
333  double zcent = geo->TPCZCent();
334  xcent = 0;
335  ycent = 0;
336  zcent = 0;
337 
338  // Make and fill a polymarker.
339  TPolyMarker3D& pm = view->AddPolyMarker3D(hits.size(), color, 1, 3);
340 
341  // Display all hits on the 3D view
342  size_t p = 0;
343  for(auto itr : hits){
344 
345  // Try to get the "best" charge measurement, ie. the one last in
346  // the calibration chain
347  //double dQdX = itr->Signal() / detp->ElectronsToADC();
348 
349  // Try to get the "best" charge measurement, ie. the one last in
350  // the calibration chain
351  auto const* pos = itr->Position();
352 
353  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
354  pm.SetPoint(p, zcent+pos[2], xcent+pos[0], ycent+pos[1]);
355  ++p;
356  }
357 
358  return;
359  }
360 
361 
362  //......................................................................
363  void RecoBaseDrawer::DrawTPCCluster3D(std::vector<const gar::rec::TPCCluster*> const& TPCClusters,
364  evdb::View3D * view,
365  int color,
366  int marker,
367  int size)
368  {
369  //auto const* detp = gar::providerFrom<detinfo::DetectorPropertiesService>();
370 
372  double xcent = geo->TPCXCent();
373  double ycent = geo->TPCYCent();
374  double zcent = geo->TPCZCent();
375  xcent = 0;
376  ycent = 0;
377  zcent = 0;
378 
379  // Make and fill a polymarker.
380  TPolyMarker3D& pm = view->AddPolyMarker3D(TPCClusters.size(), color, marker, size);
381 
382  // Display all TPCClusters on the 3D view
383  size_t p = 0;
384  for(auto itr : TPCClusters){
385 
386  // Try to get the "best" charge measurement, ie. the one last in
387  // the calibration chain
388  //double dQdX = itr->Signal() / detp->ElectronsToADC();
389 
390  // Try to get the "best" charge measurement, ie. the one last in
391  // the calibration chain
392  auto const* pos = itr->Position();
393 
394  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
395  pm.SetPoint(p, zcent+pos[2], xcent+pos[0], ycent+pos[1]);
396  ++p;
397  }
398 
399  return;
400  }
401 
402 
403 
404  //......................................................................
405  void RecoBaseDrawer::DrawTrackPolyLine3D(std::vector<const gar::rec::TrackTrajectory*> const& trajectories,
406  evdb::View3D * view,
407  int color,
408  int width)
409  {
410  //auto const* detp = gar::providerFrom<detinfo::DetectorPropertiesService>();
411 
413  double xcent = geo->TPCXCent();
414  double ycent = geo->TPCYCent();
415  double zcent = geo->TPCZCent();
416  xcent = 0;
417  ycent = 0;
418  zcent = 0;
419 
420  for (auto itr : trajectories) // there should only be one
421  {
422  std::vector<TVector3> ftraj = itr->getFWDTrajectory(); // later -- decide if we need the backward one too
423  TPolyLine3D& tpoly = view->AddPolyLine3D(ftraj.size(),color,1,1);
424  for (size_t i=0; i<ftraj.size(); ++i)
425  {
426  tpoly.SetPoint(i,zcent+ftraj.at(i).Z(),xcent+ftraj.at(i).X(),ycent+ftraj.at(i).Y());
427  }
428  tpoly.SetLineWidth(width);
429  }
430 
431  return;
432  }
433 
434 
435  //......................................................................
436  void RecoBaseDrawer::DrawCaloCluster3D(std::vector<const gar::rec::Cluster*> const& Clusters,
437  evdb::View3D * view,
438  int color)
439  {
440  //auto const* detp = gar::providerFrom<detinfo::DetectorPropertiesService>();
441 
443  double xcent = geo->TPCXCent();
444  double ycent = geo->TPCYCent();
445  double zcent = geo->TPCZCent();
446  xcent = 0;
447  ycent = 0;
448  zcent = 0;
449 
451 
452  // Make and fill polylines
453 
454  for(auto itr : Clusters){
455  TPolyLine3D& pl = view->AddPolyLine3D(14, color, 1, 1);
456 
457  auto const* pos = itr->Position();
458  auto const* dir = itr->EigenVectors();
459  //auto const* shape = itr->Shape();
460  float length = itr->Energy()*recoOpt->fCaloClusterScale;
461 
462  // vertices of an octahedron
463  float poslist[6][3];
464  for (int i=0;i<3;++i)
465  {
466  poslist[0][i] = pos[i];
467  poslist[5][i] = pos[i]+dir[i]*length;
468  poslist[1][i] = pos[i]+(dir[i] + dir[3+i]*0.2)*length/2.0;
469  poslist[2][i] = pos[i]+(dir[i] + dir[6+i]*0.2)*length/2.0;
470  poslist[3][i] = pos[i]+(dir[i] - dir[3+i]*0.2)*length/2.0;
471  poslist[4][i] = pos[i]+(dir[i] - dir[6+i]*0.2)*length/2.0;
472  }
473  for (int j=0;j<6; ++j)
474  {
475  poslist[j][0] += xcent;
476  poslist[j][1] += ycent;
477  poslist[j][2] += zcent;
478  }
479  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
480  pl.SetPoint(0 , poslist[0][2], poslist[0][0], poslist[0][1]);
481  pl.SetPoint(1 , poslist[1][2], poslist[1][0], poslist[1][1]);
482  pl.SetPoint(2 , poslist[5][2], poslist[5][0], poslist[5][1]);
483  pl.SetPoint(3 , poslist[2][2], poslist[2][0], poslist[2][1]);
484  pl.SetPoint(4 , poslist[0][2], poslist[0][0], poslist[0][1]);
485  pl.SetPoint(5 , poslist[3][2], poslist[3][0], poslist[3][1]);
486  pl.SetPoint(6 , poslist[5][2], poslist[5][0], poslist[5][1]);
487  pl.SetPoint(7 , poslist[4][2], poslist[4][0], poslist[4][1]);
488  pl.SetPoint(8 , poslist[0][2], poslist[0][0], poslist[0][1]);
489  pl.SetPoint(9 , poslist[1][2], poslist[1][0], poslist[1][1]);
490  pl.SetPoint(10, poslist[2][2], poslist[2][0], poslist[2][1]);
491  pl.SetPoint(11, poslist[3][2], poslist[3][0], poslist[3][1]);
492  pl.SetPoint(12, poslist[4][2], poslist[4][0], poslist[4][1]);
493  pl.SetPoint(13, poslist[1][2], poslist[1][0], poslist[1][1]);
494  }
495 
496  return;
497  }
498 
499 
500 
501  //......................................................................
502  void RecoBaseDrawer::DrawCaloHit3D(std::vector<const gar::rec::CaloHit*> const& CaloHits,
503  evdb::View3D * view)
504  {
505  //auto const* detp = gar::providerFrom<detinfo::DetectorPropertiesService>();
506 
507  const int colorheatindex[16] = { kBlue+2, kBlue+1, kBlue,
508  kCyan+2, kCyan+1, kCyan,
509  kGreen+2, kGreen+1, kGreen,
510  kRed-2, kRed+1, kRed,
511  kYellow+2, kYellow+1, kYellow,
512  kWhite };
513 
515  double xcent = geo->TPCXCent();
516  double ycent = geo->TPCYCent();
517  double zcent = geo->TPCZCent();
518  xcent = 0;
519  ycent = 0;
520  zcent = 0;
521 
523 
524  // Make and fill polylines -- cubes in this case
525 
526  for(auto itr : CaloHits){
527 
528  auto const* pos = itr->Position();
529  float energy=itr->Energy();
530  if (energy<=0) energy=1E-3;
531  energy = TMath::Log(energy);
532  float normenergy = (energy + recoOpt->fCaloHitScale)/recoOpt->fCaloHitScale;
533  if (normenergy < 0) normenergy = 0;
534  if (normenergy > 1) normenergy = 1;
535  int icolor = normenergy*16.0;
536  if (icolor>15) icolor = 15;
537  float halflength = 0.5; // in cm
538 
539  std::vector<int> pointlist = {0,1,5,6,2,3,7,4,0,3,7,6,2,1,5,4};
540  TPolyLine3D& pl = view->AddPolyLine3D(pointlist.size(), colorheatindex[icolor], 1, 1);
541 
542  //std::cout << "Drawing calo hit at : " << pos[0] << " " << pos[1] << " " << pos[2] << " " <<
543  // "with normenergy: " << normenergy << std::endl;
544 
545  // vertices of a cube
546 
547  float poslist[8][3];
548  std::set<int> bot = {0, 1, 2, 3};
549  std::set<int> left = {0, 3, 4, 7};
550  std::set<int> front = {0, 1, 5, 4};
551 
552  for (int i=0; i<8; ++i)
553  {
554  if (bot.find(i) == bot.end()) // we're on top
555  {
556  poslist[i][2] = pos[2] + halflength;
557  }
558  else
559  {
560  poslist[i][2] = pos[2] - halflength;
561  }
562  if (left.find(i) == left.end()) // we're on the right-hand side
563  {
564  poslist[i][0] = pos[0] + halflength;
565  }
566  else
567  {
568  poslist[i][0] = pos[0] - halflength;
569  }
570  if (front.find(i) == front.end()) // we're in back
571  {
572  poslist[i][1] = pos[1] + halflength;
573  }
574  else
575  {
576  poslist[i][1] = pos[1] - halflength;
577  }
578  }
579  // move the origin as needed
580  for (int j=0;j<8; ++j)
581  {
582  poslist[j][0] += xcent;
583  poslist[j][1] += ycent;
584  poslist[j][2] += zcent;
585  }
586 
587  for (size_t j=0; j<pointlist.size(); ++j)
588  {
589  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
590  pl.SetPoint(j,poslist[pointlist[j]][2],poslist[pointlist[j]][0],poslist[pointlist[j]][1]);
591  }
592 
593  }
594 
595  return;
596  }
597 
598  //......................................................................
599  void RecoBaseDrawer::DrawVecHit3D(std::vector<const gar::rec::VecHit*> const& vechits,
600  evdb::View3D *view,
601  int /*color*/,
602  int /*marker*/,
603  int /*size*/)
604  {
605  size_t p =0;
606  for(unsigned int idx = 0; idx < vechits.size(); ++idx){
607 
608  int colorloc = evd::kColor[idx%evd::kNCOLS];
609 
610  // Make and fill a polyline: the vechit extent in both directions
611  TPolyLine3D& pl = view->AddPolyLine3D(2, colorloc, 1, 1);
612  // Make and fill a polymarker: the vechit position
613  // TODO: Could add one but how best to display?
614  //TPolyMarker3D& pm = view->AddPolyMarker3D(1, 6, 33, 1);
615 
616  const float *pos = vechits[idx]->Position();
617  const float *dir = vechits[idx]->Direction();
618 
619  const double len = vechits[idx]->Length();
620 
621  //pm.SetPoint(0, pos[0], pos[1], pos[2]);
622  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
623 
624  pl.SetPoint(0,
625  pos[2] - dir[2]*(len/2),
626  pos[0] - dir[0]*(len/2),
627  pos[1] - dir[1]*(len/2)
628  );
629 
630  // This would be the center, but don't need to draw that
631  //pl.SetPoint(1, pos[0], pos[1], pos[2]);
632 
633  pl.SetPoint(1,
634  pos[2] + dir[2]*(len/2),
635  pos[0] + dir[0]*(len/2),
636  pos[1] + dir[1]*(len/2)
637  );
638  ++p;
639  }
640  }
641 
642  //----------------------------------------------------------------------------
644  evdb::View3D* view)
645  {
648 
649  if(rawOpt->fDrawRawOrReco < 1 ) return;
650  bool drawTracks = (recoOpt->fDrawTracks != 0);
651 
652  if(drawTracks){
653  for(auto const& which : recoOpt->fTrackLabels){
654  art::View<gar::rec::Track> trackView;
655  this->GetTracks(evt, which, trackView);
656  if(!trackView.isValid()) continue;
657 
658  art::FindMany<gar::rec::TPCCluster> fmc(trackView, evt, which);
659  if(!fmc.isValid()) continue;
660 
661  art::FindMany<gar::rec::TrackTrajectory> fmt(trackView, evt, which);
662  //if(!fmt.isValid()) continue;
663 
664  for(size_t t = 0; t < trackView.size(); ++t){
665 
667 
668  // Draw track using only embedded information.
669  auto const& TPCClusters = fmc.at(t);
670 
671  DrawTPCCluster3D(TPCClusters, view, color, recoOpt->fTPCClusterMarker,
672  recoOpt->fTPCClusterMarkerSize);
673 
674  }
675 
676  int width = recoOpt->fTrackWidth;
677 
678  size_t icounter=0;
679  for (auto tv = trackView.begin(); tv != trackView.end(); ++tv)
680  {
681  int color = evd::kColor[icounter%evd::kNCOLS];
682 
683  // draw helices for 1, track trajectory points for 2
684 
685  if (recoOpt->fDrawTracks == 1 || ! fmt.isValid())
686  {
687  DrawHelix3D((*tv)->TrackParBeg(), (*tv)->Vertex()[0], (*tv)->End()[0], view, color, width);
688  DrawHelix3D((*tv)->TrackParEnd(), (*tv)->End()[0], (*tv)->Vertex()[0], view, color, width);
689  }
690  else if (recoOpt->fDrawTracks == 2)
691  {
692  DrawTrackPolyLine3D(fmt.at(icounter),view,color,width);
693  }
694 
695  DrawArrow3D((*tv)->Vertex(),(*tv)->VtxDir(),view,0);
696  DrawArrow3D((*tv)->End(),(*tv)->EndDir(),view,0);
697 
698  ++icounter;
699  }
700  }
701  }
702  return;
703  }
704 
705 
706  //----------------------------------------------------------------------------
708  evdb::View3D* view)
709  {
712 
713  if(rawOpt->fDrawRawOrReco < 1 ) return;
714  bool drawVertices = (recoOpt->fDrawVertices != 0);
715 
716  if(drawVertices){
717  for(auto const& which : recoOpt->fVertexLabels){
718  art::View<gar::rec::Vertex> vertexView;
719  GetVertices(evt, which, vertexView);
720 
721  if(!vertexView.isValid()) continue;
722 
723  size_t icounter=0;
724  for (auto tv = vertexView.begin(); tv != vertexView.end(); ++tv)
725  {
726  int color = evd::kColor[icounter%evd::kNCOLS];
727  color = 5; // hardwire yellow for now
728  DrawVertex3D( (*tv)->Position(), view, color, 20, 1 );
729  ++icounter;
730  }
731  }
732  }
733 
734  return;
735  }
736 
737  //----------------------------------------------------------------------------
739  evdb::View3D* view)
740  {
743 
744  if(rawOpt->fDrawRawOrReco < 1) return;
745 
746  bool drawVecHit = (recoOpt->fDrawVecHits != 0);
747 
748  if(drawVecHit){
749  for(auto const& which : recoOpt->fVecHitLabels){
750  std::vector<const gar::rec::VecHit*> vhit;
751  this->GetVecHits(evt, which, vhit);
752  DrawVecHit3D(vhit, view);
753  } // loop on imod folders
754  }
755  }
756 
757  //......................................................................
759  std::string const& which,
760  std::vector<const gar::rec::Hit*> & hits)
761  {
762  hits.clear();
763 
764  std::vector<const gar::rec::Hit*> temp;
765 
766  try{
767  evt.getView(which, temp);
768  for(size_t t = 0; t < temp.size(); ++t){
769  hits.push_back(temp[t]);
770  }
771  }
772  catch(cet::exception& e){
773  writeErrMsg("GetHits", e);
774  }
775 
776  return hits.size();
777  }
778 
779 
780  //......................................................................
782  std::string const& which,
783  std::vector<const gar::rec::TPCCluster*> & TPCClusters)
784  {
785  TPCClusters.clear();
786 
787  std::vector<const gar::rec::TPCCluster*> temp;
788 
789  try{
790  evt.getView(which, temp);
791  for(size_t t = 0; t < temp.size(); ++t){
792  TPCClusters.push_back(temp[t]);
793  }
794  }
795  catch(cet::exception& e){
796  writeErrMsg("GetTPCClusters", e);
797  }
798 
799  return TPCClusters.size();
800  }
801 
802  //......................................................................
804  std::string const& which,
805  std::vector<const gar::rec::Cluster*> & Clusters)
806  {
807  Clusters.clear();
808 
809  std::vector<const gar::rec::Cluster*> temp;
810 
811  try{
812  evt.getView(which, temp);
813  for(size_t t = 0; t < temp.size(); ++t){
814  Clusters.push_back(temp[t]);
815  }
816  }
817  catch(cet::exception& e){
818  writeErrMsg("GetCaloClusters", e);
819  }
820 
821  return Clusters.size();
822  }
823 
824 
825  //......................................................................
827  std::string const& which,
828  std::vector<const gar::rec::CaloHit*> & CaloHits)
829  {
830  CaloHits.clear();
831 
832  std::vector<const gar::rec::CaloHit*> temp;
833 
834  try{
835  evt.getView(which, temp);
836  for(size_t t = 0; t < temp.size(); ++t){
837  CaloHits.push_back(temp[t]);
838  }
839  }
840  catch(cet::exception& e){
841  writeErrMsg("GetCaloHits", e);
842  }
843 
844  return CaloHits.size();
845  }
846 
847  //......................................................................
849  std::string const& which,
851  {
852  try{
853  evt.getView(which, track);
854  }
855  catch(cet::exception& e){
856  writeErrMsg("GetTracks", e);
857  }
858 
859  return track.vals().size();
860  }
861 
862  //......................................................................
864  std::string const& which,
865  std::vector<const gar::rec::VecHit*> & vechit)
866  {
867  std::vector<const gar::rec::VecHit*> temp(vechit);
868  try{
869  evt.getView(which, temp);
870  temp.swap(vechit);
871  }
872  catch(cet::exception& e){
873  writeErrMsg("GetVecHits", e);
874  }
875 
876  return vechit.size();
877  }
878 
879  //......................................................................
881  std::string const& which,
883  {
884  try{
885  evt.getView(which, vertex);
886  }
887  catch(cet::exception& e){
888  writeErrMsg("GetVertices", e);
889  }
890 
891  return vertex.vals().size();
892  }
893 
894  //......................................................................
896  std::string const& which,
898  {
899  try{
900  evt.getView(which, shower);
901  }
902  catch(cet::exception& e){
903  writeErrMsg("GetShowers", e);
904  }
905 
906  return shower.vals().size();
907  }
908 
909  }
910 }// namespace
911 ////////////////////////////////////////////////////////////////////////
int GetCaloClusters(art::Event const &evt, std::string const &which, std::vector< const rec::Cluster * > &Clusters)
std::vector< art::InputTag > fTrackLabels
module labels that produced tracks
std::string string
Definition: nybbler.cc:12
int GetTracks(art::Event const &evt, std::string const &which, art::View< rec::Track > &track)
auto end() noexcept
Definition: View.h:89
void TPCCluster3D(art::Event const &evt, evdb::View3D *view)
void DrawCaloHit3D(std::vector< const gar::rec::CaloHit * > const &CaloHits, evdb::View3D *view)
void DrawArrow3D(const float *startpos, const float *arrowvec, evdb::View3D *view, int color, float lengthscale=1.0)
int GetCaloHits(art::Event const &evt, std::string const &which, std::vector< const rec::CaloHit * > &CaloHits)
string dir
int GetVecHits(art::Event const &evt, std::string const &which, std::vector< const rec::VecHit * > &vechits)
void DrawTrackPolyLine3D(std::vector< const gar::rec::TrackTrajectory * > const &trajectories, evdb::View3D *view, int color, int width=2)
void VecHit3D(art::Event const &evt, evdb::View3D *view)
void CaloCluster3D(art::Event const &evt, evdb::View3D *view)
void Track3D(art::Event const &evt, evdb::View3D *view)
auto & vals() noexcept
Definition: View.h:68
static const int kNCOLS
Definition: eventdisplay.h:12
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
void CaloHit3D(art::Event const &evt, evdb::View3D *view)
int GetTPCClusters(art::Event const &evt, std::string const &which, std::vector< const rec::TPCCluster * > &TPCClusters)
void DrawCaloCluster3D(std::vector< const gar::rec::Cluster * > const &Clusters, evdb::View3D *view, int color)
int GetShowers(art::Event const &evt, std::string const &which, art::View< rec::Shower > &shower)
const double e
LArSoft includes.
Definition: InfoTransfer.h:33
auto begin() noexcept
Definition: View.h:83
void DrawVecHit3D(std::vector< const rec::VecHit * > const &vechits, evdb::View3D *view, int color=6, int marker=28, int size=2)
std::vector< art::InputTag > fVertexLabels
module labels that produced vertices
void DrawHit3D(std::vector< const rec::Hit * > const &hit, evdb::View3D *view, int color, int marker=2, int size=2)
void DrawTPCCluster3D(std::vector< const gar::rec::TPCCluster * > const &TPCClusters, evdb::View3D *view, int color, int marker=2, int size=2)
p
Definition: test.py:223
Definition: fwd.h:46
int GetHits(art::Event const &evt, std::string const &which, std::vector< const rec::Hit * > &hits)
void DrawVertex3D(const float *pos, evdb::View3D *view, int color=5, int marker=20, int size=1)
void Vertex3D(art::Event const &evt, evdb::View3D *view)
std::size_t color(std::string const &procname)
General GArSoft Utilities.
void DrawHelix3D(const float *trackpar, const float xpar, const float xother, evdb::View3D *view, int color, int width)
auto size() const noexcept
Definition: View.h:119
auto isValid() const noexcept
Definition: View.h:52
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:500
std::vector< art::InputTag > fHitLabels
module labels that produced hits
TCEvent evt
Definition: DataStructs.cxx:7
if(!yymsg) yymsg
LArSoft geometry interface.
Definition: ChannelGeo.h:16
art framework interface to geometry description
void Hit3D(art::Event const &evt, evdb::View3D *view)
int GetVertices(art::Event const &evt, std::string const &which, art::View< rec::Vertex > &vertex)
static const int kColor[kNCOLS]
Definition: eventdisplay.h:13
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
vertex reconstruction