Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:08:05

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDTBH4Algo.cc
0003 // Description: Position inside the mother according to (eta,phi)
0004 ///////////////////////////////////////////////////////////////////////////////
0005 
0006 #include <cmath>
0007 #include <algorithm>
0008 
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0011 #include "DetectorDescription/Core/interface/DDSolid.h"
0012 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0013 #include "DetectorDescription/Core/interface/DDSplit.h"
0014 #include "Geometry/EcalTestBeam/plugins/DDTBH4Algo.h"
0015 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0016 
0017 DDTBH4Algo::DDTBH4Algo()
0018     : m_idNameSpace(""),
0019       m_BLZBeg(0),
0020       m_BLZEnd(0),
0021       m_BLZPiv(0),
0022       m_BLRadius(0),
0023       m_VacName(""),
0024       m_VacMat(""),
0025       m_vecVacZBeg(),
0026       m_vecVacZEnd(),
0027       m_WinName(""),
0028       m_vecWinMat(),
0029       m_vecWinZBeg(),
0030       m_vecWinThick(),
0031       m_TrgMat(""),
0032       m_HoleMat(""),
0033       m_TrgVetoHoleRadius(0),
0034       m_vecTrgName(),
0035       m_vecTrgSide(),
0036       m_vecTrgThick(),
0037       m_vecTrgPhi(),
0038       m_vecTrgXOff(),
0039       m_vecTrgYOff(),
0040       m_vecTrgZPiv(),
0041       m_FibFibName(""),
0042       m_FibCladName(""),
0043       m_FibFibMat(""),
0044       m_FibCladMat(""),
0045       m_FibSide(0),
0046       m_FibCladThick(0),
0047       m_FibLength(0),
0048       m_vecFibPhi(),
0049       m_vecFibXOff(),
0050       m_vecFibYOff(),
0051       m_vecFibZPiv()
0052 
0053 {
0054   std::cout << "creating an instance if DDTBH4Algo" << std::endl;
0055   LogDebug("EcalGeom") << "DDTBH4Algo test: Creating an instance";
0056 }
0057 
0058 DDTBH4Algo::~DDTBH4Algo() {}
0059 
0060 DDRotation DDTBH4Algo::myrot(const std::string& s, const CLHEP::HepRotation& r) const {
0061   return DDrot(
0062       ddname(idNameSpace() + ":" + s),
0063       std::make_unique<DDRotationMatrix>(r.xx(), r.xy(), r.xz(), r.yx(), r.yy(), r.yz(), r.zx(), r.zy(), r.zz()));
0064 }
0065 
0066 DDMaterial DDTBH4Algo::ddmat(const std::string& s) const { return DDMaterial(ddname(s)); }
0067 
0068 DDName DDTBH4Algo::ddname(const std::string& s) const {
0069   const std::pair<std::string, std::string> temp(DDSplit(s));
0070   return DDName(temp.first, temp.second);
0071 }
0072 
0073 void DDTBH4Algo::initialize(const DDNumericArguments& nArgs,
0074                             const DDVectorArguments& vArgs,
0075                             const DDMapArguments& mArgs,
0076                             const DDStringArguments& sArgs,
0077                             const DDStringVectorArguments& vsArgs) {
0078   m_idNameSpace = DDCurrentNamespace::ns();
0079   m_BLZBeg = nArgs["BLZBeg"];
0080   m_BLZEnd = nArgs["BLZEnd"];
0081   m_BLZPiv = nArgs["BLZPiv"];
0082   m_BLRadius = nArgs["BLRadius"];
0083   m_VacName = sArgs["VacName"];
0084   m_VacMat = sArgs["VacMat"];
0085   m_vecVacZBeg = vArgs["VacZBeg"];
0086   m_vecVacZEnd = vArgs["VacZEnd"];
0087 
0088   m_WinName = sArgs["WinName"];
0089   m_vecWinMat = vsArgs["WinMat"];
0090   m_vecWinZBeg = vArgs["WinZBeg"];
0091   m_vecWinThick = vArgs["WinThick"];
0092 
0093   m_TrgMat = sArgs["TrgMat"];
0094   m_HoleMat = sArgs["HoleMat"];
0095   m_TrgVetoHoleRadius = nArgs["TrgVetoHoleRadius"];
0096   m_vecTrgName = vsArgs["TrgName"];
0097   m_vecTrgSide = vArgs["TrgSide"];
0098   m_vecTrgThick = vArgs["TrgThick"];
0099   m_vecTrgPhi = vArgs["TrgPhi"];
0100   m_vecTrgXOff = vArgs["TrgXOff"];
0101   m_vecTrgYOff = vArgs["TrgYOff"];
0102   m_vecTrgZPiv = vArgs["TrgZPiv"];
0103 
0104   m_FibFibName = sArgs["FibFibName"];
0105   m_FibCladName = sArgs["FibCladName"];
0106   m_FibFibMat = sArgs["FibFibMat"];
0107   m_FibCladMat = sArgs["FibCladMat"];
0108   m_FibSide = nArgs["FibSide"];
0109   m_FibCladThick = nArgs["FibCladThick"];
0110   m_FibLength = nArgs["FibLength"];
0111   m_vecFibPhi = vArgs["FibPhi"];
0112   m_vecFibXOff = vArgs["FibXOff"];
0113   m_vecFibYOff = vArgs["FibYOff"];
0114   m_vecFibZPiv = vArgs["FibZPiv"];
0115 }
0116 
0117 void DDTBH4Algo::execute(DDCompactView& cpv) {
0118   const unsigned int copyOne(1);
0119 
0120   const double halfZbl((blZEnd() - blZBeg()) / 2.);
0121   for (unsigned int i(0); i != vecVacZBeg().size(); ++i) {
0122     DDName vacNameNm(ddname(vacName() + std::to_string(i + 1)));
0123     const double halfZvac((vecVacZEnd()[i] - vecVacZBeg()[i]) / 2.);
0124     DDSolid vTubeSolid(DDSolidFactory::tubs(vacNameNm, halfZvac, 0, blRadius(), 0 * deg, 360 * deg));
0125     const DDLogicalPart vacLog(vacNameNm, vacMat(), vTubeSolid);
0126 
0127     cpv.position(vacLog,
0128                  parent().name(),
0129                  1 + i,
0130                  DDTranslation(0, 0, -halfZbl + halfZvac + vecVacZBeg()[i] - blZBeg()),
0131                  DDRotation());
0132   }
0133 
0134   for (unsigned int i(0); i != vecWinZBeg().size(); ++i) {
0135     DDName wName(ddname(winName() + std::to_string(i + 1)));
0136     DDSolid wTubeSolid(DDSolidFactory::tubs(wName, vecWinThick()[i] / 2., 0, blRadius(), 0 * deg, 360 * deg));
0137     const DDLogicalPart wLog(wName, ddmat(vecWinMat()[i]), wTubeSolid);
0138 
0139     const double off(0 < vecWinZBeg()[i] ? vecWinZBeg()[i] : fabs(vecWinZBeg()[i]) - vecWinThick()[i]);
0140 
0141     cpv.position(wLog,
0142                  parent().name(),
0143                  1 + i,
0144                  DDTranslation(0, 0, -halfZbl + vecWinThick()[i] / 2. + off - blZBeg()),
0145                  DDRotation());
0146   }
0147 
0148   for (unsigned int i(0); i != vecTrgName().size(); ++i) {
0149     DDName tName(ddname(vecTrgName()[i]));
0150     DDSolid tSolid(DDSolidFactory::box(tName, vecTrgSide()[i] / 2., vecTrgSide()[i] / 2., vecTrgThick()[i] / 2.));
0151     const DDLogicalPart tLog(tName, trgMat(), tSolid);
0152 
0153     if (tName.name() == "VETO") {
0154       DDName vName(ddname(tName.name() + "Hole"));
0155       DDSolid vTubeSolid(
0156           DDSolidFactory::tubs(vName, vecTrgThick()[i] / 2., 0, trgVetoHoleRadius(), 0 * deg, 360 * deg));
0157       const DDLogicalPart vLog(vName, holeMat(), vTubeSolid);
0158 
0159       cpv.position(vLog, tName, copyOne, DDTranslation(0, 0, 0), DDRotation());
0160     }
0161 
0162     cpv.position(tLog,
0163                  parent().name(),
0164                  copyOne,
0165                  DDTranslation(vecTrgXOff()[i], vecTrgYOff()[i], vecTrgZPiv()[i] - halfZbl + blZPiv() - blZBeg()),
0166                  myrot(tName.name() + "Rot", CLHEP::HepRotationZ(vecTrgPhi()[i])));
0167   }
0168 
0169   DDName pName(fibCladName());
0170   const double planeWidth(32.5 * fibSide() + 33.5 * fibCladThick());
0171   const double planeThick(2 * fibSide() + 3 * fibCladThick());
0172   DDSolid pSolid(DDSolidFactory::box(pName, planeWidth / 2., fibLength() / 2., planeThick / 2.));
0173   const DDLogicalPart pLog(pName, fibCladMat(), pSolid);
0174 
0175   DDSolid fSolid(DDSolidFactory::box(fibFibName(), fibSide() / 2., fibLength() / 2., fibSide() / 2.));
0176 
0177   const DDLogicalPart fLog(fibFibName(), fibFibMat(), fSolid);
0178 
0179   for (unsigned int j(0); j != 32; ++j) {
0180     const double xoff(planeWidth / 2. - (1 + j) * fibCladThick() - (1 + j) * fibSide());
0181     const double zoff(-planeThick / 2 + fibCladThick() + fibSide() / 2.);
0182     cpv.position(fLog, pName, 1 + j, DDTranslation(xoff, 0, zoff), DDRotation());
0183 
0184     cpv.position(fLog, pName, 33 + j, DDTranslation(xoff + (fibCladThick() + fibSide()) / 2., 0, -zoff), DDRotation());
0185   }
0186   for (unsigned int i(0); i != vecFibZPiv().size(); ++i) {
0187     cpv.position(
0188         pLog,
0189         parent().name(),
0190         1 + i,
0191         DDTranslation(
0192             vecFibXOff()[i] - 0.5 * fibSide(), vecFibYOff()[i], vecFibZPiv()[i] - halfZbl + blZPiv() - blZBeg()),
0193         myrot(pName.name() + "Rot" + std::to_string(i), CLHEP::HepRotationZ(vecFibPhi()[i])));
0194   }
0195 }