Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-01 02:45:11

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& /* description */, 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");  // Name of the central piece
0014 
0015   double shift = args.dble("Shift");                    // Shift in z
0016   vector<string> sideRod = args.vecStr("SideRodName");  // Name of the Side Rod
0017   vector<double> sideRodX = args.vecDble("SideRodX");   // x-positions
0018   vector<double> sideRodY = args.vecDble("SideRodY");   // y-positions
0019   vector<double> sideRodZ = args.vecDble("SideRodZ");   // z-positions
0020   string endRod1 = args.str("EndRod1Name");             // Name of the End Rod of type 1
0021   vector<double> endRod1Y = args.vecDble("EndRod1Y");   // y-positions
0022   vector<double> endRod1Z = args.vecDble("EndRod1Z");   // z-positions
0023   string endRod2 = args.str("EndRod2Name");             // Name of the End Rod of type 2
0024   double endRod2Y = args.dble("EndRod2Y");              // y-position
0025   double endRod2Z = args.dble("EndRod2Z");              // z-position
0026 
0027   string cable = args.str("CableName");  // Name of the Mother cable
0028   double cableZ = args.dble("CableZ");   // z-position
0029 
0030   string clamp = args.str("ClampName");                  // Name of the clamp
0031   vector<double> clampX = args.vecDble("ClampX");        // x-positions
0032   vector<double> clampZ = args.vecDble("ClampZ");        // z-positions
0033   string sideCool = args.str("SideCoolName");            // Name of the Side Cooling Tube
0034   vector<double> sideCoolX = args.vecDble("SideCoolX");  // x-positions
0035   vector<double> sideCoolY =
0036       args.vecDble("SideCoolY");  // y-positions to avoid overlap with the module (be at the same level of EndCool)
0037   vector<double> sideCoolZ = args.vecDble("SideCoolZ");  // z-positions
0038   string endCool = args.str("EndCoolName");              // Name of the End Cooling Tube
0039   string endCoolRot = args.str("EndCoolRot");            // Rotation matrix name for end cool
0040   double endCoolY = args.dble("EndCoolY");               // y-position to avoid overlap with the module
0041   double endCoolZ = args.dble("EndCoolZ");               // z-position
0042 
0043   string optFibre = args.str("OptFibreName");            // Name of the Optical Fibre
0044   vector<double> optFibreX = args.vecDble("optFibreX");  // x-positions
0045   vector<double> optFibreZ = args.vecDble("optFibreZ");  // z-positions
0046 
0047   string sideClamp1 = args.str("SideClamp1Name");              // Name of the side clamp of type 1
0048   vector<double> sideClampX = args.vecDble("SideClampX");      // x-positions
0049   vector<double> sideClamp1DZ = args.vecDble("SideClamp1DZ");  // Delta(z)-positions
0050   string sideClamp2 = args.str("SideClamp2Name");              // Name of the side clamp of type 2
0051   vector<double> sideClamp2DZ = args.vecDble("SideClamp2DZ");  // Delta(z)-positions
0052 
0053   string module = args.str("ModuleName");               // Name of the detector modules
0054   vector<string> moduleRot = args.vecStr("ModuleRot");  // Rotation matrix name for module
0055   vector<double> moduleY = args.vecDble("ModuleY");     // y-positions
0056   vector<double> moduleZ = args.vecDble("ModuleZ");     // z-positions
0057   vector<string> connect = args.vecStr("ICCName");
0058   ;                                                // Name of the connectors
0059   vector<double> connectY = args.vecDble("ICCY");  // y-positions
0060   vector<double> connectZ = args.vecDble("ICCZ");  // z-positions
0061 
0062   string aohName = args.str("AOHName");                  // AOH name
0063   vector<double> aohCopies = args.vecDble("AOHCopies");  // AOH copies to be positioned on each ICC
0064   vector<double> aohX = args.vecDble("AOHx");            // AOH translation with respect small-ICC center (X)
0065   vector<double> aohY = args.vecDble("AOHy");            // AOH translation with respect small-ICC center (Y)
0066   vector<double> aohZ = args.vecDble("AOHz");            // AOH translation with respect small-ICC center (Z)
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   // Side Rods
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   // Clamps
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   // Side Cooling tubes
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   // Optical Fibres
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   // Side Clamps
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   // End Rods
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   // End cooling tubes
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   //Mother cable
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   //Modules
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   //Connectors (ICC, CCUM, ...)
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   //AOH (only on ICCs)
0227   int copyNumber = 0;
0228   for (int i = 0; i < (int)(aohCopies.size()); i++) {
0229     if (aohCopies[i] != 0) {
0230       // first copy with (+aohX,+aohZ) translation
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       // if two copies add a copy with (-aohX,-aohZ) translation
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       // if four copies add 3 copies with (-aohX,+aohZ) (-aohX,-aohZ) (+aohX,+aohZ) and translations
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);  // copyNumber
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);  // copyNumber
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);  // copyNumber
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 // first argument is the type from the xml file
0277 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBRodAlgo, algorithm)