00001
00002
00003
00005
00006 #include <cmath>
00007 #include <algorithm>
00008
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "DetectorDescription/Base/interface/DDutils.h"
00011 #include "DetectorDescription/Core/interface/DDPosPart.h"
00012 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00013 #include "DetectorDescription/Core/interface/DDSplit.h"
00014 #include "Geometry/TrackerCommonData/interface/DDTIDModulePosAlgo.h"
00015 #include "CLHEP/Units/PhysicalConstants.h"
00016 #include "CLHEP/Units/SystemOfUnits.h"
00017
00018
00019 DDTIDModulePosAlgo::DDTIDModulePosAlgo() {
00020 LogDebug("TIDGeom") << "DDTIDModulePosAlgo info: Creating an instance";
00021 }
00022
00023 DDTIDModulePosAlgo::~DDTIDModulePosAlgo() {}
00024
00025 void DDTIDModulePosAlgo::initialize(const DDNumericArguments & nArgs,
00026 const DDVectorArguments & vArgs,
00027 const DDMapArguments & ,
00028 const DDStringArguments & sArgs,
00029 const DDStringVectorArguments & vsArgs) {
00030
00031 int i;
00032 DDName parentName = parent().name();
00033 detectorN = (int)(nArgs["DetectorNumber"]);
00034
00035 LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: Parent " << parentName
00036 << " Detector Planes " << detectorN;
00037
00038 detTilt = nArgs["DetTilt"];
00039 fullHeight = nArgs["FullHeight"];
00040 dlTop = nArgs["DlTop"];
00041 dlBottom = nArgs["DlBottom"];
00042 dlHybrid = nArgs["DlHybrid"];
00043
00044 LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: Detector Tilt "
00045 << detTilt/deg << " Height " << fullHeight
00046 << " dl(Top) " << dlTop << " dl(Bottom) " << dlBottom
00047 << " dl(Hybrid) " << dlHybrid;
00048
00049 boxFrameName = sArgs["BoxFrameName"];
00050 boxFrameHeight = nArgs["BoxFrameHeight"];
00051 boxFrameWidth = nArgs["BoxFrameWidth"];
00052 boxFrameZ = vArgs["BoxFrameZ"];
00053 bottomFrameHeight = nArgs["BottomFrameHeight"];
00054 bottomFrameOver = nArgs["BottomFrameOver"];
00055 topFrameHeight = nArgs["TopFrameHeight"];
00056 topFrameOver = nArgs["TopFrameOver"];
00057 LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << boxFrameName
00058 << " positioned at Z";
00059 for (i = 0; i < detectorN; i++)
00060 LogDebug("TIDGeom") << "\tboxFrameZ[" << i << "] = " << boxFrameZ[i];
00061 LogDebug("TIDGeom") << "\t Extra Height at Bottom " << bottomFrameHeight
00062 << " Overlap " <<bottomFrameOver;
00063
00064 sideFrameName = vsArgs["SideFrameName"];
00065 sideFrameZ = vArgs["SideFrameZ"];
00066 sideFrameRot =vsArgs["SideFrameRotation"];
00067 sideFrameWidth = nArgs["SideFrameWidth"];
00068 sideFrameOver = nArgs["SideFrameOver"];
00069 for (i = 0; i < detectorN; i++)
00070 LogDebug("TIDGeom") << "\tsideFrame[" << i << "] = " << sideFrameName[i]
00071 << " positioned at Z "<< sideFrameZ[i]
00072 << " with rotation " << sideFrameRot[i];
00073
00074 kaptonName = vsArgs["KaptonName"];
00075 kaptonZ = vArgs["KaptonZ"];
00076 kaptonRot =vsArgs["KaptonRotation"];
00077 for (i = 0; i < detectorN; i++)
00078 LogDebug("TIDGeom") << "\tkapton[" << i << "] = " << kaptonName[i]
00079 << " positioned at Z "<< kaptonZ[i]
00080 << " with rotation " << kaptonRot[i];
00081
00082 waferName =vsArgs["WaferName"];
00083 waferZ = vArgs["WaferZ"];
00084 waferRot =vsArgs["WaferRotation"];
00085 for (i = 0; i < detectorN; i++)
00086 LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << waferName[i]
00087 << " positioned at Z " << waferZ[i]
00088 << " with rotation " << waferRot[i];
00089
00090 hybridName = sArgs["HybridName"];
00091 hybridHeight = nArgs["HybridHeight"];
00092 hybridZ = vArgs["HybridZ"];
00093 LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << hybridName
00094 << " Height " << hybridHeight << " Z";
00095 for (i = 0; i < detectorN; i++)
00096 LogDebug("TIDGeom") << "\thybridZ[" << i <<"] = " << hybridZ[i];
00097
00098 pitchName =vsArgs["PitchName"];
00099 pitchHeight = nArgs["PitchHeight"];
00100 pitchZ = vArgs["PitchZ"];
00101 pitchRot =vsArgs["PitchRotation"];
00102 LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: Pitch Adapter Height "
00103 << pitchHeight;
00104 for (i = 0; i < detectorN; i++)
00105 LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << pitchName[i]
00106 << " position at Z " << pitchZ[i]
00107 << " with rotation " << pitchRot[i];
00108
00109 coolName = sArgs["CoolInsertName"];
00110 coolHeight = nArgs["CoolInsertHeight"];
00111 coolZ = nArgs["CoolInsertZ"];
00112 coolWidth = nArgs["CoolInsertWidth"];
00113 coolRadShift = vArgs["CoolInsertShift"];
00114
00115 std::string comp = sArgs["DoSpacers"];
00116 if (comp == "No" || comp == "NO" || comp == "no") doSpacers = false;
00117 else doSpacers = true;
00118
00119 botSpacersName = sArgs["BottomSpacersName"];
00120 botSpacersHeight = nArgs["BottomSpacersHeight"];
00121 botSpacersZ = nArgs["BottomSpacersZ"];
00122 sidSpacersName = sArgs["SideSpacersName"];
00123 sidSpacersHeight = nArgs["SideSpacersHeight"];
00124 sidSpacersZ = nArgs["SideSpacersZ"];
00125 sidSpacersWidth = nArgs["SideSpacersWidth"];
00126 sidSpacersRadShift = nArgs["SideSpacersShift"];
00127
00128 }
00129
00130 void DDTIDModulePosAlgo::execute() {
00131
00132 LogDebug("TIDGeom") << "==>> Constructing DDTIDModulePosAlgo...";
00133
00134 DDName parentName = parent().name();
00135 DDName name;
00136
00137 double botfr;
00138 double topfr;
00139 double kaptonHeight;
00140 if (dlHybrid > dlTop) {
00141
00142 topfr = topFrameHeight - pitchHeight - topFrameOver;
00143 botfr = bottomFrameHeight - bottomFrameOver;
00144 kaptonHeight = fullHeight + botfr;
00145 } else {
00146
00147 topfr = topFrameHeight - topFrameOver;
00148 botfr = bottomFrameHeight - bottomFrameOver - pitchHeight;
00149 kaptonHeight = fullHeight + topfr;
00150 }
00151
00152 double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr;
00153 double zCenter = 0.5 * (sideFrameHeight+boxFrameHeight);
00154
00155
00156
00157 double sidfr = sideFrameWidth - sideFrameOver;
00158 double dxbot = 0.5*dlBottom + sidfr;
00159 double dxtop = 0.5*dlTop + sidfr;
00160 double dxtopenv, dxbotenv;
00161
00162 double tanWafer=(dxtop-dxbot)/fullHeight;
00163 double thetaWafer = atan(tanWafer);
00164
00165 if (dlHybrid > dlTop) {
00166
00167 dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+pitchHeight+topfr+hybridHeight)/fullHeight;
00168 dxbotenv = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight;
00169 } else {
00170
00171 dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight;
00172 dxbotenv = dxbot;
00173 }
00174
00175 double tanEnv=(dxtopenv-dxbotenv)/(sideFrameHeight+boxFrameHeight);
00176
00177 double xpos=0; double ypos=0; double zpos=0;
00178
00179
00180 name = DDName(DDSplit(coolName).first, DDSplit(coolName).second);
00181 ypos = coolZ;
00182
00183 double zCool;
00184 int copy=0;
00185 DDRotation rot = DDRotation();
00186
00187 for (int j1=0; j1<2; j1++){
00188
00189 if (dlHybrid > dlTop) {
00190 zCool = sideFrameHeight+boxFrameHeight-coolRadShift[j1];
00191 if ( j1==0 ) zCool -= 0.5*coolHeight;
00192 } else {
00193 zCool = coolRadShift[j1];
00194 if ( j1==0 ) zCool += 0.5*coolHeight;
00195 }
00196
00197 if ( j1==0 ) {
00198 xpos = -0.5*(boxFrameWidth-coolWidth);
00199 } else {
00200 xpos = -(dxbotenv+(zCool-0.5*coolHeight)*tanEnv-0.5*coolWidth);
00201 }
00202
00203 zpos = zCool-zCenter;
00204 for ( int j2=0; j2<2; j2++) {
00205 copy++;
00206 DDpos (name, parentName, copy, DDTranslation(xpos,ypos,zpos), rot);
00207 LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
00208 << copy << " positioned in " << parentName << " at "
00209 << DDTranslation(xpos,ypos,zpos) << " with " << rot;
00210 xpos = -xpos;
00211 }
00212 }
00213
00214
00215 if ( doSpacers ) {
00216
00217 name = DDName(DDSplit(botSpacersName).first, DDSplit(botSpacersName).second);
00218 ypos = botSpacersZ;
00219
00220 double zBotSpacers;
00221 if (dlHybrid > dlTop) {
00222 zBotSpacers = sideFrameHeight+boxFrameHeight-0.5*botSpacersHeight;
00223 } else {
00224 zBotSpacers = 0.5*botSpacersHeight;
00225 }
00226 zpos = zBotSpacers - zCenter;
00227 rot = DDRotation();
00228 DDpos (name, parentName, 1, DDTranslation(0.0,ypos,zpos), rot );
00229 LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
00230 << 1 << " positioned in " << parentName << " at "
00231 << DDTranslation(0.0,ypos,zpos) << " with no rotation";
00232
00233
00234
00235 name = DDName(DDSplit(sidSpacersName).first, DDSplit(sidSpacersName).second);
00236 ypos = sidSpacersZ;
00237
00238 double zSideSpacers;
00239 if (dlHybrid > dlTop) {
00240 zSideSpacers = sideFrameHeight+boxFrameHeight-sidSpacersRadShift;
00241 } else {
00242 zSideSpacers = sidSpacersRadShift;
00243 }
00244 zpos = zSideSpacers - zCenter;
00245
00246 copy=0;
00247 xpos = dxbotenv+(zSideSpacers-0.5*sidSpacersHeight)*tanEnv-0.5*sidSpacersWidth+sideFrameOver;
00248
00249 double phix, phiy, phiz;
00250 phix=0.*deg; phiy=90.*deg; phiz=0.*deg;
00251
00252 double thetay, thetax;
00253 thetay=90.*deg;
00254 double thetaz = thetaWafer;
00255
00256 for (int j1=0; j1<2; j1++){
00257 copy++;
00258
00259
00260 thetax = 90.*deg+thetaz;
00261 double thetadeg = thetax/deg;
00262 if (thetadeg != 0) {
00263 std::string arotstr = DDSplit(sidSpacersName).first+dbl_to_string(thetadeg*10.);
00264 rot = DDrot(DDName(arotstr, DDSplit(sidSpacersName).second), thetax, phix, thetay, phiy, thetaz, phiz);
00265 }
00266
00267 DDpos (name, parentName, copy, DDTranslation(xpos,ypos,zpos), rot);
00268 LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
00269 << copy << " positioned in " << parentName << " at "
00270 << DDTranslation(xpos,ypos,zpos) << " with " << rot;
00271 xpos = -xpos;
00272 thetaz = -thetaz;
00273 }
00274 }
00275
00276
00277 for (int k = 0; k < detectorN; k++) {
00278
00279 name = DDName(DDSplit(waferName[k]).first, DDSplit(waferName[k]).second);
00280 xpos=0;
00281 zpos=0;
00282 ypos = waferZ[k];
00283 double zWafer;
00284 if (dlHybrid > dlTop) {
00285 zWafer = botfr+0.5*fullHeight;
00286 } else {
00287 zWafer = boxFrameHeight+botfr+pitchHeight+0.5*fullHeight;
00288 }
00289 zpos = zWafer - zCenter;
00290 DDTranslation tran(xpos, ypos, zpos);
00291 std::string rotstr = DDSplit(waferRot[k]).first;
00292 std::string rotns;
00293 if (rotstr != "NULL") {
00294 rotns = DDSplit(waferRot[k]).second;
00295 rot = DDRotation(DDName(rotstr, rotns));
00296 }
00297 DDpos (name, parentName, k+1, tran, rot);
00298 LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
00299 << k+1 << " positioned in " << parentName << " at "
00300 << tran << " with " << rot;
00301
00302
00303 name = DDName(DDSplit(pitchName[k]).first, DDSplit(pitchName[k]).second);
00304 if (k == 0) {
00305 xpos = 0;
00306 } else {
00307 xpos = 0.5 * fullHeight * sin(detTilt);
00308 }
00309 ypos = pitchZ[k];
00310 double zPitch;
00311 if (dlHybrid > dlTop) {
00312 zPitch = botfr+fullHeight+0.5*pitchHeight;
00313 } else {
00314 zPitch = boxFrameHeight+botfr+0.5*pitchHeight;
00315 }
00316 zpos = zPitch - zCenter;
00317 rotstr = DDSplit(pitchRot[k]).first;
00318 if (rotstr != "NULL") {
00319 rotns = DDSplit(pitchRot[k]).second;
00320 rot = DDRotation(DDName(rotstr, rotns));
00321 } else {
00322 rot = DDRotation();
00323 }
00324 tran = DDTranslation(xpos,ypos,zpos);
00325 DDpos (name, parentName, k+1, tran, rot);
00326 LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
00327 << k+1 << " positioned in " << parentName << " at "
00328 << tran << " with " << rot;
00329
00330
00331 name = DDName(DDSplit(hybridName).first, DDSplit(hybridName).second);
00332 ypos = hybridZ[k];
00333 double zHybrid;
00334 if (dlHybrid > dlTop) {
00335 zHybrid = botfr+fullHeight+pitchHeight+0.5*hybridHeight;
00336 } else {
00337 zHybrid = 0.5*hybridHeight;
00338 }
00339 zpos = zHybrid - zCenter;
00340 tran = DDTranslation(0,ypos,zpos);
00341 rot = DDRotation();
00342 DDpos (name, parentName, k+1, tran, rot);
00343 LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
00344 << k+1 << " positioned in " << parentName << " at "
00345 << tran << " with " << rot;
00346
00347
00348
00349 name = DDName(DDSplit(boxFrameName).first, DDSplit(boxFrameName).second);
00350 ypos = boxFrameZ[k];
00351 double zBoxFrame;
00352 if (dlHybrid > dlTop) {
00353 zBoxFrame = sideFrameHeight+0.5*boxFrameHeight;
00354 } else {
00355 zBoxFrame = 0.5*boxFrameHeight;
00356 }
00357 zpos = zBoxFrame - zCenter;
00358 tran = DDTranslation(0,ypos,zpos);
00359 rot = DDRotation();
00360 DDpos (name, parentName, k+1, tran, rot);
00361 LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
00362 << k+1 << " positioned in " << parentName << " at "
00363 << tran << " with " << rot;
00364
00365
00366 name = DDName(DDSplit(sideFrameName[k]).first, DDSplit(sideFrameName[k]).second);
00367 ypos = sideFrameZ[k];
00368 double zSideFrame;
00369 if (dlHybrid > dlTop) {
00370 zSideFrame = 0.5*sideFrameHeight;
00371 } else {
00372 zSideFrame = boxFrameHeight+0.5*sideFrameHeight;
00373 }
00374 zpos = zSideFrame-zCenter;
00375 rotstr = DDSplit(sideFrameRot[k]).first;
00376 if (rotstr != "NULL") {
00377 rotns = DDSplit(sideFrameRot[k]).second;
00378 rot = DDRotation(DDName(rotstr, rotns));
00379 } else {
00380 rot = DDRotation();
00381 }
00382 tran = DDTranslation(0,ypos,zpos);
00383 DDpos (name, parentName, k+1, tran, rot);
00384 LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
00385 << k+1 << " positioned in " << parentName << " at "
00386 << tran << " with " << rot;
00387
00388
00389
00390 name = DDName(DDSplit(kaptonName[k]).first, DDSplit(kaptonName[k]).second);
00391 ypos = kaptonZ[k];
00392 double zKapton;
00393 double kaptonExtraHeight=0;
00394 if (dlHybrid > dlTop) {
00395 if ( k == 1 ) kaptonExtraHeight = dlTop*sin(detTilt)-fullHeight*(1-cos(detTilt));
00396 kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
00397 zKapton = 0.5*(kaptonHeight+kaptonExtraHeight);
00398 } else {
00399 if ( k == 1 ) kaptonExtraHeight = dlBottom*sin(detTilt)-fullHeight*(1-cos(detTilt));
00400 kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
00401 zKapton = boxFrameHeight+sideFrameHeight-0.5*(kaptonHeight+kaptonExtraHeight);
00402 }
00403 zpos = zKapton-zCenter;
00404 rotstr = DDSplit(kaptonRot[k]).first;
00405 if (rotstr != "NULL") {
00406 rotns = DDSplit(kaptonRot[k]).second;
00407 rot = DDRotation(DDName(rotstr, rotns));
00408 } else {
00409 rot = DDRotation();
00410 }
00411 tran = DDTranslation(0,ypos,zpos);
00412 DDpos (name, parentName, k+1, tran, rot);
00413 LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
00414 << k+1 << " positioned in " << parentName << " at "
00415 << tran << " with " << rot;
00416 }
00417
00418 LogDebug("TIDGeom") << "<<== End of DDTIDModulePosAlgo positioning ...";
00419 }
00420
00421