-
Notifications
You must be signed in to change notification settings - Fork 102
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
Controlling Geant4 smart voxelization from the detector constructor #1361
Comments
At what phase of Geant4 do these values have to be set? |
These values are set when instantiating the logical volumes [link]. There is no UI command for later modification. |
Why do you need to access
? Is the ability to |
The problem is to pass all that information from DD4hep volumes to G4LogicalVolumes, and maybe needing to expose more functions... So maybe we can try this: Create your own G4LogicalVolume plugin to create G4LogicalVolumes that you fully control. In the c++ where you create your volumes then put something like this Volume vol = Volume("Volume", solid, material);
// ...
vol.addProperty("Geant4-plugin", "SmartlessLogicalVolume");
Then the Geant4Converter will use your code to create the G4LogicalVolume DD4hep/DDG4/src/Geant4Converter.cpp Lines 787 to 795 in 960cfa0
See the release notes entry Line 1065 in 960cfa0
|
For the record, This is the plugin I used: // Framework include files
#include <DDG4/Factories.h>
// Geant4 include files
#include <G4Material.hh>
#include <G4LogicalVolume.hh>
#include <string>
#include <charconv> // For std::from_chars
// Forward declarations
namespace { class SmartlessLogicalVolume; }
/// Namespace example name of the user
namespace dd4hep {
/** Class member specialization to create a a G4LogicalVolume specifying the Smartless parameter
*
* \author A. Tolosa-Delgado
* \version 1.0
* \ingroup DD4HEP_SIMULATION
*/
template <> G4LogicalVolume*
Geant4LogicalVolumeFactory<SmartlessLogicalVolume>::create(dd4hep::Detector& /* description */,
Volume volume,
G4VSolid* solid,
G4Material* material)
{
auto* ptr = new G4LogicalVolume(solid, material, volume.name());
const std::string default_prop = "";
std::string volume_prop = volume.getProperty("SetSmartless",default_prop);
if( default_prop != volume_prop)
{
// try conversion from string to integer
auto s = volume_prop;
int Smartless;
bool IsConversionDone = std::from_chars(s.data(), s.data() + s.size(), Smartless).ec == std::errc{} ;
if ( IsConversionDone )
{
ptr->SetSmartless(Smartless);
printout(ALWAYS,"SmartlessLogicalVolume",
"====> Created specialize logical volume [SmartlessLogicalVolume] %s with Smartless parameter %d",
volume.name(), Smartless);
}
}
return ptr;
}
} // End namespace dd4hep
DECLARE_GEANT4LOGICALVOLUME(SmartlessLogicalVolume) And in the detector constructor, one has to setup 2 properties of the // detector constructor code
dd4hep::Volume layer_v ( layer_name , layer_s, gasvolMat );
// use SmartlessLogicalVolume plugin to translate dd4hep volumes into G4LogicalVolumes
layer_v.addProperty("Geant4-plugin", "SmartlessLogicalVolume");
// example of how to disable smart voxelization, Smartless parameter equals to 0
layer_v.addProperty("SetSmartless", "0"); If you want, I can open a PR with this plugin so it is available for everybody. |
Hi,
If I understand correctly, the DD4hep class
Volume
[link] is the equivalent toLogical Volume
in Geant4. I was wondering if it would be possible to expose the following functions [link] of G4LogicalVolume from the DD4hep Volume:In my case I am dealing with the full stereo drift chamber, which may be very extreme when creating the voxelization because of the twisted geometry. I would like to investigate if it is possible to fine tune the granularity of the voxelization so it can be a better option to using hyperboloids as layers. With the Geant4 default settings, the voxelization causes the memory to explode: 4GB (60k wires placed directly into the main volume) [1] vs 2.7GB (60k placed in 112 different layers) [2].
Without the possibility of tuning the granularity of the smart voxelization, I guess the use of hyperboloids is preferred because of the smaller memory consumption, even if the tracking is slower.
Thank you for your time.
Best,
Alvaro
[1] When placing wires directly into the main gas volume, so the geometry tree looks like "main gas, cylinder" -> "wires" x60000
[2] When using hyperboloids as layers, so the geometry tree looks like "main gas, cylinder" -> "gas layer, hyperboloid" x112 -> "wires" x60000
The text was updated successfully, but these errors were encountered: