diff --git a/DDAlign/CMakeLists.txt b/DDAlign/CMakeLists.txt index 1d5b10ae668e8158bc33e2edf389b0e1f8f1b2a4..f7fbfdaacf1b152b6fd92fb106f4dabeecb0f52c 100644 --- a/DDAlign/CMakeLists.txt +++ b/DDAlign/CMakeLists.txt @@ -19,6 +19,8 @@ include_directories(${CMAKE_SOURCE_DIR}/DDCore/include file(GLOB sources src/*.cpp) add_library(DD4hepAlign SHARED ${sources}) target_link_libraries(DD4hepAlign DD4hepCore ${ROOT_LIBRARIES}) +# +# SET( CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-long-long") if(DD4HEP_USE_XERCESC) add_definitions(-DDD4HEP_USE_XERCESC) @@ -26,9 +28,10 @@ else() add_definitions(-DDD4HEP_USE_TINYXML) endif() SET_TARGET_PROPERTIES( DD4hepAlign PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION}) +# #---DD4hepAlign rootmap -------------------------------------------------------------- dd4hep_generate_rootmap(DD4hepAlign) - +# install(DIRECTORY include/DDAlign DESTINATION include PATTERN ".svn" EXCLUDE ) diff --git a/DDCore/include/DD4hep/DetectorTools.h b/DDCore/include/DD4hep/DetectorTools.h index 93a8c0e65d37c44d9c540b557f866f5026f64919..7599a5f3b583a87317e7bac0efe0b80885b4fb88 100644 --- a/DDCore/include/DD4hep/DetectorTools.h +++ b/DDCore/include/DD4hep/DetectorTools.h @@ -42,7 +42,7 @@ namespace DD4hep { /// Assemble the path of a particular detector element std::string elementPath(DetElement element); /// Assemble the path of the PlacedVolume selection - std::string elementPath(const ElementPath& nodes); + std::string elementPath(const ElementPath& nodes, bool reverse=true); /// Collect detector elements to the top detector element (world) void elementPath(DetElement elt, ElementPath& detectors); @@ -54,7 +54,9 @@ namespace DD4hep { /// Assemble the placement path from a given detector element to the world volume std::string placementPath(DetElement element); /// Assemble the path of the PlacedVolume selection - std::string placementPath(const PlacementPath& nodes); + std::string placementPath(const PlacementPath& nodes, bool reverse=true); + /// Assemble the path of the PlacedVolume selection + std::string placementPath(const std::vector<const TGeoNode*>& nodes, bool reverse=true); /// Collect detector elements placements to the top detector element (world) [no holes!] void placementPath(DetElement elt, PlacementPath& nodes); @@ -67,6 +69,13 @@ namespace DD4hep { void placementTrafo(const PlacementPath& nodes, bool inverse, TGeoHMatrix*& mat); /// Update cached matrix to transform to positions to an upper level Placement void placementTrafo(const PlacementPath& nodes, bool inverse, TGeoHMatrix& mat); + + + /// Convert VolumeID to string + std::string toString(const PlacedVolume::VolIDs& ids); + /// Convert VolumeID to string + std::string toString(const IDDescriptor& dsc, const PlacedVolume::VolIDs& ids, VolumeID code); + } } /* End namespace Geometry */ diff --git a/DDCore/src/DetectorTools.cpp b/DDCore/src/DetectorTools.cpp index 00a08e87a62d4a90bf49f80d6509c439d179ca9f..cb82b05f7b5ca5f512316c0fc59dade75423bb63 100644 --- a/DDCore/src/DetectorTools.cpp +++ b/DDCore/src/DetectorTools.cpp @@ -20,8 +20,6 @@ // ROOT include files #include "TGeoMatrix.h" - - /* * DD4hep namespace declaration */ @@ -39,7 +37,7 @@ namespace DD4hep { */ namespace DetectorTools { /// Assemble the path of the PlacedVolume selection - std::string elementPath(const PlacementPath& nodes); + std::string elementPath(const PlacementPath& nodes, bool reverse); /// Collect detector elements to any parent detector element void elementPath(DetElement parent, DetElement elt, ElementPath& detectors); /// Collect detector elements placements to the top detector element (world) [fast, but may have holes!] @@ -185,18 +183,30 @@ void DetectorTools::elementPath(DetElement element, PlacementPath& det_nodes) { } /// Assemble the path of the PlacedVolume selection -std::string DetectorTools::elementPath(const PlacementPath& nodes) { +std::string DetectorTools::elementPath(const PlacementPath& nodes, bool reverse) { string s = ""; + if ( reverse ) { for(PlacementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) s += "/" + string((*i).name()); + } + else { + for(PlacementPath::const_iterator i=nodes.begin();i!=nodes.end();++i) + s += "/" + string((*i)->GetName()); + } return s; } /// Assemble the path of the PlacedVolume selection -std::string DetectorTools::elementPath(const ElementPath& nodes) { +std::string DetectorTools::elementPath(const ElementPath& nodes, bool reverse) { string s = ""; + if ( reverse ) { for(ElementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) s += "/" + string((*i)->GetName()); + } + else { + for(ElementPath::const_iterator i=nodes.begin();i!=nodes.end();++i) + s += "/" + string((*i)->GetName()); + } return s; } @@ -277,10 +287,30 @@ std::string DetectorTools::placementPath(DetElement element) { } /// Assemble the path of the PlacedVolume selection -std::string DetectorTools::placementPath(const PlacementPath& nodes) { +std::string DetectorTools::placementPath(const PlacementPath& nodes, bool reverse) { string s=""; - for(PlacementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) - s += "/" + string((*i)->GetName()); + if ( reverse ) { + for(PlacementPath::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) + s += "/" + string((*i)->GetName()); + } + else { + for(PlacementPath::const_iterator i=nodes.begin();i!=nodes.end();++i) + s += "/" + string((*i)->GetName()); + } + return s; +} + +/// Assemble the path of the PlacedVolume selection +std::string DetectorTools::placementPath(const std::vector<const TGeoNode*>& nodes, bool reverse) { + string s=""; + if ( reverse ) { + for(std::vector<const TGeoNode*>::const_reverse_iterator i=nodes.rbegin();i!=nodes.rend();++i) + s += "/" + string((*i)->GetName()); + } + else { + for(std::vector<const TGeoNode*>::const_iterator i=nodes.begin();i!=nodes.end();++i) + s += "/" + string((*i)->GetName()); + } return s; } @@ -352,3 +382,24 @@ PlacedVolume DetectorTools::findNode(PlacedVolume top_place, const std::string& return node; } +/// Convert VolumeID to string +std::string DetectorTools::toString(const PlacedVolume::VolIDs& ids) { + stringstream log; + for (PlacedVolume::VolIDs::const_iterator vit = ids.begin(); vit != ids.end(); ++vit) + log << (*vit).first << "=" << (*vit).second << "; "; + return log.str(); +} + +/// Convert VolumeID to string +std::string DetectorTools::toString(const IDDescriptor& dsc, const PlacedVolume::VolIDs& ids, VolumeID code) { + stringstream log; + for (PlacedVolume::VolIDs::const_iterator idIt = ids.begin(); idIt != ids.end(); ++idIt) { + const PlacedVolume::VolID& id = (*idIt); + IDDescriptor::Field f = dsc.field(id.first); + VolumeID value = f->value(code); + log << id.first << "=" << id.second << "," << value << " [" << f->offset() << "," << f->width() << "] "; + } + return log.str(); +} + + diff --git a/DDG4/include/DDG4/Geant4Action.h b/DDG4/include/DDG4/Geant4Action.h index 1372fbf49b1b7f5613d8868bb64716c11536caf0..4a18b3b756275a30f4f839d83ed3e469095b17c1 100644 --- a/DDG4/include/DDG4/Geant4Action.h +++ b/DDG4/include/DDG4/Geant4Action.h @@ -318,9 +318,9 @@ namespace DD4hep { /// Access to the main generator action sequence from the kernel object Geant4GeneratorActionSequence& generatorAction() const; /// Access to the Track Persistency Manager from the kernel object - Geant4MonteCarloTruth& mcTruthMgr() const; + Geant4MonteCarloTruth* mcTruthMgr(bool throw_exception=true) const; /// Access to the MC record manager from the kernel object - Geant4MonteCarloRecordManager& mcRecordMgr() const; + Geant4MonteCarloRecordManager* mcRecordMgr(bool throw_exception=true) const; }; /// Declare property diff --git a/DDG4/include/DDG4/Geant4AssemblyVolume.h b/DDG4/include/DDG4/Geant4AssemblyVolume.h new file mode 100644 index 0000000000000000000000000000000000000000..cd53dcbf3d40300882657bd4f95f39137466391c --- /dev/null +++ b/DDG4/include/DDG4/Geant4AssemblyVolume.h @@ -0,0 +1,35 @@ +#define private public +#include "G4AssemblyVolume.hh" +#undef private + +namespace DD4hep { namespace Simulation { + struct Geant4AssemblyVolume : public G4AssemblyVolume { + std::vector<const TGeoNode*> m_entries; + typedef std::vector<const TGeoNode*> Chain; + Geant4AssemblyVolume() { + } + virtual ~Geant4AssemblyVolume() { + } + //std::vector<G4AssemblyTriplet>& triplets() { return fTriplets; } + long placeVolume(const TGeoNode* n, G4LogicalVolume* pPlacedVolume, G4Transform3D& transformation) { + size_t id = fTriplets.size(); + m_entries.push_back(n); + this->AddPlacedVolume(pPlacedVolume, transformation); + return (long)id; + } + long placeAssembly(const TGeoNode* n, Geant4AssemblyVolume* pPlacedVolume, G4Transform3D& transformation) { + size_t id = fTriplets.size(); + m_entries.push_back(n); + this->AddPlacedAssembly(pPlacedVolume, transformation); + return (long)id; + } + void imprint(Geant4GeometryInfo& info, + const TGeoNode* n, + Chain chain, + Geant4AssemblyVolume* pAssembly, + G4LogicalVolume* pMotherLV, + G4Transform3D& transformation, + G4int copyNumBase, + G4bool surfCheck ); + }; + }} diff --git a/DDG4/include/DDG4/Geant4GeometryInfo.h b/DDG4/include/DDG4/Geant4GeometryInfo.h index 9426048d9abf7841709fbcb770f4596a787a0a12..7d31e27c912037dbf7b3a0084e3a2e004013f842 100644 --- a/DDG4/include/DDG4/Geant4GeometryInfo.h +++ b/DDG4/include/DDG4/Geant4GeometryInfo.h @@ -47,10 +47,10 @@ namespace DD4hep { // Forward declarations class Geant4Mapping; + class Geant4AssemblyVolume; - struct Geant4GeometryInfo : public TNamed, public Geometry::GeoHandlerTypes::GeometryInfo { - public: - typedef std::vector<const G4VPhysicalVolume*> PlacementPath; + namespace Geant4GeometryMaps { + typedef std::vector<const G4VPhysicalVolume*> Geant4PlacementPath; typedef std::map<const TGeoElement*, G4Element*> ElementMap; typedef std::map<const TGeoMedium*, G4Material*> MaterialMap; typedef std::map<const TNamed*, G4UserLimits*> LimitMap; @@ -58,30 +58,43 @@ namespace DD4hep { typedef std::map<const TNamed*, G4Region*> RegionMap; typedef std::map<const TNamed*, G4VSensitiveDetector*> SensDetMap; typedef std::map<const TGeoVolume*, G4LogicalVolume*> VolumeMap; - typedef std::map<const TGeoVolume*, G4AssemblyVolume*> AssemblyMap; + typedef std::map<const TGeoNode*, Geant4AssemblyVolume*> AssemblyMap; + + typedef std::vector<const TGeoNode*> VolumeChain; + typedef std::pair<VolumeChain,const G4VPhysicalVolume*> ImprintEntry; + typedef std::vector<ImprintEntry> Imprints; + typedef std::map<const TGeoVolume*,Imprints> VolumeImprintMap; typedef std::map<const TGeoShape*, G4VSolid*> SolidMap; typedef std::map<const TNamed*, G4VisAttributes*> VisMap; - typedef std::map<PlacementPath, VolumeID> PathMap; + typedef std::map<Geant4PlacementPath, VolumeID> Geant4PathMap; typedef Geometry::GeoHandlerTypes::SensitiveVolumes SensitiveVolumes; typedef Geometry::GeoHandlerTypes::RegionVolumes RegionVolumes; typedef Geometry::GeoHandlerTypes::LimitVolumes LimitVolumes; + /// Assemble Geant4 volume path + std::string placementPath(const Geant4PlacementPath& path, bool reverse=true); + } - ElementMap g4Elements; - MaterialMap g4Materials; - SolidMap g4Solids; - VolumeMap g4Volumes; - PlacementMap g4Placements; - AssemblyMap g4Assemblies; - RegionMap g4Regions; - VisMap g4Vis; - LimitMap g4Limits; - SensDetMap g4SensDets; - PathMap g4Paths; + struct Geant4GeometryInfo : public TNamed, public Geometry::GeoHandlerTypes::GeometryInfo { + public: + Geant4GeometryMaps::ElementMap g4Elements; + Geant4GeometryMaps::MaterialMap g4Materials; + Geant4GeometryMaps::SolidMap g4Solids; + Geant4GeometryMaps::VolumeMap g4Volumes; + Geant4GeometryMaps::PlacementMap g4Placements; + Geant4GeometryMaps::AssemblyMap g4AssemblyVolumes; + Geant4GeometryMaps::VolumeImprintMap g4VolumeImprints; + Geant4GeometryMaps::RegionMap g4Regions; + Geant4GeometryMaps::VisMap g4Vis; + Geant4GeometryMaps::LimitMap g4Limits; + Geant4GeometryMaps::SensDetMap g4SensDets; + + Geant4GeometryMaps::Geant4PathMap g4Paths; - SensitiveVolumes sensitives; - RegionVolumes regions; - LimitVolumes limits; + Geant4GeometryMaps::SensitiveVolumes sensitives; + Geant4GeometryMaps::RegionVolumes regions; + Geant4GeometryMaps::LimitVolumes limits; + G4VPhysicalVolume* m_world; bool valid; private: friend class Geant4Mapping; @@ -89,6 +102,11 @@ namespace DD4hep { Geant4GeometryInfo(); /// Default destructor virtual ~Geant4GeometryInfo(); + public: + /// The world placement + G4VPhysicalVolume* world() const; + /// Set the world volume + void setWorld(const TGeoNode* node); }; } // End namespace Simulation diff --git a/DDG4/include/DDG4/Geant4Kernel.h b/DDG4/include/DDG4/Geant4Kernel.h index 3fe94f2a94d24bee764eda54bdc295652f79af23..27cd4b74048ffbdd11365db2608f64630f74ba11 100644 --- a/DDG4/include/DDG4/Geant4Kernel.h +++ b/DDG4/include/DDG4/Geant4Kernel.h @@ -290,9 +290,9 @@ namespace DD4hep { return *physicsList(true); } /// Access to the Track Manager from the kernel object - Geant4MonteCarloTruth& mcTruthMgr(); + Geant4MonteCarloTruth* mcTruthMgr(bool throw_exception=true); /// Access to the MC record manager from the kernel object (if instantiated!) - Geant4MonteCarloRecordManager& mcRecordMgr(); + Geant4MonteCarloRecordManager* mcRecordMgr(bool throw_exception=true); /// Construct detector geometry using lcdd plugin void loadGeometry(const std::string& compact_file); diff --git a/DDG4/include/DDG4/Geant4Mapping.h b/DDG4/include/DDG4/Geant4Mapping.h index 0098228d04453cf4e4d66ee0d99d0e273faae6f9..d14343c642e68ebdec0de7b1c0e4132b9ba955b0 100644 --- a/DDG4/include/DDG4/Geant4Mapping.h +++ b/DDG4/include/DDG4/Geant4Mapping.h @@ -43,19 +43,6 @@ namespace DD4hep { typedef Geometry::Material Material; typedef Geometry::Region Region; - typedef Geant4GeometryInfo::PlacementPath PlacementPath; - typedef Geant4GeometryInfo::ElementMap ElementMap; - typedef Geant4GeometryInfo::MaterialMap MaterialMap; - typedef Geant4GeometryInfo::LimitMap LimitMap; - typedef Geant4GeometryInfo::PlacementMap PlacementMap; - typedef Geant4GeometryInfo::RegionMap RegionMap; - typedef Geant4GeometryInfo::SensDetMap SensDetMap; - typedef Geant4GeometryInfo::AssemblyMap AssemblyMap; - typedef Geant4GeometryInfo::VolumeMap VolumeMap; - typedef Geant4GeometryInfo::SolidMap SolidMap; - typedef Geant4GeometryInfo::VisMap VisMap; - typedef Geant4GeometryInfo::PathMap PathMap; - protected: LCDD& m_lcdd; Geant4GeometryInfo* m_dataPtr; diff --git a/DDG4/include/DDG4/Geant4StepHandler.h b/DDG4/include/DDG4/Geant4StepHandler.h index 75c55ff5147612f3413cbff7a337103c2dc6bcbe..f16c049733d097c31f792e5399a99998fec35749 100644 --- a/DDG4/include/DDG4/Geant4StepHandler.h +++ b/DDG4/include/DDG4/Geant4StepHandler.h @@ -127,4 +127,4 @@ namespace DD4hep { } // End namespace Simulation } // End namespace DD4hep -#endif // DD4HEP_GEANT4HITS_H +#endif // DD4HEP_GEANT4STEPHANDLER_H diff --git a/DDG4/include/DDG4/Geant4TouchableHandler.h b/DDG4/include/DDG4/Geant4TouchableHandler.h new file mode 100644 index 0000000000000000000000000000000000000000..faf050b57b16f562ef5639480e787fb4ba4bae44 --- /dev/null +++ b/DDG4/include/DDG4/Geant4TouchableHandler.h @@ -0,0 +1,65 @@ +// $Id: Geant4TouchableHandler.h 888 2013-11-14 15:54:56Z markus.frank@cern.ch $ +//==================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------- +// +// Author : M.Frank +// +//==================================================================== +#ifndef DD4HEP_GEANT4TOUCHABLEHANDLER_H +#define DD4HEP_GEANT4TOUCHABLEHANDLER_H + +// C/C++ include files +#include <vector> +#include <string> + +// Forward declarations +class G4VPhysicalVolume; +class G4VTouchable; +class G4Step; + +/* + * DD4hep namespace declaration + */ +namespace DD4hep { + + /* + * Simulation namespace declaration + */ + namespace Simulation { + + // Forward declarations; + class Geant4TouchableHandler; + + /** @class Geant4TouchableHandler Geant4SensitiveDetector.h DDG4/Geant4SensitiveDetector.h + * + * Tiny helper/utility class to easily access Geant4 touchable information. + * Born by lazyness: Avoid typing millions of statements! + * + * @author M.Frank + * @version 1.0 + */ + class Geant4TouchableHandler { + public: + + typedef std::vector<const G4VPhysicalVolume*> Geant4PlacementPath; + + const G4VTouchable* touchable; + + /// Default constructor. + Geant4TouchableHandler(const G4VTouchable* t) : touchable(t) {} + /// Default constructor. Takes the step's pre-touchable + Geant4TouchableHandler(const G4Step* step); + + /// Helper: Generate placement path from touchable object + Geant4PlacementPath placementPath(bool exception=false) const; + + /// Helper: Access the placement path of a Geant4 touchable object as a string + std::string path() const; + + }; + + } // End namespace Simulation +} // End namespace DD4hep + +#endif // DD4HEP_GEANT4TOUCHABLEHANDLER_H diff --git a/DDG4/include/DDG4/Geant4VolumeManager.h b/DDG4/include/DDG4/Geant4VolumeManager.h index 4107fcf35a91e4e20630b0d258a1f8fe23140dda..61edda462699345a20c75d3d7f819cd7eba5f1ba 100644 --- a/DDG4/include/DDG4/Geant4VolumeManager.h +++ b/DDG4/include/DDG4/Geant4VolumeManager.h @@ -45,7 +45,7 @@ namespace DD4hep { typedef Geometry::IDDescriptor IDDescriptor; typedef IDDescriptor::VolIDFields VolIDFields; typedef std::pair<VolumeID, VolIDFields> VolIDDescriptor; - typedef Geant4GeometryInfo::PlacementPath PlacementPath; + typedef Geant4GeometryMaps::Geant4PlacementPath PlacementPath; typedef Geant4GeometryInfo Object; protected: @@ -89,20 +89,10 @@ namespace DD4hep { /// Helper: Generate placement path from touchable object PlacementPath placementPath(const G4VTouchable* touchable, bool exception = true) const; - - /// Accessor to resolve TGeo geometry placements from Geant4 placements - PlacedVolume placement(const G4VPhysicalVolume* node) const; - /// Accessor to resolve Geant4 geometry placements from TGeo placements - G4VPhysicalVolume* placement(const TGeoNode* node) const; - /// Accessor to resolve Geant4 geometry placements from TGeo placements - G4VPhysicalVolume* placement(const PlacedVolume& node) const { - return placement(node.ptr()); - } /// Access CELLID by placement path VolumeID volumeID(const PlacementPath& path) const; /// Access CELLID by Geant4 touchable object VolumeID volumeID(const G4VTouchable* touchable) const; - /// Accessfully decoded volume fields by placement path void volumeDescriptor(const PlacementPath& path, VolIDDescriptor& volume_desc) const; /// Access fully decoded volume fields by Geant4 touchable object diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index 66a74f1ed41c2c37524b71cb48a6da5f14aa56c4..36ade55af9f06482f7fe1265c97884037965dd8e 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -8,7 +8,6 @@ //==================================================================== // Framework include files #include "DDG4/Geant4SensDetAction.h" -#include "DDG4/Geant4MonteCarloTruth.h" #include "DDG4/Geant4Data.h" #include "DD4hep/Printout.h" @@ -48,6 +47,7 @@ namespace DD4hep { } } #include "DD4hep/InstanceCount.h" +#include "DDG4/Geant4TouchableHandler.h" namespace DD4hep { namespace Simulation { @@ -93,6 +93,8 @@ namespace DD4hep { } #include "DDG4/Geant4StepHandler.h" +#include "DDG4/Geant4VolumeManager.h" +#include "DDG4/Geant4Mapping.h" #include "G4OpticalPhoton.hh" #include "G4VProcess.hh" @@ -143,16 +145,22 @@ namespace DD4hep { if ( hit ) { HitContribution contrib = Hit::extractContribution(step); hit->cellID = volumeID( step ) ; + hit->energyDeposit = contrib.deposit ; hit->position = position; hit->momentum = direction; hit->length = hit_len; collection(m_collectionID)->add(hit); - mcTruthMgr().mark(h.track,true); + mark(h.track); if ( 0 == hit->cellID ) { hit->cellID = volumeID( step ) ; throw runtime_error("Invalid CELL ID for hit!"); } + printout(INFO,"SimpleTracker","%s> Hit with deposit:%f Pos:%f %f %f ID=%016X", + c_name(),step->GetTotalEnergyDeposit(),position.X(),position.Y(),position.Z(), + (void*)hit->cellID); + Geant4TouchableHandler handler(step); + printout(INFO,"SimpleTracker","%s> Geant4 path:%s",c_name(),handler.path().c_str()); return true; } throw runtime_error("new() failed: Cannot allocate hit object"); @@ -192,7 +200,7 @@ namespace DD4hep { } hit->truth.push_back(contrib); hit->energyDeposit += contrib.deposit; - mcTruthMgr().mark(h.track,true); + mark(h.track); return true; } typedef Geant4SensitiveAction<SimpleCalorimeter> Geant4SimpleCalorimeterAction; @@ -235,8 +243,8 @@ namespace DD4hep { hit->energyDeposit += contrib.deposit; hit->truth.push_back(contrib); track->SetTrackStatus(fStopAndKill); // don't step photon any further - mcTruthMgr().mark(h.track,true); - return true; + mark(h.track); + return true; } } typedef Geant4SensitiveAction<SimpleOpticalCalorimeter> Geant4SimpleOpticalCalorimeterAction; @@ -288,7 +296,7 @@ namespace DD4hep { hit->length = path_len; clear(); c->insert(hit); - mcTruthMgr().mark(h.track,true); + mark(h.track); return hit; } }; diff --git a/DDG4/src/Geant4Action.cpp b/DDG4/src/Geant4Action.cpp index b981022662692f15d34b845b59e3718e90a584ee..3f377a06d20ac104094a12c64e0a702b477e3f62 100644 --- a/DDG4/src/Geant4Action.cpp +++ b/DDG4/src/Geant4Action.cpp @@ -229,12 +229,12 @@ Geant4GeneratorActionSequence& Geant4Action::generatorAction() const { } /// Access to the Track Manager from the kernel object -Geant4MonteCarloTruth& Geant4Action::mcTruthMgr() const { - return m_context->kernel().mcTruthMgr(); +Geant4MonteCarloTruth* Geant4Action::mcTruthMgr(bool throw_exception) const { + return m_context->kernel().mcTruthMgr(throw_exception); } /// Access to the MC record manager from the kernel object -Geant4MonteCarloRecordManager& Geant4Action::mcRecordMgr() const { - return m_context->kernel().mcRecordMgr(); +Geant4MonteCarloRecordManager* Geant4Action::mcRecordMgr(bool throw_exception) const { + return m_context->kernel().mcRecordMgr(throw_exception); } diff --git a/DDG4/src/Geant4Context.cpp b/DDG4/src/Geant4Context.cpp index 3f6c668bd3da213dd5b29603c89f69aabb8badd6..f91f76433bee1a50d391b93677d3da7e42699f7f 100644 --- a/DDG4/src/Geant4Context.cpp +++ b/DDG4/src/Geant4Context.cpp @@ -79,11 +79,11 @@ Geant4SensDetSequences& Geant4Context::sensitiveActions() const { /// Access to the Track Manager from the kernel object Geant4MonteCarloTruth& Geant4Context::mcTruthMgr() const { - return m_kernel->mcTruthMgr(); + return *m_kernel->mcTruthMgr(true); } /// Access to the MC record manager from the kernel object Geant4MonteCarloRecordManager& Geant4Context::mcRecordMgr() const { - return m_kernel->mcRecordMgr(); + return *m_kernel->mcRecordMgr(true); } diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index ad8bd1a5933fb99f274b6aa5858f4bbd13a63e8f..ae3be70e928e561ba9d26ffef394811ddc499567 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -73,32 +73,39 @@ #include "G4ElectroMagneticField.hh" #include "G4FieldManager.hh" #include "G4ReflectionFactory.hh" -#include "G4AssemblyVolume.hh" #include <iostream> #include <iomanip> #include <sstream> using namespace DD4hep::Simulation; +using namespace DD4hep::Simulation::Geant4GeometryMaps; using namespace DD4hep::Geometry; using namespace DD4hep; using namespace std; -#if 0 +#include "DDG4/Geant4AssemblyVolume.h" +#include "DD4hep/DetectorTools.h" #include "G4RotationMatrix.hh" #include "G4AffineTransform.hh" #include "G4LogicalVolume.hh" #include "G4VPhysicalVolume.hh" #include "G4ReflectionFactory.hh" -void G4AssemblyVolume::MakeImprint( G4AssemblyVolume* pAssembly, - G4LogicalVolume* pMotherLV, - G4Transform3D& transformation, - G4int copyNumBase, - G4bool surfCheck ) +void Geant4AssemblyVolume::imprint(Geant4GeometryInfo& info, + const TGeoNode* parent, + Chain chain, + Geant4AssemblyVolume* pAssembly, + G4LogicalVolume* pMotherLV, + G4Transform3D& transformation, + G4int copyNumBase, + G4bool surfCheck ) { + TGeoVolume* vol = parent->GetVolume(); static int level=0; ++level; + + unsigned int numberOfDaughters; if( copyNumBase == 0 ) @@ -117,9 +124,14 @@ void G4AssemblyVolume::MakeImprint( G4AssemblyVolume* pAssembly, ImprintsCountPlus(); std::vector<G4AssemblyTriplet> triplets = pAssembly->fTriplets; + //cout << " Assembly:" << DetectorTools::placementPath(chain) << endl; + + for( unsigned int i = 0; i < triplets.size(); i++ ) { + const TGeoNode* node = pAssembly->m_entries[i]; + Chain new_chain = chain; + new_chain.push_back(node); + //cout << " Assembly: Entry: " << DetectorTools::placementPath(new_chain) << endl; - for( unsigned int i = 0; i < triplets.size(); i++ ) - { G4Transform3D Ta( *(triplets[i].GetRotation()), triplets[i].GetTranslation() ); if ( triplets[i].IsReflection() ) { Ta = Ta * G4ReflectZ3D(); } @@ -165,30 +177,36 @@ void G4AssemblyVolume::MakeImprint( G4AssemblyVolume* pAssembly, // Register the physical volume created by us so we can delete it later // fPVStore.push_back( pvPlaced.first ); - if ( pvPlaced.second ) { fPVStore.push_back( pvPlaced.second ); } + info.g4VolumeImprints[vol].push_back(make_pair(new_chain,pvPlaced.first)); +#if 0 + cout << " Assembly:Parent:" << parent->GetName() << " " << node->GetName() + << " " << (void*)node << " G4:" << pvName.str() << " Daughter:" + << DetectorTools::placementPath(new_chain) << endl; + cout << endl; +#endif + + if ( pvPlaced.second ) { + G4Exception("G4AssemblyVolume::MakeImprint(..)", "GeomVol0003", FatalException, + "Fancy construct popping new mother from the stack!"); + //fPVStore.push_back( pvPlaced.second ); + } } - else if ( triplets[i].GetAssembly() ) - { + else if ( triplets[i].GetAssembly() ) { // Place volumes in this assembly with composed transformation - // - MakeImprint( triplets[i].GetAssembly(), pMotherLV, - Tfinal, i*100+copyNumBase, surfCheck ); + imprint(info, parent, new_chain, (Geant4AssemblyVolume*)triplets[i].GetAssembly(), pMotherLV, Tfinal, i*100+copyNumBase, surfCheck ); } - else - { + else { --level; G4Exception("G4AssemblyVolume::MakeImprint(..)", "GeomVol0003", FatalException, "Triplet has no volume and no assembly"); - } + } } - cout << "Imprinted assembly level:" << level << " in mother:" << pMotherLV->GetName() << endl; + //cout << "Imprinted assembly level:" << level << " in mother:" << pMotherLV->GetName() << endl; --level; } -#endif namespace { - static TGeoNode* s_topPtr; static string indent = ""; static Double_t s_identity_rot[] = { 1., 0., 0., 0., 1., 0., 0., 0., 1. }; struct MyTransform3D : public G4Transform3D { @@ -448,8 +466,7 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume) const { Geant4GeometryInfo& info = data(); VolumeMap::const_iterator volIt = info.g4Volumes.find(volume); - AssemblyMap::const_iterator assIt = info.g4Assemblies.find(volume); - if (volIt == info.g4Volumes.end() && assIt == info.g4Assemblies.end() ) { + if (volIt == info.g4Volumes.end() ) { const TGeoVolume* v = volume; Volume _v = Ref_t(v); string n = v->GetName(); @@ -498,8 +515,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume s->IsA()->GetName(), v->IsA()->GetName(), yes_no(assembly), yes_no(det.isValid())); if (assembly) { - G4AssemblyVolume* ass = new G4AssemblyVolume(); - info.g4Assemblies[v] = ass; + //info.g4AssemblyVolumes[v] = new Geant4AssemblyVolume(); return 0; } medium = (G4Material*) handleMaterial(m->GetName(), m); @@ -552,31 +568,26 @@ void* Geant4Converter::collectVolume(const string& /* name */, const TGeoVolume* /// Dump volume placement in GDML format to output stream void* Geant4Converter::handleAssembly(const std::string& name, const TGeoNode* node) const { TGeoVolume* vol = node->GetVolume(); - bool assembly = vol->GetShape()->IsA() == TGeoShapeAssembly::Class() || vol->IsA() == TGeoVolumeAssembly::Class(); - if ( !assembly ) { + if ( vol->IsA() != TGeoVolumeAssembly::Class() ) { return 0; } Geant4GeometryInfo& info = data(); - G4AssemblyVolume* g4 = info.g4Assemblies[vol]; - if ( !node || !g4 ) { - printout(FATAL, "Geant4Converter", "+++ Invalid assembly pointer at %s : %d " - "G4AssemblyVolume: %16p, TGeoNode: %16p [%s]", - __FILE__, __LINE__, g4, node, name.c_str()); - } - if ( g4->TotalImprintedVolumes() == 0 ) { + Geant4AssemblyVolume* g4 = info.g4AssemblyVolumes[node]; + if ( !g4 ) { + g4 = new Geant4AssemblyVolume(); TGeoVolume* mot_vol = node->GetVolume(); for(Int_t i=0; i < vol->GetNdaughters(); ++i) { - TGeoNode* d = vol->GetNode(i); + TGeoNode* d = vol->GetNode(i); TGeoVolume* dau_vol = d->GetVolume(); TGeoMatrix* tr = d->GetMatrix(); MyTransform3D transform(tr->GetTranslation(),tr->IsRotation() ? tr->GetRotationMatrix() : s_identity_rot); if ( dau_vol->IsA() == TGeoVolumeAssembly::Class() ) { - AssemblyMap::iterator assIt = info.g4Assemblies.find(dau_vol); - if ( assIt == info.g4Assemblies.end() ) { + AssemblyMap::iterator assIt = info.g4AssemblyVolumes.find(d); + if ( assIt == info.g4AssemblyVolumes.end() ) { printout(FATAL, "Geant4Converter", "+++ Invalid child assembly at %s : %d parent: %s child:%s", - __FILE__, __LINE__, node->GetName(), d->GetName()); + __FILE__, __LINE__, name.c_str(), d->GetName()); } - g4->AddPlacedAssembly((*assIt).second,transform); + g4->placeAssembly(d,(*assIt).second,transform); printout(DEBUG, "Geant4Converter", "+++ Assembly: AddPlacedAssembly : dau:%s " "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", dau_vol->GetName(), mot_vol->GetName(), @@ -586,15 +597,16 @@ void* Geant4Converter::handleAssembly(const std::string& name, const TGeoNode* n VolumeMap::iterator volIt = info.g4Volumes.find(dau_vol); if ( volIt == info.g4Volumes.end() ) { printout(FATAL, "Geant4Converter", "+++ Invalid child volume at %s : %d parent: %s child:%s", - __FILE__, __LINE__, node->GetName(), d->GetName()); + __FILE__, __LINE__, name.c_str(), d->GetName()); } - g4->AddPlacedVolume((*volIt).second, transform); + g4->placeVolume(d,(*volIt).second, transform); printout(DEBUG, "Geant4Converter", "+++ Assembly: AddPlacedVolume : dau:%s " "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", dau_vol->GetName(), mot_vol->GetName(), transform.dx(), transform.dy(), transform.dz()); } } + info.g4AssemblyVolumes[node] = g4; } return g4; } @@ -618,33 +630,43 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) } else { int copy = node->GetNumber(); - bool daughter_is_assembly = vol->IsA() == TGeoVolumeAssembly::Class(); + bool node_is_assembly = vol->IsA() == TGeoVolumeAssembly::Class(); bool mother_is_assembly = mot_vol ? mot_vol->IsA() == TGeoVolumeAssembly::Class() : false; MyTransform3D transform(tr->GetTranslation(),tr->IsRotation() ? tr->GetRotationMatrix() : s_identity_rot); VolumeMap::const_iterator volIt = info.g4Volumes.find(mot_vol); - if ( daughter_is_assembly && volIt != info.g4Volumes.end() ) { - printout(DEBUG, "Geant4Converter", "+++ Assembly: makeImprint: dau:%s in mother %s " - "Tr:x=%8.3f y=%8.3f z=%8.3f", - node->GetName(), mot_vol->GetName(), - transform.dx(), transform.dy(), transform.dz()); - G4AssemblyVolume* ass = info.g4Assemblies[vol]; - ass->MakeImprint((*volIt).second, transform, copy, m_checkOverlaps); - info.g4Placements[node] = (G4VPhysicalVolume*)node; - return 0; - } - else if ( mother_is_assembly ) { // Mother is an assembly: + if ( mother_is_assembly ) { + // + // Mother is an assembly: + // Nothing to do here, because: + // -- placed volumes were already added before in "handleAssembly" + // -- imprint cannot be made, because this requires a logical volume as a mother + // printout(DEBUG, "Geant4Converter", "+++ Assembly: **** : dau:%s " "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", vol->GetName(), mot_vol->GetName(), transform.dx(), transform.dy(), transform.dz()); - info.g4Placements[node] = (G4VPhysicalVolume*)node; return 0; } + else if ( node_is_assembly ) { + // + // Node is an assembly: + // Imprint the assembly. The mother MUST already be transformed. + // + printout(INFO, "Geant4Converter", "+++ Assembly: makeImprint: dau:%s in mother %s " + "Tr:x=%8.3f y=%8.3f z=%8.3f", + node->GetName(), mot_vol->GetName(), + transform.dx(), transform.dy(), transform.dz()); + Geant4AssemblyVolume* ass = (Geant4AssemblyVolume*)info.g4AssemblyVolumes[node]; + Geant4AssemblyVolume::Chain chain; + chain.push_back(node); + ass->imprint(info,node,chain,ass,(*volIt).second, transform, copy, m_checkOverlaps); + return 0; + } else if ( node != gGeoManager->GetTopNode() && volIt == info.g4Volumes.end() ) { throw logic_error("Geant4Converter: Invalid mother volume found!"); } - else if ( daughter_is_assembly ) { // g4mot is NULL ! + else if ( node_is_assembly ) { // g4mot is NULL ! throw logic_error("Geant4Converter: Invalid mother - daughter relationship in assembly! ["+name+"]"); } G4LogicalVolume* g4vol = info.g4Volumes[vol]; @@ -929,7 +951,6 @@ Geant4Converter& Geant4Converter::create(DetElement top) { Geant4GeometryInfo& geo = this->init(); m_data->clear(); collect(top, geo); - s_topPtr = top.placement().ptr(); m_checkOverlaps = false; // We do not have to handle defines etc. @@ -963,6 +984,8 @@ Geant4Converter& Geant4Converter::create(DetElement top) { //handleMap(this, geo.sensitives, &Geant4Converter::printSensitive); //handleRMap(this, *m_data, &Geant4Converter::printPlacement); + + geo.setWorld(top.placement().ptr()); geo.valid = true; return *this; } diff --git a/DDG4/src/Geant4DetectorConstruction.cpp b/DDG4/src/Geant4DetectorConstruction.cpp index 2ffb9f86b6ecd01bc317f21131b2d419a7b50cb3..8be4b853e0bbce485310fbae157274c6466542d1 100644 --- a/DDG4/src/Geant4DetectorConstruction.cpp +++ b/DDG4/src/Geant4DetectorConstruction.cpp @@ -20,14 +20,12 @@ DD4hep::Simulation::Geant4DetectorConstruction::Geant4DetectorConstruction(Geome G4VPhysicalVolume* DD4hep::Simulation::Geant4DetectorConstruction::Construct() { typedef Simulation::Geant4Converter Geant4Converter; - TGeoNode* top = gGeoManager->GetTopNode(); Geant4Mapping& g4map = Geant4Mapping::instance(); DetElement world = m_lcdd.world(); Geant4Converter conv(m_lcdd); Geant4GeometryInfo* info = conv.create(world).detach(); g4map.attach(info); - Geant4VolumeManager mgr = g4map.volumeManager(); - m_world = mgr.placement(top); + m_world = info->world(); m_lcdd.apply("DD4hepVolumeManager", 0, 0); //Geant4HierarchyDump dmp(m_lcdd); //dmp.dump("",m_world); diff --git a/DDG4/src/Geant4GeometryInfo.cpp b/DDG4/src/Geant4GeometryInfo.cpp index 0029d01ea8de948464527bbe0a480402e021518d..17f4bea5c8dc43c0d7186399ebffc8fd024d2174 100644 --- a/DDG4/src/Geant4GeometryInfo.cpp +++ b/DDG4/src/Geant4GeometryInfo.cpp @@ -7,14 +7,53 @@ // //==================================================================== +// Framework include files +#include "G4VPhysicalVolume.hh" #include "DDG4/Geant4GeometryInfo.h" + +// C/C++ include files +#include <stdexcept> + +using namespace std; using namespace DD4hep::Simulation; + +string Geant4GeometryMaps::placementPath(const Geant4PlacementPath& path, bool reverse) { + string s; + if ( reverse ) { + for (Geant4PlacementPath::const_reverse_iterator pIt = path.rbegin(); pIt != path.rend(); ++pIt) { + s += "/"; s += (*pIt)->GetName(); + } + } + else { + for (Geant4PlacementPath::const_iterator pIt = path.begin(); pIt != path.end(); ++pIt) { + s += "/"; s += (*pIt)->GetName(); + } + } + return s; +} + /// Default constructor Geant4GeometryInfo::Geant4GeometryInfo() - : TNamed("Geant4GeometryInfo", "Geant4GeometryInfo"), valid(false) { + : TNamed("Geant4GeometryInfo", "Geant4GeometryInfo"), m_world(0), valid(false) { } /// Default destructor Geant4GeometryInfo::~Geant4GeometryInfo() { } + +/// The world placement +G4VPhysicalVolume* Geant4GeometryInfo::world() const { + if ( m_world ) return m_world; + throw runtime_error("Geant4GeometryInfo: Attempt to access invalid world placement"); +} + +/// Set the world placement +void Geant4GeometryInfo::setWorld(const TGeoNode* node) { + Geant4GeometryMaps::PlacementMap::const_iterator g4it = g4Placements.find(node); + G4VPhysicalVolume* g4 = (g4it == g4Placements.end()) ? 0 : (*g4it).second; + if (!g4) { + throw runtime_error("Geant4GeometryInfo: Attempt to SET invalid world placement"); + } + m_world = g4; +} diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index 9744ad2e0178566f0ef30c52cda0c8290756bb4d..7febc78dcec6eada4cd8094c7e258d15cc5349d3 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -385,28 +385,30 @@ Geant4PhysicsListActionSequence* Geant4Kernel::physicsList(bool create) { } /// Access to the Track Manager from the kernel object -Geant4MonteCarloTruth& Geant4Kernel::mcTruthMgr() { - if ( m_mcTruthMgr ) return *m_mcTruthMgr; +Geant4MonteCarloTruth* Geant4Kernel::mcTruthMgr(bool throw_exception) { + if ( m_mcTruthMgr ) return m_mcTruthMgr; // If not present, check if the action is registered. Geant4Action* a = globalAction("MonteCarloTruthHandler",false); if ( 0 != a ) { m_mcTruthMgr = dynamic_cast<Geant4MonteCarloTruth*>(a); - if ( m_mcTruthMgr ) return *m_mcTruthMgr; + if ( m_mcTruthMgr ) return m_mcTruthMgr; } + if ( !throw_exception ) return 0; // No action registered to handle monte carlo truth. This is fatal throw runtime_error(format("Geant4Kernel", "DDG4: No Geant4MonteCarloTruth defined. " "Geant4 monte carlo information cannot be saved!")); } /// Access to the MC record manager from the kernel object -Geant4MonteCarloRecordManager& Geant4Kernel::mcRecordMgr() { - if ( m_mcRecordMgr ) return *m_mcRecordMgr; +Geant4MonteCarloRecordManager* Geant4Kernel::mcRecordMgr(bool throw_exception) { + if ( m_mcRecordMgr ) return m_mcRecordMgr; // If not present, check if the action is registered. Geant4Action* a = globalAction("MonteCarloRecordManager",false); if ( 0 != a ) { m_mcRecordMgr = dynamic_cast<Geant4MonteCarloRecordManager*>(a); - if ( m_mcRecordMgr ) return *m_mcRecordMgr; + if ( m_mcRecordMgr ) return m_mcRecordMgr; } + if ( !throw_exception ) return 0; // No action registered to save tracks. This is fatal throw runtime_error(format("Geant4Kernel", "DDG4: No MonteCarloRecordManager defined. " "Geant4 tracks cannot be saved!")); diff --git a/DDG4/src/Geant4Mapping.cpp b/DDG4/src/Geant4Mapping.cpp index 183fb3bdc6e8bac8aba49383f3d8d5ac0a02f283..02aa98d96547dc175c9268bc2421a0c59d06073c 100644 --- a/DDG4/src/Geant4Mapping.cpp +++ b/DDG4/src/Geant4Mapping.cpp @@ -76,8 +76,8 @@ Geant4VolumeManager Geant4Mapping::volumeManager() const { /// Accessor to resolve geometry placements PlacedVolume Geant4Mapping::placement(const G4VPhysicalVolume* node) const { checkValidity(); - const PlacementMap& m = m_dataPtr->g4Placements; - for (PlacementMap::const_iterator i = m.begin(); i != m.end(); ++i) + const Geant4GeometryMaps::PlacementMap& m = m_dataPtr->g4Placements; + for (Geant4GeometryMaps::PlacementMap::const_iterator i = m.begin(); i != m.end(); ++i) if ((*i).second == node) return PlacedVolume((*i).first); return PlacedVolume(0); diff --git a/DDG4/src/Geant4SensDetAction.cpp b/DDG4/src/Geant4SensDetAction.cpp index 2e906889f4659a80d3911994cb39a0f4734f6318..9a98f9a317a33dbb4b63a047b2baa5de0c7530cd 100644 --- a/DDG4/src/Geant4SensDetAction.cpp +++ b/DDG4/src/Geant4SensDetAction.cpp @@ -172,12 +172,14 @@ void Geant4Sensitive::clear(G4HCofThisEvent* /* HCE */) { /// Mark the track to be kept for MC truth propagation during hit processing void Geant4Sensitive::mark(const G4Track* track) const { - mcTruthMgr().mark(track); + Geant4MonteCarloTruth* truth = mcTruthMgr(false); + if ( truth ) truth->mark(track,true); } /// Mark the track of this step to be kept for MC truth propagation during hit processing void Geant4Sensitive::mark(const G4Step* step) const { - mcTruthMgr().mark(step); + Geant4MonteCarloTruth* truth = mcTruthMgr(false); + if ( truth ) truth->mark(step); } /// Returns the volumeID of the sensitive volume corresponding to the step diff --git a/DDG4/src/Geant4SensitiveDetector.cpp b/DDG4/src/Geant4SensitiveDetector.cpp index 15160bcafe53dfd3c0f39a67c1be8c6a0070db2b..ec27d3b5b15581d987ca419ca46a1c1f3ab36730 100644 --- a/DDG4/src/Geant4SensitiveDetector.cpp +++ b/DDG4/src/Geant4SensitiveDetector.cpp @@ -158,7 +158,7 @@ void Geant4SensitiveDetector::dumpStep(G4Step* st, G4TouchableHistory* /* histor const G4VPhysicalVolume* pv = step.volume(step.post); - typedef Geant4Converter::PlacementMap Places; + typedef Geant4GeometryMaps::PlacementMap Places; const Places& places = cnv.data().g4Placements; for (Places::const_iterator i = places.begin(); i != places.end(); ++i) { diff --git a/DDG4/src/Geant4StepHandler.cpp b/DDG4/src/Geant4StepHandler.cpp index 3577cf293995747257e8c5fa012913f3373645f6..9dd4f61bd5de013629d28b6121447d21b50429a9 100644 --- a/DDG4/src/Geant4StepHandler.cpp +++ b/DDG4/src/Geant4StepHandler.cpp @@ -48,4 +48,3 @@ const char* Geant4StepHandler::preStepStatus() const { const char* Geant4StepHandler::postStepStatus() const { return stepStatus(post ? post->GetStepStatus() : fUndefined); } - diff --git a/DDG4/src/Geant4TouchableHandler.cpp b/DDG4/src/Geant4TouchableHandler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7a4f423a7c9ea1d0f89163844ed1d2f9f5aba5de --- /dev/null +++ b/DDG4/src/Geant4TouchableHandler.cpp @@ -0,0 +1,49 @@ +// $Id: Geant4StepHandler.cpp 888 2013-11-14 15:54:56Z markus.frank@cern.ch $ +//==================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------- +// +// Author : M.Frank +// +//==================================================================== + +// Framework include files +#include "DDG4/Geant4TouchableHandler.h" +#include "DDG4/Geant4GeometryInfo.h" + +#include "G4Step.hh" +#include "G4VTouchable.hh" + +// C/C++ include files +#include <stdexcept> + +using namespace DD4hep::Simulation; + +/// Default constructor. Takes the step's pre-touchable +Geant4TouchableHandler::Geant4TouchableHandler(const G4Step* step) { + touchable = step->GetPreStepPoint()->GetTouchable(); +} + +/// Helper: Generate placement path from touchable object +Geant4TouchableHandler::Geant4PlacementPath Geant4TouchableHandler::placementPath(bool exception) const { + Geant4PlacementPath path; + if ( touchable ) { + int i, n=touchable->GetHistoryDepth(); + path.reserve(n); + for (i=0; i < n; ++i) { + G4VPhysicalVolume* pv = touchable->GetVolume(i); + path.push_back(pv); + } + return path; + } + if ( exception ) { + throw std::runtime_error("Attempt to access invalid G4 touchable object."); + } + return path; +} + +/// Helper: Access the placement path of a Geant4 touchable object as a string +std::string Geant4TouchableHandler::path() const { + return Geant4GeometryMaps::placementPath(this->placementPath()); +} + diff --git a/DDG4/src/Geant4TrackPersistency.cpp b/DDG4/src/Geant4TrackPersistency.cpp index 086c7144cd8fa8faf9d31857fa7d018540202e67..e5adf02567bf51c8a603e93d2902b9817404ab43 100644 --- a/DDG4/src/Geant4TrackPersistency.cpp +++ b/DDG4/src/Geant4TrackPersistency.cpp @@ -530,7 +530,8 @@ void Geant4TrackPersistency::end(const G4Track* track) { } /// If required save Track record... if ( m_current.store ) { - mcRecordMgr().save(m_current); + Geant4MonteCarloRecordManager* mgr = mcRecordMgr(true); + mgr->save(m_current); } m_current.set(0,0); trackMgr()->SetUserTrackInformation(0); diff --git a/DDG4/src/Geant4TrackingAction.cpp b/DDG4/src/Geant4TrackingAction.cpp index 71004543326e683f73e6b257d2e5a3ac70765c96..54942ca39870412b401f12883b46ead3f528920d 100644 --- a/DDG4/src/Geant4TrackingAction.cpp +++ b/DDG4/src/Geant4TrackingAction.cpp @@ -90,7 +90,8 @@ void Geant4TrackingAction::end(const G4Track*) { /// Mark the track to be kept for MC truth propagation void Geant4TrackingAction::mark(const G4Track* track) const { - mcTruthMgr().mark(track); + Geant4MonteCarloTruth* truth = mcTruthMgr(false); + if ( truth ) truth->mark(track,true); } /// Get the valid Geant4 tarck information diff --git a/DDG4/src/Geant4VolumeManager.cpp b/DDG4/src/Geant4VolumeManager.cpp index 45ea049e5213a9d07c8a837d54c4c407cf509179..03911c43425aec16e21ec00d837209c491490ae3 100644 --- a/DDG4/src/Geant4VolumeManager.cpp +++ b/DDG4/src/Geant4VolumeManager.cpp @@ -11,7 +11,9 @@ #include "DD4hep/Printout.h" #include "DD4hep/Volumes.h" #include "DD4hep/Detector.h" +#include "DD4hep/DetectorTools.h" #include "DDG4/Geant4VolumeManager.h" +#include "DDG4/Geant4TouchableHandler.h" #include "DDG4/Geant4Mapping.h" // Geant4 include files @@ -23,12 +25,12 @@ #include <sstream> using namespace DD4hep::Simulation; +using namespace DD4hep::Simulation::Geant4GeometryMaps; using namespace DD4hep::Geometry; using namespace DD4hep; using namespace std; -typedef Geant4GeometryInfo::PathMap PathMap; -typedef Geant4GeometryInfo::PlacementMap PlacementMap; +#include "DDG4/Geant4AssemblyVolume.h" namespace { @@ -37,7 +39,7 @@ namespace { typedef DD4hep::Geometry::LCDD LCDD; typedef DD4hep::Geometry::Readout Readout; typedef DD4hep::Geometry::DetElement DetElement; - typedef map<VolumeID,Geant4Mapping::PlacementPath> Registries; + typedef map<VolumeID,Geant4PlacementPath> Registries; /// Reference to the LCDD instance LCDD& m_lcdd; /// Set of already added entries @@ -61,6 +63,7 @@ namespace { SensitiveDetector sd; PlacedVolume::VolIDs ids; m_entries.clear(); + chain.push_back(m_lcdd.world().placement().ptr()); scanPhysicalVolume(pv.ptr(), ids, sd, chain); continue; } @@ -98,60 +101,81 @@ namespace { } void add_entry(SensitiveDetector sd, const TGeoNode* /* n */, const PlacedVolume::VolIDs& ids, const Chain& nodes) { + Chain control; + const TGeoNode* node; + const TGeoVolume* vol; + Geant4PlacementPath path; Readout ro = sd.readout(); IDDescriptor iddesc = ro.idSpec(); VolumeID code = iddesc.encode(ids); Registries::const_iterator i = m_entries.find(code); + PrintLevel print_action = DEBUG; + PrintLevel print_chain = DEBUG; + PrintLevel print_res = DEBUG; + + printout(print_action,"Geant4VolumeManager","+++ Add path:%s vid:%016X", + DetectorTools::placementPath(nodes,true).c_str(),code); + if (i == m_entries.end()) { - Geant4Mapping::PlacementPath path; path.reserve(nodes.size()); - for (Chain::const_reverse_iterator i = nodes.rbegin(); i != nodes.rend(); ++i) { - const TGeoNode* node = *i; + for (Chain::const_reverse_iterator k = nodes.rbegin(), kend=nodes.rend(); k != kend; ++k) { + node = *(k); PlacementMap::const_iterator g4pit = m_geo.g4Placements.find(node); - if (g4pit != m_geo.g4Placements.end()) { + if (g4pit != m_geo.g4Placements.end()) { path.push_back((*g4pit).second); + printout(print_chain, "Geant4VolumeManager", "+++ Chain: Node OK: %s [%s]", + node->GetName(), (*g4pit).second->GetName().c_str()); + continue; } - } - if (m_geo.g4Paths.find(path) != m_geo.g4Paths.end()) { - stringstream log; - printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Geant4 path!!!! %s", - " [THIS SHOULD NEVER HAPPEN]"); - - for(Geant4Mapping::PlacementPath::const_reverse_iterator j=path.rbegin(); j!=path.rend(); ++j) { - log << "/" << (*j)->GetName(); + control.insert(control.begin(),node); + vol = node->GetVolume(); + VolumeImprintMap::const_iterator iVolImp = m_geo.g4VolumeImprints.find(vol); + if ( iVolImp != m_geo.g4VolumeImprints.end() ) { + const Imprints& imprints = (*iVolImp).second; + //size_t len = kend-k; + for(Imprints::const_iterator iImp=imprints.begin(); iImp != imprints.end(); ++iImp) { + const VolumeChain& c = (*iImp).first; + if ( c.size() <= control.size() && control == c ) { + path.push_back((*iImp).second); + printout(print_chain, "Geant4VolumeManager", "+++ Chain: Node OK: %s %s -> %s", + node->GetName(), DetectorTools::placementPath(c,false).c_str(), + (*iImp).second->GetName().c_str()); + control.clear(); + break; + } + } } - printout(ERROR, "Geant4VolumeManager", " Geant4 path has >= 2 instances: %s", log.str().c_str()); - log.str(""); - for (PlacedVolume::VolIDs::Base::const_iterator vit = ids.begin(); vit != ids.end(); ++vit) - log << (*vit).first << "=" << (*vit).second << "; "; - printout(ERROR, "Geant4VolumeManager", " Offend.VolIDs: %s", log.str().c_str()); - log.str(""); - for (Chain::const_iterator jc=nodes.begin(); jc!=nodes.end(); ++jc) - log << "/" << (*jc)->GetName(); - printout(ERROR, "Geant4VolumeManager", " TGeo path: %s", log.str().c_str()); } - m_geo.g4Paths[path] = code; - m_entries.insert(make_pair(code,path)); - } - else { - stringstream log; - printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Volume entry: %X %s", - code, " [THIS SHOULD NEVER HAPPEN]"); - - const Geant4Mapping::PlacementPath& path = (*i).second; - for(Geant4Mapping::PlacementPath::const_reverse_iterator j=path.rbegin(); j!=path.rend(); ++j) { - log << "/" << (*j)->GetName(); + if ( control.empty() ) { + printout(print_res, "Geant4VolumeManager", "+++ Volume IDs:%s", + DetectorTools::toString(ro.idSpec(),ids,code).c_str()); + path.erase(path.begin()+path.size()-1); + printout(print_res, "Geant4VolumeManager", "+++ Map %016X to Geant4 Path:%s", + (void*)code, placementPath(path).c_str()); + if (m_geo.g4Paths.find(path) == m_geo.g4Paths.end()) { + m_geo.g4Paths[path] = code; + m_entries.insert(make_pair(code,path)); + return; + } + printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Geant4 path!!!! %s %s", + " [THIS SHOULD NEVER HAPPEN]",placementPath(path).c_str()); + goto Err; } - printout(ERROR, "Geant4VolumeManager", " Geant4 path: %s", log.str().c_str()); - log.str(""); - for (PlacedVolume::VolIDs::Base::const_iterator vit = ids.begin(); vit != ids.end(); ++vit) - log << (*vit).first << "=" << (*vit).second << "; "; - printout(ERROR, "Geant4VolumeManager", " Offend.VolIDs: %s", log.str().c_str()); - log.str(""); - for (Chain::const_iterator jc=nodes.begin(); jc!=nodes.end(); ++jc) - log << "/" << (*jc)->GetName(); - printout(ERROR, "Geant4VolumeManager", " TGeo path: %s", log.str().c_str()); + printout(INFO, "Geant4VolumeManager", "Control block has still %d entries:%s", + int(control.size()),DetectorTools::placementPath(control,true).c_str()); + goto Err; } + printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Volume entry: %X %s", + code, " [THIS SHOULD NEVER HAPPEN]"); + + Err: + if ( i != m_entries.end() ) + printout(ERROR, "Geant4VolumeManager", " Geant4 path: %s",placementPath((*i).second).c_str()); + else if ( !path.empty() ) + printout(ERROR, "Geant4VolumeManager", " Geant4 path: %s",placementPath(path).c_str()); + printout(ERROR, "Geant4VolumeManager", " Offend.VolIDs: %s", + DetectorTools::toString(ids).c_str()); + throw runtime_error("Failed to populate Geant4 volume manager!"); } }; } @@ -168,18 +192,9 @@ Geant4VolumeManager::Geant4VolumeManager(LCDD& lcdd, Geant4GeometryInfo* info) } /// Helper: Generate placement path from touchable object -Geant4VolumeManager::PlacementPath Geant4VolumeManager::placementPath(const G4VTouchable* touchable, bool exception) const { - Geant4Mapping::PlacementPath path; - if (touchable) { - for (int i = 0, n = touchable->GetHistoryDepth(); i < n; ++i) { - G4VPhysicalVolume* pv = touchable->GetVolume(i); - path.push_back(pv); - } - } - else if (exception) { - throw runtime_error(format("Geant4VolumeManager", "Attempt to use invalid Geant4 touchable [Invalid-Touchable]")); - } - return path; +Geant4PlacementPath Geant4VolumeManager::placementPath(const G4VTouchable* touchable, bool exception) const { + Geant4TouchableHandler handler(touchable); + return handler.placementPath(exception); } /// Check the validity of the information before accessing it. @@ -197,50 +212,27 @@ bool Geant4VolumeManager::checkValidity() const { return m_isValid; } -/// Accessor to resolve G4 placements -G4VPhysicalVolume* Geant4VolumeManager::placement(const TGeoNode* node) const { - if (node && checkValidity()) { - const PlacementMap& m = ptr()->g4Placements; - PlacementMap::const_iterator i = m.find(node); - if (i != m.end()) - return (*i).second; - return 0; - } - throw runtime_error(format("Geant4VolumeManager", "Attempt to use invalid Geant4 volume manager [Invalid-Handle]")); -} - -/// Accessor to resolve geometry placements -PlacedVolume Geant4VolumeManager::placement(const G4VPhysicalVolume* node) const { - if (node && checkValidity()) { - const PlacementMap& m = ptr()->g4Placements; - for (PlacementMap::const_iterator i = m.begin(); i != m.end(); ++i) { - if ((*i).second == node) - return PlacedVolume((*i).first); - } - return PlacedVolume(0); - } - throw runtime_error(format("Geant4VolumeManager", "Attempt to lookup invalid TGeo placement [Null-Pointer]")); -} - /// Access CELLID by placement path VolumeID Geant4VolumeManager::volumeID(const PlacementPath& path) const { if (!path.empty() && checkValidity()) { - const PathMap& m = ptr()->g4Paths; - PathMap::const_iterator i = m.find(path); + const Geant4PathMap& m = ptr()->g4Paths; + Geant4PathMap::const_iterator i = m.find(path); if (i != m.end()) return (*i).second; if (!path[0]) return InvalidPath; else if (!path[0]->GetLogicalVolume()->GetSensitiveDetector()) return Insensitive; - return NonExisting; } + printout(INFO, "Geant4VolumeManager","+++ Bad volume Geant4 Path: %s", + Geant4GeometryMaps::placementPath(path).c_str()); return NonExisting; } /// Access CELLID by Geant4 touchable object VolumeID Geant4VolumeManager::volumeID(const G4VTouchable* touchable) const { - return volumeID(placementPath(touchable)); + Geant4TouchableHandler handler(touchable); + return volumeID(handler.placementPath()); } /// Accessfully decoded volume fields by placement path @@ -248,18 +240,24 @@ void Geant4VolumeManager::volumeDescriptor(const PlacementPath& path, VolIDDescr vol_desc.second.clear(); vol_desc.first = NonExisting; if (!path.empty() && checkValidity()) { - const PathMap& m = ptr()->g4Paths; - PathMap::const_iterator i = m.find(path); + const Geant4PathMap& m = ptr()->g4Paths; + Geant4PathMap::const_iterator i = m.find(path); if (i != m.end()) { VolumeID vid = (*i).second; G4LogicalVolume* lvol = path[0]->GetLogicalVolume(); if (lvol->GetSensitiveDetector()) { - PlacedVolume pv = placement(path[0]); - Geometry::SensitiveDetector sd = pv.volume().sensitiveDetector(); - Geometry::IDDescriptor dsc = sd.readout().idSpec(); - vol_desc.first = vid; - dsc.decodeFields(vid, vol_desc.second); - return; + const G4VPhysicalVolume* node = path[0]; + const PlacementMap& m = ptr()->g4Placements; + for (PlacementMap::const_iterator i = m.begin(); i != m.end(); ++i) { + if ((*i).second == node) { + PlacedVolume pv = (*i).first; + Geometry::SensitiveDetector sd = pv.volume().sensitiveDetector(); + Geometry::IDDescriptor dsc = sd.readout().idSpec(); + vol_desc.first = vid; + dsc.decodeFields(vid, vol_desc.second); + return; + } + } } vol_desc.first = Insensitive; return; diff --git a/doc/release.notes b/doc/release.notes index 37a979dc9e20a6fc35293995b77c0619200cd4d6..c8f82e4c5650b0ba8025b764bb3eac6d29e76ae0 100644 --- a/doc/release.notes +++ b/doc/release.notes @@ -2,6 +2,12 @@ DD4hep ---- Release Notes ================================= +2014/04/28 Markus Frank +------------------------ + - First attempt to understand fully the handling of recursive assemblies + from the 2014/04/25 was apparently with limited success. Now they should + work! + 2014/04/25 Markus Frank ------------------------ - Moved boost::spirit parsers to DDCore, since these parsers are also used diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..eeace3a3630c0e4cfca8c0e7326cc79bb14cf850 --- /dev/null +++ b/examples/ClientTests/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR) +#--------------------------- +set( PackageName ClientTests ) +#--------------------------- +project(${PackageName}) + +# project version +SET( ${PackageName}_VERSION_MAJOR 0 ) +SET( ${PackageName}_VERSION_MINOR 0 ) +SET( ${PackageName}_VERSION_PATCH 1 ) + +SET( ${PackageName}_VERSION "${${PackageName}_VERSION_MAJOR}.${${PackageName}_VERSION_MINOR}" ) +SET( ${PackageName}_SOVERSION "${${PackageName}_VERSION_MAJOR}.${${PackageName}_VERSION_MINOR}" ) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake ) +set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + +#------------- set the default installation directory to be the source directory +IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + SET( CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} CACHE PATH + "install prefix path - overwrite with -D CMAKE_INSTALL_PREFIX = ..." + FORCE ) + MESSAGE(STATUS "CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} - overwrite with -D CMAKE_INSTALL_PREFIX" ) +ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +find_package( DD4hep REQUIRED) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_ROOT}/cmake ) +include( DD4hep ) + +find_package( ROOT REQUIRED ) +set( ROOT_COMPONENT_LIBRARIES Geom Reflex) +#------------------------------------------------------------- +include_directories( ${CMAKE_SOURCE_DIR}/include + include + ${DD4hep_INCLUDE_DIRS} + ${ROOT_INCLUDE_DIR} + ) + +file(GLOB sources src/*.cpp ) +include(DD4hep_XML_setup) + +add_library(${PackageName} SHARED ${sources}) + +target_link_libraries(${PackageName} ${DD4hep_LIBRARIES} ${ROOT_LIBRARIES} ) + +#---Rootmap generation-------------------------------------------------------------- +if(APPLE) + dd4hep_generate_rootmap_apple(${PackageName} ) +else() + dd4hep_generate_rootmap(${PackageName} ) +endif() +#---- configure run environment --------------- +configure_file( ${DD4hep_ROOT}/cmake/thisdd4hep_package.sh.in this${PackageName}.sh @ONLY) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/this${PackageName}.sh + DESTINATION bin + ) +#--- install target------------------------------------- +install(TARGETS ${PackageName} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ) +install(DIRECTORY compact + DESTINATION examples/${PackageName} + PATTERN ".svn" EXCLUDE ) + +# to do: add corresponding uninstall... +#------------------------------------------------------- diff --git a/examples/ClientTests/compact/Assemblies.xml b/examples/ClientTests/compact/Assemblies.xml new file mode 100644 index 0000000000000000000000000000000000000000..3d286f39f3a065c7c3bca26efcb16dfec2d7d049 --- /dev/null +++ b/examples/ClientTests/compact/Assemblies.xml @@ -0,0 +1,90 @@ +<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + + <info name="Assemblies_v01" + title="Assembly Detector Toy model" + author="M.Frank" + url="http://ilcsoft.desy.de" + status="development" + version="$Id: ILDEx.xml 676 2013-08-06 11:12:53Z gaede $"> + <comment>The compact format for the ILD Detector - toy model </comment> + </info> + + <includes> + <gdmlFile ref="elements.xml"/> + <gdmlFile ref="materials.xml"/> + </includes> + + <define> + <constant name="world_side" value="10*m"/> + <constant name="world_x" value="world_side/2"/> + <constant name="world_y" value="world_side/2"/> + <constant name="world_z" value="world_side/2"/> + <constant name="CrossingAngle" value="0.014*rad"/> + + <constant name="VXD_inner_radius" value="15*mm"/> + <constant name="VXD_outer_radius" value="80*mm"/> + <constant name="VXD_zhalf" value="130*mm"/> + <constant name="TPC_zhalf" value="2500*mm"/> + <constant name="Hcal_outer_radius" value="3395.46*mm"/> + <constant name="SolenoidCoilOuterZ" value="TPC_zhalf + 0.3*m"/> + <constant name="SolenoidalFieldRadius" value="Hcal_outer_radius + 10.0*mm"/> + </define> + + <limits> + <limitset name="Tracker_limits"> + <limit name="step_length_max" particles="*" value="5.0" unit="mm" /> + </limitset> + </limits> + + <display> + <vis name="VXDVis" alpha="1.0" r="0.9" g=".1" b=".1" showDaughters="true" visible="true"/> + <vis name="VXDLayerVis" alpha="1.0" r="0" g="1" b="0" showDaughters="true" visible="true"/> + <vis name="VXDSupportVis" alpha="1" r="0" g="1" b="0" showDaughters="true" visible="true"/> + </display> + + <detectors> + <comment>Trackers</comment> + + <detector name="VXD" type="VXD_Assembly" vis="VXDVis" id="1" limits="Tracker_limits" readout="VXDCollection" insideTrackingVolume="true"> + <tubs rmin="VXD_inner_radius" rmax="VXD_outer_radius" zhalf="VXD_zhalf"/> + <layer id="0" vis="VXDLayerVis" phi0="-1.570796327e+00"> + <support thickness=".1*mm" material="Carbon" vis="VXDSupportVis"/> + <ladder zhalf="65*mm" radius="1.595000000e+01*mm" width="1.100000000e+01*mm" offset="-1.874869853e+00*mm" thickness="0.05*mm" material="Silicon" number="10"/> + </layer> + <layer id="1" vis="VXDLayerVis" phi0="-1.570796327e+00"> + <support thickness=".1*mm" material="Carbon" vis="VXDSupportVis"/> + <ladder zhalf="65*mm" radius="18*mm" width="1.100000000e+01*mm" offset="-1.874869853e+00*mm" thickness="0.05*mm" material="Silicon" number="10"/> + </layer> + <layer id="2" vis="VXDLayerVis" phi0="-1.570796327e+00"> + <support thickness=".1*mm" material="Carbon" vis="VXDSupportVis"/> + <ladder zhalf="125*mm" radius="3.695000000e+01*mm" width="2.200000000e+01*mm" offset="-1.837940563e+00*mm" thickness="0.05*mm" material="Silicon" number="11"/> + </layer> + <layer id="3" vis="VXDLayerVis" phi0="-1.570796327e+00"> + <support thickness=".1*mm" material="Carbon" vis="VXDSupportVis"/> + <ladder zhalf="125*mm" radius="39*mm" width="2.200000000e+01*mm" offset="-1.837940563e+00*mm" thickness="0.05*mm" material="Silicon" number="11"/> + </layer> + <layer id="4" vis="VXDLayerVis" phi0="-1.570796327e+00"> + <support thickness=".1*mm" material="Carbon" vis="VXDSupportVis"/> + <ladder zhalf="125*mm" radius="5.795000000e+01*mm" width="2.200000000e+01*mm" offset="-2.636744400e+00*mm" thickness="0.05*mm" material="Silicon" number="17"/> + </layer> + <layer id="5" vis="VXDLayerVis" phi0="-1.570796327e+00"> + <support thickness=".1*mm" material="Carbon" vis="VXDSupportVis"/> + <ladder zhalf="125*mm" radius="60*mm" width="2.200000000e+01*mm" offset="-2.636744400e+00*mm" thickness="0.05*mm" material="Silicon" number="17"/> + </layer> + </detector> + </detectors> + + <readouts> + <readout name="VXDCollection"> + <id>system:5,layer:10,module:10,sensor:3,side:2</id> + </readout> + </readouts> + <fields> + <field type="solenoid" name="GlobalSolenoid" inner_field="3.5*tesla" + outer_field="-1.5*tesla" zmax="SolenoidCoilOuterZ" + inner_radius="SolenoidalFieldRadius" + outer_radius="world_side" /> + </fields> +</lccdd> diff --git a/examples/ClientTests/compact/FCC_HcalBarrel.xml b/examples/ClientTests/compact/FCC_HcalBarrel.xml new file mode 100644 index 0000000000000000000000000000000000000000..7c0a430ab5b9746e1ab98b18a8d4960cb61e960f --- /dev/null +++ b/examples/ClientTests/compact/FCC_HcalBarrel.xml @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + + <includes> + <gdmlFile ref="elements.xml"/> + <gdmlFile ref="materials.xml"/> + </includes> + + <define> + <constant name="world_size" value="30*m"/> + <constant name="world_x" value="world_size"/> + <constant name="world_y" value="world_size"/> + <constant name="world_z" value="world_size"/> + <constant name="HcalBarrel_rmin" value="300*cm"/> + <constant name="HcalBarrel_rmax" value="500*cm"/> + <constant name="HcalBarrel_zmax" value="600*cm"/> + </define> + + <display> + <vis name="Invisible" showDaughters="false" visible="false"/> + <vis name="InvisibleWithChildren" showDaughters="true" visible="false"/> + <vis name="VisibleBlue" r="0.0" g="0.0" b="1.0" showDaughters="false" visible="true"/> + <vis name="VisibleGreen" alpha="1.0" r="0.0" g="1.0" b="0.0" drawingStyle="solid" lineStyle="solid" showDaughters="true" visible="true"/> + <vis name="HcalStrip" r="0.0" g="0.0" b="1.0" showDaughters="true" visible="false"/> + <vis name="HcalAbsorber" r="0.0" g="0.0" b="1.0" showDaughters="false" visible="true"/> + <vis name="HcalActive" r="0.86" g="0.86" b="0.86" showDaughters="false" visible="true"/> + </display> + + <limits> + <limitset name="cal_limits"> + <limit name="step_length_max" particles="*" value="5.0" unit="mm" /> + </limitset> + </limits> + + <detectors> + <detector id="1" name="HcalBarrel" type="FCC_HcalBarrel" readout="HcalBarrelHits" vis="InvisibleWithChildren"> + <comment>A barrel hadronic calorimeter inspired on the ATLAS Tile hadronic calorimeter</comment> + <dimensions rmin="HcalBarrel_rmin" rmax="HcalBarrel_rmax" z="HcalBarrel_zmax" phiBins="64" /> + <layer dr="10.00*cm" dz="3.00*cm" vis="HcalStrip"> + <slice material="Steel235" dz="1.00*cm" vis="HcalAbsorber"/> + <slice material="Polystyrene" dz="0.50*cm" sensitive="yes" limits="cal_limits" vis="HcalActive"/> + <slice material="Steel235" dz="1.00*cm" vis="HcalAbsorber"/> + <slice material="Steel235" dz="0.50*cm" vis="HcalAbsorber"/> + </layer> + <layer dr="10.00*cm" dz="3.00*cm" vis="HcalStrip"> + <slice material="Steel235" dz="1.00*cm" vis="HcalAbsorber"/> + <slice material="Steel235" dz="0.50*cm" vis="HcalAbsorber"/> + <slice material="Steel235" dz="1.00*cm" vis="HcalAbsorber"/> + <slice material="Polystyrene" dz="0.50*cm" sensitive="yes" limits="cal_limits" vis="HcalActive"/> + </layer> + </detector> + </detectors> + + <readouts> + <readout name="HcalBarrelHits"> + <segmentation type="CartesianGridXY" grid_size_x="3.0*cm" grid_size_y="3.0*cm" /> + <id>system:8,barrel:3,module:6,layer:8,slice:5,x:32:-16,y:-16</id> + </readout> + </readouts> + + <fields> + <field name="GlobalSolenoid" type="solenoid" + inner_field="5.0*tesla" + outer_field="-1.5*tesla" + zmax="2*m" + outer_radius="3*m"> + </field> + </fields> + +</lccdd> diff --git a/examples/ClientTests/compact/Geant4Assemblies.py b/examples/ClientTests/compact/Geant4Assemblies.py new file mode 100644 index 0000000000000000000000000000000000000000..7cb31c6b38116afc3c8681bd5b9dc794332f34bc --- /dev/null +++ b/examples/ClientTests/compact/Geant4Assemblies.py @@ -0,0 +1,112 @@ +# +# +import os, DDG4 +from SystemOfUnits import * +# +# +""" + + DD4hep example setup using the python configuration + + @author M.Frank + @version 1.0 + +""" +def run(): + install_dir = os.environ['DD4hepINSTALL'] + example_dir = install_dir+'/examples/DDG4/examples'; + kernel = DDG4.Kernel() + kernel.UI = "UI" + kernel.loadGeometry("file:"+install_dir+"/examples/ClientTests/compact/Assemblies.xml") + kernel.loadXML("file:"+example_dir+"/DDG4_field.xml") + + lcdd = kernel.lcdd() + print '+++ List of sensitive detectors:' + for i in lcdd.detectors(): + o = DDG4.DetElement(i.second) + sd = lcdd.sensitiveDetector(o.name()) + if sd.isValid(): + print '+++ %-32s type:%s'%(o.name(), sd.type(), ) + + # Configure UI + ui = DDG4.Action(kernel,"Geant4UIManager/UI") + ui.HaveVIS = True + ui.HaveUI = True + ui.SessionType = 'csh' + kernel.registerGlobalAction(ui) + + + # Configure Run actions + run1 = DDG4.RunAction(kernel,'Geant4TestRunAction/RunInit') + run1.Property_int = 12345 + run1.Property_double = -5e15*keV + run1.Property_string = 'Startrun: Hello_2' + print run1.Property_string, run1.Property_double, run1.Property_int + run1.enableUI() + kernel.registerGlobalAction(run1) + kernel.runAction().add(run1) + + evt1 = DDG4.EventAction(kernel,'Geant4TestEventAction/UserEvent_1') + evt1.Property_int=01234 + evt1.Property_double=1e11 + evt1.Property_string='Hello_1' + evt1.enableUI() + + kernel.eventAction().add(evt1) + + # Configure I/O + evt_root = DDG4.EventAction(kernel,'Geant4Output2ROOT/RootOutput') + evt_root.Control = True + evt_root.Output = "simple.root" + evt_root.enableUI() + kernel.eventAction().add(evt_root) + + # Setup particle gun + gun = DDG4.GeneratorAction(kernel,"Geant4ParticleGun/Gun") + gun.energy = 0.5*GeV + gun.particle = 'e-' + gun.multiplicity = 1 + gun.position = (0.15*mm,0.12*mm,0.1*cm) + gun.enableUI() + kernel.generatorAction().add(gun) + + # Setup global filters fur use in sensntive detectors + f1 = DDG4.Filter(kernel,'GeantinoRejectFilter/GeantinoRejector') + f4 = DDG4.Filter(kernel,'EnergyDepositMinimumCut') + f4.Cut = 0.1*MeV + f4.enableUI() + kernel.registerGlobalFilter(f1) + kernel.registerGlobalFilter(f4) + + # First the tracking detectors + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/VXD') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleTrackerAction/VXDHandler','VXD') + seq.add(act) + seq.add(f1) + seq.add(f4) + act.add(f1) + + # Now build the physics list: + phys = kernel.physicsList() + phys.extends = 'FTFP_BERT' + #phys.transportation = True + phys.decays = True + phys.enableUI() + + ph = DDG4.PhysicsList(kernel,'Geant4PhysicsList/Myphysics') + ph.addParticleConstructor('G4BosonConstructor') + ph.addParticleConstructor('G4LeptonConstructor') + ph.addParticleProcess('e[+-]','G4eMultipleScattering',-1,1,1) + ph.addPhysicsConstructor('G4OpticalPhysics') + ph.enableUI() + phys.add(ph) + + phys.dump() + + kernel.configure() + kernel.initialize() + kernel.run() + kernel.terminate() + +if __name__ == "__main__": + run() diff --git a/examples/ClientTests/compact/elements.xml b/examples/ClientTests/compact/elements.xml new file mode 100644 index 0000000000000000000000000000000000000000..e714c3a5cd544e748dd2941967cff515c0b77efc --- /dev/null +++ b/examples/ClientTests/compact/elements.xml @@ -0,0 +1,884 @@ +<materials> + <element Z="89" formula="Ac" name="Ac" > + <atom type="A" unit="g/mol" value="227.028" /> + </element> + <material formula="Ac" name="Actinium" state="solid" > + <RL type="X0" unit="cm" value="0.601558" /> + <NIL type="lambda" unit="cm" value="21.2048" /> + <D type="density" unit="g/cm3" value="10.07" /> + <composite n="1" ref="Ac" /> + </material> + <element Z="47" formula="Ag" name="Ag" > + <atom type="A" unit="g/mol" value="107.868" /> + </element> + <material formula="Ag" name="Silver" state="solid" > + <RL type="X0" unit="cm" value="0.854292" /> + <NIL type="lambda" unit="cm" value="15.8546" /> + <D type="density" unit="g/cm3" value="10.5" /> + <composite n="1" ref="Ag" /> + </material> + <element Z="13" formula="Al" name="Al" > + <atom type="A" unit="g/mol" value="26.9815" /> + </element> + <material formula="Al" name="Aluminum" state="solid" > + <RL type="X0" unit="cm" value="8.89632" /> + <NIL type="lambda" unit="cm" value="38.8766" /> + <D type="density" unit="g/cm3" value="2.699" /> + <composite n="1" ref="Al" /> + </material> + <element Z="95" formula="Am" name="Am" > + <atom type="A" unit="g/mol" value="243.061" /> + </element> + <material formula="Am" name="Americium" state="solid" > + <RL type="X0" unit="cm" value="0.42431" /> + <NIL type="lambda" unit="cm" value="15.9812" /> + <D type="density" unit="g/cm3" value="13.67" /> + <composite n="1" ref="Am" /> + </material> + <element Z="18" formula="Ar" name="Ar" > + <atom type="A" unit="g/mol" value="39.9477" /> + </element> + <material formula="Ar" name="Argon" state="gas" > + <RL type="X0" unit="cm" value="11762.1" /> + <NIL type="lambda" unit="cm" value="71926" /> + <D type="density" unit="g/cm3" value="0.00166201" /> + <composite n="1" ref="Ar" /> + </material> + <element Z="33" formula="As" name="As" > + <atom type="A" unit="g/mol" value="74.9216" /> + </element> + <material formula="As" name="Arsenic" state="solid" > + <RL type="X0" unit="cm" value="2.0838" /> + <NIL type="lambda" unit="cm" value="25.7324" /> + <D type="density" unit="g/cm3" value="5.73" /> + <composite n="1" ref="As" /> + </material> + <element Z="85" formula="At" name="At" > + <atom type="A" unit="g/mol" value="209.987" /> + </element> + <material formula="At" name="Astatine" state="solid" > + <RL type="X0" unit="cm" value="0.650799" /> + <NIL type="lambda" unit="cm" value="22.3202" /> + <D type="density" unit="g/cm3" value="9.32" /> + <composite n="1" ref="At" /> + </material> + <element Z="79" formula="Au" name="Au" > + <atom type="A" unit="g/mol" value="196.967" /> + </element> + <material formula="Au" name="Gold" state="solid" > + <RL type="X0" unit="cm" value="0.334436" /> + <NIL type="lambda" unit="cm" value="10.5393" /> + <D type="density" unit="g/cm3" value="19.32" /> + <composite n="1" ref="Au" /> + </material> + <element Z="5" formula="B" name="B" > + <atom type="A" unit="g/mol" value="10.811" /> + </element> + <material formula="B" name="Boron" state="solid" > + <RL type="X0" unit="cm" value="22.2307" /> + <NIL type="lambda" unit="cm" value="32.2793" /> + <D type="density" unit="g/cm3" value="2.37" /> + <composite n="1" ref="B" /> + </material> + <element Z="56" formula="Ba" name="Ba" > + <atom type="A" unit="g/mol" value="137.327" /> + </element> + <material formula="Ba" name="Barium" state="solid" > + <RL type="X0" unit="cm" value="2.37332" /> + <NIL type="lambda" unit="cm" value="51.6743" /> + <D type="density" unit="g/cm3" value="3.5" /> + <composite n="1" ref="Ba" /> + </material> + <element Z="4" formula="Be" name="Be" > + <atom type="A" unit="g/mol" value="9.01218" /> + </element> + <material formula="Be" name="Beryllium" state="solid" > + <RL type="X0" unit="cm" value="35.276" /> + <NIL type="lambda" unit="cm" value="39.4488" /> + <D type="density" unit="g/cm3" value="1.848" /> + <composite n="1" ref="Be" /> + </material> + <element Z="83" formula="Bi" name="Bi" > + <atom type="A" unit="g/mol" value="208.98" /> + </element> + <material formula="Bi" name="Bismuth" state="solid" > + <RL type="X0" unit="cm" value="0.645388" /> + <NIL type="lambda" unit="cm" value="21.3078" /> + <D type="density" unit="g/cm3" value="9.747" /> + <composite n="1" ref="Bi" /> + </material> + <element Z="97" formula="Bk" name="Bk" > + <atom type="A" unit="g/mol" value="247.07" /> + </element> + <material formula="Bk" name="Berkelium" state="solid" > + <RL type="X0" unit="cm" value="0.406479" /> + <NIL type="lambda" unit="cm" value="15.6902" /> + <D type="density" unit="g/cm3" value="14" /> + <composite n="1" ref="Bk" /> + </material> + <element Z="35" formula="Br" name="Br" > + <atom type="A" unit="g/mol" value="79.9035" /> + </element> + <material formula="Br" name="Bromine" state="gas" > + <RL type="X0" unit="cm" value="1615.12" /> + <NIL type="lambda" unit="cm" value="21299" /> + <D type="density" unit="g/cm3" value="0.0070721" /> + <composite n="1" ref="Br" /> + </material> + <element Z="6" formula="C" name="C" > + <atom type="A" unit="g/mol" value="12.0107" /> + </element> + <material formula="C" name="Carbon" state="solid" > + <RL type="X0" unit="cm" value="21.3485" /> + <NIL type="lambda" unit="cm" value="40.1008" /> + <D type="density" unit="g/cm3" value="2" /> + <composite n="1" ref="C" /> + </material> + <element Z="20" formula="Ca" name="Ca" > + <atom type="A" unit="g/mol" value="40.078" /> + </element> + <material formula="Ca" name="Calcium" state="solid" > + <RL type="X0" unit="cm" value="10.4151" /> + <NIL type="lambda" unit="cm" value="77.3754" /> + <D type="density" unit="g/cm3" value="1.55" /> + <composite n="1" ref="Ca" /> + </material> + <element Z="48" formula="Cd" name="Cd" > + <atom type="A" unit="g/mol" value="112.411" /> + </element> + <material formula="Cd" name="Cadmium" state="solid" > + <RL type="X0" unit="cm" value="1.03994" /> + <NIL type="lambda" unit="cm" value="19.46" /> + <D type="density" unit="g/cm3" value="8.65" /> + <composite n="1" ref="Cd" /> + </material> + <element Z="58" formula="Ce" name="Ce" > + <atom type="A" unit="g/mol" value="140.115" /> + </element> + <material formula="Ce" name="Cerium" state="solid" > + <RL type="X0" unit="cm" value="1.19506" /> + <NIL type="lambda" unit="cm" value="27.3227" /> + <D type="density" unit="g/cm3" value="6.657" /> + <composite n="1" ref="Ce" /> + </material> + <element Z="98" formula="Cf" name="Cf" > + <atom type="A" unit="g/mol" value="251.08" /> + </element> + <material formula="Cf" name="Californium" state="solid" > + <RL type="X0" unit="cm" value="0.568328" /> + <NIL type="lambda" unit="cm" value="22.085" /> + <D type="density" unit="g/cm3" value="10" /> + <composite n="1" ref="Cf" /> + </material> + <element Z="17" formula="Cl" name="Cl" > + <atom type="A" unit="g/mol" value="35.4526" /> + </element> + <material formula="Cl" name="Chlorine" state="gas" > + <RL type="X0" unit="cm" value="6437.34" /> + <NIL type="lambda" unit="cm" value="38723.9" /> + <D type="density" unit="g/cm3" value="0.00299473" /> + <composite n="1" ref="Cl" /> + </material> + <element Z="96" formula="Cm" name="Cm" > + <atom type="A" unit="g/mol" value="247.07" /> + </element> + <material formula="Cm" name="Curium" state="solid" > + <RL type="X0" unit="cm" value="0.428706" /> + <NIL type="lambda" unit="cm" value="16.2593" /> + <D type="density" unit="g/cm3" value="13.51" /> + <composite n="1" ref="Cm" /> + </material> + <element Z="27" formula="Co" name="Co" > + <atom type="A" unit="g/mol" value="58.9332" /> + </element> + <material formula="Co" name="Cobalt" state="solid" > + <RL type="X0" unit="cm" value="1.53005" /> + <NIL type="lambda" unit="cm" value="15.2922" /> + <D type="density" unit="g/cm3" value="8.9" /> + <composite n="1" ref="Co" /> + </material> + <element Z="24" formula="Cr" name="Cr" > + <atom type="A" unit="g/mol" value="51.9961" /> + </element> + <material formula="Cr" name="Chromium" state="solid" > + <RL type="X0" unit="cm" value="2.0814" /> + <NIL type="lambda" unit="cm" value="18.1933" /> + <D type="density" unit="g/cm3" value="7.18" /> + <composite n="1" ref="Cr" /> + </material> + <element Z="55" formula="Cs" name="Cs" > + <atom type="A" unit="g/mol" value="132.905" /> + </element> + <material formula="Cs" name="Cesium" state="solid" > + <RL type="X0" unit="cm" value="4.4342" /> + <NIL type="lambda" unit="cm" value="95.317" /> + <D type="density" unit="g/cm3" value="1.873" /> + <composite n="1" ref="Cs" /> + </material> + <element Z="29" formula="Cu" name="Cu" > + <atom type="A" unit="g/mol" value="63.5456" /> + </element> + <material formula="Cu" name="Copper" state="solid" > + <RL type="X0" unit="cm" value="1.43558" /> + <NIL type="lambda" unit="cm" value="15.5141" /> + <D type="density" unit="g/cm3" value="8.96" /> + <composite n="1" ref="Cu" /> + </material> + <element Z="66" formula="Dy" name="Dy" > + <atom type="A" unit="g/mol" value="162.497" /> + </element> + <material formula="Dy" name="Dysprosium" state="solid" > + <RL type="X0" unit="cm" value="0.85614" /> + <NIL type="lambda" unit="cm" value="22.2923" /> + <D type="density" unit="g/cm3" value="8.55" /> + <composite n="1" ref="Dy" /> + </material> + <element Z="68" formula="Er" name="Er" > + <atom type="A" unit="g/mol" value="167.256" /> + </element> + <material formula="Er" name="Erbium" state="solid" > + <RL type="X0" unit="cm" value="0.788094" /> + <NIL type="lambda" unit="cm" value="21.2923" /> + <D type="density" unit="g/cm3" value="9.066" /> + <composite n="1" ref="Er" /> + </material> + <element Z="63" formula="Eu" name="Eu" > + <atom type="A" unit="g/mol" value="151.964" /> + </element> + <material formula="Eu" name="Europium" state="solid" > + <RL type="X0" unit="cm" value="1.41868" /> + <NIL type="lambda" unit="cm" value="35.6178" /> + <D type="density" unit="g/cm3" value="5.243" /> + <composite n="1" ref="Eu" /> + </material> + <element Z="9" formula="F" name="F" > + <atom type="A" unit="g/mol" value="18.9984" /> + </element> + <material formula="F" name="Fluorine" state="gas" > + <RL type="X0" unit="cm" value="20838.2" /> + <NIL type="lambda" unit="cm" value="59094.3" /> + <D type="density" unit="g/cm3" value="0.00158029" /> + <composite n="1" ref="F" /> + </material> + <element Z="26" formula="Fe" name="Fe" > + <atom type="A" unit="g/mol" value="55.8451" /> + </element> + <material formula="Fe" name="Iron" state="solid" > + <RL type="X0" unit="cm" value="1.75749" /> + <NIL type="lambda" unit="cm" value="16.959" /> + <D type="density" unit="g/cm3" value="7.874" /> + <composite n="1" ref="Fe" /> + </material> + <element Z="87" formula="Fr" name="Fr" > + <atom type="A" unit="g/mol" value="223.02" /> + </element> + <material formula="Fr" name="Francium" state="solid" > + <RL type="X0" unit="cm" value="6.18826" /> + <NIL type="lambda" unit="cm" value="212.263" /> + <D type="density" unit="g/cm3" value="1" /> + <composite n="1" ref="Fr" /> + </material> + <element Z="31" formula="Ga" name="Ga" > + <atom type="A" unit="g/mol" value="69.7231" /> + </element> + <material formula="Ga" name="Gallium" state="solid" > + <RL type="X0" unit="cm" value="2.1128" /> + <NIL type="lambda" unit="cm" value="24.3351" /> + <D type="density" unit="g/cm3" value="5.904" /> + <composite n="1" ref="Ga" /> + </material> + <element Z="64" formula="Gd" name="Gd" > + <atom type="A" unit="g/mol" value="157.252" /> + </element> + <material formula="Gd" name="Gadolinium" state="solid" > + <RL type="X0" unit="cm" value="0.947208" /> + <NIL type="lambda" unit="cm" value="23.9377" /> + <D type="density" unit="g/cm3" value="7.9004" /> + <composite n="1" ref="Gd" /> + </material> + <element Z="32" formula="Ge" name="Ge" > + <atom type="A" unit="g/mol" value="72.6128" /> + </element> + <material formula="Ge" name="Germanium" state="solid" > + <RL type="X0" unit="cm" value="2.3013" /> + <NIL type="lambda" unit="cm" value="27.3344" /> + <D type="density" unit="g/cm3" value="5.323" /> + <composite n="1" ref="Ge" /> + </material> + <element Z="1" formula="H" name="H" > + <atom type="A" unit="g/mol" value="1.00794" /> + </element> + <material formula="H" name="Hydrogen" state="gas" > + <RL type="X0" unit="cm" value="752776" /> + <NIL type="lambda" unit="cm" value="421239" /> + <D type="density" unit="g/cm3" value="8.3748e-05" /> + <composite n="1" ref="H" /> + </material> + <element Z="2" formula="He" name="He" > + <atom type="A" unit="g/mol" value="4.00264" /> + </element> + <material formula="He" name="Helium" state="gas" > + <RL type="X0" unit="cm" value="567113" /> + <NIL type="lambda" unit="cm" value="334266" /> + <D type="density" unit="g/cm3" value="0.000166322" /> + <composite n="1" ref="He" /> + </material> + <element Z="72" formula="Hf" name="Hf" > + <atom type="A" unit="g/mol" value="178.485" /> + </element> + <material formula="Hf" name="Hafnium" state="solid" > + <RL type="X0" unit="cm" value="0.517717" /> + <NIL type="lambda" unit="cm" value="14.7771" /> + <D type="density" unit="g/cm3" value="13.31" /> + <composite n="1" ref="Hf" /> + </material> + <element Z="80" formula="Hg" name="Hg" > + <atom type="A" unit="g/mol" value="200.599" /> + </element> + <material formula="Hg" name="Mercury" state="solid" > + <RL type="X0" unit="cm" value="0.475241" /> + <NIL type="lambda" unit="cm" value="15.105" /> + <D type="density" unit="g/cm3" value="13.546" /> + <composite n="1" ref="Hg" /> + </material> + <element Z="67" formula="Ho" name="Ho" > + <atom type="A" unit="g/mol" value="164.93" /> + </element> + <material formula="Ho" name="Holmium" state="solid" > + <RL type="X0" unit="cm" value="0.822447" /> + <NIL type="lambda" unit="cm" value="21.8177" /> + <D type="density" unit="g/cm3" value="8.795" /> + <composite n="1" ref="Ho" /> + </material> + <element Z="53" formula="I" name="I" > + <atom type="A" unit="g/mol" value="126.904" /> + </element> + <material formula="I" name="Iodine" state="solid" > + <RL type="X0" unit="cm" value="1.72016" /> + <NIL type="lambda" unit="cm" value="35.6583" /> + <D type="density" unit="g/cm3" value="4.93" /> + <composite n="1" ref="I" /> + </material> + <element Z="49" formula="In" name="In" > + <atom type="A" unit="g/mol" value="114.818" /> + </element> + <material formula="In" name="Indium" state="solid" > + <RL type="X0" unit="cm" value="1.21055" /> + <NIL type="lambda" unit="cm" value="23.2468" /> + <D type="density" unit="g/cm3" value="7.31" /> + <composite n="1" ref="In" /> + </material> + <element Z="77" formula="Ir" name="Ir" > + <atom type="A" unit="g/mol" value="192.216" /> + </element> + <material formula="Ir" name="Iridium" state="solid" > + <RL type="X0" unit="cm" value="0.294142" /> + <NIL type="lambda" unit="cm" value="9.01616" /> + <D type="density" unit="g/cm3" value="22.42" /> + <composite n="1" ref="Ir" /> + </material> + <element Z="19" formula="K" name="K" > + <atom type="A" unit="g/mol" value="39.0983" /> + </element> + <material formula="K" name="Potassium" state="solid" > + <RL type="X0" unit="cm" value="20.0871" /> + <NIL type="lambda" unit="cm" value="138.041" /> + <D type="density" unit="g/cm3" value="0.862" /> + <composite n="1" ref="K" /> + </material> + <element Z="36" formula="Kr" name="Kr" > + <atom type="A" unit="g/mol" value="83.7993" /> + </element> + <material formula="Kr" name="Krypton" state="gas" > + <RL type="X0" unit="cm" value="3269.44" /> + <NIL type="lambda" unit="cm" value="43962.9" /> + <D type="density" unit="g/cm3" value="0.00347832" /> + <composite n="1" ref="Kr" /> + </material> + <element Z="57" formula="La" name="La" > + <atom type="A" unit="g/mol" value="138.905" /> + </element> + <material formula="La" name="Lanthanum" state="solid" > + <RL type="X0" unit="cm" value="1.32238" /> + <NIL type="lambda" unit="cm" value="29.441" /> + <D type="density" unit="g/cm3" value="6.154" /> + <composite n="1" ref="La" /> + </material> + <element Z="3" formula="Li" name="Li" > + <atom type="A" unit="g/mol" value="6.94003" /> + </element> + <material formula="Li" name="Lithium" state="solid" > + <RL type="X0" unit="cm" value="154.997" /> + <NIL type="lambda" unit="cm" value="124.305" /> + <D type="density" unit="g/cm3" value="0.534" /> + <composite n="1" ref="Li" /> + </material> + <element Z="71" formula="Lu" name="Lu" > + <atom type="A" unit="g/mol" value="174.967" /> + </element> + <material formula="Lu" name="Lutetium" state="solid" > + <RL type="X0" unit="cm" value="0.703651" /> + <NIL type="lambda" unit="cm" value="19.8916" /> + <D type="density" unit="g/cm3" value="9.84" /> + <composite n="1" ref="Lu" /> + </material> + <element Z="12" formula="Mg" name="Mg" > + <atom type="A" unit="g/mol" value="24.305" /> + </element> + <material formula="Mg" name="Magnesium" state="solid" > + <RL type="X0" unit="cm" value="14.3859" /> + <NIL type="lambda" unit="cm" value="58.7589" /> + <D type="density" unit="g/cm3" value="1.74" /> + <composite n="1" ref="Mg" /> + </material> + <element Z="25" formula="Mn" name="Mn" > + <atom type="A" unit="g/mol" value="54.938" /> + </element> + <material formula="Mn" name="Manganese" state="solid" > + <RL type="X0" unit="cm" value="1.96772" /> + <NIL type="lambda" unit="cm" value="17.8701" /> + <D type="density" unit="g/cm3" value="7.44" /> + <composite n="1" ref="Mn" /> + </material> + <element Z="42" formula="Mo" name="Mo" > + <atom type="A" unit="g/mol" value="95.9313" /> + </element> + <material formula="Mo" name="Molybdenum" state="solid" > + <RL type="X0" unit="cm" value="0.959107" /> + <NIL type="lambda" unit="cm" value="15.6698" /> + <D type="density" unit="g/cm3" value="10.22" /> + <composite n="1" ref="Mo" /> + </material> + <element Z="7" formula="N" name="N" > + <atom type="A" unit="g/mol" value="14.0068" /> + </element> + <material formula="N" name="Nitrogen" state="gas" > + <RL type="X0" unit="cm" value="32602.2" /> + <NIL type="lambda" unit="cm" value="72430.3" /> + <D type="density" unit="g/cm3" value="0.0011652" /> + <composite n="1" ref="N" /> + </material> + <element Z="11" formula="Na" name="Na" > + <atom type="A" unit="g/mol" value="22.9898" /> + </element> + <material formula="Na" name="Sodium" state="solid" > + <RL type="X0" unit="cm" value="28.5646" /> + <NIL type="lambda" unit="cm" value="102.463" /> + <D type="density" unit="g/cm3" value="0.971" /> + <composite n="1" ref="Na" /> + </material> + <element Z="41" formula="Nb" name="Nb" > + <atom type="A" unit="g/mol" value="92.9064" /> + </element> + <material formula="Nb" name="Niobium" state="solid" > + <RL type="X0" unit="cm" value="1.15783" /> + <NIL type="lambda" unit="cm" value="18.4846" /> + <D type="density" unit="g/cm3" value="8.57" /> + <composite n="1" ref="Nb" /> + </material> + <element Z="60" formula="Nd" name="Nd" > + <atom type="A" unit="g/mol" value="144.236" /> + </element> + <material formula="Nd" name="Neodymium" state="solid" > + <RL type="X0" unit="cm" value="1.11667" /> + <NIL type="lambda" unit="cm" value="26.6308" /> + <D type="density" unit="g/cm3" value="6.9" /> + <composite n="1" ref="Nd" /> + </material> + <element Z="10" formula="Ne" name="Ne" > + <atom type="A" unit="g/mol" value="20.18" /> + </element> + <material formula="Ne" name="Neon" state="gas" > + <RL type="X0" unit="cm" value="34504.8" /> + <NIL type="lambda" unit="cm" value="114322" /> + <D type="density" unit="g/cm3" value="0.000838505" /> + <composite n="1" ref="Ne" /> + </material> + <element Z="28" formula="Ni" name="Ni" > + <atom type="A" unit="g/mol" value="58.6933" /> + </element> + <material formula="Ni" name="Nickel" state="solid" > + <RL type="X0" unit="cm" value="1.42422" /> + <NIL type="lambda" unit="cm" value="15.2265" /> + <D type="density" unit="g/cm3" value="8.902" /> + <composite n="1" ref="Ni" /> + </material> + <element Z="93" formula="Np" name="Np" > + <atom type="A" unit="g/mol" value="237.048" /> + </element> + <material formula="Np" name="Neptunium" state="solid" > + <RL type="X0" unit="cm" value="0.289676" /> + <NIL type="lambda" unit="cm" value="10.6983" /> + <D type="density" unit="g/cm3" value="20.25" /> + <composite n="1" ref="Np" /> + </material> + <element Z="8" formula="O" name="O" > + <atom type="A" unit="g/mol" value="15.9994" /> + </element> + <material formula="O" name="Oxygen" state="gas" > + <RL type="X0" unit="cm" value="25713.8" /> + <NIL type="lambda" unit="cm" value="66233.9" /> + <D type="density" unit="g/cm3" value="0.00133151" /> + <composite n="1" ref="O" /> + </material> + <element Z="76" formula="Os" name="Os" > + <atom type="A" unit="g/mol" value="190.225" /> + </element> + <material formula="Os" name="Osmium" state="solid" > + <RL type="X0" unit="cm" value="0.295861" /> + <NIL type="lambda" unit="cm" value="8.92553" /> + <D type="density" unit="g/cm3" value="22.57" /> + <composite n="1" ref="Os" /> + </material> + <element Z="15" formula="P" name="P" > + <atom type="A" unit="g/mol" value="30.9738" /> + </element> + <material formula="P" name="Phosphorus" state="solid" > + <RL type="X0" unit="cm" value="9.63879" /> + <NIL type="lambda" unit="cm" value="49.9343" /> + <D type="density" unit="g/cm3" value="2.2" /> + <composite n="1" ref="P" /> + </material> + <element Z="91" formula="Pa" name="Pa" > + <atom type="A" unit="g/mol" value="231.036" /> + </element> + <material formula="Pa" name="Protactinium" state="solid" > + <RL type="X0" unit="cm" value="0.38607" /> + <NIL type="lambda" unit="cm" value="13.9744" /> + <D type="density" unit="g/cm3" value="15.37" /> + <composite n="1" ref="Pa" /> + </material> + <element Z="82" formula="Pb" name="Pb" > + <atom type="A" unit="g/mol" value="207.217" /> + </element> + <material formula="Pb" name="Lead" state="solid" > + <RL type="X0" unit="cm" value="0.561253" /> + <NIL type="lambda" unit="cm" value="18.2607" /> + <D type="density" unit="g/cm3" value="11.35" /> + <composite n="1" ref="Pb" /> + </material> + <element Z="46" formula="Pd" name="Pd" > + <atom type="A" unit="g/mol" value="106.415" /> + </element> + <material formula="Pd" name="Palladium" state="solid" > + <RL type="X0" unit="cm" value="0.765717" /> + <NIL type="lambda" unit="cm" value="13.7482" /> + <D type="density" unit="g/cm3" value="12.02" /> + <composite n="1" ref="Pd" /> + </material> + <element Z="61" formula="Pm" name="Pm" > + <atom type="A" unit="g/mol" value="144.913" /> + </element> + <material formula="Pm" name="Promethium" state="solid" > + <RL type="X0" unit="cm" value="1.04085" /> + <NIL type="lambda" unit="cm" value="25.4523" /> + <D type="density" unit="g/cm3" value="7.22" /> + <composite n="1" ref="Pm" /> + </material> + <element Z="84" formula="Po" name="Po" > + <atom type="A" unit="g/mol" value="208.982" /> + </element> + <material formula="Po" name="Polonium" state="solid" > + <RL type="X0" unit="cm" value="0.661092" /> + <NIL type="lambda" unit="cm" value="22.2842" /> + <D type="density" unit="g/cm3" value="9.32" /> + <composite n="1" ref="Po" /> + </material> + <element Z="59" formula="Pr" name="Pr" > + <atom type="A" unit="g/mol" value="140.908" /> + </element> + <material formula="Pr" name="Praseodymium" state="solid" > + <RL type="X0" unit="cm" value="1.1562" /> + <NIL type="lambda" unit="cm" value="27.1312" /> + <D type="density" unit="g/cm3" value="6.71" /> + <composite n="1" ref="Pr" /> + </material> + <element Z="78" formula="Pt" name="Pt" > + <atom type="A" unit="g/mol" value="195.078" /> + </element> + <material formula="Pt" name="Platinum" state="solid" > + <RL type="X0" unit="cm" value="0.305053" /> + <NIL type="lambda" unit="cm" value="9.46584" /> + <D type="density" unit="g/cm3" value="21.45" /> + <composite n="1" ref="Pt" /> + </material> + <element Z="94" formula="Pu" name="Pu" > + <atom type="A" unit="g/mol" value="244.064" /> + </element> + <material formula="Pu" name="Plutonium" state="solid" > + <RL type="X0" unit="cm" value="0.298905" /> + <NIL type="lambda" unit="cm" value="11.0265" /> + <D type="density" unit="g/cm3" value="19.84" /> + <composite n="1" ref="Pu" /> + </material> + <element Z="88" formula="Ra" name="Ra" > + <atom type="A" unit="g/mol" value="226.025" /> + </element> + <material formula="Ra" name="Radium" state="solid" > + <RL type="X0" unit="cm" value="1.22987" /> + <NIL type="lambda" unit="cm" value="42.6431" /> + <D type="density" unit="g/cm3" value="5" /> + <composite n="1" ref="Ra" /> + </material> + <element Z="37" formula="Rb" name="Rb" > + <atom type="A" unit="g/mol" value="85.4677" /> + </element> + <material formula="Rb" name="Rubidium" state="solid" > + <RL type="X0" unit="cm" value="7.19774" /> + <NIL type="lambda" unit="cm" value="100.218" /> + <D type="density" unit="g/cm3" value="1.532" /> + <composite n="1" ref="Rb" /> + </material> + <element Z="75" formula="Re" name="Re" > + <atom type="A" unit="g/mol" value="186.207" /> + </element> + <material formula="Re" name="Rhenium" state="solid" > + <RL type="X0" unit="cm" value="0.318283" /> + <NIL type="lambda" unit="cm" value="9.5153" /> + <D type="density" unit="g/cm3" value="21.02" /> + <composite n="1" ref="Re" /> + </material> + <element Z="45" formula="Rh" name="Rh" > + <atom type="A" unit="g/mol" value="102.906" /> + </element> + <material formula="Rh" name="Rhodium" state="solid" > + <RL type="X0" unit="cm" value="0.746619" /> + <NIL type="lambda" unit="cm" value="13.2083" /> + <D type="density" unit="g/cm3" value="12.41" /> + <composite n="1" ref="Rh" /> + </material> + <element Z="86" formula="Rn" name="Rn" > + <atom type="A" unit="g/mol" value="222.018" /> + </element> + <material formula="Rn" name="Radon" state="gas" > + <RL type="X0" unit="cm" value="697.777" /> + <NIL type="lambda" unit="cm" value="23532" /> + <D type="density" unit="g/cm3" value="0.00900662" /> + <composite n="1" ref="Rn" /> + </material> + <element Z="44" formula="Ru" name="Ru" > + <atom type="A" unit="g/mol" value="101.065" /> + </element> + <material formula="Ru" name="Ruthenium" state="solid" > + <RL type="X0" unit="cm" value="0.764067" /> + <NIL type="lambda" unit="cm" value="13.1426" /> + <D type="density" unit="g/cm3" value="12.41" /> + <composite n="1" ref="Ru" /> + </material> + <element Z="16" formula="S" name="S" > + <atom type="A" unit="g/mol" value="32.0661" /> + </element> + <material formula="S" name="Sulfur" state="solid" > + <RL type="X0" unit="cm" value="9.74829" /> + <NIL type="lambda" unit="cm" value="55.6738" /> + <D type="density" unit="g/cm3" value="2" /> + <composite n="1" ref="S" /> + </material> + <element Z="51" formula="Sb" name="Sb" > + <atom type="A" unit="g/mol" value="121.76" /> + </element> + <material formula="Sb" name="Antimony" state="solid" > + <RL type="X0" unit="cm" value="1.30401" /> + <NIL type="lambda" unit="cm" value="25.8925" /> + <D type="density" unit="g/cm3" value="6.691" /> + <composite n="1" ref="Sb" /> + </material> + <element Z="21" formula="Sc" name="Sc" > + <atom type="A" unit="g/mol" value="44.9559" /> + </element> + <material formula="Sc" name="Scandium" state="solid" > + <RL type="X0" unit="cm" value="5.53545" /> + <NIL type="lambda" unit="cm" value="41.609" /> + <D type="density" unit="g/cm3" value="2.989" /> + <composite n="1" ref="Sc" /> + </material> + <element Z="34" formula="Se" name="Se" > + <atom type="A" unit="g/mol" value="78.9594" /> + </element> + <material formula="Se" name="Selenium" state="solid" > + <RL type="X0" unit="cm" value="2.64625" /> + <NIL type="lambda" unit="cm" value="33.356" /> + <D type="density" unit="g/cm3" value="4.5" /> + <composite n="1" ref="Se" /> + </material> + <element Z="14" formula="Si" name="Si" > + <atom type="A" unit="g/mol" value="28.0854" /> + </element> + <material formula="Si" name="Silicon" state="solid" > + <RL type="X0" unit="cm" value="9.36607" /> + <NIL type="lambda" unit="cm" value="45.7531" /> + <D type="density" unit="g/cm3" value="2.33" /> + <composite n="1" ref="Si" /> + </material> + <element Z="62" formula="Sm" name="Sm" > + <atom type="A" unit="g/mol" value="150.366" /> + </element> + <material formula="Sm" name="Samarium" state="solid" > + <RL type="X0" unit="cm" value="1.01524" /> + <NIL type="lambda" unit="cm" value="24.9892" /> + <D type="density" unit="g/cm3" value="7.46" /> + <composite n="1" ref="Sm" /> + </material> + <element Z="50" formula="Sn" name="Sn" > + <atom type="A" unit="g/mol" value="118.71" /> + </element> + <material formula="Sn" name="Tin" state="solid" > + <RL type="X0" unit="cm" value="1.20637" /> + <NIL type="lambda" unit="cm" value="23.4931" /> + <D type="density" unit="g/cm3" value="7.31" /> + <composite n="1" ref="Sn" /> + </material> + <element Z="38" formula="Sr" name="Sr" > + <atom type="A" unit="g/mol" value="87.6166" /> + </element> + <material formula="Sr" name="Strontium" state="solid" > + <RL type="X0" unit="cm" value="4.237" /> + <NIL type="lambda" unit="cm" value="61.0238" /> + <D type="density" unit="g/cm3" value="2.54" /> + <composite n="1" ref="Sr" /> + </material> + <element Z="73" formula="Ta" name="Ta" > + <atom type="A" unit="g/mol" value="180.948" /> + </element> + <material formula="Ta" name="Tantalum" state="solid" > + <RL type="X0" unit="cm" value="0.409392" /> + <NIL type="lambda" unit="cm" value="11.8846" /> + <D type="density" unit="g/cm3" value="16.654" /> + <composite n="1" ref="Ta" /> + </material> + <element Z="65" formula="Tb" name="Tb" > + <atom type="A" unit="g/mol" value="158.925" /> + </element> + <material formula="Tb" name="Terbium" state="solid" > + <RL type="X0" unit="cm" value="0.893977" /> + <NIL type="lambda" unit="cm" value="23.0311" /> + <D type="density" unit="g/cm3" value="8.229" /> + <composite n="1" ref="Tb" /> + </material> + <element Z="43" formula="Tc" name="Tc" > + <atom type="A" unit="g/mol" value="97.9072" /> + </element> + <material formula="Tc" name="Technetium" state="solid" > + <RL type="X0" unit="cm" value="0.833149" /> + <NIL type="lambda" unit="cm" value="14.0185" /> + <D type="density" unit="g/cm3" value="11.5" /> + <composite n="1" ref="Tc" /> + </material> + <element Z="52" formula="Te" name="Te" > + <atom type="A" unit="g/mol" value="127.603" /> + </element> + <material formula="Te" name="Tellurium" state="solid" > + <RL type="X0" unit="cm" value="1.41457" /> + <NIL type="lambda" unit="cm" value="28.1797" /> + <D type="density" unit="g/cm3" value="6.24" /> + <composite n="1" ref="Te" /> + </material> + <element Z="90" formula="Th" name="Th" > + <atom type="A" unit="g/mol" value="232.038" /> + </element> + <material formula="Th" name="Thorium" state="solid" > + <RL type="X0" unit="cm" value="0.51823" /> + <NIL type="lambda" unit="cm" value="18.353" /> + <D type="density" unit="g/cm3" value="11.72" /> + <composite n="1" ref="Th" /> + </material> + <element Z="22" formula="Ti" name="Ti" > + <atom type="A" unit="g/mol" value="47.8667" /> + </element> + <material formula="Ti" name="Titanium" state="solid" > + <RL type="X0" unit="cm" value="3.5602" /> + <NIL type="lambda" unit="cm" value="27.9395" /> + <D type="density" unit="g/cm3" value="4.54" /> + <composite n="1" ref="Ti" /> + </material> + <element Z="81" formula="Tl" name="Tl" > + <atom type="A" unit="g/mol" value="204.383" /> + </element> + <material formula="Tl" name="Thallium" state="solid" > + <RL type="X0" unit="cm" value="0.547665" /> + <NIL type="lambda" unit="cm" value="17.6129" /> + <D type="density" unit="g/cm3" value="11.72" /> + <composite n="1" ref="Tl" /> + </material> + <element Z="69" formula="Tm" name="Tm" > + <atom type="A" unit="g/mol" value="168.934" /> + </element> + <material formula="Tm" name="Thulium" state="solid" > + <RL type="X0" unit="cm" value="0.754428" /> + <NIL type="lambda" unit="cm" value="20.7522" /> + <D type="density" unit="g/cm3" value="9.321" /> + <composite n="1" ref="Tm" /> + </material> + <element Z="92" formula="U" name="U" > + <atom type="A" unit="g/mol" value="238.029" /> + </element> + <material formula="U" name="Uranium" state="solid" > + <RL type="X0" unit="cm" value="0.31663" /> + <NIL type="lambda" unit="cm" value="11.4473" /> + <D type="density" unit="g/cm3" value="18.95" /> + <composite n="1" ref="U" /> + </material> + <element Z="23" formula="V" name="V" > + <atom type="A" unit="g/mol" value="50.9415" /> + </element> + <material formula="V" name="Vanadium" state="solid" > + <RL type="X0" unit="cm" value="2.59285" /> + <NIL type="lambda" unit="cm" value="21.2187" /> + <D type="density" unit="g/cm3" value="6.11" /> + <composite n="1" ref="V" /> + </material> + <element Z="74" formula="W" name="W" > + <atom type="A" unit="g/mol" value="183.842" /> + </element> + <material formula="W" name="Tungsten" state="solid" > + <RL type="X0" unit="cm" value="0.350418" /> + <NIL type="lambda" unit="cm" value="10.3057" /> + <D type="density" unit="g/cm3" value="19.3" /> + <composite n="1" ref="W" /> + </material> + <element Z="54" formula="Xe" name="Xe" > + <atom type="A" unit="g/mol" value="131.292" /> + </element> + <material formula="Xe" name="Xenon" state="gas" > + <RL type="X0" unit="cm" value="1546.2" /> + <NIL type="lambda" unit="cm" value="32477.9" /> + <D type="density" unit="g/cm3" value="0.00548536" /> + <composite n="1" ref="Xe" /> + </material> + <element Z="39" formula="Y" name="Y" > + <atom type="A" unit="g/mol" value="88.9058" /> + </element> + <material formula="Y" name="Yttrium" state="solid" > + <RL type="X0" unit="cm" value="2.32943" /> + <NIL type="lambda" unit="cm" value="34.9297" /> + <D type="density" unit="g/cm3" value="4.469" /> + <composite n="1" ref="Y" /> + </material> + <element Z="70" formula="Yb" name="Yb" > + <atom type="A" unit="g/mol" value="173.038" /> + </element> + <material formula="Yb" name="Ytterbium" state="solid" > + <RL type="X0" unit="cm" value="1.04332" /> + <NIL type="lambda" unit="cm" value="28.9843" /> + <D type="density" unit="g/cm3" value="6.73" /> + <composite n="1" ref="Yb" /> + </material> + <element Z="30" formula="Zn" name="Zn" > + <atom type="A" unit="g/mol" value="65.3955" /> + </element> + <material formula="Zn" name="Zinc" state="solid" > + <RL type="X0" unit="cm" value="1.74286" /> + <NIL type="lambda" unit="cm" value="19.8488" /> + <D type="density" unit="g/cm3" value="7.133" /> + <composite n="1" ref="Zn" /> + </material> + <element Z="40" formula="Zr" name="Zr" > + <atom type="A" unit="g/mol" value="91.2236" /> + </element> + <material formula="Zr" name="Zirconium" state="solid" > + <RL type="X0" unit="cm" value="1.56707" /> + <NIL type="lambda" unit="cm" value="24.2568" /> + <D type="density" unit="g/cm3" value="6.506" /> + <composite n="1" ref="Zr" /> + </material> +</materials> \ No newline at end of file diff --git a/examples/ClientTests/compact/materials.xml b/examples/ClientTests/compact/materials.xml new file mode 100644 index 0000000000000000000000000000000000000000..12107bafc23a2b39c32e457b34ec7568e5139993 --- /dev/null +++ b/examples/ClientTests/compact/materials.xml @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8"?> +<materials> + + <!-- + Air by weight from + + http://www.engineeringtoolbox.com/air-composition-24_212.html + --> + <material name="Air"> + <D type="density" unit="g/cm3" value="0.0012"/> + <fraction n="0.754" ref="N"/> + <fraction n="0.234" ref="O"/> + <fraction n="0.012" ref="Ar"/> + </material> + + <material name="Vacuum"> + <D type="density" unit="g/cm3" value="0.00000001" /> + <fraction n="1" ref="H" /> + </material> + + <material name="Epoxy"> + <D type="density" value="1.3" unit="g/cm3"/> + <composite n="44" ref="H"/> + <composite n="15" ref="C"/> + <composite n="7" ref="O"/> + </material> + + <material name="Quartz"> + <D type="density" value="2.2" unit="g/cm3"/> + <composite n="1" ref="Si"/> + <composite n="2" ref="O"/> + </material> + + <material name="G10"> + <D type="density" value="1.7" unit="g/cm3"/> + <fraction n="0.08" ref="Cl"/> + <fraction n="0.773" ref="Quartz"/> + <fraction n="0.147" ref="Epoxy"/> + </material> + + <material name="Polystyrene"> + <D value="1.032" unit="g/cm3"/> + <composite n="19" ref="C"/> + <composite n="21" ref="H"/> + </material> + + <material name="Steel235"> + <D value="7.85" unit="g/cm3"/> + <fraction n="0.998" ref="Fe"/> + <fraction n=".002" ref="C"/> + </material> + + <material name="SiliconOxide"> + <D type="density" value="2.65" unit="g/cm3"/> + <composite n="1" ref="Si"/> + <composite n="2" ref="O"/> + </material> + + <material name="BoronOxide"> + <D type="density" value="2.46" unit="g/cm3"/> + <composite n="2" ref="B"/> + <composite n="3" ref="O"/> + </material> + + <material name="SodiumOxide"> + <D type="density" value="2.65" unit="g/cm3"/> + <composite n="2" ref="Na"/> + <composite n="1" ref="O"/> + </material> + + <material name="AluminumOxide"> + <D type="density" value="3.89" unit="g/cm3"/> + <composite n="2" ref="Al"/> + <composite n="3" ref="O"/> + </material> + + <material name="PyrexGlass"> + <D type="density" value="2.23" unit="g/cm3"/> + <fraction n="0.806" ref="SiliconOxide"/> + <fraction n="0.130" ref="BoronOxide"/> + <fraction n="0.040" ref="SodiumOxide"/> + <fraction n="0.023" ref="AluminumOxide"/> + </material> + + <material name="CarbonFiber"> + <D type="density" value="1.5" unit="g/cm3"/> + <fraction n="0.65" ref="C"/> + <fraction n="0.35" ref="Epoxy"/> + </material> + + <material name="CarbonFiber_50D"> + <D type="density" value="0.75" unit="g/cm3"/> + <fraction n="0.65" ref="C"/> + <fraction n="0.35" ref="Epoxy"/> + </material> + + <material name="Rohacell31"> + <D type="density" value="0.032" unit="g/cm3"/> + <composite n="9" ref="C"/> + <composite n="13" ref="H"/> + <composite n="2" ref="O"/> + <composite n="1" ref="N"/> + </material> + + <material name="Rohacell31_50D"> + <D type="density" value="0.016" unit="g/cm3"/> + <composite n="9" ref="C"/> + <composite n="13" ref="H"/> + <composite n="2" ref="O"/> + <composite n="1" ref="N"/> + </material> + + <material name="RPCGasDefault" state="gas"> + <D type="density" value="0.0037" unit="g/cm3"/> + <composite n="209" ref="C"/> + <composite n="239" ref="H"/> + <composite n="381" ref="F"/> + </material> + + <material name="PolystyreneFoam"> + <D type="density" value="0.0056" unit="g/cm3"/> + <fraction n="1.0" ref="Polystyrene"/> + </material> + + <material name="Kapton"> + <D value="1.43" unit="g/cm3" /> + <composite n="22" ref="C"/> + <composite n="10" ref="H" /> + <composite n="2" ref="N" /> + <composite n="5" ref="O" /> + </material> + + <material name="PEEK"> + <D value="1.37" unit="g/cm3" /> + <composite n="19" ref="C"/> + <composite n="12" ref="H" /> + <composite n="3" ref="O" /> + </material> + +</materials> diff --git a/examples/ClientTests/src/Assemblies_VXD_geo.cpp b/examples/ClientTests/src/Assemblies_VXD_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..50eb9a4b991dfc9842b94bf274c524d5d6b90ec5 --- /dev/null +++ b/examples/ClientTests/src/Assemblies_VXD_geo.cpp @@ -0,0 +1,103 @@ +// $Id: ILDExVXD_geo.cpp 673 2013-08-05 10:01:33Z gaede $ +//==================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------- +// +// Author : M.Frank +// +//==================================================================== +#include "DD4hep/DetFactoryHelper.h" + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Geometry; + +static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { + xml_det_t x_det = e; + string name = x_det.nameStr(); + Assembly assembly(name+"_assembly"); + DetElement vxd(name, x_det.typeStr(), x_det.id()); + PlacedVolume pv; + + for(xml_coll_t c(e,_U(layer)); c; ++c) { + xml_comp_t x_layer (c); + xml_comp_t x_support (x_layer.child(_U(support))); + xml_comp_t x_ladder (x_layer.child(_U(ladder))); + int layer_id = x_layer.id(); + int nLadders = x_ladder.number(); + string layername = name+_toString(layer_id,"_layer%d"); + double dphi = 2.*M_PI/double(nLadders); + // --- create an assembly and DetElement for the layer + Assembly layer_assembly(layername); + //Box layer_box(1,1,1); + //Volume layer_assembly(layername,layer_box,lcdd.air()); + + DetElement layerDE( vxd , _toString(layer_id,"layer_%d"), x_det.id() ); + double zhalf = x_ladder.zhalf(); + double offset = x_ladder.offset(); + double sens_radius= x_ladder.radius(); + double sens_thick = x_ladder.thickness(); + double supp_thick = x_support.thickness(); + double radius = sens_radius - supp_thick ; + double phi0 = x_layer.phi0() ; + double width = x_ladder.width(); + + //Box ladderbox ((sens_thick+supp_thick)/2., width/2., zhalf ); + //Volume laddervol(layername+"_ladder",ladderbox,lcdd.air()); + Assembly laddervol (layername+"_ladder"); + + Box sensbox (sens_thick/2., width/2., zhalf); + Volume sensvol (layername+"_ladder_sens",sensbox,lcdd.material(x_ladder.materialStr())); + + Box suppbox (supp_thick/2.,width/2.,zhalf); + Volume suppvol (layername+"_ladder_supp",suppbox,lcdd.material(x_support.materialStr())); + + // --- position the sensitive on top of the support ! + Position senspos ( (sens_thick+supp_thick)/2. - sens_thick/2., 0, 0 ); + Position supppos ( (sens_thick+supp_thick)/2. - sens_thick - supp_thick/2., 0, 0 ); + + sens.setType("tracker"); + + layer_assembly.setVisAttributes(lcdd.invisible()); + pv = assembly.placeVolume(layer_assembly).addPhysVolID("layer",layer_id); + layerDE.setPlacement( pv ) ; + + laddervol.setVisAttributes(lcdd.invisible()); + suppvol.setVisAttributes(x_support.visStr()); + + sensvol.setSensitiveDetector(sens); + sensvol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_layer.visStr()); + + laddervol.placeVolume(sensvol,senspos); + laddervol.placeVolume(suppvol,supppos); + + for(int j=0; j<nLadders; ++j) { + double dj = double(j); + double phi = phi0 + dj*dphi; + string laddername = layername + _toString(j,"_ladder%d"); + double lthick = sens_thick + supp_thick; + RotationZYX rot( phi,0,0); + double pos_x = (radius + lthick/2.)*cos(phi) - offset * sin( phi ); + double pos_y = (radius + lthick/2.)*sin(phi) + offset * cos( phi ); + + pv = layer_assembly.placeVolume( laddervol,Transform3D(rot, Position(pos_x,pos_y,0.0))); + pv.addPhysVolID("module",j).addPhysVolID("sensor",0).addPhysVolID("side",1); + DetElement ladderDE(layerDE, laddername,x_det.id()); + ladderDE.setPlacement(pv); + DetElement ladderDEposZ(layerDE, laddername+"_posZ", x_det.id() ); + ladderDEposZ.setPlacement( pv ) ; + pv = layer_assembly.placeVolume(laddervol,Transform3D(rot, Position(pos_x, pos_y, -zhalf))); + pv.addPhysVolID("module",j).addPhysVolID("sensor",0).addPhysVolID("side",2); + + DetElement ladderDEnegZ(layerDE, laddername+"_negZ" , x_det.id() ); + ladderDEnegZ.setPlacement( pv ) ; + } + } + Volume mother = lcdd.pickMotherVolume(vxd) ; + pv = mother.placeVolume(assembly); + pv.addPhysVolID( "system", x_det.id()); + vxd.setPlacement(pv); + return vxd; +} + +DECLARE_DETELEMENT(VXD_Assembly,create_element); diff --git a/examples/ClientTests/src/FCC_HcalBarrel_geo.cpp b/examples/ClientTests/src/FCC_HcalBarrel_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..542a930052b73da4d29fd74b2c0d6e28e46e3369 --- /dev/null +++ b/examples/ClientTests/src/FCC_HcalBarrel_geo.cpp @@ -0,0 +1,182 @@ +/********************************* + * HcalBarrel_geo + * Implementing a detector + * + * Carlos.Solans@cern.ch + *********************************/ + +#include "DD4hep/DetFactoryHelper.h" +#include "XML/Layering.h" + +#include <vector> + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Geometry; + +static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens) { + //XML detector object: DDCore/XML/XMLDetector.h + xml_dim_t x_det = e; + //Create the DetElement for DD4hep + DetElement d_det(x_det.nameStr(),x_det.id()); + + //XML dimension object: DDCore/XML/XMLDimension.h + xml_dim_t x_det_dim(x_det.dimensions()); + double inner_r = x_det_dim.rmin(); + double outer_r = x_det_dim.rmax(); + //Tube: DDCore/DD4hep/Shapes.h + Tube calo_shape(inner_r,outer_r,x_det_dim.z(),2*M_PI/x_det_dim.phiBins()); + + //Create the detector mother volume + Volume calo_vol(x_det.nameStr()+"_envelope",calo_shape,lcdd.air()); + + //Set envelope volume attributes + calo_vol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det.visStr()); + + + //Declare this sensitive detector as a calorimeter + sens.setType("calorimeter"); + + + int layer_num = 0; + float layer_pos_z = 0; + double tile_phi = 2*M_PI/x_det_dim.phiBins(); + float r = x_det_dim.rmin(); + + bool debug = true; + + Assembly stave_vol(x_det.nameStr()+"_stave_0"); + + + //Repeat layers until we reach the rmax + while(r<x_det_dim.rmax()){ + + //Loop over layers of type: XML Collection_t object: DDCore/XML/XMLElements.h + for(DD4hep::XML::Collection_t layerIt(x_det,_U(layer));layerIt; ++layerIt, ++layer_num) { + + //Build a layer volume + xml_comp_t x_det_layer = layerIt; + + float dr = x_det_layer.dr(); + + string layer_name = x_det.nameStr()+_toString(layer_num,"_layer%d"); + + float x1 = r * tan(tile_phi/2.); + float x2 = (r+dr) * tan(tile_phi/2.); + float y1 = x_det_dim.z(); + float y2 = x_det_dim.z(); + float z = x_det_layer.dr(); + + if(debug){ + cout << " r:" << r + << " dr:" << dr + << " x1:" << x1 + << " x2:" << x2 + << " y1:" << y1 + << " y2:" << y2 + << " z:" << z + << endl; + } + + //Shape a Trapezoid (tile): DDCore/DD4hep/Shapes.h + Trapezoid layer_shape(x1,x2,y1,y2,z); + + //Create a volume with trapezoid shape + Volume layer_vol(layer_name, layer_shape, lcdd.air()); + layer_vol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det_layer.visStr()); + + //DetElement layer(layer_name,_toString(layer_num,"layer%d"),x_det.id()); + + //Fill the volume with tiles + + + int tile_number = 0; + vector<Volume> tiles; + + //Assembly tile_seq(layer_name+"_seq"); + Trapezoid tile_seq_shape(x1,x2,x_det_layer.dz(),x_det_layer.dz(),x_det_layer.dr()); + Volume tile_seq(layer_name + "_seq",tile_seq_shape,lcdd.air()); + tile_seq.setVisAttributes(lcdd.visAttributes("VisibleGreen")); + double total_thickness = 0; + //Repeat slices until we reach the end of the calorimeter + for(xml_coll_t k(x_det_layer,_U(slice)); k; ++k) { + xml_comp_t tile_xml = k; + string tile_name = layer_name + _toString(tile_number,"_slice%d"); + Material tile_material = lcdd.material(tile_xml.materialStr()); + float tile_thickness = tile_xml.dz(); + float tile_y1 = tile_thickness; + float tile_y2 = tile_thickness; + float tile_z = x_det_layer.dr(); + + //Shape a Trapezoid (tile): DDCore/DD4hep/Shapes.h + Trapezoid tile_shape(x1,x2,tile_y1,tile_y2,tile_z); + + //Create a volume with trapezoid shape + Volume tile_vol(tile_name,tile_shape,tile_material); + tile_seq.placeVolume(tile_vol,Position(0,total_thickness,0)); + total_thickness += tile_thickness; + if ( tile_xml.isSensitive() ) { + tile_vol.setSensitiveDetector(sens); + } + + //Set region, limitset, and visibility settings + tile_vol.setAttributes(lcdd,tile_xml.regionStr(),tile_xml.limitsStr(),tile_xml.visStr()); + tiles.push_back(tile_vol); + tile_number++; + } + + //Place the same volumes inside the envelope + float tile_pos_z = -x_det_dim.z()/2.; + while(tile_pos_z<x_det_dim.z()/2.){ + layer_vol.placeVolume(tile_seq,Position(0,tile_pos_z,0)); + tile_pos_z += total_thickness; +#if 0 + for(xml_coll_t k(x_det_layer,_U(slice)); k; ++k) { + xml_comp_t tile_xml = k; + float tile_thickness = tile_xml.dz(); + + //Place the tile inside the layer + PlacedVolume tile_plv = layer_vol.placeVolume(tiles.at(tile_number),Position(0,tile_pos_z,0)); + //Increment the z pos of the tile + tile_pos_z += tile_thickness; + tile_number++; + } +#endif + } + + //Place the same layer around the beam axis phiBins times + Transform3D tr(RotationZYX(M_PI*0.5,M_PI*0.5,0),Translation3D(r,0,layer_pos_z)); + PlacedVolume pv = stave_vol.placeVolume(layer_vol,tr); + //pv.addPhysVolID("layer",i+1); + //DetElement sd = i==0 ? stave_det : stave_det.clone(_toString(i,"stave%d")); + + r += dr; + cout << "+++ R=" << r << endl; + } + } + double mod_x_off = outer_r - (outer_r-inner_r)/2.0; + double mod_y_off = 0; + int nphi_bins = x_det_dim.phiBins(); + for(int i=0;i<nphi_bins;i++){ + if(debug) cout << "Layer:" << i << " phi:" << tile_phi << " rotz:" << (tile_phi*i) << endl; + double phi = tile_phi*i; + double pos_x = mod_x_off * cos(phi) - mod_y_off * sin(phi); + double pos_y = mod_x_off * sin(phi) + mod_y_off * cos(phi); + Transform3D tr(RotationZYX(phi,0,0),Translation3D(0,0,0)); + PlacedVolume pv = calo_vol.placeVolume(stave_vol,tr); + pv.addPhysVolID("stave",i+1); + } + + + cout << "Number of layers: " << layer_num << endl; + + //Place the calo inside the world + PlacedVolume calo_plv = lcdd.pickMotherVolume(d_det).placeVolume(calo_vol); + calo_plv.addPhysVolID("system",x_det.id()); + calo_plv.addPhysVolID("barrel",0); + d_det.setPlacement(calo_plv); + + return d_det; +} + +DECLARE_DETELEMENT(FCC_HcalBarrel,create_detector); diff --git a/examples/ClientTests/src/ORG_HcalBarrel_geo.cpp b/examples/ClientTests/src/ORG_HcalBarrel_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f134543673712f33e4057c8fecebe0a5e86b6427 --- /dev/null +++ b/examples/ClientTests/src/ORG_HcalBarrel_geo.cpp @@ -0,0 +1,176 @@ +/********************************* + * HcalBarrel_geo + * Implementing a detector + * + * Carlos.Solans@cern.ch + *********************************/ + +#include "DD4hep/DetFactoryHelper.h" +#include "XML/Layering.h" + +#include <vector> + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Geometry; + +static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens) { + + //XML detector object: DDCore/XML/XMLDetector.h + DD4hep::XML::DetElement x_det = e; + + //Create the DetElement for DD4hep + DetElement d_det(x_det.nameStr(),x_det.id()); + + //Pick the mothervolume + Volume det_vol = lcdd.pickMotherVolume(d_det); + + //XML dimension object: DDCore/XML/XMLDimension.h + DD4hep::XML::Dimension x_det_dim(x_det.dimensions()); + + //Tube: DDCore/DD4hep/Shapes.h + Tube calo_shape(x_det_dim.rmin(),x_det_dim.rmax(),x_det_dim.z(),2*M_PI/x_det_dim.phiBins()); + + //Create the detector mother volume + Volume calo_vol(x_det.nameStr()+"_envelope",calo_shape,lcdd.air()); + + //Set envelope volume attributes + calo_vol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det.visStr()); + + //Place inside the mother volume + PlacedVolume calo_plv = det_vol.placeVolume(calo_vol); + + calo_plv.addPhysVolID("system",x_det.id()); + calo_plv.addPhysVolID("barrel",0); + d_det.setPlacement(calo_plv); + + //Declare this sensitive detector as a calorimeter + sens.setType("calorimeter"); + + + int layer_num = 0; + float layer_pos_z = 0; + double tile_phi = 2*M_PI/x_det_dim.phiBins(); + float r = x_det_dim.rmin(); + + bool debug = true; + + //Repeat layers until we reach the rmax + while(r<x_det_dim.rmax()){ + + //Loop over layers of type: XML Collection_t object: DDCore/XML/XMLElements.h + for(DD4hep::XML::Collection_t layerIt(x_det,_U(layer));layerIt; ++layerIt){ + + //Build a layer volume + DD4hep::XML::Component x_det_layer = layerIt; + + float dr = x_det_layer.dr(); + + string layer_name = x_det.nameStr()+_toString(layer_num,"_layer%d"); + + float x1 = r * tan(tile_phi/2.); + float x2 = (r+dr) * tan(tile_phi/2.); + float y1 = x_det_dim.z(); + float y2 = x_det_dim.z(); + float z = x_det_layer.dr(); + + if(debug){ + cout << " r:" << r + << " dr:" << dr + << " x1:" << x1 + << " x2:" << x2 + << " y1:" << y1 + << " y2:" << y2 + << " z:" << z + << endl; + } + + //Shape a Trapezoid (tile): DDCore/DD4hep/Shapes.h + Trapezoid layer_shape(x1,x2,y1,y2,z); + + //Create a volume with trapezoid shape + Volume layer_vol(layer_name, layer_shape, lcdd.air()); + layer_vol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det_layer.visStr()); + + //DetElement layer(layer_name,_toString(layer_num,"layer%d"),x_det.id()); + + //Fill the volume with tiles + + + int tile_number = 0; + vector<Volume> tiles; + + //Repeat slices until we reach the end of the calorimeter + for(xml_coll_t k(x_det_layer,_U(slice)); k; ++k) { + + DD4hep::XML::Component tile_xml = k; + string tile_name = layer_name + _toString(tile_number,"_slice%d"); + Material tile_material = lcdd.material(tile_xml.materialStr()); + float tile_thickness = tile_xml.dz(); + float tile_y1 = tile_thickness; + float tile_y2 = tile_thickness; + float tile_z = x_det_layer.dr(); + + //Shape a Trapezoid (tile): DDCore/DD4hep/Shapes.h + Trapezoid tile_shape(x1,x2,tile_y1,tile_y2,tile_z); + + //Create a volume with trapezoid shape + Volume tile_vol(tile_name,tile_shape,tile_material); + + if ( tile_xml.isSensitive() ) { + tile_vol.setSensitiveDetector(sens); + } + + //Set region, limitset, and visibility settings + tile_vol.setAttributes(lcdd,tile_xml.regionStr(),tile_xml.limitsStr(),tile_xml.visStr()); + + tiles.push_back(tile_vol); + tile_number++; + } + + //Place the same volumes inside the envelope + float tile_pos_z = -x_det_dim.z()/2.; + while(tile_pos_z<x_det_dim.z()/2.){ + tile_number=0; + for(xml_coll_t k(x_det_layer,_U(slice)); k; ++k) { + + DD4hep::XML::Component tile_xml = k; + float tile_thickness = tile_xml.dz(); + + //Place the tile inside the layer + PlacedVolume tile_plv = layer_vol.placeVolume(tiles.at(tile_number),Position(0,tile_pos_z,0)); + + //Increment the z pos of the tile + tile_pos_z += tile_thickness; + tile_number++; + + } + } + + //Place the same layer around the beam axis phiBins times + double mod_x_off = r; + double mod_y_off = 0; + for(int i=0;i<x_det_dim.phiBins();i++){ + if(debug) cout << "Layer:" << i << " phi:" << tile_phi << " rotz:" << (tile_phi*i) << endl; + double layer_pos_x = mod_x_off * cos(tile_phi*i) - mod_y_off * sin(tile_phi*i); + double layer_pos_y = mod_x_off * sin(tile_phi*i) + mod_y_off * cos(tile_phi*i); + Transform3D tr(RotationZYX(M_PI*0.5,M_PI*0.5,0)*RotationZYX(0,tile_phi*i,0), + Translation3D(layer_pos_x,layer_pos_y,layer_pos_z)); + PlacedVolume pv = calo_vol.placeVolume(layer_vol,tr); + pv.addPhysVolID("system",x_det.id()); + pv.addPhysVolID("barrel",0); + pv.addPhysVolID("layer",i+1); + //DetElement sd = i==0 ? stave_det : stave_det.clone(_toString(i,"stave%d")); + } + + r += dr; + } + } + + //Place the calo inside the world + + return d_det; +} + +DECLARE_DETELEMENT(ORG_HcalBarrel,create_detector); +