14 #include "TPolyLine.h" 15 #include "TPolyLine3D.h" 16 #include "TPolyMarker.h" 17 #include "TPolyMarker3D.h" 22 #include "nuevdb/EventDisplayBase/View2D.h" 23 #include "nuevdb/EventDisplayBase/View3D.h" 24 #include "nuevdb/EventDisplayBase/EventHolder.h" 41 #include "Utilities/AssociationUtil.h" 43 #include "cetlib_except/exception.h" 49 #include "canvas/Persistency/Common/FindMany.h" 54 void writeErrMsg(
const char* fcn,
58 <<
" failed with message:\n" 91 rawOpt->fDrawRawOrReco < 1 )
return;
96 std::vector<const gar::rec::Hit*> hits;
97 this->
GetHits(evt, which, hits);
121 if(recoOpt->fDrawTPCClusters == 0 ||
122 rawOpt->fDrawRawOrReco < 1 )
return;
125 for(
auto const& which : recoOpt->fTPCClusterLabels) {
127 std::vector<const gar::rec::TPCCluster*> TPCClusters;
131 recoOpt->fTPCClusterMarker,
132 recoOpt->fTPCClusterMarkerSize);
153 if(recoOpt->fDrawCaloClusters == 0 ||
154 rawOpt->fDrawRawOrReco < 1 )
return;
157 for(
auto const& which : recoOpt->fCaloClusterLabels) {
159 std::vector<const gar::rec::Cluster*> Clusters;
184 if(recoOpt->fDrawCaloHits == 0 ||
185 rawOpt->fDrawRawOrReco < 1 )
return;
188 for(
auto const& which : recoOpt->fCaloHitLabels) {
190 std::vector<const gar::rec::CaloHit*> CaloHits;
207 double xcent = geo->TPCXCent();
208 double ycent = geo->TPCYCent();
209 double zcent = geo->TPCZCent();
213 TPolyMarker3D&
pm = view->AddPolyMarker3D(1, color, marker, size);
215 pm.SetPoint(0, zcent + pos[2], xcent + pos[0], ycent + pos[1] );
226 double xcent = geo->TPCXCent();
227 double ycent = geo->TPCYCent();
228 double zcent = geo->TPCZCent();
234 if (trackpar[2] != 0) r=1.0/trackpar[2];
235 float si = TMath::Tan(trackpar[4]);
237 float ycc = trackpar[0] + r*TMath::Cos(trackpar[3]);
238 float zcc = trackpar[1] - r*TMath::Sin(trackpar[3]);
240 float dphimax = TMath::Pi();
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;
248 float dphihelix=(phi2-phi1)/((
float) nptshelix);
250 TPolyLine3D& tpoly = view->AddPolyLine3D(nptshelix,color,1,1);
252 for (
int ipoint=0;ipoint<nptshelix;++ipoint)
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]);
259 tpoly.SetPoint(ipoint,zcent+zl,xcent+xl,ycent+yl);
261 tpoly.SetLineWidth(width);
266 const float *arrowvec,
272 double xcent = geo->TPCXCent();
273 double ycent = geo->TPCYCent();
274 double zcent = geo->TPCZCent();
278 TVector3 cent(xcent,ycent,zcent);
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;
287 tpoly.SetPoint(0,spcv.Z(),spcv.X(),spcv.Y());
288 tpoly.SetPoint(1,endpos.Z(),endpos.X(),endpos.Y());
290 TVector3 xhat(1,0,0);
291 TVector3 yhat(0,1,0);
292 TVector3 zhat(0,0,1);
294 TVector3 perp1 = av.Cross(xhat);
295 if (perp1.Mag() == 0)
297 perp1 = av.Cross(yhat);
299 if (perp1.Mag() == 0)
301 perp1 = av.Cross(zhat);
303 if (perp1.Mag() == 0)
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());
311 perp1 = perp1*(1.0/perp1.Mag());
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();
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());
331 double xcent = geo->TPCXCent();
332 double ycent = geo->TPCYCent();
333 double zcent = geo->TPCZCent();
339 TPolyMarker3D&
pm = view->AddPolyMarker3D(hits.size(),
color, 1, 3);
343 for(
auto itr : hits){
351 auto const*
pos = itr->Position();
354 pm.SetPoint(p, zcent+
pos[2], xcent+
pos[0], ycent+
pos[1]);
372 double xcent = geo->TPCXCent();
373 double ycent = geo->TPCYCent();
374 double zcent = geo->TPCZCent();
380 TPolyMarker3D&
pm = view->AddPolyMarker3D(TPCClusters.size(),
color, marker,
size);
384 for(
auto itr : TPCClusters){
392 auto const*
pos = itr->Position();
395 pm.SetPoint(p, zcent+
pos[2], xcent+
pos[0], ycent+
pos[1]);
413 double xcent = geo->TPCXCent();
414 double ycent = geo->TPCYCent();
415 double zcent = geo->TPCZCent();
420 for (
auto itr : trajectories)
422 std::vector<TVector3> ftraj = itr->getFWDTrajectory();
423 TPolyLine3D& tpoly = view->AddPolyLine3D(ftraj.size(),
color,1,1);
424 for (
size_t i=0; i<ftraj.size(); ++i)
426 tpoly.SetPoint(i,zcent+ftraj.at(i).Z(),xcent+ftraj.at(i).X(),ycent+ftraj.at(i).Y());
428 tpoly.SetLineWidth(width);
443 double xcent = geo->TPCXCent();
444 double ycent = geo->TPCYCent();
445 double zcent = geo->TPCZCent();
454 for(
auto itr : Clusters){
455 TPolyLine3D& pl = view->AddPolyLine3D(14, color, 1, 1);
457 auto const*
pos = itr->Position();
458 auto const*
dir = itr->EigenVectors();
460 float length = itr->Energy()*recoOpt->fCaloClusterScale;
464 for (
int i=0;i<3;++i)
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;
473 for (
int j=0;j<6; ++j)
475 poslist[j][0] += xcent;
476 poslist[j][1] += ycent;
477 poslist[j][2] += zcent;
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]);
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,
515 double xcent = geo->TPCXCent();
516 double ycent = geo->TPCYCent();
517 double zcent = geo->TPCZCent();
526 for(
auto itr : CaloHits){
528 auto const*
pos = itr->Position();
529 float energy=itr->Energy();
530 if (energy<=0) energy=1
E-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;
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);
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};
552 for (
int i=0; i<8; ++i)
554 if (bot.find(i) == bot.end())
556 poslist[i][2] =
pos[2] + halflength;
560 poslist[i][2] =
pos[2] - halflength;
562 if (left.find(i) == left.end())
564 poslist[i][0] =
pos[0] + halflength;
568 poslist[i][0] =
pos[0] - halflength;
570 if (front.find(i) == front.end())
572 poslist[i][1] =
pos[1] + halflength;
576 poslist[i][1] =
pos[1] - halflength;
580 for (
int j=0;j<8; ++j)
582 poslist[j][0] += xcent;
583 poslist[j][1] += ycent;
584 poslist[j][2] += zcent;
587 for (
size_t j=0; j<pointlist.size(); ++j)
590 pl.SetPoint(j,poslist[pointlist[j]][2],poslist[pointlist[j]][0],poslist[pointlist[j]][1]);
606 for(
unsigned int idx = 0; idx < vechits.size(); ++idx){
611 TPolyLine3D& pl = view->AddPolyLine3D(2, colorloc, 1, 1);
616 const float *
pos = vechits[idx]->Position();
617 const float *
dir = vechits[idx]->Direction();
619 const double len = vechits[idx]->Length();
625 pos[2] - dir[2]*(len/2),
626 pos[0] - dir[0]*(len/2),
627 pos[1] - dir[1]*(len/2)
634 pos[2] + dir[2]*(len/2),
635 pos[0] + dir[0]*(len/2),
636 pos[1] + dir[1]*(len/2)
649 if(rawOpt->fDrawRawOrReco < 1 )
return;
656 if(!trackView.
isValid())
continue;
658 art::FindMany<gar::rec::TPCCluster> fmc(trackView, evt, which);
659 if(!fmc.isValid())
continue;
661 art::FindMany<gar::rec::TrackTrajectory> fmt(trackView, evt, which);
664 for(
size_t t = 0;
t < trackView.
size(); ++
t){
669 auto const& TPCClusters = fmc.at(
t);
672 recoOpt->fTPCClusterMarkerSize);
676 int width = recoOpt->fTrackWidth;
679 for (
auto tv = trackView.
begin(); tv != trackView.
end(); ++tv)
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);
695 DrawArrow3D((*tv)->Vertex(),(*tv)->VtxDir(),view,0);
713 if(rawOpt->fDrawRawOrReco < 1 )
return;
721 if(!vertexView.
isValid())
continue;
724 for (
auto tv = vertexView.
begin(); tv != vertexView.
end(); ++tv)
744 if(rawOpt->fDrawRawOrReco < 1)
return;
746 bool drawVecHit = (recoOpt->fDrawVecHits != 0);
749 for(
auto const& which : recoOpt->fVecHitLabels){
750 std::vector<const gar::rec::VecHit*> vhit;
760 std::vector<const gar::rec::Hit*> & hits)
764 std::vector<const gar::rec::Hit*>
temp;
768 for(
size_t t = 0;
t < temp.size(); ++
t){
769 hits.push_back(temp[
t]);
773 writeErrMsg(
"GetHits", e);
783 std::vector<const gar::rec::TPCCluster*> & TPCClusters)
787 std::vector<const gar::rec::TPCCluster*>
temp;
791 for(
size_t t = 0;
t < temp.size(); ++
t){
792 TPCClusters.push_back(temp[
t]);
796 writeErrMsg(
"GetTPCClusters", e);
799 return TPCClusters.size();
805 std::vector<const gar::rec::Cluster*> & Clusters)
809 std::vector<const gar::rec::Cluster*>
temp;
813 for(
size_t t = 0;
t < temp.size(); ++
t){
814 Clusters.push_back(temp[
t]);
818 writeErrMsg(
"GetCaloClusters", e);
821 return Clusters.size();
828 std::vector<const gar::rec::CaloHit*> & CaloHits)
832 std::vector<const gar::rec::CaloHit*>
temp;
836 for(
size_t t = 0;
t < temp.size(); ++
t){
837 CaloHits.push_back(temp[
t]);
841 writeErrMsg(
"GetCaloHits", e);
844 return CaloHits.size();
856 writeErrMsg(
"GetTracks", e);
859 return track.
vals().size();
865 std::vector<const gar::rec::VecHit*> & vechit)
867 std::vector<const gar::rec::VecHit*>
temp(vechit);
873 writeErrMsg(
"GetVecHits", e);
876 return vechit.size();
888 writeErrMsg(
"GetVertices", e);
891 return vertex.
vals().size();
903 writeErrMsg(
"GetShowers", e);
906 return shower.
vals().size();
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
int GetTracks(art::Event const &evt, std::string const &which, art::View< rec::Track > &track)
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)
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)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
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)
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)
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
auto isValid() const noexcept
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
std::vector< art::InputTag > fHitLabels
module labels that produced hits
LArSoft geometry interface.
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]
cet::coded_exception< error, detail::translate > exception