Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:25

0001 #include "DetectorDescription/Core/interface/DDComparator.h"
0002 
0003 #include <cstddef>
0004 #include <memory>
0005 
0006 #include "DetectorDescription/Core/interface/DDBase.h"
0007 
0008 // reason for the ctor: reference initialization at construction.
0009 // FIXME: DDCompareEqual: use pointers instead of references, initialize to 0 and
0010 // FIXME: do the check in operator() instead of in the ctor
0011 
0012 bool DDCompareEqual::operator()(const DDGeoHistory&, const DDPartSelection&) { return (*this)(); }
0013 
0014 bool DDCompareEqual::operator()() {
0015   // don't compare, if history or partsel is empty! (see ctor)
0016   bool result(absResult_);
0017 
0018   /*
0019      sIndex_  =  running index in the part-selection-std::vector
0020      sMax_    =  max. value + 1 of sIndex_
0021      hIndex_  =  runninig index in the geo-history-std::vector
0022      hMax_    =  max. value + 1 of hIndex_
0023      sLp_     =  current LogicalPart (the redir-ptr!) in the part-selection-std::vector
0024      hLp_     =  current LogicalPart (the redir-ptr!) in the geo-history-std::vector
0025      sCopyno_ =  current copy-no in the part-selection-std::vector
0026   */
0027   //DCOUT('U', "DDCompareEqual: comparing");
0028 
0029   while (result && sIndex_ < sMax_) {
0030     sLp_ = partsel_[sIndex_].lp_;
0031     sCopyno_ = partsel_[sIndex_].copyno_;
0032     ddselection_type stype = partsel_[sIndex_].selectionType_;
0033     switch (stype) {
0034       case ddanylogp:
0035         result = nextAnylogp();
0036         break;
0037 
0038       case ddanyposp:
0039         result = nextAnyposp();
0040         break;
0041 
0042       case ddchildlogp:
0043         result = nextChildlogp();
0044         break;
0045 
0046       case ddchildposp:
0047         result = nextChildposp();
0048         break;
0049 
0050       case ddanychild:
0051         ++sIndex_;
0052         ++hIndex_;
0053         result = true;
0054         break;
0055 
0056       // ddanynode IS NOT SUPPORTED IN PROTOTYPE SW !!!!
0057       case ddanynode:
0058         result = false;
0059         break;
0060 
0061       default:
0062         result = false;
0063         //throw DDException("DDCompareEqual: undefined state!");
0064     }
0065     ++sIndex_;
0066   }
0067   return result;
0068 }
0069 
0070 bool DDCompareEqual::nextAnylogp() {
0071   size_t hi = hIndex_;
0072   while (hi < hMax_) {
0073     if (sLp_ == hist_[hi].logicalPart()) {
0074       hIndex_ = hi + 1;
0075       return true;
0076     }
0077     ++hi;
0078   }
0079   hIndex_ = hi;
0080   return false;
0081 }
0082 
0083 bool DDCompareEqual::nextAnyposp() {
0084   bool result(false);
0085   while (hIndex_ < hMax_) {
0086     if (sLp_ == hist_[hIndex_].logicalPart() && sCopyno_ == hist_[hIndex_].copyno()) {
0087       result = true;
0088       ++hIndex_;
0089       break;
0090     }
0091     ++hIndex_;
0092   }
0093   return result;
0094 }
0095 
0096 bool DDCompareEqual::nextChildlogp() {
0097   bool result(false);
0098   if (hIndex_ < hMax_) {
0099     if (sLp_ == hist_[hIndex_].logicalPart()) {
0100       ++hIndex_;
0101       result = true;
0102     }
0103   }
0104   return result;
0105 }
0106 
0107 bool DDCompareEqual::nextChildposp() {
0108   bool result(false);
0109   if (hIndex_ < hMax_) {
0110     if (sLp_ == hist_[hIndex_].logicalPart() && sCopyno_ == hist_[hIndex_].copyno()) {
0111       ++hIndex_;
0112       result = true;
0113     }
0114   }
0115   return result;
0116 }