CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Geometry/TrackerCommonData/plugins/DDTOBRodAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTOBRodAlgo.cc
00003 // Description: Positioning constituents of a TOB rod
00005 
00006 #include <cmath>
00007 #include <algorithm>
00008 
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00011 #include "DetectorDescription/Core/interface/DDSplit.h"
00012 #include "Geometry/TrackerCommonData/plugins/DDTOBRodAlgo.h"
00013 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00014 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00015 
00016 
00017 DDTOBRodAlgo::DDTOBRodAlgo():
00018   sideRod(0), sideRodX(0), sideRodY(0), sideRodZ(0), endRod1Y(0), endRod1Z(0),
00019   clampX(0), clampZ(0), sideCoolX(0), sideCoolY(0), sideCoolZ(0),
00020   endCoolY(0), endCoolZ(0),
00021   optFibreX(0),optFibreZ(0),
00022   sideClampX(0), sideClamp1DZ(0), sideClamp2DZ(0), moduleRot(0), moduleY(0),
00023   moduleZ(0), connect(0), connectY(0), connectZ(0),
00024   aohCopies(0), aohX(0), aohY(0), aohZ(0) {
00025   LogDebug("TOBGeom") << "DDTOBRodAlgo info: Creating an instance";
00026 }
00027 
00028 DDTOBRodAlgo::~DDTOBRodAlgo() {}
00029 
00030 void DDTOBRodAlgo::initialize(const DDNumericArguments & nArgs,
00031                               const DDVectorArguments & vArgs,
00032                               const DDMapArguments & ,
00033                               const DDStringArguments & sArgs,
00034                               const DDStringVectorArguments & vsArgs) {
00035 
00036   central      = sArgs["CentralName"];
00037   shift        = nArgs["Shift"];
00038   idNameSpace  = DDCurrentNamespace::ns();
00039   DDName parentName = parent().name();
00040   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: Parent " << parentName 
00041                       << " Central " << central << " NameSpace "
00042                       << idNameSpace << "\tShift " << shift;
00043 
00044   sideRod      = vsArgs["SideRodName"];     
00045   sideRodX     = vArgs["SideRodX"];    
00046   sideRodY     = vArgs["SideRodY"];
00047   sideRodZ     = vArgs["SideRodZ"];
00048   for (int i=0; i<(int)(sideRod.size()); i++) {
00049     LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideRod[i] 
00050                         << " to be positioned " << sideRodX.size() 
00051                         <<" times at y = " << sideRodY[i] << " z = " 
00052                         << sideRodZ[i] << " and x";
00053     for (int j=0; j<(int)(sideRodX.size()); j++)
00054       LogDebug("TOBGeom") << "\tsideRodX[" << i << "] = " << sideRodX[j];
00055   }
00056 
00057   endRod1      = sArgs["EndRod1Name"];     
00058   endRod1Y     = vArgs["EndRod1Y"];    
00059   endRod1Z     = vArgs["EndRod1Z"];    
00060   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << endRod1 << " to be "
00061                       << "positioned " << endRod1Y.size() << " times at";
00062   for (int i=0; i<(int)(endRod1Y.size()); i++)
00063     LogDebug("TOBGeom") << "\t[" << i << "]\ty = " << endRod1Y[i] 
00064                         << "\tz = " << endRod1Z[i];
00065 
00066   endRod2      = sArgs["EndRod2Name"];     
00067   endRod2Y     = nArgs["EndRod2Y"];    
00068   endRod2Z     = nArgs["EndRod2Z"];    
00069   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << endRod2 << " to be "
00070                       << "positioned at y = " << endRod2Y << " z = " 
00071                       << endRod2Z;
00072 
00073   cable        = sArgs["CableName"];       
00074   cableZ       = nArgs["CableZ"];      
00075   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << cable << " to be "
00076                       << "positioned at z = " << cableZ;
00077 
00078   clamp        = sArgs["ClampName"];       
00079   clampX       = vArgs["ClampX"];      
00080   clampZ       = vArgs["ClampZ"];      
00081   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << clamp << " to be "
00082                       << "positioned " << clampX.size() << " times at";
00083   for (int i=0; i<(int)(clampX.size()); i++)
00084     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << clampX[i] << "\tz = "
00085                         << clampZ[i];
00086 
00087   sideCool     = sArgs["SideCoolName"];    
00088   sideCoolX    = vArgs["SideCoolX"];   
00089   sideCoolY    = vArgs["SideCoolY"];   
00090   sideCoolZ    = vArgs["SideCoolZ"];   
00091   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideCool << " to be "
00092                       << "positioned " << sideCoolX.size() << " times at";
00093   for (int i=0; i<(int)(sideCoolX.size()); i++)
00094     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideCoolX[i]
00095                         << "\ty = " << sideCoolY[i]
00096                         << "\tz = " << sideCoolZ[i];
00097 
00098   endCool      = sArgs["EndCoolName"];     
00099   endCoolY     = nArgs["EndCoolY"];    
00100   endCoolZ     = nArgs["EndCoolZ"];    
00101   endCoolRot   = sArgs["EndCoolRot"];   
00102   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " <<endCool <<" to be "
00103                       << "positioned with " << endCoolRot << " rotation at"
00104                       << " y = " << endCoolY
00105                       << " z = " << endCoolZ;
00106 
00107   optFibre     = sArgs["OptFibreName"];    
00108   optFibreX    = vArgs["optFibreX"];   
00109   optFibreZ    = vArgs["optFibreZ"];   
00110   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << optFibre << " to be "
00111                           << "positioned " << optFibreX.size() << " times at";
00112   for (int i=0; i<(int)(optFibreX.size()); i++)
00113     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << optFibreX[i] 
00114                         << "\tz = " << optFibreZ[i];
00115 
00116   sideClamp1   = sArgs["SideClamp1Name"];  
00117   sideClampX   = vArgs["SideClampX"];  
00118   sideClamp1DZ = vArgs["SideClamp1DZ"];
00119   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideClamp1 << " to be "
00120                       << "positioned " << sideClampX.size() << " times at";
00121   for (int i=0; i<(int)(sideClampX.size()); i++)
00122     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] 
00123                         << "\tdz = " << sideClamp1DZ[i];
00124 
00125   sideClamp2   = sArgs["SideClamp2Name"];  
00126   sideClamp2DZ = vArgs["SideClamp2DZ"];
00127   LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideClamp2 << " to be "
00128                       << "positioned " << sideClampX.size() << " times at";
00129   for (int i=0; i<(int)(sideClampX.size()); i++)
00130     LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i]
00131                         << "\tdz = " << sideClamp2DZ[i];
00132 
00133   moduleRot    = vsArgs["ModuleRot"];   
00134   module       = sArgs["ModuleName"]; 
00135   moduleY      = vArgs["ModuleY"];     
00136   moduleZ      = vArgs["ModuleZ"];
00137   LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << module <<" positioned "
00138                       << moduleRot.size() << " times";
00139   for (int i=0; i<(int)(moduleRot.size()); i++) 
00140     LogDebug("TOBGeom") << "\tRotation " << moduleRot[i] << "\ty = " 
00141                         << moduleY[i] << "\tz = " << moduleZ[i];
00142 
00143   connect      = vsArgs["ICCName"];
00144   connectY     = vArgs["ICCY"];    
00145   connectZ     = vArgs["ICCZ"];    
00146   LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << connect.size() 
00147                       << " ICC positioned with no rotation";
00148   for (int i=0; i<(int)(connect.size()); i++) 
00149     LogDebug("TOBGeom") << "\t" << connect[i] << "\ty = " << connectY[i] 
00150                         << "\tz = " << connectZ[i];
00151 
00152   aohName   = sArgs["AOHName"]; 
00153   aohCopies = vArgs["AOHCopies"];
00154   aohX      = vArgs["AOHx"];     
00155   aohY      = vArgs["AOHy"];     
00156   aohZ      = vArgs["AOHz"];     
00157   LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << aohName <<" AOH will be positioned on ICC's";
00158   for (int i=0; i<(int)(aohCopies.size()); i++) 
00159     LogDebug("TOBGeom")  << " copies " << aohCopies[i]
00160                          << "\tx = " << aohX[i]
00161                          << "\ty = " << aohY[i] 
00162                          << "\tz = " << aohZ[i];
00163   
00164 }
00165 
00166 void DDTOBRodAlgo::execute(DDCompactView& cpv) {
00167   
00168   LogDebug("TOBGeom") << "==>> Constructing DDTOBRodAlgo...";
00169   DDName rodName = parent().name();
00170   DDName centName(DDSplit(central).first, DDSplit(central).second);
00171 
00172   // Side Rods
00173   for (int i=0; i<(int)(sideRod.size()); i++) {
00174     for (int j=0; j<(int)(sideRodX.size()); j++) {
00175       DDTranslation r(sideRodX[j], sideRodY[i], sideRodZ[i]);
00176       DDName child(DDSplit(sideRod[i]).first, DDSplit(sideRod[i]).second);
00177       cpv.position(child, rodName, j+1, r, DDRotation());
00178       LogDebug("TOBGeom") << "DDTOBRodAlgo test: "  << child << " number " 
00179                           << j+1 << " positioned in " << rodName << " at "
00180                           << r << " with no rotation";
00181     }
00182   }
00183 
00184   // Clamps
00185   for (int i=0; i<(int)(clampX.size()); i++) {
00186     DDTranslation r(clampX[i], 0, shift+clampZ[i]);
00187     DDName child(DDSplit(clamp).first, DDSplit(clamp).second);
00188     cpv.position(child, rodName, i+1, r, DDRotation());
00189     LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00190                         << i+1 << " positioned in " << rodName << " at "
00191                         << r << " with no rotation";
00192   }
00193 
00194   // Side Cooling tubes
00195   for (int i=0; i<(int)(sideCoolX.size()); i++) {
00196     DDTranslation r(sideCoolX[i], sideCoolY[i], shift+sideCoolZ[i]);
00197     DDName child(DDSplit(sideCool).first, DDSplit(sideCool).second);
00198     cpv.position(child, rodName, i+1, r, DDRotation());
00199     LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00200                         << i+1 << " positioned in " << rodName << " at "
00201                         << r << " with no rotation";
00202   }
00203 
00204   // Optical Fibres
00205   for (int i=0; i<(int)(optFibreX.size()); i++) {
00206     DDTranslation r(optFibreX[i], 0, shift+optFibreZ[i]);
00207     DDName child(DDSplit(optFibre).first, DDSplit(optFibre).second);
00208     cpv.position(child, rodName, i+1, r, DDRotation());
00209     LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00210                         << i+1 << " positioned in " << rodName << " at " 
00211                         << r << " with no rotation";
00212   }
00213 
00214   // Side Clamps
00215   for (int i=0; i<(int)(sideClamp1DZ.size()); i++) {
00216     int j = i/2;
00217     DDTranslation r(sideClampX[i],moduleY[j],shift+moduleZ[j]+sideClamp1DZ[i]);
00218     DDName child(DDSplit(sideClamp1).first, DDSplit(sideClamp1).second);
00219     cpv.position(child, rodName, i+1, r, DDRotation());
00220     LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00221                         << i+1 << " positioned in " << rodName << " at "
00222                         << r << " with no rotation";
00223   }
00224   for (int i=0; i<(int)(sideClamp2DZ.size()); i++) {
00225     int j = i/2;
00226     DDTranslation r(sideClampX[i],moduleY[j],shift+moduleZ[j]+sideClamp2DZ[i]);
00227     DDName child(DDSplit(sideClamp2).first, DDSplit(sideClamp2).second);
00228     cpv.position(child, rodName, i+1, r, DDRotation());
00229     LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00230                         << i+1 << " positioned in " << rodName << " at "
00231                         << r << " with no rotation";
00232   }
00233 
00234   // End Rods
00235   for (int i=0; i<(int)(endRod1Y.size()); i++) {
00236     DDTranslation r(0, endRod1Y[i], shift+endRod1Z[i]);
00237     DDName child(DDSplit(endRod1).first, DDSplit(endRod1).second);
00238     cpv.position(child, centName, i+1, r, DDRotation());
00239     LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
00240                         << i+1 << " positioned in " << centName << " at "
00241                         << r << " with no rotation";
00242   }
00243   DDTranslation r1(0, endRod2Y, shift+endRod2Z);
00244   DDName child1(DDSplit(endRod2).first, DDSplit(endRod2).second);
00245   cpv.position(child1, centName, 1, r1, DDRotation());
00246   LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child1 << " number 1 "
00247                       << "positioned in " << centName << " at " << r1 
00248                       << " with no rotation";
00249 
00250   // End cooling tubes
00251   DDTranslation r2(0, endCoolY, shift+endCoolZ);
00252   std::string rotstr = DDSplit(endCoolRot).first;
00253   std::string rotns  = DDSplit(endCoolRot).second;
00254   DDRotation rot2(DDName(rotstr,rotns));
00255   DDName child2(DDSplit(endCool).first, DDSplit(endCool).second);
00256   cpv.position(child2, centName, 1, r2, rot2);
00257   LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child2 << " number 1 "
00258                       << "positioned in " << centName << " at " << r2 
00259                       << " with " << rot2;
00260 
00261   //Mother cable
00262   DDTranslation r3(0, 0, shift+cableZ);
00263   DDName child3(DDSplit(cable).first, DDSplit(cable).second);
00264   cpv.position(child3, centName, 1, r3, DDRotation());
00265   LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child3 << " number 1 "
00266                       << "positioned in " << centName << " at " << r3
00267                       << " with no rotation";
00268 
00269   //Modules
00270   for (int i=0; i<(int)(moduleRot.size()); i++) {
00271     DDTranslation r(0, moduleY[i], shift+moduleZ[i]);
00272     rotstr = DDSplit(moduleRot[i]).first;
00273     DDRotation rot;
00274     if (rotstr != "NULL") {
00275       rotns  = DDSplit(moduleRot[i]).second;
00276       rot = DDRotation(DDName(rotstr, rotns));
00277     }
00278     DDName child(DDSplit(module).first, DDSplit(module).second);
00279     cpv.position(child, centName, i+1, r, rot);
00280     LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00281                         << i+1 << " positioned in " << centName << " at "
00282                         << r << " with " << rot;
00283   }
00284 
00285   //Connectors (ICC, CCUM, ...)
00286   for (int i=0; i<(int)(connect.size()); i++) {
00287     DDTranslation r(0, connectY[i], shift+connectZ[i]);
00288     DDName child(DDSplit(connect[i]).first, DDSplit(connect[i]).second);
00289     cpv.position(child, centName, i+1, r, DDRotation());
00290     LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00291                         << i+1 << " positioned in " << centName << " at "
00292                         << r << " with no rotation";
00293   }
00294 
00295   //AOH (only on ICCs)
00296   int copyNumber = 0;
00297   for (int i=0; i<(int)(aohCopies.size()); i++) {
00298     if(aohCopies[i] != 0) {
00299       // first copy with (+aohX,+aohZ) translation
00300       copyNumber++;
00301       DDTranslation r(aohX[i] + 0, aohY[i] + connectY[i], aohZ[i] + shift+connectZ[i]);
00302       DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
00303       cpv.position(child, centName, copyNumber, r, DDRotation());
00304       LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00305                           << copyNumber << " positioned in " << centName << " at "
00306                           << r << " with no rotation";
00307       // if two copies add a copy with (-aohX,-aohZ) translation
00308       if(aohCopies[i] == 2) {
00309         copyNumber++;
00310         DDTranslation r(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]);
00311         DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
00312         cpv.position(child, centName, copyNumber, r, DDRotation());
00313         LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00314                             << copyNumber << " positioned in " << centName << " at "
00315                             << r << " with no rotation";
00316       }
00317       // if four copies add 3 copies with (-aohX,+aohZ) (-aohX,-aohZ) (+aohX,+aohZ) and translations
00318       if(aohCopies[i] == 4) {
00319         for (unsigned int j = 1; j<4; j++ ) {
00320           copyNumber++;
00321           switch(j) {
00322           case 1:
00323             {
00324               DDTranslation r(-aohX[i] + 0, aohY[i] + connectY[i], +aohZ[i] + shift+connectZ[i]);
00325               DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
00326               cpv.position(child, centName, copyNumber, r, DDRotation());
00327               break;
00328             }
00329           case 2:
00330             {
00331               DDTranslation r(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]);
00332               DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
00333               cpv.position(child, centName, copyNumber, r, DDRotation());
00334               break;
00335             }
00336           case 3:
00337             {
00338               DDTranslation r(+aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]);
00339               DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
00340               cpv.position(child, centName, copyNumber, r, DDRotation());
00341               break;
00342             }
00343           }
00344           LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " 
00345                               << copyNumber << " positioned in " << centName << " at "
00346                               << r << " with no rotation";
00347         }
00348       }
00349     }
00350   }
00351   
00352   LogDebug("TOBGeom") << "<<== End of DDTOBRodAlgo construction ...";
00353 }