CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DetectorDescription/Parser/src/DDDividedBox.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // 25.04.04 - M. Case ddd-ize G4ParameterisationBox*
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   // somehow here, I want to iterate over the nDivs or nReplicas 
00033   // and make the solid, make the logical part, then position it.
00034   // since DDBox is special, I will not make the solid and logical
00035   // part but once.  We'll see how bad the others go.
00036   // ihatethisihatethisihatethis
00037   //    for (int i = 0; i < compNDiv_; ++i)
00038   //      {
00039   //         DDpos(makeDDLogicalPart(i)  // child logical part
00040   //        , div_.parent()        // parent logical part
00041   //        , i                    // copy number
00042   //        , makeDDTranslation(i) // translation
00043   //        , makeDDRotation(i)    // rotation.  box is default (i.e. identity).
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   //----- translation 
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   // in other cases, this solid will have 1, 2, 3, etc. after it.
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) //This solid has NOT been defined. 
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   // somehow here, I want to iterate over the nDivs or nReplicas 
00118   // and make the solid, make the logical part, then position it.
00119   // since DDBox is special, I will not make the solid and logical
00120   // part but once.  We'll see how bad the others go.
00121   // ihatethisihatethisihatethis
00122   //    for (int i = 0; i < compNDiv_; ++i)
00123   //      {
00124   //         DDpos(makeDDLogicalPart(i)  // child logical part
00125   //        , div_.parent()        // parent logical part
00126   //        , i                    // copy number
00127   //        , makeDDTranslation(i) // translation
00128   //        , makeDDRotation(i)    // rotation.  box is default (i.e. identity).
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   //----- translation 
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   // in other cases, this solid will have 1, 2, 3, etc. after it.
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) //This solid has NOT been defined. 
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   // somehow here, I want to iterate over the nDivs or nReplicas 
00202   // and make the solid, make the logical part, then position it.
00203   // since DDBox is special, I will not make the solid and logical
00204   // part but once.  We'll see how bad the others go.
00205   // ihatethisihatethisihatethis
00206   //    for (int i = 0; i < compNDiv_; ++i)
00207   //      {
00208   //         DDpos(makeDDLogicalPart(i)  // child logical part
00209   //        , div_.parent()        // parent logical part
00210   //        , i                    // copy number
00211   //        , makeDDTranslation(i) // translation
00212   //        , makeDDRotation(i)    // rotation.  box is default (i.e. identity).
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   //----- translation 
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   // in other cases, this solid will have 1, 2, 3, etc. after it.
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) //This solid has NOT been defined. 
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