CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cms::DDFilteredView Class Reference

#include <DDFilteredView.h>

Public Member Functions

bool checkChild ()
 count the number of children matching selection More...
 
 DDFilteredView (const DDDetector *, const Volume)
 
 DDFilteredView ()=delete
 
void down ()
 set current node to the child node in the filtered tree More...
 
std::vector< double > extractParameters () const
 extract shape parameters More...
 
bool firstChild ()
 set the current node to the first child More...
 
bool firstSibling ()
 set the current node to the first sibling More...
 
const ExpandedNodeshistory () const
 The numbering history of the current node. More...
 
void mergedSpecifics (DDSpecParRefs const &)
 User specific data. More...
 
bool next (int)
 set current node to the next node in the filtered tree More...
 
bool nextSibling ()
 set the current node to the next sibling More...
 
bool parent ()
 set the current node to the parent node ... More...
 
const Double_t * rot () const
 The absolute rotation of the current node. More...
 
bool sibling ()
 set the current node to the next sub sibling More...
 
bool siblingNoCheck ()
 
const Double_t * trans () const
 The absolute translation of the current node. More...
 
void unCheckNode ()
 pop current node More...
 
void up ()
 set current node to the parent node in the filtered tree More...
 
const PlacedVolume volume () const
 The physical volume of the current node. More...
 

Private Member Functions

bool accept (std::string_view)
 
bool addNode (Node *const)
 
bool addPath (Node *const)
 

Private Attributes

FiltercurrentFilter_ = nullptr
 
std::vector< std::unique_ptr< Filter > > filters_
 
std::vector< Iteratorit_
 
Nodenode_ = nullptr
 
ExpandedNodes nodes_
 
const DDSpecParRegistryregistry_
 

Detailed Description

Definition at line 39 of file DDFilteredView.h.

Constructor & Destructor Documentation

DDFilteredView::DDFilteredView ( const DDDetector det,
const Volume  volume 
)

Definition at line 12 of file DDFilteredView.cc.

References it_.

13  : registry_(&det->specpars()) {
14  it_.emplace_back(Iterator(volume));
15 }
DDSpecParRegistry const & specpars() const
Definition: DDDetector.h:36
const PlacedVolume volume() const
The physical volume of the current node.
TGeoIterator Iterator
const DDSpecParRegistry * registry_
std::vector< Iterator > it_
cms::DDFilteredView::DDFilteredView ( )
delete

Member Function Documentation

bool DDFilteredView::accept ( std::string_view  name)
private

Definition at line 186 of file DDFilteredView.cc.

References cms::dd::accepted(), currentFilter_, filters_, cms::Filter::keys, and mps_fire::result.

Referenced by Vispa.Gui.BoxContentDialog.BoxContentDialog::apply(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::apply(), firstChild(), esMonitoring.FDJsonServer::handle_accept(), and history().

186  {
187  bool result = false;
188  for(const auto& it : filters_) {
189  currentFilter_ = it.get();
190  result = accepted(currentFilter_->keys, name);
191  if(result)
192  return result;
193  }
194  return result;
195 }
std::vector< std::unique_ptr< Filter > > filters_
std::vector< std::string_view > keys
Definition: Filter.h:27
bool accepted(std::vector< std::string_view > const &, std::string_view)
bool DDFilteredView::addNode ( Node * const  node)
private

Definition at line 245 of file DDFilteredView.cc.

References begin, cms::ExpandedNodes::copyNos, end, mps_fire::i, gen::k, node_, nodes_, cms::ExpandedNodes::offsets, registry_, mps_fire::result, cms::DDSpecParRegistry::specpars, and cms::ExpandedNodes::tags.

Referenced by firstSibling(), history(), nextSibling(), and sibling().

245  {
246  assert(registry_);
247  node_ = node;
248  bool result(false);
249  for_each(begin(registry_->specpars), end(registry_->specpars), [&](auto const& i) {
250  auto k = find_if(begin(i.second.paths), end(i.second.paths),[&](auto const& j) {
251  return (compareEqual(node_->GetVolume()->GetName(), *begin(split(realTopName(j), "/"))) &&
252  (i.second.hasValue("CopyNoTag") ||
253  i.second.hasValue("CopyNoOffset")));
254  });
255  if(k != end(i.second.paths)) {
256  nodes_.tags.emplace_back(i.second.dblValue("CopyNoTag"));
257  nodes_.offsets.emplace_back(i.second.dblValue("CopyNoOffset"));
258  nodes_.copyNos.emplace_back(node_->GetNumber());
259  result = true;
260  }
261  });
262  return result;
263 }
ExpandedNodes nodes_
std::vector< int > copyNos
Definition: ExpandedNodes.h:29
std::vector< double > offsets
Definition: ExpandedNodes.h:28
#define end
Definition: vmac.h:39
int k[5][pyjets_maxn]
#define begin
Definition: vmac.h:32
std::vector< double > tags
Definition: ExpandedNodes.h:27
const DDSpecParRegistry * registry_
bool DDFilteredView::addPath ( Node * const  node)
private

Definition at line 217 of file DDFilteredView.cc.

References begin, cms::ExpandedNodes::copyNos, end, mps_fire::i, it_, gen::k, hcalDigis_cfi::level, node_, nodes_, cms::ExpandedNodes::offsets, registry_, mps_fire::result, cms::DDSpecParRegistry::specpars, and cms::ExpandedNodes::tags.

Referenced by firstChild(), and history().

217  {
218  assert(registry_);
219  node_ = node;
220  nodes_.tags.clear();
221  nodes_.offsets.clear();
222  nodes_.copyNos.clear();
223  bool result(false);
224 
225  int level = it_.back().GetLevel();
226  for(int nit = level; nit > 0; --nit) {
227  for_each(begin(registry_->specpars), end(registry_->specpars), [&](auto const& i) {
228  auto k = find_if(begin(i.second.paths), end(i.second.paths),[&](auto const& j) {
229  return (compareEqual(it_.back().GetNode(nit)->GetVolume()->GetName(), *begin(split(realTopName(j), "/"))) &&
230  (i.second.hasValue("CopyNoTag") ||
231  i.second.hasValue("CopyNoOffset")));
232  });
233  if(k != end(i.second.paths)) {
234  nodes_.tags.emplace_back(i.second.dblValue("CopyNoTag"));
235  nodes_.offsets.emplace_back(i.second.dblValue("CopyNoOffset"));
236  nodes_.copyNos.emplace_back(it_.back().GetNode(nit)->GetNumber());
237  result = true;
238  }
239  });
240  }
241  return result;
242 }
ExpandedNodes nodes_
std::vector< int > copyNos
Definition: ExpandedNodes.h:29
std::vector< double > offsets
Definition: ExpandedNodes.h:28
#define end
Definition: vmac.h:39
int k[5][pyjets_maxn]
#define begin
Definition: vmac.h:32
std::vector< double > tags
Definition: ExpandedNodes.h:27
const DDSpecParRegistry * registry_
std::vector< Iterator > it_
bool DDFilteredView::checkChild ( )

count the number of children matching selection

Definition at line 138 of file DDFilteredView.cc.

References cms::dd::accepted(), currentFilter_, it_, and cms::Filter::keys.

Referenced by cms::DTGeometryBuilder::buildLayer(), and history().

138  {
139  it_.back().SetType(1);
140  Node *node = nullptr;
141  while((node = it_.back().Next())) {
142  if(accepted(currentFilter_->keys, node->GetVolume()->GetName())) {
143  return true;
144  }
145  }
146  return false;
147 }
TGeoNode Node
std::vector< std::string_view > keys
Definition: Filter.h:27
bool accepted(std::vector< std::string_view > const &, std::string_view)
std::vector< Iterator > it_
void DDFilteredView::down ( )

set current node to the child node in the filtered tree

Definition at line 171 of file DDFilteredView.cc.

References currentFilter_, it_, cms::Filter::next, and next().

Referenced by cms::DTGeometryBuilder::buildGeometry(), cms::DTGeometryBuilder::buildLayer(), and history().

171  {
172  it_.emplace_back(Iterator(it_.back()));
173  next(0);
174  if(currentFilter_->next)
176 }
std::unique_ptr< Filter > next
Definition: Filter.h:28
TGeoIterator Iterator
bool next(int)
set current node to the next node in the filtered tree
std::vector< Iterator > it_
vector< double > DDFilteredView::extractParameters ( ) const

extract shape parameters

Definition at line 198 of file DDFilteredView.cc.

References fftjetcommon_cfi::Class, node_, and volume().

Referenced by cms::DTGeometryBuilder::buildChamber(), cms::DTGeometryBuilder::buildLayer(), cms::DTGeometryBuilder::buildSuperLayer(), and history().

198  {
199  Volume volume = node_->GetVolume();
200  if(volume->GetShape()->IsA() == TGeoBBox::Class()) {
201  const TGeoBBox* box = static_cast<const TGeoBBox*>(volume->GetShape());
202  return {box->GetDX(), box->GetDY(), box->GetDZ()};
203  }
204  else if(volume->GetShape()->IsA() == TGeoCompositeShape::Class()) {
205  const TGeoCompositeShape* shape = static_cast<const TGeoCompositeShape*>(volume->GetShape());
206  const TGeoBoolNode* boolean = shape->GetBoolNode();
207  while(boolean->GetLeftShape()->IsA() != TGeoBBox::Class()) {
208  boolean = static_cast<const TGeoCompositeShape*>(boolean->GetLeftShape())->GetBoolNode();
209  }
210  const TGeoBBox* box = static_cast<const TGeoBBox*>(boolean->GetLeftShape());
211  return {box->GetDX(), box->GetDY(), box->GetDZ()};
212  } else
213  return {1, 1, 1};
214 }
const PlacedVolume volume() const
The physical volume of the current node.
dd4hep::Volume Volume
bool DDFilteredView::firstChild ( )

set the current node to the first child

Definition at line 66 of file DDFilteredView.cc.

References accept(), addPath(), and it_.

Referenced by cms::DTGeometryBuilder::buildGeometry(), DDDCmsTrackerContruction::construct(), DDDCmsMTDConstruction::construct(), and history().

66  {
67  it_.back().SetType(0);
68  Node *node = nullptr;
69  while((node = it_.back().Next())) {
70  if(accept(node->GetVolume()->GetName())) {
71  addPath(node);
72  return true;
73  }
74  }
75  return false;
76 }
TGeoNode Node
bool addPath(Node *const)
bool accept(std::string_view)
std::vector< Iterator > it_
bool DDFilteredView::firstSibling ( )

set the current node to the first sibling

Definition at line 79 of file DDFilteredView.cc.

References cms::dd::accepted(), addNode(), currentFilter_, it_, cms::Filter::keys, cms::Filter::next, next(), and node_.

Referenced by cms::DTGeometryBuilder::buildGeometry(), and history().

79  {
80  next(0);
81  it_.emplace_back(Iterator(it_.back()));
82  it_.back().SetType(1);
83  if(currentFilter_->next)
85  else
86  return false;
87  do {
88  if(accepted(currentFilter_->keys, node_->GetVolume()->GetName())) {
89  addNode(node_);
90  return true;
91  }
92  } while((node_ = it_.back().Next()));
93 
94  return false;
95 }
std::vector< std::string_view > keys
Definition: Filter.h:27
std::unique_ptr< Filter > next
Definition: Filter.h:28
TGeoIterator Iterator
bool next(int)
set current node to the next node in the filtered tree
bool accepted(std::vector< std::string_view > const &, std::string_view)
std::vector< Iterator > it_
bool addNode(Node *const)
const ExpandedNodes& cms::DDFilteredView::history ( ) const
inline
void DDFilteredView::mergedSpecifics ( DDSpecParRefs const &  specs)

User specific data.

Definition at line 33 of file DDFilteredView.cc.

References begin, currentFilter_, end, f, ALCARECOTkAlBeamHalo_cff::filter, filters_, spr::find(), mps_fire::i, gen::k, cms::Filter::keys, checklumidiff::l, cms::Filter::next, and split.

Referenced by cms::DTGeometryBuilder::build(), and history().

33  {
34  for(const auto& i : specs) {
35  for(const auto& j : i->paths) {
36  vector<string_view> toks = split(j, "/");
37  auto const& filter = find_if(begin(filters_), end(filters_), [&](auto const& f) {
38  auto const& k = find(begin(f->keys), end(f->keys), toks.front());
39  if(k != end(f->keys)) {
40  currentFilter_ = f.get();
41  return true;
42  }
43  return false;
44  });
45  if(filter == end(filters_)) {
46  filters_.emplace_back(unique_ptr<Filter>(new Filter{{toks.front()}, nullptr, nullptr}));
47  currentFilter_ = filters_.back().get();
48  }
49  // all next levels
50  for(size_t pos = 1; pos < toks.size(); ++pos) {
51  if(currentFilter_->next != nullptr) {
53  auto const& l = find(begin(currentFilter_->keys), end(currentFilter_->keys), toks[pos]);
54  if(l == end(currentFilter_->keys)) {
55  currentFilter_->keys.emplace_back(toks[pos]);
56  }
57  } else {
58  currentFilter_->next.reset(new Filter{{toks[pos]}, nullptr, currentFilter_});
59  }
60  }
61  }
62  }
63 }
std::vector< std::unique_ptr< Filter > > filters_
std::vector< std::string_view > keys
Definition: Filter.h:27
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::unique_ptr< Filter > next
Definition: Filter.h:28
double f[11][100]
#define end
Definition: vmac.h:39
int k[5][pyjets_maxn]
Definition: Filter.py:1
#define begin
Definition: vmac.h:32
double split
Definition: MVATrainer.cc:139
bool DDFilteredView::next ( int  type)

set current node to the next node in the filtered tree

Definition at line 159 of file DDFilteredView.cc.

References it_, and node_.

Referenced by down(), firstSibling(), and history().

159  {
160  it_.back().SetType(type);
161  Node *node = nullptr;
162  if((node = it_.back().Next())) {
163  node_ = node;
164  return true;
165  }
166  else
167  return false;
168 }
type
Definition: HCALResponse.h:21
TGeoNode Node
std::vector< Iterator > it_
bool DDFilteredView::nextSibling ( )

set the current node to the next sibling

Definition at line 98 of file DDFilteredView.cc.

References cms::dd::accepted(), addNode(), currentFilter_, it_, cms::Filter::keys, node_, and unCheckNode().

Referenced by cms::DTGeometryBuilder::buildGeometry(), and history().

98  {
99  it_.back().SetType(1);
100  unCheckNode();
101  do {
102  if(accepted(currentFilter_->keys, node_->GetVolume()->GetName())) {
103  addNode(node_);
104  return true;
105  }
106  } while((node_ = it_.back().Next()));
107 
108  return false;
109 }
std::vector< std::string_view > keys
Definition: Filter.h:27
bool accepted(std::vector< std::string_view > const &, std::string_view)
void unCheckNode()
pop current node
std::vector< Iterator > it_
bool addNode(Node *const)
bool DDFilteredView::parent ( )

set the current node to the parent node ...

Definition at line 150 of file DDFilteredView.cc.

References it_, and up().

Referenced by Vispa.Gui.ConnectableWidget.ConnectableWidget::addMenuEntry(), Vispa.Views.LineDecayView.LineDecayContainer::applyFilter(), Vispa.Views.BoxDecayView.BoxDecayContainer::arrangeUsingRelations(), Vispa.Views.BoxDecayView.BoxDecayContainer::autolayoutAlgorithm(), Vispa.Gui.ZoomableScrollableWidgetOwner.ZoomableScrollableWidgetOwner::autosizeScrollArea(), Vispa.Views.BoxDecayView.BoxDecayContainer::autosizeScrollArea(), cms::DTGeometryBuilder::buildGeometry(), Vispa.Gui.PortWidget.PortWidget::connectionPoint(), DDDCmsMTDConstruction::construct(), DDDCmsTrackerContruction::construct(), Vispa.Main.StartupScreen.StartupScreen::createDescriptionWidget(), Vispa.Views.BoxDecayView.BoxDecayContainer::dataAccessor(), Vispa.Views.LineDecayView.LineDecayContainer::dataAccessor(), Vispa.Views.LineDecayView.DecayLine::dataAccessor(), Vispa.Views.LineDecayView.LineDecayContainer::delete(), Vispa.Views.LineDecayView.DecayNode::delete(), Vispa.Views.LineDecayView.DecayLine::delete(), Vispa.Gui.VispaWidget.VispaWidget::delete(), Vispa.Gui.VispaWidget.VispaWidget::dragWidget(), Vispa.Share.ImageExporter.ImageExporter::exportImageDialog(), Vispa.Views.LineDecayView.DecayLine::extendedSize(), history(), Vispa.Gui.VispaWidget.VispaWidget::keyPressEvent(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.ConnectableWidget.ConnectableWidget::leaveEvent(), Vispa.Gui.PortWidget.PortWidget::moduleParent(), Vispa.Gui.WidgetContainer.WidgetContainer::mouseDoubleClickEvent(), Vispa.Gui.VispaWidget.VispaWidget::mouseDoubleClickEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), Vispa.Views.LineDecayView.ParticleWidget::mousePressEvent(), Vispa.Views.LineDecayView.DecayNode::move(), Vispa.Views.LineDecayView.LineDecayContainer::noDecorationsMode(), Vispa.Views.LineDecayView.LineDecayContainer::operationId(), Vispa.Views.LineDecayView.DecayLine::paint(), Vispa.Gui.VispaWidget.VispaWidget::paintEvent(), Vispa.Gui.ConnectableWidget.ConnectableWidget::positionizeMenuWidget(), Vispa.Views.LineDecayView.DecayLine::qtLineStyle(), Vispa.Views.WidgetView.WidgetView::restoreSelection(), Vispa.Views.WidgetView.WidgetView::select(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Views.LineDecayView.LineDecayContainer::sizeHint(), Vispa.Views.LineDecayView.LineDecayContainer::tabController(), Vispa.Views.BoxDecayView.BoxDecayContainer::toggleCollapsed(), Vispa.Views.LineDecayView.DecayNode::unite(), Vispa.Views.PropertyView.PropertyView::valueChanged(), Vispa.Views.BoxDecayView.BoxDecayContainer::widgetByObject(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDoubleClicked(), and Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDragged().

150  {
151  up();
152  it_.back().SetType(0);
153  it_.back().Skip();
154 
155  return true;
156 }
void up()
set current node to the parent node in the filtered tree
std::vector< Iterator > it_
const Double_t * DDFilteredView::rot ( ) const

The absolute rotation of the current node.

Definition at line 28 of file DDFilteredView.cc.

References it_.

Referenced by history(), and cms::DTGeometryBuilder::plane().

28  {
29  return it_.back().GetCurrentMatrix()->GetRotationMatrix();
30 }
std::vector< Iterator > it_
bool DDFilteredView::sibling ( )

set the current node to the next sub sibling

Definition at line 112 of file DDFilteredView.cc.

References cms::dd::accepted(), addNode(), currentFilter_, it_, and cms::Filter::keys.

Referenced by cms::DTGeometryBuilder::buildGeometry(), and history().

112  {
113  it_.back().SetType(1);
114  Node *node = nullptr;
115  while((node = it_.back().Next())) {
116  if(accepted(currentFilter_->keys, node->GetVolume()->GetName())) {
117  addNode(node);
118  return true;
119  }
120  }
121  return false;
122 }
TGeoNode Node
std::vector< std::string_view > keys
Definition: Filter.h:27
bool accepted(std::vector< std::string_view > const &, std::string_view)
std::vector< Iterator > it_
bool addNode(Node *const)
bool DDFilteredView::siblingNoCheck ( )

Definition at line 125 of file DDFilteredView.cc.

References cms::dd::accepted(), currentFilter_, it_, cms::Filter::keys, and node_.

Referenced by cms::DTGeometryBuilder::buildLayer(), and history().

125  {
126  it_.back().SetType(1);
127  Node *node = nullptr;
128  while((node = it_.back().Next())) {
129  if(accepted(currentFilter_->keys, node->GetVolume()->GetName())) {
130  node_ = node;
131  return true;
132  }
133  }
134  return false;
135 }
TGeoNode Node
std::vector< std::string_view > keys
Definition: Filter.h:27
bool accepted(std::vector< std::string_view > const &, std::string_view)
std::vector< Iterator > it_
const Double_t * DDFilteredView::trans ( ) const

The absolute translation of the current node.

Definition at line 23 of file DDFilteredView.cc.

References it_.

Referenced by history(), and cms::DTGeometryBuilder::plane().

23  {
24  return it_.back().GetCurrentMatrix()->GetTranslation();
25 }
std::vector< Iterator > it_
void DDFilteredView::unCheckNode ( )

pop current node

Definition at line 266 of file DDFilteredView.cc.

References cms::ExpandedNodes::copyNos, nodes_, cms::ExpandedNodes::offsets, and cms::ExpandedNodes::tags.

Referenced by cms::DTGeometryBuilder::buildGeometry(), history(), and nextSibling().

266  {
267  nodes_.tags.pop_back();
268  nodes_.offsets.pop_back();
269  nodes_.copyNos.pop_back();
270 }
ExpandedNodes nodes_
std::vector< int > copyNos
Definition: ExpandedNodes.h:29
std::vector< double > offsets
Definition: ExpandedNodes.h:28
std::vector< double > tags
Definition: ExpandedNodes.h:27
void DDFilteredView::up ( )

set current node to the parent node in the filtered tree

Definition at line 179 of file DDFilteredView.cc.

References currentFilter_, it_, and cms::Filter::up.

Referenced by cms::DTGeometryBuilder::buildGeometry(), cms::DTGeometryBuilder::buildLayer(), history(), and parent().

179  {
180  it_.pop_back();
181  if(currentFilter_->up)
183 }
struct Filter * up
Definition: Filter.h:29
std::vector< Iterator > it_
const PlacedVolume DDFilteredView::volume ( void  ) const

The physical volume of the current node.

Definition at line 18 of file DDFilteredView.cc.

References node_.

Referenced by cms::DTGeometryBuilder::buildLayer(), extractParameters(), and history().

18  {
19  return PlacedVolume(node_);
20 }
dd4hep::PlacedVolume PlacedVolume

Member Data Documentation

Filter* cms::DDFilteredView::currentFilter_ = nullptr
private
std::vector<std::unique_ptr<Filter> > cms::DDFilteredView::filters_
private
std::vector<Iterator> cms::DDFilteredView::it_
private
Node* cms::DDFilteredView::node_ = nullptr
private
ExpandedNodes cms::DDFilteredView::nodes_
private

Definition at line 103 of file DDFilteredView.h.

Referenced by addNode(), addPath(), history(), and unCheckNode().

const DDSpecParRegistry* cms::DDFilteredView::registry_
private

Definition at line 108 of file DDFilteredView.h.

Referenced by addNode(), and addPath().