00001 #include "DetectorDescription/Core/interface/DDDivision.h" 00002 #include "Division.h" 00003 00004 #include "DetectorDescription/Base/interface/DDdebug.h" 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 using DDI::Division; 00015 00016 void DD_NDC(const DDName & n) { 00017 std::vector<DDName> & ns = DIVNAMES::instance()[n.name()]; 00018 typedef std::vector<DDName>::iterator IT; 00019 bool alreadyIn(false); 00020 for(IT p = ns.begin(); p != ns.end() ; ++p) { 00021 if ( p->ns() == n.ns()) { 00022 alreadyIn = true; 00023 break; 00024 } 00025 } 00026 if (!alreadyIn) { 00027 ns.push_back(n); 00028 } 00029 } 00030 00031 std::ostream & 00032 operator<<(std::ostream & os, const DDDivision & div) 00033 { 00034 DDBase<DDName,Division*>::def_type defined(div.isDefined()); 00035 if (defined.first) { 00036 os << *(defined.first) << " "; 00037 if (defined.second) { 00038 div.rep().stream(os); 00039 } 00040 else { 00041 os << "* division not defined * "; 00042 } 00043 } 00044 else { 00045 os << "* division not declared * "; 00046 } 00047 return os; 00048 } 00049 00050 DDDivision::DDDivision() : DDBase<DDName, DDI::Division*>() 00051 { } 00052 00053 DDDivision::DDDivision( const DDName & name) : DDBase<DDName,DDI::Division*>() 00054 { 00055 prep_ = StoreT::instance().create(name); 00056 DD_NC(name); 00057 } 00058 00059 DDDivision::DDDivision(const DDName & name, 00060 const DDLogicalPart & parent, 00061 const DDAxes axis, 00062 const int nReplicas, 00063 const double width, 00064 const double offset ) : DDBase<DDName,DDI::Division*>() 00065 { 00066 DCOUT('C', "create Division name=" << name << " parent=" << parent.name() << " axis=" << DDAxesNames::name(axis) << " nReplicas=" << nReplicas << " width=" << width << " offset=" << offset); 00067 prep_ = StoreT::instance().create(name, new Division(parent, axis, nReplicas, width, offset)); 00068 DD_NDC(name); 00069 } 00070 00071 DDDivision::DDDivision(const DDName & name, 00072 const DDLogicalPart & parent, 00073 const DDAxes axis, 00074 const int nReplicas, 00075 const double offset ) 00076 { 00077 DCOUT('C', "create Division name=" << name << " parent=" << parent.name() << " axis=" << DDAxesNames::name(axis) << " nReplicas=" << nReplicas << " offset=" << offset); 00078 prep_ = StoreT::instance().create(name, new Division(parent, axis, nReplicas, offset)); 00079 DD_NDC(name); 00080 } 00081 00082 DDDivision::DDDivision(const DDName & name, 00083 const DDLogicalPart & parent, 00084 const DDAxes axis, 00085 const double width, 00086 const double offset ) 00087 { 00088 DCOUT('C', "create Division name=" << name << " parent=" << parent.name() << " axis=" << DDAxesNames::name(axis) << " width=" << width << " offset=" << offset); 00089 prep_ = StoreT::instance().create(name, new Division(parent, axis, width, offset)); 00090 DD_NDC(name); 00091 } 00092 00093 const DDAxes DDDivision::axis() const 00094 { 00095 return rep().axis(); 00096 } 00097 00098 const int DDDivision::nReplicas() const 00099 { 00100 return rep().nReplicas(); 00101 } 00102 00103 const double DDDivision::width() const 00104 { 00105 return rep().width(); 00106 } 00107 00108 const double DDDivision::offset() const 00109 { 00110 return rep().offset(); 00111 } 00112 00113 const DDLogicalPart & DDDivision::parent() const 00114 { 00115 return rep().parent(); 00116 } 00117