G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
Loading...
Searching...
No Matches
G4OCCTSensitiveDetectorMap Class Reference

Maps volume name patterns to Geant4 G4VSensitiveDetector objects. More...

#include <G4OCCTSensitiveDetectorMap.hh>

Public Member Functions

 G4OCCTSensitiveDetectorMap ()=default
 
void Add (const G4String &pattern, G4VSensitiveDetector *sd)
 
G4VSensitiveDetector * Resolve (const G4String &volumeName) const
 
std::size_t Size () const
 

Detailed Description

Maps volume name patterns to Geant4 G4VSensitiveDetector objects.

Provides an ordered lookup table from volume name patterns to the corresponding Geant4 G4VSensitiveDetector pointers. Two matching strategies are supported (checked in insertion order; first match wins):

  1. Exact matchvolumeName == pattern
  2. Prefix matchvolumeName starts with pattern + "_" and the remaining suffix consists entirely of decimal digits. This handles Geant4's MakeUniqueName deduplication convention (e.g. "Absorber_1", "Absorber_2" are both matched by the pattern "Absorber").

Most volumes in a detector are not sensitive, so Resolve() returns nullptr for unmatched names rather than throwing a fatal error.

Usage

sdMap.Add("Absorber", absorberSD);
sdMap.Add("Gap", gapSD);
G4VSensitiveDetector* sd = sdMap.Resolve("Absorber_1"); // returns absorberSD
G4VSensitiveDetector* no = sdMap.Resolve("World"); // returns nullptr
Maps volume name patterns to Geant4 G4VSensitiveDetector objects.
void Add(const G4String &pattern, G4VSensitiveDetector *sd)
G4VSensitiveDetector * Resolve(const G4String &volumeName) const

Definition at line 44 of file G4OCCTSensitiveDetectorMap.hh.

Constructor & Destructor Documentation

◆ G4OCCTSensitiveDetectorMap()

G4OCCTSensitiveDetectorMap::G4OCCTSensitiveDetectorMap ( )
default

Member Function Documentation

◆ Add()

void G4OCCTSensitiveDetectorMap::Add ( const G4String &  pattern,
G4VSensitiveDetector *  sd 
)

Register a mapping from a volume name pattern to a sensitive detector.

If pattern is already registered the previous entry is silently overwritten.

Parameters
patternVolume name pattern (case-sensitive). Used for both exact and prefix matching (see class documentation).
sdNon-null pointer to the sensitive detector. A null pointer triggers a fatal G4Exception with code G4OCCT_SDMap000.

Definition at line 15 of file G4OCCTSensitiveDetectorMap.cc.

Referenced by G4OCCTAssemblySDSetup::Apply(), and G4OCCTSensitiveDetectorMapReader::ReadFile().

◆ Resolve()

G4VSensitiveDetector * G4OCCTSensitiveDetectorMap::Resolve ( const G4String &  volumeName) const

Look up the sensitive detector for a given volume name.

Checks each registered entry in insertion order and returns the first match (exact or prefix). Returns nullptr if no entry matches — this is the expected result for non-sensitive volumes.

Parameters
volumeNameGeant4 logical volume name to resolve.
Returns
Pointer to the matching G4VSensitiveDetector, or nullptr if no entry matches.

Definition at line 30 of file G4OCCTSensitiveDetectorMap.cc.

Referenced by G4OCCTAssemblyVolume::ApplySDMap().

◆ Size()

std::size_t G4OCCTSensitiveDetectorMap::Size ( ) const
inline

Return the number of registered entries.

Definition at line 77 of file G4OCCTSensitiveDetectorMap.hh.


The documentation for this class was generated from the following files: