Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare first release using Geant4 units (mm,ns,MeV) #772

Merged
merged 6 commits into from
Jan 8, 2021

Conversation

MarkusFrankATcernch
Copy link
Contributor

@MarkusFrankATcernch MarkusFrankATcernch commented Jan 6, 2021

BEGINRELEASENOTES

  • This is the first release prepared to use Geant4 units (mm,ns,MeV). This compilation mode can be steered by a cmake flag: -DDD4HEP_USE_GEANT4_UNITS=ON. Once set, the flag is automatically propagated to depending projects in the generated DD4hepConfig.cmake. It programs TGeo to use the Geant4 units system. The unit system is applied also to depending quantities like interaction lengths etc.
  • Update some tests and ensure compatibility in the checks/reference files for both unit system. There is one caveat: Mesh-creation of shapes depends to some degree on the unit system, because mesh points are removed depending on a tolerance value which is the same for both systems.
  • A fix had to be applied to propagate the flag DD4HEP_BUILD_DEBUG to depending projects. This flag affects some object layouts and hence MUST be applied also to depending projects.
  • Remove inclusions of Plugins.h from being processed by rootcling. Plugins.h uses #include <any>, which cannot be processed.
    ENDRELEASENOTES

@MarkusFrankATcernch
Copy link
Contributor Author

@andresailer Could you please have a look to the changes in cmake ? This is not really my strength....

Copy link
Member

@andresailer andresailer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why the manual propagation of DD4HEP_DEBUG is necessary, unless you have something that doesn't link (transitively) against DDCore?

DDCore/src/Volumes.cpp Outdated Show resolved Hide resolved
@@ -950,8 +957,8 @@ void* shape_mesh_verifier(Detector& description, int argc, char** argv) {
solid.setDimensions(params);
}
else if ( isInstance<PseudoTrap>(solid) ) {
auto params = solid.dimensions();
solid.setDimensions(params);
//auto params = solid.dimensions();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh. This was a mistake.

@@ -565,6 +570,10 @@ function(dd4hep_add_dictionary dictionary )
LIST(APPEND comp_defs ${def})
endforeach()

if(DD4HEP_BUILD_DEBUG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(DD4HEP_BUILD_DEBUG)
if(DD4HEP_BUILD_DEBUG)

But is this really necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently yes. ROOT data streaming simply crashed for conditions, where this flag actually changes the structure layout.
Also the TStreamerInfo was wrong.
For this reason the compile flag must be passed to rootcling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that rootcling is being passed this information from one of the targets (or USE parameter?), if you can tell me more details I will investigate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know. The very best would probably be to generate some "config.h", which contains all relevant compile parameters.
This would ensure that such parameters, which cannot be changed for one release build are also properly propagated
to all client projects....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me this

USES DDParsers ${XML_LIBRARIES} ${TBB_IMPORTED_TARGETS}

is missing DDCore and thus not inheriting the DD4HEP_DEBUG.
I did get crashes for various tests without DDCore here when DD4HEP_BUILD_DEBUG was ON

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And probably also in the other dictionaries in DDCore/CMakeLists.txt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. These are exactly the dictionaries in question.
But how can DDCore depend on DDCore ?

So your claim is:
If the flags are set in DD4hep explicitly, the statement:

IF(DD4HEP_BUILD_DEBUG MATCHES "ON" OR (CMAKE_BUILD_TYPE MATCHES "DEBUG|Debug" AND NOT DD4HEP_BUILD_DEBUG MATCHES "OFF"))
target_compile_definitions(DDCore PUBLIC DD4HEP_DEBUG=1)
ENDIF()

Would do all the job ?
However, it then must move to cmake/DD4hepBuild.cmake so that it is picked up by all clients.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The properties are stored in DD4hepConfig-targets.cmake there is no need to move this anywhere else

# Create imported target DD4hep::DDCore
add_library(DD4hep::DDCore SHARED IMPORTED)

set_target_properties(DD4hep::DDCore PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "DD4HEP_DEBUG=1"
  INTERFACE_COMPILE_FEATURES "cxx_std_14"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "DD4hep::DDParsers;ROOT::Core;ROOT::Rint;ROOT::Tree;ROOT::Physics;ROOT::Geom;ROOT::GenVector;XercesC::XercesC;dl"
)

But how can DDCore depend on DDCore ?

Thanks to the generator expressions which are evaluated at build time

LIST(APPEND comp_defs $<TARGET_PROPERTY:${DEP},INTERFACE_COMPILE_DEFINITIONS>)

CMakeLists.txt Outdated
IF(DD4HEP_BUILD_DEBUG MATCHES "ON" OR (CMAKE_BUILD_TYPE MATCHES "DEBUG|Debug" AND NOT DD4HEP_BUILD_DEBUG MATCHES "OFF"))
message(STATUS "BUILD DD4HEP with debug extensions")
set(DD4HEP_BUILD_DEBUG ON)
add_compile_definitions(DD4HEP_DEBUG=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? The definition for the DDCore target should be inherited by anything that links against DDCore, which should be everything, no? (This should also propagate to any project using DDCore outside of DD4hep)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Must retest this.

@@ -50,6 +52,10 @@ endif()
FIND_DEPENDENCY(Boost REQUIRED)
DD4HEP_SETUP_BOOST_TARGETS()

if(DD4HEP_BUILD_DEBUG)
add_compile_definitions(DD4HEP_DEBUG=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES. Absolutely.
Everything depending on DDCore (better including DD4hep/detail/ConditionsInterna.h) needs this flag.
Otherwise you have conflicting object layouts.

@@ -43,6 +43,11 @@ macro(dd4hep_set_compiler_flags)
set ( COMPILER_FLAGS ${COMPILER_FLAGS} -Winconsistent-missing-override -Wno-c++1z-extensions -Wheader-hygiene )
endif()

IF( DD4HEP_USE_GEANT4_UNITS )
MESSAGE(STATUS "+++ Building DD4hep with Geant4 units......")
add_compile_definitions(DD4HEP_USE_GEANT4_UNITS=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be added as a target_compile_definitions to DDG4(?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe.
Then it also must enter in cmake/DD4hepConfig.cmake.in because DD4hepUnits.h must be consistently used for all
depending code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which it would because of the transitivity of the cmake target properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I misunderstood your comment.
The flag DD4HEP_USE_GEANT4_UNITS has nothing to do with Geant4.
It tells dd4hep to instruct TGeo to natively compute all quantities in the same units as Geant4 has (mm,ns,MeV).
This is independent of DDG4. I will try to do the same thing as with DD4HEP_DEBUG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants