Detector Geometry Interface
Implementation
Andrea Dotti (adotti@slac.stanford.edu) ; SD/EPP/Computing
Document: https://gitlab.com/ESC/documents
Introduction
Proposed Work Plan
Recap of discussion so far
Describe geometry in terms of shapes, materials and (hierarchical) structure is not enough
Main issue is how to associate Sensitivity and exchange this information between applications/detectors
Start with GDML
Already available: examples/extended/persistency/gdml/G04 : “Simple example showing how to associate detector sensitivity to a logical-volume, making use of the auxiliary-information.”
Some definitions first
What is a G4Hit and what is a Sensitive Detector?
Geant4 performs simulation in steps: the atomistic-unit of the simulation: two (ordered) points in space, with associated energy deposit. One and only one track is associated to any given step. At any given moment during the simulation only one step exists in a Geant4 application (the current step)
A (Geant4) hit is a way for the user to make this information persist for the duration of an event, see: Geant4 Application Developers Manual chapter 4.4 Hits are organized in collections of the same type (e.g. c++ class), and SDs are responsible of creating and filling one or more collections
Consequences
A G4Hit is not the response of the detector (e.g. pulse shape, digital output, response of a PMT)
In Geant4 the concept of G4Digit is used for this (limited use)
However often some low-level detector effects (Birks’ saturation, some zero suppression) are included in hits for convenience
A SD a relatively simple algorithm that transforms the G4Step in a G4Hit
With some detectors (e.g. calorimeters) it is impractical to transform each single G4Step to a hit (too many), thus accumulation is preferred (e.g. one hit per calorimeter cell, that accumulates all energy deposits)
Moving forward
Proposal
Hits
Define three types of hits (names to be changed):
A hit is identified by a key
The key is unique given an event and a collection
Does not have to be a number (e.g. a tuple, an hash, a name)
Managing Hits
Once the hit structure is defined, SDs make the mapping
Develop simple and generic SDs that can create these hits. This could be used as a starting point for a new detector-specific developments or used directly without modifications
Geant4 integration 1
With this approach, SDs and Hits become detector independent, a stand-alone library will be created
Based on example G04: should show how to integrate w/ GDML. Any framework/detector (+our library) should be able share GDML
An optional part of the library could also provide a way to write out hits in files (options: ROOT, gprotobuf, HDF5, ASCII, …)
Note: hits file are not self-describing, one needs the GDML to be able to do reconstruction (e.g. same calorimeter hits with two different inner detectors)
Geant4 integration 2
Starting from Geant4 10.3 (2016), it is possible to have multiple SD associated to a single (logical) volume
Add our SDs to an existing detector preserving existing code
What should be in a hit: “tracker”
ID | Int |
Volume ID(s) | []*sizeof(int) OR []*string |
PreStepPoint {x,y,z,t} | 4*sizeof(double) |
PostStepPoint {x,y,z,t} | 4*sizeof(double) |
ΔE | 1*sizeof(double) |
PDG code | sizeof(long) //needed for ions |
Truth {Px,Py,Pz,E} | 4*sizeof(double) |
| 896B + IDs |
We can talk about space optimization later (e.g. save one time in double and Δt in float, direction angles and step length in float)
What should be in a hit: “calorimeter”
ID | Int |
Volume ID(s) | []*sizeof(int) OR []*string |
Characteristic space Point {x,y,z} | 3*sizeof(double) |
Min t and Max t | 2*sizeof(double) |
At least one ΔE (for time info needs to distinguish late hits) | >1*sizeof(double) |
PDG codes? All, only for ΔE>min{threshold,0} | >1*sizeof(long) //needed for ions |
Truth {Px,Py,Pz,E}? All only one for ΔE>{threshold,0} | >4*sizeof(double) |
| >704B + ID |
The idea is to have hits independent of detector effects (e.g. no cut on t), to be able to reprocess hits with different “detector electronics setups”. But we could allow to have simplified hits with less information (e.g. fixed time cut)
Calorimeter hits
Much more challenging because they depend on how the detector is defined (e.g. calorimeters cell structure)
As a first step we could implement the “tracker” hits, that are logically simpler
Possibilities:
Remember: the idea is that complete applications keep their existing systems
Locating a step: and write in hit this ocation
The input to an SD is a G4Step, one can locate its position in a detector-independent way:
auto point = aStep->GetPreStepPoint();
auto touchable = point->GetTouchable();
int copyN = touchable->GetCopyNumber( depth = 0);
int replicaN = touchable->GetReplicaNumber( depth = 0);
/*
auto physvol = touchable->GetVolume( depth = 0);
auto lv = physvol->GetLogicalVolume();
const G4String& name = lv->GetName();
*/
Loop on depth to “climb”
geometry hierarchy