File indexing completed on 2024-05-10 02:20:54
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/GlobalPhysicalConstants.h>
0016 #include <CLHEP/Units/SystemOfUnits.h>
0017
0018 #include <string>
0019 #include <vector>
0020
0021 using namespace std;
0022
0023 class DDTIDAxialCableAlgo : public DDAlgorithm {
0024 public:
0025
0026 DDTIDAxialCableAlgo();
0027 ~DDTIDAxialCableAlgo() override;
0028
0029 void initialize(const DDNumericArguments& nArgs,
0030 const DDVectorArguments& vArgs,
0031 const DDMapArguments& mArgs,
0032 const DDStringArguments& sArgs,
0033 const DDStringVectorArguments& vsArgs) override;
0034
0035 void execute(DDCompactView& cpv) override;
0036
0037 private:
0038 double zBend;
0039 double zEnd;
0040 double rMin;
0041 double rMax;
0042 double rTop;
0043 double width;
0044 double thick;
0045 vector<double> angles;
0046 vector<double> zposWheel;
0047 vector<double> zposRing;
0048
0049 string idNameSpace;
0050 string childName;
0051 string matIn;
0052 string matOut;
0053 };
0054
0055 DDTIDAxialCableAlgo::DDTIDAxialCableAlgo() { LogDebug("TIDGeom") << "DDTIDAxialCableAlgo info: Creating an instance"; }
0056
0057 DDTIDAxialCableAlgo::~DDTIDAxialCableAlgo() {}
0058
0059 void DDTIDAxialCableAlgo::initialize(const DDNumericArguments& nArgs,
0060 const DDVectorArguments& vArgs,
0061 const DDMapArguments&,
0062 const DDStringArguments& sArgs,
0063 const DDStringVectorArguments&) {
0064 zBend = nArgs["ZBend"];
0065 zEnd = nArgs["ZEnd"];
0066 rMin = nArgs["RMin"];
0067 rMax = nArgs["RMax"];
0068 rTop = nArgs["RTop"];
0069 width = nArgs["Width"];
0070 thick = nArgs["Thick"];
0071 angles = vArgs["Angles"];
0072 zposWheel = vArgs["ZPosWheel"];
0073 zposRing = vArgs["ZPosRing"];
0074
0075 LogDebug("TIDGeom") << "DDTIDAxialCableAlgo debug: Parameters for creating " << (zposWheel.size() + 2)
0076 << " axial cables and position"
0077 << "ing " << angles.size() << " copies in Service volume"
0078 << "\n zBend " << zBend << " zEnd " << zEnd << " rMin " << rMin
0079 << " rMax " << rMax << " Cable width " << width / CLHEP::deg << " thickness " << thick
0080 << " with Angles";
0081 for (int i = 0; i < (int)(angles.size()); i++)
0082 LogDebug("TIDGeom") << "\tangles[" << i << "] = " << angles[i] / CLHEP::deg;
0083 LogDebug("TIDGeom") << " Wheels " << zposWheel.size() << " at Z";
0084 for (int i = 0; i < (int)(zposWheel.size()); i++)
0085 LogDebug("TIDGeom") << "\tzposWheel[" << i << "] = " << zposWheel[i];
0086 LogDebug("TIDGeom") << " each with " << zposRing.size() << " Rings at Z";
0087 for (int i = 0; i < (int)(zposRing.size()); i++)
0088 LogDebug("TIDGeom") << "\tzposRing[" << i << "] = " << zposRing[i];
0089
0090 idNameSpace = DDCurrentNamespace::ns();
0091 childName = sArgs["ChildName"];
0092 matIn = sArgs["MaterialIn"];
0093 matOut = sArgs["MaterialOut"];
0094
0095 DDName parentName = parent().name();
0096 LogDebug("TIDGeom") << "DDTIDAxialCableAlgo debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
0097 << idNameSpace << "\tMaterial " << matIn << " and " << matOut;
0098 }
0099
0100 void DDTIDAxialCableAlgo::execute(DDCompactView& cpv) {
0101 DDName mother = parent().name();
0102 vector<DDName> logs;
0103 double thk = thick / zposRing.size();
0104 double r = rMin;
0105 double thktot = 0;
0106 double z;
0107
0108
0109 for (int k = 0; k < (int)(zposWheel.size()); k++) {
0110 vector<double> pconZ, pconRmin, pconRmax;
0111 for (int i = 0; i < (int)(zposRing.size()); i++) {
0112 thktot += thk;
0113 z = zposWheel[k] + zposRing[i] - 0.5 * thk;
0114 if (i != 0) {
0115 pconZ.emplace_back(z);
0116 pconRmin.emplace_back(r);
0117 pconRmax.emplace_back(rMax);
0118 }
0119 r = rMin;
0120 pconZ.emplace_back(z);
0121 pconRmin.emplace_back(r);
0122 pconRmax.emplace_back(rMax);
0123 z += thk;
0124 pconZ.emplace_back(z);
0125 pconRmin.emplace_back(r);
0126 pconRmax.emplace_back(rMax);
0127 r = rMax - thktot;
0128 pconZ.emplace_back(z);
0129 pconRmin.emplace_back(r);
0130 pconRmax.emplace_back(rMax);
0131 }
0132 if (k >= ((int)(zposWheel.size()) - 1))
0133 z = zBend;
0134 else
0135 z = zposWheel[k + 1] + zposRing[0] - 0.5 * thk;
0136 pconZ.emplace_back(z);
0137 pconRmin.emplace_back(r);
0138 pconRmax.emplace_back(rMax);
0139
0140 string name = childName + to_string(k);
0141 DDSolid solid = DDSolidFactory::polycone(DDName(name, idNameSpace), -0.5 * width, width, pconZ, pconRmin, pconRmax);
0142
0143 LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: " << DDName(name, idNameSpace) << " Polycone made of " << matIn
0144 << " from " << -0.5 * width / CLHEP::deg << " to " << 0.5 * width / CLHEP::deg << " and with "
0145 << pconZ.size() << " sections ";
0146 for (int i = 0; i < (int)(pconZ.size()); i++)
0147 LogDebug("TIDGeom") << "\t[" << i << "]\tZ = " << pconZ[i] << "\tRmin = " << pconRmin[i]
0148 << "\tRmax = " << pconRmax[i];
0149
0150 DDName mat(DDSplit(matIn).first, DDSplit(matIn).second);
0151 DDMaterial matter(mat);
0152 DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
0153 logs.emplace_back(DDName(name, idNameSpace));
0154 }
0155
0156
0157 vector<double> pconZ, pconRmin, pconRmax;
0158 r = thktot * rMax / rTop;
0159 z = zBend - thktot;
0160 LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: Thk " << thk << " Total " << thktot << " rMax " << rMax << " rTop "
0161 << rTop << " dR " << r << " z " << z;
0162 pconZ.emplace_back(z);
0163 pconRmin.emplace_back(rMax);
0164 pconRmax.emplace_back(rMax);
0165 z = zBend - r;
0166 pconZ.emplace_back(z);
0167 pconRmin.emplace_back(rMax);
0168 pconRmax.emplace_back(rTop);
0169 pconZ.emplace_back(zBend);
0170 pconRmin.emplace_back(rMax);
0171 pconRmax.emplace_back(rTop);
0172
0173 string name = childName + to_string(zposWheel.size());
0174 DDSolid solid = DDSolidFactory::polycone(DDName(name, idNameSpace), -0.5 * width, width, pconZ, pconRmin, pconRmax);
0175
0176 LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: " << DDName(name, idNameSpace) << " Polycone made of " << matIn
0177 << " from " << -0.5 * width / CLHEP::deg << " to " << 0.5 * width / CLHEP::deg << " and with "
0178 << pconZ.size() << " sections ";
0179 for (int i = 0; i < (int)(pconZ.size()); i++)
0180 LogDebug("TIDGeom") << "\t[" << i << "]\tZ = " << pconZ[i] << "\tRmin = " << pconRmin[i]
0181 << "\tRmax = " << pconRmax[i];
0182
0183 DDMaterial matter(DDName(DDSplit(matIn).first, DDSplit(matIn).second));
0184 DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
0185 logs.emplace_back(DDName(name, idNameSpace));
0186
0187
0188 name = childName + to_string(zposWheel.size() + 1);
0189 r = rTop - r;
0190 solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * (zEnd - zBend), r, rTop, -0.5 * width, width);
0191 LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << matOut
0192 << " from " << -0.5 * width / CLHEP::deg << " to " << 0.5 * width / CLHEP::deg << " with Rin "
0193 << r << " Rout " << rTop << " ZHalf " << 0.5 * (zEnd - zBend);
0194 matter = DDMaterial(DDName(DDSplit(matOut).first, DDSplit(matOut).second));
0195 genlogic = DDLogicalPart(DDName(name, idNameSpace), matter, solid);
0196 logs.emplace_back(DDName(name, idNameSpace));
0197
0198
0199 double theta = 90. * CLHEP::deg;
0200 for (int i = 0; i < (int)(angles.size()); i++) {
0201 double phix = angles[i];
0202 double phiy = phix + 90. * CLHEP::deg;
0203 double phideg = phix / CLHEP::deg;
0204
0205 DDRotation rotation;
0206 if (phideg != 0) {
0207 string rotstr = childName + to_string(phideg * 10.);
0208 rotation = DDRotation(DDName(rotstr, idNameSpace));
0209 if (!rotation) {
0210 LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: Creating a new "
0211 << "rotation: " << rotstr << " " << theta / CLHEP::deg << ", " << phix / CLHEP::deg << ", "
0212 << theta / CLHEP::deg << ", " << phiy / CLHEP::deg << ", 0, 0";
0213 rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
0214 }
0215 }
0216
0217 for (int k = 0; k < (int)(logs.size()); k++) {
0218 DDTranslation tran(0, 0, 0);
0219 if (k == ((int)(logs.size()) - 1))
0220 tran = DDTranslation(0, 0, 0.5 * (zEnd + zBend));
0221 cpv.position(logs[k], mother, i + 1, tran, rotation);
0222 LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test " << logs[k] << " number " << i + 1 << " positioned in "
0223 << mother << " at " << tran << " with " << rotation;
0224 }
0225 }
0226 }
0227
0228 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTIDAxialCableAlgo, "track:DDTIDAxialCableAlgo");