Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DD Cleanup: DD Compact View #23285

Merged
merged 2 commits into from May 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 3 additions & 23 deletions DetectorDescription/Core/interface/DDCompactView.h
Expand Up @@ -14,7 +14,6 @@
#include "DetectorDescription/Core/interface/DDPosData.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DataFormats/Math/interface/Graph.h"
#include "DataFormats/Math/interface/GraphWalker.h"

class DDCompactViewImpl;
class DDDivision;
Expand Down Expand Up @@ -82,24 +81,10 @@ Updated: Michael Case [ MEC ] 2010-02-11
these will be accessed via the DDCompactView.
*/
class DDCompactView
{

{
public:
//! container-type of children of a given node in the compact-view
typedef std::vector<DDLogicalPart> logchild_type;
using Graph = math::Graph<DDLogicalPart, DDPosData* >;

//! container-type of pairs of children nodes and their relative position data of a given node in the compact-view
typedef std::vector< std::pair<DDLogicalPart,DDPosData*> > poschildren_type;

//! pair ...
typedef std::pair<DDLogicalPart,DDPosData*> pos_type;

typedef math::GraphWalker<DDLogicalPart,DDPosData*> walker_type;

//! type of representation of the compact-view (acyclic directed multigraph)
/** Nodes are instances of DDLogicalPart, edges are pointers to instances of DDPosData */
typedef math::Graph<DDLogicalPart,DDPosData*> graph_type;

//! Creates a compact-view
explicit DDCompactView();

Expand All @@ -109,7 +94,7 @@ class DDCompactView
~DDCompactView();

//! Provides read-only access to the data structure of the compact-view.
const graph_type & graph() const;
const Graph & graph() const;

//! returns the DDLogicalPart representing the root of the geometrical hierarchy
const DDLogicalPart & root() const;
Expand Down Expand Up @@ -138,9 +123,6 @@ class DDCompactView
//! \b don't \b use : interface not stable ....
void setRoot(const DDLogicalPart & root);

//! \b dont't \b use ! Proper implementation missing ...
walker_type walker() const;

// ---------------------------------------------------------------
// +++ DDCore INTERNAL USE ONLY ++++++++++++++++++++++++++++++++++

Expand All @@ -159,6 +141,4 @@ class DDCompactView
DDI::Store<DDName, DDRotationMatrix*> rotStore_;
};

//! global type for a compact-view walker
typedef DDCompactView::walker_type walker_type;
#endif
4 changes: 0 additions & 4 deletions DetectorDescription/Core/interface/DDCompactViewImpl.h
Expand Up @@ -6,7 +6,6 @@
#include "DetectorDescription/Core/interface/DDPosData.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DataFormats/Math/interface/Graph.h"
#include "DataFormats/Math/interface/GraphWalker.h"

class DDDivision;
struct DDPosData;
Expand All @@ -16,7 +15,6 @@ class DDCompactViewImpl
public:

using GraphNav = math::Graph<DDLogicalPart, DDPosData* >;
using WalkerType = math::GraphWalker<DDLogicalPart, DDPosData* >;

explicit DDCompactViewImpl();
DDCompactViewImpl(const DDLogicalPart & rootnodedata);
Expand All @@ -31,8 +29,6 @@ class DDCompactViewImpl

const GraphNav & graph() const { return graph_; }

math::GraphWalker<DDLogicalPart,DDPosData*> walker() const;

void position (const DDLogicalPart & self,
const DDLogicalPart & parent,
int copyno,
Expand Down
12 changes: 5 additions & 7 deletions DetectorDescription/Core/interface/DDExpandedView.h
Expand Up @@ -16,6 +16,7 @@
#include "DetectorDescription/Core/interface/DDPosData.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DetectorDescription/Core/interface/DDsvalues.h"
#include "DataFormats/Math/interface/GraphWalker.h"

class DDFilteredView;
class DDLogicalPart;
Expand All @@ -42,6 +43,8 @@ class DDExpandedView
friend class DDFilteredView;

public:
using WalkerType = math::GraphWalker<DDLogicalPart, DDPosData* >;

//! std::vector of sibling numbers
typedef std::vector<int> nav_type;
typedef std::pair<int const *, size_t> NavRange;
Expand Down Expand Up @@ -119,20 +122,15 @@ class DDExpandedView
//! clears the scope and sets the ExpandedView to its root-node
void reset();

/** NOT IN THE PROTOTYPE
\todo void addNodeAction(const DDNodeAction &);

\todo bool removeNodeAction(const DDNodeAction &);
*/
/* was protected, now public; was named goTo, now goToHistory*/
bool goToHistory(const DDGeoHistory & sc);

protected:
bool descend(const DDGeoHistory & sc);

protected:
DDCompactView::walker_type * walker_; //!< the tricky walker
DDCompactView::walker_type w2_;
WalkerType * walker_; //!< the tricky walker
WalkerType w2_;
const DDTranslation trans_;
const DDRotationMatrix rot_;
DDGeoHistory history_; //!< std::vector of DDExpandedNode
Expand Down
17 changes: 8 additions & 9 deletions DetectorDescription/Core/src/DDCheck.cc
Expand Up @@ -45,8 +45,8 @@ bool DDCheckLP( const DDLogicalPart & lp , std::ostream & os )


// checks PosData* if it contains sensfull stuff ...
//:void DDCheckPD(const DDLogicalPart & lp, graph_type::neighbour_type & nb, std::ostream & os)
bool DDCheckPD(const DDLogicalPart & lp, DDCompactView::graph_type::edge_range nb, const DDCompactView::graph_type & g, std::ostream & os)
//:void DDCheckPD(const DDLogicalPart & lp, Graph::neighbour_type & nb, std::ostream & os)
bool DDCheckPD(const DDLogicalPart & lp, DDCompactView::Graph::edge_range nb, const DDCompactView::Graph & g, std::ostream & os)
{
bool result = false;
if (nb.first != nb.second) {
Expand Down Expand Up @@ -80,8 +80,7 @@ bool DDCheckConnect(const DDCompactView & cpv, std::ostream & os)

// Pass 1:
std::map<DDLogicalPart,bool> visited;
// walker_type wkr = DDCompactView().walker();
walker_type wkr = cpv.walker();
auto wkr = math::GraphWalker<DDLogicalPart, DDPosData*>( cpv.graph(), cpv.root());
visited[wkr.current().first]=true;
while(wkr.next()) {
// std::cout << "DDCheck" << " " << wkr.current().first << std::endl;
Expand All @@ -91,10 +90,10 @@ bool DDCheckConnect(const DDCompactView & cpv, std::ostream & os)
<< " (multiple-)connected LogicalParts with root=" << cpv.root().ddname() << std::endl;

// Pass 2:
DDCompactView::graph_type & g = const_cast<DDCompactView::graph_type&>(cpv.graph());
DDCompactView::Graph & g = const_cast<DDCompactView::Graph&>(cpv.graph());

int uc = 0;
DDCompactView::graph_type::adj_list::size_type it = 0;
DDCompactView::Graph::adj_list::size_type it = 0;

for(; it < g.size(); ++it) {
if (! visited[g.nodeData(it)] ) {
Expand Down Expand Up @@ -122,13 +121,13 @@ bool DDCheckConnect(const DDCompactView & cpv, std::ostream & os)
bool DDCheckAll(const DDCompactView & cpv, std::ostream & os)
{
bool result = false;
// const_cast because graph_type does not provide const_iterators!
DDCompactView::graph_type & g = const_cast<DDCompactView::graph_type&>(cpv.graph());
// const_cast because Graph does not provide const_iterators!
DDCompactView::Graph & g = const_cast<DDCompactView::Graph&>(cpv.graph());

// basic debuggger
std::map< std::pair<std::string,std::string>, int > lp_names;

DDCompactView::graph_type::adj_list::size_type it = 0;
DDCompactView::Graph::adj_list::size_type it = 0;
for(; it < g.size(); ++it) {
const DDLogicalPart & lp = g.nodeData(it);
lp_names[std::make_pair(lp.name().ns(),lp.name().name())]++;
Expand Down
7 changes: 1 addition & 6 deletions DetectorDescription/Core/src/DDCompactView.cc
Expand Up @@ -56,7 +56,7 @@ DDCompactView::~DDCompactView()
by an instance of class Graph<DDLogicalPart, DDPosData*).
Graph provides methods for navigating its content.
*/
const DDCompactView::graph_type & DDCompactView::graph() const
const DDCompactView::Graph & DDCompactView::graph() const
{
return rep_->graph();
}
Expand All @@ -71,11 +71,6 @@ const DDPosData* DDCompactView::worldPosition() const
return worldpos_.get();
}

DDCompactView::walker_type DDCompactView::walker() const
{
return rep_->walker();
}

void DDCompactView::position (const DDLogicalPart & self,
const DDLogicalPart & parent,
const std::string& copyno,
Expand Down
7 changes: 0 additions & 7 deletions DetectorDescription/Core/src/DDCompactViewImpl.cc
@@ -1,7 +1,6 @@
#include "DetectorDescription/Core/interface/DDCompactViewImpl.h"
#include "DetectorDescription/Core/interface/DDName.h"
#include "DetectorDescription/Core/interface/DDPosData.h"
#include "DataFormats/Math/interface/GraphWalker.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

DDCompactViewImpl::DDCompactViewImpl( const DDLogicalPart & rootnodedata )
Expand Down Expand Up @@ -29,12 +28,6 @@ DDCompactViewImpl::~DDCompactViewImpl()
edm::LogInfo("DDCompactViewImpl") << std::endl << "DDD transient representation has been destructed." << std::endl << std::endl;
}

math::GraphWalker<DDLogicalPart, DDPosData*>
DDCompactViewImpl::walker() const
{
return math::GraphWalker<DDLogicalPart, DDPosData*>( graph_, root_);
}

void
DDCompactViewImpl::position( const DDLogicalPart & self,
const DDLogicalPart & parent,
Expand Down
6 changes: 3 additions & 3 deletions DetectorDescription/Core/src/DDExpandedView.cc
Expand Up @@ -19,7 +19,7 @@ class DDPartSelection;
After construction the instance corresponds to the root of the geometrical tree.
*/
DDExpandedView::DDExpandedView( const DDCompactView & cpv )
: walker_(nullptr),
: walker_( nullptr ),
w2_( cpv.graph(), cpv.root()),
trans_( DDTranslation()),
rot_( DDRotationMatrix()),
Expand Down Expand Up @@ -92,7 +92,7 @@ bool DDExpandedView::nextSibling()
else {
if ((*walker_).nextSibling()) {
DDExpandedNode & expn(history_.back()); // back of history_ is always current node
DDCompactView::walker_type::value_type curr = (*walker_).current();
WalkerType::value_type curr = (*walker_).current();
DDPosData const * posdOld = expn.posd_;
expn.logp_=curr.first;
expn.posd_=curr.second;
Expand Down Expand Up @@ -142,7 +142,7 @@ bool DDExpandedView::firstChild()
if (depthNotReached) {
if ((*walker_).firstChild()) {
DDExpandedNode & expnBefore(history_.back());
DDCompactView::walker_type::value_type curr = (*walker_).current();
WalkerType::value_type curr = (*walker_).current();

DDPosData * newPosd = curr.second;

Expand Down
12 changes: 7 additions & 5 deletions DetectorDescription/OfflineDBLoader/plugins/OutputDDToDDL.cc
Expand Up @@ -103,7 +103,10 @@ OutputDDToDDL::beginRun( const edm::Run&, edm::EventSetup const& es )
edm::ESTransientHandle<DDCompactView> pDD;
es.get<IdealGeometryRecord>().get( pDD );

DDCompactView::DDCompactView::graph_type gra = pDD->graph();
using Graph = DDCompactView::Graph;
using adjl_iterator = Graph::const_adj_iterator;

const auto& gra = pDD->graph();
// temporary stores:
std::set<DDLogicalPart> lpStore;
std::set<DDMaterial> matStore;
Expand Down Expand Up @@ -133,12 +136,11 @@ OutputDDToDDL::beginRun( const edm::Run&, edm::EventSetup const& es )
std::string ns_ = out.ns_;

(*m_xos) << std::fixed << std::setprecision(18);
typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;

adjl_iterator git = gra.begin();
adjl_iterator gend = gra.end();

DDCompactView::graph_type::index_type i=0;
Graph::index_type i=0;
(*m_xos) << "<PosPartSection label=\"" << ns_ << "\">" << std::endl;
git = gra.begin();
for( ; git != gend; ++git ) {
Expand All @@ -152,8 +154,8 @@ OutputDDToDDL::beginRun( const edm::Run&, edm::EventSetup const& es )
++i;
if( !git->empty()) {
// ask for children of ddLP
DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
auto cit = git->begin();
auto cend = git->end();
for( ; cit != cend; ++cit ) {
const DDLogicalPart & ddcurLP = gra.nodeData( cit->first );
if( lpStore.find( ddcurLP ) != lpStore.end()) {
Expand Down
Expand Up @@ -105,7 +105,7 @@ OutputMagneticFieldDDToDDL::beginRun( const edm::Run&, edm::EventSetup const& es
edm::ESTransientHandle<DDCompactView> pDD;
es.get<IdealMagneticFieldRecord>().get( pDD );

DDCompactView::DDCompactView::graph_type gra = pDD->graph();
const auto& gra = pDD->graph();

// Temporary stores:
std::set<DDLogicalPart> lpStore;
Expand Down Expand Up @@ -143,12 +143,13 @@ OutputMagneticFieldDDToDDL::beginRun( const edm::Run&, edm::EventSetup const& es

( *m_xos ) << std::fixed << std::setprecision( 18 );

typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
using Graph = DDCompactView::Graph;
using adjl_iterator = Graph::const_adj_iterator;

adjl_iterator git = gra.begin();
adjl_iterator gend = gra.end();

DDCompactView::graph_type::index_type i=0;
Graph::index_type i=0;
( *m_xos) << "<PosPartSection label=\"" << ns_ << "\">\n";
git = gra.begin();
for( ; git != gend; ++git )
Expand All @@ -165,8 +166,8 @@ OutputMagneticFieldDDToDDL::beginRun( const edm::Run&, edm::EventSetup const& es
if( !git->empty())
{
// ask for children of ddLP
DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
auto cit = git->begin();
auto cend = git->end();
for( ; cit != cend; ++cit )
{
const DDLogicalPart & ddcurLP = gra.nodeData( cit->first );
Expand Down
8 changes: 5 additions & 3 deletions DetectorDescription/OfflineDBLoader/src/GeometryInfoDump.cc
Expand Up @@ -15,6 +15,9 @@
#include <set>
#include <vector>

using Graph = DDCompactView::Graph;
using adjl_iterator = Graph::const_adj_iterator;

GeometryInfoDump::GeometryInfoDump () { }

GeometryInfoDump::~GeometryInfoDump () { }
Expand Down Expand Up @@ -65,12 +68,11 @@ void GeometryInfoDump::dumpInfo ( bool dumpHistory, bool dumpSpecs, bool dumpPos
// final destination of the DDSpecifics
std::string dsname = "dumpSpecs" + fname;
std::ofstream dump(dsname.c_str());
DDCompactView::DDCompactView::graph_type gra = cpv.graph();
const auto& gra = cpv.graph();
std::set<DDLogicalPart> lpStore;
typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
adjl_iterator git = gra.begin();
adjl_iterator gend = gra.end();
DDCompactView::graph_type::index_type i=0;
Graph::index_type i=0;
for (; git != gend; ++git)
{
const DDLogicalPart & ddLP = gra.nodeData(git);
Expand Down
11 changes: 6 additions & 5 deletions DetectorDescription/Parser/test/dumpDDCompactView.cpp
Expand Up @@ -23,7 +23,8 @@

int main(int argc, char *argv[])
{
typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
using Graph = DDCompactView::Graph;
using adjl_iterator = Graph::const_adj_iterator;

// Copied from example stand-alone program in Message Logger July 18, 2007
std::string const kProgramName = argv[0];
Expand Down Expand Up @@ -92,17 +93,17 @@ int main(int argc, char *argv[])
// cpv.setRoot(DDLogicalPart(DDName("cms:World")));

std::cout << "edge size of produce graph:" << cpv.graph().edge_size() << std::endl;
const DDCompactView::graph_type& gt = cpv.graph();
const auto& gt = cpv.graph();
adjl_iterator git = gt.begin();
adjl_iterator gend = gt.end();

DDCompactView::graph_type::index_type i=0;
Graph::index_type i=0;
for (; git != gend; ++git) {
const DDLogicalPart & ddLP = gt.nodeData(git);
std::cout << ++i << " P " << ddLP.name() << std::endl;
if (!git->empty()) {
DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
auto cit = git->begin();
auto cend = git->end();
for (; cit != cend; ++cit) {
const DDLogicalPart & ddcurLP = gt.nodeData(cit->first);
std::cout << ++i << " c--> " << gt.edgeData(cit->second)->copyno() << " " << ddcurLP.name() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion DetectorDescription/Parser/test/dumpDDExpandedView.cpp
Expand Up @@ -70,7 +70,7 @@ int main(int argc, char *argv[])
std::cout << "main::initialize DDL parser\n";

DDCompactView cpv;
DDLParser myP(cpv);// = DDLParser::instance();
DDLParser myP(cpv);

std::cout << "main::about to start parsing main configuration... \n";
FIPConfiguration dp(cpv);
Expand Down