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 Read Only View #4476

Merged
merged 4 commits into from Jul 3, 2014
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
9 changes: 6 additions & 3 deletions DetectorDescription/Core/interface/DDCompactView.h
Expand Up @@ -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;
Expand Down Expand Up @@ -155,10 +158,10 @@ class DDCompactView

void lockdown();

protected:
DDCompactViewImpl* rep_;

private:
std::unique_ptr<DDCompactViewImpl> rep_;
std::unique_ptr<DDPosData> worldpos_ ;

// 2010-01-27 memory patch
// for copying and protecting DD Store's after parsing is complete.
DDI::Store<DDName, DDI::Material*> matStore_;
Expand Down
1 change: 0 additions & 1 deletion DetectorDescription/Core/interface/DDExpandedView.h
Expand Up @@ -135,7 +135,6 @@ class DDExpandedView
unsigned int depth_; //!< depth of the scope, 0==unrestricted depth
DDPosData * worldpos_ ; //!< ???
std::vector<nav_type> nextBStack_;
//std::map<std::string,std::string> dummySpecifics_;
};

std::ostream & printNavType(std::ostream &, int const * n, size_t sz);
Expand Down
24 changes: 13 additions & 11 deletions DetectorDescription/Core/src/DDCompactView.cc
Expand Up @@ -15,8 +15,6 @@

#include <iostream>

//DDCompactViewmpl * DDCompactView::global_ = 0;

/**
Compact-views can be created only after an appropriate geometrical hierarchy
has been defined using DDpos().
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions DetectorDescription/Core/src/DDCompactViewImpl.cc
Expand Up @@ -33,8 +33,7 @@ DDCompactViewImpl::~DDCompactViewImpl()

graphwalker<DDLogicalPart,DDPosData*> DDCompactViewImpl::walker() const
{
DCOUT('C',"DDCompactView::walker() root_=" << root_);
return graphwalker<DDLogicalPart,DDPosData*>(graph_,root_);
return graphwalker<DDLogicalPart,DDPosData*>(graph_,root_);
}

// calculates the weight and caches it in LogicalPartImpl
Expand Down
3 changes: 2 additions & 1 deletion DetectorDescription/Core/src/DDExpandedNode.cc
Expand Up @@ -22,7 +22,8 @@ bool DDExpandedNode::operator==(const DDExpandedNode & n) const {


int DDExpandedNode::copyno() const
{
{
assert( posd_ );
return posd_->copyno_;
}

Expand Down
94 changes: 13 additions & 81 deletions DetectorDescription/Core/src/DDExpandedView.cc
Expand Up @@ -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_,
Expand All @@ -34,10 +27,8 @@ DDExpandedView::DDExpandedView(const DDCompactView & cpv)
history_.push_back(expn);
}


DDExpandedView::~DDExpandedView() { }


const DDLogicalPart & DDExpandedView::logicalPart() const
{
return history_.back().logp_;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -305,39 +281,32 @@ std::vector< const DDsvalues_type *> DDExpandedView::specifics() const
return result;
}

void DDExpandedView::specificsV(std::vector<const DDsvalues_type * > & result) const
void
DDExpandedView::specificsV(std::vector<const DDsvalues_type * > & result) const
{
unsigned int i(0);
//edm::LogInfo("DDExpandedView") << " in ::specifics " << std::endl;
const std::vector<std::pair<DDPartSelection*, DDsvalues_type*> > & 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<specs.size(); ++i) {
const std::pair<DDPartSelection*,DDsvalues_type*>& 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
{

Expand All @@ -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.
Expand All @@ -372,7 +339,6 @@ void DDExpandedView::clearScope()
depth_=0;
}


void DDExpandedView::reset()
{
clearScope();
Expand Down Expand Up @@ -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<DDRotationMatrix> rotVec(s);
std::vector<DDTranslation> transVec(s);

DDGeoHistory::size_type c(s);
for (int i=0; i<s; ++i) {
rotVec[i] = h[i].posd_->rot_;
transVec[i] = h[i].posd_->trans_;
}

if (s>1) {
for (int i=1; i<s; ++i) {
rotVec[i] = rotVec[i-1]*rotVec[i];
//h[i].rot_ = h[i-1].posd_->rot_ * h[i].posd_->rot_;
}

for (int i=1; i<s; ++i)
transVec[i] = transVec[i-1] + rotVec[i-1]*transVec[i];
//h[i].trans_ = h[i-1].trans_ + h[i-1].rot_ * h[i]
}
h[s-1].trans_ = transVec[s-1];
h[s-1].rot_ = rotVec[s-1];

}
*/