diff --git a/DetectorDescription/Core/interface/DDCompactView.h b/DetectorDescription/Core/interface/DDCompactView.h index f63e20c298553..a3d05c46628e4 100644 --- a/DetectorDescription/Core/interface/DDCompactView.h +++ b/DetectorDescription/Core/interface/DDCompactView.h @@ -111,6 +111,9 @@ class DDCompactView //! returns the DDLogicalPart representing the root of the geometrical hierarchy const DDLogicalPart & root() const; + + //! The absolute position of the world + DDPosData * worldPosition() const; //! Prototype version of calculating the weight of a detector component double weight(const DDLogicalPart & p) const; @@ -155,10 +158,10 @@ class DDCompactView void lockdown(); - protected: - DDCompactViewImpl* rep_; - private: + std::unique_ptr rep_; + std::unique_ptr worldpos_ ; + // 2010-01-27 memory patch // for copying and protecting DD Store's after parsing is complete. DDI::Store matStore_; diff --git a/DetectorDescription/Core/interface/DDExpandedView.h b/DetectorDescription/Core/interface/DDExpandedView.h index 36ea9f117a41a..0bb0228a2a542 100644 --- a/DetectorDescription/Core/interface/DDExpandedView.h +++ b/DetectorDescription/Core/interface/DDExpandedView.h @@ -135,7 +135,6 @@ class DDExpandedView unsigned int depth_; //!< depth of the scope, 0==unrestricted depth DDPosData * worldpos_ ; //!< ??? std::vector nextBStack_; - //std::map dummySpecifics_; }; std::ostream & printNavType(std::ostream &, int const * n, size_t sz); diff --git a/DetectorDescription/Core/src/DDCompactView.cc b/DetectorDescription/Core/src/DDCompactView.cc index 8293b5b5410e9..66ce4553cfd7a 100644 --- a/DetectorDescription/Core/src/DDCompactView.cc +++ b/DetectorDescription/Core/src/DDCompactView.cc @@ -15,8 +15,6 @@ #include -//DDCompactViewmpl * DDCompactView::global_ = 0; - /** Compact-views can be created only after an appropriate geometrical hierarchy has been defined using DDpos(). @@ -35,7 +33,8 @@ */ // DDCompactView::DDCompactView(const DDLogicalPart & rootnodedata) - : rep_(new DDCompactViewImpl(rootnodedata)) + : rep_( new DDCompactViewImpl( rootnodedata )), + worldpos_( new DDPosData( DDTranslation(), DDRotation(), 0 )) { // 2010-01-27 I am leaving this here so that we are sure the global stores // are open when a new DDCompactView is being made. Eventually I want to @@ -48,11 +47,7 @@ DDCompactView::DDCompactView(const DDLogicalPart & rootnodedata) } DDCompactView::~DDCompactView() -{ - if (rep_ != 0) { - delete rep_; - } -} +{} /** The compact-view is kept in an acyclic directed multigraph represented @@ -70,10 +65,14 @@ DDCompactView::graph_type & DDCompactView::writeableGraph() } const DDLogicalPart & DDCompactView::root() const -{ +{ return rep_->root(); } - + +DDPosData* DDCompactView::worldPosition() const +{ + return worldpos_.get(); +} DDCompactView::walker_type DDCompactView::walker() const { @@ -166,7 +165,10 @@ void DDCompactView::swap( DDCompactView& repToSwap ) { rep_->swap ( *(repToSwap.rep_) ); } -DDCompactView::DDCompactView() : rep_(new DDCompactViewImpl) { } +DDCompactView::DDCompactView() + : rep_(new DDCompactViewImpl), + worldpos_( new DDPosData( DDTranslation(), DDRotation(), 0 )) +{ } void DDCompactView::lockdown() { // at this point we should have a valid store of DDObjects and we will move these diff --git a/DetectorDescription/Core/src/DDCompactViewImpl.cc b/DetectorDescription/Core/src/DDCompactViewImpl.cc index 5914dadd33f20..49d26b6105541 100644 --- a/DetectorDescription/Core/src/DDCompactViewImpl.cc +++ b/DetectorDescription/Core/src/DDCompactViewImpl.cc @@ -33,8 +33,7 @@ DDCompactViewImpl::~DDCompactViewImpl() graphwalker DDCompactViewImpl::walker() const { - DCOUT('C',"DDCompactView::walker() root_=" << root_); - return graphwalker(graph_,root_); + return graphwalker(graph_,root_); } // calculates the weight and caches it in LogicalPartImpl diff --git a/DetectorDescription/Core/src/DDExpandedNode.cc b/DetectorDescription/Core/src/DDExpandedNode.cc index 2ce35cd514dc9..193ef89ad9246 100644 --- a/DetectorDescription/Core/src/DDExpandedNode.cc +++ b/DetectorDescription/Core/src/DDExpandedNode.cc @@ -22,7 +22,8 @@ bool DDExpandedNode::operator==(const DDExpandedNode & n) const { int DDExpandedNode::copyno() const -{ +{ + assert( posd_ ); return posd_->copyno_; } diff --git a/DetectorDescription/Core/src/DDExpandedView.cc b/DetectorDescription/Core/src/DDExpandedView.cc index b56e2eb9e4702..81bf45ef69542 100644 --- a/DetectorDescription/Core/src/DDExpandedView.cc +++ b/DetectorDescription/Core/src/DDExpandedView.cc @@ -4,26 +4,19 @@ /** After construction the instance corresponds to the root of the geometrical tree. */ -DDExpandedView::DDExpandedView(const DDCompactView & cpv) - : walker_(0),w2_(cpv.graph(),cpv.root()), trans_(DDTranslation()), rot_(DDRotationMatrix()), - depth_(0), worldpos_(0) +DDExpandedView::DDExpandedView( const DDCompactView & cpv ) + : walker_(0), + w2_(cpv.graph(),cpv.root()), + trans_( DDTranslation()), + rot_( DDRotationMatrix()), + depth_( 0 ), + worldpos_( cpv.worldPosition()) { - // std::cout << "Building a DDExpandedView" << std::endl; - // MEC:2010-02-08 - consider the ROOT as where you want to start LOOKING at - // the DDD, and worldpos_ as the "real" root node of the graph. MOVE all this - // logic to DDCompactView. This should really be just the traverser... - DDRotation::StoreT::instance().setReadOnly(false); - worldpos_ = new DDPosData(DDTranslation(),DDRotation(),0); - DDRotation::StoreT::instance().setReadOnly(true); - walker_ = &w2_; - // std::cout << "Walker: current.first=" << (*walker_).current().first << std::endl; - // std::cout << "Walker: current.second=" << (*walker_).current().second << std::endl; - DDPosData * pd((*walker_).current().second); if (!pd) - pd = worldpos_; + pd = worldpos_; DDExpandedNode expn((*walker_).current().first, pd, trans_, @@ -34,10 +27,8 @@ DDExpandedView::DDExpandedView(const DDCompactView & cpv) history_.push_back(expn); } - DDExpandedView::~DDExpandedView() { } - const DDLogicalPart & DDExpandedView::logicalPart() const { return history_.back().logp_; @@ -174,17 +165,6 @@ bool DDExpandedView::firstChild() newTrans, newRot, 0); history_.push_back(expn); - - /* debug output - edm::LogInfo("DDExpandedView") << "FIRSTCHILD: name=" << expn.logicalPart().ddname() - << " rot="; - - if (expn.absRotation().isIdentity()) - edm::LogInfo("DDExpandedView") << "[none]" << std::endl; - else - edm::LogInfo("DDExpandedView") << expn.absRotation() << std::endl; - */ - result = true; } // if firstChild } // if depthNotReached @@ -280,10 +260,6 @@ void dump(const DDGeoHistory & h) int i=0; for (; it != h.end(); ++it) { edm::LogInfo("DDExpandedView") << " " << i << it->logicalPart() << std::endl; - /* - << " " << it->logicalPart().material() << std::endl - << " " << it->logicalPart().solid() << std::endl; - */ ++i; } edm::LogInfo("DDExpandedView") << "]---------" << std::endl; @@ -305,39 +281,32 @@ std::vector< const DDsvalues_type *> DDExpandedView::specifics() const return result; } -void DDExpandedView::specificsV(std::vector & result) const +void +DDExpandedView::specificsV(std::vector & result) const { unsigned int i(0); - //edm::LogInfo("DDExpandedView") << " in ::specifics " << std::endl; const std::vector > & specs = logicalPart().attachedSpecifics(); - if (specs.size()) { // do only if SpecPar has data defined - //edm::LogInfo("DDExpandedView") << " found: specifics size=" << specs.size() << std::endl; + if( specs.size()) + { result.reserve(specs.size()); for (; i& sp = specs[i]; // a part selection const DDPartSelection & psel = *(sp.first); - //edm::LogInfo("DDExpandedView") << " partsel.size = " << psel.size() << std::endl; - //edm::LogInfo("DDExpandedView") << " geohistory = " << geoHistory() << std::endl; const DDGeoHistory & hist = geoHistory(); - //dump(hist); - //dump(psel); - - if (DDCompareEqual(hist, psel)()) //edm::LogInfo("DDExpandedView") << "MATCH!!!!" << std::endl; + if (DDCompareEqual(hist, psel)()) result.push_back( sp.second ); } } } - DDsvalues_type DDExpandedView::mergedSpecifics() const { DDsvalues_type merged; mergedSpecificsV(merged); return merged; } - void DDExpandedView::mergedSpecificsV(DDsvalues_type & merged) const { @@ -351,10 +320,8 @@ void DDExpandedView::mergedSpecificsV(DDsvalues_type & merged) const if (DDCompareEqual(hist, psel)()) merge(merged,*sp.second); } - // std::sort(merged.begin(),merged.end()); } - /** All navigational commands only operate in the subtree rooted by the node marked by the node of the DDGeoHistory returned by this method. @@ -372,7 +339,6 @@ void DDExpandedView::clearScope() depth_=0; } - void DDExpandedView::reset() { clearScope(); @@ -577,37 +543,3 @@ std::ostream & printNavType(std::ostream & os, int const * n, size_t sz){ os << ')'; return os; } - - - -//THIS IS WRONG, THIS IS WRONG, THIS IS WRONG (not functional wrong but in any other case!) -//THIS IS WRONG, THIS IS STUPID, i bin a depp ... -/* -void doit(DDGeoHistory& h) { - DDRotationMatrix m1, m2, m3; - DDGeoHistory::size_type s(h.size()); - std::vector rotVec(s); - std::vector transVec(s); - - DDGeoHistory::size_type c(s); - for (int i=0; irot_; - transVec[i] = h[i].posd_->trans_; - } - - if (s>1) { - for (int i=1; irot_ * h[i].posd_->rot_; - } - - for (int i=1; i