Nested Parameterization

Slides:



Advertisements
Similar presentations
Geant4 v9.2p02 Speed up Makoto Asai (SLAC) Geant4 Tutorial Course.
Advertisements

Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
Specialized Geant4 navigation for GATE Jan De Beenhouwer Steven Staelens.
Geant4 v9.2p02 Geometry IV Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Tutorial Course
Geant4 v9.2p02 Kernel III Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.2p02 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.2p02 Scoring II Makoto Asai (SLAC) Geant4 Tutorial Course.
Geometry IV Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Primary particle generation Makoto Asai (SLAC) Geant4 Users CERN Nov. 12 th, 2002.
Geant4 v9.4 Geometry II Makoto Asai (SLAC) Geant4 Tutorial Course.
Primary particle generation Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 15 th, 2002 Customizing Run Management.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 12 th, 2002 Detector Sensitivity.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Detector Sensitivity.
Scoring II Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Geant4 v9.4 Geometry II Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 20th, 2002 Stack management, Digitization and Pile-up.
Geometry II Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Geant4 v9.3 Scoring II Makoto Asai (SLAC) Geant4 Tutorial Course.
Geometry III Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002 Stack management, Digitization and Pile-up.
Some tips for geometries of medical applications Makoto Asai (SLAC)
Geometry 5 I.Hrivnacova¹, J.Apostolakis² ¹IPN, Orsay; ²CERN Cours Paris June 2007.
Geant4 Geometry – building your virtual experiment
Detector Description – advanced features The full set of lecture notes of this Geant4 Course is available at
Tabular Editors for Geant4 Geant4 Geometry Editor and Geant4 Physics Editor CHEP 2000 at Padova Hajime Yoshida Naruto University of Education.
Detector Description – Part II Ivana Hrivnacova, IPN Orsay Tatiana Nikitina, CERN Aknowledgement: Slides by: J.Apostolakis, G.Cosmo, A. Lechner.
Geometry Detector geometry A detector geometry in Geant4 is made of a number of volumes. The largest volume is called the World volume. It must contain.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Geant4 v9.3p01 Kernel III Makoto Asai (SLAC) Geant4 Tutorial Course.
Maria Grazia Pia Detector Response Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
山下智弘 JST CREST/ 神戸大学 Borrowing especially from presentations of M. Asai(SLAC) Geant4 Japan Oct, RCNS, based on Geant4 9.0.p01.
Geant4 v9.4 Kernel III Makoto Asai (SLAC) Geant4 Tutorial Course.
More About Objects and Methods Chapter 5. Outline Programming with Methods Static Methods and Static Variables Designing Methods Overloading Constructors.
Detector Description: Basics
Geometry 4 I.Hrivnacova IPN, Orsay Most slides thanks to M. Asai, SLAC Cours Paris June 2007.
The GeoModel Toolkit for Detector Description Joe Boudreau Vakho Tsulaia University of Pittsburgh CHEP’04 Interlaken.
VMC workshop1 Ideas for G4 navigation interface using ROOT geometry A.Gheata ALICE offline week, 30 May 05.
Run and Event G4Run and G4RunManager In Geant4, the Run is the largest unit of simulation and it consist of a series of events Within a Run, the detector.
A Thread-Parallel Geant4 with Shared Geometry Gene Cooperman and Xin Dong College of Computer and Information Science Northeastern University 360 Huntington.
Geant4 Release 8.0 Highlights J. Apostolakis for G4.
Detector Description: Basics
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
Pedro Arce G4WS’10 October 6th, Voxelised geometries intersected with a volume Pedro Arce CIEMAT, Madrid 2010 Geant4 Workshop ESA, 4-8 October 2010.
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Read-out and detector response
Geometry 3 I.Hrivnacova IPN, Orsay Most slides thanks to M. Asai, SLAC Cours Paris June 2007.
Makoto Asai.  Parallel layered mass geometry  Other minor improvement  G4Exception.
Makoto Asai.  In the past, material is considered only if it appears in the mass (tracking) world. The user might define parallel world(s) for artificial.
Detector Description: Advanced Features
J. Apostolakis, M. Asai, G. Cosmo, A. Howard
Geant4 Geometry Speed-ups
Detector Description – advanced features
Ideas for G4 navigation interface using ROOT geometry
This pointer, Dynamic memory allocation, Constructors and Destructor
C++ for Geant4 users A collection of most useful and/or common features used in and to use Geant4 Marc Verderi LLR – Ecole polytechnique 14/11/2018 Marc.
Makoto Asai (SLAC) Geant4 Tutorial Course
Detector Description – advanced features
Geant4 introduction 2008/03/18 Nobu Katayama KEK
Makoto Asai (SLAC) Geant4 Tutorial Course
Read-out and detector response
Makoto Asai (SLAC) Geant4 Tutorial Course
Detector sensitivity Makoto Asai (SLAC Computing Services)
Read-out and detector response
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Marc Verderi GEANT4 collaboration meeting 01/10/2002
Customizing Run Management
Geant4: Detector description module
Presentation transcript:

Nested Parameterization Makoto Asai (SLAC) 4th Geant4 Space Users’ Workshop

Contents Smart voxelization for geometry optimization Nested parameterization Scorer for nested parameterization Moving objects Nested parameterization - M.Asai (SLAC)

Geometry optimization ("voxelization")

Smart voxelization In case of Geant 3.21, the user had to carefully implement his/her geometry to maximize the performance of geometrical navigation. While in Geant4, user’s geometry is automatically optimized to most suitable to the navigation. - "Voxelization" For each mother volume, one-dimensional virtual division is performed. Subdivisions (slices) containing same volumes are gathered into one. Additional division again using second and/or third Cartesian axes, if needed. so that each division (voxel) has 2 (default) daughters at most "Smart voxels" are computed at initialization time When the detector geometry is closed Does not require large memory or computing resources At tracking time, searching is done in a hierarchy of virtual divisions Nested parameterization - M.Asai (SLAC)

Detector description tuning Some geometry topologies may require ‘special’ tuning for ideal and efficient optimisation for example: a dense nucleus of volumes included in very large mother volume Granularity of voxelisation can be explicitly set Methods Set/GetSmartless() from G4LogicalVolume Critical regions for optimisation can be detected Helper class G4SmartVoxelStat for monitoring time spent in detector geometry optimisation Automatically activated if /run/verbose greater than 1 Percent Memory Heads Nodes Pointers Total CPU Volume ------- ------ ----- ----- -------- --------- ----------- 91.70 1k 1 50 50 0.00 Calorimeter 8.30 0k 1 3 4 0.00 Layer Nested parameterization - M.Asai (SLAC)

Visualising voxel structure The computed voxel structure can be visualized with the final detector geometry Helper class G4DrawVoxels Visualize voxels given a logical volume G4DrawVoxels::DrawVoxels(const G4LogicalVolume*) Allows setting of visualization attributes for voxels G4DrawVoxels::SetVoxelsVisAttributes(…) useful for debugging purposes Nested parameterization - M.Asai (SLAC)

Optimization of 3-D parameterized volume 3-D parameterized volume has two options of smart voxelization, chosen by EAxis parameter of G4PVParameterised 1-D voxelization (EAxis == kXAxis, kYAxis, ...) Compact memory size but slow 3-D voxelization (EAxis == kUndefined) Fast but huge memory size Use replicas for the first and second axes slices and 1-D parameterization for the third axis. Use G4NestedParameterisation to parameterize the material. The material of a voxel should be defined as a function not only of the copy number of the parameterization, but also of the copy numbers of its mother and grand-mother replicas. Nested parameterization - M.Asai (SLAC)

Nested parameterization

Nested parameterization Suppose your geometry has three-dimensional regular reputation of same shape and size of volumes without gap between volumes. And material of such volumes are changing according to the position. E.g. voxels made for CT Scan data (DICOM), Semiconductor, etc. Instead of direct three-dimensional parameterized volume, use replicas for the first and second axes sequentially, and then use one-dimensional parameterization along the third axis. It requires much less memory for geometry optimization and gives much faster navigation for ultra-large number of voxels. Nested parameterization - M.Asai (SLAC)

Nested parameterization 2 Given geometry is defined as two sequential replicas and then one-dimensional parameterization, Material of a voxel must be parameterized not only by the copy number of the voxel, but also by the copy numbers of ancestors. Material is indexed by three indices. 1 2 1 2 3 1 G4VNestedParameterisation is a special parameterization class derived from G4VPVParameterisation base class. ComputeMaterial() method of G4VNestedParameterisation has a touchable object of the parent physical volume, in addition to the copy number of the voxel. Index of first axis = theTouchable->GetCopyNumber(1); Index of second axis = theTouchable->GetCopyNumber(0); Index of third axis = copy number Nested parameterization - M.Asai (SLAC)

G4VNestedParameterisation G4VNestedParameterisation is derived from G4VPVParameterization. G4VNestedParameterisation class has three pure virtual methods you have to implement, in addition to ComputeTransformation() method, which is mandatory for all G4VPVParameterization classes. virtual G4Material* ComputeMaterial(G4VPhysicalVolume *currentVol, const G4int repNo, const G4VTouchable *parentTouch=0)=0; Return a material pointer w.r.t. copy numbers of itself and ancestors. Must cope with parentTouch=0 for navigator's sake. Typically, return a default material if parentTouch=0. virtual G4int GetNumberOfMaterials() const=0; Return total number of materials which may appear as the return value of ComputeMaterial() method. virtual G4Material* GetMaterial(G4int idx) const=0; Return idx-th material. “idx” is not a copy number. idx = [0, nMaterial-1] Nested parameterization - M.Asai (SLAC)

G4VNestedParameterisation G4VNestedParameterisation is a kind of G4VPVParameterization. It can be used as an argument of G4PVParameterised. All other arguments of G4PVParameterised are unaffected. Nested parameterization of placement volume is not supported. All levels used as indices of material must be repeated volume. There cannot be a level of placement volume in between. Nested parameterization - M.Asai (SLAC)

Scorer for nested parameterization

Keys of G4THitsMap All provided primitive scorer classes use G4THitsMap<G4double>. By default, the copy number is taken from the physical volume to which G4MultiFunctionalDetector is assigned. If the physical volume is placed only once, but its (grand-)mother volume is replicated, use the second argument of the constructor of the primitive scorer to indicate the level where the copy number should be taken. e.g. G4PSCellFlux(G4Steing name, G4int depth=0) See exampleN07 If your indexing scheme is more complicated (e.g. utilizing copy numbers of more than one hierarchies), you can override the virtual method GetIndex() provided for all the primitive scorers. Key should be taken from upper geometry hierarchy Copy No 0 Copy No 1 Copy No 2 CopyNo Copy No CopyNo Copy No CopyNo Copy No Scorer A Scorer B Nested parameterization - M.Asai (SLAC)

Keys for nested parameterization For 3-D nested parameterization volume, the unique ID to be used as the key of G4THitsMap should be the combination of three indices. GetIndex() method of the provided scorer must be overwritten. class MyPSDoseScorer : public G4PSDoseScorer { public: virtual G4int GetIndex(G4Step* theStep); }; G4int MyPSDoseScorer::GetIndex(G4Step* theStep) { G4StepPoint* preStep = thestep->GetPreStepPoint(); G4TouchableHistory* th = (G4TouchableHistory*)(preStep->GetTouchable()); G4int idx = th->GetReplicaNumber(0) + 1000 * th->GetReplicaNumber(1) + 1000000 * th->GetReplicaNumber(2); return idx; } parameterized volume mother replica grand-mother replica Nested parameterization - M.Asai (SLAC)

Moving objects

Moving objects In some applications, it is essential to simulate the movement of some volumes. E.g. particle therapy simulation Geant4 can deal with moving volume In case speed of the moving volume is slow enough compared to speed of elementary particles, so that you can assume the position of moving volume is still within one event. Two tips to simulate moving objects : Use parameterized volume to represent the moving volume. Do not optimize (voxelize) the mother volume of the moving volume(s). Nested parameterization - M.Asai (SLAC)

Moving objects - tip 1 Use parameterized volume to represent the moving volume. Use event number as a time stamp and calculate position/rotation of the volume as a function of event number. void MyMovingVolumeParameterisation::ComputeTransformation (const G4int copyNo, G4VPhysicalVolume *physVol) const { static G4RotationMatrix rMat; G4int eID = 0; const G4Event* evt = G4RunManager::GetRunManager()->GetCurrentEvent(); if(evt) eID = evt->GetEventID(); G4double t = 0.1*s*eID; G4double r = rotSpeed*t; G4double z = velocity*t+orig; while(z>0.*m) {z-=8.*m;} rMat.set(HepRotationX(-r)); physVol->SetTranslation(G4ThreeVector(0.,0.,z)); physVol->SetRotation(&rMat0); } Null pointer must be protected. This method is also invoked while geometry is being closed at the beginning of run, i.e. event loop has not yet began. Here, event number is converted to time. (0.1 sec/event) You are responsible not to make the moving volume get out of (protrude from) the mother volume. Position and rotation are set as the function of event number. Nested parameterization - M.Asai (SLAC)

Moving objects - tip 2 Do not optimize (voxelize) the mother volume of the moving volume(s). If moving volume gets out of the original optimized voxel, the navigator gets lost. motherLogical -> SetSmartless( number_of_daughters_or_larger ); With this method invocation, the one-and-only optimized voxel has all daughter volumes. For the best performance, use hierarchal geometry so that each mother volume has least number of daughters. If you are interested in, you can download a sample program http://www.slac.stanford.edu/~asai/Rot.tar.gz Nested parameterization - M.Asai (SLAC)