File indexing completed on 2024-05-10 02:20:53
0001
0002
0003
0004
0005
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0008 #include "DetectorDescription/Core/interface/DDSolid.h"
0009 #include "DetectorDescription/Core/interface/DDMaterial.h"
0010 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0011 #include "DetectorDescription/Core/interface/DDSplit.h"
0012 #include "DetectorDescription/Core/interface/DDTypes.h"
0013 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0014 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0015 #include <CLHEP/Units/PhysicalConstants.h>
0016 #include <CLHEP/Units/SystemOfUnits.h>
0017
0018 #include <cmath>
0019 #include <algorithm>
0020 #include <map>
0021 #include <string>
0022 #include <vector>
0023
0024 using namespace std;
0025
0026 class DDPixBarLayerUpgradeAlgo : public DDAlgorithm {
0027 public:
0028
0029 DDPixBarLayerUpgradeAlgo();
0030 ~DDPixBarLayerUpgradeAlgo() override;
0031
0032 void initialize(const DDNumericArguments& nArgs,
0033 const DDVectorArguments& vArgs,
0034 const DDMapArguments& mArgs,
0035 const DDStringArguments& sArgs,
0036 const DDStringVectorArguments& vsArgs) override;
0037
0038 void execute(DDCompactView& cpv) override;
0039
0040 private:
0041 string idNameSpace;
0042 string genMat;
0043 int number;
0044 double layerDz;
0045 double coolDz;
0046 double coolThick;
0047 double coolRadius;
0048 double coolDist;
0049 double cool1Offset;
0050 double cool2Offset;
0051 string coolMat;
0052 string tubeMat;
0053 string coolMatHalf;
0054 string tubeMatHalf;
0055 string ladder;
0056 double ladderWidth;
0057 double ladderThick;
0058 double ladderOffset;
0059 int outerFirst;
0060 double phiFineTune;
0061 double rOuterFineTune;
0062 double rInnerFineTune;
0063 };
0064
0065 DDPixBarLayerUpgradeAlgo::DDPixBarLayerUpgradeAlgo() {
0066 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo info: Creating an instance";
0067 }
0068
0069 DDPixBarLayerUpgradeAlgo::~DDPixBarLayerUpgradeAlgo() {}
0070
0071 void DDPixBarLayerUpgradeAlgo::initialize(const DDNumericArguments& nArgs,
0072 const DDVectorArguments& vArgs,
0073 const DDMapArguments&,
0074 const DDStringArguments& sArgs,
0075 const DDStringVectorArguments& vsArgs) {
0076 idNameSpace = DDCurrentNamespace::ns();
0077 DDName parentName = parent().name();
0078
0079 genMat = sArgs["GeneralMaterial"];
0080 number = int(nArgs["Ladders"]);
0081 layerDz = nArgs["LayerDz"];
0082 coolDz = nArgs["CoolDz"];
0083 coolThick = nArgs["CoolThick"];
0084 coolRadius = nArgs["CoolRadius"];
0085 coolDist = nArgs["CoolDist"];
0086 cool1Offset = nArgs["Cool1Offset"];
0087 cool2Offset = nArgs["Cool2Offset"];
0088 coolMat = sArgs["CoolMaterial"];
0089 tubeMat = sArgs["CoolTubeMaterial"];
0090 coolMatHalf = sArgs["CoolMaterialHalf"];
0091 tubeMatHalf = sArgs["CoolTubeMaterialHalf"];
0092 phiFineTune = nArgs["PitchFineTune"];
0093 rOuterFineTune = nArgs["OuterOffsetFineTune"];
0094 rInnerFineTune = nArgs["InnerOffsetFineTune"];
0095
0096 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace
0097 << "\n"
0098 << "\tLadders " << number << "\tGeneral Material " << genMat << "\tLength " << layerDz
0099 << "\tSpecification of Cooling Pieces:\n"
0100 << "\tLength " << coolDz << " Thickness of Shell " << coolThick << " Radial distance "
0101 << coolDist << " Materials " << coolMat << ", " << tubeMat;
0102
0103 ladder = sArgs["LadderName"];
0104 ladderWidth = nArgs["LadderWidth"];
0105 ladderThick = nArgs["LadderThick"];
0106 ladderOffset = nArgs["LadderOffset"];
0107 outerFirst = int(nArgs["OuterFirst"]);
0108
0109 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Full Ladder " << ladder << " width/thickness "
0110 << ladderWidth << ", " << ladderThick;
0111 }
0112
0113 void DDPixBarLayerUpgradeAlgo::execute(DDCompactView& cpv) {
0114 DDName mother = parent().name();
0115 const string& idName = mother.name();
0116
0117 double dphi = CLHEP::twopi / number;
0118 double x2 = coolDist * sin(0.5 * dphi);
0119 double rtmi = coolDist * cos(0.5 * dphi) - (coolRadius + ladderThick) + rInnerFineTune;
0120 double rmxh = coolDist * cos(0.5 * dphi) + (coolRadius + ladderThick + ladderOffset) + rOuterFineTune;
0121 double rtmx = sqrt(rmxh * rmxh + ladderWidth * ladderWidth / 4);
0122 DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace), 0.5 * layerDz, rtmi, rtmx, 0, CLHEP::twopi);
0123 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << DDName(idName, idNameSpace) << " Tubs made of "
0124 << genMat << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rtmi << " Rout "
0125 << rtmx << " ZHalf " << 0.5 * layerDz;
0126 DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
0127 DDMaterial matter(matname);
0128 DDLogicalPart layer(solid.ddname(), matter, solid);
0129
0130
0131 string name = idName + "CoolTube";
0132 solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * coolDz, 0, coolRadius, 0, CLHEP::twopi);
0133 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMat
0134 << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rout " << coolRadius << " ZHalf "
0135 << 0.5 * coolDz;
0136 matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
0137 DDLogicalPart coolTube(solid.ddname(), matter, solid);
0138
0139
0140 name = idName + "CoolTubeHalf";
0141 solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * coolDz, 0, coolRadius, 0, CLHEP::pi);
0142 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMatHalf
0143 << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rout " << coolRadius << " ZHalf "
0144 << 0.5 * coolDz;
0145 matter = DDMaterial(DDName(DDSplit(tubeMatHalf).first, DDSplit(tubeMatHalf).second));
0146 DDLogicalPart coolTubeHalf(solid.ddname(), matter, solid);
0147
0148
0149 name = idName + "Coolant";
0150 solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * coolDz, 0, coolRadius - coolThick, 0, CLHEP::twopi);
0151 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMat
0152 << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rout " << coolRadius - coolThick
0153 << " ZHalf " << 0.5 * coolDz;
0154 matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
0155 DDLogicalPart cool(solid.ddname(), matter, solid);
0156 cpv.position(cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
0157 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name() << " number 1 positioned in "
0158 << coolTube.name() << " at (0,0,0) with no rotation";
0159
0160
0161 name = idName + "CoolantHalf";
0162 solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * coolDz, 0, coolRadius - coolThick, 0, CLHEP::pi);
0163 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMatHalf
0164 << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rout " << coolRadius - coolThick
0165 << " ZHalf " << 0.5 * coolDz;
0166 matter = DDMaterial(DDName(DDSplit(coolMatHalf).first, DDSplit(coolMatHalf).second));
0167 DDLogicalPart coolHalf(solid.ddname(), matter, solid);
0168 cpv.position(coolHalf, coolTubeHalf, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
0169 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name() << " number 1 positioned in "
0170 << coolTube.name() << " at (0,0,0) with no rotation";
0171
0172 DDName ladderFull(DDSplit(ladder).first, DDSplit(ladder).second);
0173 int copy = 1, iup = (-1) * outerFirst;
0174 int copyoffset = number + 2;
0175 for (int i = 1; i < number + 1; i++) {
0176 double phi = i * dphi + 90 * CLHEP::deg - 0.5 * dphi + phiFineTune;
0177 double phix, phiy, rrr, rrroffset;
0178 string rots;
0179 DDTranslation tran;
0180 DDRotation rot;
0181 iup = -iup;
0182 double dr;
0183 if ((i == 1) || (i == number / 2 + 1)) {
0184 dr = coolRadius + 0.5 * ladderThick + ladderOffset;
0185 } else {
0186 dr = coolRadius + 0.5 * ladderThick;
0187 }
0188 if (i % 2 == 1) {
0189 rrr = coolDist * cos(0.5 * dphi) + iup * dr + rOuterFineTune;
0190 } else {
0191 rrr = coolDist * cos(0.5 * dphi) + iup * dr + rInnerFineTune;
0192 }
0193 tran = DDTranslation(rrr * cos(phi), rrr * sin(phi), 0);
0194 rots = idName + to_string(copy);
0195 if (iup > 0)
0196 phix = phi - 90 * CLHEP::deg;
0197 else
0198 phix = phi + 90 * CLHEP::deg;
0199 phiy = phix + 90. * CLHEP::deg;
0200 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
0201 << "rotation: " << rots << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
0202 << ", 0, 0";
0203 rot = DDrot(DDName(rots, idNameSpace), 90 * CLHEP::deg, phix, 90 * CLHEP::deg, phiy, 0., 0.);
0204 cpv.position(ladderFull, layer, copy, tran, rot);
0205 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << ladderFull << " number " << copy << " positioned in "
0206 << layer.name() << " at " << tran << " with " << rot;
0207 copy++;
0208 rrr = coolDist * cos(0.5 * dphi) + coolRadius / 2.;
0209 rots = idName + to_string(i + 100);
0210 phix = phi + 90. * CLHEP::deg;
0211 if (iup < 0)
0212 phix += dphi;
0213 phiy = phix + 90. * CLHEP::deg;
0214 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
0215 << "rotation: " << rots << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
0216 << ", 0, 0";
0217 tran = DDTranslation(rrr * cos(phi) - x2 * sin(phi), rrr * sin(phi) + x2 * cos(phi), 0);
0218 rot = DDrot(DDName(rots, idNameSpace), 90 * CLHEP::deg, phix, 90 * CLHEP::deg, phiy, 0., 0.);
0219 cpv.position(coolTubeHalf, layer, i + 1, tran, rot);
0220 if ((i == 1) || (i == number / 2 + 1)) {
0221 rrroffset = coolDist * cos(0.5 * dphi) + iup * ladderOffset + rOuterFineTune;
0222 tran = DDTranslation(
0223 rrroffset * cos(phi) - cool1Offset * sin(phi), rrroffset * sin(phi) + cool1Offset * cos(phi), 0);
0224 cpv.position(coolTube, layer, copyoffset, tran, DDRotation());
0225 copyoffset++;
0226 tran = DDTranslation(
0227 rrroffset * cos(phi) - cool2Offset * sin(phi), rrroffset * sin(phi) + cool2Offset * cos(phi), 0);
0228 cpv.position(coolTube, layer, copyoffset, tran, DDRotation());
0229 copyoffset++;
0230 }
0231 LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << coolTube.name() << " number " << i + 1
0232 << " positioned in " << layer.name() << " at " << tran << " with " << rot;
0233 }
0234 }
0235
0236 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDPixBarLayerUpgradeAlgo, "track:DDPixBarLayerUpgradeAlgo");