File indexing completed on 2025-01-18 09:14:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "DD4hep/DetFactoryHelper.h"
0016
0017 using namespace dd4hep;
0018
0019 static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector sens) {
0020 xml_det_t x_det = e;
0021 std::string name = x_det.nameStr();
0022 Assembly assembly(name+"_assembly");
0023 DetElement vxd(name, x_det.typeStr(), x_det.id());
0024 PlacedVolume pv;
0025
0026 assembly.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
0027 for(xml_coll_t c(e,_U(layer)); c; ++c) {
0028 xml_comp_t x_layer (c);
0029 xml_comp_t x_support (x_layer.child(_U(support)));
0030 xml_comp_t x_ladder (x_layer.child(_U(ladder)));
0031 int layer_id = x_layer.id();
0032 int nLadders = x_ladder.number();
0033 std::string layername = name+_toString(layer_id,"_layer%d");
0034 double dphi = 2.*M_PI/double(nLadders);
0035
0036 Assembly layer_assembly(layername);
0037
0038
0039
0040 DetElement layerDE( vxd , _toString(layer_id,"layer_%d"), x_det.id() );
0041 double zhalf = x_ladder.zhalf();
0042 double offset = x_ladder.offset();
0043 double sens_radius= x_ladder.radius();
0044 double sens_thick = x_ladder.thickness();
0045 double supp_thick = x_support.thickness();
0046 double radius = sens_radius - supp_thick ;
0047 double phi0 = x_layer.phi0() ;
0048 double width = x_ladder.width();
0049
0050
0051
0052 Assembly laddervol (layername+"_ladder");
0053
0054 Box sensbox (sens_thick/2., width/2., zhalf);
0055 Volume sensvol (layername+"_ladder_sens",sensbox,description.material(x_ladder.materialStr()));
0056
0057 Box suppbox (supp_thick/2.,width/2.,zhalf);
0058 Volume suppvol (layername+"_ladder_supp",suppbox,description.material(x_support.materialStr()));
0059
0060
0061 Position senspos ( (sens_thick+supp_thick)/2. - sens_thick/2., 0, 0 );
0062 Position supppos ( (sens_thick+supp_thick)/2. - sens_thick - supp_thick/2., 0, 0 );
0063
0064 sens.setType("tracker");
0065
0066 layer_assembly.setAttributes(description,x_layer.regionStr(),x_layer.limitsStr(),"invisible");
0067 pv = assembly.placeVolume(layer_assembly).addPhysVolID("layer",layer_id);
0068 layerDE.setPlacement( pv ) ;
0069
0070 laddervol.setAttributes(description,x_ladder.regionStr(),x_ladder.limitsStr(),"invisible");
0071 suppvol.setAttributes(description,x_support.regionStr(),x_support.limitsStr(),x_support.visStr());
0072
0073 sensvol.setSensitiveDetector(sens);
0074 sensvol.setAttributes(description,x_ladder.regionStr(),x_ladder.limitsStr(),x_layer.visStr());
0075
0076 laddervol.placeVolume(sensvol,senspos);
0077 laddervol.placeVolume(suppvol,supppos);
0078
0079 for(int j=0; j<nLadders; ++j) {
0080 double dj = double(j);
0081 double phi = phi0 + dj*dphi;
0082 std::string laddername = layername + _toString(j,"_ladder%d");
0083 double lthick = sens_thick + supp_thick;
0084 RotationZYX rot( phi,0,0);
0085 double pos_x = (radius + lthick/2.)*cos(phi) - offset * sin( phi );
0086 double pos_y = (radius + lthick/2.)*sin(phi) + offset * cos( phi );
0087
0088 pv = layer_assembly.placeVolume( laddervol,Transform3D(rot, Position(pos_x,pos_y,0.0)));
0089 pv.addPhysVolID("module",j).addPhysVolID("sensor",0).addPhysVolID("side",1);
0090 DetElement ladderDE(layerDE, laddername,x_det.id());
0091 ladderDE.setPlacement(pv);
0092 DetElement ladderDEposZ(layerDE, laddername+"_posZ", x_det.id() );
0093 ladderDEposZ.setPlacement( pv ) ;
0094 pv = layer_assembly.placeVolume(laddervol,Transform3D(rot, Position(pos_x, pos_y, -zhalf)));
0095 pv.addPhysVolID("module",j).addPhysVolID("sensor",0).addPhysVolID("side",2);
0096
0097 DetElement ladderDEnegZ(layerDE, laddername+"_negZ" , x_det.id() );
0098 ladderDEnegZ.setPlacement( pv ) ;
0099 }
0100 }
0101 Volume mother = description.pickMotherVolume(vxd) ;
0102 pv = mother.placeVolume(assembly);
0103 pv.addPhysVolID( "system", x_det.id());
0104 vxd.setPlacement(pv);
0105 return vxd;
0106 }
0107
0108 DECLARE_DETELEMENT(VXD_Assembly,create_element)