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 
2 #include <algorithm>
6 //#include "DetectorDescription/Core/interface/DDSpecifics.h"
7 
8 
9 using DDI::LogicalPart;
10 
11 LogicalPart::LogicalPart(const DDMaterial & m,
12  const DDSolid & s,
14  : material_(m), solid_(s), cat_(c), weight_(0), specifics_(0), hasDDValue_(1,false)
15 { }
16 
17 
18 
19 
20 const DDMaterial & LogicalPart::material() const { return material_; }
21 const DDSolid & LogicalPart::solid() const { return solid_; }
23 void LogicalPart::stream(std::ostream & os)
24 {
25  os << std::endl << " mat=" << material().ddname() << std::endl << " solid=" << solid();
26 }
27 
28 double & LogicalPart::weight() { return weight_; }
29 
30 void LogicalPart::addSpecifics(const std::pair<DDPartSelection*,DDsvalues_type*> & s)
31 {
32  if ( ! (s.first && s.second) ) {
33  // FIXME
34  std::cerr << "LogicalPart::addSpecific error pointer 0 "
35  << s.first << "," << s.second << std::endl;
36  return;
37  }
38  specifics_.push_back(s);
39  DDsvalues_type::const_iterator it = s.second->begin();
40  DDsvalues_type::const_iterator ed = s.second->end();
41  for (; it != ed; ++it) {
42  unsigned int id = it->first;
43  if ( id < hasDDValue_.size() ) {
44  hasDDValue_[id] = true;
45  }
46  else {
47  hasDDValue_.resize(id+1,false);
48  hasDDValue_[id] = true;
49  }
50 
51  DCOUT('S', "hasValue_.size()=" << hasDDValue_.size() << " DDValue_id=" << id << std::flush
52  << " DDValue_name=" << DDValue(id).name() << std::flush
53  << " DDValue_string=" << DDValue(id).strings().size() );
54  }
55 }
56 
57 bool LogicalPart::hasDDValue(const DDValue & v) const
58 {
59  bool result = false;
60  unsigned int id = v.id();
61  if ( id < hasDDValue_.size()) {
62  result = hasDDValue_[id];
63  }
64  return result;
65 }
66 
67 void LogicalPart::removeSpecifics(const std::pair<DDPartSelection*,DDsvalues_type*> & s)
68 {
69  std::vector<std::pair<DDPartSelection*,DDsvalues_type* > >::iterator it =
70  std::find(specifics_.begin(),specifics_.end(),s);
71  specifics_.erase(it);
72 }
73 
74 
75 std::vector<const DDsvalues_type*> LogicalPart::specifics() const
76 {
77  std::vector<const DDsvalues_type*> result;
78  specificsV(result);
79  return result;
80 
81 }
82 
83 void LogicalPart::specificsV(std::vector<const DDsvalues_type*> & result) const
84 {
85  typedef std::vector<std::pair<DDPartSelection*,DDsvalues_type* > > sp_type;
86  sp_type::const_iterator it = specifics_.begin();
87  sp_type::const_iterator ed = specifics_.end();
88  for (; it != ed; ++it) {
89  DDPartSelection & ps = *(it->first);
90  if (ps.size()==1 && ps[0].selectionType_==ddanylogp) {
91  result.push_back(it->second);
92  }
93  }
94 }
95 
97  DDsvalues_type merged;
98  mergedSpecificsV(merged);
99  return merged;
100 }
101 
102 
104  merged.clear();
105  std::vector<const DDsvalues_type *> unmerged; specificsV(unmerged);
106  if (unmerged.size()==1) {
107  merged = *(unmerged[0]);
108  }
109  else if (unmerged.size()>1) {
110  std::vector<const DDsvalues_type *>::const_iterator it = unmerged.begin();
111  std::vector<const DDsvalues_type *>::const_iterator ed = unmerged.end();
112  for (; it != ed; ++it) {
113  merge(merged, **it);
114  }
115  }
116 }
117 
118 
119 /*
120 const std::vector<DDPartSelection*> & LogicalPart::partSelections(const DDValue &) const{
121  static std::vector<DDPartSelection*> empty_;
122  std::vector<DDPartSelection*> * result_ = &empty;
123  std::map<DDValue, std::vector<DDPartSelection*> >::const_iterator it = valToPartsel_.find(v);
124  if (it != valToPartsel_.end()) {
125  result = &(it->second);
126  }
127  return *result;
128 }
129 */
unsigned int id() const
returns the ID of the DDValue
Definition: DDValue.h:63
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDEnums::Category category() const
Definition: LogicalPart.cc:22
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
A DDSolid represents the shape of a part.
Definition: DDSolid.h:42
std::vector< bool > hasDDValue_
Definition: LogicalPart.h:48
const DDMaterial & material() const
Definition: LogicalPart.cc:20
std::vector< std::pair< DDPartSelection *, DDsvalues_type * > > specifics_
Definition: LogicalPart.h:47
void addSpecifics(const std::pair< DDPartSelection *, DDsvalues_type * > &)
Definition: LogicalPart.cc:30
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:23
Category
Definition: DDEnums.h:7
std::vector< const DDsvalues_type * > specifics() const
Definition: LogicalPart.cc:75
DDMaterial material_
Definition: LogicalPart.h:40
bool hasDDValue(const DDValue &) const
Definition: LogicalPart.cc:57
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:76
DDEnums::Category cat_
Definition: LogicalPart.h:42
void mergedSpecificsV(DDsvalues_type &res) const
Definition: LogicalPart.cc:103
const DDSolid & solid() const
Definition: LogicalPart.cc:21
string s
Definition: asciidump.py:422
double & weight()
Definition: LogicalPart.cc:28
DDsvalues_type mergedSpecifics() const
Definition: LogicalPart.cc:96
const std::string & name() const
the name of the DDValue
Definition: DDValue.h:69
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
mathSSE::Vec4< T > v
void removeSpecifics(const std::pair< DDPartSelection *, DDsvalues_type * > &)
Definition: LogicalPart.cc:67
void specificsV(std::vector< const DDsvalues_type * > &result) const
Definition: LogicalPart.cc:83
const N & ddname() const
Definition: DDBase.h:90