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 Offline DB Loader Cleanup #9590

Merged
merged 6 commits into from Jun 14, 2015
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
14 changes: 3 additions & 11 deletions DetectorDescription/Core/interface/DDSpecifics.h
@@ -1,7 +1,6 @@
#ifndef DDSpecifics_h
#define DDSpecifics_h


#include <map>
#include <string>
#include <vector>
Expand All @@ -11,8 +10,6 @@
#include "DetectorDescription/Core/interface/DDsvalues.h"
#include "DetectorDescription/Core/interface/DDExpandedView.h"

//#include "DetectorDescription/Core/interface/DDExpandedView.h"

class DDSpecifics;
class DDPartSelection;
class DDNodes;
Expand Down Expand Up @@ -64,9 +61,9 @@ class DDSpecifics : public DDBase<DDName,DDI::Specific*>
bla, bla, bla
*/
DDSpecifics(const DDName & name,
const selectors_type & partSelections,
const DDsvalues_type & svalues,
bool doRegex=true);
const std::vector<std::string> & partSelections,
const DDsvalues_type & svalues,
bool doRegex=true);

~DDSpecifics();

Expand All @@ -76,13 +73,8 @@ class DDSpecifics : public DDBase<DDName,DDI::Specific*>
//! Reference to the user-data attached to all nodes selected by the selections-strings given through selection
const DDsvalues_type & specifics() const;

//! Calculates all expanded-nodes which are selected by the selection-strings
bool nodes(DDNodes & nds) const;

//! Calculates the geometrical history of a fully specified PartSelector
std::pair<bool,DDExpandedView> node() const;

/* static void clear(); */
};

#endif
5 changes: 0 additions & 5 deletions DetectorDescription/Core/interface/DDStrVector.h
Expand Up @@ -11,8 +11,6 @@ class DDStrVector;
//! output operator for printing ...
std::ostream & operator<<(std::ostream & o, const DDStrVector & cons);

//typedef std::vector<double> dd_constant_type;

//! a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsStrVector>
class DDStrVector : public DDBase<DDName, std::vector<std::string>* >
{
Expand All @@ -21,9 +19,6 @@ class DDStrVector : public DDBase<DDName, std::vector<std::string>* >
//! size type for the size of the stored values
typedef std::vector<std::string>::size_type size_t;

//! iterator for read-only acces to stored values
//typedef std::vector<std::string>::const_iterator const_iterator;

//! value type of the managed object
typedef std::vector<std::string> value_type;

Expand Down
2 changes: 1 addition & 1 deletion DetectorDescription/Core/interface/DDValue.h
Expand Up @@ -86,6 +86,7 @@ class DDValue
//! A DDValue a is smaller than a DDValue b if (a.id()<b.id()) OR (a.id()==b.id() and value(a)<value(b))
bool operator<( const DDValue & ) const;

private:
///Only used internally
struct StringHolder {
StringHolder() {}
Expand All @@ -110,7 +111,6 @@ class DDValue
std::atomic<unsigned int> value_;
};

private:
void init( const std::string & );

using Names = tbb::concurrent_vector<StringHolder,tbb::zero_allocator<StringHolder>>;
Expand Down
7 changes: 2 additions & 5 deletions DetectorDescription/Core/src/DDMap.cc
Expand Up @@ -2,7 +2,6 @@

DDMap::DDMap() : DDBase<DDName,dd_map_type*>() { }


DDMap::DDMap(const DDName & name) : DDBase<DDName,dd_map_type*>()
{
prep_ = StoreT::instance().create(name);
Expand All @@ -13,16 +12,14 @@ DDMap::DDMap(const DDName & name,dd_map_type* vals)
prep_ = StoreT::instance().create(name,vals);
}


std::ostream & operator<<(std::ostream & os, const DDMap & cons)
{
os << "DDMap name=" << cons.name();

if(cons.isDefined().second) {
os << " size=" << cons.size() << " vals=( ";
DDMap::value_type::const_iterator it(cons.values().begin()), ed(cons.values().end());
for(; it != ed; ++it) {
os << it->first << '=' << it->second << ' ';
for( const auto& it : cons.values()) {
os << it.first << '=' << it.second << ' ';
}
os << ')';
}
Expand Down
57 changes: 16 additions & 41 deletions DetectorDescription/Core/src/DDSpecifics.cc
@@ -1,70 +1,54 @@
#include "DetectorDescription/Core/interface/DDSpecifics.h"
#include "Specific.h"
#include "DetectorDescription/Core/src/Specific.h"
#include "DetectorDescription/Base/interface/DDdebug.h"

#include <utility>

// Message logger.
#include "FWCore/MessageLogger/interface/MessageLogger.h"

using DDI::Specific;

//DDBase<DDName,Specific*>::StoreT::pointer_type
// DDBase<DDName,Specific*>::StoreT::instance_ = 0;

DDSpecifics::DDSpecifics() : DDBase<DDName,Specific*>()
{ }


DDSpecifics::DDSpecifics(const DDName & name) : DDBase<DDName,Specific*>()
{
prep_ = StoreT::instance().create(name);
}


DDSpecifics::DDSpecifics(const DDName & name,
const selectors_type & partSelections,
const std::vector<std::string> & partSelections,
const DDsvalues_type & svalues,
bool doRegex)
: DDBase<DDName,Specific*>()
{
prep_ = StoreT::instance().create(name, new Specific(partSelections,svalues,doRegex));
typedef std::vector<std::pair<DDLogicalPart,std::pair<const DDPartSelection*, const DDsvalues_type*> > > strange_type;
strange_type v;
std::vector<std::pair<DDLogicalPart,std::pair<const DDPartSelection*, const DDsvalues_type*> > > v;
rep().updateLogicalPart(v);
strange_type::iterator it = v.begin();
for(; it != v.end(); ++it) {
if (it->first.isDefined().second) {
it->first.addSpecifics(it->second);
DCOUT('C', "add specifics to LP: partsel=" << *(it->second.first) );
for( auto& it : v ) {
if( it.first.isDefined().second ) {
it.first.addSpecifics( it.second );
DCOUT('C', "add specifics to LP: partsel=" << *( it.second.first ));
}
else {
std::string serr("Definition of LogicalPart missing! name=");
serr+= it->first.ddname().fullname();
throw cms::Exception("DDException") << serr;
throw cms::Exception("DDException") << "Definition of LogicalPart missing! name="
<< it.first.ddname().fullname();
}
}
}


DDSpecifics::~DDSpecifics() { }


const std::vector<DDPartSelection> & DDSpecifics::selection() const //
const std::vector<DDPartSelection> & DDSpecifics::selection() const
{
return rep().selection();
}


const DDsvalues_type & DDSpecifics::specifics() const
{
return rep().specifics();
}

bool DDSpecifics::nodes(DDNodes & result) const
{
return rep().nodes(result);
}
// bool DDSpecifics::nodes(DDNodes & result) const
// {
// return rep().nodes(result);
// }

/** node() will only work, if
- there is only one PartSelection std::string
Expand All @@ -79,12 +63,6 @@ std::pair<bool,DDExpandedView> DDSpecifics::node() const
return rep().node();
}

// void DDSpecifics::clear()
// {
// StoreT::instance().clear();
// }


std::ostream & operator<<( std::ostream & os, const DDSpecifics & sp)
{
DDBase<DDName,DDI::Specific*>::def_type defined(sp.isDefined());
Expand All @@ -101,15 +79,12 @@ std::ostream & operator<<( std::ostream & os, const DDSpecifics & sp)
os << "* specific not declared * ";
}
return os;

}


std::ostream & operator<<( std::ostream & os, const std::vector<std::string> & v)
{
std::vector<std::string>::const_iterator it = v.begin();
for (; it!=v.end(); ++it) {
os << *it << std::endl;
for( const auto& it : v ) {
os << it << std::endl;
}
return os;
}
11 changes: 2 additions & 9 deletions DetectorDescription/Core/src/DDStrVector.cc
@@ -1,11 +1,7 @@

#include "DetectorDescription/Core/interface/DDStrVector.h"

// Evaluator

DDStrVector::DDStrVector() : DDBase<DDName,std::vector<std::string>*>() { }


DDStrVector::DDStrVector(const DDName & name) : DDBase<DDName,std::vector<std::string>*>()
{
prep_ = StoreT::instance().create(name);
Expand All @@ -16,16 +12,14 @@ DDStrVector::DDStrVector(const DDName & name,std::vector<std::string>* vals)
prep_ = StoreT::instance().create(name,vals);
}


std::ostream & operator<<(std::ostream & os, const DDStrVector & cons)
{
os << "DDStrVector name=" << cons.name();

if(cons.isDefined().second) {
os << " size=" << cons.size() << " vals=( ";
DDStrVector::value_type::const_iterator it(cons.values().begin()), ed(cons.values().end());
for(; it<ed; ++it) {
os << *it << ' ';
for( const auto& it : cons.values()) {
os << it << ' ';
}
os << ')';
}
Expand All @@ -34,4 +28,3 @@ std::ostream & operator<<(std::ostream & os, const DDStrVector & cons)
}
return os;
}

12 changes: 2 additions & 10 deletions DetectorDescription/Core/src/DDsvalues.cc
Expand Up @@ -92,19 +92,11 @@ bool DDfetch(const DDsvalues_type * p, DDValue & v)
unsigned int DDfetch(const std::vector<const DDsvalues_type *> & sp, DDValue & toFetch, std::vector<DDValue> & result)
{
unsigned int count = 0;
std::vector<const DDsvalues_type *>::const_iterator it(sp.begin()), ed(sp.end());
for (; it != ed; ++it) {
if (DDfetch(*it, toFetch)) {
for( const auto & it : sp ) {
if (DDfetch( it, toFetch)) {
result.push_back(toFetch);
++count;
}
}
return count;
}

/*
DDValue DDsvalues_type::operator[](const unsigned int& i) const
{
return DDValue(i);
}
*/
47 changes: 12 additions & 35 deletions DetectorDescription/Core/src/LogicalPart.cc
@@ -1,10 +1,7 @@

#include <algorithm>
#include "DetectorDescription/Core/src/LogicalPart.h"
#include "DetectorDescription/Core/interface/DDPartSelection.h"
#include "DetectorDescription/Base/interface/DDdebug.h"
//#include "DetectorDescription/Core/interface/DDSpecifics.h"


using DDI::LogicalPart;

Expand All @@ -14,12 +11,12 @@ LogicalPart::LogicalPart(const DDMaterial & m,
: material_(m), solid_(s), cat_(c), weight_(0), specifics_(0), hasDDValue_(1,false)
{ }




const DDMaterial & LogicalPart::material() const { return material_; }

const DDSolid & LogicalPart::solid() const { return solid_; }

DDEnums::Category LogicalPart::category() const { return cat_; }

void LogicalPart::stream(std::ostream & os)
{
os << std::endl << " mat=" << material().ddname() << std::endl << " solid=" << solid();
Expand All @@ -36,10 +33,8 @@ void LogicalPart::addSpecifics(const std::pair<const DDPartSelection*, const DDs
return;
}
specifics_.push_back(s);
DDsvalues_type::const_iterator it = s.second->begin();
DDsvalues_type::const_iterator ed = s.second->end();
for (; it != ed; ++it) {
unsigned int id = it->first;
for( const auto& it : *s.second ) {
unsigned int id = it.first;
if ( id < hasDDValue_.size() ) {
hasDDValue_[id] = true;
}
Expand Down Expand Up @@ -71,7 +66,6 @@ void LogicalPart::removeSpecifics(const std::pair<const DDPartSelection*, const
specifics_.erase(it);
}


std::vector<const DDsvalues_type*> LogicalPart::specifics() const
{
std::vector<const DDsvalues_type*> result;
Expand All @@ -83,12 +77,10 @@ std::vector<const DDsvalues_type*> LogicalPart::specifics() const
void LogicalPart::specificsV(std::vector<const DDsvalues_type*> & result) const
{
typedef std::vector<std::pair<const DDPartSelection*, const DDsvalues_type* > > sp_type;
sp_type::const_iterator it = specifics_.begin();
sp_type::const_iterator ed = specifics_.end();
for (; it != ed; ++it) {
const DDPartSelection & ps = *(it->first);
for( const auto& it : specifics_ ) {
const DDPartSelection & ps = *(it.first);
if (ps.size()==1 && ps[0].selectionType_==ddanylogp) {
result.push_back(it->second);
result.push_back(it.second);
}
}
}
Expand All @@ -99,31 +91,16 @@ DDsvalues_type LogicalPart::mergedSpecifics() const {
return merged;
}


void LogicalPart::mergedSpecificsV(DDsvalues_type & merged) const {
merged.clear();
std::vector<const DDsvalues_type *> unmerged; specificsV(unmerged);
std::vector<const DDsvalues_type *> unmerged;
specificsV(unmerged);
if (unmerged.size()==1) {
merged = *(unmerged[0]);
}
else if (unmerged.size()>1) {
std::vector<const DDsvalues_type *>::const_iterator it = unmerged.begin();
std::vector<const DDsvalues_type *>::const_iterator ed = unmerged.end();
for (; it != ed; ++it) {
merge(merged, **it);
for( const auto& it : unmerged ) {
merge(merged, *it);
}
}
}


/*
const std::vector<DDPartSelection*> & LogicalPart::partSelections(const DDValue &) const{
static std::vector<DDPartSelection*> empty_;
std::vector<DDPartSelection*> * result_ = &empty;
std::map<DDValue, std::vector<DDPartSelection*> >::const_iterator it = valToPartsel_.find(v);
if (it != valToPartsel_.end()) {
result = &(it->second);
}
return *result;
}
*/
8 changes: 3 additions & 5 deletions DetectorDescription/Core/src/Solid.cc
@@ -1,10 +1,8 @@
#include "DetectorDescription/Core/src/Solid.h"
#include<ostream>
#include <ostream>

void DDI::Solid::stream(std::ostream & os) const
{
std::vector<double>::const_iterator i = p_.begin();
std::vector<double>::const_iterator e = p_.end();
for (; i != e ; ++i)
os << *i << ' ';
for( const auto& i : p_ )
os << i << ' ';
}