G4tgrSolid.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: G4tgrSolid.cc 69803 2013-05-15 15:24:50Z gcosmo $
00028 //
00029 //
00030 // class G4tgrSolid
00031 
00032 // History:
00033 // - Created.                                 P.Arce, CIEMAT (November 2007)
00034 // -------------------------------------------------------------------------
00035 
00036 #include <map>
00037 #include <set>
00038 
00039 #include "G4tgrSolid.hh"
00040 
00041 #include "G4SystemOfUnits.hh"
00042 #include "G4tgrUtils.hh"
00043 #include "G4tgrMessenger.hh"
00044 #include "G4tgrVolumeMgr.hh"
00045 
00046 // -------------------------------------------------------------------------
00047 G4tgrSolid::G4tgrSolid()
00048 {
00049 }
00050 
00051 
00052 // -------------------------------------------------------------------------
00053 G4tgrSolid::~G4tgrSolid()
00054 {
00055 }
00056 
00057 
00058 // -------------------------------------------------------------------------
00059 G4tgrSolid::G4tgrSolid( const std::vector<G4String>& wl) 
00060 {
00061   //---------- set name 
00062   theName = G4tgrUtils::GetString( wl[1] ); 
00063 
00064   //---------- set solid type
00065   theType = G4tgrUtils::GetString( wl[2] ); 
00066 
00067   //---------- create only vector<double> of theSolidParams
00068   FillSolidParams( wl );
00069 
00070   G4tgrVolumeMgr::GetInstance()->RegisterMe( this );
00071 
00072 
00073 #ifdef G4VERBOSE
00074   if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00075   {
00076      G4cout << " Created " << *this << G4endl;
00077   }
00078 #endif
00079 
00080 }
00081 
00082 
00083 // -------------------------------------------------------------------------
00084 const std::vector< std::vector<G4double>* > G4tgrSolid::GetSolidParams() const
00085 {
00086   return theSolidParams;
00087 }
00088 
00089 
00090 // -------------------------------------------------------------------------
00091 const G4String& G4tgrSolid::GetRelativeRotMatName() const
00092 {
00093   return theName;  // Dummy ...
00094 }
00095 
00096 
00097 // -------------------------------------------------------------------------
00098 G4ThreeVector G4tgrSolid::GetRelativePlace() const
00099 {
00100   return G4ThreeVector(0,0,0);  // Dummy...
00101 }
00102 
00103 
00104 // -------------------------------------------------------------------------
00105 void G4tgrSolid::FillSolidParams( const std::vector<G4String>& wl )
00106 {
00107   //---- Setting which are angle parameters (for dimensions...)
00108   std::map< G4String, std::set<G4int> > angleParams;
00109   std::set<G4int> apar;
00110   apar.clear(); apar.insert(3); apar.insert(4);
00111   angleParams["TUBS"] = apar;
00112   apar.clear(); apar.insert(5); apar.insert(6);
00113   angleParams["CONS"] = apar;
00114   apar.clear(); apar.insert(3); apar.insert(4); apar.insert(5);
00115   angleParams["PARA"] = apar;
00116   apar.clear(); apar.insert(1); apar.insert(2); apar.insert(6); apar.insert(10);
00117   angleParams["TRAP"] = apar;
00118   apar.clear(); apar.insert(2); apar.insert(3); apar.insert(4); apar.insert(5);
00119   angleParams["SPHERE"] = apar;
00120   apar.clear(); apar.insert(3); apar.insert(4);
00121   angleParams["TORUS"] = apar;
00122   apar.clear(); apar.insert(0); apar.insert(1);
00123   angleParams["POLYCONE"] = apar;
00124   apar.clear(); apar.insert(0); apar.insert(1);
00125   angleParams["POLYHEDRA"] = apar;
00126   apar.clear(); apar.insert(2); apar.insert(3);
00127   angleParams["HYPE"] = apar;
00128   apar.clear(); apar.insert(0);
00129   angleParams["TWISTED_BOX"] = apar;
00130   apar.clear(); apar.insert(0); apar.insert(2); apar.insert(3); apar.insert(10);
00131   angleParams["TWISTED_TRAP"] = apar;
00132   apar.clear(); apar.insert(5);
00133   angleParams["TWISTED_TRD"] = apar;
00134   apar.clear(); apar.insert(0); apar.insert(4);
00135   angleParams["TWISTED_TUBS"] = apar;
00136 
00137   std::vector<G4double>* vd = new std::vector<G4double>;
00138   theSolidParams.push_back( vd );
00139   size_t noParRead = wl.size()-3;
00140 
00141   G4String solidType = wl[2];
00142   //--- Default unit (mm) if length, deg if angle
00143   for(size_t ii = 0; ii < noParRead; ii++)
00144   {
00145     G4bool isAngle = 0;
00146     std::map< G4String, std::set<G4int> >::iterator ite
00147        = angleParams.find(solidType);
00148     if( ite != angleParams.end() )
00149     {
00150       std::set<G4int> apar2 = (*ite).second;
00151       if( apar2.find(ii) != apar2.end() )
00152       {
00153         isAngle = 1;
00154         vd->push_back( G4tgrUtils::GetDouble( wl[3+ii], deg ));
00155 #ifdef G4VERBOSE
00156         if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00157         {
00158           G4cout << " G4tgrSolid::FillSolidParams() - Angle param found "
00159                  << solidType << " " << ii << G4endl;
00160         }
00161 #endif
00162       }
00163     } 
00164     if(!isAngle)
00165     {
00166       vd->push_back( G4tgrUtils::GetDouble( wl[3+ii] ) );
00167     }
00168   }
00169 }
00170 
00171 
00172 // -------------------------------------------------------------------------
00173 std::ostream& operator<<(std::ostream& os, const G4tgrSolid& sol)
00174 {
00175   os << "G4tgrSolid= " << sol.theName
00176      << " of type " << sol.theType << " PARAMS: ";
00177   if( sol.theSolidParams.size() != 0 )
00178   {
00179     std::vector<G4double> solpar = *(sol.theSolidParams[0]); 
00180     for( size_t ii = 0; ii < solpar.size(); ii++)
00181     {
00182       os << solpar[ii] << " " ;
00183     }
00184   }
00185   os << G4endl;
00186 
00187   return os;
00188 }

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