Download Geant4 User's Guide for Application Developers

Transcript
Detector Definition and Response
G4Allocator is a class for fast allocation of objects to the heap through the paging mechanism. For details of
G4Allocator, refer to Section 3.2.4. Use of G4Allocator is not mandatory, but it is recommended, especially for
users who are not familiar with the C++ memory allocation mechanism or alternative tools of memory allocation.
On the other hand, note that G4Allocator is to be used only for the concrete class that is not used as a base class
of any other classes. For example, do not use the G4Trajectory class as a base class for a customized trajectory
class, since G4Trajectory uses G4Allocator.
G4THitsMap
G4THitsMap is an alternative to G4THitsCollection. G4THitsMap does not demand G4VHit, but instead any
variable which can be mapped with an integer key. Typically the key is a copy number of the volume, and the
mapped value could for example be a double, such as the energy deposition in a volume. G4THitsMap is convenient for applications which do not need to output event-by-event data but instead just accumulate them. All the
G4VPrimitiveScorer classes discussed in Section 4.4.5 use G4THitsMap.
G4THitsMap is derived from the G4VHitsCollection abstract base class and all objects of this class are also stored
in G4HCofThisEvent at the end of an event. How to access a G4THitsMap object is discussed in the following
section (Section 4.4.5).
4.4.2. Sensitive detector
G4VSensitiveDetector
G4VSensitiveDetector is an abstract base class which represents a detector. The principal mandate of a sensitive detector is the construction of hit objects using information from steps along a particle track. The ProcessHits()
method of G4VSensitiveDetector performs this task using G4Step objects as input. In the case of a "Readout"
geometry (see Section 4.4.3), objects of the G4TouchableHistory class may be used as an optional input.
Your concrete detector class should be instantiated with the unique name of your detector. The name can be
associated with one or more global names with "/" as a delimiter for categorizing your detectors. For example
myEMcal = new MyEMcal("/myDet/myCal/myEMcal");
where myEMcal is the name of your detector. The pointer to your sensitive detector must be set to one or
more G4LogicalVolume objects to set the sensitivity of these volumes. The pointer should also be registered to
G4SDManager, as described in Section 4.4.4.
G4VSensitiveDetector has three major virtual methods.
ProcessHits()
This method is invoked by G4SteppingManager when a step is composed in the G4LogicalVolume which
has the pointer to this sensitive detector. The first argument of this method is a G4Step object of the current
step. The second argument is a G4TouchableHistory object for the ‘‘Readout geometry'' described in the next
section. The second argument is NULL if ‘‘Readout geometry'' is not assigned to this sensitive detector. In this
method, one or more G4VHit objects should be constructed if the current step is meaningful for your detector.
Initialize()
This method is invoked at the beginning of each event. The argument of this method is an object of
the G4HCofThisEvent class. Hit collections, where hits produced in this particular event are stored, can
be associated with the G4HCofThisEvent object in this method. The hit collections associated with the
G4HCofThisEvent object during this method can be used for ‘‘during the event processing'' digitization.
EndOfEvent()
This method is invoked at the end of each event. The argument of this method is the same object as the
previous method. Hit collections occasionally created in your sensitive detector can be associated with the
G4HCofThisEvent object.
119