Open asalzburger opened 1 year ago
@H4m5t3r - do you need help for these first steps?
I couldn't get the geoPluginRun tool to run, but Paul helped me so now I will continue with this.
@asalzburger Could you write some more instructions for the steps? I know the partly commented parts of the file OpenDataDetector.xml are different pixel layers, but I don't know what I'm supposed to do to create a TrackingGeometry before running the file material_recording.py.
I will prepare that for you.
Please have a look at: sms2023-flag
This implements a python binding method that creates a single layer TrackingGeometry
.
m.def("createSingleCylinderGeometry",
[](ActsScalar r, ActsScalar hZ, unsigned binsZ,
unsigned binsPhi) -> std::shared_ptr<Acts::TrackingGeometry> {
// Create the cylindrical layer bounds, this defines the shape
// of the single cylinder
auto cylinderBounds = std::make_shared<CylinderBounds>(r, hZ);
// Create the cylindrical layer, this creates the cylindrical
// representation
auto cylinderLayer = CylinderLayer::create(
Transform3::Identity(), cylinderBounds, nullptr, 1.);
// Create the Material proxy for the mapping, this is a description
// how the material should be binned for the mapping
BinUtility zPhiUtility = BinUtility(binsZ, -hZ, +hZ, open, binZ);
zPhiUtility += BinUtility(binsPhi, -M_PI, M_PI, closed, binPhi);
auto protoMaterial =
std::make_shared<ProtoSurfaceMaterial>(zPhiUtility);
cylinderLayer->assignSurfaceMaterial(protoMaterial);
// Create the cylinder volume bounds
auto volumeBounds =
std::make_shared<CylinderVolumeBounds>(0., 2. * r, 1.25 * hZ);
// Create the layerArray
auto layerArrayCreator = LayerArrayCreator(
LayerArrayCreator::Config(),
getDefaultLogger("LayerArrayCreator", Logging::VERBOSE));
auto layerArray = layerArrayCreator.layerArray(
GeometryContext(), {cylinderLayer}, 0, 2. * r, arbitrary, binR);
// Create the tracking volume, this is the top level container
// for the geometry
auto cylindricalVolume = TrackingVolume::create(
Transform3::Identity(), volumeBounds, nullptr,
std::move(layerArray), nullptr, {}, "SingleCylinderVolume");
return std::make_shared<TrackingGeometry>(cylindricalVolume);
});
This should be all we need.
The TrackingGeometry
is a simplified geometry model of the actual full 3D geometry as shown on the picture. We model this one as a single cylinder (the radius and half length need to be adjusted), and we give it a grid in z/phi to allow modelling the material in different bins.
If you take this branch, you should be able to run as a first:
Examples/flag_geometry.py
which produces some obj
files at output.
This is the output of the L1 layer (it will actually produce 3 layers, but layer L0 and L2 are only virtual layers that do not have material).
This layer L1 is the one where we want to map the material from the ODD Pixel barrel onto.
You see in the construction that I have already included the option to chose a binning in z and phi for the material.
Now, the next step is to run the material recording for the ODD detector, for this - as a start - we can try to run the material recording from GDML input (if this doesn't work, we'll have to fiddle a little bit with DD4hep).
I have prepared a flag_material_recording.py
which should work for this, it requires, however, a GDML file of the layer above, which you have not at hand (yet).
You can produce this directory from running the geoPlugin
, by exporting from the root prompt.
salzburg@andimacbookprom1 root % geoPluginRun -input /Users/salzburg/Documents/work/dev/acts-flug/thirdparty/OpenDataDetector/xml/OpenDataDetector.xml -interactive -plugin DD4hep_GeometryDisplay -level 8
PersistencyIO INFO +++ Set Streamer to dd4hep::OpaqueDataBlock
Info in <TGeoManager::TGeoManager>: Geometry default, Detector Geometry created
Info in <TGeoNavigator::BuildCache>: --- Maximum geometry depth set to 100
CompactLoader INFO +++ Processing compact file: /Users/salzburg/Documents/work/dev/acts-flug/thirdparty/OpenDataDetector/xml/OpenDataDetector.xml with flag BUILD_DEFAULT
DD4hep WARN ++ STD conditions NOT defined by client. NTP defaults taken.
Warning in <TGeoMixture::ComputeDerivedQuantities>: Mixture PE: sum of weights is: 6
Detector INFO *********** Created World volume with size: 1000 1000 1000
Info in <TGeoManager::SetTopVolume>: Top volume is world_volume. Master volume is world_volume
Utilities INFO +++ setDetectorTypeFlags for detector: Pixels not set.
Compact INFO ++ Converted subdetector:Pixels of type DD4hep_SubdetectorAssembly
Compact INFO ++ Converted subdetector:PixelEndcapN of type ODDPixelEndcap [tracker]
Compact INFO ++ Converted subdetector:PixelBarrel of type ODDPixelBarrel [tracker]
Compact INFO ++ Converted subdetector:PixelEndcapP of type ODDPixelEndcap [tracker]
ParametersPlugin INFO +++ Applying 2 parameters
ParametersPlugin INFO +++ PixelEndcapN -> layer_pattern: str = PixelEndcapN\d|PixelEndplate
ParametersPlugin INFO +++ Applying 2 parameters
ParametersPlugin INFO +++ PixelEndcapP -> layer_pattern: str = PixelEndcapP\d|PixelEndplate
ParametersPlugin INFO +++ Applying 2 parameters
ParametersPlugin INFO +++ PixelBarrel -> layer_pattern: str = PixelLayer\d
Info in <TGeoManager::CheckGeometry>: Fixing runtime shapes...
Info in <TGeoManager::CheckGeometry>: ...Nothing to fix
Info in <TGeoManager::CloseGeometry>: Counting nodes...
Info in <TGeoManager::Voxelize>: Voxelizing...
Info in <TGeoManager::CloseGeometry>: Building cache...
Info in <TGeoManager::CountLevels>: max level = 6, max placements = 30
Info in <TGeoManager::CloseGeometry>: 1175 nodes/ 24 volume UID's in Detector Geometry
Info in <TGeoManager::CloseGeometry>: ----------------modeler ready----------------
Detector INFO +++ Patching names of anonymous shapes....
------------------------------------------------------------------
| Welcome to ROOT 6.28/04 https://root.cern |
| (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for macosxarm64 on May 08 2023, 02:44:07 |
| From tags/v6-28-04@v6-28-04 |
| With Apple clang version 14.0.3 (clang-1403.0.22.14.1) |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
Info in <TGeoManager::SetVisLevel>: Automatic visible depth disabled
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
geoPluginRun: [ 0.958 sec] Executed dd4hep plugin: 'DD4hep_GeometryDisplay' with args (2) :[ -level 8 ]
root [0] gGeoManager->Export("ODD_Pixel_l0.gdml")
I have gotten to the point where I run the material recording, but it gives me the following error:
(cern_venv) taleiko@lx9-fuxi101:~/builds/acts/Examples/Scripts/Python$ python3 flag_material_recording.py
15:47:42 Sequencer INFO Create Sequencer (single-threaded)
15:47:42 Sequencer INFO Add Reader 'EventGenerator'
15:47:42 Sequencer INFO -> OutputParticles 'particles_initial':
15:47:42 Sequencer INFO flat_set<Particle, detail::CompareParticleId, void>
**************************************************************
Geant4 version Name: geant4-11-01-patch-01 [MT] (10-February-2023)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
: NIM A 835 (2016), 186-225
WWW : http://geant4.org/
**************************************************************
G4GDML: Reading 'ODD_Pixel_l0.gdml'...
G4GDML: Reading definitions...
G4GDML: Reading materials...
-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : mat031
issued by : G4Material::AddElementByMassFraction()
For material PE and added element C_elm massFraction= 2 is wrong
*** Fatal Exception *** core dump ***
**** Track information is not available at this moment
**** Step information is not available at this moment
-------- EEEE -------- G4Exception-END --------- EEEE -------
*** G4Exception: Aborting execution ***
Aborted (core dumped)
Am I doing something wrong?
Ha! The gdml file was right, sorry I was super confusing - the reason I called he file l0 is just because we only have one pixel layer, this is then translated into L1 of the Acts::TrackingGeometry. However, I see that the material conversion fails, so we will have to go via DD4Hep. I will update the branch.
I have updated the recipe to run the material recording directly from DD4hep->DDG4 (direct Geant4 translation) and not from DD4hep->GDML (as this seems to have problems).
There are now three files:
Examples/Scripts/Python/flag_dd4hep_geometry.py
Examples/Scripts/Python/flag_material_recording.py
Examples/Scripts/Python/flag_tracking_geometry.py
Please try to run all of them - does this work?
Yes, now they all work.
The resulting plot from the material tracking looks like this:
Note that I have updated the issue and task list above, the next step should be the material mapping, I have also updated the branch accordingly.
In the part where I have to use flag_tracking_geometry.py
, what are the parameters r
and hz
and where do I adjust them?
Is it the line
trackingGeometry = acts.createSingleCylinderGeometry(34, 400, 100, 36)
?
Do you use any specific software for viewing the .obj files?
Do you use any specific software for viewing the .obj files?
I use MeshLab
In the part where I have to use
flag_tracking_geometry.py
, what are the parametersr
andhz
and where do I adjust them?Is it the line
trackingGeometry = acts.createSingleCylinderGeometry(34, 400, 100, 36)
?
I will update the code accordingly with documentation.
I will split the new items into a new task. Can you upload your screenshots here for documentation purpose?
Which screenshots are we talking about here? These ones from after the material recording?
The idea is to build a single layer of the Open Data Detector first and run it through material recording and mapping in ACTS.
This can be done by modifying three files: https://cernbox.cern.ch/index.php/s/rW4ECrrgI7KoE6F
The result should be this:
The command to run the display is actually:
For visual inspection.
Step by step procedure:
geoPlugin
.gdml
file representing this geometryActs
r
,hz
to represent the single ODD layer accordingly, run this withflag_tracking_geometry.py
flag_dd4hep_geometry.py
flag_material_recording.py
and inspect the output on single layerflag_material_mapping.py
and adjust the layer parameters to represent the single layerflag_material_valiation.py
which reads the output of the ones above