File indexing completed on 2025-01-18 09:14:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include "DD4hep/DetFactoryHelper.h"
0020 #include "DD4hep/Printout.h"
0021 #include "XML/Utilities.h"
0022
0023 using namespace std;
0024 using namespace dd4hep;
0025 using namespace dd4hep::detail;
0026
0027 static Ref_t create_element(Detector& description, xml_h e, Ref_t) {
0028 xml_det_t x_det (e);
0029 string det_name = x_det.nameStr();
0030 DetElement sdet(det_name, x_det.id());
0031 Volume vol;
0032
0033 bool useRot = x_det.hasChild(_U(rotation));
0034 bool usePos = x_det.hasChild(_U(position));
0035 Position pos;
0036 RotationZYX rot;
0037
0038 sdet.setType("compound");
0039 xml::setDetectorTypeFlag( e, sdet ) ;
0040
0041 if( usePos ) {
0042 pos = Position(x_det.position().x(), x_det.position().y(), x_det.position().z());
0043 }
0044 if( useRot ) {
0045 rot = RotationZYX(x_det.rotation().x(), x_det.rotation().y(), x_det.rotation().z());
0046 }
0047
0048 if ( x_det.hasChild(_U(shape)) ) {
0049 xml_comp_t x_shape = x_det.child(_U(shape));
0050 string type = x_shape.typeStr();
0051 Solid solid = xml::createShape(description, type, x_shape);
0052 Material mat = description.material(x_shape.materialStr());
0053 printout(DEBUG,det_name,"+++ Creating detector assembly with shape of type:%s",type.c_str());
0054 vol = Volume(det_name,solid,mat);
0055 }
0056 else {
0057 printout(DEBUG,det_name,"+++ Creating detector assembly without shape");
0058 vol = Assembly(det_name);
0059 }
0060
0061 vol.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
0062
0063 Volume mother = description.pickMotherVolume(sdet);
0064 PlacedVolume pv;
0065 if( useRot && usePos ){
0066 pv = mother.placeVolume(vol, Transform3D(rot, pos));
0067 } else if( useRot ){
0068 pv = mother.placeVolume(vol, rot);
0069 } else if( usePos ){
0070 pv = mother.placeVolume(vol, pos);
0071 } else {
0072 pv = mother.placeVolume(vol);
0073 }
0074
0075 sdet.setPlacement(pv);
0076
0077 for(xml_coll_t c(x_det,_U(composite)); c; ++c) {
0078 xml_dim_t component = c;
0079 string nam = component.nameStr();
0080 description.declareParent(nam, sdet);
0081 }
0082 return sdet;
0083 }
0084
0085 DECLARE_DETELEMENT(Lhe_SubdetectorAssembly,create_element)