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