EIC 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 #include <xercesc/dom/DOM.hpp>
46 #include <xercesc/framework/LocalFileFormatTarget.hpp>
47 #include <xercesc/util/PlatformUtils.hpp>
48 #include <xercesc/util/XMLString.hpp>
49 
50 #include <Geant4/G4Transform3D.hh>
51 
52 
53 #include "PHG4GDMLAuxStructType.hh"
54 
55 class G4LogicalVolume;
56 class G4VPhysicalVolume;
57 
59 {
60  typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
61  typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
62  typedef std::map<G4int,G4int> DepthMapType;
63 
64  public: // with description
65 
66  G4Transform3D Write(const G4String& filename,
67  const G4LogicalVolume* const topLog,
68  const G4String& schemaPath,
69  const G4int depth, G4bool storeReferences=true);
70  //
71  // Main method for writing GDML files.
72 
73  void AddModule(const G4VPhysicalVolume* const topVol);
74  void AddModule(const G4int depth);
75  //
76  // Split geometry structure in modules, by volume subtree or level
77 
79  //
80  // Import auxiliary structure
81 
82  static void SetAddPointerToName(G4bool);
83  //
84  // Specify if to add or not memory addresses to IDs.
85 
86  virtual void DefineWrite(xercesc::DOMElement*)=0;
87  virtual void MaterialsWrite(xercesc::DOMElement*)=0;
88  virtual void SolidsWrite(xercesc::DOMElement*)=0;
89  virtual void StructureWrite(xercesc::DOMElement*)=0;
90  virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
91  const G4int)=0;
92  virtual void SurfacesWrite()=0;
93  virtual void SetupWrite(xercesc::DOMElement*,
94  const G4LogicalVolume* const)=0;
95  //
96  // Pure virtual methods implemented in concrete writer plugin's classes
97 
98  virtual void ExtensionWrite(xercesc::DOMElement*);
99  virtual void UserinfoWrite(xercesc::DOMElement*);
100  virtual void AddExtension(xercesc::DOMElement*,
101  const G4LogicalVolume* const);
102  //
103  // To be implemented in the client code for handling extensions
104  // to the GDML schema, identified with the tag "extension".
105  // The implementation should be placed inside a user-class
106  // inheriting from PHG4GDMLWriteStructure and being registered
107  // as argument to PHG4GDMLParser.
108 
109  G4String GenerateName(const G4String&,const void* const);
110 
111  protected:
112 
113  PHG4GDMLWrite();
114  virtual ~PHG4GDMLWrite();
115 
117 
118  xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
119  xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
120  xercesc::DOMElement* NewElement(const G4String&);
121  G4String Modularize(const G4VPhysicalVolume* const topvol,
122  const G4int depth);
123 
124  void AddAuxInfo(PHG4GDMLAuxListType* auxInfoList, xercesc::DOMElement* element);
125 
126  G4bool FileExists(const G4String&) const;
129 
130  protected:
131 
132  G4String SchemaLocation;
133  static G4bool addPointerToName;
134  xercesc::DOMDocument* doc;
135  xercesc::DOMElement* extElement;
136  xercesc::DOMElement* userinfoElement;
137  XMLCh tempStr[10000];
139 };
140 
141 #endif
142