forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DetectorConstruction.hh
85 lines (68 loc) · 2.2 KB
/
DetectorConstruction.hh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//----------------------------------*-C++-*----------------------------------//
// Copyright 2022-2023 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celer-g4/DetectorConstruction.hh
//---------------------------------------------------------------------------//
#pragma once
#include <map>
#include <memory>
#include <string>
#include <G4VUserDetectorConstruction.hh>
#include "accel/SetupOptions.hh"
class G4LogicalVolume;
class G4MagneticField;
namespace celeritas
{
class SharedParams;
class GeantSimpleCalo;
namespace app
{
//---------------------------------------------------------------------------//
/*!
* Construct a detector from a GDML filename set in GlobalSetup.
*/
class DetectorConstruction final : public G4VUserDetectorConstruction
{
public:
//!@{
//! \name Type aliases
using SPParams = std::shared_ptr<SharedParams>;
//!@}
public:
// Set up global celeritas SD options during construction
explicit DetectorConstruction(SPParams params);
G4VPhysicalVolume* Construct() final;
void ConstructSDandField() final;
private:
//// TYPES ////
using UPPhysicalVolume = std::unique_ptr<G4VPhysicalVolume>;
using MapDetectors = std::multimap<std::string, G4LogicalVolume*>;
using AlongStepFactory = SetupOptions::AlongStepFactory;
using SPMagneticField = std::shared_ptr<G4MagneticField>;
using SPSimpleCalo = std::shared_ptr<GeantSimpleCalo>;
struct GeoData
{
MapDetectors detectors;
UPPhysicalVolume world;
};
struct FieldData
{
AlongStepFactory along_step;
SPMagneticField g4field;
};
//// DATA ////
SPParams params_;
MapDetectors detectors_;
SPMagneticField mag_field_;
std::vector<SPSimpleCalo> simple_calos_;
//// METHODS ////
GeoData construct_geo() const;
FieldData construct_field() const;
template<class F>
void foreach_detector(F&&) const;
};
//---------------------------------------------------------------------------//
} // namespace app
} // namespace celeritas