Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:55:06

0001 #include "DetectorDescription/Parser/src/DDDividedTubs.h"
0002 #include "DetectorDescription/Core/interface/DDRotationMatrix.h"
0003 #include "DetectorDescription/Core/interface/DDAxes.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 "DataFormats/Math/interface/GeantUnits.h"
0010 #include "DetectorDescription/Parser/src/DDDividedGeometryObject.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 
0013 #include <string>
0014 #include <utility>
0015 
0016 class DDCompactView;
0017 using namespace geant_units::operators;
0018 
0019 DDDividedTubsRho::DDDividedTubsRho(const DDDivision& div, DDCompactView* cpv)
0020     : DDDividedGeometryObject::DDDividedGeometryObject(div, cpv) {
0021   checkParametersValidity();
0022   setType("DivisionTubsRho");
0023   DDTubs msol = (DDTubs)(div_.parent().solid());
0024 
0025   if (divisionType_ == DivWIDTH) {
0026     compNDiv_ = calculateNDiv(msol.rIn() - msol.rOut(), div_.width(), div_.offset());
0027   } else if (divisionType_ == DivNDIV) {
0028     compWidth_ = calculateWidth(msol.rIn() - msol.rOut(), div_.nReplicas(), div_.offset());
0029   }
0030 }
0031 
0032 double DDDividedTubsRho::getMaxParameter(void) const {
0033   DDTubs msol = (DDTubs)(div_.parent().solid());
0034   return msol.rOut() - msol.rIn();
0035 }
0036 
0037 DDRotation DDDividedTubsRho::makeDDRotation(const int copyNo) const {
0038   DDRotation myddrot;  // sets to identity.
0039   return myddrot;
0040 }
0041 
0042 DDTranslation DDDividedTubsRho::makeDDTranslation(const int copyNo) const {
0043   DDTranslation translation;
0044   return translation;
0045 }
0046 
0047 DDLogicalPart DDDividedTubsRho::makeDDLogicalPart(const int copyNo) const {
0048   // must always make new name and new solid
0049   DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo), div_.parent().ddname().ns());
0050   DDSolid ddtubs(solname);
0051   DDMaterial usemat(div_.parent().material());
0052   DDTubs msol = (DDTubs)(div_.parent().solid());
0053   DDLogicalPart ddlp;
0054 
0055   double pRMin = msol.rIn() + div_.offset() + compWidth_ * copyNo;
0056   double pRMax = msol.rIn() + div_.offset() + compWidth_ * (copyNo + 1);
0057   double pDz = msol.zhalf();
0058   double pSPhi = msol.startPhi();
0059   double pDPhi = msol.deltaPhi();
0060   ddtubs = DDSolidFactory::tubs(DDName(solname), pDz, pRMin, pRMax, pSPhi, pDPhi);
0061   ddlp = DDLogicalPart(solname, usemat, ddtubs);
0062   return ddlp;
0063 }
0064 
0065 DDDividedTubsPhi::DDDividedTubsPhi(const DDDivision& div, DDCompactView* cpv)
0066     : DDDividedGeometryObject::DDDividedGeometryObject(div, cpv) {
0067   checkParametersValidity();
0068   setType("DivisionTubsPhi");
0069 
0070   DDTubs msol = (DDTubs)(div_.parent().solid());
0071   if (divisionType_ == DivWIDTH) {
0072     //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
0073     if (msol.deltaPhi() == 360._deg) {
0074       compNDiv_ = calculateNDiv(msol.deltaPhi(), div_.width(), 0.);
0075     } else {
0076       compNDiv_ = calculateNDiv(msol.deltaPhi(), div_.width(), div_.offset());
0077     }
0078 
0079   } else if (divisionType_ == DivNDIV) {
0080     if (msol.deltaPhi() == 360._deg) {
0081       compWidth_ = calculateWidth(msol.deltaPhi(), div_.nReplicas(), 0.);
0082     } else {
0083       compWidth_ = calculateWidth(msol.deltaPhi(), div_.nReplicas(), div_.offset());
0084     }
0085   }
0086 }
0087 
0088 double DDDividedTubsPhi::getMaxParameter(void) const {
0089   DDTubs msol = (DDTubs)(div_.parent().solid());
0090   return msol.deltaPhi();
0091 }
0092 
0093 DDRotation DDDividedTubsPhi::makeDDRotation(const int copyNo) const {
0094   DDRotation myddrot;                       // sets to identity.
0095   double posi = (copyNo - 1) * compWidth_;  // This should put the first one at the 0 of the parent.
0096   DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT" + std::to_string(copyNo),
0097                    div_.parent().ddname().ns());
0098   myddrot = DDrot(ddrotname, changeRotMatrix(posi));
0099 
0100   return myddrot;
0101 }
0102 
0103 DDTranslation DDDividedTubsPhi::makeDDTranslation(const int copyNo) const {
0104   DDTranslation translation;
0105   return translation;
0106 }
0107 
0108 DDLogicalPart DDDividedTubsPhi::makeDDLogicalPart(const int copyNo) const {
0109   DDName solname(div_.name());
0110   DDSolid ddtubs(solname);
0111   DDMaterial usemat(div_.parent().material());
0112   DDTubs msol = (DDTubs)(div_.parent().solid());
0113   DDLogicalPart ddlp(solname);
0114 
0115   if (!ddtubs.isDefined().second)  // only if it is not defined, make new dimensions and solid.
0116   {
0117     double pRMin = msol.rIn();
0118     double pRMax = msol.rOut();
0119     double pDz = msol.zhalf();
0120     double pSPhi = msol.startPhi() + div_.offset();
0121     double pDPhi = compWidth_;
0122     ddtubs = DDSolidFactory::tubs(DDName(solname), pDz, pRMin, pRMax, pSPhi, pDPhi);
0123     ddlp = DDLogicalPart(solname, usemat, ddtubs);
0124   }
0125   return ddlp;
0126 }
0127 
0128 DDDividedTubsZ::DDDividedTubsZ(const DDDivision& div, DDCompactView* cpv)
0129     : DDDividedGeometryObject::DDDividedGeometryObject(div, cpv) {
0130   checkParametersValidity();
0131 
0132   DDTubs msol = (DDTubs)(div_.parent().solid());
0133 
0134   setType("DivisionTubsZ");
0135   if (divisionType_ == DivWIDTH) {
0136     compNDiv_ = calculateNDiv(2 * msol.zhalf(), div_.width(), div_.offset());
0137   } else if (divisionType_ == DivNDIV) {
0138     compWidth_ = calculateWidth(2 * msol.zhalf(), div_.nReplicas(), div_.offset());
0139   }
0140 }
0141 
0142 double DDDividedTubsZ::getMaxParameter(void) const {
0143   DDTubs msol = (DDTubs)(div_.parent().solid());
0144   return 2 * msol.zhalf();
0145 }
0146 
0147 DDRotation DDDividedTubsZ::makeDDRotation(const int copyNo) const {
0148   DDRotation myddrot;  // sets to identity.
0149   return myddrot;
0150 }
0151 
0152 DDTranslation DDDividedTubsZ::makeDDTranslation(const int copyNo) const {
0153   DDTranslation translation;
0154 
0155   DDTubs msol = (DDTubs)(div_.parent().solid());
0156   double posi = -msol.zhalf() + div_.offset() + compWidth_ / 2 + copyNo * compWidth_;
0157   translation.SetZ(posi);
0158 
0159   return translation;
0160 }
0161 
0162 DDLogicalPart DDDividedTubsZ::makeDDLogicalPart(const int copyNo) const {
0163   DDMaterial usemat(div_.parent().material());
0164   DDTubs msol = (DDTubs)(div_.parent().solid());
0165   DDLogicalPart ddlp;
0166 
0167   DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
0168   DDSolid ddtubs(solname);
0169 
0170   if (!ddtubs.isDefined().second)  // only if it is not defined, make new dimensions and solid.
0171   {
0172     double pRMin = msol.rIn();
0173     double pRMax = msol.rOut();
0174     double pDz = compWidth_ / 2.;
0175     double pSPhi = msol.startPhi();
0176     double pDPhi = msol.deltaPhi();
0177     ddtubs = DDSolidFactory::tubs(DDName(solname), pDz, pRMin, pRMax, pSPhi, pDPhi);
0178     ddlp = DDLogicalPart(solname, usemat, ddtubs);
0179   } else {
0180     ddlp = DDLogicalPart(solname);
0181   }
0182   return ddlp;
0183 }