00001
00002
00003
00004
00005
00006 #include "DetectorDescription/Parser/src/DDDividedBox.h"
00007
00008 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00009 #include "DetectorDescription/Core/interface/DDName.h"
00010 #include "DetectorDescription/Core/interface/DDAxes.h"
00011 #include "DetectorDescription/Core/interface/DDSolid.h"
00012 #include "DetectorDescription/Core/interface/DDMaterial.h"
00013 #include "DetectorDescription/Core/interface/DDDivision.h"
00014
00015 #include "DetectorDescription/Base/interface/DDdebug.h"
00016
00017 #include <iomanip>
00018
00019 DDDividedBoxX::DDDividedBoxX( const DDDivision& div, DDCompactView* cpv)
00020 : DDDividedGeometryObject::DDDividedGeometryObject( div, cpv )
00021 {
00022 checkParametersValidity();
00023 setType( "DivisionBoxX" );
00024 DDBox mbox = (DDBox)(div_.parent().solid());
00025
00026 if( divisionType_ == DivWIDTH ) {
00027 compNDiv_ = calculateNDiv( 2*mbox.halfX(), div_.width(), div_.offset() );
00028 } else if( divisionType_ == DivNDIV ) {
00029 compWidth_ = calculateWidth( 2*mbox.halfX(), div_.nReplicas(), div_.offset() );
00030 }
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 DCOUT_V ('P', " DDDividedBoxX:DDDividedBoxX" << std::endl);
00048 }
00049
00050 DDDividedBoxX::~DDDividedBoxX( void )
00051 {}
00052
00053 double
00054 DDDividedBoxX::getMaxParameter( void ) const
00055 {
00056 DDBox msol = (DDBox)(div_.parent().solid());
00057 return 2*msol.halfX();
00058 }
00059
00060 DDRotation
00061 DDDividedBoxX::makeDDRotation( const int copyNo ) const
00062 {
00063 return DDRotation();
00064 }
00065
00066 DDTranslation
00067 DDDividedBoxX::makeDDTranslation( const int copyNo ) const
00068 {
00069 DDBox msol = (DDBox)(div_.parent().solid());
00070 double mdx = msol.halfX();
00071
00072
00073 DDTranslation translation;
00074 double posi = -mdx + div_.offset() + (copyNo+0.5) * compWidth_;
00075 translation.SetX( posi );
00076
00077 DCOUT_V ('P', " DDDividedBoxX: " << copyNo << "\n Position " << translation << " Axis " << DDAxesNames::name(div_.axis()) << "\n");
00078 return translation;
00079 }
00080
00081 DDLogicalPart
00082 DDDividedBoxX::makeDDLogicalPart( const int copyNo ) const
00083 {
00084
00085 DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
00086 DDSolid ddbox(solname);
00087 DDMaterial usemat(div_.parent().material());
00088 DDBox msol = (DDBox) (div_.parent().solid());
00089 DDLogicalPart ddlp(solname);
00090 if (!ddbox.isDefined().second)
00091 {
00092 double pDx = msol.halfX();
00093 double pDy = compWidth_/2.;
00094 double pDz = msol.halfZ();
00095
00096 ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
00097 ddlp = DDLogicalPart(solname, usemat, ddbox);
00098 }
00099 DCOUT_V ('P', " DDDividedBoxX::computeDimensions() lp:\n" << ddlp);
00100 return ddlp;
00101 }
00102
00103 DDDividedBoxY::DDDividedBoxY( const DDDivision& div, DDCompactView* cpv)
00104 : DDDividedGeometryObject::DDDividedGeometryObject( div, cpv )
00105 {
00106 checkParametersValidity();
00107 setType( "DivisionBoxY" );
00108 DDBox mbox = (DDBox)(div_.parent().solid());
00109
00110 if( divisionType_ == DivWIDTH ) {
00111 compNDiv_ = calculateNDiv( 2*mbox.halfY(), div_.width(), div_.offset() );
00112 } else if( divisionType_ == DivNDIV ) {
00113 compWidth_ = calculateWidth( 2*mbox.halfY(), div_.nReplicas(), div_.offset() );
00114 }
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 DCOUT_V ('P', " DDDividedBoxY:DDDividedBoxY" << std::endl);
00133 }
00134
00135 DDDividedBoxY::~DDDividedBoxY( void )
00136 {}
00137
00138 double
00139 DDDividedBoxY::getMaxParameter( void ) const
00140 {
00141 DDBox msol = (DDBox)(div_.parent().solid());
00142 return 2*msol.halfY();
00143 }
00144
00145 DDRotation
00146 DDDividedBoxY::makeDDRotation( const int copyNo ) const
00147 {
00148 return DDRotation();
00149 }
00150
00151 DDTranslation
00152 DDDividedBoxY::makeDDTranslation( const int copyNo ) const
00153 {
00154 DDBox msol = (DDBox)(div_.parent().solid());
00155 double mdx = msol.halfY();
00156
00157
00158 DDTranslation translation;
00159
00160 double posi = -mdx + div_.offset() + (copyNo+0.5) * compWidth_;
00161 translation.SetY( posi );
00162
00163 DCOUT_V ('P', " DDDividedBoxY: " << copyNo << "\n Position " << translation << " Axis " << DDAxesNames::name(div_.axis()) << "\n");
00164 return translation;
00165 }
00166
00167 DDLogicalPart
00168 DDDividedBoxY::makeDDLogicalPart( const int copyNo ) const
00169 {
00170
00171 DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
00172 DDSolid ddbox(solname);
00173 DDMaterial usemat(div_.parent().material());
00174 DDBox msol = (DDBox) (div_.parent().solid());
00175 DDLogicalPart ddlp(solname);
00176 if (!ddbox.isDefined().second)
00177 {
00178 double pDx = msol.halfX();
00179 double pDy = compWidth_/2.;
00180 double pDz = msol.halfZ();
00181 ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
00182 ddlp = DDLogicalPart(solname, usemat, ddbox);
00183 }
00184 DCOUT_V ('P', " DDDividedBoxY::computeDimensions() lp:\n" << ddlp);
00185 return ddlp;
00186 }
00187
00188 DDDividedBoxZ::DDDividedBoxZ( const DDDivision& div, DDCompactView* cpv)
00189 : DDDividedGeometryObject::DDDividedGeometryObject( div, cpv )
00190 {
00191 checkParametersValidity();
00192 setType( "DivisionBoxZ" );
00193 DDBox mbox = (DDBox)(div_.parent().solid());
00194
00195 if( divisionType_ == DivWIDTH ) {
00196 compNDiv_ = calculateNDiv( 2*mbox.halfZ(), div_.width(), div_.offset() );
00197 } else if( divisionType_ == DivNDIV ) {
00198 compWidth_ = calculateWidth( 2*mbox.halfY(), div_.nReplicas(), div_.offset() );
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 DCOUT_V ('P', " DDDividedBoxZ:DDDividedBoxZ" << std::endl);
00217 }
00218
00219 DDDividedBoxZ::~DDDividedBoxZ( void )
00220 {}
00221
00222 double
00223 DDDividedBoxZ::getMaxParameter( void ) const
00224 {
00225 DDBox msol = (DDBox)(div_.parent().solid());
00226 return 2*msol.halfZ();
00227 }
00228
00229 DDRotation
00230 DDDividedBoxZ::makeDDRotation( const int copyNo ) const
00231 {
00232 return DDRotation();
00233 }
00234
00235 DDTranslation
00236 DDDividedBoxZ::makeDDTranslation( const int copyNo ) const
00237 {
00238 DDBox msol = (DDBox)(div_.parent().solid());
00239 double mdx = msol.halfZ();
00240
00241
00242 DDTranslation translation;
00243
00244 double posi = -mdx + div_.offset() + (copyNo+0.5) * compWidth_;
00245 translation.SetZ( posi );
00246
00247 DCOUT_V ('P', " DDDividedBoxZ: " << copyNo << "\n Position " << translation << " Axis " << DDAxesNames::name(div_.axis()) << "\n");
00248 return translation;
00249 }
00250
00251 DDLogicalPart
00252 DDDividedBoxZ::makeDDLogicalPart( const int copyNo ) const
00253 {
00254
00255 DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
00256 DDSolid ddbox(solname);
00257 DDMaterial usemat(div_.parent().material());
00258 DDBox msol = (DDBox) (div_.parent().solid());
00259 DDLogicalPart ddlp(solname);
00260 if (!ddbox.isDefined().second)
00261 {
00262 double pDx = msol.halfX();
00263 double pDy = msol.halfY();
00264 double pDz = compWidth_/2.;
00265 ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
00266 ddlp = DDLogicalPart(solname, usemat, ddbox);
00267 }
00268 DCOUT_V ('P', " DDDividedBoxZ::computeDimensions() lp:\n" << ddlp);
00269 return ddlp;
00270 }
00271
00272
00273