Newer
Older
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// $Id: Geant4Converter.cpp 603 2013-06-13 21:15:14Z markus.frank $
//====================================================================
// AIDA Detector description implementation for LCD
//--------------------------------------------------------------------
//
// Author : M.Frank
//
//====================================================================
#include <algorithm>
#include "DD4hep/Printout.h"
#include "DD4hep/InstanceCount.h"
#include "DDG4/Geant4Context.h"
#include "DDG4/Geant4Action.h"
#include "DDG4/Geant4Kernel.h"
using namespace std;
using namespace DD4hep;
using namespace DD4hep::Simulation;
TypeName TypeName::split(const string& type_name) {
size_t idx = type_name.find("/");
string typ=type_name, nam=type_name;
if ( idx != string::npos ) {
typ = type_name.substr(0,idx);
nam = type_name.substr(idx+1);
}
return TypeName(typ,nam);
}
/// Default constructor
Geant4TrackInformation::Geant4TrackInformation()
: G4VUserTrackInformation(), m_flags(0)
{
}
/// Standard destructor
Geant4TrackInformation::~Geant4TrackInformation() {
}
/// Access flag if track should be stored
Geant4TrackInformation& Geant4TrackInformation::storeTrack(bool value) {
value ? m_flags |= STORE : m_flags &= ~STORE;
return *this;
}
/// Standard constructor
Geant4Action::Geant4Action(Geant4Context* context, const string& nam)
: m_context(context), m_name(nam), m_refCount(1)
{
InstanceCount::increment(this);
declareProperty("name",m_name);
}
/// Default destructor
Geant4Action::~Geant4Action() {
InstanceCount::decrement(this);
}
/// Implicit destruction
long Geant4Action::addRef() {
return ++m_refCount;
}
/// Decrease reference count. Implicit destruction
long Geant4Action::release() {
long count = --m_refCount;
if ( m_refCount <= 0 ) {
cout << "Geant4Action: Deleting object " << name()
<< " of type " << typeinfoName(typeid(*this)) << endl;
delete this;
}
return count;
}
/// Set the context pointer
void Geant4Action::setContext(Geant4Context* context) {
m_context = context;
}
/// Set object properties
Geant4Action& Geant4Action::setProperties(PropertyConfigurator& setup) {
m_properties.set(m_name,setup);
return *this;
}
/// Support of debug messages.
void Geant4Action::debug(const string& fmt, ...) const {
va_list args;
va_start(args,fmt);
DD4hep::printout(DD4hep::DEBUG,"Geant4Action",fmt,args);
va_end(args);
}
/// Support of info messages.
void Geant4Action::info(const string& fmt, ...) const {
va_list args;
va_start(args,fmt);
DD4hep::printout(DD4hep::INFO,"Geant4Action",fmt,args);
va_end(args);
}
/// Support of warning messages.
void Geant4Action::warning(const string& fmt, ...) const {
va_list args;
va_start(args,fmt);
DD4hep::printout(DD4hep::WARNING,"Geant4Action",fmt,args);
va_end(args);
}
/// Action to support error messages.
void Geant4Action::error(const string& fmt, ...) const {
va_list args;
va_start(args,fmt);
DD4hep::printout(DD4hep::ERROR,"Geant4Action",fmt,args);
va_end(args);
}
/// Action to support error messages.
bool Geant4Action::error(bool return_value, const string& fmt, ...) const {
va_list args;
va_start(args,fmt);
DD4hep::printout(DD4hep::ERROR,"Geant4Action",fmt,args);
va_end(args);
return return_value;
}
/// Support of fatal messages. Throws exception if required.
void Geant4Action::fatal(const string& fmt, ...) const {
string err;
va_list args;
va_start(args,fmt);
DD4hep::printout(DD4hep::FATAL,"Geant4Action",fmt,args);
va_end(args);
}
/// Support of exceptions: Print fatal message and throw runtime_error.
void Geant4Action::except(const string& fmt, ...) const {
string err;
va_list args;
va_start(args,fmt);
DD4hep::printout(DD4hep::FATAL,"Geant4Action",fmt,args);
err = DD4hep::format("Geant4Action",fmt,args);
va_end(args);
throw runtime_error(err);
}
/// Access to the main run action sequence from the kernel object
Geant4RunActionSequence& Geant4Action::runAction() const {
return m_context->runAction();
}
/// Access to the main event action sequence from the kernel object
Geant4EventActionSequence& Geant4Action::eventAction() const {
return m_context->eventAction();
}
/// Access to the main stepping action sequence from the kernel object
Geant4SteppingActionSequence& Geant4Action::steppingAction() const {
return m_context->steppingAction();
}
/// Access to the main tracking action sequence from the kernel object
Geant4TrackingActionSequence& Geant4Action::trackingAction() const {
return m_context->trackingAction();
}
/// Access to the main stacking action sequence from the kernel object
Geant4StackingActionSequence& Geant4Action::stackingAction() const {
return m_context->stackingAction();
}
/// Access to the main generator action sequence from the kernel object
Geant4GeneratorActionSequence& Geant4Action::generatorAction() const {
return m_context->generatorAction();
}