4 #include "TEveBrowser.h"
10 #include "application/gui/MainWindow.h"
11 #include "application/Application.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);
40 void MainWindow::CreateMaps(){
41 static const std::string routineName(
"MainWindow::CreateMaps");
45 for( TString _det : thisApp->GetFileManager()->GetDetList() ){
46 COUT(DEBUG) <<
"Det is " << _det <<
ENDL;
48 if( _DetectorHitMap.find(_det.Data()) == _DetectorHitMap.end() ){
49 COUT(DEBUG) <<
" DetectorHit not found, creating one... " <<
ENDL;
51 _dhit->SetDisplayType(DetectorHit::kColorCodedHit);
52 _DetectorHitMap.insert( std::make_pair(_det.Data(), std::move(_dhit)) );
53 AddElement( _DetectorHitMap[_det.Data()]->GetTEveElementList() );
55 COUT(DEBUG) <<
" DetectorHit already there, passing on... " <<
ENDL;
60 GenerateHashTable( thisApp->GetGeoManager()->GetEveGeoTopNode() );
62 for( TString _det : thisApp->GetFileManager()->GetDetList() ){
63 auto thisTEveGeoShapeMapPtr = _DetectorHitMap.find(_det.Data())->second->GetTEveGeoShapeMap();
64 COUT(DEBUG) <<
"map for detector " << _det <<
" has " << thisTEveGeoShapeMapPtr->size() <<
" entries " << thisTEveGeoShapeMapPtr <<
ENDL;
69 gEve->GetBrowser()->SetTab(0, 1);
73 void MainWindow::GenerateHashTable(TEveGeoNode* node){
74 static const std::string routineName(
"MainWindow::GenerateHashTable");
76 static std::vector<std::string> pathLevels;
79 std::pair<UOMIterator, bool> mapResult;
80 std::string nodeName = node->GetElementName();
81 pathLevels.push_back( nodeName );
82 std::string path =
"", dpath =
"";
83 for(
size_t il=0; il<pathLevels.size(); il++) path.append(pathLevels[il] +
"/");
84 for(
size_t il=0; il<pathLevels.size(); il++) dpath.append(pathLevels[il] +
".");
90 std::unordered_map<std::string, TEveGeoShape*>* theMap;
91 bool foundMap =
false;
92 for( TString _det : thisApp->GetFileManager()->GetDetList() ){
93 std::string volName = node->GetNode()->GetVolume()->GetName();
95 if (volName.size() == 7 && volName[4] ==
'H' && (volName[5] ==
'1' || volName[5] ==
'2' || volName[5] ==
'4') && volName[6] ==
'E')
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++) lvlString +=
"-";
121 _TEveGeoNodeMap.insert( std::make_pair(dpath, node) );
124 TEveGeoShape* shape =
new TEveGeoShape(nodeName.data(), path.data());
125 shape->RefMainTrans().SetFrom(*gGeoManager->GetCurrentMatrix());
126 shape->SetShape((TGeoShape*) gGeoManager->GetCurrentVolume()->GetShape()->Clone());
128 mapResult = (*theMap).insert( make_pair(dpath, shape) );
129 if( mapResult.second ==
false ){
130 COUT(DEBUG) << lvlString <<
" Could not insert node " << dpath <<
" with value " << shape <<
" into map " << theMap <<
ENDL;
135 if( node->NumChildren() > 0 ){
136 TEveElementList::List_i iter;
137 for( iter = node->BeginChildren(); iter != node->EndChildren(); iter++ ){
139 GenerateHashTable( (TEveGeoNode*) *iter );
144 pathLevels.pop_back();
148 void MainWindow::MakeTransparentScene(
int transp){
149 static const std::string routineName(
"MainWindow::MakeTransparentScene");
151 COUT(DEBUG) <<
"Setting scene transparency to " << transp <<
ENDL;
155 for( std::pair<std::string, TEveGeoNode*> element : _TEveGeoNodeMap ){
156 node = element.second;
157 node->SetMainTransparency( transp );
160 GetGlobalScene()->Changed();
161 GetGlobalScene()->Repaint();
166 void MainWindow::LoadEvent(){
167 static const std::string routineName(
"MainWindow::LoadEvent");
171 _MCTruthList->RemoveElements();
174 gStyle->SetPalette(kRainBow);
175 COUT(DEBUG) << gStyle->GetNumberOfColors() <<
ENDL;
176 COUT(DEBUG) << gStyle->GetColorPalette(0) <<
ENDL;
178 MakeTransparentScene(95);
182 _DEBUGPointSet->Reset();
184 SetMCTruth( thisApp->GetFileManager()->GetMCTruthReader() );
186 for( TString _det : thisApp->GetFileManager()->GetDetList() ){
187 _DetectorHitMap[_det.Data()]->GetTEveElementList()->RemoveElements();
188 SetDetectorHits( _det, thisApp->GetFileManager()->GetHitsReader() );
191 gEve->FullRedraw3D();
196 void MainWindow::SetEventNumber(UInt_t evt){
197 static const std::string routineName(
"MainWindow::SetEventNumber");
201 _evField->SetIntNumber( evt );
202 _evFileText->ChangeText(Form(
" of %i", (
int) thisApp->GetFileManager()->
GetEntries()));
203 _evNumbersFrame->Layout();
204 _progressBar->SetPosition( evt );
208 void MainWindow::UpdateFileEntries(){
211 _progressBar->SetRange(0, (
int) thisApp->GetFileManager()->
GetEntries());
214 void MainWindow::SetFileName(TString filename){
216 _fileField->SetText( filename.Data(), kFALSE );
220 void MainWindow::SetDisplayDetector(TString det, Bool_t s){
221 static const std::string routineName(
"MainWindow::SetDisplayDetector");
223 COUT(DEBUG) <<
"Called with det=" << det <<
ENDL;
224 _DetectorHitMap[det.Data()]->GetTEveElementList()->SetRnrState(s);
228 void MainWindow::SetDetectorHitType(TString det, DetectorHit::hitType type){
229 _DetectorHitMap[det.Data()]->SetDisplayType(type);
234 void MainWindow::SetDetectorHitThreshold(TString det, Float_t thr){
235 _DetectorHitMap[det.Data()]->SetThreshold(thr);
240 void MainWindow::SetDetectorHitColor(TString det, Color_t col){
241 _DetectorHitMap[det.Data()]->SetColor(col);
246 void MainWindow::SetDisplayPartHits(Bool_t s){
247 _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.