Skip to content

Commit

Permalink
Merge pull request #26218 from ianna/dd-filtered-view-v4
Browse files Browse the repository at this point in the history
DD4hep: DD Filtered View
  • Loading branch information
cmsbuild authored Mar 21, 2019
2 parents 6050be8 + 642e621 commit 2a20749
Show file tree
Hide file tree
Showing 18 changed files with 982 additions and 400 deletions.
2 changes: 1 addition & 1 deletion DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<Include ref='Geometry/MuonCommonData/data/csc/2015/v2/csc.xml'/>
<Include ref='Geometry/MuonCommonData/data/mfshield/2015/v1/mfshield.xml'/>
<Include ref='Geometry/MuonCommonData/data/muonNumbering/2015/v2/muonNumbering.xml'/>
<Include ref='Geometry/DTGeometryBuilder/data/dtSpecsFilter.xml'/>
<Include ref='Geometry/DTGeometryBuilder/data/dtSpecsFilter/2019/v1/dtSpecsFilter.xml'/>
<Include ref='DetectorDescription/DDCMS/data/trackerParameters.xml'/>
</IncludeSection>

Expand Down
36 changes: 0 additions & 36 deletions DetectorDescription/DDCMS/interface/DDExpandedNode.h

This file was deleted.

108 changes: 57 additions & 51 deletions DetectorDescription/DDCMS/interface/DDFilteredView.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,88 +18,94 @@
// Created: Wed, 30 Jan 2019 09:24:30 GMT
//
//
#include "DetectorDescription/DDCMS/interface/DDExpandedNode.h"

#include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h"
#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h"
#include "DetectorDescription/DDCMS/interface/Filter.h"
#include <DD4hep/Volumes.h>
#include <memory>
#include <vector>

namespace cms {

class DDDetector;

//! Geometrical 'path' of the current node up to the root-node
using DDGeoHistory = std::vector<DDExpandedNode>;
using Volume = dd4hep::Volume;
using PlacedVolume = dd4hep::PlacedVolume;
using ExpandedNodes = cms::ExpandedNodes;
using Filter = cms::Filter;
using Iterator = TGeoIterator;
using Node = TGeoNode;

class DDFilteredView {

public:

struct DDFilteredView {

struct ExpandedNodes {
std::vector<double> tags;
std::vector<double> offsets;
std::vector<int> copyNos;
} nodes;
DDFilteredView(const DDDetector*, const Volume);
DDFilteredView() = delete;

DDFilteredView(const DDDetector*);
//! The numbering history of the current node
const ExpandedNodes& history() const {
return nodes_;
}

//! The logical-part of the current node in the filtered-view
const DDVolume & volume() const;
//! The physical volume of the current node
const PlacedVolume volume() const;

//! The absolute translation of the current node
const DDTranslation & translation() const;
const Double_t* trans() const;

//! The absolute rotation of the current node
const DDRotationMatrix & rotation() const;
const Double_t* rot() const;

//! User specific data
void mergedSpecifics(DDSpecParRefs const&);

//! set the current node to the first child
bool firstChild();

//! set the current node to the first sibling
bool firstSibling();

//! set the current node to the next sibling
bool nextSibling();

//! set current node to the next node in the filtered tree
bool next();
//! set the current node to the next sub sibling
bool sibling();
bool siblingNoCheck();

//! The list of ancestors up to the root-node of the current node
const DDGeoHistory & geoHistory() const;

bool accepted(std::string_view, std::string_view) const;
bool accepted(std::vector<std::string_view> const&, std::string_view) const;
bool acceptedM(std::vector<std::string_view>&, std::string_view) const;
std::vector<std::string_view> const& topNodes() const { return topNodes_; }
std::vector<std::string_view> const& nextNodes() const { return nextNodes_; }
std::vector<std::string_view> const& afterNextNodes() const { return afterNextNodes_; }
//! count the number of children matching selection
bool checkChild();

std::vector<double> extractParameters() const;
std::vector<std::string_view> paths(const char*) const;
bool checkPath(std::string_view, TGeoNode *);
bool checkNode(TGeoNode *);
//! set the current node to the parent node ...
bool parent();

//! set current node to the next node in the filtered tree
bool next(int);

//! set current node to the child node in the filtered tree
void down();

//! set current node to the parent node in the filtered tree
void up();

//! pop current node
void unCheckNode();
void filter(DDSpecParRefs&, std::string_view, std::string_view) const;
std::vector<std::string_view> vPathsTo(const DDSpecPar&, unsigned int) const;
std::vector<std::string_view> tails(const std::vector<std::string_view>& fullPath) const;

DDGeoHistory parents_;

//! extract shape parameters
std::vector<double> extractParameters() const;

private:
const DDSpecParRegistry* registry_;

bool isRegex(std::string_view) const;
int contains(std::string_view, std::string_view) const;
std::string_view realTopName(std::string_view input) const;
int copyNo(std::string_view input) const;
std::string_view noCopyNo(std::string_view input) const;
std::string_view noNamespace(std::string_view input) const;
std::vector<std::string_view> split(std::string_view, const char*) const;
bool acceptRegex(std::string_view, std::string_view) const;
bool accept(std::string_view);
bool addPath(std::string_view, Node* const);
bool addNode(Node* const);

std::vector<std::string_view> topNodes_;
std::vector<std::string_view> nextNodes_;
std::vector<std::string_view> afterNextNodes_;

TGeoVolume *topVolume_ = nullptr;
TGeoNode *node_ = nullptr;
ExpandedNodes nodes_;
std::vector<Iterator> it_;
std::vector<std::unique_ptr<Filter>> filters_;
Filter* currentFilter_ = nullptr;
Node *node_ = nullptr;
const DDSpecParRegistry* registry_;
};
}

Expand Down
33 changes: 33 additions & 0 deletions DetectorDescription/DDCMS/interface/ExpandedNodes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef DETECTOR_DESCRIPTION_EXPANDED_NODES_H
#define DETECTOR_DESCRIPTION_EXPANDED_NODES_H

// -*- C++ -*-
//
// Package: DetectorDescription/ExpandedNodes
// Class: ExpandedNodes
//
/**\class ExpandedNodes
Description: ExpandedNodes extra attributes: tags, offsets
and copy numbers
Implementation:
ExpandedNodes structure to keep the nodes history
*/
//
// Original Author: Ianna Osborne
// Created: Tue, 18 Mar 2019 12:22:35 CET
//
//
#include <vector>

namespace cms {

struct ExpandedNodes {
std::vector<double> tags;
std::vector<double> offsets;
std::vector<int> copyNos;
};
}

#endif
45 changes: 45 additions & 0 deletions DetectorDescription/DDCMS/interface/Filter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef DETECTOR_DESCRIPTION_FILTER_H
#define DETECTOR_DESCRIPTION_FILTER_H

// -*- C++ -*-
//
// Package: DetectorDescription/Filter
// Class: Filter
//
/**\class Filter
Description: Filter list
Implementation:
Filter criteria is defined in XML
*/
//
// Original Author: Ianna Osborne
// Created: Tue, 12 Mar 2019 09:51:33 CET
//
//
#include <memory>
#include <vector>

namespace cms {

struct Filter {
std::vector<std::string_view> keys;
std::unique_ptr<Filter> next;
struct Filter* up;
};

namespace dd {
bool accepted(std::vector<std::string_view> const&, std::string_view);
int contains(std::string_view, std::string_view);
bool isRegex(std::string_view);
bool compareEqual(std::string_view, std::string_view);
std::string_view realTopName(std::string_view input);
std::string_view noCopyNo(std::string_view input);
int copyNo(std::string_view input);
std::string_view noNamespace(std::string_view input);
std::vector<std::string_view> split(std::string_view, const char*);
}
}

#endif
4 changes: 2 additions & 2 deletions DetectorDescription/DDCMS/interface/MuonNumbering.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DETECTOR_DESCRIPTION_MUON_NUMBERING_H
#define DETECTOR_DESCRIPTION_MUON_NUMBERING_H

#include "DetectorDescription/DDCMS/interface/DDFilteredView.h"
#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h"
#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
#include <string>
#include <unordered_map>
Expand All @@ -13,7 +13,7 @@ namespace cms {
using MuonConstants = std::unordered_map<std::string_view, int>;

struct MuonNumbering {
const MuonBaseNumber geoHistoryToBaseNumber(const DDFilteredView::ExpandedNodes&) const;
const MuonBaseNumber geoHistoryToBaseNumber(const cms::ExpandedNodes&) const;
const int get(const char*) const;

MuonConstants values;
Expand Down
3 changes: 2 additions & 1 deletion DetectorDescription/DDCMS/python/cmsMFGeometryXML_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource",
geomXMLFiles = cms.vstring('Geometry/CMSCommonData/data/normal/cmsextent.xml',
'Geometry/CMSCommonData/data/cms.xml',
'Geometry/CMSCommonData/data/cmsMagneticField.xml',
'Geometry/CMSCommonData/data/cmsMagneticField.xml',
'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_1.xml',
'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_2.xml',
'Geometry/CMSCommonData/data/materials.xml'),
rootNodeName = cms.string('cms:MCMS')
)
Loading

0 comments on commit 2a20749

Please sign in to comment.