|
||||
Warning, file /include/XML/VolumeBuilder.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 XML_VOLUMEBUILDER_H 0014 #define XML_VOLUMEBUILDER_H 0015 0016 // Framework include files 0017 #include <XML/XMLElements.h> 0018 #include <XML/XMLDetector.h> 0019 #include <DD4hep/Detector.h> 0020 0021 // C/C++ include files 0022 #include <set> 0023 #include <map> 0024 #include <memory> 0025 0026 /// Namespace for the AIDA detector description toolkit 0027 namespace dd4hep { 0028 0029 /// Namespace for the AIDA detector description toolkit supporting XML utilities 0030 namespace xml { 0031 0032 /// Declaration of the XML tools namespace 0033 namespace tools { 0034 0035 /// Helper class to build volume and shapes according to ertain patterns in the XML tree. 0036 /** 0037 * 1) Shape builder pattern (buildShape): <br> 0038 @verbatim 0039 <parent_element> 0040 <shape name="Shape1" type="Box" dx="Bls:ScintSSizeX" dy="Bls:ScintSSizeY" dz="Bls:ScintSSizeZ"/> 0041 <shape name="Shape2" type="Box" dx="Bls:ScintMSizeX" dy="Bls:ScintMSizeY" dz="Bls:ScintMSizeZ"/> 0042 <shape name="Shape3" type="Box" dx="Bls:ScintLSizeX" dy="Bls:ScintLSizeY" dz="Bls:ScintLSizeZ"/> 0043 .... 0044 <shape name="ShapeN" type="Trapezoid" z="Bls:FiberCoverH" 0045 x1="Bls:ScintLSizeX" y1="Bls:ScintSSizeZ" x2="Bls:ScintSSizeX" y2="Bls:ScintSSizeZ"/> 0046 <parent_element> 0047 0048 @endverbatim 0049 * 0050 * 2) Volume builder pattern 0051 * 2.a) Regular pattern using anonymouns shapes 0052 * Call: size_t buildVolumes(xml_h handle); 0053 * In the example handle references <detector> 0054 * 0055 @verbatim 0056 <detector id="Bls:ID" name="Bls" type="LHCb_Bcm" 0057 parent="${Bls:Parent}" 0058 0059 <volume name="lvBlsScintS" material="Bls/BlsSc" vis="Bls:ScintillatorVis"> 0060 <shape type="Box" dx="Bls:ScintSSizeX" dy="Bls:ScintSSizeY" dz="Bls:ScintSSizeZ"/> 0061 </volume> 0062 <volume name="lvBlsScintM" material="Bls/BlsSc" vis="Bls:ScintillatorVis"> 0063 <shape type="Box" dx="Bls:ScintMSizeX" dy="Bls:ScintMSizeY" dz="Bls:ScintMSizeZ"/> 0064 </volume> 0065 .... 0066 </detector> 0067 @endverbatim 0068 * 0069 * 2.b) Regular pattern referencing named shapes (created and registered by buildShapes) 0070 * Call: size_t buildVolumes(xml_h handle); 0071 * In the example handle references <detector> 0072 * 0073 @verbatim 0074 <detector> 0075 <volume name="lvBlsScintS1" material="Bls/BlsSc" vis="Bls:ScintillatorVis" shape="Shape1"> 0076 <volume name="lvBlsScintS2" material="Bls/BlsSc" vis="Bls:ScintillatorVis" shape="Shape2"> 0077 <volume name="lvBlsScintS3" material="Bls/BlsSc" vis="Bls:ScintillatorVis" shape="Shape3"> 0078 .... 0079 <volume name="lvBlsScintSN" material="Bls/BlsSc" vis="Bls:ScintillatorVis" shape="ShapeN"> 0080 </detector> 0081 @endverbatim 0082 * 2.c) Pattern to create named assembly volumes 0083 * Call: size_t buildVolumes(xml_h handle); 0084 * In the example handle references <detector> 0085 * 0086 @verbatim 0087 <volume name="lvBlsScintS1" vis="Bls:ScintillatorVis" assemply="1"> 0088 <volume name="lvBlsScintS2" vis="Bls:ScintillatorVis" assemply="1"> 0089 <volume name="lvBlsScintS3" vis="Bls:ScintillatorVis" assemply="1"> 0090 .... 0091 <volume name="lvBlsScintSN" vis="Bls:ScintillatorVis" assemply="1"> 0092 </detector> 0093 @endverbatim 0094 * Alternative 0095 @verbatim 0096 <volume name="lvBlsScintS1" vis="Bls:ScintillatorVis"> 0097 <assembly/> 0098 </volume> 0099 @endverbatim 0100 * 0101 * Volume placement patterns 0102 * 3.c) Pattern to place daughter volumes into parent 0103 * void VolumeBuilder::placeDaughters(DetElement parent, Volume vol, xml_h handle) 0104 * In the example handle references <assembly> 0105 * 0106 @verbatim 0107 <assembly name="lvBcmDownMount"> 0108 <physvol logvol="lvBcmDownMountFront"> 0109 <position/> 0110 </physvol> 0111 <physvol logvol="lvBcmDownMountBackSection"> 0112 <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> 0113 <rotation z="45*degree"/> 0114 </physvol> 0115 <physvol logvol="lvBcmDownMountBackSection"> 0116 <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> 0117 <rotation z="135*degree"/> 0118 </physvol> 0119 <physvol logvol="lvBcmDownMountBackSection"> 0120 <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> 0121 <rotation z="225*degree"/> 0122 </physvol> 0123 <physvol logvol="lvBcmDownMountBackSection"> 0124 <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> 0125 <rotation z="315*degree"/> 0126 </physvol> 0127 </assembly> 0128 @endverbatim 0129 * 0130 * 0131 * Please Note: 0132 * It is the user's responsability to ensure all reated entities are 0133 * properly registered to the detector description (and TGeo). 0134 * No cleanup and referencing is done here! 0135 * 0136 * \author M.Frank 0137 * \version 1.0 0138 * \date 12/10/2018 0139 */ 0140 class VolumeBuilder { 0141 public: 0142 typedef ::dd4hep::DetElement DetElement; 0143 typedef ::dd4hep::xml::DetElement xml_det_h; 0144 typedef std::map<std::string,std::pair<Handle_t,Solid> > Shapes; 0145 typedef std::map<std::string,std::pair<Handle_t,Volume> > Volumes; 0146 typedef std::map<std::string,Material> Materials; 0147 typedef std::map<std::string,std::pair<Handle_t,Transform3D> > Transformations; 0148 std::map<std::string, std::unique_ptr<xml::DocumentHolder> > included_docs; 0149 Detector& description; 0150 xml_det_h x_det; 0151 int id = -1; 0152 std::string name; 0153 DetElement detector; 0154 SensitiveDetector sensitive; 0155 DetectorBuildType buildType; 0156 Shapes shapes; 0157 Volumes volumes; 0158 Materials materials; 0159 Transformations transformations; 0160 std::set<std::string> shape_veto, vol_veto; 0161 bool debug = false; 0162 0163 protected: 0164 /// Place single volumes 0165 void _placeSingleVolume(DetElement de, Volume vol, Handle_t c); 0166 /// Place parametrized volumes 0167 void _placeParamVolumes(DetElement de, Volume vol, Handle_t c); 0168 0169 public: 0170 /// Inhibit default constructor 0171 VolumeBuilder() = delete; 0172 /// Inhibit move constructor 0173 VolumeBuilder(VolumeBuilder&& copy) = delete; 0174 /// Inhibit copy constructor 0175 VolumeBuilder(const VolumeBuilder& copy) = delete; 0176 /// Initializing constructor 0177 VolumeBuilder(Detector& dsc, 0178 Handle_t x_parent, 0179 SensitiveDetector sd=SensitiveDetector()); 0180 /// Default constructor 0181 virtual ~VolumeBuilder() {} 0182 /// Inhibit move assignment 0183 VolumeBuilder& operator=(VolumeBuilder&& copy) = delete; 0184 /// Inhibit copy assignment 0185 VolumeBuilder& operator=(const VolumeBuilder& copy) = delete; 0186 0187 /// Collect a set of materials from the leafs of an xml tag 0188 size_t collectMaterials(Handle_t element); 0189 0190 /// Access element from transformation cache by name 0191 Transform3D getTransform(const std::string& nam) const; 0192 /// Access element from shape cache by name. Invalid returns means 'veto'. Otherwise exception 0193 Solid getShape(const std::string& nam) const; 0194 /// Create a new shape from the information given in the xml handle 0195 Solid makeShape(Handle_t handle); 0196 /// Access a registered volume by name 0197 Volume volume(const std::string& nam) const; 0198 /// Register shape to map 0199 void registerShape(const std::string& nam, Solid shape); 0200 /// Register volume to map 0201 void registerVolume(const std::string& nam, Volume volume); 0202 /// Build all <shape/> identifiers in the passed parent xml element 0203 size_t buildShapes(Handle_t handle); 0204 /// Build all <volume/> identifiers in the passed parent xml element 0205 size_t buildVolumes(Handle_t handle); 0206 /// Build all <transformation/> identifiers in the passed parent xml element 0207 size_t buildTransformations(Handle_t handle); 0208 /// Load include tags contained in the passed XML handle 0209 size_t load(Handle_t element, const std::string& tag); 0210 /// Build all <physvol/> identifiers as PlaceVolume daughters. Ignores structure 0211 VolumeBuilder& placeDaughters(Volume vol, Handle_t handle); 0212 /// Build all <physvol/> identifiers as PlaceVolume daughters. Also handles structure 0213 VolumeBuilder& placeDaughters(DetElement parent, Volume vol, Handle_t handle); 0214 /// Place the detector object into the mother volume returned by the Detector instance 0215 PlacedVolume placeDetector(Volume vol); 0216 PlacedVolume placeDetector(Volume vol, Handle_t handle); 0217 }; 0218 } /* End namespace tools */ 0219 } /* End namespace xml */ 0220 } /* End namespace dd4hep */ 0221 #endif // XML_VOLUMEBUILDER_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |