File indexing completed on 2024-04-06 12:05:31
0001 #include "DetectorDescription/Parser/src/DDDividedBox.h"
0002 #include "DetectorDescription/Core/interface/DDAxes.h"
0003 #include "DetectorDescription/Core/interface/DDDivision.h"
0004 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0005 #include "DetectorDescription/Core/interface/DDMaterial.h"
0006 #include "DetectorDescription/Core/interface/DDName.h"
0007 #include "DetectorDescription/Core/interface/DDSolid.h"
0008 #include "DetectorDescription/Core/interface/DDTransform.h"
0009 #include "DetectorDescription/Parser/src/DDDividedGeometryObject.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011
0012 #include <ostream>
0013 #include <string>
0014 #include <utility>
0015
0016 class DDCompactView;
0017
0018 DDDividedBoxX::DDDividedBoxX(const DDDivision& div, DDCompactView* cpv)
0019 : DDDividedGeometryObject::DDDividedGeometryObject(div, cpv) {
0020 checkParametersValidity();
0021 setType("DivisionBoxX");
0022 DDBox mbox = (DDBox)(div_.parent().solid());
0023
0024 if (divisionType_ == DivWIDTH) {
0025 compNDiv_ = calculateNDiv(2 * mbox.halfX(), div_.width(), div_.offset());
0026 } else if (divisionType_ == DivNDIV) {
0027 compWidth_ = calculateWidth(2 * mbox.halfX(), div_.nReplicas(), div_.offset());
0028 }
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 }
0045
0046 double DDDividedBoxX::getMaxParameter(void) const {
0047 DDBox msol = (DDBox)(div_.parent().solid());
0048 return 2 * msol.halfX();
0049 }
0050
0051 DDRotation DDDividedBoxX::makeDDRotation(const int copyNo) const { return DDRotation(); }
0052
0053 DDTranslation DDDividedBoxX::makeDDTranslation(const int copyNo) const {
0054 DDBox msol = (DDBox)(div_.parent().solid());
0055 double mdx = msol.halfX();
0056
0057
0058 DDTranslation translation;
0059 double posi = -mdx + div_.offset() + (copyNo + 0.5) * compWidth_;
0060 translation.SetX(posi);
0061
0062 return translation;
0063 }
0064
0065 DDLogicalPart DDDividedBoxX::makeDDLogicalPart(const int copyNo) const {
0066
0067 DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
0068 DDSolid ddbox(solname);
0069 DDMaterial usemat(div_.parent().material());
0070 DDBox msol = (DDBox)(div_.parent().solid());
0071 DDLogicalPart ddlp(solname);
0072 if (!ddbox.isDefined().second)
0073 {
0074 double pDx = msol.halfX();
0075 double pDy = compWidth_ / 2.;
0076 double pDz = msol.halfZ();
0077
0078 ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
0079 ddlp = DDLogicalPart(solname, usemat, ddbox);
0080 }
0081 return ddlp;
0082 }
0083
0084 DDDividedBoxY::DDDividedBoxY(const DDDivision& div, DDCompactView* cpv)
0085 : DDDividedGeometryObject::DDDividedGeometryObject(div, cpv) {
0086 checkParametersValidity();
0087 setType("DivisionBoxY");
0088 DDBox mbox = (DDBox)(div_.parent().solid());
0089
0090 if (divisionType_ == DivWIDTH) {
0091 compNDiv_ = calculateNDiv(2 * mbox.halfY(), div_.width(), div_.offset());
0092 } else if (divisionType_ == DivNDIV) {
0093 compWidth_ = calculateWidth(2 * mbox.halfY(), div_.nReplicas(), div_.offset());
0094 }
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 }
0111
0112 double DDDividedBoxY::getMaxParameter(void) const {
0113 DDBox msol = (DDBox)(div_.parent().solid());
0114 return 2 * msol.halfY();
0115 }
0116
0117 DDRotation DDDividedBoxY::makeDDRotation(const int copyNo) const { return DDRotation(); }
0118
0119 DDTranslation DDDividedBoxY::makeDDTranslation(const int copyNo) const {
0120 DDBox msol = (DDBox)(div_.parent().solid());
0121 double mdx = msol.halfY();
0122
0123
0124 DDTranslation translation;
0125
0126 double posi = -mdx + div_.offset() + (copyNo + 0.5) * compWidth_;
0127 translation.SetY(posi);
0128
0129 return translation;
0130 }
0131
0132 DDLogicalPart DDDividedBoxY::makeDDLogicalPart(const int copyNo) const {
0133
0134 DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
0135 DDSolid ddbox(solname);
0136 DDMaterial usemat(div_.parent().material());
0137 DDBox msol = (DDBox)(div_.parent().solid());
0138 DDLogicalPart ddlp(solname);
0139 if (!ddbox.isDefined().second)
0140 {
0141 double pDx = msol.halfX();
0142 double pDy = compWidth_ / 2.;
0143 double pDz = msol.halfZ();
0144 ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
0145 ddlp = DDLogicalPart(solname, usemat, ddbox);
0146 }
0147 return ddlp;
0148 }
0149
0150 DDDividedBoxZ::DDDividedBoxZ(const DDDivision& div, DDCompactView* cpv)
0151 : DDDividedGeometryObject::DDDividedGeometryObject(div, cpv) {
0152 checkParametersValidity();
0153 setType("DivisionBoxZ");
0154 DDBox mbox = (DDBox)(div_.parent().solid());
0155
0156 if (divisionType_ == DivWIDTH) {
0157 compNDiv_ = calculateNDiv(2 * mbox.halfZ(), div_.width(), div_.offset());
0158 } else if (divisionType_ == DivNDIV) {
0159 compWidth_ = calculateWidth(2 * mbox.halfY(), div_.nReplicas(), div_.offset());
0160 }
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176 }
0177
0178 double DDDividedBoxZ::getMaxParameter(void) const {
0179 DDBox msol = (DDBox)(div_.parent().solid());
0180 return 2 * msol.halfZ();
0181 }
0182
0183 DDRotation DDDividedBoxZ::makeDDRotation(const int copyNo) const { return DDRotation(); }
0184
0185 DDTranslation DDDividedBoxZ::makeDDTranslation(const int copyNo) const {
0186 DDBox msol = (DDBox)(div_.parent().solid());
0187 double mdx = msol.halfZ();
0188
0189
0190 DDTranslation translation;
0191
0192 double posi = -mdx + div_.offset() + (copyNo + 0.5) * compWidth_;
0193 translation.SetZ(posi);
0194
0195 return translation;
0196 }
0197
0198 DDLogicalPart DDDividedBoxZ::makeDDLogicalPart(const int copyNo) const {
0199
0200 DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
0201 DDSolid ddbox(solname);
0202 DDMaterial usemat(div_.parent().material());
0203 DDBox msol = (DDBox)(div_.parent().solid());
0204 DDLogicalPart ddlp(solname);
0205 if (!ddbox.isDefined().second)
0206 {
0207 double pDx = msol.halfX();
0208 double pDy = msol.halfY();
0209 double pDz = compWidth_ / 2.;
0210 ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
0211 ddlp = DDLogicalPart(solname, usemat, ddbox);
0212 }
0213 return ddlp;
0214 }