Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:09

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4tgbGeometryDumper
0027 //
0028 // Class description:
0029 //
0030 // Class for dumping the whole geometry.
0031 
0032 // Author: P.Arce, CIEMAT (November 2007)
0033 // --------------------------------------------------------------------
0034 #ifndef G4tgbGeometryDumper_hh
0035 #define G4tgbGeometryDumper_hh 1
0036 
0037 #include <fstream>
0038 #include <map>
0039 #include <vector>
0040 
0041 #include "globals.hh"
0042 #include "G4RotationMatrix.hh"
0043 
0044 class G4Material;
0045 class G4Element;
0046 class G4Isotope;
0047 class G4VSolid;
0048 class G4LogicalVolume;
0049 class G4VPhysicalVolume;
0050 class G4PVParameterised;
0051 class G4PVReplica;
0052 
0053 class G4tgbGeometryDumper
0054 {
0055   public:
0056 
0057     static G4tgbGeometryDumper* GetInstance();
0058     ~G4tgbGeometryDumper();
0059 
0060     void DumpGeometry(const G4String& fname);
0061     G4VPhysicalVolume* GetTopPhysVol();
0062     void DumpPhysVol(G4VPhysicalVolume* pv);
0063     void DumpPVPlacement(G4VPhysicalVolume* pv, const G4String& lvName,
0064                          G4int copyNo = -999);
0065     void DumpPVParameterised(G4PVParameterised* pv);
0066     void DumpPVReplica(G4PVReplica* pv, const G4String& lvName);
0067     G4String DumpLogVol(G4LogicalVolume* lv, const G4String& extraName = "",
0068                         G4VSolid* solid = nullptr, G4Material* mate = nullptr);
0069     G4String DumpMaterial(G4Material* mat);
0070     void DumpElement(G4Element* ele);
0071     void DumpIsotope(G4Isotope* ele);
0072     G4String DumpSolid(G4VSolid* solid, const G4String& extraName = "");
0073     void DumpBooleanVolume(const G4String& solidType, G4VSolid* so);
0074     void DumpMultiUnionVolume(  G4VSolid* so);
0075     void DumpScaledVolume( G4VSolid* so);
0076     void DumpSolidParams(G4VSolid* so);
0077     std::vector<G4double> GetSolidParams(const G4VSolid* so);
0078     void DumpPolySections(G4int zPlanes, G4double* z, G4double* rmin,
0079                           G4double* rmax);
0080     G4String DumpRotationMatrix(G4RotationMatrix* rotm);
0081 
0082   private:
0083 
0084     G4tgbGeometryDumper();
0085 
0086     std::vector<G4VPhysicalVolume*> GetPVChildren(G4LogicalVolume* lv);
0087     G4String GetTGSolidType(const G4String& solidtype);
0088     G4double MatDeterminant(G4RotationMatrix* ro);
0089     G4double approxTo0(G4double val);
0090     G4String AddQuotes(const G4String& str);
0091 
0092     G4String GetIsotopeName(G4Isotope*);
0093     template <class TYP>
0094       G4String GetObjectName(TYP* obj, std::map<G4String, TYP*> objectsDumped);
0095     G4bool CheckIfLogVolExists(const G4String& name, G4LogicalVolume* pt);
0096     G4bool CheckIfPhysVolExists(const G4String& name, G4VPhysicalVolume*);
0097     G4String LookForExistingRotation(const G4RotationMatrix* rotm);
0098     G4String SupressRefl(G4String name);
0099     G4String SubstituteRefl(G4String name);
0100     G4bool Same2G4Isotopes(G4Isotope* ele1, G4Isotope* ele2);
0101     const G4String& FindSolidName(G4VSolid* solid);
0102 
0103   private:
0104 
0105     static G4ThreadLocal G4tgbGeometryDumper* theInstance;
0106 
0107     std::ofstream* theFile = nullptr;
0108 
0109     std::map<G4String, G4Material*> theMaterials;
0110     std::map<G4String, G4Element*> theElements;
0111     std::map<G4String, G4Isotope*> theIsotopes;
0112     std::map<G4String, G4VSolid*> theSolids;
0113     std::map<G4String, G4LogicalVolume*> theLogVols;
0114     std::map<G4String, G4VPhysicalVolume*> thePhysVols;
0115     std::map<G4String, G4RotationMatrix*> theRotMats;
0116 
0117     G4int theRotationNumber = 0;
0118 };
0119 
0120 #endif