~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to tests/cpp_unit/Simulation/MAUSSteppingActionTest.cc

  • Committer: Durga Rajaram
  • Date: 2014-10-06 20:45:37 UTC
  • mfrom: (697.24.7 trunk)
  • mto: (697.30.10 maus)
  • mto: This revision was merged to the branch mainline in revision 703.
  • Revision ID: durga@fnal.gov-20141006204537-1aokre71ss0b2vcv
merge from trunk; set part_event_number for extra emr events

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
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"
21
26
 
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.));
 
44
 
39
45
    track = new G4Track(dyn, 7., G4ThreeVector(4., 5., 6.));
40
46
 
41
47
    step = new G4Step(); // memory leak?
130
136
}
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);
 
141
 
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());
154
163
 
 
164
  EXPECT_EQ(out["material"].asString(), "");
 
165
  EXPECT_EQ(out["volume"].asString(), "");
 
166
 
155
167
  out = stepping->StepToJson(step, false);
156
168
  EXPECT_DOUBLE_EQ(out["time"].asDouble(), post->GetGlobalTime());
157
 
}
 
169
  EXPECT_EQ(out["material"].asString(), "material_test");
 
170
}
 
171
 
 
172
// test that we write volume to json correctly; disabled because it throws a
 
173
// G4Exception
 
174
/*
 
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);
 
180
 
 
181
  point->SetTouchableHandle(&touchable);
 
182
 
 
183
  Json::Value out = stepping->StepToJson(step, true);
 
184
  EXPECT_EQ(out["volume"].asString(), "volume_test");
 
185
}
 
186
*/
 
187
 
158
188
G4Track* SetG4TrackAndStep(G4Step* step) {
159
189
  G4ParticleDefinition* pd =
160
190
                       G4ParticleTable::GetParticleTable()->FindParticle(-13);