remage
Simulation framework for HPGe-based experiments
Toggle main menu visibility
Loading...
Searching...
No Matches
RMGOpticalDetector.hh
1
// Copyright (C) 2022 Luigi Pertoldi <https://orcid.org/0000-0002-0467-2571>
2
//
3
// This program is free software: you can redistribute it and/or modify it under
4
// the terms of the GNU Lesser General Public License as published by the Free
5
// Software Foundation, either version 3 of the License, or (at your option) any
6
// later version.
7
//
8
// This program is distributed in the hope that it will be useful, but WITHOUT
9
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11
// details.
12
//
13
// You should have received a copy of the GNU Lesser General Public License
14
// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16
#ifndef _RMG_OPTICAL_DETECTOR_HH_
17
#define _RMG_OPTICAL_DETECTOR_HH_
18
19
#include <memory>
20
#include <string>
21
22
#include "G4Allocator.hh"
23
#include "G4THitsCollection.hh"
24
#include "G4TouchableHandle.hh"
25
#include "G4VHit.hh"
26
#include "G4VSensitiveDetector.hh"
27
33
class
RMGOpticalDetectorHit :
public
G4VHit
{
34
35
public
:
36
37
RMGOpticalDetectorHit() =
default
;
38
~RMGOpticalDetectorHit() =
default
;
39
40
RMGOpticalDetectorHit(RMGOpticalDetectorHit
const
&) =
delete
;
41
RMGOpticalDetectorHit& operator=(RMGOpticalDetectorHit
const
&) =
delete
;
42
RMGOpticalDetectorHit(RMGOpticalDetectorHit&&) =
delete
;
43
RMGOpticalDetectorHit& operator=(RMGOpticalDetectorHit&&) =
delete
;
44
45
bool
operator==(
const
RMGOpticalDetectorHit&)
const
;
46
47
inline
void
*
operator
new
(size_t);
48
inline
void
operator
delete
(
void
*);
49
50
void
Print()
override
;
52
void
Draw
()
override
;
53
54
G4TouchableHandle
detector_touchable
;
55
int
detector_uid
= -1;
56
double
photon_wavelength
= 0.;
57
double
global_time
= -1;
58
};
59
60
using
RMGOpticalDetectorHitsCollection =
G4THitsCollection<RMGOpticalDetectorHit>
;
61
62
class
G4Step
;
63
class
G4HCofThisEvent
;
64
class
G4TouchableHistory
;
71
class
RMGOpticalDetector :
public
G4VSensitiveDetector
{
72
73
public
:
74
75
RMGOpticalDetector();
76
~RMGOpticalDetector() =
default
;
77
78
RMGOpticalDetector(RMGOpticalDetector
const
&) =
delete
;
79
RMGOpticalDetector& operator=(RMGOpticalDetector
const
&) =
delete
;
80
RMGOpticalDetector(RMGOpticalDetector&&) =
delete
;
81
RMGOpticalDetector& operator=(RMGOpticalDetector&&) =
delete
;
82
84
void
Initialize
(
G4HCofThisEvent
* hit_coll)
override
;
86
bool
ProcessHits
(
G4Step
* step,
G4TouchableHistory
* history)
override
;
87
void
EndOfEvent(
G4HCofThisEvent
* hit_coll)
override
;
88
89
private
:
90
91
RMGOpticalDetectorHitsCollection* fHitsCollection =
nullptr
;
92
};
93
95
extern
G4ThreadLocal
G4Allocator<RMGOpticalDetectorHit>
* RMGOpticalDetectorHitAllocator;
97
98
inline
void
* RMGOpticalDetectorHit::operator
new
(size_t) {
99
if
(!RMGOpticalDetectorHitAllocator)
100
RMGOpticalDetectorHitAllocator =
new
G4Allocator<RMGOpticalDetectorHit>
;
101
return
(
void
*)RMGOpticalDetectorHitAllocator->MallocSingle();
102
}
103
104
inline
void
RMGOpticalDetectorHit::operator
delete
(
void
* hit) {
105
RMGOpticalDetectorHitAllocator->FreeSingle(
static_cast<
RMGOpticalDetectorHit
*
>
(hit));
106
}
107
108
#endif
109
110
// vim: tabstop=2 shiftwidth=2 expandtab
G4Allocator
G4HCofThisEvent
G4Step
G4THitsCollection
G4TouchableHistory
G4VHit
G4VSensitiveDetector
RMGOpticalDetectorHit
Hit produced by RMGOpticalDetector when an optical photon is absorbed.
Definition
RMGOpticalDetector.hh:33
RMGOpticalDetectorHit::detector_uid
int detector_uid
Remage unique identifier of the absorbing detector.
Definition
RMGOpticalDetector.hh:55
RMGOpticalDetectorHit::Draw
void Draw() override
Color the detector volume if hit.
Definition
RMGOpticalDetector.cc:49
RMGOpticalDetectorHit::photon_wavelength
double photon_wavelength
Absorbed-photon wavelength (Geant4 length units).
Definition
RMGOpticalDetector.hh:56
RMGOpticalDetectorHit::global_time
double global_time
Global time at absorption (Geant4 time units).
Definition
RMGOpticalDetector.hh:57
RMGOpticalDetectorHit::detector_touchable
G4TouchableHandle detector_touchable
Touchable of the absorbing volume, used by Draw.
Definition
RMGOpticalDetector.hh:54
RMGOpticalDetector::Initialize
void Initialize(G4HCofThisEvent *hit_coll) override
Allocate and register the hit collection for the current event.
Definition
RMGOpticalDetector.cc:73
RMGOpticalDetector::ProcessHits
bool ProcessHits(G4Step *step, G4TouchableHistory *history) override
Record an absorbed optical photon as a hit.
Definition
RMGOpticalDetector.cc:89
include
RMGOpticalDetector.hh
Generated by
1.17.0