forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeantSimpleCalo.hh
81 lines (69 loc) · 2.65 KB
/
GeantSimpleCalo.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
//----------------------------------*-C++-*----------------------------------//
// Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file accel/GeantSimpleCalo.hh
//---------------------------------------------------------------------------//
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "corecel/io/OutputInterface.hh"
#include "celeritas/Quantities.hh"
class G4LogicalVolume;
class G4VSensitiveDetector;
namespace celeritas
{
//---------------------------------------------------------------------------//
class SharedParams;
namespace detail
{
struct GeantSimpleCaloStorage;
}
//---------------------------------------------------------------------------//
/*!
* Manage a simple calorimeter sensitive detector across threads.
*
* The factory should be created in DetectorConstruction or
* DetectorConstruction::Construct and added to the output parameters. Calling
* \c MakeSensitiveDetector will emit a sensitive detector for the local thread
* *and attach it* to the logical volumes on the local thread.
*/
class GeantSimpleCalo final : public OutputInterface
{
public:
//!@{
//! \name Type aliases
using SPConstParams = std::shared_ptr<SharedParams const>;
using UPSensitiveDetector = std::unique_ptr<G4VSensitiveDetector>;
using VecLV = std::vector<G4LogicalVolume*>;
using VecReal = std::vector<double>;
using EnergyUnits = units::Mev;
//!@}
public:
// Construct with SD name and the volumes to attach the SD to
GeantSimpleCalo(std::string name, SPConstParams params, VecLV volumes);
// Emit a new detector for the local thread and attach to the stored LVs
UPSensitiveDetector MakeSensitiveDetector();
//! Get the list of volumes with this SD attached
VecLV const& Volumes() const { return volumes_; }
// Get accumulated energy deposition over all threads
VecReal CalcTotalEnergyDeposition() const;
//!@{
//! \name Output interface
//! Category of data to write
Category category() const final { return Category::result; }
// Key for the entry inside the category
std::string_view label() const final;
// Write output to the given JSON object
void output(JsonPimpl*) const final;
//!@}
private:
using SPStorage = std::shared_ptr<detail::GeantSimpleCaloStorage>;
SPConstParams params_;
VecLV volumes_;
SPStorage storage_;
};
//---------------------------------------------------------------------------//
} // namespace celeritas