From b92318e74704424a1f5f0364e4153046bff15800 Mon Sep 17 00:00:00 2001 From: Markus Frank <markus.frank@cern.ch> Date: Tue, 25 Nov 2014 10:39:30 +0000 Subject: [PATCH] Add new client example with 2 silicon blocks to test radiation lengths --- DDDetectors/src/BoxSegment_geo.cpp | 17 ++++++++++++++--- DDDetectors/src/PolyconeSupport_geo.cpp | 18 ++++++++++++++---- DDDetectors/src/TubeSegment_geo.cpp | 16 +++++++++++++--- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/DDDetectors/src/BoxSegment_geo.cpp b/DDDetectors/src/BoxSegment_geo.cpp index e27a0dc04..305f4d4ee 100644 --- a/DDDetectors/src/BoxSegment_geo.cpp +++ b/DDDetectors/src/BoxSegment_geo.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace DD4hep; using namespace DD4hep::Geometry; -static Ref_t create_element(LCDD& lcdd, xml_h e, Ref_t) { +static Ref_t create_element(LCDD& lcdd, xml_h e, Ref_t sens) { xml_det_t x_det = e; string name = x_det.nameStr(); xml_comp_t box (x_det.child(_U(box))); @@ -23,9 +23,20 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, Ref_t) { Volume det_vol(name+"_vol",Box(box.x(),box.y(),box.z()), mat); Volume mother = lcdd.pickMotherVolume(det); Transform3D transform(Rotation3D(RotationZYX(rot.z(),rot.y(),rot.x())),Position(pos.x(),pos.y(),pos.z())); - det_vol.setVisAttributes(lcdd, x_det.visStr()); PlacedVolume phv = mother.placeVolume(det_vol,transform); - phv.addPhysVolID("id",x_det.id()); + + det_vol.setVisAttributes(lcdd, x_det.visStr()); + det_vol.setLimitSet(lcdd, x_det.limitsStr()); + det_vol.setRegion(lcdd, x_det.regionStr()); + if ( x_det.isSensitive() ) { + SensitiveDetector sd = sens; + xml_dim_t sd_typ = x_det.child(_U(sensitive)); + det_vol.setSensitiveDetector(sens); + sd.setType(sd_typ.typeStr()); + } + if ( x_det.hasAttr(_U(id)) ) { + phv.addPhysVolID("system",x_det.id()); + } det.setPlacement(phv); return det; } diff --git a/DDDetectors/src/PolyconeSupport_geo.cpp b/DDDetectors/src/PolyconeSupport_geo.cpp index 50b2b6382..954323ab8 100644 --- a/DDDetectors/src/PolyconeSupport_geo.cpp +++ b/DDDetectors/src/PolyconeSupport_geo.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace DD4hep; using namespace DD4hep::Geometry; -static Ref_t create_detector(LCDD& lcdd, xml_h e, Ref_t) { +static Ref_t create_detector(LCDD& lcdd, xml_h e, Ref_t sens) { xml_det_t x_det = e; string name = x_det.nameStr(); DetElement sdet (name,x_det.id()); @@ -30,10 +30,20 @@ static Ref_t create_detector(LCDD& lcdd, xml_h e, Ref_t) { throw runtime_error("PolyCone["+name+"]> Not enough Z planes. minimum is 2!"); } Polycone cone (0,2*M_PI,rmin,rmax,z); - Volume volume(name, cone, mat); - volume.setVisAttributes(lcdd, x_det.visStr()); - PlacedVolume pv = lcdd.pickMotherVolume(sdet).placeVolume(volume); + Volume det_vol(name, cone, mat); + PlacedVolume pv = lcdd.pickMotherVolume(sdet).placeVolume(det_vol); + sdet.setPlacement(pv); + det_vol.setVisAttributes(lcdd, x_det.visStr()); + det_vol.setLimitSet(lcdd, x_det.limitsStr()); + det_vol.setRegion(lcdd, x_det.regionStr()); + if ( x_det.isSensitive() ) { + SensitiveDetector sd = sens; + xml_dim_t sd_typ = x_det.child(_U(sensitive)); + det_vol.setSensitiveDetector(sens); + sd.setType(sd_typ.typeStr()); + } + if ( x_det.hasAttr(_U(id)) ) { int det_id = x_det.id(); pv.addPhysVolID("system",det_id); diff --git a/DDDetectors/src/TubeSegment_geo.cpp b/DDDetectors/src/TubeSegment_geo.cpp index 4a1e556cd..9d31f211b 100644 --- a/DDDetectors/src/TubeSegment_geo.cpp +++ b/DDDetectors/src/TubeSegment_geo.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace DD4hep; using namespace DD4hep::Geometry; -static Ref_t create_element(LCDD& lcdd, xml_h e, Ref_t) { +static Ref_t create_element(LCDD& lcdd, xml_h e, Ref_t sens) { xml_det_t x_det (e); xml_comp_t x_tube = x_det.tubs(); xml_dim_t pos = x_det.position(); @@ -22,12 +22,22 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, Ref_t) { Volume vol (name,tub,lcdd.material(x_det.materialStr())); vol.setVisAttributes(lcdd, x_det.visStr()); - + vol.setLimitSet(lcdd, x_det.limitsStr()); + vol.setRegion(lcdd, x_det.regionStr()); + if ( x_det.isSensitive() ) { + SensitiveDetector sd = sens; + xml_dim_t sd_typ = x_det.child(_U(sensitive)); + vol.setSensitiveDetector(sens); + sd.setType(sd_typ.typeStr()); + } + DetElement sdet(name,x_det.id()); Volume mother = lcdd.pickMotherVolume(sdet); PlacedVolume phv = mother.placeVolume(vol,Transform3D(RotationZYX(rot.z(),rot.y(),rot.x()),Position(-pos.x(),-pos.y(),pos.z()))); - phv.addPhysVolID("id",x_det.id()); + if ( x_det.hasAttr(_U(id)) ) { + phv.addPhysVolID("system",x_det.id()); + } sdet.setPlacement(phv); return sdet; } -- GitLab