CMS 3D CMS Logo

DDFilteredView.cc
Go to the documentation of this file.
2 
3 #include <iterator>
4 #include <memory>
5 #include <ostream>
6 
8 
9 class DDCompactView;
10 class DDLogicalPart;
11 
13  : epv_(cpv), filter_(&fltr)
14 {
15  parents_.emplace_back(epv_.geoHistory());
16 }
17 
19 {
20  return epv_.logicalPart();
21 }
22 
24 {
25  return epv_.translation();
26 }
27 
29 {
30  return epv_.rotation();
31 }
32 
34 {
35  return epv_.geoHistory();
36 }
37 
38 std::vector<const DDsvalues_type * > DDFilteredView::specifics() const
39 {
40  std::vector<const DDsvalues_type * > result; epv_.specificsV(result);
41  return result;
42 }
43 
44 void DDFilteredView::specificsV(std::vector<const DDsvalues_type * > & result) const
45 {
46  epv_.specificsV(result);
47 }
48 
50 {
51  epv_.mergedSpecificsV(merged);
52 }
53 
55 {
56  DDsvalues_type merged;
57  epv_.mergedSpecificsV(merged);
58  return merged;
59 }
60 
62 {
63  return epv_.copyno();
64 }
65 
67 {
68  return epv_.scope();
69 }
70 
72 {
73  bool result = epv_.setScope(hist,0);
74  if (result) {
75  parents_.clear();
76  parents_.emplace_back(hist);
77  }
78  return result;
79 }
80 
82 {
83  epv_.clearScope();
84  parents_.clear();
85  parents_.emplace_back(epv_.geoHistory());
86 }
87 
89 {
90  bool result = false;
91  int i=0;
92  while(epv_.next()) {
93  ++i;
94  if ( filter() ) {
95  result = true;
96  break;
97  }
98  }
99  return result;
100 }
101 
109 {
110  bool result = false;
111 
112  // save the current position
113  DDGeoHistory savedPos = epv_.geoHistory();
114 
115  // save the current scope
116  DDGeoHistory savedScope = epv_.scope_;
117  int savedDepth = epv_.depth_;
118 
119  // set current node to be the scope
121  epv_.depth_ = 0;
122 
123  // search the subtree for the first matching node
124  if (next()) {
125  result = true;
126  epv_.scope_ = savedScope;
127  epv_.depth_ = savedDepth;
128  }
129  else { // restore the starting point
130  epv_.scope_ = savedScope;
131  epv_.depth_ = savedDepth;
132  epv_.goToHistory(savedPos);
133  }
134 
135  if (result) {
136  parents_.emplace_back(epv_.geoHistory());
137  }
138 
139  return result;
140 }
141 
149 {
150  //PRE: the current node A is one matching the filter or the (scoped) root
151  //POST: current node is A if no filter has matched, or B with matching filter
152  // B is the firstChild matching the filter in the subtrees of A's siblings
153  bool result = false;
154  DDGeoHistory savedPos = epv_.geoHistory();
155 
156  bool flag = true;
157  //bool shuffleParent = false;
158  while (flag) {
159  if (epv_.nextSibling()) {
160  if ( filter() ) {
161  result = true;
162  break;
163  }
164  else if (firstChild()) {
165  result = true;
166  // firstChild increases parents!
167  parents_.pop_back();
168  break;
169  }
170  } // <-- epv_.nextSibling
171  else if (!epv_.parent()) {
172  flag = false;
173  }
174  if (epv_.geoHistory().size() == parents_[parents_.size()-2].size()) {
175  flag = false;
176  }
177  }
178 
179  if (!result)
180  epv_.goToHistory(savedPos);
181  else
182  parents_.back() = epv_.geoHistory();
183 
184  return result;
185 }
186 
188 {
189  bool result = false;
190 
191  if (parents_.size()==1) {
192  result = false;
193  }
194  else {
195  parents_.pop_back();
196  epv_.goToHistory(parents_.back());
197  result = true;
198  }
199 
200  // =====> CHECK WHETHER THE FOLLOWING REMARKS STILL REPRESENT THE IMPLEMENTATION ABOVE <===
201  // case 1: we've reached the (scoped) root of the underlying expanded-view
202  // from the first child of the fitered-view; result must be true
203  // case 2: we've reached a parent-node where the filter said 'yes';
204  // result must be true
205  // case 3: we are already at the (scoped) root of the underlying expanded-view
206  // result must be false
207 
208  return result;
209 }
210 
212 {
213  epv_.reset();
214  parents_.clear();
215  parents_.emplace_back(epv_.geoHistory());
216 }
217 
219 {
220  return filter_->accept(epv_) ;
221 }
222 
224 {
225  return epv_.navPos();
226 }
227 
229 {
230  return epv_.copyNumbers();
231 }
232 
234 {
235  // WARNING!!!!!!!!!!
236  // NOT IMPLEMENTED!!!!!!!
237  bool result(false);
238  return result;
239 }
240 
242  edm::LogInfo("DDFliteredView") << "FilteredView Status" << std::endl
243  << "-------------------" << std::endl
244  << "scope = " << epv_.scope_ << std::endl
245  << "parents:" << std::endl;
246  for (const auto & parent : parents_)
247  edm::LogInfo("DDFliteredView") << " " << parent << std::endl;
248 
249 }
250 
251 const std::vector<DDGeoHistory> & DDFilteredView::history() const
252 {
253  return parents_;
254 }
bool next()
set current node to the next node in the expanded tree
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
bool parent()
set the current node to the parent node ...
bool parent()
set the current node to the parent node ...
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
void mergedSpecificsV(DDsvalues_type &merged) const
nav_type copyNumbers() const
return the stack of copy numbers
nav_type copyNumbers() const
return the stack of copy numbers
DDExpandedView epv_
bool nextSibling()
set the current node to the next sibling ...
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
std::vector< DDGeoHistory > parents_
nav_type navPos() const
return the stack of sibling numbers
unsigned int depth_
depth of the scope, 0==unrestricted depth
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
const std::vector< DDGeoHistory > & history() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
nav_type navPos() const
return the stack of sibling numbers which indicates the current position in the DDExpandedView ...
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
bool goTo(const nav_type &)
int copyno() const
Copy number associated with the current node.
void specificsV(std::vector< const DDsvalues_type * > &vc) const
bool next()
set current node to the next node in the filtered tree
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
bool setScope(const DDGeoHistory &hist)
sets the scope of the expanded view
bool setScope(const DDGeoHistory &hist, int depth=0)
sets the scope of the expanded view
const DDTranslation & translation() const
The absolute translation of the current node.
void clearScope()
clears the scope; the full tree is available, depth=0
std::vector< DDExpandedNode > DDGeoHistory
Geometrical &#39;path&#39; of the current node up to the root-node.
DDFilter const * filter_
const DDGeoHistory & scope() const
The scope of the expanded-view.
void reset()
true, if a call to firstChild() would succeed (current node has at least one child) ...
int copyno() const
Copy number associated with the current node.
bool nextSibling()
set the current node to the next sibling ...
DDsvalues_type mergedSpecifics() const
const DDGeoHistory & scope() const
The scope of the expanded-view.
DDExpandedView::nav_type nav_type
void clearScope()
clears the scope; the full tree is available, depth=0
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
bool firstChild()
set the current node to the first child ...
bool goToHistory(const DDGeoHistory &sc)
A Filter accepts or rejects a DDExpandedNode based on a user-coded decision rule. ...
Definition: DDFilter.h:15
void specificsV(std::vector< const DDsvalues_type * > &result) const
User specific data attached to the current node.
void reset()
clears the scope and sets the filtered view to its root-node
DDFilteredView()=delete
const DDTranslation & translation() const
The absolute translation of the current node.
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
std::vector< const DDsvalues_type * > specifics() const
DDGeoHistory scope_
scope of the expanded view
virtual bool accept(const DDExpandedView &) const =0
true, if the DDExpandedNode fulfills the filter criteria
void mergedSpecificsV(DDsvalues_type &res) const