Loading src/modules/DepositionGeant4/DepositionGeant4Module.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -391,9 +391,12 @@ void DepositionGeant4Module::construct_sensitive_detectors_and_fields(double fan } useful_deposition = true; // Get the hit transformation matrix auto* hit_transform = calculate_hit_transform(detector->getModel()); // Get model of the sensitive device auto* sensitive_detector_action = new SensitiveDetectorActionG4( detector, track_info_manager_.get(), charge_creation_energy, fano_factor, cutoff_time); detector, track_info_manager_.get(), hit_transform, charge_creation_energy, fano_factor, cutoff_time); auto logical_volume = geo_manager_->getExternalObject<G4LogicalVolume>(detector->getName(), "sensor_log"); if(logical_volume == nullptr) { throw ModuleError("Detector " + detector->getName() + " has no sensitive device (broken Geant4 geometry)"); Loading Loading @@ -444,3 +447,7 @@ void DepositionGeant4Module::record_module_statistics() { total_charges_ += sensor->getTotalDepositedCharge(); } } G4RotationMatrix* DepositionGeant4Module::calculate_hit_transform(const std::shared_ptr<DetectorModel>&) { return new G4RotationMatrix(); } src/modules/DepositionGeant4/DepositionGeant4Module.hpp +10 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,16 @@ namespace allpix { */ void record_module_statistics(); /** * @brief Calculate hit transformation matrix for a given detector model * @param model Detector model * @returns Hit transformation matrix pointer * * @note This matrix transforms the Geant4 local coordinate system of the sensor * volume to the APSQ local coordinate system based on the detector model type. */ G4RotationMatrix* calculate_hit_transform(const std::shared_ptr<DetectorModel>& model); Messenger* messenger_; GeometryManager* geo_manager_; Loading src/modules/DepositionGeant4/SensitiveDetectorActionG4.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ using namespace allpix; SensitiveDetectorActionG4::SensitiveDetectorActionG4(const std::shared_ptr<Detector>& detector, TrackInfoManager* track_info_manager, const G4RotationMatrix* hit_transform, double charge_creation_energy, double fano_factor, double cutoff_time) Loading @@ -46,6 +47,8 @@ SensitiveDetectorActionG4::SensitiveDetectorActionG4(const std::shared_ptr<Detec // Add the sensor to the internal sensitive detector manager G4SDManager* sd_man_g4 = G4SDManager::GetSDMpointer(); sd_man_g4->AddNewDetector(this); hit_transform_ = hit_transform; } G4bool SensitiveDetectorActionG4::ProcessHits(G4Step* step, G4TouchableHistory*) { Loading Loading @@ -74,6 +77,9 @@ G4bool SensitiveDetectorActionG4::ProcessHits(G4Step* step, G4TouchableHistory*) auto deposit_position = detector_->getLocalPosition(static_cast<ROOT::Math::XYZPoint>(step_pos)); auto deposit_position_g4 = theTouchable->GetHistory()->GetTopTransform().TransformPoint(step_pos); // Transform the hit position using the rotation matrix deposit_position_g4 *= *hit_transform_; // Calculate number of electron hole pairs produced, taking into account fluctuations between ionization and lattice // excitations via the Fano factor. We assume Gaussian statistics here. auto mean_charge = edep / charge_creation_energy_; Loading src/modules/DepositionGeant4/SensitiveDetectorActionG4.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -36,12 +36,14 @@ namespace allpix { * @brief Constructs the action handling for every sensitive detector * @param detector Detector this sensitive device is bound to * @param track_info_manager Pointer to the track information manager * @param hit_transform Pointer to the hit transformation matrix * @param charge_creation_energy Energy needed per deposited charge * @param fano_factor Fano factor for fluctuations in the energy fraction going into e/h pair creation * @param cutoff_time Cut-off time for the creation of secondary particles */ SensitiveDetectorActionG4(const std::shared_ptr<Detector>& detector, TrackInfoManager* track_info_manager, const G4RotationMatrix* hit_transform, double charge_creation_energy, double fano_factor, double cutoff_time); Loading Loading @@ -124,6 +126,8 @@ namespace allpix { std::vector<int> deposit_to_id_; // Map from track id to mc particle index std::map<int, size_t> id_to_particle_; const G4RotationMatrix* hit_transform_; }; } // namespace allpix Loading Loading
src/modules/DepositionGeant4/DepositionGeant4Module.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -391,9 +391,12 @@ void DepositionGeant4Module::construct_sensitive_detectors_and_fields(double fan } useful_deposition = true; // Get the hit transformation matrix auto* hit_transform = calculate_hit_transform(detector->getModel()); // Get model of the sensitive device auto* sensitive_detector_action = new SensitiveDetectorActionG4( detector, track_info_manager_.get(), charge_creation_energy, fano_factor, cutoff_time); detector, track_info_manager_.get(), hit_transform, charge_creation_energy, fano_factor, cutoff_time); auto logical_volume = geo_manager_->getExternalObject<G4LogicalVolume>(detector->getName(), "sensor_log"); if(logical_volume == nullptr) { throw ModuleError("Detector " + detector->getName() + " has no sensitive device (broken Geant4 geometry)"); Loading Loading @@ -444,3 +447,7 @@ void DepositionGeant4Module::record_module_statistics() { total_charges_ += sensor->getTotalDepositedCharge(); } } G4RotationMatrix* DepositionGeant4Module::calculate_hit_transform(const std::shared_ptr<DetectorModel>&) { return new G4RotationMatrix(); }
src/modules/DepositionGeant4/DepositionGeant4Module.hpp +10 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,16 @@ namespace allpix { */ void record_module_statistics(); /** * @brief Calculate hit transformation matrix for a given detector model * @param model Detector model * @returns Hit transformation matrix pointer * * @note This matrix transforms the Geant4 local coordinate system of the sensor * volume to the APSQ local coordinate system based on the detector model type. */ G4RotationMatrix* calculate_hit_transform(const std::shared_ptr<DetectorModel>& model); Messenger* messenger_; GeometryManager* geo_manager_; Loading
src/modules/DepositionGeant4/SensitiveDetectorActionG4.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ using namespace allpix; SensitiveDetectorActionG4::SensitiveDetectorActionG4(const std::shared_ptr<Detector>& detector, TrackInfoManager* track_info_manager, const G4RotationMatrix* hit_transform, double charge_creation_energy, double fano_factor, double cutoff_time) Loading @@ -46,6 +47,8 @@ SensitiveDetectorActionG4::SensitiveDetectorActionG4(const std::shared_ptr<Detec // Add the sensor to the internal sensitive detector manager G4SDManager* sd_man_g4 = G4SDManager::GetSDMpointer(); sd_man_g4->AddNewDetector(this); hit_transform_ = hit_transform; } G4bool SensitiveDetectorActionG4::ProcessHits(G4Step* step, G4TouchableHistory*) { Loading Loading @@ -74,6 +77,9 @@ G4bool SensitiveDetectorActionG4::ProcessHits(G4Step* step, G4TouchableHistory*) auto deposit_position = detector_->getLocalPosition(static_cast<ROOT::Math::XYZPoint>(step_pos)); auto deposit_position_g4 = theTouchable->GetHistory()->GetTopTransform().TransformPoint(step_pos); // Transform the hit position using the rotation matrix deposit_position_g4 *= *hit_transform_; // Calculate number of electron hole pairs produced, taking into account fluctuations between ionization and lattice // excitations via the Fano factor. We assume Gaussian statistics here. auto mean_charge = edep / charge_creation_energy_; Loading
src/modules/DepositionGeant4/SensitiveDetectorActionG4.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -36,12 +36,14 @@ namespace allpix { * @brief Constructs the action handling for every sensitive detector * @param detector Detector this sensitive device is bound to * @param track_info_manager Pointer to the track information manager * @param hit_transform Pointer to the hit transformation matrix * @param charge_creation_energy Energy needed per deposited charge * @param fano_factor Fano factor for fluctuations in the energy fraction going into e/h pair creation * @param cutoff_time Cut-off time for the creation of secondary particles */ SensitiveDetectorActionG4(const std::shared_ptr<Detector>& detector, TrackInfoManager* track_info_manager, const G4RotationMatrix* hit_transform, double charge_creation_energy, double fano_factor, double cutoff_time); Loading Loading @@ -124,6 +126,8 @@ namespace allpix { std::vector<int> deposit_to_id_; // Map from track id to mc particle index std::map<int, size_t> id_to_particle_; const G4RotationMatrix* hit_transform_; }; } // namespace allpix Loading