Warning, file /DD4hep/examples/DDCMS/src/plugins/DDShapeTest.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <DD4hep/World.h>
0018 #include <DD4hep/Detector.h>
0019 #include <DD4hep/DetFactoryHelper.h>
0020 #include <DD4hep/GeoHandler.h>
0021 #include <DD4hep/Printout.h>
0022 #include <DDCMS/DDShapes.h>
0023
0024 #include "TClass.h"
0025
0026 #include <sstream>
0027
0028
0029 namespace dd4hep {
0030
0031
0032 namespace cms {
0033
0034
0035
0036
0037
0038
0039
0040 class ShapeDump: public detail::GeoHandler {
0041 public:
0042 ShapeDump() = default;
0043
0044 virtual ~ShapeDump() = default;
0045
0046 virtual void* handleSolid(const std::string& name, const TGeoShape* volume) const;
0047 };
0048 }
0049 }
0050
0051
0052 void* dd4hep::cms::ShapeDump::handleSolid(const std::string& name, const TGeoShape* shape) const {
0053 if (shape) {
0054 Solid solid(shape);
0055 Box box = solid;
0056 if (shape->IsA() == TGeoCompositeShape::Class()) {
0057 }
0058 else {
0059 const TClass* isa = shape->IsA();
0060 cms::DDBox ddbox = solid;
0061
0062 if (isa == TGeoBBox::Class()) {
0063 printout(INFO, "ShapeDump","Got shape '%s' of type:%-16s -> DDBox:%p dx:%7.2f [cm] dy:%7.2f [cm] dz:%7.2f [cm]",
0064 name.c_str(), isa->GetName(), ddbox.ptr(), ddbox.halfX(), ddbox.halfY(), ddbox.halfZ());
0065 }
0066 else if (isa == TGeoTube::Class()) {
0067 }
0068 else if (isa == TGeoTubeSeg::Class()) {
0069 }
0070 else if (isa == TGeoTrd1::Class()) {
0071 }
0072 else if (isa == TGeoTrd2::Class()) {
0073 }
0074 else if (isa == TGeoPgon::Class()) {
0075 printout(INFO, "ShapeDump","Got shape '%s' of type:%-16s -> DDBox:%p dx:%7.2f [cm] dy:%7.2f [cm] dz:%7.2f [cm]",
0076 name.c_str(), isa->GetName(), ddbox.ptr(), ddbox.halfX(), ddbox.halfY(), ddbox.halfZ());
0077 }
0078 else if (isa == TGeoPcon::Class()) {
0079 cms::DDPolycone pcon = box;
0080 printout(INFO, "ShapeDump","Got shape '%s' of type:%-16s", name.c_str(), isa->GetName());
0081 printout(INFO, "ShapeDump"," DDBox: %p dx:%7.2f [cm] dy:%7.2f [cm] dz:%7.2f [cm]",
0082 ddbox.ptr(), ddbox.halfX(), ddbox.halfY(), ddbox.halfZ());
0083 printout(INFO, "ShapeDump"," DDPolycone:%p phi-start: %7.2f [rad] delta:%7.2f [rad] zplanes: N_z:%ld N_rmin:%ld N_rmax:%ld",
0084 pcon.ptr(), pcon.startPhi(), pcon.deltaPhi(), pcon.zVec().size(), pcon.rMinVec().size(), pcon.rMaxVec().size());
0085 }
0086 }
0087 }
0088 return 0;
0089 }
0090
0091 static long exec_ShapeDump(dd4hep::Detector& description, int, char**) {
0092 dd4hep::cms::ShapeDump dmp;
0093 dd4hep::detail::GeoHandlerTypes::GeometryInfo geo;
0094 dmp.collect(description.world(), geo);
0095 for (const auto s : geo.solids )
0096 dmp.handleSolid(s->GetName(), s);
0097 return 1;
0098 }
0099 DECLARE_APPLY(DDCMS_DDShapeDump,exec_ShapeDump)