Back to home page

EIC code displayed by LXR

 
 

    


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 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 //
0014 // Specialized generic detector constructor
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 /// Namespace for the AIDA detector description toolkit
0029 namespace dd4hep {
0030 
0031   /// Namespace for implementation details of the AIDA detector description toolkit
0032   namespace cms  {
0033 
0034     /// Geometry to screen dump action
0035     /**
0036      *  \author  M.Frank
0037      *  \version 1.0
0038      *  \ingroup DD4HEP_CORE
0039      */
0040     class ShapeDump: public detail::GeoHandler {
0041     public:
0042       ShapeDump() = default;
0043       /// Standard destructor
0044       virtual ~ShapeDump() = default;
0045       /// Dump solid in GDML format to output stream
0046       virtual void* handleSolid(const std::string& name, const TGeoShape* volume) const;
0047     };
0048   }    // End namespace detail
0049 }      // End namespace dd4hep
0050 
0051 /// Dump solid in GDML format to output stream
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; // Every shape implements a TGeoBBox
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)