Back to home page

Project CMSSW displayed by LXR

 
 

    


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   // somehow here, I want to iterate over the nDivs or nReplicas
0031   // and make the solid, make the logical part, then position it.
0032   // since DDBox is special, I will not make the solid and logical
0033   // part but once.  We'll see how bad the others go.
0034   // ihatethisihatethisihatethis
0035   //    for (int i = 0; i < compNDiv_; ++i)
0036   //      {
0037   //         DDpos(makeDDLogicalPart(i)  // child logical part
0038   //        , div_.parent()        // parent logical part
0039   //        , i                    // copy number
0040   //        , makeDDTranslation(i) // translation
0041   //        , makeDDRotation(i)    // rotation.  box is default (i.e. identity).
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   //----- translation
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   // in other cases, this solid will have 1, 2, 3, etc. after it.
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)  //This solid has NOT been defined.
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   // somehow here, I want to iterate over the nDivs or nReplicas
0097   // and make the solid, make the logical part, then position it.
0098   // since DDBox is special, I will not make the solid and logical
0099   // part but once.  We'll see how bad the others go.
0100   // ihatethisihatethisihatethis
0101   //    for (int i = 0; i < compNDiv_; ++i)
0102   //      {
0103   //         DDpos(makeDDLogicalPart(i)  // child logical part
0104   //        , div_.parent()        // parent logical part
0105   //        , i                    // copy number
0106   //        , makeDDTranslation(i) // translation
0107   //        , makeDDRotation(i)    // rotation.  box is default (i.e. identity).
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   //----- translation
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   // in other cases, this solid will have 1, 2, 3, etc. after it.
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)  //This solid has NOT been defined.
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   // somehow here, I want to iterate over the nDivs or nReplicas
0163   // and make the solid, make the logical part, then position it.
0164   // since DDBox is special, I will not make the solid and logical
0165   // part but once.  We'll see how bad the others go.
0166   // ihatethisihatethisihatethis
0167   //    for (int i = 0; i < compNDiv_; ++i)
0168   //      {
0169   //         DDpos(makeDDLogicalPart(i)  // child logical part
0170   //        , div_.parent()        // parent logical part
0171   //        , i                    // copy number
0172   //        , makeDDTranslation(i) // translation
0173   //        , makeDDRotation(i)    // rotation.  box is default (i.e. identity).
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   //----- translation
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   // in other cases, this solid will have 1, 2, 3, etc. after it.
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)  //This solid has NOT been defined.
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 }