File indexing completed on 2025-02-22 09:54:43
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <memory>
0011 #include <string>
0012 #include <vector>
0013 #include <G4TouchableHandle.hh>
0014
0015 #include "celeritas/Types.hh"
0016 #include "celeritas/user/DetectorSteps.hh"
0017 #include "celeritas/user/StepData.hh"
0018
0019 class G4LogicalVolume;
0020 class G4Step;
0021 class G4Navigator;
0022 class G4ParticleDefinition;
0023 class G4Track;
0024 class G4VSensitiveDetector;
0025
0026 namespace celeritas
0027 {
0028 struct StepSelection;
0029 struct DetectorStepOutput;
0030
0031 namespace detail
0032 {
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 class HitProcessor
0052 {
0053 public:
0054
0055
0056 using StepStateHostRef = HostRef<StepStateData>;
0057 using StepStateDeviceRef = DeviceRef<StepStateData>;
0058 using SPConstVecLV
0059 = std::shared_ptr<std::vector<G4LogicalVolume const*> const>;
0060 using VecParticle = std::vector<G4ParticleDefinition const*>;
0061
0062
0063 public:
0064
0065 HitProcessor(SPConstVecLV detector_volumes,
0066 VecParticle const& particles,
0067 StepSelection const& selection,
0068 bool locate_touchable,
0069 StreamId stream);
0070
0071
0072 ~HitProcessor();
0073
0074
0075 void operator()(StepStateHostRef const&);
0076
0077
0078 void operator()(StepStateDeviceRef const&);
0079
0080
0081 void operator()(DetectorStepOutput const& out) const;
0082
0083
0084 inline G4LogicalVolume const* detector_volume(DetectorId) const;
0085
0086
0087 inline G4VSensitiveDetector* detector(DetectorId) const;
0088
0089 private:
0090
0091 SPConstVecLV detector_volumes_;
0092
0093 std::vector<G4VSensitiveDetector*> detectors_;
0094
0095 DetectorStepOutput steps_;
0096
0097
0098 std::unique_ptr<G4Step> step_;
0099
0100 std::vector<std::unique_ptr<G4Track>> tracks_;
0101
0102 std::unique_ptr<G4Navigator> navi_;
0103
0104 G4TouchableHandle touch_handle_;
0105
0106
0107 StepPointSelection post_step_selection_;
0108
0109
0110 StreamId stream_;
0111
0112 void update_track(ParticleId id) const;
0113 };
0114
0115
0116
0117
0118
0119
0120
0121 G4LogicalVolume const* HitProcessor::detector_volume(DetectorId did) const
0122 {
0123 CELER_EXPECT(did < detector_volumes_->size());
0124 return (*detector_volumes_)[did.unchecked_get()];
0125 }
0126
0127
0128
0129
0130
0131 G4VSensitiveDetector* HitProcessor::detector(DetectorId did) const
0132 {
0133 CELER_EXPECT(did < detectors_.size());
0134 return detectors_[did.unchecked_get()];
0135 }
0136
0137
0138 }
0139 }