CMS 3D CMS Logo

DDDividedBox.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // 25.04.04 - M. Case ddd-ize G4ParameterisationBox*
00004 // ********************************************************************
00005 
00006 #include "DDDividedBox.h"
00007 
00008 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00009 #include "DetectorDescription/Core/interface/DDName.h"
00010 #include "DetectorDescription/Core/interface/DDPosPart.h"
00011 #include "DetectorDescription/Core/interface/DDAxes.h"
00012 #include "DetectorDescription/Core/interface/DDSolid.h"
00013 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
00014 #include "DetectorDescription/Core/interface/DDMaterial.h"
00015 #include "DetectorDescription/Core/interface/DDDivision.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 <iomanip>
00023 
00024 //--------------------------------------------------------------------------
00025 DDDividedBoxX::DDDividedBoxX( const DDDivision & div) : 
00026   DDDividedGeometryObject::DDDividedGeometryObject(div)
00027 {
00028   checkParametersValidity();
00029   setType( "DivisionBoxX" );
00030   DDBox mbox = (DDBox)(div_.parent().solid());
00031 
00032   if( divisionType_ == DivWIDTH ) {
00033     compNDiv_ = calculateNDiv( 2*mbox.halfX(), div_.width(), div_.offset() );
00034   } else if( divisionType_ == DivNDIV ) {
00035     compWidth_ = calculateWidth( 2*mbox.halfX(), div_.nReplicas(), div_.offset() );
00036   }
00037   
00038   // somehow here, I want to iterate over the nDivs or nReplicas 
00039   // and make the solid, make the logical part, then position it.
00040   // since DDBox is special, I will not make the solid and logical
00041   // part but once.  We'll see how bad the others go.
00042   // ihatethisihatethisihatethis
00043   //    for (int i = 0; i < compNDiv_; ++i)
00044   //      {
00045   //         DDpos(makeDDLogicalPart(i)  // child logical part
00046   //        , div_.parent()        // parent logical part
00047   //        , i                    // copy number
00048   //        , makeDDTranslation(i) // translation
00049   //        , makeDDRotation(i)    // rotation.  box is default (i.e. identity).
00050   //        );
00051   //      }
00052 
00053   DCOUT_V ('P', " DDDividedBoxX:DDDividedBoxX"  << std::endl);
00054 }
00055 
00056 //------------------------------------------------------------------------
00057 DDDividedBoxX::~DDDividedBoxX()
00058 {
00059 }
00060 
00061 //------------------------------------------------------------------------
00062 double DDDividedBoxX::getMaxParameter() const
00063 {
00064   DDBox msol = (DDBox)(div_.parent().solid());
00065   return 2*msol.halfX();
00066 }
00067 
00068 //------------------------------------------------------------------------
00069 DDRotation DDDividedBoxX::makeDDRotation( const int copyNo ) const
00070 {
00071   return DDRotation();
00072 }
00073 
00074 //------------------------------------------------------------------------
00075 DDTranslation DDDividedBoxX::makeDDTranslation( const int copyNo ) const
00076 {
00077   DDBox msol = (DDBox)(div_.parent().solid());
00078   double mdx = msol.halfX();
00079 
00080   //----- translation 
00081   DDTranslation translation;
00082   double posi = -mdx + div_.offset() + (copyNo+0.5) * compWidth_;
00083   translation.SetX( posi );
00084 
00085   DCOUT_V ('P', " DDDividedBoxX: " << copyNo << "\n Position " << translation << " Axis " << DDAxesNames::name(div_.axis()) << "\n");
00086   return translation;
00087 }
00088 
00089 //------------------------------------------------------------------------
00090 DDLogicalPart DDDividedBoxX::makeDDLogicalPart( const int copyNo ) const
00091 {
00092   // in other cases, this solid will have 1, 2, 3, etc. after it.
00093   DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
00094   DDSolid ddbox(solname);
00095   DDMaterial usemat(div_.parent().material());
00096   DDBox msol = (DDBox) (div_.parent().solid());
00097   DDLogicalPart ddlp(solname);
00098   if (!ddbox.isDefined().second) //This solid has NOT been defined. 
00099     {
00100       double pDx = msol.halfX();
00101       double pDy = compWidth_/2.;
00102       double pDz = msol.halfZ();
00103     
00104       ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
00105       ddlp =  DDLogicalPart(solname, usemat, ddbox);
00106     }
00107   DCOUT_V ('P', " DDDividedBoxX::computeDimensions() lp:\n" << ddlp); 
00108   return ddlp;
00109 }
00110 
00111 //--------------------------------------------------------------------------
00112 DDDividedBoxY::DDDividedBoxY( const DDDivision & div) : 
00113   DDDividedGeometryObject::DDDividedGeometryObject(div)
00114 {
00115   checkParametersValidity();
00116   setType( "DivisionBoxY" );
00117   DDBox mbox = (DDBox)(div_.parent().solid());
00118 
00119   if( divisionType_ == DivWIDTH ) {
00120     compNDiv_ = calculateNDiv( 2*mbox.halfY(), div_.width(), div_.offset() );
00121   } else if( divisionType_ == DivNDIV ) {
00122     compWidth_ = calculateWidth( 2*mbox.halfY(), div_.nReplicas(), div_.offset() );
00123   } 
00124 
00125   
00126   // somehow here, I want to iterate over the nDivs or nReplicas 
00127   // and make the solid, make the logical part, then position it.
00128   // since DDBox is special, I will not make the solid and logical
00129   // part but once.  We'll see how bad the others go.
00130   // ihatethisihatethisihatethis
00131   //    for (int i = 0; i < compNDiv_; ++i)
00132   //      {
00133   //         DDpos(makeDDLogicalPart(i)  // child logical part
00134   //        , div_.parent()        // parent logical part
00135   //        , i                    // copy number
00136   //        , makeDDTranslation(i) // translation
00137   //        , makeDDRotation(i)    // rotation.  box is default (i.e. identity).
00138   //        );
00139   //      }
00140 
00141   DCOUT_V ('P', " DDDividedBoxY:DDDividedBoxY"  << std::endl);
00142 }
00143 
00144 //------------------------------------------------------------------------
00145 DDDividedBoxY::~DDDividedBoxY()
00146 {
00147 }
00148 
00149 //------------------------------------------------------------------------
00150 double DDDividedBoxY::getMaxParameter() const
00151 {
00152   DDBox msol = (DDBox)(div_.parent().solid());
00153   return 2*msol.halfY();
00154 }
00155 
00156 //------------------------------------------------------------------------
00157 DDRotation DDDividedBoxY::makeDDRotation( const int copyNo ) const
00158 {
00159   return DDRotation();
00160 }
00161 
00162 //------------------------------------------------------------------------
00163 DDTranslation DDDividedBoxY::makeDDTranslation( const int copyNo ) const
00164 {
00165   DDBox msol = (DDBox)(div_.parent().solid());
00166   double mdx = msol.halfY();
00167 
00168   //----- translation 
00169   DDTranslation translation;
00170 
00171   double posi = -mdx + div_.offset() + (copyNo+0.5) * compWidth_;
00172   translation.SetY( posi );
00173 
00174   DCOUT_V ('P', " DDDividedBoxY: " << copyNo << "\n Position " << translation << " Axis " << DDAxesNames::name(div_.axis()) << "\n");
00175   return translation;
00176 }
00177 
00178 //------------------------------------------------------------------------
00179 DDLogicalPart DDDividedBoxY::makeDDLogicalPart( const int copyNo ) const
00180 {
00181   // in other cases, this solid will have 1, 2, 3, etc. after it.
00182   DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
00183   DDSolid ddbox(solname);
00184   DDMaterial usemat(div_.parent().material());
00185   DDBox msol = (DDBox) (div_.parent().solid());
00186   DDLogicalPart ddlp(solname);
00187   if (!ddbox.isDefined().second) //This solid has NOT been defined. 
00188     {
00189       double pDx = msol.halfX();
00190       double pDy = compWidth_/2.;
00191       double pDz = msol.halfZ();
00192       ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
00193       ddlp =  DDLogicalPart(solname, usemat, ddbox);
00194     }
00195   DCOUT_V ('P', " DDDividedBoxY::computeDimensions() lp:\n" << ddlp); 
00196   return ddlp;
00197 }
00198 
00199 //--------------------------------------------------------------------------
00200 DDDividedBoxZ::DDDividedBoxZ( const DDDivision & div) : 
00201   DDDividedGeometryObject::DDDividedGeometryObject(div)
00202 {
00203   checkParametersValidity();
00204   setType( "DivisionBoxZ" );
00205   DDBox mbox = (DDBox)(div_.parent().solid());
00206 
00207   if( divisionType_ == DivWIDTH ) {
00208     compNDiv_ = calculateNDiv( 2*mbox.halfZ(), div_.width(), div_.offset() );
00209   } else if( divisionType_ == DivNDIV ) {
00210     compWidth_ = calculateWidth( 2*mbox.halfY(), div_.nReplicas(), div_.offset() );
00211   }
00212   
00213   // somehow here, I want to iterate over the nDivs or nReplicas 
00214   // and make the solid, make the logical part, then position it.
00215   // since DDBox is special, I will not make the solid and logical
00216   // part but once.  We'll see how bad the others go.
00217   // ihatethisihatethisihatethis
00218   //    for (int i = 0; i < compNDiv_; ++i)
00219   //      {
00220   //         DDpos(makeDDLogicalPart(i)  // child logical part
00221   //        , div_.parent()        // parent logical part
00222   //        , i                    // copy number
00223   //        , makeDDTranslation(i) // translation
00224   //        , makeDDRotation(i)    // rotation.  box is default (i.e. identity).
00225   //        );
00226   //      }
00227 
00228   DCOUT_V ('P', " DDDividedBoxZ:DDDividedBoxZ"  << std::endl);
00229 }
00230 
00231 //------------------------------------------------------------------------
00232 DDDividedBoxZ::~DDDividedBoxZ()
00233 {
00234 }
00235 
00236 //------------------------------------------------------------------------
00237 double DDDividedBoxZ::getMaxParameter() const
00238 {
00239   DDBox msol = (DDBox)(div_.parent().solid());
00240   return 2*msol.halfZ();
00241 }
00242 
00243 //------------------------------------------------------------------------
00244 DDRotation DDDividedBoxZ::makeDDRotation( const int copyNo ) const
00245 {
00246   return DDRotation();
00247 }
00248 
00249 //------------------------------------------------------------------------
00250 DDTranslation DDDividedBoxZ::makeDDTranslation( const int copyNo ) const
00251 {
00252   DDBox msol = (DDBox)(div_.parent().solid());
00253   double mdx = msol.halfZ();
00254 
00255   //----- translation 
00256   DDTranslation translation;
00257 
00258   double posi = -mdx + div_.offset() + (copyNo+0.5) * compWidth_;
00259   translation.SetZ( posi );
00260 
00261   DCOUT_V ('P', " DDDividedBoxZ: " << copyNo << "\n Position " << translation << " Axis " << DDAxesNames::name(div_.axis()) << "\n");
00262   return translation;
00263 }
00264 
00265 //------------------------------------------------------------------------
00266 DDLogicalPart DDDividedBoxZ::makeDDLogicalPart( const int copyNo ) const
00267 {
00268   // in other cases, this solid will have 1, 2, 3, etc. after it.
00269   DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
00270   DDSolid ddbox(solname);
00271   DDMaterial usemat(div_.parent().material());
00272   DDBox msol = (DDBox) (div_.parent().solid());
00273   DDLogicalPart ddlp(solname);
00274   if (!ddbox.isDefined().second) //This solid has NOT been defined. 
00275     {
00276       double pDx = msol.halfX();
00277       double pDy = msol.halfY();
00278       double pDz = compWidth_/2.;
00279       ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
00280       ddlp =  DDLogicalPart(solname, usemat, ddbox);
00281     }
00282   DCOUT_V ('P', " DDDividedBoxZ::computeDimensions() lp:\n" << ddlp); 
00283   return ddlp;
00284 }
00285 
00286 
00287 

Generated on Tue Jun 9 17:32:23 2009 for CMSSW by  doxygen 1.5.4