Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4tgbRotationMatrixMgr.cc
Go to the documentation of this file.
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// $Id$
28//
29//
30// class G4tgbRotationMatrixMgr
31
32// History:
33// - Created. P.Arce, CIEMAT (November 2007)
34// -------------------------------------------------------------------------
35
37
38#include "G4SystemOfUnits.hh"
40#include "G4tgrMessenger.hh"
41
42// -------------------------------------------------------------------------
43
44G4tgbRotationMatrixMgr * G4tgbRotationMatrixMgr::theInstance = 0;
45
46
47// -------------------------------------------------------------------------
48G4tgbRotationMatrixMgr::G4tgbRotationMatrixMgr()
49{
50}
51
52
53// -------------------------------------------------------------------------
55{
56 if( !theInstance )
57 {
58 theInstance = new G4tgbRotationMatrixMgr;
59 theInstance->CopyRotMats();
60 }
61 return theInstance;
62}
63
64
65// -------------------------------------------------------------------------
67{
68 G4mstgbrotm::const_iterator tgbcite;
69 for( tgbcite = theTgbRotMats.begin();
70 tgbcite != theTgbRotMats.end(); tgbcite++)
71 {
72 delete (*tgbcite).second;
73 }
74 theTgbRotMats.clear();
75 delete theInstance;
76}
77
78
79// -------------------------------------------------------------------------
80void G4tgbRotationMatrixMgr::CopyRotMats()
81{
82 G4mstgrrotm tgrRotms =
84 G4mstgrrotm::iterator cite;
85 for( cite = tgrRotms.begin(); cite != tgrRotms.end(); cite++ )
86 {
87 G4tgrRotationMatrix* tgr = (*cite).second;
89 theTgbRotMats[tgb->GetName()] = tgb;
90 }
91}
92
93
94// -------------------------------------------------------------------------
97{
98#ifdef G4VERBOSE
100 {
101 G4cout << " G4tgbRotationMatrixMgr::FindOrBuildG4RotMatrix() - "
102 << name << G4endl;
103 }
104#endif
105 G4RotationMatrix* g4rotm = FindG4RotMatrix( name );
106 if( g4rotm == 0 )
107 {
109 // GetRotMatrix() never returns 0, otherwise if not found, it crashes
110 g4rotm = hrotm->BuildG4RotMatrix();
111 }
112 return g4rotm;
113}
114
115
116// -------------------------------------------------------------------------
118{
119 G4RotationMatrix* g4rotm = 0;
120
121 G4msg4rotm::const_iterator cite = theG4RotMats.find( name );
122 if( cite != theG4RotMats.end() )
123 {
124 g4rotm = (*cite).second;
125 }
126
127#ifdef G4VERBOSE
129 {
130 G4cout << " G4tgbRotationMatrixMgr::FindG4RotMatrix(): " << G4endl
131 << " Name: " << name << " = " << g4rotm << G4endl;
132 }
133#endif
134
135 return g4rotm;
136}
137
138
139// -------------------------------------------------------------------------
142{
144
145 if( rotm == 0 )
146 {
147 G4String ErrMessage = "Rotation Matrix " + name + " not found !";
148 G4Exception("G4tgbRotationMatrixFactory::FindOrBuildRotMatrix()",
149 "InvalidSetup", FatalException, ErrMessage);
150 }
151 return rotm;
152}
153
154
155// -------------------------------------------------------------------------
158{
159 G4tgbRotationMatrix* rotm = 0;
160
161 G4mstgbrotm::const_iterator cite = theTgbRotMats.find( name );
162 if( cite != theTgbRotMats.end() )
163 {
164 rotm = (*cite).second;
165 }
166 return rotm;
167}
168
169
170// -------------------------------------------------------------------------
171std::ostream& operator<<(std::ostream& os , const G4RotationMatrix & rot)
172{
173 os << "[ "
174 << rot.thetaX()/deg << '\t' << rot.phiX()/deg << '\t'
175 << rot.thetaY()/deg << '\t' << rot.phiY()/deg << '\t'
176 << rot.thetaZ()/deg << '\t' << rot.phiZ()/deg << " ]"
177 << G4endl;
178 return os;
179}
@ FatalException
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
std::ostream & operator<<(std::ostream &os, const G4RotationMatrix &rot)
std::map< G4String, G4tgrRotationMatrix * > G4mstgrrotm
double thetaY() const
Definition: Rotation.cc:145
double phiY() const
Definition: Rotation.cc:133
double thetaX() const
Definition: Rotation.cc:141
double phiX() const
Definition: Rotation.cc:129
double thetaZ() const
Definition: Rotation.cc:149
double phiZ() const
Definition: Rotation.cc:137
static G4tgbRotationMatrixMgr * GetInstance()
G4RotationMatrix * FindG4RotMatrix(const G4String &name)
G4RotationMatrix * FindOrBuildG4RotMatrix(const G4String &name)
G4tgbRotationMatrix * FindOrBuildTgbRotMatrix(const G4String &name)
G4tgbRotationMatrix * FindTgbRotMatrix(const G4String &name)
G4RotationMatrix * BuildG4RotMatrix()
static G4int GetVerboseLevel()
const G4mstgrrotm & GetRotMatMap() const
static G4tgrRotationMatrixFactory * GetInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41