diff --git a/.gitignore b/.gitignore index 89e701a8dfbd57b9b2b955e18f3d1a900028cd29..791cadea13425fc298ad10caf7775f8c212c756f 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ Version.h *~ *.DS_Store + +# XML files for DDUpgrade that are downloaded with cmake +/examples/DDUpgrade/data diff --git a/DDCore/include/DD4hep/BuildType.h b/DDCore/include/DD4hep/BuildType.h index f9035db1859c331b9712cabb0c24c69110666079..9f83329d1b102cd89c0672799b0a31d5252bcdb2 100644 --- a/DDCore/include/DD4hep/BuildType.h +++ b/DDCore/include/DD4hep/BuildType.h @@ -43,5 +43,8 @@ namespace dd4hep { /// Translate string representation of the geometry build type to value DetectorBuildType buildType(const std::string& value); + /// Check if a build type matches the current + bool buildMatch(const std::string& value, DetectorBuildType match); + } /* End namespace dd4hep */ #endif // DD4HEP_BUILDTYPES_H diff --git a/DDCore/include/DD4hep/Detector.h b/DDCore/include/DD4hep/Detector.h index c3b82901f7f9372e7c48168fc58d05066bf53258..932bad79f5dffb2819d1b3755e9e1b6b31458fd9 100644 --- a/DDCore/include/DD4hep/Detector.h +++ b/DDCore/include/DD4hep/Detector.h @@ -184,12 +184,15 @@ namespace dd4hep { /** Miscaneleous accessors to the detexctor description */ - /// Register new mother volume using the detector name. + /// Register new parent detector using the detector name. /** Volumes must be registered/declared PRIOR to be picked up! + * Once registered, Detector::pickMotherVolume(detector) will automatically return the + * proper parent volume! + * * The method throws an exception if another volume was already declared for this subdetector * The method throws an exception if the volume to be registered is invalid. */ - virtual void declareMotherVolume(const std::string& detector_name, const Volume& vol) = 0; + virtual void declareParent(const std::string& detector_name, const DetElement& det) = 0; /// Access mother volume by detector element /** The method uses the detector element's name for volume identification. diff --git a/DDCore/include/DD4hep/DetectorData.h b/DDCore/include/DD4hep/DetectorData.h index 4679e19e8e349e9155fa5cb63c6300b2223d0193..976ba15b649230d3273414a7210e6072bd205466 100644 --- a/DDCore/include/DD4hep/DetectorData.h +++ b/DDCore/include/DD4hep/DetectorData.h @@ -110,7 +110,7 @@ namespace dd4hep { // GDML fields ObjectHandleMap m_define; - std::map<std::string,Volume> m_motherVolumes; + std::map<std::string,DetElement> m_detectorParents; DetElement m_world; DetElement m_trackers; diff --git a/DDCore/include/DD4hep/DetectorTools.h b/DDCore/include/DD4hep/DetectorTools.h index 6abbf4c8ec15c0d74791e78f9845c5fce676c010..73d174f1e3a60ba26eae8d67d989bbede6164a33 100644 --- a/DDCore/include/DD4hep/DetectorTools.h +++ b/DDCore/include/DD4hep/DetectorTools.h @@ -49,7 +49,7 @@ namespace dd4hep { /// Collect detector elements to the top detector element (world) void elementPath(DetElement elt, ElementPath& detectors); /// Find DetElement as child of the top level volume by it's absolute path - DetElement findElement(Detector& description, const std::string& path); + DetElement findElement(const Detector& description, const std::string& path); /// Find DetElement as child of a parent by it's relative or absolute path DetElement findDaughterElement(DetElement parent, const std::string& subpath); /// Find path between the child element and the parent element diff --git a/DDCore/include/Parsers/detail/Dimension.h b/DDCore/include/Parsers/detail/Dimension.h index 3c4a258810f4342cbb4d13fb243753a4ff00279a..4ec720438d831d12dbdb5e1f0cc3e93adf2d0325 100644 --- a/DDCore/include/Parsers/detail/Dimension.h +++ b/DDCore/include/Parsers/detail/Dimension.h @@ -69,6 +69,9 @@ namespace dd4hep { /// Access parameters: id, if not present returns default int id(int default_value) const; + /// Access parameters: station + int station() const; + /// Access parameters: type int type() const; /// Access rotation constants: combineHits diff --git a/DDCore/include/Parsers/detail/Dimension.imp b/DDCore/include/Parsers/detail/Dimension.imp index 4d659636df1cae76bfaedeb5fc5d51b9220444f8..636cb512b04e2de3c900d2ba5d153e90c0f1be69 100644 --- a/DDCore/include/Parsers/detail/Dimension.imp +++ b/DDCore/include/Parsers/detail/Dimension.imp @@ -22,6 +22,7 @@ XML_ATTR_ACCESSOR(int, id) XML_ATTR_ACCESSOR_INT(id) XML_ATTR_ACCESSOR(bool, combineHits) +XML_ATTR_ACCESSOR(int, station) XML_ATTR_ACCESSOR_DOUBLE(x) XML_ATTR_ACCESSOR_DOUBLE(X) diff --git a/DDCore/include/XML/UnicodeValues.h b/DDCore/include/XML/UnicodeValues.h index ab34cc3f951f887dff606d58f06452eb3023ce19..0fab5e518c51c8a287da610b6e52b2486f4b08c9 100644 --- a/DDCore/include/XML/UnicodeValues.h +++ b/DDCore/include/XML/UnicodeValues.h @@ -57,6 +57,7 @@ UNICODE (barrel_envelope); UNICODE (beampipe); UNICODE (beta); UNICODE (box); +UNICODE (build); UNICODE (c); UNICODE (distance); @@ -296,6 +297,7 @@ UNICODE (o); UNICODE (O); UNICODE (offset); UNICODE (open); +UNICODE (operation); UNICODE (overlap); UNICODE (outer); UNICODE (outer_field); @@ -342,6 +344,7 @@ UNICODE (polyhedra); UNICODE (polycone); UNICODE (position); UNICODE (positionref); +UNICODE (positionRPhiZ); UNICODE (pressure); UNICODE (projective_cylinder); UNICODE (projective_zplane); @@ -460,6 +463,7 @@ UNICODE (torus); UNICODE (tracker); UNICODE (tracking_cylinder); UNICODE (tracking_volume); +UNICODE (transformation); UNICODE (trap); UNICODE (trapezoid); UNICODE (trd); diff --git a/DDCore/include/XML/Utilities.h b/DDCore/include/XML/Utilities.h index 618b5fca86f6f11def5da0c4cd94cc45cb7208e1..2e96327b1e4358408c6443667f96fd3eae893bcd 100644 --- a/DDCore/include/XML/Utilities.h +++ b/DDCore/include/XML/Utilities.h @@ -19,12 +19,40 @@ #include "XML/XMLElements.h" #include "DD4hep/Detector.h" +// C/C++ include files +#include <set> +#include <map> + /// Namespace for the AIDA detector description toolkit namespace dd4hep { /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace xml { + /// Create layered transformation from xml information + /** The xml content of the information supposedly looks like this: + * <transformation> + * <position/> + * <rotation x="-90*degree"/> + * <position/> + * <rotation y="-90*degree"/> + * <position x="CutX" + * y=" 0.5*YokeHorHeight" + * z="-0.5*(YokeHorD1+YokeHorA1)"/> + * <rotation x="-HoleAngle"/> + * <position/> + * <rotation z="CutTrapTheta"/> + * </transformation> + * + * Every pair position, rotation will be combined to a Transform3D + * and combined to the resulting transformation. + */ + Transform3D createTransformation(xml::Element element); + + /// Create a volume using the plugin mechanism from the attributes of the XML element + Volume createVolume(Detector& description, xml::Element element); + + /// Create a solid shape using the plugin mechanism from the attributes of the XML element Solid createShape(Detector& description, const std::string& shape_type, xml::Element element); @@ -43,11 +71,8 @@ namespace dd4hep { * @author S.Lu DESY, F. Gaede CERN/DESY */ Volume createPlacedEnvelope( dd4hep::Detector& description, dd4hep::xml::Handle_t e , - dd4hep::DetElement sdet ) ; - - - - + dd4hep::DetElement sdet ) ; + /** Sets the type flag specified in the \<type_flags\> element for the given DetElement, example: <br> @verbatim <type_flags type=" DetType_TRACKER + DetType_PIXEL + DetType_VERTEX "/> @@ -56,6 +81,167 @@ namespace dd4hep { */ void setDetectorTypeFlag( dd4hep::xml::Handle_t e, dd4hep::DetElement sdet ) ; - } /* End namespace xml */ -} /* End namespace dd4hep */ + + /// Declaration of the XML tools namespace + namespace tools { + + /// Helper class to build volume and shapes according to ertain patterns in the XML tree. + /** + * 1) Shape builder pattern (buildShape): <br> + @verbatim + <parent_element> + <shape name="Shape1" type="Box" dx="Bls:ScintSSizeX" dy="Bls:ScintSSizeY" dz="Bls:ScintSSizeZ"/> + <shape name="Shape2" type="Box" dx="Bls:ScintMSizeX" dy="Bls:ScintMSizeY" dz="Bls:ScintMSizeZ"/> + <shape name="Shape3" type="Box" dx="Bls:ScintLSizeX" dy="Bls:ScintLSizeY" dz="Bls:ScintLSizeZ"/> + .... + <shape name="ShapeN" type="Trapezoid" z="Bls:FiberCoverH" + x1="Bls:ScintLSizeX" y1="Bls:ScintSSizeZ" x2="Bls:ScintSSizeX" y2="Bls:ScintSSizeZ"/> + <parent_element> + + @endverbatim + * + * 2) Volume builder pattern + * 2.a) Regular pattern using anonymouns shapes + * Call: size_t buildVolumes(xml_h handle); + * In the example handle references <detector> + * + @verbatim + <detector id="Bls:ID" name="Bls" type="LHCb_Bcm" + parent="${Bls:Parent}" + + <volume name="lvBlsScintS" material="Bls/BlsSc" vis="Bls:ScintillatorVis"> + <shape type="Box" dx="Bls:ScintSSizeX" dy="Bls:ScintSSizeY" dz="Bls:ScintSSizeZ"/> + </volume> + <volume name="lvBlsScintM" material="Bls/BlsSc" vis="Bls:ScintillatorVis"> + <shape type="Box" dx="Bls:ScintMSizeX" dy="Bls:ScintMSizeY" dz="Bls:ScintMSizeZ"/> + </volume> + .... + </detector> + @endverbatim + * + * 2.b) Regular pattern referencing named shapes (created and registered by buildShapes) + * Call: size_t buildVolumes(xml_h handle); + * In the example handle references <detector> + * + @verbatim + <detector> + <volume name="lvBlsScintS1" material="Bls/BlsSc" vis="Bls:ScintillatorVis" shape="Shape1"> + <volume name="lvBlsScintS2" material="Bls/BlsSc" vis="Bls:ScintillatorVis" shape="Shape2"> + <volume name="lvBlsScintS3" material="Bls/BlsSc" vis="Bls:ScintillatorVis" shape="Shape3"> + .... + <volume name="lvBlsScintSN" material="Bls/BlsSc" vis="Bls:ScintillatorVis" shape="ShapeN"> + </detector> + @endverbatim + * 2.c) Pattern to create named assembly volumes + * Call: size_t buildVolumes(xml_h handle); + * In the example handle references <detector> + * + @verbatim + <volume name="lvBlsScintS1" vis="Bls:ScintillatorVis" assemply="1"> + <volume name="lvBlsScintS2" vis="Bls:ScintillatorVis" assemply="1"> + <volume name="lvBlsScintS3" vis="Bls:ScintillatorVis" assemply="1"> + .... + <volume name="lvBlsScintSN" vis="Bls:ScintillatorVis" assemply="1"> + </detector> + @endverbatim + * Alternative + @verbatim + <volume name="lvBlsScintS1" vis="Bls:ScintillatorVis"> + <assembly/> + </volume> + @endverbatim + * + * Volume placement patterns + * 3.c) Pattern to place daughter volumes into parent + * void VolumeBuilder::placeDaughters(DetElement parent, Volume vol, xml_h handle) + * In the example handle references <assembly> + * + @verbatim + <assembly name="lvBcmDownMount"> + <physvol logvol="lvBcmDownMountFront"> + <position/> + </physvol> + <physvol logvol="lvBcmDownMountBackSection"> + <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> + <rotation z="45*degree"/> + </physvol> + <physvol logvol="lvBcmDownMountBackSection"> + <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> + <rotation z="135*degree"/> + </physvol> + <physvol logvol="lvBcmDownMountBackSection"> + <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> + <rotation z="225*degree"/> + </physvol> + <physvol logvol="lvBcmDownMountBackSection"> + <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> + <rotation z="315*degree"/> + </physvol> + </assembly> + @endverbatim + * + * + * Please Note: + * It is the user's responsability to ensure all reated entities are + * properly registered to the detector description (and TGeo). + * No cleanup and referencing is done here! + * + * \author M.Frank + * \version 1.0 + * \date 12/10/2018 + */ + class VolumeBuilder { + public: + typedef ::dd4hep::DetElement DetElement; + typedef std::map<std::string,std::pair<Handle_t,Solid> > Shapes; + typedef std::map<std::string,std::pair<Handle_t,Volume> > Volumes; + typedef std::map<std::string,std::pair<Handle_t,Transform3D> > Transformations; + Detector& description; + Handle_t x_det; + DetElement detector; + SensitiveDetector sensitive; + DetectorBuildType buildType; + Shapes shapes; + Volumes volumes; + Transformations transformations; + std::set<std::string> shape_veto, vol_veto; + + /// Inhibit default constructor + VolumeBuilder() = delete; + /// Inhibit move constructor + VolumeBuilder(VolumeBuilder&& copy) = delete; + /// Inhibit copy constructor + VolumeBuilder(const VolumeBuilder& copy) = delete; + /// Initializing constructor + VolumeBuilder(Detector& dsc, + Handle_t x_parent, + SensitiveDetector sd=SensitiveDetector()); + /// Default constructor + ~VolumeBuilder() {} + /// Inhibit move assignment + VolumeBuilder& operator=(VolumeBuilder&& copy) = delete; + /// Inhibit copy assignment + VolumeBuilder& operator=(const VolumeBuilder& copy) = delete; + + /// Access element from shape cache by name. Invalid returns means 'veto'. Otherwise exception + Solid getShape(const std::string& nam) const; + /// Create a new shape from the information given in the xml handle + Solid makeShape(Handle_t handle); + /// Build all <shape/> identifiers in the passed parent xml element + size_t buildShapes(Handle_t handle); + /// Build all <volume/> identifiers in the passed parent xml element + size_t buildVolumes(Handle_t handle); + /// Build all <transformation/> identifiers in the passed parent xml element + size_t buildTransformations(Handle_t handle); + /// Build all <physvol/> identifiers as PlaceVolume daughters. Ignores structure + VolumeBuilder& placeDaughters(Volume vol, Handle_t handle); + /// Build all <physvol/> identifiers as PlaceVolume daughters. Also handles structure + VolumeBuilder& placeDaughters(DetElement parent, Volume vol, Handle_t handle); + /// Place the detector object into the mother volume returned by the Detector instance + PlacedVolume placeDetector(Volume vol); + PlacedVolume placeDetector(Volume vol, Handle_t handle); + }; + } /* End namespace tools */ + } /* End namespace xml */ +} /* End namespace dd4hep */ #endif /* dd4hep_XML_XMLUTILITIES_H */ diff --git a/DDCore/src/BuildType.cpp b/DDCore/src/BuildType.cpp index c7b40bb6401f4125c4d371ae5167dc0dee0e1c2a..05b3e4dfe35a603e375a04b8698e548fec91cc0a 100644 --- a/DDCore/src/BuildType.cpp +++ b/DDCore/src/BuildType.cpp @@ -48,3 +48,21 @@ dd4hep::DetectorBuildType dd4hep::buildType(const char* value) { dd4hep::DetectorBuildType dd4hep::buildType(const std::string& value) { return buildType(value.c_str()); } + +/// Check if a build type matches the current +bool dd4hep::buildMatch(const std::string& value, DetectorBuildType match) { + switch(match) { + case BUILD_RECO: + return value.find("REC") != std::string::npos; + case BUILD_ENVELOPE: + return value.find("ENV") != std::string::npos; + case BUILD_DISPLAY: + return value.find("DIS") != std::string::npos; + //case BUILD_SIMU: + //return value.find("SIM") != std::string::npos; + case BUILD_DEFAULT: + return true; + default: + return true; + } +} diff --git a/DDCore/src/DetectorData.cpp b/DDCore/src/DetectorData.cpp index 97ad6100fbbab2124b6efd859589840ad1812420..9dc4622b7872ccf88a5bd20cd911752c162889dd 100644 --- a/DDCore/src/DetectorData.cpp +++ b/DDCore/src/DetectorData.cpp @@ -204,7 +204,7 @@ void DetectorData::unpatchRootStreamer(TClass* cl) { /// Clear data content: releases all allocated resources void DetectorData::destroyData(bool destroy_mgr) { m_extensions.clear(); - m_motherVolumes.clear(); + m_detectorParents.clear(); destroyHandle(m_world); destroyHandle(m_field); @@ -240,7 +240,7 @@ void DetectorData::destroyData(bool destroy_mgr) { /// Clear data content: releases all allocated resources void DetectorData::clearData() { m_extensions.clear(false); - m_motherVolumes.clear(); + m_detectorParents.clear(); m_world.clear(); m_field.clear(); m_header.clear(); @@ -280,7 +280,7 @@ void DetectorData::adoptData(DetectorData& source, bool clr) { m_fields = source.m_fields; m_define = source.m_define; - m_motherVolumes = source.m_motherVolumes; + m_detectorParents = source.m_detectorParents; m_world = source.m_world; m_trackers = source.m_trackers; m_worldVol = source.m_worldVol; diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index 46102e0c1fca01c8ef4f0ad37c9e26edd27fb65d..9f2f64e4c0c8d3e96dc4fe51f0fd839fb5921796 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -16,6 +16,8 @@ #include "DD4hep/Printout.h" #include "DD4hep/GeoHandler.h" #include "DD4hep/DetectorHelper.h" +#include "DD4hep/DetectorTools.h" + #include "DD4hep/InstanceCount.h" #include "DD4hep/detail/ObjectsInterna.h" #include "DD4hep/detail/DetectorInterna.h" @@ -168,50 +170,70 @@ void* DetectorImp::userExtension(unsigned long long int key, bool alert) const { } /// Register new mother volume using the detector name. -void DetectorImp::declareMotherVolume(const string& detector_name, const Volume& vol) { +void DetectorImp::declareParent(const string& detector_name, const DetElement& parent) { if ( !detector_name.empty() ) { - if ( vol.isValid() ) { - auto i = m_motherVolumes.find(detector_name); - if (i == m_motherVolumes.end()) { - m_motherVolumes.insert(make_pair(detector_name,vol)); - return; + if ( parent.isValid() ) { + auto i = m_detectorParents.find(detector_name); + if (i == m_detectorParents.end()) { + Volume parent_volume = parent.placement().volume(); + if ( parent_volume.isValid() ) { + m_detectorParents.insert(make_pair(detector_name,parent)); + return; + } + except("DD4hep","+++ Failed to access valid parent volume of %s from %s", + detector_name.c_str(), parent.name()); } except("DD4hep", - "+++ A mother volume to the detector %s was already registered.", + "+++ A parent to the detector %s was already registered.", detector_name.c_str()); } except("DD4hep", - "+++ Attempt to register invalid mother volume for detector: %s [Invalid-Handle].", + "+++ Attempt to register invalid parent for detector: %s [Invalid-Handle].", detector_name.c_str()); } except("DD4hep", - "+++ Attempt to register mother volume to invalid detector [Invalid-detector-name]."); + "+++ Attempt to register parent to invalid detector [Invalid-detector-name]."); } /// Access mother volume by detector element Volume DetectorImp::pickMotherVolume(const DetElement& de) const { if ( de.isValid() ) { string de_name = de.name(); - auto i = m_motherVolumes.find(de_name); - if (i == m_motherVolumes.end()) { + auto i = m_detectorParents.find(de_name); + if (i == m_detectorParents.end()) { if ( m_worldVol.isValid() ) { return m_worldVol; } except("DD4hep", - "+++ The world volume is not (yet) valid. Are you correctly building detector %s?", + "+++ The world volume is not (yet) valid. " + "Are you correctly building detector %s?", de.name()); } if ( (*i).second.isValid() ) { - return (*i).second; + Volume vol = (*i).second.volume(); + if ( vol.isValid() ) { + return vol; + } } except("DD4hep", - "+++ The mother volume of %s is not valid. Are you correctly building detectors?", + "+++ The mother volume of %s is not valid. " + "Are you correctly building detectors?", de.name()); } except("DD4hep","Detector: Attempt access mother volume of invalid detector [Invalid-handle]"); return 0; } +/// Retrieve a subdetector element by it's name from the detector description +DetElement DetectorImp::detector(const std::string& name) const { + HandleMap::const_iterator i = m_detectors.find(name); + if (i != m_detectors.end()) { + return (*i).second; + } + DetElement de = detail::tools::findElement(*this,name); + return de; +} + Detector& DetectorImp::addDetector(const Handle<NamedObject>& ref_det) { DetElement det_element(ref_det); DetectorHelper helper(this); @@ -230,21 +252,33 @@ Detector& DetectorImp::addDetector(const Handle<NamedObject>& ref_det) { det_element->flag |= DetElement::Object::IS_TOP_LEVEL_DETECTOR; Volume volume = det_element.placement()->GetMotherVolume(); if ( volume == m_worldVol ) { - printout(DEBUG,"Detector","Added detector %s to the world instance.",det_element.name()); + printout(DEBUG,"DD4hep","+++ Detector: Added detector %s to the world instance.", + det_element.name()); m_world.add(det_element); return *this; } + /// Check if the parent is part of the compounds + auto ipar = m_detectorParents.find(det_element.name()); + if (ipar != m_detectorParents.end()) { + DetElement parent = (*ipar).second; + parent.add(det_element); + printout(DEBUG,"DD4hep","+++ Detector: Added detector %s to parent %s.", + det_element.name(), parent.name()); + return *this; + } + // The detector's placement must be one of the existing detectors - for(HandleMap::iterator i = m_detectors.begin(); i!=m_detectors.end(); ++i) { - DetElement parent((*i).second); + for(HandleMap::iterator idet = m_detectors.begin(); idet != m_detectors.end(); ++idet) { + DetElement parent((*idet).second); Volume vol = parent.placement().volume(); if ( vol == volume ) { - printout(INFO,"Detector","Added detector %s to the parent:%s.",det_element.name(),parent.name()); + printout(INFO,"DD4hep","+++ Detector: Added detector %s to the parent:%s.", + det_element.name(),parent.name()); parent.add(det_element); return *this; } } - except("DD4hep","Detector: The detector %s has no known parent.", det_element.name()); + except("DD4hep","+++ Detector: The detector %s has no known parent.", det_element.name()); throw runtime_error("Detector-Error"); // Never called.... } diff --git a/DDCore/src/DetectorImp.h b/DDCore/src/DetectorImp.h index af5fb999afbf909e16d6f657456cffb6b89e0587..4c32fe5525caff9f4e3031ff2be49222235a490e 100644 --- a/DDCore/src/DetectorImp.h +++ b/DDCore/src/DetectorImp.h @@ -110,7 +110,7 @@ namespace dd4hep { virtual Handle<NamedObject> getRefChild(const HandleMap& e, const std::string& name, bool throw_if_not = true) const; /// Register new mother volume using the detector name. - virtual void declareMotherVolume(const std::string& detector_name, const Volume& vol) override; + virtual void declareParent(const std::string& detector_name, const DetElement& parent) override; /// Access mother volume by detector element virtual Volume pickMotherVolume(const DetElement& sd) const override; @@ -212,9 +212,8 @@ namespace dd4hep { return getRefChild(m_readouts, name); } /// Retrieve a subdetector element by it's name from the detector description - virtual DetElement detector(const std::string& name) const override { - return getRefChild(m_detectors, name); - } + virtual DetElement detector(const std::string& name) const override; + //{ return getRefChild(m_detectors, name); } /// Retrieve a sensitive detector by it's name from the detector description virtual SensitiveDetector sensitiveDetector(const std::string& name) const override { return getRefChild(m_sensitive, name, false); diff --git a/DDCore/src/DetectorTools.cpp b/DDCore/src/DetectorTools.cpp index 9576dee8a3a3f692cbde5a6e9626ed76500c9502..18db92695b5833643e025406cd79bfddec0590c6 100644 --- a/DDCore/src/DetectorTools.cpp +++ b/DDCore/src/DetectorTools.cpp @@ -212,7 +212,7 @@ string detail::tools::elementPath(DetElement element) { } /// Find DetElement as child of the top level volume by it's absolute path -DetElement detail::tools::findElement(Detector& description, const string& path) { +DetElement detail::tools::findElement(const Detector& description, const string& path) { return findDaughterElement(description.world(),path); } diff --git a/DDCore/src/XML/Utilities.cpp b/DDCore/src/XML/Utilities.cpp index 20b0fcaac2ebbdbd2d2cf88ea59a57c94b02e90c..eccb27da2b21e2fe2a36587925443145ce203b94 100644 --- a/DDCore/src/XML/Utilities.cpp +++ b/DDCore/src/XML/Utilities.cpp @@ -18,12 +18,53 @@ #include "DD4hep/Plugins.h" #include "DD4hep/Detector.h" #include "DD4hep/DetFactoryHelper.h" +#include "Math/Polar2D.h" class TObject; using namespace std; using namespace dd4hep; using namespace dd4hep::detail; +using namespace dd4hep::xml::tools; + +/// Create layered transformation from xml information +Transform3D dd4hep::xml::createTransformation(xml::Element e) { + int cnt = 0; + Position pos; + RotationZYX rot; + Transform3D result; + for( xml_coll_t c(e,_U(star)); c; ++c ) { + string tag = c.tag(); + xml_dim_t x_elt = c; + if ( tag == "positionRPhiZ" ) { + Transform3D trafo = Transform3D(pos); + if ( cnt > 1 ) trafo *= Transform3D(rot); + result = trafo * result; + ROOT::Math::Polar2D<double> dim(x_elt.r(0.0), x_elt.phi(0.0)); + pos.SetXYZ(dim.X(), dim.Y(), x_elt.z(0.0)); + rot.SetComponents(0,0,0); + cnt = 1; + } + else if ( tag == "position" ) { + Transform3D trafo = Transform3D(pos); + if ( cnt > 1 ) trafo *= Transform3D(rot); + result = trafo * result; + pos.SetXYZ(x_elt.x(0), x_elt.y(0), x_elt.z(0)); + rot.SetComponents(0,0,0); + cnt = 1; + } + else if ( tag == "rotation" ) { + rot = RotationZYX(x_elt.z(0), x_elt.y(0), x_elt.x(0)); + cnt = 2; + } + } + if ( cnt > 0 ) { + Transform3D trafo = Transform3D(pos); + if ( cnt > 1 ) trafo *= Transform3D(rot); + result = trafo * result; + } + return result; +} /// Create a solid shape using the plugin mechanism from the attributes of the XML element Solid dd4hep::xml::createShape(Detector& description, @@ -41,6 +82,23 @@ Solid dd4hep::xml::createShape(Detector& description, return solid; } +/// Create a volume using the plugin mechanism from the attributes of the XML element +Volume dd4hep::xml::createVolume(Detector& description, xml::Element element) { + xml_dim_t e(element); + if ( e.hasAttr(_U(material)) ) { + xml_dim_t x_s = e.child(_U(shape)); + string typ = x_s.typeStr(); + Material mat = description.material(e.attr<string>(_U(material))); + Solid sol = createShape(description, typ, x_s); + Volume vol("volume", sol, mat); + if ( e.hasAttr(_U(name)) ) vol->SetName(e.attr<string>(_U(name)).c_str()); + vol.setAttributes(description,e.regionStr(),e.limitsStr(),e.visStr()); + return vol; + } + except("xml::createVolume","Failed to create volume. No material specified!"); + return Volume(); +} + Volume dd4hep::xml::createPlacedEnvelope( dd4hep::Detector& description, dd4hep::xml::Handle_t e, dd4hep::DetElement sdet) @@ -121,14 +179,310 @@ void dd4hep::xml::setDetectorTypeFlag( dd4hep::xml::Handle_t e, dd4hep::DetElem string det_name = x_det.nameStr(); try{ - xml_comp_t x_dettype = x_det.child( dd4hep::xml::Strng_t("type_flags") ) ; + xml_comp_t x_dettype = x_det.child( dd4hep::xml::Strng_t("type_flags") ) ; unsigned int typeFlag = x_dettype.type() ; printout(DEBUG,"Utilities","+++ setDetectorTypeFlags for detector :%s set to 0x%x", det_name.c_str(), typeFlag ) ; sdet.setTypeFlag( typeFlag ) ; - } catch(std::runtime_error){ + } + catch(std::runtime_error) { printout(INFO,"Utilities", "+++ setDetectorTypeFlags for detector :%s no xml element <type_flags/> found - nothing to set ", det_name.c_str() ) ; } } + +/// Initializing constructor +VolumeBuilder::VolumeBuilder(Detector& dsc, xml_h x_parent, SensitiveDetector sd) + : description(dsc), x_det(x_parent), sensitive(sd) +{ + if ( x_det ) { + xml_comp_t c(x_det); + string name = c.nameStr(); + detector = DetElement(name, c.id()); + } + buildType = description.buildType(); +} + +/// Access element from shape cache by name. Invalid returns means 'veto'. Otherwise exception +Solid VolumeBuilder::getShape(const string& nam) const { + auto is = shapes.find(nam); + if ( is == shapes.end() ) { + auto ib = shape_veto.find(nam); + if ( ib != shape_veto.end() ) { + // Veto'ed shape. Ignore it. + return Solid(); + } + except("VolumeBuilder","+++ Shape %s is not known to this builder unit. ",nam.c_str()); + } + Solid solid = (*is).second.second; + if ( !solid.isValid() ) { + except("VolumeBuilder","+++ Failed to access shape %s from the local cache.",nam.c_str()); + } + return solid; +} + +/// Create a new shape from the information given in the xml handle +Solid VolumeBuilder::makeShape(xml_h handle) { + xml_comp_t x = handle; + string nam; + xml_attr_t a = handle.attr_nothrow(_U(name)); + if ( a ) { + nam = handle.attr<string>(a); + auto is = shapes.find(nam); + if ( is == shapes.end() ) { + except("VolumeBuilder","+++ The named shape %s is already known to this builder unit. " + "Cannot be overridded.",nam.c_str()); + } + } + /// Was it veto'ed before ? + if ( !nam.empty() ) { + auto iv = shape_veto.find(nam); + if ( iv == shape_veto.end() ) { + return Solid(); + } + } + /// Check if this volume is part of the volumes to be built for this description type + a = handle.attr_nothrow(_U(build)); + if ( a ) { + string build = handle.attr<string>(a); + if ( !buildMatch(build,buildType) ) { + printout(INFO,"VolumeBuilder", + "+++ Shape %s does NOT match build requirements. [Ignored]",nam.c_str()); + if ( !nam.empty() ) shape_veto.insert(nam); + return Solid(); + } + } + /// Now we create the shape.... + string type = x.attr<string>(_U(type)); + Solid solid = xml::createShape(description, type, x); + if ( !solid.isValid() ) { + except("VolumeBuilder","+++ Failed to create shape %s of type: %s", + nam.c_str(), type.c_str()); + } + /// And register it if it is not anonymous + if ( !nam.empty() ) { + solid.setName(nam); + shapes.insert(make_pair(nam,make_pair(handle,solid))); + } + return solid; +} + +/// Build all <shape/> identifiers in the passed parent xml element +size_t VolumeBuilder::buildShapes(xml_h handle) { + size_t len = shapes.size(); + for( xml_coll_t c(handle,_U(shape)); c; ++c ) { + xml_elt_t x = c; + string nam = x.attr<string>(_U(name)); + auto is = shapes.find(nam); + if ( is == shapes.end() ) { + /// Check if this volume is part of the volumes to be built for this description type + xml_attr_t x_build = c.attr_nothrow(_U(build)); + if ( x_build ) { + string build = c.attr<string>(x_build); + if ( !buildMatch(build,buildType) ) { + printout(INFO,"VolumeBuilder", + "+++ Shape %s does NOT match build requirements. [Ignored]",nam.c_str()); + shape_veto.insert(nam); + continue; + } + } + string type = x.attr<string>(_U(type)); + Solid solid = xml::createShape(description, type,c); + if ( solid.isValid() ) { + except("VolumeBuilder","+++ Failed to create shape %s of type: %s", + nam.c_str(), type.c_str()); + } + shapes.insert(make_pair(nam,make_pair(c,solid))); + continue; + } + except("VolumeBuilder","+++ Shape %s is already known to this builder unit. " + "Cannot be overridded.",nam.c_str()); + } + return shapes.size()-len; +} + +/// Build all <volume/> identifiers in the passed parent xml element +size_t VolumeBuilder::buildVolumes(xml_h handle) { + size_t len = volumes.size(); + xml_elt_t x_comp(0); + for( xml_coll_t c(handle,_U(volume)); c; ++c ) { + Solid solid; + xml_comp_t x = c; + string nam = x.attr<string>(_U(name)); + xml_attr_t attr = c.attr_nothrow(_U(build)); + /// Check if this volume is part of the volumes to be built for this description type + if ( attr ) { + string build = c.attr<string>(attr); + if ( !buildMatch(build,buildType) ) { + printout(INFO,"VolumeBuilder", + "+++ Volume %s does NOT match build requirements. [Ignored]",nam.c_str()); + continue; + } + } + /// Check if the volume has a shape attribute --> shape reference + if ( (attr=c.attr_nothrow(_U(shape))) ) { + string ref = c.attr<string>(attr); + if ( !(solid=getShape(ref)).isValid() ) continue; + } + /// Else use anonymous shape embedded in volume + else if ( (x_comp=x.child(_U(shape),false)) ) { + if ( !(solid=makeShape(x_comp)).isValid() ) continue; + } + + /// We have a real volume here with a concrete shape: + if ( solid.isValid() ) { + Material mat = description.material(x.attr<string>(_U(material))); + Volume vol(nam, solid, mat); + placeDaughters(detector, vol, x); + vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr()); + volumes.insert(make_pair(nam,make_pair(c,vol))); + /// Check if the volume is sensitive + if ( c.attr_nothrow(_U(sensitive)) ) { + vol.setSensitiveDetector(sensitive); + } + continue; + } + bool is_assembly = true; + is_assembly |= x.child(_U(assembly),false) != 0; + is_assembly |= c.attr_nothrow(_U(assembly)) != 0; + if ( is_assembly ) { + Assembly vol(nam); + placeDaughters(detector, vol, x); + vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr()); + volumes.insert(make_pair(nam,make_pair(c,vol))); + continue; + } + except("VolumeBuilder","+++ Failed to create volume %s. " + "It is neither Volume nor assembly....", nam.c_str()); + } + return volumes.size()-len; +} + +/// Build all <physvol/> identifiers as PlaceVolume daughters. Ignores structure +VolumeBuilder& VolumeBuilder::placeDaughters(Volume vol, xml_h handle) { + for( xml_coll_t c(handle,_U(physvol)); c; ++c ) { + xml_comp_t x_comp = c; + string nam = x_comp.attr<string>(_U(logvol)); + if ( vol_veto.find(nam) == vol_veto.end() ) { + auto iv = volumes.find(nam); + if ( iv == volumes.end() ) { + except("VolumeBuilder","+++ Failed to locate volume %s. [typo somewhere in the XML?]", + nam.c_str()); + } + xml_attr_t attr = c.attr_nothrow(_U(transformation)); + if ( attr ) { + string tr_nam = c.attr<string>(attr); + auto it = transformations.find(tr_nam); + if ( it == transformations.end() ) { + except("VolumeBuilder", + "+++ Failed to locate name transformation %s. " + "[typo somewhere in the XML?]", + nam.c_str()); + } + const Transform3D& tr = (*it).second.second; + vol.placeVolume((*iv).second.second, tr); + } + else { + Transform3D tr = xml::createTransformation(c); + vol.placeVolume((*iv).second.second, tr); + } + } + } + return *this; +} + +/// Build all <physvol/> identifiers as PlaceVolume daughters. Also handles structure +VolumeBuilder& VolumeBuilder::placeDaughters(DetElement parent, Volume vol, xml_h handle) +{ + for( xml_coll_t c(handle,_U(physvol)); c; ++c ) { + xml_comp_t x_comp = c; + string nam = x_comp.attr<string>(_U(logvol)); + if ( vol_veto.find(nam) == vol_veto.end() ) { + auto iv = volumes.find(nam); + if ( iv == volumes.end() ) { + except("VolumeBuilder", + "+++ Failed to locate volume %s. [typo somewhere in the XML?]", + nam.c_str()); + } + PlacedVolume pv; + xml_attr_t attr = c.attr_nothrow(_U(transformation)); + if ( attr ) { + string tr_nam = c.attr<string>(attr); + auto it = transformations.find(tr_nam); + if ( it == transformations.end() ) { + except("VolumeBuilder", + "+++ Failed to locate name transformation %s. " + "[typo somewhere in the XML?]", + nam.c_str()); + } + const Transform3D& tr = (*it).second.second; + pv = vol.placeVolume((*iv).second.second, tr); + } + else { + Transform3D tr = xml::createTransformation(c); + pv = vol.placeVolume((*iv).second.second, tr); + } + if ( (attr=c.attr_nothrow(_U(element))) ) { + int id = parent.id(); + string elt = c.attr<string>(attr); + attr = c.attr_nothrow(_U(id)); + if ( attr ) { + id = c.attr<int>(attr); + elt += c.attr<string>(attr); + } + DetElement de(parent,elt,id); + de.setPlacement(pv); + } + } + } + return *this; +} + +/// Build all <transformation/> identifiers in the passed parent xml element +size_t VolumeBuilder::buildTransformations(Handle_t handle) { + size_t len = transformations.size(); + for( xml_coll_t c(handle,_U(transformation)); c; ++c ) { + string nam = xml_comp_t(c).nameStr(); + transformations.insert(make_pair(nam,make_pair(c,xml::createTransformation(c)))); + } + return transformations.size() - len; +} + +/// Place the detector object into the mother volume returned by the Detector instance +PlacedVolume VolumeBuilder::placeDetector(Volume vol) { + return placeDetector(vol, x_det); +} + +/// Place the detector object into the mother volume returned by the Detector instance +PlacedVolume VolumeBuilder::placeDetector(Volume vol, xml_h handle) { + xml_comp_t x = handle; + xml_dim_t x_pos = x_det.child(_U(position),false); + xml_dim_t x_rot = x_det.child(_U(rotation),false); + xml_dim_t x_tr = x_det.child(_U(transformation),false); + Volume mother = description.pickMotherVolume(detector); + PlacedVolume pv; + + if ( x_tr ) { + Transform3D tr = createTransformation(x_tr); + pv = mother.placeVolume(vol, tr); + } + else if ( x_pos && x_rot ) { + Transform3D tr = createTransformation(x_det); + pv = mother.placeVolume(vol, tr); + } + else if ( x_pos ) { + pv = mother.placeVolume(vol, Position(x_pos.x(0),x_pos.y(0),x_pos.z(0))); + } + else { + pv = mother.placeVolume(vol); + } + vol.setVisAttributes(description, x.visStr()); + vol.setLimitSet(description, x.limitsStr()); + vol.setRegion(description, x.regionStr()); + if ( detector.isValid() ) { + detector.setPlacement(pv); + } + return pv; +} + #endif diff --git a/DDCore/src/gdml/GdmlPlugins.cpp b/DDCore/src/gdml/GdmlPlugins.cpp index 405e3922c866bfc6e3d437c34d7d88d23efb38b8..22a3c166fe521b9f11eb794c0e9bdc2cd35ed3c2 100644 --- a/DDCore/src/gdml/GdmlPlugins.cpp +++ b/DDCore/src/gdml/GdmlPlugins.cpp @@ -43,25 +43,30 @@ using namespace dd4hep; static long gdml_parse(Detector& description, int argc, char** argv) { if ( argc > 0 ) { string input, path; + bool wrld = false; for(int i = 0; i < argc && argv[i]; ++i) { if ( 0 == ::strncmp("-input",argv[i],2) ) input = argv[++i]; - if ( 0 == ::strncmp("-path", argv[i],2) ) + else if ( 0 == ::strncmp("-path", argv[i],2) ) path = argv[++i]; + else if ( 0 == ::strncmp("-world", argv[i],2) ) + wrld = true; } - if ( input.empty() || path.empty() ) { + if ( input.empty() || (path.empty() && !wrld) ) { cout << - "Usage: -plugin <name> -arg [-arg] \n" - " name: factory name DD4hep_ROOTGDMLParse \n" - " -input <string> Input file name. \n" - " -path <string> Path to parent detector element to attach \n" - " top volume from GDML file. \n" + "Usage: -plugin <name> -arg [-arg] \n" + " name: factory name DD4hep_ROOTGDMLParse \n" + " -input <string> Input file name. \n" + " -path <string> Path to parent detector element to attach \n" + " top volume from GDML file. \n" + " -world <string> Name of the world object if to be imported from gdml.\n" + " Note: -path and -world options are exclusive. \n" "\tArguments given: " << arguments(argc,argv) << endl << flush; ::exit(EINVAL); } printout(INFO,"ROOTGDMLParse","+++ Read geometry from GDML file file:%s",input.c_str()); vector<string> elements = detail::tools::pathElements(path); - if ( !elements.empty() ) { + if ( !wrld && !elements.empty() ) { DetElement world = description.world(); DetElement parent = world, child; for(size_t i=0; i < elements.size(); ++i) { @@ -100,6 +105,23 @@ static long gdml_parse(Detector& description, int argc, char** argv) { else parent.add(child); } } + else if ( wrld ) { + TGDMLParse parser; + TUri uri(input.c_str()); + input = uri.GetRelativePart(); + Volume vol = parser.GDMLReadFile(input.c_str()); + if ( vol.isValid() ) { + vol.import(); // We require the extensions in dd4hep. + description.manager().SetTopVolume(vol.ptr()); + description.init(); + description.endDocument(); + printout(INFO,"ROOTGDMLParse","+++ Attach GDML volume %s", vol.name()); + return 1; + } + except("ROOTGDMLParse","+++ Failed to parse GDML file:%s for path:%s", + input.c_str(),path.c_str()); + } + except("ROOTGDMLParse","+++ Invalid DetElement path given: %s", path.c_str()); } except("ROOTGDMLParse","+++ No input file name given."); @@ -118,34 +140,89 @@ DECLARE_APPLY(DD4hep_ROOTGDMLParse,gdml_parse) */ static long gdml_extract(Detector& description, int argc, char** argv) { if ( argc > 0 ) { + bool detector = true, volpath = false, volname = false; string output, path; for(int i = 0; i < argc && argv[i]; ++i) { if ( 0 == ::strncmp("-output",argv[i],2) ) output = argv[++i]; - if ( 0 == ::strncmp("-path", argv[i],2) ) + else if ( 0 == ::strncmp("-path", argv[i],2) ) path = argv[++i]; + else if ( 0 == ::strncmp("-volpath", argv[i],7) ) + volpath = true, volname = false, detector = false; + else if ( 0 == ::strncmp("-volname", argv[i],7) ) + volpath = false, volname = true, detector = false; + else if ( 0 == ::strncmp("-detector", argv[i],8) ) + volpath = false, volname = false, detector = true; } if ( output.empty() || path.empty() ) { cout << "Usage: -plugin <name> -arg [-arg] \n" " name: factory name DD4hep_ROOTGDMLExtract \n" " -output <string> Output file name. \n" - " -path <string> Path to parent detector element to attach \n" - " top volume from GDML file. \n" + " -path <string> Path to parent detector element to extract \n" + " top volume to GDML file. \n" + " -detector Indicate that the path is a DetElement path \n" + " -volpath Indicate that the path is a volume path \n" + " -volname Indicate that the path is a volume name prefix \n" "\tArguments given: " << arguments(argc,argv) << endl << flush; ::exit(EINVAL); } - printout(INFO,"ROOTGDMLExtract","+++ Write geometry %s to GDML file file:%s", - path.c_str(), output.c_str()); - DetElement detector = detail::tools::findElement(description,path); - if ( detector.isValid() ) { - TGDMLWrite extract; - TUri uri(output.c_str()); - Volume volume = detector.volume(); - extract.WriteGDMLfile(&description.manager(), volume.ptr(), uri.GetRelativePart()); - return 1; + if ( detector ) { + printout(INFO,"ROOTGDMLExtract","+++ Write geometry %s to GDML file file:%s", + path.c_str(), output.c_str()); + DetElement de = detail::tools::findElement(description,path); + if ( de.isValid() ) { + TGDMLWrite extract; + TUri uri(output.c_str()); + Volume vol = de.volume(); + extract.WriteGDMLfile(&description.manager(), vol.ptr(), uri.GetRelativePart()); + return 1; + } + except("ROOTGDMLExtract","+++ Invalid DetElement path given: %s", path.c_str()); + } + else { + struct Actor { + bool _volpath; + const string& _path; + TGeoVolume* _volume = 0; + Actor(const string& p, bool vp) : _volpath(vp), _path(p) {} + void scan(TGeoNode* n, const std::string& p="") { + string nam; + if ( _volpath ) { + nam = p + '/'; + nam += n->GetName(); + if ( _volpath && nam.find(_path) == 0 ) + _volume = n->GetVolume(); + for (Int_t idau = 0, ndau = n->GetNdaughters(); _volume == 0 && idau < ndau; ++idau) + scan(n->GetDaughter(idau), p); + return; + } + nam = n->GetName(); + if ( nam.find(_path) == 0 ) { + _volume = n->GetVolume(); + printout(ALWAYS,"Check","+++ Found required volume: %s",_path.c_str()); + printout(ALWAYS,"Check","+++ -> %s",nam.c_str()); + return; + } + for (Int_t idau = 0, ndau = n->GetNdaughters(); _volume == 0 && idau < ndau; ++idau) + scan(n->GetDaughter(idau),nam); + } + }; + Volume top = description.worldVolume(); + TObjArray* ents = top->GetNodes(); + Actor a(path, volpath ? true : volname ? false : true); + for (Int_t i = 0, n = ents->GetEntries(); i < n && a._volume == 0; ++i) { + TGeoNode* node = (TGeoNode*)ents->At(i); + a.scan(node, node->GetName()); + } + if ( a._volume ) { + TGDMLWrite extract; + TUri uri(output.c_str()); + extract.WriteGDMLfile(&description.manager(), a._volume, uri.GetRelativePart()); + return 1; + } + except("ROOTGDMLExtract","+++ Invalid volume path/name given: %s", path.c_str()); } - except("ROOTGDMLExtract","+++ Invalid DetElement path given: %s", path.c_str()); } except("ROOTGDMLExtract","+++ No output file name given."); return 0; diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index b4f862a1a24e5c7e0f43a51cf10f782ca9c81216..1c1682bb6517c67152be84c604c1ab66d47d9656 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -992,22 +992,23 @@ template <> void Converter<DetElement>::operator()(xml_h element) const { if (ign_typs && strstr(ign_typs, type_match.c_str())) return; try { + string par_name; xml_attr_t attr_par = element.attr_nothrow(_U(parent)); - if (attr_par) { + xml_elt_t elt_par(0); + if (attr_par) + par_name = element.attr<string>(attr_par); + else if ( (elt_par=element.child(_U(parent),false)) ) + par_name = elt_par.attr<string>(_U(name)); + if ( !par_name.empty() ) { // We have here a nested detector. If the mother volume is not yet registered // it must be done here, so that the detector constructor gets the correct answer from // the call to Detector::pickMotherVolume(DetElement). - string par_name = element.attr<string>(attr_par); - DetElement parent_detector = description.detector(par_name); - if ( !parent_detector.isValid() ) { + if ( par_name[0] == '$' ) par_name = xml::getEnviron(par_name); + DetElement parent = description.detector(par_name); + if ( !parent.isValid() ) { except("Compact","Failed to access valid parent detector of %s",name.c_str()); } - Volume parent_volume = parent_detector.placement().volume(); - if ( !parent_volume.isValid() ) { - except("Compact","Failed to access valid parent volume of %s from %s", - name.c_str(), par_name.c_str()); - } - description.declareMotherVolume(name, parent_volume); + description.declareParent(name, parent); } xml_attr_t attr_ro = element.attr_nothrow(_U(readout)); SensitiveDetector sd; @@ -1203,7 +1204,7 @@ template <> void Converter<Compact>::operator()(xml_h element) const { if (element.hasChild(_U(debug))) (Converter<Debug>(description))(xml_h(compact.child(_U(debug)))); - + if ( steer_geometry ) { xml_elt_t steer = compact.child(_U(geometry)); if ( steer.hasAttr(_U(open)) ) open_geometry = steer.attr<bool>(_U(open)); @@ -1257,9 +1258,9 @@ template <> void Converter<Compact>::operator()(xml_h element) const { xml_coll_t(compact, _U(sensitive_detectors)).for_each(_U(sd), Converter<SensitiveDetector>(description)); xml_coll_t(compact, _U(parallelworld_volume)).for_each(Converter<Parallelworld_Volume>(description)); - ::snprintf(text, sizeof(text), "%u", xml_h(element).checksum(0)); - description.addConstant(Constant("compact_checksum", text)); if ( --num_calls == 0 && close_geometry ) { + ::snprintf(text, sizeof(text), "%u", xml_h(element).checksum(0)); + description.addConstant(Constant("compact_checksum", text)); description.endDocument(); } xml_coll_t(compact, _U(plugins)).for_each(_U(plugin), Converter<Plugin> (description)); diff --git a/DDCore/src/plugins/JsonProcessor.cpp b/DDCore/src/plugins/JsonProcessor.cpp index d6e7e3f7d1eef891d106cc96589fd086a4310b64..736e14c401be82bc275cd0df9f101c3688c12341 100644 --- a/DDCore/src/plugins/JsonProcessor.cpp +++ b/DDCore/src/plugins/JsonProcessor.cpp @@ -80,12 +80,7 @@ template <> void Converter<detector>::operator()(json_h element) const { if ( !parent_detector.isValid() ) { except("Compact","Failed to access valid parent detector of %s",name.c_str()); } - Volume parent_volume = parent_detector.placement().volume(); - if ( !parent_volume.isValid() ) { - except("Compact","Failed to access valid parent volume of %s from %s", - name.c_str(), par_name.c_str()); - } - description.declareMotherVolume(name, parent_volume); + description.declareParent(name, parent_detector); } json_attr_t attr_ro = element.attr_nothrow(_U(readout)); SensitiveDetector sd; diff --git a/DDCore/src/plugins/ShapePlugins.cpp b/DDCore/src/plugins/ShapePlugins.cpp index 2ecbf2f04614ab0f105d31aa6f433c686008d1cc..d99b2b0c61ab0e285575b7ad5804ad5a09ab23ae 100644 --- a/DDCore/src/plugins/ShapePlugins.cpp +++ b/DDCore/src/plugins/ShapePlugins.cpp @@ -14,6 +14,7 @@ // Framework include files #include "DD4hep/DetFactoryHelper.h" #include "DD4hep/Printout.h" +#include "XML/Utilities.h" #include "TGeoShapeAssembly.h" #include "TSystem.h" #include "TClass.h" @@ -27,13 +28,17 @@ using namespace dd4hep::detail; static Handle<TObject> create_Assembly(Detector&, xml_h e) { xml_dim_t dim(e); - return Handle<TObject>(new TGeoShapeAssembly()); + Solid solid = Handle<TNamed>(new TGeoShapeAssembly()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Assembly__shape_constructor,create_Assembly) static Handle<TObject> create_Box(Detector&, xml_h e) { xml_dim_t dim(e); - return Box(dim.dx(),dim.dy(),dim.dz()); + Solid solid = Box(dim.dx(),dim.dy(),dim.dz()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Box__shape_constructor,create_Box) @@ -43,7 +48,9 @@ static Handle<TObject> create_HalfSpace(Detector&, xml_h e) { xml_dim_t normal = e.child(_U(normal)); double p[3] = { point.x(), point.y(), point.z()}; double n[3] = { normal.x(), normal.y(), normal.z()}; - return HalfSpace(p, n); + Solid solid = HalfSpace(p, n); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(HalfSpace__shape_constructor,create_HalfSpace) @@ -61,106 +68,138 @@ static Handle<TObject> create_Polycone(Detector&, xml_h element) { if ( num < 2 ) { throw runtime_error("PolyCone Shape> Not enough Z planes. minimum is 2!"); } - return Polycone(start,deltaphi,rmin,rmax,z); + Solid solid = Polycone(start,deltaphi,rmin,rmax,z); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Polycone__shape_constructor,create_Polycone) static Handle<TObject> create_ConeSegment(Detector&, xml_h element) { xml_dim_t e(element); - return ConeSegment(e.dz(),e.rmin1(0.0),e.rmax1(),e.rmin2(0.0),e.rmax2(),e.phi1(0.0),e.phi2(2*M_PI)); + Solid solid = ConeSegment(e.dz(),e.rmin1(0.0),e.rmax1(),e.rmin2(0.0),e.rmax2(),e.phi1(0.0),e.phi2(2*M_PI)); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(ConeSegment__shape_constructor,create_ConeSegment) static Handle<TObject> create_Tube(Detector&, xml_h element) { xml_dim_t e(element); - return Tube(e.rmin(0.0),e.rmax(),e.dz(0.0),e.startphi(0.0),e.deltaphi(2*M_PI)); + Solid solid = Tube(e.rmin(0.0),e.rmax(),e.dz(0.0),e.startphi(0.0),e.deltaphi(2*M_PI)); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Tube__shape_constructor,create_Tube) static Handle<TObject> create_CutTube(Detector&, xml_h element) { xml_dim_t e(element); - return CutTube(e.rmin(0.0),e.rmax(),e.dz(), - e.attr<double>(_U(phi1)), - e.attr<double>(_U(phi2)), - e.attr<double>(_U(lx)), - e.attr<double>(_U(ly)), - e.attr<double>(_U(lz)), - e.attr<double>(_U(tx)), - e.attr<double>(_U(ty)), - e.attr<double>(_U(tz))); + Solid solid = CutTube(e.rmin(0.0),e.rmax(),e.dz(), + e.attr<double>(_U(phi1)), + e.attr<double>(_U(phi2)), + e.attr<double>(_U(lx)), + e.attr<double>(_U(ly)), + e.attr<double>(_U(lz)), + e.attr<double>(_U(tx)), + e.attr<double>(_U(ty)), + e.attr<double>(_U(tz))); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(CutTube__shape_constructor,create_CutTube) static Handle<TObject> create_EllipticalTube(Detector&, xml_h element) { xml_dim_t e(element); - return EllipticalTube(e.a(),e.b(),e.dz()); + Solid solid = EllipticalTube(e.a(),e.b(),e.dz()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(EllipticalTube__shape_constructor,create_EllipticalTube) static Handle<TObject> create_TruncatedTube(Detector&, xml_h element) { xml_dim_t e(element); double sp = e.startphi(0.0), dp = e.deltaphi(2*M_PI); - return TruncatedTube(e.zhalf(), e.rmin(0.0), e.rmax(), sp, dp, - e.attr<double>(xml_tag_t("cutAtStart")), - e.attr<double>(xml_tag_t("cutAtDelta")), - e.attr<bool>(xml_tag_t("cutInside"))); + Solid solid = TruncatedTube(e.zhalf(), e.rmin(0.0), e.rmax(), sp, dp, + e.attr<double>(xml_tag_t("cutAtStart")), + e.attr<double>(xml_tag_t("cutAtDelta")), + e.attr<bool>(xml_tag_t("cutInside"))); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(TruncatedTube__shape_constructor,create_TruncatedTube) static Handle<TObject> create_Cone(Detector&, xml_h element) { xml_dim_t e(element); double rmi1 = e.rmin1(0.0), rma1 = e.rmax1(); - return Cone(e.z(0.0),rmi1,rma1,e.rmin2(rmi1),e.rmax2(rma1)); + Solid solid = Cone(e.z(0.0),rmi1,rma1,e.rmin2(rmi1),e.rmax2(rma1)); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Cone__shape_constructor,create_Cone) static Handle<TObject> create_Trap(Detector&, xml_h element) { xml_dim_t e(element); + Solid solid; if ( e.hasAttr(_U(dz)) ) - return Trap(e.dz(),e.dy(),e.dx(),_toDouble(_Unicode(pLTX))); - return Trap(e.z(0.0),e.theta(),e.phi(0),e.y1(),e.x1(),e.x2(),e.alpha1(),e.y2(),e.x3(),e.x4(),e.alpha2()); + solid = Trap(e.dz(),e.dy(),e.dx(),_toDouble(_Unicode(pLTX))); + else + solid = Trap(e.z(0.0),e.theta(0),e.phi(0),e.y1(),e.x1(),e.x2(),e.alpha1(0),e.y2(),e.x3(),e.x4(),e.alpha2(0)); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Trap__shape_constructor,create_Trap) static Handle<TObject> create_PseudoTrap(Detector&, xml_h element) { xml_dim_t e(element); - return PseudoTrap(e.x1(),e.x2(),e.y1(),e.y2(),e.z(),e.radius(),e.attr<bool>(xml_tag_t("minusZ"))); + Solid solid = PseudoTrap(e.x1(),e.x2(),e.y1(),e.y2(),e.z(),e.radius(),e.attr<bool>(xml_tag_t("minusZ"))); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(PseudoTrap__shape_constructor,create_PseudoTrap) static Handle<TObject> create_Trapezoid(Detector&, xml_h element) { xml_dim_t e(element); - return Trapezoid(e.x1(),e.x2(),e.y1(),e.y2(),e.z(0.0)); + Solid solid = Trapezoid(e.x1(),e.x2(),e.y1(),e.y2(),e.z(0.0)); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Trapezoid__shape_constructor,create_Trapezoid) static Handle<TObject> create_Torus(Detector&, xml_h element) { xml_dim_t e(element); - return Torus(e.r(),e.rmin(),e.rmax(),e.phi(M_PI),e.deltaphi(2.*M_PI)); + Solid solid = Torus(e.r(),e.rmin(),e.rmax(),e.phi(M_PI),e.deltaphi(2.*M_PI)); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Torus__shape_constructor,create_Torus) static Handle<TObject> create_Sphere(Detector&, xml_h element) { xml_dim_t e(element); - return Sphere(e.rmin(),e.rmax(),e.theta(0e0),e.deltatheta(M_PI),e.phi(0e0),e.deltaphi(2.*M_PI)); + Solid solid = Sphere(e.rmin(),e.rmax(),e.theta(0e0),e.deltatheta(M_PI),e.phi(0e0),e.deltaphi(2.*M_PI)); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Sphere__shape_constructor,create_Sphere) static Handle<TObject> create_Paraboloid(Detector&, xml_h element) { xml_dim_t e(element); - return Paraboloid(e.rmin(0.0),e.rmax(),e.dz()); + Solid solid = Paraboloid(e.rmin(0.0),e.rmax(),e.dz()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Paraboloid__shape_constructor,create_Paraboloid) static Handle<TObject> create_Hyperboloid(Detector&, xml_h element) { xml_dim_t e(element); - return Hyperboloid(e.rmin(), e.inner_stereo(), e.rmax(), e.outer_stereo(), e.dz()); + Solid solid = Hyperboloid(e.rmin(), e.inner_stereo(), e.rmax(), e.outer_stereo(), e.dz()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Hyperboloid__shape_constructor,create_Hyperboloid) static Handle<TObject> create_PolyhedraRegular(Detector&, xml_h element) { xml_dim_t e(element); - return PolyhedraRegular(e.numsides(),e.rmin(),e.rmax(),e.dz()); + Solid solid = PolyhedraRegular(e.numsides(),e.rmin(),e.rmax(),e.dz()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(PolyhedraRegular__shape_constructor,create_PolyhedraRegular) @@ -173,7 +212,9 @@ static Handle<TObject> create_Polyhedra(Detector&, xml_h element) { rmax.push_back(plane.rmax()); z.push_back(plane.z()); } - return Polyhedra(e.numsides(),e.startphi(),e.deltaphi(),z,rmin,rmax); + Solid solid = Polyhedra(e.numsides(),e.startphi(),e.deltaphi(),z,rmin,rmax); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(Polyhedra__shape_constructor,create_Polyhedra) @@ -192,7 +233,9 @@ static Handle<TObject> create_ExtrudedPolygon(Detector&, xml_h element) { pt_x.push_back(point.attr<double>(_U(x))); pt_y.push_back(point.attr<double>(_U(y))); } - return ExtrudedPolygon(pt_x, pt_y, sec_z, sec_x, sec_y, sec_scale); + Solid solid = ExtrudedPolygon(pt_x, pt_y, sec_z, sec_x, sec_y, sec_scale); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(ExtrudedPolygon__shape_constructor,create_ExtrudedPolygon) @@ -206,12 +249,13 @@ static Handle<TObject> create_EightPointSolid(Detector&, xml_h element) { v[num][0] = vtx.x(); v[num][1] = vtx.y(); } - return EightPointSolid(e.dz(),&v[0][0]); + Solid solid = EightPointSolid(e.dz(),&v[0][0]); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(EightPointSolid__shape_constructor,create_EightPointSolid) - /** Plugin function for creating a boolean solid from an xml element <shape type=\"BooleanShape\"/>. * Expects exactly two child elements <shape/> and a string attribute 'operation', which is one of * 'subtraction', 'union' or 'intersection'. Optionally <position/> and/or <rotation/> can be specified. @@ -235,15 +279,18 @@ static Handle<TObject> create_BooleanShape(Detector&, xml_h element) { Solid solid2( xml_comp_t( x_shape2 ).createShape()) ; - std::string op = e.attr<std::string>( dd4hep::xml::Strng_t("operation") ) ; + std::string op = e.attr<std::string>(_U(operation)) ; std::transform( op.begin(), op.end(), op.begin(), ::tolower); Solid resultSolid ; - bool useRot(false), usePos(false) ; + bool useRot(false), usePos(false), useTrans(false); Position pos ; RotationZYX rot ; + if( e.hasChild( _U(transformation) ) ) { + useTrans = true ; + } if( e.hasChild( _U(position) ) ) { usePos = true ; xml_comp_t x_pos = e.position(); @@ -256,44 +303,56 @@ static Handle<TObject> create_BooleanShape(Detector&, xml_h element) { } if( op == "subtraction" ) { - - if( useRot && usePos ) - resultSolid = SubtractionSolid( solid1 , solid2 , Transform3D( rot, pos ) ); - else if( useRot) - resultSolid = SubtractionSolid( solid1 , solid2 , rot ); + if ( useTrans ) { + Transform3D tr = xml::createTransformation(e.child(_U(transformation))); + resultSolid = SubtractionSolid(solid1, solid2, tr); + } + else if( useRot && usePos ) { + resultSolid = SubtractionSolid(solid1, solid2, Transform3D(rot, pos)); + } + else if( useRot ) + resultSolid = SubtractionSolid(solid1, solid2, rot); else if( usePos) - resultSolid = SubtractionSolid( solid1 , solid2 , pos ); + resultSolid = SubtractionSolid(solid1, solid2, pos); else - resultSolid = SubtractionSolid( solid1 , solid2 ) ; + resultSolid = SubtractionSolid(solid1, solid2); } else if( op == "union" ) { - - if( useRot && usePos ) - resultSolid = UnionSolid( solid1 , solid2 , Transform3D( rot, pos ) ); + if ( useTrans ) { + Transform3D tr = xml::createTransformation(e.child(_U(transformation))); + resultSolid = UnionSolid(solid1, solid2, tr); + } + else if( useRot && usePos ) + resultSolid = UnionSolid(solid1, solid2, Transform3D(rot, pos)); else if( useRot) - resultSolid = UnionSolid( solid1 , solid2 , rot ); - else if( usePos) - resultSolid = UnionSolid( solid1 , solid2 , pos ); + resultSolid = UnionSolid(solid1, solid2, rot); + else if( usePos) + resultSolid = UnionSolid(solid1, solid2, pos); else - resultSolid = UnionSolid( solid1 , solid2 ) ; + resultSolid = UnionSolid(solid1, solid2); } else if( op == "intersection" ) { - - if( useRot && usePos ) - resultSolid = IntersectionSolid( solid1 , solid2 , Transform3D( rot, pos ) ); + if ( useTrans ) { + Transform3D tr = xml::createTransformation(e.child(_U(transformation))); + resultSolid = IntersectionSolid(solid1, solid2, tr); + } + else if( useRot && usePos ) + resultSolid = IntersectionSolid(solid1, solid2, Transform3D(rot, pos)); else if( useRot) - resultSolid = IntersectionSolid( solid1 , solid2 , rot ); + resultSolid = IntersectionSolid(solid1, solid2, rot); else if( usePos) - resultSolid = IntersectionSolid( solid1 , solid2 , pos ); + resultSolid = IntersectionSolid(solid1, solid2, pos); else - resultSolid = IntersectionSolid( solid1 , solid2 ) ; + resultSolid = IntersectionSolid(solid1, solid2) ; - } else{ + } else { throw std::runtime_error(std::string(" create_BooleanShape - unknown operation given: ") + op + std::string(" - needs to be one of 'subtraction','union' or 'intersection' ") ) ; } - return resultSolid ; + Solid solid = resultSolid ; + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; } DECLARE_XML_SHAPE(BooleanShape__shape_constructor,create_BooleanShape) @@ -314,15 +373,15 @@ static Ref_t create_shape(Detector& description, xml_h e, Ref_t /* sens */) { Volume volume (name+_toString(count,"_vol_%d"),solid, description.air()); if ( pos.ptr() && rot.ptr() ) { - Transform3D trafo(Rotation3D(RotationZYX(rot.z(),rot.y(),rot.x())), - Position(pos.x(),pos.y(),pos.z())); + Transform3D trafo(Rotation3D(RotationZYX(rot.z(0),rot.y(0),rot.x(0))), + Position(pos.x(0),pos.y(0),pos.z(0))); pv = assembly.placeVolume(volume,trafo); } else if ( pos.ptr() ) { - pv = assembly.placeVolume(volume,Position(pos.x(),pos.y(),pos.z())); + pv = assembly.placeVolume(volume,Position(pos.x(0),pos.y(0),pos.z(0))); } else if ( rot.ptr() ) { - pv = assembly.placeVolume(volume,Rotation3D(RotationZYX(rot.z(),rot.y(),rot.x()))); + pv = assembly.placeVolume(volume,Rotation3D(RotationZYX(rot.z(0),rot.y(0),rot.x(0)))); } else { pv = assembly.placeVolume(volume); diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 468d237d6cf453b12dcff767976444fc77e20c2d..a5c975a05cddf78e82248113ac728fbe3900f128 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -798,6 +798,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { bool m_printPositions = false; bool m_printMaterials = false; bool m_printSensitivesOnly = false; + long m_printMaxLevel = 999999; long m_numNodes = 0; long m_numShapes = 0; long m_numSensitive = 0; @@ -816,9 +817,10 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { if ( c == '-' ) { ++p; c = ::tolower(av[i][1]); } if ( c == '-' ) { ++p; c = ::tolower(av[i][1]); } if ( ::strncmp(p,"volume_ids",3) == 0 ) m_printVolIDs = true; + else if ( ::strncmp(p,"level",3) == 0 ) m_printMaxLevel = ::atol(av[++i]); + else if ( ::strncmp(p,"materials",3) == 0 ) m_printMaterials = true; else if ( ::strncmp(p,"pathes",3) == 0 ) m_printPathes = true; else if ( ::strncmp(p,"positions",3) == 0 ) m_printPositions = true; - else if ( ::strncmp(p,"materials",3) == 0 ) m_printMaterials = true; else if ( ::strncmp(p,"pointers",3) == 0 ) m_printPointers = true; else if ( ::strncmp(p,"shapes",3) == 0 ) m_printShapes = true; else if ( ::strncmp(p,"sensitive",3) == 0 ) m_printSensitivesOnly = true; @@ -829,6 +831,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { "Usage: -plugin <name> -arg [-arg] \n" " -detector <string> Top level DetElement path. Default: '/world' \n" " -pathes Print DetElement pathes \n" + " -level <number> Maximal depth to be explored by the scan \n" " -positions Print placement positions \n" " -volume_ids Print placement volume IDs \n" " -materials Print volume materials \n" @@ -839,6 +842,15 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { "\tArguments given: " << arguments(ac,av) << endl << flush; } } + if ( m_printMaxLevel < 999999 ) + printout(ALWAYS,"VolumeDump","+++ Maximal print level: %ld",m_printMaxLevel); + if ( !m_detector.empty() ) + printout(ALWAYS,"VolumeDump","+++ Subdetector path: %s",m_detector.c_str()); + printout(ALWAYS,"VolumeDump","+++ Printing positions: %s",yes_no(m_printPositions)); + printout(ALWAYS,"VolumeDump","+++ Printing shapes: %s",yes_no(m_printShapes)); + printout(ALWAYS,"VolumeDump","+++ Printing materials: %s",yes_no(m_printMaterials)); + printout(ALWAYS,"VolumeDump","+++ Printing volume ids: %s",yes_no(m_printVolIDs)); + printout(ALWAYS,"VolumeDump","+++ Print only sensitives: %s",yes_no(m_printSensitivesOnly)); } ~Actor() { printout(ALWAYS,"VolumeDump", @@ -867,6 +879,9 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { bool sensitive = false; string opt_info, pref = prefix; + if ( level >= m_printMaxLevel ) { + return 1; + } ++m_numNodes; if ( level == 0 ) currTop = ""; @@ -877,6 +892,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { else if ( level > 1 ) { ++top_counts[currTop]; } + if ( m_printPathes ) { pref += "/"; pref += aligned->GetName(); diff --git a/DDDetectors/src/SubdetectorAssembly_geo.cpp b/DDDetectors/src/SubdetectorAssembly_geo.cpp index 52b769b94c324e118536bf3b86b7da5d24d5c447..f1c876a14f6231e8c5d9b9c7d47f511f6ed6ece4 100644 --- a/DDDetectors/src/SubdetectorAssembly_geo.cpp +++ b/DDDetectors/src/SubdetectorAssembly_geo.cpp @@ -59,7 +59,7 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t) { for(xml_coll_t c(x_det,_U(composite)); c; ++c) { xml_dim_t component = c; string nam = component.nameStr(); - description.declareMotherVolume(nam, vol); + description.declareParent(nam, sdet); } vol.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr()); diff --git a/DDDetectors/src/VolumeAssembly_geo.cpp b/DDDetectors/src/VolumeAssembly_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..62615da6b49a5f0455a541d4e79c65f59b4ae1e5 --- /dev/null +++ b/DDDetectors/src/VolumeAssembly_geo.cpp @@ -0,0 +1,162 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/DetectorTools.h" +#include "DD4hep/Printout.h" +#include "XML/Utilities.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::detail; + + +namespace { + /// Helper to create the volume assembly + struct Builder { + /// Created volumes + map<string, Volume> volumes; + Detector& description; + /// Default constructor + Builder(Detector& dsc) : description(dsc) {} + + /// Default destructor + ~Builder() {} + + /// Place single volume in mother + PlacedVolume placeVolume(DetElement parent, Volume mother, xml_h c) { + xml_dim_t x_vol = c; + string vnam = x_vol.attr<string>(_U(volume)); + string name = x_vol.hasAttr(_U(name)) ? x_vol.nameStr() : string(""); + xml_dim_t x_tr = x_vol.child(_U(transformation),false); + xml_dim_t x_pos = x_vol.child(_U(position),false); + xml_dim_t x_rot = x_vol.child(_U(rotation),false); + PlacedVolume pv; + + auto iv = volumes.find(vnam); + if ( iv == volumes.end() ) { + except("VolumeAssembly","+++ Failed to attach unknown volume: %s",vnam.c_str()); + } + Volume vol = (*iv).second; + for(xml_coll_t coll(c,_U(physvol)); coll; ++coll) { + if ( coll.hasAttr(_U(element)) ) { + DetElement de(parent, coll.attr<string>(_U(element)), parent.id()); + pv = placeVolume(de, vol, coll); + de.setType("compound"); + de.setPlacement(pv); + continue; + } + placeVolume(parent, vol, coll); + } + + if ( x_tr ) { + Transform3D tr = xml::createTransformation(x_tr); + pv = mother.placeVolume(vol, tr); + } + else if ( x_rot && x_pos ) { + Position pos(x_pos.x(0.0),x_pos.y(0.0),x_pos.z(0.0)); + RotationZYX rot(x_rot.z(0.0),x_rot.y(0.0),x_rot.x(0.0)); + pv = mother.placeVolume(vol, Transform3D(rot, pos)); + } + else if ( x_rot ) { + RotationZYX rot(x_rot.z(0.0),x_rot.y(0.0),x_rot.x(0.0)); + pv = mother.placeVolume(vol, rot); + } + else if ( x_pos ) { + Position pos(x_pos.x(0.0),x_pos.y(0.0),x_pos.z(0.0)); + pv = mother.placeVolume(vol, pos); + } + else { + pv = mother.placeVolume(vol); + } + return pv; + } + + Ref_t create(xml_h e, SensitiveDetector sens) { + xml_det_t x_det(e); + xml_comp_t x_env = x_det.child(_U(envelope)); + xml_comp_t x_envshape = x_env.child(_U(shape),false); + string det_name = x_det.nameStr(); + DetElement sdet(det_name, x_det.id()); + Volume assembly; + PlacedVolume pv; + + if ( !x_envshape ) x_envshape = x_env; + if ( x_envshape.typeStr() == "Assembly" ) { + assembly = Assembly("lv"+det_name); + } + else { + Material mat = description.material(x_env.materialStr()); + Solid solid = xml::createShape(description, x_envshape.typeStr(), x_envshape); + assembly = Volume("lv"+det_name, solid, mat); + } + assembly.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr()); + if ( x_det.hasAttr(_U(sensitive)) ) { + sens.setType(x_det.attr<string>(_U(sensitive))); + } + + for(xml_coll_t coll(e,_U(volume)); coll; ++coll) { + xml_comp_t x_vol = coll; + Volume vol = xml::createVolume(description,x_vol); + if ( x_vol.isSensitive() ) { + vol.setSensitiveDetector(sens); + } + volumes.insert(make_pair(vol.name(), vol)); + } + for(xml_coll_t coll(e,_U(physvol)); coll; ++coll) { + if ( coll.hasAttr(_U(element)) ) { + string de_name = coll.attr<string>(_U(element)); + DetElement de(sdet, de_name, x_det.id()); + pv = placeVolume(de, assembly, coll); + de.setType("compound"); + de.setPlacement(pv); + continue; + } + placeVolume(sdet, assembly, coll); + } + + xml_dim_t x_tr = x_det.child(_U(transformation),false); + xml_dim_t x_pos = x_det.child(_U(position),false); + xml_dim_t x_rot = x_det.child(_U(rotation),false); + Volume mother = description.pickMotherVolume(sdet); + if ( x_tr ) { + Transform3D tr = xml::createTransformation(x_tr); + pv = mother.placeVolume(assembly, tr); + } + else if( x_rot && x_pos ){ + Position pos(x_pos.x(0.0),x_pos.y(0.0),x_pos.z(0.0)); + RotationZYX rot(x_rot.z(0.0),x_rot.y(0.0),x_rot.x(0.0)); + pv = mother.placeVolume(assembly, Transform3D(rot, pos)); + } else if( x_rot ){ + RotationZYX rot(x_rot.z(0.0),x_rot.y(0.0),x_rot.x(0.0)); + pv = mother.placeVolume(assembly, rot); + } else if( x_pos ){ + Position pos(x_pos.x(0.0),x_pos.y(0.0),x_pos.z(0.0)); + pv = mother.placeVolume(assembly, pos); + } else { + pv = mother.placeVolume(assembly); + } + sdet.setPlacement(pv); + return sdet; + } + }; +} + +static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector sens) { + Builder b(description); + return b.create(e, sens); +} +DECLARE_DETELEMENT(DD4hep_VolumeAssembly,create_element) diff --git a/examples/DDUpgrade/CMakeLists.txt b/examples/DDUpgrade/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3c616d4f58521c8dc302a63da1c4eb6327decc53 --- /dev/null +++ b/examples/DDUpgrade/CMakeLists.txt @@ -0,0 +1,52 @@ +#========================================================================== +# AIDA Detector description implementation +#-------------------------------------------------------------------------- +# 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. +# +#========================================================================== +cmake_minimum_required(VERSION 3.3 FATAL_ERROR) + +find_package ( DD4hep REQUIRED ) + +include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +#----------------------------------------------------------------------------------- +dd4hep_configure_output () +dd4hep_package ( DDUpgrade MAJOR 0 MINOR 0 PATCH 1 + USES [ROOT REQUIRED COMPONENTS Geom] + [DD4hep REQUIRED COMPONENTS DDCore] + ) +# +#---DDUpgrade plugin library ------------------------------------------------------- +dd4hep_add_plugin(DDUpgradePlugins + SOURCES src/*.cpp + USES [ROOT REQUIRED COMPONENTS Gdml Geom GenVector] +) +# +# +include(ExternalProject) +ExternalProject_Add( + DDUpgrade_data + PREFIX "data" + URL http://dd4hep.web.cern.ch/dd4hep/repo_data/DDUpgrade_data.tgz + URL_HASH SHA512=f3aeb50b104dc8e088904427403c4da11b75faf701d677ac5fe61bad206406104d92f71d6aeb69c04f470885a117b515306445fdee968c73e95a97ae37e27bbc + DOWNLOAD_NO_EXTRACT 1 + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + PATCH_COMMAND tar -xzf ${CMAKE_BINARY_DIR}/data/src/DDUpgrade_data.tgz -C ${CMAKE_SOURCE_DIR} +) +# +# +dd4hep_install_dir( data compact python DESTINATION ${CMAKE_INSTALL_PREFIX}/examples/DDUpgrade ) +dd4hep_install_files(FILES Upgrade.root DESTINATION ${CMAKE_INSTALL_PREFIX}/examples/DDUpgrade ) +#-------------------------------------------------------------------------- +# +dd4hep_configure_scripts ( DDUpgrade DEFAULT_SETUP WITH_TESTS ) +# +#---Testing------------------------------------------------------------------------- +# diff --git a/examples/DDUpgrade/compact/Bcm/BcmDown.xml b/examples/DDUpgrade/compact/Bcm/BcmDown.xml new file mode 100644 index 0000000000000000000000000000000000000000..bc2bc79e0d046b7feaaced2b710b3e73859832f6 --- /dev/null +++ b/examples/DDUpgrade/compact/Bcm/BcmDown.xml @@ -0,0 +1,125 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the BLS parameter definitions --> +<!-- ========================================================================== --> +<lccdd> + + <detectors> + <!-- + BCM detector: upper module + --> + <detector id="BcmDown:ID" name="BcmDown" type="LHCb_Bcm" parent="${BcmDown:Parent}" + station="1" readout="BcmDownHits" vis="Bcm:BcmVis"> + <position x="0*mm" y="0*mm" z="2766.0*mm - Regions:MagnetRegionZPos"/> + + <!-- G10 contact plate --> + <volume name="lvBcmDownContact" material="Bcm/G10" vis="Bcm:ContactVis"> + <shape type="Tube" + dz="Bcm:ContactThick/2" + rmin="Bcm:DownContactInRad" + rmax="Bcm:DownContactOutRad"/> + </volume> + + <!-- Wire --> + <volume name="lvBcmDownWire" material="Bcm/Wire" vis="Bcm:WireVis"> + <shape type="BooleanShape" operation="union"> + <shape type="BooleanShape" operation="union"> + <shape type="Tube" dz="Bcm:DownWireStartLength/2" rmax="Bcm:DownWireOutRad" rmin="0*mm"/> + <shape type="Tube" dz="Bcm:DownWireLongLength/2" rmax="Bcm:DownWireOutRad" rmin="0*mm"/> + <position x="Bcm:DownWireLongPosX" z="Bcm:DownWireLongPosZ"/> + </shape> + <shape type="Tube" dz="Bcm:DownWireCrossLength/2" rmax="Bcm:DownWireOutRad" rmin="0*mm"/> + <transformation> + <position x="Bcm:DownWireCrossPosX" z="Bcm:DownWireCrossPosZ"/> + <rotation y="90.0*degree"/> + </transformation> + </shape> + </volume> + + <!-- Back part of downstream mount --> + <volume name="lvBcmDownMountBackSection" material="Bcm/Tekapeek" vis="Bcm:MountVis"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="Tube" dz="Bcm:DownMountBackSectionLength/2" + rmax="Bcm:DownMountBackSectionOutRad" rmin="Bcm:DownMountBackSecitonInRad" + startphi="44.9*degree" deltaphi="89.8*degree"/> + <shape type="Tube" dz="Bcm:DownMountBackSectionHoleLength/2" rmax="Bcm:DownMountBackSectionHoleRad" rmin="0.0*mm"/> + <transformation> + <position z="Bcm:DownMountBackSectionHolePosZ" y="Bcm:DownMountBackSectionHolePosY" /> + <rotation x="90.0*degree"/> + </transformation> + </shape> + <shape type="Box" dx="Bcm:DownMountBackSectionSlotWidth" + dy="Bcm:DownMountBackSectionSlotThick" + dz="Bcm:DownMountBackSectionSlotLenght"/> + <position z="Bcm:DownMountBackSectionSlotPosZ" y="Bcm:DownMountBackSectionSlotPosY"/> + </shape> + </volume> + + <!-- Front part of downstream mount --> + <volume name="lvBcmDownMountFront" material="Bcm/Tekapeek" vis="Bcm:MountVis"> + <shape type="Tube" dz="Bcm:DownMountFrontLength/2" + rmax="Bcm:DownMountFrontOutRad" + rmin="Bcm:DownMountFrontInRad"/> + </volume> + + <!-- Assembly of front and back part --> + <volume name="lvBcmDownMount" assembly="1"> + <physvol logvol="lvBcmDownMountFront"> + <position/> + </physvol> + <physvol logvol="lvBcmDownMountBackSection"> + <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> + <rotation z="45*degree"/> + </physvol> + <physvol logvol="lvBcmDownMountBackSection"> + <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> + <rotation z="135*degree"/> + </physvol> + <physvol logvol="lvBcmDownMountBackSection"> + <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> + <rotation z="225*degree"/> + </physvol> + <physvol logvol="lvBcmDownMountBackSection"> + <position z="Bcm:DownMountFrontLength/2 + Bcm:DownMountBackSectionLength/2 + 0.01*mm"/> + <rotation z="315*degree"/> + </physvol> + </volume> + + <physvol logvol="lvBcmDownMount" element="Mount"/> + <physvol logvol="lvBcmDownWire"> + <positionRPhiZ r="Bcm:DownWireRad" phi="180.0*degree" z="0*mm"/> + <rotation y="270.0*degree"/> + <position x="0*mm" y="0*mm" z="0*mm"/> + <rotation z="45.0*degree"/> + </physvol> + <physvol logvol="lvBcmDownContact" element="Contact"> + <position z="Bcm:DownContactPosZ"/> + </physvol> + + <!-- Diamond sensor with start of placement positioning --> + <sensor material="Bcm/Diamond" vis="Bcm:SensorVis" + dx="Bcm:SensorWidth/2" dy="Bcm:SensorWidth/2" dz="Bcm:SensorThick/2"> + <position r="Bcm:DownSensorRad" phi="90.0*degree" z="Bcm:DownSensorPosZ"/> + </sensor> + + </detector> + </detectors> + + <readouts> + <readout name="BcmDownHits"> + <id>system:8,station:8,sensor:16</id> + </readout> + </readouts> + +</lccdd> diff --git a/examples/DDUpgrade/compact/Bcm/BcmUp.xml b/examples/DDUpgrade/compact/Bcm/BcmUp.xml new file mode 100644 index 0000000000000000000000000000000000000000..230f8654f22e716feb10cb0ab5a41219509e7030 --- /dev/null +++ b/examples/DDUpgrade/compact/Bcm/BcmUp.xml @@ -0,0 +1,84 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the BCM stations --> +<!-- ========================================================================== --> +<lccdd> + + <detectors> + <!-- + BCM detector: upper module + --> + <detector id="BcmUp:ID" name="BcmUp" type="LHCb_Bcm" + parent="${BcmUp:Parent}" + station="0" readout="BcmUpHits" vis="Bcm:BcmVis"> + <position z="-2135.0*mm + Regions:BeforeMagnetZSize/2 - Regions:BeforeVeloZSize/2"/> + + <!-- G10 contact plate --> + <volume name="lvBcmUpContact" material="Bcm/G10" vis="Bcm:ContactVis" build="DEFAULT,SIM,REC"> + <shape type="Tube" + dz="Bcm:ContactThick/2" + rmin="Bcm:UpContactInRad" + rmax="Bcm:UpContactOutRad"/> + </volume> + + <!-- Wire --> + <volume name="lvBcmUpWire" material="Bcm/Wire" vis="Bcm:WireVis" build="DEFAULT,SIM"> + <shape type="BooleanShape" operation="union"> + <shape type="Tube" dz="Bcm:UpWireStartLength/2" rmax="Bcm:UpWireOutRad" rmin="0*mm"/> + <shape type="Tube" dz="Bcm:UpWireLongLength/2" rmax="Bcm:UpWireOutRad" rmin="0*mm"/> + <position x="Bcm:UpWireLongPosX" z="Bcm:UpWireLongPosZ"/> + <rotation y="90.0*degree"/> + </shape> + </volume> + + <!-- Upstream mount --> + <volume name="lvBcmUpMount" material="Bcm/Aluminium" vis="Bcm:MountVis" build="DEFAULT,SIM,REC,DISPLAY"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="Box" dx="Bcm:UpMountWidth/2" dy="Bcm:UpMountHeight/2" dz="Bcm:UpMountThick/2"/> + <shape type="Tube" dz="Bcm:UpMountHoleThick/2" rmax="Bcm:UpMountHoleRad" rmin="0.0*mm"/> + </shape> + <shape type="Box" dx="Bcm:UpMountSlotWidth/2" dy="Bcm:UpMountSlotLength/2" dz="Bcm:UpMountSlotThick/2"/> + <position y="Bcm:UpMountSlotPosY"/> + </shape> + </volume> + + <physvol logvol="lvBcmUpWire"> + <positionRPhiZ r="Bcm:UpWireRad" phi="270.0*degree" z="Bcm:UpWirePosZ"/> + <rotation x="90.0*degree"/> + <position/> + <rotation x="270.0*degree"/> + </physvol> + <physvol logvol="lvBcmUpMount" element="Mount"/> + <physvol logvol="lvBcmUpContact" element="Contact"> + <position z="Bcm:UpContactPosZ"/> + </physvol> + + <!-- Diamond sensor --> + <sensor material="Bcm/Diamond" vis="Bcm:SensorVis" + dx="Bcm:SensorWidth/2." + dy="Bcm:SensorWidth/2" + dz="Bcm:SensorThick/2"> + <position r="Bcm:UpSensorRad" phi="90.0*degree" z="Bcm:UpSensorPosZ"/> + </sensor> + + </detector> + </detectors> + + <readouts> + <readout name="BcmUpHits"> + <id>system:8,station:8,sensor:16</id> + </readout> + </readouts> + +</lccdd> diff --git a/examples/DDUpgrade/compact/Bcm/detector.xml b/examples/DDUpgrade/compact/Bcm/detector.xml new file mode 100644 index 0000000000000000000000000000000000000000..d7b5ef0d309648aada5d41ec87b730830ad3980b --- /dev/null +++ b/examples/DDUpgrade/compact/Bcm/detector.xml @@ -0,0 +1,22 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the BCM stations --> +<!-- ========================================================================== --> +<lccdd> + <!-- + XML description of the 2 BCM stations + <include ref="BcmDown.xml"/> + --> + <include ref="BcmUp.xml"/> + +</lccdd> diff --git a/examples/DDUpgrade/compact/Bcm/parameters.xml b/examples/DDUpgrade/compact/Bcm/parameters.xml new file mode 100644 index 0000000000000000000000000000000000000000..b8935d6df557310c788e14b9ea883811c5f17524 --- /dev/null +++ b/examples/DDUpgrade/compact/Bcm/parameters.xml @@ -0,0 +1,123 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the BCM parameter definitions --> +<!-- ========================================================================== --> +<lccdd> + + <define> + <constant name="Bcm:DownWireOutRad" value="2.5*mm" /> + <constant name="Bcm:UpWireStartLength" value="10.0*mm" /> + <constant name="Bcm:UpWireOutRad" value="2.5*mm" /> + <constant name="Bcm:DownWireLongLength" value="985.0*mm" /> + <constant name="Bcm:UpMountThick" value="2.0*mm" /> + <constant name="Bcm:DownMountFrontLength" value="4.0*mm" /> + <constant name="Bcm:UpMountWidth" value="264.0*mm" /> + <constant name="Bcm:DownPosZ" value="2766.0*mm" /> + <constant name="Bcm:SensorWidth" value="10.0*mm" /> + <constant name="Bcm:DownMountBackSectionSlotLenght" value="6.0*mm" /> + <constant name="Bcm:DownMountBackSectionHoleRad" value="2.5*mm" /> + <constant name="Bcm:ContactThick" value="1.0*mm" /> + <constant name="Bcm:DownWireStartLength" value="10.0*mm" /> + <constant name="Bcm:DownWireCrossLength" value="10.0*mm" /> + <constant name="Bcm:UpWireLongLength" value="1000.0*mm" /> + <constant name="Bcm:DownMountBackSectionLength" value="15.0*mm" /> + <constant name="Bcm:SensorThick" value="0.5*mm" /> + <constant name="Bcm:DownContactOutRad" value="49.0*mm" /> + <constant name="Bcm:UpContactOutRad" value="80.0*mm" /> + <constant name="Bcm:UpMountHoleRad" value="62.5*mm" /> + <constant name="Bcm:UpMountHeight" value="355.0*mm" /> + <constant name="Bcm:UpWireLongPosZ" value="Bcm:UpWireStartLength/2" /> + <constant name="Bcm:UpWirePosZ" value="Bcm:UpMountThick/2 + Bcm:UpWireOutRad + 0.01*mm" /> + <constant name="Bcm:UpMountHoleThick" value="Bcm:UpMountThick + 0.1*mm" /> + <constant name="Bcm:DownMountBackSectionSlotWidth" value="2 * Bcm:DownMountBackSectionHoleRad" /> + <constant name="Bcm:UpContactPosZ" value="Bcm:UpMountThick/2 + Bcm:ContactThick/2 + 0.01*mm" /> + <constant name="Bcm:DownContactPosZ" value="-Bcm:DownMountFrontLength/2 - Bcm:ContactThick/2 - 0.01*mm" /> + <constant name="Bcm:DownWireLongPosZ" value="Bcm:DownWireLongLength/2 + Bcm:DownWireStartLength/2" /> + <constant name="Bcm:DownWireCrossPosZ" value="Bcm:DownWireStartLength/2" /> + <constant name="Bcm:DownWireLongPosX" value="Bcm:DownWireCrossLength" /> + <constant name="Bcm:DownWireCrossPosX" value="Bcm:DownWireCrossLength/2" /> + <constant name="Bcm:UpWireLongPosX" value="Bcm:UpWireLongLength/2" /> + <constant name="Bcm:DownMountBackSectionHolePosZ" value="Bcm:DownMountBackSectionLength/2 - 5.5*mm" /> + <constant name="Bcm:DownWireRad" value="Bcm:DownContactOutRad + Bcm:DownWireStartLength/2 + 0.01*mm" /> + <constant name="Bcm:DownContactInRad" value="Bcm:DownContactOutRad - 18.0*mm" /> + <constant name="Bcm:DownMountFrontOutRad" value="Bcm:DownContactOutRad" /> + <constant name="Bcm:UpContactInRad" value="Bcm:UpContactOutRad - 17.5*mm" /> + <constant name="Bcm:UpWireRad" value="Bcm:UpContactOutRad + Bcm:UpWireStartLength/2 + 0.01*mm" /> + <constant name="Bcm:UpMountSlotWidth" value="2 * Bcm:UpMountHoleRad" /> + <constant name="Bcm:UpMountSlotLength" value="Bcm:UpMountHeight/2 + 0.1*mm" /> + <constant name="Bcm:UpMountSlotThick" value="Bcm:UpMountHoleThick" /> + <constant name="Bcm:UpSensorPosZ" value="Bcm:UpContactPosZ + Bcm:ContactThick/2 + Bcm:SensorThick/2 + 0.01*mm" /> + <constant name="Bcm:DownSensorPosZ" value="Bcm:DownContactPosZ - Bcm:ContactThick/2 - Bcm:SensorThick/2 - 0.01*mm" /> + <constant name="Bcm:DownMountBackSectionSlotPosZ" value="Bcm:DownMountBackSectionHolePosZ + Bcm:DownMountBackSectionSlotLenght/2" /> + <constant name="Bcm:DownSensorRad" value="Bcm:DownContactInRad + Bcm:SensorWidth/2" /> + <constant name="Bcm:DownMountBackSectionOutRad" value="Bcm:DownMountFrontOutRad" /> + <constant name="Bcm:DownMountFrontInRad" value="Bcm:DownMountFrontOutRad - 6.0*mm" /> + <constant name="Bcm:UpSensorRad" value="Bcm:UpContactInRad + Bcm:SensorWidth/2" /> + <constant name="Bcm:UpMountSlotPosY" value="-Bcm:UpMountHeight/2 + Bcm:UpMountSlotLength/2" /> + <constant name="Bcm:DownMountBackSectionHolePosY" value="Bcm:DownMountBackSectionOutRad" /> + <constant name="Bcm:DownMountBackSectionSlotPosY" value="Bcm:DownMountBackSectionOutRad" /> + <constant name="Bcm:DownMountBackSecitonInRad" value="Bcm:DownMountBackSectionOutRad - 2.0*mm" /> + <constant name="Bcm:DownMountBackSectionHoleLength" value="Bcm:DownMountBackSectionOutRad" /> + <constant name="Bcm:DownMountBackSectionSlotThick" value="Bcm:DownMountBackSectionHoleLength" /> + </define> + + <materials> + <material name="Bcm/Diamond" I="78.0*eV" > + <D type="density" value="3.52" unit="g/cm3"/> + <composite ref="Carbon" n="1"/> + </material> + + <material name="Bcm/Tekapeek"> + <D type="density" value="1.49" unit="g/cm3"/> + <composite ref="N" n="2"/> + <composite ref="H" n="10"/> + <composite ref="C" n="22"/> + <composite ref="O" n="5"/> + </material> + + <material name="Bcm/G10"> + <D type="density" value="1.7" unit="g/cm3"/> + <composite ref="Si" n="1" /> + <composite ref="O" n="2" /> + </material> + + <material name="Bcm/Aluminium" I="166.0*eV"> + <D type="density" unit="g/cm3" value="2.7" /> + <composite ref="Al" n="1" /> + </material> + + <material name="Bcm/EFTE"> + <D type="density" value="1.74" unit="g/cm3"/> + <composite ref="C" n="1" /> + <composite ref="H" n="2" /> + <composite ref="F" n="2" /> + </material> + + <material name="Bcm/Wire"> + <D type="density" value="2.33" unit="g/cm3"/> + <composite ref="Cu" n="0.172" /> + <composite ref="Bcm/EFTE" n="0.100" /> + <composite ref="Bcm/Aluminium" n="0.433" /> + <composite ref="Air" n="0.295" /> + </material> + </materials> + + <display> + <vis name="Bcm:BcmVis" alpha="0.3" r="1.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="Bcm:SensorVis" alpha="1.0" r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="Bcm:WireVis" alpha="1.0" r="0.8" g="0.4" b="0.4" showDaughters="true" visible="true"/> + <vis name="Bcm:ContactVis" alpha="0.3" r="1.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="Bcm:MountVis" alpha="0.6" r="0.7" g="0.7" b="0.7" showDaughters="true" visible="true"/> + </display> + +</lccdd> diff --git a/examples/DDUpgrade/compact/Bls/detector.xml b/examples/DDUpgrade/compact/Bls/detector.xml new file mode 100644 index 0000000000000000000000000000000000000000..93e788e2fd94544570f4614866c2550417c7a78c --- /dev/null +++ b/examples/DDUpgrade/compact/Bls/detector.xml @@ -0,0 +1,138 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the BLS stations --> +<!-- ========================================================================== --> +<lccdd> + + <detectors> + <detector id="Bls:ID" name="Bls" type="LHCb_Bls" parent="${Bls:Parent}" readout="BlsHits" vis="Bls:BlsVis"> + + <!-- Since all volumes have the same positioning within the mother, we include it here --> + <volume name="lvBlsScintS" material="Bls/Sc" vis="Bls:ScintillatorVis" sensitive="true"> + <shape type="Box" dx="Bls:ScintSSizeX/2" dy="Bls:ScintSSizeY/2" dz="Bls:ScintSSizeZ/2"/> + </volume> + <volume name="lvBlsScintM" material="Bls/Sc" vis="Bls:ScintillatorVis" sensitive="true"> + <shape type="Box" dx="Bls:ScintMSizeX/2" dy="Bls:ScintMSizeY/2" dz="Bls:ScintMSizeZ/2"/> + </volume> + <volume name="lvBlsScintL" material="Bls/Sc" vis="Bls:ScintillatorVis" sensitive="true"> + <shape type="Box" dx="Bls:ScintLSizeX/2" dy="Bls:ScintLSizeY/2" dz="Bls:ScintLSizeZ/2"/> + </volume> + <volume name="lvBlsFiber" material="Bls/Resin" vis="Bls:FiberVis"> + <shape type="Trapezoid" z="Bls:FiberCoverH/2" + x1="Bls:ScintLSizeX" y1="Bls:ScintSSizeZ" x2="Bls:ScintSSizeX" y2="Bls:ScintSSizeZ"/> + </volume> + <volume name="lvBlsRing" material="Bls/Vinyp" vis="Bls:PassiveVis"> + <shape type="Tube" dz="Bls:RingH/2" rmin="Bls:RingInnerD / 2.0 + Bls:GeometryPrecision" rmax="Bls:RingOuterD / 2.0"/> + </volume> + <volume name="lvBlsPmt" material="Bls/Alu" vis="Bls:PmtVis"> + <shape type="Tube" dz="Bls:PmtH/2" rmin="Bls:PmtInnerD / 2" rmax="Bls:PmtOuterD / 2"/> + </volume> + <volume name="lvBlsFill" material="Bls/Resin" vis="Bls:PassiveVis"> + <shape type="Tube" dz="Bls:FillH/2" rmin="0*mm" rmax="Bls:FillOuterD / 2"/> + </volume> + <volume name="lvBlsTube" material="Bls/Steel" vis="Bls:PassiveVis"> + <shape type="Tube" dz="Bls:TubeH/2" rmin="Bls:TubeInnerD / 2.0 + Bls:GeometryPrecision" rmax="Bls:TubeOuterD / 2"/> + </volume> + + <transformation name="trBlsScintS"/> + <transformation name="trBlsScintM"> + <position y="(Bls:ScintSSizeY / 2 + Bls:FiberCoverH + Bls:ScintMSizeY / 2)"/> + </transformation> + <transformation name="trBlsScintL"> + <position y="(Bls:ScintSSizeY / 2 + Bls:FiberCoverH + Bls:ScintLSizeY / 2)"/> + </transformation> + <transformation name="trBlsFiber"> + <position y="(Bls:ScintSSizeY / 2 + Bls:FiberCoverH / 2)"/> + <rotation x="90*degree"/> + </transformation> + <transformation name="trBlsRing"> + <position y="0*mm"/> + <rotation x="90*degree"/> + </transformation> + <transformation name="trBlsPmt"> + <position y="-1 * (Bls:ScintSSizeY / 2 + Bls:PmtH / 2) "/> + <rotation x="90*degree"/> + </transformation> + <transformation name="trBlsFill"> + <position y="-1 * (Bls:ScintSSizeY / 2 + Bls:PmtH + Bls:FillH / 2) "/> + <rotation x="90.0*degree"/> + </transformation> + <transformation name="trBlsTube"> + <position y="-1 * (Bls:TubeH / 2 - Bls:ScintSSizeY / 2) "/> + <rotation x="90.0*degree"/> + </transformation> + + <!-- BLS3/4 two inner small --> + <volume name="lvBls34"> + <physvol logvol="lvBlsFiber" transformation="trBlsFiber"/> + <physvol logvol="lvBlsScintM" transformation="trBlsScintM"/> + <physvol logvol="lvBlsRing" transformation="trBlsRing"/> + <physvol logvol="lvBlsPmt" transformation="trBlsPmt"/> + <physvol logvol="lvBlsFill" transformation="trBlsFill"/> + <physvol logvol="lvBlsTube" transformation="trBlsTube"/> + </volume> + + <!-- BLS5/6 two outer large --> + <volume name="lvBls56"> + <physvol logvol="lvBlsFiber" transformation="trBlsFiber"/> + <physvol logvol="lvBlsScintL" transformation="trBlsScintL"/> + <physvol logvol="lvBlsRing" transformation="trBlsRing"/> + <physvol logvol="lvBlsPmt" transformation="trBlsPmt"/> + <physvol logvol="lvBlsFill" transformation="trBlsFill"/> + <physvol logvol="lvBlsTube" transformation="trBlsTube"/> + </volume> + + <!-- BLS7/8 two old standard --> + <volume name="lvBls78"> + <physvol logvol="lvBlsScintS" transformation="trBlsScintS"/> + <physvol logvol="lvBlsRing" transformation="trBlsRing"/> + <physvol logvol="lvBlsPmt" transformation="trBlsPmt"/> + <physvol logvol="lvBlsFill" transformation="trBlsFill"/> + <physvol logvol="lvBlsTube" transformation="trBlsTube"/> + </volume> + +<!-- +--> + <physvol element="Bls" id="3" logvol="lvBls34" > + <position z="-Bls:OffsetZ" x="Bls:OffsetX34" y="Bls:OffsetY34" /> + <rotation z="-90.0*degree" /> + </physvol> + <physvol element="Bls" id="4" logvol="lvBls34"> + <position z="-Bls:OffsetZ" x="Bls:OffsetX34" y="-Bls:OffsetY34" /> + <rotation z="-90.0*degree" /> + </physvol> + <physvol element="Bls" id="5" logvol="lvBls56" > + <position z="-Bls:OffsetZ" x="Bls:OffsetX56" y="Bls:OffsetY56"/> + <rotation z="-90*degree"/> + </physvol> + <physvol element="Bls" id="6" logvol="lvBls56"> + <position z="-Bls:OffsetZ" x="+Bls:OffsetX56" y="-Bls:OffsetY56"/> + <rotation z="-90*degree"/> + </physvol> + <physvol element="Bls" id="7" logvol="lvBls78" > + <position z="-Bls:OffsetZ" x="-Bls:OffsetX78" y="Bls:OffsetY78"/> + </physvol> + <physvol element="Bls" id="8" logvol="lvBls78"> + <position z="-Bls:OffsetZ" x="Bls:OffsetX78" y="Bls:OffsetY78"/> + </physvol> +<!-- +--> + </detector> + </detectors> + <readouts> + <readout name="BlsHits"> + <id>system:8,module:8,sensor:8</id> + </readout> + </readouts> + +</lccdd> diff --git a/examples/DDUpgrade/compact/Bls/parameters.xml b/examples/DDUpgrade/compact/Bls/parameters.xml new file mode 100644 index 0000000000000000000000000000000000000000..9e19046d90d724cec0dfc29b34cec409a590a40f --- /dev/null +++ b/examples/DDUpgrade/compact/Bls/parameters.xml @@ -0,0 +1,106 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the BLS parameter definitions --> +<!-- ========================================================================== --> +<lccdd> + + <define> + <constant name="Bls:GeometryPrecision" value="0.01*mm" /> + + <constant name="Bls:ScintLSizeX" value="140.0*mm" /> + <constant name="Bls:ScintLSizeY" value="280.0*mm" /> + <constant name="Bls:ScintLSizeZ" value= "30.0*mm" /> + + <constant name="Bls:ScintMSizeX" value="140.0*mm" /> + <constant name="Bls:ScintMSizeY" value="140.0*mm" /> + <constant name="Bls:ScintMSizeZ" value= "30.0*mm" /> + + <constant name="Bls:ScintSSizeX" value="40.0*mm" /> + <constant name="Bls:ScintSSizeY" value="40.0*mm" /> + <constant name="Bls:ScintSSizeZ" value="30.0*mm" /> + + <constant name="Bls:TubeH" value="240.0*mm" /> + <constant name="Bls:TubeInnerD" value="64.0*mm" /> + <constant name="Bls:TubeOuterD" value="70.0*mm" /> + + <constant name="Bls:RingH" value="32.0*mm" /> + <constant name="Bls:RingInnerD" value="50.0*mm" /> + <constant name="Bls:RingOuterD" value="Bls:TubeInnerD" /> + + <constant name="Bls:PmtH" value="100.0*mm" /> + <constant name="Bls:PmtInnerD" value="50.0*mm" /> + <constant name="Bls:PmtOuterD" value="52.0*mm" /> + + <constant name="Bls:FillH" value="Bls:TubeH - Bls:PmtH - Bls:ScintSSizeX" /> + <constant name="Bls:FillOuterD" value="Bls:TubeInnerD" /> + + <!-- As from Rustem sketch --> + <constant name="Bls:TotalWidth" value="1110.0*mm" /> + + <!-- ...the last minus is an estimate for cables to go down --> + <constant name="Bls:FiberCoverH" value="Bls:TotalWidth - Bls:ScintLSizeY - Bls:TubeH - Bls:TubeH / 2.0" /> + + <constant name="Bls:OffsetZ" value="247.5*mm" /> + <constant name="Bls:OffsetX34" value="-1 * ( Bls:ScintSSizeY / 2 + Bls:FiberCoverH + Bls:ScintMSizeY / 2 )" /> + <constant name="Bls:OffsetY34" value="280.0*mm" /> + <constant name="Bls:OffsetX56" value="-1 * ( Bls:ScintSSizeY / 2 + Bls:FiberCoverH + Bls:ScintLSizeY / 2 )" /> + <constant name="Bls:OffsetY56" value="610.0*mm" /> + <constant name="Bls:OffsetX78" value="120.0*mm" /> + <constant name="Bls:OffsetY78" value="0.0*mm" /> + + </define> + + <materials> + <material name="Bls/Sc"> + <D type="density" value="1.032" unit="g/cm3"/> + <RL type="X0" unit="cm" value="42.4" /> + <NIL type="lambda" unit="cm" value="79.46" /> + <component name="Hydrogen" natoms="8" /> + <component name="Carbon" natoms="8" /> + </material> + + <material name="Bls/Steel"> + <D type="density" value="7.87" unit="g/cm3"/> + <component name="Iron" fractionmass="0.97" /> + <component name="Carbon" fractionmass="0.03" /> + </material> + + <material name="Bls/Resin"> + <D type="density" value="0.04" unit="g/cm3"/> + <component name="Carbon" natoms="36" /> + <component name="Hydrogen" natoms="4" /> + <component name="Oxygen" natoms="10" /> + <component name="Nitrogen" natoms="1" /> + </material> + + <material name="Bls/Vinyp"> + <D type="density" value="1.38" unit="g/cm3"/> + <component name="Carbon" natoms="2" /> + <component name="Hydrogen" natoms="3" /> + <component name="Chlorine" natoms="1" /> + </material> + + <material name="Bls/Alu"> + <D type="density" value="2.7" unit="g/cm3"/> + <component name="Aluminium" natoms="1" /> + </material> + </materials> + + <display> + <vis name="Bls:BlsVis" alpha="0.3" r="1.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="Bls:ScintillatorVis" alpha="1.0" r="1.0" g="0.0" b="0.0" showDaughters="false" visible="true"/> + <vis name="Bls:FiberVis" alpha="0.5" r="0.8" g="0.8" b="0.0" showDaughters="false" visible="true"/> + <vis name="Bls:PmtVis" alpha="0.9" r="0.4" g="0.4" b="1.0" showDaughters="false" visible="true"/> + <vis name="Bls:PassiveVis" alpha="0.5" r="0.5" g="0.5" b="0.5" showDaughters="false" visible="true"/> + </display> +</lccdd> diff --git a/examples/DDUpgrade/compact/GdmlImports.xml b/examples/DDUpgrade/compact/GdmlImports.xml new file mode 100644 index 0000000000000000000000000000000000000000..98a491da8390154efc00a408b8daf4e7ccbb4d22 --- /dev/null +++ b/examples/DDUpgrade/compact/GdmlImports.xml @@ -0,0 +1,60 @@ +<lccdd> + + <detectors> + <detector id="200" name="VP" type="DD4hep_GdmlImport"> + <gdmlFile ref="${DD4hepExamplesINSTALL}/examples/DDUpgrade/data/VP.gdml"/> + <region name="BeforeMagnetRegion"/> + <position x="0*cm" y="0*cm" z="0*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector id="201" name="Rich1" type="DD4hep_GdmlImport"> + <gdmlFile ref="${DD4hepExamplesINSTALL}/examples/DDUpgrade/data/Rich1.gdml"/> + <region name="BeforeMagnetRegion"/> + <position x="0*cm" y="0*cm" z="150*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector id="202" name="UT" type="DD4hep_GdmlImport"> + <gdmlFile ref="${DD4hepExamplesINSTALL}/examples/DDUpgrade/data/UT.gdml"/> + <region name="BeforeMagnetRegion"/> + <position x="0*cm" y="0*cm" z="248.5*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector id="208" name="FT" type="DD4hep_GdmlImport"> + <gdmlFile ref="${DD4hepExamplesINSTALL}/examples/DDUpgrade/data/FT.gdml"/> + <region name="AfterMagnetRegion"/> + <position x="0*cm" y="0*cm" z="-123.05*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector id="208" name="Rich2" type="DD4hep_GdmlImport"> + <gdmlFile ref="${DD4hepExamplesINSTALL}/examples/DDUpgrade/data/Rich2.gdml"/> + <region name="AfterMagnetRegion"/> + <position x="0.027*cm" y="-4.32*cm" z="90.435*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector id="210" name="Ecal" type="DD4hep_GdmlImport"> + <gdmlFile ref="${DD4hepExamplesINSTALL}/examples/DDUpgrade/data/Ecal.gdml"/> + <region name="DownstreamRegion"/> + <position x="0*cm" y="-0.019*cm" z="-296.75*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector id="211" name="Hcal" type="DD4hep_GdmlImport"> + <gdmlFile ref="${DD4hepExamplesINSTALL}/examples/DDUpgrade/data/Hcal.gdml"/> + <region name="DownstreamRegion"/> + <position x="0*cm" y="-0.082*cm" z="-168.25*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector id="212" name="Muon" type="DD4hep_GdmlImport"> + <gdmlFile ref="${DD4hepExamplesINSTALL}/examples/DDUpgrade/data/Muon.gdml"/> + <region name="DownstreamRegion"/> + <position x="0*cm" y="0*cm" z="160.*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + </detectors> +</lccdd> diff --git a/examples/DDUpgrade/compact/Magnet/detector.xml b/examples/DDUpgrade/compact/Magnet/detector.xml new file mode 100644 index 0000000000000000000000000000000000000000..857b032efe7c68ae9872926671a76eb6176a0bb2 --- /dev/null +++ b/examples/DDUpgrade/compact/Magnet/detector.xml @@ -0,0 +1,312 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the LHCb magnet installation --> +<!-- ========================================================================== --> +<lccdd> + <detectors> + <!-- ********************************************************************** --> + <!-- Note: --> + <!-- --> + <!-- The DD4hep_VolumeAssembly solution was chosen for simplicity: --> + <!-- In this particular example the generic XML implementation has roughly --> + <!-- the same length as the C++ implementation. Hence I simply did it this --> + <!-- way. Otherwise typically the mixed xml/C++ implementation is favorable --> + <!-- --> + <!-- ********************************************************************** --> + <detector name="Magnet" type="DD4hep_VolumeAssembly" parent="/world/MagnetRegion"> + <mother name="/world/MagnetRegion"/> + <position x="0*cm" y="0*cm" z="-1.4*cm"/> + <envelope name="MagnetEnvelope" type="Assembly" material="Air"/> + + <!-- ******************************************************************** --> + <!-- Vertical Yoke --> + <!-- ******************************************************************** --> + <volume name="YokeVert" material="Magnet/YokeSteel" vis="Mag:YokeVis"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="Box" name="Vertical_Part_Subtraction" + dx="Mag:YokeVertSizeX/2" + dy="Mag:YokeVertSizeY/2" + dz="Mag:YokeVertSizeZ/2"/> + <shape type="Box" name="Subtracted_Upper_Box" + dx="Mag:YokeVertSizeX" + dy="Mag:YokeHorBase1/2" + dz="Mag:YokeVertL1/cos(Mag:Aperture)"/> + <position y="Mag:YokeVertH1+0.5*Mag:YokeHorBase1*cos(Mag:Aperture)" + z="0.5*Mag:YokeVertSizeZ-0.5*Mag:YokeHorBase1*sin(Mag:Aperture)"/> + <rotation x="-1*Mag:Aperture"/> + </shape> + <shape type="Box" name="Subtracted_Lower_Box" + dx="Mag:YokeVertSizeX" + dy="Mag:YokeHorBase1/2" + dz="Mag:YokeVertL1/cos(Mag:Aperture)"/> + <position y="-1*Mag:YokeVertH1-0.5*Mag:YokeHorBase1*cos(Mag:Aperture)" + z="0.5*Mag:YokeVertSizeZ-0.5*Mag:YokeHorBase1*sin(Mag:Aperture)"/> + <rotation x="Mag:Aperture"/> + </shape> + <shape type="Box" name="Subtracted_Inner_Box" + dx="7*Mag:YokePlateThick*cos(Mag:YokeCut)" + dy="Mag:YokeVertSizeY" + dz="2*Mag:YokeVertSizeZ"/> + <position x="0.5*Mag:YokeVertSizeX" z="0.5*Mag:YokeVertSizeZ"/> + <rotation y="-1*Mag:YokeCut"/> + </shape> + </volume> + + <!-- ******************************************************************** --> + <!-- Horizontal Yoke --> + <!-- ******************************************************************** --> + <volume name="YokeHor" material="Magnet/YokeSteel" vis="Mag:YokeVis"> + <shape type="BooleanShape" operation="subtraction" name="Horizontal_Yoke"> + <shape type="BooleanShape" operation="subtraction" name="Horizontal_Yoke"> + <shape type="Trap" name="Horizontal_Trapezoid" + z="Mag:SizeX/2" + y1="Mag:YokeHorHeight/2" + x1="Mag:YokeHorBase1/2" + x2="Mag:YokeHorBase2/2" + y2="Mag:YokeHorHeight/2" + x3="Mag:YokeHorBase1/2" + x4="Mag:YokeHorBase2/2" + alpha1="-1*atan(0.5*tan(Mag:Aperture))" + alpha2="-1*atan(0.5*tan(Mag:Aperture))"/> + <shape type="Trap" name ="Cut_out_right" + z="2*Mag:YokeHorHeight" + y1="(Mag:YokeHorE27+Mag:CutTolerance)/2" + x1="Mag:YokeCutBase1/2" + x2="Mag:YokeCutBase2/2" + y2="(Mag:YokeHorE27+Mag:CutTolerance)/2" + x3="Mag:YokeCutBase1/2" + x4="Mag:YokeCutBase2/2" + alpha1="-1*Mag:CutTrapAlp" + alpha2="-1*Mag:CutTrapAlp"/> + <transformation> + <position/> + <rotation x="-90*degree"/> + <position/> + <rotation y="-90*degree"/> + <position x="Mag:CutX" + y="0.5*Mag:YokeHorHeight" + z="0.5*(Mag:YokeHorD1+Mag:YokeHorA1)"/> + <rotation x="Mag:HoleAngle"/> + <position/> + <rotation z ="Mag:CutTrapTheta"/> + </transformation> + </shape> + <shape type="Trap" name ="Cut_out_left" + z="2*Mag:YokeHorHeight" + y1="(Mag:YokeHorE27+Mag:CutTolerance)/2" + x1="Mag:YokeCutBase1/2" + x2="Mag:YokeCutBase2/2" + y2="(Mag:YokeHorE27+Mag:CutTolerance)/2" + x3="Mag:YokeCutBase1/2" + x4="Mag:YokeCutBase2/2" + alpha1="Mag:CutTrapAlp" + alpha2="Mag:CutTrapAlp"/> + <transformation> + <position/> + <rotation x="-90*degree"/> + <position/> + <rotation y="-90*degree"/> + <position x="Mag:CutX" + y=" 0.5*Mag:YokeHorHeight" + z="-0.5*(Mag:YokeHorD1+Mag:YokeHorA1)"/> + <rotation x="-Mag:HoleAngle"/> + <position/> + <rotation z="Mag:CutTrapTheta"/> + </transformation> + </shape> + </volume> + <!-- ******************************************************************** --> + <!-- Coil Geometry --> + <!-- ******************************************************************** --> + <!-- % -Z((X1,X2)Y1) % --> + <!-- % +Z((X3,X4)Y2) % --> + <volume name="Coil" material="Magnet/CoilAl" vis="Mag:CoilVis"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="BooleanShape" operation="subtraction"> + <shape type="Trap" name="Basic_Trapezoid" + z="Mag:CoilSizeZ/2" + y1="Mag:CoilSizeY" x1="(Mag:CoilS5-Mag:CoilUpDeltaX+2*Mag:CoilSizeY)" x2="(Mag:CoilS5-Mag:CoilUpDeltaX)" + y2="Mag:CoilSizeY" x3="(Mag:CoilS5+Mag:CoilLowDeltaX+2*Mag:CoilSizeY)" x4="(Mag:CoilS5+Mag:CoilLowDeltaX)"/> + <shape type="Trap" name="Inner_Cutout" + z="(Mag:CoilSizeZ+Mag:CoilTolerance)/2" + y1="Mag:CoilSizeY" x1="(Mag:InnBendUpX+2*Mag:CoilSizeY)" x2="Mag:InnBendUpX" + y2="Mag:CoilSizeY" x3="(Mag:InnBendLowX+2*Mag:CoilSizeY)" x4="Mag:InnBendLowX"/> + <position y="-1*Mag:CoilThick"/> + </shape> + <shape type="Box" name="Vertical_Cut_Right" + dx="2*Mag:CoilSizeX/2" + dy="5*Mag:CoilSizeY/2" + dz="4*Mag:CoilSizeZ/2"/> + <position z="0.5*Mag:CoilSizeZ-Mag:CoilSizeX*sin(Mag:CutAngle)" x="Mag:InnBendLowX+Mag:PlateLowY+Mag:CoilSizeX*cos(Mag:CutAngle)"/> + <rotation y="Mag:CutAngle"/> + </shape> + <shape type="Box" name="Vertical_Cut_Left" + dx="2*Mag:CoilSizeX/2" + dy="5*Mag:CoilSizeY/2" + dz="4*Mag:CoilSizeZ/2"/> + <position z="0.5*Mag:CoilSizeZ-Mag:CoilSizeX*sin(Mag:CutAngle)" + x="-Mag:InnBendLowX-Mag:PlateLowY-Mag:CoilSizeX*cos(Mag:CutAngle)"/> + <rotation y="-Mag:CutAngle"/> + </shape> + <shape type="Box" name="Vertical_Cut_Right_Low_Delta" + dx="(2*Mag:CoilOutRadius*(1/sin(45*degree-0.5*Mag:CoilAngle)-1)*cos(45*degree))/2" + dy="5*Mag:CoilSizeY/2" + dz="4*Mag:CoilSizeZ/2"/> + <position z="0.5*Mag:CoilSizeZ" x="Mag:InnBendLowX+Mag:PlateLowY"/> + <rotation y="-45*degree+0.5*Mag:CoilAngle"/> + </shape> + <shape type="Box" name="Vertical_Cut_Left_Low_Delta" + dx="(2*Mag:CoilOutRadius*(1/sin(45*degree-0.5*Mag:CoilAngle)-1)*cos(45*degree))/2" + dy="5*Mag:CoilSizeY/2" + dz="4*Mag:CoilSizeZ/2"/> + <position z="0.5*Mag:CoilSizeZ" x="-Mag:InnBendLowX-Mag:PlateLowY"/> + <rotation y="45*degree-0.5*Mag:CoilAngle"/> + </shape> + <shape type="Box" name="Vertical_Cut_Right_Up_Delta" + dx="(2*Mag:CoilOutRadius*(1/sin(45*degree+0.5*Mag:CoilAngle)-1)*0.9)/2" + dy="5*Mag:CoilSizeY/2" + dz="4*Mag:CoilSizeZ/2"/> + <position z="-0.5*Mag:CoilSizeZ" x="Mag:InnBendUpX+Mag:PlateUpY"/> + <rotation y="-135*degree-0.5*Mag:CoilAngle"/> + </shape> + <shape type="Box" name="Vertical_Cut_Left_Up_Delta" + dx="(2*Mag:CoilOutRadius*(1/sin(45*degree+0.5*Mag:CoilAngle)-1)*0.9)/2" + dy="5*Mag:CoilSizeY/2" + dz="4*Mag:CoilSizeZ/2"/> + <position z="-0.5*Mag:CoilSizeZ" x="-Mag:InnBendUpX-Mag:PlateUpY"/> + <rotation y="135*degree+0.5*Mag:CoilAngle"/> + </shape> + <shape type="Trap" name ="Central_Hole" + z="Mag:CoilHoleZ/2" + y1="7*Mag:CoilSizeY/2" + x1="(Mag:CoilS5+(Mag:CoilCylX1-Mag:CoilS5)*cos(45*degree))" + x2="(Mag:CoilS5+(Mag:CoilCylX1-Mag:CoilS5)*cos(45*degree))" + y2="7*Mag:CoilSizeY/2" + x3="(2*(Mag:CoilS5+(Mag:CoilCylX2-Mag:CoilS5)*cos(45*degree))+Mag:Delta)/2" + x4="(2*(Mag:CoilS5+(Mag:CoilCylX2-Mag:CoilS5)*cos(45*degree))+Mag:Delta)/2"/> + </shape> + <shape type="Tube" name="Upper_Right_Cylinder" + dz="4.1*Mag:CoilSizeY/2" + rmax="Mag:CoilInnRadius+Mag:CoilTolerance"/> + <position x="Mag:CoilCylX1-Mag:UpCylDeltaX" + z="-0.5*Mag:CoilInnZ"/> + <rotation x="90*degree"/> + </shape> + <shape type="Tube" name="Lower_Right_Cylinder" + z="4.1*Mag:CoilSizeY/2" + rmax="Mag:CoilInnRadius"/> + <position x="Mag:CoilCylX2-Mag:LowCylDeltaX" + z="0.5*Mag:CoilInnZ"/> + <rotation x="90*degree"/> + </shape> + <shape type="Tube" name="Upper_Left_Cylinder" + z="4*Mag:CoilSizeY/2" + rmax="Mag:CoilInnRadius+Mag:CoilTolerance"/> + <position x="-Mag:CoilCylX1+Mag:UpCylDeltaX" + z="-0.5*Mag:CoilInnZ"/> + <rotation x="90*degree"/> + </shape> + <shape type="Tube" name="Lower_Left_Cylinder" + z="4*Mag:CoilSizeY/2" + rmax="Mag:CoilInnRadius"/> + <position x="-Mag:CoilCylX2+Mag:LowCylDeltaX" + z="0.5*Mag:CoilInnZ"/> + <rotation x="90*degree"/> + </shape> + <shape type="Box" name ="Hole_Right_Box" + dx="2*Mag:CoilInnRadius/2" + dy="7*Mag:CoilSizeY/2" + dz="(Mag:CoilLatLength+Mag:CoilTolerance)/2"/> + <position x="0.5*(Mag:CoilCylX1+Mag:CoilCylX2)-Mag:BoxDeltaX"/> + <rotation y="Mag:CoilAngle-Mag:TolAngle2"/> + </shape> + <shape type="Box" name="Hole_Left_Box" + dx="2*Mag:CoilInnRadius/2" + dy="7*Mag:CoilSizeY/2" + dz="(Mag:CoilLatLength+Mag:CoilTolerance)/2"/> + <position x="-0.5*(Mag:CoilCylX1+Mag:CoilCylX2)+Mag:BoxDeltaX"/> + <rotation y="-Mag:CoilAngle+Mag:TolAngle2"/> + </shape> + </volume> + + + <!-- %%% Installation of Yoke Vertical Parts (+Z looks at me) %%% --> + <physvol name="Left_Vertical_Part" volume="YokeVert"> + <position z="-Mag:YokePlateThick" x="-0.5*(Mag:SizeX-1*Mag:YokeVertSizeX)"/> + </physvol> + <physvol name="Right_Vertical_Part" volume="YokeVert"> + <position z="-Mag:YokePlateThick" + x="0.5*(Mag:SizeX-1*Mag:YokeVertSizeX)"/> + <rotation z="180*degree"/> + </physvol> + + <!-- %%% Installation of Yoke Horizontal Parts %%% --> + <physvol name="Upper_Horizontal_Part" volume="YokeHor"> + <transformation> + <position/> + <rotation y="90*degree"/> + <position/> + <rotation x="90*degree-1*Mag:Aperture"/> + <position y="Mag:YokeVertH20+0.5*Mag:YokeHorAvBase*cos(Mag:Aperture)+1.*mm" + z="-0.5*Mag:YokeHorAvBase*sin(Mag:Aperture)"/> + </transformation> + </physvol> + + <physvol name="Lower_Horizontal_Part" volume="YokeHor"> + <transformation> + <position/> + <rotation y="90*degree"/> + <position/> + <rotation x="90*degree-1*Mag:Aperture"/> + <position y="Mag:YokeVertH20+0.5*Mag:YokeHorAvBase*cos(Mag:Aperture)+1.*mm" + z="-0.5*Mag:YokeHorAvBase*sin(Mag:Aperture)"/> + <rotation/> + <position/> + <rotation z="180*degree"/> + </transformation> + </physvol> + + <!-- %%% Coils Installation %%% --> + <physvol name="UpperCoil" volume="Coil"> + <position y="-1*(Mag:CoilSizeY-Mag:CoilThick-Mag:CoilOffset1)*cos(Mag:Aperture)+Mag:YokeVertH20" + z="(Mag:CoilSizeY-Mag:CoilThick-Mag:CoilOffset1)*sin(Mag:Aperture)+Mag:CoilOffset2*cos(Mag:Aperture)-Mag:CoilOffset3"/> + <rotation x="-1*Mag:Aperture"/> + </physvol> + + <physvol name="LowerCoil" volume="Coil"> + <transformation> + <position/> + <rotation z="180*degree"/> + <position y="(Mag:CoilSizeY-Mag:CoilThick-Mag:CoilOffset1)*cos(Mag:Aperture)-Mag:YokeVertH20" + z="(Mag:CoilSizeY-Mag:CoilThick-Mag:CoilOffset1)*sin(Mag:Aperture)+Mag:CoilOffset2*cos(Mag:Aperture)-Mag:CoilOffset3"/> + <rotation x="Mag:Aperture"/> + </transformation> + </physvol> + </detector> + </detectors> + +</lccdd> diff --git a/examples/DDUpgrade/compact/Magnet/parameters.xml b/examples/DDUpgrade/compact/Magnet/parameters.xml new file mode 100644 index 0000000000000000000000000000000000000000..e3edb86c43b7a9b5bc8b4448e393ce382db83dd4 --- /dev/null +++ b/examples/DDUpgrade/compact/Magnet/parameters.xml @@ -0,0 +1,169 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the LHCb magnet parameters --> +<!-- ========================================================================== --> +<lccdd> + + <define> + <!-- ******************************************************************* --> + <!-- Magnet Parameters Definition --> + <!-- ******************************************************************* --> + <constant name="Mag:SizeX" value="11000*mm"/> + <constant name="Mag:SizeY" value="8010*mm"/> + <constant name="Mag:SizeZ" value="6000*mm"/> + + <constant name="Mag:Aperture" value="0.25*rad"/> + <!-- ******************************************************************* --> + <!-- Yoke Parameters Definition --> + <!-- Names of the Yoke Parameters : Yoke* --> + <!-- ******************************************************************* --> + + <!-- %%% Vertical parts of Yoke %%% --> + <constant name="Mag:YokeVertSizeX" value="2300*mm"/> + <constant name="Mag:YokeVertSizeY" value="4000*mm"/> + <constant name="Mag:YokeVertSizeZ" value="3100*mm"/> + + <constant name="Mag:YokeVertH1" value="1832.2*mm"/> + <constant name="Mag:YokeVertL1" value="2758*mm"/> + + <constant name="Mag:YokeVertH20" value="1461.7*mm"/> + <constant name="Mag:YokePlateThick" value="100*mm"/> + + <constant name="Mag:YokeCut" value="18*degree"/> + + <!-- %%% Horizontal parts of Yoke: trapezoids %%% --> + <constant name="Mag:YokeHorBase1" value="2969.8*mm"/> + <constant name="Mag:YokeHorBase2" value="2280.4*mm"/> + <constant name="Mag:YokeHorHeight" value="2700.0*mm"/> + <constant name="Mag:YokeHorAvBase" value="0.5*(Mag:YokeHorBase1+Mag:YokeHorBase2)"/> + + <!-- %%% Cut-outs trapezoids (for coil installation) + (defined as in engineering drawings) %%% --> + + <constant name="Mag:YokeHorA1" value="2785.0*mm"/> + <constant name="Mag:YokeHorA27" value="1685.5*mm"/> + + <constant name="Mag:YokeHorC1" value="3352.0*mm"/> + <constant name="Mag:YokeHorC27" value="2277.0*mm"/> + + <constant name="Mag:YokeHorD1" value="3836.5*mm"/> + <constant name="Mag:YokeHorD27" value="3045.0*mm"/> + + <constant name="Mag:YokeHorE1" value="484.5*mm"/> + <constant name="Mag:YokeHorE27" value="768.0*mm"/> + <!-- ******************************************************************* --> + <!-- Coil Parameters Definition --> + <!-- Names of the Coil Parameters : Coil* --> + <!-- ******************************************************************* --> + + <constant name="Mag:CoilSizeX" value="7282*mm"/> + <constant name="Mag:CoilSizeY" value="2134*mm"/> + <constant name="Mag:CoilSizeZ" value="4549*mm"/> + + <!-- Basic sizes of unbended "pancake" --> + <constant name="Mag:CoilThick" value="815.5*mm"/> + <constant name="Mag:CoilWidth" value="799.5*mm"/> + + <constant name="Mag:CoilInnRadius" value="400*mm"/> + <constant name="Mag:CoilCylX1" value="1880*mm"/> + <constant name="Mag:CoilCylX2" value="2857.3*mm"/> + <constant name="Mag:CoilInnZ" value="2150*mm"/> + + <constant name="Mag:CoilLatLength" value="2361.7*mm"/> + + <!-- Bending line angle and basic sizes --> + <constant name="Mag:CoilBendLine" value="0.29*rad"/> + <constant name="Mag:CoilS1" value="1103*mm"/> + <constant name="Mag:CoilS5" value="1386.4*mm"/> + + <!-- installation offsets --> + <constant name="Mag:CoilOffset1" value="200*mm"/> + <constant name="Mag:CoilOffset2" value="100*mm"/> + <!-- Jan Amoraal: I want the Magnet to fit in its envelope --> + <!-- This is just some arbitrary offset for now --> + <constant name="Mag:CoilOffset3" value="18.5*mm"/> + + <!-- ******************************************************************** --> + <!-- %%% Parameters of Coil subtractions %%% --> + <!-- XZ plate: unbended "pancake" basic trapezia (x_half_size) --> + <!-- ******************************************************************** --> + <constant name ="Mag:CoilOutRadius" value="Mag:CoilInnRadius+Mag:CoilWidth"/> + <constant name ="Mag:CoilAngle" value="acos(Mag:CoilInnZ/Mag:CoilLatLength)"/> + <constant name ="Mag:TrapUpX" value="Mag:CoilCylX1+(Mag:CoilInnRadius+Mag:CoilWidth)*tan(45*degree-0.5*Mag:CoilAngle)"/> + <constant name ="Mag:TrapLowX" value="Mag:CoilCylX2+(Mag:CoilInnRadius+Mag:CoilWidth)*tan(45*degree+0.5*Mag:CoilAngle)"/> + + <!-- basic bended trapezoid (before subtractions) --> + <constant name="Mag:CoilHoleZ" value="Mag:CoilInnZ+2*Mag:CoilInnRadius"/> + <constant name="Mag:CoilUpDeltaX" value="Mag:CoilWidth*tan(Mag:CoilBendLine)"/> + <constant name="Mag:CoilLowDeltaX" value="(Mag:CoilHoleZ+Mag:CoilWidth)*tan(Mag:CoilBendLine)"/> + + <!-- inner subtracted trapezoid --> + <constant name="Mag:InnBendUpX" value="Mag:CoilS1-Mag:CoilUpDeltaX"/> + <constant name="Mag:InnBendLowX" value="Mag:CoilS1+Mag:CoilLowDeltaX"/> + + <!-- "inner" plate of bended "pancake" --> + <constant name ="Mag:PlateUpY" value="(Mag:TrapUpX-Mag:InnBendUpX)*cos(45*degree)"/> + <constant name ="Mag:PlateLowY" value="(Mag:TrapLowX-Mag:InnBendLowX)*cos(45*degree)"/> + + <!-- lateral angle of vertical cut --> + <constant name ="Mag:CutAngle" value="atan((Mag:InnBendLowX+Mag:PlateLowY-Mag:InnBendUpX-Mag:PlateUpY)/Mag:CoilSizeZ)"/> + + <!-- parameters of cylindrical hole bending --> + <constant name ="Mag:UpCylDeltaX" value="(Mag:CoilCylX1-Mag:CoilS5)*(1-cos(45*degree))"/> + <constant name ="Mag:LowCylDeltaX" value="(Mag:CoilCylX2-Mag:CoilS5-Mag:CoilInnZ*tan(Mag:CoilBendLine))*(1-cos(45*degree))"/> + + <!-- "lateral box" bending --> + <constant name ="Mag:BoxDeltaX" value="0.5*(Mag:UpCylDeltaX+Mag:LowCylDeltaX)"/> + + <!-- tolerances --> + <constant name ="Mag:CoilTolerance" value="1*mm"/> + <constant name ="Mag:TolAngle1" value="2.1*degree"/> + <constant name ="Mag:TolAngle2" value="2*degree"/> + <constant name ="Mag:Delta" value="250*mm"/> + </define> + + <!-- ******************************************************************** --> + <!-- Yoke Parts Geometry --> + <!-- ******************************************************************** --> + <define> + <!-- %%% Parameters of cut-out trapezoids (in horizontal parts )%%%--> + <constant name="Mag:CutTrapTheta" value="atan((Mag:YokeHorE27-1*Mag:YokeHorE1)/Mag:YokeHorHeight)"/> + <constant name="Mag:HoleAngle" value="atan((Mag:YokeHorA1-1*Mag:YokeHorA27)/Mag:YokeHorHeight)"/> + <constant name="Mag:YokeCutBase1" value="(Mag:YokeHorD1-1*Mag:YokeHorA1)*cos(Mag:HoleAngle)"/> + <constant name="Mag:YokeCutBase2" value="(Mag:YokeHorC1-1*Mag:YokeHorA1)*cos(Mag:HoleAngle)"/> + <constant name="Mag:CutTrapAlp" value="atan((Mag:YokeHorD1-Mag:YokeHorC1)/(2*Mag:YokeHorE27))"/> + <constant name="Mag:CutX" value="-0.5*(Mag:YokeHorAvBase-1*Mag:YokeHorE27+Mag:YokeHorHeight*sin(Mag:CutTrapTheta))"/> + <constant name="Mag:CutTolerance" value="1*mm"/> + </define> + + <comment>Magnet visualization attributes</comment> + <display> + <vis name="Mag:BlackVis" alpha="1" r="0.1" g="0.1" b="0.1" showDaughters="false" visible="true"/> + <vis name="Mag:YokeVis" alpha="1" r="0." g="0.1" b="1.0" showDaughters="false" visible="true"/> + <vis name="Mag:CoilVis" alpha="1" r="0.8" g="0." b="0.8" showDaughters="false" visible="true"/> + </display> + + <comment>Magnet specific material definitions</comment> + <materials> + <material name="Magnet/YokeSteel"> + <D value="7.85" unit="g/cm3"/> + <fraction n="0.998" ref="Fe"/> + <fraction n=".002" ref="C"/> + </material> + <material name="Magnet/CoilAl"> + <D value="2.699" unit="g/cm3"/> + <fraction n="1.0" ref="Al"/> + </material> + </materials> + +</lccdd> diff --git a/examples/DDUpgrade/compact/PipeBeforeMagGeomParams.xml b/examples/DDUpgrade/compact/PipeBeforeMagGeomParams.xml new file mode 100644 index 0000000000000000000000000000000000000000..ac8ef312ae21bb62cc013efe065353f226c62355 --- /dev/null +++ b/examples/DDUpgrade/compact/PipeBeforeMagGeomParams.xml @@ -0,0 +1,198 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<define> +<!-- ***************************************************************** --> +<!-- * BeamPipe in BeforeMagnet geometry parameters * --> +<!-- * * --> +<!-- * Date: 2006-03-02 * --> +<!-- * Author: Gloria Corti * --> +<!-- * * --> +<!-- * The connection to Velo window is in Velo2Rich1 * --> +<!-- * This section of the beam pipe extend from z=970mm to 2700mm * --> +<!-- * * --> +<!-- ***************************************************************** --> + +<!-- ***************************************************************** --> +<!-- * UX85-1 In RICH1 * --> +<!-- ***************************************************************** --> + +<!-- UX84-2 --> + <constant name = "UX842CylLength" value = "1621.00*mm"/> + <constant name = "UX842CylThick" value = "2.00*mm"/> + <constant name = "UX842CylRadius" value = "40.00*mm"/> + +<!-- UX84 Flange Down --> + <constant name = "UX84FlangeDownLength" value = "20.00*mm"/> + <constant name = "UX84FlangeDownThick" value = "34.00*mm"/> + <constant name = "UX84FlangeDownRadius" value = "UX842CylRadius+UX842CylThick"/> + <constant name = "UX84FlangeDownPosZ" value = "UX842CylLength/2-UX84FlangeDownLength/2"/> + +<!-- UX84 Support --> + <constant name = "PipeSupBefVeloRec1X" value = "300.00*mm"/> + <constant name = "PipeSupBefVeloRec1Y" value = "380.00*mm"/> + <constant name = "PipeSupBefVeloRec1Z" value = "15.00*mm"/> + <constant name = "PipeSupBefVeloRec1HoleRad" value = "81.00*mm"/> + <constant name = "PipeSupBefVeloRec2X" value = "180.00*mm"/> + <constant name = "PipeSupBefVeloRec2Y" value = "187.00*mm"/> + <constant name = "PipeSupBefVeloRec2Z" value = "20.00*mm"/> + <constant name = "PipeSupBefVeloRec2HoleRad" value = "42.50*mm"/> + +<!-- UX85-1 Step to 54 mm diameter (after RF connection in Velo2Rich1 --> + <constant name = "UX851Cyl01Lenght" value = "1.00*mm"/> + <constant name = "UX851Cyl01Thick" value = "3.50*mm"/> + <constant name = "UX851Cyl01Radius" value = "27.00*mm"/> + <constant name = "UX851Cyl01Zpos" value = "0.5*UX851Cyl01Lenght"/> + +<!-- UX85-1 Cylinder 54 mm diamater Aluminium --> + <constant name = "UX851Cyl02Lenght" value = "16.00*mm"/> + <constant name = "UX851Cyl02Thick" value = "1.50*mm"/> + <constant name = "UX851Cyl02Radius" value = "27.00*mm"/> + <constant name = "UX851Cyl02Zpos" + value = "UX851Cyl01Lenght + 0.5*UX851Cyl02Lenght"/> + +<!-- UX85-1 Cylinder 54 mm diamater Beryllium - welding --> +<!-- extend from z = 987 mm to z = 982 mm - RICH1SubMaster split --> +<!-- ***************************************************************** --> + <constant name = "UX851Cyl03Lenght" value = "5.00*mm"/> + <constant name = "UX851Cyl03Thick" value = "1.50*mm"/> + <constant name = "UX851Cyl03Radius" value = "27.00*mm"/> + + <constant name = "UX851Cyl03ALenght" + value = "UX851Rich1SplitZminIP - UX851ZStartIP - UX851Cyl01Lenght - + UX851Cyl02Lenght"/> + <constant name = "UX851Cyl03AZpos" + value = "UX851Cyl01Lenght + UX851Cyl02Lenght + 0.5*UX851Cyl03ALenght"/> + + <constant name = "UX851Cyl03BLenght" + value = "UX851Cyl03Lenght - UX851Cyl03ALenght"/> + <constant name = "UX851Cyl03BZpos" + value = "UX851Cyl01Lenght + UX851Cyl02Lenght + UX851Cyl03ALenght+ + 0.5*UX851Cyl03BLenght"/> + +<!-- UX85-1 Cylinder 54 mm diamater Beryllium --> + <constant name = "UX851Cyl04Lenght" value = "88.00*mm"/> + <constant name = "UX851Cyl04Radius" value = "27.00*mm"/> + <constant name = "UX851Cyl04Thick" value = "1.00*mm"/> + <constant name = "UX851Cyl04Zpos" + value = "UX851Cyl01Lenght + UX851Cyl02Lenght+UX851Cyl03Lenght + + 0.5*UX851Cyl04Lenght"/> + +<!-- UX85-1 Cone 25 mrad --> +<!-- extend from z = 1080 mm to z = 2210 mm - RICH1SubMaster split --> +<!-- ***************************************************************** --> + <constant name = "UX851Cone05Lenght" value = "1130.00*mm"/> + <constant name = "UX851Cone05Thick" value = "1.00*mm"/> + + <constant name = "UX851Cone05ALenght" + value = "UX851Rich1SplitZmaxIP - UX851ZStartIP - UX851Cyl01Lenght - + UX851Cyl02Lenght - UX851Cyl03Lenght - UX851Cyl04Lenght"/> + <constant name = "UX851Cone05ARadiusZmin" value = "27.00*mm"/> + <constant name = "UX851Cone05ARadiusZmax" + value = "UX851Rich1SplitZmaxIP*tan(UX851Angle)"/> + <constant name = "UX851Cone05AZpos" + value = "UX851Cyl01Lenght + UX851Cyl02Lenght + UX851Cyl03Lenght + + UX851Cyl04Lenght + 0.5*UX851Cone05ALenght"/> + + <constant name = "UX851Cone05BLenght" + value = "UX851Cone05Lenght - UX851Cone05ALenght"/> + <constant name = "UX851Cone05BRadiusZmin" value = "UX851Cone05ARadiusZmax"/> + <constant name = "UX851Cone05BRadiusZmax" value = "55.21*mm"/> + <constant name = "UX851Cone05BZpos" + value = "UX851Cyl01Lenght + UX851Cyl02Lenght + UX851Cyl03Lenght+ + UX851Cyl04Lenght + UX851Cone05ALenght + 0.5*UX851Cone05BLenght"/> + +<!-- UX85-1 Flange to seal RICH1 gas enclosure - around UX851Cone05 --> + <constant name = "UX851Rich1Flange1Length" value = "1*mm"/> + <constant name = "UX851Rich1FlangeOffset" + value = "UX851Rich1FlangeOffsetIP - UX851ZStartIP"/> + <constant name = "UX851Rich1FlangeOuterRadius" value = "63.00*mm"/> + <constant name = "UX851Rich1FlangeRadiusZmin" + value = "UX851Rich1FlangeOffsetIP*tan(UX851Angle) + + UX851Cone05Thick"/> + <constant name = "UX851Rich1FlangeRadiusZMax" + value = "(UX851Rich1FlangeOffsetIP + UX851Rich1Flange1Length)* + tan(UX851Angle) + UX851Cone05Thick"/> + <constant name = "UX851Rich1FlangeZpos" + value = "UX851Rich1FlangeOffset + 0.5*UX851Rich1Flange1Length"/> + +<!-- UX85-1 Window of -37 degree at end of 25 mrad cone --> + <constant name = "UX851Win06Lenght" value = "40.10*mm"/> + <constant name = "UX851Win06Thick" value = "1.0*mm"/> + <constant name = "UX851Win06RadiusZmin" value = "UX851Cone05BRadiusZmax"/> + <constant name = "UX851Win06RadiusZmax" value = "25*mm"/> + <constant name = "UX851Win06Zpos" + value = "UX851Cyl01Lenght + UX851Cyl02Lenght + UX851Cyl03Lenght + + UX851Cyl04Lenght + UX851Cone05Lenght + 0.5*UX851Win06Lenght"/> + +<!-- UX85-1 Cylinder of 50 mm diameter --> +<!-- extend from z = 2250.1 mm to z = 2500 mm - RICH1/TT split --> +<!-- Rich1 section --> + <constant name = "UX851Cyl07Lenght" value = "249.90*mm"/> + <constant name = "UX851Cyl07Thick" value = "1.00*mm"/> + <constant name = "UX851Cyl07Radius" value = "25.00*mm"/> + + <constant name = "UX851Cyl07ALenght" + value = "UX851Rich1TTSplitZposIP - UX851ZStartIP - UX851Cyl01Lenght - + UX851Cyl02Lenght - UX851Cyl03Lenght - UX851Cyl04Lenght - + UX851Cone05Lenght - UX851Win06Lenght"/> + <constant name = "UX851Cyl07AZpos" + value = "UX851Cyl01Lenght + UX851Cyl02Lenght + UX851Cyl03Lenght + + UX851Cyl04Lenght + UX851Cone05Lenght + UX851Win06Lenght + + 0.5*UX851Cyl07ALenght"/> + +<!-- UX85-1 in Rich1 --> + <constant name = "UX851Rich1ALenght" + value = "UX851Cyl01Lenght+UX851Cyl02Lenght+UX851Cyl03ALenght"/> + <constant name = "UX851Rich1BLenght" + value = "UX851Cyl03BZpos+UX851Cyl04Lenght+UX851Cone05ALenght"/> + <constant name = "UX851Rich1CLenght" + value = "UX851Cone05BLenght+UX851Win06Lenght+UX851Cyl07ALenght"/> + + <constant name = "UX851InRich1Lenght" + value = "UX851Cyl01Lenght + UX851Cyl02Lenght + UX851Cyl03Lenght + + UX851Cyl04Lenght + UX851Cone05Lenght + UX851Win06Lenght + + UX851Cyl07ALenght"/> + +<!-- Vacuum sections overlapping various of the mechanical sections above --> +<!-- only segmentation due to shape or regions --> +<!-- Rich1 Before SubMaster --> + <constant name = "UX85Vacuum01Lenght" + value = "UX851Cyl01Lenght+UX851Cyl02Lenght+UX851Cyl03ALenght"/> +<!-- Rich1 In SubMaster --> + <constant name = "UX85Vacuum03BLenght" + value = "UX851Cyl03BLenght+UX851Cyl04Lenght"/> + +<!-- ***************************************************************** --> +<!-- * UX85-1 In TT * --> +<!-- ***************************************************************** --> + +<!-- UX85-1 Cylinder of 50 mm diameter --> +<!-- extend from z = 2250.1 mm to z = 2500 mm - RICH1/TT split --> +<!-- TT section --> + <constant name = "UX851Cyl07BLenght" + value = "UX851Cyl07Lenght - UX851Cyl07ALenght"/> + <constant name = "UX851Cyl07BZpos" + value = "0.5*UX851Cyl07BLenght"/> + +<!-- UX85-1 Cone 10 mrad --> +<!-- Stop at end of BeforeMagnet Region --> + <constant name = "UX851Cone08ALenght" + value = "UX851TTMagnetSplitZposIP - UX851ZStartIP - UX851Cyl01Lenght - + UX851Cyl02Lenght - UX851Cyl03Lenght - UX851Cyl04Lenght - + UX851Cone05Lenght - UX851Win06Lenght - UX851Cyl07Lenght"/> + <constant name = "UX851Cone08AThick" value = "1.00*mm"/> + <constant name = "UX851Cone08ARadiusZmin" value = "25.00*mm"/> + <constant name = "UX851Cone08ARadiusZmax" + value = "UX851TTMagnetSplitZposIP*tan(UX851to4Angle)"/> + <constant name = "UX851Cone08AZpos" + value = "UX851Cyl07BLenght + 0.5*UX851Cone08ALenght"/> + +<!-- UX85-1 in TT --> + <constant name = "UX851TTLenght" + value = "UX851Cyl07BZpos+UX851Cone08ALenght"/> + +<!-- UX85BeforeMagnet --> + <constant name = "UX85BeforeMagnetLenght" + value = "UX851Rich1ALenght+UX851Rich1BLenght+UX851Rich1CLenght+ + UX851TTLenght"/> + +</define> diff --git a/examples/DDUpgrade/compact/PipeGeomParams.xml b/examples/DDUpgrade/compact/PipeGeomParams.xml new file mode 100644 index 0000000000000000000000000000000000000000..c708b498f7bbda233ec69a6af8ada78b8bb1550f --- /dev/null +++ b/examples/DDUpgrade/compact/PipeGeomParams.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<define> + +<!-- ***************************************************************** --> +<!-- * BeamPipe geometry parameters * --> +<!-- * * --> +<!-- * Date: 2006-03-02 * --> +<!-- * Author: Gloria Corti * --> +<!-- * * --> +<!-- * The connection to Velo window is in Velo2Rich1 * --> +<!-- ***************************************************************** --> + +<!-- Angle of cones of the beam pipe --> + + <constant name = "UX851Angle" value = "25.0*mrad"/> + <constant name = "UX851to4Angle" value = "10.0*mrad"/> + +<!-- UX85-1 General Positions and splits --> + <constant name = "UX851ZStartIP" value = "970.00*mm"/> + <constant name = "UX851Rich1SplitZminIP" value = "990.00*mm"/> + <constant name = "UX851Rich1SplitZmaxIP" value = "2165.00*mm"/> + <constant name = "UX851Rich1TTSplitZposIP" value = "2270.00*mm"/> + <constant name = "UX851TTMagnetSplitZposIP" value = "2700.00*mm"/> + <constant name = "UX851Rich1FlangeOffsetIP" value = "2146.00*mm"/> + +<!-- UX85-1 Lenght of section split between BeforeMagnet and Magnet --> + <constant name = "UX851Cone08Lenght" value = "250.00*mm"/> + +<!-- Compensator at 2800 General Positions --> + <constant name = "UX85C2800ZStartIP" value = "2798.80*mm"/> + +<!-- UX85-3 General Positions and splits --> + <constant name = "UX853ZStartIP" value = "7050.00*mm"/> + <constant name = "UX853MagnetTSplitZposIP" value = "7620.00*mm"/> + <constant name = "UX853TRich2SplitZposIP" value = "9439.00*mm"/> + <constant name = "UX853Rich2DownSplitZposIP" value = "11900.00*mm"/> + +<!-- UX85-3 Lenght of sections related to split between Magnet and T --> + <constant name = "UX853Flange01Cone02Lenght" value = "48.80*mm"/> + <constant name = "UX853Cone0304Lenght" value = "401.20*mm"/> + <constant name = "UX853Cone05Lenght" value = "800.00*mm"/> + +<!-- UX85-3 Lenght of sections related to split between Rich2 and Downstream --> +<!-- manifactured 5 mm shorter than design --> + <constant name = "UX853Cone11Cone14Lenght" value = "1495.00*mm"/> + <constant name = "UX853Cone15Flange17Lenght" value = "100.00*mm"/> + <constant name = "UX853ConeSupportFromEnd" value = "1175.50*mm"/> + <constant name = "UX853Cone12Lenght" value = "50.00*mm"/> + +<!-- Support Ring between Rich2 and M1 split --> + <constant name = "UX853CableZposIP" value = "11907.00*mm"/> + <constant name = "UX853CollarInnerRadius" value = "122.10*mm"/> + <constant name = "UX853CollarMiddleRadius" value = "126.50*mm"/> + <constant name = "UX853CollarOuterRadius" value = "140.00*mm"/> + <constant name = "UX853CollarSize" value = "24.00*mm"/> + <constant name = "UX853CollarRich2Size" + value = "UX853Rich2DownSplitZposIP - + (UX853CableZposIP - 0.5*UX853CollarSize)"/> + +<!-- Permanent Bakeout in RICH2 --> + <constant name = "UX853BakeoutRich2StartIP" value = "9450.00*mm"/> + <constant name = "UX853BakeoutRich2Lenght" + value = "(UX853Rich2DownSplitZposIP - UX853CollarRich2Size) - + UX853BakeoutRich2StartIP" /> + +<!-- Compensator at 13100 (-5mm shorter) General Positions and splits --> + <constant name = "UX85C13100ZStartIP" value ="13095.00*mm"/> + +<!-- UX85-4 General Positions--> + <constant name = "UX854ZStartIP" value ="14400.00*mm"/> + + +</define> diff --git a/examples/DDUpgrade/compact/Regions/detector.xml b/examples/DDUpgrade/compact/Regions/detector.xml new file mode 100644 index 0000000000000000000000000000000000000000..818150e953efdad4a2c6d73f461d80dc4f973d1a --- /dev/null +++ b/examples/DDUpgrade/compact/Regions/detector.xml @@ -0,0 +1,56 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the LHCb detector region definitions --> +<!-- ========================================================================== --> +<lccdd> + <detectors> + <detector name="UpstreamRegion" type="DD4hep_VolumeAssembly" vis="Regions:UpstreamVis"> + <envelope name="UpstreamRegionEnvelope" type="Box" material="Air" dx="1000*cm" dy="1000*cm" dz="1000*cm"/> + <position x="0*cm" y="0*cm" z="-1270*cm"/> + </detector> + + <detector name="BeforeMagnetRegion" type="DD4hep_VolumeAssembly" vis="Regions:BeforeMagnetVis"> + <envelope material="Air"> + <shape type="Box" dx="1000*cm" dy="1000*cm" dz="270*cm"/> + </envelope> + <position x="0*cm" y="0*cm" z="0*cm"/> + <volume name="lvBeforeVelo" material="Air" vis="Regions:BeforeVeloVis"> + <shape type="Box" + dx="Regions:BeforeVeloXSize/2" + dy="Regions:BeforeVeloYSize/2" + dz="Regions:BeforeVeloZSize/2"/> + </volume> + <physvol element="BeforeVelo" volume="lvBeforeVelo"> + <position x="0*mm" y="0*mm" z="-1792.5*mm"/> + </physvol> + </detector> + + <detector name="MagnetRegion" type="DD4hep_VolumeAssembly" vis="Regions:MagnetVis"> + <envelope type="Box" material="Air" + dx="Regions:MagnetRegionXSize/2" dy="Regions:MagnetRegionYSize/2" dz="Regions:MagnetRegionZSize/2"/> + <position x="0*cm" y="0*cm" z="516*cm"/> + </detector> + + <detector name="AfterMagnetRegion" type="DD4hep_VolumeAssembly" vis="Regions:AfterMagnetVis"> + <envelope type="Box" material="Air" dx="1000*cm" dy="1000*cm" dz="214*cm"/> + <position x="0*cm" y="0*cm" z="976*cm"/> + </detector> + + <detector name="DownstreamRegion" type="DD4hep_VolumeAssembly" vis="Regions:DownstreamVis"> + <envelope material="Air"> + <shape type="Box" dx="1000*cm" dy="1000*cm" dz="400*cm"/> + </envelope> + <position x="0*cm" y="0*cm" z="1590*cm"/> + </detector> + </detectors> +</lccdd> diff --git a/examples/DDUpgrade/compact/Regions/parameters.xml b/examples/DDUpgrade/compact/Regions/parameters.xml new file mode 100644 index 0000000000000000000000000000000000000000..f69cd91bc652af3f0c42c4f1db22c51fea4b931f --- /dev/null +++ b/examples/DDUpgrade/compact/Regions/parameters.xml @@ -0,0 +1,74 @@ +<!-- ========================================================================== --> +<!-- --> +<!-- 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 --> +<!-- @date 14/10/2018 --> +<!-- --> +<!-- ========================================================================== --> +<!-- XML description of the LHCb detector region parameters --> +<!-- ========================================================================== --> +<lccdd> + + <define> + <!-- Upstream parameters --> + <constant name="Regions:UpstreamXSize" value="20000*mm" /> + <constant name="Regions:UpstreamYSize" value="20000*mm" /> + <!-- UpstreamZSize = 22700 mm - 2700 mm--> + <constant name="Regions:UpstreamZSize" value="20000*mm" /> + + <!-- BeforeMagnet parameters --> + <constant name="Regions:BeforeMagnetXSize" value="20000*mm" /> + <constant name="Regions:BeforeMagnetYSize" value="20000*mm" /> + <!-- BeforeMagnetZSize = 2700 mm + 2700 mm --> + <constant name="Regions:BeforeMagnetZSize" value="5400*mm" /> + + <!-- Magnet parameters --> + <constant name="Regions:MagnetRegionXSize" value="20000*mm" /> + <constant name="Regions:MagnetRegionYSize" value="20000*mm" /> + <!-- MagnetZSize = 7620 mm - 2700 mm --> + <constant name="Regions:MagnetRegionZSize" value="4920*mm" /> + + <!-- AfterMagnet parameters --> + <constant name="Regions:AfterMagnetXSize" value="20000*mm" /> + <constant name="Regions:AfterMagnetYSize" value="20000*mm" /> + <!-- IT1 starts at 7620mm = 7628mm - 8mm (=3950*4mrad) --> + <!-- AfterMagnetZSize = 11900 mm - 7620 mm --> + <constant name="Regions:AfterMagnetZSize" value="4280*mm" /> + + <!-- DownStream parameters --> + <constant name="Regions:DownstreamXSize" value="20000*mm" /> + <constant name="Regions:DownstreamYSize" value="20000*mm" /> + <!-- AfterMagnetZSize = 22900 mm - 11900 mm --> + <constant name="Regions:DownstreamZSize" value="8000*mm" /> + + <!-- Z_center coordinates of the regions --> + <constant name="Regions:UpstreamZPos" + value="-.5*(Regions:UpstreamZSize+Regions:BeforeMagnetZSize)" /> + <!-- BeforeMagnet region is centered about the LHCb origin --> + <constant name="Regions:BeforeMagnetZPos" value="0" /> + <constant name="Regions:MagnetRegionZPos" value=".5*(Regions:BeforeMagnetZSize+Regions:MagnetRegionZSize)" /> + <constant name="Regions:AfterMagnetZPos" + value="Regions:MagnetRegionZSize+.5*(Regions:BeforeMagnetZSize+Regions:AfterMagnetZSize)" /> + <constant name="Regions:DownstreamZPos" + value="Regions:MagnetRegionZSize+Regions:AfterMagnetZSize+.5*(Regions:BeforeMagnetZSize+Regions:DownstreamZSize)" /> + + <constant name="Regions:BeforeVeloXSize" value="3100*mm"/> + <constant name="Regions:BeforeVeloYSize" value="3100*mm"/> + <constant name="Regions:BeforeVeloZSize" value="1815*mm"/> + </define> + + <display> + <vis name="Regions:UpstreamVis" alpha="0.3" r="0.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="Regions:BeforeMagnetVis" alpha="0.3" r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="Regions:BeforeVeloVis" alpha="0.5" r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="Regions:MagnetVis" alpha="0.3" r="0.0" g="0.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="Regions:AfterMagnetVis" alpha="0.3" r="1.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="Regions:DownstreamVis" alpha="0.3" r="1.0" g="0.0" b="1.0" showDaughters="true" visible="true"/> + </display> + +</lccdd> diff --git a/examples/DDUpgrade/compact/UT.xml b/examples/DDUpgrade/compact/UT.xml new file mode 100644 index 0000000000000000000000000000000000000000..ee82669cb17fddc6ee4c7f501a54894a9bb81bdb --- /dev/null +++ b/examples/DDUpgrade/compact/UT.xml @@ -0,0 +1,490 @@ +<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"> + <!-- Have the materials --> + <includes> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> + </includes> + + <define> + <!-- Define the world box --> + <constant name="world_side" value="50000*mm"/> + <constant name="world_x" value="world_side"/> + <constant name="world_y" value="world_side"/> + <constant name="world_z" value="world_side"/> + + <include ref="PipeGeomParams.xml"/> + <include ref="PipeBeforeMagGeomParams.xml"/> + <include ref="UTGeometryParams.xml"/> + + </define> + <materials> + <material name="UT/BoxWall"> + <D value="17.7" unit="g/cm3"/> + <fraction n="0.925" ref="W"/> + <fraction n="0.066" ref="Ni"/> + <fraction n="0.009" ref="Fe"/> + </material> + <material name="UT/BeamPipeJacket"> + <D value="17.7" unit="g/cm3"/> + <fraction n="1.0" ref="Fe"/> + </material> + <material name="UT/HybridFlex"> + <D type="density" value="2.65" unit="g/cm3"/> + <composite n="1" ref="Si"/> + </material> + <material name="UT/UTAsic"> + <D type="density" value="2.65" unit="g/cm3"/> + <composite n="1" ref="Si"/> + </material> + </materials> + + <comment>Common Generic visualization attributes</comment> + <display> + <vis name="InvisibleWithDaughters" showDaughters="true" visible="false"/> + <vis name="BlackVis" alpha="1.0" r="0.1" g="0.1" b="0.1" showDaughters="false" visible="true"/> + <vis name="UT_Envelope_Vis" alpha="0.1" r="0.9" g="0.9" b="0.9" showDaughters="true" visible="false"/> +<!-- + <vis name="UT_Envelope_Vis" alpha="0.1" r="0.9" g="0.9" b="0.9" showDaughters="true" visible="true"/> +--> + <vis name="UT_Frame_Vis" alpha="0.4" r="0.1" g="0.1" b="0.5" showDaughters="true" visible="true"/> + <vis name="UT_Box_Vis" alpha="0.4" r="0.5" g="0.0" b="0.0" showDaughters="true" visible="false"/> + <vis name="UT_A_Vis" alpha="0.1" r="0.9" g="0.0" b="0.9" showDaughters="true" visible="false"/> + <vis name="UT_B_Vis" alpha="0.1" r="0.0" g="0.9" b="0.0" showDaughters="true" visible="false"/> + + <vis name="UT_Module_Vis" alpha="1.0" r="0.9" g="0.2" b="0.2" showDaughters="true" visible="false"/> + <vis name="UT_Hybrid_Vis" alpha="0.8" r="0.0" g="0.2" b="0.9" showDaughters="true" visible="false"/> + <vis name="UT_Hybrid_Flex_Vis" alpha="0.8" r="1.0" g="0.2" b="0.0" showDaughters="true" visible="true"/> + <vis name="UT_Asic_Vis" alpha="0.8" r="0.0" g="0.2" b="0.9" showDaughters="true" visible="true"/> + <vis name="UT_Station_Vis" alpha="1.0" r="0.2" g="0.8" b="0.2" showDaughters="true" visible="true"/> + <vis name="UT_Xlayer_Vis" alpha="1.0" r="0.4" g="0.4" b="0.4" showDaughters="true" visible="false"/> + <vis name="UT_Ulayer_Vis" alpha="1.0" r="0.9" g="0.9" b="0.0" showDaughters="true" visible="false"/> + </display> + + <geometry open="true" close="true"/> + + <!-- Includes for sensitives and support --> + <detectors> + + <detector id="1" name="UT" type="DD4hep_UT" vis="UUT_Envelope_Vis" readout="UUTHits"> + <params> + <param name="BeamHoleRadius" value="UTBeamHoleRadius"/> + + <param name="FrameOuterWidth" value="UTFrameOuterWidth"/> + <param name="FrameOuterHeight" value="UTFrameOuterHeight"/> + <param name="FrameInnerWidth" value="UTFrameInnerWidth"/> + <param name="FrameInnerHeight" value="UTFrameInnerHeight"/> + <param name="FrameThickness" value="UTFrameThickness"/> + + <param name="BoxOuterWidth" value="UTBoxOuterWidth"/> + <param name="BoxOuterHeight" value="UTBoxOuterHeight"/> + <param name="BoxOuterThickness" value="UTBoxOuterThickness"/> + <param name="BoxInnerWidth" value="UTBoxInnerWidth"/> + <param name="BoxInnerHeight" value="UTBoxInnerHeight"/> + <param name="BoxInnerThickness" value="UTBoxInnerThickness"/> + <param name="BoxBeamHoleRadius" value="UTBoxBeamHoleRadius"/> + + <param name="VirtualBoxWidth" value="UTVirtualBoxWidth"/> + <param name="VirtualBoxHeight" value="UTVirtualBoxHeight"/> + <param name="VirtualHoleRadius" value="UTVirtualHoleRadius"/> + + <param name="LayerDz" value="UTLayerDz"/> + <param name="LayerThickness" value="UTLayerThickness"/> + + <param name="StationDz" value="UTStationDz"/> + <param name="StationThickness" value="UTStationThickness"/> + + <param name="SensorWidth" value="UTSensorWidth"/> + <param name="SensorHeight" value="UTSensorHeight"/> + + <param name="ModuleWidth" value="UTModuleWidth"/> + <param name="ModuleHeight" value="UTModuleHeight"/> + <param name="ModuleThickness" value="UTModuleThickness"/> + <param name="ModuleHybridStepY" value="UTModuleHybridStepY"/> + <param name="ModuleHybridZ" value="UTModuleHybridZ"/> + + <param name="BalconyYposX" value="UTBalconyYposX"/> +<!-- + <param name="" value=""/> + <param name="" value=""/> + <param name="" value=""/> +--> + <param name="SensorSiWidth" value="UTSensorSiWidth"/> + <param name="SensorSiHeight" value="UTSensorSiHeight"/> + <param name="SensorSiZ" value="UTSensorSiZ"/> + <param name="SensorSiThickness" value="UTSensorSiThickness"/> + <param name="SensorSiOverlapX" value="UTSensorSiOverlapX"/> + <param name="SensorSiOverlapY" value="UTSensorSiOverlapY"/> + + <param name="SensorGRWidth" value="UTSensorGRWidth"/> + <param name="SensorGRZ" value="UTSensorGRZ"/> + <param name="SensorGRThickness" value="UTSensorGRThickness"/> + <param name="SensorAlZ" value="UTSensorAlZ"/> + <param name="SensorAlThickness" value="UTSensorAlThickness"/> + + <param name="AsicWidth" value="UTAsicWidth"/> + <param name="AsicHeight" value="UTAsicHeight"/> + <param name="AsicThickness" value="UTAsicThicknessAve"/> + + <param name="HybridWidth" value="UTHybridWidth"/> + <param name="HybridHeight" value="UTHybridHeight"/> + <param name="HybridThickness" value="UTHybridThickness"/> + <param name="HybridSensorZ" value="UTHybridSensorZ"/> + <param name="HybridAsicY" value="UTHybridAsicY"/> + <param name="HybridAsicZbase" value="UTHybridAsicZbase"/> + + <param name="HybridFlexY" value="UTHybridFlexY"/> + <param name="HybridFlexZ" value="UTHybridFlexZ"/> + <param name="HybridFlexWidth" value="UTHybridFlexWidth"/> + <param name="HybridFlexHeight" value="UTHybridFlexHeight"/> + <param name="HybridFlexThickness" value="UTHybridFlexThickness"/> + + <param name="CylJacketLength" value="UTCylJacketLength"/> + <param name="CylJacketRadius" value="UTCylJacketRadius"/> + <param name="CylJacketThickness" value="UTCylJacketThickness"/> + <param name="CylJacketZpos" value="UTCylJacketZpos"/> + + <param name="ConeJacketLength" value="UTConeJacketLength"/> + <param name="ConeJacketRadiusZmax" value="UTConeJacketRadiusZmax"/> + <param name="ConeJacketRadiusZmin" value="UTConeJacketRadiusZmin"/> + <param name="ConeJacketThickness" value="UTConeJacketThickness"/> + <param name="ConeJacketZpos" value="UTConeJacketZpos"/> + </params> +<!-- + <param name="" value=""/> + <param name="" value=""/> + <param name="" value=""/> + <param name="" value=""/> + <param name="" value=""/> +--> + + <debug> + <item name="Build_Box" value="true"/> + <item name="Build_Frame" value="true"/> + <item name="Build_Jacket" value="true"/> + <item name="Build_UTA" value="true"/> + <item name="Build_UTB" value="true"/> + </debug> + + <volumes> + <volume name="lvUT" material="Air" vis="UT_Envelope_Vis"> + <shape type="Box" x="UTFrameOuterWidth" y="UTFrameOuterHeight" z="UTBoxOuterThickness"/> + </volume> + <volume name="lvUTFrame" material="Al" vis="UT_Frame_Vis"> + <shape type="subtraction"/> + <shape type="Box" x="UTFrameOuterWidth" y="UTFrameOuterHeight" z="UTFrameThickness"/> + <shape type="Box" x="UTFrameOuterWidth" y="UTFrameOuterHeight" z="1.1*UTFrameThickness"/> + <!-- optional <position x="0" y="0" z="0"/> --> + </volume> + <volume name="lvUTBox" material="" vis="UT_Frame_Vis"> + <shape type="subtraction"/> + <shape type="subtraction"/> + <shape type="Box" x="UTBoxOuterWidth" y="UTBoxOuterHeight" z="UTBoxOuterThickness"/> + <shape type="Box" x="UTBoxInnerWidth" y="UTBoxInnerHeight" z="UTBoxInnerThickness"/> + </shape> + <shape type="Tube" rmax="UTBoxBeamHoleRadius" dz="UTBoxOuterThickness*1.1"/> + </shape> + </volume> + + <!-- ========== Jacket sub-volumes ========== --> + <volume name="lvUTCylJacket" material="UT/Kapton"> + <shape type="Tube" rmin="UTCylJacketRadius" rmax="UTCylJacketRadius+UTCylJacketThickness" dz="UTCylJacketLength"/> + </volume> + <volume name="lvUTConeJacket" material="UT/Kapton"> + <shape type="Cone" rmin1="UTConeJacketRadiusZmin" rmax1="UTConeJacketRadiusZmin+UTConeJacketThickness" + rmin2="UTConeJacketRadiusZmax" rmax2="UTConeJacketRadiusZmax+UTConeJacketThickness" + z="UTConeJacketLength"/> + </shape> + </volume> + + <!-- ========== Readout ASIC ========== --> + <volume name="lvAsic4" material="UT/UTAsic"> + <shape type="Box" x="UTSensorWidth" y="UTAsicHeight" z="UTAsicThicknessAve*4"/> + </volume> + <volume name="lvAsic8" material="UT/UTAsic"> + <shape type="Box" x="UTSensorWidth" y="UTAsicHeight" z="UTAsicThicknessAve*8"/> + </volume> + <volume name="lvAsic16" material="UT/UTAsic"> + <shape type="Box" x="UTSensorWidth" y="UTAsicHeight" z="UTAsicThicknessAve*16"/> + </volume> + <volume name="lvAsic3Slim" material="UT/UTAsic"> + <shape type="Box" x="UTSensorWidth" y="UTAsicHeight" z="UTAsicThicknessAve*3"/> + </volume> + <volume name="lvAsic6Slim" material="UT/UTAsic"> + <shape type="Box" x="UTSensorWidth" y="UTAsicHeight" z="UTAsicThicknessAve*6"/> + </volume> + <volume name="lvAsic11Slim" material="UT/UTAsic"> + <shape type="Box" x="UTSensorWidth" y="UTAsicHeight" z="UTAsicThicknessAve*11"/> + </volume> + + <!-- ========== Substrate ========== --> + <volume name="lvSubstrate" material="UT/Substrate"> + <shape type="Box" x="UTSubstrateWidth" y="UTSubstrateHeight" z="UTSubstrateThickness"/> + </volume> + <volume name="lvSubstrateSlim" material="UT/Substrate"> + <shape type="Box" x="UTSubstrateWidthSlim" y="UTSubstrateHeight" z="UTSubstrateThickness"/> + </volume> + <volume name="lvSubstrateSlimCut" material="UT/Substrate"> + <shape type="subtraction"/> + <shape type="Box" x="UTSubstrateWidthSlim" y="UTSubstrateHeight" z="UTSubstrateThickness"/> + <shape type="Tube" rmax="UTBeamHoleRadius" dz="UTSubstrateThickness*2"/> + <position y="UTSubstrateHeight/2+UTSensorMiddleDistY-UTHybridSensorEdge1"/> + </shape> + </volume> + + <!-- ========== Hybrid = Sensor + Substrate + ASICs ========== --> + <volume name="HybridNorm" material="Air"> + <shape type="Box" x="UTHybridWidth" y="UTHybridHeight" z="UTHybridThickness"/> + <physvol logvol="lvSubstrateNorm"> <position z="UTHybridSubstrateZ"/></physvol> + <physvol logvol="lvGroupNorm"> <position y="UTHybridSensorY" z="UTHybridSensorZ"/></physvol> + <physvol logvol="lvAsic4"> <position y="UTHybridAsicY " z="UTHybridAsicZbase-UTAsicThicknessAve*4/2"/></physvol> + </volume> + <volume name="HybridDual" material="Air"> + <shape type="Box" x="UTHybridWidth" y="UTHybridHeight" z="UTHybridThickness"/> + <physvol logvol="lvSubstrate"> <position z="UTHybridSubstrateZ"/></physvol> + <physvol logvol="lvGroupDual"> <position y="UTHybridSensorY" z="UTHybridSensorZ"/></physvol> + <physvol logvol="lvAsic8"> <position y="UTHybridAsicY " z="UTHybridAsicZbase-UTAsicThicknessAve*8/2"/></physvol> + </volume> + <volume name="HybridQuad" material="Air"> + <shape type="Box" x="UTHybridWidth" y="UTHybridHeight" z="UTHybridThickness"/> + <physvol logvol="lvSubstrateQuad"> <position z="UTHybridSubstrateZ"/></physvol> + <physvol logvol="lvGroupQuad"> <position y="UTHybridSensorY" z="UTHybridSensorZ"/></physvol> + <physvol logvol="lvAsic16"> <position y="UTHybridAsicY" z="UTHybridAsicZbase-UTAsicThicknessAve*16/2"/></physvol> + </volume> + <volume name="HybridNormSlim" material="Air"> + <shape type="Box" x="UTHybridWidthSlim" y="UTHybridHeight" z="UTHybridThickness"/> + <physvol logvol="lvSubstrateSlim"> <position z="UTHybridSubstrateZ"/></physvol> + <physvol logvol="lvGroupDualSlim"> <position y="UTHybridSensorY" z="UTHybridSensorZ"/></physvol> + <physvol logvol="lvAsic6Slim"> <position y="UTHybridAsicY " z="UTHybridAsicZbase-UTAsicThicknessAveSlim*3/2"/></physvol> + </volume> + <volume name="HybridDualSlim" material="Air"> + <shape type="Box" x="UTHybridWidthSlim" y="UTHybridHeight" z="UTHybridThickness"/> + <physvol logvol="lvSubstrateDualSlim"><position z="UTHybridSubstrateZ"/></physvol> + <physvol logvol="lvGroupDualSlim"> <position y="UTHybridSensorY" z="UTHybridSensorZ"/></physvol> + <physvol logvol="lvAsic6Slim"> <position y="UTHybridAsicY " z="UTHybridAsicZbase-UTAsicThicknessAveSlim*6/2"/></physvol> + </volume> + <volume name="HybridQuadSlim" material="Air"> + <shape type="subtraction"/> + <shape type="Box" x="UTHybridWidthSlim" y="UTHybridHeight" z="UTHybridThickness"/> + <shape type="Tube" rmax="UTBeamHoleRadius" dz="UTHybridThickness*2"/> + <position y="UTHybridHeight/2+UTSensorMiddleDistY-UTHybridSensorEdge1"/> + </shape> + <physvol logvol="lvSubstrateQuadSlimCut"><position z="UTHybridSubstrateZ"/></physvol> + <physvol logvol="lvGroupQuadSlim"> <position y="UTHybridSensorY" z="UTHybridSensorZ"/></physvol> + <physvol logvol="lvAsic6Slim"> <position y="UTHybridAsicY " z="UTHybridAsicZbase-UTAsicThicknessAveSlim*11/2"/></physvol> + </volume> + </volumes> + + <jacket name="lvUTJacket" material="UT/BeamPipeJacket" vis="UT_Jacket_Vis"> + <physvol name="pvUTCylJacket"><position z="UTCylJacketZpos"/></physvol> + <physvol name="lvUTConeJacket"><position z="UTConeJacketZpos"/></physvol> + </jacket> + + <envelope name="lvUT" vis="UT_Envelope_Vis"> + + <modules> + <module name="lvModuleA" material="Air"> + <stave/> + </module> + <modules> + + <!-- UT A --> + <uta name="UTa" material="Air" vis="UT_A_Vis"> + <envelope> + <box x="UTVirtualBoxWidth" y="UTVirtualBoxHeight" z="UTStationThickness"/> + <tube rmax="UTVirtualHoleRadius" z="UTStationThickness*1.1"/> + </envelope> + <position z="-0.5*UTStationDz"/> + <layers> + <layer name="UTaXLayer" type="X" vis="UT_Xlayer_Vis"> + <!-- Envelope volume --> + <envelope> + <box x="UTVirtualBoxWidth" y="UTVirtualBoxHeight" z="UTLayerThickness"/> + <tube rmax="UTVirtualHoleRadius" z="UTLayerThickness*1.1"/> + </envelope> + + <!-- Description of the containing modules --> + <modules> + <!-- Region 1 at -X --> + <module type="ModuleA"> + <position x="-UTModuleXposXLR-UTModuleStepUTaX0*7-UTModuleXposUTaXOffset0" z="-UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposXLR-UTModuleStepUTaX1*6" z="UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposXLR-UTModuleStepUTaX0*5-UTModuleXposUTaXOffset0" z="-UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposXLR-UTModuleStepUTaX1*4" z="UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposXLR-UTModuleStepUTaX0*3-UTModuleXposUTaXOffset0" z="-UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposXLR-UTModuleStepUTaX1*2" z="UTModuleDz/2"/> + </module> + <!-- Region 2 at -X --> + <module type="ModuleC"> + <position x="UTModuleXposXLR" z="UTModuleDz/2"/> + </module> + <module type="ModuleB"> + <position x="UTModuleXposXLR+UTModuleStepUTaX0+UTModuleXposUTaXOffset0" z="-UTModuleDz/2"/> + <rotation z="pi*rad"/> + </module> + <!-- Region 3 at +X --> + <module type="ModuleA"> + <position x="UTModuleXposXLR+UTModuleStepUTaX1*2" z="UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposXLR+UTModuleStepUTaX0*3+UTModuleXposUTaXOffset0" z="-UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposXLR+UTModuleStepUTaX1*4" z="UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposXLR+UTModuleStepUTaX0*5+UTModuleXposUTaXOffset0" z="-UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposXLR+UTModuleStepUTaX1*6" z="UTModuleDz/2"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposXLR+UTModuleStepUTaX0*7+UTModuleXposUTaXOffset0" z="-UTModuleDz/2"/> + </module> + </modules> + <!-- Balocony description --> + <balcony name="lvUTaXBalcony" material="Al" vis="UT_Alu_Vis"> + <box x="UTBalconyWidthUTa" y="UTBalconyHeightX" z="UTBalconyThickness"/> + <params step="UTModuleStepX" correction="UTModuleCorrectXa" dz="UTModuleDz/2"/> + <position y="UTBalconyYposX"/> + <position y="-UTBalconyYposX"/> + </balcony> + <!-- Layer position --> + <position z="-0.5*UTLayerDz"/> + </layer> + <layer type="U" vis="UT_Ulayer_Vis"> + <!-- Envelope volume --> + <envelope> + <box x="UTVirtualBoxWidth" y="UTVirtualBoxHeight" z="UTLayerThickness"/> + <tube rmax="UTVirtualHoleRadius" z="UTLayerThickness*1.1"/> + </envelope> + <!-- Description of the containing modules --> + <modules> + <!-- Region 1 at -X --> + <module type="ModuleA"> + <position x="-UTModuleXposULR-UTModuleStepUTaU0*7-UTModuleXposUTaUOffset0" z="-UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposULR-UTModuleStepUTaU1*6" z="UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposULR-UTModuleStepUTaU0*5-UTModuleXposUTaUOffset0" z="-UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposULR-UTModuleStepUTaU1*4" z="UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposULR-UTModuleStepUTaU0*3-UTModuleXposUTaUOffset0" z="-UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="-UTModuleXposULR-UTModuleStepUTaU1*2" z="UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <!-- Region 2 at -X --> + <module type="ModuleB"> + <position x="-UTModuleXposULR-UTModuleStepUTaU0-UTModuleXposUTaUOffset0" z="-UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleC"> + <position x="-UTModuleXposULR" z="UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <!-- Region 2 in the middle --> + <module type="ModuleD"> + <position x="-UTModuleXposUTB" y="-UTModuleYposUTB" z="-UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleD"> + <position x="UTModuleXposUTB" y="UTModuleYposUTB" z="UTModuleDz/2"/> + <rotation z="pi*rad--UTAngle"/> + </module> + <!-- Region 2 at +X --> + <module type="ModuleA"> + <position x="UTModuleXposULR" z="-UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposULR+UTModuleStepUTaU0+UTModuleXposUTaUOffset0" z="UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <!-- Region 3 at +X --> + <module type="ModuleA"> + <position x="UTModuleXposULR+UTModuleStepUTaU1*2" z="UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposULR+UTModuleStepUTaU0*3+UTModuleXposUTaUOffset0" z="-UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposULR+UTModuleStepUTaU1*4" z="UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposULR+UTModuleStepUTaU0*5+UTModuleXposUTaUOffset0" z="-UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposULR+UTModuleStepUTaU1*6" z="UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + <module type="ModuleA"> + <position x="UTModuleXposULR+UTModuleStepUTaU0*7+UTModuleXposUTaUOffset0" z="-UTModuleDz/2"/> + <rotation z="-UTAngle"/> + </module> + </modules> + <!-- Balocony description --> + <balcony name="lvUTaUBalcony" material="Al" vis="UT_Alu_Vis"> + <box x="UTBalconyWidthUTa" y="UTBalconyHeightU" z="UTBalconyThickness"/> + <params step="UTModuleStepX" correction="UTModuleCorrectXa" dz="UTModuleDz/2"/> + <position x="UTBalconyYposU*UTSinAngle" y="UTBalconyYposU" z="0.0*mm"/> + <position x="-UTBalconyYposU*UTSinAngle" y="-UTBalconyYposU" z="0.0*mm"/> + </balcony> + <!-- Layer position --> + <position z="0.5*UTLayerDz"/> + </layer> + </uta> + <utb name="lvUTb" material="Air" vis="UT_B_Vis"> + <position z="0.5*UTStationDz"/> + <V vis="UT_Ulayer_Vis"><position z="-0.5*UTLayerDz"/></V> + <X vis="UT_Xlayer_Vis"><position z="0.5*UTLayerDz"/></X> + </utb> + </envelope> + + </detector> + </detectors> + <limits> + <limitset name="codex_limits"> + <limit name="step_length_max" particles="*" value="5.0" unit="mm" /> + </limitset> + </limits> + <readouts> + <readout name="UUTHits"> + <segmentation type="CartesianGridXY" grid_size_x="1*cm" grid_size_y="1*cm" /> + <id>system:8,type:3,station:10,x:32:-16,y:-16</id> + </readout> + </readouts> + + <fields> + </fields> + +</lccdd> + + + diff --git a/examples/DDUpgrade/compact/UTGeometryParams.xml b/examples/DDUpgrade/compact/UTGeometryParams.xml new file mode 100644 index 0000000000000000000000000000000000000000..f8460857a91383748df8bbf8668dfec2a1752ce0 --- /dev/null +++ b/examples/DDUpgrade/compact/UTGeometryParams.xml @@ -0,0 +1,174 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<define> + + <!-- UT Geometry parameters --> + <!-- * Author: Jianchun Wang * --> + + <!-- Aluminium frame --> + <constant name="UTFrameThickness" value="15*mm" /> + <constant name="UTFrameOuterWidth" value="2586*mm" /> + <constant name="UTFrameOuterHeight" value="2628*mm" /> + <constant name="UTFrameInnerWidth" value="1960*mm" /> + <constant name="UTFrameInnerHeight" value="2000*mm" /> + + <!-- UT light tight box --> + <constant name="UTBoxOuterThickness" value="430.0*mm" /> + <constant name="UTBoxOuterWidth" value="UTFrameInnerWidth" /> + <constant name="UTBoxOuterHeight" value="UTFrameInnerHeight" /> + <constant name="UTBoxInnerThickness" value="UTBoxOuterThickness-2*UTBoxWallThickness" /> + <constant name="UTBoxInnerWidth" value="UTBoxOuterWidth-2*UTBoxWallThickness" /> + <constant name="UTBoxInnerHeight" value="UTBoxOuterHeight-2*UTBoxWallThickness" /> + <constant name="UTBoxWallThickness" value="0.4*mm" /> + <constant name="UTBoxBeamHoleRadius" value="28.2*mm" /> + + <!-- Kapton beam pipe jacket --> + <constant name="UTCylJacketThickness" value="0.1*mm" /> + <constant name="UTCylJacketZpos" value="UTCylJacketLength*0.5" /> + <constant name="UTCylJacketLength" value="UX851Cyl07BLenght" /> <!-- 230 --> + <constant name="UTCylJacketRadius" value="UX851Cyl07Radius+UX851Cyl07Thick+0.01*mm" /> <!-- 25+1+0.01 --> + + <constant name="UTConeJacketThickness" value="0.1*mm" /> + <constant name="UTConeJacketZpos" value="UTCylJacketLength+UTConeJacketLength*0.5" /> + <constant name="UTConeJacketLength" value="UX851Cone08ALenght" /> <!-- 200 --> + <constant name="UTConeJacketRadiusZmax" value="UX851Cone08ARadiusZmax+UX851Cone08AThick+0.01*mm" /> <!-- 27.0009+1+0.01 --> + <constant name="UTConeJacketRadiusZmin" value="UX851Cone08ARadiusZmin+UX851Cone08AThick+0.01*mm" /> <!-- 25+1+0.01 --> + + <!-- Detector Z positions --> + <constant name="UTSystemZ" value="2485*mm" /> + <constant name="UTStationDz" value="270*mm" /> + <constant name="UTLayerDz" value="45*mm" /> + <constant name="UTModuleDz" value="10*mm" /> + + <!-- virtual thickness --> + <constant name="UTStationThickness" value="70*mm" /> + <constant name="UTLayerThickness" value="25*mm" /> + <constant name="UTVirtualBoxWidth" value="1900*mm" /> + <constant name="UTVirtualBoxHeight" value="1900*mm" /> + <constant name="UTVirtualHoleRadius" value="UTBeamHoleRadius"/> + + <!-- Beam pipe hole --> + <constant name="UTBeamHoleRadius" value="27.6*mm"/> + + <!-- Balcony for each UT layer --> + <constant name="UTBalconyThickness" value="8.0*mm"/> + <constant name="UTBalconyWidthUTa" value="1500*mm"/> + <constant name="UTBalconyWidthUTb" value="1677*mm"/> + <constant name="UTBalconyHeightX" value="130.0*mm"/> + <constant name="UTBalconyHeightU" value="UTBalconyHeightX-1.15*mm"/> + <constant name="UTBalconyYposX" value="0.5*(UTModuleHeight+UTBalconyHeightX)+2.0*mm" /> + <constant name="UTBalconyYposU" value="0.5*(UTModuleHeight*UTCosAngle+UTModuleWidth*UTSinAngle+UTBalconyHeightU)+2.0*mm" /> + + <!-- UT sensors --> + <constant name="UTSensorAlThickness" value="0.01*mm" /> + <constant name="UTSensorSiThickness" value="0.25*mm" /> + <constant name="UTSensorHeight" value="100.0*mm" /> + <constant name="UTSensorWidth" value="92.0*mm" /> + <constant name="UTSensorWidthSlim" value="2*UTBeamHoleRadius+2*UTModuleOverlapX -0.2*mm" /> <!-- 57.8 --> + <constant name="UTSensorThickness" value="UTSensorAlThickness+UTSensorSiThickness" /> + + <constant name="UTSensorGRWidth" value="0.5*mm" /> + <constant name="UTSensorGRSiThickness" value="UTSensorSiThickness" /> + <constant name="UTSensorWidthInner" value="UTSensorWidth-2*UTSensorGRWidth" /> + <constant name="UTSensorWidthInnerSlim" value="UTSensorWidthSlim-2*UTSensorGRWidth" /> + <constant name="UTSensorHeightInner" value="UTSensorHeight-2*UTSensorGRWidth" /> + + <constant name="UTSensorMiddleDistY" value="10*mm" /> <!-- the closest edge to Y=0 --> + <constant name="UTSensorOverlapY" value="1.2*mm" /> + + <!-- Asic --> + <constant name="UTAsicWidth" value="5.4*mm" /> + <constant name="UTAsicHeight" value="6.6*mm" /> + <constant name="UTAsicThickness" value="0.12*mm" /> + + <constant name="UTAsicThicknessAve" value="UTAsicThickness*UTAsicWidth/UTSensorWidth" /> + <constant name="UTAsicThicknessAveSlim" value="UTAsicThickness*UTAsicWidth/UTSensorWidthSlim" /> + + <!-- Substrate --> + <constant name="UTSubstrateWidth" value="UTSensorWidth" /> + <constant name="UTSubstrateWidthSlim" value="UTSensorWidthSlim" /> + <constant name="UTSubstrateHeight" value="110*mm" /> + <constant name="UTSubstrateThickness" value="0.356*mm" /> + + <!-- Hybrid --> + <constant name="UTHybridWidth" value="UTSubstrateWidth" /> + <constant name="UTHybridWidthSlim" value="UTSubstrateWidthSlim" /> + <constant name="UTHybridHeight" value="UTSubstrateHeight" /> + <constant name="UTHybridThickness" value="UTSubstrateThickness+UTSensorThickness" /> + + <!-- 0.0 + (100) + 2 + (6.6) + 1.4 = 110 --> + <constant name="UTHybridSubstrateZ" value="UTSensorThickness/2" /> + <constant name="UTHybridSensorZ" value="-UTSubstrateThickness/2" /> + <constant name="UTHybridAsicZ" value="(UTSensorThickness-UTSubstrateThickness-UTAsicThickness)/2" /> + <constant name="UTHybridAsicZbase" value="(UTSensorThickness-UTSubstrateThickness)/2" /> + <constant name="UTHybridSensorEdge1" value="0.0*mm" /> + <constant name="UTHybridSensorEdge2" value="UTHybridHeight-UTSensorHeight-UTHybridSensorEdge1" /> + <constant name="UTHybridSensorY" value="(UTHybridHeight-UTSensorHeight)/2-UTHybridSensorEdge1" /> + <constant name="UTHybridAsicEdge1" value="1.4*mm" /> + <constant name="UTHybridAsicEdge2" value="UTHybridHeight-UTAsicHeight-UTHybridAsicEdge1" /> + <constant name="UTHybridAsicY" value="-(UTHybridHeight-UTAsicHeight)/2+UTHybridAsicEdge1" /> + + <!-- Module Support --> + <constant name="UTModuleSupportEndHeight" value="75.0*mm" /> + <constant name="UTModuleSupportWidth" value="UTSensorWidth" /> + <constant name="UTModuleSupportHeight" value="UTSensorHeight*13-UTSensorOverlapY*12+UTHybridSensorEdge2*2+UTModuleSupportEndHeight*2" /> <!-- 1456.8 --> + <constant name="UTModuleSupportWidthSlim" value="UTSensorWidthSlim" /> + <constant name="UTModuleSupportHeightSlim" value="UTModuleSupportHeight/2-UTSensorMiddleDistY" /> <!-- 718.4 --> + <constant name="UTModuleSupportEndHeightSlim" value="UTModuleSupportHeightSlim-(UTSensorHeight*6-UTSensorOverlapY*5+UTHybridSensorEdge1+UTHybridSensorEdge2)" /> + + <constant name="UTModuleSupportThickness" value="1.982*mm" /> + <constant name="UTModuleSupportTrueThickness" value="3.3*mm" /> + + <!-- Kapton foil--> + <constant name="UTKaptonWidthX" value="20.0*mm" /> + <constant name="UTKaptonWidthY" value="UTKaptonWidthX" /> + <constant name="UTKaptonFoilWidth" value="UTModuleSupportWidth" /> + <constant name="UTKaptonFoilWidthSlim" value="UTModuleSupportWidthSlim" /> + <constant name="UTKaptonFoilHeight" value="UTModuleSupportHeight" /> + <constant name="UTKaptonFoilHeightSlim" value="UTModuleSupportHeightSlim" /> + <constant name="UTKaptonFoilThickness" value="0.122*mm" /> + + <!-- UT module --> + <constant name="UTModuleWidth" value="UTModuleSupportWidth" /> + <constant name="UTModuleWidthSlim" value="UTModuleSupportWidthSlim" /> + <constant name="UTModuleHeight" value="UTModuleSupportHeight" /> + <constant name="UTModuleHeightSlim" value="UTModuleSupportHeightSlim" /> + <constant name="UTModuleThickness" value="UTHybridThickness*2+UTKaptonFoilThickness*2+UTModuleSupportTrueThickness" /> + + <constant name="UTModuleHybridStepY" value="UTSensorHeight-UTSensorOverlapY" /> + <constant name="UTModuleHybridStepY0" value="UTModuleHybridStepY - 0.090*mm" /> <!-- upstream --> + <constant name="UTModuleHybridStepY1" value="UTModuleHybridStepY + 0.090*mm" /> <!-- downstream --> + <constant name="UTModuleSlimY7" value="UTModuleHeightSlim/2-UTHybridHeight/2" /> + <constant name="UTModuleSlimYOffset1" value="0.109*mm" /> + + <constant name="UTModuleKaptonFoilZ" value="UTModuleSupportTrueThickness/2+UTKaptonFoilThickness/2" /> + <constant name="UTModuleHybridZ" value="UTModuleSupportTrueThickness/2+UTHybridThickness/2+UTKaptonFoilThickness" /> + + <!-- Stereo angle --> + <constant name="UTAngle" value="5.0*degree"/> + <constant name="UTSinAngle" value="sin(UTAngle)"/> + <constant name="UTCosAngle" value="cos(UTAngle)"/> + + <!-- Module positions --> + <constant name="UTModuleOverlapX" value="1.4*mm" /> + + <constant name="UTModuleXposXLR" value="UTBeamHoleRadius+UTSensorWidth/2.0" /> + <constant name="UTModuleYposXTB" value="UTSensorMiddleDistY+UTModuleHeightSlim/2" /> + <constant name="UTModuleStepUTaX0" value="UTSensorWidth-UTModuleOverlapX - 0.195*mm" /> + <constant name="UTModuleStepUTaX1" value="UTSensorWidth-UTModuleOverlapX + 0.195*mm" /> + <constant name="UTModuleStepUTbX0" value="UTSensorWidth-UTModuleOverlapX - 0.171*mm" /> + <constant name="UTModuleStepUTbX1" value="UTSensorWidth-UTModuleOverlapX + 0.171*mm" /> + <constant name="UTModuleXposUTaXOffset0" value="-0.316*mm" /> + <constant name="UTModuleXposUTbXOffset0" value="-0.278*mm" /> + + <constant name="UTModuleXposULR" value="UTModuleXposXLR/UTCosAngle" /> + <constant name="UTModuleXposUTB" value="UTModuleYposXTB*UTSinAngle" /> + <constant name="UTModuleYposUTB" value="UTModuleYposXTB*UTCosAngle" /> + <constant name="UTModuleStepUTaU0" value="(UTSensorWidth-UTModuleOverlapX - 0.191*mm)/UTCosAngle" /> + <constant name="UTModuleStepUTaU1" value="(UTSensorWidth-UTModuleOverlapX + 0.191*mm)/UTCosAngle" /> + <constant name="UTModuleStepUTbV0" value="(UTSensorWidth-UTModuleOverlapX - 0.174*mm)/UTCosAngle" /> + <constant name="UTModuleStepUTbV1" value="(UTSensorWidth-UTModuleOverlapX + 0.174*mm)/UTCosAngle" /> + <constant name="UTModuleXposUTaUOffset0" value="-0.310*mm/UTCosAngle" /> + <constant name="UTModuleXposUTbVOffset0" value="-0.283*mm/UTCosAngle" /> + + +</define> diff --git a/examples/DDUpgrade/compact/UUT.xml b/examples/DDUpgrade/compact/UUT.xml new file mode 100644 index 0000000000000000000000000000000000000000..79c1acd5fda68c18eacba8b6d37658d77441bc64 --- /dev/null +++ b/examples/DDUpgrade/compact/UUT.xml @@ -0,0 +1,219 @@ +<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"> + <!-- Have the materials --> + <includes> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> + </includes> + + <define> + <!-- Define the world box --> + <constant name="world_side" value="50000*mm"/> + <constant name="world_x" value="world_side"/> + <constant name="world_y" value="world_side"/> + <constant name="world_z" value="world_side"/> + + <include ref="PipeGeomParams.xml"/> + <include ref="PipeBeforeMagGeomParams.xml"/> + <include ref="UUTGeometryParams.xml"/> + + </define> + <materials> + <material name="UT/BoxWall"> + <D value="17.7" unit="g/cm3"/> + <fraction n="0.925" ref="W"/> + <fraction n="0.066" ref="Ni"/> + <fraction n="0.009" ref="Fe"/> + </material> + <material name="UT/BeamPipeJacket"> + <D value="17.7" unit="g/cm3"/> + <fraction n="1.0" ref="Fe"/> + </material> + <material name="UT/HybridFlex"> + <D type="density" value="2.65" unit="g/cm3"/> + <composite n="1" ref="Si"/> + </material> + <material name="UT/UTAsic"> + <D type="density" value="2.65" unit="g/cm3"/> + <composite n="1" ref="Si"/> + </material> + </materials> + + <comment>Common Generic visualization attributes</comment> + <display> + <vis name="InvisibleWithDaughters" showDaughters="true" visible="false"/> + <vis name="BlackVis" alpha="1.0" r="0.1" g="0.1" b="0.1" showDaughters="false" visible="true"/> + <vis name="UT_Envelope_Vis" alpha="0.1" r="0.9" g="0.9" b="0.9" showDaughters="true" visible="false"/> +<!-- + <vis name="UT_Envelope_Vis" alpha="0.1" r="0.9" g="0.9" b="0.9" showDaughters="true" visible="true"/> +--> + <vis name="UT_Frame_Vis" alpha="0.4" r="0.1" g="0.1" b="0.5" showDaughters="true" visible="true"/> + <vis name="UT_Box_Vis" alpha="0.4" r="0.5" g="0.0" b="0.0" showDaughters="true" visible="false"/> + <vis name="UT_A_Vis" alpha="0.1" r="0.9" g="0.0" b="0.9" showDaughters="true" visible="false"/> + <vis name="UT_B_Vis" alpha="0.1" r="0.0" g="0.9" b="0.0" showDaughters="true" visible="false"/> + + <vis name="UT_Module_Vis" alpha="1.0" r="0.9" g="0.2" b="0.2" showDaughters="true" visible="false"/> + <vis name="UT_Hybrid_Vis" alpha="0.8" r="0.0" g="0.2" b="0.9" showDaughters="true" visible="false"/> + <vis name="UT_Hybrid_Flex_Vis" alpha="0.8" r="1.0" g="0.2" b="0.0" showDaughters="true" visible="true"/> + <vis name="UT_Asic_Vis" alpha="0.8" r="0.0" g="0.2" b="0.9" showDaughters="true" visible="true"/> + <vis name="UT_Station_Vis" alpha="1.0" r="0.2" g="0.8" b="0.2" showDaughters="true" visible="true"/> + <vis name="UT_Xlayer_Vis" alpha="1.0" r="0.4" g="0.4" b="0.4" showDaughters="true" visible="false"/> + <vis name="UT_Ulayer_Vis" alpha="1.0" r="0.9" g="0.9" b="0.0" showDaughters="true" visible="false"/> + </display> + + <geometry open="true" close="true"/> + + <!-- Includes for sensitives and support --> + <detectors> + + <detector id="1" name="UUT" type="DD4hep_UUT" vis="UUT_Envelope_Vis" readout="UUTHits"> + <params> + <param name="BeamHoleRadius" value="UTBeamHoleRadius"/> + + <param name="FrameOuterWidth" value="UTFrameOuterWidth"/> + <param name="FrameOuterHeight" value="UTFrameOuterHeight"/> + <param name="FrameInnerWidth" value="UTFrameInnerWidth"/> + <param name="FrameInnerHeight" value="UTFrameInnerHeight"/> + <param name="FrameThickness" value="UTFrameThickness"/> + + <param name="BoxOuterWidth" value="UTBoxOuterWidth"/> + <param name="BoxOuterHeight" value="UTBoxOuterHeight"/> + <param name="BoxOuterThickness" value="UTBoxOuterThickness"/> + <param name="BoxInnerWidth" value="UTBoxInnerWidth"/> + <param name="BoxInnerHeight" value="UTBoxInnerHeight"/> + <param name="BoxInnerThickness" value="UTBoxInnerThickness"/> + <param name="BoxBeamHoleRadius" value="UTBoxBeamHoleRadius"/> + + <param name="VirtualBoxWidth" value="UTVirtualBoxWidth"/> + <param name="VirtualBoxHeight" value="UTVirtualBoxHeight"/> + <param name="VirtualHoleRadius" value="UTVirtualHoleRadius"/> + + <param name="LayerDz" value="UTLayerDz"/> + <param name="LayerThickness" value="UTLayerThickness"/> + + <param name="StationDz" value="UTStationDz"/> + <param name="StationThickness" value="UTStationThickness"/> + + <param name="SensorWidth" value="UTSensorWidth"/> + <param name="SensorHeight" value="UTSensorHeight"/> + + <param name="ModuleWidth" value="UTModuleWidth"/> + <param name="ModuleHeight" value="UTModuleHeight"/> + <param name="ModuleThickness" value="UTModuleThickness"/> + <param name="ModuleHybridStepY" value="UTModuleHybridStepY"/> + <param name="ModuleHybridZ" value="UTModuleHybridZ"/> + + <param name="BalconyYposX" value="UTBalconyYposX"/> +<!-- + <param name="" value=""/> + <param name="" value=""/> + <param name="" value=""/> +--> + <param name="SensorSiWidth" value="UTSensorSiWidth"/> + <param name="SensorSiHeight" value="UTSensorSiHeight"/> + <param name="SensorSiZ" value="UTSensorSiZ"/> + <param name="SensorSiThickness" value="UTSensorSiThickness"/> + <param name="SensorSiOverlapX" value="UTSensorSiOverlapX"/> + <param name="SensorSiOverlapY" value="UTSensorSiOverlapY"/> + + <param name="SensorGRWidth" value="UTSensorGRWidth"/> + <param name="SensorGRZ" value="UTSensorGRZ"/> + <param name="SensorGRThickness" value="UTSensorGRThickness"/> + <param name="SensorAlZ" value="UTSensorAlZ"/> + <param name="SensorAlThickness" value="UTSensorAlThickness"/> + + <param name="AsicWidth" value="UTAsicWidth"/> + <param name="AsicHeight" value="UTAsicHeight"/> + <param name="AsicThickness" value="UTAsicThicknessAve"/> + + <param name="HybridWidth" value="UTHybridWidth"/> + <param name="HybridHeight" value="UTHybridHeight"/> + <param name="HybridThickness" value="UTHybridThickness"/> + <param name="HybridSensorZ" value="UTHybridSensorZ"/> + <param name="HybridAsicY" value="UTHybridAsicY"/> + <param name="HybridAsicZbase" value="UTHybridAsicZbase"/> + + <param name="HybridFlexY" value="UTHybridFlexY"/> + <param name="HybridFlexZ" value="UTHybridFlexZ"/> + <param name="HybridFlexWidth" value="UTHybridFlexWidth"/> + <param name="HybridFlexHeight" value="UTHybridFlexHeight"/> + <param name="HybridFlexThickness" value="UTHybridFlexThickness"/> + + <param name="CylJacketLength" value="UTCylJacketLength"/> + <param name="CylJacketRadius" value="UTCylJacketRadius"/> + <param name="CylJacketThickness" value="UTCylJacketThickness"/> + <param name="CylJacketZpos" value="UTCylJacketZpos"/> + + <param name="ConeJacketLength" value="UTConeJacketLength"/> + <param name="ConeJacketRadiusZmax" value="UTConeJacketRadiusZmax"/> + <param name="ConeJacketRadiusZmin" value="UTConeJacketRadiusZmin"/> + <param name="ConeJacketThickness" value="UTConeJacketThickness"/> + <param name="ConeJacketZpos" value="UTConeJacketZpos"/> + </params> +<!-- + <param name="" value=""/> + <param name="" value=""/> + <param name="" value=""/> + <param name="" value=""/> + <param name="" value=""/> +--> + + <debug> + <item name="Build_Box" value="true"/> + <item name="Build_Frame" value="true"/> + <item name="Build_Jacket" value="true"/> + <item name="Build_UTA" value="true"/> + <item name="Build_UTB" value="true"/> + </debug> + + <envelope name="lvUT" vis="UT_Envelope_Vis"> + <frame name="lvUTFrame" material="Al" vis="UT_Frame_Vis"/> + <box name="lvUTBox" material="UT/BoxWall" vis="UT_Box_Vis"/> + <uta name="lvUTa" material="Air" vis="UT_A_Vis"> + <position z="-0.5*UTStationDz"/> + <X vis="UT_Xlayer_Vis"><position z="-0.5*UTLayerDz"/> + <balcony name="lvUTaXBalcony" material="Al" vis="UT_Alu_Vis"> + <box x="UTBalconyWidthUTa" y="UTBalconyHeightX" z="UTBalconyThickness"/> + <params step="UTModuleStepX" correction="UTModuleCorrectXa" dz="UTModuleDz/2"/> + <position y="UTBalconyYposX"/> + <position y="-UTBalconyYposX"/> + </balcony> + </X> + <U vis="UT_Ulayer_Vis"><position z="0.5*UTLayerDz"/></U> + </uta> + <utb name="lvUTb" material="Air" vis="UT_B_Vis"> + <position z="0.5*UTStationDz"/> + <V vis="UT_Ulayer_Vis"><position z="-0.5*UTLayerDz"/></V> + <X vis="UT_Xlayer_Vis"><position z="0.5*UTLayerDz"/></X> + </utb> + <module name="lvModuleA" material="Air"> + <stave/> + </module> + + <jacket name="lvUTJacket" material="UT/BeamPipeJacket" vis="UT_Jacket_Vis"> + <position z="UX851Rich1TTSplitZposIP-UTSystemZ"/> + </jacket> + </envelope> + + </detector> + </detectors> + <limits> + <limitset name="codex_limits"> + <limit name="step_length_max" particles="*" value="5.0" unit="mm" /> + </limitset> + </limits> + <readouts> + <readout name="UUTHits"> + <segmentation type="CartesianGridXY" grid_size_x="1*cm" grid_size_y="1*cm" /> + <id>system:8,type:3,station:10,x:32:-16,y:-16</id> + </readout> + </readouts> + + <fields> + </fields> + +</lccdd> + + + diff --git a/examples/DDUpgrade/compact/UUTGeometryParams.xml b/examples/DDUpgrade/compact/UUTGeometryParams.xml new file mode 100644 index 0000000000000000000000000000000000000000..dc09b10d6057bf8640dc114b0f7761ca05e9d245 --- /dev/null +++ b/examples/DDUpgrade/compact/UUTGeometryParams.xml @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<define> + + <!-- UT Geometry parameters --> + <!-- * Author: Jianchun Wang * --> + + <constant name="UTModuleStaveTrueThickness" value="3.46*mm" /> + <constant name="UTSensorGRWidth" value="0.8*mm" /> + <constant name="UTModuleStaveThickness" value="1.757*mm" /> + <constant name="UTConeJacketLength" value="UX851Cone08ALenght" /> + <constant name="UTFrameOuterHeight" value="2628*mm" /> + <constant name="UTHybridFlexThickness" value="0.217*mm" /> + <constant name="UTSensorSiThickness" value="0.25*mm" /> + <constant name="UTStationDz" value="270*mm" /> + <constant name="UTVirtualBoxWidth" value="1900*mm" /> + <constant name="UTKaptonCableThickness" value="0.133*mm" /> + <constant name="UTGeomVersion" value="1.1" /> + <constant name="UTBalconyHeightX" value="130.0*mm" /> + <constant name="UTModuleDz" value="10*mm" /> + <constant name="UTBalconyWidthUTa" value="1550*mm" /> + <constant name="UTBalconyWidthUTb" value="1750*mm" /> + <constant name="UTBoxOuterThickness" value="430.0*mm" /> + <constant name="UTFrameOuterWidth" value="2586*mm" /> + <constant name="UTSensorSiHeight" value="97.28*mm" /> + <constant name="UTBalconyThickness" value="8.0*mm" /> + <constant name="UTAsicHeight" value="6.6*mm" /> + <constant name="UTFrameInnerWidth" value="1960*mm" /> + <constant name="UTStationThickness" value="70*mm" /> + <constant name="UTFrameThickness" value="15*mm" /> + <constant name="UTFrameInnerHeight" value="2000*mm" /> + <constant name="UTSystemZ" value="2485*mm" /> + <constant name="UTHybridInterval" value="2.0*mm" /> + <constant name="UTVirtualBoxHeight" value="1900*mm" /> + <constant name="UTCylJacketLength" value="UX851Cyl07BLenght" /> + <constant name="UTHybridFlexShort" value="0.0*mm" /> + <constant name="UTCylJacketRadius" value="UX851Cyl07Radius+UX851Cyl07Thick+0.01*mm" /> + <constant name="UTSensorSiWidth" value="97.28*mm" /> + <constant name="UTAngle" value="5.0*degree" /> + <constant name="UTBeamHoleRadius" value="33.4*mm" /> + <constant name="UTHybridFlexEnd" value="20.0*mm" /> + <constant name="UTModuleStaveEnd" value="75.0*mm" /> + <constant name="UTModuleCorrectXb" value="0.171*mm" /> + <constant name="UTModuleCorrectXa" value="0.195*mm" /> + <constant name="UTAsicThickness" value="0.12*mm" /> + <constant name="UTConeJacketRadiusZmax" value="UX851Cone08ARadiusZmax+UX851Cone08AThick+0.01*mm" /> + <constant name="UTLayerDz" value="45*mm" /> + <constant name="UTAsicWidth" value="5.4*mm" /> + <constant name="UTConeJacketRadiusZmin" value="UX851Cone08ARadiusZmin+UX851Cone08AThick+0.01*mm" /> + <constant name="UTCylJacketThickness" value="5.0*mm" /> + <constant name="UTSensorSiOverlapX" value="1.2*mm" /> + <constant name="UTSensorSiOverlapY" value="1.2*mm" /> + <constant name="UTSensorAlThickness" value="0.01*mm" /> + <constant name="UTBoxWallThickness" value="0.4*mm" /> + <constant name="UTLayerThickness" value="25*mm" /> + <constant name="UTHybridSensorZ" value="-UTHybridFlexThickness/2" /> + <constant name="UTSensorAlZ" value="UTSensorSiThickness/2" /> + <constant name="UTSensorGRThickness" value="UTSensorSiThickness" /> + <constant name="UTModuleKaptonCableZ" value="UTModuleStaveTrueThickness/2+UTKaptonCableThickness/2" /> + <constant name="UTBalconyHeightU" value="UTBalconyHeightX-1.15*mm" /> + <constant name="UTSensorHeight" value="UTSensorSiHeight+2*UTSensorGRWidth" /> + <constant name="UTBoxOuterWidth" value="UTFrameInnerWidth" /> + <constant name="UTBoxOuterHeight" value="UTFrameInnerHeight" /> + <constant name="UTConeJacketZpos" value="UTCylJacketLength+UTConeJacketLength*0.5" /> + <constant name="UTCylJacketZpos" value="UTCylJacketLength*0.5" /> + <constant name="UTSensorWidth" value="UTSensorSiWidth+2*UTSensorGRWidth" /> + <constant name="UTSinAngle" value="sin(UTAngle)" /> + <constant name="UTCosAngle" value="cos(UTAngle)" /> + <constant name="UTBoxBeamHoleRadius" value="UTBeamHoleRadius-0.1*mm" /> + <constant name="UTVirtualHoleRadius" value="UTBeamHoleRadius-0.1*mm" /> + <constant name="UTHybridFlexY" value="-(UTHybridFlexEnd+UTHybridFlexShort)/2" /> + <constant name="UTConeJacketThickness" value="UTCylJacketThickness" /> + <constant name="UTSensorOverlapX" value="UTSensorSiOverlapX+2*UTSensorGRWidth" /> + <constant name="UTSensorOverlapY" value="UTSensorSiOverlapY+2*UTSensorGRWidth" /> + <constant name="UTSensorGRZ" value="-UTSensorAlThickness/2" /> + <constant name="UTSensorSiZ" value="-UTSensorAlThickness/2" /> + <constant name="UTSensorThickness" value="UTSensorAlThickness+UTSensorSiThickness" /> + <constant name="UTBoxInnerThickness" value="UTBoxOuterThickness-2*UTBoxWallThickness" /> + <constant name="UTHybridFlexHeight" value="UTSensorHeight+UTHybridFlexEnd-UTHybridFlexShort" /> + <constant name="UTHybridHeight" value="UTSensorHeight+2*UTHybridFlexEnd" /> + <constant name="UTHybridAsicY" value="-(UTSensorHeight/2+UTAsicHeight/2+UTHybridInterval)" /> + <constant name="UTBoxInnerWidth" value="UTBoxOuterWidth-2*UTBoxWallThickness" /> + <constant name="UTBoxInnerHeight" value="UTBoxOuterHeight-2*UTBoxWallThickness" /> + <constant name="UTHybridFlexWidth" value="UTSensorWidth" /> + <constant name="UTAsicThicknessAve" value="UTAsicThickness*UTAsicWidth/UTSensorWidth" /> + <constant name="UTHybridWidth" value="UTSensorWidth" /> + <constant name="UTModuleCorrectUa" value="UTModuleCorrectXa/UTCosAngle" /> + <constant name="UTModuleCorrectUb" value="UTModuleCorrectXb/UTCosAngle" /> + <constant name="UTModuleOverlapX" value="UTSensorOverlapX" /> + <constant name="UTModuleHeight" value="UTSensorHeight*14-UTSensorOverlapY*13+UTHybridFlexEnd*2+UTModuleStaveEnd*2" /> + <constant name="UTModuleHybridStepY" value="UTSensorHeight-UTSensorOverlapY" /> + <constant name="UTHybridFlexZ" value="UTSensorThickness/2" /> + <constant name="UTHybridAsicZbase" value="(UTSensorThickness-UTHybridFlexThickness)/2-0.005*mm" /> + <constant name="UTHybridThickness" value="UTHybridFlexThickness+UTSensorThickness+0.005*mm" /> + <constant name="UTModuleWidth" value="UTHybridWidth" /> + <constant name="UTModuleStepX" value="UTSensorWidth-UTModuleOverlapX" /> + <constant name="UTModuleStaveHeight" value="UTModuleHeight" /> + <constant name="UTBalconyYposX" value="0.5*(UTModuleHeight+UTBalconyHeightX)+2.0*mm" /> + <constant name="UTModuleThickness" value="UTHybridThickness*2+UTKaptonCableThickness*2+UTModuleStaveTrueThickness" /> + <constant name="UTModuleHybridZ" value="UTModuleStaveTrueThickness/2+UTHybridThickness/2+UTKaptonCableThickness" /> + <constant name="UTModuleStaveWidth" value="UTModuleWidth" /> + <constant name="UTBalconyYposU" value="0.5*(UTModuleHeight*UTCosAngle+UTBalconyHeightU)+UTModuleWidth*UTSinAngle+2.0*mm" /> + <constant name="UTModuleYposUHole" value="UTModuleStepX/2*UTSinAngle" /> + <constant name="UTModuleStepU" value="UTModuleStepX/UTCosAngle" /> + <constant name="UTModuleXposUHole" value="UTModuleStepX/2*UTCosAngle" /> + <constant name="UTKaptonCableHeight" value="UTModuleStaveHeight" /> + <constant name="UTKaptonCableWidth" value="UTModuleStaveWidth" /> + +</define> diff --git a/examples/DDUpgrade/compact/compact.xml b/examples/DDUpgrade/compact/compact.xml new file mode 100644 index 0000000000000000000000000000000000000000..23b5a5bc4cd153c8a6d95af1c6b21e922f8f49ab --- /dev/null +++ b/examples/DDUpgrade/compact/compact.xml @@ -0,0 +1,128 @@ +<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"> + <!-- Have the materials --> + <includes> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> + </includes> + + <define> + <!-- Define the world box --> + <constant name="world_side" value="50000*mm"/> + <constant name="world_x" value="world_side"/> + <constant name="world_y" value="world_side"/> + <constant name="world_z" value="world_side"/> + + <constant name="VeloRad" value="590*mm"/> + + <constant name="COBEX_beam_angle" value="60*degree"/> + <constant name="COBEX_cone_len" value="50*m"/> + </define> + + <comment>Common Generic visualization attributes</comment> + <display> + <vis name="BlackVis" alpha="1" r="0.1" g="0.1" b="0.1" showDaughters="false" visible="true"/> + <vis name="Codex_Envelope_Vis" alpha=".3" r="0.7" g="0.7" b="0.7" showDaughters="true" visible="true"/> + <vis name="Codex_Module1_Vis" alpha="1" r="0.8" g="0.2" b="0.2" showDaughters="true" visible="true"/> + <vis name="Codex_Module2_Vis" alpha="1" r="0.2" g="0.8" b="0.2" showDaughters="true" visible="true"/> + <vis name="Codex_Module3_Vis" alpha="1" r="0.2" g="0.2" b="0.8" showDaughters="true" visible="true"/> + <vis name="Codex_Shield_Pb_Vis" alpha="1" r="0.4" g="0.4" b="0.4" showDaughters="false" visible="true"/> + <vis name="Codex_Shield_Veto_Vis" alpha="1" r="0.9" g="0.9" b="0.0" showDaughters="true" visible="true"/> + </display> + + <geometry open="false" close="false"/> + + <include ref="Magnet.xml"/> + <!-- Includes for sensitives and support --> + <detectors> + + <detector id="1" name="VeloPix" type="DD4hep_VeloPix" vis="VeloPix_Envelope_Vis" readout="VeloPixHits"> + <parameter name = "OpenX" value = "0.0*mm"/> + <parameter name = "Epsilon" value = "0.01*mm"/> + <parameter name = "VeloZ" value = "1670*mm"/> + <parameter name = "VeloRad" value = "590*mm"/> + <parameter name = "VeloDSEndStartZ" value = "VeloZ/2"/> + <parameter name = "VeloDSEndDeltaZ" value = "135*mm"/> + <parameter name = "VeloEWFlangeZExcess" value = "5*mm"/> + + <!-- <parameter name = "VPRotation" value = "0*degree"/> --> + <parameter name = "VPRotation" value = "45*degree"/> + + <parameter name = "VPEpsilon" value = "0.001*mm"/> <!-- original 0.000001 --> + + <!-- Z positions of stations --> + <parameter name = "Right2LeftDist" value = "12.5*mm"/> + + <!-- regularised layout --> + <parameter name="Station00Z" value="-28.125*cm"/> + <parameter name="Station01Z" value="-25.625*cm"/> + <parameter name="Station02Z" value="-23.125*cm"/> + <parameter name="Station03Z" value="-20.625*cm"/> + <parameter name="Station04Z" value="-13.125*cm"/> + <parameter name="Station05Z" value="-5.625*cm"/> + <parameter name="Station06Z" value="-3.125*cm"/> + <parameter name="Station07Z" value="-0.625*cm"/> + <parameter name="Station08Z" value="1.875*cm"/> + <parameter name="Station09Z" value="4.375*cm"/> + <parameter name="Station10Z" value="6.875*cm"/> + <parameter name="Station11Z" value="9.375*cm"/> + <parameter name="Station12Z" value="11.875*cm"/> + <parameter name="Station13Z" value="14.375*cm"/> + <parameter name="Station14Z" value="16.875*cm"/> + <parameter name="Station15Z" value="19.375*cm"/> + <parameter name="Station16Z" value="21.875*cm"/> + <parameter name="Station17Z" value="24.375*cm"/> + <parameter name="Station18Z" value="26.875*cm"/> + <parameter name="Station19Z" value="31.875*cm"/> + <parameter name="Station20Z" value="39.375*cm"/> + <parameter name="Station21Z" value="49.375*cm"/> + <parameter name="Station22Z" value="59.375*cm"/> + <parameter name="Station23Z" value="64.375*cm"/> + <parameter name="Station24Z" value="69.375*cm"/> + <parameter name="Station25Z" value="74.375*cm"/> + + <LadderParam> + <!-- Distance between two readout chips --> + <parameter name = "Chip2ChipDist" value = "0.165*mm"/> + <!-- Chip dimensions --> + <parameter name = "ChipThick" value = "0.200*mm"/> <!-- PJ original: 0.150 --> + <parameter name = "ChipSizeX" value = "14.08*mm"/> + <parameter name = "ChipSizeY" value = "15.08*mm"/> + <!-- Thickness of glue layer --> + <parameter name = "GlueThick" value = "0.03*mm"/> + <!-- Sensor dimensions (active area) --> + <parameter name = "SiThick" value = "0.200*mm"/> + <parameter name = "SiSizeX" value = "3*(ChipSizeX+Chip2ChipDist)-Chip2ChipDist"/> + <parameter name = "SiSizeY" value = "ChipSizeX"/> + <!-- Width of inactive edge --> + <parameter name = "SiEdge" value = "0.45*mm"/> + <!-- Distance of closest pixel cell to beam line--> + <parameter name = "ClosestPixel" value = "5.100*mm"/> + <!-- Distance between the two adjacent (same-side) sensors --> + <parameter name = "Sensor2SensorDist" value = "0.1*mm"/> <!-- was 0.715*mm-2*GR (0.3mm)--> + <!-- Shift between ladders on opposite sides --> + <parameter name = "LadderShift" value = "0.110*mm"/> <!-- 0.110 mm for MicroChannel, 0.550 mm for PocoFoam --> + </LadderParam> + + </detector> + </detectors> + <limits> + <limitset name="codex_limits"> + <limit name="step_length_max" particles="*" value="5.0" unit="mm" /> + </limitset> + </limits> + <readouts> + <readout name="CodexHits"> + <segmentation type="CartesianGridXY" grid_size_x="1*cm" grid_size_y="1*cm" /> + <id>system:8,type:3,station:10,x:32:-16,y:-16</id> + </readout> + </readouts> + + <fields> + </fields> + +</lccdd> + + + diff --git a/examples/DDUpgrade/compact/test.xml b/examples/DDUpgrade/compact/test.xml new file mode 100644 index 0000000000000000000000000000000000000000..0f445d36c1f5a26391dbd2726a8143b82a8c958a --- /dev/null +++ b/examples/DDUpgrade/compact/test.xml @@ -0,0 +1,103 @@ +<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"> + <!-- Have the materials --> + <includes> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> + </includes> + + <!-- + <materials> + <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="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="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> + + <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.0000000001" /> + <fraction n="0.754" ref="N"/> + <fraction n="0.234" ref="O"/> + <fraction n="0.012" ref="Ar"/> + </material> + </materials> +--> + <define> + <!-- Define the world box --> + <constant name="world_side" value="50000*mm"/> + <constant name="world_x" value="world_side"/> + <constant name="world_y" value="world_side"/> + <constant name="world_z" value="world_side"/> + <constant name="Bls:ID" value="30"/> + <constant name="BcmUp:ID" value="22"/> + <constant name="BcmDown:ID" value="23"/> + + <constant name="Bls:Parent" value="/world/BeforeMagnetRegion/BeforeVelo" type="string"/> + <constant name="BcmUp:Parent" value="/world/BeforeMagnetRegion/BeforeVelo" type="string"/> + <constant name="BcmDown:Parent" value="/world/MagnetRegion" type="string"/> +<!-- + <constant name="BcmUp:Parent" value="/world" type="string"/> + <constant name="BcmDown:Parent" value="/world" type="string"/> + <constant name="Bls:Parent" value="/world" type="string"/> +--> + </define> + + <comment>Common Generic visualization attributes</comment> + <display> + <vis name="BlackVis" alpha="1" r="0.1" g="0.1" b="0.1" showDaughters="false" visible="true"/> + </display> + + <include ref="Regions/parameters.xml"/> + <include ref="Bls/parameters.xml"/> + <include ref="Bcm/parameters.xml"/> + <include ref="Magnet/parameters.xml"/> + + <include ref="Regions/detector.xml"/> + <include ref="Bcm/detector.xml"/> + <include ref="Bls/detector.xml"/> + <include ref="Magnet/detector.xml"/> +<!-- + <include ref="GdmlImports.xml"/> +--> + + <detectors> + </detectors> + + <fields> + </fields> + +</lccdd> + + + diff --git a/examples/DDUpgrade/extract_gdml.sh b/examples/DDUpgrade/extract_gdml.sh new file mode 100644 index 0000000000000000000000000000000000000000..186004b39665f701a7792af292ec7af84edf72e3 --- /dev/null +++ b/examples/DDUpgrade/extract_gdml.sh @@ -0,0 +1,11 @@ + +geoPluginRun -input file:../DD4hep/examples/DDUpgrade/data/load_LHCb.xml -ui -destroy -plugin DD4hep_ROOTGDMLExtract -output VP.gdml -volname -path _dd_Structure_LHCb_BeforeMagnetRegion_UT +geoPluginRun -input file:../DD4hep/examples/DDUpgrade/data/load_LHCb.xml -ui -destroy -plugin DD4hep_ROOTGDMLExtract -output UT.gdml -volname -path _dd_Structure_LHCb_BeforeMagnetRegion_UT +geoPluginRun -input file:../DD4hep/examples/DDUpgrade/data/load_LHCb.xml -ui -destroy -plugin DD4hep_ROOTGDMLExtract -output VP.gdml -volname -path _dd_Structure_LHCb_BeforeMagnetRegion_VP +geoPluginRun -input file:../DD4hep/examples/DDUpgrade/data/load_LHCb.xml -ui -destroy -plugin DD4hep_ROOTGDMLExtract -output Rich1.gdml -volname -path _dd_Structure_LHCb_BeforeMagnetRegion_Rich1 +geoPluginRun -input file:../DD4hep/examples/DDUpgrade/data/load_LHCb.xml -ui -destroy -plugin DD4hep_ROOTGDMLExtract -output Rich2.gdml -volname -path _dd_Structure_LHCb_AfterMagnetRegion_Rich2 +geoPluginRun -input file:../DD4hep/examples/DDUpgrade/data/load_LHCb.xml -ui -destroy -plugin DD4hep_ROOTGDMLExtract -output Ecal.gdml -volname -path _dd_Structure_LHCb_DownstreamRegion_Ecal +geoPluginRun -input file:../DD4hep/examples/DDUpgrade/data/load_LHCb.xml -ui -destroy -plugin DD4hep_ROOTGDMLExtract -output Hcal.gdml -volname -path _dd_Structure_LHCb_DownstreamRegion_Hcal +geoPluginRun -input file:../DD4hep/examples/DDUpgrade/data/load_LHCb.xml -ui -destroy -plugin DD4hep_ROOTGDMLExtract -output FT.gdml -volname -path _dd_Structure_LHCb_AfterMagnetRegion_T_FT +geoPluginRun -input file:../DD4hep/examples/DDUpgrade/data/load_LHCb.xml -ui -destroy -plugin DD4hep_ROOTGDMLExtract -output Muon.gdml -volname -path _dd_Structure_LHCb_DownStreamRegion_Muon + diff --git a/examples/DDUpgrade/src/BCM_geo.cpp b/examples/DDUpgrade/src/BCM_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..80ae9833a2abd407850c6df23f4b494e765f550b --- /dev/null +++ b/examples/DDUpgrade/src/BCM_geo.cpp @@ -0,0 +1,72 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== + +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "XML/Utilities.h" +#include "UpgradeTags.h" +#include "Math/Polar2D.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::detail; +using namespace dd4hep::xml::tools; + +static Ref_t create_element(Detector& description, xml_h e, Ref_t sens_det) { + xml_det_t x_det = e; + VolumeBuilder builder(description, x_det, sens_det); + DetElement bcm_det = builder.detector; + string name = bcm_det.name(); + Assembly bcm_vol("lv"+name); + PlacedVolume pv; + + // Diamond sensor + xml_comp_t x_sens = x_det.child(_U(sensor)); + xml_dim_t x_sens_pos = x_sens.position(); + Material sens_mat = description.material(x_sens.materialStr()); + Box sens_box(x_sens.dx(),x_sens.dy(),x_sens.dz()); + Volume sens_vol("lv"+name+"Sensor", sens_box, sens_mat); + + sens_vol.setVisAttributes(description, x_sens.visStr()); + sens_vol.setSensitiveDetector(sens_det); + + // Place the sensors in the main frame of the detector: + double phi = x_sens_pos.phi(); + double radius = x_sens_pos.r(); + double z_pos = x_sens_pos.z(); + string fmt = name+"Sensor%d"; + RotationZYX rotZ(M_PI/4e0, 0,0); + for(int isens=0; isens < 8; ++isens) { + DetElement de(bcm_det,_toString(isens,fmt.c_str()),x_det.id()); + ROOT::Math::Polar2D<double> dim(radius, phi); + Transform3D tr(RotationZYX(phi,0,0),Position(dim.X(), dim.Y(), z_pos)); + pv = bcm_vol.placeVolume(sens_vol, tr); + pv.addPhysVolID("sensor",isens); + de.setPlacement(pv); + phi += M_PI/4e0; // Advance by 45 degree + } + builder.buildVolumes(e); + builder.placeDaughters(bcm_det, bcm_vol, e); + pv = builder.placeDetector(bcm_vol); + pv.addPhysVolID("station", x_det.station()); + pv.addPhysVolID("system", x_det.id()); + return bcm_det; +} + +// first argument is the type from the xml file +DECLARE_DETELEMENT(LHCb_Bcm,create_element) + diff --git a/examples/DDUpgrade/src/BLS_geo.cpp b/examples/DDUpgrade/src/BLS_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b812fb08cc9aba433909e03b7f5cba21c78f7898 --- /dev/null +++ b/examples/DDUpgrade/src/BLS_geo.cpp @@ -0,0 +1,53 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== + +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "XML/Utilities.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::xml::tools; + +static Ref_t create_element(Detector& description, xml_h e, Ref_t sens_det) { + xml_det_t x_det = e; + VolumeBuilder builder(description, x_det, sens_det); + DetElement bls_det = builder.detector; + Assembly bls_vol(string("lv")+bls_det.name()); + + builder.buildTransformations(e); + builder.buildVolumes(e); + builder.placeDaughters(bls_det, bls_vol, e); + /// Now we have to attach the volume ids for the sensitive volumes for DDG4 + const auto& children = bls_det.children(); + for ( const auto& c : children ) { + PlacedVolume pv = c.second.placement(); + pv.addPhysVolID("module",c.second.id()); + for (Int_t idau = 0, ndau = pv->GetNdaughters(); idau < ndau; ++idau) { + PlacedVolume p(pv->GetDaughter(idau)); + if ( p.volIDs().empty() && p.volume().isSensitive() ) { + p.addPhysVolID("sensor",1); + } + } + } + PlacedVolume pv = builder.placeDetector(bls_vol); + pv.addPhysVolID("system", x_det.id()); + return bls_det; +} +// first argument is the type from the xml file +DECLARE_DETELEMENT(LHCb_Bls,create_element) + diff --git a/examples/DDUpgrade/src/DetectorRegion.cpp b/examples/DDUpgrade/src/DetectorRegion.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ee6fd4aed65441a6cda9ec372a1d6eaee837176 --- /dev/null +++ b/examples/DDUpgrade/src/DetectorRegion.cpp @@ -0,0 +1,66 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== + +#include "DD4hep/DetFactoryHelper.h" +#include "XML/Utilities.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::detail; + +static Ref_t create_element(Detector& description, xml_h e, Ref_t /* sens_det */) { + xml_det_t x_det = e; + int id = x_det.hasAttr(_U(id)) ? x_det.id() : 0; + string name = x_det.nameStr(); + xml_comp_t x_vol (x_det.child(_U(volume))); + xml_dim_t x_pos (x_det.child(_U(position),false)); + xml_dim_t x_rot (x_det.child(_U(rotation),false)); + Material mat (description.material(x_vol.materialStr())); + DetElement det (name,id); + Volume mother = description.pickMotherVolume(det); + Solid solid = xml::createShape(description, x_vol.typeStr(), x_vol); + Volume volume(name+"_vol",solid, mat); + PlacedVolume pv; + + if ( x_pos && x_rot ) { + Transform3D transform(Rotation3D(RotationZYX(x_rot.z(),x_rot.y(),x_rot.x())), + Position(x_pos.x(),x_pos.y(),x_pos.z())); + pv = mother.placeVolume(volume,transform); + } + else if ( x_rot ) { + Transform3D transform(Rotation3D(RotationZYX(x_rot.z(),x_rot.y(),x_rot.x())), + Position(0,0,0)); + pv = mother.placeVolume(volume,transform); + } + else if ( x_pos ) { + pv = mother.placeVolume(volume,Position(x_pos.x(),x_pos.y(),x_pos.z())); + } + else { + pv = mother.placeVolume(volume); + } + volume.setVisAttributes(description, x_det.visStr()); + volume.setLimitSet(description, x_det.limitsStr()); + volume.setRegion(description, x_det.regionStr()); + if ( id != 0 ) { + pv.addPhysVolID("system", id); + } + det.setPlacement(pv); + return det; +} + +// first argument is the type from the xml file +DECLARE_DETELEMENT(DD4hep_DetectorRegion,create_element) diff --git a/examples/DDUpgrade/src/GdmlImport.cpp b/examples/DDUpgrade/src/GdmlImport.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b32fc42576a4d4a68d737b1992222f705ab6153a --- /dev/null +++ b/examples/DDUpgrade/src/GdmlImport.cpp @@ -0,0 +1,84 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== + +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "XML/Utilities.h" +#include "TGeoManager.h" +#include "TGDMLParse.h" +#include "TUri.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::detail; + +static Ref_t create_element(Detector& description, xml_h e, Ref_t /* sens_det */) { + xml_det_t x_det = e; + int id = x_det.hasAttr(_U(id)) ? x_det.id() : 0; + xml_dim_t x_pos (x_det.child(_U(position),false)); + xml_dim_t x_rot (x_det.child(_U(rotation),false)); + xml_dim_t x_gdml (x_det.child(_U(gdmlFile))); + xml_dim_t x_reg (x_det.child(_U(region))); + string name = x_det.nameStr(); + string region = x_reg.nameStr(); + string input = x_gdml.attr<string>(_U(ref)); + DetElement det_region = description.detector(region); + TGDMLParse parser; + TUri uri(input.c_str()); + + input = uri.GetRelativePart(); + if ( !det_region.isValid() ) { + except(name,"+++ Cannot access detector region: %s",region.c_str()); + } + DetElement sdet(name, id); + Volume volume = parser.GDMLReadFile(input.c_str()); + if ( !volume.isValid() ) { + except("ROOTGDMLParse","+++ Failed to parse GDML file:%s",input.c_str()); + } + volume.import(); // We require the extensions in dd4hep. + printout(INFO,"ROOTGDMLParse","+++ Attach GDML volume %s", volume.name()); + Volume mother = det_region.volume(); + PlacedVolume pv; + + if ( x_pos && x_rot ) { + Rotation3D rot(RotationZYX(x_rot.z(),x_rot.y(),x_rot.x())); + Transform3D transform(rot,Position(x_pos.x(),x_pos.y(),x_pos.z())); + pv = mother.placeVolume(volume,transform); + } + else if ( x_rot ) { + Rotation3D rot(RotationZYX(x_rot.z(),x_rot.y(),x_rot.x())); + Transform3D transform(rot,Position(0,0,0)); + pv = mother.placeVolume(volume,transform); + } + else if ( x_pos ) { + pv = mother.placeVolume(volume,Position(x_pos.x(),x_pos.y(),x_pos.z())); + } + else { + pv = mother.placeVolume(volume); + } + volume.setVisAttributes(description, x_det.visStr()); + volume.setLimitSet(description, x_det.limitsStr()); + volume.setRegion(description, x_det.regionStr()); + if ( id != 0 ) { + pv.addPhysVolID("system", id); + } + sdet.setPlacement(pv); + return sdet; +} + +// first argument is the type from the xml file +DECLARE_DETELEMENT(DD4hep_GdmlImport,create_element) diff --git a/examples/DDUpgrade/src/UT_geo.cpp b/examples/DDUpgrade/src/UT_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..23b86bb5a9fb95568da73f16029264b7ee628769 --- /dev/null +++ b/examples/DDUpgrade/src/UT_geo.cpp @@ -0,0 +1,523 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "XML/Utilities.h" +#include "UpgradeTags.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::detail; + +namespace { + struct xml_params_t { + xml_elt_t element; + std::map<std::string, double> data; + xml_params_t(xml_h params_handle); + double operator()(const char* name) const; + }; + xml_params_t::xml_params_t(xml_h handle) : element(handle) { + for(xml_coll_t i(handle,_U(param)); i; ++i) { + xml_comp_t c(i); + data[c.nameStr()] = c.attr<double>(_U(value)); + } + } + + double xml_params_t::operator()(const char* name) const { + auto i = name ? data.find(name) : data.end(); + if ( i != data.end() ) return (*i).second; + stringstream str; + xml::dump_tree(element, str); + except("XML-Parameters","+++ No parameter with name: %s present:%s", + name ? name : "UNKNOWN", str.str().c_str()); + return 0.0; + } + + struct UTBuild { + Detector& description; + xml_det_t x_det; + xml_comp_t x_env; + xml_params_t x_params; + string det_name; + DetElement sdet; + SensitiveDetector sd; + std::map<std::string,Volume> m_volumes; + std::map<std::string,Volume> m_modules; + Volume vol_group_norm, vol_hybrid_norm; + Volume vol_group_dual, vol_hybrid_dual; + Volume vol_group_quad, vol_hybrid_quad; + Volume vol_moduleA, vol_moduleB, vol_moduleC; + Volume vol_frame, vol_box; + Volume vol_uta, vol_utb; + double beamHoleRadius; + + double vboxWidth; + double vboxHeight; + double vholeRadius; + + double moduleWidth; + double moduleHeight; + double moduleThick; + double moduleHybridStepY; + double moduleHybridZ; + + double stationThick; + double layerDz; + double layerThick; + + double sensorWidth; + double sensorHeight; + + double sensorSiZ; + double sensorSiWidth; + double sensorSiHeight; + double sensorSiThick; + double sensorSiOverlapX; + double sensorSiOverlapY; + + double sensorAlZ; + double sensorAlThick; + double sensorGRZ; + double sensorGRWidth; + double sensorGRThick; + + double asicWidth; + double asicHeight; + double asicThick; + + double hybridWidth; + double hybridHeight; + double hybridThick; + double hybridFlexWidth; + double hybridFlexHeight; + double hybridFlexThick; + double hybridAsicY; + double hybridAsicZbase; + double hybridFlexY; + double hybridFlexZ; + double hybridSensorZ; + + double balconyYposX; + + // Debug flags + bool m_build_uta = true; + bool m_build_utb = true; + bool m_build_frame = true; + bool m_build_box = true; + bool m_build_jacket = true; + bool m_build_layers = true; + bool m_build_sensors = true; + + UTBuild(Detector& description, xml_elt_t e, Ref_t sens); + void build_volumes(); + void build_jacket(Volume parent_vol, xml_comp_t x_jacket); + void build_station(DetElement sdet, xml_comp_t x_station); + void build_hybrids(); + void build_sensors(); + void build_modules(); + void build_layers(); + DetElement instantiate(); + }; + UTBuild::UTBuild(Detector& dsc, xml_elt_t e, Ref_t sens) + : description(dsc), x_det(e), x_env(0), x_params(x_det.params()), sd(sens) + { + x_env = x_det.envelope(); + det_name = x_det.nameStr(); + sdet = DetElement(det_name,x_det.id()); + beamHoleRadius = x_params("BeamHoleRadius"); + + vboxWidth = x_params("VirtualBoxWidth"); + vboxHeight = x_params("VirtualBoxHeight"); + vholeRadius = x_params("VirtualHoleRadius"); + + moduleWidth = x_params("ModuleWidth"); + moduleHeight = x_params("ModuleHeight"); + moduleThick = x_params("ModuleThickness"); + moduleHybridStepY = x_params("ModuleHybridStepY"); + moduleHybridZ = x_params("ModuleHybridZ"); + + stationThick = x_params("StationThickness"); + layerDz = x_params("LayerDz"); + layerThick = x_params("LayerThickness"); + + sensorWidth = x_params("SensorWidth"); + sensorHeight = x_params("SensorHeight"); + + sensorSiZ = x_params("SensorSiZ"); + sensorSiWidth = x_params("SensorSiWidth"); + sensorSiHeight = x_params("SensorSiHeight"); + sensorSiThick = x_params("SensorSiThickness"); + sensorSiOverlapX = x_params("SensorSiOverlapX"); + sensorSiOverlapY = x_params("SensorSiOverlapY"); + + sensorAlZ = x_params("SensorAlZ"); + sensorAlThick = x_params("SensorAlThickness"); + sensorGRZ = x_params("SensorGRZ"); + sensorGRWidth = x_params("SensorGRWidth"); + sensorGRThick = x_params("SensorGRThickness"); + + asicWidth = x_params("AsicWidth"); + asicHeight = x_params("AsicHeight"); + asicThick = x_params("AsicThickness"); + + hybridWidth = x_params("HybridWidth"); + hybridHeight = x_params("HybridHeight"); + hybridThick = x_params("HybridThickness"); + hybridFlexWidth = x_params("HybridFlexWidth"); + hybridFlexHeight = x_params("HybridFlexHeight"); + hybridFlexThick = x_params("HybridFlexThickness"); + hybridAsicY = x_params("HybridAsicY"); + hybridAsicZbase = x_params("HybridAsicZbase"); + hybridFlexY = x_params("HybridFlexY"); + hybridFlexZ = x_params("HybridFlexZ"); + hybridSensorZ = x_params("HybridSensorZ"); + + balconyYposX = x_params("BalconyYposX"); + + + // Process debug flags + xml_comp_t x_dbg = x_det.child(_U(debug), false); + if ( x_dbg.ptr() ) { + for(xml_coll_t i(x_dbg,_U(item)); i; ++i) { + xml_comp_t c(i); + if ( c.nameStr() == "Build_UTA" ) m_build_uta = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_UTB" ) m_build_utb = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Jacket" ) m_build_jacket = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Layers" ) m_build_layers = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Sensors" ) m_build_sensors = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Frame" ) m_build_frame = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Box" ) m_build_box = c.attr<bool>(_U(value)); + cout << "Dbg:" << c.nameStr() << " " << c.attr<bool>(_U(value)) << endl; + } + } + } + + void UTBuild::build_sensors() { + Material mat_air = description.air(); + Material mat_Si = description.material("Si"); + Material mat_Al = description.material("Al"); + + Volume vol_metal_layer_full("lvMetalLayerFull", + Box(sensorWidth, sensorHeight, sensorAlThick), mat_Al); + + SubtractionSolid sol_metal_layer_hole(Box(sensorWidth/2.0, sensorHeight/2.0, sensorGRThick), + Tube(0.0, beamHoleRadius, sensorAlThick*2.0), + Position(sensorSiWidth/2.0-sensorSiOverlapX/2.0, + sensorSiHeight/2.0-sensorSiOverlapY/2.0, + 0)); + Volume vol_metal_layer_hole ("lvGuardRingHole", sol_metal_layer_hole, mat_Si); + + SubtractionSolid sol_guard_ring_full(Box(sensorWidth, sensorHeight, sensorGRThick), + Box(sensorSiWidth, sensorSiHeight, sensorSiThick*2.0)); + Volume vol_guard_ring_full ("lvGuardRingFull", sol_guard_ring_full, mat_Si); + + SubtractionSolid sol_guard_ring_frame1(Box(sensorWidth, sensorHeight, sensorGRThick), + Tube(0.0, beamHoleRadius+sensorGRWidth, sensorGRThick*2.0), + Position(sensorSiWidth/2-sensorSiOverlapX/2, + sensorSiHeight/2-sensorSiOverlapY/2, + 0)); + SubtractionSolid sol_guard_ring_frame(sol_guard_ring_frame1, + Box(sensorSiWidth, sensorSiHeight, sensorGRThick*3.0)); + Volume vol_guard_ring_frame ("lvGuardRingFrame", sol_guard_ring_frame, mat_Si); + + IntersectionSolid sol_guard_ring_arc(Box(sensorWidth, sensorHeight, sensorGRThick), + Tube(beamHoleRadius, beamHoleRadius+sensorGRWidth, sensorGRThick*2.0), + Position((sensorSiWidth-sensorSiOverlapX)/2.0, + (sensorSiHeight-sensorSiOverlapY)/2.0, + 0)); + Volume vol_guard_ring_arc ("lvGuardRingArc", sol_guard_ring_arc, mat_Si); + + SubtractionSolid sol_sensor_hole(Box(sensorWidth/2.0, sensorHeight/2.0, sensorGRThick), + Tube(0.0, beamHoleRadius+sensorGRWidth, sensorGRThick*2.0), + Position(sensorSiWidth/4.0-sensorSiOverlapX/2.0, + sensorSiHeight/4.0-sensorSiOverlapY/2.0, + 0)); + Volume vol_sensor_hole ("lvGuardRingHole", sol_sensor_hole, mat_Si); + + Box box_sensor_norm(sensorSiWidth,sensorSiHeight,sensorSiThick); + Volume vol_sensor_norm("lvSensorNorm", box_sensor_norm, mat_Si); + Volume vol_sector_norm("lvSectorNorm", box_sensor_norm, mat_air); + vol_sector_norm.placeVolume(vol_sensor_norm); + vol_group_norm = Assembly("lvGroupNorm"); + vol_group_norm.placeVolume(vol_metal_layer_full, Position(0,0,sensorAlZ)); + vol_group_norm.placeVolume(vol_guard_ring_full, Position(0,0,sensorGRZ)); + vol_group_norm.placeVolume(vol_sector_norm, Position(0,0,sensorSiZ)); + + Box box_sensor_dual(sensorSiWidth/2.0,sensorSiHeight,sensorSiThick); + Volume vol_sensor_dual("lvSensorDual", box_sensor_dual, mat_Si); + Volume vol_sector_dual("lvSectorDual", box_sensor_dual, mat_air); + vol_sector_dual.placeVolume(vol_sensor_dual); + vol_group_dual = Assembly("lvGroupDual"); + vol_group_dual.placeVolume(vol_metal_layer_full, Position(0,0,sensorAlZ)); + vol_group_dual.placeVolume(vol_guard_ring_full, Position(0,0,sensorGRZ)); + vol_group_dual.placeVolume(vol_sector_dual, Position(-sensorSiHeight/4.0,0,sensorSiZ)); + vol_group_dual.placeVolume(vol_sector_dual, Position( sensorSiHeight/4.0,0,sensorSiZ)); + + Box box_sensor_quad(sensorSiWidth/2.0,sensorSiHeight/2.0,sensorSiThick); + Volume vol_sensor_quad("lvSensorQuad", Box(sensorSiWidth,sensorSiHeight,sensorSiThick), mat_Si); + Volume vol_sector_quad("lvSectorQuad", Box(sensorSiWidth,sensorSiHeight,sensorSiThick), mat_air); + vol_sector_quad.placeVolume(vol_sensor_quad); + vol_group_quad = Assembly("lvGroupQuad"); + vol_group_quad.placeVolume(vol_metal_layer_hole, Position(0,0,sensorAlZ)); + vol_group_quad.placeVolume(vol_guard_ring_frame, Position(0,0,sensorGRZ)); + vol_group_quad.placeVolume(vol_guard_ring_arc, Position(0,0,sensorGRZ)); + vol_group_quad.placeVolume(vol_sector_quad, Position(-sensorSiHeight/4.0,-sensorSiHeight/4.0,sensorSiZ)); + vol_group_quad.placeVolume(vol_sector_quad, Position( sensorSiHeight/4.0,-sensorSiHeight/4.0,sensorSiZ)); + vol_group_quad.placeVolume(vol_sector_quad, Position(-sensorSiHeight/4.0, sensorSiHeight/4.0,sensorSiZ)); + vol_group_quad.placeVolume(vol_sector_quad, Position( sensorSiHeight/4.0, sensorSiHeight/4.0,sensorSiZ)); + } + + void UTBuild::build_hybrids() { + Material air = description.air(); + Material mat_hybrid_flex = description.material("UT/HybridFlex"); + Material mat_asic = description.material("UT/UTAsic"); + VisAttr hybrid_vis = description.visAttributes("UT_Hybrid_Vis"); + VisAttr hybrid_flex_vis = description.visAttributes("UT_Hybrid_Flex_Vis"); + VisAttr asic_vis = description.visAttributes("UT_Asic_Vis"); + Box hybrid_norm_box(hybridWidth, hybridHeight, hybridThick); + Box hybrid_flex_box(hybridFlexWidth, hybridFlexHeight, hybridFlexThick); + + Volume vol_asic ( "lvAsic", Box(asicWidth, asicHeight, asicThick), mat_asic); + Volume vol_asic4 ("lvAsic4", Box(sensorWidth, asicHeight, asicThick*4), mat_asic); + Volume vol_asic8 ("lvAsic8", Box(sensorWidth, asicHeight, asicThick*8), mat_asic); + Volume vol_asic16("lvAsic16",Box(sensorWidth, asicHeight, asicThick*16), mat_asic); + Volume vol_hybrid_flex_full("lvHybridFlex", hybrid_flex_box, mat_hybrid_flex); + + vol_hybrid_norm = Volume("lvHybridNorm", hybrid_norm_box, air); + vol_hybrid_norm.placeVolume(vol_group_norm,Position(0, 0, hybridSensorZ)); + vol_hybrid_norm.placeVolume(vol_hybrid_flex_full,Position(0, hybridFlexY, hybridFlexZ)); + + Tube hybrid_hole(0.0, beamHoleRadius, hybridFlexThick*2.0); + Position hybrid_hole_pos((sensorSiWidth-sensorSiOverlapX)/2.0, + (sensorSiHeight-sensorSiOverlapY)/2.0, + hybridFlexThick*2.0); + Volume vol_hybrid_flex_hole("lvHybridFlexHole", + SubtractionSolid(hybrid_flex_box, hybrid_hole, hybrid_hole_pos), + mat_hybrid_flex); + + vol_asic.setVisAttributes(asic_vis); + vol_asic4.setVisAttributes(asic_vis); + vol_asic8.setVisAttributes(asic_vis); + vol_asic16.setVisAttributes(asic_vis); + vol_hybrid_flex_full.setVisAttributes(hybrid_flex_vis); + vol_hybrid_flex_hole.setVisAttributes(hybrid_flex_vis); + + vol_hybrid_norm.placeVolume(vol_asic4, Position(0, hybridAsicY, hybridAsicZbase-asicThick*4.0/2.0)); + vol_hybrid_norm.setVisAttributes(hybrid_vis); + + vol_hybrid_dual = Volume("lvHybridDual", hybrid_norm_box, air); + vol_hybrid_dual.placeVolume(vol_group_dual, Position(0, 0, hybridSensorZ)); + vol_hybrid_dual.placeVolume(vol_hybrid_flex_full,Position(0, hybridFlexY, hybridFlexZ)); + vol_hybrid_dual.placeVolume(vol_asic8, Position(0, hybridAsicY, hybridAsicZbase-asicThick*8.0/2.0)); + vol_hybrid_dual.setVisAttributes(hybrid_vis); + + vol_hybrid_quad = Volume("lvHybridQuad", hybrid_norm_box, air); + vol_hybrid_dual.placeVolume(vol_group_quad, Position(0, 0, hybridSensorZ)); + vol_hybrid_dual.placeVolume(vol_hybrid_flex_hole,Position(0, hybridFlexY, hybridFlexZ)); // ???? Hole ???? + vol_hybrid_dual.placeVolume(vol_asic16, Position(0, hybridAsicY, hybridAsicZbase-asicThick*16.0/2.0)); + vol_hybrid_quad.setVisAttributes(hybrid_vis); + } + + void UTBuild::build_modules() { + Box box_module(moduleWidth, moduleHeight, moduleThick); + RotationZYX rot_Y(0,M_PI,0); + RotationZYX rot_Z(0,0,M_PI); + RotationZYX rot_YZ(0,M_PI,M_PI); + vol_moduleA = Volume("lvModuleA", box_module, description.air()); + vol_moduleB = Volume("lvModuleB", box_module, description.air()); + vol_moduleC = Volume("lvModuleC", box_module, description.air()); + vol_moduleA.setVisAttributes(description, "UT_Module_Vis"); + vol_moduleB.setVisAttributes(description, "UT_Module_Vis"); + vol_moduleC.setVisAttributes(description, "UT_Module_Vis"); + Volume vol, dau, vols[3] = {vol_moduleA, vol_moduleB, vol_moduleC}; + for(int alt=-1, i = -13; i <= 13; i += 2, alt *= -1) { + for(size_t ivol=0; ivol<3; ++ivol) { + Position pos(0,double(i)/2.0*moduleHybridStepY, double(alt)*moduleHybridZ); + vol = vols[ivol]; + if ( ivol > 1 && std::abs(i) < 2 ) dau = vol_hybrid_quad; + else if ( ivol > 0 && std::abs(i) < 4 ) dau = vol_hybrid_dual; + else dau = vol_hybrid_norm; + + cout << "Placeing module " << dau.name() << " " << pos << endl; + if ( i*alt > 0 ) + (i<0) ? vol.placeVolume(dau, Transform3D(rot_Y,pos)) : vol.placeVolume(dau, Transform3D(rot_YZ,pos)); + else + (i<0) ? vol.placeVolume(dau, pos) : vol.placeVolume(dau, Transform3D(rot_Z,pos)); + } + } + } + + void UTBuild::build_volumes() { + for(xml_coll_t ivol(x_det.child(_U(volumes)),_U(module)); ivol; ++ivol) { + Volume volume; + xml_comp_t x_vol = ivol; + xml_comp_t x_shape = x_vol.child(_U(solid), false); + if ( x_shape.ptr() ) { + Solid solid = xml::createShape(description, x_shape.typeStr(), x_shape); + Material mat = description.material(x_vol.materialStr()); + volume = Volume(x_vol.nameStr(), solid, mat); + } + else { + volume = Assembly(x_vol.nameStr()); + } + m_volumes[x_vol.nameStr()] = volume; + } +#if 0 + for(xml_coll_t ivol(x_det.child(_U(volumes)),_U(module)); ivol; ++ivol) { + volume.setAttributes(description, x_vol.regionStr(), x_vol.limitsStr(), x_vol.visStr()); + for(xml_coll_t i(ivol,_U(physvol)); i; ++i) { + xml_comp_t x_phys = i; + + } + m_volumes[x_vol.nameStr()] = volume; + } +#endif + } + + void UTBuild::build_layers() { + + } + + void UTBuild::build_jacket(Volume parent_vol, xml_comp_t x_jacket) { + xml_dim_t x_pos = x_jacket.position(); + Assembly jacket_vol("lvUTJacket"); + for(xml_coll_t ivol(x_jacket,_U(physvol)); ivol; ++ivol) { + xml_dim_t x_v = ivol; + xml_dim_t x_p = x_v.position(); + Volume vol = m_volumes[x_v.nameStr()]; + jacket_vol.placeVolume(vol, Position(x_p.x(0), x_p.y(0), x_v.z(0))); + } + parent_vol.placeVolume(jacket_vol, Position(x_pos.x(0), x_pos.y(0), x_pos.z(0))); + } + + void UTBuild::build_station(DetElement det, xml_comp_t x_station) { + Material mat = description.material(x_station.materialStr()); + Volume station_vol; + Position station_pos; + { + xml_dim_t x_solid = x_station.child(_U(envelope)); + xml_dim_t x_box = x_solid.child(_U(box)); + xml_dim_t x_tub = x_solid.child(_U(tube)); + xml_dim_t x_pos = x_station.position(); + Box box(x_box.x(), x_box.y(), x_box.z()); + Tube tub(x_tub.rmin(0.0), x_tub.rmax(), x_tub.z()); + if ( x_pos ) station_pos = Position(x_pos.x(0), x_pos.y(0), x_pos.z(0)); + station_vol = Volume("lv"+x_station.nameStr(), SubtractionSolid(box, tub), mat); + station_vol.setAttributes(description, x_station.regionStr(), x_station.limitsStr(), x_station.visStr()); + } + for(xml_coll_t ilayer(x_station.child(_U(layers)),_U(layer)); ilayer; ++ilayer) { + xml_comp_t x_layer = ilayer; + xml_dim_t x_solid = x_layer.child(_U(envelope)); + xml_dim_t x_p = x_layer.position(); + xml_dim_t x_box = x_solid.child(_U(box)); + xml_dim_t x_tub = x_solid.child(_U(tube)); + xml_dim_t x_modules = x_layer.child(_U(modules)); + xml_comp_t x_balcony = x_layer.child(_LBU(balcony)); + xml_dim_t x_balcony_box = x_balcony.child(_U(box)); + //xml_dim_t x_balcony_par = x_balcony.child(_U(params)); + + string layer_nam = x_layer.nameStr(); + Box layer_box(x_box.x(), x_box.y(), x_box.z()); + Tube layer_tub(x_tub.rmin(0.0), x_tub.rmax(), x_tub.z()); + Volume layer_vol("lv"+layer_nam, SubtractionSolid(layer_box, layer_tub), mat); + Position layer_pos(x_p.x(0.0), x_p.y(0.0), x_p.z(0.0)); + + Material balcony_mat = description.material(x_balcony.materialStr()); + Box balcony_box(x_balcony_box.x(0.0), x_balcony_box.y(0.0), x_balcony_box.z(0.0)); + Volume balcony_vol(x_balcony.nameStr(),balcony_box,balcony_mat); + + layer_vol.setVisAttributes(description, x_layer.visStr()); + balcony_vol.setVisAttributes(description, x_balcony.visStr()); + for(xml_coll_t ibalc(x_balcony,_U(position)); ibalc; ++ibalc) { + xml_dim_t x_pos = ibalc; + layer_vol.placeVolume(balcony_vol,Position(x_pos.x(0.0), x_pos.y(0.0), x_pos.z(0.0))); + } + for(xml_coll_t imodule(x_modules,_U(module)); imodule; ++imodule) { + xml_comp_t x_mod = imodule; + xml_dim_t x_pos = x_mod.position(); + xml_dim_t x_rot = x_mod.child(_U(rotation),false); + string typ = x_mod.typeStr(); + Volume vol = m_modules[typ]; + if ( x_pos.ptr() && x_rot.ptr() ) { + Position p(x_pos.x(0.0),x_pos.y(0.0),x_pos.z(0.0)); + RotationZYX r(x_rot.z(0.0),x_rot.y(0.0),x_rot.x(0.0)); + layer_vol.placeVolume(vol, Transform3D(r,p)); + } + else if ( x_rot.ptr() ) { + RotationZYX r(x_rot.z(0.0),x_rot.y(0.0),x_rot.x(0.0)); + layer_vol.placeVolume(vol, r); + } + else if ( x_pos.ptr() ) { + layer_vol.placeVolume(vol, Position(x_pos.x(0.0),x_pos.y(0.0),x_pos.z(0.0))); + } + else { + layer_vol.placeVolume(vol); + } + } + station_vol.placeVolume(layer_vol, layer_pos); + } + det.volume().placeVolume(station_vol, station_pos); + } + + DetElement UTBuild::instantiate() { + Volume sdet_vol;//WRONG: (x_env.nameStr(), m_volumes["lvUT"], description.air()); + /* + * See DDDB/UUT/geometry.xml for the structure + */ + if ( m_build_frame ) { // Build lvUTFrame + sdet_vol.placeVolume(m_volumes["lvUTFrame"]); + } + if ( m_build_box ) { // Build lvUTBox + Position pos; + sdet_vol.placeVolume(m_volumes["lvUTBox"], pos); + } + if ( m_build_uta ) { // Build lvUTa + build_station(sdet, x_env.child(_LBU(uta))); + } + if ( m_build_utb ) { // Build lvUTb + build_station(sdet, x_env.child(_LBU(utb))); + } + + if ( m_build_jacket ) { // Build lvUTJacket + build_jacket(sdet_vol, x_env.child(_LBU(jacket))); + } + { // Build lvUX851InUT + } + + sd.setType("tracker"); + PlacedVolume pv; + Volume mother = description.pickMotherVolume(sdet); + pv = mother.placeVolume(sdet_vol); + if ( x_det.hasAttr(_U(id)) ) { + pv.addPhysVolID("system",x_det.id()); + } + sdet.setPlacement(pv); + return sdet; + } +} + +static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { + UTBuild b(description, e, sens); + b.build_volumes(); + b.build_sensors(); + b.build_hybrids(); + b.build_modules(); + b.build_layers(); + DetElement sdet = b.instantiate(); + return sdet; +} +DECLARE_DETELEMENT(DD4hep_UT,create_element) diff --git a/examples/DDUpgrade/src/UUT_geo.cpp b/examples/DDUpgrade/src/UUT_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c2b53c47bf83a729d093b5f289a3f9bfd219ce85 --- /dev/null +++ b/examples/DDUpgrade/src/UUT_geo.cpp @@ -0,0 +1,587 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +// +// Specialized generic detector constructor +// +//========================================================================== +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include "UpgradeTags.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::detail; + +namespace { + struct xml_params_t { + xml_elt_t element; + std::map<std::string, double> data; + xml_params_t(xml_h params_handle); + double operator()(const char* name) const; + }; + xml_params_t::xml_params_t(xml_h handle) : element(handle) { + for(xml_coll_t i(handle,_U(param)); i; ++i) { + xml_comp_t c(i); + data[c.nameStr()] = c.attr<double>(_U(value)); + } + } + + double xml_params_t::operator()(const char* name) const { + auto i = name ? data.find(name) : data.end(); + if ( i != data.end() ) return (*i).second; + stringstream str; + xml::dump_tree(element, str); + except("XML-Parameters","+++ No parameter with name: %s present:%s", + name ? name : "UNKNOWN", str.str().c_str()); + return 0.0; + } + + struct UTBuild { + Detector& description; + xml_det_t x_det; + xml_comp_t x_env; + xml_params_t x_params; + string det_name; + DetElement sdet; + SensitiveDetector sd; + Volume vol_group_norm, vol_hybrid_norm; + Volume vol_group_dual, vol_hybrid_dual; + Volume vol_group_quad, vol_hybrid_quad; + Volume vol_moduleA, vol_moduleB, vol_moduleC; + Volume vol_frame, vol_box; + Volume vol_uta, vol_utb; + double beamHoleRadius; + + double frameOuterWidth; + double frameOuterHeight; + double frameInnerWidth; + double frameInnerHeight; + double frameThick; + double boxOuterThickness; + double vboxWidth; + double vboxHeight; + double vholeRadius; + + double moduleWidth; + double moduleHeight; + double moduleThick; + double moduleHybridStepY; + double moduleHybridZ; + + double stationThick; + double layerDz; + double layerThick; + + double sensorWidth; + double sensorHeight; + + double sensorSiZ; + double sensorSiWidth; + double sensorSiHeight; + double sensorSiThick; + double sensorSiOverlapX; + double sensorSiOverlapY; + + double sensorAlZ; + double sensorAlThick; + double sensorGRZ; + double sensorGRWidth; + double sensorGRThick; + + double asicWidth; + double asicHeight; + double asicThick; + + double hybridWidth; + double hybridHeight; + double hybridThick; + double hybridFlexWidth; + double hybridFlexHeight; + double hybridFlexThick; + double hybridAsicY; + double hybridAsicZbase; + double hybridFlexY; + double hybridFlexZ; + double hybridSensorZ; + + double balconyYposX; + + // Debug flags + bool m_build_uta = true; + bool m_build_utb = true; + bool m_build_frame = true; + bool m_build_box = true; + bool m_build_jacket = true; + bool m_build_layers = true; + bool m_build_sensors = true; + + UTBuild(Detector& description, xml_elt_t e, Ref_t sens); + void build_hybrids(); + void build_sensors(); + void build_modules(); + void build_layers(); + DetElement instantiate(); + }; + UTBuild::UTBuild(Detector& dsc, xml_elt_t e, Ref_t sens) + : description(dsc), x_det(e), x_env(0), x_params(x_det.params()), sd(sens) + { + x_env = x_det.envelope(); + det_name = x_det.nameStr(); + sdet = DetElement(det_name,x_det.id()); + beamHoleRadius = x_params("BeamHoleRadius"); + + frameOuterWidth = x_params("FrameOuterWidth"); + frameOuterHeight = x_params("FrameOuterHeight"); + frameInnerWidth = x_params("FrameInnerWidth"); + frameInnerHeight = x_params("FrameInnerHeight"); + frameThick = x_params("FrameThickness"); + boxOuterThickness = x_params("BoxOuterThickness"); + + vboxWidth = x_params("VirtualBoxWidth"); + vboxHeight = x_params("VirtualBoxHeight"); + vholeRadius = x_params("VirtualHoleRadius"); + + moduleWidth = x_params("ModuleWidth"); + moduleHeight = x_params("ModuleHeight"); + moduleThick = x_params("ModuleThickness"); + moduleHybridStepY = x_params("ModuleHybridStepY"); + moduleHybridZ = x_params("ModuleHybridZ"); + + stationThick = x_params("StationThickness"); + layerDz = x_params("LayerDz"); + layerThick = x_params("LayerThickness"); + + sensorWidth = x_params("SensorWidth"); + sensorHeight = x_params("SensorHeight"); + + sensorSiZ = x_params("SensorSiZ"); + sensorSiWidth = x_params("SensorSiWidth"); + sensorSiHeight = x_params("SensorSiHeight"); + sensorSiThick = x_params("SensorSiThickness"); + sensorSiOverlapX = x_params("SensorSiOverlapX"); + sensorSiOverlapY = x_params("SensorSiOverlapY"); + + sensorAlZ = x_params("SensorAlZ"); + sensorAlThick = x_params("SensorAlThickness"); + sensorGRZ = x_params("SensorGRZ"); + sensorGRWidth = x_params("SensorGRWidth"); + sensorGRThick = x_params("SensorGRThickness"); + + asicWidth = x_params("AsicWidth"); + asicHeight = x_params("AsicHeight"); + asicThick = x_params("AsicThickness"); + + hybridWidth = x_params("HybridWidth"); + hybridHeight = x_params("HybridHeight"); + hybridThick = x_params("HybridThickness"); + hybridFlexWidth = x_params("HybridFlexWidth"); + hybridFlexHeight = x_params("HybridFlexHeight"); + hybridFlexThick = x_params("HybridFlexThickness"); + hybridAsicY = x_params("HybridAsicY"); + hybridAsicZbase = x_params("HybridAsicZbase"); + hybridFlexY = x_params("HybridFlexY"); + hybridFlexZ = x_params("HybridFlexZ"); + hybridSensorZ = x_params("HybridSensorZ"); + + balconyYposX = x_params("BalconyYposX"); + + + // Process debug flags + xml_comp_t x_dbg = x_det.child(_U(debug), false); + if ( x_dbg.ptr() ) { + for(xml_coll_t i(x_dbg,_U(item)); i; ++i) { + xml_comp_t c(i); + if ( c.nameStr() == "Build_UTA" ) m_build_uta = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_UTB" ) m_build_utb = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Jacket" ) m_build_jacket = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Layers" ) m_build_layers = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Sensors" ) m_build_sensors = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Frame" ) m_build_frame = c.attr<bool>(_U(value)); + if ( c.nameStr() == "Build_Box" ) m_build_box = c.attr<bool>(_U(value)); + cout << "Dbg:" << c.nameStr() << " " << c.attr<bool>(_U(value)) << endl; + } + } + } + + void UTBuild::build_sensors() { + Material mat_air = description.air(); + Material mat_Si = description.material("Si"); + Material mat_Al = description.material("Al"); + + Volume vol_metal_layer_full("lvMetalLayerFull", + Box(sensorWidth, sensorHeight, sensorAlThick), mat_Al); + + SubtractionSolid sol_metal_layer_hole(Box(sensorWidth/2.0, sensorHeight/2.0, sensorGRThick), + Tube(0.0, beamHoleRadius, sensorAlThick*2.0), + Position(sensorSiWidth/2.0-sensorSiOverlapX/2.0, + sensorSiHeight/2.0-sensorSiOverlapY/2.0, + 0)); + Volume vol_metal_layer_hole ("lvGuardRingHole", sol_metal_layer_hole, mat_Si); + + SubtractionSolid sol_guard_ring_full(Box(sensorWidth, sensorHeight, sensorGRThick), + Box(sensorSiWidth, sensorSiHeight, sensorSiThick*2.0)); + Volume vol_guard_ring_full ("lvGuardRingFull", sol_guard_ring_full, mat_Si); + + SubtractionSolid sol_guard_ring_frame1(Box(sensorWidth, sensorHeight, sensorGRThick), + Tube(0.0, beamHoleRadius+sensorGRWidth, sensorGRThick*2.0), + Position(sensorSiWidth/2-sensorSiOverlapX/2, + sensorSiHeight/2-sensorSiOverlapY/2, + 0)); + SubtractionSolid sol_guard_ring_frame(sol_guard_ring_frame1, + Box(sensorSiWidth, sensorSiHeight, sensorGRThick*3.0)); + Volume vol_guard_ring_frame ("lvGuardRingFrame", sol_guard_ring_frame, mat_Si); + + IntersectionSolid sol_guard_ring_arc(Box(sensorWidth, sensorHeight, sensorGRThick), + Tube(beamHoleRadius, beamHoleRadius+sensorGRWidth, sensorGRThick*2.0), + Position((sensorSiWidth-sensorSiOverlapX)/2.0, + (sensorSiHeight-sensorSiOverlapY)/2.0, + 0)); + Volume vol_guard_ring_arc ("lvGuardRingArc", sol_guard_ring_arc, mat_Si); + + SubtractionSolid sol_sensor_hole(Box(sensorWidth/2.0, sensorHeight/2.0, sensorGRThick), + Tube(0.0, beamHoleRadius+sensorGRWidth, sensorGRThick*2.0), + Position(sensorSiWidth/4.0-sensorSiOverlapX/2.0, + sensorSiHeight/4.0-sensorSiOverlapY/2.0, + 0)); + Volume vol_sensor_hole ("lvGuardRingHole", sol_sensor_hole, mat_Si); + + Box box_sensor_norm(sensorSiWidth,sensorSiHeight,sensorSiThick); + Volume vol_sensor_norm("lvSensorNorm", box_sensor_norm, mat_Si); + Volume vol_sector_norm("lvSectorNorm", box_sensor_norm, mat_air); + vol_sector_norm.placeVolume(vol_sensor_norm); + vol_group_norm = Assembly("lvGroupNorm"); + vol_group_norm.placeVolume(vol_metal_layer_full, Position(0,0,sensorAlZ)); + vol_group_norm.placeVolume(vol_guard_ring_full, Position(0,0,sensorGRZ)); + vol_group_norm.placeVolume(vol_sector_norm, Position(0,0,sensorSiZ)); + + Box box_sensor_dual(sensorSiWidth/2.0,sensorSiHeight,sensorSiThick); + Volume vol_sensor_dual("lvSensorDual", box_sensor_dual, mat_Si); + Volume vol_sector_dual("lvSectorDual", box_sensor_dual, mat_air); + vol_sector_dual.placeVolume(vol_sensor_dual); + vol_group_dual = Assembly("lvGroupDual"); + vol_group_dual.placeVolume(vol_metal_layer_full, Position(0,0,sensorAlZ)); + vol_group_dual.placeVolume(vol_guard_ring_full, Position(0,0,sensorGRZ)); + vol_group_dual.placeVolume(vol_sector_dual, Position(-sensorSiHeight/4.0,0,sensorSiZ)); + vol_group_dual.placeVolume(vol_sector_dual, Position( sensorSiHeight/4.0,0,sensorSiZ)); + + Box box_sensor_quad(sensorSiWidth/2.0,sensorSiHeight/2.0,sensorSiThick); + Volume vol_sensor_quad("lvSensorQuad", Box(sensorSiWidth,sensorSiHeight,sensorSiThick), mat_Si); + Volume vol_sector_quad("lvSectorQuad", Box(sensorSiWidth,sensorSiHeight,sensorSiThick), mat_air); + vol_sector_quad.placeVolume(vol_sensor_quad); + vol_group_quad = Assembly("lvGroupQuad"); + vol_group_quad.placeVolume(vol_metal_layer_hole, Position(0,0,sensorAlZ)); + vol_group_quad.placeVolume(vol_guard_ring_frame, Position(0,0,sensorGRZ)); + vol_group_quad.placeVolume(vol_guard_ring_arc, Position(0,0,sensorGRZ)); + vol_group_quad.placeVolume(vol_sector_quad, Position(-sensorSiHeight/4.0,-sensorSiHeight/4.0,sensorSiZ)); + vol_group_quad.placeVolume(vol_sector_quad, Position( sensorSiHeight/4.0,-sensorSiHeight/4.0,sensorSiZ)); + vol_group_quad.placeVolume(vol_sector_quad, Position(-sensorSiHeight/4.0, sensorSiHeight/4.0,sensorSiZ)); + vol_group_quad.placeVolume(vol_sector_quad, Position( sensorSiHeight/4.0, sensorSiHeight/4.0,sensorSiZ)); + } + + void UTBuild::build_hybrids() { + Material air = description.air(); + Material mat_hybrid_flex = description.material("UT/HybridFlex"); + Material mat_asic = description.material("UT/UTAsic"); + VisAttr hybrid_vis = description.visAttributes("UT_Hybrid_Vis"); + VisAttr hybrid_flex_vis = description.visAttributes("UT_Hybrid_Flex_Vis"); + VisAttr asic_vis = description.visAttributes("UT_Asic_Vis"); + Box hybrid_norm_box(hybridWidth, hybridHeight, hybridThick); + Box hybrid_flex_box(hybridFlexWidth, hybridFlexHeight, hybridFlexThick); + + Volume vol_asic ( "lvAsic", Box(asicWidth, asicHeight, asicThick), mat_asic); + Volume vol_asic4 ("lvAsic4", Box(sensorWidth, asicHeight, asicThick*4), mat_asic); + Volume vol_asic8 ("lvAsic8", Box(sensorWidth, asicHeight, asicThick*8), mat_asic); + Volume vol_asic16("lvAsic16",Box(sensorWidth, asicHeight, asicThick*16), mat_asic); + Volume vol_hybrid_flex_full("lvHybridFlex", hybrid_flex_box, mat_hybrid_flex); + + vol_hybrid_norm = Volume("lvHybridNorm", hybrid_norm_box, air); + vol_hybrid_norm.placeVolume(vol_group_norm,Position(0, 0, hybridSensorZ)); + vol_hybrid_norm.placeVolume(vol_hybrid_flex_full,Position(0, hybridFlexY, hybridFlexZ)); + + Tube hybrid_hole(0.0, beamHoleRadius, hybridFlexThick*2.0); + Position hybrid_hole_pos((sensorSiWidth-sensorSiOverlapX)/2.0, + (sensorSiHeight-sensorSiOverlapY)/2.0, + hybridFlexThick*2.0); + Volume vol_hybrid_flex_hole("lvHybridFlexHole", + SubtractionSolid(hybrid_flex_box, hybrid_hole, hybrid_hole_pos), + mat_hybrid_flex); + + vol_asic.setVisAttributes(asic_vis); + vol_asic4.setVisAttributes(asic_vis); + vol_asic8.setVisAttributes(asic_vis); + vol_asic16.setVisAttributes(asic_vis); + vol_hybrid_flex_full.setVisAttributes(hybrid_flex_vis); + vol_hybrid_flex_hole.setVisAttributes(hybrid_flex_vis); + + vol_hybrid_norm.placeVolume(vol_asic4, Position(0, hybridAsicY, hybridAsicZbase-asicThick*4.0/2.0)); + vol_hybrid_norm.setVisAttributes(hybrid_vis); + + vol_hybrid_dual = Volume("lvHybridDual", hybrid_norm_box, air); + vol_hybrid_dual.placeVolume(vol_group_dual, Position(0, 0, hybridSensorZ)); + vol_hybrid_dual.placeVolume(vol_hybrid_flex_full,Position(0, hybridFlexY, hybridFlexZ)); + vol_hybrid_dual.placeVolume(vol_asic8, Position(0, hybridAsicY, hybridAsicZbase-asicThick*8.0/2.0)); + vol_hybrid_dual.setVisAttributes(hybrid_vis); + + vol_hybrid_quad = Volume("lvHybridQuad", hybrid_norm_box, air); + vol_hybrid_dual.placeVolume(vol_group_quad, Position(0, 0, hybridSensorZ)); + vol_hybrid_dual.placeVolume(vol_hybrid_flex_hole,Position(0, hybridFlexY, hybridFlexZ)); // ???? Hole ???? + vol_hybrid_dual.placeVolume(vol_asic16, Position(0, hybridAsicY, hybridAsicZbase-asicThick*16.0/2.0)); + vol_hybrid_quad.setVisAttributes(hybrid_vis); + } + + void UTBuild::build_modules() { + Box box_module(moduleWidth, moduleHeight, moduleThick); + RotationZYX rot_Y(0,M_PI,0); + RotationZYX rot_Z(0,0,M_PI); + RotationZYX rot_YZ(0,M_PI,M_PI); + vol_moduleA = Volume("lvModuleA", box_module, description.air()); + vol_moduleB = Volume("lvModuleB", box_module, description.air()); + vol_moduleC = Volume("lvModuleC", box_module, description.air()); + vol_moduleA.setVisAttributes(description, "UT_Module_Vis"); + vol_moduleB.setVisAttributes(description, "UT_Module_Vis"); + vol_moduleC.setVisAttributes(description, "UT_Module_Vis"); + Volume vol, dau, vols[3] = {vol_moduleA, vol_moduleB, vol_moduleC}; + for(int alt=-1, i = -13; i <= 13; i += 2, alt *= -1) { + for(size_t ivol=0; ivol<3; ++ivol) { + Position pos(0,double(i)/2.0*moduleHybridStepY, double(alt)*moduleHybridZ); + vol = vols[ivol]; + if ( ivol > 1 && std::abs(i) < 2 ) dau = vol_hybrid_quad; + else if ( ivol > 0 && std::abs(i) < 4 ) dau = vol_hybrid_dual; + else dau = vol_hybrid_norm; + + cout << "Placeing module " << dau.name() << " " << pos << endl; + if ( i*alt > 0 ) + (i<0) ? vol.placeVolume(dau, Transform3D(rot_Y,pos)) : vol.placeVolume(dau, Transform3D(rot_YZ,pos)); + else + (i<0) ? vol.placeVolume(dau, pos) : vol.placeVolume(dau, Transform3D(rot_Z,pos)); + } + } + } + + void UTBuild::build_layers() { + + } + + DetElement UTBuild::instantiate() { + Box sdet_box(frameOuterWidth, frameOuterHeight, boxOuterThickness); + Volume sdet_vol(x_env.nameStr(), sdet_box, description.air()); + + sdet_vol.setAttributes(description, x_env.regionStr(), x_env.limitsStr(), x_env.visStr()); + /** + * See DDDB/UUT/geometry.xml for the structure + **/ + if ( m_build_frame ) { // Build lvUTFrame + Position pos; + xml_comp_t x_frame = x_env.child(_U(frame)); + xml_dim_t x_p = x_frame.position(false); + Material mat = description.material(x_frame.materialStr()); + Box b_outer(frameOuterWidth,frameOuterHeight,frameThick); + Box b_inner(frameInnerWidth,frameInnerHeight,frameThick*1.1); + cout << "Frame inner:" << frameInnerWidth << " " << frameInnerHeight << " " << frameThick*1.1 << endl; + cout << "Frame outer:" << frameOuterWidth << " " << frameOuterHeight << " " << frameThick << endl; + vol_frame = Volume("lvUTFrame", SubtractionSolid(b_outer, b_inner), mat); + vol_frame.setAttributes(description, x_frame.regionStr(), x_frame.limitsStr(), x_frame.visStr()); + if ( x_p ) pos = Position(x_p.x(0), x_p.y(0), x_p.z(0)); + sdet_vol.placeVolume(vol_frame, pos); + } + if ( m_build_box ) { // Build lvUTBox + Position pos; + xml_comp_t x_box = x_env.child(_U(box)); + xml_dim_t x_p = x_box.position(false); + Box b1(x_params("BoxOuterWidth"), x_params("BoxOuterHeight"), x_params("BoxOuterThickness")); + Box b2(x_params("BoxInnerWidth"), x_params("BoxInnerHeight"), x_params("BoxInnerThickness")); + Tube tub(0.0, beamHoleRadius, x_params("BoxOuterThickness")); + SubtractionSolid s2(SubtractionSolid(b1, b2), tub); + vol_box = Volume(x_box.nameStr(), s2, description.material(x_box.materialStr())); + vol_box.setAttributes(description, x_box.regionStr(), x_box.limitsStr(), x_box.visStr()); + if ( x_p ) pos = Position(x_p.x(0), x_p.y(0), x_p.z(0)); + sdet_vol.placeVolume(vol_box, pos); + } + if ( m_build_uta ) { // Build lvUTa + xml_comp_t x_uta = x_env.child(_LBU(uta)); + Material mat = description.material(x_uta.materialStr()); + Position pos, pos_layX, pos_layU; + Volume vol_layX, vol_layU; { + xml_dim_t x_p = x_uta.position(); + Box box(vboxWidth, vboxHeight, stationThick); + Tube tub(0.0, vholeRadius, stationThick*1.1); + if ( x_p ) pos = Position(x_p.x(0), x_p.y(0), x_p.z(0)); + vol_uta = Volume("lvUTa", SubtractionSolid(box, tub), mat); + vol_uta.setAttributes(description, x_uta.regionStr(), x_uta.limitsStr(), x_uta.visStr()); + } { + xml_comp_t x_X = x_uta.child(_U(X)); + xml_dim_t x_p = x_X.position(); + xml_comp_t x_balcony = x_X.child(_LBU(balcony)); + xml_dim_t x_balcony_box = x_balcony.child(_U(box)); + xml_dim_t x_balcony_par = x_balcony.child(_U(params)); + double dz = x_balcony_par.dz(); + double step = x_balcony_par.step(); + double corr = x_balcony_par.correction(); + Box box(vboxWidth, vboxHeight, layerThick); + Tube tub(0.0, vholeRadius, layerThick*1.1); + Box box_balcony(x_balcony_box.x(0.0), x_balcony_box.y(0.0), x_balcony_box.z(0.0)); + Volume vol_balcony(x_balcony.nameStr(),box_balcony,description.material(x_balcony.materialStr())); + + + cout << "lvUTa: Step:" << step << " Corr:" << corr << endl; + + pos_layX = Position(x_p.x(0.0), x_p.y(0.0), x_p.z(0.0)); + vol_layX = Volume("lvUTaXLayer", SubtractionSolid(box, tub), mat); + vol_layX.setVisAttributes(description, x_X.visStr()); + + vol_balcony.setVisAttributes(description, x_balcony.visStr()); + for(xml_coll_t i(x_balcony,_U(position)); i; ++i) { + xml_dim_t x_pos = i; + vol_layX.placeVolume(vol_balcony,Position(x_pos.x(0.0), x_pos.y(0.0), x_pos.z(0.0))); + } + // Add the modules to the layer(s) + RotationZYX rot_Y(0,M_PI,0); + double dx; + // Region 1 at -X + corr = 0; + dz *= 5.0; + // +#define DEBUG_IT { cout << "DX: " << dx << endl; } + vol_layX.placeVolume(vol_moduleA, Position(dx=-15.*step-7.*corr,0,dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx=-13.*step+6.*corr,0,-dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx=-11.*step-5.*corr,0,dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx=-9.*step+4.*corr,0,-dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx=-7.*step-3.*corr,0,dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx=-5.*step+2.*corr,0,-dz)); + DEBUG_IT + + // Region 2 in the middle + vol_layX.placeVolume(vol_moduleB, Position(dx=-3.*step-corr,0,dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleC, Position(dx=-1.*step,0,-dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleC, Position(dx= 1.*step,0,dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleB, Position(dx= 3.*step-corr,0,-dz)); + DEBUG_IT + + // Region 3 at +X + vol_layX.placeVolume(vol_moduleA, Position(dx= 5.*step+2.*corr,0,dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx= 7.*step-3.*corr,0,-dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx= 9.*step+4.*corr,0,dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx=11.*step-5.*corr,0,-dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx=13.*step+6.*corr,0,dz)); + DEBUG_IT + vol_layX.placeVolume(vol_moduleA, Position(dx=15.*step-7.*corr,0,-dz)); + DEBUG_IT + // Balconies + vol_layX.placeVolume(vol_balcony, Position(0,balconyYposX,0)); + vol_layX.placeVolume(vol_balcony, Position(0,-balconyYposX,0)); + } { + xml_comp_t x_U = x_uta.child(_U(U)); + xml_dim_t x_p = x_U.position(); + Box box(vboxWidth, vboxHeight, layerThick); + Tube tub(layerThick, 0.0, vholeRadius*2.0); + pos_layU = Position(x_p.x(0.0), x_p.y(0.0), x_p.z(0.0)); + vol_layU = Volume("lvUTaULayer", SubtractionSolid(box, tub), mat); + vol_layU.setVisAttributes(description, x_U.visStr()); + } + vol_uta.placeVolume(vol_layX, pos_layX); + vol_uta.placeVolume(vol_layU, pos_layU); + sdet_vol.placeVolume(vol_uta, pos); + } + if ( m_build_utb ) { // Build lvUTb + xml_comp_t x_utb = x_env.child(_LBU(utb)); + Material mat = description.material(x_utb.materialStr()); + Position pos, pos_layX, pos_layV; + Volume vol_layX, vol_layV; { + xml_dim_t x_p = x_utb.position(); + Box box(vboxWidth, vboxHeight, stationThick); + Tube tub(0.0, vholeRadius, stationThick*1.1); + pos = Position(x_p.x(0), x_p.y(0), x_p.z(0)); + vol_utb = Volume("lvUTb", SubtractionSolid(box, tub), mat); + vol_utb.setAttributes(description, x_utb.regionStr(), x_utb.limitsStr(), x_utb.visStr()); + } { + xml_comp_t x_X = x_utb.child(_U(X)); + xml_dim_t x_p = x_X.position(); + Box box(vboxWidth, vboxHeight, layerThick); + Tube tub(0.0, vholeRadius, layerThick*1.1); + pos_layX = Position(x_p.x(0.0), x_p.y(0.0), x_p.z(0.0)); + vol_layX = Volume("lvUTbXLayer", SubtractionSolid(box, tub), mat); + vol_layX.setVisAttributes(description, x_X.visStr()); + } { + xml_comp_t x_V = x_utb.child(_U(V)); + xml_dim_t x_p = x_V.position(); + Box box(vboxWidth, vboxHeight, layerThick); + Tube tub(layerThick, 0.0, vholeRadius*2.0); + pos_layV = Position(x_p.x(0.0), x_p.y(0.0), x_p.z(0.0)); + vol_layV = Volume("lvUTbVLayer", SubtractionSolid(box, tub), mat); + vol_layV.setVisAttributes(description, x_V.visStr()); + } + vol_utb.placeVolume(vol_layX, pos_layX); + vol_utb.placeVolume(vol_layV, pos_layV); + cout << "UTB position: " << pos << endl; + sdet_vol.placeVolume(vol_utb, pos); + } + if ( m_build_jacket ) { // Build lvUTJacket + Position pos; + xml_comp_t x_jacket = x_env.child(_LBU(jacket)); + xml_dim_t x_p = x_jacket.position(); + double coneJacketThick = x_params("ConeJacketThickness"); + double cylJacketLength = x_params("CylJacketLength"); + double cylJacketRadius = x_params("CylJacketRadius"); + double cylJacketThick = x_params("CylJacketThickness"); + vector<double> rmin{x_params("ConeJacketRadiusZmin"), x_params("ConeJacketRadiusZmax")}; + vector<double> rmax{rmin[0]+coneJacketThick, rmin[1]+coneJacketThick}; + vector<double> z{0,x_params("ConeJacketLength")}; + + Tube cyl (cylJacketRadius,cylJacketRadius+cylJacketThick,cylJacketLength); + Polycone con (0, 2.0*M_PI, rmin, rmax, z); + Material mat = description.material(x_jacket.materialStr()); + Volume cyl_vol("lvUTCylJacket", cyl, mat); + Volume con_vol("lvUTConeJacket", con, description.material(x_jacket.materialStr())); + Assembly jacket_vol("lvUTJacket"); + jacket_vol.placeVolume(cyl_vol, Position(0,0,x_params("CylJacketZpos"))); + jacket_vol.placeVolume(con_vol, Position(0,0,x_params("ConeJacketZpos"))); + sdet_vol.placeVolume(jacket_vol, Position(x_p.x(0), x_p.y(0), x_p.z(0))); + } + { // Build lvUX851InUT + } + + sd.setType("tracker"); + PlacedVolume pv; + Volume mother = description.pickMotherVolume(sdet); + pv = mother.placeVolume(sdet_vol); + if ( x_det.hasAttr(_U(id)) ) { + pv.addPhysVolID("system",x_det.id()); + } + sdet.setPlacement(pv); + return sdet; + } +} + +static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { + UTBuild b(description, e, sens); + b.build_sensors(); + b.build_hybrids(); + b.build_modules(); + b.build_layers(); + DetElement sdet = b.instantiate(); + return sdet; +} +DECLARE_DETELEMENT(DD4hep_UUT,create_element) + diff --git a/examples/DDUpgrade/src/UpgradeTags.cpp b/examples/DDUpgrade/src/UpgradeTags.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cdbbf6e7f0c7cb0473d88b6a24997a45a5dd0c17 --- /dev/null +++ b/examples/DDUpgrade/src/UpgradeTags.cpp @@ -0,0 +1,20 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== + +// Framework include files +#include "XML/XMLTags.h" +#include "XML/XMLElements.h" + +// Define unicode tags +#define UNICODE(x) extern const ::dd4hep::xml::Tag_t Unicode_##x ( #x ) +#include "UpgradeTags.h" diff --git a/examples/DDUpgrade/src/UpgradeTags.h b/examples/DDUpgrade/src/UpgradeTags.h new file mode 100644 index 0000000000000000000000000000000000000000..355f0bb0b4ea035bb4fd318ad2909d9912546597 --- /dev/null +++ b/examples/DDUpgrade/src/UpgradeTags.h @@ -0,0 +1,53 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +#ifndef DD4HEP_CONDITIONS_CONDITIONSTAGS_H +#define DD4HEP_CONDITIONS_CONDITIONSTAGS_H + +// Framework include files +#include "XML/XMLElements.h" + +#ifndef UNICODE +#define UNICODE(x) extern const ::dd4hep::xml::Tag_t Unicode_##x +#endif + +/// Namespace for the AIDA detector description toolkit +namespace dd4hep { + + /// Namespace for the AIDA detector description toolkit supporting XML utilities + namespace xml { + + /// Namespace of conditions unicode tags + namespace ddupgrade { + + UNICODE(uta); + UNICODE(utb); + UNICODE(jacket); + UNICODE(balcony); + UNICODE(correction); + + // BCM + UNICODE(wire); + UNICODE(contact); + UNICODE(mount); + + } + // User must ensure there are no clashes. If yes, then the clashing entry is unnecessary. + //using namespace ::dd4hep::xml::Conditions; + } +} +#undef UNICODE // Do not miss this one! + +#include "XML/XMLTags.h" +#define _LBU(x) ::dd4hep::xml::ddupgrade::Unicode_##x + +#endif /* DD4HEP_CONDITIONS_CONDITIONSTAGS_H */ diff --git a/examples/LHeD/src/Lhe_SubdetectorAssembly_geo.cpp b/examples/LHeD/src/Lhe_SubdetectorAssembly_geo.cpp index 29a65770b4ede1861ea6074fa298dad5e848fa39..d3c1806bef2528acca7c9d2e8a560c5138212c75 100644 --- a/examples/LHeD/src/Lhe_SubdetectorAssembly_geo.cpp +++ b/examples/LHeD/src/Lhe_SubdetectorAssembly_geo.cpp @@ -61,7 +61,7 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t) { for(xml_coll_t c(x_det,_U(composite)); c; ++c) { xml_dim_t component = c; string nam = component.nameStr(); - description.declareMotherVolume(nam, vol); + description.declareParent(nam, sdet); } vol.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());