Skip to content

Commit

Permalink
Merge branch 'master' into fixFabs
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusFrankATcernch authored Nov 24, 2023
2 parents 05cf409 + 04bb629 commit 7b7813a
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 30 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SET_PROPERTY(DIRECTORY . PROPERTY PACKAGE_NAME DD4hep)

SET( DD4hep_VERSION_MAJOR 1 )
SET( DD4hep_VERSION_MINOR 27 )
SET( DD4hep_VERSION_PATCH 0 )
SET( DD4hep_VERSION_PATCH 1 )

#######################
# Basic project setup #
Expand Down Expand Up @@ -137,6 +137,10 @@ if(DD4HEP_USE_GEANT4)
IF(NOT Geant4_builtin_clhep_FOUND)
SET(DD4HEP_USE_CLHEP TRUE)
ENDIF()
if(Geant4_CXX_STANDARD MATCHES "[0-9]+" AND Geant4_CXX_STANDARD LESS ${CMAKE_CXX_STANDARD})
message(FATAL_ERROR "Geant4 was compiled with C++${Geant4_CXX_STANDARD}, but DD4hep requires C++${CMAKE_CXX_STANDARD}")
endif()

DD4HEP_SETUP_GEANT4_TARGETS()
# Geant4 sets the CLHEP include directory to include_directories, we undo this here
# we don't do this inside DD4hep_SETUP_GEANT4_TARGETS, because that is also used in
Expand Down
6 changes: 6 additions & 0 deletions DDCore/src/plugins/ReadoutSegmentations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ DECLARE_SEGMENTATION(CartesianGridYZ,create_segmentation<dd4hep::DDSegmentation:
#include "DDSegmentation/CartesianGridXYZ.h"
DECLARE_SEGMENTATION(CartesianGridXYZ,create_segmentation<dd4hep::DDSegmentation::CartesianGridXYZ>)

#include "DDSegmentation/CartesianGridXYStaggered.h"
DECLARE_SEGMENTATION(CartesianGridXYStaggered,dd4hep::create_segmentation<dd4hep::DDSegmentation::CartesianGridXYStaggered>)

#include "DDSegmentation/CartesianStripX.h"
DECLARE_SEGMENTATION(CartesianStripX,create_segmentation<dd4hep::DDSegmentation::CartesianStripX>)

Expand Down Expand Up @@ -75,3 +78,6 @@ DECLARE_SEGMENTATION(ProjectiveCylinder,create_segmentation<dd4hep::DDSegmentati

#include "DDSegmentation/MultiSegmentation.h"
DECLARE_SEGMENTATION(MultiSegmentation,create_segmentation<dd4hep::DDSegmentation::MultiSegmentation>)

#include "DDSegmentation/HexGrid.h"
DECLARE_SEGMENTATION(HexGrid,create_segmentation<dd4hep::DDSegmentation::HexGrid>)
4 changes: 0 additions & 4 deletions DDCore/src/segmentations/CartesianGridXYStaggered.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,3 @@ std::vector<double> CartesianGridXYStaggered::cellDimensions(const CellID& cellI

} /* namespace DDSegmentation */
} /* namespace dd4hep */

// This is done DDCore/src/plugins/ReadoutSegmentations.cpp so the plugin is not part of libDDCore
// needs also #include "DD4hep/Factories.h"
// DECLARE_SEGMENTATION(CartesianGridXYStaggered,dd4hep::create_segmentation<dd4hep::DDSegmentation::CartesianGridXYStaggered>)
2 changes: 0 additions & 2 deletions DDCore/src/segmentations/HexGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,3 @@ namespace dd4hep {

} /* namespace DDSegmentation */
} /* namespace dd4hep */

DECLARE_SEGMENTATION(HexGrid, create_segmentation<dd4hep::DDSegmentation::HexGrid>)
5 changes: 5 additions & 0 deletions DDEve/src/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "DD4hep/Printout.h"

// ROOT include files
#include "TROOT.h"
#include "TH2.h"
#include "TFile.h"
#include "TSystem.h"
Expand Down Expand Up @@ -270,7 +271,11 @@ void Display::UnregisterEvents(View* view) {

/// Open standard message box
void Display::MessageBox(PrintLevel level, const string& text, const string& title) const {
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2)
string path = TString::Format("%s/", TROOT::GetIconPath().Data()).Data();
#else
string path = TString::Format("%s/icons/", gSystem->Getenv("ROOTSYS")).Data();
#endif
const TGPicture* pic = 0;
if ( level == VERBOSE )
pic = client().GetPicture((path+"mb_asterisk_s.xpm").c_str());
Expand Down
5 changes: 5 additions & 0 deletions DDEve/src/EventControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "DD4hep/InstanceCount.h"

// ROOT include files
#include <TROOT.h>
#include <TSystem.h>
#include <TGTab.h>
#include <TGLabel.h>
Expand Down Expand Up @@ -158,7 +159,11 @@ void EventControl::OnNewEvent(EventHandler& handler) {

/// User callback to add elements to the control
void EventControl::OnBuild() {
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2)
string icondir = TString::Format("%s/", TROOT::GetIconPath().Data()).Data();
#else
string icondir = TString::Format("%s/icons/", gSystem->Getenv("ROOTSYS")).Data();
#endif
TGGroupFrame* group = new TGGroupFrame(m_frame,"Event I/O Control");
TGCompositeFrame* top = new TGHorizontalFrame(group);
TGPictureButton* b = 0;
Expand Down
9 changes: 9 additions & 0 deletions DDEve/src/GenericEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <stdexcept>

/// ROOT include files
#include "TROOT.h"
#include "TGMsgBox.h"
#include "TSystem.h"
#include <climits>
Expand Down Expand Up @@ -136,7 +137,11 @@ bool GenericEventHandler::Open(const string& file_type, const string& file_name)
err = "\nAn exception occurred \n"
"while opening event data:\n" + string(e.what()) + "\n\n";
}
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2)
string path = TString::Format("%s/stop_t.xpm", TROOT::GetIconPath().Data()).Data();
#else
string path = TString::Format("%s/icons/stop_t.xpm", gSystem->Getenv("ROOTSYS")).Data();
#endif
const TGPicture* pic = gClient->GetPicture(path.c_str());
new TGMsgBox(gClient->GetRoot(),0,"Failed to open event data",err.c_str(),pic,
kMBDismiss,0,kVerticalFrame,kTextLeft|kTextCenterY);
Expand All @@ -157,7 +162,11 @@ bool GenericEventHandler::NextEvent() {
throw runtime_error("+++ EventHandler::readEvent: No file open!");
}
catch(const exception& e) {
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2)
string path = TString::Format("%s/stop_t.xpm", TROOT::GetIconPath().Data()).Data();
#else
string path = TString::Format("%s/icons/stop_t.xpm", gSystem->Getenv("ROOTSYS")).Data();
#endif
string err = "\nAn exception occurred \n"
"while reading a new event:\n" + string(e.what()) + "\n\n";
const TGPicture* pic = gClient->GetPicture(path.c_str());
Expand Down
10 changes: 5 additions & 5 deletions UtilityApps/src/run_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ namespace {
std::cout << "]" << std::endl << std::flush;
}
if ( name && name[0] ) {
result = run_plugin(description, name, a.first, a.second);
return result;
result = run_plugin(description, name, a.first, a.second);
return result;
}
std::cout << "WARNING: run_plugin: No plugin name supplied. "
<< "Implicitly assuming execution steered by XML." << std::endl;
<< "Implicitly assuming execution steered by XML." << std::endl;
return ENOENT;
}
};
Expand Down Expand Up @@ -279,7 +279,7 @@ namespace dd4hep {
}
else {
result = args.run(description, name);
}
}
if ( result == EINVAL ) usage_default(name);
}
else {
Expand Down Expand Up @@ -329,7 +329,7 @@ namespace dd4hep {
!arguments.ui &&
!arguments.interpreter &&
arguments.plugins.empty() &&
arguments.geo_files.empty() )
arguments.geo_files.empty() )
{
usage_plugin_runner();
}
Expand Down
61 changes: 43 additions & 18 deletions UtilityApps/src/teve_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "run_plugin.h"
#include "TRint.h"

#include "TROOT.h"
#include "TEveGeoNode.h"
#include "TEveBrowser.h"
#include "TGNumberEntry.h"
Expand Down Expand Up @@ -65,21 +66,32 @@ TEveStraightLineSet* getSurfaceVectors(bool addO=true, bool addU= true, bool add

//=====================================================================================

static long teve_display(Detector& description, int /* argc */, char** /* argv */) {
static long teve_display(Detector& description, int argc, char** argv) {
int level = 4, visopt = 0, help = 0;

for( int i=0; i<argc; ++i ) {
if ( strncmp(argv[i],"-visopt",4) == 0 ) visopt = ::atol(argv[++i]);
else if ( strncmp(argv[i],"-level", 4) == 0 ) level = ::atol(argv[++i]);
else help = 1;
}
if ( help ) {
std::cout <<
"Usage: teveDisplay -arg [-arg] \n\n"
" Invoke TEve display using the factory mechanism. \n\n"
" -level <number> Visualization level [TGeoManager::SetVisLevel] Default: 4 \n"
" -visopt <number> Visualization option [TGeoManager::SetVisOption] Default: 0 \n"
" -help Print this help output" << std::endl << std::flush;
::exit(EINVAL);
}

TGeoManager* mgr = &description.manager();
mgr->SetNsegments(100); // Increase the visualization resolution.
TEveManager::Create();

// mgr->SetVisOption(1) ;
// mgr->SetVisLevel(4) ;

// gEve->fGeometries->Add(new TObjString("DefaultGeometry"),mgr);

TEveGeoTopNode* tn = new TEveGeoTopNode(mgr, mgr->GetTopNode());
// option 0 in TEve seems to correspond to option 1 in TGeo ( used in geoDisplay ...)
tn->SetVisOption(0) ;
tn->SetVisLevel(4);
tn->SetVisOption(visopt) ;
tn->SetVisLevel(level);

// // ---- try to set transparency - does not seem to work ...
// TGeoNode* node1 = gGeoManager->GetTopNode();
Expand Down Expand Up @@ -130,13 +142,9 @@ static long teve_display(Detector& description, int /* argc */, char** /* argv *
MultiView::instance()->ImportGeomRPhi( helperSurfaces );
MultiView::instance()->ImportGeomRhoZ( helperSurfaces ) ;


make_gui();

next_event();

gEve->FullRedraw3D(kTRUE);

return 1;
}
DECLARE_APPLY(DD4hepTEveDisplay,teve_display)
Expand All @@ -145,18 +153,31 @@ DECLARE_APPLY(DD4hepTEveDisplay,teve_display)
//=====================================================================================================================

int main(int argc,char** argv) {
return dd4hep::execute::main_default("DD4hepTEveDisplay",argc,argv);
std::vector<const char*> av;
std::string level, visopt, opt;
bool help = false;
for( int i=0; i<argc; ++i ) {
if ( i==1 && argv[i][0] != '-' ) av.emplace_back("-input");
else if ( strncmp(argv[i],"-help",4) == 0 ) help = true, av.emplace_back(argv[i]);
else if ( strncmp(argv[i],"-visopt",4) == 0 ) visopt = argv[++i];
else if ( strncmp(argv[i],"-level", 4) == 0 ) level = argv[++i];
else if ( strncmp(argv[i],"-option",4) == 0 ) opt = argv[++i];
else av.emplace_back(argv[i]);
}
av.emplace_back("-interactive");
av.emplace_back("-plugin");
av.emplace_back("DD4hepTEveDisplay");
if ( help ) av.emplace_back("-help");
if ( !opt.empty() ) av.emplace_back("-opt"), av.emplace_back(opt.c_str());
if ( !level.empty() ) av.emplace_back("-level"), av.emplace_back(level.c_str());
if ( !visopt.empty() ) av.emplace_back("-visopt"), av.emplace_back(visopt.c_str());
return dd4hep::execute::main_plugins("DD4hepTEveDisplay", av.size(), (char**)&av[0]);
}

//=====================================================================================================================


TEveStraightLineSet* getSurfaceVectors(bool addO, bool addU, bool addV, bool addN, TString name,int color) {

TEveStraightLineSet* ls = new TEveStraightLineSet(name);

Detector& description = Detector::getInstance();

DetElement world = description.world() ;

// create a list of all surfaces in the detector:
Expand Down Expand Up @@ -262,7 +283,11 @@ void make_gui() {
TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain);
{

#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2)
TString icondir( Form("%s/", TROOT::GetIconPath().Data()) );
#else
TString icondir( Form("%s/icons/", gSystem->Getenv("ROOTSYS")) );
#endif
TGPictureButton* b = 0;
EvNavHandler *fh = new EvNavHandler;

Expand Down
16 changes: 16 additions & 0 deletions doc/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# v01-27-01

* 2023-11-20 jmcarcell ([PR#1191](https://github.com/aidasoft/DD4hep/pull/1191))
- CMake: Add a check for the c++ standard that Geant4 was compiled with, and fail if it is
different from the one required for DD4hep.

* 2023-11-19 Wouter Deconinck ([PR#1190](https://github.com/aidasoft/DD4hep/pull/1190))
- Use TROOT::GetIconPath to find icons in DDEve

* 2023-11-17 Markus Frank ([PR#1187](https://github.com/aidasoft/DD4hep/pull/1187))
- Implement startup flags to set the visualization depth in teveDisplay like for geoDisplay.
See Issue: See deeper hierarchy in teveDisplay https://github.com/AIDASoft/DD4hep/issues/1186 for details.

* 2023-11-17 Dmitry Kalinkin ([PR#1184](https://github.com/aidasoft/DD4hep/pull/1184))
- Fixed runtime issues during initialization caused by incorrectly placed `DECLARE_SEGMENTATION` for CartesianGridXYStaggered and HexGrid.

# v01-27

* 2023-10-19 Alvaro Tolosa Delgado ([PR#1174](https://github.com/aidasoft/dd4hep/pull/1174))
Expand Down

0 comments on commit 7b7813a

Please sign in to comment.