ECCE @ EIC Software
 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 
36 
37 #include "G4SystemOfUnits.hh"
39 #include "G4tgrMessenger.hh"
40 
41 // -------------------------------------------------------------------------
42 
44 
45 
46 // -------------------------------------------------------------------------
48 {
49 }
50 
51 
52 // -------------------------------------------------------------------------
54 {
55  if( !theInstance )
56  {
59  }
60  return theInstance;
61 }
62 
63 
64 // -------------------------------------------------------------------------
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 // -------------------------------------------------------------------------
80 {
81  G4mstgrrotm tgrRotms =
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 // -------------------------------------------------------------------------
96 {
97 #ifdef G4VERBOSE
99  {
100  G4cout << " G4tgbRotationMatrixMgr::FindOrBuildG4RotMatrix() - "
101  << name << G4endl;
102  }
103 #endif
104  G4RotationMatrix* g4rotm = FindG4RotMatrix( name );
105  if( g4rotm == 0 )
106  {
108  // GetRotMatrix() never returns 0, otherwise if not found, it crashes
109  g4rotm = hrotm->BuildG4RotMatrix();
110  }
111  return g4rotm;
112 }
113 
114 
115 // -------------------------------------------------------------------------
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
128  {
129  G4cout << " G4tgbRotationMatrixMgr::FindG4RotMatrix(): " << G4endl
130  << " Name: " << name << " = " << g4rotm << G4endl;
131  }
132 #endif
133 
134  return g4rotm;
135 }
136 
137 
138 // -------------------------------------------------------------------------
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 // -------------------------------------------------------------------------
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 }