File indexing completed on 2025-01-18 09:14:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "DDRec/DetectorData.h"
0013
0014 #include "DD4hep/DetFactoryHelper.h"
0015
0016 #include "XML/Layering.h"
0017 #include "XML/Utilities.h"
0018
0019
0020 #include "TGeoTrd2.h"
0021
0022 using namespace std;
0023 using namespace dd4hep;
0024 using namespace dd4hep::detail;
0025
0026 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) {
0027 xml_det_t x_det = e;
0028 int det_id = x_det.id();
0029 string det_name = x_det.nameStr();
0030 DetElement sdet (det_name,det_id);
0031
0032
0033
0034
0035 Volume envelope = xml::createPlacedEnvelope( description, e , sdet ) ;
0036 xml::setDetectorTypeFlag( e, sdet ) ;
0037
0038 if( description.buildType() == BUILD_ENVELOPE ) return sdet ;
0039
0040
0041
0042
0043 Material air = description.air();
0044 PlacedVolume pv;
0045 int n = 0;
0046
0047
0048 rec::LayeredCalorimeterData* solenoidData = new rec::LayeredCalorimeterData;
0049 solenoidData->inner_symmetry = 0;
0050 solenoidData->outer_symmetry = 0;
0051 solenoidData->layoutType = rec::LayeredCalorimeterData::BarrelLayout ;
0052
0053 double inner_radius= std::numeric_limits<double>::max();
0054 double outer_radius= 0;
0055
0056 double detZ= 0.;
0057
0058 for(xml_coll_t i(x_det,_U(layer)); i; ++i, ++n) {
0059 xml_comp_t x_layer = i;
0060 string l_name = det_name+_toString(n,"_layer%d");
0061 double z = x_layer.outer_z();
0062 double rmin = x_layer.inner_r();
0063 double r = rmin;
0064 DetElement layer(sdet,_toString(n,"layer%d"),x_layer.id());
0065 Tube l_tub (rmin,2*rmin,z);
0066 Volume l_vol(l_name,l_tub,air);
0067 int im = 0;
0068
0069
0070 for(xml_coll_t j(x_layer,_U(slice)); j; ++j, ++im) {
0071 xml_comp_t x_slice = j;
0072 Material mat = description.material(x_slice.materialStr());
0073 string s_name= l_name+_toString(m,"_slice%d");
0074 double thickness = x_slice.thickness();
0075
0076
0077
0078 rec::LayeredCalorimeterData::Layer solenoidLayer;
0079 solenoidLayer.distance = r;
0080
0081 solenoidLayer.inner_thickness = thickness/2.;
0082 solenoidLayer.outer_thickness = solenoidLayer.inner_thickness ;
0083
0084 solenoidLayer.cellSize0 = 0;
0085 solenoidLayer.cellSize1 = z;
0086 solenoidData->layers.push_back(solenoidLayer);
0087
0088 Tube s_tub(r,r+thickness,z,2*M_PI);
0089 Volume s_vol(s_name, s_tub, mat);
0090
0091 r += thickness;
0092 if ( x_slice.isSensitive() ) {
0093 sens.setType("tracker");
0094 s_vol.setSensitiveDetector(sens);
0095 }
0096
0097 s_vol.setAttributes(description,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
0098 pv = l_vol.placeVolume(s_vol);
0099
0100 pv.addPhysVolID("slice",im);
0101 }
0102 l_tub.setDimensions(rmin,r,z);
0103
0104 if (rmin < inner_radius)
0105 inner_radius = rmin;
0106
0107 if (z>detZ)
0108 detZ = z;
0109
0110 if (r>outer_radius)
0111 outer_radius = r;
0112
0113 l_vol.setVisAttributes(description,x_layer.visStr());
0114
0115 pv = envelope.placeVolume(l_vol);
0116 pv.addPhysVolID("layer",n);
0117 layer.setPlacement(pv);
0118 }
0119 if ( x_det.hasAttr(_U(combineHits)) ) {
0120 sdet.setCombineHits(x_det.combineHits(),sens);
0121 }
0122
0123
0124 solenoidData->extent[0] = inner_radius ;
0125 solenoidData->extent[1] = outer_radius ;
0126 solenoidData->extent[2] = 0. ;
0127 solenoidData->extent[3] = detZ;
0128
0129
0130 sdet.addExtension< rec::LayeredCalorimeterData >( solenoidData ) ;
0131
0132 return sdet;
0133
0134 }
0135
0136 DECLARE_DETELEMENT(DD4hep_Solenoid_o1_v01,create_detector)