G4tgrRotationMatrixFactory.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4tgrRotationMatrixFactory.cc 69803 2013-05-15 15:24:50Z gcosmo $
00028 //
00029 //
00030 // class G4tgrRotationMatrixFactory
00031 
00032 // History:
00033 // - Created.                                 P.Arce, CIEMAT (November 2007)
00034 // -------------------------------------------------------------------------
00035 
00036 #include "G4tgrRotationMatrixFactory.hh"
00037 #include "G4tgrMessenger.hh"
00038 #include "G4tgrUtils.hh"
00039 
00040 
00041 G4tgrRotationMatrixFactory * G4tgrRotationMatrixFactory::theInstance = 0;
00042 
00043 
00044 // -------------------------------------------------------------------------
00045 G4tgrRotationMatrixFactory* G4tgrRotationMatrixFactory::GetInstance()
00046 {
00047   if( !theInstance )
00048   {
00049     theInstance = new G4tgrRotationMatrixFactory;
00050   }
00051   return theInstance;
00052 }
00053 
00054 
00055 // -------------------------------------------------------------------------
00056 G4tgrRotationMatrixFactory::G4tgrRotationMatrixFactory()
00057 {
00058 }
00059 
00060 
00061 // -------------------------------------------------------------------------
00062 G4tgrRotationMatrixFactory::~G4tgrRotationMatrixFactory()
00063 {
00064   G4mstgrrotm::iterator cite;
00065   for( cite = theTgrRotMats.begin(); cite != theTgrRotMats.end(); cite++)
00066   {
00067     delete (*cite).second;
00068   }
00069   theTgrRotMats.clear();
00070   delete theInstance;
00071 }
00072 
00073 
00074 // -------------------------------------------------------------------------
00075 G4tgrRotationMatrix*
00076 G4tgrRotationMatrixFactory::AddRotMatrix( const std::vector<G4String>& wl )
00077 {
00078   //---------- Check for miminum number of words read 
00079   if( wl.size() != 5 && wl.size() != 8 && wl.size() != 11 )
00080   {
00081     G4tgrUtils::DumpVS(wl, "G4tgrRotationMatrixFactory::AddRotMatrix()");
00082     G4Exception("G4tgrRotationMatrixFactory::AddRotMatrix()", "InvalidMatrix",
00083                 FatalException, "Line should have 5, 8 or 11 words !");
00084   }
00085 
00086 #ifdef G4VERBOSE
00087   if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00088   {
00089     G4cout << " G4tgrRotationMatrixFactory::AddRotMatrix() - Adding: "
00090            << wl[1] << G4endl;
00091   }
00092 #endif
00093   //---------- Look if rotation matrix exists
00094   if( FindRotMatrix( G4tgrUtils::GetString(wl[1]) ) != 0 )
00095   {
00096     G4String ErrMessage = "Rotation matrix repeated... " + wl[1];
00097     G4Exception("G4tgrRotationMatrixFactory::AddRotMatrix()",
00098                 "InvalidInput", FatalException, ErrMessage);
00099   } 
00100  
00101   G4tgrRotationMatrix* rotm = new G4tgrRotationMatrix( wl );
00102   theTgrRotMats[ rotm->GetName() ] =  rotm;
00103   theTgrRotMatList.push_back( rotm );
00104  
00105   return rotm;
00106 }
00107 
00108 
00109 // -------------------------------------------------------------------------
00110 G4tgrRotationMatrix*
00111 G4tgrRotationMatrixFactory::FindRotMatrix(const G4String& name)
00112 {
00113   G4tgrRotationMatrix* rotm = 0;
00114 
00115   G4mstgrrotm::const_iterator cite = theTgrRotMats.find( name );
00116   if( cite != theTgrRotMats.end() )
00117   { 
00118     rotm = (*cite).second;
00119   } 
00120 
00121   return rotm;
00122 }
00123 
00124 
00125 // -------------------------------------------------------------------------
00126 void G4tgrRotationMatrixFactory::DumpRotmList()
00127 {
00128   G4cout << " @@@@@@@@@@@@@@@@ DUMPING G4tgrRotationMatrix's List " << G4endl;
00129   G4mstgrrotm::const_iterator cite;
00130   for(cite = theTgrRotMats.begin(); cite != theTgrRotMats.end(); cite++)
00131   {
00132     G4cout << " ROTM: " << (*cite).second->GetName() << G4endl;
00133   }
00134 }

Generated on Mon May 27 17:49:59 2013 for Geant4 by  doxygen 1.4.7