Geant4  10.02.p02
G4tgrRotationMatrixFactory.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: G4tgrRotationMatrixFactory.cc 66872 2013-01-15 01:25:57Z japost $
28 //
29 //
30 // class G4tgrRotationMatrixFactory
31 
32 // History:
33 // - Created. P.Arce, CIEMAT (November 2007)
34 // -------------------------------------------------------------------------
35 
37 #include "G4tgrMessenger.hh"
38 #include "G4tgrUtils.hh"
39 
40 
42 
43 
44 // -------------------------------------------------------------------------
46 {
47  if( !theInstance )
48  {
50  }
51  return theInstance;
52 }
53 
54 
55 // -------------------------------------------------------------------------
57 {
58 }
59 
60 
61 // -------------------------------------------------------------------------
63 {
64  G4mstgrrotm::iterator cite;
65  for( cite = theTgrRotMats.begin(); cite != theTgrRotMats.end(); cite++)
66  {
67  delete (*cite).second;
68  }
69  theTgrRotMats.clear();
70  delete theInstance;
71 }
72 
73 
74 // -------------------------------------------------------------------------
76 G4tgrRotationMatrixFactory::AddRotMatrix( const std::vector<G4String>& wl )
77 {
78  //---------- Check for miminum number of words read
79  if( wl.size() != 5 && wl.size() != 8 && wl.size() != 11 )
80  {
81  G4tgrUtils::DumpVS(wl, "G4tgrRotationMatrixFactory::AddRotMatrix()");
82  G4Exception("G4tgrRotationMatrixFactory::AddRotMatrix()", "InvalidMatrix",
83  FatalException, "Line should have 5, 8 or 11 words !");
84  }
85 
86 #ifdef G4VERBOSE
88  {
89  G4cout << " G4tgrRotationMatrixFactory::AddRotMatrix() - Adding: "
90  << wl[1] << G4endl;
91  }
92 #endif
93  //---------- Look if rotation matrix exists
94  if( FindRotMatrix( G4tgrUtils::GetString(wl[1]) ) != 0 )
95  {
96  G4String ErrMessage = "Rotation matrix repeated... " + wl[1];
97  G4Exception("G4tgrRotationMatrixFactory::AddRotMatrix()",
98  "InvalidInput", FatalException, ErrMessage);
99  }
100 
101  G4tgrRotationMatrix* rotm = new G4tgrRotationMatrix( wl );
102  theTgrRotMats[ rotm->GetName() ] = rotm;
103  theTgrRotMatList.push_back( rotm );
104 
105  return rotm;
106 }
107 
108 
109 // -------------------------------------------------------------------------
112 {
113  G4tgrRotationMatrix* rotm = 0;
114 
115  G4mstgrrotm::const_iterator cite = theTgrRotMats.find( name );
116  if( cite != theTgrRotMats.end() )
117  {
118  rotm = (*cite).second;
119  }
120 
121  return rotm;
122 }
123 
124 
125 // -------------------------------------------------------------------------
127 {
128  G4cout << " @@@@@@@@@@@@@@@@ DUMPING G4tgrRotationMatrix's List " << G4endl;
129  G4mstgrrotm::const_iterator cite;
130  for(cite = theTgrRotMats.begin(); cite != theTgrRotMats.end(); cite++)
131  {
132  G4cout << " ROTM: " << (*cite).second->GetName() << G4endl;
133  }
134 }
static G4ThreadLocal G4tgrRotationMatrixFactory * theInstance
G4String name
Definition: TRTMaterials.hh:40
G4tgrRotationMatrix * FindRotMatrix(const G4String &rotm)
#define G4ThreadLocal
Definition: tls.hh:89
G4tgrRotationMatrix * AddRotMatrix(const std::vector< G4String > &wl)
static G4tgrRotationMatrixFactory * GetInstance()
G4GLOB_DLL std::ostream G4cout
static G4int GetVerboseLevel()
std::vector< G4tgrRotationMatrix * > theTgrRotMatList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static void DumpVS(const std::vector< G4String > &wl, const char *msg)
Definition: G4tgrUtils.cc:158
const G4String & GetName()
static G4String GetString(const G4String &str)
Definition: G4tgrUtils.cc:180
#define G4endl
Definition: G4ios.hh:61