Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DDExpandedNode_h
0002 #define DDExpandedNode_h
0003 
0004 #include <iosfwd>
0005 #include <vector>
0006 
0007 #include "DetectorDescription/Core/interface/DDRotationMatrix.h"
0008 #include "DetectorDescription/Core/interface/DDTranslation.h"
0009 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0010 #include "DetectorDescription/Core/interface/DDTransform.h"
0011 
0012 class DDExpandedView;
0013 struct DDPosData;
0014 
0015 //! represents one node in the DDExpandedView
0016 class DDExpandedNode {
0017   friend class DDExpandedView;
0018 
0019 public:
0020   DDExpandedNode(
0021       const DDLogicalPart &lp, const DDPosData *pd, const DDTranslation &t, const DDRotationMatrix &r, int siblingno);
0022 
0023   ~DDExpandedNode();
0024 
0025   bool operator==(const DDExpandedNode &n) const;
0026 
0027   //! the LogicalPart describing this node
0028   const DDLogicalPart &logicalPart() const { return logp_; }
0029 
0030   //! absolute translation of this node
0031   const DDTranslation &absTranslation() const { return trans_; }
0032 
0033   //! absolute rotation of this node
0034   const DDRotationMatrix &absRotation() const { return rot_; }
0035 
0036   //! copy number of this node
0037   int copyno() const;
0038 
0039   //! sibling number of this node
0040   int siblingno() const { return siblingno_; }
0041 
0042   const DDPosData *posdata() const { return posd_; }
0043 
0044 private:
0045   DDLogicalPart logp_;  // logicalpart to provide access to solid & material information
0046   const DDPosData *posd_;
0047   DDTranslation trans_;   // absolute translation
0048   DDRotationMatrix rot_;  // absolute rotation
0049   int siblingno_;         // internal sibling-numbering from 0 to max-sibling
0050 };
0051 
0052 //! function object to compare to ExpandedNodes
0053 /**
0054   compares (for STL usage) two DDExpandedNodes for 
0055 */
0056 struct DDExpandedNodeLess {
0057   bool operator()(const DDExpandedNode &n1, const DDExpandedNode &n2) {
0058     const DDTranslation &t1 = n1.absTranslation();
0059     const DDTranslation &t2 = n2.absTranslation();
0060 
0061     bool result = false;
0062 
0063     // 'alphabetical ordering' according to absolute position
0064 
0065     if (t1.z() < t2.z()) {
0066       result = true;
0067     } else if ((t1.z() == t2.z()) && (t1.y() < t2.y())) {
0068       result = true;
0069     } else if ((t1.z() == t2.z()) && (t1.y() == t2.y()) && (t1.x() < t2.x())) {
0070       result = true;
0071     } else if (n1.siblingno() < n2.siblingno()) {
0072       result = true;
0073     } else if (n1.logicalPart().ddname() < n2.logicalPart().ddname()) {
0074       result = true;
0075     }
0076 
0077     return result;
0078   }
0079 };
0080 
0081 //! Geometrical 'path' of the current node up to the root-node
0082 typedef std::vector<DDExpandedNode> DDGeoHistory;
0083 
0084 std::ostream &operator<<(std::ostream &, const DDExpandedNode &);
0085 std::ostream &operator<<(std::ostream &, const DDGeoHistory &);
0086 #endif