CMS 3D CMS Logo

LogicalPart.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <memory>
3 
8 
9 using DDI::LogicalPart;
10 
11 LogicalPart::LogicalPart(const DDMaterial& m, const DDSolid& s, DDEnums::Category c)
12  : material_(m), solid_(s), cat_(c), specifics_(0), hasDDValue_(1, false) {}
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  os << std::endl << " mat=" << material().ddname() << std::endl << " solid=" << solid();
22 }
23 
24 void LogicalPart::addSpecifics(const std::pair<const DDPartSelection*, const DDsvalues_type*>& s) {
25  if (!(s.first && s.second)) {
26  // FIXME
27  std::cerr << "LogicalPart::addSpecific error pointer 0 " << s.first << "," << s.second << std::endl;
28  return;
29  }
30  specifics_.emplace_back(s);
31  for (const auto& it : *s.second) {
32  unsigned int id = it.first;
33  if (id < hasDDValue_.size()) {
34  hasDDValue_[id] = true;
35  } else {
36  hasDDValue_.resize(id + 1, false);
37  hasDDValue_[id] = true;
38  }
39  }
40 }
41 
42 bool LogicalPart::hasDDValue(const DDValue& v) const {
43  bool result = false;
44  unsigned int id = v.id();
45  if (id < hasDDValue_.size()) {
47  }
48  return result;
49 }
50 
51 void LogicalPart::removeSpecifics(const std::pair<const DDPartSelection*, const DDsvalues_type*>& s) {
52  std::vector<std::pair<const DDPartSelection*, const DDsvalues_type*> >::iterator it =
53  std::find(specifics_.begin(), specifics_.end(), s);
54  specifics_.erase(it);
55 }
56 
57 std::vector<const DDsvalues_type*> LogicalPart::specifics() const {
58  std::vector<const DDsvalues_type*> result;
60  return result;
61 }
62 
63 void LogicalPart::specificsV(std::vector<const DDsvalues_type*>& result) const {
64  for (const auto& it : specifics_) {
65  const DDPartSelection& ps = *(it.first);
66  if (ps.size() == 1 && ps[0].selectionType_ == ddanylogp) {
67  result.emplace_back(it.second);
68  }
69  }
70 }
71 
73  DDsvalues_type merged;
74  mergedSpecificsV(merged);
75  return merged;
76 }
77 
79  merged.clear();
80  std::vector<const DDsvalues_type*> unmerged;
81  specificsV(unmerged);
82  if (unmerged.size() == 1) {
83  merged = *(unmerged[0]);
84  } else if (unmerged.size() > 1) {
85  for (const auto& it : unmerged) {
86  merge(merged, *it);
87  }
88  }
89 }
DDsvalues_type mergedSpecifics() const
Definition: LogicalPart.cc:72
const DDMaterial & material() const
Definition: LogicalPart.cc:14
void specificsV(std::vector< const DDsvalues_type *> &result) const
Definition: LogicalPart.cc:63
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
std::vector< const DDsvalues_type * > specifics() const
Definition: LogicalPart.cc:57
const DDSolid & solid() const
Definition: LogicalPart.cc:16
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
void mergedSpecificsV(DDsvalues_type &res) const
Definition: LogicalPart.cc:78
std::vector< bool > hasDDValue_
Definition: LogicalPart.h:44
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
void removeSpecifics(const std::pair< const DDPartSelection *, const DDsvalues_type *> &)
Definition: LogicalPart.cc:51
void stream(std::ostream &)
Definition: LogicalPart.cc:20
DDEnums::Category category() const
Definition: LogicalPart.cc:18
Category
Definition: DDEnums.h:7
bool hasDDValue(const DDValue &) const
Definition: LogicalPart.cc:42
DDMaterial material_
Definition: LogicalPart.h:38
DDEnums::Category cat_
Definition: LogicalPart.h:40
const N & ddname() const
Definition: DDBase.h:61
std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > specifics_
Definition: LogicalPart.h:43
void addSpecifics(const std::pair< const DDPartSelection *, const DDsvalues_type *> &)
Definition: LogicalPart.cc:24
def merge(dictlist, TELL=False)
Definition: MatrixUtil.py:205