Geant4 v9.2p02 Geometry IV Makoto Asai (SLAC) Geant4 Tutorial Course.

Slides:



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

Isoparametric Elements Element Stiffness Matrices
Review for Test 3.
Algorithms + L. Grewe.
Query Evaluation. An SQL query and its RA equiv. Employees (sin INT, ename VARCHAR(20), rating INT, age REAL) Maintenances (sin INT, planeId INT, day.
Defining Material and Geometry Makoto Asai (SLAC) Geant4 Tutorial Course the 2nd Finnish Geant4 Workshop June , Helsinki Institute of Physics June.
Geometry IV Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Geant4 v9.4 Geometry II Makoto Asai (SLAC) Geant4 Tutorial Course.
Detector Description Gabriele Cosmo, Geant4 Users’ Workshop Tutorial SLAC February 18-22, 2002.
Nested Parameterization
Geant4 v9.4 Geometry II Makoto Asai (SLAC) Geant4 Tutorial Course.
Highlights of latest developments ESA/ESTEC Makoto Asai (SLAC)
Geometry II Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
16.5 Introduction to Cost- based plan selection Amith KC Student Id: 109.
Some tips for geometries of medical applications Makoto Asai (SLAC)
Camera Parameters and Calibration. Camera parameters From last time….
Geometry 5 I.Hrivnacova¹, J.Apostolakis² ¹IPN, Orsay; ²CERN Cours Paris June 2007.
Modeling and representation 1 – comparative review and polygon mesh models 2.1 Introduction 2.2 Polygonal representation of three-dimensional objects 2.3.
Geant4 Geometry – building your virtual experiment
Detector Description – advanced features The full set of lecture notes of this Geant4 Course is available at
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
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.
Lecture 7 – Data Reorganization Pattern Data Reorganization Pattern Parallel Computing CIS 410/510 Department of Computer and Information Science.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
+ Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time.
Maria Grazia Pia Detector Response Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
Field propagation in Geant4 John Apostolakis 25 th May 2005 Ver. 
Field propagation in Geant4 John Apostolakis, CERN Ecole Geant June 2007, Paris 25 th May 2005 Ver. 
Detector Description: Sensitive Detector & Field
The propagation of a microwave in an atmospheric pressure plasma layer: 1 and 2 dimensional numerical solutions Conference on Computation Physics-2006.
Geometry 4 I.Hrivnacova IPN, Orsay Most slides thanks to M. Asai, SLAC Cours Paris June 2007.
Advanced EM - Master in Physics We have now calculated all the intermediate derivatives which we need for calculating the fields E and B. We.
Magnetic Field Issues for Simulation and Reconstruction N. Amapane, N. Neumeister Workshop on LHC Physics with High-p T Muons in CMS Bologna, April 9-12,
The GeoModel Toolkit for Detector Description Joe Boudreau Vakho Tsulaia University of Pittsburgh CHEP’04 Interlaken.
Raquel A. Romano 1 Scientific Computing Seminar May 12, 2004 Projective Geometry for Computer Vision Projective Geometry for Computer Vision Raquel A.
VMC workshop1 Ideas for G4 navigation interface using ROOT geometry A.Gheata ALICE offline week, 30 May 05.
Geant4 Simulation of the Beam Line for the HARP Experiment M.Gostkin, A.Jemtchougov, E.Rogalev (JINR, Dubna)
Detector Description – Part III Ivana Hrivnacova, IPN Orsay Tatiana Nikitina, CERN Aknowledgement: Slides by: J.Apostolakis, G.Cosmo, A. Lechner.
Geant4 Tracking Test (D. Lunesu)1 Daniela Lunesu, Stefano Magni Dario Menasce INFN Milano GEANT4 TRACING TESTs.
Detector Description: Basics
Pedro Arce G4WS’10 October 6th, Voxelised geometries intersected with a volume Pedro Arce CIEMAT, Madrid 2010 Geant4 Workshop ESA, 4-8 October 2010.
Introduction to Scale Space and Deep Structure. Importance of Scale Painting by Dali Objects exist at certain ranges of scale. It is not known a priory.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
Geometry 3 I.Hrivnacova IPN, Orsay Most slides thanks to M. Asai, SLAC Cours Paris June 2007.
Geometry and Fields: Further and advanced features J. Apostolakis & G. Cosmo.
3D Object Representations 2009, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
CIVET seminar Presentation day: Presenter : Park, GilSoon.
Detector Description: Advanced Features
Dmitry Sorokin (GSoC 2016), John Apostolakis (CERN)
Larmor Orbits The general solution of the harmonic oscillator equation
Detector Description - Advanced
Use of interpolation and FSAL property for integration in field
Geant4 Geometry Speed-ups
Detector Description – advanced features
Ideas for G4 navigation interface using ROOT geometry
Detector Description - Advanced
Field propagation in Geant4
Detector Description – advanced features
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Read-out and detector response
Detector sensitivity Makoto Asai (SLAC Computing Services)
A shortcut to the tracking
Field propagation in Geant4
Hierarchical Modeling & Constructive Solid Geometry
Field propagation in Geant4
Field propagation in Geant4
Marc Verderi GEANT4 collaboration meeting 01/10/2002
Presentation transcript:

Geant4 v9.2p02 Geometry IV Makoto Asai (SLAC) Geant4 Tutorial Course

Contents Magnetic field Field integration and other types of field Advanced ways of placement –Nested parameterization –Reflected volume –Assembly volume Geometry optimization Geometry IV - M.Asai (SLAC)2

Geant4 v9.2p02 Defining a magnetic field

Magnetic field (1) Create your Magnetic field class –Uniform field : Use an object of the G4UniformMagField class G4MagneticField* magField = new G4UniformMagField(G4ThreeVector(1.*Tesla,0.,0.); –Non-uniform field : Create your own concrete class derived from G4MagneticField and implement GetFieldValue method. void MyField::GetFieldValue( const double Point[4], double *field) const Point[0..2] are position in global coordinate system, Point[3] is time field[0..2] are returning magnetic field Geometry IV - M.Asai (SLAC)4

Magnetic field (2) Tell Geant4 to use your field 1.Find the global Field Manager G4FieldManager* globalFieldMgr = G4TransportationManager::GetTransportationManager() ->GetFieldManager(); 2.Set the field for this FieldManager, globalFieldMgr->SetDetectorField(magField); 3.and create a Chord Finder. globalFieldMgr->CreateChordFinder(magField); /example/novice/N04/ExN04 is a good starting point Geometry IV - M.Asai (SLAC)5

Global and local fields One field manager is associated with the ‘world’ and it is set in G4TransportationManager Other volumes can override this –An alternative field manager can be associated with any logical volume The field must accept position in global coordinates and return field in global coordinates –By default this is propagated to all its daughter volumes G4FieldManager* localFieldMgr = new G4FieldManager(magField); logVolume->setFieldManager(localFieldMgr, true); where ‘ true ’ makes it push the field to all the volumes it contains, unless a daughter has its own field manager. Customizing the field propagation classes –Choosing an appropriate stepper for your field –Setting precision parameters Geometry IV - M.Asai (SLAC)6

Field integration In order to propagate a particle inside a field (e.g. magnetic, electric or both), we solve the equation of motion of the particle in the field. We use a Runge-Kutta method for the integration of the ordinary differential equations of motion. –Several Runge-Kutta ‘steppers’ are available. In specific cases other solvers can also be used: –In a uniform field, using the analytical solution. –In a smooth but varying field, with RK+helix. Using the method to calculate the track's motion in a field, Geant4 breaks up this curved path into linear chord segments. –We determine the chord segments so that they closely approximate the curved path. Geometry IV - M.Asai (SLAC)7 ‘Tracking’ Step Chords Real Trajectory

Tracking in field We use the chords to interrogate the G4Navigator, to see whether the track has crossed a volume boundary. One physics/tracking step can create several chords. –In some cases, one step consists of several helix turns. User can set the accuracy of the volume intersection, –By setting a parameter called the “miss distance” It is a measure of the error in whether the approximate track intersects a volume. It is quite expensive in CPU performance to set too small “miss distance”. Geometry IV - M.Asai (SLAC)8 "miss distance" ‘Tracking’ Step Chords Real Trajectory

Tunable parameters In addition to the “miss distance” there are two more parameters which the user can set in order to adjust the accuracy (and performance) of tracking in a field. –These parameters govern the accuracy of the intersection with a volume boundary and the accuracy of the integration of other steps. The “delta intersection” parameter is the accuracy to which an intersection with a volume boundary is calculated. This parameter is especially important because it is used to limit a bias that our algorithm (for boundary crossing in a field) exhibits. The intersection point is always on the 'inside' of the curve. By setting a value for this parameter that is much smaller than some acceptable error, the user can limit the effect of this bias. Geometry IV - M.Asai (SLAC)9 boundary real trajectory Chord estimated intersection correct intersection “delta intersection”

Tunable parameters The “delta one step” parameter is the accuracy for the endpoint of 'ordinary' integration steps, those which do not intersect a volume boundary. This parameter is a limit on the estimation error of the endpoint of each physics step. “delta intersection” and “delta one step” are strongly coupled. These values must be reasonably close to each other. –At most within one order of magnitude These tunable parameters can be set by theChordFinder->SetDeltaChord( miss_distance ); theFieldManager->SetDeltaIntersection( delta_intersection ); theFieldManager->SetDeltaOneStep( delta_one_step ); Further details are described in Section 4.3 (Electromagnetic Field) of the Application Developers Manual. Geometry IV - M.Asai (SLAC)10

Geant4 v9.2p02 Field integration and Other types of field

Customizing field integration Runge-Kutta integration is used to compute the motion of a charged track in a general field. There are many general steppers from which to choose, of low and high order, and specialized steppers for pure magnetic fields. By default, Geant4 uses the classical fourth-order Runge-Kutta stepper (G4ClassicalRK4), which is general purpose and robust. –If the field is known to have specific properties, lower or higher order steppers can be used to obtain the results of same quality using fewer computing cycles. In particular, if the field is calculated from a field map, a lower order stepper is recommended. The less smooth the field is, the lower the order of the stepper that should be used. –The choice of lower order steppers includes the third order stepper G4SimpleHeum, the second order G4ImplicitEuler and G4SimpleRunge, and the first order G4ExplicitEuler. A first order stepper would be useful only for very rough fields. –For somewhat smooth fields (intermediate), the choice between second and third order steppers should be made by trial and error. Geometry IV - M.Asai (SLAC)12

Customizing field integration Trying a few different types of steppers for a particular field or application is suggested if maximum performance is a goal. Specialized steppers for pure magnetic fields are also available. They take into account the fact that a local trajectory in a slowly varying field will not vary significantly from a helix. –Combining this in with a variation, the Runge-Kutta method can provide higher accuracy at lower computational cost when large steps are possible. To change the stepper theChordFinder ->GetIntegrationDriver() ->RenewStepperAndAdjust( newStepper ); Further details are described in Section 4.3 (Electromagnetic Field) of the Application Developers Manual. Geometry IV - M.Asai (SLAC)13

Other types of field The user can create their own type of field, inheriting from G4VField, and an associated Equation of Motion class (inheriting from G4EqRhs) to simulate other types of fields. Field can be time-dependent. For pure electric field, Geant4 has G4ElectricField and G4UniformElectricField classes. For combined electromagnetic field, Geant4 has G4ElectroMagneticField class. Equation of Motion class for electromagnetic field is G4MagElectricField. G4ElectricField* fEMfield = new G4UniformElectricField( G4ThreeVector(0., *kilovolt/cm, 0.) ); G4EqMagElectricField* fEquation = new G4EqMagElectricField(fEMfield); G4MagIntegratorStepper* fStepper = new G4ClassicalRK4( fEquation, nvar ); G4FieldManager* fFieldMgr = G4TransportationManager::GetTransportationManager()-> GetFieldManager(); fFieldManager->SetDetectorField( fEMfield ); G4MagInt_Driver* fIntgrDriver = new G4MagInt_Driver(fMinStep, fStepper, fStepper->GetNumberOfVariables() ); G4ChordFinder* fChordFinder = new G4ChordFinder(fIntgrDriver); Geometry IV - M.Asai (SLAC)14

Geant4 v9.2p02 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 by CT Scan data (DICOM)  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 Geometry IV - M.Asai (SLAC)16

Nested parameterization Geometry IV - M.Asai (SLAC)  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.  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

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] Geometry IV - M.Asai (SLAC)18

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. Geometry IV - M.Asai (SLAC)19

Geant4 v9.2p02 Assembly volume

Grouping volumes To represent a regular pattern of positioned volumes, composing a more or less complex structure –structures which are hard to describe with simple replicas or parameterised volumes –structures which may consist of different shapes –Too densely positioned to utilize a mother volume Assembly volume –acts as an envelope for its daughter volumes –its role is over once its logical volume has been placed –daughter physical volumes become independent copies in the final structure Participating daughter logical volumes are treated as triplets –logical volume –translation w.r.t. envelop –rotation w.r.t. envelop Geometry IV - M.Asai (SLAC)21

G4AssemblyVolume G4AssemblyVolume::AddPlacedVolume ( G4LogicalVolume* volume, G4ThreeVector& translation, G4RotationMatrix* rotation ); Helper class to combine daughter logical volumes in arbitrary way –Imprints of the assembly volume are made inside a mother logical volume through G4AssemblyVolume::MakeImprint(…) –Each physical volume name is generated automatically Format: av_WWW_impr_XXX_YYY_ZZZ –WWW – assembly volume instance number –XXX – assembly volume imprint number –YYY – name of the placed logical volume in the assembly –ZZZ – index of the associated logical volume –Generated physical volumes (and related transformations) are automatically managed (creation and destruction) Geometry IV - M.Asai (SLAC)22

G4AssemblyVolume : example G4AssemblyVolume* assembly = new G4AssemblyVolume(); G4RotationMatrix Ra; G4ThreeVector Ta; Ta.setX(…); Ta.setY(…); Ta.setZ(…); assembly->AddPlacedVolume( plateLV, Ta, Ra ); … // repeat placement for each daughter for( unsigned int i = 0; i < layers; i++ ) { G4RotationMatrix Rm(…); G4ThreeVector Tm(…); assembly->MakeImprint( worldLV, Tm, Rm ); } Geometry IV - M.Asai (SLAC)23

Geant4 v9.2p02 Reflected volume

Reflecting solids G4ReflectedSolid (derived from G4VSolid) –Utility class representing a solid shifted from its original reference frame to a new mirror symmetric one –The reflection (G4Reflect[X/Y/Z]3D) is applied as a decomposition into rotation and translation G4ReflectionFactory –Singleton object using G4ReflectedSolid for generating placements of reflected volumes Reflections are currently limited to simple CSG solids. –will be extended soon to all solids Geometry IV - M.Asai (SLAC)25  Let's take an example of a pair of mirror symmetric volumes.  Such geometry cannot be made by parallel transformation or 180 degree rotation.

Reflecting hierarchies of volumes - 1 G4PhysicalVolumesPair G4ReflectionFactory::Place (const G4Transform3D& transform3D, // the transformation const G4String& name, // the name G4LogicalVolume* LV, // the logical volume G4LogicalVolume* motherLV, // the mother volume G4bool noBool, // currently unused G4int copyNo) // optional copy number Used for normal placements: i. Performs the transformation decomposition ii. Generates a new reflected solid and logical volume  Retrieves it from a map if the reflected object is already created iii. Transforms any daughter and places them in the given mother iv. Returns a pair of physical volumes, the second being a placement in the reflected mother G4PhysicalVolumesPair is std::map Geometry IV - M.Asai (SLAC)26

Reflecting hierarchies of volumes - 2 G4PhysicalVolumesPair G4ReflectionFactory::Replicate (const G4String& name, // the actual name G4LogicalVolume* LV, // the logical volume G4LogicalVolume* motherLV, // the mother volume Eaxis axis // axis of replication G4int replicaNo // number of replicas G4int width, // width of single replica G4int offset=0) // optional mother offset –Creates replicas in the given mother volume –Returns a pair of physical volumes, the second being a replica in the reflected mother Geometry IV - M.Asai (SLAC)27

Geant4 v9.2p02 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. "Smart voxels" are computed at initialisation 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 Geometry IV - M.Asai (SLAC)29

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 k Calorimeter k Layer Geometry IV - M.Asai (SLAC)30

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 Geometry IV - M.Asai (SLAC)31