ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4tgrRotationMatrixFactory.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4tgrRotationMatrixFactory.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 G4tgrRotationMatrixFactory
30 
31 // History:
32 // - Created. P.Arce, CIEMAT (November 2007)
33 // -------------------------------------------------------------------------
34 
36 #include "G4tgrMessenger.hh"
37 #include "G4tgrUtils.hh"
38 
39 
41 
42 
43 // -------------------------------------------------------------------------
45 {
46  if( !theInstance )
47  {
49  }
50  return theInstance;
51 }
52 
53 
54 // -------------------------------------------------------------------------
56 {
57 }
58 
59 
60 // -------------------------------------------------------------------------
62 {
63  G4mstgrrotm::iterator cite;
64  for( cite = theTgrRotMats.begin(); cite != theTgrRotMats.end(); cite++)
65  {
66  delete (*cite).second;
67  }
68  theTgrRotMats.clear();
69  delete theInstance;
70 }
71 
72 
73 // -------------------------------------------------------------------------
75 G4tgrRotationMatrixFactory::AddRotMatrix( const std::vector<G4String>& wl )
76 {
77  //---------- Check for miminum number of words read
78  if( wl.size() != 5 && wl.size() != 8 && wl.size() != 11 )
79  {
80  G4tgrUtils::DumpVS(wl, "G4tgrRotationMatrixFactory::AddRotMatrix()");
81  G4Exception("G4tgrRotationMatrixFactory::AddRotMatrix()", "InvalidMatrix",
82  FatalException, "Line should have 5, 8 or 11 words !");
83  }
84 
85 #ifdef G4VERBOSE
87  {
88  G4cout << " G4tgrRotationMatrixFactory::AddRotMatrix() - Adding: "
89  << wl[1] << G4endl;
90  }
91 #endif
92  //---------- Look if rotation matrix exists
93  if( FindRotMatrix( G4tgrUtils::GetString(wl[1]) ) != 0 )
94  {
95  G4String ErrMessage = "Rotation matrix repeated... " + wl[1];
96  G4Exception("G4tgrRotationMatrixFactory::AddRotMatrix()",
97  "InvalidInput", FatalException, ErrMessage);
98  }
99 
100  G4tgrRotationMatrix* rotm = new G4tgrRotationMatrix( wl );
101  theTgrRotMats[ rotm->GetName() ] = rotm;
102  theTgrRotMatList.push_back( rotm );
103 
104  return rotm;
105 }
106 
107 
108 // -------------------------------------------------------------------------
111 {
112  G4tgrRotationMatrix* rotm = 0;
113 
114  G4mstgrrotm::const_iterator cite = theTgrRotMats.find( name );
115  if( cite != theTgrRotMats.end() )
116  {
117  rotm = (*cite).second;
118  }
119 
120  return rotm;
121 }
122 
123 
124 // -------------------------------------------------------------------------
126 {
127  G4cout << " @@@@@@@@@@@@@@@@ DUMPING G4tgrRotationMatrix's List " << G4endl;
128  G4mstgrrotm::const_iterator cite;
129  for(cite = theTgrRotMats.begin(); cite != theTgrRotMats.end(); cite++)
130  {
131  G4cout << " ROTM: " << (*cite).second->GetName() << G4endl;
132  }
133 }