From dc5b08f501e8bfd7365c4a14b0a2261e12288740 Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Fri, 21 Oct 2016 14:43:42 +0200 Subject: [PATCH] Restore access to DDSegmentation object from DD4hep segmentation --- DDCore/include/DD4hep/Segmentations.h | 10 +++++ DDCore/src/Segmentations.cpp | 15 +++++++ DDDB/src/DDDBLogVolumeDump.cpp | 65 +++++++++++++++++++++++++++ DDDB/src/DDDBPlugins.cpp | 7 ++- 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 DDDB/src/DDDBLogVolumeDump.cpp diff --git a/DDCore/include/DD4hep/Segmentations.h b/DDCore/include/DD4hep/Segmentations.h index deadd6f0e..c245cad22 100644 --- a/DDCore/include/DD4hep/Segmentations.h +++ b/DDCore/include/DD4hep/Segmentations.h @@ -87,6 +87,16 @@ namespace DD4hep { VolumeID volumeID(const CellID& cellID) const; /// Calculates the neighbours of the given cell ID and adds them to the list of neighbours void neighbours(const CellID& cellID, std::set<CellID>& neighbours) const; + /** \brief Returns a vector<double> of the cellDimensions of the given cell ID + * in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + * + * \param cellID cellID of the cell for which parameters are returned + * \return vector<double> in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + */ + std::vector<double> cellDimensions(const CellID& cellID) const; + + /// Access to the base DDSegmentation object. WARNING: Deprecated call! + BaseSegmentation* segmentation() const; }; } /* End namespace Geometry */ diff --git a/DDCore/src/Segmentations.cpp b/DDCore/src/Segmentations.cpp index 77f13ac8b..d34d91edb 100644 --- a/DDCore/src/Segmentations.cpp +++ b/DDCore/src/Segmentations.cpp @@ -82,6 +82,21 @@ void Segmentation::neighbours(const CellID& cell, std::set<CellID>& nb) const { data<Object>()->segmentation->neighbours(cell, nb); } +/** \brief Returns a vector<double> of the cellDimensions of the given cell ID + * in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + * + * \param cellID cellID of the cell for which parameters are returned + * \return vector<double> in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + */ +std::vector<double> Segmentation::cellDimensions(const CellID& cell) const { + return data<Object>()->segmentation->cellDimensions(cell); +} + +/// Access to the base DDSegmentation object. WARNING: Deprecated call! +Segmentation::BaseSegmentation* Segmentation::segmentation() const { + return data<Object>()->segmentation; +} + /// Access the underlying decoder BitField64* Segmentation::decoder() const { return data<Object>()->segmentation->decoder(); diff --git a/DDDB/src/DDDBLogVolumeDump.cpp b/DDDB/src/DDDBLogVolumeDump.cpp new file mode 100644 index 000000000..6d67edd6b --- /dev/null +++ b/DDDB/src/DDDBLogVolumeDump.cpp @@ -0,0 +1,65 @@ +// $Id$ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== +// +// DDDB is a detector description convention developed by the LHCb experiment. +// For further information concerning the DTD, please see: +// http://lhcb-comp.web.cern.ch/lhcb-comp/Frameworks/DetDesc/Documents/lhcbDtd.pdf +// +//========================================================================== + +// Framework includes +#include "DD4hep/LCDD.h" +#include "DD4hep/Plugins.h" +#include "DD4hep/Printout.h" +#include "DD4hep/Factories.h" +#include "DD4hep/objects/DetectorInterna.h" + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Geometry; + +/// Anonymous namespace for plugins +namespace { + class VolumeScan { + std::set<TGeoVolume*> scanned_vols; + public: + VolumeScan() {} + void scan_daughters(TGeoVolume* vol, string path) { + auto ivol = scanned_vols.find(vol); + if ( ivol == scanned_vols.end() ) { + int num_dau = vol->GetNdaughters(); + scanned_vols.insert(vol); + path += "/"; + path += vol->GetName(); + printout(INFO,"DDDB_vol_dump","%s",path.c_str()); + for(int i=0; i<num_dau; ++i) { + TGeoNode* n = vol->GetNode(i); + TGeoVolume* v = n->GetVolume(); + scan_daughters(v,path); + } + } + } + }; + + /// Plugin function + long dddb_dump_logical_volumes(LCDD& lcdd, int , char** ) { + VolumeScan scan; + Volume world_vol = lcdd.worldVolume(); + scan.scan_daughters(world_vol,string()); + return 1; + } +} /* End anonymous namespace */ + +DECLARE_APPLY(DDDB_LogVolumeDump,dddb_dump_logical_volumes) +//========================================================================== diff --git a/DDDB/src/DDDBPlugins.cpp b/DDDB/src/DDDBPlugins.cpp index 43f108f0d..02cc0f8c6 100644 --- a/DDDB/src/DDDBPlugins.cpp +++ b/DDDB/src/DDDBPlugins.cpp @@ -235,7 +235,12 @@ namespace { return result; } /// __________________________________________________________________________________ - void printDetElement(int level, DetElement de, ConditionPrinter& prt, bool with_placement=false, bool with_keys=false, bool with_values=false) { + void printDetElement(int level, DetElement de, + ConditionPrinter& prt, + bool with_placement=false, + bool with_keys=false, + bool with_values=false) + { typedef Conditions::Container::Object::Keys _K; char fmt[128]; const DetElement::Children& c = de.children(); -- GitLab