18 #include <phgeom/PHGeomUtility.h>
21 #include "TEveManager.h"
22 #include "TEveVSDStructs.h"
23 #include "TEveGeoNode.h"
24 #include "TEveVector.h"
25 #include "TEveTrack.h"
26 #include "TEveTrackPropagator.h"
27 #include "TEvePointSet.h"
28 #include "TEveWindowManager.h"
29 #include "TEveWindow.h"
30 #include "TEveViewer.h"
31 #include "TEveBrowser.h"
33 #include "TGeoManager.h"
35 #include "TGeoVolume.h"
36 #include "TGeoMedium.h"
38 #include "TGLViewer.h"
46 #include <phfield/PHField.h>
49 using namespace CLHEP;
55 const std::string& mapname,
56 const std::string& filename,
68 _use_fieldmap(use_fieldmap),
69 _use_geofile(use_geofile),
70 _jet_pt_threshold(5.0),
71 _calo_e_threshold(0.2),
72 map_filename(mapname),
73 geo_filename(filename),
76 if (
verbosity) std::cout <<
"PHEveDisplay initialized. " << std::endl;
80 se->
Print(
"NODETREE");}
87 TEveManager::Terminate();
88 }
catch (std::exception &e) {
89 std::cout <<
"Exception caught during deconstruction: " << e.what() << std::endl;
96 TFile* geom =
new TFile();
100 throw std::runtime_error(
"Could not open sphenix_geo.root geometry file, aborting.");
105 std::cout <<
"PHEveDisplay::load_geometry:" <<
" Using PHGeomUtility for Geometry" << std::endl;
111 gStyle->SetPalette(1);
112 TGeoVolume* top = gGeoManager->GetTopVolume();
113 const int nd = top->GetNdaughters();
114 std::cout <<
"nd= " << nd << std::endl;
117 for (
int i = 0; i < nd; i++) {
118 node[i] = top->GetNode(i);
119 std::cout <<
"Node " << i <<
" : " << node[i]->GetName() << std::endl;
121 node[i]->GetVolume()->SetTransparency(95);
123 std::string name(node[i]->GetName());
124 if (name.find(
"fmag") < 5 || name.find(
"kmag") < 5) {
125 TGeoVolume* subvol = node[i]->GetVolume();
126 const int nsub = subvol->GetNdaughters();
127 TGeoNode* subnod[nsub];
128 for (
int j = 0; j < nsub; j++) {
129 subnod[j] = subvol->GetNode(j);
130 subnod[j]->GetVolume()->SetTransparency(100);
135 TGeoNode *node_c = gGeoManager->GetCurrentNode();
136 TEveGeoTopNode* tnode_c =
new TEveGeoTopNode(gGeoManager, node_c);
137 gEve->AddGlobalElement(tnode_c);
151 _dc_list =
new TEveElementList(
"DC");
154 _dp_list =
new TEveElementList(
"DP");
170 std::cout <<
"PHEveDisplay::config_bfields:" <<
" Field from file deprecated!!" << std::endl;
173 std::cout <<
"PHEveDisplay::config_bfields:" <<
" Using PHField fields for track propagation" << std::endl;
174 cnt_prop =
new TEveTrackPropagator(
"cnt_prop",
"Current Propagator",
new MappedField(field));
178 cnt_prop->SetStepper(TEveTrackPropagator::kRungeKutta);
186 TEveViewer* cur_win = geve->GetDefaultViewer();
187 TEveCompositeFrame* fEveFrame = cur_win->GetEveFrame();
188 TEveWindow* return_cont = fEveFrame->GetEveParentAsWindow();
190 if (return_cont && ! return_cont->CanMakeNewSlots())
193 TEveCompositeFrameInPack* packframe =
dynamic_cast<TEveCompositeFrameInPack*
>(fEveFrame);
195 TGPack* pack = (TGPack*)(packframe->GetParent());
196 pack->HideFrame(fEveFrame);
199 TGMainFrame* mf =
new TGMainFrame(gClient->GetRoot(),
_width,
_height);
200 gVirtualX->SetMWMHints(mf->GetId(),0,0,0);
201 mf->SetCleanup(kLocalCleanup);
203 TEveCompositeFrameInMainFrame *slot =
new TEveCompositeFrameInMainFrame(mf, 0, mf);
204 TEveWindowSlot* ew_slot = TEveWindow::CreateDefaultWindowSlot();
205 ew_slot->PopulateEmptyFrame(slot);
207 mf->AddFrame(slot,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
213 TEveWindow::SwapWindows(ew_slot, cur_win);
215 ((TEveCompositeFrameInMainFrame*) fEveFrame)->
216 SetOriginalSlotAndContainer(ew_slot, return_cont);
218 geve->GetWindowManager()->HideAllEveDecorations();
219 geve->GetWindowManager()->WindowUndocked(cur_win);
223 gVirtualX->MoveResizeWindow(mf->GetId(), 0, offset,
_width,
_height);
237 loc[0]=x*cm; loc[1]=y*cm; loc[2]=z*cm; loc[3]=0;
240 _fieldmap->GetFieldValue(loc, bvec);
241 const double unit = tesla;
TEveElementList * _prop_list
TEveElementList * _true_list
TEveElementList * _hodo_list
void load_geometry(PHCompositeNode *topNode, TEveManager *geve)
virtual void Print(const std::string &what="ALL") const
MappedField(const PHField *field)
static Fun4AllServer * instance()
TEveElementList * _dc_list
transient DST object for field storage and access
void config_bfields(const PHField *field)
TEveElementList * _top_list
TEveTrackPropagator * cnt_prop
TEveElementList * _dp_list
virtual TEveVectorD GetFieldD(Double_t x, Double_t y, Double_t z) const
static TGeoManager * GetTGeoManager(PHCompositeNode *topNode)
Main user interface: DST node -> TGeoManager for downstream use.
PHEveDisplay(int w, int h, bool use_fieldmap, bool use_goefile, const std::string &mapname, const std::string &filename, int verb)
void add_elements(TEveManager *geve)
void go_fullscreen(TEveManager *geve)