19#include "EventDisplay.hh"
27#include "TEveManager.h"
28#include "TGeoManager.h"
29#include "TEveGeoNode.h"
30#include "TEvePointSet.h"
31#include "TEveBoxSet.h"
34#include "TEveEventManager.h"
36#include "BDSOutputROOTEventLoss.hh"
37#include "BDSOutputROOTEventModel.hh"
38#include "BDSOutputROOTEventOptions.hh"
39#include "BDSOutputROOTEventTrajectory.hh"
52 {std::cout <<
"EventDisplay> WARNING - no file supplied" << std::endl;}
64 TString dataFileNameIn):
65 geoFileName(geoFileNameIn),
66 dataFileName(dataFileNameIn)
68 std::cout <<
"EventDisplay::EventDisplay(" << geoFileName <<
")" << std::endl;
69 TEveManager::Create();
70 dataLoader =
new DataLoader(std::string(dataFileName.Data()));
86EventDisplay::~EventDisplay()
94 std::cout <<
"EventDisplay::LoadGeometry>" << std::endl;
95 TFile::SetCacheFileDir(
".");
96 std::cout << geoFileName.Data() << std::endl;
97 gGeoManager = gEve->GetGeometry(geoFileName.Data());
98 gGeoManager->DefaultColors();
100 TEveGeoTopNode* tn =
new TEveGeoTopNode(gGeoManager, gGeoManager->GetTopNode());
101 gEve->AddGlobalElement(tn);
102 gEve->FullRedraw3D(kTRUE);
107 std::cout <<
"EventDisplay::LoadModel>" << std::endl;
108 modelTree->GetEntry(iMod);
113 std::cout <<
"EventDisplay::LoadOptions>" << std::endl;
114 optionsTree->GetEntry(iOpt);
119 std::cout <<
"EventDisplay::LoadData>" << std::endl;
120 eventTree->GetEntry(i);
125 std::cout <<
"EventDisplay::ClearEvent>" << std::endl;
126 gEve->GetCurrentEvent()->DestroyElements();
140 std::cout <<
"EventDisplay::DrawModel>" << std::endl;
142 std::cout <<
"EventDisplay::DrawModel> horizontalWidth " << ob->horizontalWidth << std::endl;
143 double horizontalWidth = ob->horizontalWidth;
146 TEveBoxSet* bs =
new TEveBoxSet(
"model");
147 bs->Reset(TEveBoxSet::kBT_FreeBox, kFALSE,64);
151 for(
auto mp : model->
model->midPos)
153 double modelLength = model->
model->length[i];
154 TRotation modelRotation = model->
model->midRot[i];
157 TVector3 v1 = 100*(mp + modelRotation*TVector3(-horizontalWidth / 2, -horizontalWidth / 2, -modelLength / 2));
158 TVector3 v2 = 100*(mp + modelRotation*TVector3(-horizontalWidth / 2, horizontalWidth / 2, -modelLength / 2));
159 TVector3 v3 = 100*(mp + modelRotation*TVector3( horizontalWidth / 2, horizontalWidth / 2, -modelLength / 2));
160 TVector3 v4 = 100*(mp + modelRotation*TVector3( horizontalWidth / 2, -horizontalWidth / 2, -modelLength / 2));
162 TVector3 v5 = 100*(mp + modelRotation*TVector3(-horizontalWidth / 2, -horizontalWidth / 2, modelLength / 2));
163 TVector3 v6 = 100*(mp + modelRotation*TVector3(-horizontalWidth / 2, horizontalWidth / 2, modelLength / 2));
164 TVector3 v7 = 100*(mp + modelRotation*TVector3( horizontalWidth / 2, horizontalWidth / 2, modelLength / 2));
165 TVector3 v8 = 100*(mp + modelRotation*TVector3( horizontalWidth / 2, -horizontalWidth / 2, modelLength / 2));
168 vert[0] = (float) v1.x();
169 vert[1] = (float) v1.y();
170 vert[2] = (float) v1.z();
172 vert[3] = (float) v2.x();
173 vert[4] = (float) v2.y();
174 vert[5] = (float) v2.z();
176 vert[6] = (float) v3.x();
177 vert[7] = (float) v3.y();
178 vert[8] = (float) v3.z();
180 vert[9] = (float) v4.x();
181 vert[10] = (float) v4.y();
182 vert[11] = (float) v4.z();
184 vert[12] = (float) v5.x();
185 vert[13] = (float) v5.y();
186 vert[14] = (float) v5.z();
188 vert[15] = (float) v6.x();
189 vert[16] = (float) v6.y();
190 vert[17] = (float) v6.z();
192 vert[18] = (float) v7.x();
193 vert[19] = (float) v7.y();
194 vert[20] = (float) v7.z();
196 vert[21] = (float) v8.x();
197 vert[22] = (float) v8.y();
198 vert[23] = (float) v8.z();
203 bs->SetMainColor(kWhite);
204 bs->SetRenderMode(TEveBoxSet::kRM_Line);
205 gEve->AddElement(bs);
211 std::cout <<
"EventDisplay::DrawElossHits>" << std::endl;
212 TEvePointSet* ps =
new TEvePointSet(
"Eloss");
213 for(
int i=0;i<(int)event->
Eloss->X.size();++i)
215 ps->SetNextPoint(event->
Eloss->X[i]*100.0,
216 event->
Eloss->Y[i]*100.0,
217 event->
Eloss->Z[i]*100.0);
219 ps->SetMainColor(kWhite);
220 gEve->AddElement(ps);
226 std::cout <<
"EventDisplay::DrawTunnelHits>" << std::endl;
228 TEveBoxSet* bs =
new TEveBoxSet(
"TunnelHits");
229 bs->Reset(TEveBoxSet::kBT_AABox, kFALSE,64);
231 for(
int i=0;i<(int)event->
TunnelHit->X.size();++i)
242 bs->SetMainColor(kWhite);
243 gEve->AddElement(bs);
249 std::cout <<
"EventDisplay::DrawSamplers>" << std::endl;
254 TEvePointSet* ps =
new TEvePointSet((std::string(
"Sampler_")+sampler->samplerName.c_str()).c_str());
257 TVector3 mpos = model->
model->endPos[sampler->modelID];
258 TRotation mrot = model->
model->endRot[sampler->modelID];
261 for(
int i=0;i<sampler->n;++i)
263 TVector3 v = mpos + mrot*TVector3(sampler->x[i],sampler->y[i],0);
264 ps->SetNextPoint(v.x()*100.0,
269 ps->SetMainColor(kBlue);
270 gEve->AddElement(ps);
277 std::cout <<
"EventDisplay::DrawTrajectories>" << std::endl;
278 std::cout <<
"EventDisplay::DrawTrajectories> ntraj=" <<
event->Trajectory->XYZ.size() << std::endl;
283 std::string trajNameAppend = std::string();
285 {trajNameAppend =
"_primary";}
287 {trajNameAppend =
"_"+std::to_string(event->
Trajectory->trackID[iTraj]);}
289 TEveLine* et =
new TEveLine((std::string(
"Trajectory")+trajNameAppend).c_str());
294 et->SetNextPoint(tp.x()*100,
298 et->SetMainColor(kWhite);
299 gEve->AddElement(et);
std::vector< float > energy
Energy deposited in step.
Class to store all options for a BDSIM run.
Loader for a ROOT file using classes used to generate the file.
Event * GetEvent()
Accessor.
TChain * GetOptionsTree()
Accessor.
TChain * GetModelTree()
Accessor.
Options * GetOptions()
Accessor.
TChain * GetEventTree()
Accessor.
Model * GetModel()
Accessor.
Event viewer using ROOT EVE framework.
EventDisplay()
Private default constructor as singleton pattern.
void LoadData(int iEvt)
Load an entry in the event tree.
void DrawModel()
Draw the geometry.
static EventDisplay * Instance()
Singleton accessor.
void LoadGeometry()
Load the geometry from gdml file.
void DrawTrajectories()
Draw loaded trajectories.
void LoadModel(int iMod)
Load an entry from the model tree.
void ClearEvent()
Clear a currently displayed event.
void DrawSamplers()
Draw hits on a sampler plane.
void LoadOptions(int iOpt)
Load an entry from the options tree.
void DrawElossHits()
Draw energy loss deposits.
static EventDisplay * instance
Singleton instance.
void Draw()
Draw all things loaded at this point.
void DrawTunnelHits()
Draw tunnel energy deposits.
BDSOutputROOTEventLoss * TunnelHit
Local variable ROOT data is mapped to.
BDSOutputROOTEventTrajectory * Trajectory
Local variable ROOT data is mapped to.
std::vector< BDSOutputROOTEventSampler< double > * > Samplers
Local variable ROOT data is mapped to.
BDSOutputROOTEventLoss * Eloss
Local variable ROOT data is mapped to.
BDSOutputROOTEventModel * model
Member that ROOT can map file data to locally.
BDSOutputROOTEventOptions * options
Member that ROOT can map file data to locally.