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