Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:02

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 //
0027 // $Id: PHG4GDMLWrite.hh 69013 2013-04-15 09:41:13Z gcosmo $
0028 //
0029 //
0030 // class PHG4GDMLWrite
0031 //
0032 // Class description:
0033 //
0034 // GDML writer.
0035 
0036 // History:
0037 // - Created.                                  Zoltan Torzsok, November 2007
0038 // -------------------------------------------------------------------------
0039 
0040 #ifndef _PHG4GDMLWRITE_INCLUDED_
0041 #define _PHG4GDMLWRITE_INCLUDED_
0042 
0043 #include <map>
0044 
0045 #pragma GCC diagnostic push
0046 #pragma GCC diagnostic ignored "-Wshadow"
0047 #include <xercesc/dom/DOM.hpp>
0048 #include <xercesc/framework/LocalFileFormatTarget.hpp>
0049 #include <xercesc/util/PlatformUtils.hpp>
0050 #include <xercesc/util/XMLString.hpp>
0051 #pragma GCC diagnostic pop
0052 
0053 #include <Geant4/G4Transform3D.hh>
0054 
0055 
0056 #include "PHG4GDMLAuxStructType.hh"
0057 
0058 class G4LogicalVolume;
0059 class G4VPhysicalVolume;
0060 
0061 class PHG4GDMLWrite
0062 {
0063   typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
0064   typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
0065   typedef std::map<G4int,G4int> DepthMapType;
0066 
0067   public:  // with description
0068 
0069     G4Transform3D Write(const G4String& filename,
0070                         const G4LogicalVolume* const topLog,
0071                         const G4String& schemaPath,
0072                         const G4int depth, G4bool storeReferences=true);
0073       //
0074       // Main method for writing GDML files.
0075 
0076     void AddModule(const G4VPhysicalVolume* const topVol);
0077     void AddModule(const G4int depth);
0078       //
0079       // Split geometry structure in modules, by volume subtree or level
0080 
0081     void AddAuxiliary(PHG4GDMLAuxStructType myaux);
0082       //
0083       // Import auxiliary structure
0084 
0085     static void SetAddPointerToName(G4bool);
0086       //
0087       // Specify if to add or not memory addresses to IDs.
0088 
0089     virtual void DefineWrite(xercesc::DOMElement*)=0;
0090     virtual void MaterialsWrite(xercesc::DOMElement*)=0;
0091     virtual void SolidsWrite(xercesc::DOMElement*)=0;
0092     virtual void StructureWrite(xercesc::DOMElement*)=0;
0093     virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
0094                                              const G4int)=0;
0095     virtual void SurfacesWrite()=0;
0096     virtual void SetupWrite(xercesc::DOMElement*,
0097                             const G4LogicalVolume* const)=0;
0098       //
0099       // Pure virtual methods implemented in concrete writer plugin's classes
0100 
0101     virtual void ExtensionWrite(xercesc::DOMElement*);
0102     virtual void UserinfoWrite(xercesc::DOMElement*);
0103     virtual void AddExtension(xercesc::DOMElement*,
0104                               const G4LogicalVolume* const);
0105       //
0106       // To be implemented in the client code for handling extensions
0107       // to the GDML schema, identified with the tag "extension".
0108       // The implementation should be placed inside a user-class
0109       // inheriting from PHG4GDMLWriteStructure and being registered
0110       // as argument to PHG4GDMLParser.
0111 
0112     G4String GenerateName(const G4String&,const void* const);
0113 
0114   protected:
0115 
0116     PHG4GDMLWrite();
0117     virtual ~PHG4GDMLWrite();
0118 
0119     VolumeMapType& VolumeMap();
0120 
0121     xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
0122     xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
0123     xercesc::DOMElement* NewElement(const G4String&);
0124     G4String Modularize(const G4VPhysicalVolume* const topvol,
0125                         const G4int depth);
0126 
0127     void AddAuxInfo(PHG4GDMLAuxListType* auxInfoList, xercesc::DOMElement* element);
0128 
0129     G4bool FileExists(const G4String&) const;
0130     PhysVolumeMapType& PvolumeMap();
0131     DepthMapType& DepthMap();
0132 
0133   protected:
0134 
0135     G4String SchemaLocation;
0136     static G4bool addPointerToName;
0137     xercesc::DOMDocument* doc;
0138     xercesc::DOMElement* extElement;
0139     xercesc::DOMElement* userinfoElement;
0140     XMLCh tempStr[10000];
0141     PHG4GDMLAuxListType auxList;
0142 };
0143 
0144 #endif
0145