CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDFilteredView.cc
Go to the documentation of this file.
4 
6  : epv_(cpv)
7 {
8  parents_.push_back(epv_.geoHistory());
9 }
10 
12 { }
13 
15 {
16  return epv_.logicalPart();
17 }
18 
20 {
21  criteria_.push_back(&f);
22  logOps_.push_back(op);
23 }
24 
26 {
27  return epv_.translation();
28 }
29 
31 {
32  return epv_.rotation();
33 }
34 
36 {
37  return epv_.geoHistory();
38 }
39 
40 std::vector<const DDsvalues_type * > DDFilteredView::specifics() const
41 {
42  std::vector<const DDsvalues_type * > result; epv_.specificsV(result);
43  return result;
44 }
45 
46 void DDFilteredView::specificsV(std::vector<const DDsvalues_type * > & result) const
47 {
48  epv_.specificsV(result);
49 }
50 
52 {
53  epv_.mergedSpecificsV(merged);
54 }
55 
57 {
58  DDsvalues_type merged;
59  epv_.mergedSpecificsV(merged);
60  return merged;
61 }
62 
64 {
65  return epv_.copyno();
66 }
67 
69 {
70  return epv_.scope();
71 }
72 
74 {
75  bool result = epv_.setScope(hist,0);
76  if (result) {
77  parents_.clear();
78  parents_.push_back(hist);
79  }
80  return result;
81 }
82 
84 {
85  epv_.clearScope();
86  parents_.clear();
87  parents_.push_back(epv_.geoHistory());
88 }
89 
91 {
92  bool result = false;
93  int i=0;
94  while(epv_.next()) {
95  ++i;
96  if ( filter() ) {
97  result = true;
98  break;
99  }
100  }
101  return result;
102 }
103 
111 {
112  bool result = false;
113 
114  // save the current position
115  DDGeoHistory savedPos = epv_.geoHistory();
116 
117  // save the current scope
118  DDGeoHistory savedScope = epv_.scope_;
119  int savedDepth = epv_.depth_;
120 
121  // set current node to be the scope
123  epv_.depth_ = 0;
124 
125  // search the subtree for the first matching node
126  if (next()) {
127  result = true;
128  epv_.scope_ = savedScope;
129  epv_.depth_ = savedDepth;
130  }
131  else { // restore the starting point
132  epv_.scope_ = savedScope;
133  epv_.depth_ = savedDepth;
134  epv_.goToHistory(savedPos);
135  }
136 
137  if (result) {
138  parents_.push_back(epv_.geoHistory());
139  }
140 
141  return result;
142 }
143 
151 {
152  //PRE: the current node A is one matching the filter or the (scoped) root
153  //POST: current node is A if no filter has matched, or B with matching filter
154  // B is the firstChild matching the filter in the subtrees of A's siblings
155  bool result = false;
156  DDGeoHistory savedPos = epv_.geoHistory();
157 
158  bool flag = true;
159  //bool shuffleParent = false;
160  while (flag) {
161  if (epv_.nextSibling()) {
162  if ( filter() ) {
163  result = true;
164  break;
165  }
166  else if (firstChild()) {
167  result = true;
168  // firstChild increases parents!
169  parents_.pop_back();
170  break;
171  }
172  } // <-- epv_.nextSibling
173  else if (!epv_.parent()) {
174  flag = false;
175  }
176  if (epv_.geoHistory().size() == parents_[parents_.size()-2].size()) {
177  flag = false;
178  }
179  }
180 
181  if (!result)
182  epv_.goToHistory(savedPos);
183  else
184  parents_.back() = epv_.geoHistory();
185 
186  return result;
187 }
188 
190 {
191  bool result = false;
192 
193  if (parents_.size()==1) {
194  result = false;
195  }
196  else {
197  parents_.pop_back();
198  epv_.goToHistory(parents_.back());
199  result = true;
200  }
201 
202  // =====> CHECK WHETHER THE FOLLOWING REMARKS STILL REPRESENT THE IMPLEMENTATION ABOVE <===
203  // case 1: we've reached the (scoped) root of the underlying expanded-view
204  // from the first child of the fitered-view; result must be true
205  // case 2: we've reached a parent-node where the filter said 'yes';
206  // result must be true
207  // case 3: we are already at the (scoped) root of the underlying expanded-view
208  // result must be false
209 
210  return result;
211 }
212 
214 {
215  epv_.reset();
216  parents_.clear();
217  parents_.push_back(epv_.geoHistory());
218 }
219 
221 {
222  bool result = true;
223  auto logOpIt = logOps_.begin();
224  // loop over all user-supplied criteria (==filters)
225  for( auto it = begin(criteria_); it != end(criteria_); ++it, ++logOpIt) {
226  // avoid useless evaluations
227  if(( result && ( *logOpIt ) == DDLogOp::OR ) ||
228  (( !result ) && ( *logOpIt ) == DDLogOp::AND )) continue;
229 
230  bool locres = (*it)->accept(epv_);
231 
232  // now do the logical-operations on the results encountered so far:
233  if (*logOpIt == DDLogOp::AND) { // AND
234  result &= locres;
235  }
236  else { // OR
237  result |= locres;
238  }
239  } // <-- loop over filters
240  return result;
241 }
242 
244 {
245  return epv_.navPos();
246 }
247 
249 {
250  return epv_.copyNumbers();
251 }
252 
254 {
255  // WARNING!!!!!!!!!!
256  // NOT IMPLEMENTED!!!!!!!
257  bool result(false);
258  return result;
259 }
260 
262  edm::LogInfo("DDFliteredView") << "FilteredView Status" << std::endl
263  << "-------------------" << std::endl
264  << "scope = " << epv_.scope_ << std::endl
265  << "parents:" << std::endl;
266  for (unsigned int i=0; i<parents_.size(); ++i)
267  edm::LogInfo("DDFliteredView") << " " << parents_[i] << std::endl;
268 
269 }
270 
271 const std::vector<DDGeoHistory> & DDFilteredView::history() const
272 {
273  return parents_;
274 }
bool next()
set current node to the next node in the expanded tree
int i
Definition: DBlmapReader.cc:9
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
DDLogOp
logical operations to obtain one result from two filter comparisons
Definition: DDFilter.h:15
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
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.
std::vector< DDGeoHistory > parents_
nav_type navPos() const
return the stack of sibling numbers
unsigned int depth_
depth of the scope, 0==unrestricted depth
type of data representation of DDCompactView
Definition: DDCompactView.h:77
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
std::vector< DDFilter const * > criteria_
bool next()
set current node to the next node in the filtered tree
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
std::vector< DDLogOp > logOps_
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
bool setScope(const DDGeoHistory &hist)
sets the scope of the expanded view
double f[11][100]
#define end
Definition: vmac.h:37
DDFilteredView(const DDCompactView &)
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.
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
#define begin
Definition: vmac.h:30
void clearScope()
clears the scope; the full tree is available, depth=0
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:18
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
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
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void mergedSpecificsV(DDsvalues_type &res) const