Import Geant4 9.1.0 source tree
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
# $Id: GNUmakefile,v 1.26 2006/11/14 16:12:17 gcosmo Exp $
|
||||
# $Id: GNUmakefile,v 1.29 2007/11/02 16:22:05 gcosmo Exp $
|
||||
# -----------------------------------------------------------------------
|
||||
# GNUmakefile for persistency library. Gabriele Cosmo, 16/11/96.
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
name := G4persistency
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../..
|
||||
SUBDIRS := mctruth
|
||||
SUBLIBS = G4mctruth
|
||||
|
||||
ifdef G4LIB_BUILD_GDML
|
||||
SUBDIRS += gdml
|
||||
SUBLIBS += G4gdml
|
||||
endif
|
||||
|
||||
GLOBLIBS = libG4run.lib libG4event.lib
|
||||
@@ -14,29 +18,9 @@ GLOBLIBS += libG4tracking.lib libG4digits_hits.lib libG4track.lib
|
||||
GLOBLIBS += libG4particles.lib libG4geometry.lib libG4materials.lib
|
||||
GLOBLIBS += libG4graphics_reps.lib libG4intercoms.lib libG4global.lib
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4INSTALL)/source/global/management/include \
|
||||
-I$(G4INSTALL)/source/global/HEPGeometry/include \
|
||||
-I$(G4INSTALL)/source/digits_hits/hits/include \
|
||||
-I$(G4INSTALL)/source/digits_hits/digits/include \
|
||||
-I$(G4INSTALL)/source/particles/management/include \
|
||||
-I$(G4INSTALL)/source/run/include \
|
||||
-I$(G4INSTALL)/source/event/include \
|
||||
-I$(G4INSTALL)/source/track/include \
|
||||
-I$(G4INSTALL)/source/tracking/include \
|
||||
-I$(G4INSTALL)/source/intercoms/include \
|
||||
-I$(G4INSTALL)/source/geometry/management/include
|
||||
ifdef G4LIB_USE_HEPMC
|
||||
ifndef HEPMC_DIR
|
||||
@echo HEPMC_DIR not defined!
|
||||
endif
|
||||
CPPFLAGS += -I$(HEPMC_DIR)/include
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
|
||||
.PHONY: global
|
||||
|
||||
global: lib
|
||||
|
||||
include $(G4INSTALL)/config/globlib.gmk
|
||||
|
||||
@@ -15,6 +15,16 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
02 November, 07 G.Cosmo (persistency-V09-00-00)
|
||||
- Added G4LIB_BUILD_GDML/G4LIB_USE_GDML flags to trigger compilation through
|
||||
the central scripts. Moved setup for XERCESC (includes and libs paths) to
|
||||
central scripts.
|
||||
- Coworks with tag "config-V09-00-06".
|
||||
|
||||
17 October, 07 Z.Torzsok
|
||||
- Introduced new "gdml" plugin sub-module, based on new GDML release 3.
|
||||
- Moved existing classes to "mctruth" sub-module; renamed libraries.
|
||||
|
||||
14 November, 06 G.Cosmo (persistency-V08-01-02)
|
||||
- Cleared trivial compilation warnings in G4PersistencyManager implementation.
|
||||
- Added setup for retrieving HepMC in case G4LIB_USE_HEPMC is set and the
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
# $Id: GNUmakefile,v 1.6 2007/12/11 15:00:49 gcosmo Exp $
|
||||
# -----------------------------------------------------------------------
|
||||
# GNUmakefile for persistency library. Gabriele Cosmo, 16/11/96.
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
name := G4gdml
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4INSTALL)/source/global/management/include \
|
||||
-I$(G4INSTALL)/source/global/HEPGeometry/include \
|
||||
-I$(G4INSTALL)/source/digits_hits/hits/include \
|
||||
-I$(G4INSTALL)/source/digits_hits/digits/include \
|
||||
-I$(G4INSTALL)/source/particles/management/include \
|
||||
-I$(G4INSTALL)/source/run/include \
|
||||
-I$(G4INSTALL)/source/event/include \
|
||||
-I$(G4INSTALL)/source/track/include \
|
||||
-I$(G4INSTALL)/source/tracking/include \
|
||||
-I$(G4INSTALL)/source/intercoms/include \
|
||||
-I$(G4INSTALL)/source/geometry/management/include \
|
||||
-I$(G4INSTALL)/source/geometry/volumes/include \
|
||||
-I$(G4INSTALL)/source/geometry/management/include \
|
||||
-I$(G4INSTALL)/source/geometry/solids/CSG/include \
|
||||
-I$(G4INSTALL)/source/geometry/solids/Boolean/include \
|
||||
-I$(G4INSTALL)/source/geometry/solids/specific/include \
|
||||
-I$(G4INSTALL)/source/geometry/divisions/include \
|
||||
-I$(G4INSTALL)/source/materials/include \
|
||||
-I$(G4INSTALL)/source/graphics_reps/include
|
||||
|
||||
ifdef G4LIB_USE_GDML
|
||||
ifndef XERCESCROOT
|
||||
@echo XERCESCROOT not defined!
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,46 @@
|
||||
$Id: History,v 1.5 2007/11/30 15:11:22 gcosmo Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
Category History file
|
||||
---------------------
|
||||
This file should be used by G4 developers and category coordinators
|
||||
to briefly summarize all major modifications introduced in the code
|
||||
and keep track of all category-tags.
|
||||
It DOES NOT substitute the CVS log-message one should put at every
|
||||
committal in the CVS repository !
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
30 November, 07 Z.Torzsok (gdml-V09-00-04)
|
||||
- Fine tuning of the class hierarchy and fixed issue with reflections.
|
||||
|
||||
23 November, 07 Z.Torzsok (gdml-V09-00-03)
|
||||
- Better handling of embedded loops and first adaptation.
|
||||
|
||||
22 November, 07 Z.Torzsok (gdml-V09-00-02)
|
||||
- Handling of embedded loops added.
|
||||
- Fixed compilation problems on Windows platform.
|
||||
|
||||
19 November, 07 G.Cosmo (gdml-V09-00-01)
|
||||
- Better handling of modular GDML files and reflections (Z.Torzsok).
|
||||
- Added disclaimer to all files. Use G4 types.
|
||||
- Fixed compilation problems on SUN platform.
|
||||
|
||||
15 November, 07 Z.Torzsok (gdml-V09-00-00)
|
||||
- Added support for modular files.
|
||||
- Completed set of specific solids. Supported reflections and divisions.
|
||||
|
||||
02 November, 07 G.Cosmo (persistency-V09-00-00)
|
||||
- Added G4LIB_BUILD_GDML/G4LIB_USE_GDML flags to trigger compilation through
|
||||
the central scripts. Moved setup for XERCESC (includes and libs paths) to
|
||||
central scripts.
|
||||
- Coworks with tag "config-V09-00-06".
|
||||
|
||||
17 October, 07 Z.Torzsok
|
||||
- Introduced new "gdml" plugin sub-module, based on new GDML release 3.
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLBase.hh,v 1.3 2007/11/30 11:58:46 ztorzsok Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
//
|
||||
// class G4GDMLBase
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// History:
|
||||
// - Created. Zoltan Torzsok, November 2007
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#ifndef _G4GDMLBASE_INCLUDED_
|
||||
#define _G4GDMLBASE_INCLUDED_
|
||||
|
||||
#include <xercesc/parsers/XercesDOMParser.hpp>
|
||||
#include <xercesc/util/PlatformUtils.hpp>
|
||||
#include <xercesc/util/XMLUni.hpp>
|
||||
#include <xercesc/dom/DOM.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
#include "G4GDMLEvaluator.hh"
|
||||
|
||||
class G4GDMLBase {
|
||||
private:
|
||||
xercesc::XercesDOMParser* parser; // This should be a static member
|
||||
G4String prename;
|
||||
protected:
|
||||
G4GDMLEvaluator eval;
|
||||
|
||||
G4String GenerateName(const G4String&);
|
||||
|
||||
virtual void defineRead(const xercesc::DOMElement* const)=0;
|
||||
virtual void materialsRead(const xercesc::DOMElement* const)=0;
|
||||
virtual void solidsRead(const xercesc::DOMElement* const)=0;
|
||||
virtual void structureRead(const xercesc::DOMElement* const)=0;
|
||||
virtual void setupRead(const xercesc::DOMElement* const)=0;
|
||||
|
||||
virtual G4LogicalVolume* getVolume(const G4String&) const=0;
|
||||
virtual G4String getSetup(const G4String&)=0;
|
||||
public:
|
||||
G4GDMLBase();
|
||||
~G4GDMLBase();
|
||||
|
||||
void Parse(const G4String& fileName);
|
||||
G4PVPlacement* getTopVolume(const G4String& setupName);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLDefine.hh,v 1.11 2007/11/30 11:58:46 ztorzsok Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
//
|
||||
//
|
||||
// class G4GDMLDefine
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// GDML class for positionings and transformations according to
|
||||
// specifications in Geant4.
|
||||
|
||||
// History:
|
||||
// - Created. Zoltan Torzsok, November 2007
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#ifndef _G4GDMLDEFINE_INCLUDED_
|
||||
#define _G4GDMLDEFINE_INCLUDED_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4GDMLBase.hh"
|
||||
|
||||
class G4GDMLDefine : public G4GDMLBase {
|
||||
private:
|
||||
std::map<G4String,G4ThreeVector*> positionMap;
|
||||
std::map<G4String,G4ThreeVector*> rotationMap;
|
||||
std::map<G4String,G4ThreeVector*> scaleMap;
|
||||
|
||||
void constantRead(const xercesc::DOMElement* const);
|
||||
void positionRead(const xercesc::DOMElement* const);
|
||||
void rotationRead(const xercesc::DOMElement* const);
|
||||
void scaleRead(const xercesc::DOMElement* const);
|
||||
void variableRead(const xercesc::DOMElement* const);
|
||||
void defineRead(const xercesc::DOMElement* const);
|
||||
protected:
|
||||
G4ThreeVector* getPosition(const G4String&);
|
||||
G4ThreeVector* getRotation(const G4String&);
|
||||
G4ThreeVector* getScale(const G4String&);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLEvaluator.hh,v 1.10 2007/11/28 10:27:18 ztorzsok Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
//
|
||||
//
|
||||
// class G4GDMLEvaluator
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// GDML class for evaluation of expressions.
|
||||
|
||||
// History:
|
||||
// - Created. Zoltan Torzsok, November 2007
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#ifndef _G4GDMLEVALUATOR_INCLUDED_
|
||||
#define _G4GDMLEVALUATOR_INCLUDED_
|
||||
|
||||
#include <CLHEP/Evaluator/Evaluator.h>
|
||||
|
||||
#include "G4Types.hh"
|
||||
#include "G4String.hh"
|
||||
#include "G4Box.hh"
|
||||
|
||||
class G4GDMLEvaluator {
|
||||
HepTool::Evaluator eval;
|
||||
std::vector<G4String> variableList;
|
||||
public:
|
||||
G4GDMLEvaluator();
|
||||
|
||||
void defineConstant(const G4String&,G4double);
|
||||
void defineVariable(const G4String&,G4double);
|
||||
void setVariable(const G4String&,G4double);
|
||||
void checkVariable(const G4String&);
|
||||
|
||||
G4double Evaluate(const G4String&);
|
||||
G4int EvaluateInteger(const G4String&);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLMaterials.hh,v 1.10 2007/11/30 11:58:46 ztorzsok Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
//
|
||||
//
|
||||
// class G4GDMLMaterials
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// GDML class for loading isotopes, elements and materials according to
|
||||
// specifications in Geant4.
|
||||
|
||||
// History:
|
||||
// - Created. Zoltan Torzsok, November 2007
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#ifndef _G4GDMLMATERIALS_INCLUDED_
|
||||
#define _G4GDMLMATERIALS_INCLUDED_
|
||||
|
||||
#include "G4GDMLDefine.hh"
|
||||
|
||||
#include "G4Element.hh"
|
||||
#include "G4Isotope.hh"
|
||||
#include "G4Material.hh"
|
||||
|
||||
class G4GDMLMaterials : public G4GDMLDefine {
|
||||
private:
|
||||
G4double atomRead(const xercesc::DOMElement* const);
|
||||
G4double DRead(const xercesc::DOMElement* const);
|
||||
void elementRead(const xercesc::DOMElement* const);
|
||||
G4double fractionRead(const xercesc::DOMElement* const,G4String&);
|
||||
void isotopeRead(const xercesc::DOMElement* const);
|
||||
void materialRead(const xercesc::DOMElement* const);
|
||||
void mixtureRead(const xercesc::DOMElement* const,G4Element*);
|
||||
void mixtureRead(const xercesc::DOMElement* const,G4Material*);
|
||||
void materialsRead(const xercesc::DOMElement* const);
|
||||
protected:
|
||||
G4Isotope* getIsotope(const G4String&) const;
|
||||
G4Material* getMaterial(const G4String&) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLParser.hh,v 1.10 2007/11/30 11:58:46 ztorzsok Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
//
|
||||
//
|
||||
// class G4GDMLParser
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// History:
|
||||
// - Created. Zoltan Torzsok, November 2007
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#ifndef _G4GDMLPARSER_INCLUDED_
|
||||
#define _G4GDMLPARSER_INCLUDED_
|
||||
|
||||
#include "G4GDMLStructure.hh"
|
||||
|
||||
class G4GDMLParser {
|
||||
G4GDMLStructure structure;
|
||||
public:
|
||||
void Read(const G4String& fileName) { structure.Parse(fileName); }
|
||||
G4VPhysicalVolume* GetWorldVolume(const G4String& setupName="Default") { return structure.getTopVolume(setupName); }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLSetup.hh,v 1.9 2007/11/29 13:13:06 ztorzsok Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
//
|
||||
//
|
||||
// class G4GDMLSetup
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// GDML class for geometry setup of physical volumes.
|
||||
|
||||
// History:
|
||||
// - Created. Zoltan Torzsok, November 2007
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#ifndef _G4GDMLSETUP_INCLUDED_
|
||||
#define _G4GDMLSETUP_INCLUDED_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "G4String.hh"
|
||||
|
||||
#include "G4GDMLSolids.hh"
|
||||
|
||||
class G4GDMLSetup : public G4GDMLSolids {
|
||||
private:
|
||||
std::map<G4String,G4String> setupMap;
|
||||
protected:
|
||||
void setupRead(const xercesc::DOMElement* const element);
|
||||
public:
|
||||
G4String getSetup(const G4String&);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLSolids.hh,v 1.16 2007/11/30 14:51:20 ztorzsok Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
//
|
||||
//
|
||||
// class G4GDMLSolids
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// GDML class for loading solids according to specifications in Geant4.
|
||||
|
||||
// History:
|
||||
// - Created. Zoltan Torzsok, November 2007
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#ifndef _G4GDMLSOLIDS_INCLUDED_
|
||||
#define _G4GDMLSOLIDS_INCLUDED_
|
||||
|
||||
#include "G4Box.hh"
|
||||
#include "G4Cons.hh"
|
||||
#include "G4Ellipsoid.hh"
|
||||
#include "G4EllipticalTube.hh"
|
||||
#include "G4ExtrudedSolid.hh"
|
||||
#include "G4Hype.hh"
|
||||
#include "G4IntersectionSolid.hh"
|
||||
#include "G4Orb.hh"
|
||||
#include "G4Para.hh"
|
||||
#include "G4Polycone.hh"
|
||||
#include "G4Polyhedra.hh"
|
||||
#include "G4QuadrangularFacet.hh"
|
||||
#include "G4ReflectedSolid.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
#include "G4SubtractionSolid.hh"
|
||||
#include "G4TessellatedSolid.hh"
|
||||
#include "G4Tet.hh"
|
||||
#include "G4Torus.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4Trap.hh"
|
||||
#include "G4Trd.hh"
|
||||
#include "G4TriangularFacet.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4UnionSolid.hh"
|
||||
|
||||
#include "G4GDMLMaterials.hh"
|
||||
|
||||
class G4GDMLSolids : public G4GDMLMaterials {
|
||||
private:
|
||||
enum BooleanOp {UNION,SUBTRACTION,INTERSECTION};
|
||||
typedef struct zplaneType { G4double rmin,rmax,z; };
|
||||
|
||||
void booleanRead(const xercesc::DOMElement* const,const BooleanOp);
|
||||
void boxRead(const xercesc::DOMElement* const);
|
||||
void coneRead(const xercesc::DOMElement* const);
|
||||
void ellipsoidRead(const xercesc::DOMElement* const);
|
||||
void eltubeRead(const xercesc::DOMElement* const);
|
||||
void hypeRead(const xercesc::DOMElement* const);
|
||||
void loopRead(const xercesc::DOMElement* const);
|
||||
void orbRead(const xercesc::DOMElement* const);
|
||||
void paraRead(const xercesc::DOMElement* const);
|
||||
void polyconeRead(const xercesc::DOMElement* const);
|
||||
void polyhedraRead(const xercesc::DOMElement* const);
|
||||
G4QuadrangularFacet* quadrangularRead(const xercesc::DOMElement* const);
|
||||
G4String refRead(const xercesc::DOMElement* const);
|
||||
void reflectedSolidRead(const xercesc::DOMElement* const);
|
||||
G4ExtrudedSolid::ZSection sectionRead(const xercesc::DOMElement* const,G4double);
|
||||
void sphereRead(const xercesc::DOMElement* const);
|
||||
void tessellatedRead(const xercesc::DOMElement* const);
|
||||
void tetRead(const xercesc::DOMElement* const);
|
||||
void torusRead(const xercesc::DOMElement* const);
|
||||
void trapRead(const xercesc::DOMElement* const);
|
||||
void trdRead(const xercesc::DOMElement* const);
|
||||
G4TriangularFacet* triangularRead(const xercesc::DOMElement* const);
|
||||
void tubeRead(const xercesc::DOMElement* const);
|
||||
G4TwoVector twoDimVertexRead(const xercesc::DOMElement* const,G4double);
|
||||
void xtruRead(const xercesc::DOMElement* const);
|
||||
zplaneType zplaneRead(const xercesc::DOMElement* const,G4double);
|
||||
void solidsRead(const xercesc::DOMElement* const);
|
||||
protected:
|
||||
G4ThreeVector positionRead(const xercesc::DOMElement* const);
|
||||
G4ThreeVector rotationRead(const xercesc::DOMElement* const);
|
||||
G4ThreeVector scaleRead(const xercesc::DOMElement* const);
|
||||
G4VSolid* getSolid(const G4String&) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLStructure.hh,v 1.16 2007/11/30 14:51:20 ztorzsok Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
//
|
||||
//
|
||||
// class G4GDMLStructure
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// GDML class for loading physical volumes according to various
|
||||
// specifications in Geant4.
|
||||
|
||||
// History:
|
||||
// - Created. Zoltan Torzsok, November 2007
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#ifndef _G4GDMLSTRUCTURE_INCLUDED_
|
||||
#define _G4GDMLSTRUCTURE_INCLUDED_
|
||||
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4PVDivision.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4ReflectionFactory.hh"
|
||||
|
||||
#include "G4GDMLSetup.hh"
|
||||
|
||||
class G4GDMLStructure : public G4GDMLSetup {
|
||||
private:
|
||||
EAxis directionRead(const xercesc::DOMElement* const);
|
||||
void divisionvolRead(const xercesc::DOMElement* const,G4LogicalVolume*);
|
||||
G4LogicalVolume* fileRead(const xercesc::DOMElement* const);
|
||||
void loopRead(const xercesc::DOMElement* const);
|
||||
void paramvolRead(const xercesc::DOMElement* const,G4LogicalVolume*);
|
||||
void physvolRead(const xercesc::DOMElement* const,G4LogicalVolume*);
|
||||
G4double quantityRead(const xercesc::DOMElement* const);
|
||||
G4String refRead(const xercesc::DOMElement* const);
|
||||
void replicate_along_axisRead(const xercesc::DOMElement* const,G4double&,G4double&,EAxis&);
|
||||
void replicavolRead(const xercesc::DOMElement* const,G4LogicalVolume*);
|
||||
void volumeRead(const xercesc::DOMElement* const);
|
||||
void volume_contentRead(const xercesc::DOMElement* const,G4LogicalVolume*);
|
||||
void volume_loopRead(const xercesc::DOMElement* const,G4LogicalVolume*);
|
||||
void structureRead(const xercesc::DOMElement* const);
|
||||
protected:
|
||||
G4LogicalVolume* getVolume(const G4String&) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,158 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLBase.cc,v 1.3 2007/11/30 11:58:46 ztorzsok Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
//
|
||||
//
|
||||
// class G4GDMLBase
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// History:
|
||||
// - Created. Zoltan Torzsok, November 2007
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#include "G4GDMLBase.hh"
|
||||
|
||||
G4GDMLBase::G4GDMLBase() {
|
||||
|
||||
try {
|
||||
|
||||
xercesc::XMLPlatformUtils::Initialize();
|
||||
}
|
||||
catch(xercesc::XMLException& e) {
|
||||
|
||||
char* message = xercesc::XMLString::transcode(e.getMessage());
|
||||
G4cerr << "XML toolkit initialization error: " << message << G4endl;
|
||||
xercesc::XMLString::release(&message);
|
||||
}
|
||||
|
||||
parser = new xercesc::XercesDOMParser;
|
||||
|
||||
parser->setValidationScheme(xercesc::XercesDOMParser::Val_Always);
|
||||
parser->setDoNamespaces(true);
|
||||
parser->setDoSchema(true);
|
||||
parser->setValidationSchemaFullChecking(true);
|
||||
}
|
||||
|
||||
G4GDMLBase::~G4GDMLBase() {
|
||||
|
||||
if (parser) delete parser;
|
||||
|
||||
try {
|
||||
|
||||
xercesc::XMLPlatformUtils::Terminate();
|
||||
}
|
||||
catch(xercesc::XMLException& e) {
|
||||
|
||||
char* message = xercesc::XMLString::transcode(e.getMessage());
|
||||
G4cerr << "XML toolkit termination error: " << message << G4endl;
|
||||
xercesc::XMLString::release(&message);
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4GDMLBase::GenerateName(const G4String& in) {
|
||||
|
||||
std::string out(prename);
|
||||
|
||||
std::string::size_type open = in.find("[",0);
|
||||
|
||||
out.append(in,0,open);
|
||||
|
||||
while (open != std::string::npos) {
|
||||
|
||||
std::string::size_type close = in.find("]",open);
|
||||
|
||||
if (close == std::string::npos) G4Exception("Bracket mismatch in loop!");
|
||||
|
||||
std::string expr = in.substr(open+1,close-open-1);
|
||||
|
||||
std::stringstream stream;
|
||||
|
||||
stream << "[" << eval.EvaluateInteger(expr) << "]";
|
||||
|
||||
out.append(stream.str());
|
||||
|
||||
open = in.find("[",close);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void G4GDMLBase::Parse(const G4String& fileName) {
|
||||
|
||||
prename = fileName + "_";
|
||||
|
||||
try {
|
||||
|
||||
parser->parse(fileName.c_str());
|
||||
}
|
||||
catch (const xercesc::XMLException &e) {
|
||||
|
||||
char* message = xercesc::XMLString::transcode(e.getMessage());
|
||||
G4cout << "XML: " << message << G4endl;
|
||||
xercesc::XMLString::release(&message);
|
||||
}
|
||||
catch (const xercesc::DOMException &e) {
|
||||
|
||||
char* message = xercesc::XMLString::transcode(e.getMessage());
|
||||
G4cout << "DOM: " << message << G4endl;
|
||||
xercesc::XMLString::release(&message);
|
||||
}
|
||||
|
||||
xercesc::DOMDocument* doc = parser->getDocument();
|
||||
|
||||
if (!doc) G4Exception("GDML: Unable to open document: "+fileName);
|
||||
|
||||
xercesc::DOMElement* element = doc->getDocumentElement();
|
||||
|
||||
if (!element) G4Exception("GDML: Empty document!");
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="define" ) defineRead(child); else
|
||||
if (tag=="materials") materialsRead(child); else
|
||||
if (tag=="solids" ) solidsRead(child); else
|
||||
if (tag=="setup" ) setupRead(child); else
|
||||
if (tag=="structure") structureRead(child);
|
||||
}
|
||||
}
|
||||
|
||||
G4PVPlacement* G4GDMLBase::getTopVolume(const G4String& setupName) {
|
||||
|
||||
G4LogicalVolume* volume = getVolume(getSetup(setupName));
|
||||
|
||||
volume->SetVisAttributes(G4VisAttributes::Invisible);
|
||||
|
||||
return new G4PVPlacement(0,G4ThreeVector(),volume,"",0,0,0);
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLDefine.cc,v 1.14 2007/11/30 13:27:24 ztorzsok Exp $
|
||||
// GEANT4 tag $ Name:$
|
||||
//
|
||||
// class G4GDMLDefine Implementation
|
||||
//
|
||||
// Original author: Zoltan Torzsok, November 2007
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GDMLDefine.hh"
|
||||
|
||||
void G4GDMLDefine::constantRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String value;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* node = attributes->item(attribute_index);
|
||||
|
||||
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value; else
|
||||
if (attribute_name=="value") value = attribute_value;
|
||||
}
|
||||
|
||||
eval.defineConstant(name,eval.Evaluate(value));
|
||||
}
|
||||
|
||||
void G4GDMLDefine::positionRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String unit("1");
|
||||
G4String x;
|
||||
G4String y;
|
||||
G4String z;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* node = attributes->item(attribute_index);
|
||||
|
||||
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value; else
|
||||
if (attribute_name=="unit") unit = attribute_value; else
|
||||
if (attribute_name=="x") x = attribute_value; else
|
||||
if (attribute_name=="y") y = attribute_value; else
|
||||
if (attribute_name=="z") z = attribute_value;
|
||||
}
|
||||
|
||||
G4double _unit = eval.Evaluate(unit);
|
||||
|
||||
G4double _x = eval.Evaluate(x)*_unit;
|
||||
G4double _y = eval.Evaluate(y)*_unit;
|
||||
G4double _z = eval.Evaluate(z)*_unit;
|
||||
|
||||
positionMap[GenerateName(name)] = new G4ThreeVector(_x,_y,_z);
|
||||
}
|
||||
|
||||
void G4GDMLDefine::rotationRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String unit("1");
|
||||
G4String x;
|
||||
G4String y;
|
||||
G4String z;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* node = attributes->item(attribute_index);
|
||||
|
||||
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value; else
|
||||
if (attribute_name=="unit") unit = attribute_value; else
|
||||
if (attribute_name=="x") x = attribute_value; else
|
||||
if (attribute_name=="y") y = attribute_value; else
|
||||
if (attribute_name=="z") z = attribute_value;
|
||||
}
|
||||
|
||||
G4double _unit = eval.Evaluate(unit);
|
||||
|
||||
G4double _x = eval.Evaluate(x)*_unit;
|
||||
G4double _y = eval.Evaluate(y)*_unit;
|
||||
G4double _z = eval.Evaluate(z)*_unit;
|
||||
|
||||
rotationMap[GenerateName(name)] = new G4ThreeVector(_x,_y,_z);
|
||||
}
|
||||
|
||||
void G4GDMLDefine::scaleRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String x;
|
||||
G4String y;
|
||||
G4String z;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* node = attributes->item(attribute_index);
|
||||
|
||||
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value; else
|
||||
if (attribute_name=="x") x = attribute_value; else
|
||||
if (attribute_name=="y") y = attribute_value; else
|
||||
if (attribute_name=="z") z = attribute_value;
|
||||
}
|
||||
|
||||
G4double _x = eval.Evaluate(x);
|
||||
G4double _y = eval.Evaluate(y);
|
||||
G4double _z = eval.Evaluate(z);
|
||||
|
||||
scaleMap[GenerateName(name)] = new G4ThreeVector(_x,_y,_z);
|
||||
}
|
||||
|
||||
void G4GDMLDefine::variableRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String value;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* node = attributes->item(attribute_index);
|
||||
|
||||
if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value; else
|
||||
if (attribute_name=="value") value = attribute_value;
|
||||
}
|
||||
|
||||
eval.defineVariable(name,eval.Evaluate(value));
|
||||
}
|
||||
|
||||
void G4GDMLDefine::defineRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="constant") constantRead(child); else
|
||||
if (tag=="position") positionRead(child); else
|
||||
if (tag=="rotation") rotationRead(child); else
|
||||
if (tag=="scale") scaleRead(child); else
|
||||
if (tag=="variable") variableRead(child); else
|
||||
G4Exception("GDML: Unknown tag in define: "+tag);
|
||||
}
|
||||
}
|
||||
|
||||
G4ThreeVector* G4GDMLDefine::getPosition(const G4String& ref) {
|
||||
|
||||
if (positionMap.find(ref) != positionMap.end()) return positionMap[ref];
|
||||
|
||||
G4Exception("GDML: Referenced position '"+ref+"' was not found!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4ThreeVector* G4GDMLDefine::getRotation(const G4String& ref) {
|
||||
|
||||
if (rotationMap.find(ref) != rotationMap.end()) return rotationMap[ref];
|
||||
|
||||
G4Exception("GDML: Referenced rotation '"+ref+"' was not found!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4ThreeVector* G4GDMLDefine::getScale(const G4String& ref) {
|
||||
|
||||
if (scaleMap.find(ref) != scaleMap.end()) return scaleMap[ref];
|
||||
|
||||
G4Exception("GDML: Referenced scale '"+ref+"' was not found!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLEvaluator.cc,v 1.11 2007/11/28 10:27:18 ztorzsok Exp $
|
||||
// GEANT4 tag $ Name:$
|
||||
//
|
||||
// class G4GDMLEvaluator Implementation
|
||||
//
|
||||
// Original author: Zoltan Torzsok, November 2007
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GDMLEvaluator.hh"
|
||||
|
||||
G4GDMLEvaluator::G4GDMLEvaluator() {
|
||||
|
||||
eval.clear();
|
||||
eval.setStdMath();
|
||||
eval.setSystemOfUnits(1.e+3,1./1.60217733e-25,1.e+9,1./1.60217733e-10,1.0,1.0,1.0);
|
||||
}
|
||||
|
||||
void G4GDMLEvaluator::defineConstant(const G4String& name,G4double value) {
|
||||
|
||||
if (eval.findVariable(name)) G4Exception("GDML: Constant or variable '"+name+"' is already defined!");
|
||||
|
||||
eval.setVariable(name.c_str(),value);
|
||||
}
|
||||
|
||||
void G4GDMLEvaluator::defineVariable(const G4String& name,G4double value) {
|
||||
|
||||
if (eval.findVariable(name)) G4Exception("GDML: Constant or variable '"+name+"' is already defined!");
|
||||
|
||||
eval.setVariable(name.c_str(),value);
|
||||
variableList.push_back(name);
|
||||
}
|
||||
|
||||
void G4GDMLEvaluator::setVariable(const G4String& name,G4double value) {
|
||||
|
||||
checkVariable(name);
|
||||
|
||||
eval.setVariable(name.c_str(),value);
|
||||
}
|
||||
|
||||
void G4GDMLEvaluator::checkVariable(const G4String& name) {
|
||||
|
||||
for (std::vector<G4String>::iterator iter = variableList.begin(); iter != variableList.end(); iter++) {
|
||||
|
||||
if (name == *iter) return;
|
||||
}
|
||||
|
||||
G4Exception("GDML: Variable '"+name+"' is not defined!");
|
||||
}
|
||||
|
||||
G4double G4GDMLEvaluator::Evaluate(const G4String& expression) {
|
||||
|
||||
G4double value = 0.0;
|
||||
|
||||
if (!expression.empty()) {
|
||||
|
||||
value = eval.evaluate(expression.c_str());
|
||||
|
||||
if (eval.status() != HepTool::Evaluator::OK) {
|
||||
|
||||
eval.print_error();
|
||||
G4Exception("Error in evaluator!");
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
G4int G4GDMLEvaluator::EvaluateInteger(const G4String& expression) {
|
||||
|
||||
G4double value = Evaluate(expression);
|
||||
|
||||
G4int whole = (G4int)value;
|
||||
G4double frac = value - (G4double)whole;
|
||||
|
||||
if (frac != 0.0) G4Exception("GDML: Expression '"+expression+"' is expected to have an integer value!");
|
||||
|
||||
return whole;
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLMaterials.cc,v 1.12 2007/11/30 15:20:00 gcosmo Exp $
|
||||
// GEANT4 tag $ Name:$
|
||||
//
|
||||
// class G4GDMLMaterials Implementation
|
||||
//
|
||||
// Original author: Zoltan Torzsok, November 2007
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GDMLMaterials.hh"
|
||||
|
||||
G4double G4GDMLMaterials::atomRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String value;
|
||||
G4String unit("g/mole");
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="value") value = attribute_value; else
|
||||
if (attribute_name=="unit") unit = attribute_value;
|
||||
}
|
||||
|
||||
return eval.Evaluate(value)*eval.Evaluate(unit);
|
||||
}
|
||||
|
||||
G4double G4GDMLMaterials::DRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String value;
|
||||
G4String unit("g/cm3");
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="value") value = attribute_value; else
|
||||
if (attribute_name=="unit") unit = attribute_value;
|
||||
}
|
||||
|
||||
return eval.Evaluate(value)*eval.Evaluate(unit);
|
||||
}
|
||||
|
||||
void G4GDMLMaterials::elementRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String formula;
|
||||
G4String Z;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value; else
|
||||
if (attribute_name=="formula") formula = attribute_value; else
|
||||
if (attribute_name=="Z") Z = attribute_value;
|
||||
}
|
||||
|
||||
G4double _Z = eval.Evaluate(Z);
|
||||
G4double _a = 0;
|
||||
|
||||
G4int nComponents = 0;
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="atom") _a = atomRead(child); else
|
||||
if (tag=="fraction") nComponents++; else
|
||||
G4Exception("GDML: Unknown tag in element: "+tag);
|
||||
}
|
||||
|
||||
if (nComponents>0) mixtureRead(element,new G4Element(GenerateName(name),formula,nComponents));
|
||||
else new G4Element(GenerateName(name),formula,_Z,_a);
|
||||
}
|
||||
|
||||
G4double G4GDMLMaterials::fractionRead(const xercesc::DOMElement* const element,G4String& ref) {
|
||||
|
||||
G4String n;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="n") n = attribute_value; else
|
||||
if (attribute_name=="ref") ref = attribute_value;
|
||||
}
|
||||
|
||||
return eval.Evaluate(n);
|
||||
}
|
||||
|
||||
void G4GDMLMaterials::isotopeRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String Z;
|
||||
G4String N;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value; else
|
||||
if (attribute_name=="Z") Z = attribute_value; else
|
||||
if (attribute_name=="N") N = attribute_value;
|
||||
}
|
||||
|
||||
G4double __Z = eval.Evaluate(Z);
|
||||
G4double __N = eval.Evaluate(N);
|
||||
G4double __a = 0;
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="atom") __a = atomRead(child);
|
||||
}
|
||||
|
||||
new G4Isotope(GenerateName(name),(G4int)__Z,(G4int)__N,__a);
|
||||
}
|
||||
|
||||
void G4GDMLMaterials::materialRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String Z;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value; else
|
||||
if (attribute_name=="Z") Z = attribute_value;
|
||||
}
|
||||
|
||||
G4double _Z = eval.Evaluate(Z);
|
||||
G4double _D = 0.0;
|
||||
G4double _a = 0.0;
|
||||
|
||||
G4int nComponents = 0;
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="D") _D = DRead(child); else
|
||||
if (tag=="atom") _a = atomRead(child); else
|
||||
if (tag=="fraction") nComponents++; else
|
||||
G4Exception("GDML: Unknown tag in material: "+tag);
|
||||
}
|
||||
|
||||
if (nComponents>0) mixtureRead(element,new G4Material(GenerateName(name),_D,nComponents));
|
||||
else new G4Material(GenerateName(name),_Z,_a,_D);
|
||||
}
|
||||
|
||||
void G4GDMLMaterials::mixtureRead(const xercesc::DOMElement *const element,G4Element *ele) {
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="fraction") {
|
||||
|
||||
G4String ref;
|
||||
G4double _n = fractionRead(child,ref);
|
||||
|
||||
ele->AddIsotope(getIsotope(GenerateName(ref)),_n);
|
||||
} else G4Exception("GDML: Unknown tag in mixture element: "+tag);
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLMaterials::mixtureRead(const xercesc::DOMElement *const element,G4Material *material) {
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="D") { /*already processed*/ } else
|
||||
if (tag=="fraction") {
|
||||
|
||||
G4String ref;
|
||||
G4double _n = fractionRead(child,ref);
|
||||
|
||||
G4Material *materialPtr = G4Material::GetMaterial(GenerateName(ref),false);
|
||||
G4Element *elementPtr = G4Element::GetElement(GenerateName(ref),false);
|
||||
|
||||
if (materialPtr != 0) material->AddMaterial(materialPtr,_n); else
|
||||
if (elementPtr != 0) material->AddElement(elementPtr,_n);
|
||||
|
||||
if ((materialPtr == 0) && (elementPtr == 0)) G4Exception("GDML: Referenced material/element '"+GenerateName(ref)+"' was not found!");
|
||||
} else G4Exception("GDML: Unknown tag in mixture material: "+tag);
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLMaterials::materialsRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="element") elementRead(child); else
|
||||
if (tag=="isotope") isotopeRead(child); else
|
||||
if (tag=="material") materialRead(child); else
|
||||
G4Exception("GDML: Unknown tag in materials: "+tag);
|
||||
}
|
||||
}
|
||||
|
||||
G4Isotope* G4GDMLMaterials::getIsotope(const G4String& ref) const {
|
||||
|
||||
G4Isotope* isotopePtr = G4Isotope::GetIsotope(ref,false);
|
||||
|
||||
if (!isotopePtr) G4Exception("GDML: Referenced isotope '"+ref+"' was not found!");
|
||||
|
||||
return isotopePtr;
|
||||
}
|
||||
|
||||
G4Material* G4GDMLMaterials::getMaterial(const G4String& ref) const {
|
||||
|
||||
G4Material *materialPtr = G4Material::GetMaterial(ref,false);
|
||||
|
||||
if (!materialPtr) G4Exception("GDML: Referenced material '"+ref+"' was not found!");
|
||||
|
||||
return materialPtr;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
#include "G4GDMLParser.hh"
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLSetup.cc,v 1.11 2007/11/29 13:13:06 ztorzsok Exp $
|
||||
// GEANT4 tag $ Name:$
|
||||
//
|
||||
// class G4GDMLSetup Implementation
|
||||
//
|
||||
// Original author: Zoltan Torzsok, November 2007
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GDMLSetup.hh"
|
||||
|
||||
G4String G4GDMLSetup::getSetup(const G4String& ref) {
|
||||
|
||||
if (setupMap.find(ref) == setupMap.end())
|
||||
G4Exception("GDML: Referenced setup '"+ref+"' was not found!");
|
||||
|
||||
return setupMap[ref];
|
||||
}
|
||||
|
||||
void G4GDMLSetup::setupRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value;
|
||||
}
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag != "world") continue;
|
||||
|
||||
XMLCh *ref_attr = xercesc::XMLString::transcode("ref");
|
||||
G4String ref = xercesc::XMLString::transcode(child->getAttribute(ref_attr));
|
||||
xercesc::XMLString::release(&ref_attr);
|
||||
|
||||
setupMap[name] = GenerateName(ref);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,504 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLStructure.cc,v 1.25 2007/11/30 14:51:20 ztorzsok Exp $
|
||||
// GEANT4 tag $ Name:$
|
||||
//
|
||||
// class G4GDMLStructure Implementation
|
||||
//
|
||||
// Original author: Zoltan Torzsok, November 2007
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GDMLStructure.hh"
|
||||
|
||||
EAxis G4GDMLStructure::directionRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String x;
|
||||
G4String y;
|
||||
G4String z;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="x") x = attribute_value; else
|
||||
if (attribute_name=="y") y = attribute_value; else
|
||||
if (attribute_name=="z") z = attribute_value;
|
||||
}
|
||||
|
||||
G4double _x = eval.Evaluate(x);
|
||||
G4double _y = eval.Evaluate(y);
|
||||
G4double _z = eval.Evaluate(z);
|
||||
|
||||
if (_x == 1.0 && _y == 0.0 && _z == 0.0) return kXAxis; else
|
||||
if (_x == 0.0 && _y == 1.0 && _z == 0.0) return kYAxis; else
|
||||
if (_x == 0.0 && _y == 0.0 && _z == 1.0) return kZAxis;
|
||||
|
||||
G4Exception("GDML: Only directions along axes are supported!");
|
||||
|
||||
return kZAxis;
|
||||
}
|
||||
|
||||
void G4GDMLStructure::divisionvolRead(const xercesc::DOMElement* const element,G4LogicalVolume* pMother) {
|
||||
|
||||
G4String unit("1");
|
||||
G4String axis;
|
||||
G4String width;
|
||||
G4String offset;
|
||||
G4String number;
|
||||
G4String volumeref;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="unit") unit = attribute_value; else
|
||||
if (attribute_name=="axis") axis = attribute_value; else
|
||||
if (attribute_name=="width") width = attribute_value; else
|
||||
if (attribute_name=="offset") offset = attribute_value; else
|
||||
if (attribute_name=="number") number = attribute_value;
|
||||
}
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="volumeref") volumeref = refRead(child);
|
||||
}
|
||||
|
||||
G4LogicalVolume* pLogical = getVolume(GenerateName(volumeref));
|
||||
|
||||
G4double _unit = eval.Evaluate(unit);
|
||||
|
||||
G4double _width = eval.Evaluate(width)*_unit;
|
||||
G4double _offset = eval.Evaluate(offset)*_unit;
|
||||
G4double _number = eval.Evaluate(number);
|
||||
|
||||
EAxis _axis = kZAxis;
|
||||
|
||||
if (axis=="kXAxis") _axis = kXAxis; else
|
||||
if (axis=="kYAxis") _axis = kYAxis; else
|
||||
if (axis=="kZAxis") _axis = kZAxis; else
|
||||
if (axis=="kRho") _axis = kRho; else
|
||||
if (axis=="kPhi") _axis = kPhi;
|
||||
|
||||
new G4PVDivision("",pLogical,pMother,_axis,(G4int)_number,_width,_offset);
|
||||
}
|
||||
|
||||
G4LogicalVolume* G4GDMLStructure::fileRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String volname;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="name") name = attribute_value; else
|
||||
if (attribute_name=="volname") volname = attribute_value;
|
||||
}
|
||||
|
||||
G4GDMLStructure structure; // We create a new structure with a new evaluator
|
||||
|
||||
structure.Parse(name);
|
||||
|
||||
return structure.getVolume(structure.GenerateName(volname));
|
||||
}
|
||||
|
||||
void G4GDMLStructure::loopRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String var;
|
||||
G4String from;
|
||||
G4String to;
|
||||
G4String step;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="var") var = attribute_value; else
|
||||
if (attribute_name=="from") from = attribute_value; else
|
||||
if (attribute_name=="to") to = attribute_value; else
|
||||
if (attribute_name=="step") step = attribute_value;
|
||||
}
|
||||
|
||||
eval.checkVariable(var);
|
||||
|
||||
G4int _var = eval.EvaluateInteger(var );
|
||||
G4int _from = eval.EvaluateInteger(from);
|
||||
G4int _to = eval.EvaluateInteger(to );
|
||||
G4int _step = eval.EvaluateInteger(step);
|
||||
|
||||
if (!from.empty()) _var = _from;
|
||||
|
||||
while (_var <= _to) {
|
||||
|
||||
eval.setVariable(var,_var);
|
||||
structureRead(element);
|
||||
|
||||
_var += _step;
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLStructure::paramvolRead(const xercesc::DOMElement* const element,G4LogicalVolume *pMotherLogical) {
|
||||
|
||||
pMotherLogical = 0;
|
||||
|
||||
G4String volumeref;
|
||||
G4String parameterised_position_size;
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="parameterised_position_size") { ; } else
|
||||
if (tag=="volumeref") volumeref = refRead(child);
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLStructure::physvolRead(const xercesc::DOMElement* const element,G4LogicalVolume *mother) {
|
||||
|
||||
G4String volumeref;
|
||||
G4String positionref;
|
||||
G4String rotationref;
|
||||
G4String scaleref;
|
||||
|
||||
G4LogicalVolume* logvol = 0;
|
||||
|
||||
G4ThreeVector position;
|
||||
G4ThreeVector rotation;
|
||||
G4ThreeVector scale(1.0,1.0,1.0);
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="file") logvol = fileRead(child); else
|
||||
if (tag=="volumeref") volumeref = refRead(child); else
|
||||
if (tag=="position") position = positionRead(child); else
|
||||
if (tag=="rotation") rotation = rotationRead(child); else
|
||||
if (tag=="scale") scale = scaleRead(child); else
|
||||
if (tag=="positionref") positionref = refRead(child); else
|
||||
if (tag=="rotationref") rotationref = refRead(child); else
|
||||
if (tag=="scaleref") scaleref = refRead(child);
|
||||
}
|
||||
|
||||
if (!volumeref.empty()) logvol = getVolume(GenerateName(volumeref));
|
||||
|
||||
if (!positionref.empty()) position = *getPosition(GenerateName(positionref));
|
||||
if (!rotationref.empty()) rotation = *getRotation(GenerateName(rotationref));
|
||||
if (!scaleref.empty()) scale = *getScale(GenerateName(scaleref));
|
||||
|
||||
G4RotationMatrix Rot;
|
||||
|
||||
Rot.rotateX(rotation.x());
|
||||
Rot.rotateY(rotation.y());
|
||||
Rot.rotateZ(rotation.z());
|
||||
|
||||
G4Transform3D transform(Rot.inverse(),position);
|
||||
transform = transform*G4Scale3D(scale.x(),scale.y(),scale.z());
|
||||
|
||||
G4ReflectionFactory::Instance()->Place(transform,"",logvol,mother,false,0);
|
||||
}
|
||||
|
||||
G4double G4GDMLStructure::quantityRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String value;
|
||||
G4String unit("1");
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="value") value = attribute_value;
|
||||
if (attribute_name=="unit") unit = attribute_value;
|
||||
}
|
||||
|
||||
return eval.Evaluate(value)*eval.Evaluate(unit);
|
||||
}
|
||||
|
||||
G4String G4GDMLStructure::refRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String ref;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="ref") ref = attribute_value;
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
void G4GDMLStructure::replicate_along_axisRead(const xercesc::DOMElement* const element,G4double& _width,G4double& _offset,EAxis& _axis) {
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="width") _width = quantityRead(child); else
|
||||
if (tag=="offset") _offset = quantityRead(child); else
|
||||
if (tag=="direction") _axis = directionRead(child);
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLStructure::replicavolRead(const xercesc::DOMElement* const element,G4LogicalVolume* pMother) {
|
||||
|
||||
G4String volumeref;
|
||||
G4String numb;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="numb") numb = attribute_value;
|
||||
}
|
||||
|
||||
G4double _numb = eval.Evaluate(numb);
|
||||
G4double _width = 0.0;
|
||||
G4double _offset = 0.0;
|
||||
EAxis _axis;
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="volumeref") volumeref = refRead(child); else
|
||||
if (tag=="replicate_along_axis") replicate_along_axisRead(child,_width,_offset,_axis);
|
||||
}
|
||||
|
||||
G4LogicalVolume* pLogical = getVolume(GenerateName(volumeref));
|
||||
|
||||
new G4PVReplica("",pLogical,pMother,_axis,(G4int)_numb,_width,_offset);
|
||||
}
|
||||
|
||||
void G4GDMLStructure::volumeRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
G4String name;
|
||||
G4String solidref;
|
||||
G4String materialref;
|
||||
|
||||
XMLCh *name_attr = xercesc::XMLString::transcode("name");
|
||||
name = xercesc::XMLString::transcode(element->getAttribute(name_attr));
|
||||
xercesc::XMLString::release(&name_attr);
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="materialref") materialref = refRead(child); else
|
||||
if (tag=="solidref") solidref = refRead(child);
|
||||
}
|
||||
|
||||
G4Material* materialPtr = getMaterial(GenerateName(materialref));
|
||||
G4VSolid* solidPtr = getSolid(GenerateName(solidref));
|
||||
|
||||
volume_contentRead(element,new G4LogicalVolume(solidPtr,materialPtr,GenerateName(name),0,0,0));
|
||||
}
|
||||
|
||||
void G4GDMLStructure::volume_contentRead(const xercesc::DOMElement* const element,G4LogicalVolume* volumePtr) {
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="loop") volume_loopRead(child,volumePtr); else
|
||||
if (tag=="paramvol") paramvolRead(child,volumePtr); else
|
||||
if (tag=="physvol") physvolRead(child,volumePtr); else
|
||||
if (tag=="replicavol") replicavolRead(child,volumePtr); else
|
||||
if (tag=="divisionvol") divisionvolRead(child,volumePtr);
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLStructure::volume_loopRead(const xercesc::DOMElement* const element,G4LogicalVolume* volumePtr) {
|
||||
|
||||
G4String var;
|
||||
G4String from;
|
||||
G4String to;
|
||||
G4String step;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
|
||||
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
|
||||
|
||||
const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
|
||||
const G4String attribute_name = xercesc::XMLString::transcode(attribute->getName());
|
||||
const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
|
||||
|
||||
if (attribute_name=="var") var = attribute_value; else
|
||||
if (attribute_name=="from") from = attribute_value; else
|
||||
if (attribute_name=="to") to = attribute_value; else
|
||||
if (attribute_name=="step") step = attribute_value;
|
||||
}
|
||||
|
||||
eval.checkVariable(var);
|
||||
|
||||
G4int _var = eval.EvaluateInteger(var);
|
||||
G4int _from = eval.EvaluateInteger(from);
|
||||
G4int _to = eval.EvaluateInteger(to);
|
||||
G4int _step = eval.EvaluateInteger(step);
|
||||
|
||||
if (!from.empty()) _var = _from;
|
||||
|
||||
while (_var <= _to) {
|
||||
|
||||
eval.setVariable(var,_var);
|
||||
volume_contentRead(element,volumePtr);
|
||||
|
||||
_var += _step;
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLStructure::structureRead(const xercesc::DOMElement* const element) {
|
||||
|
||||
for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
|
||||
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
|
||||
|
||||
const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
|
||||
const G4String tag = xercesc::XMLString::transcode(child->getTagName());
|
||||
|
||||
if (tag=="loop") loopRead(child); else
|
||||
if (tag=="volume") volumeRead(child); else
|
||||
G4Exception("GDML: Unknown tag in structure: "+tag);
|
||||
}
|
||||
}
|
||||
|
||||
G4LogicalVolume* G4GDMLStructure::getVolume(const G4String& ref) const {
|
||||
|
||||
G4LogicalVolume *volumePtr = G4LogicalVolumeStore::GetInstance()->GetVolume(ref,false);
|
||||
|
||||
if (!volumePtr) G4Exception("GDML: Referenced volume '"+ref+"' was not found!");
|
||||
|
||||
return volumePtr;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# $Id: GNUmakefile,v 1.1 2007/10/17 09:33:17 gcosmo Exp $
|
||||
# -----------------------------------------------------------------------
|
||||
# GNUmakefile for persistency library. Gabriele Cosmo, 16/11/96.
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
name := G4mctruth
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4INSTALL)/source/global/management/include \
|
||||
-I$(G4INSTALL)/source/global/HEPGeometry/include \
|
||||
-I$(G4INSTALL)/source/digits_hits/hits/include \
|
||||
-I$(G4INSTALL)/source/digits_hits/digits/include \
|
||||
-I$(G4INSTALL)/source/particles/management/include \
|
||||
-I$(G4INSTALL)/source/run/include \
|
||||
-I$(G4INSTALL)/source/event/include \
|
||||
-I$(G4INSTALL)/source/track/include \
|
||||
-I$(G4INSTALL)/source/tracking/include \
|
||||
-I$(G4INSTALL)/source/intercoms/include \
|
||||
-I$(G4INSTALL)/source/geometry/management/include
|
||||
ifdef G4LIB_USE_HEPMC
|
||||
ifndef HEPMC_DIR
|
||||
@echo HEPMC_DIR not defined!
|
||||
endif
|
||||
CPPFLAGS += -I$(HEPMC_DIR)/include
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
|
||||
Reference in New Issue
Block a user