5 #include "G4HCofThisEvent.hh"
7 #include "G4TouchableHistory.hh"
10 #include "G4StepPoint.hh"
11 #include "G4DynamicParticle.hh"
12 #include "G4ThreeVector.hh"
14 #include "G4NistManager.hh"
15 #include "G4Material.hh"
16 #include "G4VPhysicalVolume.hh"
17 #include "G4SystemOfUnits.hh"
24 void DerivedG4SensitiveDetectorTestSetting(G4Step& sp, G4double& totalEnergyDeposit, std::vector<G4String>& physicalNames, G4String& logicalName1, std::vector<G4int>& copyNos, G4ThreeVector& preStepPos, G4ThreeVector& postStepPos, G4double& globalTime0, G4double& kineticEnergy0, G4double& velocity0, G4double& globalTime, G4double& kineticEnergy, G4double& globalTime1, G4double& kineticEnergy1, G4double& velocity1, G4double& steplength, G4double&
charge, G4int&
encoding, G4int& antiencoding, G4String& astring, G4ProcessType& atype, G4String& nop1, G4String& nop2, G4String& nop3)
27 if (copyNos.size()!=physicalNames.size()) {
throw std::runtime_error(
"ERROR: physicalNames and copyNos must have the same length."); }
29 G4double TotalEnergyDeposit = totalEnergyDeposit;
30 sp.SetTotalEnergyDeposit( TotalEnergyDeposit );
34 G4StepPoint* stepPoint =
new G4StepPoint();
35 stepPoint->SetPosition(preStepPos);
36 G4NavigationHistory* navigationHistory =
new G4NavigationHistory();
37 G4String boxName =
"name";
38 G4Box* box =
new G4Box(boxName, 1.0, 1.0, 1.0);
39 G4NistManager* man = G4NistManager::Instance();
40 G4Material* material = man->FindOrBuildMaterial(
"G4_AIR");
41 G4String
name =
"logicalName";
42 G4LogicalVolume* fLogical =
new G4LogicalVolume(box, material,
name);
43 G4String PhysicalName = physicalNames[0];
44 G4VPhysicalVolume* pPhysical =
nullptr;
46 G4int CopyNo = copyNos[0];
49 navigationHistory->SetFirstEntry(physicalVolume);
50 if (physicalNames.size()==1) {
52 navigationHistory->NewLevel(physicalVolume, kNormal, nReplica);
53 navigationHistory->NewLevel(physicalVolume, kNormal, nReplica);
54 navigationHistory->NewLevel(physicalVolume, kNormal, nReplica);
55 navigationHistory->NewLevel(physicalVolume, kNormal, nReplica);
56 navigationHistory->NewLevel(physicalVolume, kNormal, nReplica);
61 for(
const auto&
name : physicalNames) {
66 navigationHistory->NewLevel(parentPhysVol, kNormal, nReplica);
69 G4TouchableHistory* touchableHistory =
new G4TouchableHistory(*navigationHistory);
70 G4TouchableHandle touchableHandle(touchableHistory);
71 stepPoint->SetTouchableHandle(touchableHandle);
72 G4double GlobalTime0 = globalTime0;
73 G4double KineticEnergy0 = kineticEnergy0;
74 G4double Velocity0 = velocity0;
75 stepPoint->SetGlobalTime(GlobalTime0);
76 stepPoint->SetKineticEnergy(KineticEnergy0);
77 stepPoint->SetVelocity(Velocity0);
79 sp.SetPreStepPoint(stepPoint);
83 G4StepPoint* stepPoint1 =
new G4StepPoint();
84 stepPoint1->SetPosition(postStepPos);
85 G4double GlobalTime1 = globalTime1;
86 G4double KineticEnergy1 = kineticEnergy1;
87 G4double Velocity1 = velocity1;
88 stepPoint1->SetGlobalTime(GlobalTime1);
89 stepPoint1->SetKineticEnergy(KineticEnergy1);
90 stepPoint1->SetVelocity(Velocity1);
92 sp.SetPostStepPoint(stepPoint1);
103 G4int Antiencoding = antiencoding;
104 G4String NOP1 = nop1;
105 G4String NOP2 = nop2;
106 G4String NOP3 = nop3;
107 G4ParticleDefinition*
particle =
new G4ParticleDefinition(NOP1, 0.0*
MeV, 0.0*
MeV, Charge,
110 NOP2, 0, 0, Encoding,
112 false, NOP3, Antiencoding
114 G4ThreeVector aMomentumDirection(0,0,0);
115 G4double aKineticEnergy = kineticEnergy;
116 G4DynamicParticle* dynamicPar =
new G4DynamicParticle(
particle, aMomentumDirection, aKineticEnergy);
117 G4double aValueTime = 1;
118 G4ThreeVector ValuePosition(1.0, 1.0, 1.0);
119 G4Track*
track =
new G4Track(dynamicPar, aValueTime, ValuePosition);
121 track->SetGlobalTime(globalTime);
123 track->SetTrackID(trackID);
124 G4String boxName1 =
"name";
125 G4Box* box1 =
new G4Box(boxName1, 1.0, 1.0, 1.0);
126 G4NistManager* man1 = G4NistManager::Instance();
127 G4Material* material1 = man1->FindOrBuildMaterial(
"G4_AIR");
128 G4String name2 = logicalName1;
129 G4LogicalVolume* fLogical1 =
new G4LogicalVolume(box1, material1, name2);
130 track->SetLogicalVolumeAtVertex(fLogical1);
131 G4Step* stepForTrack =
new G4Step();
132 G4StepPoint* stepPoint2 =
new G4StepPoint();
133 G4Material* mat1 = man1->FindOrBuildMaterial(
"G4_AIR");
134 G4MaterialPropertiesTable* propertiesTable =
new G4MaterialPropertiesTable();
136 G4double Values[5] = {1,2,3,4,5};
137 size_t VectorLength = 5;
138 G4MaterialPropertyVector* mpv =
new G4MaterialPropertyVector(
Energies, Values, VectorLength);
139 G4MaterialPropertyVector* mpv1 =
new G4MaterialPropertyVector(
Energies, Values, VectorLength);
140 propertiesTable->AddProperty(
"RINDEX", mpv);
141 propertiesTable->AddProperty(
"ABSLENGTH", mpv1);
142 mat1->SetMaterialPropertiesTable(propertiesTable);
143 stepPoint2->SetMaterial(mat1);
144 stepForTrack->SetPreStepPoint(stepPoint2);
145 track->SetStep(stepForTrack);
147 G4ProcessType aType = atype;
148 G4String aString = astring;
152 track->SetTouchableHandle(touchableHandle);