19
19
#include "Geant4/G4Step.hh"
20
20
#include "Geant4/G4ParticleTable.hh"
21
#include "Geant4/G4Material.hh"
22
#include "Geant4/G4GRSVolume.hh"
23
#include "Geant4/G4RotationMatrix.hh"
24
#include "Geant4/G4ThreeVector.hh"
25
#include "Geant4/G4PVPlacement.hh"
22
27
#include "src/common_cpp/Utils/JsonWrapper.hh"
23
28
#include "src/common_cpp/Simulation/MAUSGeant4Manager.hh"
35
40
G4ParticleDefinition* pd =
36
41
G4ParticleTable::GetParticleTable()->FindParticle(-13);
37
42
G4DynamicParticle* dyn =
38
new G4DynamicParticle(pd, G4ThreeVector(1., 2., 3.));
43
new G4DynamicParticle(pd, G4ThreeVector(1., 2., 3.));
39
45
track = new G4Track(dyn, 7., G4ThreeVector(4., 5., 6.));
41
47
step = new G4Step(); // memory leak?
131
137
// test that we write to json correctly
132
138
TEST_F(MAUSSteppingActionTest, StepToJsonTest) {
139
G4Material material("material_test", 1, 1, 1.);
140
post->SetMaterial(&material);
133
142
Json::Value out = stepping->StepToJson(step, true);
134
143
EXPECT_DOUBLE_EQ(out["position"]["x"].asDouble(), point->GetPosition().x());
135
144
EXPECT_DOUBLE_EQ(out["position"]["y"].asDouble(), point->GetPosition().y());
152
161
EXPECT_DOUBLE_EQ(out["proper_time"].asDouble(), point->GetProperTime());
153
162
EXPECT_DOUBLE_EQ(out["path_length"].asDouble(), track->GetTrackLength());
164
EXPECT_EQ(out["material"].asString(), "");
165
EXPECT_EQ(out["volume"].asString(), "");
155
167
out = stepping->StepToJson(step, false);
156
168
EXPECT_DOUBLE_EQ(out["time"].asDouble(), post->GetGlobalTime());
169
EXPECT_EQ(out["material"].asString(), "material_test");
172
// test that we write volume to json correctly; disabled because it throws a
175
TEST_F(MAUSSteppingActionTest, StepToJsonVolumeTest) {
176
G4RotationMatrix rot;
177
G4ThreeVector vec(1., 1., 1.);
178
G4PVPlacement vol(&rot, vec, NULL, "volume_test", NULL, false, 0);
179
G4GRSVolume touchable(&vol, rot, vec);
181
point->SetTouchableHandle(&touchable);
183
Json::Value out = stepping->StepToJson(step, true);
184
EXPECT_EQ(out["volume"].asString(), "volume_test");
158
188
G4Track* SetG4TrackAndStep(G4Step* step) {
159
189
G4ParticleDefinition* pd =
160
190
G4ParticleTable::GetParticleTable()->FindParticle(-13);