File indexing completed on 2024-04-06 12:15:22
0001 #include "DD4hep/DetFactoryHelper.h"
0002 #include "DataFormats/Math/interface/CMSUnits.h"
0003 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005
0006 using namespace std;
0007 using namespace dd4hep;
0008 using namespace cms;
0009 using namespace cms_units::operators;
0010
0011 static long algorithm(Detector& , cms::DDParsingContext& ctxt, xml_h e) {
0012 cms::DDNamespace ns(ctxt, e, true);
0013 DDAlgoArguments args(ctxt, e);
0014 double diskDz = args.dble("DiskDz");
0015 double rMax = args.dble("RMax");
0016 double cableT = args.dble("CableT");
0017 vector<double> rodRin = args.vecDble("RodRin");
0018 vector<double> rodRout = args.vecDble("RodRout");
0019 vector<string> cableM = args.vecStr("CableMaterial");
0020 double connW = args.dble("ConnW");
0021 double connT = args.dble("ConnT");
0022 vector<string> connM = args.vecStr("ConnMaterial");
0023 vector<double> coolR1 = args.vecDble("CoolR1");
0024 vector<double> coolR2 = args.vecDble("CoolR2");
0025 double coolRin = args.dble("CoolRin");
0026 double coolRout1 = args.dble("CoolRout1");
0027 double coolRout2 = args.dble("CoolRout2");
0028 double coolStartPhi1 = args.dble("CoolStartPhi1");
0029 double coolDeltaPhi1 = args.dble("CoolDeltaPhi1");
0030 double coolStartPhi2 = args.dble("CoolStartPhi2");
0031 double coolDeltaPhi2 = args.dble("CoolDeltaPhi2");
0032 string coolM1 = args.str("CoolMaterial1");
0033 string coolM2 = args.str("CoolMaterial2");
0034 vector<string> names = args.vecStr("RingName");
0035
0036 string parentName = args.parentName();
0037 edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Parent " << parentName << " NameSpace " << ns.name();
0038 edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Disk Half width " << diskDz << "\tRMax " << rMax
0039 << "\tCable Thickness " << cableT << "\tRadii of disk position and cable materials:";
0040 for (int i = 0; i < (int)(rodRin.size()); i++)
0041 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tRin = " << rodRin[i] << "\tRout = " << rodRout[i] << " "
0042 << cableM[i];
0043 edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Connector Width = " << connW << "\tThickness = " << connT
0044 << "\tMaterials: ";
0045 for (int i = 0; i < (int)(connM.size()); i++)
0046 edm::LogVerbatim("TOBGeom") << "\tconnM[" << i << "] = " << connM[i];
0047 edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Cool Manifold Torus Rin = " << coolRin
0048 << " Rout = " << coolRout1 << "\t Phi start = " << coolStartPhi1
0049 << " Phi Range = " << coolDeltaPhi1 << "\t Material = " << coolM1
0050 << "\t Radial positions:";
0051 for (int i = 0; i < (int)(coolR1.size()); i++)
0052 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tR = " << coolR1[i];
0053 for (int i = 0; i < (int)(coolR2.size()); i++)
0054 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tR = " << coolR2[i];
0055 edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: Cooling Fluid Torus Rin = " << coolRin
0056 << " Rout = " << coolRout2 << "\t Phi start = " << coolStartPhi2
0057 << " Phi Range = " << coolDeltaPhi2 << "\t Material = " << coolM2
0058 << "\t Radial positions:";
0059 for (int i = 0; i < (int)(coolR1.size()); i++)
0060 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tR = " << coolR1[i];
0061 for (int i = 0; i < (int)(coolR2.size()); i++)
0062 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tR = " << coolR2[i];
0063 for (int i = 0; i < (int)(names.size()); i++)
0064 edm::LogVerbatim("TOBGeom") << "DDTOBRadCableAlgo debug: names[" << i << "] = " << names[i];
0065
0066 Volume disk = ns.volume(parentName);
0067
0068 for (int i = 0; i < (int)(names.size()); i++) {
0069 Solid solid;
0070 string name;
0071 double dz, rin, rout;
0072
0073
0074 name = "TOBCoolingManifold" + names[i] + "a";
0075 dz = coolRout1;
0076 solid = ns.addSolid(ns.prepend(name), Torus(coolR1[i], coolRin, coolRout1, coolStartPhi1, coolDeltaPhi1));
0077 edm::LogVerbatim("TOBGeom") << solid.name() << " Torus made of " << coolM1 << " from "
0078 << convertRadToDeg(coolStartPhi1) << " to "
0079 << convertRadToDeg((coolStartPhi1 + coolDeltaPhi1)) << " with Rin " << coolRin
0080 << " Rout " << coolRout1 << " R torus " << coolR1[i];
0081 Volume coolManifoldLogic_a = ns.addVolume(Volume(solid.name(), solid, ns.material(coolM1)));
0082 Position r1(0, 0, (dz - diskDz));
0083 disk.placeVolume(coolManifoldLogic_a, i + 1, r1);
0084 edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << disk.name() << " at "
0085 << r1 << " with no rotation";
0086
0087
0088 name = "TOBCoolingManifoldFluid" + names[i] + "a";
0089 solid = ns.addSolid(ns.prepend(name), Torus(coolR1[i], coolRin, coolRout2, coolStartPhi2, coolDeltaPhi2));
0090 edm::LogVerbatim("TOBGeom") << solid.name() << " Torus made of " << coolM2 << " from "
0091 << convertRadToDeg(coolStartPhi2) << " to "
0092 << convertRadToDeg((coolStartPhi2 + coolDeltaPhi2)) << " with Rin " << coolRin
0093 << " Rout " << coolRout2 << " R torus " << coolR1[i];
0094 Volume coolManifoldFluidLogic_a = ns.addVolume(Volume(solid.name(), solid, ns.material(coolM2)));
0095 coolManifoldLogic_a.placeVolume(coolManifoldFluidLogic_a, i + 1);
0096 edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << coolM2
0097 << " with no translation and no rotation";
0098
0099 name = "TOBCoolingManifold" + names[i] + "r";
0100 dz = coolRout1;
0101 solid = ns.addSolid(ns.prepend(name), Torus(coolR2[i], coolRin, coolRout1, coolStartPhi1, coolDeltaPhi1));
0102 edm::LogVerbatim("TOBGeom") << solid.name() << " Torus made of " << coolM1 << " from "
0103 << convertRadToDeg(coolStartPhi1) << " to "
0104 << convertRadToDeg((coolStartPhi1 + coolDeltaPhi1)) << " with Rin " << coolRin
0105 << " Rout " << coolRout1 << " R torus " << coolR2[i];
0106 Volume coolManifoldLogic_r = ns.addVolume(Volume(solid.name(), solid, ns.material(coolM1)));
0107 r1 = Position(0, 0, (dz - diskDz));
0108 disk.placeVolume(coolManifoldLogic_r, i + 1, r1);
0109 edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << disk.name() << " at "
0110 << r1 << " with no rotation";
0111
0112
0113 name = "TOBCoolingManifoldFluid" + names[i] + "r";
0114 solid = ns.addSolid(ns.prepend(name), Torus(coolR2[i], coolRin, coolRout2, coolStartPhi2, coolDeltaPhi2));
0115 edm::LogVerbatim("TOBGeom") << solid.name() << " Torus made of " << coolM2 << " from "
0116 << convertRadToDeg(coolStartPhi2) << " to "
0117 << convertRadToDeg((coolStartPhi2 + coolDeltaPhi2)) << " with Rin " << coolRin
0118 << " Rout " << coolRout2 << " R torus " << coolR2[i];
0119 Volume coolManifoldFluidLogic_r = ns.addVolume(Volume(solid.name(), solid, ns.material(coolM2)));
0120 coolManifoldLogic_r.placeVolume(coolManifoldFluidLogic_r, i + 1);
0121 edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << coolM2
0122 << " with no translation and no rotation";
0123
0124
0125 name = "TOBConn" + names[i];
0126 dz = 0.5 * connT;
0127 rin = 0.5 * (rodRin[i] + rodRout[i]) - 0.5 * connW;
0128 rout = 0.5 * (rodRin[i] + rodRout[i]) + 0.5 * connW;
0129 solid = ns.addSolid(ns.prepend(name), Tube(rin, rout, dz));
0130 edm::LogVerbatim("TOBGeom") << solid.name() << " Tubs made of " << connM[i] << " from 0 to "
0131 << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf " << dz;
0132 Volume connLogic = ns.addVolume(Volume(solid.name(), solid, ns.material(connM[i])));
0133 Position r2(0, 0, (dz - diskDz));
0134 disk.placeVolume(connLogic, i + 1, r2);
0135 edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << disk.name() << " at "
0136 << r2 << " with no rotation";
0137
0138
0139 name = "TOBRadServices" + names[i];
0140 rin = 0.5 * (rodRin[i] + rodRout[i]);
0141 rout = (i + 1 == (int)(names.size()) ? rMax : 0.5 * (rodRin[i + 1] + rodRout[i + 1]));
0142 vector<double> pgonZ;
0143 pgonZ.emplace_back(-0.5 * cableT);
0144 pgonZ.emplace_back(cableT * (rin / rMax - 0.5));
0145 pgonZ.emplace_back(0.5 * cableT);
0146 vector<double> pgonRmin;
0147 pgonRmin.emplace_back(rin);
0148 pgonRmin.emplace_back(rin);
0149 pgonRmin.emplace_back(rin);
0150 vector<double> pgonRmax;
0151 pgonRmax.emplace_back(rout);
0152 pgonRmax.emplace_back(rout);
0153 pgonRmax.emplace_back(rout);
0154 solid = ns.addSolid(ns.prepend(name), Polycone(0, 2_pi, pgonRmin, pgonRmax, pgonZ));
0155 edm::LogVerbatim("TOBGeom") << solid.name() << " Polycone made of " << cableM[i] << " from 0 to "
0156 << convertRadToDeg(2_pi) << " and with " << pgonZ.size() << " sections";
0157 for (int ii = 0; ii < (int)(pgonZ.size()); ii++)
0158 edm::LogVerbatim("TOBGeom") << "\t[" << ii << "]\tZ = " << pgonZ[ii] << "\tRmin = " << pgonRmin[ii]
0159 << "\tRmax = " << pgonRmax[ii];
0160 Volume cableLogic = ns.addVolume(Volume(solid.name(), solid, ns.material(cableM[i])));
0161 Position r3(0, 0, (diskDz - (i + 0.5) * cableT));
0162 disk.placeVolume(cableLogic, i + 1, r3);
0163 edm::LogVerbatim("TOBGeom") << solid.name() << " number " << i + 1 << " positioned in " << disk.name() << " at "
0164 << r3 << " with no rotation";
0165 }
0166 edm::LogVerbatim("TOBGeom") << "<<== End of DDTOBRadCableAlgo construction ...";
0167 return 1;
0168 }
0169
0170
0171 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBRadCableAlgo, algorithm)