CMS 3D CMS Logo

Specific.cc
Go to the documentation of this file.
2 
3 #include <cassert>
4 #include <ext/alloc_traits.h>
5 #include <cstddef>
6 #include <memory>
7 
17 
18 namespace DDI {
19 
20  Specific::Specific(const std::vector<std::string>& selections, const DDsvalues_type& specs, bool doRegex)
21  : specifics_(specs), partSelections_(0), valid_(false), doRegex_(doRegex) {
22  for (const auto& it : selections) {
24  }
25  }
26 
27  Specific::Specific(const std::vector<DDPartSelection>& selections, const DDsvalues_type& specs)
28  : specifics_(specs), partSelections_(selections), valid_(false), doRegex_(false) {}
29 
31  std::vector<DDPartSelRegExpLevel> regv;
32  std::vector<DDPartSelection> temp;
33  DDTokenize2(selString, regv);
34 
35  if (regv.empty())
36  throw cms::Exception("DDException") << "Could not evaluate the selection-std::string ->" << selString << "<-";
37 
38  std::pair<bool, std::string> res;
39  for (const auto& it : regv) {
40  std::vector<DDLogicalPart> lpv;
41  res = DDIsValid(it.ns_, it.nm_, lpv, doRegex_);
42  if (!res.first) {
43  std::string msg("Could not process q-name of a DDLogicalPart, reason:\n" + res.second);
44  msg += "\nSpecPar selection is:\n" + selString + "\n";
45  //throw cms::Exception("DDException") << "Could not process q-name of a DDLogicalPart, reason:\n" << res.second;
46  edm::LogError("Specific") << msg;
47  break; //EXIT for loop
48  }
49  addSelectionLevel(lpv, it.copyno_, it.selectionType_, temp);
50  }
51  if (res.first) { // i.e. it wasn't "thrown" out of the loop
52  partSelections_.reserve(temp.size() + partSelections_.size());
53  for (const auto& iit : temp) {
54  partSelections_.emplace_back(iit);
55  }
56  }
57  }
58 
59  void Specific::addSelectionLevel(std::vector<DDLogicalPart>& lpv,
60  int copyno,
62  std::vector<DDPartSelection>& selv) {
63  if (selv.empty()) { // create one, no entry yet!
64  selv.emplace_back(DDPartSelection());
65  }
66  typedef std::vector<DDLogicalPart>::size_type lpv_sizetype;
67  typedef std::vector<DDPartSelection>::size_type ps_sizetype;
68  ps_sizetype ps_sz = selv.size();
69  lpv_sizetype lpv_sz = lpv.size();
70  lpv_sizetype lpv_i = 0;
71  std::vector<DDPartSelection> result;
72  for (; lpv_i < lpv_sz; ++lpv_i) {
73  std::vector<DDPartSelection>::const_iterator ps_it = selv.begin();
74  for (; ps_it != selv.end(); ++ps_it) {
75  result.emplace_back(*ps_it);
76  }
77  }
78  ps_sizetype ps_i = 0;
79  for (lpv_i = 0; lpv_i < lpv_sz; ++lpv_i) {
80  for (ps_i = ps_sz * lpv_i; ps_i < ps_sz * (lpv_i + 1); ++ps_i) {
81  result[ps_i].emplace_back(DDPartSelectionLevel(lpv[lpv_i], copyno, st));
82  }
83  }
84  selv = result;
85  }
86 
87  const std::vector<DDPartSelection>& Specific::selection() const { return partSelections_; }
88 
89  void Specific::stream(std::ostream& os) const {
90  os << " Size: " << specifics_.size() << std::endl;
91  os << "\tSelections:" << std::endl;
92  for (const auto& pit : partSelections_) {
93  os << pit << std::endl;
94  }
95  for (const auto& vit : specifics_) {
96  const DDValue& v = vit.second;
97  os << "\tParameter name= \"" << v.name() << "\" " << std::endl;
98  os << "\t\t Value pairs: " << std::endl;
99  size_t s = v.size();
100  size_t i = 0;
101  if (v.isEvaluated()) {
102  for (; i < s; ++i) {
103  os << "\t\t\t\"" << v[i].first << "\""
104  << ", " << v[i].second << std::endl;
105  }
106  } else { // v is not evaluated
107  for (const auto& i : v.strings()) {
108  os << "\t\t\t\"" << i << "\""
109  << ", not evaluated" << std::endl;
110  }
111  }
112  }
113  }
114 
116  std::vector<std::pair<DDLogicalPart, std::pair<const DDPartSelection*, const DDsvalues_type*> > >& result) const {
117  if (!partSelections_.empty()) {
118  const DDsvalues_type* sv = (&specifics_);
119  for (const auto& it : partSelections_) {
120  DDLogicalPart logp = it.back().lp_;
121  const DDPartSelection* ps = (&it);
122  assert(ps);
123  assert(sv);
124  std::pair<const DDPartSelection*, const DDsvalues_type*> pssv(ps, sv);
125  result.emplace_back(std::make_pair(logp, pssv));
126  }
127  }
128  }
129 
138  std::pair<bool, DDExpandedView> Specific::node() const {
140  DDExpandedView e(c);
141 
142  if (partSelections_.size() != 1) {
143  edm::LogError("Specific") << " >> more or less than one part-selector, currently NOT SUPPORTED! <<" << std::endl;
144  return std::make_pair(false, e);
145  }
146  const DDPartSelection& ps = partSelections_[0];
147 
148  DDPartSelection::const_iterator it = ps.begin();
149  DDPartSelection::const_iterator ed = ps.end();
150  if ((it != ed) && (it->selectionType_ != ddanyposp)) {
151  edm::LogError("Specific") << " >> part-selector must start with //Name[no] ! << " << std::endl;
152  return std::make_pair(false, e);
153  }
154  ++it;
155  for (; it != ps.end(); ++it) {
156  if (it->selectionType_ != ddchildposp) {
157  edm::LogError("Specific") << " >> part-selector must be a concatenation of direct children\n"
158  << " including their copy-number only, CURRENT LIMITATION! <<" << std::endl;
159  return std::make_pair(false, e);
160  }
161  }
162 
163  it = ps.begin();
164  bool result = true;
165  for (; it != ed; ++it) {
166  while (result) {
167  if ((it->copyno_ == e.copyno()) && (it->lp_ == e.logicalPart())) {
168  break;
169  } else {
170  result = e.nextSibling();
171  }
172  }
173  if ((ed - it) > 1) {
174  result = e.firstChild();
175  }
176  }
177  return std::make_pair(result, e);
178  }
179 } // namespace DDI
DDValuePair.h
DDBase.h
DDI
Definition: DDCompactView.h:25
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
ddanyposp
Definition: DDPartSelection.h:16
HistogramManager_cfi.specs
specs
Definition: HistogramManager_cfi.py:80
DDI::Specific::selection
const std::vector< DDPartSelection > & selection() const
Definition: Specific.cc:87
DDExpandedView.h
cms::cuda::assert
assert(be >=bs)
DDI::Specific::updateLogicalPart
void updateLogicalPart(std::vector< std::pair< DDLogicalPart, std::pair< const DDPartSelection *, const DDsvalues_type * > > > &) const
Definition: Specific.cc:115
DDPartSelection
Definition: DDPartSelection.h:37
mps_check.msg
tuple msg
Definition: mps_check.py:285
findQualityFiles.v
v
Definition: findQualityFiles.py:179
Specific.h
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
DDI::Specific::specifics_
DDsvalues_type specifics_
Definition: Specific.h:46
DDCompactView.h
sistrip::valid_
static const uint16_t valid_
Definition: Constants.h:17
alignCSCRings.s
s
Definition: alignCSCRings.py:92
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
ddchildposp
Definition: DDPartSelection.h:18
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
DDExpandedView
Provides an exploded view of the detector (tree-view)
Definition: DDExpandedView.h:41
DDValue.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ddselection_type
ddselection_type
Definition: DDPartSelection.h:11
DDPartSelectionLevel
Definition: DDPartSelection.h:30
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
DDI::Specific::createPartSelections
void createPartSelections(const std::string &selString)
Definition: Specific.cc:30
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DDLogicalPart.h
res
Definition: Electron.h:6
DDI::Specific::stream
void stream(std::ostream &) const
Definition: Specific.cc:89
DDI::Specific::partSelections_
std::vector< DDPartSelection > partSelections_
Definition: Specific.h:47
DDCompactViewImpl.h
DDI::Specific::doRegex_
bool doRegex_
Definition: Specific.h:49
DDValue
Definition: DDValue.h:21
DDI::Specific::addSelectionLevel
void addSelectionLevel(std::vector< DDLogicalPart > &lpv, int copyno, ddselection_type st, std::vector< DDPartSelection > &selv)
Definition: Specific.cc:59
DDI::Specific::node
std::pair< bool, DDExpandedView > node() const
gives the geometrical history of a fully specified PartSelector
Definition: Specific.cc:138
DDIsValid
std::pair< bool, std::string > DDIsValid(const std::string &ns, const std::string &name, std::vector< DDLogicalPart > &result, bool doRegex=true)
Definition: DDLogicalPart.cc:248
Exception.h
clusterbigeventsdebugger_cfi.selections
selections
Definition: clusterbigeventsdebugger_cfi.py:10
DDTokenize2
void DDTokenize2(const std::string &selectionString, std::vector< DDPartSelRegExpLevel > &result)
Definition: DDPartSelection.cc:174
mps_fire.result
result
Definition: mps_fire.py:311
cms::Exception
Definition: Exception.h:70
DDI::Specific::Specific
Specific(const std::vector< std::string > &selections, const DDsvalues_type &specs, bool doRegex=true)
Definition: Specific.cc:20
DDsvalues_type
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37