1 #include "TEveBrowser.h"
10 #include "application/Application.h"
11 #include "application/gui/MainWindow.h"
13 const int MainWindow::_defWidth = 1280;
14 const int MainWindow::_defHeight = 800;
15 const Option_t *MainWindow::_defOpt =
"IV";
17 MainWindow::MainWindow(UInt_t w, UInt_t h) : TEveManager(w, h, kTRUE, _defOpt) {
22 GetMainWindow()->SetWindowName(
"GGSLeonard");
24 _DEBUGPointSet =
new TEvePointSet(
"DEBUG Volume position");
25 _DEBUGPointSet->SetMainColor(kRed);
27 _MCTruthList =
new TEveElementList(
"MC Truth");
28 _MCTruthShortInfo =
new TGLAnnotation(GetDefaultGLViewer(),
"", 0.01, 0.99);
29 _MCTruthShortInfo->SetTextSize(0.03);
31 AddElement(_MCTruthList);
33 AddElement(_DEBUGPointSet);
38 void MainWindow::CreateMaps() {
39 static const std::string routineName(
"MainWindow::CreateMaps");
43 for (TString _det : thisApp->GetFileManager()->GetDetList()) {
44 COUT(DEBUG) <<
"Det is " << _det <<
ENDL;
46 if (_DetectorHitMap.find(_det.Data()) == _DetectorHitMap.end()) {
47 COUT(DEBUG) <<
" DetectorHit not found, creating one... " <<
ENDL;
49 _dhit->SetDisplayType(DetectorHit::kColorCodedHit);
50 _DetectorHitMap.insert(std::make_pair(_det.Data(), std::move(_dhit)));
51 AddElement(_DetectorHitMap[_det.Data()]->GetTEveElementList());
53 COUT(DEBUG) <<
" DetectorHit already there, passing on... " <<
ENDL;
57 GenerateHashTable(thisApp->GetGeoManager()->GetEveGeoTopNode());
59 for (TString _det : thisApp->GetFileManager()->GetDetList()) {
60 auto thisTEveGeoShapeMapPtr = _DetectorHitMap.find(_det.Data())->second->GetTEveGeoShapeMap();
61 COUT(DEBUG) <<
"map for detector " << _det <<
" has " << thisTEveGeoShapeMapPtr->size() <<
" entries "
62 << thisTEveGeoShapeMapPtr <<
ENDL;
67 gEve->GetBrowser()->SetTab(0, 1);
70 void MainWindow::GenerateHashTable(TEveGeoNode *node) {
71 static const std::string routineName(
"MainWindow::GenerateHashTable");
73 static std::vector<std::string> pathLevels;
76 std::pair<UOMIterator, bool> mapResult;
77 std::string nodeName = node->GetElementName();
78 pathLevels.push_back(nodeName);
79 std::string path =
"", dpath =
"";
80 for (
size_t il = 0; il < pathLevels.size(); il++)
81 path.append(pathLevels[il] +
"/");
82 for (
size_t il = 0; il < pathLevels.size(); il++)
83 dpath.append(pathLevels[il] +
".");
89 std::unordered_map<std::string, TEveGeoShape *> *theMap;
90 bool foundMap =
false;
91 for (TString _det : thisApp->GetFileManager()->GetDetList()) {
92 std::string volName = node->GetNode()->GetVolume()->GetName();
94 if (volName.size() == 7 && volName[4] ==
'H' && (volName[5] ==
'1' || volName[5] ==
'2' || volName[5] ==
'4') &&
96 volName = volName.substr(0, 4);
97 if (volName == _det.Data()) {
98 auto _dhitIter = _DetectorHitMap.find(_det.Data());
99 if (_dhitIter == _DetectorHitMap.end()) {
100 COUT(DEBUG) <<
"Could not find map for detector " << _det <<
ENDL;
103 theMap = _dhitIter->second->GetTEveGeoShapeMap();
110 theMap = &_TEveGeoShapeMap_World;
113 if (!gGeoManager->cd(path.data())) {
114 COUT(WARNING) <<
"Node " << path <<
" not found" <<
ENDL;
118 TString lvlString =
"";
119 for (
int is = 0; is < level; is++)
122 _TEveGeoNodeMap.insert(std::make_pair(dpath, node));
126 TEveGeoShape *shape =
new TEveGeoShape(nodeName.data(), path.data());
127 shape->RefMainTrans().SetFrom(*gGeoManager->GetCurrentMatrix());
128 shape->SetShape((TGeoShape *)gGeoManager->GetCurrentVolume()->GetShape()->Clone());
130 mapResult = (*theMap).insert(make_pair(dpath, shape));
131 if (mapResult.second ==
false) {
132 COUT(DEBUG) << lvlString <<
" Could not insert node " << dpath <<
" with value " << shape <<
" into map " << theMap
139 if (node->NumChildren() > 0) {
140 TEveElementList::List_i iter;
141 for (iter = node->BeginChildren(); iter != node->EndChildren(); iter++) {
143 GenerateHashTable((TEveGeoNode *)*iter);
148 pathLevels.pop_back();
151 void MainWindow::MakeTransparentScene(
int transp) {
152 static const std::string routineName(
"MainWindow::MakeTransparentScene");
154 COUT(DEBUG) <<
"Setting scene transparency to " << transp <<
ENDL;
158 for (std::pair<std::string, TEveGeoNode *> element : _TEveGeoNodeMap) {
159 node = element.second;
160 node->SetMainTransparency(transp);
163 GetGlobalScene()->Changed();
164 GetGlobalScene()->Repaint();
167 void MainWindow::LoadEvent() {
168 static const std::string routineName(
"MainWindow::LoadEvent");
172 _MCTruthList->RemoveElements();
175 gStyle->SetPalette(kRainBow);
176 COUT(DEBUG) << gStyle->GetNumberOfColors() <<
ENDL;
177 COUT(DEBUG) << gStyle->GetColorPalette(0) <<
ENDL;
179 MakeTransparentScene(95);
183 _DEBUGPointSet->Reset();
185 SetMCTruth(thisApp->GetFileManager()->GetMCTruthReader());
187 for (TString _det : thisApp->GetFileManager()->GetDetList()) {
188 _DetectorHitMap[_det.Data()]->GetTEveElementList()->RemoveElements();
189 SetDetectorHits(_det, thisApp->GetFileManager()->GetHitsReader());
192 gEve->FullRedraw3D();
195 void MainWindow::SetEventNumber(UInt_t evt) {
196 static const std::string routineName(
"MainWindow::SetEventNumber");
200 _evField->SetIntNumber(evt);
201 _evFileText->ChangeText(Form(
" of %i", (
int)thisApp->GetFileManager()->
GetEntries()));
202 _evNumbersFrame->Layout();
203 _progressBar->SetPosition(evt);
206 void MainWindow::UpdateFileEntries() {
209 _progressBar->SetRange(0, (
int)thisApp->GetFileManager()->
GetEntries());
212 void MainWindow::SetFileName(TString filename) { _fileField->SetText(filename.Data(), kFALSE); }
214 void MainWindow::SetDisplayDetector(TString det, Bool_t s) {
215 static const std::string routineName(
"MainWindow::SetDisplayDetector");
217 COUT(DEBUG) <<
"Called with det=" << det <<
ENDL;
218 _DetectorHitMap[det.Data()]->GetTEveElementList()->SetRnrState(s);
222 void MainWindow::SetDetectorHitType(TString det, DetectorHit::hitType type) {
223 _DetectorHitMap[det.Data()]->SetDisplayType(type);
228 void MainWindow::SetDetectorHitThreshold(TString det, Float_t thr) {
229 _DetectorHitMap[det.Data()]->SetThreshold(thr);
234 void MainWindow::SetDetectorHitColor(TString det, Color_t col) {
235 _DetectorHitMap[det.Data()]->SetColor(col);
240 void MainWindow::SetDisplayPartHits(Bool_t s) {
241 _MCPartHitList->SetRnrState(s);
#define COUT(level)
Smart log macro. It writes on stdout only if the specified verbosity level is lesser than the maximum...
Long64_t GetEntries()
The total number of events.