00001
00002
00003
00004
00005
00006 #include "DDDividedCons.h"
00007 #include "DDXMLElement.h"
00008
00009 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00010 #include "DetectorDescription/Core/interface/DDName.h"
00011 #include "DetectorDescription/Core/interface/DDPosPart.h"
00012 #include "DetectorDescription/Core/interface/DDAxes.h"
00013 #include "DetectorDescription/Core/interface/DDSolid.h"
00014 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
00015 #include "DetectorDescription/Core/interface/DDMaterial.h"
00016
00017 #include "DetectorDescription/Base/interface/DDdebug.h"
00018 #include "DetectorDescription/Base/interface/DDException.h"
00019 #include "DetectorDescription/Base/interface/DDRotationMatrix.h"
00020 #include "DetectorDescription/Base/interface/DDTranslation.h"
00021
00022 #include "CLHEP/Units/SystemOfUnits.h"
00023
00024
00025 DDDividedConsRho::
00026 DDDividedConsRho( const DDDivision & div )
00027 : DDDividedGeometryObject::DDDividedGeometryObject (div)
00028 {
00029 checkParametersValidity();
00030 setType( "DivisionConsRho" );
00031 DDCons msol = (DDCons)(div_.parent().solid());
00032
00033 if( msol.rInPlusZ() == 0. )
00034 {
00035 std::cout << "WARNING - DDDividedConsRho, rOutMinusZ = 0. "
00036 << std::endl
00037 << " Width is calculated as that of rOutMinusZ !"
00038 << std::endl;
00039 }
00040
00041 if( divisionType_ == DivWIDTH )
00042 {
00043 compNDiv_ = calculateNDiv( msol.rOutMinusZ()
00044 - msol.rInMinusZ(), div_.width(), div_.offset() );
00045 }
00046 else if( divisionType_ == DivNDIV )
00047 {
00048 DDCons msol = (DDCons)(div_.parent().solid());
00049 compWidth_ = calculateWidth( msol.rOutMinusZ() - msol.rInMinusZ()
00050 , div_.nReplicas()
00051 , div_.offset() );
00052 }
00053
00054 DCOUT_V ('P', " DDDividedConsRho - no divisions " << compNDiv_ << " = " << div_.nReplicas() << "\n Offset " << div_.offset() << "\n Width " << compWidth_ << " = " << div_.width() << "\n DivType " << divisionType_);
00055
00056 }
00057
00058
00059 DDDividedConsRho::~DDDividedConsRho()
00060 {
00061 }
00062
00063
00064 double DDDividedConsRho::getMaxParameter() const
00065 {
00066 DDCons msol = (DDCons)(div_.parent().solid());
00067 return msol.rOutMinusZ() - msol.rInMinusZ();
00068
00069 }
00070
00071
00072 DDRotation DDDividedConsRho::makeDDRotation(const int copyNo) const
00073 {
00074 DDRotation myddrot;
00075 DCOUT_V ('P', "DDDividedConsRho::makeDDRotation : " << myddrot);
00076 return myddrot;
00077 }
00078
00079
00080 DDTranslation DDDividedConsRho::makeDDTranslation( const int copyNo ) const
00081 {
00082
00083 DDTranslation translation;
00084 DCOUT_V ('P', " DDDividedConsRho " << "\n\t Position: " << translation << " - Width: " << compWidth_ << " - Axis " << DDAxesNames::name(div_.axis()));
00085 return translation;
00086 }
00087
00088
00089 DDLogicalPart DDDividedConsRho::makeDDLogicalPart( const int copyNo ) const
00090 {
00091 DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
00092 + DDXMLElement::itostr(copyNo)
00093 , div_.parent().ddname().ns());
00094 DDSolid ddcons(solname);
00095 DDMaterial usemat(div_.parent().material());
00096 DDCons msol = (DDCons)(div_.parent().solid());
00097
00098 double pRMin1 = msol.rInMinusZ() + div_.offset() + compWidth_ * copyNo;
00099 double pRMax1 = msol.rInMinusZ() + div_.offset() + compWidth_ * (copyNo+1);
00100
00101
00102
00103
00104
00105 double compWidth_Plus = calculateWidth( msol.rOutPlusZ()
00106 - msol.rInPlusZ(), compNDiv_, div_.offset() );
00107 double pRMin2 = msol.rInPlusZ()
00108 + div_.offset() + compWidth_Plus * copyNo;
00109 double pRMax2 = msol.rInPlusZ()
00110 + div_.offset() + compWidth_Plus * (copyNo+1);
00111 double pDz = msol.zhalf();
00112
00113 double pSPhi = msol.phiFrom();
00114 double pDPhi = msol.deltaPhi();
00115
00116 ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1
00117 , pRMin2, pRMax2, pSPhi, pDPhi);
00118
00119 DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
00120 DCOUT_V ('P', " DDDividedConsRho::makeDDLogicalPart() lp:" << ddlp);
00121 return ddlp;
00122
00123 }
00124
00125
00126
00127 DDDividedConsPhi::DDDividedConsPhi( const DDDivision & div )
00128 : DDDividedGeometryObject::DDDividedGeometryObject (div)
00129 {
00130 checkParametersValidity();
00131 setType( "DivisionConsPhi" );
00132 DDCons msol = (DDCons)(div_.parent().solid());
00133
00134 if( divisionType_ == DivWIDTH )
00135 {
00136 DDCons msol = (DDCons)(div_.parent().solid());
00137
00138 if( msol.deltaPhi() == 360.*deg ) {
00139 compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
00140 }else {
00141 compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), div_.offset() );
00142 }
00143 }
00144 else if( divisionType_ == DivNDIV )
00145 {
00146 DDCons msol = (DDCons)(div_.parent().solid());
00147 if( msol.deltaPhi() == 360.*deg ) {
00148 compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
00149 }else {
00150 compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), div_.offset() );
00151 }
00152
00153 }
00154
00155 DCOUT_V ('P', " DDDividedConsPhi - no divisions " << compNDiv_ << " = " << div_.nReplicas() << "\n Offset " << div_.offset() << "\n Width " << compWidth_ << " = " << div_.width() << "\n DivType " << divisionType_);
00156
00157 }
00158
00159
00160 DDDividedConsPhi::~DDDividedConsPhi()
00161 {
00162 }
00163
00164
00165 double DDDividedConsPhi::getMaxParameter() const
00166 {
00167 DDCons msol = (DDCons)(div_.parent().solid());
00168 return msol.deltaPhi();
00169 }
00170
00171
00172 DDRotation DDDividedConsPhi::makeDDRotation(const int copyNo) const
00173 {
00174 DDRotation myddrot;
00175 double posi = ( copyNo - 1 ) * compWidth_;
00176 DDRotationMatrix* rotMat = changeRotMatrix( posi );
00177
00178
00179 DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT" + DDXMLElement::itostr(copyNo)
00180 , div_.parent().ddname().ns());
00181 myddrot = DDrot(ddrotname, rotMat);
00182
00183 DCOUT_V ('P', "DDDividedConsPhi::makeDDRotation : " << myddrot);
00184 return myddrot;
00185 }
00186
00187
00188 DDTranslation DDDividedConsPhi::makeDDTranslation( const int copyNo ) const
00189 {
00190
00191 DDTranslation translation;
00192 DCOUT_V ('P', " DDDividedConsPhi " << "\n\t Position: " << translation << " - Width: " << compWidth_ << " - Axis " << DDAxesNames::name(div_.axis()));
00193 return translation;
00194 }
00195
00196
00197 DDLogicalPart DDDividedConsPhi::makeDDLogicalPart( const int copyNo ) const
00198 {
00199 DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
00200 , div_.parent().ddname().ns());
00201 DDSolid ddcons(solname);
00202 DDMaterial usemat(div_.parent().material());
00203 DDCons msol = (DDCons)(div_.parent().solid());
00204
00205 if (!ddcons.isDefined().second)
00206 {
00207 double pRMin1 = msol.rInMinusZ();
00208 double pRMax1 = msol.rOutMinusZ();
00209 double pRMin2 = msol.rInPlusZ();
00210 double pRMax2 = msol.rOutPlusZ();
00211 double pDz = msol.zhalf();
00212
00213
00214 double pSPhi = div_.offset() + msol.phiFrom();
00215 double pDPhi = compWidth_;
00216 ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1
00217 , pRMin2, pRMax2, pSPhi, pDPhi);
00218 }
00219
00220 DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
00221 DCOUT_V ('P', " DDDividedConsPhi::makeDDLogicalPart() lp:" << ddlp);
00222 return ddlp;
00223
00224 }
00225
00226
00227
00228 DDDividedConsZ::DDDividedConsZ( const DDDivision & div )
00229 : DDDividedGeometryObject::DDDividedGeometryObject (div)
00230 {
00231 checkParametersValidity();
00232
00233 DDCons msol = (DDCons)(div_.parent().solid());
00234 setType( "DivisionConsZ" );
00235
00236 if( divisionType_ == DivWIDTH )
00237 {
00238 DDCons msol = (DDCons)(div_.parent().solid());
00239 compNDiv_ = calculateNDiv( 2*msol.zhalf()
00240 , div_.width(), div_.offset() );
00241 }
00242 else if( divisionType_ == DivNDIV )
00243 {
00244 DDCons msol = (DDCons)(div_.parent().solid());
00245 compWidth_ = calculateWidth( 2*msol.zhalf()
00246 , div_.nReplicas(), div_.offset() );
00247 }
00248
00249 DCOUT_V ('P', " DDDividedConsZ - no divisions " << compNDiv_ << " = " << div_.nReplicas() << "\n Offset " << div_.offset() << "\n Width " << compWidth_ << " = " << div_.width() << "\n DivType " << divisionType_);
00250
00251 }
00252
00253
00254 DDDividedConsZ::~DDDividedConsZ()
00255 {
00256 }
00257
00258
00259 double DDDividedConsZ::getMaxParameter() const
00260 {
00261 DDCons msol = (DDCons)(div_.parent().solid());
00262 return 2*msol.zhalf();
00263 }
00264
00265
00266 DDRotation DDDividedConsZ::makeDDRotation(const int copyNo) const
00267 {
00268 DDRotation myddrot;
00269 DCOUT_V ('P', "DDDividedConsZ::makeDDRotation : " << myddrot);
00270 return myddrot;
00271 }
00272
00273
00274 DDTranslation DDDividedConsZ::makeDDTranslation( const int copyNo ) const
00275 {
00276
00277 DDTranslation translation;
00278
00279 DDCons motherCons = (DDCons)(div_.parent().solid());
00280 double posi = - motherCons.zhalf() + div_.offset()
00281 + compWidth_/2 + copyNo*compWidth_;
00282 translation.SetZ(posi);
00283
00284 DCOUT_V ('P', " DDDividedConsZ " << "\n\t Position: " << translation << " - Width: " << compWidth_ << " - Axis " << DDAxesNames::name(div_.axis()));
00285 return translation;
00286 }
00287
00288
00289 DDLogicalPart DDDividedConsZ::makeDDLogicalPart( const int copyNo ) const
00290 {
00291 DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + DDXMLElement::itostr(copyNo)
00292 , div_.parent().ddname().ns());
00293 DDSolid ddcons(solname);
00294 DDMaterial usemat(div_.parent().material());
00295 DDCons msol = (DDCons)(div_.parent().solid());
00296
00297 double mHalfLength = msol.zhalf();
00298 double aRInner = (msol.rInPlusZ()
00299 - msol.rInMinusZ()) / (2*mHalfLength);
00300 double bRInner = (msol.rInPlusZ()
00301 + msol.rInMinusZ()) / 2;
00302 double aROuter = (msol.rOutPlusZ()
00303 - msol.rOutMinusZ()) / (2*mHalfLength);
00304 double bROuter = (msol.rOutPlusZ()
00305 + msol.rOutMinusZ()) / 2;
00306 double xMinusZ = -mHalfLength + div_.offset() + compWidth_*copyNo;
00307 double xPlusZ = -mHalfLength + div_.offset() + compWidth_*(copyNo+1);
00308
00309 double pDz = compWidth_ / 2.;
00310 double pSPhi = msol.phiFrom();
00311 double pDPhi = msol.deltaPhi();
00312
00313 ddcons = DDSolidFactory::cons(DDName(solname)
00314 , pDz
00315 , aRInner * xMinusZ + bRInner
00316 , aROuter * xMinusZ + bROuter
00317 , aRInner * xPlusZ + bRInner
00318 , aROuter * xPlusZ + bROuter
00319 , pSPhi
00320 , pDPhi
00321 );
00322
00323 DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
00324 DCOUT_V ('P', " DDDividedConsZ::makeDDLogicalPart() lp:" << ddlp);
00325 return ddlp;
00326
00327 }
00328
00329