Upload
caitlin-sanders
View
222
Download
1
Tags:
Embed Size (px)
Citation preview
Detector Description – Part II
Ivana Hrivnacova, IPN Orsay Tatiana Nikitina, CERN
Aknowledgement:Slides by: J.Apostolakis, G.Cosmo, A. Lechner
PART II
Detector Description: Detector Description: Advanced featuresAdvanced features
- Repeated Placements- Touchables - Regions- Optimisation Techniques- Grouping Volumes and Reflection- Magnetic field
Repeated PlacementsRepeated Placements
- Parameterised Volumes
- Replicas
Detector Description - Geant4 Course 4
Physical VolumesPhysical Volumes
repeated
placement
Placement: it is one positioned volume
Represents one “real” volume
Repeated: a volume placed many times can represent any number of volumes reduces use of memory. Replica and Division
• simple repetition along one axis Parameterised
• Repetition with respect to copy number
A mother volume can contain either
many placement volumes OR one repeated volume
Detector Description - Geant4 Course 5
Parameterised Physical VolumesParameterised Physical Volumes User written functions define:
the size of the solid (dimensions)• Function ComputeDimensions(…)
where it is positioned (transformation)• Function ComputeTransformations(…)
Optional: the type of the solid
• Function ComputeSolid(…) the material
• Function ComputeMaterial(…) Limitations:
Applies to simple CSG solids only Daughter volumes allowed only for special cases
Very powerful Consider parameterised volumes as “leaf” volumes
Detector Description - Geant4 Course 6
Uses of Parameterised VolumesUses of Parameterised Volumes
Complex detectors with large repetition of
volumes• regular or irregular
Medical applications the material in animal tissue is
measured• cubes with varying material
Detector Description - Geant4 Course 7
G4PVParameterisedG4PVParameterisedG4PVParameterised(const G4String& pName, G4LogicalVolume* pCurrentLogical, G4LogicalVolume* pMotherLogical, const EAxis pAxis, const G4int nReplicas, G4VPVParameterisation* pParam);
Replicates the volume nReplicas times using the parameterisation pParam, within the mother volume
The positioning of the replicas is dominant along the specified Cartesian axis If kUndefined is specified as axis, 3D voxelisation for
optimisation of the geometry is adopted Represents many touchable detector elements differing in
their positioning and dimensions. Both are calculated by means of a G4VPVParameterisation object
Alternative constructor using pointer to physical volume for the mother
Detector Description - Geant4 Course 8
ParameterisationParameterisationExampleExample
G4VSolid* solidChamber = new G4Box("chamber", 100*cm, 100*cm, 10*cm);
G4LogicalVolume* logicChamber =
new G4LogicalVolume(solidChamber, chamberMater, "Chamber", 0, 0, 0);
...
G4VPVParameterisation* chamberParam
= new ChamberParameterisation(
nofChambers, firstPositionZ, spacingZ,
chamberWidth, firstLength, lastLength);
G4VPhysicalVolume* physChamber
= new G4PVParameterised(
"Chamber",
logicChamber,
logicTracker,
kZAxis,
NbOfChambers,
chamberParam);
Use kUndefined for activating 3D voxelisation for optimisation Use kUndefined for activating 3D voxelisation for optimisation
See the class definition on the next slide
Detector Description - Geant4 Course 9
ParameterisationParameterisationExample (cont.)Example (cont.)
class ChamberParameterisation : public G4VPVParameterisation{ public: ChamberParameterisation(..); ~ChamberParameterisation(); void ComputeTransformation( G4int copyNo, G4VPhysicalVolume* physVol) const; void ComputeDimensions ( G4Box& trackerLayer, G4int copyNo, const G4VPhysicalVolume* physVol) const;
private: G4int fNoChambers; G4double fStartZ; G4double fSpacingZ; G4double fHalfWidth; G4double fHalfLengthFirst; G4double fHalfLengthIncr;};
Detector Description - Geant4 Course 10
ParameterisationParameterisationExample (cont)Example (cont)
void ChamberParameterisation::ComputeTransformation ( G4int copyNo, G4VPhysicalVolume* physVol) const
{
G4double zPosition= fStartZ + (copyNo+1) * fSpacingZ;
physVol->SetTranslation(G4ThreeVector(0, 0, zPosition));
physVol->SetRotation(0);
}
void ChamberParameterisation::ComputeDimensions (
G4Box& trackerChamber,
G4int copyNo,
const G4VPhysicalVolume* physVol) const
{
G4double halfLength = fHalfLengthFirst + copyNo * fHalfLengthIncr;
trackerChamber.SetXHalfLength(halfLength);
trackerChamber.SetYHalfLength(halfLength);
trackerChamber.SetZHalfLength(fHalfWidth);
}
Detector Description - Geant4 Course 11
Replicated Physical VolumesReplicated Physical Volumes
repeated
The mother volume is sliced into replicas, all of the same size and dimensions.
Represents many touchable detector elements differing only in their positioning.
Depending on the mother shape, replication may occur along: Cartesian axes (X, Y, Z) – slices are considered
perpendicular to the axis of replication• Coordinate system at the center of each replica
Radial axis (Rho) – cons/tubs sections centered on the origin and un-rotated
• Coordinate system same as the mother Phi axis (Phi) – phi sections or wedges, of
cons/tubs form• Coordinate system rotated such as that the X axis
bisects the angle made by each wedge
Detector Description - Geant4 Course 12
G4PVReplicaG4PVReplicaG4PVReplica(const G4String& pName, G4LogicalVolume* pCurrentLogical, G4LogicalVolume* pMotherLogical, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset=0);
Alternative constructor: using pointer to physical volume for the mother
An offset can only be associated to a mother offset along the axis of replication
Features and restrictions: Replicas can be placed inside other replicas Normal placement volumes can be placed inside replicas, assuming
no intersection/overlaps with the mother volume or with other replicas No volume can be placed inside a radial replication Parameterised volumes cannot be placed inside a replica
a daughter volume to be replicated
mother volume
Detector Description - Geant4 Course 13
Replica – axis, width, offsetReplica – axis, width, offset
Cartesian axes - kXaxis, kYaxis, kZaxis
offset shall not be used
Center of n-th daughter is given as
-width*(nReplicas-1)*0.5+n*width
Radial axis - kRho
Center of n-th daughter is given as
width*(n+0.5)+offset
Phi axis - kPhi
Center of n-th daughter is given as
width*(n+0.5)+offset
offset
width
offset
width
width
Detector Description - Geant4 Course 14
ReplicaReplicaExampleExample
G4double tube_dPhi = 360.*deg; G4VSolid* tube = new G4Tubs("tube", 20*cm, 50*cm, 30*cm, 0., tube_dPhi); G4LogicalVolume* tube_log = new G4LogicalVolume(tube, Ar, "tubeL", 0, 0, 0); G4VPhysicalVolume* tube_phys = new G4PVPlacement(0, G4ThreeVector(-200.*cm, 0., 0.*cm), "tubeP", tube_log, world_phys, false, 0); G4double divided_tube_dPhi = tube_dPhi/6.; G4VSolid* divided_tube = new G4Tubs("divided_tube", 20*cm, 50*cm, 30*cm, -divided_tube_dPhi/2., divided_tube_dPhi); G4LogicalVolume* divided_tube_log = new G4LogicalVolume(divided_tube, Ar, "div_tubeL", 0, 0, 0); G4VPhysicalVolume* divided_tube_phys = new G4PVReplica("divided_tube_phys", divided_tube_log, tube_log, kPhi, 6, divided_tube_dPhi);
Detector Description - Geant4 Course 15
Divided Physical VolumesDivided Physical Volumes
Implemented as “special” kind of parameterised volumes Applies to CSG-like and some specific solids
only (box, tubs, cons, para, trd, polycone, polyhedra)
Divides a volume along one of its axis (copies are not strictly identical)
• E.g. - a tube divided along its radial axis• Offsets can be specified
The possible axes of division vary according to the supported solid type
G4PVDivision is the class defining the division The parameterisation is calculated
automatically using the values provided in input
TouchablesTouchables
- Definition of Touchables
- Benefits in Track
- Examples
Detector Description - Geant4 Course 17
How to identify a volume uniquely?How to identify a volume uniquely? Suppose a geometry is made of
sensitive layers C which are placed in a volume B
The volume A has a 24
positions in the world
While in the 'logical' geometry tree the volume C is represented by just one physical volume, in the real world there are many C 'volumes'
How can we then identify these volumes C ?
Volume B is a daughter volume of a divided volume A
B C
B
A
Detector Description - Geant4 Course 18
Basics of TouchablesBasics of Touchables A touchable for a volume serves the purpose
of providing a unique identification for a detector element
It is a geometrical entity (volume or solid) which has a unique placement in a detector description
It can be uniquely identified by providing the copy numbers for all daughters in the geometry hierarchy
In our case these are
• CopyNo of C in B: 1
• CopyNo of B in A: 1,2,3
• CopyNo of A in the world: 1, .., 24
Example of touchable identification:
• A.3/B.2/C.1 A.1 A.2 A.3 A.4 ...
C.1
B.1B.2B.3
Detector Description - Geant4 Course 19
What can a touchable do ?What can a touchable do ? G4VTouchable - a base class for all touchable implementations – defines
the following 'requests' (methods) which all touchable have to respond, where depth means always the number of levels up in the tree to be considered: depth = 0 : the bottom level (volume C in B)
depth = 1 : the level of its mother volume (volume B in A)
depth = 2 : the grandmother volume (volume A in world) GetCopyNumber(G4int depth =0)
returns the copy number of the given level GetTranslation(G4int depth = 0); GetRotation(G4int depth=0)
return the components of the volume's transformation GetSolid(G4int depth =0)
returns the solid GetVolume(G4int depth =0)
returns the physical volume
Detector Description - Geant4 Course 20
Benefits of Touchables in trackBenefits of Touchables in track
•A1A1 •A2A2
Full geometrical information available to processes, to sensitive detectors, to hits
All the geometrical information of the particular step should be taken from “PreStepPoint” Available in G4TouchableHistory object
• Copy-number, transformations Accessible via Handles (or smart-pointers) to
touchables Note: Geometrical information associated with G4Track
is basically same as “PostStepPoint”
Detector Description - Geant4 Course 21
Using Touchable: examplesUsing Touchable: examples Touchable has information of geometrical
hierarchy of the point
G4StepPoint* preStepPoint = ... ;
G4TouchableHandle theTouchable
= preStepPoint->GetTouchableHandle();
// Get copyNo, motherCopyNo
G4int copyNo = theTouchable->GetReplicaNumber();
G4int motherCopyNo = theTouchable->GetReplicaNumber(1);
// Convert point in local coordinates (local to the current volume)
G4ThreeVector worldPos = preStepPoint->GetPosition();
G4ThreeVector localPos
= theTouchable->GetHistory()
-> GetTopTransform().TransformPoint(worldPos);
RegionsRegions
- Cuts by Region
- Concept of Region
- Example
Detector Description - Geant4 Course 23
Cuts by RegionCuts by Region
Geant4 used to have a unique production threshold (‘cut’) expressed in length (i.e. minimum range of secondary) For all volumes, but possibly different for each particle(e+,e-,gamma)
Appropriate length scales can vary greatly between different areas of a large detector E.g. a vertex detector (5 m) and a muon detector (2.5 cm) Having a unique (low) cut can create a performance penalty
Geant4 allows for several cuts Globally or per particle Enabling the tuning of production thresholds at the level of a sub-
detector, i.e. region Cuts are applied only for gamma, electron and positron and only for
processes which have infrared divergence
Detector Description - Geant4 Course 24
Detector RegionDetector Region
Concept of region: Set of geometry volumes,
typically of a sub-system• barrel + end-caps of the
calorimeter;• “Deep” areas of support
structures can be a region. Or any group of volumes
A set of cuts in range is associated to a region a different range cut for each
particle among gamma, e-, e+ is allowed in a region
Is unique in the region
Region B
RegionB
DefaultRegion Region B
Region B
Region A
CC
Detector Description - Geant4 Course25
World Volume - Default Region
Region and cutRegion and cut
World volume is recognized as the default region. The default cuts defined in Physics list are used for it. User is not allowed to define a region
to the world volume or a cut to the default region
A logical volume becomes a root logical volume once it is assigned to a region. All daughter volumes belonging to the
root logical volume share the same region (and properties),
unless a daughter volume itself becomes to another root logical volume
Important restriction : No logical volume can be shared by
more than one regions, regardless of root volume or not
Root logical - Region A
Root logical - Region B
Detector Description - Geant4 Course 26
ExampleExample// Create a regionG4Region* emCalorimeter = new G4Region(“EM-Calorimeter”);// Attach a logical volume to the regionemCalorimeter->AddRootLogicalVolume(emCalorimeterLV);[…]// Retrieve the region by its nameG4Region* region = G4RegionStore::GetInstance()->GetRegion(“EM-Calorimeter”);// Create production cutscuts = new G4ProductionCuts;cuts->SetProductionCut(0.01*mm, G4ProductionCuts::GetIndex(“gamma”));cuts->SetProductionCut(0.1*mm, G4ProductionCuts::GetIndex(“e-”));cuts->SetProductionCut(0.1*mm, G4ProductionCuts::GetIndex(“e+”));// Attach cuts to the regionregion->SetProductionCuts(cuts);
Optimisation Optimisation TechniquesTechniques
- Smart voxels
Detector Description - Geant4 Course 28
Smart voxelsSmart voxels
For each mother volume a one-dimensional virtual division is performed
• the virtual division is along a chosen axis• the axis is chosen by using an heuristic
Subdivisions (slices) containing same volumes are gathered into one
Subdivisions containing many volumes are refined• applying a virtual division again using a second Cartesian axis• the third axis can be used for a further refinement, in case
Smart voxels are computed at initialisation time When the detector geometry is closed Do not require large memory or computing resources At tracking time, searching is done in a hierarchy of virtual
divisions
Detector Description - Geant4 Course 29
Detector description tuningDetector 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
Detector Description - Geant4 Course 30
Visualising voxel structureVisualising voxel structure The computed voxel structure can be visualized
with the final detector geometryHelper class G4DrawVoxelsVisualize voxels given a logical volume
• G4DrawVoxels::DrawVoxels(const G4LogicalVolume*)
Allows setting of visualization attributes for voxels• G4DrawVoxels::SetVoxelsVisAttributes(…)
useful for debugging purposesCan also be done through a visualization
command at run-time:• /vis/scene/add/logicalVolume <logical-volume-name> [<depth>]
Detector Description - Geant4 Course 31
Customising optimisationCustomising optimisation
Detector regions may be excluded from optimisation (ex. for debug purposes or in case of dynamic geometries) Optional argument in constructor of G4LogicalVolume or
through provided set methods• SetOptimisation/IsToOptimise()
Optimisation is turned on by default
Optimisation for parameterised volumes can be chosen Along one single Cartesian axis
• Specifying the axis in the constructor for G4PVParameterised Using 3D voxelisation along the 3 Cartesian axes
• Specifying in kUndefined in the constructor for G4PVParameterised
Debugging geometriesDebugging geometries
Debugging tools:
- Optional checks at Construction
- David
- Run-time commands
- OLAP
Detector Description - Geant4 Course 33
Debugging Debugging geometriesgeometries
An overlapping volume is a contained volume which actually protrudes from its mother volume Volumes are also often positioned in a same volume with the
intent of not provoking intersections between themselves. When volumes in a common mother actually intersect themselves are defined as overlapping
Geant4 does not allow for malformed geometries The problem of detecting overlaps between volumes is
bounded by the complexity of the solid models description Utilities are provided for detecting wrong positioning
Graphical tools Kernel run-time commands
protruding overlapping
34
Constructors of G4PVPlacement and G4PVParameterised have an optional argument “pSurfChk”:G4PVPlacement(G4RotationMatrix* pRot, ..., ,
G4bool pSurfChk=false); If this flag is true, overlap check is done at construction.
Some number of points(1000 by default) are randomly sampled on the surface of creating volume.
Each of these points are examined• If it is outside of the mother volume, or• If it is inside of already existing other volumes in the
same mother volume. This check may requires lots of CPU time( depending on
the complexity of geometry), but it is worth to try at least once when you implement your geometry of some complexity.
Debugging tools:Debugging tools: Overlapping check at Overlapping check at ConstructionConstruction
Detector Description - Geant4 Course
Detector Description - Geant4 Course 35
Debugging tools: DAVIDDebugging tools: DAVID
DAVID is a graphical debugging tool for detecting potential intersections of volumes
Accuracy of the graphical representation can be tuned to the exact geometrical description. physical-volume surfaces are automatically
decomposed into 3D polygons intersections of the generated polygons are
parsed. If a polygon intersects with another one, the
physical volumes associated to these polygons are highlighted in color (red is the default).
DAVID can be downloaded from the Web as external tool for Geant4
http://geant4.kek.jp/GEANT4/vis/DAWN/About_DAVID.html
Detector Description - Geant4 Course 36
Debugging run-time commandsDebugging run-time commands
Built-in run-time commands to activate verification tests for the user geometry. Tests can be applied recursively to all depth levels (may require CPU time!): [recursion_flag]
geometry/test/run [recursion_flag] orgeometry/test/grid_test [recursion_flag] to start verification of geometry for overlapping regions based on
a standard grid setupgeometry/test/cylinder_test [recursion_flag] shoots lines according to a cylindrical patterngeometry/test/line_test [recursion_flag] to shoot a line along a specified direction and positiongeometry/test/position and geometry/test/direction to specify position & direction for the line_test
Resolution/dimensions of grid/cylinders can be tuned
Detector Description - Geant4 Course 37
Debugging run-time commandsDebugging run-time commands - 2 - 2
Example layout:
GeomTest: no daughter volume extending outside mother detected.GeomTest Error: Overlapping daughter volumes The volumes Tracker[0] and Overlap[0], both daughters of volume World[0], appear to overlap at the following points in global coordinates: (list truncated) length (cm) ----- start position (cm) ----- ----- end position (cm) ----- 240 -240 -145.5 -145.5 0 -145.5 -145.5Which in the mother coordinate system are: length (cm) ----- start position (cm) ----- ----- end position (cm) ----- . . .Which in the coordinate system of Tracker[0] are: length (cm) ----- start position (cm) ----- ----- end position (cm) ----- . . .Which in the coordinate system of Overlap[0] are: length (cm) ----- start position (cm) ----- ----- end position (cm) ----- . . .
Detector Description - Geant4 Course 38
Debugging tools: OLAPDebugging tools: OLAP
Uses tracking of neutral particles to verify boundary crossing in opposite directions
Stand-alone batch applicationProvided as extended exampleCan be combined with a graphical
environment and GUI (ex. Qt library)Integrated in the CMS Iguana Framework
Detector Description - Geant4 Course 39
Debugging tools: OLAPDebugging tools: OLAP
Detector DescriptionDetector DescriptionAdvanced featuresAdvanced features
- Grouping volumes
- Reflections of volumes and hierarchies
Detector Description - Geant4 Course 41
Grouping volumesGrouping 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
Assembly volume : G4AssemblyVolume 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
Detector Description - Geant4 Course 42
G4AssemblyVolumeG4AssemblyVolume
G4AssemblyVolume::AddPlacedVolume( G4LogicalVolume* volume, G4ThreeVector& translation, G4RotationMatrix* rotation);
Helper class to combine logical volumes in arbitrary way Participating logical volumes are treated as triplets
• logical volume, translation, rotation 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)
Detector Description - Geant4 Course 43
Assembly of volumes:Assembly of volumes:Example (first part)Example (first part)// Define a plateG4VSolid* PlateBox = new G4Box( "PlateBox", ...);G4LogicalVolume* plateLV = new G4LogicalVolume( PlateBox, Pb, "PlateLV");
// Define one layer as one assembly volumeG4AssemblyVolume* assemblyDetector = new G4AssemblyVolume();
// Define transformations of each plate inside the assembly:// transform3D_1, transform3D_2, transform3D_3, transform3D_4, // Fill the assembly by the platesassemblyDetector->AddPlacedVolume( plateLV, transform3D_1 );assemblyDetector->AddPlacedVolume( plateLV, transform3D_2 );assemblyDetector->AddPlacedVolume( plateLV, transform3D_3 );assemblyDetector->AddPlacedVolume( plateLV, transform3D_4 );
// Now instantiate (place) the layersfor( unsigned int i = 0; i < layers; i++ ) { // Translation of the assembly inside the world G4ThreeVector Tm(0, 0, i*(caloZ + caloCaloOffset) - firstCaloPos); assemblyDetector->MakeImprint( worldLV, G4Transform3D(Rm,Tm) );}
Detector Description - Geant4 Course 44
Assembly of volumes:Assembly of volumes:Example (cont.)Example (cont.)
Detector Description - Geant4 Course 45
Reflecting volumesReflecting volumes
G4ReflectedSolid utility class representing a solid shifted from its
original reference frame to a new symmetric one the reflection (G4Reflect[X/Y/Z]3D) is applied
directly to a solid, and a reflected solid is placed with “pure” rotation and translation
G4ReflectionFactory
Singleton object using G4ReflectedSolid for generating placements of reflected volumes
Provides tools to detect/return a reflected volume Reflections can be applied to CSG and specific solids
Detector Description - Geant4 Course 46
Reflecting hierarchies of volumes - 1Reflecting hierarchies of volumes - 1
G4ReflectionFactory::Place(…) Used for normal placements:
i. Performs the transformation decompositionii. 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
G4PhysicalVolumesPairPlace(const G4Transform3D& transform3D, // the transformation const G4String& name, // the actual name G4LogicalVolume* LV, // the logical volume G4LogicalVolume* motherLV, // the mother volume G4bool noBool, // currently unused G4int copyNo) // optional copy number
Detector Description - Geant4 Course 47
Reflecting hierarchies of volumes - 2Reflecting hierarchies of volumes - 2
G4ReflectionFactory::Replicate(…) Creates replicas in the given mother volume Returns a pair of physical volumes, the second being a
replica in the reflected mother
G4PhysicalVolumesPairReplicate(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
Magnetic fieldMagnetic field
- Defining Magnetic Field
Detector Description - Geant4 Course 49
Magnetic field - 1Magnetic field - 1
Magnetic field class Uniform field :
G4UniformMagField class object: G4MagneticField* magField = new G4UniformMagField(G4ThreeVector(0, 0, 1.*Tesla));
Non-uniform field :
User has to define his own concrete class derived from G4MagneticField, which implements the method GetFieldValue(..)
Detector Description - Geant4 Course50
Magnetic field - 2Magnetic field - 2 Set your Field as the ‘global’ Field
1. Retrieve the global Field Manager from G4TransportationManager
G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager() ->GetFieldManager();
2. Register the field to the Field Manager fieldMgr->SetDetectorField(magField);
3. Create a Chord Finder fieldMgr->CreateChordFinder(magField);
Tune the parameters of tracking in Field in order to
adjust accuracy(ex.microbeam or planet) and performance
Details are described in section 4.3 (Electromagnetic Field) in the
Application Developers Guide.
Novice example N04 is a good starting point