Skip to content

Commit 1a7d9e4

Browse files
committed
Add binding for G4MultiSensitiveDetector
1 parent aca93b7 commit 1a7d9e4

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <pybind11/pybind11.h>
2+
#include <pybind11/stl.h>
3+
4+
#include <G4MultiSensitiveDetector.hh>
5+
6+
#include "typecast.hh"
7+
#include "opaques.hh"
8+
9+
namespace py = pybind11;
10+
11+
class PublicG4MultiSensitiveDetector : public G4MultiSensitiveDetector {
12+
public:
13+
using G4MultiSensitiveDetector::ProcessHits;
14+
};
15+
16+
// Trampolin class
17+
class PyG4MultiSensitiveDetector : public G4MultiSensitiveDetector, public py::trampoline_self_life_support {
18+
public:
19+
using G4MultiSensitiveDetector::G4MultiSensitiveDetector;
20+
21+
void Initialize(G4HCofThisEvent *hCofThisEvent) override
22+
{
23+
PYBIND11_OVERRIDE(void, G4MultiSensitiveDetector, Initialize, hCofThisEvent);
24+
}
25+
26+
void EndOfEvent(G4HCofThisEvent *hCofThisEvent) override
27+
{
28+
PYBIND11_OVERRIDE(void, G4MultiSensitiveDetector, EndOfEvent, hCofThisEvent);
29+
}
30+
31+
void clear() override { PYBIND11_OVERRIDE(void, G4MultiSensitiveDetector, clear, ); }
32+
33+
void DrawAll() override { PYBIND11_OVERRIDE(void, G4MultiSensitiveDetector, DrawAll, ); }
34+
35+
void PrintAll() override { PYBIND11_OVERRIDE(void, G4MultiSensitiveDetector, PrintAll, ); }
36+
37+
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override
38+
{
39+
PYBIND11_OVERRIDE(G4bool, G4MultiSensitiveDetector, ProcessHits, aStep, ROhist);
40+
}
41+
};
42+
43+
void export_G4MultiSensitiveDetector(py::module &m)
44+
{
45+
py::class_<G4MultiSensitiveDetector, PyG4MultiSensitiveDetector, G4VSensitiveDetector>(m, "G4MultiSensitiveDetector")
46+
47+
.def(py::init<G4String>())
48+
49+
.def("Initialize", &G4MultiSensitiveDetector::Initialize)
50+
.def("EndOfEvent", &G4MultiSensitiveDetector::EndOfEvent)
51+
.def("clear", &G4MultiSensitiveDetector::clear)
52+
.def("DrawAll", &G4MultiSensitiveDetector::DrawAll)
53+
.def("PrintAll", &G4MultiSensitiveDetector::PrintAll)
54+
.def("ProcessHits", &PublicG4MultiSensitiveDetector::ProcessHits)
55+
.def("GetSD", &G4MultiSensitiveDetector::GetSD)
56+
.def("GetSize", &G4MultiSensitiveDetector::GetSize)
57+
.def("ClearSDs", &G4MultiSensitiveDetector::ClearSDs)
58+
.def("AddSD", &G4MultiSensitiveDetector::AddSD);
59+
}

source/digits_hits/pymodG4digits_hits.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ void export_G4SDManager(py::module &);
1212
void export_G4VHitsCollection(py::module &);
1313
void export_G4HCofThisEvent(py::module &);
1414
void export_G4MultiFunctionalDetector(py::module &);
15+
void export_G4MultiSensitiveDetector(py::module &);
1516
void export_G4VSDFilter(py::module &);
1617
void export_G4SDFilter(py::module &);
1718
void export_G4VPrimitiveScorer(py::module &);
@@ -26,6 +27,7 @@ void export_modG4digit_hits(py::module &m)
2627
export_G4VHitsCollection(m);
2728
export_G4HCofThisEvent(m);
2829
export_G4MultiFunctionalDetector(m);
30+
export_G4MultiSensitiveDetector(m);
2931
export_G4VSDFilter(m);
3032
export_G4SDFilter(m);
3133
export_G4VPrimitiveScorer(m);

0 commit comments

Comments
 (0)