CMS 3D CMS Logo

DDScope.cc

Go to the documentation of this file.
00001 
00002 
00003 #include "DetectorDescription/Core/interface/DDScope.h"
00004 
00005 dd_scope_class DDScopeClassification::operator()(const DDGeoHistory & left,
00006                                                  const DDGeoHistory & right) const
00007 {
00008   
00009   dd_scope_class result = subtree;
00010   DDGeoHistory::const_iterator lit = left.begin(); // left-iterator
00011   DDGeoHistory::const_iterator rit = right.begin(); // right-iterator
00012   //DDGeoHistory::size_type depth = 0;
00013   while(lit != left.end() && rit!=right.end()) {
00014     //DCOUT('s', "  classify: a=" << *lit << std::endl << "              : b=" << *rit );
00015     if (lit->siblingno() != rit->siblingno()) {
00016       result = different_branch;
00017       break;
00018     }  
00019     //++depth;
00020     ++lit;
00021     ++rit;
00022   }
00023   
00024   if (result != different_branch) {
00025     if(lit==left.end()) { // left history leaf node marks the root of a subtree which contains
00026       result=supertree;   // the leaf node of the right history or both roots are the same ...
00027     }
00028     else {
00029       result=subtree;
00030     }    
00031   }
00032   return result;
00033  
00034 }
00035 
00036 
00037 DDScope::DDScope() { }
00038 
00039 
00040 DDScope::DDScope(const DDGeoHistory & h, int depth)
00041  : depth_(depth)
00042 {
00043   subtrees_.push_back(h);
00044 }
00045 
00046 
00047 DDScope::~DDScope() 
00048 { }
00049 
00050 
00051 bool DDScope::addScope(const DDGeoHistory & h)
00052 {
00053    bool result = false;
00054    //DCOUT('S',"DDScope::addScope()" << h);
00055    scope_type::iterator it = subtrees_.begin();
00056    scope_type buf;
00057    int supertreeCount = 0;
00058    bool diffBranch = false;
00059    bool subTree = false;
00060    //DDGeoHistory::size_type pos = subtree_.size();
00061    
00062    for(; it != subtrees_.end(); ++it) {
00063      dd_scope_class classification = classify_(h,*it);
00064      switch (classification) {
00065      
00066      case different_branch:
00067        buf.push_back(*it);
00068        diffBranch=true;
00069        //buf.push_back(h);
00070        //DCOUT('S',"  ->different_branch");
00071        break;
00072      
00073      case subtree:
00074        buf.push_back(*it);
00075        subTree = true;
00076        //DCOUT('S',"  ->subtree");
00077        break;
00078      
00079      case supertree:
00080        //buf.push_back(h);   
00081        ++supertreeCount;
00082        if (supertreeCount==1)
00083          buf.push_back(h);
00084        //DCOUT('S',"  ->supertree");
00085        break;
00086        
00087      default:
00088       ;  
00089      }
00090    }
00091    
00092    if (diffBranch) {
00093      if (subTree==false) {
00094        buf.push_back(h);
00095      }  
00096    }
00097    
00098    if (!subtrees_.size()) 
00099      subtrees_.push_back(h);
00100    else  
00101      subtrees_ = buf;
00102    
00103    //DCOUT('S',"DDScope.size()=" << subtrees_.size() );  
00104    return result;
00105 }
00106 
00107 
00108 void DDScope::setDepth(int d)
00109 {
00110   depth_ = d;
00111 }
00112 
00113 
00114 int DDScope::depth() const
00115 {
00116   return depth_;
00117 }
00118 
00119 
00120 const DDScope::scope_type & DDScope::scope() const
00121 {
00122    return subtrees_;
00123 }
00124 
00125 std::ostream & operator<<(std::ostream & os, const DDScope & scope)
00126 {
00127    DDScope::scope_type::const_iterator it = scope.subtrees_.begin();
00128    for (; it!=scope.subtrees_.end(); ++ it) {
00129      os << *it << std::endl;
00130    }
00131    return os;
00132 }
00133 

Generated on Tue Jun 9 17:32:16 2009 for CMSSW by  doxygen 1.5.4