13 #include "canvas/Persistency/Common/FindMany.h" 18 #include "nuevdb/EventDisplayBase/NavState.h" 26 #include "CoreUtils/ServiceUtil.h" 53 #include "cetlib_except/demangle.h" 58 #include <TApplication.h> 66 #include <TGButtonGroup.h> 67 #include <TGTextEntry.h> 68 #include <TGTextView.h> 72 #include <TGeoManager.h> 75 #include <TGeoCompositeShape.h> 76 #include <TGeoBoolNode.h> 77 #include <TEveGeoNode.h> 78 #include <TEvePointSet.h> 80 #include "TEveTrack.h" 81 #include "TEveTrackPropagator.h" 82 #include "TEvePathMark.h" 83 #include "TTimeStamp.h" 84 #include "TEveManager.h" 85 #include "TEveEventManager.h" 86 #include "TEveScene.h" 87 #include "TEveViewer.h" 88 #include "TEveBrowser.h" 89 #include "TEveRGBAPaletteOverlay.h" 90 #include "TEveFrameBox.h" 91 #include "TEveQuadSet.h" 92 #include "TEveTrans.h" 93 #include "TEveProjectionAxes.h" 94 #include "TEveProjectionManager.h" 95 #include "TEveWindow.h" 96 #include "TGLViewer.h" 97 #include "TGLCameraOverlay.h" 100 #include "TEveArrow.h" 101 #include "TGLAnnotation.h" 102 #include "TGLFontManager.h" 103 #include "TPolyLine3D.h" 104 #include "TDatabasePDG.h" 105 #include "TParticle.h" 113 void writeErrMsg(
const char* fcn,
117 <<
" failed with message:\n" 234 void DrawTrackPolyLine3D(std::vector<const gar::rec::TrackTrajectory*>
const& trajectories, TEveElementList* &eve_list,
int counter);
236 void DrawTPCCluster3D(std::vector<const gar::rec::TPCCluster*>
const& TPCClusters, TEveElementList* &eve_list);
240 void DrawHelix3D(
const float *trackpar,
const float xpar,
const float xother, TEveLine* &eve_track,
int color);
242 void DrawArrow3D(
const float *fVertex,
const float *fDir,
int color, TEveArrow* &arrow);
303 fGeoManager->DefaultColors();
323 fRawHitLabels = pset.
get< std::vector<std::string> > (
"RawHitModuleLabels" );
328 fTrackLabels = pset.
get< std::vector<std::string> > (
"TrackModuleLabels" );
329 fVertexLabels = pset.
get< std::vector<std::string> > (
"VertexModuleLabels" );
349 TEveBrowser* browser =
fEve->GetBrowser();
350 browser->StartEmbedding(TRootBrowser::kLeft);
352 TGMainFrame* frmMain =
new TGMainFrame(gClient->GetRoot(), 800, 600);
353 frmMain->SetWindowName(
"EVT NAV");
354 frmMain->SetCleanup(kDeepCleanup);
356 TGHorizontalFrame* navFrame =
new TGHorizontalFrame(frmMain);
357 TGVerticalFrame* evtidFrame =
new TGVerticalFrame(frmMain);
359 TString icondir(
TString::Format(
"%s/icons/", gSystem->Getenv(
"ROOTSYS")) );
360 TGPictureButton*
b = 0;
363 b =
new TGPictureButton(navFrame, gClient->GetPicture(icondir +
"GoBack.gif"));
364 navFrame->AddFrame(b);
365 b->Connect(
"Clicked()",
"gar::evd3d::EventDisplay3DUtils",
fEvtDisplayUtil.get(),
"PrevEvent()");
368 b =
new TGPictureButton(navFrame, gClient->GetPicture(icondir +
"GoForward.gif"));
369 navFrame->AddFrame(b);
370 b->Connect(
"Clicked()",
"gar::evd3d::EventDisplay3DUtils",
fEvtDisplayUtil.get(),
"NextEvent()");
373 TGHorizontalFrame* runoFrame =
new TGHorizontalFrame(evtidFrame);
374 fTlRun =
new TGLabel(runoFrame,
"Run Number");
375 fTlRun->SetTextJustify(kTextLeft);
376 fTlRun->SetMargins(5,5,5,0);
377 runoFrame->AddFrame(
fTlRun);
381 fTeRun->Connect(
"ReturnPressed()",
"gar::evd3d::EventDisplay3DUtils",
fEvtDisplayUtil.get(),
"GotoEvent()");
382 runoFrame->AddFrame(
fTeRun,
new TGLayoutHints(kLHintsExpandX));
385 TGHorizontalFrame* evnoFrame =
new TGHorizontalFrame(evtidFrame);
386 fTlEvt =
new TGLabel(evnoFrame,
"Evt Number");
387 fTlEvt->SetTextJustify(kTextLeft);
388 fTlEvt->SetMargins(5,5,5,0);
389 evnoFrame->AddFrame(
fTlEvt);
393 fTeEvt->Connect(
"ReturnPressed()",
"gar::evd3d::EventDisplay3DUtils",
fEvtDisplayUtil.get(),
"GotoEvent()");
394 evnoFrame->AddFrame(
fTeEvt,
new TGLayoutHints(kLHintsExpandX));
397 evtidFrame->AddFrame(runoFrame,
new TGLayoutHints(kLHintsExpandX));
398 evtidFrame->AddFrame(evnoFrame,
new TGLayoutHints(kLHintsExpandX));
401 frmMain->AddFrame(navFrame);
402 TGHorizontal3DLine *separator =
new TGHorizontal3DLine(frmMain);
403 frmMain->AddFrame(separator,
new TGLayoutHints(kLHintsExpandX));
404 frmMain->AddFrame(evtidFrame);
406 frmMain->MapSubwindows();
408 frmMain->MapWindow();
410 browser->StopEmbedding();
411 browser->SetTabTitle(
"Event Nav", 0);
419 gROOT->SetBatch(kFALSE);
420 fEve = TEveManager::Create();
422 TEveElementList*
simple =
new TEveElementList(
"simplifiedGeometry");
426 fEve->AddGlobalElement(simple);
437 glViewer->ColorSet().Background().SetColor(kWhite);
438 glViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
439 glViewer->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kTRUE,
origin);
440 glViewer->SetDrawCameraCenter(kTRUE);
445 ann->SetRole(TGLOverlayElement::kViewer);
446 ann->SetUseColorSet(
true);
447 ann->SetTextSize(0.04);
448 ann->SetTextAlign(TGLFont::kLeft);
449 ann->SetAllowClose(
false);
450 ann->SetTextColor(kBlack);
453 fEve->Redraw3D(kTRUE);
472 std::ostringstream sstr;
473 sstr <<
event.id().run();
477 gClient->NeedRedraw(
fTeRun);
480 sstr <<
event.id().event();
483 gClient->NeedRedraw(
fTeEvt);
515 if(
fEve->GetCurrentEvent() !=
nullptr)
516 fEve->GetCurrentEvent()->DestroyElements();
528 bool hasHall =
false;
531 TGeoMatrix* topHall = &nullmatgm;
532 if(topnodes.size() != 0) hasHall =
true;
534 std::cout <<
"Has the hall in the list of volumes? " << hasHall <<
std::endl;
539 for(
unsigned int i = 0; i < topnodes.size(); i++)
542 if(nodename.find(
"rockBox_lv") == std::string::npos)
continue;
544 const TGeoNode *
top = topnodes.at(i);
545 topHall = top->GetMatrix();
550 bool hasEnclosure =
false;
552 TGeoMatrix* topEnclosure = &nullmatgm;
553 if(topnodes.size() != 0) hasEnclosure =
true;
555 std::cout <<
"Has the Enclosure in the list of volumes? " << hasEnclosure <<
std::endl;
560 for(
unsigned int i = 0; i < topnodes.size(); i++)
563 if(nodename.find(
"volDetEnclosure") == std::string::npos)
continue;
565 const TGeoNode *
top = topnodes.at(i);
566 topEnclosure = top->GetMatrix();
573 TGeoMatrix* topND = &nullmatgm;
574 for(
unsigned int i = 0; i < topnodes.size(); i++)
577 if(nodename.find(
"volMPD_0") == std::string::npos)
continue;
579 const TGeoNode *
top = topnodes.at(i);
580 topND = top->GetMatrix();
600 for(
unsigned int i = 0; i < nodevec.size(); i++)
603 if(nodename.find(volname) == std::string::npos)
continue;
605 const TGeoNode *node = nodevec.at(i);
608 if(nodename.find(
"BarrelECal") != std::string::npos || nodename.find(
"EndcapECal") != std::string::npos)
610 TGeoScale nullmatgm_local;
611 TGeoMatrix* topECal = &nullmatgm_local;
612 topECal = node->GetMatrix();
614 for(
int idaugh = 0; idaugh < node->GetNdaughters(); idaugh++)
616 const TGeoNode *daugh_node = node->GetDaughter(idaugh);
617 TGeoShape *daugh_shape = daugh_node->GetVolume()->GetShape();
618 TGeoShape* daugh_clonedShape =
dynamic_cast<TGeoShape*
> (daugh_shape->Clone(
"fakeShape"));
619 TEveGeoShape *daugh_fakeShape =
new TEveGeoShape(daugh_shape->GetName());
620 daugh_fakeShape->SetShape(daugh_clonedShape);
622 if(nodename.find(
"BarrelECal") != std::string::npos)
624 daugh_fakeShape->SetMainColor(kOrange+10);
625 daugh_fakeShape->SetMainTransparency(80);
627 else if(nodename.find(
"EndcapECal") != std::string::npos)
629 daugh_fakeShape->SetMainColor(kGreen+1);
630 daugh_fakeShape->SetMainTransparency(80);
633 TGeoMatrix* currMat = daugh_node->GetMatrix();
634 TGeoMatrix* mat = currMat->MakeClone();
635 TGeoHMatrix *
m =
new TGeoHMatrix(*mat);
636 m->MultiplyLeft(topECal);
638 m->MultiplyLeft(topND);
639 if(hasEnclosure) m->MultiplyLeft(topEnclosure);
640 if(hasHall) m->MultiplyLeft(topHall);
641 daugh_fakeShape->SetTransMatrix(*m);
643 list->AddElement(daugh_fakeShape);
647 TGeoShape *shape = node->GetVolume()->GetShape();
648 TGeoShape* clonedShape =
dynamic_cast<TGeoShape*
> (shape->Clone(
"fakeShape"));
650 TEveGeoShape *fakeShape =
new TEveGeoShape(shape->GetName());
651 fakeShape->SetShape(clonedShape);
653 if(nodename.find(
"TPC") != std::string::npos)
655 fakeShape->SetMainColor(kBlue+8);
656 fakeShape->SetMainTransparency(80);
658 else if(nodename.find(
"PV") != std::string::npos)
660 fakeShape->SetMainColor(kGray+1);
661 fakeShape->SetMainTransparency(70);
664 fakeShape->SetMainColor(node->GetVolume()->GetLineColor());
665 fakeShape->SetMainTransparency(70);
668 TGeoMatrix* currMat = node->GetMatrix();
669 TGeoMatrix* mat = currMat->MakeClone();
670 TGeoHMatrix *
m =
new TGeoHMatrix(*mat);
671 m->MultiplyLeft(topND);
672 if(hasEnclosure) m->MultiplyLeft(topEnclosure);
673 if(hasHall) m->MultiplyLeft(topHall);
674 fakeShape->SetTransMatrix(*m);
677 list->AddElement(fakeShape);
686 if(topnodes.size() != 0) hasLAr =
true;
689 for(
unsigned int i = 0; i < topnodes.size(); i++)
692 if(nodename.find(
"volArgonCubeDetector") == std::string::npos)
continue;
694 const TGeoNode *node = topnodes.at(i);
696 TGeoScale nullmatgm_local;
697 TGeoMatrix* topLAr = &nullmatgm_local;
698 topLAr = node->GetMatrix();
700 for(
int idaugh = 0; idaugh < node->GetNdaughters(); idaugh++)
702 const TGeoNode *daugh_node = node->GetDaughter(idaugh);
703 TGeoShape *daugh_shape = daugh_node->GetVolume()->GetShape();
704 TGeoShape* daugh_clonedShape =
dynamic_cast<TGeoShape*
> (daugh_shape->Clone(
"fakeShape"));
705 TEveGeoShape *daugh_fakeShape =
new TEveGeoShape(daugh_shape->GetName());
706 daugh_fakeShape->SetShape(daugh_clonedShape);
707 daugh_fakeShape->SetMainColor(kGreen+1);
708 daugh_fakeShape->SetMainTransparency(80);
709 TGeoMatrix* currMat = daugh_node->GetMatrix();
710 TGeoMatrix* mat = currMat->MakeClone();
711 TGeoHMatrix *
m =
new TGeoHMatrix(*mat);
712 m->MultiplyLeft(topLAr);
713 if(hasEnclosure) m->MultiplyLeft(topEnclosure);
714 if(hasHall) m->MultiplyLeft(topHall);
715 daugh_fakeShape->SetTransMatrix(*m);
717 list->AddElement(daugh_fakeShape);
729 int neutralColor(12);
730 int neutrinoColor(38);
732 std::vector<const simb::MCParticle*> plist;
735 fMCTrajectoryList =
new TEveElementList(
"g4Trajectories",
"Geant4 Trajectories");
739 double minPartEnergy(0.01);
741 for(
unsigned int p = 0;
p < plist.size(); ++
p)
747 int pdgCode(mcPart->
PdgCode());
750 double partCharge = partPDG ? partPDG->Charge() : 0.;
751 double partEnergy = mcPart->
E();
753 if(
nullptr == partPDG)
continue;
756 if (!mcTraj.
empty() && partEnergy > minPartEnergy)
759 int numTrajPoints = mcTraj.
size();
761 std::ostringstream
label;
762 label <<
"Particle pdg " << pdgCode <<
"\n";
763 label <<
"Charge: " << partCharge <<
"\n";
764 label <<
"Energy: " << partEnergy <<
" GeV\n";
765 label <<
"Momentum (" << mcPart->
Px() <<
", " << mcPart->
Py() <<
", " << mcPart->
Pz() <<
" )";
767 TEveLine *MCtrack =
new TEveLine(numTrajPoints);
768 MCtrack->SetName(
"MC trajectory");
769 MCtrack->SetTitle(label.str().c_str());
770 if (partCharge == 0.){
771 MCtrack->SetLineColor(neutralColor);
772 MCtrack->SetLineWidth(2);
773 MCtrack->SetLineStyle(3);
776 MCtrack->SetLineColor(colorIdx);
777 MCtrack->SetLineWidth(2);
778 MCtrack->SetLineStyle(1);
781 for(
int hitIdx = 0; hitIdx < numTrajPoints; hitIdx++)
783 double xPos = mcTraj.
X(hitIdx);
784 double yPos = mcTraj.
Y(hitIdx);
785 double zPos = mcTraj.
Z(hitIdx);
788 TVector3 point(xPos, yPos, zPos);
791 MCtrack->SetPoint(hitIdx, xPos, yPos, zPos);
799 std::vector<const simb::MCTruth*> mctruth;
803 for (
unsigned int idx = 0; idx < mctruth.size(); idx++)
806 for (
int particleIdx = 0; particleIdx < mctruth[idx]->NParticles(); particleIdx++)
816 TVector3 particlePosition(mcPart.
Vx(), mcPart.
Vy(), mcPart.
Vz());
819 TVector3 oppPartDir(-mcPart.
Px(), -mcPart.
Py(), -mcPart.
Pz());
821 if (oppPartDir.Mag2() > 0.) oppPartDir.SetMag(1.);
823 double arcLenToDraw = 50.0;
826 TEveLine *motherPart =
new TEveLine(2);
827 motherPart->SetLineColor(neutrinoColor);
828 motherPart->SetLineWidth(2);
829 motherPart->SetLineStyle(2);
831 motherPart->SetPoint(0, particlePosition.X(), particlePosition.Y(), particlePosition.Z());
832 particlePosition +=
std::min(arcLenToDraw + 10., 1000.) * oppPartDir;
833 motherPart->SetPoint(1,particlePosition.X(), particlePosition.Y(), particlePosition.Z());
848 std::vector<const sdp::EnergyDeposit*> simlist;
851 fTPCSimHitList =
new TEveElementList(
"TPC Hits",
"Simulated TPC hits");
855 for(
unsigned int p = 0;
p < simlist.size(); ++
p)
859 std::ostringstream
label;
860 label <<
"TPC Sim Hit " <<
p <<
"\n";
861 label <<
"Energy: " << simHit->
Energy() <<
" GeV\n";
862 label <<
"Position (" << simHit->
X() <<
", " << simHit->
Y() <<
", " << simHit->
Z() <<
" ) cm\n";
864 TEvePointSet *evehit =
new TEvePointSet(1);
866 evehit->SetTitle(label.str().c_str());
867 evehit->SetMarkerSize(1);
868 evehit->SetMarkerStyle(1);
870 evehit->SetPoint(0, simHit->
X(), simHit->
Y(), simHit->
Z());
880 std::vector<const sdp::CaloDeposit*> simlist;
883 fCaloSimHitList =
new TEveElementList(
"ECAL Sim Calo Hits",
"Simulated ECAL hits");
887 for(
unsigned int p = 0;
p < simlist.size(); ++
p)
891 std::ostringstream
label;
892 label <<
"ECAL/MuID Sim Hit " <<
p <<
"\n";
893 label <<
"Energy: " << simHit->
Energy() <<
" GeV\n";
894 label <<
"Position (" << simHit->
X() <<
", " << simHit->
Y() <<
", " << simHit->
Z() <<
" ) cm\n";
895 label <<
"CellID: " << simHit->
CellID() <<
"\n";
903 TEvePointSet *evehit =
new TEvePointSet(1);
905 evehit->SetTitle(label.str().c_str());
906 evehit->SetMarkerSize(1);
907 evehit->SetMarkerStyle(20);
909 evehit->SetPoint(0, simHit->
X(), simHit->
Y(), simHit->
Z());
919 std::vector<const raw::CaloRawDigit*> rawlist;
922 fCaloRawHitList =
new TEveElementList(
"ECAL Raw Calo Hits",
"Digitized ECAL hits");
926 for(
unsigned int p = 0;
p < rawlist.size(); ++
p)
929 const std::array<double, 3> point = { rawHit->
X(), rawHit->
Y(), rawHit->
Z() };
931 std::ostringstream
label;
932 label <<
"ECAL/MuID Digi Hit " <<
p <<
"\n";
933 label <<
"Energy: " << rawHit->
ADC().first <<
" ADC\n";
934 label <<
"Position (" << rawHit->
X() <<
", " << rawHit->
Y() <<
", " << rawHit->
Z() <<
" ) cm\n";
935 label <<
"CellID: " << rawHit->
CellID() <<
"\n";
943 TEvePointSet *evehit =
new TEvePointSet(1);
945 evehit->SetTitle(label.str().c_str());
946 evehit->SetMarkerSize(1);
947 evehit->SetMarkerStyle(20);
949 evehit->SetPoint(0, rawHit->
X(), rawHit->
Y(), rawHit->
Z());
959 std::vector<const rec::CaloHit*> recolist;
962 fCaloRecoHitList =
new TEveElementList(
"ECAL Reco Calo Hits",
"Reconstructed ECAL hits");
966 for(
unsigned int p = 0;
p < recolist.size(); ++
p)
971 std::ostringstream
label;
972 label <<
"ECAL Reco Hit " <<
p <<
"\n";
973 label <<
"Energy: " << recoHit->
Energy() * 1000 <<
" MeV\n";
974 label <<
"Position (" << recoHit->
Position()[0] <<
", " << recoHit->
Position()[1] <<
", " << recoHit->
Position()[2] <<
" ) cm\n";
975 label <<
"CellID: " << recoHit->
CellID() <<
"\n";
983 TEvePointSet *evehit =
new TEvePointSet(1);
985 evehit->SetTitle(label.str().c_str());
986 evehit->SetMarkerSize(1);
987 evehit->SetMarkerStyle(20);
1001 fCaloMuIDHitList =
new TEveElementList(
"MuID Reco Hits",
"Reconstructed MuID hits");
1005 for(
unsigned int p = 0;
p < recolist.size(); ++
p)
1010 std::ostringstream
label;
1011 label <<
"MuID Reco Hit " <<
p <<
"\n";
1012 label <<
"Energy: " << recoHit->
Energy() * 1000 <<
" MeV\n";
1013 label <<
"Position (" << recoHit->
Position()[0] <<
", " << recoHit->
Position()[1] <<
", " << recoHit->
Position()[2] <<
" ) cm\n";
1014 label <<
"CellID: " << recoHit->
CellID() <<
"\n";
1022 TEvePointSet *evehit =
new TEvePointSet(1);
1024 evehit->SetTitle(label.str().c_str());
1025 evehit->SetMarkerSize(1);
1026 evehit->SetMarkerStyle(20);
1042 std::vector<const gar::rec::Cluster*> clusters;
1045 fCaloClusterList =
new TEveElementList(
"ECAL Clusters",
"Clustered ECAL hits");
1049 for(
unsigned int p = 0;
p < clusters.size(); ++
p)
1054 auto const* shape = clus->
Shape();
1059 float poslist[6][3];
1061 for (
int i = 0; i < 3; ++i)
1073 std::ostringstream
label;
1074 label <<
"Cluster " <<
p <<
"\n";
1075 label <<
"PID " << clus->
ParticleID() <<
"\n";
1076 label <<
"Energy: " << clus->
Energy() * 1000 <<
" MeV\n";
1077 label <<
"Position (" << clus->
Position()[0] <<
", " << clus->
Position()[1] <<
", " << clus->
Position()[2] <<
" ) cm\n";
1078 label <<
"Shape: r_forw " << shape[0] <<
", r_bck " << shape[1] <<
", r2 " << shape[2] <<
", r3 " << shape[3] <<
", vol " << shape[4] <<
", width " << shape[5];
1080 TEveLine *eve_r1cluster =
new TEveLine(6);
1082 eve_r1cluster->SetTitle(label.str().c_str());
1083 eve_r1cluster->SetLineWidth(2);
1084 eve_r1cluster->SetLineStyle(1);
1086 eve_r1cluster->SetPoint(0, poslist[0][0], poslist[0][1], poslist[0][2]);
1087 eve_r1cluster->SetPoint(1, poslist[1][0], poslist[1][1], poslist[1][2]);
1088 eve_r1cluster->SetPoint(2, poslist[2][0], poslist[2][1], poslist[2][2]);
1089 eve_r1cluster->SetPoint(3, poslist[3][0], poslist[3][1], poslist[3][2]);
1090 eve_r1cluster->SetPoint(4, poslist[4][0], poslist[4][1], poslist[4][2]);
1091 eve_r1cluster->SetPoint(5, poslist[5][0], poslist[5][1], poslist[5][2]);
1102 if(!trackView.
isValid())
return;
1104 art::FindMany<gar::rec::TPCCluster> fmc(trackView, event,
fTrackLabels.at(0));
1105 if(!fmc.isValid())
return;
1107 art::FindMany<gar::rec::TrackTrajectory> fmt(trackView, event,
fTrackLabels.at(0));
1111 fTPCClusterList =
new TEveElementList(
"TPC Clusters",
"Reconstructed TPC Clusters");
1115 for(
size_t t = 0;
t < trackView.
size(); ++
t) {
1117 auto const& TPCClusters = fmc.at(
t);
1126 fTrackList =
new TEveElementList(
"Fitted Tracks",
"Tracks in the TPC");
1130 unsigned int icounter = 0;
1131 for (
auto tv = trackView.
begin(); tv != trackView.
end(); ++tv)
1133 if(!fmt.isValid()) {
1155 std::vector<const gar::rec::Vertex*> vertexs;
1158 fVertexList =
new TEveElementList(
"Reconstructed vertex",
"Reconstructed vertex");
1162 for(
unsigned int p = 0;
p < vertexs.size(); ++
p)
1168 TEvePointSet *evevx =
new TEvePointSet(1);
1169 evevx->SetMarkerSize(1);
1170 evevx->SetMarkerStyle(20);
1171 evevx->SetMarkerColor(5);
1172 evevx->SetPoint(0,
pos[0],
pos[1],
pos[2]);
1187 const float fStartX = (forward ==
true) ? trk->
Vertex()[0] : trk->
End()[0];
1188 const float fEndX = (forward ==
true) ? trk->
End()[0] : trk->
Vertex()[0];
1192 TEveLine *eve_track =
new TEveLine();
1193 this->
DrawHelix3D(fTrackpar, fStartX, fEndX, eve_track, color);
1195 eve_track->SetName(trackname.Data());
1196 std::ostringstream
label;
1197 label <<
"Track " << counter <<
"\n";
1198 label <<
"Vertex (" << trk->
Vertex()[0] <<
", " << trk->
Vertex()[1] <<
", " << trk->
Vertex()[2] <<
") cm\n";
1199 label <<
"End (" << trk->
End()[0] <<
", " << trk->
End()[1] <<
", " << trk->
End()[2] <<
") cm\n";
1200 label <<
"Omega " << fTrackpar[2] <<
"\n";
1201 label <<
"phi " << fTrackpar[3] <<
"\n";
1202 label <<
"TanLambda " << std::tan(fTrackpar[4]) <<
"\n";
1203 label <<
"Momentum " << fMomentum <<
" GeV\n";
1204 label <<
"Charge " << fTrackpar[2] / std::fabs(fTrackpar[2]);
1205 eve_track->SetTitle(label.str().c_str());
1207 const float *fVertex = (forward ==
true) ? trk->
Vertex() : trk->
End();
1208 const float *fDir = (forward ==
true) ? trk->
VtxDir() : trk->
EndDir();
1210 TEveArrow *arrow =
new TEveArrow();
1213 eve_list->AddElement(eve_track);
1214 eve_list->AddElement(arrow);
1224 for (
auto itr : trajectories)
1226 std::vector<TVector3> ftraj = itr->getFWDTrajectory();
1227 TEveLine* tpoly =
new TEveLine();
1228 tpoly->SetLineColor(color);
1229 tpoly->SetLineWidth(2);
1230 tpoly->SetLineStyle(1);
1232 for (
size_t i=0; i<ftraj.size(); ++i)
1233 tpoly->SetPoint(i, ftraj.at(i).X(), ftraj.at(i).Y(), ftraj.at(i).Z());
1235 eve_list->AddElement(tpoly);
1244 unsigned int idx = 0;
1245 for(
auto itr : TPCClusters)
1247 std::ostringstream
label;
1248 label <<
"TPC Cluster " << idx <<
"\n";
1249 label <<
"Energy: " << itr->Signal() <<
" pe\n";
1250 label <<
"Position (" << itr->Position()[0] <<
", " << itr->Position()[1] <<
", " << itr->Position()[2] <<
" ) cm";
1252 TEvePointSet *evehit =
new TEvePointSet(1);
1254 evehit->SetTitle(label.str().c_str());
1255 evehit->SetMarkerSize(1);
1256 evehit->SetMarkerStyle(20);
1257 evehit->SetMarkerColor(
fEvtDisplayUtil->LogColor(itr->Signal(), 0, 1000, 5));
1258 evehit->SetPoint(0, itr->Position()[0], itr->Position()[1], itr->Position()[2]);
1260 eve_list->AddElement(evehit);
1270 float xyz_intersection[3] = {0., 0., 0.};
1271 float xyz_otherintersect[3];
1277 std::ostringstream
label;
1281 TEvePointSet *intersection1 =
new TEvePointSet(1);
1282 intersection1->SetName(
TString::Format(
"Track forward Calo Intersection Barrel %i", counter).
Data());
1283 label <<
"Barrel Intersection forward - Track " << counter <<
"\n";
1284 label <<
"Position (" << xyz_intersection[0] <<
", " << xyz_intersection[1] <<
", " << xyz_intersection[2] <<
") cm";
1285 intersection1->SetTitle(label.str().c_str());
1286 intersection1->SetMarkerSize(1.3);
1287 intersection1->SetMarkerStyle(22);
1288 intersection1->SetMarkerColor(color);
1289 intersection1->SetPoint(0, xyz_intersection[0], xyz_intersection[1], xyz_intersection[2]);
1290 fTrackList_local->AddElement(intersection1);
1300 TEvePointSet *intersection3 =
new TEvePointSet(1);
1301 intersection3->SetName(
TString::Format(
"Track forward Calo Intersection Endcap %i", counter).
Data());
1304 label <<
"Endcap Intersection forward - Track " << counter <<
"\n";
1305 label <<
"Position (" << xyz_intersection[0] <<
", " << xyz_intersection[1] <<
", " << xyz_intersection[2] <<
") cm";
1306 intersection3->SetTitle(label.str().c_str());
1307 intersection3->SetMarkerSize(1.3);
1308 intersection3->SetMarkerStyle(29);
1309 intersection3->SetMarkerColor(color);
1310 intersection3->SetPoint(0, xyz_intersection[0], xyz_intersection[1], xyz_intersection[2]);
1311 fTrackList_local->AddElement(intersection3);
1322 TEvePointSet *intersection2 =
new TEvePointSet(1);
1323 intersection2->SetName(
TString::Format(
"Track backward Calo Intersection Barrel %i", counter).
Data());
1326 label <<
"Barrel Intersection backward - Track " << counter <<
"\n";
1327 label <<
"Position (" << xyz_intersection[0] <<
", " << xyz_intersection[1] <<
", " << xyz_intersection[2] <<
") cm";
1328 intersection2->SetTitle(label.str().c_str());
1329 intersection2->SetMarkerSize(1.3);
1330 intersection2->SetMarkerStyle(23);
1331 intersection2->SetMarkerColor(color);
1332 intersection2->SetPoint(0, xyz_intersection[0], xyz_intersection[1], xyz_intersection[2]);
1333 fTrackList_local->AddElement(intersection2);
1343 TEvePointSet *intersection4 =
new TEvePointSet(1);
1344 intersection4->SetName(
TString::Format(
"Track backward Calo Intersection Endcap %i", counter).
Data());
1347 label <<
"Endcap Intersection backward - Track " << counter <<
"\n";
1348 label <<
"Position (" << xyz_intersection[0] <<
", " << xyz_intersection[1] <<
", " << xyz_intersection[2] <<
") cm";
1349 intersection4->SetTitle(label.str().c_str());
1350 intersection4->SetMarkerSize(1.3);
1351 intersection4->SetMarkerStyle(29);
1352 intersection4->SetMarkerColor(color);
1353 intersection4->SetPoint(0, xyz_intersection[0], xyz_intersection[1], xyz_intersection[2]);
1354 fTrackList_local->AddElement(intersection4);
1365 if (trackpar[2] != 0) r=1.0/trackpar[2];
1367 float si = TMath::Tan(trackpar[4]);
1368 float ycc = trackpar[0] + r*TMath::Cos(trackpar[3]);
1369 float zcc = trackpar[1] - r*TMath::Sin(trackpar[3]);
1370 float dphimax = TMath::Pi();
1372 float phi2 = (xother-xpar)*trackpar[2]/si;
1374 if (phi2-phi1>dphimax) phi2 = phi1+dphimax;
1375 if (phi2-phi1<-dphimax) phi2 = phi1-dphimax;
1376 if (phi2-phi1==0) phi2=phi1+0.01;
1379 float dphihelix=(phi2-phi1)/((
float) nptshelix);
1381 for (
int ipoint=0;ipoint<nptshelix;++ipoint)
1383 float philoc = phi1 + ipoint*dphihelix;
1384 float xl = xpar + r*si*(philoc);
1385 float yl = ycc - r*TMath::Cos(philoc + trackpar[3]);
1386 float zl = zcc + r*TMath::Sin(philoc + trackpar[3]);
1388 TVector3 point(xl, yl, zl);
1391 eve_track->SetPoint(ipoint, xl, yl, zl);
1394 eve_track->SetLineWidth(2);
1395 eve_track->SetLineStyle(1);
1396 eve_track->SetLineColor(color);
1404 TVector3 spv(fVertex);
1405 TVector3 spcv = spv + cent;
1408 arrow->SetOrigin(spcv.X(), spcv.Y(), spcv.Z());
1409 arrow->SetVector(av.X()*10, av.Y()*10, av.Z()*10);
1410 arrow->SetMainColor(color);
1411 arrow->SetTubeR(0.1);
1412 arrow->SetConeL(0.5);
1413 arrow->SetConeR(0.2);
1422 std::vector<const sdp::EnergyDeposit*> tempTPC;
1427 for(
size_t t = 0;
t < tempTPC.size(); ++
t)
1428 simTPC.push_back(tempTPC[
t]);
1431 writeErrMsg(
"GetSim TPC", e);
1439 std::vector<const sdp::CaloDeposit*> tempCalo;
1445 for(
size_t t = 0;
t < tempCalo.size(); ++
t)
1446 simCalo.push_back(tempCalo[
t]);
1450 writeErrMsg(
"GetSim Calo", e);
1458 std::vector<const raw::CaloRawDigit*> tempCalo;
1464 for(
size_t t = 0;
t < tempCalo.size(); ++
t)
1465 digitCalo.push_back(tempCalo[
t]);
1469 writeErrMsg(
"GetDigits Calo", e);
1477 std::vector<const rec::CaloHit*> tempCalo;
1482 for(
size_t t = 0;
t < tempCalo.size(); ++
t)
1483 recoCalo.push_back(tempCalo[
t]);
1486 writeErrMsg(
"GetHits Calo", e);
1494 std::vector<const rec::CaloHit*> tempMuID;
1499 for(
size_t t = 0;
t < tempMuID.size(); ++
t)
1500 recoMuID.push_back(tempMuID[
t]);
1503 writeErrMsg(
"GetHits MuID", e);
1510 caloCluster.clear();
1512 std::vector<const gar::rec::Cluster*>
temp;
1516 for(
size_t t = 0;
t < temp.size(); ++
t){
1517 caloCluster.push_back(temp[
t]);
1521 writeErrMsg(
"GetCaloClusters", e);
1534 writeErrMsg(
"GetTracks", e);
1545 std::vector<const gar::rec::Vertex*>
temp;
1549 for(
size_t t = 0;
t < temp.size(); ++
t){
1550 vertex.push_back(temp[
t]);
1554 writeErrMsg(
"GetVertices", e);
1567 std::vector<const simb::MCTruth*>
temp;
1571 auto mctcol =
event.getMany<std::vector<simb::MCTruth> >();
1572 for(
size_t mctc = 0; mctc < mctcol.size(); ++mctc)
1575 for(
size_t i = 0; i < mclistHandle->size(); ++i)
1576 temp.push_back(&(mclistHandle->at(i)));
1582 writeErrMsg(
"GetMCTruth", e);
1595 std::vector<const simb::MCParticle*>
temp;
1601 for(
unsigned int i = 0; i < plcol.
vals().size(); ++i)
1602 temp.push_back(plcol.
vals().at(i));
1607 writeErrMsg(
"GetParticle", e);
1616 unsigned long long int tsval =
event.time().value();
1617 int run =
event.run();
1618 int srun =
event.subRun();
1621 unsigned int year, month, day, dayofweek;
1622 unsigned int hour, minute,
second;
1625 const unsigned long int mask32 = 0xFFFFFFFFUL;
1626 unsigned long int lup = ( tsval >> 32 ) & mask32;
1627 unsigned long int llo = tsval & mask32;
1628 TTimeStamp ts(lup, (
int)llo);
1630 ts.GetDate(kTRUE,0,&year,&month,&day);
1631 ts.GetTime(kTRUE,0,&hour,&minute,&second);
1632 nano = ts.GetNanoSec();
1633 dayofweek = ts.GetDayOfWeek();
1634 char eventbuff[256];
1640 static const char* days[] = {
"",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun"};
1641 static const char* months[] = {
"",
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
1643 sprintf(runbuff,
"Run: %d/%d\n", run, srun);
1644 sprintf(eventbuff,
"Event: %d\n", evt);
1645 sprintf(datebuff,
"UTC %s %s %u, %u\n", days[dayofweek], months[month], day, year);
1646 sprintf(timebuff,
"%.2u:%.2u:%2.9f\n", hour, minute, (
float)second+(
float)nano/1.0E9);
1649 char annotation[2560];
1650 sprintf(annotation,
"DUNE ND HPgTPC\n%s%s%s%s", runbuff, eventbuff, datebuff, timebuff);
1651 ann->SetText(annotation);
1652 ann->SetRole(TGLOverlayElement::kViewer);
1653 ann->SetUseColorSet(
true);
1654 ann->SetTextSize(0.04);
1655 ann->SetTextAlign(TGLFont::kLeft);
1656 ann->SetAllowClose(
false);
1657 ann->SetTextColor(kBlack);
double E(const int i=0) const
float const & Momentum_beg() const
std::vector< std::string > fSimHitLabels
module labels that produced sim hits
double Z(const size_type i) const
double X(const size_type i) const
std::vector< std::string > fCaloClusterLabels
module labels that produced Calorimeter Clusters
std::vector< std::string > fRawHitLabels
module labels that produced raw hits
std::unique_ptr< evd3d::EventDisplay3DUtils > fEvtDisplayUtil
float Y() const
Y position.
double Py(const int i=0) const
std::pair< unsigned int, unsigned int > ADC() const
Reference to the compressed ADC count vector.
void DrawTrack(const gar::rec::Track *trk, TEveElementList *&eve_list, int counter, bool forward)
TEveElementList * fMCTrajectoryList
const float * TrackParBeg() const
raw::CellID_t CellID() const
std::vector< std::string > fVolumesToShow
list of volumes to show in the Eve display
const simb::MCTrajectory & Trajectory() const
gar::geo::BitFieldCoder * fFieldDecoder
float const & Energy() const
bool PointInGArTPC(TVector3 const &point) const
float X() const
X position.
double Px(const int i=0) const
TEveElementList * fCaloRawHitList
void GetVertices(std::vector< const rec::Vertex * > &vertex, const art::Event &event)
std::vector< TGeoNode const * > FindVolumePath(std::string const &vol_name) const
Returns all the nodes with volumes with any of the specified names.
Description of geometry of one entire detector.
EDAnalyzer(fhicl::ParameterSet const &pset)
void beginRun(const art::Run &run) override
void DrawHelix3D(const float *trackpar, const float xpar, const float xother, TEveLine *&eve_track, int color)
TEveElementList * fTPCClusterList
const float * VtxDir() const
std::vector< std::string > fRecoECALHitLabels
module labels that produced reco hits ecal
float const & Energy() const
TGeoManager * fGeoManager
std::vector< std::string > fTrackLabels
module labels that produced tracks
bool isTile(const std::array< double, 3 > &point, const gar::raw::CellID_t &cID) const
void GetRecoCaloHits(std::vector< const rec::CaloHit * > &recoCalo, const art::Event &event)
void GetMCTruth(std::vector< const simb::MCTruth * > &mcvec, const art::Event &event)
const gar::detinfo::DetectorProperties * fDetProp
const gar::geo::GeometryCore * fGeometry
std::vector< std::string > fInstanceName
const float * Vertex() const
double Y(const size_type i) const
#define DEFINE_ART_MODULE(klass)
void GetRawCaloHits(std::vector< const raw::CaloRawDigit * > &digitCalo, const art::Event &event)
const gar::detinfo::DetectorClocks * fTime
CellID_t CellID() const
cellID
Helper class for decoding and encoding a bit field of 64bits for convenient declaration.
EventDisplay3D(fhicl::ParameterSet const &pset)
void DrawHighLevelReco(const art::Event &event)
void DrawIntersections(const gar::rec::Track *trk, TEveElementList *&fTrackList, int counter)
T get(std::string const &key) const
static int ColorFromPDG(int pdgcode)
void DrawRecoHits(const art::Event &event)
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
static int PropagateToX(const float *trackpar, const float *Xpoint, const float x, float *retXYZ, const float Rmax=0.0)
void GetCaloClusters(std::vector< const rec::Cluster * > &caloCluster, const art::Event &event)
void GetParticle(std::vector< const simb::MCParticle * > &plist, const art::Event &event)
const float * TrackParEnd() const
float TPCZCent() const
Returns the Z location of the center of the TPC in cm.
const fhicl::ParameterSet fParamSet
static int PropagateToCylinder(const float *trackpar, const float *Xpoint, const float rCyl, const float yCyl, const float zCyl, float *retXYZ1, float *retXYZ2, const float Xmax=0.0, const float epsilon=2.0e-5)
void DrawArrow3D(const float *fVertex, const float *fDir, int color, TEveArrow *&arrow)
Definition of basic calo raw digits.
const float * EigenVectors() const
TEveElementList * fCaloMuIDHitList
raw::CellID_t const & CellID() const
const float * End() const
TEveElementList * fVertexList
const float * Position() const
float GetECALEndcapStartX() const
Interface to propagate a Track to the specific point.
const float * Position() const
void DrawRawHits(const art::Event &event)
void DrawTrackPolyLine3D(std::vector< const gar::rec::TrackTrajectory * > const &trajectories, TEveElementList *&eve_list, int counter)
float GetECALOuterBarrelRadius() const
void reconfigure(fhicl::ParameterSet const &pset)
std::size_t color(std::string const &procname)
TEveElementList * fCaloRecoHitList
void DrawMCTPCTruth(const art::Event &event)
General GArSoft Utilities.
double Vx(const int i=0) const
std::string fG4Label
module label that produced G4 hits
long64 get(long64 bitfield, size_t index) const
const float * Position() const
void UpdateHeader(const art::Event &event)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
auto size() const noexcept
auto isValid() const noexcept
float TPCYCent() const
Returns the Y location of the center of the TPC in cm.
void DrawMCCaloTruth(const art::Event &event)
std::vector< std::string > fVertexLabels
module labels that produced vertices
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
bool HasMuonDetector() const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
const std::string GetECALCellIDEncoding() const
void DrawMCTruth(const art::Event &event)
double Pz(const int i=0) const
virtual ~EventDisplay3D()
double Vz(const int i=0) const
void GetSimTPCHits(std::vector< const sdp::EnergyDeposit * > &simTPC, const art::Event &event)
float const & Momentum_end() const
float GetECALInnerBarrelRadius() const
void analyze(const art::Event &event) override
void DrawTPCCluster3D(std::vector< const gar::rec::TPCCluster * > const &TPCClusters, TEveElementList *&eve_list)
void GetSimCaloHits(std::vector< const sdp::CaloDeposit * > &simCalo, const art::Event &event)
second_as<> second
Type of time stored in seconds, in double precision.
TEveElementList * fTrackList
art framework interface to geometry description
const float * Shape() const
float Z() const
Z position.
TEveElementList * fCaloSimHitList
static const int kColor[kNCOLS]
double Vy(const int i=0) const
void GetTracks(art::View< gar::rec::Track > &track, const art::Event &event)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Event finding and building.
void GetRecoMuIDHits(std::vector< const rec::CaloHit * > &recoMuID, const art::Event &event)
TEveElementList * fCaloClusterList
std::vector< std::string > fRecoMuIDHitLabels
module labels that produced reco hits muid
const float * EndDir() const
TEveElementList * fTPCSimHitList
void PickVolumes(TEveElementList *&list)