File indexing completed on 2024-04-06 12:15:22
0001 #include "DD4hep/DetFactoryHelper.h"
0002 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004
0005 using namespace std;
0006 using namespace dd4hep;
0007 using namespace cms;
0008
0009 static long algorithm(Detector& , cms::DDParsingContext& ctxt, xml_h e) {
0010 cms::DDNamespace ns(ctxt, e, true);
0011 DDAlgoArguments args(ctxt, e);
0012 string parentName = args.parentName();
0013 string central = args.str("CentralName");
0014
0015 double shift = args.dble("Shift");
0016 vector<string> sideRod = args.vecStr("SideRodName");
0017 vector<double> sideRodX = args.vecDble("SideRodX");
0018 vector<double> sideRodY = args.vecDble("SideRodY");
0019 vector<double> sideRodZ = args.vecDble("SideRodZ");
0020 string endRod1 = args.str("EndRod1Name");
0021 vector<double> endRod1Y = args.vecDble("EndRod1Y");
0022 vector<double> endRod1Z = args.vecDble("EndRod1Z");
0023 string endRod2 = args.str("EndRod2Name");
0024 double endRod2Y = args.dble("EndRod2Y");
0025 double endRod2Z = args.dble("EndRod2Z");
0026
0027 string cable = args.str("CableName");
0028 double cableZ = args.dble("CableZ");
0029
0030 string clamp = args.str("ClampName");
0031 vector<double> clampX = args.vecDble("ClampX");
0032 vector<double> clampZ = args.vecDble("ClampZ");
0033 string sideCool = args.str("SideCoolName");
0034 vector<double> sideCoolX = args.vecDble("SideCoolX");
0035 vector<double> sideCoolY =
0036 args.vecDble("SideCoolY");
0037 vector<double> sideCoolZ = args.vecDble("SideCoolZ");
0038 string endCool = args.str("EndCoolName");
0039 string endCoolRot = args.str("EndCoolRot");
0040 double endCoolY = args.dble("EndCoolY");
0041 double endCoolZ = args.dble("EndCoolZ");
0042
0043 string optFibre = args.str("OptFibreName");
0044 vector<double> optFibreX = args.vecDble("optFibreX");
0045 vector<double> optFibreZ = args.vecDble("optFibreZ");
0046
0047 string sideClamp1 = args.str("SideClamp1Name");
0048 vector<double> sideClampX = args.vecDble("SideClampX");
0049 vector<double> sideClamp1DZ = args.vecDble("SideClamp1DZ");
0050 string sideClamp2 = args.str("SideClamp2Name");
0051 vector<double> sideClamp2DZ = args.vecDble("SideClamp2DZ");
0052
0053 string module = args.str("ModuleName");
0054 vector<string> moduleRot = args.vecStr("ModuleRot");
0055 vector<double> moduleY = args.vecDble("ModuleY");
0056 vector<double> moduleZ = args.vecDble("ModuleZ");
0057 vector<string> connect = args.vecStr("ICCName");
0058 ;
0059 vector<double> connectY = args.vecDble("ICCY");
0060 vector<double> connectZ = args.vecDble("ICCZ");
0061
0062 string aohName = args.str("AOHName");
0063 vector<double> aohCopies = args.vecDble("AOHCopies");
0064 vector<double> aohX = args.vecDble("AOHx");
0065 vector<double> aohY = args.vecDble("AOHy");
0066 vector<double> aohZ = args.vecDble("AOHz");
0067
0068 edm::LogVerbatim("TOBGeom") << "Parent " << parentName << " Central " << central << " NameSpace " << ns.name()
0069 << "\tShift " << shift;
0070 for (int i = 0; i < (int)(sideRod.size()); i++) {
0071 edm::LogVerbatim("TOBGeom") << sideRod[i] << " to be positioned " << sideRodX.size()
0072 << " times at y = " << sideRodY[i] << " z = " << sideRodZ[i] << " and x";
0073 for (double j : sideRodX)
0074 edm::LogVerbatim("TOBGeom") << "\tsideRodX[" << i << "] = " << j;
0075 }
0076 edm::LogVerbatim("TOBGeom") << endRod1 << " to be "
0077 << "positioned " << endRod1Y.size() << " times at";
0078 for (int i = 0; i < (int)(endRod1Y.size()); i++)
0079 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\ty = " << endRod1Y[i] << "\tz = " << endRod1Z[i];
0080 edm::LogVerbatim("TOBGeom") << endRod2 << " to be "
0081 << "positioned at y = " << endRod2Y << " z = " << endRod2Z;
0082 edm::LogVerbatim("TOBGeom") << cable << " to be "
0083 << "positioned at z = " << cableZ;
0084 edm::LogVerbatim("TOBGeom") << clamp << " to be "
0085 << "positioned " << clampX.size() << " times at";
0086 for (int i = 0; i < (int)(clampX.size()); i++)
0087 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tx = " << clampX[i] << "\tz = " << clampZ[i];
0088 edm::LogVerbatim("TOBGeom") << sideCool << " to be "
0089 << "positioned " << sideCoolX.size() << " times at";
0090 for (int i = 0; i < (int)(sideCoolX.size()); i++)
0091 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tx = " << sideCoolX[i] << "\ty = " << sideCoolY[i]
0092 << "\tz = " << sideCoolZ[i];
0093 edm::LogVerbatim("TOBGeom") << endCool << " to be "
0094 << "positioned with " << endCoolRot << " rotation at"
0095 << " y = " << endCoolY << " z = " << endCoolZ;
0096 edm::LogVerbatim("TOBGeom") << optFibre << " to be "
0097 << "positioned " << optFibreX.size() << " times at";
0098 for (int i = 0; i < (int)(optFibreX.size()); i++)
0099 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tx = " << optFibreX[i] << "\tz = " << optFibreZ[i];
0100 edm::LogVerbatim("TOBGeom") << sideClamp1 << " to be "
0101 << "positioned " << sideClampX.size() << " times at";
0102 for (int i = 0; i < (int)(sideClampX.size()); i++)
0103 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] << "\tdz = " << sideClamp1DZ[i];
0104 edm::LogVerbatim("TOBGeom") << sideClamp2 << " to be "
0105 << "positioned " << sideClampX.size() << " times at";
0106 for (int i = 0; i < (int)(sideClampX.size()); i++)
0107 edm::LogVerbatim("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] << "\tdz = " << sideClamp2DZ[i];
0108 edm::LogVerbatim("TOBGeom") << "DDTOBRodAlgo debug:\t" << module << " positioned " << moduleRot.size() << " times";
0109 for (int i = 0; i < (int)(moduleRot.size()); i++)
0110 edm::LogVerbatim("TOBGeom") << "\tRotation " << moduleRot[i] << "\ty = " << moduleY[i] << "\tz = " << moduleZ[i];
0111 edm::LogVerbatim("TOBGeom") << "DDTOBRodAlgo debug:\t" << connect.size() << " ICC positioned with no rotation";
0112 for (int i = 0; i < (int)(connect.size()); i++)
0113 edm::LogVerbatim("TOBGeom") << "\t" << connect[i] << "\ty = " << connectY[i] << "\tz = " << connectZ[i];
0114 edm::LogVerbatim("TOBGeom") << "DDTOBRodAlgo debug:\t" << aohName << " AOH will be positioned on ICC's";
0115 for (int i = 0; i < (int)(aohCopies.size()); i++)
0116 edm::LogVerbatim("TOBGeom") << " copies " << aohCopies[i] << "\tx = " << aohX[i] << "\ty = " << aohY[i]
0117 << "\tz = " << aohZ[i];
0118
0119 const string& centName = central;
0120 string child;
0121 const string& rodName = parentName;
0122 Volume rod = ns.volume(rodName);
0123
0124
0125 for (int i = 0; i < (int)(sideRod.size()); i++) {
0126 for (int j = 0; j < (int)(sideRodX.size()); j++) {
0127 Position r(sideRodX[j], sideRodY[i], sideRodZ[i]);
0128 child = sideRod[i];
0129 rod.placeVolume(ns.volume(child), j + 1, r);
0130 edm::LogVerbatim("TOBGeom") << child << " number " << j + 1 << " positioned in " << rodName << " at " << r
0131 << " with no rotation";
0132 }
0133 }
0134
0135 for (int i = 0; i < (int)(clampX.size()); i++) {
0136 Position r(clampX[i], 0, shift + clampZ[i]);
0137 child = clamp;
0138 rod.placeVolume(ns.volume(child), i + 1, r);
0139 edm::LogVerbatim("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
0140 << " with no rotation";
0141 }
0142
0143 for (int i = 0; i < (int)(sideCoolX.size()); i++) {
0144 Position r(sideCoolX[i], sideCoolY[i], shift + sideCoolZ[i]);
0145 child = sideCool;
0146 rod.placeVolume(ns.volume(child), i + 1, r);
0147 edm::LogVerbatim("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
0148 << " with no rotation";
0149 }
0150
0151 for (int i = 0; i < (int)(optFibreX.size()); i++) {
0152 Position r(optFibreX[i], 0, shift + optFibreZ[i]);
0153 child = optFibre;
0154 rod.placeVolume(ns.volume(child), i + 1, r);
0155 edm::LogVerbatim("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
0156 << " with no rotation";
0157 }
0158
0159
0160 for (int i = 0; i < (int)(sideClamp1DZ.size()); i++) {
0161 int j = i / 2;
0162 Position r(sideClampX[i], moduleY[j], shift + moduleZ[j] + sideClamp1DZ[i]);
0163 child = sideClamp1;
0164 rod.placeVolume(ns.volume(child), i + 1, r);
0165 edm::LogVerbatim("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
0166 << " with no rotation";
0167 }
0168 for (int i = 0; i < (int)(sideClamp2DZ.size()); i++) {
0169 int j = i / 2;
0170 Position r(sideClampX[i], moduleY[j], shift + moduleZ[j] + sideClamp2DZ[i]);
0171 child = sideClamp2;
0172 rod.placeVolume(ns.volume(child), i + 1, r);
0173 edm::LogVerbatim("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
0174 << " with no rotation";
0175 }
0176
0177 Volume cent = ns.volume(centName);
0178
0179 for (int i = 0; i < (int)(endRod1Y.size()); i++) {
0180 Position r(0, endRod1Y[i], shift + endRod1Z[i]);
0181 child = endRod1;
0182 cent.placeVolume(ns.volume(child), i + 1, r);
0183 edm::LogVerbatim("TOBGeom") << child << " number " << i + 1 << " positioned in " << centName << " at " << r
0184 << " with no rotation";
0185 }
0186 Position r1(0, endRod2Y, shift + endRod2Z);
0187 child = endRod2;
0188 cent.placeVolume(ns.volume(child), 1, r1);
0189 edm::LogVerbatim("TOBGeom") << child << " number 1 "
0190 << "positioned in " << centName << " at " << r1 << " with no rotation";
0191
0192
0193 Position r2(0, endCoolY, shift + endCoolZ);
0194 const Rotation3D& rot2 = ns.rotation(endCoolRot);
0195 child = endCool;
0196 cent.placeVolume(ns.volume(child), 1, Transform3D(rot2, r2));
0197 edm::LogVerbatim("TOBGeom") << child << " number 1 "
0198 << "positioned in " << centName << " at " << r2 << " with " << rot2;
0199
0200
0201 Position r3(0, 0, shift + cableZ);
0202 child = cable;
0203 cent.placeVolume(ns.volume(child), 1, r3);
0204 edm::LogVerbatim("TOBGeom") << child << " number 1 "
0205 << "positioned in " << centName << " at " << r3 << " with no rotation";
0206
0207
0208 for (int i = 0; i < (int)(moduleRot.size()); i++) {
0209 Position r(0, moduleY[i], shift + moduleZ[i]);
0210 const Rotation3D& rot = ns.rotation(moduleRot[i]);
0211 child = module;
0212 cent.placeVolume(ns.volume(child), i + 1, Transform3D(rot, r));
0213 edm::LogVerbatim("TOBGeom") << child << " number " << i + 1 << " positioned in " << centName << " at " << r
0214 << " with " << rot;
0215 }
0216
0217
0218 for (int i = 0; i < (int)(connect.size()); i++) {
0219 Position r(0, connectY[i], shift + connectZ[i]);
0220 child = connect[i];
0221 cent.placeVolume(ns.volume(child), i + 1, r);
0222 edm::LogVerbatim("TOBGeom") << child << " number " << i + 1 << " positioned in " << centName << " at " << r
0223 << " with no rotation";
0224 }
0225
0226
0227 int copyNumber = 0;
0228 for (int i = 0; i < (int)(aohCopies.size()); i++) {
0229 if (aohCopies[i] != 0) {
0230
0231 copyNumber++;
0232 Position r(aohX[i] + 0, aohY[i] + connectY[i], aohZ[i] + shift + connectZ[i]);
0233 child = aohName;
0234 cent.placeVolume(ns.volume(child), copyNumber, r);
0235 edm::LogVerbatim("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at " << r
0236 << " with no rotation";
0237
0238 if (aohCopies[i] == 2) {
0239 copyNumber++;
0240 r = Position(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift + connectZ[i]);
0241 child = aohName;
0242 cent.placeVolume(ns.volume(child), copyNumber, r);
0243 edm::LogVerbatim("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at " << r
0244 << " with no rotation";
0245 }
0246
0247 if (aohCopies[i] == 4) {
0248 Position rr;
0249 for (unsigned int j = 1; j < 4; j++) {
0250 copyNumber++;
0251 child = aohName;
0252 switch (j) {
0253 case 1:
0254 rr = Position(-aohX[i] + 0, aohY[i] + connectY[i], +aohZ[i] + shift + connectZ[i]);
0255 cent.placeVolume(ns.volume(child), copyNumber, rr);
0256 break;
0257 case 2:
0258 rr = Position(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift + connectZ[i]);
0259 cent.placeVolume(ns.volume(child), copyNumber, rr);
0260 break;
0261 case 3:
0262 rr = Position(+aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift + connectZ[i]);
0263 cent.placeVolume(ns.volume(child), copyNumber, rr);
0264 break;
0265 }
0266 edm::LogVerbatim("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at "
0267 << rr << " with no rotation";
0268 }
0269 }
0270 }
0271 }
0272 edm::LogVerbatim("TOBGeom") << "<<== End of DDTOBRodAlgo construction ...";
0273 return 1;
0274 }
0275
0276
0277 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBRodAlgo, algorithm)