CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LogicalPart.cc
Go to the documentation of this file.
1 #include <algorithm>
5 
6 using DDI::LogicalPart;
7 
8 LogicalPart::LogicalPart(const DDMaterial & m,
9  const DDSolid & s,
11  : material_(m), solid_(s), cat_(c), weight_(0), specifics_(0), hasDDValue_(1,false)
12 { }
13 
14 const DDMaterial & LogicalPart::material() const { return material_; }
15 
16 const DDSolid & LogicalPart::solid() const { return solid_; }
17 
19 
20 void LogicalPart::stream(std::ostream & os)
21 {
22  os << std::endl << " mat=" << material().ddname() << std::endl << " solid=" << solid();
23 }
24 
25 double & LogicalPart::weight() { return weight_; }
26 
27 void LogicalPart::addSpecifics(const std::pair<const DDPartSelection*, const DDsvalues_type*> & s)
28 {
29  if ( ! (s.first && s.second) ) {
30  // FIXME
31  std::cerr << "LogicalPart::addSpecific error pointer 0 "
32  << s.first << "," << s.second << std::endl;
33  return;
34  }
35  specifics_.push_back(s);
36  for( const auto& it : *s.second ) {
37  unsigned int id = it.first;
38  if ( id < hasDDValue_.size() ) {
39  hasDDValue_[id] = true;
40  }
41  else {
42  hasDDValue_.resize(id+1,false);
43  hasDDValue_[id] = true;
44  }
45 
46  DCOUT('S', "hasValue_.size()=" << hasDDValue_.size() << " DDValue_id=" << id << std::flush
47  << " DDValue_name=" << DDValue(id).name() << std::flush
48  << " DDValue_string=" << DDValue(id).strings().size() );
49  }
50 }
51 
52 bool LogicalPart::hasDDValue(const DDValue & v) const
53 {
54  bool result = false;
55  unsigned int id = v.id();
56  if ( id < hasDDValue_.size()) {
57  result = hasDDValue_[id];
58  }
59  return result;
60 }
61 
62 void LogicalPart::removeSpecifics(const std::pair<const DDPartSelection*, const DDsvalues_type*> & s)
63 {
64  std::vector<std::pair<const DDPartSelection*, const DDsvalues_type* > >::iterator it =
65  std::find(specifics_.begin(),specifics_.end(),s);
66  specifics_.erase(it);
67 }
68 
69 std::vector<const DDsvalues_type*> LogicalPart::specifics() const
70 {
71  std::vector<const DDsvalues_type*> result;
72  specificsV(result);
73  return result;
74 
75 }
76 
77 void LogicalPart::specificsV(std::vector<const DDsvalues_type*> & result) const
78 {
79  typedef std::vector<std::pair<const DDPartSelection*, const DDsvalues_type* > > sp_type;
80  for( const auto& it : specifics_ ) {
81  const DDPartSelection & ps = *(it.first);
82  if (ps.size()==1 && ps[0].selectionType_==ddanylogp) {
83  result.push_back(it.second);
84  }
85  }
86 }
87 
89  DDsvalues_type merged;
90  mergedSpecificsV(merged);
91  return merged;
92 }
93 
95  merged.clear();
96  std::vector<const DDsvalues_type *> unmerged;
97  specificsV(unmerged);
98  if (unmerged.size()==1) {
99  merged = *(unmerged[0]);
100  }
101  else if (unmerged.size()>1) {
102  for( const auto& it : unmerged ) {
103  merge(merged, *it);
104  }
105  }
106 }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:55
std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > specifics_
Definition: LogicalPart.h:47
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
DDEnums::Category category() const
Definition: LogicalPart.cc:18
void removeSpecifics(const std::pair< const DDPartSelection *, const DDsvalues_type * > &)
Definition: LogicalPart.cc:62
void addSpecifics(const std::pair< const DDPartSelection *, const DDsvalues_type * > &)
Definition: LogicalPart.cc:27
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
unsigned int id(void) const
returns the ID of the DDValue
Definition: DDValue.h:49
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
std::vector< bool > hasDDValue_
Definition: LogicalPart.h:48
const DDMaterial & material() const
Definition: LogicalPart.cc:14
tuple result
Definition: query.py:137
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:19
void stream(std::ostream &)
Definition: LogicalPart.cc:20
Category
Definition: DDEnums.h:7
std::vector< const DDsvalues_type * > specifics() const
Definition: LogicalPart.cc:69
DDMaterial material_
Definition: LogicalPart.h:40
bool hasDDValue(const DDValue &) const
Definition: LogicalPart.cc:52
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
Definition: DDValue.h:62
DDEnums::Category cat_
Definition: LogicalPart.h:42
void mergedSpecificsV(DDsvalues_type &res) const
Definition: LogicalPart.cc:94
const DDSolid & solid() const
Definition: LogicalPart.cc:16
double & weight()
Definition: LogicalPart.cc:25
volatile std::atomic< bool > shutdown_flag false
DDsvalues_type mergedSpecifics() const
Definition: LogicalPart.cc:88
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
void specificsV(std::vector< const DDsvalues_type * > &result) const
Definition: LogicalPart.cc:77
const N & ddname() const
Definition: DDBase.h:80