Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:58:00

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DD4HEP_DETECTORTOOLS_H
0014 #define DD4HEP_DETECTORTOOLS_H
0015 
0016 // Framework include files
0017 #include <DD4hep/DetElement.h>
0018 
0019 // Forward declarations
0020 class TGeoHMatrix;
0021 
0022 /// Namespace for the AIDA detector description toolkit
0023 namespace dd4hep {
0024 
0025   // Forward declarations
0026   class Detector;
0027 
0028   namespace detail   {
0029     
0030     /// Helper namespace used to answer detector element specific questons
0031     /**
0032      *
0033      *  \author  M.Frank
0034      *  \version 1.0
0035      *  \ingroup DD4HEP_CORE
0036      */
0037     namespace tools {
0038       typedef std::vector<DetElement>   ElementPath;
0039       typedef std::vector<PlacedVolume> PlacementPath;
0040 
0041       /// Determine top level element (=world) for any element walking up the detector element tree
0042       DetElement topElement(DetElement child);
0043 
0044       /// Assemble the path of a particular detector element
0045       std::string elementPath(DetElement element);
0046       /// Assemble the path of the PlacedVolume selection
0047       std::string elementPath(const ElementPath& nodes, bool reverse=true);
0048 
0049       /// Collect detector elements to the top detector element (world)
0050       void elementPath(DetElement elt, ElementPath& detectors);
0051       /// Find DetElement as child of the top level volume by its absolute path
0052       DetElement findElement(const Detector& description, const std::string& path);
0053       /// Find DetElement as child of a parent by its relative or absolute path
0054       DetElement findDaughterElement(DetElement parent, const std::string& subpath);
0055       /// Find path between the child element and the parent element
0056       bool isParentElement(DetElement parent, DetElement child);
0057 
0058       /// Assemble the placement path from a given detector element to the world volume
0059       std::string placementPath(DetElement element);
0060       /// Assemble the path of the PlacedVolume selection
0061       std::string placementPath(const PlacementPath& nodes, bool reverse=true);
0062       /// Assemble the path of the PlacedVolume selection
0063       std::string placementPath(const std::vector<const TGeoNode*>& nodes, bool reverse=true);
0064 
0065       /// Collect detector elements placements to the top detector element (world) [no holes!]
0066       void placementPath(DetElement elt, PlacementPath& nodes);
0067       /// Collect detector elements placements to the parent detector element [no holes!]
0068       void placementPath(DetElement parent, DetElement child, PlacementPath& nodes);
0069 
0070       /// Find a given node in the hierarchy starting from the top node (absolute placement!)
0071       PlacedVolume findNode(PlacedVolume top_place, const std::string& place);
0072       /// Update cached matrix to transform to positions to an upper level Placement
0073       void placementTrafo(const PlacementPath& nodes, bool inverse, TGeoHMatrix*& mat);
0074       /// Update cached matrix to transform to positions to an upper level Placement
0075       void placementTrafo(const PlacementPath& nodes, bool inverse, TGeoHMatrix& mat);
0076 
0077 
0078       /// Convert VolumeID to string
0079       std::string toString(const PlacedVolume::VolIDs& ids);
0080       /// Convert VolumeID to string
0081       std::string toString(const IDDescriptor& dsc, const PlacedVolume::VolIDs& ids, VolumeID code);
0082       /// Extract all the path elements from a path
0083       std::vector<std::string> pathElements(const std::string& path);
0084     }
0085   }
0086 }         /* End namespace dd4hep                   */
0087 #endif // DD4HEP_DETECTORTOOLS_H