Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4GDMLWrite.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4GDMLWrite.hh
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 // $Id: PHG4GDMLWrite.hh 69013 2013-04-15 09:41:13Z gcosmo $
28 //
29 //
30 // class PHG4GDMLWrite
31 //
32 // Class description:
33 //
34 // GDML writer.
35 
36 // History:
37 // - Created. Zoltan Torzsok, November 2007
38 // -------------------------------------------------------------------------
39 
40 #ifndef _PHG4GDMLWRITE_INCLUDED_
41 #define _PHG4GDMLWRITE_INCLUDED_
42 
43 #include <map>
44 
45 #pragma GCC diagnostic push
46 #pragma GCC diagnostic ignored "-Wshadow"
47 #include <xercesc/dom/DOM.hpp>
48 #include <xercesc/framework/LocalFileFormatTarget.hpp>
49 #include <xercesc/util/PlatformUtils.hpp>
50 #include <xercesc/util/XMLString.hpp>
51 #pragma GCC diagnostic pop
52 
53 #include <Geant4/G4Transform3D.hh>
54 
55 
56 #include "PHG4GDMLAuxStructType.hh"
57 
58 class G4LogicalVolume;
59 class G4VPhysicalVolume;
60 
62 {
63  typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
64  typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
65  typedef std::map<G4int,G4int> DepthMapType;
66 
67  public: // with description
68 
69  G4Transform3D Write(const G4String& filename,
70  const G4LogicalVolume* const topLog,
71  const G4String& schemaPath,
72  const G4int depth, G4bool storeReferences=true);
73  //
74  // Main method for writing GDML files.
75 
76  void AddModule(const G4VPhysicalVolume* const topVol);
77  void AddModule(const G4int depth);
78  //
79  // Split geometry structure in modules, by volume subtree or level
80 
82  //
83  // Import auxiliary structure
84 
85  static void SetAddPointerToName(G4bool);
86  //
87  // Specify if to add or not memory addresses to IDs.
88 
89  virtual void DefineWrite(xercesc::DOMElement*)=0;
90  virtual void MaterialsWrite(xercesc::DOMElement*)=0;
91  virtual void SolidsWrite(xercesc::DOMElement*)=0;
92  virtual void StructureWrite(xercesc::DOMElement*)=0;
93  virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
94  const G4int)=0;
95  virtual void SurfacesWrite()=0;
96  virtual void SetupWrite(xercesc::DOMElement*,
97  const G4LogicalVolume* const)=0;
98  //
99  // Pure virtual methods implemented in concrete writer plugin's classes
100 
101  virtual void ExtensionWrite(xercesc::DOMElement*);
102  virtual void UserinfoWrite(xercesc::DOMElement*);
103  virtual void AddExtension(xercesc::DOMElement*,
104  const G4LogicalVolume* const);
105  //
106  // To be implemented in the client code for handling extensions
107  // to the GDML schema, identified with the tag "extension".
108  // The implementation should be placed inside a user-class
109  // inheriting from PHG4GDMLWriteStructure and being registered
110  // as argument to PHG4GDMLParser.
111 
112  G4String GenerateName(const G4String&,const void* const);
113 
114  protected:
115 
116  PHG4GDMLWrite();
117  virtual ~PHG4GDMLWrite();
118 
120 
121  xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
122  xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
123  xercesc::DOMElement* NewElement(const G4String&);
124  G4String Modularize(const G4VPhysicalVolume* const topvol,
125  const G4int depth);
126 
127  void AddAuxInfo(PHG4GDMLAuxListType* auxInfoList, xercesc::DOMElement* element);
128 
129  G4bool FileExists(const G4String&) const;
132 
133  protected:
134 
135  G4String SchemaLocation;
136  static G4bool addPointerToName;
137  xercesc::DOMDocument* doc;
138  xercesc::DOMElement* extElement;
139  xercesc::DOMElement* userinfoElement;
140  XMLCh tempStr[10000];
142 };
143 
144 #endif
145