Skip to content

Commit

Permalink
Make sure the Store is read-only. Make all the changes needed at a co…
Browse files Browse the repository at this point in the history
…mpact view construction.
  • Loading branch information
ianna committed Jul 1, 2014
1 parent b85ccfc commit 74753d8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 91 deletions.
5 changes: 5 additions & 0 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 @@ -159,6 +162,8 @@ class DDCompactView
DDCompactViewImpl* rep_;

private:
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
16 changes: 9 additions & 7 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 Down Expand Up @@ -45,13 +43,13 @@ DDCompactView::DDCompactView(const DDLogicalPart & rootnodedata)
DDLogicalPart::StoreT::instance().setReadOnly(false);
DDSpecifics::StoreT::instance().setReadOnly(false);
DDRotation::StoreT::instance().setReadOnly(false);
worldpos_ = new DDPosData( DDTranslation(), DDRotation(), 0 );
}

DDCompactView::~DDCompactView()
{
if (rep_ != 0) {
delete rep_;
}
delete rep_;
delete worldpos_;
}

/**
Expand All @@ -70,10 +68,14 @@ DDCompactView::graph_type & DDCompactView::writeableGraph()
}

const DDLogicalPart & DDCompactView::root() const
{
{
return rep_->root();
}


DDPosData* DDCompactView::worldPosition() const
{
return worldpos_;
}

DDCompactView::walker_type DDCompactView::walker() const
{
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
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];
}
*/

0 comments on commit 74753d8

Please sign in to comment.