-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeometry.cc
53 lines (40 loc) · 1017 Bytes
/
geometry.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "field.h"
#include "geometry.h"
#include <G4GDMLParser.hh>
#include <G4FieldManager.hh>
#include <G4TransportationManager.hh>
#include <G4UniformMagField.hh>
#include <err.h>
#include <unistd.h>
#include <cstdio>
static G4FieldManager *field_manager()
{
return G4TransportationManager::GetTransportationManager()->GetFieldManager();
}
static G4VPhysicalVolume *load_gdml(const char *gdml)
{
if (access(gdml, R_OK))
err(errno, "%s", gdml);
G4GDMLParser p;
p.Read(gdml, /* validate */ false);
auto world = p.GetWorldVolume();
if (!world)
errx(1, "error reading geometry file");
return world;
}
DetectorConstruction::DetectorConstruction(const char *gdml, const char *fieldopts)
{
world = load_gdml(gdml);
field = create_magnetic_field(fieldopts);
}
G4VPhysicalVolume *DetectorConstruction::Construct()
{
return world;
}
void DetectorConstruction::ConstructSDandField()
{
if (!field)
return;
field_manager()->SetDetectorField(field);
field_manager()->CreateChordFinder(field);
}