ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_FastCaloSim
ISF_FastCaloSimSD
src
SDWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
SDWrapper.h
"
6
7
// Geant4 includes
8
#include "G4SDManager.hh"
9
10
// Framework utilities
11
12
// Project includes
13
#include "
ISF_FastCaloSimEvent/FCS_StepInfoCollection.h
"
14
15
// Local includes
16
#include "
FCS_StepInfoSD.h
"
17
18
namespace
FCS_Param
{
19
20
namespace
detail
{
21
22
//-------------------------------------------------------------------------
23
// Construct with a hit collection name
24
//-------------------------------------------------------------------------
25
template
<
class
SDType,
class
HitContainerType>
26
SDWrapper<SDType, HitContainerType>::SDWrapper
(
27
const
std::string& name,
const
std::string& hitCollectionName)
28
: G4VSensitiveDetector(name),
29
m_hitCollName
(hitCollectionName),
30
m_hitColl
(hitCollectionName) {}
31
32
//-------------------------------------------------------------------------
33
// Add a unique SD to the list
34
//-------------------------------------------------------------------------
35
template
<
class
SDType,
class
HitContainerType>
36
void
SDWrapper<SDType, HitContainerType>::addSD
(SDType* sd) {
37
m_sdList
.push_back(sd);
38
}
39
40
//-------------------------------------------------------------------------
41
// Initialize the hit collection at the beginning of the G4 event
42
//-------------------------------------------------------------------------
43
template
<
class
SDType,
class
HitContainerType>
44
void
SDWrapper<SDType, HitContainerType>::Initialize
(G4HCofThisEvent*) {
45
if
(!
m_hitColl
.isValid()) {
46
if
(verboseLevel >= 5) {
47
G4cout << GetName() <<
" \tDEBUG\t"
48
<<
"Initializing hit container: "
<<
m_hitCollName
<< G4endl;
49
}
50
m_hitColl
= std::make_unique<HitContainerType>();
51
}
52
}
53
54
//-------------------------------------------------------------------------
55
// This should not be called
56
//-------------------------------------------------------------------------
57
template
<
class
SDType,
class
HitContainerType>
58
bool
SDWrapper<SDType, HitContainerType>::ProcessHits
(G4Step*,
59
G4TouchableHistory*) {
60
G4ExceptionDescription
description
;
61
description
<<
"ProcessHits: this SD shouldn't be assigned to volumes!"
;
62
G4Exception(GetName(),
"SDError"
, FatalException,
description
);
63
return
false
;
64
}
65
66
//-------------------------------------------------------------------------
67
// Gather the hits into the WriteHandle from all the SDs
68
//-------------------------------------------------------------------------
69
template
<
class
SDType,
class
HitContainerType>
70
void
SDWrapper<SDType, HitContainerType>::EndOfAthenaEvent
() {
71
if
(!
m_hitColl
.isValid()) {
72
G4cerr << GetName() <<
" \tERROR\t"
<<
"Hit collection WriteHandle is "
73
<<
"invalid!"
<< G4endl;
74
throw
std::runtime_error(
"Invalid hit container WriteHandle: "
+
75
m_hitColl
.name());
76
}
77
// Loop over each SD and fill the container
78
for
(
auto
& sd :
m_sdList
) {
79
sd->EndOfAthenaEvent(&*
m_hitColl
);
80
}
81
}
82
83
//-------------------------------------------------------------------------
84
// Explit template instantiations
85
//-------------------------------------------------------------------------
86
template
class
SDWrapper
<
FCS_StepInfoSD
,
87
ISF_FCS_Parametrization::FCS_StepInfoCollection
>;
88
89
}
// namespace detail
90
91
}
// namespace FCS_Param
FCS_StepInfoCollection.h
FCS_StepInfoSD.h
SDWrapper.h
FCS_Param::detail::SDWrapper
A template class which wraps multiple sensitive detectors.
Definition
SDWrapper.h:47
FCS_Param::detail::SDWrapper::ProcessHits
virtual bool ProcessHits(G4Step *, G4TouchableHistory *) override final
This method should not be called. It will throw.
Definition
SDWrapper.cxx:58
FCS_Param::detail::SDWrapper::Initialize
virtual void Initialize(G4HCofThisEvent *) override final
Beginning of G4 event; initialize the hit collection.
Definition
SDWrapper.cxx:44
FCS_Param::detail::SDWrapper::SDWrapper
SDWrapper(const std::string &name, const std::string &hitCollectionName)
Construct the wrapper from the output collection name.
Definition
SDWrapper.cxx:26
FCS_Param::detail::SDWrapper::EndOfAthenaEvent
void EndOfAthenaEvent()
Gather the hits into the WriteHandle from all the SDs.
Definition
SDWrapper.cxx:70
FCS_Param::detail::SDWrapper::m_hitCollName
std::string m_hitCollName
The hit container name.
Definition
SDWrapper.h:70
FCS_Param::detail::SDWrapper::m_sdList
SDList_t m_sdList
The list of sensitive detectors that I own and manage.
Definition
SDWrapper.h:76
FCS_Param::detail::SDWrapper::addSD
void addSD(SDType *sd)
Add an SD to this wrapper.
Definition
SDWrapper.cxx:36
FCS_Param::detail::SDWrapper::m_hitColl
SG::WriteHandle< HitContainerType > m_hitColl
The hit container handle.
Definition
SDWrapper.h:73
FCS_StepInfoSD
Common sensitive detector class for LAr systems.
Definition
FCS_StepInfoSD.h:71
ISF_FCS_Parametrization::FCS_StepInfoCollection
Class for collection of StepInfo class (G4 hits) copied and modified version to ISF.
Definition
FCS_StepInfoCollection.h:30
description
std::string description
glabal timer - how long have I taken so far?
Definition
hcg.cxx:93
FCS_Param
Definition
FCS_StepInfoSD.h:35
detail
Definition
extract_histogram_tag.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0