File indexing completed on 2025-01-18 09:14:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 #include "DD4hep/DetFactoryHelper.h"
0043
0044 using namespace std;
0045 using namespace dd4hep;
0046 using namespace dd4hep::detail;
0047
0048 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sensitive) {
0049 xml_det_t x_det = e;
0050 string name = x_det.nameStr();
0051 DetElement sdet (name,x_det.id());
0052 Assembly assembly(name+"_assembly");
0053 Material mat (description.material(x_det.materialStr()));
0054 PlacedVolume pv;
0055
0056 sensitive.setType("escape_counter");
0057 for(xml_coll_t xm(e,_U(module)); xm; ++xm) {
0058 xml_comp_t mod = xm;
0059 vector<double> rmin,rmax,z;
0060 string vis = mod.visStr().empty() ? x_det.visStr() : mod.visStr();
0061 int num = 0;
0062 for(xml_coll_t c(mod,_U(zplane)); c; ++c, ++num) {
0063 xml_comp_t dim(c);
0064 rmin.push_back(dim.rmin());
0065 rmax.push_back(dim.rmax());
0066 z.push_back(dim.z()/2);
0067 }
0068 if ( num < 2 ) {
0069 throw runtime_error("ZylinderShell["+name+"]> Not enough Z planes. minimum is 2!");
0070 }
0071 Polycone cone (0.,2*M_PI,rmin,rmax,z);
0072 Volume volume(name, cone, mat);
0073 volume.setVisAttributes(description, vis);
0074 volume.setSensitiveDetector(sensitive);
0075 pv = assembly.placeVolume(volume);
0076 pv.addPhysVolID("barrel",mod.id());
0077 }
0078
0079 pv = description.pickMotherVolume(sdet).placeVolume(assembly);
0080 pv.addPhysVolID("system",x_det.id());
0081 sdet.setPlacement(pv);
0082 return sdet;
0083 }
0084
0085 DECLARE_DETELEMENT(Lhe_CylinderShell,create_detector)