diff --git a/DDCore/include/DD4hep/Objects.h b/DDCore/include/DD4hep/Objects.h index c73fd919b118d41a4d420b0aa586563c35a1c52d..e7b74a993689541664a6e79bab9b6d463c6edcee 100644 --- a/DDCore/include/DD4hep/Objects.h +++ b/DDCore/include/DD4hep/Objects.h @@ -14,8 +14,8 @@ #define DD4HEP_OBJECTS_H // Framework include files -#include "DD4hep/Handle.h" -#include "DD4hep/NamedObject.h" +#include <DD4hep/Handle.h> +#include <DD4hep/NamedObject.h> // Forward declarations class TMap; @@ -33,23 +33,22 @@ class TGeoIdentity; #pragma GCC diagnostic ignored "-Wdeprecated" // Code that causes warning goes here #endif // ROOT include files -#include "Math/Vector3D.h" -#include "Math/Transform3D.h" -#include "Math/Translation3D.h" -#include "Math/RotationX.h" -#include "Math/RotationY.h" -#include "Math/RotationZ.h" -#include "Math/Rotation3D.h" -#include "Math/RotationZYX.h" -#include "Math/EulerAngles.h" -#include "Math/VectorUtil.h" +#include <Math/Vector3D.h> +#include <Math/Transform3D.h> +#include <Math/Translation3D.h> +#include <Math/RotationX.h> +#include <Math/RotationY.h> +#include <Math/RotationZ.h> +#include <Math/Rotation3D.h> +#include <Math/RotationZYX.h> +#include <Math/EulerAngles.h> +#include <Math/VectorUtil.h> #include <TGeoElement.h> #include <TGeoMaterial.h> #include <TGeoMedium.h> -#include "TGeoPhysicalNode.h" -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) -#include "TGDMLMatrix.h" -#endif +#include <TGeoPhysicalNode.h> +#include <TGDMLMatrix.h> + #ifdef __GNUC__ #pragma GCC diagnostic pop #endif @@ -272,9 +271,8 @@ namespace dd4hep { */ class Material: public Handle<TGeoMedium> { public: -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) typedef const TGDMLMatrix* Property; -#endif + public: /// Default constructor Material() = default; @@ -304,7 +302,6 @@ namespace dd4hep { double intLength() const; /// Access the fraction of an element within the material double fraction(Atom atom) const; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Access to tabular properties of the material Property property(const char* name) const; /// Access to tabular properties of the material @@ -315,7 +312,6 @@ namespace dd4hep { double constProperty(const std::string& name) const; /// Access string property value from the material table std::string constPropertyRef(const std::string& name, const std::string& default_value=""); -#endif }; /// Handle class describing visualization attributes @@ -506,8 +502,8 @@ namespace dd4hep { } /* End namespace dd4hep */ -#include "Math/Vector4D.h" -#include "Math/Point3D.h" +#include <Math/Vector4D.h> +#include <Math/Point3D.h> namespace ROOT { namespace Math { diff --git a/DDCore/include/DD4hep/OpticalSurfaceManager.h b/DDCore/include/DD4hep/OpticalSurfaceManager.h index 9a42471abec94e30c024b787f335c1d0563a5808..1cd761b67e769a33c82069561b54b2d4144b3342 100644 --- a/DDCore/include/DD4hep/OpticalSurfaceManager.h +++ b/DDCore/include/DD4hep/OpticalSurfaceManager.h @@ -14,10 +14,10 @@ #define DD4HEP_OPTICALSURFACEMANAGER_H // Framework include files -#include "DD4hep/OpticalSurfaces.h" +#include <DD4hep/OpticalSurfaces.h> // ROOT include files -#include "TGeoManager.h" +#include <TGeoManager.h> /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -58,7 +58,6 @@ namespace dd4hep { /// static accessor calling DD4hepOpticalSurfaceManagerPlugin if necessary static OpticalSurfaceManager getOpticalSurfaceManager(Detector& description); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Access skin surface by its full name SkinSurface skinSurface(const std::string& full_name) const; /// Access skin surface by its identifier tuple (DetElement, name) @@ -80,7 +79,6 @@ namespace dd4hep { /// Register the temporary surface objects with the TGeoManager void registerSurfaces(DetElement subdetector); -#endif }; } /* End namespace dd4hep */ #endif // DD4HEP_OPTICALSURFACEMANAGER_H diff --git a/DDCore/include/DD4hep/OpticalSurfaces.h b/DDCore/include/DD4hep/OpticalSurfaces.h index d286f04f194586268fb1e95e6dbd972b844178e8..c8b98e9a3b8fd28d38294ae01a8c149eb3615be0 100644 --- a/DDCore/include/DD4hep/OpticalSurfaces.h +++ b/DDCore/include/DD4hep/OpticalSurfaces.h @@ -14,13 +14,11 @@ #define DD4HEP_OPTICALSURFACES_H // Framework include files -#include "DD4hep/Volumes.h" -#include "DD4hep/DetElement.h" - -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) +#include <DD4hep/Volumes.h> +#include <DD4hep/DetElement.h> // ROOT include files -#include "TGeoOpticalSurface.h" +#include <TGeoOpticalSurface.h> /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -192,8 +190,5 @@ namespace dd4hep { /// Access the right node of the border surface PlacedVolume right() const; }; - - -} /* End namespace dd4hep */ -#endif /* ROOT_VERSION */ +} /* End namespace dd4hep */ #endif // DD4HEP_OPTICALSURFACES_H diff --git a/DDCore/include/DD4hep/PropertyTable.h b/DDCore/include/DD4hep/PropertyTable.h index 524e2363b2742f4c28f03b7b1a06d72f3bab0ca5..be06bd4567ee414a2128f59a8013d253d685f605 100644 --- a/DDCore/include/DD4hep/PropertyTable.h +++ b/DDCore/include/DD4hep/PropertyTable.h @@ -13,14 +13,11 @@ #ifndef DD4HEP_PROPERTYTABLE_H #define DD4HEP_PROPERTYTABLE_H -#include "RVersion.h" -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) - // Framework include files -#include "DD4hep/Handle.h" +#include <DD4hep/Handle.h> // ROOT include files -#include "TGDMLMatrix.h" +#include <TGDMLMatrix.h> /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -59,6 +56,5 @@ namespace dd4hep { PropertyTable& operator=(const PropertyTable& m) = default; }; -} /* End namespace dd4hep */ -#endif /* ROOT_VERSION */ +} // End namespace dd4hep #endif // DD4HEP_PROPERTYTABLE_H diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h index a186bb448bc31572d07c6ee90cc313f0ed52184a..cb0f8b32a11d9b8711c106c451792f497dba7d4c 100644 --- a/DDCore/include/DD4hep/Shapes.h +++ b/DDCore/include/DD4hep/Shapes.h @@ -46,9 +46,7 @@ #include <TGeoCompositeShape.h> #include <TGeoShapeAssembly.h> #include <TGeoPara.h> -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) #include <TGeoTessellated.h> -#endif #ifdef __GNUC__ #pragma GCC diagnostic pop @@ -1762,7 +1760,6 @@ namespace dd4hep { } }; -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) /// Class describing a tessellated shape /** * For any further documentation please see the following ROOT documentation: @@ -1833,7 +1830,6 @@ namespace dd4hep { /// Access a single vertex from the shape const Vertex& vertex(int index) const; }; -#endif /// Base class describing boolean (=union,intersection,subtraction) solids /** @@ -2012,6 +2008,5 @@ namespace dd4hep { /// Copy Assignment operator IntersectionSolid& operator=(const IntersectionSolid& copy) = default; }; - -} /* End namespace dd4hep */ +} /* End namespace dd4hep */ #endif // DD4HEP_SHAPES_H diff --git a/DDCore/include/DD4hep/detail/OpticalSurfaceManagerInterna.h b/DDCore/include/DD4hep/detail/OpticalSurfaceManagerInterna.h index 51d0bda2a019a3dcd7ba9e5c25c0a26c6ab5ca0f..979e3a314b2fe89d3258834132aeb34aaaa963c2 100644 --- a/DDCore/include/DD4hep/detail/OpticalSurfaceManagerInterna.h +++ b/DDCore/include/DD4hep/detail/OpticalSurfaceManagerInterna.h @@ -22,7 +22,7 @@ #define DD4HEP_DETAIL_OPTICALSURFACEMANAGERINTERNA_H /// Framework include files -#include "DD4hep/Detector.h" +#include <DD4hep/Detector.h> /// C/C++ include files #include <map> @@ -46,11 +46,9 @@ namespace dd4hep { /// Reference to the main detector description object Detector& detector; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) std::map<LocalKey, SkinSurface> skinSurfaces; std::map<LocalKey, BorderSurface> borderSurfaces; std::map<std::string, OpticalSurface> opticalSurfaces; -#endif public: /// Default constructor diff --git a/DDCore/include/DD4hep/detail/Plugins.inl b/DDCore/include/DD4hep/detail/Plugins.inl index 11258d5dd916406481bad6f2219f37e5a15d42ec..d26913c114240466116df71734d9032ec53fd457 100644 --- a/DDCore/include/DD4hep/detail/Plugins.inl +++ b/DDCore/include/DD4hep/detail/Plugins.inl @@ -14,7 +14,7 @@ #ifndef DD4HEP_PLUGINS_INL #define DD4HEP_PLUGINS_INL -#include "DD4hep/Plugins.h" +#include <DD4hep/Plugins.h> #if !defined(DD4HEP_PARSERS_NO_ROOT) && ROOT_VERSION_CODE < ROOT_VERSION(6,0,0) #include <set> diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index 7e5eeb4d3cdecfe2814a57d1153011d7e5afae73..9f77b5b24a5bf66f6ece7f61991bc7d33a2af96d 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -14,19 +14,19 @@ #define DD4HEP_MUST_USE_DETECTORIMP_H 1 // Framework include files -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DD4hep/GeoHandler.h" -#include "DD4hep/DetectorHelper.h" -#include "DD4hep/DetectorTools.h" - -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/ObjectsInterna.h" -#include "DD4hep/detail/DetectorInterna.h" -#include "DD4hep/detail/VolumeManagerInterna.h" -#include "DD4hep/detail/OpticalSurfaceManagerInterna.h" -#include "DD4hep/DetectorImp.h" -#include "DD4hep/DD4hepUnits.h" +#include <DD4hep/Plugins.h> +#include <DD4hep/Printout.h> +#include <DD4hep/GeoHandler.h> +#include <DD4hep/DetectorHelper.h> +#include <DD4hep/DetectorTools.h> + +#include <DD4hep/InstanceCount.h> +#include <DD4hep/detail/ObjectsInterna.h> +#include <DD4hep/detail/DetectorInterna.h> +#include <DD4hep/detail/VolumeManagerInterna.h> +#include <DD4hep/detail/OpticalSurfaceManagerInterna.h> +#include <DD4hep/DetectorImp.h> +#include <DD4hep/DD4hepUnits.h> // C/C++ include files #include <iostream> @@ -35,21 +35,19 @@ #include <mutex> // ROOT inlcude files -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) -#include "TGeoSystemOfUnits.h" -#endif -#include "TGeoCompositeShape.h" -#include "TGeoBoolNode.h" -#include "TGeoManager.h" -#include "TGeoMatrix.h" -#include "TGeoVolume.h" -#include "TGeoShape.h" -#include "TClass.h" +#include <TGeoSystemOfUnits.h> +#include <TGeoCompositeShape.h> +#include <TGeoBoolNode.h> +#include <TGeoManager.h> +#include <TGeoMatrix.h> +#include <TGeoVolume.h> +#include <TGeoShape.h> +#include <TClass.h> -#include "XML/DocumentHandler.h" +#include <XML/DocumentHandler.h> #ifndef __TIXML__ -#include "xercesc/dom/DOMException.hpp" +#include <xercesc/dom/DOMException.hpp> namespace dd4hep { namespace xml { typedef xercesc::DOMException XmlException; @@ -58,12 +56,12 @@ namespace dd4hep { #endif using namespace dd4hep; -using namespace std; ClassImp(DetectorImp) namespace { - recursive_mutex s_detector_apply_lock; + + std::recursive_mutex s_detector_apply_lock; struct TypePreserve { DetectorBuildType& m_t; @@ -76,16 +74,16 @@ namespace { }; struct Instances { - recursive_mutex lock; - map<string, Detector*> detectors; + std::recursive_mutex lock; + std::map<std::string, Detector*> detectors; Instances() = default; ~Instances() { } - Detector* get(const string& name) { + Detector* get(const std::string& name) { auto i = detectors.find(name); return i == detectors.end() ? 0 : (*i).second; } - void insert(const string& name, Detector* detector) { + void insert(const std::string& name, Detector* detector) { auto i = detectors.find(name); if ( i == detectors.end() ) { detectors.emplace(name,detector); @@ -93,7 +91,7 @@ namespace { } except("DD4hep","Cannot insert detector instance %s [Already present]",name.c_str()); } - Detector* remove(const string& name) { + Detector* remove(const std::string& name) { auto i = detectors.find(name); if ( i != detectors.end() ) { Detector* det = (*i).second; @@ -106,8 +104,8 @@ namespace { class DetectorGuard final { protected: - static pair<recursive_mutex, map<DetectorImp*, TGeoManager*> >& detector_lock() { - static pair<recursive_mutex, map<DetectorImp*, TGeoManager*> > s_inst; + static std::pair<std::recursive_mutex, std::map<DetectorImp*, TGeoManager*> >& detector_lock() { + static std::pair<std::recursive_mutex, std::map<DetectorImp*, TGeoManager*> > s_inst; return s_inst; } DetectorImp* detector {nullptr}; @@ -124,8 +122,8 @@ namespace { auto& lock = detector_lock(); auto i = lock.second.find(detector); if ( i != lock.second.end() ) { - mgr = (*i).second; - lock.second.erase(i); + mgr = (*i).second; + lock.second.erase(i); } lock.first.unlock(); return mgr; @@ -138,19 +136,19 @@ namespace { } } -string dd4hep::versionString(){ - string vs("vXX-YY") ; - sprintf( &vs[0] , "v%2.2d-%2.2d", DD4HEP_MAJOR_VERSION, DD4HEP_MINOR_VERSION ) ; +std::string dd4hep::versionString(){ + std::string vs("vXX-YY") ; + std::sprintf( &vs[0] , "v%2.2d-%2.2d", DD4HEP_MAJOR_VERSION, DD4HEP_MINOR_VERSION ) ; return vs; } -unique_ptr<Detector> Detector::make_unique(const std::string& name) { +std::unique_ptr<Detector> Detector::make_unique(const std::string& name) { Detector* description = new DetectorImp(name); - return unique_ptr<Detector>(description); + return std::unique_ptr<Detector>(description); } Detector& Detector::getInstance(const std::string& name) { - lock_guard<recursive_mutex> lock(detector_instances().lock); + std::lock_guard<std::recursive_mutex> lock(detector_instances().lock); Detector* description = detector_instances().get(name); if ( 0 == description ) { gGeoManager = 0; @@ -162,7 +160,7 @@ Detector& Detector::getInstance(const std::string& name) { /// Destroy the instance void Detector::destroyInstance(const std::string& name) { - lock_guard<recursive_mutex> lock(detector_instances().lock); + std::lock_guard<std::recursive_mutex> lock(detector_instances().lock); Detector* description = detector_instances().remove(name); if (description) delete description; @@ -179,34 +177,21 @@ DetectorImp::DetectorImp() } /// Initializing constructor -DetectorImp::DetectorImp(const string& name) +DetectorImp::DetectorImp(const std::string& name) : TNamed(), DetectorData(), DetectorLoad(this), m_buildType(BUILD_NONE) { -#if defined(DD4HEP_USE_GEANT4_UNITS) && ROOT_VERSION_CODE >= ROOT_VERSION(6,22,7) - printout(INFO,"DD4hep","++ Using globally Geant4 unit system (mm,ns,MeV)"); - if ( TGeoManager::GetDefaultUnits() != TGeoManager::kG4Units ) { - TGeoManager::LockDefaultUnits(kFALSE); - TGeoManager::SetDefaultUnits(TGeoManager::kG4Units); - TGeoManager::LockDefaultUnits(kTRUE); - } -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,22,7) - if ( TGeoManager::GetDefaultUnits() != TGeoManager::kRootUnits ) { - TGeoManager::LockDefaultUnits(kFALSE); - TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits); - TGeoManager::LockDefaultUnits(kTRUE); - } +#if defined(DD4HEP_USE_GEANT4_UNITS) + printout(INFO,"DD4hep","++ Using globally Geant4 unit system (mm,ns,MeV)"); + if ( TGeoManager::GetDefaultUnits() != TGeoManager::kG4Units ) { + TGeoManager::LockDefaultUnits(kFALSE); + TGeoManager::SetDefaultUnits(TGeoManager::kG4Units); + TGeoManager::LockDefaultUnits(kTRUE); + } #else - static bool first = true; - if ( first ) { - first = false; -#if defined(DD4HEP_USE_GEANT4_UNITS) && ROOT_VERSION_CODE >= ROOT_VERSION(6,20,0) - printout(INFO,"DD4hep","++ Using globally Geant4 unit system (mm,ns,MeV)"); - TGeoManager::SetDefaultG4Units(); - TGeoUnit::setUnitType(TGeoUnit::kTGeant4Units); -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,20,0) - TGeoManager::SetDefaultRootUnits(); - TGeoUnit::setUnitType(TGeoUnit::kTGeoUnits); -#endif + if ( TGeoManager::GetDefaultUnits() != TGeoManager::kRootUnits ) { + TGeoManager::LockDefaultUnits(kFALSE); + TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits); + TGeoManager::LockDefaultUnits(kTRUE); } #endif @@ -251,7 +236,7 @@ DetectorImp::DetectorImp(const string& name) DetectorImp::~DetectorImp() { DetectorGuard(this).lock(gGeoManager); if ( m_manager ) { - lock_guard<recursive_mutex> lock(detector_instances().lock); + std::lock_guard<std::recursive_mutex> lock(detector_instances().lock); if ( m_manager == gGeoManager ) gGeoManager = 0; Detector* description = detector_instances().get(GetName()); if ( 0 != description ) { @@ -280,10 +265,10 @@ Int_t DetectorImp::saveObject(const char *name, Int_t option, Int_t bufsize) con DetectorData::unpatchRootStreamer(TGeoNode::Class()); return nbytes; } - catch (const exception& e) { + catch (const std::exception& e) { DetectorData::unpatchRootStreamer(TGeoVolume::Class()); DetectorData::unpatchRootStreamer(TGeoNode::Class()); - except("Detector","Exception %s while saving dd4hep::Detector object",e.what()); + except("Detector","Exception %s while saving dd4hep::Detector object", e.what()); } catch (...) { DetectorData::unpatchRootStreamer(TGeoVolume::Class()); @@ -315,7 +300,7 @@ void* DetectorImp::userExtension(unsigned long long int key, bool alert) const { } /// Register new mother volume using the detector name. -void DetectorImp::declareParent(const string& detector_name, const DetElement& parent) { +void DetectorImp::declareParent(const std::string& detector_name, const DetElement& parent) { if ( !detector_name.empty() ) { if ( parent.isValid() ) { auto i = m_detectorParents.find(detector_name); @@ -343,7 +328,7 @@ void DetectorImp::declareParent(const string& detector_name, const DetElement& p /// Access mother volume by detector element Volume DetectorImp::pickMotherVolume(const DetElement& de) const { if ( de.isValid() ) { - string de_name = de.name(); + std::string de_name = de.name(); auto i = m_detectorParents.find(de_name); if (i == m_detectorParents.end()) { if ( m_worldVol.isValid() ) { @@ -422,14 +407,14 @@ DetElement DetectorImp::detector(const std::string& name) const { } Detector& DetectorImp::addDetector(const Handle<NamedObject>& ref_det) { - DetElement det_element(ref_det); + DetElement det_element(ref_det); DetectorHelper helper(this); - DetElement existing_det = helper.detectorByID(det_element.id()); + DetElement existing_det = helper.detectorByID(det_element.id()); if ( existing_det.isValid() ) { SensitiveDetector sd = helper.sensitiveDetector(existing_det); if ( sd.isValid() ) { - stringstream str; + std::stringstream str; str << "Detector: The sensitive sub-detectors " << det_element.name() << " and " << existing_det.name() << " have the identical ID:" << det_element.id() << "."; except("DD4hep",str.str()); @@ -439,9 +424,9 @@ Detector& DetectorImp::addDetector(const Handle<NamedObject>& ref_det) { det_element->flag |= DetElement::Object::IS_TOP_LEVEL_DETECTOR; PlacedVolume pv = det_element.placement(); if ( !pv.isValid() ) { - stringstream str; + std::stringstream str; str << "Detector: Adding subdetectors with no valid placement is not allowed: " - << det_element.name() << " ID:" << det_element.id() << "."; + << det_element.name() << " ID:" << det_element.id() << "."; except("DD4hep",str.str()); } Volume volume = pv->GetMotherVolume(); @@ -464,7 +449,7 @@ Detector& DetectorImp::addDetector(const Handle<NamedObject>& ref_det) { // The detector's placement must be one of the existing detectors for(HandleMap::iterator idet = m_detectors.begin(); idet != m_detectors.end(); ++idet) { DetElement parent((*idet).second); - Volume vol = parent.placement().volume(); + Volume vol = parent.placement().volume(); if ( vol == volume ) { printout(INFO,"DD4hep","+++ Detector: Added detector %s to the parent:%s.", det_element.name(),parent.name()); @@ -473,7 +458,7 @@ Detector& DetectorImp::addDetector(const Handle<NamedObject>& ref_det) { } } except("DD4hep","+++ Detector: The detector %s has no known parent.", det_element.name()); - throw runtime_error("Detector-Error"); // Never called.... + throw std::runtime_error("Detector-Error"); // Never called.... } /// Add a new constant by named reference to the detector description @@ -488,38 +473,38 @@ Detector& DetectorImp::addConstant(const Handle<NamedObject>& x) { } /// Retrieve a constant by its name from the detector description -Constant DetectorImp::constant(const string& name) const { +Constant DetectorImp::constant(const std::string& name) const { if ( !m_inhibitConstants ) { return getRefChild(m_define, name); } - throw runtime_error("Detector:constant("+name+"): Access to global constants is inhibited."); + throw std::runtime_error("Detector:constant("+name+"): Access to global constants is inhibited."); } /// Typed access to constants: access string values -string DetectorImp::constantAsString(const string& name) const { +std::string DetectorImp::constantAsString(const std::string& name) const { if ( !m_inhibitConstants ) { Handle<NamedObject> c = constant(name); if (c.isValid()) return c->GetTitle(); - throw runtime_error("Detector:constantAsString: The constant " + name + " is not known to the system."); + throw std::runtime_error("Detector:constantAsString: The constant " + name + " is not known to the system."); } - throw runtime_error("Detector:constantAsString("+name+"):: Access to global constants is inhibited."); + throw std::runtime_error("Detector:constantAsString("+name+"):: Access to global constants is inhibited."); } /// Typed access to constants: long values -long DetectorImp::constantAsLong(const string& name) const { +long DetectorImp::constantAsLong(const std::string& name) const { if ( !m_inhibitConstants ) { return _toLong(constantAsString(name)); } - throw runtime_error("Detector:constantAsLong("+name+"): Access to global constants is inhibited."); + throw std::runtime_error("Detector:constantAsLong("+name+"): Access to global constants is inhibited."); } /// Typed access to constants: double values -double DetectorImp::constantAsDouble(const string& name) const { +double DetectorImp::constantAsDouble(const std::string& name) const { if ( !m_inhibitConstants ) { return _toDouble(constantAsString(name)); } - throw runtime_error("Detector:constantAsDouble("+name+"): Access to global constants is inhibited."); + throw std::runtime_error("Detector:constantAsDouble("+name+"): Access to global constants is inhibited."); } /// Add a field component by named reference to the detector description @@ -530,12 +515,12 @@ Detector& DetectorImp::addField(const Handle<NamedObject>& x) { } /// Retrieve a matrial by its name from the detector description -Material DetectorImp::material(const string& name) const { +Material DetectorImp::material(const std::string& name) const { TGeoMedium* mat = m_manager->GetMedium(name.c_str()); if (mat) { return Material(mat); } - throw runtime_error("Cannot find a material referenced by name:" + name); + throw std::runtime_error("Cannot find a material referenced by name:" + name); } /// Internal helper to map detector types once the geometry is closed @@ -560,36 +545,36 @@ void DetectorImp::mapDetectorTypes() { } /// Access the availible detector types -vector<string> DetectorImp::detectorTypes() const { +std::vector<std::string> DetectorImp::detectorTypes() const { if ( m_manager->IsClosed() ) { - vector<string> v; + std::vector<std::string> v; v.reserve(m_detectorTypes.size()); for(const auto& t : m_detectorTypes ) v.emplace_back(t.first); return v; } - throw runtime_error("detectorTypes: Call only available once the geometry is closed!"); + throw std::runtime_error("detectorTypes: Call only available once the geometry is closed!"); } /// Access a set of subdetectors according to the sensitive type. -const vector<DetElement>& DetectorImp::detectors(const string& type, bool throw_exc) const { +const std::vector<DetElement>& DetectorImp::detectors(const std::string& type, bool throw_exc) const { if ( m_manager->IsClosed() ) { DetectorTypeMap::const_iterator i=m_detectorTypes.find(type); if ( i != m_detectorTypes.end() ) return (*i).second; if ( throw_exc ) { - throw runtime_error("detectors("+type+"): Detectors of this type do not exist in the current setup!"); + throw std::runtime_error("detectors("+type+"): Detectors of this type do not exist in the current setup!"); } // return empty vector instead of exception return m_detectorTypes.at("") ; } - throw runtime_error("detectors("+type+"): Detectors can only selected by type once the geometry is closed!"); + throw std::runtime_error("detectors("+type+"): Detectors can only selected by type once the geometry is closed!"); } -vector<DetElement> DetectorImp::detectors(unsigned int includeFlag, unsigned int excludeFlag ) const { +std::vector<DetElement> DetectorImp::detectors(unsigned int includeFlag, unsigned int excludeFlag ) const { if( ! m_manager->IsClosed() ) { - throw runtime_error("detectors(typeFlag): Detectors can only selected by typeFlag once the geometry is closed!"); + throw std::runtime_error("detectors(typeFlag): Detectors can only selected by typeFlag once the geometry is closed!"); } - vector<DetElement> dets ; + std::vector<DetElement> dets ; dets.reserve( m_detectors.size() ) ; for(HandleMap::const_iterator i=m_detectors.begin(); i!=m_detectors.end(); ++i) { @@ -608,13 +593,13 @@ vector<DetElement> DetectorImp::detectors(unsigned int includeFlag, unsigned int } /// Access a set of subdetectors according to several sensitive types. -vector<DetElement> DetectorImp::detectors(const string& type1, - const string& type2, - const string& type3, - const string& type4, - const string& type5 ) { +std::vector<DetElement> DetectorImp::detectors(const std::string& type1, + const std::string& type2, + const std::string& type3, + const std::string& type4, + const std::string& type5 ) { if ( m_manager->IsClosed() ) { - vector<DetElement> v; + std::vector<DetElement> v; DetectorTypeMap::const_iterator i, end=m_detectorTypes.end(); if ( !type1.empty() && (i=m_detectorTypes.find(type1)) != end ) v.insert(v.end(),(*i).second.begin(),(*i).second.end()); @@ -628,10 +613,10 @@ vector<DetElement> DetectorImp::detectors(const string& type1, v.insert(v.end(),(*i).second.begin(),(*i).second.end()); return v; } - throw runtime_error("detectors("+type1+","+type2+",...): Detectors can only selected by type once the geometry is closed!"); + throw std::runtime_error("detectors("+type1+","+type2+",...): Detectors can only selected by type once the geometry is closed!"); } -Handle<NamedObject> DetectorImp::getRefChild(const HandleMap& e, const string& name, bool do_throw) const { +Handle<NamedObject> DetectorImp::getRefChild(const HandleMap& e, const std::string& name, bool do_throw) const { HandleMap::const_iterator it = e.find(name); if (it != e.end()) { return it->second; @@ -658,7 +643,7 @@ Handle<NamedObject> DetectorImp::getRefChild(const HandleMap& e, const string& n err << it->first; } err << "}"; - throw runtime_error(err.str()); + throw std::runtime_error(err.str()); } return 0; } @@ -673,7 +658,7 @@ namespace { void patchShapes() { auto& data = *m_data; char text[32]; - string nam; + std::string nam; printout(INFO,"Detector","+++ Patching names of anonymous shapes...."); for (auto i = data.rbegin(); i != data.rend(); ++i) { for( const TGeoNode* n : (*i).second ) { @@ -693,7 +678,7 @@ namespace { } else { nam = sn; - if (nam.find("_shape") == string::npos) + if (nam.find("_shape") == std::string::npos) nam += text; s->SetName(nam.c_str()); } @@ -726,7 +711,7 @@ namespace { /// Finalize/close the geometry void DetectorImp::endDocument(bool close_geometry) { TGeoManager* mgr = m_manager; - lock_guard<recursive_mutex> lock(s_detector_apply_lock); + std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock); if ( close_geometry && !mgr->IsClosed() ) { #if 0 Region trackingRegion("TrackingRegion"); @@ -758,7 +743,7 @@ void DetectorImp::endDocument(bool close_geometry) { void DetectorImp::init() { if (!m_world.isValid()) { TGeoManager* mgr = m_manager; - lock_guard<recursive_mutex> lock(s_detector_apply_lock); + std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock); Constant air_const = getRefChild(m_define, "Air", false); Constant vac_const = getRefChild(m_define, "Vacuum", false); Box worldSolid; @@ -817,16 +802,16 @@ void DetectorImp::init() { } /// Read any geometry description or alignment file -void DetectorImp::fromXML(const string& xmlfile, DetectorBuildType build_type) { +void DetectorImp::fromXML(const std::string& xmlfile, DetectorBuildType build_type) { TypePreserve build_type_preserve(m_buildType = build_type); - lock_guard<recursive_mutex> lock(s_detector_apply_lock); + std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock); processXML(xmlfile,0); } /// Read any geometry description or alignment file with external XML entity resolution -void DetectorImp::fromXML(const string& fname, xml::UriReader* entity_resolver, DetectorBuildType build_type) { +void DetectorImp::fromXML(const std::string& fname, xml::UriReader* entity_resolver, DetectorBuildType build_type) { TypePreserve build_type_preserve(m_buildType = build_type); - lock_guard<recursive_mutex> lock(s_detector_apply_lock); + std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock); processXML(fname,entity_resolver); } @@ -839,8 +824,8 @@ void DetectorImp::dump() const { /// Manipulate geometry using facroy converter long DetectorImp::apply(const char* factory_type, int argc, char** argv) const { - lock_guard<recursive_mutex> lock(s_detector_apply_lock); - string fac = factory_type; + std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock); + std::string fac = factory_type; try { Detector* thisPtr = const_cast<DetectorImp*>(this); long result = PluginService::Create<long>(fac, thisPtr, argc, argv); @@ -848,24 +833,24 @@ long DetectorImp::apply(const char* factory_type, int argc, char** argv) const PluginDebug dbg; result = PluginService::Create<long>(fac, thisPtr, argc, argv); if ( 0 == result ) { - throw runtime_error("dd4hep: apply-plugin: Failed to locate plugin " + - fac + ". " + dbg.missingFactory(fac)); + throw std::runtime_error("dd4hep: apply-plugin: Failed to locate plugin " + + fac + ". " + dbg.missingFactory(fac)); } } result = *(long*) result; if (result != 1) { - throw runtime_error("dd4hep: apply-plugin: Failed to execute plugin " + fac); + throw std::runtime_error("dd4hep: apply-plugin: Failed to execute plugin " + fac); } return result; } catch (const xml::XmlException& e) { - throw runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception with plugin:" + fac); + throw std::runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception with plugin:" + fac); } - catch (const exception& e) { - throw runtime_error(string(e.what()) + "\ndd4hep: with plugin:" + fac); + catch (const std::exception& e) { + throw std::runtime_error(std::string(e.what()) + "\ndd4hep: with plugin:" + fac); } catch (...) { - throw runtime_error("UNKNOWN exception from plugin:" + fac); + throw std::runtime_error("UNKNOWN exception from plugin:" + fac); } return EINVAL; } diff --git a/DDCore/src/Handle.cpp b/DDCore/src/Handle.cpp index cbc9b1b7bf1491a6a87c400895aa33a5b5a37f16..c947af98398687f65bb47a92e01f6919f2287586 100644 --- a/DDCore/src/Handle.cpp +++ b/DDCore/src/Handle.cpp @@ -11,10 +11,10 @@ // //========================================================================== -#include "DD4hep/detail/Handle.inl" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Printout.h" -#include "Evaluator/Evaluator.h" +#include <DD4hep/detail/Handle.inl> +#include <DD4hep/InstanceCount.h> +#include <DD4hep/Printout.h> +#include <Evaluator/Evaluator.h> /// C/C++ include files #include <iostream> @@ -35,7 +35,6 @@ namespace { const dd4hep::tools::Evaluator& eval(dd4hep::evaluator()); } -using namespace std; using namespace dd4hep; using namespace dd4hep::detail; @@ -45,9 +44,9 @@ namespace { static bool s_allow_variable_redefine = true; /// - void check_evaluation(const string& value, std::pair<int,double> res, stringstream& err) { + void check_evaluation(const std::string& value, std::pair<int,double> res, std::stringstream& err) { if ( res.first != tools::Evaluator::OK) { - throw runtime_error("dd4hep: "+err.str()+" : value="+value+" [Evaluation error]"); + throw std::runtime_error("dd4hep: "+err.str()+" : value="+value+" [Evaluation error]"); } } } @@ -61,121 +60,121 @@ namespace dd4hep { return tmp; } - std::pair<int, double> _toFloatingPoint(const string& value) { - stringstream err; + std::pair<int, double> _toFloatingPoint(const std::string& value) { + std::stringstream err; auto result = eval.evaluate(value, err); check_evaluation(value, result, err); return result; } - std::pair<int, double> _toInteger(const string& value) { - string s(value); + std::pair<int, double> _toInteger(const std::string& value) { + std::string s(value); size_t idx = s.find("(int)"); - if (idx != string::npos) + if (idx != std::string::npos) s.erase(idx, 5); idx = s.find("(long)"); - if (idx != string::npos) + if (idx != std::string::npos) s.erase(idx, 6); while (s[0] == ' ') s.erase(0, 1); return _toFloatingPoint(s); } - short _toShort(const string& value) { + short _toShort(const std::string& value) { return (short) _toInteger(value).second; } - unsigned short _toUShort(const string& value) { + unsigned short _toUShort(const std::string& value) { return (unsigned short) _toInteger(value).second; } - int _toInt(const string& value) { + int _toInt(const std::string& value) { return (int) _toInteger(value).second; } - unsigned int _toUInt(const string& value) { + unsigned int _toUInt(const std::string& value) { return (unsigned int) _toInteger(value).second; } - long _toLong(const string& value) { + long _toLong(const std::string& value) { return (long) _toInteger(value).second; } - unsigned long _toULong(const string& value) { + unsigned long _toULong(const std::string& value) { return (unsigned long) _toInteger(value).second; } - bool _toBool(const string& value) { + bool _toBool(const std::string& value) { return value == "true" || value == "yes" || value == "True"; } /// String conversions: string to float value - float _toFloat(const string& value) { + float _toFloat(const std::string& value) { return (float) _toFloatingPoint(value).second; } /// String conversions: string to double value - double _toDouble(const string& value) { + double _toDouble(const std::string& value) { return _toFloatingPoint(value).second; } /// Generic type conversion from string to primitive value \ingroup DD4HEP_CORE - template <typename T> T _toType(const string& value) { + template <typename T> T _toType(const std::string& value) { notImplemented("Value "+value+" cannot be converted to type "+typeName(typeid(T))); return T(); } /// Generic type conversion from string to primitive value - template <> bool _toType<bool>(const string& value) { + template <> bool _toType<bool>(const std::string& value) { return _toBool(value); } /// Generic type conversion from string to primitive value - template <> short _toType<short>(const string& value) { + template <> short _toType<short>(const std::string& value) { return _toShort(value); } /// Generic type conversion from string to primitive value - template <> unsigned short _toType<unsigned short>(const string& value) { + template <> unsigned short _toType<unsigned short>(const std::string& value) { return (unsigned short)_toShort(value); } /// Generic type conversion from string to primitive value - template <> int _toType<int>(const string& value) { + template <> int _toType<int>(const std::string& value) { return _toInt(value); } /// Generic type conversion from string to primitive value - template <> unsigned int _toType<unsigned int>(const string& value) { + template <> unsigned int _toType<unsigned int>(const std::string& value) { return (unsigned int)_toInt(value); } /// Generic type conversion from string to primitive value - template <> long _toType<long>(const string& value) { + template <> long _toType<long>(const std::string& value) { return _toLong(value); } /// Generic type conversion from string to primitive value - template <> unsigned long _toType<unsigned long>(const string& value) { + template <> unsigned long _toType<unsigned long>(const std::string& value) { return (unsigned long)_toLong(value); } /// Generic type conversion from string to primitive value - template <> float _toType<float>(const string& value) { + template <> float _toType<float>(const std::string& value) { return _toFloat(value); } /// Generic type conversion from string to primitive value - template <> double _toType<double>(const string& value) { + template <> double _toType<double>(const std::string& value) { return _toDouble(value); } /// Generic type conversion from string to primitive value - template <> string _toType<string>(const string& value) { + template <> std::string _toType<std::string>(const std::string& value) { return value; } - template <> char _multiply<char>(const string& left, const string& right) { + template <> char _multiply<char>(const std::string& left, const std::string& right) { double val = _toDouble(left + "*" + right); if ( val >= double(SCHAR_MIN) && val <= double(SCHAR_MAX) ) return (char) (int)val; @@ -185,7 +184,7 @@ namespace dd4hep { return 0; } - template <> unsigned char _multiply<unsigned char>(const string& left, const string& right) { + template <> unsigned char _multiply<unsigned char>(const std::string& left, const std::string& right) { double val = _toDouble(left + "*" + right); if ( val >= 0 && val <= double(UCHAR_MAX) ) return (unsigned char) (int)val; @@ -195,7 +194,7 @@ namespace dd4hep { return 0; } - template <> short _multiply<short>(const string& left, const string& right) { + template <> short _multiply<short>(const std::string& left, const std::string& right) { double val = _toDouble(left + "*" + right); if ( val >= double(SHRT_MIN) && val <= double(SHRT_MAX) ) return (short) val; @@ -205,7 +204,7 @@ namespace dd4hep { return 0; } - template <> unsigned short _multiply<unsigned short>(const string& left, const string& right) { + template <> unsigned short _multiply<unsigned short>(const std::string& left, const std::string& right) { double val = _toDouble(left + "*" + right); if ( val >= 0 && val <= double(USHRT_MAX) ) return (unsigned short)val; @@ -215,49 +214,49 @@ namespace dd4hep { return 0; } - template <> int _multiply<int>(const string& left, const string& right) { + template <> int _multiply<int>(const std::string& left, const std::string& right) { return (int) _toDouble(left + "*" + right); } - template <> unsigned int _multiply<unsigned int>(const string& left, const string& right) { + template <> unsigned int _multiply<unsigned int>(const std::string& left, const std::string& right) { return (unsigned int) _toDouble(left + "*" + right); } - template <> long _multiply<long>(const string& left, const string& right) { + template <> long _multiply<long>(const std::string& left, const std::string& right) { return (long) _toDouble(left + "*" + right); } - template <> unsigned long _multiply<unsigned long>(const string& left, const string& right) { + template <> unsigned long _multiply<unsigned long>(const std::string& left, const std::string& right) { return (unsigned long) _toDouble(left + "*" + right); } - template <> float _multiply<float>(const string& left, const string& right) { + template <> float _multiply<float>(const std::string& left, const std::string& right) { return _toFloat(left + "*" + right); } - template <> double _multiply<double>(const string& left, const string& right) { + template <> double _multiply<double>(const std::string& left, const std::string& right) { return _toDouble(left + "*" + right); } - void _toDictionary(const string& name, const string& value) { + void _toDictionary(const std::string& name, const std::string& value) { _toDictionary(name, value, "number"); } /// Enter name value pair to the dictionary. \ingroup DD4HEP_CORE - void _toDictionary(const string& name, const string& value, const string& typ) { + void _toDictionary(const std::string& name, const std::string& value, const std::string& typ) { if ( typ == "string" ) { eval.setEnviron(name.c_str(),value.c_str()); return; } else { int status; - stringstream err; - string n = name, v = value; + std::stringstream err; + std::string n = name, v = value; size_t idx = v.find("(int)"); - if (idx != string::npos) + if (idx != std::string::npos) v.erase(idx, 5); idx = v.find("(float)"); - if (idx != string::npos) + if (idx != std::string::npos) v.erase(idx, 7); while (v[0] == ' ') v.erase(0, 1); @@ -266,48 +265,47 @@ namespace dd4hep { err.str(""); status = eval.setVariable(n, result.second, err); if ( status != tools::Evaluator::OK ) { - stringstream err_msg; - err_msg << "name=" << name << " value=" << value - << " " << err.str() << " [setVariable error]"; - if ( status == tools::Evaluator::WARNING_EXISTING_VARIABLE ) { - if ( s_allow_variable_redefine ) - printout(WARNING,"Evaluator","+++ Overwriting variable: "+err_msg.str()); - else - except("Evaluator","+++ Overwriting variable: "+err_msg.str()); - } + std::stringstream err_msg; + err_msg << "name=" << name << " value=" << value + << " " << err.str() << " [setVariable error]"; + if ( status == tools::Evaluator::WARNING_EXISTING_VARIABLE ) { + if ( s_allow_variable_redefine ) + printout(WARNING,"Evaluator","+++ Overwriting variable: "+err_msg.str()); + else + except("Evaluator","+++ Overwriting variable: "+err_msg.str()); + } } } } /// Evaluate string constant using environment stored in the evaluator - string _getEnviron(const string& env) { - // We are trying to deal with the case when several variables are being replaced in the - // string. + std::string _getEnviron(const std::string& env) { + // We are trying to deal with the case when several variables are being replaced in the string. size_t current_index = 0; - stringstream processed_variable; + std::stringstream processed_variable; while (true) { // Looking for the start of a variable use, with the syntax // "path1/path2/${VAR1}/path3/${VAR2}" size_t id1 = env.find("${", current_index); // variable start found, do a greedy search for the variable end - if (id1 == string::npos) { - // In this case we did not find the ${ to indicate a start of variable, + if (id1 == std::string::npos) { + // In this case we did not find the ${ to indicate a start of variable, // we just copy the rest of the variable to the stringstream and exit processed_variable << env.substr(current_index); break; } size_t id2 = env.find("}", id1); - if (id2 == string::npos) { - runtime_error("dd4hep: Syntax error, bad variable syntax: " + env); + if (id2 == std::string::npos) { + std::runtime_error("dd4hep: Syntax error, bad variable syntax: " + env); } processed_variable << env.substr(current_index, id1 -current_index ); - string v = env.substr(id1, id2-id1+1); - stringstream err; + std::string v = env.substr(id1, id2-id1+1); + std::stringstream err; auto ret = eval.getEnviron(v, err); // Checking that the variable lookup worked if ( ret.first != tools::Evaluator::OK) { - cerr << v << ": " << err.str() << endl; - throw runtime_error("dd4hep: Severe error during environment lookup of " + v + " " + err.str()); + std::cerr << v << ": " << err.str() << std::endl; + throw std::runtime_error("dd4hep: Severe error during environment lookup of " + v + " " + err.str()); } // Now adding the variable processed_variable << ret.second; @@ -317,8 +315,8 @@ namespace dd4hep { } /// String manipulations: Remove unconditionally all white spaces - string remove_whitespace(const string& v) { - string value; + std::string remove_whitespace(const std::string& v) { + std::string value; value.reserve(v.length()+1); for(const char* p = v.c_str(); *p; ++p) { if ( !::isspace(*p) ) value += *p; @@ -326,37 +324,37 @@ namespace dd4hep { return value; } - template <typename T> static inline string __to_string(T value, const char* fmt) { + template <typename T> static inline std::string __to_string(T value, const char* fmt) { char text[128]; ::snprintf(text, sizeof(text), fmt, value); return text; } - string _toString(bool value) { + std::string _toString(bool value) { return value ? "true" : "false"; } - string _toString(short value, const char* fmt) { + std::string _toString(short value, const char* fmt) { return __to_string((int)value, fmt); } - string _toString(int value, const char* fmt) { + std::string _toString(int value, const char* fmt) { return __to_string(value, fmt); } - string _toString(unsigned long value, const char* fmt) { + std::string _toString(unsigned long value, const char* fmt) { return __to_string(value, fmt); } - string _toString(float value, const char* fmt) { + std::string _toString(float value, const char* fmt) { return __to_string(value, fmt); } - string _toString(double value, const char* fmt) { + std::string _toString(double value, const char* fmt) { return __to_string(value, fmt); } - string _ptrToString(const void* value, const char* fmt) { + std::string _ptrToString(const void* value, const char* fmt) { return __to_string(value, fmt); } @@ -371,19 +369,19 @@ namespace dd4hep { } void warning_deprecated_xml_factory(const char* name) { const char* edge = "++++++++++++++++++++++++++++++++++++++++++"; - size_t len = ::strlen(name); - cerr << edge << edge << edge << endl; - cerr << "++ The usage of the factory: \"" << name << "\" is DEPRECATED due to naming conventions." - << setw(53-len) << right << "++" << endl; - cerr << "++ Please use \"DD4hep_" << name << "\" instead." << setw(93-len) << right << "++" << endl; - cerr << edge << edge << edge << endl; + size_t len = std::strlen(name); + std::cerr << edge << edge << edge << std::endl; + std::cerr << "++ The usage of the factory: \"" << name << "\" is DEPRECATED due to naming conventions." + << std::setw(53-len) << std::right << "++" << std::endl; + std::cerr << "++ Please use \"DD4hep_" << name << "\" instead." << std::setw(93-len) << std::right << "++" << std::endl; + std::cerr << edge << edge << edge << std::endl; } } #include "DDSegmentation/Segmentation.h" typedef DDSegmentation::Segmentation _Segmentation; namespace dd4hep { - template <> void Handle<_Segmentation>::assign(_Segmentation* s, const string& n, const string&) { + template <> void Handle<_Segmentation>::assign(_Segmentation* s, const std::string& n, const std::string&) { this->m_element = s; s->setName(n); } @@ -393,9 +391,9 @@ namespace dd4hep { template class dd4hep::Handle<_Segmentation>; } -#include "DD4hep/Detector.h" -#include "TMap.h" -#include "TColor.h" +#include <DD4hep/Detector.h> +#include <TMap.h> +#include <TColor.h> template class dd4hep::Handle<NamedObject>; DD4HEP_SAFE_CAST_IMPLEMENTATION(NamedObject,NamedObject) @@ -404,14 +402,14 @@ DD4HEP_INSTANTIATE_HANDLE_UNNAMED(Detector); DD4HEP_INSTANTIATE_HANDLE_CODE(RAW,TObject,NamedObject); DD4HEP_INSTANTIATE_HANDLE_CODE(NONE,TNamed,TObject,NamedObject); -#include "TGeoMedium.h" -#include "TGeoMaterial.h" -#include "TGeoElement.h" +#include <TGeoMedium.h> +#include <TGeoMaterial.h> +#include <TGeoElement.h> DD4HEP_INSTANTIATE_HANDLE(TGeoElement); DD4HEP_INSTANTIATE_HANDLE(TGeoMaterial); DD4HEP_INSTANTIATE_HANDLE(TGeoMedium); -#include "TGeoMatrix.h" +#include <TGeoMatrix.h> DD4HEP_INSTANTIATE_HANDLE(TGeoMatrix); DD4HEP_INSTANTIATE_HANDLE(TGeoRotation); DD4HEP_INSTANTIATE_HANDLE(TGeoTranslation); @@ -419,7 +417,7 @@ DD4HEP_INSTANTIATE_HANDLE(TGeoIdentity); DD4HEP_INSTANTIATE_HANDLE(TGeoCombiTrans); DD4HEP_INSTANTIATE_HANDLE(TGeoGenTrans); -#include "TGeoNode.h" +#include <TGeoNode.h> DD4HEP_INSTANTIATE_HANDLE_CODE(RAW,TGeoAtt); DD4HEP_INSTANTIATE_HANDLE_CODE(RAW,TAtt3D); DD4HEP_INSTANTIATE_HANDLE_CODE(RAW,TAttLine); @@ -428,23 +426,24 @@ DD4HEP_INSTANTIATE_HANDLE(TGeoNodeMatrix); DD4HEP_INSTANTIATE_HANDLE(TGeoNodeOffset); // Shapes (needed by "Shapes.cpp") -#include "TGeoBBox.h" -#include "TGeoPcon.h" -#include "TGeoPgon.h" -#include "TGeoTube.h" -#include "TGeoCone.h" -#include "TGeoArb8.h" -#include "TGeoTrd1.h" -#include "TGeoTrd2.h" -#include "TGeoParaboloid.h" -#include "TGeoSphere.h" -#include "TGeoTorus.h" -#include "TGeoBoolNode.h" -#include "TGeoVolume.h" -#include "TGeoScaledShape.h" -#include "TGeoCompositeShape.h" -#include "TGeoShapeAssembly.h" -#include "DD4hep/detail/ShapesInterna.h" +#include <TGeoBBox.h> +#include <TGeoPcon.h> +#include <TGeoPgon.h> +#include <TGeoTube.h> +#include <TGeoCone.h> +#include <TGeoArb8.h> +#include <TGeoTrd1.h> +#include <TGeoTrd2.h> +#include <TGeoParaboloid.h> +#include <TGeoSphere.h> +#include <TGeoTorus.h> +#include <TGeoTessellated.h> +#include <TGeoBoolNode.h> +#include <TGeoVolume.h> +#include <TGeoScaledShape.h> +#include <TGeoCompositeShape.h> +#include <TGeoShapeAssembly.h> +#include <DD4hep/detail/ShapesInterna.h> DD4HEP_INSTANTIATE_HANDLE(TGeoVolumeAssembly,TGeoVolume,TGeoAtt); DD4HEP_INSTANTIATE_HANDLE(TGeoVolumeMulti,TGeoVolume,TGeoAtt); DD4HEP_INSTANTIATE_HANDLE(TGeoVolume,TGeoAtt,TAttLine,TAtt3D); @@ -475,27 +474,23 @@ DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoTrd1); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoTrd2); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoSphere); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoTorus); - -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) -#include "TGeoTessellated.h" DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoTessellated); -#endif DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoHalfSpace); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoShapeAssembly); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoCompositeShape); // Volume Placements (needed by "Volumes.cpp") -#include "TGeoPhysicalNode.h" +#include <TGeoPhysicalNode.h> DD4HEP_INSTANTIATE_HANDLE(TGeoPhysicalNode); -#include "TGeoBoolNode.h" +#include <TGeoBoolNode.h> DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoUnion); DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoIntersection); DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoSubtraction); // Replicated Volumes (needed by "Volumes.cpp") -#include "TGeoPatternFinder.h" +#include <TGeoPatternFinder.h> DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoPatternFinder); DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoPatternX); DD4HEP_INSTANTIATE_HANDLE_UNNAMED(TGeoPatternY); diff --git a/DDCore/src/Objects.cpp b/DDCore/src/Objects.cpp index 181f07ca7b087ad652b6e45f0d221cea9acf383e..d8fd13246404815b9e1545e9192a34ba1086be55 100644 --- a/DDCore/src/Objects.cpp +++ b/DDCore/src/Objects.cpp @@ -12,26 +12,25 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/IDDescriptor.h" -#include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/ObjectsInterna.h" - -#include "TMap.h" -#include "TROOT.h" -#include "TColor.h" -#include "TGeoMatrix.h" -#include "TGeoManager.h" -#include "TGeoElement.h" -#include "TGeoMaterial.h" +#include <DD4hep/Detector.h> +#include <DD4hep/Printout.h> +#include <DD4hep/IDDescriptor.h> +#include <DD4hep/InstanceCount.h> +#include <DD4hep/detail/ObjectsInterna.h> + +#include <TMap.h> +#include <TROOT.h> +#include <TColor.h> +#include <TGeoMatrix.h> +#include <TGeoManager.h> +#include <TGeoElement.h> +#include <TGeoMaterial.h> // C/C++ include files #include <cmath> #include <sstream> #include <iomanip> -using namespace std; using namespace dd4hep; /// Constructor to be used when creating a new DOM tree @@ -40,122 +39,122 @@ Author::Author(Detector& /* description */) { } /// Access the auhor's name -string Author::authorName() const { +std::string Author::authorName() const { return m_element->GetName(); } /// Set the author's name -void Author::setAuthorName(const string& nam) { +void Author::setAuthorName(const std::string& nam) { m_element->SetName(nam.c_str()); } /// Access the auhor's email address -string Author::authorEmail() const { +std::string Author::authorEmail() const { return m_element->GetTitle(); } /// Set the author's email address -void Author::setAuthorEmail(const string& addr) { +void Author::setAuthorEmail(const std::string& addr) { m_element->SetTitle(addr.c_str()); } /// Constructor to be used when creating a new DOM tree -Header::Header(const string& author_name, const string& descr_url) { +Header::Header(const std::string& author_name, const std::string& descr_url) { Object* obj_ptr = new Object(); assign(obj_ptr, author_name, descr_url); } /// Accessor to object name -const string Header::name() const { +const std::string Header::name() const { return m_element->GetName(); } /// Accessor: set object name -void Header::setName(const string& new_name) { +void Header::setName(const std::string& new_name) { m_element->SetName(new_name.c_str()); } /// Accessor to object title -const string Header::title() const { +const std::string Header::title() const { return m_element->GetTitle(); } /// Accessor: set object title -void Header::setTitle(const string& new_title) { +void Header::setTitle(const std::string& new_title) { m_element->SetTitle(new_title.c_str()); } /// Accessor to object url -const string& Header::url() const { +const std::string& Header::url() const { return data<Object>()->url; } /// Accessor: set object url -void Header::setUrl(const string& new_url) { +void Header::setUrl(const std::string& new_url) { data<Object>()->url = new_url; } /// Accessor to object author -const string& Header::author() const { +const std::string& Header::author() const { return data<Object>()->author; } /// Accessor: set object author -void Header::setAuthor(const string& new_author) { +void Header::setAuthor(const std::string& new_author) { data<Object>()->author = new_author; } /// Accessor to object status -const string& Header::status() const { +const std::string& Header::status() const { return data<Object>()->status; } /// Accessor: set object status -void Header::setStatus(const string& new_status) { +void Header::setStatus(const std::string& new_status) { data<Object>()->status = new_status; } /// Accessor to object version -const string& Header::version() const { +const std::string& Header::version() const { return data<Object>()->version; } /// Accessor: set object version -void Header::setVersion(const string& new_version) { +void Header::setVersion(const std::string& new_version) { data<Object>()->version = new_version; } /// Accessor to object comment -const string& Header::comment() const { +const std::string& Header::comment() const { return data<Object>()->comment; } /// Accessor: set object comment -void Header::setComment(const string& new_comment) { +void Header::setComment(const std::string& new_comment) { data<Object>()->comment = new_comment; } /// Constructor to be used when creating a new DOM tree -Constant::Constant(const string& nam, const string& val, const string& typ) { +Constant::Constant(const std::string& nam, const std::string& val, const std::string& typ) { m_element = new Object(nam, val, typ); } /// Constructor to be used when creating a new DOM tree -Constant::Constant(const string& nam) { +Constant::Constant(const std::string& nam) { m_element = new Object(nam.c_str(), "", "number"); } /// Access the constant -string Constant::dataType() const { +std::string Constant::dataType() const { if ( isValid() ) { return m_element->dataType; } - throw runtime_error("dd4hep: Attempt to access internals from invalid Constant handle!"); + throw std::runtime_error("dd4hep: Attempt to access internals from invalid Constant handle!"); } /// String representation of this object -string Constant::toString() const { - stringstream os; +std::string Constant::toString() const { + std::stringstream os; os << m_element->GetName() << " \"" << m_element->GetTitle() << "\" "; if ( m_element->dataType == "string" ) os << "Value:" << m_element->GetTitle(); else os << "Value:" << _toDouble(m_element->GetTitle()); @@ -163,7 +162,7 @@ string Constant::toString() const { } /// Constructor to be used when creating a new DOM tree -Atom::Atom(const string& nam, const string& formula, int Z, int N, double density) { +Atom::Atom(const std::string& nam, const std::string& formula, int Z, int N, double density) { TGeoElementTable* t = TGeoElement::GetElementTable(); TGeoElement* e = t->FindElement(nam.c_str()); if (!e) { @@ -180,9 +179,9 @@ double Material::Z() const { TGeoMaterial* mat = val->GetMaterial(); if ( mat ) return mat->GetZ(); - throw runtime_error("dd4hep: The medium " + string(val->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("dd4hep: The medium " + std::string(val->GetName()) + " has an invalid material reference!"); } - throw runtime_error("dd4hep: Attempt to access proton number from invalid material handle!"); + throw std::runtime_error("dd4hep: Attempt to access proton number from invalid material handle!"); } /// atomic number of the underlying material @@ -191,9 +190,9 @@ double Material::A() const { TGeoMaterial* mat = ptr()->GetMaterial(); if ( mat ) return mat->GetA(); - throw runtime_error("dd4hep: The medium " + string(ptr()->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("dd4hep: The medium " + std::string(ptr()->GetName()) + " has an invalid material reference!"); } - throw runtime_error("dd4hep: Attempt to access atomic number from invalid material handle!"); + throw std::runtime_error("dd4hep: Attempt to access atomic number from invalid material handle!"); } /// density of the underlying material @@ -202,9 +201,9 @@ double Material::density() const { TGeoMaterial* mat = ptr()->GetMaterial(); if ( mat ) return mat->GetDensity(); - throw runtime_error("dd4hep: The medium " + string(ptr()->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("dd4hep: The medium " + std::string(ptr()->GetName()) + " has an invalid material reference!"); } - throw runtime_error("dd4hep: Attempt to access density from invalid material handle!"); + throw std::runtime_error("dd4hep: Attempt to access density from invalid material handle!"); } /// Access the radiation length of the underlying material @@ -213,9 +212,9 @@ double Material::radLength() const { TGeoMaterial* mat = ptr()->GetMaterial(); if ( mat ) return mat->GetRadLen(); - throw runtime_error("dd4hep: The medium " + string(ptr()->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("dd4hep: The medium " + std::string(ptr()->GetName()) + " has an invalid material reference!"); } - throw runtime_error("dd4hep: Attempt to access radiation length from invalid material handle!"); + throw std::runtime_error("dd4hep: Attempt to access radiation length from invalid material handle!"); } /// Access the radiation length of the underlying material @@ -224,9 +223,9 @@ double Material::intLength() const { TGeoMaterial* mat = ptr()->GetMaterial(); if ( mat ) return mat->GetIntLen(); - throw runtime_error("The medium " + string(ptr()->GetName()) + " has an invalid material reference!"); + throw std::runtime_error("The medium " + std::string(ptr()->GetName()) + " has an invalid material reference!"); } - throw runtime_error("Attempt to access interaction length from invalid material handle!"); + throw std::runtime_error("Attempt to access interaction length from invalid material handle!"); } /// Access the fraction of an element within the material @@ -256,7 +255,6 @@ double Material::fraction(Atom atom) const { return tot>1e-20 ? frac/tot : 0.0; } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Access to tabular properties of the optical surface Material::Property Material::property(const char* nam) const { return access()->GetMaterial()->GetProperty(nam); @@ -281,7 +279,7 @@ double Material::constProperty(const std::string& nam) const { auto* o = access()->GetMaterial(); double value = o->GetConstProperty(nam.c_str(), &err); if ( err != kTRUE ) return value; - throw runtime_error("Attempt to access non existing material const property: "+nam); + throw std::runtime_error("Attempt to access non existing material const property: "+nam); } /// Access string property value from the material table @@ -291,23 +289,22 @@ std::string Material::constPropertyRef(const std::string& name, const std::strin if ( p ) return p; return default_value; } -#endif /// String representation of this object -string Material::toString() const { +std::string Material::toString() const { if ( isValid() ) { TGeoMedium* val = ptr(); - stringstream out; + std::stringstream out; out << val->GetName() << " " << val->GetTitle() - << " id:" << hex << val->GetId() + << " id:" << std::hex << val->GetId() << " Pointer:" << val->GetPointerName(); return out.str(); } - throw runtime_error("Attempt to convert invalid material handle to string!"); + throw std::runtime_error("Attempt to convert invalid material handle to string!"); } /// Constructor to be used when creating a new entity -VisAttr::VisAttr(const string& nam) { +VisAttr::VisAttr(const std::string& nam) { Object* obj = new Object(); assign(obj, nam, "vis"); obj->color = gROOT->GetColor(kWhite); @@ -390,13 +387,9 @@ void VisAttr::setColor(float alpha, float red, float green, float blue) { except("VisAttr","+++ %s Failed to allocate Color: r:%02X g:%02X b:%02X", this->name(), int(red*255.), int(green*255.), int(blue*255)); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(5,34,25) o.colortr = new TColor(gROOT->GetListOfColors()->GetLast()+1, o.color->GetRed(), o.color->GetGreen(), o.color->GetBlue()); o.colortr->SetAlpha(alpha); -#else - o.colortr = o.color; -#endif } /// Get RGB values of the color (if valid) @@ -421,13 +414,13 @@ bool VisAttr::argb(float& alpha, float& red, float& green, float& blue) const { } /// String representation of this object -string VisAttr::toString() const { +std::string VisAttr::toString() const { const VisAttr::Object* obj = &object<Object>(); TColor* c = obj->color; char text[256]; - ::snprintf(text, sizeof(text), "%-20s RGB:%-8s [%d] %7.2f Style:%d %d ShowDaughters:%3s Visible:%3s", ptr()->GetName(), - c->AsHexString(), c->GetNumber(), c->GetAlpha(), int(obj->drawingStyle), int(obj->lineStyle), - yes_no(obj->showDaughters), yes_no(obj->visible)); + std::snprintf(text, sizeof(text), "%-20s RGB:%-8s [%d] %7.2f Style:%d %d ShowDaughters:%3s Visible:%3s", ptr()->GetName(), + c->AsHexString(), c->GetNumber(), c->GetAlpha(), int(obj->drawingStyle), int(obj->lineStyle), + yes_no(obj->showDaughters), yes_no(obj->visible)); return text; } @@ -448,8 +441,8 @@ bool Limit::operator<(const Limit& c) const { } /// Conversion to a string representation -string Limit::toString() const { - string res = name + " = " + content; +std::string Limit::toString() const { + std::string res = name + " = " + content; if (!unit.empty()) res += unit + " "; res += " (" + particles + ")"; @@ -457,25 +450,25 @@ string Limit::toString() const { } /// Constructor to be used when creating a new DOM tree -LimitSet::LimitSet(const string& nam) { +LimitSet::LimitSet(const std::string& nam) { assign(new Object(), nam, "limitset"); } /// Add new limit. Returns true if the new limit was added, false if it already existed. bool LimitSet::addLimit(const Limit& limit) { - pair<Object::iterator, bool> ret = data<Object>()->limits.insert(limit); + std::pair<Object::iterator, bool> ret = data<Object>()->limits.insert(limit); return ret.second; } /// Accessor to limits container -const set<Limit>& LimitSet::limits() const { +const std::set<Limit>& LimitSet::limits() const { const Object* o = data<Object>(); return o->limits; } /// Add new limit. Returns true if the new limit was added, false if it already existed. bool LimitSet::addCut(const Limit& cut_obj) { - pair<Object::iterator, bool> ret = data<Object>()->cuts.insert(cut_obj); + std::pair<Object::iterator, bool> ret = data<Object>()->cuts.insert(cut_obj); return ret.second; } @@ -485,7 +478,7 @@ const std::set<Limit>& LimitSet::cuts() const { } /// Constructor to be used when creating a new DOM tree -Region::Region(const string& nam) { +Region::Region(const std::string& nam) { Object* p = new Object(); assign(p, nam, "region"); p->magic = magic_word(); @@ -514,7 +507,7 @@ Region& Region::setCut(double value) { } /// Access references to user limits -vector<string>& Region::limits() const { +std::vector<std::string>& Region::limits() const { return object<Object>().user_limits; } @@ -555,28 +548,28 @@ struct IDSpec : public Ref_t { template <typename Q> IDSpec(const Handle<Q>& e) : Ref_t(e) {} /// Constructor to be used when creating a new DOM tree - IDSpec(Detector& doc, const string& name, const IDDescriptor& dsc); - void addField(const string& name, const pair<int,int>& field); + IDSpec(Detector& doc, const std::string& name, const IDDescriptor& dsc); + void addField(const std::string& name, const std::pair<int,int>& field); }; -IDSpec::IDSpec(Detector& description, const string& name, const IDDescriptor& dsc) +IDSpec::IDSpec(Detector& description, const std::string& name, const IDDescriptor& dsc) : RefElement(doc,Tag_idspec,name) { const IDDescriptor::FieldIDs& f = dsc.ids(); const IDDescriptor::FieldMap& m = dsc.fields(); object<Object>().Attr_length = dsc.maxBit(); for(const auto& i : f ) { - const string& nam = i.second; + const std::string& nam = i.second; const pair<int,int>& fld = m.find(nam)->second; addField(nam,fld); } } -void IDSpec::addField(const string& name, const pair<int,int>& field) { +void IDSpec::addField(const std::string& name, const pair<int,int>& field) { addField(Strng_t(name),field); } -void IDSpec::addField(const string& name, const pair<int,int>& field) { +void IDSpec::addField(const std::string& name, const pair<int,int>& field) { Element e(document(),Tag_idfield); e.object<Object>().Attr_signed = field.second<0; e.object<Object>().Attr_label = name; diff --git a/DDCore/src/OpticalSurfaceManager.cpp b/DDCore/src/OpticalSurfaceManager.cpp index d991f4e977fb1b085f85405b023805a16b34510a..41c996f28168d11ec4002df1dd68f00c7af2ac65 100644 --- a/DDCore/src/OpticalSurfaceManager.cpp +++ b/DDCore/src/OpticalSurfaceManager.cpp @@ -12,17 +12,16 @@ //========================================================================== // Framework include files -#include "DD4hep/OpticalSurfaceManager.h" -#include "DD4hep/detail/OpticalSurfaceManagerInterna.h" -#include "DD4hep/ExtensionEntry.h" -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" +#include <DD4hep/OpticalSurfaceManager.h> +#include <DD4hep/detail/OpticalSurfaceManagerInterna.h> +#include <DD4hep/ExtensionEntry.h> +#include <DD4hep/Detector.h> +#include <DD4hep/Printout.h> // C/C++ includes #include <sstream> #include <iomanip> -using namespace std; using namespace dd4hep; /// static accessor calling DD4hepOpticalSurfaceManagerPlugin if necessary @@ -30,13 +29,11 @@ OpticalSurfaceManager OpticalSurfaceManager::getOpticalSurfaceManager(Detector& return description.surfaceManager(); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) - /// Access skin surface by its identifier -SkinSurface OpticalSurfaceManager::skinSurface(DetElement de, const string& nam) const { +SkinSurface OpticalSurfaceManager::skinSurface(DetElement de, const std::string& nam) const { if ( de.isValid() ) { Object* o = access(); - string n = de.path() + '#' + nam; + std::string n = de.path() + '#' + nam; TGeoSkinSurface* surf = o->detector.manager().GetSkinSurface(n.c_str()); if ( surf ) return surf; auto i = o->skinSurfaces.find(Object::LocalKey(de, nam)); @@ -49,15 +46,15 @@ SkinSurface OpticalSurfaceManager::skinSurface(DetElement de, const string& nam } /// Access skin surface by its full name -SkinSurface OpticalSurfaceManager::skinSurface(const string& full_nam) const { +SkinSurface OpticalSurfaceManager::skinSurface(const std::string& full_nam) const { return access()->detector.manager().GetSkinSurface(full_nam.c_str()); } /// Access border surface by its identifier -BorderSurface OpticalSurfaceManager::borderSurface(DetElement de, const string& nam) const { +BorderSurface OpticalSurfaceManager::borderSurface(DetElement de, const std::string& nam) const { if ( de.isValid() ) { Object* o = access(); - string n = de.path() + '#' + nam; + std::string n = de.path() + '#' + nam; TGeoBorderSurface* surf = o->detector.manager().GetBorderSurface(n.c_str()); if ( surf ) return surf; auto i = o->borderSurfaces.find(Object::LocalKey(de, nam)); @@ -70,15 +67,15 @@ BorderSurface OpticalSurfaceManager::borderSurface(DetElement de, const string& } /// Access border surface by its full name -BorderSurface OpticalSurfaceManager::borderSurface(const string& full_nam) const { +BorderSurface OpticalSurfaceManager::borderSurface(const std::string& full_nam) const { return access()->detector.manager().GetBorderSurface(full_nam.c_str()); } /// Access optical surface data by its identifier -OpticalSurface OpticalSurfaceManager::opticalSurface(DetElement de, const string& nam) const { +OpticalSurface OpticalSurfaceManager::opticalSurface(DetElement de, const std::string& nam) const { if ( de.isValid() ) { Object* o = access(); - string n = de.path() + '#' + nam; + std::string n = de.path() + '#' + nam; TGeoOpticalSurface* surf = o->detector.manager().GetOpticalSurface(n.c_str()); if ( surf ) return surf; auto i = o->opticalSurfaces.find(n); @@ -91,13 +88,13 @@ OpticalSurface OpticalSurfaceManager::opticalSurface(DetElement de, const string } /// Access optical surface data by its identifier -OpticalSurface OpticalSurfaceManager::opticalSurface(const string& full_nam) const { +OpticalSurface OpticalSurfaceManager::opticalSurface(const std::string& full_nam) const { return access()->detector.manager().GetOpticalSurface(full_nam.c_str()); } /// Add skin surface to manager void OpticalSurfaceManager::addSkinSurface(DetElement de, SkinSurface surf) const { - if ( access()->skinSurfaces.emplace(make_pair(de,surf->GetName()), surf).second ) + if ( access()->skinSurfaces.emplace(std::make_pair(de,surf->GetName()), surf).second ) return; except("OpticalSurfaceManager","++ Skin surface %s already present for DE:%s.", surf->GetName(), de.name()); @@ -105,7 +102,7 @@ void OpticalSurfaceManager::addSkinSurface(DetElement de, SkinSurface surf) con /// Add border surface to manager void OpticalSurfaceManager::addBorderSurface(DetElement de, BorderSurface surf) const { - if ( access()->borderSurfaces.emplace(make_pair(de,surf->GetName()), surf).second ) + if ( access()->borderSurfaces.emplace(std::make_pair(de,surf->GetName()), surf).second ) return; except("OpticalSurfaceManager","++ Border surface %s already present for DE:%s.", surf->GetName(), de.name()); @@ -122,7 +119,7 @@ void OpticalSurfaceManager::addOpticalSurface(OpticalSurface surf) const { /// Register the temporary surface objects with the TGeoManager void OpticalSurfaceManager::registerSurfaces(DetElement subdetector) { Object* o = access(); - unique_ptr<Object> extension(new Object(o->detector)); + std::unique_ptr<Object> extension(new Object(o->detector)); for(auto& optical : o->opticalSurfaces) { o->detector.manager().AddOpticalSurface(optical.second.ptr()); extension->opticalSurfaces.insert(optical); @@ -130,7 +127,7 @@ void OpticalSurfaceManager::registerSurfaces(DetElement subdetector) { o->opticalSurfaces.clear(); for(auto& skin : o->skinSurfaces) { - string n = skin.first.first.path() + '#' + skin.first.second; + std::string n = skin.first.first.path() + '#' + skin.first.second; skin.second->SetName(n.c_str()); o->detector.manager().AddSkinSurface(skin.second.ptr()); extension->skinSurfaces.insert(skin); @@ -138,7 +135,7 @@ void OpticalSurfaceManager::registerSurfaces(DetElement subdetector) { o->skinSurfaces.clear(); for(auto& border : o->borderSurfaces) { - string n = border.first.first.path() + '#' + border.first.second; + std::string n = border.first.first.path() + '#' + border.first.second; border.second->SetName(n.c_str()); o->detector.manager().AddBorderSurface(border.second.ptr()); extension->borderSurfaces.insert(border); @@ -152,4 +149,4 @@ void OpticalSurfaceManager::registerSurfaces(DetElement subdetector) { } subdetector.addExtension(new detail::DeleteExtension<Object,Object>(extension.release())); } -#endif + diff --git a/DDCore/src/OpticalSurfaces.cpp b/DDCore/src/OpticalSurfaces.cpp index 8b423a6925e768a2d434627ebcf95fd966985602..bd3fdad69fac0a95ad99c650f52c31cecfa623a1 100644 --- a/DDCore/src/OpticalSurfaces.cpp +++ b/DDCore/src/OpticalSurfaces.cpp @@ -12,36 +12,33 @@ //========================================================================== // Framework include files -#include "DD4hep/OpticalSurfaces.h" -#include "DD4hep/NamedObject.h" -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" -#include "DD4hep/World.h" +#include <DD4hep/OpticalSurfaces.h> +#include <DD4hep/NamedObject.h> +#include <DD4hep/Detector.h> +#include <DD4hep/Printout.h> +#include <DD4hep/World.h> -#include "DD4hep/detail/Handle.inl" +#include <DD4hep/detail/Handle.inl> // C/C++ includes #include <sstream> #include <iomanip> -using namespace std; using namespace dd4hep; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) - DD4HEP_INSTANTIATE_HANDLE(TGeoSkinSurface); DD4HEP_INSTANTIATE_HANDLE(TGeoBorderSurface); DD4HEP_INSTANTIATE_HANDLE(TGeoOpticalSurface); /// Initializing constructor. OpticalSurface::OpticalSurface(Detector& detector, - const string& full_name, + const std::string& full_name, EModel model, EFinish finish, EType type, double value) { - unique_ptr<Object> obj(new Object(full_name.c_str(), model, finish, type, value)); + std::unique_ptr<Object> obj(new Object(full_name.c_str(), model, finish, type, value)); detector.manager().AddOpticalSurface(m_element=obj.release()); } @@ -56,12 +53,12 @@ OpticalSurface::Property OpticalSurface::property(const std::string& nam) const } /// Initializing constructor: Creates the object and registers it to the manager -SkinSurface::SkinSurface(Detector& detector, DetElement de, const string& nam, OpticalSurface surf, Volume vol) +SkinSurface::SkinSurface(Detector& detector, DetElement de, const std::string& nam, OpticalSurface surf, Volume vol) { if ( de.isValid() ) { if ( vol.isValid() ) { if ( surf.isValid() ) { - unique_ptr<Object> obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), vol.ptr())); + std::unique_ptr<Object> obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), vol.ptr())); detector.surfaceManager().addSkinSurface(de, m_element=obj.release()); return; } @@ -98,7 +95,7 @@ Volume SkinSurface::volume() const { /// Initializing constructor: Creates the object and registers it to the manager BorderSurface::BorderSurface(Detector& detector, DetElement de, - const string& nam, + const std::string& nam, OpticalSurface surf, PlacedVolume lft, PlacedVolume rht) @@ -106,7 +103,7 @@ BorderSurface::BorderSurface(Detector& detector, if ( de.isValid() ) { if ( lft.isValid() && rht.isValid() ) { if ( surf.isValid() ) { - unique_ptr<Object> obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), lft.ptr(), rht.ptr())); + std::unique_ptr<Object> obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), lft.ptr(), rht.ptr())); detector.surfaceManager().addBorderSurface(de, m_element=obj.release()); return; } @@ -144,4 +141,4 @@ PlacedVolume BorderSurface::left() const { PlacedVolume BorderSurface::right() const { return access()->GetNode2(); } -#endif + diff --git a/DDCore/src/PropertyTable.cpp b/DDCore/src/PropertyTable.cpp index b0047e6d5dee8c7f5f343102edf11c0952fe9148..3a1324b5cf012e7a6ae3f0fe630f660003f9a4f3 100644 --- a/DDCore/src/PropertyTable.cpp +++ b/DDCore/src/PropertyTable.cpp @@ -12,33 +12,29 @@ //========================================================================== // Framework include files -#include "DD4hep/PropertyTable.h" -#include "DD4hep/NamedObject.h" -#include "DD4hep/Detector.h" -#include "DD4hep/Printout.h" +#include <DD4hep/PropertyTable.h> +#include <DD4hep/NamedObject.h> +#include <DD4hep/Detector.h> +#include <DD4hep/Printout.h> -#include "DD4hep/detail/Handle.inl" +#include <DD4hep/detail/Handle.inl> // C/C++ includes #include <sstream> #include <iomanip> -using namespace std; using namespace dd4hep; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) - DD4HEP_INSTANTIATE_HANDLE(TGDMLMatrix); /// Initializing constructor. PropertyTable::PropertyTable(Detector& description, - const string& table_name, - const string& property_name, + const std::string& table_name, + const std::string& property_name, size_t num_rows, size_t num_cols) { - unique_ptr<Object> table(new Object(table_name.c_str(), num_rows, num_cols)); + std::unique_ptr<Object> table(new Object(table_name.c_str(), num_rows, num_cols)); table->SetTitle(property_name.c_str()); description.manager().AddGDMLMatrix(m_element=table.release()); } -#endif diff --git a/DDCore/src/ShapeUtilities.cpp b/DDCore/src/ShapeUtilities.cpp index 71af25f271ea538b2bbc12b36f9566e0123b6bcd..11c89c214417f2c1c25d43827949661222760076 100644 --- a/DDCore/src/ShapeUtilities.cpp +++ b/DDCore/src/ShapeUtilities.cpp @@ -33,8 +33,6 @@ #include <TGeoScaledShape.h> #include <TGeoCompositeShape.h> -using namespace std; - /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -48,7 +46,7 @@ namespace dd4hep { except("Dimension","Invalid shape pointer!"); return 0; } - inline void invalidSetDimensionCall(const TGeoShape* sh, const vector<double>& params) { + inline void invalidSetDimensionCall(const TGeoShape* sh, const std::vector<double>& params) { except("Solid","+++ Shape:%s setDimension: Invalid number of parameters: %ld", (sh ? typeName(typeid(*sh)) : typeName(typeid(sh))).c_str(), params.size()); } @@ -78,9 +76,7 @@ namespace dd4hep { template bool isInstance<PolyhedraRegular> (const Handle<TGeoShape>& solid); template bool isInstance<Polyhedra> (const Handle<TGeoShape>& solid); template bool isInstance<ExtrudedPolygon> (const Handle<TGeoShape>& solid); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) template bool isInstance<TessellatedSolid> (const Handle<TGeoShape>& solid); -#endif template bool isInstance<BooleanSolid> (const Handle<TGeoShape>& solid); template <> bool isInstance<Cone>(const Handle<TGeoShape>& solid) { @@ -153,9 +149,7 @@ namespace dd4hep { template bool isA<ExtrudedPolygon>(const Handle<TGeoShape>& solid); template bool isA<Polycone>(const Handle<TGeoShape>& solid); template bool isA<EightPointSolid>(const Handle<TGeoShape>& solid); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) template bool isA<TessellatedSolid>(const Handle<TGeoShape>& solid); -#endif template <> bool isA<TwistedTube>(const Handle<TGeoShape>& solid) { return check_shape_type<TwistedTubeObject>(solid) && ::strcmp(solid->GetTitle(), TWISTEDTUBE_TAG) == 0; @@ -188,7 +182,7 @@ namespace dd4hep { } /// Retrieve tag name from shape type - string get_shape_tag(const TGeoShape* sh) { + std::string get_shape_tag(const TGeoShape* sh) { if ( sh ) { TClass* cl = sh->IsA(); if ( cl == TGeoShapeAssembly::Class() ) @@ -237,10 +231,8 @@ namespace dd4hep { return EXTRUDEDPOLYGON_TAG; else if ( cl == TGeoScaledShape::Class() ) return SCALE_TAG; -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if ( cl == TGeoTessellated::Class() ) return TESSELLATEDSOLID_TAG; -#endif else if (isA<TruncatedTube>(sh) ) return TRUNCATEDTUBE_TAG; else if (isA<PseudoTrap>(sh) ) @@ -260,30 +252,30 @@ namespace dd4hep { return ""; } - template <typename T> vector<double> dimensions(const TGeoShape* shape) { - stringstream str; + template <typename T> std::vector<double> dimensions(const TGeoShape* shape) { + std::stringstream str; if ( shape ) str << "Shape: dimension(" << typeName(typeid(*shape)) << "): Invalid call!"; else str << "Shape: dimension<TGeoShape): Invalid call && pointer!"; - throw runtime_error(str.str()); + throw std::runtime_error(str.str()); } - template <> vector<double> dimensions<TGeoShapeAssembly>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoShapeAssembly>(const TGeoShape* shape) { const auto* sh = get_ptr<TGeoShapeAssembly>(shape); return { sh->GetDX(), sh->GetDY(), sh->GetDZ() }; } - template <> vector<double> dimensions<TGeoBBox>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoBBox>(const TGeoShape* shape) { const auto* sh = get_ptr<TGeoBBox>(shape); return { sh->GetDX(), sh->GetDY(), sh->GetDZ() }; } - template <> vector<double> dimensions<TGeoHalfSpace>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoHalfSpace>(const TGeoShape* shape) { auto* sh = get_ptr<TGeoHalfSpace>(shape); return { sh->GetPoint()[0], sh->GetPoint()[1], sh->GetPoint()[2], sh->GetNorm()[0], sh->GetNorm()[1], sh->GetNorm()[2] }; } - template <> vector<double> dimensions<TGeoPcon>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoPcon>(const TGeoShape* shape) { const TGeoPcon* sh = get_ptr<TGeoPcon>(shape); - vector<double> pars { sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg, double(sh->GetNz()) }; + std::vector<double> pars { sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg, double(sh->GetNz()) }; pars.reserve(3+3*sh->GetNz()); for (Int_t i = 0; i < sh->GetNz(); ++i) { pars.emplace_back(sh->GetZ(i)); @@ -292,30 +284,30 @@ namespace dd4hep { } return pars; } - template <> vector<double> dimensions<TGeoConeSeg>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoConeSeg>(const TGeoShape* shape) { const TGeoConeSeg* sh = get_ptr<TGeoConeSeg>(shape); return { sh->GetDz(), sh->GetRmin1(), sh->GetRmax1(), sh->GetRmin2(), sh->GetRmax2(), sh->GetPhi1()*units::deg, sh->GetPhi2()*units::deg }; } - template <> vector<double> dimensions<TGeoCone>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoCone>(const TGeoShape* shape) { const TGeoCone* sh = get_ptr<TGeoCone>(shape); return { sh->GetDz(), sh->GetRmin1(), sh->GetRmax1(), sh->GetRmin2(), sh->GetRmax2() }; } - template <> vector<double> dimensions<TGeoTube>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoTube>(const TGeoShape* shape) { const TGeoTube* sh = get_ptr<TGeoTube>(shape); return { sh->GetRmin(), sh->GetRmax(), sh->GetDz() }; } - template <> vector<double> dimensions<TGeoTubeSeg>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoTubeSeg>(const TGeoShape* shape) { const TGeoTubeSeg* sh = get_ptr<TGeoTubeSeg>(shape); return { sh->GetRmin(), sh->GetRmax(), sh->GetDz(), sh->GetPhi1()*units::deg, sh->GetPhi2()*units::deg }; } - template <> vector<double> dimensions<TwistedTubeObject>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TwistedTubeObject>(const TGeoShape* shape) { const TwistedTubeObject* sh = get_ptr<TwistedTubeObject>(shape); return { sh->GetPhiTwist(), sh->GetRmin(), sh->GetRmax(), sh->GetNegativeEndZ(), sh->GetPositiveEndZ(), double(sh->GetNsegments()), sh->GetPhi2()*units::deg }; } - template <> vector<double> dimensions<TGeoCtub>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoCtub>(const TGeoShape* shape) { const TGeoCtub* sh = get_ptr<TGeoCtub>(shape); const Double_t* lo = sh->GetNlow(); const Double_t* hi = sh->GetNhigh(); @@ -323,42 +315,42 @@ namespace dd4hep { sh->GetPhi1()*units::deg, sh->GetPhi2()*units::deg, lo[0], lo[1], lo[2], hi[0], hi[1], hi[2] }; } - template <> vector<double> dimensions<TGeoEltu>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoEltu>(const TGeoShape* shape) { const TGeoEltu* sh = get_ptr<TGeoEltu>(shape); return { sh->GetA(), sh->GetB(), sh->GetDz() }; } - template <> vector<double> dimensions<TGeoTrd1>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoTrd1>(const TGeoShape* shape) { const TGeoTrd1* sh = get_ptr<TGeoTrd1>(shape); return { sh->GetDx1(), sh->GetDx2(), sh->GetDy(), sh->GetDz() }; } - template <> vector<double> dimensions<TGeoTrd2>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoTrd2>(const TGeoShape* shape) { const TGeoTrd2* sh = get_ptr<TGeoTrd2>(shape); return { sh->GetDx1(), sh->GetDx2(), sh->GetDy1(), sh->GetDy2(), sh->GetDz() }; } - template <> vector<double> dimensions<TGeoParaboloid>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoParaboloid>(const TGeoShape* shape) { const TGeoParaboloid* sh = get_ptr<TGeoParaboloid>(shape); return { sh->GetRlo(), sh->GetRhi(), sh->GetDz() }; } - template <> vector<double> dimensions<TGeoHype>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoHype>(const TGeoShape* shape) { const TGeoHype* sh = get_ptr<TGeoHype>(shape); return { sh->GetDz(), sh->GetRmin(), sh->GetStIn()*units::deg, sh->GetRmax(), sh->GetStOut()*units::deg }; } - template <> vector<double> dimensions<TGeoSphere>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoSphere>(const TGeoShape* shape) { const TGeoSphere* sh = get_ptr<TGeoSphere>(shape); return { sh->GetRmin(), sh->GetRmax(), sh->GetTheta1()*units::deg, sh->GetTheta2()*units::deg, sh->GetPhi1()*units::deg, sh->GetPhi2()*units::deg }; } - template <> vector<double> dimensions<TGeoTorus>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoTorus>(const TGeoShape* shape) { const TGeoTorus* sh = get_ptr<TGeoTorus>(shape); return { sh->GetR(), sh->GetRmin(), sh->GetRmax(), sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg }; } - template <> vector<double> dimensions<TGeoPgon>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoPgon>(const TGeoShape* shape) { const TGeoPgon* sh = get_ptr<TGeoPgon>(shape); - vector<double> pars { sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg, double(sh->GetNedges()), double(sh->GetNz()) }; + std::vector<double> pars { sh->GetPhi1()*units::deg, sh->GetDphi()*units::deg, double(sh->GetNedges()), double(sh->GetNz()) }; pars.reserve(4+3*sh->GetNz()); for (Int_t i = 0; i < sh->GetNz(); ++i) { pars.emplace_back(sh->GetZ(i)); @@ -367,10 +359,10 @@ namespace dd4hep { } return pars; } - template <> vector<double> dimensions<TGeoXtru>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoXtru>(const TGeoShape* shape) { const TGeoXtru* sh = get_ptr<TGeoXtru>(shape); Int_t nz = sh->GetNz(); - vector<double> pars { double(nz) }; + std::vector<double> pars { double(nz) }; pars.reserve(1+4*nz); for(Int_t i=0; i<nz; ++i) { pars.emplace_back(sh->GetZ(i)); @@ -380,45 +372,44 @@ namespace dd4hep { } return pars; } - template <> vector<double> dimensions<TGeoArb8>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoArb8>(const TGeoShape* shape) { TGeoArb8* sh = get_ptr<TGeoArb8>(shape); struct _V { double xy[8][2]; } *vtx = (_V*)sh->GetVertices(); - vector<double> pars { sh->GetDz() }; + std::vector<double> pars { sh->GetDz() }; for ( size_t i=0; i<8; ++i ) { pars.emplace_back(vtx->xy[i][0]); pars.emplace_back(vtx->xy[i][1]); } return pars; } - template <> vector<double> dimensions<TGeoTrap>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoTrap>(const TGeoShape* shape) { const TGeoTrap* sh = get_ptr<TGeoTrap>(shape); return { sh->GetDz(), sh->GetTheta()*units::deg, sh->GetPhi()*units::deg, sh->GetH1(), sh->GetBl1(), sh->GetTl1(), sh->GetAlpha1()*units::deg, sh->GetH2(), sh->GetBl2(), sh->GetTl2(), sh->GetAlpha2()*units::deg }; } - template <> vector<double> dimensions<TGeoGtra>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoGtra>(const TGeoShape* shape) { const TGeoGtra* sh = get_ptr<TGeoGtra>(shape); return { sh->GetDz(), sh->GetTheta()*units::deg, sh->GetPhi()*units::deg, sh->GetH1(), sh->GetBl1(), sh->GetTl1(), sh->GetAlpha1()*units::deg, sh->GetH2(), sh->GetBl2(), sh->GetTl2(), sh->GetAlpha2()*units::deg, sh->GetTwistAngle()*units::deg }; } - template <> vector<double> dimensions<TGeoScaledShape>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoScaledShape>(const TGeoShape* shape) { TGeoScaledShape* sh = get_ptr<TGeoScaledShape>(shape); TGeoShape* s_sh = sh->GetShape(); const Double_t* scale = sh->GetScale()->GetScale(); - vector<double> pars {scale[0],scale[1],scale[2]}; - vector<double> s_pars = get_shape_dimensions(s_sh); + std::vector<double> pars {scale[0],scale[1],scale[2]}; + std::vector<double> s_pars = get_shape_dimensions(s_sh); for(auto p : s_pars) pars.push_back(p); return pars; } -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) - template <> vector<double> dimensions<TGeoTessellated>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoTessellated>(const TGeoShape* shape) { TGeoTessellated* sh = get_ptr<TGeoTessellated>(shape); int num_facet = sh->GetNfacets(); int num_vtx = sh->GetNvertices(); - vector<double> pars; + std::vector<double> pars; printout(DEBUG,"TessellatedSolid","+++ Saving %d vertices, %d facets",num_vtx, num_facet); pars.reserve(num_facet*5+num_vtx*3+2); @@ -444,9 +435,8 @@ namespace dd4hep { } return pars; } -#endif - template <> vector<double> dimensions<TGeoCompositeShape>(const TGeoShape* shape) { + template <> std::vector<double> dimensions<TGeoCompositeShape>(const TGeoShape* shape) { const TGeoCompositeShape* sh = get_ptr<TGeoCompositeShape>(shape); const TGeoBoolNode* boolean = sh->GetBoolNode(); TGeoMatrix* right_matrix = boolean->GetRightMatrix(); @@ -460,9 +450,9 @@ namespace dd4hep { const Double_t* right_tr = right_matrix->GetTranslation(); const Double_t* right_rot = right_matrix->GetRotationMatrix(); - vector<double> pars { double(oper) }; - vector<double> left_par = Solid(left_solid).dimensions(); - vector<double> right_par = Solid(right_solid).dimensions(); + std::vector<double> pars { double(oper) }; + std::vector<double> left_par = Solid(left_solid).dimensions(); + std::vector<double> right_par = Solid(right_solid).dimensions(); pars.insert(pars.end(), left_par.begin(), left_par.end()); pars.insert(pars.end(), left_rot, left_rot+9); @@ -474,43 +464,41 @@ namespace dd4hep { return pars; } - template <typename T> vector<double> dimensions(const Handle<TGeoShape>& shape) + template <typename T> std::vector<double> dimensions(const Handle<TGeoShape>& shape) { return dimensions<typename T::Object>(get_ptr<typename T::Object>(shape.ptr())); } - template vector<double> dimensions<ShapelessSolid> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Box> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Scale> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<HalfSpace> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Polycone> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<ConeSegment> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Tube> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<CutTube> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<TwistedTube> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<EllipticalTube> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Cone> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Trap> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Trd1> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Trd2> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Torus> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Sphere> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Paraboloid> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Hyperboloid> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<PolyhedraRegular> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<Polyhedra> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<ExtrudedPolygon> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<EightPointSolid> (const Handle<TGeoShape>& shape); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) - template vector<double> dimensions<TessellatedSolid> (const Handle<TGeoShape>& shape); -#endif - template vector<double> dimensions<BooleanSolid> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<SubtractionSolid> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<UnionSolid> (const Handle<TGeoShape>& shape); - template vector<double> dimensions<IntersectionSolid>(const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<ShapelessSolid> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Box> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Scale> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<HalfSpace> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Polycone> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<ConeSegment> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Tube> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<CutTube> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<TwistedTube> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<EllipticalTube> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Cone> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Trap> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Trd1> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Trd2> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Torus> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Sphere> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Paraboloid> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Hyperboloid> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<PolyhedraRegular> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<Polyhedra> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<ExtrudedPolygon> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<EightPointSolid> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<TessellatedSolid> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<BooleanSolid> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<SubtractionSolid> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<UnionSolid> (const Handle<TGeoShape>& shape); + template std::vector<double> dimensions<IntersectionSolid>(const Handle<TGeoShape>& shape); - template <> vector<double> dimensions<PseudoTrap>(const Handle<TGeoShape>& shape) { + template <> std::vector<double> dimensions<PseudoTrap>(const Handle<TGeoShape>& shape) { const TGeoCompositeShape* sh = get_ptr<TGeoCompositeShape>(shape.ptr()); TGeoMatrix* right_matrix = sh->GetBoolNode()->GetRightMatrix(); - stringstream params(right_matrix->GetTitle()); - vector<double> pars; + std::stringstream params(right_matrix->GetTitle()); + std::vector<double> pars; pars.reserve(7); #ifdef DIMENSION_DEBUG cout << "dimensions: [" << PSEUDOTRAP_TAG << "]" << endl @@ -527,11 +515,11 @@ namespace dd4hep { return pars; } - template <> vector<double> dimensions<TruncatedTube>(const Handle<TGeoShape>& shape) { + template <> std::vector<double> dimensions<TruncatedTube>(const Handle<TGeoShape>& shape) { const TGeoCompositeShape* sh = get_ptr<TGeoCompositeShape>(shape.ptr()); TGeoMatrix* right_matrix = sh->GetBoolNode()->GetRightMatrix(); - stringstream params(right_matrix->GetTitle()); - vector<double> pars; + std::stringstream params(right_matrix->GetTitle()); + std::vector<double> pars; pars.reserve(8); for(size_t i=0; i<8; ++i) { double val; @@ -544,7 +532,7 @@ namespace dd4hep { return pars; } - template <> vector<double> dimensions<Solid>(const Handle<TGeoShape>& shape) { + template <> std::vector<double> dimensions<Solid>(const Handle<TGeoShape>& shape) { if ( shape.ptr() ) { TClass* cl = shape->IsA(); if ( cl == TGeoShapeAssembly::Class() ) @@ -593,10 +581,8 @@ namespace dd4hep { return dimensions<TGeoXtru>(shape.ptr() ); else if ( cl == TGeoScaledShape::Class() ) return dimensions<TGeoScaledShape>(shape.ptr() ); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if ( cl == TGeoTessellated::Class() ) return dimensions<TGeoTessellated>(shape.ptr() ); -#endif else if (isA<TruncatedTube>(shape.ptr() )) return dimensions<TruncatedTube>(shape); else if (isA<PseudoTrap>(shape.ptr() )) @@ -614,21 +600,21 @@ namespace dd4hep { } /// Access Shape dimension parameters (As in TGeo, but angles in radians rather than degrees) - vector<double> get_shape_dimensions(const Handle<TGeoShape>& shape) { + std::vector<double> get_shape_dimensions(const Handle<TGeoShape>& shape) { return dimensions<Solid>(shape); } /// Access Shape dimension parameters (As in TGeo, but angles in radians rather than degrees) - vector<double> get_shape_dimensions(TGeoShape* shape) { + std::vector<double> get_shape_dimensions(TGeoShape* shape) { return dimensions<Solid>(Solid(shape)); } template <typename T> void set_dimensions(T shape, const std::vector<double>& ) { - stringstream str; + std::stringstream str; if ( shape ) str << "Shape: set_dimension(" << typeName(typeid(*shape)) << "): Invalid call!"; else str << "Shape: set_dimension<TGeoShape): Invalid call && pointer!"; - throw runtime_error(str.str()); + throw std::runtime_error(str.str()); } template <> void set_dimensions(TGeoShapeAssembly* , const std::vector<double>& ) { @@ -656,7 +642,7 @@ namespace dd4hep { if ( params.size() != 3 + 3*nz ) { invalidSetDimensionCall(sh,params); } - vector<double> pars = params; + std::vector<double> pars = params; pars[0] /= units::deg; pars[1] /= units::deg; Solid(sh)._setDimensions(&pars[0]); @@ -827,7 +813,6 @@ namespace dd4hep { s_sh.access()->SetDimensions(&pars[3]); } -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) template <> void set_dimensions(TGeoTessellated* sh, const std::vector<double>& params) { int num_vtx = params[0]; int num_facet = params[1]; @@ -840,8 +825,8 @@ namespace dd4hep { double z = params[++i_par]; vertices.emplace_back(x, y, z); } - string nam = sh->GetName(); - string tit = sh->GetTitle(); + std::string nam = sh->GetName(); + std::string tit = sh->GetTitle(); sh->~TGeoTessellated(); new(sh) TGeoTessellated(nam.c_str(), vertices); sh->SetTitle(tit.c_str()); @@ -859,7 +844,6 @@ namespace dd4hep { } sh->CloseShape(true, true, false); } -#endif template <> void set_dimensions(TGeoCompositeShape*, const std::vector<double>&) { // In general TGeoCompositeShape instances have an empty SetDimension call @@ -873,7 +857,7 @@ namespace dd4hep { Solid(sh)._setDimensions(&pars[0]); #endif #ifdef DIMENSION_DEBUG - throw runtime_error("Composite shape. setDimensions is not implemented!"); + throw std::runtime_error("Composite shape. setDimensions is not implemented!"); #endif } @@ -921,10 +905,8 @@ namespace dd4hep { { set_dimensions(shape.ptr(), params); } template <> void set_dimensions(EightPointSolid shape, const std::vector<double>& params) { set_dimensions(shape.ptr(), params); } -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) template <> void set_dimensions(TessellatedSolid shape, const std::vector<double>& params) { set_dimensions(shape.ptr(), params); } -#endif template <> void set_dimensions(BooleanSolid shape, const std::vector<double>& params) { set_dimensions(shape.ptr(), params); } template <> void set_dimensions(SubtractionSolid shape, const std::vector<double>& params) @@ -1072,7 +1054,7 @@ namespace dd4hep { except("PseudoTrap","+++ Incompatible change of parameters."); } ((TGeoTranslation*)right_matrix)->SetTranslation(0,0,displacement); - stringstream str; + std::stringstream str; str << x1 << " " << x2 << " " << y1 << " " << y2 << " " << z << " " << r << " " << char(atMinusZ ? '1' : '0') << " "; right_matrix->SetTitle(str.str().c_str()); @@ -1125,10 +1107,8 @@ namespace dd4hep { set_dimensions(ExtrudedPolygon(shape), params); else if ( cl == TGeoArb8::Class() ) set_dimensions(EightPointSolid(shape), params); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if ( cl == TGeoTessellated::Class() ) set_dimensions(TessellatedSolid(shape), params); -#endif else if ( cl == TGeoScaledShape::Class() ) { TGeoScaledShape* sh = (TGeoScaledShape*) shape.ptr(); set_dimensions(sh, params); @@ -1156,25 +1136,25 @@ namespace dd4hep { set_dimensions<Solid>(Solid(shape), params); } /// Set the shape dimensions. As for the TGeo shape, but angles in rad rather than degrees. - void set_shape_dimensions(TGeoShape* shape, const vector<double>& params) { + void set_shape_dimensions(TGeoShape* shape, const std::vector<double>& params) { set_dimensions<Solid>(Solid(shape), params); } /// Set the shape dimensions. As for the TGeo shape, but angles in rad rather than degrees. - void set_shape_dimensions(Solid solid, const vector<double>& params) { + void set_shape_dimensions(Solid solid, const std::vector<double>& params) { set_dimensions<Solid>(solid, params); } /// Pretty print of solid attributes - string toStringSolid(const TGeoShape* shape, int precision) { + std::string toStringSolid(const TGeoShape* shape, int precision) { if ( !shape ) { return "[Invalid shape]"; } - stringstream log; + std::stringstream log; TClass* cl = shape->IsA(); int prec = log.precision(); - log.setf(ios::fixed,ios::floatfield); - log << setprecision(precision); + log.setf(std::ios::fixed,std::ios::floatfield); + log << std::setprecision(precision); log << cl->GetName(); if ( cl == TGeoBBox::Class() ) { TGeoBBox* sh = (TGeoBBox*) shape; @@ -1307,14 +1287,14 @@ namespace dd4hep { log << "Intersection: "; log << " Left:" << toStringSolid(left) << " Right:" << toStringSolid(right); } - log << setprecision(prec); + log << std::setprecision(prec); return log.str(); } /// Output mesh vertices to string - string toStringMesh(const TGeoShape* shape, int prec) { + std::string toStringMesh(const TGeoShape* shape, int prec) { Solid sol(shape); - stringstream os; + std::stringstream os; // Prints shape parameters Int_t nvert = 0, nsegs = 0, npols = 0; @@ -1323,31 +1303,31 @@ namespace dd4hep { Double_t* points = new Double_t[3*nvert]; sol->SetPoints(points); - os << setw(16) << left << sol->IsA()->GetName() - << " " << nvert << " Mesh-points:" << endl; - os << setw(16) << left << sol->IsA()->GetName() << " " << sol->GetName() + os << std::setw(16) << std::left << sol->IsA()->GetName() + << " " << nvert << " Mesh-points:" << std::endl; + os << std::setw(16) << std::left << sol->IsA()->GetName() << " " << sol->GetName() << " N(mesh)=" << sol->GetNmeshVertices() - << " N(vert)=" << nvert << " N(seg)=" << nsegs << " N(pols)=" << npols << endl; + << " N(vert)=" << nvert << " N(seg)=" << nsegs << " N(pols)=" << npols << std::endl; for(Int_t i=0; i<nvert; ++i) { Double_t* p = points + 3*i; - os << setw(16) << left << sol->IsA()->GetName() << " " << setw(3) << left << i - << " Local (" << setw(7) << setprecision(prec) << fixed << right << p[0]/dd4hep::cm - << ", " << setw(7) << setprecision(prec) << fixed << right << p[1]/dd4hep::cm - << ", " << setw(7) << setprecision(prec) << fixed << right << p[2]/dd4hep::cm - << ")" << endl; + os << std::setw(16) << std::left << sol->IsA()->GetName() << " " << std::setw(3) << std::left << i + << " Local (" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << p[0]/dd4hep::cm + << ", " << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << p[1]/dd4hep::cm + << ", " << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << p[2]/dd4hep::cm + << ")" << std::endl; } Box box = sol; const Double_t* org = box->GetOrigin(); - os << setw(16) << left << sol->IsA()->GetName() + os << std::setw(16) << std::left << sol->IsA()->GetName() << " Bounding box: " - << " dx=" << setw(7) << setprecision(prec) << fixed << right << box->GetDX()/dd4hep::cm - << " dy=" << setw(7) << setprecision(prec) << fixed << right << box->GetDY()/dd4hep::cm - << " dz=" << setw(7) << setprecision(prec) << fixed << right << box->GetDZ()/dd4hep::cm - << " Origin: x=" << setw(7) << setprecision(prec) << fixed << right << org[0]/dd4hep::cm - << " y=" << setw(7) << setprecision(prec) << fixed << right << org[1]/dd4hep::cm - << " z=" << setw(7) << setprecision(prec) << fixed << right << org[2]/dd4hep::cm - << endl; + << " dx=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << box->GetDX()/dd4hep::cm + << " dy=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << box->GetDY()/dd4hep::cm + << " dz=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << box->GetDZ()/dd4hep::cm + << " Origin: x=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << org[0]/dd4hep::cm + << " y=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << org[1]/dd4hep::cm + << " z=" << std::setw(7) << std::setprecision(prec) << std::fixed << std::right << org[2]/dd4hep::cm + << std::endl; /// -------------------- DONE -------------------- delete [] points; diff --git a/DDCore/src/Shapes.cpp b/DDCore/src/Shapes.cpp index 10d4643d535f48ddbc24e97992c4b47a438ef6b4..3077b215b09c23f36f6872c489734de7683071ea 100644 --- a/DDCore/src/Shapes.cpp +++ b/DDCore/src/Shapes.cpp @@ -33,7 +33,6 @@ #include <TGeoScaledShape.h> #include <TGeoCompositeShape.h> -using namespace std; using namespace dd4hep; namespace units = dd4hep; @@ -45,7 +44,7 @@ template <typename T> void Solid_type<T>::_setDimensions(double* param) const /// Assign pointrs and register solid to geometry template <typename T> -void Solid_type<T>::_assign(T* n, const string& nam, const string& tit, bool cbbox) { +void Solid_type<T>::_assign(T* n, const std::string& nam, const std::string& tit, bool cbbox) { this->assign(n, nam, tit); if (cbbox) n->ComputeBBox(); @@ -74,7 +73,7 @@ template <typename T> Solid_type<T>& Solid_type<T>::setName(const char* value) } /// Set new shape name -template <typename T> Solid_type<T>& Solid_type<T>::setName(const string& value) { +template <typename T> Solid_type<T>& Solid_type<T>::setName(const std::string& value) { this->access()->SetName(value.c_str()); return *this; } @@ -88,19 +87,19 @@ template <typename T> const char* Solid_type<T>::type() const { } /// Access the dimensions of the shape: inverse of the setDimensions member function -template <typename T> vector<double> Solid_type<T>::dimensions() { +template <typename T> std::vector<double> Solid_type<T>::dimensions() { return get_shape_dimensions(this->access()); } /// Set the shape dimensions. As for the TGeo shape, but angles in rad rather than degrees. -template <typename T> Solid_type<T>& Solid_type<T>::setDimensions(const vector<double>& params) { +template <typename T> Solid_type<T>& Solid_type<T>::setDimensions(const std::vector<double>& params) { set_shape_dimensions(this->access(), params); return *this; } /// Divide volume into subsections (See the ROOT manuloa for details) template <typename T> TGeoVolume* -Solid_type<T>::divide(const Volume& voldiv, const string& divname, +Solid_type<T>::divide(const Volume& voldiv, const std::string& divname, int iaxis, int ndiv, double start, double step) const { T* p = this->ptr(); if ( p ) { @@ -117,12 +116,12 @@ Solid_type<T>::divide(const Volume& voldiv, const string& divname, } /// Constructor to create an anonymous new box object (retrieves name from volume) -ShapelessSolid::ShapelessSolid(const string& nam) { +ShapelessSolid::ShapelessSolid(const std::string& nam) { _assign(new TGeoShapeAssembly(), nam, SHAPELESS_TAG, true); } -void Scale::make(const string& nam, Solid base, double x_scale, double y_scale, double z_scale) { - auto scale = make_unique<TGeoScale>(x_scale, y_scale, z_scale); +void Scale::make(const std::string& nam, Solid base, double x_scale, double y_scale, double z_scale) { + auto scale = std::make_unique<TGeoScale>(x_scale, y_scale, z_scale); _assign(new TGeoScaledShape(nam.c_str(), base.access(), scale.release()), "", SCALE_TAG, true); } @@ -141,7 +140,7 @@ double Scale::scale_z() const { return this->access()->GetScale()->GetScale()[2]; } -void Box::make(const string& nam, double x_val, double y_val, double z_val) { +void Box::make(const std::string& nam, double x_val, double y_val, double z_val) { _assign(new TGeoBBox(nam.c_str(), x_val, y_val, z_val), "", BOX_TAG, true); } @@ -168,7 +167,7 @@ double Box::z() const { } /// Internal helper method to support object construction -void HalfSpace::make(const string& nam, const double* const point, const double* const normal) { +void HalfSpace::make(const std::string& nam, const double* const point, const double* const normal) { _assign(new TGeoHalfSpace(nam.c_str(),(Double_t*)point, (Double_t*)normal), "", HALFSPACE_TAG,true); } @@ -179,18 +178,18 @@ Polycone::Polycone(double startPhi, double deltaPhi) { /// Constructor to be used when creating a new polycone object. Add at the same time all Z planes Polycone::Polycone(double startPhi, double deltaPhi, - const vector<double>& rmin, const vector<double>& rmax, const vector<double>& z) { - vector<double> params; + const std::vector<double>& rmin, const std::vector<double>& rmax, const std::vector<double>& z) { + std::vector<double> params; if (rmin.size() < 2) { - throw runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); + throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); } if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) ) { - throw runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length"); + throw std::runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length"); } params.emplace_back(startPhi/units::deg); params.emplace_back(deltaPhi/units::deg); params.emplace_back(rmin.size()); - for (size_t i = 0; i < rmin.size(); ++i) { + for (std::size_t i = 0; i < rmin.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(rmin[i] ); params.emplace_back(rmax[i] ); @@ -199,18 +198,18 @@ Polycone::Polycone(double startPhi, double deltaPhi, } /// Constructor to be used when creating a new polycone object. Add at the same time all Z planes -Polycone::Polycone(double startPhi, double deltaPhi, const vector<double>& r, const vector<double>& z) { - vector<double> params; +Polycone::Polycone(double startPhi, double deltaPhi, const std::vector<double>& r, const std::vector<double>& z) { + std::vector<double> params; if (r.size() < 2) { - throw runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); + throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); } if((z.size()!=r.size()) ) { - throw runtime_error("dd4hep: Polycone: vectors z,r not of same length"); + throw std::runtime_error("dd4hep: Polycone: vectors z,r not of same length"); } params.emplace_back(startPhi/units::deg); params.emplace_back(deltaPhi/units::deg); params.emplace_back(r.size()); - for (size_t i = 0; i < r.size(); ++i) { + for (std::size_t i = 0; i < r.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(0.0 ); params.emplace_back(r[i] ); @@ -219,24 +218,24 @@ Polycone::Polycone(double startPhi, double deltaPhi, const vector<double>& r, co } /// Constructor to be used when creating a new object -Polycone::Polycone(const string& nam, double startPhi, double deltaPhi) { +Polycone::Polycone(const std::string& nam, double startPhi, double deltaPhi) { _assign(new TGeoPcon(nam.c_str(), startPhi/units::deg, deltaPhi/units::deg, 0), "", POLYCONE_TAG, false); } /// Constructor to be used when creating a new polycone object. Add at the same time all Z planes -Polycone::Polycone(const string& nam, double startPhi, double deltaPhi, - const vector<double>& rmin, const vector<double>& rmax, const vector<double>& z) { - vector<double> params; +Polycone::Polycone(const std::string& nam, double startPhi, double deltaPhi, + const std::vector<double>& rmin, const std::vector<double>& rmax, const std::vector<double>& z) { + std::vector<double> params; if (rmin.size() < 2) { - throw runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); + throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); } if((z.size()!=rmin.size()) || (z.size()!=rmax.size()) ) { - throw runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length"); + throw std::runtime_error("dd4hep: Polycone: vectors z,rmin,rmax not of same length"); } params.emplace_back(startPhi/units::deg); params.emplace_back(deltaPhi/units::deg); params.emplace_back(rmin.size()); - for (size_t i = 0; i < rmin.size(); ++i) { + for (std::size_t i = 0; i < rmin.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(rmin[i] ); params.emplace_back(rmax[i] ); @@ -245,18 +244,18 @@ Polycone::Polycone(const string& nam, double startPhi, double deltaPhi, } /// Constructor to be used when creating a new polycone object. Add at the same time all Z planes -Polycone::Polycone(const string& nam, double startPhi, double deltaPhi, const vector<double>& r, const vector<double>& z) { - vector<double> params; +Polycone::Polycone(const std::string& nam, double startPhi, double deltaPhi, const std::vector<double>& r, const std::vector<double>& z) { + std::vector<double> params; if (r.size() < 2) { - throw runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); + throw std::runtime_error("dd4hep: PolyCone Not enough Z planes. minimum is 2!"); } if((z.size()!=r.size()) ) { - throw runtime_error("dd4hep: Polycone: vectors z,r not of same length"); + throw std::runtime_error("dd4hep: Polycone: vectors z,r not of same length"); } params.emplace_back(startPhi/units::deg); params.emplace_back(deltaPhi/units::deg); params.emplace_back(r.size()); - for (size_t i = 0; i < r.size(); ++i) { + for (std::size_t i = 0; i < r.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(0.0 ); params.emplace_back(r[i] ); @@ -265,22 +264,22 @@ Polycone::Polycone(const string& nam, double startPhi, double deltaPhi, const ve } /// Add Z-planes to the Polycone -void Polycone::addZPlanes(const vector<double>& rmin, const vector<double>& rmax, const vector<double>& z) { +void Polycone::addZPlanes(const std::vector<double>& rmin, const std::vector<double>& rmax, const std::vector<double>& z) { TGeoPcon* sh = *this; - vector<double> params; - size_t num = sh->GetNz(); + std::vector<double> params; + std::size_t num = sh->GetNz(); if (rmin.size() < 2) { except("PolyCone","++ addZPlanes: Not enough Z planes. minimum is 2!"); } params.emplace_back(sh->GetPhi1()); params.emplace_back(sh->GetDphi()); params.emplace_back(num + rmin.size()); - for (size_t i = 0; i < num; ++i) { + for (std::size_t i = 0; i < num; ++i) { params.emplace_back(sh->GetZ(i)); params.emplace_back(sh->GetRmin(i)); params.emplace_back(sh->GetRmax(i)); } - for (size_t i = 0; i < rmin.size(); ++i) { + for (std::size_t i = 0; i < rmin.size(); ++i) { params.emplace_back(z[i] ); params.emplace_back(rmin[i] ); params.emplace_back(rmax[i] ); @@ -289,7 +288,7 @@ void Polycone::addZPlanes(const vector<double>& rmin, const vector<double>& rmax } /// Constructor to be used when creating a new cone segment object -void ConeSegment::make(const string& nam, +void ConeSegment::make(const std::string& nam, double dz, double rmin1, double rmax1, double rmin2, double rmax2, @@ -310,7 +309,7 @@ ConeSegment& ConeSegment::setDimensions(double dz, } /// Constructor to be used when creating a new object with attribute initialization -void Cone::make(const string& nam, double z, double rmin1, double rmax1, double rmin2, double rmax2) { +void Cone::make(const std::string& nam, double z, double rmin1, double rmax1, double rmin2, double rmax2) { _assign(new TGeoCone(nam.c_str(), z, rmin1, rmax1, rmin2, rmax2 ), "", CONE_TAG, true); } @@ -322,7 +321,7 @@ Cone& Cone::setDimensions(double z, double rmin1, double rmax1, double rmin2, do } /// Constructor to be used when creating a new object with attribute initialization -void Tube::make(const string& nam, double rmin, double rmax, double z, double start_phi, double end_phi) { +void Tube::make(const std::string& nam, double rmin, double rmax, double z, double start_phi, double end_phi) { // Check if it is a full tube if(fabs(end_phi-start_phi-2*M_PI)<10e-6){ _assign(new TGeoTubeSeg(nam.c_str(), rmin, rmax, z, start_phi/units::deg, start_phi/units::deg+360.),nam,TUBE_TAG,true); @@ -345,14 +344,14 @@ CutTube::CutTube(double rmin, double rmax, double dz, double start_phi, double e } /// Constructor to be used when creating a new object with attribute initialization -CutTube::CutTube(const string& nam, +CutTube::CutTube(const std::string& nam, double rmin, double rmax, double dz, double start_phi, double end_phi, double lx, double ly, double lz, double tx, double ty, double tz) { make(nam, rmin,rmax,dz,start_phi/units::deg,end_phi/units::deg,lx,ly,lz,tx,ty,tz); } /// Constructor to be used when creating a new object with attribute initialization -void CutTube::make(const string& nam, double rmin, double rmax, double dz, double start_phi, double end_phi, +void CutTube::make(const std::string& nam, double rmin, double rmax, double dz, double start_phi, double end_phi, double lx, double ly, double lz, double tx, double ty, double tz) { _assign(new TGeoCtub(nam.c_str(), rmin,rmax,dz,start_phi,end_phi,lx,ly,lz,tx,ty,tz),"",CUTTUBE_TAG,true); } @@ -363,13 +362,13 @@ TruncatedTube::TruncatedTube(double dz, double rmin, double rmax, double start_p { make("", dz, rmin, rmax, start_phi/units::deg, delta_phi/units::deg, cut_atStart, cut_atDelta, cut_inside); } /// Constructor to create a truncated tube object with attribute initialization -TruncatedTube::TruncatedTube(const string& nam, +TruncatedTube::TruncatedTube(const std::string& nam, double dz, double rmin, double rmax, double start_phi, double delta_phi, double cut_atStart, double cut_atDelta, bool cut_inside) { make(nam, dz, rmin, rmax, start_phi/units::deg, delta_phi/units::deg, cut_atStart, cut_atDelta, cut_inside); } /// Internal helper method to support object construction -void TruncatedTube::make(const string& nam, +void TruncatedTube::make(const std::string& nam, double dz, double rmin, double rmax, double start_phi, double delta_phi, double cut_atStart, double cut_atDelta, bool cut_inside) { // check the parameters @@ -411,55 +410,55 @@ void TruncatedTube::make(const string& nam, TGeoCombiTrans* combi = new TGeoCombiTrans(trans, rot); TGeoSubtraction* sub = new TGeoSubtraction(tubs, box, nullptr, combi); _assign(new TGeoCompositeShape(nam.c_str(), sub),"",TRUNCATEDTUBE_TAG,true); - stringstream params; - params << dz << " " << endl - << rmin << " " << endl - << rmax << " " << endl - << start_phi*units::deg << " " << endl - << delta_phi*units::deg << " " << endl - << cut_atStart << " " << endl - << cut_atDelta << " " << endl - << char(cut_inside ? '1' : '0') << endl; + std::stringstream params; + params << dz << " " << std::endl + << rmin << " " << std::endl + << rmax << " " << std::endl + << start_phi*units::deg << " " << std::endl + << delta_phi*units::deg << " " << std::endl + << cut_atStart << " " << std::endl + << cut_atDelta << " " << std::endl + << char(cut_inside ? '1' : '0') << std::endl; combi->SetTitle(params.str().c_str()); - //cout << "Params: " << params.str() << endl; + //cout << "Params: " << params.str() << std::endl; #if 0 - params << TRUNCATEDTUBE_TAG << ":" << endl - << "\t dz: " << dz << " " << endl - << "\t rmin: " << rmin << " " << endl - << "\t rmax: " << rmax << " " << endl - << "\t startPhi: " << start_phi << " " << endl - << "\t deltaPhi: " << delta_phi << " " << endl - << "\t r/cutAtStart:" << cut_atStart << " " << endl - << "\t R/cutAtDelta:" << cut_atDelta << " " << endl - << "\t cutInside: " << char(cut_inside ? '1' : '0') << endl - << "\t\t alpha: " << alpha << endl - << "\t\t sin_alpha: " << sin_alpha << endl - << "\t\t boxY: " << boxY << endl - << "\t\t xBox: " << xBox << endl; + params << TRUNCATEDTUBE_TAG << ":" << std::endl + << "\t dz: " << dz << " " << std::endl + << "\t rmin: " << rmin << " " << std::endl + << "\t rmax: " << rmax << " " << std::endl + << "\t startPhi: " << start_phi << " " << std::endl + << "\t deltaPhi: " << delta_phi << " " << std::endl + << "\t r/cutAtStart:" << cut_atStart << " " << std::endl + << "\t R/cutAtDelta:" << cut_atDelta << " " << std::endl + << "\t cutInside: " << char(cut_inside ? '1' : '0') << std::endl + << "\t\t alpha: " << alpha << std::endl + << "\t\t sin_alpha: " << sin_alpha << std::endl + << "\t\t boxY: " << boxY << std::endl + << "\t\t xBox: " << xBox << std::endl; #endif #if 0 - cout << "Trans:"; trans.Print(); cout << endl; - cout << "Rot: "; rot.Print(); cout << endl; + cout << "Trans:"; trans.Print(); cout << std::endl; + cout << "Rot: "; rot.Print(); cout << std::endl; cout << " Dz: " << dz << " rmin: " << rmin << " rmax: " << rmax << " r/cutAtStart: " << r << " R/cutAtDelta: " << R << " cutInside: " << (cut_inside ? "YES" : "NO ") - << endl; + << std::endl; cout << " cath: " << cath << " hypo: " << hypo << " cos_alpha: " << cos_alpha << " alpha: " << alpha << " alpha(deg):" << alpha/dd4hep::deg - << endl; + << std::endl; cout << " Deg: " << dd4hep::deg << " cm: " << dd4hep::cm << " xBox: " << xBox - << endl; - cout << "Box:" << "x:" << box->GetDX() << " y:" << box->GetDY() << " z:" << box->GetDZ() << endl; + << std::endl; + cout << "Box:" << "x:" << box->GetDX() << " y:" << box->GetDY() << " z:" << box->GetDZ() << std::endl; cout << "Tubs:" << " rmin:" << rmin << " rmax" << rmax << "dZ" << dZ - << " startPhi:" << start_phi << " deltaPhi:" << delta_phi << endl; + << " startPhi:" << start_phi << " deltaPhi:" << delta_phi << std::endl; #endif } @@ -504,7 +503,7 @@ bool TruncatedTube::cutInside() const { } /// Constructor to be used when creating a new object with attribute initialization -void EllipticalTube::make(const string& nam, double a, double b, double dz) { +void EllipticalTube::make(const std::string& nam, double a, double b, double dz) { _assign(new TGeoEltu(nam.c_str(), a, b, dz), "", ELLIPTICALTUBE_TAG, true); } @@ -516,7 +515,7 @@ void TwistedTube::make(const std::string& nam, double twist_angle, double rmin, } /// Constructor to be used when creating a new object with attribute initialization -void Trd1::make(const string& nam, double x1, double x2, double y, double z) { +void Trd1::make(const std::string& nam, double x1, double x2, double y, double z) { _assign(new TGeoTrd1(nam.c_str(), x1, x2, y, z ), "", TRD1_TAG, true); } @@ -528,7 +527,7 @@ Trd1& Trd1::setDimensions(double x1, double x2, double y, double z) { } /// Constructor to be used when creating a new object with attribute initialization -void Trd2::make(const string& nam, double x1, double x2, double y1, double y2, double z) { +void Trd2::make(const std::string& nam, double x1, double x2, double y1, double y2, double z) { _assign(new TGeoTrd2(nam.c_str(), x1, x2, y1, y2, z ), "", TRD2_TAG, true); } @@ -540,7 +539,7 @@ Trd2& Trd2::setDimensions(double x1, double x2, double y1, double y2, double z) } /// Constructor to be used when creating a new object with attribute initialization -void Paraboloid::make(const string& nam, double r_low, double r_high, double delta_z) { +void Paraboloid::make(const std::string& nam, double r_low, double r_high, double delta_z) { _assign(new TGeoParaboloid(nam.c_str(), r_low, r_high, delta_z ), "", PARABOLOID_TAG, true); } @@ -552,7 +551,7 @@ Paraboloid& Paraboloid::setDimensions(double r_low, double r_high, double delta_ } /// Constructor to create a new anonymous object with attribute initialization -void Hyperboloid::make(const string& nam, double rin, double stin, double rout, double stout, double dz) { +void Hyperboloid::make(const std::string& nam, double rin, double stin, double rout, double stout, double dz) { _assign(new TGeoHype(nam.c_str(), rin, stin/units::deg, rout, stout/units::deg, dz), "", HYPERBOLOID_TAG, true); } @@ -564,7 +563,7 @@ Hyperboloid& Hyperboloid::setDimensions(double rin, double stin, double rout, do } /// Constructor function to be used when creating a new object with attribute initialization -void Sphere::make(const string& nam, double rmin, double rmax, double startTheta, double endTheta, double startPhi, double endPhi) { +void Sphere::make(const std::string& nam, double rmin, double rmax, double startTheta, double endTheta, double startPhi, double endPhi) { _assign(new TGeoSphere(nam.c_str(), rmin, rmax, startTheta/units::deg, endTheta/units::deg, startPhi/units::deg, endPhi/units::deg), "", SPHERE_TAG, true); @@ -578,7 +577,7 @@ Sphere& Sphere::setDimensions(double rmin, double rmax, double startTheta, doubl } /// Constructor to be used when creating a new object with attribute initialization -void Torus::make(const string& nam, double r, double rmin, double rmax, double startPhi, double deltaPhi) { +void Torus::make(const std::string& nam, double r, double rmin, double rmax, double startPhi, double deltaPhi) { _assign(new TGeoTorus(nam.c_str(), r, rmin, rmax, startPhi/units::deg, deltaPhi/units::deg), "", TORUS_TAG, true); } @@ -599,7 +598,7 @@ Trap::Trap(double z, double theta, double phi, } /// Constructor to be used when creating a new anonymous object with attribute initialization -Trap::Trap(const string& nam, +Trap::Trap(const std::string& nam, double z, double theta, double phi, double h1, double bl1, double tl1, double alpha1, double h2, double bl2, double tl2, double alpha2) { @@ -609,7 +608,7 @@ Trap::Trap(const string& nam, } /// Constructor to be used when creating a new anonymous object with attribute initialization -void Trap::make(const string& nam, double pZ, double pY, double pX, double pLTX) { +void Trap::make(const std::string& nam, double pZ, double pY, double pX, double pLTX) { double fDz = 0.5*pZ; double fTheta = 0; double fPhi = 0; @@ -640,7 +639,7 @@ Trap& Trap::setDimensions(double z, double theta, double phi, } /// Internal helper method to support object construction -void PseudoTrap::make(const string& nam, double x1, double x2, double y1, double y2, double z, double r, bool atMinusZ) { +void PseudoTrap::make(const std::string& nam, double x1, double x2, double y1, double y2, double z, double r, bool atMinusZ) { double x = atMinusZ ? x1 : x2; double h = 0; bool intersec = false; // union or intersection solid @@ -724,7 +723,7 @@ void PseudoTrap::make(const string& nam, double x1, double x2, double y1, double Solid trap(new TGeoTrd2((nam+"Trd2").c_str(), x1, x2, y1, y2, halfZ)); Solid tubs(new TGeoTubeSeg((nam+"Tubs").c_str(), 0.,std::abs(r),h,startPhi,startPhi + halfOpeningAngle*2.)); - stringstream params; + std::stringstream params; params << x1 << " " << x2 << " " << y1 << " " << y2 << " " << z << " " << r << " " << char(atMinusZ ? '1' : '0') << " "; TGeoCompositeShape* solid = 0; @@ -742,21 +741,21 @@ void PseudoTrap::make(const string& nam, double x1, double x2, double y1, double } /// Helper function to create poly hedron -void PolyhedraRegular::make(const string& nam, int nsides, double rmin, double rmax, +void PolyhedraRegular::make(const std::string& nam, int nsides, double rmin, double rmax, double zpos, double zneg, double start, double delta) { if (rmin < 0e0 || rmin > rmax) - throw runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmin:<" + _toString(rmin) + "> is invalid!"); + throw std::runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmin:<" + _toString(rmin) + "> is invalid!"); else if (rmax < 0e0) - throw runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmax:<" + _toString(rmax) + "> is invalid!"); + throw std::runtime_error("dd4hep: PolyhedraRegular: Illegal argument rmax:<" + _toString(rmax) + "> is invalid!"); double params[] = { start/units::deg, delta/units::deg, double(nsides), 2e0, zpos, rmin, rmax, zneg, rmin, rmax }; _assign(new TGeoPgon(params), nam, POLYHEDRA_TAG, false); //_setDimensions(¶ms[0]); } /// Helper function to create poly hedron -void Polyhedra::make(const string& nam, int nsides, double start, double delta, - const vector<double>& z, const vector<double>& rmin, const vector<double>& rmax) { - vector<double> temp; +void Polyhedra::make(const std::string& nam, int nsides, double start, double delta, + const std::vector<double>& z, const std::vector<double>& rmin, const std::vector<double>& rmax) { + std::vector<double> temp; if ( rmin.size() != z.size() || rmax.size() != z.size() ) { except("Polyhedra", "Number of values to define zplanes are incorrect: z:%ld rmin:%ld rmax:%ld", @@ -768,7 +767,7 @@ void Polyhedra::make(const string& nam, int nsides, double start, double delta, temp.emplace_back(delta/units::deg); temp.emplace_back(double(nsides)); temp.emplace_back(double(z.size())); - for(size_t i=0; i<z.size(); ++i) { + for(std::size_t i=0; i<z.size(); ++i) { temp.emplace_back(z[i]); temp.emplace_back(rmin[i]); temp.emplace_back(rmax[i]); @@ -777,28 +776,27 @@ void Polyhedra::make(const string& nam, int nsides, double start, double delta, } /// Helper function to create the polyhedron -void ExtrudedPolygon::make(const string& nam, - const vector<double>& pt_x, - const vector<double>& pt_y, - const vector<double>& sec_z, - const vector<double>& sec_x, - const vector<double>& sec_y, - const vector<double>& sec_scale) +void ExtrudedPolygon::make(const std::string& nam, + const std::vector<double>& pt_x, + const std::vector<double>& pt_y, + const std::vector<double>& sec_z, + const std::vector<double>& sec_x, + const std::vector<double>& sec_y, + const std::vector<double>& sec_scale) { TGeoXtru* solid = new TGeoXtru(sec_z.size()); _assign(solid, nam, EXTRUDEDPOLYGON_TAG, false); // No need to transform coordinates to cm. We are in the dd4hep world: all is already in cm. solid->DefinePolygon(pt_x.size(), &(*pt_x.begin()), &(*pt_y.begin())); - for( size_t i = 0; i < sec_z.size(); ++i ) + for( std::size_t i = 0; i < sec_z.size(); ++i ) solid->DefineSection(i, sec_z[i], sec_x[i], sec_y[i], sec_scale[i]); } /// Creator method for arbitrary eight point solids -void EightPointSolid::make(const string& nam, double dz, const double* vtx) { +void EightPointSolid::make(const std::string& nam, double dz, const double* vtx) { _assign(new TGeoArb8(nam.c_str(), dz, (double*)vtx), "", EIGHTPOINTSOLID_TAG, true); } -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) /// Internal helper method to support object construction void TessellatedSolid::make(const std::string& nam, int num_facets) { _assign(new TGeoTessellated(nam.c_str(), num_facets), nam, TESSELLATEDSOLID_TAG, false); @@ -848,7 +846,6 @@ int TessellatedSolid::num_vertex() const { const TessellatedSolid::Vertex& TessellatedSolid::vertex(int index) const { return ptr()->GetVertex(index); } -#endif /// Access right solid of the boolean Solid BooleanSolid::rightShape() const { @@ -901,31 +898,31 @@ SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2, con } /// Constructor to be used when creating a new object. Position is identity, Rotation is the identity rotation -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity()); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } /// Constructor to be used when creating a new object. Placement by a generic transformation within the mother -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans)); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } /// Constructor to be used when creating a new object. Rotation is the identity rotation -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos)); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } /// Constructor to be used when creating a new object -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot)); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } /// Constructor to be used when creating a new object -SubtractionSolid::SubtractionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { +SubtractionSolid::SubtractionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { TGeoSubtraction* sub = new TGeoSubtraction(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot)); _assign(new TGeoCompositeShape(nam.c_str(), sub), "", SUBTRACTION_TAG, true); } @@ -961,31 +958,31 @@ UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2, const Rotation3 } /// Constructor to be used when creating a new object. Position is identity, Rotation is identity rotation -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2) { TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity()); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } /// Constructor to be used when creating a new object. Placement by a generic transformation within the mother -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans)); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } /// Constructor to be used when creating a new object. Rotation is identity rotation -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { TGeoUnion* uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos)); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } /// Constructor to be used when creating a new object -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { TGeoUnion *uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot)); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } /// Constructor to be used when creating a new object -UnionSolid::UnionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { +UnionSolid::UnionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { TGeoUnion *uni = new TGeoUnion(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot)); _assign(new TGeoCompositeShape(nam.c_str(), uni), "", UNION_TAG, true); } @@ -1021,31 +1018,31 @@ IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2, c } /// Constructor to be used when creating a new object. Position is identity, Rotation is identity rotation -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_identity()); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } /// Constructor to be used when creating a new object. Placement by a generic transformation within the mother -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Transform3D& trans) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_transform(trans)); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } /// Constructor to be used when creating a new object. Position is identity. -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Position& pos) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_translation(pos)); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } /// Constructor to be used when creating a new object -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const RotationZYX& rot) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotationZYX(rot)); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } /// Constructor to be used when creating a new object -IntersectionSolid::IntersectionSolid(const string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { +IntersectionSolid::IntersectionSolid(const std::string& nam, const Solid& shape1, const Solid& shape2, const Rotation3D& rot) { TGeoIntersection* inter = new TGeoIntersection(shape1, shape2, detail::matrix::_identity(), detail::matrix::_rotation3D(rot)); _assign(new TGeoCompositeShape(nam.c_str(), inter), "", INTERSECTION_TAG, true); } @@ -1075,7 +1072,4 @@ INSTANTIATE(TGeoTrd2); INSTANTIATE(TGeoCtub); INSTANTIATE(TGeoScaledShape); INSTANTIATE(TGeoCompositeShape); - -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) INSTANTIATE(TGeoTessellated); -#endif diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 1b1a88601e7bbdf9c3621535af03a60eeb26d3df..775545a6d3beaf68a76944b0bdac8d7405a1eedb 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -1157,7 +1157,7 @@ const Volume& Volume::setVisAttributes(const VisAttr& attr) const { #if ROOT_VERSION_CODE >= ROOT_VERSION(6,29,0) // Set directly transparency to the volume, NOT to the material as for ROOT < 6.29 m_element->ResetTransparency(Char_t((1.0-vis->alpha)*100)); -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) +#else // As suggested by Valentin Volkl https://sft.its.cern.ch/jira/browse/DDFORHEP-20 // // According to https://root.cern.ch/phpBB3/viewtopic.php?t=2309#p66013 diff --git a/DDCore/src/gdml/GdmlPlugins.cpp b/DDCore/src/gdml/GdmlPlugins.cpp index 0e9130a823b8050bffc9456e976c7e4ca9d9a908..d1c3157114eeed23fe4be6e6d7277d897fa7de6b 100644 --- a/DDCore/src/gdml/GdmlPlugins.cpp +++ b/DDCore/src/gdml/GdmlPlugins.cpp @@ -33,8 +33,6 @@ using namespace std; using namespace dd4hep; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,13,0) - /// ROOT GDML reader plugin /** * Factory: DD4hep_ROOTGDMLParse @@ -186,10 +184,8 @@ static long gdml_extract(Detector& description, int argc, char** argv) { extract.SetIgnoreDummyMaterial(true); extract.SetNamingSpeed(TGDMLWrite::kfastButUglySufix); extract.WriteGDMLfile(&description.manager(), de.placement().ptr(), uri.GetRelativePart()); -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,20,0) - extract.WriteGDMLfile(&description.manager(), de.placement().ptr(), uri.GetRelativePart()); #else - extract.WriteGDMLfile(&description.manager(), de.volume().ptr(), uri.GetRelativePart()); + extract.WriteGDMLfile(&description.manager(), de.placement().ptr(), uri.GetRelativePart()); #endif return 1; } @@ -235,14 +231,12 @@ static long gdml_extract(Detector& description, int argc, char** argv) { TGDMLWrite extract; TUri uri(output.c_str()); description.manager().SetExportPrecision(precision); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,27,1) +#if ROOT_VERSION_CODE > ROOT_VERSION(6,27,1) extract.SetIgnoreDummyMaterial(true); extract.SetNamingSpeed(TGDMLWrite::kfastButUglySufix); extract.WriteGDMLfile(&description.manager(), a._node, uri.GetRelativePart()); -#elif ROOT_VERSION_CODE >= ROOT_VERSION(6,20,0) - extract.WriteGDMLfile(&description.manager(), a._node, uri.GetRelativePart()); #else - extract.WriteGDMLfile(&description.manager(), a._node->GetVolume(), uri.GetRelativePart()); + extract.WriteGDMLfile(&description.manager(), a._node, uri.GetRelativePart()); #endif return 1; } @@ -348,5 +342,3 @@ static Ref_t create_detector(Detector& description, xml_h e, Ref_t /* sens_det * // first argument is the type from the xml file DECLARE_DETELEMENT(DD4hep_GdmlDetector,create_detector) - -#endif diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index a9bdc3c984e165dbaa9520465e6c401ede489d4c..1eb0ca12d8ca24b94d1d77fae00a990b30a54e57 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -41,12 +41,8 @@ // Root/TGeo include files #include <TGeoManager.h> #include <TGeoMaterial.h> -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) #include <TGeoPhysicalConstants.h> -#endif -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) #include <TGDMLMatrix.h> -#endif #include <TMath.h> // C/C++ include files @@ -93,11 +89,9 @@ namespace dd4hep { template <> void Converter<Property>::operator()(xml_h element) const; template <> void Converter<CartesianField>::operator()(xml_h element) const; template <> void Converter<SensitiveDetector>::operator()(xml_h element) const; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) template <> void Converter<OpticalSurface>::operator()(xml_h element) const; template <> void Converter<PropertyTable>::operator()(xml_h element) const; template <> void Converter<PropertyConstant>::operator()(xml_h element) const; -#endif template <> void Converter<DetElement>::operator()(xml_h element) const; template <> void Converter<STD_Conditions>::operator()(xml_h element) const; template <> void Converter<IncludeFile>::operator()(xml_h element) const; @@ -516,10 +510,8 @@ template <> void Converter<Material>::operator()(xml_h e) const { matname, dens_val, temp_val/dd4hep::kelvin, pressure_val/dd4hep::pascal/100.0); mix->SetRadLen(0e0); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) mix->ComputeDerivedQuantities(); -#endif -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) + /// /// In case there were material properties specified: convert them here for(xml_coll_t properties(x_mat, _U(constant)); properties; ++properties) { xml_elt_t p = properties; @@ -576,7 +568,6 @@ template <> void Converter<Material>::operator()(xml_h e) const { throw_print("Compact2Objects[ERROR]: Converting material:" + mname + " Property missing: " + ref); } } -#endif } TGeoMedium* medium = mgr.GetMedium(matname); if (0 == medium) { @@ -740,7 +731,6 @@ template <> void Converter<STD_Conditions>::operator()(xml_h e) const { } } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /** Convert compact optical surface objects (defines) * * @@ -840,7 +830,6 @@ template <> void Converter<OpticalSurface>::operator()(xml_h element) const { surf->GetName(), pname.c_str(), ptyp.c_str()); } } -#endif } /** Convert compact constant property (Material properties stored in TGeoManager) @@ -1449,9 +1438,7 @@ template <> void Converter<DetElement>::operator()(xml_h element) const { throw runtime_error("Failed to execute subdetector creation plugin. " + dbg.missingFactory(type)); } description.addDetector(det); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) description.surfaceManager().registerSurfaces(det); -#endif return; } catch (const exception& e) { @@ -1734,13 +1721,12 @@ template <> void Converter<Compact>::operator()(xml_h element) const { (Converter<Header>(description))(xml_h(compact.child(_U(info)))); xml_coll_t(compact, _U(properties)).for_each(_U(attributes), Converter<Property>(description)); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// These two must be parsed early, because they are needed by the detector constructors xml_coll_t(compact, _U(properties)).for_each(_U(constant), Converter<PropertyConstant>(description)); xml_coll_t(compact, _U(properties)).for_each(_U(matrix), Converter<PropertyTable>(description)); xml_coll_t(compact, _U(properties)).for_each(_U(plugin), Converter<Plugin> (description)); xml_coll_t(compact, _U(surfaces)).for_each(_U(opticalsurface), Converter<OpticalSurface>(description)); -#endif + xml_coll_t(compact, _U(materials)).for_each(_U(element), Converter<Atom>(description)); xml_coll_t(compact, _U(materials)).for_each(_U(material), Converter<Material>(description)); xml_coll_t(compact, _U(materials)).for_each(_U(plugin), Converter<Plugin> (description)); diff --git a/DDCore/src/plugins/ShapePlugins.cpp b/DDCore/src/plugins/ShapePlugins.cpp index 5487c170f312ce818b4be384d39e1159cb217bd6..e2448f589974eed7cb50ff1eb7046eaf98eebc63 100644 --- a/DDCore/src/plugins/ShapePlugins.cpp +++ b/DDCore/src/plugins/ShapePlugins.cpp @@ -25,7 +25,6 @@ #include <fstream> #include <memory> -using namespace std; using namespace dd4hep; using namespace dd4hep::detail; @@ -47,7 +46,7 @@ static Handle<TObject> create_Scaled(Detector&, xml_h e) { xml_dim_t scale(e); Solid shape(xml_comp_t(scale.child(_U(shape))).createShape()); Solid solid = Scale(shape.ptr(), scale.x(1.0), scale.y(1.0), scale.z(1.0)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Scale__shape_constructor,create_Scaled) @@ -67,7 +66,7 @@ DECLARE_XML_SHAPE(Scale__shape_constructor,create_Scaled) static Handle<TObject> create_Assembly(Detector&, xml_h e) { xml_dim_t dim(e); Solid solid = Handle<TNamed>(new TGeoShapeAssembly()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Assembly__shape_constructor,create_Assembly) @@ -87,7 +86,7 @@ DECLARE_XML_SHAPE(Assembly__shape_constructor,create_Assembly) static Handle<TObject> create_Box(Detector&, xml_h e) { xml_dim_t dim(e); Solid solid = Box(dim.dx(),dim.dy(),dim.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Box__shape_constructor,create_Box) @@ -113,7 +112,7 @@ static Handle<TObject> create_HalfSpace(Detector&, xml_h e) { double p[3] = { point.x(), point.y(), point.z()}; double n[3] = { normal.x(), normal.y(), normal.z()}; Solid solid = HalfSpace(p, n); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(HalfSpace__shape_constructor,create_HalfSpace) @@ -134,7 +133,7 @@ static Handle<TObject> create_Cone(Detector&, xml_h element) { xml_dim_t e(element); double rmi1 = e.rmin1(0.0), rma1 = e.rmax1(); Solid solid = Cone(e.z(0.0), rmi1, rma1, e.rmin2(rmi1), e.rmax2(rma1)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Cone__shape_constructor,create_Cone) @@ -159,7 +158,7 @@ DECLARE_XML_SHAPE(Cone__shape_constructor,create_Cone) static Handle<TObject> create_Polycone(Detector&, xml_h element) { xml_dim_t e(element); int num = 0; - vector<double> rmin,rmax,z; + std::vector<double> rmin,rmax,z; double start = e.startphi(0e0), deltaphi = e.deltaphi(2*M_PI); for(xml_coll_t c(e,_U(zplane)); c; ++c, ++num) { xml_comp_t plane(c); @@ -168,10 +167,10 @@ static Handle<TObject> create_Polycone(Detector&, xml_h element) { z.emplace_back(plane.z()); } if ( num < 2 ) { - throw runtime_error("PolyCone Shape> Not enough Z planes. minimum is 2!"); + throw std::runtime_error("PolyCone Shape> Not enough Z planes. minimum is 2!"); } Solid solid = Polycone(start,deltaphi,rmin,rmax,z); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Polycone__shape_constructor,create_Polycone) @@ -215,7 +214,7 @@ static Handle<TObject> create_ConeSegment(Detector&, xml_h element) { /// New naming: angles from [startphi,startphi+deltaphi] solid = ConeSegment(e.dz(),e.rmin1(0.0),e.rmax1(),e.rmin2(0.0),e.rmax2(),start_phi,start_phi+delta_phi); } - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(ConeSegment__shape_constructor,create_ConeSegment) @@ -256,7 +255,7 @@ static Handle<TObject> create_Tube(Detector&, xml_h element) { double phi2 = phi1 + e.deltaphi(2*M_PI); solid = Tube(e.rmin(0.0),e.rmax(),e.dz(0.0),phi1,phi2); } - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Tube__shape_constructor,create_Tube) @@ -284,7 +283,7 @@ static Handle<TObject> create_TwistedTube(Detector&, xml_h element) { } solid = TwistedTube(e.twist(0.0), e.rmin(0.0),e.rmax(),zneg, zpos, nseg, e.deltaphi(2*M_PI)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(TwistedTube__shape_constructor,create_TwistedTube) @@ -306,7 +305,7 @@ static Handle<TObject> create_CutTube(Detector&, xml_h element) { e.attr<double>(_U(tx)), e.attr<double>(_U(ty)), e.attr<double>(_U(tz))); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(CutTube__shape_constructor,create_CutTube) @@ -320,7 +319,7 @@ DECLARE_XML_SHAPE(CutTube__shape_constructor,create_CutTube) static Handle<TObject> create_EllipticalTube(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = EllipticalTube(e.a(),e.b(),e.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(EllipticalTube__shape_constructor,create_EllipticalTube) @@ -338,7 +337,7 @@ static Handle<TObject> create_TruncatedTube(Detector&, xml_h element) { e.attr<double>(xml_tag_t("cutAtStart")), e.attr<double>(xml_tag_t("cutAtDelta")), e.attr<bool>(xml_tag_t("cutInside"))); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(TruncatedTube__shape_constructor,create_TruncatedTube) @@ -379,7 +378,7 @@ static Handle<TObject> create_Trap(Detector&, xml_h element) { double y2 = (attr=element.attr_nothrow(_U(y2))) ? element.attr<double>(attr) : y1; solid = Trap(e.z(0.0),e.theta(0),e.phi(0),y1,x1,x2,e.alpha1(0),y2,x3,x4,e.alpha2(0)); } - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Trap__shape_constructor,create_Trap) @@ -393,7 +392,7 @@ DECLARE_XML_SHAPE(Trap__shape_constructor,create_Trap) static Handle<TObject> create_PseudoTrap(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = PseudoTrap(e.x1(),e.x2(),e.y1(),e.y2(),e.z(),e.radius(),e.attr<bool>(xml_tag_t("minusZ"))); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(PseudoTrap__shape_constructor,create_PseudoTrap) @@ -412,7 +411,7 @@ DECLARE_XML_SHAPE(PseudoTrap__shape_constructor,create_PseudoTrap) static Handle<TObject> create_Trd1(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = Trd1(e.x1(),e.x2(),e.y(),e.z(0.0)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Trd1__shape_constructor,create_Trd1) @@ -431,7 +430,7 @@ DECLARE_XML_SHAPE(Trd1__shape_constructor,create_Trd1) static Handle<TObject> create_Trd2(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = Trd2(e.x1(),e.x2(),e.y1(),e.y2(),e.z(0.0)); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Trapezoid__shape_constructor,create_Trd2) @@ -473,7 +472,7 @@ static Handle<TObject> create_Torus(Detector&, xml_h element) { /// TGeo naming: angles from [startphi,startphi+deltaphi] solid = Torus(e.r(), e.rmin(0.0), e.rmax(), start_phi, delta_phi); } - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Torus__shape_constructor,create_Torus) @@ -519,7 +518,7 @@ static Handle<TObject> create_Sphere(Detector&, xml_h element) { endtheta = starttheta + e.deltatheta(); Solid solid = Sphere(e.rmin(0e0), e.rmax(), starttheta, endtheta, startphi, endphi); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Sphere__shape_constructor,create_Sphere) @@ -538,7 +537,7 @@ DECLARE_XML_SHAPE(Sphere__shape_constructor,create_Sphere) static Handle<TObject> create_Paraboloid(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = Paraboloid(e.rmin(0.0),e.rmax(),e.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Paraboloid__shape_constructor,create_Paraboloid) @@ -559,7 +558,7 @@ DECLARE_XML_SHAPE(Paraboloid__shape_constructor,create_Paraboloid) static Handle<TObject> create_Hyperboloid(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = Hyperboloid(e.rmin(), e.inner_stereo(), e.rmax(), e.outer_stereo(), e.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Hyperboloid__shape_constructor,create_Hyperboloid) @@ -579,7 +578,7 @@ DECLARE_XML_SHAPE(Hyperboloid__shape_constructor,create_Hyperboloid) static Handle<TObject> create_PolyhedraRegular(Detector&, xml_h element) { xml_dim_t e(element); Solid solid = PolyhedraRegular(e.numsides(),e.rmin(),e.rmax(),e.dz()); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(PolyhedraRegular__shape_constructor,create_PolyhedraRegular) @@ -608,7 +607,7 @@ static Handle<TObject> create_Polyhedra(Detector&, xml_h element) { z.emplace_back(plane.z()); } Solid solid = Polyhedra(e.numsides(),e.startphi(),e.deltaphi(),z,rmin,rmax); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(Polyhedra__shape_constructor,create_Polyhedra) @@ -635,7 +634,7 @@ static Handle<TObject> create_ExtrudedPolygon(Detector&, xml_h element) { pt_y.emplace_back(point.attr<double>(_U(y))); } Solid solid = ExtrudedPolygon(pt_x, pt_y, sec_z, sec_x, sec_y, sec_scale); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(ExtrudedPolygon__shape_constructor,create_ExtrudedPolygon) @@ -657,12 +656,11 @@ static Handle<TObject> create_EightPointSolid(Detector&, xml_h element) { v[num][1] = vtx.y(); } Solid solid = EightPointSolid(e.dz(),&v[0][0]); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(EightPointSolid__shape_constructor,create_EightPointSolid) -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) /// Plugin factory to create tessellated shapes /** * @@ -679,7 +677,7 @@ static Handle<TObject> create_TessellatedSolid(Detector&, xml_h element) { int num_facets = 0; for ( xml_coll_t facet(element, _U(facet)); facet; ++facet ) ++num_facets; TessellatedSolid solid = TessellatedSolid(num_facets); - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); for ( xml_coll_t facet(element, _U(facet)); facet; ++facet ) { xml_dim_t f(facet); size_t i0 = f.attr<size_t>(_U(v0)); @@ -696,10 +694,9 @@ static Handle<TObject> create_TessellatedSolid(Detector&, xml_h element) { return solid; } DECLARE_XML_SHAPE(TessellatedSolid__shape_constructor,create_TessellatedSolid) -#endif /** Plugin function for creating a boolean solid from an xml element <shape type=\"BooleanShape\"/>. - * Expects exactly two child elements <shape/> and a string attribute 'operation', which is one of + * Expects exactly two child elements <shape/> and a std::string attribute 'operation', which is one of * 'subtraction', 'union' or 'intersection'. Optionally <position/> and/or <rotation/> can be specified. * More complex boolean solids can be created by nesting the xml elements accordingly. * @@ -793,7 +790,7 @@ static Handle<TObject> create_BooleanShape(Detector&, xml_h element) { std::string(" - needs to be one of 'subtraction','union' or 'intersection' ") ) ; } Solid solid = resultSolid ; - if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<std::string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(BooleanShapeOld__shape_constructor,create_BooleanShape) @@ -812,15 +809,15 @@ static Handle<TObject> create_BooleanMulti(Detector& description, xml_h element) //printout(ALWAYS,"","Boolean shape ---> %s",op.c_str()); for (xml_coll_t i(e ,_U(star)); i; ++i ) { xml_comp_t x_elt = i; - string tag = x_elt.tag(); + std::string tag = x_elt.tag(); if ( tag == "shape" && !result.isValid() ) { result = xml::createShape(description, x_elt.typeStr(), x_elt); - if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr<string>(attr).c_str()); + if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr<std::string>(attr).c_str()); flag = 1; } else if ( tag == "shape" && !solid.isValid() ) { solid = xml::createShape(description, x_elt.typeStr(), x_elt); - if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr<string>(attr).c_str()); + if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr<std::string>(attr).c_str()); flag = 3; } else if ( result.isValid() && solid.isValid() ) { @@ -870,7 +867,7 @@ static Handle<TObject> create_BooleanMulti(Detector& description, xml_h element) result = tmp; trafo = position = rotation = Transform3D(); solid = xml::createShape(description, x_elt.typeStr(), x_elt); - if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr<string>(attr).c_str()); + if ( (attr=i.attr_nothrow(_U(name))) ) result->SetName(i.attr<std::string>(attr).c_str()); flag = 3; } } @@ -893,7 +890,7 @@ static Handle<TObject> create_BooleanMulti(Detector& description, xml_h element) } attr = element.attr_nothrow(_U(name)); if ( attr ) { - string nam = element.attr<string>(attr); + std::string nam = element.attr<std::string>(attr); result->SetName(nam.c_str()); } return result; @@ -920,8 +917,8 @@ DECLARE_XML_VOLUME(DD4hep_StdVolume,create_std_volume) * \version 1.0 */ static Handle<TObject> create_gen_volume(Detector& description, xml_h element) { - xml_dim_t elt = element; - string typ = elt.attr<string>(_U(type)); + xml_dim_t elt = element; + std::string typ = elt.attr<std::string>(_U(type)); return xml::createVolume(description, typ, element); } DECLARE_XML_VOLUME(DD4hep_GenericVolume,create_gen_volume) @@ -943,7 +940,7 @@ TGeoCombiTrans* createPlacement(const Rotation3D& iRot, const Position& iTrans) */ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens) { xml_det_t x_det = e; - string name = x_det.nameStr(); + std::string name = x_det.nameStr(); xml_dim_t x_reflect = x_det.child(_U(reflect), false); DetElement det (name,x_det.id()); Material mat = description.air(); @@ -952,21 +949,21 @@ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens int count = 0; if ( x_det.hasChild(_U(material)) ) { - mat = description.material(x_det.child(_U(material)).attr<string>(_U(name))); + mat = description.material(x_det.child(_U(material)).attr<std::string>(_U(name))); printout(INFO,"TestShape","+++ Volume material is %s", mat.name()); } for ( xml_coll_t itm(e, _U(check)); itm; ++itm, ++count ) { - xml_dim_t x_check = itm; - xml_comp_t shape (x_check.child(_U(shape))); - xml_dim_t pos (x_check.child(_U(position), false)); - xml_dim_t rot (x_check.child(_U(rotation), false)); - bool reflect = x_check.hasChild(_U(reflect)); - bool reflectZ = x_check.hasChild(_U(reflect_z)); - bool reflectY = x_check.hasChild(_U(reflect_y)); - bool reflectX = x_check.hasChild(_U(reflect_x)); - string shape_type = shape.typeStr(); - Solid solid; - Volume volume; + xml_dim_t x_check = itm; + xml_comp_t shape (x_check.child(_U(shape))); + xml_dim_t pos (x_check.child(_U(position), false)); + xml_dim_t rot (x_check.child(_U(rotation), false)); + bool reflect = x_check.hasChild(_U(reflect)); + bool reflectZ = x_check.hasChild(_U(reflect_z)); + bool reflectY = x_check.hasChild(_U(reflect_y)); + bool reflectX = x_check.hasChild(_U(reflect_x)); + std::string shape_type = shape.typeStr(); + Solid solid; + Volume volume; if ( shape_type == "CAD_Assembly" || shape_type == "CAD_MultiVolume" ) { volume = xml::createVolume(description, shape_type, shape); @@ -977,7 +974,7 @@ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens volume = Volume(name+_toString(count,"_vol_%d"),solid, mat); } if ( x_det.hasChild(_U(sensitive)) ) { - string sens_type = x_det.child(_U(sensitive)).attr<string>(_U(type)); + std::string sens_type = x_det.child(_U(sensitive)).attr<std::string>(_U(type)); volume.setSensitiveDetector(sens); sens.setType(sens_type); printout(INFO,"TestShape","+++ Sensitive type is %s", sens_type.c_str()); @@ -1060,12 +1057,10 @@ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens instance_test = isInstance<ExtrudedPolygon>(solid); else if ( 0 == strcasecmp(solid->GetTitle(),SCALE_TAG) ) instance_test = isInstance<Scale>(solid); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if ( 0 == strcasecmp(solid->GetTitle(),TESSELLATEDSOLID_TAG) ) { instance_test = isInstance<TessellatedSolid>(solid); shape_type = TESSELLATEDSOLID_TAG; } -#endif else if ( 0 == strcasecmp(solid->GetTitle(),POLYCONE_TAG) ) instance_test = isInstance<Polycone>(solid); else if ( 0 == strcasecmp(solid->GetTitle(),TWISTEDTUBE_TAG) ) { @@ -1176,7 +1171,7 @@ static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens /// Execute test plugin(s) on the placed volume if desired for ( xml_coll_t itm(e, xml_tag_t("test")); itm; ++itm, ++count ) { xml_comp_t x_test = itm; - string typ = x_test.typeStr(); + std::string typ = x_test.typeStr(); const void* argv[] = { &e, &pv, 0}; Ref_t result = (NamedObject*)PluginService::Create<void*>(typ, &description, 2, (char**)argv); if ( !result.isValid() ) { @@ -1214,8 +1209,8 @@ void* shape_mesh_verifier(Detector& description, int argc, char** argv) { int ref_cr = x_test.hasAttr(_U(create)) ? x_test.attr<int>(_U(create)) : 0; int nseg = x_test.hasAttr(_U(segmentation)) ? x_test.attr<int>(_U(segmentation)) : -1; TString ref = x_test.refStr().c_str(); - string ref_str; - stringstream os; + std::string ref_str; + std::stringstream os; if ( nseg > 0 ) { description.manager().SetNsegments(nseg); @@ -1234,7 +1229,7 @@ void* shape_mesh_verifier(Detector& description, int argc, char** argv) { } gSystem->ExpandPathName(ref); if ( ref_cr ) { - ofstream out(ref, ofstream::out); + std::ofstream out(ref, std::fstream::out); if ( !out.is_open() ) { except("Mesh_Verifier","+++ FAILED to open(WRITE) reference file: "+x_test.refStr()); } @@ -1244,7 +1239,7 @@ void* shape_mesh_verifier(Detector& description, int argc, char** argv) { } else if ( ref.Length() > 0 ) { char c; - ifstream in(ref.Data(), ofstream::in); + std::ifstream in(ref.Data(), std::fstream::in); if ( !in.is_open() ) { except("Mesh_Verifier","+++ FAILED to access reference file: "+x_test.refStr()); } diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index ac92a0d9c9bd7b8dcbac2f57ec469abc50d7122f..bdd409aa308d750fb6086cf43901e29f92e67a18 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -37,10 +37,7 @@ #include <TSystem.h> #include <TClass.h> #include <TRint.h> -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) #include <TGDMLMatrix.h> -#endif - // C/C++ include files #include <cerrno> @@ -279,7 +276,6 @@ DECLARE_APPLY(DD4hep_InteractiveUI,root_ui) static long root_dump_gdml_tables(Detector& description, int /* argc */, char** /* argv */) { size_t num_tables = 0; size_t num_elements = 0; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) const TObjArray* c = description.manager().GetListOfGDMLMatrices(); TObjArrayIter arr(c); printout(INFO,"Dump_GDMLTables","+++ Dumping known GDML tables from TGeoManager."); @@ -289,7 +285,6 @@ static long root_dump_gdml_tables(Detector& description, int /* argc */, char** ++num_tables; gdmlMat->Print(); } -#endif printout(INFO,"Dump_GDMLTables", "+++ Successfully dumped %ld GDML tables with %ld elements.", num_tables, num_elements); @@ -309,7 +304,6 @@ DECLARE_APPLY(DD4hep_Dump_GDMLTables,root_dump_gdml_tables) static long root_dump_optical_surfaces(Detector& description, int /* argc */, char** /* argv */) { size_t num_surfaces = 0; printout(ALWAYS,"",""); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) const TObjArray* c = description.manager().GetListOfOpticalSurfaces(); TObjArrayIter arr(c); printout(ALWAYS,"Dump_OpticalSurfaces","+++ Dumping known Optical Surfaces from TGeoManager."); @@ -318,7 +312,6 @@ static long root_dump_optical_surfaces(Detector& description, int /* argc */, ch ++num_surfaces; optSurt->Print(); } -#endif printout(ALWAYS,"Dump_OpticalSurfaces", "+++ Successfully dumped %ld Optical surfaces.",num_surfaces); return 1; @@ -337,7 +330,6 @@ DECLARE_APPLY(DD4hep_Dump_OpticalSurfaces,root_dump_optical_surfaces) static long root_dump_skin_surfaces(Detector& description, int /* argc */, char** /* argv */) { size_t num_surfaces = 0; printout(ALWAYS,"",""); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) const TObjArray* c = description.manager().GetListOfSkinSurfaces(); TObjArrayIter arr(c); printout(ALWAYS,"Dump_SkinSurfaces","+++ Dumping known Skin Surfaces from TGeoManager."); @@ -346,7 +338,6 @@ static long root_dump_skin_surfaces(Detector& description, int /* argc */, char* ++num_surfaces; skinSurf->Print(); } -#endif printout(ALWAYS,"Dump_SkinSurfaces", "+++ Successfully dumped %ld Skin surfaces.",num_surfaces); return 1; @@ -365,7 +356,6 @@ DECLARE_APPLY(DD4hep_Dump_SkinSurfaces,root_dump_skin_surfaces) static long root_dump_border_surfaces(Detector& description, int /* argc */, char** /* argv */) { size_t num_surfaces = 0; printout(ALWAYS,"",""); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) const TObjArray* c = description.manager().GetListOfBorderSurfaces(); TObjArrayIter arr(c); printout(ALWAYS,"Dump_BorderSurfaces","+++ Dumping known Border Surfaces from TGeoManager."); @@ -374,7 +364,6 @@ static long root_dump_border_surfaces(Detector& description, int /* argc */, cha ++num_surfaces; bordSurt->Print(); } -#endif printout(ALWAYS,"Dump_BorderSurfaces", "+++ Successfully dumped %ld Border surfaces.",num_surfaces); return 1; @@ -562,7 +551,6 @@ static long root_materials(Detector& description, int argc, char** argv) { ::printf(" %-6s Fraction: %7.3f Z=%3d A=%6.2f N=%3d Neff=%6.2f\n", elt->GetName(), frac, elt->Z(), elt->A(), elt->N(), elt->Neff()); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Print material property virtual void printProperty(elt_h, TNamed* prop, TGDMLMatrix* matrix) { if ( matrix ) @@ -572,7 +560,6 @@ static long root_materials(Detector& description, int argc, char** argv) { ::printf(" Property: %-20s [ERROR: NO TABLE!] --> %s\n", prop->GetName(), prop->GetTitle()); } -#endif virtual void operator()(TGeoMaterial* mat) { Double_t* mix = mat->IsMixture() ? ((TGeoMixture*)mat)->GetWmixt() : 0; elt_h mh = print(mat); @@ -580,12 +567,10 @@ static long root_materials(Detector& description, int argc, char** argv) { TGeoElement* elt = mat->GetElement(i); print(mh, elt, mix ? mix[i] : 1); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) TListIter mat_iter(&mat->GetProperties()); for( TObject* i = mat_iter.Next(); i; i=mat_iter.Next() ) { printProperty(mh, (TNamed*)i, description.manager().GetGDMLMatrix(i->GetTitle())); } -#endif } }; /// XML printer to produce XML output @@ -641,13 +626,11 @@ static long root_materials(Detector& description, int argc, char** argv) { elt.setAttr(_U(n),frac); elt.setAttr(_U(ref),element->GetName()); } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) virtual void printProperty(elt_h mat, TNamed* prop, TGDMLMatrix* /* matrix */) { elt_h elt = mat.addChild(_U(property)); elt.setAttr(_U(name),prop->GetName()); elt.setAttr(_U(ref), prop->GetTitle()); } -#endif }; std::string type = "text", output = "", name = ""; diff --git a/DDCore/src/plugins/TGeoCodeGenerator.cpp b/DDCore/src/plugins/TGeoCodeGenerator.cpp index da87aa452cbb16a5a4835323d888f7888b710a51..ea560ea128ecd07d52a540015ad9d1f76d2fcec6 100644 --- a/DDCore/src/plugins/TGeoCodeGenerator.cpp +++ b/DDCore/src/plugins/TGeoCodeGenerator.cpp @@ -10,14 +10,14 @@ // Author : M.Frank // //========================================================================== -#include "DD4hep/Factories.h" -#include "DD4hep/Shapes.h" -#include "DD4hep/Volumes.h" -#include "DD4hep/Detector.h" -#include "DD4hep/MatrixHelpers.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Path.h" +#include <DD4hep/Factories.h> +#include <DD4hep/Shapes.h> +#include <DD4hep/Volumes.h> +#include <DD4hep/Detector.h> +#include <DD4hep/MatrixHelpers.h> +#include <DD4hep/DD4hepUnits.h> +#include <DD4hep/Printout.h> +#include <DD4hep/Path.h> // C/C++ include files #include <stdexcept> @@ -26,12 +26,11 @@ #include <fstream> // ROOT includes -#include "TClass.h" -#include "TGeoMatrix.h" -#include "TGeoBoolNode.h" -#include "TGeoCompositeShape.h" +#include <TClass.h> +#include <TGeoMatrix.h> +#include <TGeoBoolNode.h> +#include <TGeoCompositeShape.h> -using namespace std; using namespace dd4hep; namespace { @@ -57,68 +56,68 @@ namespace { Actor() = default; ~Actor() = default; - ostream& handleHeader (ostream& log); - ostream& handleTrailer (ostream& log); - ostream& handleSolid (ostream& log, const TGeoShape* sh); - ostream& handleMatrix (ostream& log, TGeoMatrix* mat); - ostream& handleElement (ostream& log, TGeoElement* elt); - ostream& handleMaterial (ostream& log, TGeoMedium* mat); - ostream& handlePlacement(ostream& log, TGeoNode* parent, TGeoNode* node); + std::ostream& handleHeader (std::ostream& log); + std::ostream& handleTrailer (std::ostream& log); + std::ostream& handleSolid (std::ostream& log, const TGeoShape* sh); + std::ostream& handleMatrix (std::ostream& log, TGeoMatrix* mat); + std::ostream& handleElement (std::ostream& log, TGeoElement* elt); + std::ostream& handleMaterial (std::ostream& log, TGeoMedium* mat); + std::ostream& handlePlacement(std::ostream& log, TGeoNode* parent, TGeoNode* node); }; typedef void* pvoid_t; - ostream& newline(ostream& log) { - return log << endl << prefix; + std::ostream& newline(std::ostream& log) { + return log << std::endl << prefix; } - ostream& Actor::handleHeader (ostream& log) { - log << "#include \"TClass.h\"" << endl - << "#include \"TGeoNode.h\"" << endl - << "#include \"TGeoExtension.h\"" << endl - << "#include \"TGeoShapeAssembly.h\"" << endl - << "#include \"TGeoMedium.h\"" << endl - << "#include \"TGeoVolume.h\"" << endl - << "#include \"TGeoShape.h\"" << endl - << "#include \"TGeoPhysicalNode.h\"" << endl - << "#include \"TGeoCone.h\"" << endl - << "#include \"TGeoParaboloid.h\"" << endl - << "#include \"TGeoPgon.h\"" << endl - << "#include \"TGeoPcon.h\"" << endl - << "#include \"TGeoSphere.h\"" << endl - << "#include \"TGeoArb8.h\"" << endl - << "#include \"TGeoTrd1.h\"" << endl - << "#include \"TGeoTrd2.h\"" << endl - << "#include \"TGeoTube.h\"" << endl - << "#include \"TGeoEltu.h\"" << endl - << "#include \"TGeoXtru.h\"" << endl - << "#include \"TGeoHype.h\"" << endl - << "#include \"TGeoTorus.h\"" << endl - << "#include \"TGeoHalfSpace.h\"" << endl - << "#include \"TGeoCompositeShape.h\"" << endl - << "#include \"TGeoShapeAssembly.h\"" << endl - << "#include \"TGeoMatrix.h\"" << endl - << "#include \"TGeoBoolNode.h\"" << endl - << "#include \"TGeoCompositeShape.h\"" << endl - << "#include \"TGeoManager.h\"" << endl - << "#include <vector>" << endl - << "#include <map>" << endl - << "#include <set>" << endl << endl << endl; + std::ostream& Actor::handleHeader (std::ostream& log) { + log << "#include \"TClass.h\"" << std::endl + << "#include \"TGeoNode.h\"" << std::endl + << "#include \"TGeoExtension.h\"" << std::endl + << "#include \"TGeoShapeAssembly.h\"" << std::endl + << "#include \"TGeoMedium.h\"" << std::endl + << "#include \"TGeoVolume.h\"" << std::endl + << "#include \"TGeoShape.h\"" << std::endl + << "#include \"TGeoPhysicalNode.h\"" << std::endl + << "#include \"TGeoCone.h\"" << std::endl + << "#include \"TGeoParaboloid.h\"" << std::endl + << "#include \"TGeoPgon.h\"" << std::endl + << "#include \"TGeoPcon.h\"" << std::endl + << "#include \"TGeoSphere.h\"" << std::endl + << "#include \"TGeoArb8.h\"" << std::endl + << "#include \"TGeoTrd1.h\"" << std::endl + << "#include \"TGeoTrd2.h\"" << std::endl + << "#include \"TGeoTube.h\"" << std::endl + << "#include \"TGeoEltu.h\"" << std::endl + << "#include \"TGeoXtru.h\"" << std::endl + << "#include \"TGeoHype.h\"" << std::endl + << "#include \"TGeoTorus.h\"" << std::endl + << "#include \"TGeoHalfSpace.h\"" << std::endl + << "#include \"TGeoCompositeShape.h\"" << std::endl + << "#include \"TGeoShapeAssembly.h\"" << std::endl + << "#include \"TGeoMatrix.h\"" << std::endl + << "#include \"TGeoBoolNode.h\"" << std::endl + << "#include \"TGeoCompositeShape.h\"" << std::endl + << "#include \"TGeoManager.h\"" << std::endl + << "#include <vector>" << std::endl + << "#include <map>" << std::endl + << "#include <set>" << std::endl << std::endl << std::endl; log << "TGeoVolume* generate_geometry() {" << newline; return log; } - ostream& Actor::handleTrailer (ostream& log) { - log << endl << "}" << endl << endl; + std::ostream& Actor::handleTrailer (std::ostream& log) { + log << std::endl << "}" << std::endl << std::endl; log << "void " << function << "() {" << newline << "if ( !gGeoManager ) gGeoManager = new TGeoManager();" << newline << "TGeoVolume* vol_top = generate_geometry();" << newline << "gGeoManager->SetTopVolume(vol_top);" << newline << "vol_top->Draw(\"ogl\");" << newline - << endl << "}" << endl; + << std::endl << "}" << std::endl; return log; } - ostream& Actor::handlePlacement(ostream& log, TGeoNode* parent, TGeoNode* node) { + std::ostream& Actor::handlePlacement(std::ostream& log, TGeoNode* parent, TGeoNode* node) { if ( node && nodes.find(node) == nodes.end() ) { TGeoVolume* vol = node->GetVolume(); TGeoMatrix* mat = node->GetMatrix(); @@ -163,13 +162,13 @@ namespace { << "->GetNode(" << ndau << ");" << newline; } else { - log << "return vol_" << pvoid_t(vol) << ";" << endl; + log << "return vol_" << pvoid_t(vol) << ";" << std::endl; } } return log; } - ostream& Actor::handleElement (ostream& log, TGeoElement* elt) { + std::ostream& Actor::handleElement (std::ostream& log, TGeoElement* elt) { if ( elt && elements.find(elt) == elements.end() ) { elements.insert(elt); log << "TGeoElement* elt_" << pvoid_t(elt) << " = new TGeoElement(\"" @@ -191,7 +190,7 @@ namespace { return log; } - ostream& Actor::handleMaterial(ostream& log, TGeoMedium* medium) { + std::ostream& Actor::handleMaterial(std::ostream& log, TGeoMedium* medium) { if ( medium && materials.find(medium) == materials.end() ) { materials.insert(medium); if ( !dump_mat ) { @@ -218,9 +217,7 @@ namespace { << newline; } mix->SetRadLen(0e0); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) mix->ComputeDerivedQuantities(); -#endif } else { double z = mat->GetZ(), a = mat->GetA(); @@ -245,7 +242,7 @@ namespace { return log; } - ostream& Actor::handleMatrix(ostream& log, TGeoMatrix* mat) { + std::ostream& Actor::handleMatrix(std::ostream& log, TGeoMatrix* mat) { if ( mat && matrices.find(mat) == matrices.end() ) { const Double_t* rot = mat->GetRotationMatrix(); const Double_t* tra = mat->GetTranslation(); @@ -282,7 +279,7 @@ namespace { } /// Pretty print of solid attributes - ostream& Actor::handleSolid(ostream& log, const TGeoShape* shape) { + std::ostream& Actor::handleSolid(std::ostream& log, const TGeoShape* shape) { if ( !shape || solids.find(shape) != solids.end() ) { return log; } @@ -399,7 +396,7 @@ namespace { } else if (cl == TGeoPgon::Class()) { const TGeoPgon* sh = (const TGeoPgon*) shape; - vector<double> params; + std::vector<double> params; params.emplace_back(sh->GetPhi1()); params.emplace_back(sh->GetDphi()); params.emplace_back(double(sh->GetNedges())); @@ -415,7 +412,7 @@ namespace { } else if (cl == TGeoPcon::Class()) { const TGeoPcon* sh = (const TGeoPcon*) shape; - vector<double> params; + std::vector<double> params; params.emplace_back(sh->GetPhi1()); params.emplace_back(sh->GetDphi()); params.emplace_back(double(sh->GetNz())); @@ -534,7 +531,7 @@ namespace { } static long generate_cxx(Detector& description, int argc, char** argv) { - string output; + std::string output; Actor actor; for(int i=0; i<argc; ++i) { @@ -551,21 +548,21 @@ static long generate_cxx(Detector& description, int argc, char** argv) { else if ( c == 'm' ) actor.dump_mat = true; else { - cout << + std::cout << "Usage: -plugin DD4hep_CxxRootGenerator -arg [-arg] \n" " -output <string> Set output file for generated code. Default: stdout \n" " -visualization Also dump visualization attributes of volumes \n" " -materials Also dump proper materials. Default to IRON \n" " -help Show thi help message \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } } - unique_ptr<ofstream> out; - ostream* os = &cout; + std::unique_ptr<std::ofstream> out; + std::ostream* os = &std::cout; if ( !output.empty() ) { Path path(output); - out.reset(new ofstream(path.c_str())); + out.reset(new std::ofstream(path.c_str())); if ( !out->good() ) { out.reset(); except("CxxRootGenerator", @@ -574,7 +571,7 @@ static long generate_cxx(Detector& description, int argc, char** argv) { } os = out.get(); actor.function = path.filename(); - if ( actor.function.rfind('.') != string::npos ) + if ( actor.function.rfind('.') != std::string::npos ) actor.function = actor.function.substr(0, actor.function.rfind('.')); printout(INFO, "CxxRootGenerator", "++ Dump generated code to output files: %s [function: %s()]", diff --git a/DDG4/examples/initAClick.C b/DDG4/examples/initAClick.C index 3051214d855d920298ff072c0c5c3b42ee4fe5b3..38179469f96183feb7f636e7e13f7e89a446064d 100644 --- a/DDG4/examples/initAClick.C +++ b/DDG4/examples/initAClick.C @@ -32,13 +32,9 @@ std::string make_str(const char* data) { int processCommand(const char* command, bool end_process) { int status; // Disabling auto-parse is a hack required by a bug in ROOT -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) gInterpreter->SetClassAutoparsing(false); status = gInterpreter->ProcessLine(command); gInterpreter->SetClassAutoparsing(true); -#else - status = gInterpreter->ProcessLine(command); -#endif ::printf("+++ Status(%s) = %d\n",command,status); if ( end_process ) { gInterpreter->ProcessLine("gSystem->Exit(0)"); diff --git a/DDG4/include/DDG4/Geant4Converter.h b/DDG4/include/DDG4/Geant4Converter.h index acdf9ea167f5a1eb1f72c883d1c9385061284f2c..2abf2721add7b4b9cc47c388f84ead8f08090005 100644 --- a/DDG4/include/DDG4/Geant4Converter.h +++ b/DDG4/include/DDG4/Geant4Converter.h @@ -14,8 +14,8 @@ #define DDG4_GEANT4CONVERTER_H // Framework include files -#include "DD4hep/Printout.h" -#include "DDG4/Geant4Mapping.h" +#include <DD4hep/Printout.h> +#include <DDG4/Geant4Mapping.h> /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -72,7 +72,6 @@ namespace dd4hep { /// Create geometry conversion Geant4Converter& create(DetElement top); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Convert the geometry type material into the corresponding Geant4 object(s). virtual void* handleMaterialProperties(TObject* matrix) const; @@ -84,7 +83,7 @@ namespace dd4hep { /// Convert the border surface to Geant4 void* handleBorderSurface(TObject* surface) const; -#endif + /// Convert the geometry type material into the corresponding Geant4 object(s). virtual void* handleMaterial(const std::string& name, Material medium) const; @@ -128,5 +127,4 @@ namespace dd4hep { }; } // End namespace sim } // End namespace dd4hep - #endif // DDG4_GEANT4CONVERTER_H diff --git a/DDG4/include/DDG4/Geant4GeometryInfo.h b/DDG4/include/DDG4/Geant4GeometryInfo.h index 9b58046305aa7d9ea6d506500d9f85781d45eeb1..31b6aa6e3f2588471306527a0516038b99be4be8 100644 --- a/DDG4/include/DDG4/Geant4GeometryInfo.h +++ b/DDG4/include/DDG4/Geant4GeometryInfo.h @@ -10,16 +10,15 @@ // Author : M.Frank // //========================================================================== - #ifndef DDG4_GEANT4GEOMETRYINFO_H #define DDG4_GEANT4GEOMETRYINFO_H // Framework include files -#include "DD4hep/Objects.h" -#include "DD4hep/Printout.h" -#include "DD4hep/GeoHandler.h" -#include "DD4hep/PropertyTable.h" -#include "DDG4/Geant4Primitives.h" +#include <DD4hep/Objects.h> +#include <DD4hep/Printout.h> +#include <DD4hep/GeoHandler.h> +#include <DD4hep/PropertyTable.h> +#include <DDG4/Geant4Primitives.h> // C/C++ include files #include <map> @@ -127,12 +126,10 @@ namespace dd4hep { PropertyVector() = default; ~PropertyVector() = default; }; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) std::map<PropertyTable, PropertyVector*> g4OpticalProperties; std::map<OpticalSurface, G4OpticalSurface*> g4OpticalSurfaces; std::map<SkinSurface, G4LogicalSkinSurface*> g4SkinSurfaces; std::map<BorderSurface, G4LogicalBorderSurface*> g4BorderSurfaces; -#endif std::map<Region, G4Region*> g4Regions; std::map<VisAttr, G4VisAttributes*> g4Vis; std::map<LimitSet, G4UserLimits*> g4Limits; @@ -160,5 +157,4 @@ namespace dd4hep { } // End namespace sim } // End namespace dd4hep - #endif // DDG4_GEANT4GEOMETRYINFO_H diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index edb4402ac3330d2890265a9fcc57e01ea3ceff8f..1e00a3143e6f412020de164cac8643a69ee43932 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -81,7 +81,6 @@ namespace units = dd4hep; using namespace dd4hep::sim; using namespace dd4hep; -using namespace std; namespace { @@ -92,7 +91,7 @@ namespace { static constexpr const char* GEANT4_TAG_MEE = "MeanExcitationEnergy"; static constexpr const char* GEANT4_TAG_ENE_PER_ION_PAIR = "MeanEnergyPerIonPair"; - static string indent = ""; + static std::string indent = ""; template <typename O, typename C, typename F> void handleRefs(const O* o, const C& c, F pmf) { for (typename C::const_iterator i = c.begin(); i != c.end(); ++i) { @@ -120,7 +119,7 @@ namespace { template <typename O, typename C, typename F> void handleRMap(const O* o, const C& c, F pmf) { for (typename C::const_reverse_iterator i = c.rbegin(); i != c.rend(); ++i) { - //cout << "Handle RMAP [ " << (*i).first << " ]" << endl; + //cout << "Handle RMAP [ " << (*i).first << " ]" << std::endl; handle(o, (*i).second, pmf); } } @@ -133,8 +132,8 @@ namespace { } } - string make_NCName(const string& in) { - string res = detail::str_replace(in, "/", "_"); + std::string make_NCName(const std::string& in) { + std::string res = detail::str_replace(in, "/", "_"); res = detail::str_replace(res, "#", "_"); return res; } @@ -154,7 +153,7 @@ namespace { public: Region region; double threshold; - bool storeSecondaries; + bool storeSecondaries; G4UserRegionInformation() : threshold(0.0), storeSecondaries(false) { } @@ -166,40 +165,40 @@ namespace { } }; - pair<double,double> g4PropertyConversion(int index) { + std::pair<double,double> g4PropertyConversion(int index) { #if G4VERSION_NUMBER >= 1040 switch(index) { - case kRINDEX: return make_pair(CLHEP::keV/units::keV, 1.0); - case kREFLECTIVITY: return make_pair(CLHEP::keV/units::keV, 1.0); - case kREALRINDEX: return make_pair(CLHEP::keV/units::keV, 1.0); - case kIMAGINARYRINDEX: return make_pair(CLHEP::keV/units::keV, 1.0); - case kEFFICIENCY: return make_pair(CLHEP::keV/units::keV, 1.0); - case kTRANSMITTANCE: return make_pair(CLHEP::keV/units::keV, 1.0); - case kSPECULARLOBECONSTANT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kSPECULARSPIKECONSTANT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kBACKSCATTERCONSTANT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kGROUPVEL: return make_pair(CLHEP::keV/units::keV, (CLHEP::m/CLHEP::s)/(units::m/units::s)); // meter/second - case kMIEHG: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); - case kRAYLEIGH: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); // ??? says its a length - case kWLSCOMPONENT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kWLSABSLENGTH: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); - case kABSLENGTH: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); + case kRINDEX: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kREFLECTIVITY: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kREALRINDEX: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kIMAGINARYRINDEX: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kEFFICIENCY: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kTRANSMITTANCE: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kSPECULARLOBECONSTANT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kSPECULARSPIKECONSTANT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kBACKSCATTERCONSTANT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kGROUPVEL: return std::make_pair(CLHEP::keV/units::keV, (CLHEP::m/CLHEP::s)/(units::m/units::s)); // meter/second + case kMIEHG: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); + case kRAYLEIGH: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); // ??? says its a length + case kWLSCOMPONENT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kWLSABSLENGTH: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); + case kABSLENGTH: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); #if G4VERSION_NUMBER >= 1100 - case kWLSCOMPONENT2: return make_pair(CLHEP::keV/units::keV, 1.0); - case kWLSABSLENGTH2: return make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); - case kSCINTILLATIONCOMPONENT1: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kSCINTILLATIONCOMPONENT2: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kSCINTILLATIONCOMPONENT3: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kWLSCOMPONENT2: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kWLSABSLENGTH2: return std::make_pair(CLHEP::keV/units::keV, CLHEP::m/units::m); + case kSCINTILLATIONCOMPONENT1: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kSCINTILLATIONCOMPONENT2: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kSCINTILLATIONCOMPONENT3: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); #else - case kFASTCOMPONENT: return make_pair(CLHEP::keV/units::keV, 1.0); - case kSLOWCOMPONENT: return make_pair(CLHEP::keV/units::keV, 1.0); + case kFASTCOMPONENT: return std::make_pair(CLHEP::keV/units::keV, 1.0); + case kSLOWCOMPONENT: return std::make_pair(CLHEP::keV/units::keV, 1.0); #endif - case kPROTONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); // Yields: 1/energy - case kDEUTERONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kTRITONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kALPHASCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kIONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); - case kELECTRONSCINTILLATIONYIELD: return make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kPROTONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); // Yields: 1/energy + case kDEUTERONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kTRITONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kALPHASCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kIONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); + case kELECTRONSCINTILLATIONYIELD: return std::make_pair(CLHEP::keV/units::keV, units::keV/CLHEP::keV); default: break; } @@ -207,7 +206,7 @@ namespace { #else printout(FATAL,"Geant4Converter", "+++ Cannot convert material property with index: %d [Need Geant4 > 10.03]", index); #endif - return make_pair(0e0,0e0); + return std::make_pair(0e0,0e0); } double g4ConstPropertyConversion(int index) { @@ -306,7 +305,7 @@ Geant4Converter::~Geant4Converter() { } /// Handle the conversion of isotopes -void* Geant4Converter::handleIsotope(const string& /* name */, const TGeoIsotope* iso) const { +void* Geant4Converter::handleIsotope(const std::string& /* name */, const TGeoIsotope* iso) const { G4Isotope* g4i = data().g4Isotopes[iso]; if ( !g4i ) { double a_conv = (CLHEP::g / CLHEP::mole); @@ -320,7 +319,7 @@ void* Geant4Converter::handleIsotope(const string& /* name */, const TGeoIsotope } /// Handle the conversion of elements -void* Geant4Converter::handleElement(const string& name, const Atom element) const { +void* Geant4Converter::handleElement(const std::string& name, const Atom element) const { G4Element* g4e = data().g4Elements[element]; if ( !g4e ) { PrintLevel lvl = debugElements ? ALWAYS : outputLevel; @@ -339,8 +338,8 @@ void* Geant4Converter::handleElement(const string& name, const Atom element) con printout(lvl, "Geant4Converter", "++ Created G4 Isotope %s from data: Z=%d N=%d A=%.3f [g/mole]", element->GetName(), element->Z(), element->N(), element->A()); } - stringstream str; - str << (*g4e) << endl; + std::stringstream str; + str << (*g4e) << std::endl; printout(lvl, "Geant4Converter", "++ Created G4 element %s", str.str().c_str()); data().g4Elements[element] = g4e; } @@ -348,7 +347,7 @@ void* Geant4Converter::handleElement(const string& name, const Atom element) con } /// Dump material in GDML format to output stream -void* Geant4Converter::handleMaterial(const string& name, Material medium) const { +void* Geant4Converter::handleMaterial(const std::string& name, Material medium) const { Geant4GeometryInfo& info = data(); G4Material* mat = info.g4Materials[medium]; if ( !mat ) { @@ -405,18 +404,17 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const material->GetTemperature(), material->GetPressure()); } - string plugin_name { }; + std::string plugin_name { }; double value = 0e0; double ionisation_mee = -2e100; double ionisation_birks_constant = -2e100; double ionisation_ene_per_ion_pair = -2e100; -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Attach the material properties if any G4MaterialPropertiesTable* tab = 0; TListIter propIt(&material->GetProperties()); for(TObject* obj=propIt.Next(); obj; obj = propIt.Next()) { - string exc_str; + std::string exc_str; TNamed* named = (TNamed*)obj; TGDMLMatrix* matrix = info.manager->GetGDMLMatrix(named->GetTitle()); const char* cptr = ::strstr(matrix->GetName(), GEANT4_TAG_IGNORE); @@ -460,7 +458,7 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const } // We need to convert the property from TGeo units to Geant4 units auto conv = g4PropertyConversion(idx); - vector<double> bins(v->bins), vals(v->values); + std::vector<double> bins(v->bins), vals(v->values); for(std::size_t i=0, count=bins.size(); i<count; ++i) bins[i] *= conv.first, vals[i] *= conv.second; @@ -477,7 +475,7 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const /// Attach the material properties if any TListIter cpropIt(&material->GetConstProperties()); for(TObject* obj=cpropIt.Next(); obj; obj = cpropIt.Next()) { - string exc_str; + std::string exc_str; Bool_t err = kFALSE; TNamed* named = (TNamed*)obj; @@ -555,10 +553,10 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const printout(lvl, name, "++ CONST Property: %-20s %g ", named->GetName(), value); tab->AddConstProperty(named->GetName(), value * conv); } -#endif + // // Set Birk's constant if it was supplied in the material table of the TGeoMaterial auto* ionisation = mat->GetIonisation(); - stringstream str; + std::stringstream str; str << (*mat); if ( ionisation ) { if ( ionisation_birks_constant > 0e0 ) { @@ -596,7 +594,7 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const } /// Dump solid in GDML format to output stream -void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) const { +void* Geant4Converter::handleSolid(const std::string& name, const TGeoShape* shape) const { G4VSolid* solid = nullptr; if ( shape ) { if ( nullptr != (solid = data().g4Solids[shape]) ) { @@ -650,10 +648,8 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c solid = convertShape<TGeoArb8>(shape); else if (isa == TGeoPara::Class()) solid = convertShape<TGeoPara>(shape); -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if (isa == TGeoTessellated::Class()) solid = convertShape<TGeoTessellated>(shape); -#endif else if (isa == TGeoScaledShape::Class()) { TGeoScaledShape* sh = (TGeoScaledShape*) shape; TGeoShape* sol = sh->GetShape(); @@ -743,7 +739,7 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c } /// Dump logical volume in GDML format to output stream -void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume) const { +void* Geant4Converter::handleVolume(const std::string& name, const TGeoVolume* volume) const { Volume _v(volume); Geant4GeometryInfo& info = data(); PrintLevel lvl = debugVolumes ? ALWAYS : outputLevel; @@ -791,7 +787,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume G4LogicalVolume* g4vol = nullptr; if ( _v.hasProperties() && !_v.getProperty(GEANT4_TAG_PLUGIN,"").empty() ) { Detector* det = const_cast<Detector*>(&m_detDesc); - string plugin = _v.getProperty(GEANT4_TAG_PLUGIN,""); + std::string plugin = _v.getProperty(GEANT4_TAG_PLUGIN,""); g4vol = PluginService::Create<G4LogicalVolume*>(plugin, det, _v, g4solid, g4medium); if ( !g4vol ) { except("G4Cnv::volume["+name+"]","++ FATAL Failed to call plugin to create logical volume."); @@ -846,7 +842,7 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume } /// Dump logical volume in GDML format to output stream -void* Geant4Converter::collectVolume(const string& /* name */, const TGeoVolume* volume) const { +void* Geant4Converter::collectVolume(const std::string& /* name */, const TGeoVolume* volume) const { Geant4GeometryInfo& info = data(); Volume _v(volume); Region reg = _v.region(); @@ -866,7 +862,7 @@ void* Geant4Converter::collectVolume(const string& /* name */, const TGeoVolume* } /// Dump volume placement in GDML format to output stream -void* Geant4Converter::handleAssembly(const string& name, const TGeoNode* node) const { +void* Geant4Converter::handleAssembly(const std::string& name, const TGeoNode* node) const { TGeoVolume* mot_vol = node->GetVolume(); PrintLevel lvl = debugVolumes ? ALWAYS : outputLevel; if ( mot_vol->IsA() != TGeoVolumeAssembly::Class() ) { @@ -939,7 +935,7 @@ void* Geant4Converter::handleAssembly(const string& name, const TGeoNode* node) } /// Dump volume placement in GDML format to output stream -void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) const { +void* Geant4Converter::handlePlacement(const std::string& name, const TGeoNode* node) const { Geant4GeometryInfo& info = data(); PrintLevel lvl = debugPlacements ? ALWAYS : outputLevel; Geant4GeometryMaps::PlacementMap::const_iterator g4it = info.g4Placements.find(node); @@ -1008,7 +1004,7 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) return nullptr; } else if ( node != info.manager->GetTopNode() && volIt == info.g4Volumes.end() ) { - throw logic_error("Geant4Converter: Invalid mother volume found!"); + throw std::logic_error("Geant4Converter: Invalid mother volume found!"); } PlacedVolume pv(node); const auto* pv_data = pv.data(); @@ -1108,7 +1104,7 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) } /// Convert the geometry type region into the corresponding Geant4 object(s). -void* Geant4Converter::handleRegion(Region region, const set<const TGeoVolume*>& /* volumes */) const { +void* Geant4Converter::handleRegion(Region region, const std::set<const TGeoVolume*>& /* volumes */) const { G4Region* g4 = data().g4Regions[region]; if ( !g4 ) { PrintLevel lvl = debugRegions ? ALWAYS : outputLevel; @@ -1117,7 +1113,7 @@ void* Geant4Converter::handleRegion(Region region, const set<const TGeoVolume*>& // create region info with storeSecondaries flag if( not r.wasThresholdSet() and r.storeSecondaries() ) { - throw runtime_error("G4Region: StoreSecondaries is True, but no explicit threshold set:"); + throw std::runtime_error("G4Region: StoreSecondaries is True, but no explicit threshold set:"); } printout(lvl, "Geant4Converter", "++ Setting up region: %s", r.name()); G4UserRegionInformation* info = new G4UserRegionInformation(); @@ -1127,7 +1123,7 @@ void* Geant4Converter::handleRegion(Region region, const set<const TGeoVolume*>& g4->SetUserInformation(info); printout(lvl, "Geant4Converter", "++ Converted region settings of:%s.", r.name()); - vector < string > &limits = r.limits(); + std::vector < std::string > &limits = r.limits(); G4ProductionCuts* cuts = 0; // set production cut if( not r.useDefaultCut() ) { @@ -1149,7 +1145,7 @@ void* Geant4Converter::handleRegion(Region region, const set<const TGeoVolume*>& else if ( c.particles == "e[-+]" ) pid = -idxG4PositronCut-idxG4ElectronCut; else if ( c.particles == "gamma" ) pid = idxG4GammaCut; else if ( c.particles == "proton" ) pid = idxG4ProtonCut; - else throw runtime_error("G4Region: Invalid production cut particle-type:" + c.particles); + else throw std::runtime_error("G4Region: Invalid production cut particle-type:" + c.particles); if ( !cuts ) cuts = new G4ProductionCuts(); if ( pid == -(idxG4PositronCut+idxG4ElectronCut) ) { cuts->SetProductionCut(c.value*CLHEP::mm/units::mm, idxG4PositronCut); @@ -1186,7 +1182,7 @@ void* Geant4Converter::handleRegion(Region region, const set<const TGeoVolume*>& } /// Convert the geometry type LimitSet into the corresponding Geant4 object(s). -void* Geant4Converter::handleLimitSet(LimitSet limitset, const set<const TGeoVolume*>& /* volumes */) const { +void* Geant4Converter::handleLimitSet(LimitSet limitset, const std::set<const TGeoVolume*>& /* volumes */) const { G4UserLimits* g4 = data().g4Limits[limitset]; if ( !g4 ) { PrintLevel lvl = debugLimits || debugRegions ? ALWAYS : outputLevel; @@ -1228,7 +1224,7 @@ void* Geant4Converter::handleLimitSet(LimitSet limitset, const set<const TGeoVol } /// Convert the geometry visualisation attributes to the corresponding Geant4 object(s). -void* Geant4Converter::handleVis(const string& /* name */, VisAttr attr) const { +void* Geant4Converter::handleVis(const std::string& /* name */, VisAttr attr) const { Geant4GeometryInfo& info = data(); G4VisAttributes* g4 = info.g4Vis[attr]; if ( !g4 ) { @@ -1255,35 +1251,34 @@ void* Geant4Converter::handleVis(const string& /* name */, VisAttr attr) const { /// Handle the geant 4 specific properties void Geant4Converter::handleProperties(Detector::Properties& prp) const { - map < string, string > processors; + std::map < std::string, std::string > processors; static int s_idd = 9999999; for( const auto& [nam, vals] : prp ) { if ( nam.substr(0, 6) == "geant4" ) { auto id_it = vals.find("id"); - string id = (id_it == vals.end()) ? _toString(++s_idd,"%d") : (*id_it).second; + std::string id = (id_it == vals.end()) ? _toString(++s_idd,"%d") : (*id_it).second; processors.emplace(id, nam); } } for( const auto& p : processors ) { const GeoHandler* hdlr = this; const Detector::PropertyValues& vals = prp[p.second]; - string type = vals.find("type")->second; - string tag = type + "_Geant4_action"; + std::string type = vals.find("type")->second; + std::string tag = type + "_Geant4_action"; Detector* det = const_cast<Detector*>(&m_detDesc); long res = PluginService::Create<long>(tag, det, hdlr, &vals); if ( 0 == res ) { - throw runtime_error("Failed to locate plugin to interprete files of type" - " \"" + tag + "\" - no factory:" + type); + throw std::runtime_error("Failed to locate plugin to interprete files of type" + " \"" + tag + "\" - no factory:" + type); } res = *(long*)res; if ( res != 1 ) { - throw runtime_error("Failed to invoke the plugin " + tag + " of type " + type); + throw std::runtime_error("Failed to invoke the plugin " + tag + " of type " + type); } printout(outputLevel, "Geant4Converter", "+++++ Executed Successfully Geant4 setup module *%s*.", type.c_str()); } } -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Convert the geometry type material into the corresponding Geant4 object(s). void* Geant4Converter::handleMaterialProperties(TObject* mtx) const { Geant4GeometryInfo& info = data(); @@ -1422,7 +1417,7 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { G4SurfaceType type = geant4_surface_type(optSurf->GetType()); G4OpticalSurfaceModel model = geant4_surface_model(optSurf->GetModel()); G4OpticalSurfaceFinish finish = geant4_surface_finish(optSurf->GetFinish()); - string name = make_NCName(optSurf->GetName()); + std::string name = make_NCName(optSurf->GetName()); PrintLevel lvl = debugSurfaces ? ALWAYS : DEBUG; g4 = new G4OpticalSurface(name, model, finish, type, optSurf->GetValue()); g4->SetSigmaAlpha(optSurf->GetSigmaAlpha()); @@ -1440,7 +1435,7 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { G4MaterialPropertiesTable* tab = nullptr; TListIter itp(&optSurf->GetProperties()); for(TObject* obj = itp.Next(); obj; obj = itp.Next()) { - string exc_str; + std::string exc_str; TNamed* named = (TNamed*)obj; TGDMLMatrix* matrix = info.manager->GetGDMLMatrix(named->GetTitle()); const char* cptr = ::strstr(matrix->GetName(), GEANT4_TAG_IGNORE); @@ -1475,7 +1470,7 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { } // We need to convert the property from TGeo units to Geant4 units auto conv = g4PropertyConversion(idx); - vector<double> bins(v->bins), vals(v->values); + std::vector<double> bins(v->bins), vals(v->values); for(std::size_t i=0, count=v->bins.size(); i<count; ++i) bins[i] *= conv.first, vals[i] *= conv.second; G4MaterialPropertyVector* vec = new G4MaterialPropertyVector(&bins[0], &vals[0], bins.size()); @@ -1494,7 +1489,7 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { #if ROOT_VERSION_CODE >= ROOT_VERSION(6,31,1) TListIter itc(&optSurf->GetConstProperties()); for(TObject* obj = itc.Next(); obj; obj = itc.Next()) { - string exc_str; + std::string exc_str; TNamed* named = (TNamed*)obj; const char* cptr = ::strstr(named->GetName(), GEANT4_TAG_IGNORE); if ( nullptr != cptr ) { @@ -1554,7 +1549,7 @@ void* Geant4Converter::handleSkinSurface(TObject* surface) const { if ( !g4 ) { G4OpticalSurface* optSurf = info.g4OpticalSurfaces[OpticalSurface(surf->GetSurface())]; G4LogicalVolume* v = info.g4Volumes[surf->GetVolume()]; - string name = make_NCName(surf->GetName()); + std::string name = make_NCName(surf->GetName()); g4 = new G4LogicalSkinSurface(name, v, optSurf); printout(debugSurfaces ? ALWAYS : DEBUG, "Geant4Converter", "++ Created SkinSurface: %-18s optical:%s", @@ -1573,7 +1568,7 @@ void* Geant4Converter::handleBorderSurface(TObject* surface) const { G4OpticalSurface* optSurf = info.g4OpticalSurfaces[OpticalSurface(surf->GetSurface())]; G4VPhysicalVolume* n1 = info.g4Placements[surf->GetNode1()]; G4VPhysicalVolume* n2 = info.g4Placements[surf->GetNode2()]; - string name = make_NCName(surf->GetName()); + std::string name = make_NCName(surf->GetName()); g4 = new G4LogicalBorderSurface(name, n1, n2, optSurf); printout(debugSurfaces ? ALWAYS : DEBUG, "Geant4Converter", "++ Created BorderSurface: %-18s optical:%s", @@ -1582,38 +1577,38 @@ void* Geant4Converter::handleBorderSurface(TObject* surface) const { } return g4; } -#endif /// Convert the geometry type SensitiveDetector into the corresponding Geant4 object(s). -void Geant4Converter::printSensitive(SensitiveDetector sens_det, const set<const TGeoVolume*>& /* volumes */) const { - Geant4GeometryInfo& info = data(); - set<const TGeoVolume*>& volset = info.sensitives[sens_det]; - SensitiveDetector sd = sens_det; - stringstream str; +void Geant4Converter::printSensitive(SensitiveDetector sens_det, const std::set<const TGeoVolume*>& /* volumes */) const { + Geant4GeometryInfo& info = data(); + std::set<const TGeoVolume*>& volset = info.sensitives[sens_det]; + SensitiveDetector sd = sens_det; + std::stringstream str; printout(INFO, "Geant4Converter", "++ SensitiveDetector: %-18s %-20s Hits:%-16s", sd.name(), ("[" + sd.type() + "]").c_str(), sd.hitsCollection().c_str()); - str << " | " << "Cutoff:" << setw(6) << left << sd.energyCutoff() << setw(5) << right << volset.size() + str << " | " << "Cutoff:" << std::setw(6) << std::left + << sd.energyCutoff() << std::setw(5) << std::right << volset.size() << " volumes "; if (sd.region().isValid()) - str << " Region:" << setw(12) << left << sd.region().name(); + str << " Region:" << std::setw(12) << std::left << sd.region().name(); if (sd.limits().isValid()) - str << " Limits:" << setw(12) << left << sd.limits().name(); + str << " Limits:" << std::setw(12) << std::left << sd.limits().name(); str << "."; printout(INFO, "Geant4Converter", str.str().c_str()); for (const auto i : volset ) { - map<Volume, G4LogicalVolume*>::iterator v = info.g4Volumes.find(i); + std::map<Volume, G4LogicalVolume*>::iterator v = info.g4Volumes.find(i); G4LogicalVolume* vol = (*v).second; str.str(""); - str << " | " << "Volume:" << setw(24) << left << vol->GetName() << " " + str << " | " << "Volume:" << std::setw(24) << std::left << vol->GetName() << " " << vol->GetNoDaughters() << " daughters."; printout(INFO, "Geant4Converter", str.str().c_str()); } } -string printSolid(G4VSolid* sol) { - stringstream str; +std::string printSolid(G4VSolid* sol) { + std::stringstream str; if (typeid(*sol) == typeid(G4Box)) { const G4Box* b = (G4Box*) sol; str << "++ Box: x=" << b->GetXHalfLength() << " y=" << b->GetYHalfLength() << " z=" << b->GetZHalfLength(); @@ -1627,7 +1622,7 @@ string printSolid(G4VSolid* sol) { } /// Print G4 placement -void* Geant4Converter::printPlacement(const string& name, const TGeoNode* node) const { +void* Geant4Converter::printPlacement(const std::string& name, const TGeoNode* node) const { Geant4GeometryInfo& info = data(); G4VPhysicalVolume* g4 = info.g4Placements[node]; G4LogicalVolume* vol = info.g4Volumes[node->GetVolume()]; @@ -1638,7 +1633,7 @@ void* Geant4Converter::printPlacement(const string& name, const TGeoNode* node) if ( !sd ) { return g4; } - stringstream str; + std::stringstream str; str << "G4Cnv::placement: + " << name << " No:" << node->GetNumber() << " Vol:" << vol->GetName() << " Solid:" << sol->GetName(); printout(outputLevel, "G4Placement", str.str().c_str()); @@ -1667,10 +1662,8 @@ Geant4Converter& Geant4Converter::create(DetElement top) { // We do not have to handle defines etc. // All positions and the like are not really named. // Hence, start creating the G4 objects for materials, solids and log volumes. -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) handleArray(this, geo.manager->GetListOfGDMLMatrices(), &Geant4Converter::handleMaterialProperties); handleArray(this, geo.manager->GetListOfOpticalSurfaces(), &Geant4Converter::handleOpticalSurface); -#endif handle(this, geo.volumes, &Geant4Converter::collectVolume); handle(this, geo.solids, &Geant4Converter::handleSolid); @@ -1686,11 +1679,9 @@ Geant4Converter& Geant4Converter::create(DetElement top) { handleRMap(this, *m_data, &Geant4Converter::handleAssembly); // Now place all this stuff appropriately handleRMap(this, *m_data, &Geant4Converter::handlePlacement); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) /// Handle concrete surfaces handleArray(this, geo.manager->GetListOfSkinSurfaces(), &Geant4Converter::handleSkinSurface); handleArray(this, geo.manager->GetListOfBorderSurfaces(), &Geant4Converter::handleBorderSurface); -#endif //==================== Fields handleProperties(m_detDesc.properties()); if ( printSensitives ) { diff --git a/DDG4/src/Geant4Data.cpp b/DDG4/src/Geant4Data.cpp index f97c565f464cc5c5dd73dfe5f5d51c57eaa59b5f..4d57b09ca5685cd5b3f368654e223e32aa6e6308 100644 --- a/DDG4/src/Geant4Data.cpp +++ b/DDG4/src/Geant4Data.cpp @@ -24,7 +24,6 @@ #include <G4Allocator.hh> #include <G4OpticalPhoton.hh> -using namespace std; using namespace dd4hep; using namespace dd4hep::sim; diff --git a/DDG4/src/Geant4DataConversion.cpp b/DDG4/src/Geant4DataConversion.cpp index b1982dffcfccfdd737f89bb2b2b5d32aba565ee2..40472cd4d0c8b132501564de368508d7b65fac98 100644 --- a/DDG4/src/Geant4DataConversion.cpp +++ b/DDG4/src/Geant4DataConversion.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DDG4/Geant4DataConversion.h" +#include <DDG4/Geant4DataConversion.h> using namespace dd4hep::sim; diff --git a/DDG4/src/Geant4DataDump.cpp b/DDG4/src/Geant4DataDump.cpp index a92f01f933e3c00930b651ce80df5d4b62351651..f07fefa7c2cf173e517960e69a31bbaf68bdb3fd 100644 --- a/DDG4/src/Geant4DataDump.cpp +++ b/DDG4/src/Geant4DataDump.cpp @@ -12,10 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/Primitives.h" -#include "DDG4/Geant4DataDump.h" +#include <DD4hep/Primitives.h> +#include <DDG4/Geant4DataDump.h> -using namespace std; using namespace dd4hep; using namespace dd4hep::sim; diff --git a/DDG4/src/Geant4DetectorConstruction.cpp b/DDG4/src/Geant4DetectorConstruction.cpp index 1a74a2a268613abd4f2cb44a52634aa72f43c70b..1eddbf98953ead03003f27c41de055b08e2b181d 100644 --- a/DDG4/src/Geant4DetectorConstruction.cpp +++ b/DDG4/src/Geant4DetectorConstruction.cpp @@ -12,13 +12,13 @@ //========================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4Mapping.h" -#include "DDG4/Geant4GeometryInfo.h" -#include "DDG4/Geant4DetectorConstruction.h" +#include <DD4hep/InstanceCount.h> +#include <DDG4/Geant4Mapping.h> +#include <DDG4/Geant4GeometryInfo.h> +#include <DDG4/Geant4DetectorConstruction.h> -#include "G4VUserDetectorConstruction.hh" -#include "G4SDManager.hh" +#include <G4VUserDetectorConstruction.hh> +#include <G4SDManager.hh> using namespace std; using namespace dd4hep; @@ -114,63 +114,63 @@ void Geant4DetectorConstructionSequence::constructSensitives(Geant4DetectorConst const map<Region, G4Region*>& Geant4DetectorConstructionSequence::regions() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Regions; - throw runtime_error("+++ Geant4DetectorConstructionSequence::regions: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::regions: Access not possible. Geometry is not yet converted!"); } #if 0 /// Access to the converted sensitive detectors const Geant4GeometryMaps::SensDetMap& Geant4DetectorConstructionSequence::sensitives() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4SensDets; - throw runtime_error("+++ Geant4DetectorConstructionSequence::sensitives: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::sensitives: Access not possible. Geometry is not yet converted!"); } #endif /// Access to the converted volumes const map<Volume, G4LogicalVolume*>& Geant4DetectorConstructionSequence::volumes() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Volumes; - throw runtime_error("+++ Geant4DetectorConstructionSequence::volumes: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::volumes: Access not possible. Geometry is not yet converted!"); } /// Access to the converted shapes const map<const TGeoShape*, G4VSolid*>& Geant4DetectorConstructionSequence::shapes() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Solids; - throw runtime_error("+++ Geant4DetectorConstructionSequence::shapes: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::shapes: Access not possible. Geometry is not yet converted!"); } /// Access to the converted limit sets const map<LimitSet, G4UserLimits*>& Geant4DetectorConstructionSequence::limits() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Limits; - throw runtime_error("+++ Geant4DetectorConstructionSequence::limits: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::limits: Access not possible. Geometry is not yet converted!"); } /// Access to the converted assemblies const map<PlacedVolume, Geant4AssemblyVolume*>& Geant4DetectorConstructionSequence::assemblies() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4AssemblyVolumes; - throw runtime_error("+++ Geant4DetectorConstructionSequence::assemblies: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::assemblies: Access not possible. Geometry is not yet converted!"); } /// Access to the converted placements const map<PlacedVolume, G4VPhysicalVolume*>& Geant4DetectorConstructionSequence::placements() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Placements; - throw runtime_error("+++ Geant4DetectorConstructionSequence::placements: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::placements: Access not possible. Geometry is not yet converted!"); } /// Access to the converted materials const Geant4GeometryMaps::MaterialMap& Geant4DetectorConstructionSequence::materials() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Materials; - throw runtime_error("+++ Geant4DetectorConstructionSequence::materials: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::materials: Access not possible. Geometry is not yet converted!"); } /// Access to the converted elements const Geant4GeometryMaps::ElementMap& Geant4DetectorConstructionSequence::elements() const { Geant4GeometryInfo* p = Geant4Mapping::instance().ptr(); if ( p ) return p->g4Elements; - throw runtime_error("+++ Geant4DetectorConstructionSequence::elements: Access not possible. Geometry is not yet converted!"); + throw std::runtime_error("+++ Geant4DetectorConstructionSequence::elements: Access not possible. Geometry is not yet converted!"); } diff --git a/DDG4/src/Geant4ShapeConverter.cpp b/DDG4/src/Geant4ShapeConverter.cpp index c46644716bc4ed86807aa1617dd73c5a426d6a21..b7b35a31ecd54b90409de08672c277b1d1bf8b62 100644 --- a/DDG4/src/Geant4ShapeConverter.cpp +++ b/DDG4/src/Geant4ShapeConverter.cpp @@ -43,6 +43,9 @@ #include <G4GenericTrap.hh> #include <G4ExtrudedSolid.hh> #include <G4EllipticalTube.hh> +#include <G4TessellatedSolid.hh> +#include <G4TriangularFacet.hh> +#include <G4QuadrangularFacet.hh> // C/C++ include files @@ -237,18 +240,6 @@ namespace dd4hep { vertices.emplace_back(vtx_xy[0] * CM_2_MM, vtx_xy[1] * CM_2_MM); return new G4GenericTrap(sh->GetName(), sh->GetDz() * CM_2_MM, vertices); } - } // End namespace sim -} // End namespace dd4hep - -#if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) -#include <G4TessellatedSolid.hh> -#include <G4TriangularFacet.hh> -#include <G4QuadrangularFacet.hh> - -/// Namespace for the AIDA detector description toolkit -namespace dd4hep { - /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit - namespace sim { template <> G4VSolid* convertShape<TGeoTessellated>(const TGeoShape* shape) { TGeoTessellated* sh = (TGeoTessellated*) shape; @@ -299,5 +290,3 @@ namespace dd4hep { } // End namespace sim } // End namespace dd4hep -#endif // ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) - diff --git a/DDG4/src/python/Geant4PythonCall.cpp b/DDG4/src/python/Geant4PythonCall.cpp index b8f12fd99eb30b56759f57e46adcae303c7ebdcb..60f39683ebbfb8ef792e8d655791cb06ee57cd0a 100644 --- a/DDG4/src/python/Geant4PythonCall.cpp +++ b/DDG4/src/python/Geant4PythonCall.cpp @@ -13,14 +13,13 @@ //========================================================================== // Framework include files -#include "DDG4/Python/Geant4PythonCall.h" -#include "DDG4/Python/DDPython.h" -#include "TPyReturn.h" +#include <DDG4/Python/Geant4PythonCall.h> +#include <DDG4/Python/DDPython.h> +#include <TPyReturn.h> // C/C++ include files #include <stdexcept> -using namespace std; using namespace dd4hep; using namespace dd4hep::sim; @@ -87,9 +86,7 @@ namespace dd4hep { namespace sim { INSTANTIATE(unsigned long); INSTANTIATE(float); INSTANTIATE(double); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) INSTANTIATE(char*); -#endif INSTANTIATE(const char*); INSTANTIATE(PyObject*); INSTANTIATE(void*); diff --git a/DDParsers/include/Evaluator/DD4hepUnits.h b/DDParsers/include/Evaluator/DD4hepUnits.h index 0fd32607aab2a423543dc4c9dc091f958ff4d80b..d4b24bfb2b322aeeb17f55c63c3babc61274662d 100644 --- a/DDParsers/include/Evaluator/DD4hepUnits.h +++ b/DDParsers/include/Evaluator/DD4hepUnits.h @@ -29,16 +29,6 @@ #include "RVersion.h" -// We use the ROOT system units if they are avalible (FAILS SOME TESTS FOR NOW) -#if 0 -/// ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) -#include "TGeoSystemOfUnits.h" -/// Main dd4hep namespace. We must import here the ROOT TGeo units -namespace dd4hep { - using namespace TGeoUnit; -} -#else - /// Main dd4hep namespace. We must import here the ROOT TGeo units namespace dd4hep { @@ -423,6 +413,4 @@ namespace dd4hep { static constexpr double universe_mean_density = 1.e-25 * g / cm3; //} } -#endif - #endif // EVALUATOR_DD4HEPUNITS_H diff --git a/UtilityApps/src/teve_display.cpp b/UtilityApps/src/teve_display.cpp index 8e70d502545826a97eb8c078f8835011588e94ed..7c5940630cca119a58490292795f4a46a3e5bd6c 100644 --- a/UtilityApps/src/teve_display.cpp +++ b/UtilityApps/src/teve_display.cpp @@ -12,50 +12,49 @@ //========================================================================== // Framework include files -#include "DD4hep/Factories.h" -#include "DD4hep/Detector.h" -#include "DDRec/SurfaceHelper.h" +#include <DD4hep/Factories.h> +#include <DD4hep/Detector.h> +#include <DDRec/SurfaceHelper.h> #include "EvNavHandler.h" #include "MultiView.h" #include "run_plugin.h" -#include "TRint.h" - -#include "TROOT.h" -#include "TEveGeoNode.h" -#include "TEveBrowser.h" -#include "TGNumberEntry.h" -#include "TGButton.h" -#include "TGLabel.h" -#include "TStyle.h" -#include "TGComboBox.h" -#include "TEveManager.h" -#include "TSystem.h" -#include "TGLViewer.h" -#include "TEveViewer.h" -#include "TGLPerspectiveCamera.h" -#include "TGLCamera.h" -#include "TEveStraightLineSet.h" -#include "TSysEvtHandler.h" +#include <TRint.h> + +#include <TROOT.h> +#include <TEveGeoNode.h> +#include <TEveBrowser.h> +#include <TGNumberEntry.h> +#include <TGButton.h> +#include <TGLabel.h> +#include <TStyle.h> +#include <TGComboBox.h> +#include <TEveManager.h> +#include <TSystem.h> +#include <TGLViewer.h> +#include <TEveViewer.h> +#include <TGLPerspectiveCamera.h> +#include <TGLCamera.h> +#include <TEveStraightLineSet.h> +#include <TSysEvtHandler.h> #include <TEveScene.h> #include <TEveProjectionManager.h> #include <TEveProjectionAxes.h> #include <TEveWindow.h> -#include "TGeoManager.h" -#include "TGLClip.h" -#include "TMap.h" -#include "TObjString.h" -#include "TGeoShape.h" -#include "TGLScenePad.h" +#include <TGeoManager.h> +#include <TGLClip.h> +#include <TMap.h> +#include <TObjString.h> +#include <TGeoShape.h> +#include <TGLScenePad.h> using namespace dd4hep ; using namespace rec ; using namespace detail ; - //===================================================================================== // function declarations: void next_event(); @@ -295,12 +294,7 @@ void make_gui() { TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain); { - -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,9,2) TString icondir( Form("%s/", TROOT::GetIconPath().Data()) ); -#else - TString icondir( Form("%s/icons/", gSystem->Getenv("ROOTSYS")) ); -#endif TGPictureButton* b = 0; EvNavHandler *fh = new EvNavHandler; diff --git a/examples/ClientTests/src/Assemblies_VXD_geo.cpp b/examples/ClientTests/src/Assemblies_VXD_geo.cpp index fa6a7cdd524c53eb4b5b4f5201f8dbb0e7e99b7c..e6a647790122f9794606f5f83dc468aca94a8b51 100644 --- a/examples/ClientTests/src/Assemblies_VXD_geo.cpp +++ b/examples/ClientTests/src/Assemblies_VXD_geo.cpp @@ -14,13 +14,11 @@ // Framework includes #include "DD4hep/DetFactoryHelper.h" -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector sens) { xml_det_t x_det = e; - string name = x_det.nameStr(); + std::string name = x_det.nameStr(); Assembly assembly(name+"_assembly"); DetElement vxd(name, x_det.typeStr(), x_det.id()); PlacedVolume pv; @@ -32,7 +30,7 @@ static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector se xml_comp_t x_ladder (x_layer.child(_U(ladder))); int layer_id = x_layer.id(); int nLadders = x_ladder.number(); - string layername = name+_toString(layer_id,"_layer%d"); + std::string layername = name+_toString(layer_id,"_layer%d"); double dphi = 2.*M_PI/double(nLadders); // --- create an assembly and DetElement for the layer Assembly layer_assembly(layername); @@ -81,7 +79,7 @@ static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector se for(int j=0; j<nLadders; ++j) { double dj = double(j); double phi = phi0 + dj*dphi; - string laddername = layername + _toString(j,"_ladder%d"); + std::string laddername = layername + _toString(j,"_ladder%d"); double lthick = sens_thick + supp_thick; RotationZYX rot( phi,0,0); double pos_x = (radius + lthick/2.)*cos(phi) - offset * sin( phi ); diff --git a/examples/ClientTests/src/MaterialTester_geo.cpp b/examples/ClientTests/src/MaterialTester_geo.cpp index 5fe7a2ae36cf68739df7498df3a6f433f38a4eb1..79161f06790d06d06b5a6ab05d36593c97a1b83d 100644 --- a/examples/ClientTests/src/MaterialTester_geo.cpp +++ b/examples/ClientTests/src/MaterialTester_geo.cpp @@ -11,29 +11,23 @@ // //========================================================================== -#include "RVersion.h" - -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,20,0) - // Framework include files -#include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/DD4hepUnits.h" -#include "DD4hep/Printout.h" +#include <DD4hep/DetFactoryHelper.h> +#include <DD4hep/DD4hepUnits.h> +#include <DD4hep/Printout.h> // ROOT include file -#include "TGeoElement.h" -#include "TGeoPhysicalConstants.h" -#include "TGeant4PhysicalConstants.h" -#include "TMath.h" +#include <TGeoElement.h> +#include <TGeoPhysicalConstants.h> +#include <TGeant4PhysicalConstants.h> +#include <TMath.h> namespace units = dd4hep; -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; static Ref_t create_element(Detector& description, xml_h xml_det, SensitiveDetector /* sens */) { xml_det_t x_det = xml_det; - string det_name = x_det.nameStr(); + std::string det_name = x_det.nameStr(); Assembly assembly(det_name+"_assembly"); DetElement det(det_name,x_det.typeStr(), x_det.id()); @@ -41,7 +35,7 @@ static Ref_t create_element(Detector& description, xml_h xml_det, SensitiveDetec xml_det_t xbox = x_det.child(_U(box)); Volume box = Volume(det_name+"_box", Box(xbox.x(), xbox.y(), xbox.z()), - description.material(xbox.attr<string>(_U(material)))); + description.material(xbox.attr<std::string>(_U(material)))); PlacedVolume place = assembly.placeVolume(box); place.addPhysVolID("box",0); } @@ -140,4 +134,4 @@ static Ref_t create_element(Detector& description, xml_h xml_det, SensitiveDetec } DECLARE_DETELEMENT(MaterialTester,create_element) -#endif + diff --git a/examples/ClientTests/src/MiniTel.cpp b/examples/ClientTests/src/MiniTel.cpp index 524b2a32c0c3cb39b6cea4e37e4a7d57cfb02c6c..d1231c5df7e8ff28390f8d0b08d7b990a4193838 100644 --- a/examples/ClientTests/src/MiniTel.cpp +++ b/examples/ClientTests/src/MiniTel.cpp @@ -16,14 +16,14 @@ #include "DD4hep/Printout.h" #include "DD4hep/Detector.h" +// C/C++ include files #include <iostream> #include <map> -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; namespace { + struct MyDetExtension { int idD, Ni, Nj; double dimDX, dimDY, dimDZ; @@ -45,14 +45,14 @@ namespace { typedef MyDetExtension DetectorExtension; static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector sens) { - xml_det_t x_det = e; //xml-detelemnt of the detector taken as an argument - xml_comp_t det_dim = x_det.child(_U(dimensions)); - xml_comp_t det_mod = x_det.child(_U(module)); // considering the module-pixel of the detector - string det_name = x_det.nameStr(); //det_name is the name of the xml-detelement - Assembly assembly (det_name); - DetElement sdet(det_name,x_det.id()); //sdet is the detelement of the detector!!(actually is a Handle,already a pointer to m_element) - Volume motherVol = description.pickMotherVolume(sdet); //the mothers volume of our detector - Material mat = description.material("Silicon"); + xml_det_t x_det = e; //xml-detelemnt of the detector taken as an argument + xml_comp_t det_dim = x_det.child(_U(dimensions)); + xml_comp_t det_mod = x_det.child(_U(module)); // considering the module-pixel of the detector + std::string det_name = x_det.nameStr(); //det_name is the name of the xml-detelement + Assembly assembly (det_name); + DetElement sdet(det_name,x_det.id()); //sdet is the detelement of the detector!!(actually is a Handle,already a pointer to m_element) + Volume motherVol = description.pickMotherVolume(sdet); //the mothers volume of our detector + Material mat = description.material("Silicon"); DetectorExtension* ext = new MyDetExtension(sdet); sdet.addExtension<MyDetExtension>(ext); diff --git a/examples/ClientTests/src/PlacedVolumeScannerTest.cpp b/examples/ClientTests/src/PlacedVolumeScannerTest.cpp index 7800e7b1caefc10ca23a9491b08530d596d8e129..4945fac0192e0414b5775a67117d02f1f182498b 100644 --- a/examples/ClientTests/src/PlacedVolumeScannerTest.cpp +++ b/examples/ClientTests/src/PlacedVolumeScannerTest.cpp @@ -19,7 +19,7 @@ geoPluginRun -destroy -plugin DD4hep_VolumeScannerTest -opt [-opt] */ -// Framework include files +/// Framework include files #include "DD4hep/Volumes.h" #include "DD4hep/Detector.h" #include "DD4hep/Printout.h" @@ -27,6 +27,8 @@ #include "DD4hep/DetectorTools.h" #include "DD4hep/VolumeProcessor.h" #include "TClass.h" + +/// C/C++ include files #include <iomanip> namespace { @@ -61,7 +63,6 @@ namespace { }; } -using namespace std; using namespace dd4hep; /// Plugin function: Test example of the volume scanner using a customized callback functor @@ -73,7 +74,7 @@ using namespace dd4hep; */ static int scan_volumes (Detector& detector, int argc, char** argv) { bool help = false; - string det_element_path, placed_vol_path; + std::string det_element_path, placed_vol_path; for(int i=0; i<argc && argv[i]; ++i) { if ( 0 == ::strncmp("-help",argv[i],4) ) help = true; @@ -86,13 +87,13 @@ static int scan_volumes (Detector& detector, int argc, char** argv) { } if ( help ) { /// Help printout describing the basic command line interface - cout << + std::cout << "Usage: -plugin <name> -arg [-arg] \n" " name: factory name DD4hep_PlacedVolumeScannerTest \n" " -detector <name> Path to the detector element where to start the scan.\n" " -path <name> Alternatively specify the physical volume path. \n" " -help Ahow this help. \n" - "\tArguments given: " << arguments(argc,argv) << endl << flush; + "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush; ::exit(EINVAL); } diff --git a/examples/ClientTests/src/Property_test.cpp b/examples/ClientTests/src/Property_test.cpp index 214a1a6dddc7260f5ebb06f536712d4cfeb4d719..e3aa96ff94ec80d88262ba65d39d28902c6a2b85 100644 --- a/examples/ClientTests/src/Property_test.cpp +++ b/examples/ClientTests/src/Property_test.cpp @@ -11,13 +11,14 @@ // //========================================================================== -// Framework include files +/// Framework include files #include <DD4hep/ComponentProperties.h> #include <DD4hep/Factories.h> + +/// C/C++ include files #include <iostream> #include <deque> -using namespace std; using namespace dd4hep; /// Plugin function: Condition program example @@ -30,72 +31,78 @@ using namespace dd4hep; */ #include <sstream> namespace { - template <typename T> int _test_prop(const string& tag, const string& data) { + template <typename T> int _test_prop(const std::string& tag, const std::string& data) { T value; - stringstream log; + std::stringstream log; Property prop(value); try { prop.str(data); - log << "| " << setw(32) << left << tag << " " << setw(6) << left << "" << " " << setw(10) << left << value << " "; - cout << log.str() << endl; + log << "| " << std::setw(32) << std::left << tag << " " + << std::setw(6) << std::left << "" << " " + << std::setw(10) << std::left << value << " "; + std::cout << log.str() << std::endl; } - catch(const exception& e) { - cout << "Test FAILED: " << tag << " Exception: " << e.what() << endl; + catch(const std::exception& e) { + std::cout << "Test FAILED: " << tag << " Exception: " << e.what() << std::endl; return 1; } return 0; } - template <typename T> int _test_cont(const string& tag, const string& data) { + template <typename T> int _test_cont(const std::string& tag, const std::string& data) { T value; - stringstream log; + std::stringstream log; Property prop(value); try { prop.str(data); - log << "| " << setw(32) << left << tag << " "; + log << "| " << std::setw(32) << std::left << tag << " "; for(const auto& p : value) - log << setw(6) << left << "" << " " << setw(10) << left << p << " "; - cout << log.str() << endl; + log << std::setw(6) << std::left << "" << " " << std::setw(10) << std::left << p << " "; + std::cout << log.str() << std::endl; } - catch(const exception& e) { - cout << "Test FAILED: " << tag << " Exception: " << e.what() << endl; + catch(const std::exception& e) { + std::cout << "Test FAILED: " << tag << " Exception: " << e.what() << std::endl; return 1; } return 0; } - template <> int _test_cont<vector<bool> >(const string& tag, const string& data) { - vector<bool> value; - stringstream log; + template <> int _test_cont<std::vector<bool> >(const std::string& tag, const std::string& data) { + std::vector<bool> value; + std::stringstream log; Property prop(value); try { prop.str(data); - log << "| " << setw(32) << left << tag << " "; + log << "| " << std::setw(32) << std::left << tag << " "; for(const auto p : value) - log << setw(6) << left << "" << " " << setw(10) << left << p << " "; - cout << log.str() << endl; + log << std::setw(6) << std::left << "" << " " << std::setw(10) << std::left << p << " "; + std::cout << log.str() << std::endl; } - catch(const exception& e) { - cout << "Test FAILED: " << tag << " Exception: " << e.what() << endl; + catch(const std::exception& e) { + std::cout << "Test FAILED: " << tag << " Exception: " << e.what() << std::endl; return 1; } return 0; } - template <typename T> int _test_map(const string& tag, const string& data) { + template <typename T> int _test_map(const std::string& tag, const std::string& data) { T value; - stringstream log; + std::stringstream log; Property prop(value); try { prop.str(data); - log << "| " << setw(32) << left << tag << " "; + log << "| " << std::setw(32) << std::left << tag << " "; for(const auto& p : value) - log << setw(6) << left << p.first << " = " << setw(10) << left << p.second << " "; - cout << log.str() << endl; + log << std::setw(6) << std::left << p.first << " = " << std::setw(10) << std::left << p.second << " "; + std::cout << log.str() << std::endl; } - catch(const exception& e) { - cout << "Test FAILED: " << tag << " Exception: " << e.what() << endl; + catch(const std::exception& e) { + std::cout << "Test FAILED: " << tag << " Exception: " << e.what() << std::endl; return 1; } return 0; } + void line() { + std::cout << "+-----------------------------------------------------" + << "-----------------------------------------------------" << std::endl; + } } static int property_test(Detector& /* description */, int /* argc */, char** /* argv */) { @@ -104,8 +111,8 @@ static int property_test(Detector& /* description */, int /* argc */, char** /* using XYZVector = ROOT::Math::XYZVector; using PxPyPzE = ROOT::Math::PxPyPzEVector; int result = 0; - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_prop<string> ("prop_str", "'a'"); + line(); + result += _test_prop<std::string> ("prop_str", "'a'"); result += _test_prop<bool> ("prop_bool", "true"); result += _test_prop<int> ("prop_int", "11"); result += _test_prop<int> ("prop_int_eval", "1*11"); @@ -123,119 +130,119 @@ static int property_test(Detector& /* description */, int /* argc */, char** /* result += _test_prop<XYZVector> ("prop_XYZVector_eval", "(1*GeV, 2*GeV, 3*GeV)"); result += _test_prop<PxPyPzE> ("prop_PxPyPzEVector", "(1, 2, 3, 4)"); result += _test_prop<PxPyPzE> ("prop_PxPyPzEVector_eval", "(1*GeV, 2*GeV, 3*GeV, 4*GeV)"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_map <map<string, string> > ("map_str_str", "{'a': 'a', 'b': 'bb', 'c': 'ccc'}"); - result += _test_map <map<string, bool> > ("map_str_bool", "{'a': true, 'b': false, 'c': true}"); - result += _test_map <map<string, int> > ("map_str_int", "{'a': 11, 'b': 222, 'c': 3333}"); - result += _test_map <map<string, int> > ("map_str_int_eval", "{'a': 1*11, 'b': 2*111, 'c': 3*1111}"); - result += _test_map <map<string, long> > ("map_str_long", "{'a': 111, 'b': 222, 'c': 3333}"); - result += _test_map <map<string, long> > ("map_str_long_eval", "{'a': 1*111, 'b': 2*111, 'c': 3*1111}"); - result += _test_map <map<string, float> > ("map_str_float", "{'a': 1.11, 'b': 22.22, 'c': 333.33}"); - result += _test_map <map<string, float> > ("map_str_float_eval", "{'a': '1.11*GeV','b':'22.22*MeV', 'c': '333.3*TeV'}"); - result += _test_map <map<string, double> > ("map_str_double", "{'a': 1.11, 'b': 22.22, 'c': 333.33}"); - result += _test_map <map<string, double> > ("map_str_double_eval", "{'a': '1.11*GeV','b':'22.22*MeV', 'c': '333.3*TeV'}"); - //result += _test_map <map<string, XYZPoint> > ("map_str_XYZPoint", "{['a', (1, 2, 3)]}");//, 'b': (10,20,30), 'c': (100,200,300)}"); - //result += _test_map <map<string, XYZVector> > ("map_str_XYZVector", "{'a': (1, 2, 3), 'b': (10,20,30), 'c': (100,200,300)}"); - //result += _test_map <map<string, PxPyPzE> > ("map_str_PxPyPzEVector", "{'a': (1, 2, 3, 4), 'b': (10,20,30,40), 'c': (100,200,300,400)}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_map <map<int, string> > ("map_int_str", "{ 10: 'a', 200: 'bb', 3000: ' ccc'}"); - result += _test_map <map<int, bool> > ("map_int_bool", "{ 10: true, 200: false, 3000: true}"); - result += _test_map <map<int, int> > ("map_int_int", "{ 10: 11, 200: 200, 3000: 3000}"); - result += _test_map <map<int, int> > ("map_int_int_eval", "{ 10: 1*11, 200: 2*100, 3000: 3*1000}"); - result += _test_map <map<int, long> > ("map_int_long", "{ 10: 111, 200: 222, 3000: 3333}"); - result += _test_map <map<int, long> > ("map_int_long_eval", "{ 10: 1*111, 200: 2*111, 3000: 3*1111}"); - result += _test_map <map<int, float> > ("map_int_float", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); - result += _test_map <map<int, float> > ("map_int_float_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); - result += _test_map <map<int, double> > ("map_int_double", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); - result += _test_map <map<int, double> > ("map_int_double_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); - //result += _test_map <map<int, string> > ("map_eval_int_str", "{ 1*10: 'a', 2*100: 'bb', 3*1000: 'ccc'}"); - result += _test_map <map<int, double> > ("map_eval_int_double", "{ 1*10: 1.11, 2*100: 22.22, 3*1000: 333.33}"); - //result += _test_map <map<int, XYZPoint> > ("map_int_XYZPoint", "{ 10: (1, 2, 3), 200: (10,20,30), 3000: (100,200,300)}"); - //result += _test_map <map<int, XYZVector> > ("map_int_XYZVector", "{ 10: (1, 2, 3), 200: (10,20,30), 3000: (100,200,300)}"); - //result += _test_map <map<int, PxPyPzE> > ("map_int_PxPyPzEVector", "{ 10: (1, 2, 3, 4), 200: (10,20,30,40), 3000: (100,200,300,400)}"); + line(); + result += _test_map <std::map<std::string, std::string> >("map_str_str", "{'a': 'a', 'b': 'bb', 'c': 'ccc'}"); + result += _test_map <std::map<std::string, bool> > ("map_str_bool", "{'a': true, 'b': false, 'c': true}"); + result += _test_map <std::map<std::string, int> > ("map_str_int", "{'a': 11, 'b': 222, 'c': 3333}"); + result += _test_map <std::map<std::string, int> > ("map_str_int_eval", "{'a': 1*11, 'b': 2*111, 'c': 3*1111}"); + result += _test_map <std::map<std::string, long> > ("map_str_long", "{'a': 111, 'b': 222, 'c': 3333}"); + result += _test_map <std::map<std::string, long> > ("map_str_long_eval", "{'a': 1*111, 'b': 2*111, 'c': 3*1111}"); + result += _test_map <std::map<std::string, float> > ("map_str_float", "{'a': 1.11, 'b': 22.22, 'c': 333.33}"); + result += _test_map <std::map<std::string, float> > ("map_str_float_eval", "{'a': '1.11*GeV','b':'22.22*MeV', 'c': '333.3*TeV'}"); + result += _test_map <std::map<std::string, double> > ("map_str_double", "{'a': 1.11, 'b': 22.22, 'c': 333.33}"); + result += _test_map <std::map<std::string, double> > ("map_str_double_eval", "{'a': '1.11*GeV','b':'22.22*MeV', 'c': '333.3*TeV'}"); + //result += _test_map <std::map<std::string, XYZPoint> > ("map_str_XYZPoint", "{['a', (1, 2, 3)]}");//, 'b': (10,20,30), 'c': (100,200,300)}"); + //result += _test_map <std::map<std::string, XYZVector> > ("map_str_XYZVector", "{'a': (1, 2, 3), 'b': (10,20,30), 'c': (100,200,300)}"); + //result += _test_map <std::map<std::string, PxPyPzE> > ("map_str_PxPyPzEVector", "{'a': (1, 2, 3, 4), 'b': (10,20,30,40), 'c': (100,200,300,400)}"); + line(); + result += _test_map <std::map<int, std::string> > ("map_int_str", "{ 10: 'a', 200: 'bb', 3000: ' ccc'}"); + result += _test_map <std::map<int, bool> > ("map_int_bool", "{ 10: true, 200: false, 3000: true}"); + result += _test_map <std::map<int, int> > ("map_int_int", "{ 10: 11, 200: 200, 3000: 3000}"); + result += _test_map <std::map<int, int> > ("map_int_int_eval", "{ 10: 1*11, 200: 2*100, 3000: 3*1000}"); + result += _test_map <std::map<int, long> > ("map_int_long", "{ 10: 111, 200: 222, 3000: 3333}"); + result += _test_map <std::map<int, long> > ("map_int_long_eval", "{ 10: 1*111, 200: 2*111, 3000: 3*1111}"); + result += _test_map <std::map<int, float> > ("map_int_float", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); + result += _test_map <std::map<int, float> > ("map_int_float_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); + result += _test_map <std::map<int, double> > ("map_int_double", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); + result += _test_map <std::map<int, double> > ("map_int_double_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); + //result += _test_map <std::map<int, std::string> > ("map_eval_int_str", "{ 1*10: 'a', 2*100: 'bb', 3*1000: 'ccc'}"); + result += _test_map <std::map<int, double> > ("map_eval_int_double", "{ 1*10: 1.11, 2*100: 22.22, 3*1000: 333.33}"); + //result += _test_map <std::map<int, XYZPoint> > ("map_int_XYZPoint", "{ 10: (1, 2, 3), 200: (10,20,30), 3000: (100,200,300)}"); + //result += _test_map <std::map<int, XYZVector> > ("map_int_XYZVector", "{ 10: (1, 2, 3), 200: (10,20,30), 3000: (100,200,300)}"); + //result += _test_map <std::map<int, PxPyPzE> > ("map_int_PxPyPzEVector", "{ 10: (1, 2, 3, 4), 200: (10,20,30,40), 3000: (100,200,300,400)}"); #if defined(DD4HEP_HAVE_ALL_PARSERS) - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_map <map<float, string> > ("map_float_str", "{ 10: 'a', 200: 'bb', 3000: 'ccc'}"); - result += _test_map <map<float, bool> > ("map_float_bool", "{ 10: true, 200: false, 3000: true}"); - result += _test_map <map<float, int> > ("map_float_int", "{ 10: 11, 200: 200, 3000: 3000}"); - result += _test_map <map<float, int> > ("map_float_int_eval", "{ 10: 1*11, 200: 2*100, 3000: 3*1000}"); - result += _test_map <map<float, float> > ("map_float_float", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); - result += _test_map <map<float, float> > ("map_float_float_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); - result += _test_map <map<float, double> > ("map_float_double", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); - result += _test_map <map<float, double> > ("map_float_double_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); + line(); + result += _test_map <std::map<float, std::string> > ("map_float_str", "{ 10: 'a', 200: 'bb', 3000: 'ccc'}"); + result += _test_map <std::map<float, bool> > ("map_float_bool", "{ 10: true, 200: false, 3000: true}"); + result += _test_map <std::map<float, int> > ("map_float_int", "{ 10: 11, 200: 200, 3000: 3000}"); + result += _test_map <std::map<float, int> > ("map_float_int_eval", "{ 10: 1*11, 200: 2*100, 3000: 3*1000}"); + result += _test_map <std::map<float, float> > ("map_float_float", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); + result += _test_map <std::map<float, float> > ("map_float_float_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); + result += _test_map <std::map<float, double> > ("map_float_double", "{ 10: 1.11, 200: 22.22, 3000: 333.33}"); + result += _test_map <std::map<float, double> > ("map_float_double_eval", "{ 10: 1.11*GeV, 200: 22.22*MeV, 3000: 333.3*TeV}"); #endif - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_cont<set<string> > ("set_str", "{'a', 'bb', 'ccc'}"); - result += _test_cont<set<bool> > ("set_bool", "{true, false, true}"); - result += _test_cont<set<int> > ("set_int", "{11, 222, 3333}"); - result += _test_cont<set<int> > ("set_int_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont<set<int> > ("set_int", "{11, 222, 3333}"); - result += _test_cont<set<long> > ("set_long_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont<set<long> > ("set_long", "{11, 222, 3333}"); - result += _test_cont<set<float> > ("set_float", "{1.11, 22.22, 333.33}"); - result += _test_cont<set<float> > ("set_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont<set<double> > ("set_double", "{1.11, 22.22, 333.33}"); - result += _test_cont<set<double> > ("set_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont<set<XYZPoint> > ("set_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont<set<XYZPoint> > ("set_XYZPoint_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont<set<XYZVector> > ("set_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont<set<XYZVector> > ("set_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont<set<PxPyPzE> > ("set_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); - result += _test_cont<set<PxPyPzE> > ("set_PxPyPzEVector_eval", "{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_cont<vector<string> > ("vector_str", "{'a', 'bb', 'ccc'}"); - result += _test_cont<vector<bool> > ("vector_bool", "{true, false, true}"); - result += _test_cont<vector<int> > ("vector_int", "{11, 222, 3333}"); - result += _test_cont<vector<int> > ("vector_int_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont<vector<long> > ("vector_long_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont<vector<long> > ("vector_long", "{11, 222, 3333}"); - result += _test_cont<vector<_ulong> > ("vector_ulong_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont<vector<_ulong> > ("vector_ulong", "{11, 222, 3333}"); - result += _test_cont<vector<float> > ("vector_float", "{1.11, 22.22, 333.33}"); - result += _test_cont<vector<float> > ("vector_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont<vector<double> > ("vector_double", "{1.11, 22.22, 333.33}"); - result += _test_cont<vector<double> > ("vector_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont<vector<XYZPoint> > ("vector_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont<vector<XYZPoint> > ("vector_XYZPoint_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont<vector<XYZVector> > ("vector_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont<vector<XYZVector> > ("vector_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont<vector<PxPyPzE> > ("vector_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); - result += _test_cont<vector<PxPyPzE> > ("vector_PxPyPzEVector_eval","{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; - result += _test_cont<list<string> > ("list_str", "{'a', 'bb', 'ccc'}"); - result += _test_cont<list<bool> > ("list_bool", "{true, false, true}"); - result += _test_cont<list<int> > ("list_int", "{11, 222, 3333}"); - result += _test_cont<list<int> > ("list_int_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont<list<long> > ("list_long_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont<list<long> > ("list_long", "{11, 222, 3333}"); - result += _test_cont<list<_ulong> > ("list_ulong_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont<list<_ulong> > ("list_ulong", "{11, 222, 3333}"); - result += _test_cont<list<float> > ("list_float", "{1.11, 22.22, 333.33}"); - result += _test_cont<list<float> > ("list_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont<list<double> > ("list_double", "{1.11, 22.22, 333.33}"); - result += _test_cont<list<double> > ("list_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont<list<XYZPoint> > ("list_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont<list<XYZVector> > ("list_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); - result += _test_cont<list<PxPyPzE> > ("list_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); - result += _test_cont<list<XYZVector> > ("list_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); - result += _test_cont<list<PxPyPzE> > ("list_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); - result += _test_cont<list<PxPyPzE> > ("list_PxPyPzEVector_eval", "{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; + line(); + result += _test_cont<std::set<std::string> > ("set_str", "{'a', 'bb', 'ccc'}"); + result += _test_cont<std::set<bool> > ("set_bool", "{true, false, true}"); + result += _test_cont<std::set<int> > ("set_int", "{11, 222, 3333}"); + result += _test_cont<std::set<int> > ("set_int_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont<std::set<int> > ("set_int", "{11, 222, 3333}"); + result += _test_cont<std::set<long> > ("set_long_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont<std::set<long> > ("set_long", "{11, 222, 3333}"); + result += _test_cont<std::set<float> > ("set_float", "{1.11, 22.22, 333.33}"); + result += _test_cont<std::set<float> > ("set_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont<std::set<double> > ("set_double", "{1.11, 22.22, 333.33}"); + result += _test_cont<std::set<double> > ("set_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont<std::set<XYZPoint> > ("set_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont<std::set<XYZPoint> > ("set_XYZPoint_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont<std::set<XYZVector> > ("set_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont<std::set<XYZVector> > ("set_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont<std::set<PxPyPzE> > ("set_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); + result += _test_cont<std::set<PxPyPzE> > ("set_PxPyPzEVector_eval", "{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); + line(); + result += _test_cont<std::vector<std::string> > ("vector_str", "{'a', 'bb', 'ccc'}"); + result += _test_cont<std::vector<bool> > ("vector_bool", "{true, false, true}"); + result += _test_cont<std::vector<int> > ("vector_int", "{11, 222, 3333}"); + result += _test_cont<std::vector<int> > ("vector_int_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont<std::vector<long> > ("vector_long_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont<std::vector<long> > ("vector_long", "{11, 222, 3333}"); + result += _test_cont<std::vector<_ulong> > ("vector_ulong_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont<std::vector<_ulong> > ("vector_ulong", "{11, 222, 3333}"); + result += _test_cont<std::vector<float> > ("vector_float", "{1.11, 22.22, 333.33}"); + result += _test_cont<std::vector<float> > ("vector_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont<std::vector<double> > ("vector_double", "{1.11, 22.22, 333.33}"); + result += _test_cont<std::vector<double> > ("vector_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont<std::vector<XYZPoint> > ("vector_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont<std::vector<XYZPoint> > ("vector_XYZPoint_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont<std::vector<XYZVector> > ("vector_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont<std::vector<XYZVector> > ("vector_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont<std::vector<PxPyPzE> > ("vector_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); + result += _test_cont<std::vector<PxPyPzE> > ("vector_PxPyPzEVector_eval","{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); + line(); + result += _test_cont<std::list<std::string> > ("list_str", "{'a', 'bb', 'ccc'}"); + result += _test_cont<std::list<bool> > ("list_bool", "{true, false, true}"); + result += _test_cont<std::list<int> > ("list_int", "{11, 222, 3333}"); + result += _test_cont<std::list<int> > ("list_int_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont<std::list<long> > ("list_long_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont<std::list<long> > ("list_long", "{11, 222, 3333}"); + result += _test_cont<std::list<_ulong> > ("list_ulong_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont<std::list<_ulong> > ("list_ulong", "{11, 222, 3333}"); + result += _test_cont<std::list<float> > ("list_float", "{1.11, 22.22, 333.33}"); + result += _test_cont<std::list<float> > ("list_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont<std::list<double> > ("list_double", "{1.11, 22.22, 333.33}"); + result += _test_cont<std::list<double> > ("list_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont<std::list<XYZPoint> > ("list_XYZPoint", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont<std::list<XYZVector> > ("list_XYZVector", "{(1, 2, 3), (10,20,30), (100,200,300)}"); + result += _test_cont<std::list<PxPyPzE> > ("list_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); + result += _test_cont<std::list<XYZVector> > ("list_XYZVector_eval", "{(1*m, 2*m, 3*m), (10*m,20*m,30*m), (100*m,200*m,300*m)}"); + result += _test_cont<std::list<PxPyPzE> > ("list_PxPyPzEVector", "{(1, 2, 3,4), (10,20,30,40), (100,200,300,400)}"); + result += _test_cont<std::list<PxPyPzE> > ("list_PxPyPzEVector_eval", "{(1*m, 2*m, 3*m, 4*m), (10*m,20*m,30*m,40*m), (100*m,200*m,300*m,400*m)}"); + line(); #if defined(DD4HEP_HAVE_ALL_PARSERS) - result += _test_cont<deque<string> > ("deque_str", "{'a', 'bb', 'ccc'}"); - result += _test_cont<deque<bool> > ("deque_bool", "{true, false, true}"); - result += _test_cont<deque<int> > ("deque_int", "{11, 222, 3333}"); - result += _test_cont<deque<int> > ("deque_int_eval", "{1*11, 2*111, 3*1111}"); - result += _test_cont<deque<float> > ("deque_float", "{1.11, 22.22, 333.33}"); - result += _test_cont<deque<float> > ("deque_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - result += _test_cont<deque<double> > ("deque_double", "{1.11, 22.22, 333.33}"); - result += _test_cont<deque<double> > ("deque_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); - cout << "+----------------------------------------------------------------------------------------------------------" << endl; + result += _test_cont<std::deque<std::string> > ("deque_str", "{'a', 'bb', 'ccc'}"); + result += _test_cont<std::deque<bool> > ("deque_bool", "{true, false, true}"); + result += _test_cont<std::deque<int> > ("deque_int", "{11, 222, 3333}"); + result += _test_cont<std::deque<int> > ("deque_int_eval", "{1*11, 2*111, 3*1111}"); + result += _test_cont<std::deque<float> > ("deque_float", "{1.11, 22.22, 333.33}"); + result += _test_cont<std::deque<float> > ("deque_float_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + result += _test_cont<std::deque<double> > ("deque_double", "{1.11, 22.22, 333.33}"); + result += _test_cont<std::deque<double> > ("deque_double_eval", "{1.11*GeV, 22.22*MeV, 333.3*TeV}"); + line(); #endif if ( 0 == result ) - cout << endl << "Test PASSED" << endl << endl; + std::cout << std::endl << "Test PASSED" << std::endl << std::endl; else - cout << endl << "Test FAILED" << endl << "===> " << result << " Subtests FAILED" << endl; + std::cout << std::endl << "Test FAILED" << std::endl << "===> " << result << " Subtests FAILED" << std::endl; // All done. return 1; diff --git a/examples/ClientTests/src/SectorBarrelCalorimeter_geo.cpp b/examples/ClientTests/src/SectorBarrelCalorimeter_geo.cpp index b8d12d118df00f692b99e35e5a7c646edc8bd0e3..3fce2478638ae60ebf189231dafbfd50f0f33626 100644 --- a/examples/ClientTests/src/SectorBarrelCalorimeter_geo.cpp +++ b/examples/ClientTests/src/SectorBarrelCalorimeter_geo.cpp @@ -15,9 +15,7 @@ #include "XML/Layering.h" #include <limits> -using namespace std; using namespace dd4hep; -using namespace dd4hep::detail; static void placeStaves(DetElement& parent, DetElement& stave, @@ -55,7 +53,7 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s Layering layering(x_det); //xml_comp_t staves = x_det.staves(); xml_dim_t dim = x_det.dimensions(); - string det_name = x_det.nameStr(); + std::string det_name = x_det.nameStr(); Material air = description.air(); double totalThickness = layering.totalThickness(); int numSides = dim.numsides(); @@ -108,9 +106,9 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s const Layer* lay = layering.layer(layer_num-1); // Get the layer from the layering engine. // Loop over repeats for this layer. for (int j = 0; j < repeat; j++) { - string layer_name = det_name+_toString(layer_num,"_layer%d"); - double layer_thickness = lay->thickness(); - DetElement layer(stave,_toString(layer_num,"layer%d"),x_det.id()); + std::string layer_name = det_name+_toString(layer_num,"_layer%d"); + double layer_thickness = lay->thickness(); + DetElement layer(stave,_toString(layer_num,"layer%d"),x_det.id()); // Layer position in Z within the stave. layer_pos_z += layer_thickness / 2; @@ -121,11 +119,11 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s double slice_pos_z = -(layer_thickness / 2); int slice_number = 1; for(xml_coll_t k(x_layer,_U(slice)); k; ++k) { - xml_comp_t x_slice = k; - string slice_name = layer_name + _toString(slice_number,"_slice%d"); - double slice_thickness = x_slice.thickness(); - Material slice_material = description.material(x_slice.materialStr()); - DetElement slice(layer,_toString(slice_number,"slice%d"),x_det.id()); + xml_comp_t x_slice = k; + std::string slice_name = layer_name + _toString(slice_number,"_slice%d"); + double slice_thickness = x_slice.thickness(); + Material slice_material = description.material(x_slice.materialStr()); + DetElement slice(layer,_toString(slice_number,"slice%d"),x_det.id()); slice_pos_z += slice_thickness / 2; // Slice volume & box @@ -159,7 +157,10 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s // Increment the layer X dimension. layer_pos_x = (layerR-rmin)/tan_external; layer_dim_x = (std::sqrt(rmax*rmax - layerR*layerR)+half_polyFace - layer_pos_x)/2.0; - cout<<"Rmin: "<< rmin<<" Rmax: "<<rmax<<" half_polyFace: "<<half_polyFace<<" Layer " <<layer_num<<" layerR: "<<layerR<<" layer_dim_x:" <<layer_dim_x<<endl; + std::cout << "Rmin: " << rmin << " Rmax: " << rmax + << " half_polyFace: " << half_polyFace + << " Layer " << layer_num << " layerR: " << layerR << " layer_dim_x:" << layer_dim_x + << std::endl; // Increment the layer Z position. layer_pos_z += layer_thickness / 2; // Increment the layer number. diff --git a/examples/DDCMS/src/plugins/DDDefinitions2Objects.cpp b/examples/DDCMS/src/plugins/DDDefinitions2Objects.cpp index 3dd609378e5a0a893438ea866d309c973c3d77db..a9eeeb2c5f20e39812cbd46a563166b56e73ca8e 100644 --- a/examples/DDCMS/src/plugins/DDDefinitions2Objects.cpp +++ b/examples/DDCMS/src/plugins/DDDefinitions2Objects.cpp @@ -474,9 +474,7 @@ template <> void Converter<elementarymaterial>::operator()(xml_h element) const #endif mix->AddElement(elt, 1.0); mix->SetRadLen(0e0); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) mix->ComputeDerivedQuantities(); -#endif /// Create medium from the material TGeoMedium* medium = mgr.GetMedium(matname); if (0 == medium) { @@ -516,9 +514,7 @@ template <> void Converter<compositematerial>::operator()(xml_h element) const fracname.c_str()); } mix->SetRadLen(0e0); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0) mix->ComputeDerivedQuantities(); -#endif printout(_ns.context->debug.materials ? ALWAYS : DEBUG, "DDCMS", "++ Converting material %-48s Density: %8.3f [g/cm3] ROOT: %8.3f [g/cm3]", ('"'+nam+'"').c_str(), density, mix->GetDensity()); diff --git a/examples/LHeD/scripts/initAClick.C b/examples/LHeD/scripts/initAClick.C index dc1614a3fdab74e8132060ac99eef7d6223d10d7..1d9cb41d5ce102346c4eb7df938b352eb92f30b8 100644 --- a/examples/LHeD/scripts/initAClick.C +++ b/examples/LHeD/scripts/initAClick.C @@ -32,13 +32,9 @@ std::string make_str(const char* data) { int processCommand(const char* command, bool end_process) { int status; // Disabling auto-parse is a hack required by a bug in ROOT -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) gInterpreter->SetClassAutoparsing(false); status = gInterpreter->ProcessLine(command); gInterpreter->SetClassAutoparsing(true); -#else - status = gInterpreter->ProcessLine(command); -#endif ::printf("+++ Status(%s) = %d\n",command,status); if ( end_process ) { gInterpreter->ProcessLine("gSystem->Exit(0)"); diff --git a/examples/OpticalSurfaces/src/OpNovice_geo.cpp b/examples/OpticalSurfaces/src/OpNovice_geo.cpp index c4221a7a98b76537670a8bd78948042ba5842b5e..6ff2738dcb949c928fd2601121b24b8c1824aa03 100644 --- a/examples/OpticalSurfaces/src/OpNovice_geo.cpp +++ b/examples/OpticalSurfaces/src/OpNovice_geo.cpp @@ -12,33 +12,33 @@ //========================================================================== // Include files -#include "DD4hep/DetFactoryHelper.h" -#include "DD4hep/OpticalSurfaces.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Detector.h" +#include <DD4hep/DetFactoryHelper.h> +#include <DD4hep/OpticalSurfaces.h> +#include <DD4hep/Printout.h> +#include <DD4hep/Detector.h> +// C/C++ include files #include <iostream> #include <map> -using namespace std; using namespace dd4hep; using namespace dd4hep::detail; /// Example of a water box with a box of air inside, the "bubble" static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector /* sens */) { - xml_det_t x_det = e; - string det_name = x_det.nameStr(); - DetElement sdet(det_name,x_det.id()); - xml_det_t x_tank = x_det.child(_Unicode(tank)); - xml_det_t x_bubble = x_det.child(_Unicode(bubble)); + xml_det_t x_det = e; + std::string det_name = x_det.nameStr(); + DetElement sdet(det_name,x_det.id()); + xml_det_t x_tank = x_det.child(_Unicode(tank)); + xml_det_t x_bubble = x_det.child(_Unicode(bubble)); Assembly hall_vol("Hall"); Box encl_box(_toDouble("world_x-2*cm"),_toDouble("world_y-2*cm"),_toDouble("world_z-2*cm")); Volume encl_vol("Enclosure",encl_box,description.air()); Box tank_box(x_tank.x(), x_tank.y(), x_tank.z()); - Volume tank_vol("Tank",tank_box,description.material(x_tank.attr<string>(_U(material)))); + Volume tank_vol("Tank",tank_box,description.material(x_tank.attr<std::string>(_U(material)))); Box bubble_box(x_bubble.x(), x_bubble.y(), x_bubble.z()); - Volume bubble_vol("Bubble",bubble_box,description.material(x_bubble.attr<string>(_U(material)))); + Volume bubble_vol("Bubble",bubble_box,description.material(x_bubble.attr<std::string>(_U(material)))); encl_vol.setVisAttributes(description.invisible()); tank_vol.setVisAttributes(description, x_tank.visStr()); @@ -53,7 +53,6 @@ static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector / hallPlace.addPhysVolID("system",x_det.id()); sdet.setPlacement(hallPlace); -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,17,0) // Now attach the surface OpticalSurfaceManager surfMgr = description.surfaceManager(); OpticalSurface waterSurf = surfMgr.opticalSurface("/world/"+det_name+"#WaterSurface"); @@ -62,9 +61,6 @@ static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector / BorderSurface bubbleSurf = BorderSurface(description, sdet, "TankBubble", airSurf, bubblePlace, tankPlace); bubbleSurf.isValid(); tankSurf.isValid(); -#else - bubblePlace.isValid(); -#endif return sdet; } DECLARE_DETELEMENT(DD4hep_OpNovice,create_detector)