From fb5753ef5a972c9d639b5d42e1e9ae8b5011f4cf Mon Sep 17 00:00:00 2001 From: Markus Frank <markus.frank@cern.ch> Date: Thu, 30 Jan 2014 13:50:10 +0000 Subject: [PATCH] Fix bug, which appears with earlier versions than root 5.34.10 --- DDCore/CMakeLists.txt | 2 +- DDCore/include/DD4hep/Shapes.h | 30 +++++- DDCore/src/Detector.cpp | 8 +- DDCore/src/Evaluator/Evaluator.cpp | 100 ++++++++++------- DDCore/src/Evaluator/string.src | 2 +- DDCore/src/GeoHandler.cpp | 1 - DDCore/src/Handle.cpp | 2 +- DDCore/src/LCDDImp.cpp | 32 ++---- DDCore/src/Readout.cpp | 4 + DDCore/src/Segmentations.cpp | 32 +++--- DDCore/src/Shapes.cpp | 6 +- DDCore/src/VolumeManager.cpp | 18 ++-- DDCore/src/Volumes.cpp | 137 +++++++++++------------- DDCore/src/plugins/Compact2Objects.cpp | 11 +- DDCore/src/plugins/Geant4XML.cpp | 6 +- DDCore/src/plugins/LCDDConverter.cpp | 40 ++++--- DDCore/src/plugins/LCDDFields.cpp | 12 +-- DDCore/src/plugins/PandoraConverter.cpp | 6 +- DDCore/src/plugins/StandardPlugins.cpp | 24 +++-- 19 files changed, 246 insertions(+), 227 deletions(-) diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt index a99f7150a..b70bc0a9c 100644 --- a/DDCore/CMakeLists.txt +++ b/DDCore/CMakeLists.txt @@ -27,7 +27,7 @@ target_link_libraries(DD4hepCore ${ROOT_LIBRARIES} ${XML_LIBRARIES} DDSegmentati add_library(DD4hepPlugins SHARED ${plugin_sources}) target_link_libraries(DD4hepPlugins ${ROOT_LIBRARIES} ${XML_LIBRARIES} DD4hepCore Geom Reflex ${libraries}) - +SET( CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-long-long") SET_TARGET_PROPERTIES( DD4hepCore DD4hepPlugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION}) #---Rootmap generation-------------------------------------------------------------- diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h index 13ac21fe1..4b877a58a 100644 --- a/DDCore/include/DD4hep/Shapes.h +++ b/DDCore/include/DD4hep/Shapes.h @@ -297,6 +297,9 @@ namespace DD4hep { * @version 1.0 */ struct Trap: public Solid_type<TGeoTrap> { + private: + void make(double pz, double py, double px, double pLTX); + public: /// Constructor to be used when reading the already parsed object template <typename Q> Trap(const Handle<Q>& e) : Solid_type<TGeoTrap>(e) { @@ -307,8 +310,12 @@ namespace DD4hep { double alpha2); /// Constructor to create a new anonymous object for right angular wedge from STEP (Se G4 manual for details) - Trap(double pz, double py, double px, double pLTX); - + Trap(double pz, double py, double px, double pLTX) { make(pz,py,px,pLTX); } + + /// Constructor to create a new anonymous object with attribute initialization + template <typename PZ,typename PY,typename PX,typename PLTX> Trap(PZ pz, PY py, PX px, PLTX pLTX) + { make(_toDouble(pz),_toDouble(py),_toDouble(px),_toDouble(pLTX)); } + /// Set the trap dimensions Trap& setDimensions(double z, double theta, double phi, double y1, double x1, double x2, double alpha1, double y2, double x3, double x4, double alpha2); @@ -320,12 +327,19 @@ namespace DD4hep { * @version 1.0 */ struct Trapezoid: public Solid_type<TGeoTrd2> { + private: + void make(double x1, double x2, double y1, double y2, double z); + public: /// Constructor to be used when reading the already parsed object template <typename Q> Trapezoid(const Handle<Q>& e) : Solid_type<TGeoTrd2>(e) { } /// Constructor to create a new anonymous object with attribute initialization - Trapezoid(double x1, double x2, double y1, double y2, double z); + Trapezoid(double x1, double x2, double y1, double y2, double z) { make(x1,x2,y1,y2,z); } + /// Constructor to create a new anonymous object with attribute initialization + template <typename X1,typename X2,typename Y1,typename Y2,typename Z> + Trapezoid(X1 x1, X2 x2, Y1 y1, Y2 y2, Z z) + { make(_toDouble(x1),_toDouble(x2),_toDouble(y1),_toDouble(y2),_toDouble(z)); } /// Set the Trapezoid dimensions Trapezoid& setDimensions(double x1, double x2, double y1, double y2, double z); }; @@ -336,12 +350,20 @@ namespace DD4hep { * @version 1.0 */ struct Torus: public Solid_type<TGeoTorus> { + private: + void make(double r, double rmin, double rmax, double phi, double delta_phi); + public: /// Constructor to be used when reading the already parsed object template <typename Q> Torus(const Handle<Q>& e) : Solid_type<TGeoTorus>(e) { } /// Constructor to create a new anonymous object with attribute initialization - Torus(double r, double rmin, double rmax, double phi = M_PI*RAD_2_DEGREE, double delta_phi = 2. * M_PI*RAD_2_DEGREE); + template<typename R, typename RMIN, typename RMAX, typename PHI, typename DELTA_PHI> + Torus(R r, RMIN rmin, RMAX rmax, PHI phi = M_PI*RAD_2_DEGREE, DELTA_PHI delta_phi = 2. * M_PI*RAD_2_DEGREE) + { make(_toDouble(r),_toDouble(rmin),_toDouble(rmax),_toDouble(phi),_toDouble(delta_phi)); } + /// Constructor to create a new anonymous object with attribute initialization + Torus(double r, double rmin, double rmax, double phi = M_PI*RAD_2_DEGREE, double delta_phi = 2. * M_PI*RAD_2_DEGREE) + { make(r,rmin,rmax,phi,delta_phi); } /// Set the Torus dimensions Torus& setDimensions(double r, double rmin, double rmax, double phi, double delta_phi); }; diff --git a/DDCore/src/Detector.cpp b/DDCore/src/Detector.cpp index 184e56be3..fbcadad98 100644 --- a/DDCore/src/Detector.cpp +++ b/DDCore/src/Detector.cpp @@ -35,7 +35,6 @@ namespace { return s_map; } } -; static bool find_child(TGeoNode* parent, TGeoNode* child, vector<TGeoNode*>& path) { if (parent && child) { @@ -290,12 +289,12 @@ void* DetElement::i_addExtension(void* ptr, const type_info& info, void* (*copy) m.insert(make_pair(&info, entry)); i = m.find(&info); } - ExtensionEntry& e = (*i).second; //cout << "Extension[" << name() << "]:" << ptr << " " << info.name() << endl; return o.extensions[&info] = ptr; } throw runtime_error( - "DD4hep: addExtension: The object " + string(name()) + " already has an extension of type:" + string(info.name()) + "."); + "DD4hep: addExtension: The object " + string(name()) + + " already has an extension of type:" + string(info.name()) + "."); } /// Access an existing extension object from the detector element @@ -717,8 +716,7 @@ void* SensitiveDetector::i_addExtension(void* ptr, const type_info& info, void ( m.insert(make_pair(&info, entry)); i = m.find(&info); } - ExtensionEntry& e = (*i).second; - cout << "Extension[" << name() << "]:" << ptr << " " << typeid(*(TNamed*) ptr).name() << endl; + //cout << "Add Extension[" << name() << "]:" << ptr << " " << typeid(*(TNamed*) ptr).name() << endl; return o.extensions[&info] = ptr; } throw runtime_error( diff --git a/DDCore/src/Evaluator/Evaluator.cpp b/DDCore/src/Evaluator/Evaluator.cpp index 6365a3512..2e174e56e 100644 --- a/DDCore/src/Evaluator/Evaluator.cpp +++ b/DDCore/src/Evaluator/Evaluator.cpp @@ -30,13 +30,32 @@ struct Item { typedef char * pchar; typedef hash_map<string,Item> dic_type; -struct Struct { - dic_type theDictionary; - pchar theExpression; - pchar thePosition; - int theStatus; - double theResult; -}; +namespace { + struct Struct { + dic_type theDictionary; + pchar theExpression; + pchar thePosition; + int theStatus; + double theResult; + }; + + union FCN { + void* ptr; + double (*f0)(); + double (*f1)(double); + double (*f2)(double,double); + double (*f3)(double,double,double); + double (*f4)(double,double,double,double); + double (*f5)(double,double,double,double,double); + FCN(void* p) { ptr = p; } + FCN(double (*f)()) { f0 = f; } + FCN(double (*f)(double)) { f1 = f; } + FCN(double (*f)(double,double)) { f2 = f; } + FCN(double (*f)(double,double,double)) { f3 = f; } + FCN(double (*f)(double,double,double,double)) { f4 = f; } + FCN(double (*f)(double,double,double,double,double)) { f5 = f; } + }; +} //--------------------------------------------------------------------------- #define EVAL XmlTools::Evaluator @@ -91,7 +110,6 @@ static int variable(const string & name, double & result, pchar exp_end = exp_begin + strlen(exp_begin) - 1; if (engine(exp_begin, exp_end, result, exp_end, dictionary) == EVAL::OK) return EVAL::OK; - return EVAL::ERROR_CALCULATION_ERROR; } default: return EVAL::ERROR_CALCULATION_ERROR; @@ -127,27 +145,25 @@ static int function(const string & name, stack<double> & par, for(int i=0; i<npar; i++) { pp[i] = par.top(); par.pop(); } errno = 0; if (item.function == 0) return EVAL::ERROR_CALCULATION_ERROR; + FCN fcn(item.function); switch (npar) { case 0: - result = ((double (*)())item.function)(); + result = (*fcn.f0)(); break; case 1: - result = ((double (*)(double))item.function)(pp[0]); + result = (*fcn.f1)(pp[0]); break; case 2: - result = ((double (*)(double,double))item.function)(pp[1], pp[0]); + result = (*fcn.f2)(pp[1], pp[0]); break; case 3: - result = ((double (*)(double,double,double))item.function) - (pp[2],pp[1],pp[0]); + result = (*fcn.f3)(pp[2],pp[1],pp[0]); break; case 4: - result = ((double (*)(double,double,double,double))item.function) - (pp[3],pp[2],pp[1],pp[0]); + result = (*fcn.f4)(pp[3],pp[2],pp[1],pp[0]); break; case 5: - result = ((double (*)(double,double,double,double,double))item.function) - (pp[4],pp[3],pp[2],pp[1],pp[0]); + result = (*fcn.f5)(pp[4],pp[3],pp[2],pp[1],pp[0]); break; } return (errno == 0) ? EVAL::OK : EVAL::ERROR_CALCULATION_ERROR; @@ -327,7 +343,6 @@ static int maker(int op, stack<double> & val) errno = 0; val.top() = pow(val1,val2); if (errno == 0) return EVAL::OK; - return EVAL::ERROR_CALCULATION_ERROR; default: return EVAL::ERROR_CALCULATION_ERROR; } @@ -593,11 +608,10 @@ double Evaluator::evaluate(const char * expression) { s->theStatus = WARNING_BLANK_STRING; s->theResult = 0.0; if (expression != 0) { - size_t len = strlen(expression); - s->theExpression = new char[len+1]; - strncpy(s->theExpression, expression, len+1); + s->theExpression = new char[strlen(expression)+1]; + strcpy(s->theExpression, expression); s->theStatus = engine(s->theExpression, - s->theExpression+len-1, + s->theExpression+strlen(expression)-1, s->theResult, s->thePosition, s->theDictionary); @@ -658,29 +672,35 @@ void Evaluator::setVariable(const char * name, const char * expression) { setItem("", name, Item(expression), (Struct *)p); } //--------------------------------------------------------------------------- -void Evaluator::setFunction(const char * name, - double (*fun)()) -{ setItem("0", name, Item((void *)fun), (Struct *)p); } +void Evaluator::setFunction(const char * name,double (*fun)()) { + FCN fcn(fun); + setItem("0", name, Item(fcn.ptr), (Struct *)p); +} -void Evaluator::setFunction(const char * name, - double (*fun)(double)) -{ setItem("1", name, Item((void *)fun), (Struct *)p); } +void Evaluator::setFunction(const char * name,double (*fun)(double)) { + FCN fcn(fun); + setItem("1", name, Item(fcn.ptr), (Struct *)p); +} -void Evaluator::setFunction(const char * name, - double (*fun)(double,double)) -{ setItem("2", name, Item((void *)fun), (Struct *)p); } +void Evaluator::setFunction(const char * name, double (*fun)(double,double)) { + FCN fcn(fun); + setItem("2", name, Item(fcn.ptr), (Struct *)p); +} -void Evaluator::setFunction(const char * name, - double (*fun)(double,double,double)) -{ setItem("3", name, Item((void *)fun), (Struct *)p); } +void Evaluator::setFunction(const char * name, double (*fun)(double,double,double)) { + FCN fcn(fun); + setItem("3", name, Item(fcn.ptr), (Struct *)p); +} -void Evaluator::setFunction(const char * name, - double (*fun)(double,double,double,double)) -{ setItem("4", name, Item((void *)fun), (Struct *)p); } +void Evaluator::setFunction(const char * name, double (*fun)(double,double,double,double)) { + FCN fcn(fun); + setItem("4", name, Item(fcn.ptr), (Struct *)p); +} -void Evaluator::setFunction(const char * name, - double (*fun)(double,double,double,double,double)) -{ setItem("5", name, Item((void *)fun), (Struct *)p); } +void Evaluator::setFunction(const char * name, double (*fun)(double,double,double,double,double)) { + FCN fcn(fun); + setItem("5", name, Item(fcn.ptr), (Struct *)p); +} //--------------------------------------------------------------------------- bool Evaluator::findVariable(const char * name) const { diff --git a/DDCore/src/Evaluator/string.src b/DDCore/src/Evaluator/string.src index 40842444f..41d382c15 100644 --- a/DDCore/src/Evaluator/string.src +++ b/DDCore/src/Evaluator/string.src @@ -22,7 +22,7 @@ struct string { struct srep { char* s; // pointer to data int n; // reference count - srep() : n(1), s(0) {} + srep() : s(0), n(1) {} } *p; // Default constructor. diff --git a/DDCore/src/GeoHandler.cpp b/DDCore/src/GeoHandler.cpp index 842f119f8..d7f8d4146 100644 --- a/DDCore/src/GeoHandler.cpp +++ b/DDCore/src/GeoHandler.cpp @@ -72,7 +72,6 @@ GeoHandler& GeoHandler::collect(DetElement element, GeometryInfo& info) { m_data->clear(); i_collect(element.placement().ptr(), 0); for (Data::const_reverse_iterator i = m_data->rbegin(); i != m_data->rend(); ++i) { - int level = (*i).first; const Data::mapped_type& v = (*i).second; for (Data::mapped_type::const_iterator j = v.begin(); j != v.end(); ++j) { const TGeoNode* n = *j; diff --git a/DDCore/src/Handle.cpp b/DDCore/src/Handle.cpp index 19d4a3389..fa9e06c92 100644 --- a/DDCore/src/Handle.cpp +++ b/DDCore/src/Handle.cpp @@ -319,7 +319,7 @@ typedef DDSegmentation::Segmentation _Segmentation; //INSTANTIATE_UNNAMED(_Segmentation); namespace DD4hep { namespace Geometry { - template <> void Handle<_Segmentation>::assign(_Segmentation* s, const std::string& n, const std::string& t) { + template <> void Handle<_Segmentation>::assign(_Segmentation* s, const std::string& n, const std::string&) { this->m_element = s; s->setName(n); } diff --git a/DDCore/src/LCDDImp.cpp b/DDCore/src/LCDDImp.cpp index 96c4469d8..ecc31e5ca 100644 --- a/DDCore/src/LCDDImp.cpp +++ b/DDCore/src/LCDDImp.cpp @@ -42,9 +42,7 @@ using namespace DD4hep; using namespace std; namespace { struct TopDetElement: public DetElement { - TopDetElement(const string& nam, Volume vol) - : DetElement(nam,/* "structure", */0) { - //object<Object>().volume = vol; + TopDetElement(const string& nam) : DetElement(nam,/* "structure", */0) { } }; struct TypePreserve { @@ -171,9 +169,7 @@ void* LCDDImp::addUserExtension(void* ptr, const std::type_info& info) { ExtensionEntry entry; entry.id = ++s_extensionID; m.insert(make_pair(&info, entry)); - i = m.find(&info); } - ExtensionEntry& e = (*i).second; //cout << "Extension[" << name() << "]:" << ptr << " " << info.name() << endl; return m_extensions[&info] = ptr; } @@ -263,7 +259,6 @@ namespace { string nam; cout << "++ Patching names of anonymous shapes...." << endl; for (GeoHandler::Data::const_reverse_iterator i = data.rbegin(); i != data.rend(); ++i) { - int level = (*i).first; const GeoHandler::Data::mapped_type& v = (*i).second; for (GeoHandler::Data::mapped_type::const_iterator j = v.begin(); j != v.end(); ++j) { const TGeoNode* n = *j; @@ -316,8 +311,6 @@ namespace { void LCDDImp::endDocument() { TGeoManager* mgr = m_manager; if (!mgr->IsClosed()) { - LCDD& lcdd = *this; - #if 0 Region trackingRegion("TrackingRegion"); trackingRegion.setThreshold(1); @@ -338,8 +331,8 @@ void LCDDImp::endDocument() { worldVis.setColor(1.0, 1.0, 1.0); worldVis.setLineStyle(VisAttr::SOLID); worldVis.setDrawingStyle(VisAttr::WIREFRAME); -#ifndef DD4HEP_EMULATE_TGEOEXTENSIONS m_worldVol.setVisAttributes(worldVis); +#ifndef DD4HEP_EMULATE_TGEOEXTENSIONS #endif add(worldVis); @@ -356,27 +349,24 @@ void LCDDImp::init() { TGeoManager* mgr = m_manager; Box worldSolid("world_x", "world_y", "world_z"); std::cout << " *********** created World volume with size : " << worldSolid->GetDX() << ", " << worldSolid->GetDY() << ", " - << worldSolid->GetDZ() << std::endl; - Material vacuum = material("Vacuum"); - Material air = material("Air"); - Volume world("world_volume", worldSolid, air); + << worldSolid->GetDZ() << std::endl; + + m_materialAir = material("Air"); + m_materialVacuum = material("Vacuum"); - m_world = TopDetElement("world", world); + Volume world("world_volume", worldSolid, m_materialAir); + m_world = TopDetElement("world"); m_worldVol = world; #if 0 - Tube trackingSolid(0., - _toDouble("tracking_region_radius"), - _toDouble("2*tracking_region_zmax"),2*M_PI); - Volume tracking("tracking_volume",trackingSolid, air); - m_trackers = TopDetElement("tracking",tracking); + Tube trackingSolid(0.,"tracking_region_radius","2*tracking_region_zmax",2*M_PI); + Volume tracking("tracking_volume",trackingSolid, m_materialAir); + m_trackers = TopDetElement("tracking"); m_trackingVol = tracking; PlacedVolume pv = m_worldVol.placeVolume(tracking); m_trackers.setPlacement(pv); m_world.add(m_trackers); #endif - m_materialAir = air; - m_materialVacuum = vacuum; m_detectors.append(m_world); m_manager->SetTopVolume(m_worldVol.ptr()); m_world.setPlacement(PlacedVolume(mgr->GetTopNode())); diff --git a/DDCore/src/Readout.cpp b/DDCore/src/Readout.cpp index dc68bf8b8..d6c1471ea 100644 --- a/DDCore/src/Readout.cpp +++ b/DDCore/src/Readout.cpp @@ -26,6 +26,10 @@ Readout::Object::Object() { Readout::Object::~Object() { //destroyHandle(segmentation); InstanceCount::decrement(this); + if ( segmentation.isValid() ) { + delete segmentation.ptr(); + segmentation = Segmentation(); + } } /// Initializing constructor to create a new object diff --git a/DDCore/src/Segmentations.cpp b/DDCore/src/Segmentations.cpp index 9399f3b62..7f390ccf3 100644 --- a/DDCore/src/Segmentations.cpp +++ b/DDCore/src/Segmentations.cpp @@ -45,53 +45,53 @@ long64 Segmentation::Object::cellID(const DDSegmentation::Position& localPositio /// Access the encoding string string Segmentation::Object::fieldDescription() const { - return segmentation->fieldDescription(); + return segmentation->fieldDescription(); } /// Access the segmentation name const string& Segmentation::Object::name() const { - return segmentation->name(); + return segmentation->name(); } /// Set the segmentation name void Segmentation::Object::setName(const string& value) { - segmentation->setName(value); + segmentation->setName(value); } /// Access the segmentation type const string& Segmentation::Object::type() const { - return segmentation->type(); + return segmentation->type(); } /// Access the description of the segmentation const string& Segmentation::Object::description() const { - return segmentation->description(); + return segmentation->description(); } /// Access the underlying decoder BitField64* Segmentation::Object::decoder() { - return segmentation->decoder(); + return segmentation->decoder(); } /// Set the underlying decoder void Segmentation::Object::setDecoder(BitField64* decoder) { - segmentation->setDecoder(decoder); + segmentation->setDecoder(decoder); } /// Access to parameter by name Parameter Segmentation::Object::parameter(const string& parameterName) const { - return segmentation->parameter(parameterName); + return segmentation->parameter(parameterName); } /// Access to all parameters Parameters Segmentation::Object::parameters() const { - return segmentation->parameters(); + return segmentation->parameters(); } /// Set all parameters from an existing set of parameters void Segmentation::Object::setParameters(const Parameters& parameters) { - segmentation->setParameters(parameters); + segmentation->setParameters(parameters); } /// Constructor to used when creating a new object Segmentation::Segmentation(const string& type, const string& name) : - Handle<Implementation>() { + Handle<Implementation>() { BaseSegmentation* s = DDSegmentation::SegmentationFactory::instance()->create(type); if (s != 0) { assign(new Object(s), name, ""); } else { - throw runtime_error("FAILED to create segmentation: " + type + ". Missing factory method for: " + type + "!"); + throw runtime_error("FAILED to create segmentation: " + type + ". Missing factory method for: " + type + "!"); } } @@ -106,20 +106,20 @@ bool Segmentation::useForHitPosition() const { /// Access to the parameters Parameters Segmentation::parameters() const { - return data<Object>()->parameters(); + return data<Object>()->parameters(); } /// Access segmentation object DDSegmentation::Segmentation* Segmentation::segmentation() const { - return data<Object>()->segmentation; + return data<Object>()->segmentation; } /// determine the local position based on the cell ID Position Segmentation::position(const long64& cellID) const { - return Position(segmentation()->position(cellID)); + return Position(segmentation()->position(cellID)); } /// determine the cell ID based on the local position long64 Segmentation::cellID(const Position& localPosition, const Position& globalPosition, const long64& volumeID) const { - return segmentation()->cellID(localPosition, globalPosition, volumeID); + return segmentation()->cellID(localPosition, globalPosition, volumeID); } diff --git a/DDCore/src/Shapes.cpp b/DDCore/src/Shapes.cpp index a850eceb6..1f658f1f5 100644 --- a/DDCore/src/Shapes.cpp +++ b/DDCore/src/Shapes.cpp @@ -163,7 +163,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 -Trapezoid::Trapezoid(double x1, double x2, double y1, double y2, double z) { +void Trapezoid::make(double x1, double x2, double y1, double y2, double z) { _assign(new TGeoTrd2(x1, x2, y1, y2, z ), "", "trd2", true); } @@ -200,7 +200,7 @@ Sphere& Sphere::setDimensions(double rmin, double rmax, double theta, double del } /// Constructor to be used when creating a new object with attribute initialization -Torus::Torus(double r, double rmin, double rmax, double phi, double delta_phi) { +void Torus::make(double r, double rmin, double rmax, double phi, double delta_phi) { _assign(new TGeoTorus(r, rmin, rmax, phi, delta_phi), "", "torus", true); } @@ -218,7 +218,7 @@ Trap::Trap(double z, double theta, double phi, double y1, double x1, double x2, } /// Constructor to be used when creating a new anonymous object with attribute initialization -Trap::Trap(double pz, double py, double px, double pLTX) { +void Trap::make(double pz, double py, double px, double pLTX) { double z = pz / 2e0; double theta = 0e0; double phi = 0e0; diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index 3468e8965..e03801478 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -232,8 +232,9 @@ namespace { print_node(sd, parent, e, n, ids, nodes); } #endif - void print_node(SensitiveDetector sd, DetElement parent, DetElement e, const TGeoNode* n, const PlacedVolume::VolIDs& ids, - const Chain& nodes) { + void print_node(SensitiveDetector sd, DetElement /* parent */, DetElement e, + const TGeoNode* n, const PlacedVolume::VolIDs& ids, const Chain& /* nodes */) + { static int s_count = 0; Readout ro = sd.readout(); const IDDescriptor& en = ro.idSpec(); @@ -282,10 +283,6 @@ VolumeManager::Object::Object(LCDD& l) /// Default destructor VolumeManager::Object::~Object() { - Object* obj = dynamic_cast<Object*>(top); - bool isTop = obj == this; - bool hasTop = (flags & VolumeManager::ONE) == VolumeManager::ONE; - bool isSdet = (flags & VolumeManager::TREE) == VolumeManager::TREE && obj != this; /// Cleanup volume tree for_each(volumes.begin(), volumes.end(), destroyObjects(volumes)); volumes.clear(); @@ -301,8 +298,9 @@ VolumeManager::Context* VolumeManager::Object::search(const VolIdentifier& id) c VolIdentifier volume_id(id); volume_id &= detMask; Volumes::const_iterator i = volumes.find(volume_id); - if (i != volumes.end()) + if (i != volumes.end()) { context = (*i).second; + } //else if ( sysID == 8 ) { // for(i=volumes.begin(); i!=volumes.end();++i) // cout << (void*)(*i).first << " " << (*i).second->placement.name() << endl; @@ -433,7 +431,7 @@ IDDescriptor VolumeManager::idSpec() const { } /// Register physical volume with the manager (normally: section manager) -bool VolumeManager::adoptPlacement(VolumeID sys_id, Context* context) { +bool VolumeManager::adoptPlacement(VolumeID /* sys_id */, Context* context) { stringstream err; Object& o = _data(); PlacedVolume pv = context->placement; @@ -569,8 +567,8 @@ std::ostream& DD4hep::Geometry::operator<<(std::ostream& os, const VolumeManager const VolumeManager::Object& o = *m.data<VolumeManager::Object>(); VolumeManager::Object* top = dynamic_cast<VolumeManager::Object*>(o.top); bool isTop = top == &o; - bool hasTop = (o.flags & VolumeManager::ONE) == VolumeManager::ONE; - bool isSdet = (o.flags & VolumeManager::TREE) == VolumeManager::TREE && top != &o; + //bool hasTop = (o.flags & VolumeManager::ONE) == VolumeManager::ONE; + //bool isSdet = (o.flags & VolumeManager::TREE) == VolumeManager::TREE && top != &o; string prefix(isTop ? "" : "++ "); os << prefix << (isTop ? "TOP Level " : "Secondary ") << "Volume manager:" << &o << " " << o.detector.name() << " IDD:" << o.id.toString() << " SysID:" << (void*) o.sysID << " " << o.managers.size() << " subsections " << o.volumes.size() diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 4979bfac0..3ab070da8 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -35,26 +35,37 @@ using namespace DD4hep::Geometry; namespace DD4hep { namespace Geometry { - struct DD_TGeoNodeMatrix : public TGeoNodeMatrix { + struct DDExtension { TGeoExtension* m_extension; - DD_TGeoNodeMatrix(const TGeoVolume* v, const TGeoMatrix* m) - : TGeoNodeMatrix(v, m), m_extension(0) { - INCREMENT_COUNTER; - } - DD_TGeoNodeMatrix(const DD_TGeoNodeMatrix& c) - : TGeoNodeMatrix(c.GetVolume(), c.GetMatrix()), m_extension(0) { + DDExtension() : m_extension(0) {} + DDExtension(const DDExtension& c) : m_extension(0) { if ( c.m_extension ) m_extension = c.m_extension->Grab(); - INCREMENT_COUNTER; } - virtual ~DD_TGeoNodeMatrix() { + virtual ~DDExtension() { if ( m_extension ) m_extension->Release(); - DECREMENT_COUNTER; } void SetUserExtension(TGeoExtension *ext) { if (m_extension) m_extension->Release(); m_extension = 0; if (ext) m_extension = ext->Grab(); } + TGeoExtension* GetUserExtension() const { + return m_extension; + } + }; + struct DD_TGeoNodeMatrix : public TGeoNodeMatrix, public DDExtension { + TGeoExtension* m_extension; + DD_TGeoNodeMatrix(const TGeoVolume* v, const TGeoMatrix* m) + : TGeoNodeMatrix(v, m), DDExtension() { + INCREMENT_COUNTER; + } + DD_TGeoNodeMatrix(const DD_TGeoNodeMatrix& c) + : TGeoNodeMatrix(c.GetVolume(), c.GetMatrix()), DDExtension(c) { + INCREMENT_COUNTER; + } + virtual ~DD_TGeoNodeMatrix() { + DECREMENT_COUNTER; + } virtual TGeoNode *MakeCopyNode() const { TGeoNodeMatrix *node = new DD_TGeoNodeMatrix(*this); node->SetName(this->TGeoNodeMatrix::GetName()); @@ -80,17 +91,13 @@ namespace DD4hep { } }; - template <class T> struct _VolWrap: public T { - TGeoExtension* m_extension; - _VolWrap(const char* name, TGeoShape* s = 0, TGeoMedium* m = 0); + template <class T> struct _VolWrap: public T, public DDExtension { + _VolWrap(const char* name) : T(name), DDExtension() { + INCREMENT_COUNTER; + } virtual ~_VolWrap() { - if ( m_extension ) m_extension->Release(); - m_extension = 0; DECREMENT_COUNTER; } - TGeoExtension* GetUserExtension() const { - return m_extension; - } virtual void AddNode(const TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat, Option_t* = "") { TGeoMatrix *matrix = mat; if (matrix == 0) @@ -128,22 +135,18 @@ namespace DD4hep { } }; - template <> _VolWrap<TGeoVolume>::_VolWrap(const char* name, TGeoShape* s, TGeoMedium* m) - : TGeoVolume(name, s, m), m_extension(0) { + template <> _VolWrap<TGeoVolume>::_VolWrap(const char* name) : TGeoVolume(name,0,0), DDExtension() { INCREMENT_COUNTER; - } - template <> _VolWrap<TGeoVolumeAssembly>::_VolWrap(const char* name, TGeoShape* /* s */, TGeoMedium* /* m */) - : TGeoVolumeAssembly(name), m_extension(0) { - INCREMENT_COUNTER; - } + } struct TGeoVolumeValue : public _VolWrap<TGeoVolume> { - TGeoVolumeValue(const char* name) : _VolWrap<TGeoVolume>(name, 0, 0) { } + TGeoVolumeValue(const char* name, TGeoShape* s, TGeoMedium* m) : _VolWrap<TGeoVolume>(name) { + SetShape(s); + SetMedium(m); + } virtual ~TGeoVolumeValue() { } TGeoVolume *_copyVol(TGeoShape *newshape) const { - TGeoVolumeValue *vol = new TGeoVolumeValue(this->TGeoVolume::GetName()); - vol->SetShape(newshape); - vol->SetMedium(fMedium); + TGeoVolumeValue *vol = new TGeoVolumeValue(this->TGeoVolume::GetName(),newshape,fMedium); if ( m_extension ) vol->m_extension = m_extension->Grab(); //vol->copy(*this); return vol; @@ -206,7 +209,7 @@ namespace DD4hep { }; struct TGeoVolumeAssemblyValue : public _VolWrap<TGeoVolumeAssembly> { - TGeoVolumeAssemblyValue(const char* name) : _VolWrap<TGeoVolumeAssembly>(name, 0, 0) { + TGeoVolumeAssemblyValue(const char* name) : _VolWrap<TGeoVolumeAssembly>(name) { } virtual ~TGeoVolumeAssemblyValue() { } @@ -246,34 +249,15 @@ namespace DD4hep { } } -typedef DD_TGeoNodeMatrix geo_node_t; +typedef DD_TGeoNodeMatrix geo_node_t; +typedef TGeoVolumeValue geo_volume_t; +typedef TGeoVolumeAssemblyValue geo_assembly_t; -TGeoVolume* _createTGeoVolume(const string& name, TGeoShape* s, TGeoMedium* m) { - TGeoVolume* v = new TGeoVolumeValue(name.c_str()); - v->SetShape(s); - v->SetMedium(m); - return v; -} -TGeoVolume* _createTGeoVolumeAssembly(const string& name) { - return new TGeoVolumeAssemblyValue(name.c_str()); -} -PlacedVolume::Object* _userExtension(const PlacedVolume& v) { - geo_node_t* n = dynamic_cast<geo_node_t*>(v.ptr()); - // The above dynamic_cast fails for the top-level volume, where the placement is set by the - // TGeoManager. This volume will not have a placement.... - return (PlacedVolume::Object*)(n ? n->m_extension : 0); -} -Volume::Object* _userExtension(const Volume& v) { - const TGeoVolume* vol = v.ptr(); - if ( vol->IsA() == TGeoVolume::Class() ) { - const TGeoVolumeValue* o = dynamic_cast<const TGeoVolumeValue*>(v.ptr()); - return (Volume::Object*)(o ? o->GetUserExtension() : 0); - } - else if ( vol->IsA() == TGeoVolumeAssembly::Class() ) { - const TGeoVolumeAssemblyValue* o = dynamic_cast<const TGeoVolumeAssemblyValue*>(v.ptr()); - return (Volume::Object*)(o ? o->GetUserExtension() : 0); - } - return 0; +template <typename T> static typename T::Object* _userExtension(const T& v) { + typedef typename T::Object O; + const DDExtension* p = dynamic_cast<const DDExtension*>(v.ptr()); + O* o = (O*)(p ? p->GetUserExtension() : 0); + return o; } #else @@ -284,17 +268,9 @@ Volume::Object* _userExtension(const Volume& v) { * M.Frank */ -typedef TGeoNode geo_node_t; -TGeoVolume* _createTGeoVolume(const string& name, TGeoShape* s, TGeoMedium* m) { - TGeoVolume* e = new TGeoVolume(name.c_str(),s,m); - e->SetUserExtension(new Volume::Object()); - return e; -} -TGeoVolume* _createTGeoVolumeAssembly(const string& name) { - TGeoVolume* e = new TGeoVolumeAssembly(name.c_str()); // It is important to use the correct constructor!! - e->SetUserExtension(new Assembly::Object()); - return e; -} +typedef TGeoNode geo_node_t; +typedef TGeoVolume geo_volume_t; +typedef TGeoVolumeAssembly geo_assembly_t; template <typename T> static typename T::Object* _userExtension(const T& v) { typedef typename T::Object O; O* o = (O*)(v.ptr()->GetUserExtension()); @@ -302,16 +278,27 @@ template <typename T> static typename T::Object* _userExtension(const T& v) { } #endif +static TGeoVolume* _createTGeoVolume(const string& name, TGeoShape* s, TGeoMedium* m) { + geo_volume_t* e = new geo_volume_t(name.c_str(),s,m); + e->SetUserExtension(new Volume::Object()); + return e; +} +static TGeoVolume* _createTGeoVolumeAssembly(const string& name) { + geo_assembly_t* e = new geo_assembly_t(name.c_str()); // It is important to use the correct constructor!! + e->SetUserExtension(new Assembly::Object()); + return e; +} + /// Default constructor PlacedVolume::Object::Object() - : TGeoExtension(), magic(0), refCount(-1), volIDs(), detector() { + : TGeoExtension(), magic(0), refCount(0), volIDs(), detector() { magic = magic_word(); INCREMENT_COUNTER; } /// Copy constructor PlacedVolume::Object::Object(const Object& c) - : TGeoExtension(), magic(c.magic), refCount(-1), volIDs(c.volIDs), detector(c.detector) { + : TGeoExtension(), magic(c.magic), refCount(0), volIDs(c.volIDs), detector(c.detector) { INCREMENT_COUNTER; } @@ -322,13 +309,12 @@ PlacedVolume::Object::~Object() { /// TGeoExtension overload: Method called whenever requiring a pointer to the extension TGeoExtension* PlacedVolume::Object::Grab() { - Object* ext = const_cast<Object*>(this); - ++ext->refCount; + ++this->refCount; #ifdef ___print_vols if ( detector.ptr() ) cout << "Placement grabbed with valid detector element....." << endl; else cout << "Placement grabbed....." << endl; #endif - return ext; + return this; } /// TGeoExtension overload: Method called always when the pointer to the extension is not needed anymore @@ -571,6 +557,7 @@ const Volume& Volume::setVisAttributes(const VisAttr& attr) const { m_element->SetFillStyle(1001); // Root: solid } else { + //m_element->SetStyle(); m_element->SetFillColor(0); m_element->SetFillStyle(0); // Root: hollow } @@ -586,7 +573,8 @@ const Volume& Volume::setVisAttributes(const VisAttr& attr) const { m_element->SetAttBit(TGeoAtt::kVisContainers, kTRUE); m_element->SetVisDaughters(vis->showDaughters ? kTRUE : kFALSE); } - _data(*this)->vis = attr; + Volume::Object* o = _userExtension(*this); + if ( o ) o->vis = attr; return *this; } @@ -594,7 +582,6 @@ const Volume& Volume::setVisAttributes(const VisAttr& attr) const { const Volume& Volume::setVisAttributes(const LCDD& lcdd, const string& name) const { if (!name.empty()) { VisAttr attr = lcdd.visAttributes(name); - _data(*this)->vis = attr; setVisAttributes(attr); } else { diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 52251ad0a..732b2c924 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -79,7 +79,7 @@ static Ref_t create_ConstantField(lcdd_t& /* lcdd */, xml_h e) { obj.assign(ptr, field.nameStr(), field.typeStr()); return obj; } -DECLARE_XMLELEMENT(ConstantField,create_ConstantField); +DECLARE_XMLELEMENT(ConstantField,create_ConstantField) static Ref_t create_SolenoidField(lcdd_t& lcdd, xml_h e) { xml_comp_t c(e); @@ -126,9 +126,9 @@ static Ref_t create_SolenoidField(lcdd_t& lcdd, xml_h e) { obj.assign(ptr, c.nameStr(), c.typeStr()); return obj; } -DECLARE_XMLELEMENT(SolenoidMagnet,create_SolenoidField); +DECLARE_XMLELEMENT(SolenoidMagnet,create_SolenoidField) // This is the plugin required for slic: note the different name -DECLARE_XMLELEMENT(solenoid,create_SolenoidField); +DECLARE_XMLELEMENT(solenoid,create_SolenoidField) static Ref_t create_DipoleField(lcdd_t& /* lcdd */, xml_h e) { xml_comp_t c(e); @@ -150,14 +150,14 @@ static Ref_t create_DipoleField(lcdd_t& /* lcdd */, xml_h e) { obj.assign(ptr, c.nameStr(), c.typeStr()); return obj; } -DECLARE_XMLELEMENT(DipoleMagnet,create_DipoleField); +DECLARE_XMLELEMENT(DipoleMagnet,create_DipoleField) static long create_Compact(lcdd_t& lcdd, xml_h element) { Converter < Compact > converter(lcdd); converter(element); return 1; } -DECLARE_XML_DOC_READER(lccdd,create_Compact); +DECLARE_XML_DOC_READER(lccdd,create_Compact) /** Convert compact constant objects (defines) * @@ -580,7 +580,6 @@ template <> void Converter<CartesianField>::operator()(xml_h e) const { template <> void Converter<SensitiveDetector>::operator()(xml_h element) const { string name = element.attr < string > (_U(name)); try { - DetElement det = lcdd.detector(name); SensitiveDetector sd = lcdd.sensitiveDetector(name); xml_attr_t type = element.attr_nothrow(_U(type)); diff --git a/DDCore/src/plugins/Geant4XML.cpp b/DDCore/src/plugins/Geant4XML.cpp index dc0c7acde..1c1fd9ca2 100644 --- a/DDCore/src/plugins/Geant4XML.cpp +++ b/DDCore/src/plugins/Geant4XML.cpp @@ -38,13 +38,13 @@ static long create_Geant4(lcdd_t& lcdd, const xml_h& element) { (Converter < Geant4 > (lcdd))(element); return 1; } -DECLARE_XML_DOC_READER(geant4,create_Geant4); +DECLARE_XML_DOC_READER(geant4,create_Geant4) static Ref_t handle_Geant4(lcdd_t& lcdd, const xml_h& element) { (Converter < Geant4 > (lcdd))(element); return Ref_t(0); } -DECLARE_XMLELEMENT(geant4_xml_setup,handle_Geant4); +DECLARE_XMLELEMENT(geant4_xml_setup,handle_Geant4) #include <iostream> using namespace std; @@ -61,4 +61,4 @@ static long handle_blabla(lcdd_t& lcdd, const xml_h& element) { (Converter<Blabla>(lcdd))(element); return 1; } -DECLARE_XML_DOC_READER(blabla,handle_blabla); +DECLARE_XML_DOC_READER(blabla,handle_blabla) diff --git a/DDCore/src/plugins/LCDDConverter.cpp b/DDCore/src/plugins/LCDDConverter.cpp index db55f19e6..f1054fa3e 100644 --- a/DDCore/src/plugins/LCDDConverter.cpp +++ b/DDCore/src/plugins/LCDDConverter.cpp @@ -99,7 +99,7 @@ LCDDConverter::~LCDDConverter() { } /// Dump element in GDML format to output stream -xml_h LCDDConverter::handleElement(const string& name, const TGeoElement* element) const { +xml_h LCDDConverter::handleElement(const string& /* name */, const TGeoElement* element) const { GeometryInfo& geo = data(); xml_h e = geo.xmlElements[element]; if (!e) { @@ -316,7 +316,7 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con solid.setAttr(_U(numsides), s->GetNedges()); solid.setAttr(_U(aunit), "rad"); solid.setAttr(_U(lunit), "mm"); - for (size_t i = 0; i < s->GetNz(); ++i) { + for (Int_t i = 0; i < s->GetNz(); ++i) { zplane = xml_elt_t(geo.doc, _U(zplane)); zplane.setAttr(_U(rmin), s->GetRmin(i) * CM_2_MM); zplane.setAttr(_U(rmax), s->GetRmax(i) * CM_2_MM); @@ -332,7 +332,7 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con solid.setAttr(_U(deltaphi), s->GetDphi() * DEGREE_2_RAD); solid.setAttr(_U(aunit), "rad"); solid.setAttr(_U(lunit), "mm"); - for (size_t i = 0; i < s->GetNz(); ++i) { + for (Int_t i = 0; i < s->GetNz(); ++i) { zplane = xml_elt_t(geo.doc, _U(zplane)); zplane.setAttr(_U(rmin), s->GetRmin(i) * CM_2_MM); zplane.setAttr(_U(rmax), s->GetRmax(i) * CM_2_MM); @@ -470,7 +470,6 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con solid.setAttr(_U(name), Unicode(name)); first.setAttr(_U(ref), ls->GetName()); const double *tr = lm->GetTranslation(); - double phi = 0., theta = 0., psi = 0.; if ((tr[0] != 0.0) || (tr[1] != 0.0) || (tr[2] != 0.0)) { first.append(obj = xml_elt_t(geo.doc, _U(firstposition))); @@ -493,7 +492,7 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con tr = rm->GetTranslation(); solid.append(second = xml_elt_t(geo.doc, _U(second))); second.setAttr(_U(ref), rs->GetName()); - ::snprintf(text, sizeof(text), "_%p_", rm); + ::snprintf(text, sizeof(text), "_%p_", (void*)rm); string rnam = rs->GetName(); rnam += text; if ((tr[0] != 0.0) || (tr[1] != 0.0) || (tr[2] != 0.0)) { @@ -651,7 +650,7 @@ xml_h LCDDConverter::handleVolume(const string& name, const TGeoVolume* volume) } /// Dump logical volume in GDML format to output stream -xml_h LCDDConverter::handleVolumeVis(const string& name, const TGeoVolume* volume) const { +xml_h LCDDConverter::handleVolumeVis(const string& /* name */, const TGeoVolume* volume) const { GeometryInfo& geo = data(); xml_h vol = geo.xmlVolumes[volume]; if (!vol) { @@ -672,7 +671,7 @@ xml_h LCDDConverter::handleVolumeVis(const string& name, const TGeoVolume* volum } /// Dump logical volume in GDML format to output stream -void LCDDConverter::collectVolume(const string& name, const TGeoVolume* volume) const { +void LCDDConverter::collectVolume(const string& /* name */, const TGeoVolume* volume) const { Volume v = Ref_t(volume); if (dynamic_cast<const Volume::Object*>(volume)) { GeometryInfo& geo = data(); @@ -729,9 +728,9 @@ xml_h LCDDConverter::handlePlacement(const string& name, const TGeoNode* node) c place.setRef(_U(volumeref), vol.name()); if (m) { char text[32]; - ::snprintf(text, sizeof(text), "_%p_pos", node); + ::snprintf(text, sizeof(text), "_%p_pos", (void*)node); xml_ref_t pos = handlePosition(name + text, m); - ::snprintf(text, sizeof(text), "_%p_rot", node); + ::snprintf(text, sizeof(text), "_%p_rot", (void*)node); xml_ref_t rot = handleRotation(name + text, m); place.setRef(_U(positionref), pos.name()); place.setRef(_U(rotationref), rot.name()); @@ -757,7 +756,7 @@ xml_h LCDDConverter::handlePlacement(const string& name, const TGeoNode* node) c } /// Convert the geometry type region into the corresponding LCDD object(s). -xml_h LCDDConverter::handleRegion(const std::string& name, const TNamed* region) const { +xml_h LCDDConverter::handleRegion(const std::string& /* name */, const TNamed* region) const { GeometryInfo& geo = data(); xml_h reg = geo.xmlRegions[region]; if (!reg) { @@ -774,7 +773,7 @@ xml_h LCDDConverter::handleRegion(const std::string& name, const TNamed* region) } /// Convert the geometry type LimitSet into the corresponding LCDD object(s) -xml_h LCDDConverter::handleLimitSet(const std::string& name, const TNamed* limitset) const { +xml_h LCDDConverter::handleLimitSet(const std::string& /* name */, const TNamed* limitset) const { GeometryInfo& geo = data(); xml_h xml = geo.xmlLimits[limitset]; if (!xml) { @@ -829,7 +828,7 @@ xml_h LCDDConverter::handleSegmentation(Segmentation seg) const { } /// Convert the geometry type SensitiveDetector into the corresponding LCDD object(s). -xml_h LCDDConverter::handleSensitive(const string& name, const TNamed* sens_det) const { +xml_h LCDDConverter::handleSensitive(const string& /* name */, const TNamed* sens_det) const { GeometryInfo& geo = data(); xml_h sensdet = geo.xmlSensDets[sens_det]; if (!sensdet) { @@ -891,7 +890,7 @@ xml_h LCDDConverter::handleIdSpec(const std::string& name, const TNamed* id_spec } /// Convert the geometry visualisation attributes to the corresponding LCDD object(s). -xml_h LCDDConverter::handleVis(const string& name, const TNamed* v) const { +xml_h LCDDConverter::handleVis(const string& /* name */, const TNamed* v) const { GeometryInfo& geo = data(); xml_h vis = geo.xmlVis[v]; if (!vis) { @@ -926,7 +925,7 @@ xml_h LCDDConverter::handleVis(const string& name, const TNamed* v) const { } /// Convert the electric or magnetic fields into the corresponding Xml object(s). -xml_h LCDDConverter::handleField(const std::string& name, const TNamed* f) const { +xml_h LCDDConverter::handleField(const std::string& /* name */, const TNamed* f) const { GeometryInfo& geo = data(); xml_h field = geo.xmlFields[f]; if (!field) { @@ -1097,7 +1096,6 @@ xml_doc_t LCDDConverter::createGDML(DetElement top) { /// Create geometry conversion xml_doc_t LCDDConverter::createVis(DetElement top) { - LCDD& lcdd = m_lcdd; if (!top.isValid()) { throw runtime_error("Attempt to call createLCDD with an invalid geometry!"); } @@ -1247,9 +1245,9 @@ static long create_vis(LCDD& lcdd, int argc, char** argv) { return dump_output(wr.createVis(lcdd.world()), argc, argv); } -static long create_visASCII(LCDD& lcdd, int argc, char** argv) { +static long create_visASCII(LCDD& lcdd, int /* argc */, char** argv) { LCDDConverter wr(lcdd); - xml_doc_t doc = wr.createVis(lcdd.world()); + /* xml_doc_t doc = */ wr.createVis(lcdd.world()); LCDDConverter::GeometryInfo& geo = wr.data(); map<string, xml_comp_t> vis_map; for (xml_coll_t c(geo.doc_display, _U(vis)); c; ++c) @@ -1271,7 +1269,7 @@ static long create_visASCII(LCDD& lcdd, int argc, char** argv) { return 1; } -DECLARE_APPLY(DD4hepGeometry2VIS, create_vis); -DECLARE_APPLY(DD4hepGeometry2VISASCII, create_visASCII); -DECLARE_APPLY(DD4hepGeometry2GDML, create_gdml); -DECLARE_APPLY(DD4hepGeometry2LCDD, create_lcdd); +DECLARE_APPLY(DD4hepGeometry2VIS, create_vis) +DECLARE_APPLY(DD4hepGeometry2VISASCII, create_visASCII) +DECLARE_APPLY(DD4hepGeometry2GDML, create_gdml) +DECLARE_APPLY(DD4hepGeometry2LCDD, create_lcdd) diff --git a/DDCore/src/plugins/LCDDFields.cpp b/DDCore/src/plugins/LCDDFields.cpp index 8f44c0202..bd81e49fc 100644 --- a/DDCore/src/plugins/LCDDFields.cpp +++ b/DDCore/src/plugins/LCDDFields.cpp @@ -13,7 +13,7 @@ using namespace DD4hep::Geometry; -static Ref_t convert_constant_field(LCDD& lcdd, xml_h field, Ref_t object) { +static Ref_t convert_constant_field(LCDD&, xml_h field, Ref_t object) { xml_doc_t doc = xml_elt_t(field).document(); ConstantField* s = object.data<ConstantField>(); field.setAttr(_U(lunit), "mm"); @@ -30,9 +30,9 @@ static Ref_t convert_constant_field(LCDD& lcdd, xml_h field, Ref_t object) { field.append(strength); return object; } -DECLARE_XML_PROCESSOR(ConstantField_Convert2LCDD,convert_constant_field); +DECLARE_XML_PROCESSOR(ConstantField_Convert2LCDD,convert_constant_field) -static Ref_t convert_solenoid(LCDD& lcdd, xml_h field, Ref_t object) { +static Ref_t convert_solenoid(LCDD&, xml_h field, Ref_t object) { char text[128]; SolenoidField* s = object.data<SolenoidField>(); field.setAttr(_U(lunit), "mm"); @@ -49,9 +49,9 @@ static Ref_t convert_solenoid(LCDD& lcdd, xml_h field, Ref_t object) { field.setAttr(_U(zmax), s->maxZ); return object; } -DECLARE_XML_PROCESSOR(solenoid_Convert2LCDD,convert_solenoid); +DECLARE_XML_PROCESSOR(solenoid_Convert2LCDD,convert_solenoid) -static Ref_t convert_dipole(LCDD& lcdd, xml_h field, Ref_t object) { +static Ref_t convert_dipole(LCDD&, xml_h field, Ref_t object) { char text[128]; xml_doc_t doc = xml_elt_t(field).document(); DipoleField* s = object.data<DipoleField>(); @@ -71,5 +71,5 @@ static Ref_t convert_dipole(LCDD& lcdd, xml_h field, Ref_t object) { } return object; } -DECLARE_XML_PROCESSOR(DipoleField_Convert2LCDD,convert_dipole); +DECLARE_XML_PROCESSOR(DipoleField_Convert2LCDD,convert_dipole) diff --git a/DDCore/src/plugins/PandoraConverter.cpp b/DDCore/src/plugins/PandoraConverter.cpp index 8c32a920f..d32daa0c1 100644 --- a/DDCore/src/plugins/PandoraConverter.cpp +++ b/DDCore/src/plugins/PandoraConverter.cpp @@ -101,7 +101,7 @@ PandoraConverter::~PandoraConverter() { } /// Create geometry conversion in Pandora XML format -xml_doc_t PandoraConverter::create(DetElement top) { +xml_doc_t PandoraConverter::create(DetElement /* top */) { const char empty_xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\">\n" "<!-- \n" " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" @@ -131,7 +131,7 @@ xml_doc_t PandoraConverter::create(DetElement top) { return geo.doc; } -static long create_lcdd(LCDD& lcdd, int argc, char** argv) { +static long create_lcdd(LCDD& /* lcdd */, int /* argc */, char** /* argv */) { throw runtime_error("The pandora xml conversion plugin is not yet implemented"); return 0; #if 0 @@ -889,4 +889,4 @@ public class Main implements Converter } #endif } -DECLARE_APPLY(DD4hepGeometry2PANDORA,create_lcdd); +DECLARE_APPLY(DD4hepGeometry2PANDORA,create_lcdd) diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index ddd084090..b1ac3fd66 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -24,7 +24,7 @@ using namespace DD4hep::Geometry; static void* create_lcdd_instance(const char* /* name */) { return &LCDD::getInstance(); } -DECLARE_CONSTRUCTOR(LCDD_constructor,create_lcdd_instance); +DECLARE_CONSTRUCTOR(LCDD_constructor,create_lcdd_instance) static long display(LCDD& lcdd, int argc, char** argv) { TGeoManager& mgr = lcdd.manager(); @@ -41,25 +41,28 @@ static long display(LCDD& lcdd, int argc, char** argv) { } return 0; } -DECLARE_APPLY(DD4hepGeometryDisplay,display); +DECLARE_APPLY(DD4hepGeometryDisplay,display) static long load_compact(LCDD& lcdd, int argc, char** argv) { - for (size_t j = 0; j < argc; ++j) { + for (int j = 0; j < argc; ++j) { string input = argv[j]; cout << "Processing compact input file : " << input << endl; lcdd.fromCompact(input); } return 1; } -DECLARE_APPLY(DD4hepCompactLoader,load_compact); +DECLARE_APPLY(DD4hepCompactLoader,load_compact) static long load_xml(LCDD& lcdd, int argc, char** argv) { - string input = argv[0]; - cout << "Processing compact input file : " << input << endl; - lcdd.fromXML(input); - return 1; + if ( argc >= 1 ) { + string input = argv[0]; + cout << "Processing compact input file : " << input << endl; + lcdd.fromXML(input); + return 1; + } + throw runtime_error("load_xml: Invalid number of arguments [argc=0]"); } -DECLARE_APPLY(DD4hepXMLLoader,load_xml); +DECLARE_APPLY(DD4hepXMLLoader,load_xml) static long load_volmgr(LCDD& lcdd, int, char**) { try { @@ -79,4 +82,5 @@ static long load_volmgr(LCDD& lcdd, int, char**) { } return 0; } -DECLARE_APPLY(DD4hepVolumeManager,load_volmgr); +DECLARE_APPLY(DD4hepVolumeManager,load_volmgr) + -- GitLab