ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4tgbRotationMatrixMgr.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4tgbRotationMatrixMgr.cc
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
//
27
//
28
//
29
// class G4tgbRotationMatrixMgr
30
31
// History:
32
// - Created. P.Arce, CIEMAT (November 2007)
33
// -------------------------------------------------------------------------
34
35
#include "
G4tgbRotationMatrixMgr.hh
"
36
37
#include "
G4SystemOfUnits.hh
"
38
#include "
G4tgrRotationMatrixFactory.hh
"
39
#include "
G4tgrMessenger.hh
"
40
41
// -------------------------------------------------------------------------
42
43
G4ThreadLocal
G4tgbRotationMatrixMgr
*
G4tgbRotationMatrixMgr::theInstance
= 0;
44
45
46
// -------------------------------------------------------------------------
47
G4tgbRotationMatrixMgr::G4tgbRotationMatrixMgr
()
48
{
49
}
50
51
52
// -------------------------------------------------------------------------
53
G4tgbRotationMatrixMgr
*
G4tgbRotationMatrixMgr::GetInstance
()
54
{
55
if
( !
theInstance
)
56
{
57
theInstance
=
new
G4tgbRotationMatrixMgr
;
58
theInstance
->
CopyRotMats
();
59
}
60
return
theInstance
;
61
}
62
63
64
// -------------------------------------------------------------------------
65
G4tgbRotationMatrixMgr::~G4tgbRotationMatrixMgr
()
66
{
67
G4mstgbrotm::const_iterator tgbcite;
68
for
( tgbcite =
theTgbRotMats
.begin();
69
tgbcite !=
theTgbRotMats
.end(); tgbcite++)
70
{
71
delete
(*tgbcite).second;
72
}
73
theTgbRotMats
.clear();
74
delete
theInstance
;
75
}
76
77
78
// -------------------------------------------------------------------------
79
void
G4tgbRotationMatrixMgr::CopyRotMats
()
80
{
81
G4mstgrrotm
tgrRotms =
82
G4tgrRotationMatrixFactory::GetInstance
()->
GetRotMatMap
();
83
G4mstgrrotm::iterator cite;
84
for
( cite = tgrRotms.begin(); cite != tgrRotms.end(); cite++ )
85
{
86
G4tgrRotationMatrix
* tgr = (*cite).second;
87
G4tgbRotationMatrix
* tgb =
new
G4tgbRotationMatrix
( tgr );
88
theTgbRotMats
[tgb->
GetName
()] = tgb;
89
}
90
}
91
92
93
// -------------------------------------------------------------------------
94
G4RotationMatrix
*
95
G4tgbRotationMatrixMgr::FindOrBuildG4RotMatrix
(
const
G4String
&
name
)
96
{
97
#ifdef G4VERBOSE
98
if
(
G4tgrMessenger::GetVerboseLevel
() >= 2 )
99
{
100
G4cout
<<
" G4tgbRotationMatrixMgr::FindOrBuildG4RotMatrix() - "
101
<< name <<
G4endl
;
102
}
103
#endif
104
G4RotationMatrix
* g4rotm =
FindG4RotMatrix
( name );
105
if
( g4rotm == 0 )
106
{
107
G4tgbRotationMatrix
* hrotm =
FindOrBuildTgbRotMatrix
( name );
108
// GetRotMatrix() never returns 0, otherwise if not found, it crashes
109
g4rotm = hrotm->
BuildG4RotMatrix
();
110
}
111
return
g4rotm;
112
}
113
114
115
// -------------------------------------------------------------------------
116
G4RotationMatrix
*
G4tgbRotationMatrixMgr::FindG4RotMatrix
(
const
G4String
&
name
)
117
{
118
G4RotationMatrix
* g4rotm = 0;
119
120
G4msg4rotm::const_iterator cite =
theG4RotMats
.find( name );
121
if
( cite !=
theG4RotMats
.end() )
122
{
123
g4rotm = (*cite).second;
124
}
125
126
#ifdef G4VERBOSE
127
if
(
G4tgrMessenger::GetVerboseLevel
() >= 2 )
128
{
129
G4cout
<<
" G4tgbRotationMatrixMgr::FindG4RotMatrix(): "
<<
G4endl
130
<<
" Name: "
<< name <<
" = "
<< g4rotm <<
G4endl
;
131
}
132
#endif
133
134
return
g4rotm;
135
}
136
137
138
// -------------------------------------------------------------------------
139
G4tgbRotationMatrix
*
140
G4tgbRotationMatrixMgr::FindOrBuildTgbRotMatrix
(
const
G4String
&
name
)
141
{
142
G4tgbRotationMatrix
* rotm =
FindTgbRotMatrix
( name );
143
144
if
( rotm == 0 )
145
{
146
G4String
ErrMessage =
"Rotation Matrix "
+ name +
" not found !"
;
147
G4Exception
(
"G4tgbRotationMatrixFactory::FindOrBuildRotMatrix()"
,
148
"InvalidSetup"
,
FatalException
, ErrMessage);
149
}
150
return
rotm;
151
}
152
153
154
// -------------------------------------------------------------------------
155
G4tgbRotationMatrix
*
156
G4tgbRotationMatrixMgr::FindTgbRotMatrix
(
const
G4String
&
name
)
157
{
158
G4tgbRotationMatrix
* rotm = 0;
159
160
G4mstgbrotm::const_iterator cite =
theTgbRotMats
.find( name );
161
if
( cite !=
theTgbRotMats
.end() )
162
{
163
rotm = (*cite).second;
164
}
165
return
rotm;
166
}
167
168
169
// -------------------------------------------------------------------------
170
std::ostream&
operator<<
(std::ostream& os ,
const
G4RotationMatrix
& rot)
171
{
172
os <<
"[ "
173
<< rot.
thetaX
()/
deg
<<
'\t'
<< rot.
phiX
()/
deg
<<
'\t'
174
<< rot.
thetaY
()/
deg
<<
'\t'
<< rot.
phiY
()/
deg
<<
'\t'
175
<< rot.
thetaZ
()/
deg
<<
'\t'
<< rot.
phiZ
()/
deg
<<
" ]"
176
<<
G4endl
;
177
return
os;
178
}
geant4
tree
geant4-10.6-release
source
persistency
ascii
src
G4tgbRotationMatrixMgr.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:25
using
1.8.2 with
ECCE GitHub integration