CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes
DDCompareEqual Class Reference

compares a given geometrical-history whether it corresponds to the given part-selector More...

#include <DDComparator.h>

Public Member Functions

 DDCompareEqual ()=delete
 
 DDCompareEqual (const DDGeoHistory &h, const DDPartSelection &s)
 
bool operator() ()
 
bool operator() (const DDGeoHistory &, const DDPartSelection &)
 

Protected Member Functions

bool nextAnylogp ()
 
bool nextAnyposp ()
 
bool nextChildlogp ()
 
bool nextChildposp ()
 

Private Attributes

bool absResult_
 
DDGeoHistory::size_type hIndex_
 
const DDGeoHistoryhist_
 
const DDGeoHistory::size_type hMax_
 
const DDPartSelectionpartsel_
 
int sCopyno_
 
DDPartSelection::size_type sIndex_
 
DDLogicalPart sLp_
 
const DDPartSelection::size_type sMax_
 

Detailed Description

compares a given geometrical-history whether it corresponds to the given part-selector

This is a function-object.

Definition at line 15 of file DDComparator.h.

Constructor & Destructor Documentation

◆ DDCompareEqual() [1/2]

DDCompareEqual::DDCompareEqual ( const DDGeoHistory h,
const DDPartSelection s 
)
inline

Definition at line 17 of file DDComparator.h.

18  : hist_(h),
19  partsel_(s),
20  hMax_(h.size()),
21  hIndex_(0),
22  sMax_(s.size()),
23  sIndex_(0),
24  sLp_(),
25  sCopyno_(0),
26  absResult_(hMax_ > 0 && sMax_ > 0) {
27  // it makes only sense to compare if both std::vectors have at least one entry each.
28  }

◆ DDCompareEqual() [2/2]

DDCompareEqual::DDCompareEqual ( )
delete

Member Function Documentation

◆ nextAnylogp()

bool DDCompareEqual::nextAnylogp ( )
inlineprotected

Definition at line 70 of file DDComparator.cc.

70  {
71  size_t hi = hIndex_;
72  while (hi < hMax_) {
73  if (sLp_ == hist_[hi].logicalPart()) {
74  hIndex_ = hi + 1;
75  return true;
76  }
77  ++hi;
78  }
79  hIndex_ = hi;
80  return false;
81 }

References hIndex_, hist_, hMax_, and sLp_.

Referenced by operator()().

◆ nextAnyposp()

bool DDCompareEqual::nextAnyposp ( )
inlineprotected

Definition at line 83 of file DDComparator.cc.

83  {
84  bool result(false);
85  while (hIndex_ < hMax_) {
86  if (sLp_ == hist_[hIndex_].logicalPart() && sCopyno_ == hist_[hIndex_].copyno()) {
87  result = true;
88  ++hIndex_;
89  break;
90  }
91  ++hIndex_;
92  }
93  return result;
94 }

References hIndex_, hist_, hMax_, mps_fire::result, sCopyno_, and sLp_.

Referenced by operator()().

◆ nextChildlogp()

bool DDCompareEqual::nextChildlogp ( )
inlineprotected

Definition at line 96 of file DDComparator.cc.

96  {
97  bool result(false);
98  if (hIndex_ < hMax_) {
99  if (sLp_ == hist_[hIndex_].logicalPart()) {
100  ++hIndex_;
101  result = true;
102  }
103  }
104  return result;
105 }

References hIndex_, hist_, hMax_, mps_fire::result, and sLp_.

Referenced by operator()().

◆ nextChildposp()

bool DDCompareEqual::nextChildposp ( )
inlineprotected

Definition at line 107 of file DDComparator.cc.

107  {
108  bool result(false);
109  if (hIndex_ < hMax_) {
110  if (sLp_ == hist_[hIndex_].logicalPart() && sCopyno_ == hist_[hIndex_].copyno()) {
111  ++hIndex_;
112  result = true;
113  }
114  }
115  return result;
116 }

References hIndex_, hist_, hMax_, mps_fire::result, sCopyno_, and sLp_.

Referenced by operator()().

◆ operator()() [1/2]

bool DDCompareEqual::operator() ( )

Definition at line 14 of file DDComparator.cc.

14  {
15  // don't compare, if history or partsel is empty! (see ctor)
16  bool result(absResult_);
17 
18  /*
19  sIndex_ = running index in the part-selection-std::vector
20  sMax_ = max. value + 1 of sIndex_
21  hIndex_ = runninig index in the geo-history-std::vector
22  hMax_ = max. value + 1 of hIndex_
23  sLp_ = current LogicalPart (the redir-ptr!) in the part-selection-std::vector
24  hLp_ = current LogicalPart (the redir-ptr!) in the geo-history-std::vector
25  sCopyno_ = current copy-no in the part-selection-std::vector
26  */
27  //DCOUT('U', "DDCompareEqual: comparing");
28 
29  while (result && sIndex_ < sMax_) {
30  sLp_ = partsel_[sIndex_].lp_;
31  sCopyno_ = partsel_[sIndex_].copyno_;
32  ddselection_type stype = partsel_[sIndex_].selectionType_;
33  switch (stype) {
34  case ddanylogp:
35  result = nextAnylogp();
36  break;
37 
38  case ddanyposp:
39  result = nextAnyposp();
40  break;
41 
42  case ddchildlogp:
44  break;
45 
46  case ddchildposp:
48  break;
49 
50  case ddanychild:
51  ++sIndex_;
52  ++hIndex_;
53  result = true;
54  break;
55 
56  // ddanynode IS NOT SUPPORTED IN PROTOTYPE SW !!!!
57  case ddanynode:
58  result = false;
59  break;
60 
61  default:
62  result = false;
63  //throw DDException("DDCompareEqual: undefined state!");
64  }
65  ++sIndex_;
66  }
67  return result;
68 }

References absResult_, ddanychild, ddanylogp, ddanynode, ddanyposp, ddchildlogp, ddchildposp, hIndex_, nextAnylogp(), nextAnyposp(), nextChildlogp(), nextChildposp(), partsel_, mps_fire::result, sCopyno_, sIndex_, sLp_, and sMax_.

◆ operator()() [2/2]

bool DDCompareEqual::operator() ( const DDGeoHistory ,
const DDPartSelection  
)

Definition at line 12 of file DDComparator.cc.

12 { return (*this)(); }

Member Data Documentation

◆ absResult_

bool DDCompareEqual::absResult_
private

Definition at line 50 of file DDComparator.h.

Referenced by operator()().

◆ hIndex_

DDGeoHistory::size_type DDCompareEqual::hIndex_
private

Definition at line 45 of file DDComparator.h.

Referenced by nextAnylogp(), nextAnyposp(), nextChildlogp(), nextChildposp(), and operator()().

◆ hist_

const DDGeoHistory& DDCompareEqual::hist_
private

Definition at line 42 of file DDComparator.h.

Referenced by nextAnylogp(), nextAnyposp(), nextChildlogp(), and nextChildposp().

◆ hMax_

const DDGeoHistory::size_type DDCompareEqual::hMax_
private

Definition at line 44 of file DDComparator.h.

Referenced by nextAnylogp(), nextAnyposp(), nextChildlogp(), and nextChildposp().

◆ partsel_

const DDPartSelection& DDCompareEqual::partsel_
private

Definition at line 43 of file DDComparator.h.

Referenced by operator()().

◆ sCopyno_

int DDCompareEqual::sCopyno_
private

Definition at line 49 of file DDComparator.h.

Referenced by nextAnyposp(), nextChildposp(), and operator()().

◆ sIndex_

DDPartSelection::size_type DDCompareEqual::sIndex_
private

Definition at line 47 of file DDComparator.h.

Referenced by operator()().

◆ sLp_

DDLogicalPart DDCompareEqual::sLp_
private

Definition at line 48 of file DDComparator.h.

Referenced by nextAnylogp(), nextAnyposp(), nextChildlogp(), nextChildposp(), and operator()().

◆ sMax_

const DDPartSelection::size_type DDCompareEqual::sMax_
private

Definition at line 46 of file DDComparator.h.

Referenced by operator()().

ddanychild
Definition: DDPartSelection.h:14
DDCompareEqual::hMax_
const DDGeoHistory::size_type hMax_
Definition: DDComparator.h:44
DDCompareEqual::absResult_
bool absResult_
Definition: DDComparator.h:50
DDCompareEqual::sMax_
const DDPartSelection::size_type sMax_
Definition: DDComparator.h:46
ddanyposp
Definition: DDPartSelection.h:16
alignCSCRings.s
s
Definition: alignCSCRings.py:92
ddchildposp
Definition: DDPartSelection.h:18
DDCompareEqual::partsel_
const DDPartSelection & partsel_
Definition: DDComparator.h:43
DDCompareEqual::sIndex_
DDPartSelection::size_type sIndex_
Definition: DDComparator.h:47
h
ddselection_type
ddselection_type
Definition: DDPartSelection.h:11
DDCompareEqual::hist_
const DDGeoHistory & hist_
Definition: DDComparator.h:42
DDCompareEqual::hIndex_
DDGeoHistory::size_type hIndex_
Definition: DDComparator.h:45
DDCompareEqual::sCopyno_
int sCopyno_
Definition: DDComparator.h:49
ddanynode
Definition: DDPartSelection.h:13
ddanylogp
Definition: DDPartSelection.h:15
DDCompareEqual::sLp_
DDLogicalPart sLp_
Definition: DDComparator.h:48
DDCompareEqual::nextAnyposp
bool nextAnyposp()
Definition: DDComparator.cc:83
hi
Definition: EPCuts.h:4
DDCompareEqual::nextChildlogp
bool nextChildlogp()
Definition: DDComparator.cc:96
ddchildlogp
Definition: DDPartSelection.h:17
DDCompareEqual::nextAnylogp
bool nextAnylogp()
Definition: DDComparator.cc:70
DDCompareEqual::nextChildposp
bool nextChildposp()
Definition: DDComparator.cc:107
mps_fire.result
result
Definition: mps_fire.py:311