Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-24 09:25:08

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 //
0014 // Specialized generic detector constructor
0015 // 
0016 //==========================================================================
0017 
0018 // Framework include files
0019 #include "DD4hep/DetFactoryHelper.h"
0020 #include "DDCMS/DDCMSPlugins.h"
0021 
0022 using namespace std;
0023 using namespace dd4hep;
0024 using namespace dd4hep::cms;
0025 
0026 static long algorithm(Detector& /* description */,
0027                       ParsingContext& ctxt,
0028                       xml_h e,
0029                       SensitiveDetector& /* sens */)
0030 {
0031   Namespace      ns(ctxt, e, true);
0032   AlgoArguments  args(ctxt, e);
0033   string         parentName    = args.parentName();
0034   string         central       = args.str("CentralName");        // Name of the central piece
0035                           
0036   double         shift         = args.dble("Shift");          // Shift in z
0037   vector<string> sideRod       = args.vecStr("SideRodName");        // Name of the Side Rod
0038   vector<double> sideRodX      = args.vecDble("SideRodX");       // x-positions
0039   vector<double> sideRodY      = args.vecDble("SideRodY");       // y-positions
0040   vector<double> sideRodZ      = args.vecDble("SideRodZ");       // z-positions
0041   string         endRod1       = args.str("EndRod1Name");        // Name of the End Rod of type 1
0042   vector<double> endRod1Y      = args.vecDble("EndRod1Y");       // y-positions
0043   vector<double> endRod1Z      = args.vecDble("EndRod1Z");       // z-positions
0044   string         endRod2       = args.str("EndRod2Name");        // Name of the End Rod of type 2
0045   double         endRod2Y      = args.dble("EndRod2Y");          // y-position
0046   double         endRod2Z      = args.dble("EndRod2Z");          // z-position
0047                           
0048   string         cable         = args.str("CableName");          // Name of the Mother cable
0049   double         cableZ        = args.dble("CableZ");            // z-position
0050                           
0051   string         clamp         = args.str("ClampName");          // Name of the clamp
0052   vector<double> clampX        = args.vecDble("ClampX");         // x-positions
0053   vector<double> clampZ        = args.vecDble("ClampZ");         // z-positions
0054   string         sideCool      = args.str("SideCoolName");       // Name of the Side Cooling Tube
0055   vector<double> sideCoolX     = args.vecDble("SideCoolX");      // x-positions
0056   vector<double> sideCoolY     = args.vecDble("SideCoolY");      // y-positions to avoid overlap with the module (be at the same level of EndCool)
0057   vector<double> sideCoolZ     = args.vecDble("SideCoolZ");      // z-positions
0058   string         endCool       = args.str("EndCoolName");        // Name of the End Cooling Tube
0059   string         endCoolRot    = args.str("EndCoolRot");         // Rotation matrix name for end cool
0060   double         endCoolY      = args.dble("EndCoolY");          // y-position to avoid overlap with the module
0061   double         endCoolZ      = args.dble("EndCoolZ");          // z-position
0062                           
0063   string         optFibre      = args.str("OptFibreName");       // Name of the Optical Fibre
0064   vector<double> optFibreX     = args.vecDble("optFibreX");      // x-positions
0065   vector<double> optFibreZ     = args.vecDble("optFibreZ");      // z-positions
0066                           
0067   string         sideClamp1    = args.str("SideClamp1Name");     // Name of the side clamp of type 1
0068   vector<double> sideClampX    = args.vecDble("SideClampX");     // x-positions
0069   vector<double> sideClamp1DZ  = args.vecDble("SideClamp1DZ");   // Delta(z)-positions
0070   string         sideClamp2    = args.str("SideClamp2Name");     // Name of the side clamp of type 2
0071   vector<double> sideClamp2DZ  = args.vecDble("SideClamp2DZ");   // Delta(z)-positions
0072                           
0073   string         module        = args.str("ModuleName");         // Name of the detector modules
0074   vector<string> moduleRot     = args.vecStr("ModuleRot");      // Rotation matrix name for module
0075   vector<double> moduleY       = args.vecDble("ModuleY");        // y-positions
0076   vector<double> moduleZ       = args.vecDble("ModuleZ");        // z-positions
0077   vector<string> connect       = args.vecStr("ICCName");;        // Name of the connectors
0078   vector<double> connectY      = args.vecDble("ICCY");       // y-positions
0079   vector<double> connectZ      = args.vecDble("ICCZ");       // z-positions
0080                           
0081   string         aohName       = args.str("AOHName");        // AOH name
0082   vector<double> aohCopies     = args.vecDble("AOHCopies");      // AOH copies to be positioned on each ICC
0083   vector<double> aohX          = args.vecDble("AOHx");           // AOH translation with respect small-ICC center (X)
0084   vector<double> aohY          = args.vecDble("AOHy");           // AOH translation with respect small-ICC center (Y)
0085   vector<double> aohZ          = args.vecDble("AOHz");           // AOH translation with respect small-ICC center (Z)
0086 
0087   LogDebug("TOBGeom") << "Parent " << parentName << " Central " << central << " NameSpace "
0088                       << ns.name << "\tShift " << shift;
0089   for (int i=0; i<(int)(sideRod.size()); i++) {
0090     LogDebug("TOBGeom") << sideRod[i] << " to be positioned " << sideRodX.size() 
0091                         <<" times at y = " << sideRodY[i] << " z = " << sideRodZ[i] << " and x";
0092     for (double j : sideRodX)
0093       LogDebug("TOBGeom") << "\tsideRodX[" << i << "] = " << j;
0094   }
0095   LogDebug("TOBGeom") << endRod1 << " to be "
0096                       << "positioned " << endRod1Y.size() << " times at";
0097   for (int i=0; i<(int)(endRod1Y.size()); i++)
0098     LogDebug("TOBGeom") << "\t[" << i << "]\ty = " << endRod1Y[i] 
0099                         << "\tz = " << endRod1Z[i];
0100   LogDebug("TOBGeom") << endRod2 << " to be "
0101                       << "positioned at y = " << endRod2Y << " z = " 
0102                       << endRod2Z;
0103   LogDebug("TOBGeom") << cable << " to be "
0104                       << "positioned at z = " << cableZ;
0105   LogDebug("TOBGeom") << clamp << " to be "
0106                       << "positioned " << clampX.size() << " times at";
0107   for (int i=0; i<(int)(clampX.size()); i++)
0108     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << clampX[i] << "\tz = "
0109                         << clampZ[i];
0110   LogDebug("TOBGeom") << sideCool << " to be "
0111                       << "positioned " << sideCoolX.size() << " times at";
0112   for (int i=0; i<(int)(sideCoolX.size()); i++)
0113     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideCoolX[i]
0114                         << "\ty = " << sideCoolY[i]
0115                         << "\tz = " << sideCoolZ[i];
0116   LogDebug("TOBGeom") << endCool <<" to be "
0117                       << "positioned with " << endCoolRot << " rotation at"
0118                       << " y = " << endCoolY
0119                       << " z = " << endCoolZ;
0120   LogDebug("TOBGeom") << optFibre << " to be "
0121                       << "positioned " << optFibreX.size() << " times at";
0122   for (int i=0; i<(int)(optFibreX.size()); i++)
0123     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << optFibreX[i] 
0124                         << "\tz = " << optFibreZ[i];
0125   LogDebug("TOBGeom") << sideClamp1 << " to be "
0126                       << "positioned " << sideClampX.size() << " times at";
0127   for (int i=0; i<(int)(sideClampX.size()); i++)
0128     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] 
0129                         << "\tdz = " << sideClamp1DZ[i];
0130   LogDebug("TOBGeom") << sideClamp2 << " to be "
0131                       << "positioned " << sideClampX.size() << " times at";
0132   for (int i=0; i<(int)(sideClampX.size()); i++)
0133     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i]
0134                         << "\tdz = " << sideClamp2DZ[i];
0135   LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << module <<" positioned "
0136                       << moduleRot.size() << " times";
0137   for (int i=0; i<(int)(moduleRot.size()); i++) 
0138     LogDebug("TOBGeom") << "\tRotation " << moduleRot[i] << "\ty = " 
0139                         << moduleY[i] << "\tz = " << moduleZ[i];
0140   LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << connect.size() 
0141                       << " ICC positioned with no rotation";
0142   for (int i=0; i<(int)(connect.size()); i++)
0143     LogDebug("TOBGeom") << "\t" << connect[i] << "\ty = " << connectY[i] 
0144                         << "\tz = " << connectZ[i];
0145   LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << aohName <<" AOH will be positioned on ICC's";
0146   for (int i=0; i<(int)(aohCopies.size()); i++)
0147     LogDebug("TOBGeom") << " copies " << aohCopies[i] << "\tx = " << aohX[i]
0148                         << "\ty = " << aohY[i] << "\tz = " << aohZ[i];
0149 
0150   string centName = central;
0151   string child;
0152   string rodName = parentName;
0153   Volume rod = ns.volume(rodName);
0154 
0155   // Side Rods
0156   for (int i=0; i<(int)(sideRod.size()); i++) {
0157     for (int j=0; j<(int)(sideRodX.size()); j++) {
0158       Position r(sideRodX[j], sideRodY[i], sideRodZ[i]);
0159       child = sideRod[i];
0160       rod.placeVolume(ns.volume(child), j+1, r);
0161       LogDebug("TOBGeom") << child << " number " << j+1 << " positioned in "
0162                           << rodName << " at " << r << " with no rotation";
0163     }
0164   }
0165   // Clamps
0166   for (int i=0; i<(int)(clampX.size()); i++) {
0167     Position r(clampX[i], 0, shift+clampZ[i]);
0168     child = clamp;
0169     rod.placeVolume(ns.volume(child), i+1, r);
0170     LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in "
0171                         << rodName << " at " << r << " with no rotation";
0172   }
0173   // Side Cooling tubes
0174   for (int i=0; i<(int)(sideCoolX.size()); i++) {
0175     Position r(sideCoolX[i], sideCoolY[i], shift+sideCoolZ[i]);
0176     child = sideCool;
0177     rod.placeVolume(ns.volume(child), i+1, r);
0178     LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in "
0179                         << rodName << " at " << r << " with no rotation";
0180   }
0181   // Optical Fibres
0182   for (int i=0; i<(int)(optFibreX.size()); i++) {
0183     Position r(optFibreX[i], 0, shift+optFibreZ[i]);
0184     child = optFibre;
0185     rod.placeVolume(ns.volume(child), i+1, r);
0186     LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in "
0187                         << rodName << " at " << r << " with no rotation";
0188   }
0189 
0190   // Side Clamps
0191   for (int i=0; i<(int)(sideClamp1DZ.size()); i++) {
0192     int j = i/2;
0193     Position r(sideClampX[i],moduleY[j],shift+moduleZ[j]+sideClamp1DZ[i]);
0194     child = sideClamp1;
0195     rod.placeVolume(ns.volume(child), i+1, r);
0196     LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " << rodName << " at "
0197                         << r << " with no rotation";
0198   }
0199   for (int i=0; i<(int)(sideClamp2DZ.size()); i++) {
0200     int j = i/2;
0201     Position r(sideClampX[i],moduleY[j],shift+moduleZ[j]+sideClamp2DZ[i]);
0202     child = sideClamp2;
0203     rod.placeVolume(ns.volume(child), i+1, r);
0204     LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " << rodName << " at "
0205                         << r << " with no rotation";
0206   }
0207 
0208   Volume cent = ns.volume(centName);
0209   // End Rods
0210   for (int i=0; i<(int)(endRod1Y.size()); i++) {
0211     Position r(0, endRod1Y[i], shift+endRod1Z[i]);
0212     child = endRod1;
0213     cent.placeVolume(ns.volume(child), i+1, r);
0214     LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " << centName << " at "
0215                         << r << " with no rotation";
0216   }
0217   Position r1(0, endRod2Y, shift+endRod2Z);
0218   child = endRod2;
0219   cent.placeVolume(ns.volume(child), 1, r1);
0220   LogDebug("TOBGeom") << child << " number 1 " << "positioned in " << centName << " at " << r1 
0221                       << " with no rotation";
0222 
0223   // End cooling tubes
0224   Position r2(0, endCoolY, shift+endCoolZ);
0225   Rotation3D rot2 = ns.rotation(endCoolRot);
0226   child = endCool;
0227   cent.placeVolume(ns.volume(child), 1, Transform3D(rot2,r2));
0228   LogDebug("TOBGeom") << child << " number 1 " << "positioned in " << centName << " at " << r2 
0229                       << " with " << rot2;
0230 
0231   //Mother cable
0232   Position r3(0, 0, shift+cableZ);
0233   child = cable;
0234   cent.placeVolume(ns.volume(child), 1, r3);
0235   LogDebug("TOBGeom") << child << " number 1 " << "positioned in " << centName << " at " << r3
0236                       << " with no rotation";
0237 
0238   //Modules
0239   for (int i=0; i<(int)(moduleRot.size()); i++) {
0240     Position r(0, moduleY[i], shift+moduleZ[i]);
0241     Rotation3D rot = ns.rotation(moduleRot[i]);
0242     child = module;
0243     cent.placeVolume(ns.volume(child), i+1, Transform3D(rot,r));
0244     LogDebug("TOBGeom") << child << " number " 
0245                         << i+1 << " positioned in " << centName << " at "
0246                         << r << " with " << rot;
0247   }
0248 
0249   //Connectors (ICC, CCUM, ...)
0250   for (int i=0; i<(int)(connect.size()); i++) {
0251     Position r(0, connectY[i], shift+connectZ[i]);
0252     child = connect[i];
0253     cent.placeVolume(ns.volume(child), i+1, r);
0254     LogDebug("TOBGeom") << child << " number " << i+1 << " positioned in " << centName << " at "
0255                         << r << " with no rotation";
0256   }
0257 
0258   //AOH (only on ICCs)
0259   int copyNumber = 0;
0260   for (int i=0; i<(int)(aohCopies.size()); i++) {
0261     if(aohCopies[i] != 0) {
0262       // first copy with (+aohX,+aohZ) translation
0263       copyNumber++;
0264       Position r(aohX[i] + 0, aohY[i] + connectY[i], aohZ[i] + shift+connectZ[i]);
0265       child = aohName;
0266       cent.placeVolume(ns.volume(child), copyNumber, r);
0267       LogDebug("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at "
0268                           << r << " with no rotation";
0269       // if two copies add a copy with (-aohX,-aohZ) translation
0270       if(aohCopies[i] == 2) {
0271         copyNumber++;
0272         r = Position(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]);
0273         child = aohName;
0274         cent.placeVolume(ns.volume(child), copyNumber, r);
0275         LogDebug("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at "
0276                             << r << " with no rotation";
0277       }
0278       // if four copies add 3 copies with (-aohX,+aohZ) (-aohX,-aohZ) (+aohX,+aohZ) and translations
0279       if(aohCopies[i] == 4) {
0280         Position rr;
0281         for (unsigned int j = 1; j<4; j++ ) {
0282           copyNumber++;
0283           child = aohName;
0284           switch(j) {
0285           case 1:
0286             rr = Position(-aohX[i] + 0, aohY[i] + connectY[i], +aohZ[i] + shift+connectZ[i]);
0287             cent.placeVolume(ns.volume(child), copyNumber, rr); // copyNumber
0288             break;
0289           case 2:
0290             rr = Position(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]);
0291             cent.placeVolume(ns.volume(child), copyNumber, rr); // copyNumber
0292             break;
0293           case 3:
0294             rr = Position(+aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]);
0295             cent.placeVolume(ns.volume(child), copyNumber, rr); // copyNumber
0296             break;
0297           }
0298           LogDebug("TOBGeom") << child << " number " << copyNumber
0299                               << " positioned in " << centName << " at "
0300                               << rr << " with no rotation";
0301         }
0302       }
0303     }
0304   }  
0305   LogDebug("TOBGeom") << "<<== End of DDTOBRodAlgo construction ...";
0306   return 1;
0307 }
0308 
0309 // first argument is the type from the xml file
0310 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBRodAlgo,algorithm)