CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Geometry/TrackerCommonData/plugins/DDTECModuleAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTECModuleAlgo        .cc
00003 // Description: Creation of a TEC Test
00005 
00006 #include <cmath>
00007 #include <algorithm>
00008 #include <cstdio>
00009 
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00012 #include "DetectorDescription/Core/interface/DDSolid.h"
00013 #include "DetectorDescription/Core/interface/DDMaterial.h"
00014 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00015 #include "DetectorDescription/Core/interface/DDSplit.h"
00016 #include "Geometry/TrackerCommonData/plugins/DDTECModuleAlgo.h"
00017 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00018 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00019 
00020 
00021 DDTECModuleAlgo::DDTECModuleAlgo() {
00022   LogDebug("TECGeom") << "DDTECModuleAlgo info: Creating an instance";
00023 }
00024 
00025 DDTECModuleAlgo::~DDTECModuleAlgo() {}
00026 
00027 void DDTECModuleAlgo::initialize(const DDNumericArguments & nArgs,
00028                                  const DDVectorArguments & vArgs,
00029                                  const DDMapArguments & ,
00030                                  const DDStringArguments & sArgs,
00031                                  const DDStringVectorArguments & vsArgs) {
00032 
00033   idNameSpace  = DDCurrentNamespace::ns();
00034   genMat       = sArgs["GeneralMaterial"];
00035 
00036   DDName parentName = parent().name(); 
00037 
00038   LogDebug("TECGeom") << "DDTECModuleAlgo debug: Parent " << parentName 
00039                       << " NameSpace " << idNameSpace << " General Material "
00040                       << genMat;
00041   ringNo = (int)nArgs["RingNo"];
00042   moduleThick    = nArgs["ModuleThick"];
00043   detTilt        = nArgs["DetTilt"];
00044   fullHeight     = nArgs["FullHeight"];
00045   dlTop          = nArgs["DlTop"];
00046   dlBottom       = nArgs["DlBottom"];
00047   dlHybrid       = nArgs["DlHybrid"];
00048   rPos           = nArgs["RPos"];
00049   standardRot    = sArgs["StandardRotation"];
00050 
00051   isRing6 = (ringNo == 6);
00052 
00053   LogDebug("TECGeom") << "DDTECModuleAlgo debug: ModuleThick " << moduleThick
00054                       << " Detector Tilt " << detTilt/CLHEP::deg << " Height "
00055                       << fullHeight << " dl(Top) " << dlTop << " dl(Bottom) "
00056                       << dlBottom << " dl(Hybrid) " << dlHybrid
00057                       << " rPos " << rPos << " standrad rotation " 
00058                       << standardRot;
00059 
00060   frameWidth     = nArgs["FrameWidth"];
00061   frameThick     = nArgs["FrameThick"];
00062   frameOver      = nArgs["FrameOver"];
00063   LogDebug("TECGeom") << "DDTECModuleAlgo debug: Frame Width " << frameWidth 
00064                       << " Thickness " << frameThick << " Overlap " 
00065                       << frameOver;
00066 
00067   topFrameMat    = sArgs["TopFrameMaterial"];
00068   topFrameHeight = nArgs["TopFrameHeight"];
00069   topFrameTopWidth= nArgs["TopFrameTopWidth"];
00070   topFrameBotWidth= nArgs["TopFrameBotWidth"];
00071   topFrameThick  = nArgs["TopFrameThick"];
00072   topFrameZ      = nArgs["TopFrameZ"];
00073   LogDebug("TECGeom") << "DDTECModuleAlgo debug: Top Frame Material " 
00074                       << topFrameMat << " Height " << topFrameHeight 
00075                       << " Top Width " << topFrameTopWidth << " Bottom Width "
00076                       << topFrameTopWidth
00077                       << " Thickness " << topFrameThick <<" positioned at"
00078                       << topFrameZ;
00079   double resizeH =0.96;
00080   sideFrameMat   = sArgs["SideFrameMaterial"];
00081   sideFrameThick = nArgs["SideFrameThick"];
00082   sideFrameLWidth =  nArgs["SideFrameLWidth"]; 
00083   sideFrameLHeight = resizeH*nArgs["SideFrameLHeight"];
00084   sideFrameLtheta =  nArgs["SideFrameLtheta"];
00085   sideFrameRWidth =  nArgs["SideFrameRWidth"]; 
00086   sideFrameRHeight = resizeH*nArgs["SideFrameRHeight"];
00087   sideFrameRtheta =  nArgs["SideFrameRtheta"];
00088   siFrSuppBoxWidth  = vArgs["SiFrSuppBoxWidth"];
00089   siFrSuppBoxHeight = vArgs["SiFrSuppBoxHeight"];
00090   siFrSuppBoxYPos = vArgs["SiFrSuppBoxYPos"];
00091   siFrSuppBoxThick =  nArgs["SiFrSuppBoxThick"]; 
00092   siFrSuppBoxMat = sArgs["SiFrSuppBoxMaterial"]; 
00093   sideFrameZ     = nArgs["SideFrameZ"];
00094   LogDebug("TECGeom") << "DDTECModuleAlgo debug : Side Frame Material " 
00095                       << sideFrameMat << " Thickness " << sideFrameThick
00096                       << " left Leg's Width: " << sideFrameLWidth
00097                       << " left Leg's Height: " << sideFrameLHeight
00098                       << " left Leg's tilt(theta): " << sideFrameLtheta
00099                       << " right Leg's Width: " << sideFrameRWidth
00100                       << " right Leg's Height: " << sideFrameRHeight
00101                       << " right Leg's tilt(theta): " << sideFrameRtheta
00102                       << "Supplies Box's Material: " << siFrSuppBoxMat
00103                       << " positioned at" << sideFrameZ;
00104   for (int i= 0; i < (int)(siFrSuppBoxWidth.size());i++){
00105     LogDebug("TECGeom") << " Supplies Box" << i << "'s Width: " 
00106                         << siFrSuppBoxWidth[i] << " Supplies Box" << i
00107                         <<"'s Height: " << siFrSuppBoxHeight[i]
00108                         << " Supplies Box" << i << "'s y Position: " 
00109                         << siFrSuppBoxYPos[i];
00110   }
00111   waferMat       = sArgs["WaferMaterial"];
00112   sideWidthTop   = nArgs["SideWidthTop"];
00113   sideWidthBottom= nArgs["SideWidthBottom"];
00114   waferRot       = sArgs["WaferRotation"];
00115   waferPosition  = nArgs["WaferPosition"];
00116   LogDebug("TECGeom") << "DDTECModuleAlgo debug: Wafer Material " 
00117                       << waferMat << " Side Width Top" << sideWidthTop
00118                       << " Side Width Bottom" << sideWidthBottom
00119                       << " and positioned at "<<waferPosition
00120                       << " positioned with rotation"    << " matrix:"
00121                       << waferRot;
00122 
00123   activeMat      = sArgs["ActiveMaterial"];
00124   activeHeight   = nArgs["ActiveHeight"];
00125   waferThick     = nArgs["WaferThick"];
00126   activeRot      = sArgs["ActiveRotation"];
00127   activeZ        = nArgs["ActiveZ"];
00128   backplaneThick = nArgs["BackPlaneThick"];
00129   LogDebug("TECGeom") << "DDTECModuleAlgo debug: Active Material " 
00130                       << activeMat << " Height " << activeHeight 
00131                       << " rotated by " << activeRot
00132                       << " translated by (0,0," << -0.5 * backplaneThick << ")"
00133                       << " Thickness/Z"
00134                       << waferThick-backplaneThick << "/" << activeZ;
00135 
00136   
00137   hybridMat      = sArgs["HybridMaterial"];
00138   hybridHeight   = nArgs["HybridHeight"];
00139   hybridWidth    = nArgs["HybridWidth"];
00140   hybridThick    = nArgs["HybridThick"];
00141   hybridZ        = nArgs["HybridZ"];
00142   LogDebug("TECGeom") << "DDTECModuleAlgo debug: Hybrid Material " 
00143                       << hybridMat << " Height " << hybridHeight 
00144                       << " Width " << hybridWidth << " Thickness " 
00145                       << hybridThick << " Z"  << hybridZ;
00146 
00147   pitchMat       = sArgs["PitchMaterial"];
00148   pitchHeight    = nArgs["PitchHeight"];
00149   pitchThick     = nArgs["PitchThick"];
00150   pitchWidth     = nArgs["PitchWidth"];
00151   pitchZ         = nArgs["PitchZ"];
00152   pitchRot       = sArgs["PitchRotation"];
00153   LogDebug("TECGeom") << "DDTECModuleAlgo debug: Pitch Adapter Material " 
00154                       << pitchMat << " Height " << pitchHeight 
00155                       << " Thickness " << pitchThick << " position with "
00156                       << " rotation " << pitchRot << " at Z" << pitchZ;
00157 
00158   bridgeMat      = sArgs["BridgeMaterial"];
00159   bridgeWidth    = nArgs["BridgeWidth"];
00160   bridgeThick    = nArgs["BridgeThick"];
00161   bridgeHeight   = nArgs["BridgeHeight"];
00162   bridgeSep      = nArgs["BridgeSeparation"];
00163   LogDebug("TECGeom") << "DDTECModuleAlgo debug: Bridge Material " 
00164                       << bridgeMat << " Width " << bridgeWidth 
00165                       << " Thickness " << bridgeThick << " Height " 
00166                       << bridgeHeight << " Separation "<< bridgeSep;
00167 
00168   siReenforceWidth  = vArgs["SiReenforcementWidth"];
00169   siReenforceHeight = vArgs["SiReenforcementHeight"];
00170   siReenforceYPos =   vArgs["SiReenforcementPosY"];
00171   siReenforceThick =  nArgs["SiReenforcementThick"]; 
00172   siReenforceMat   =  sArgs["SiReenforcementMaterial"];
00173  
00174   LogDebug("TECGeom") << "FALTBOOT DDTECModuleAlgo debug : Si-Reenforcement Material " 
00175                       << sideFrameMat << " Thickness " << siReenforceThick;
00176     
00177   for (int i= 0; i < (int)(siReenforceWidth.size());i++){
00178     LogDebug("TECGeom") << " SiReenforcement" << i << "'s Width: " 
00179                         << siReenforceWidth[i] << " SiReenforcement" << i 
00180                         << "'s Height: " << siReenforceHeight[i]
00181                         << " SiReenforcement" << i << "'s y Position: "
00182                         <<siReenforceYPos[i];
00183   }
00184   inactiveDy  = 0;
00185   inactivePos = 0;
00186   if(ringNo > 3){
00187     inactiveDy = nArgs["InactiveDy"];
00188     inactivePos = nArgs["InactivePos"];
00189     inactiveMat = sArgs["InactiveMaterial"];
00190   }
00191 
00192   noOverlapShift = nArgs["NoOverlapShift"];
00193   //Everything that is normal/stereo specific comes here
00194   isStereo = (int)nArgs["isStereo"] == 1;
00195   if(!isStereo){
00196     LogDebug("TECGeom") << "This is a normal module, in ring "<<ringNo<<"!"; 
00197   } else {
00198     LogDebug("TECGeom") << "This is a stereo module, in ring "<<ringNo<<"!"; 
00199     posCorrectionPhi= nArgs["PosCorrectionPhi"];
00200     topFrame2LHeight = nArgs["TopFrame2LHeight"];
00201     topFrame2RHeight = nArgs["TopFrame2RHeight"];
00202     topFrame2Width   = nArgs["TopFrame2Width"];
00203     LogDebug("TECGeom") << "Phi Position corrected by " << posCorrectionPhi << "*rad";
00204     LogDebug("TECGeom") << "DDTECModuleAlgo debug: stereo Top Frame 2nd Part left Heigt " 
00205                         << topFrame2LHeight << " right Height " << topFrame2RHeight 
00206                         << " Width " << topFrame2Width ;
00207     
00208     sideFrameLWidthLow =  nArgs["SideFrameLWidthLow"]; 
00209     sideFrameRWidthLow =  nArgs["SideFrameRWidthLow"]; 
00210 
00211     LogDebug("TECGeom") << " left Leg's lower Width: " << sideFrameLWidthLow
00212                         << " right Leg's lower Width: " << sideFrameRWidthLow;
00213 
00214     // posCorrectionR =  nArgs["PosCorrectionR"]; 
00215     //LogDebug("TECGeom") << "Stereo Module Position Correction with R = " << posCorrectionR;
00216   }
00217 }
00218 
00219 void DDTECModuleAlgo::doPos(DDLogicalPart toPos, DDLogicalPart mother, 
00220                             int copyNr, double x, double y, double z, 
00221                             std::string rotName, DDCompactView& cpv) {
00222 
00223   DDTranslation tran(z, x, y);
00224   DDRotation rot;
00225   std::string rotstr = DDSplit(rotName).first;
00226   std::string rotns; 
00227   if (rotstr != "NULL") {
00228     rotns = DDSplit(rotName).second;
00229     rot   = DDRotation(DDName(rotstr, rotns));
00230   } else {
00231     rot = DDRotation();
00232   }
00233         
00234   cpv.position(toPos, mother, copyNr, tran, rot);
00235   LogDebug("TECGeom") << "DDTECModuleAlgo test: " << toPos.name()
00236                       << " positioned in "<< mother.name() 
00237                       << " at " << tran  << " with " << rot;
00238 }
00239 
00240 void DDTECModuleAlgo::doPos(DDLogicalPart toPos, double x, double y, double z,
00241                             std::string rotName, DDCompactView& cpv) {
00242   int           copyNr = 1;
00243   if (isStereo) copyNr = 2;
00244 
00245   // This has to be done so that the Mother coordinate System of a Tub resembles 
00246   // the coordinate System of a Trap or Box.
00247   z += rPos;
00248 
00249   if(isStereo){
00250     // z is x , x is y
00251     //z+= rPos*sin(posCorrectionPhi);  <<- this is already corrected with the r position!
00252     x+= rPos*sin(posCorrectionPhi);
00253   }
00254   if (rotName == "NULL") rotName = standardRot;
00255 
00256   doPos(toPos,parent(),copyNr,x,y,z,rotName, cpv);
00257 }
00258 
00259 void DDTECModuleAlgo::execute(DDCompactView& cpv) {
00260 
00261   LogDebug("TECGeom") << "==>> Constructing DDTECModuleAlgo...";
00262   //declarations
00263   double tmp;
00264   double dxdif, dzdif;
00265   double dxbot, dxtop; // topfr;
00266   //positions
00267   double xpos, ypos, zpos;
00268   //dimensons
00269   double bl1, bl2;
00270   double h1;
00271   double dx, dy, dz;
00272   double thet;
00273   //names
00274   std::string idName;
00275   std::string name;
00276   std::string tag("Rphi");
00277   if (isStereo) tag = "Stereo";
00278   char buf[5]; //for string operations
00279   //usefull constants
00280   const double topFrameEndZ = 0.5 * (-waferPosition + fullHeight) + pitchHeight + hybridHeight - topFrameHeight;
00281   DDName  parentName = parent().name(); 
00282   idName = parentName.name();
00283   LogDebug("TECGeom") << "==>> " << idName << " parent " << parentName << " namespace " << idNameSpace;
00284   DDSolid solid;
00285 
00286   //set global parameters
00287   DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
00288   DDMaterial matter(matname);
00289   dzdif = fullHeight + topFrameHeight;
00290   if(isStereo) dzdif += 0.5*(topFrame2LHeight+topFrame2RHeight);
00291   
00292   dxbot = 0.5*dlBottom + frameWidth - frameOver;
00293   dxtop = 0.5*dlHybrid + frameWidth - frameOver;
00294   //  topfr = 0.5*dlBottom * sin(detTilt);
00295   if (isRing6) {
00296     dxbot = dxtop;
00297     dxtop = 0.5*dlTop    + frameWidth - frameOver;
00298     //    topfr = 0.5*dlTop    * sin(detTilt);
00299   }
00300   dxdif = dxtop - dxbot;
00301 
00302   //Frame Sides
00303   // left Frame
00304   name    = idName + "SideFrameLeft";
00305   matname =  DDName(DDSplit(sideFrameMat).first, DDSplit(sideFrameMat).second);
00306   matter  = DDMaterial(matname);
00307 
00308   h1 = 0.5 * sideFrameThick;
00309   dz = 0.5 * sideFrameLHeight;
00310   bl1 = bl2 = 0.5 * sideFrameLWidth;
00311   thet = sideFrameLtheta;
00312   //for stereo modules
00313   if(isStereo)  bl1 = 0.5 * sideFrameLWidthLow;
00314   solid = DDSolidFactory::trap(DDName(name,idNameSpace), dz, thet, 0, h1, bl1, 
00315                                bl1, 0, h1, bl2, bl2, 0);
00316   LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00317                       << " Trap made of " << matname << " of dimensions "
00318                       << dz << ",  "<<thet<<", 0, " << h1 << ", " << bl1 << ", "
00319                       << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2
00320                       << ", 0";
00321   DDLogicalPart sideFrameLeft(solid.ddname(), matter, solid);
00322   //translate
00323   xpos = - 0.5*topFrameBotWidth +bl2+ tan(fabs(thet)) * dz;
00324   ypos = sideFrameZ;
00325   zpos = topFrameEndZ -dz;
00326   //flip ring 6
00327   if (isRing6){
00328     zpos *= -1;
00329     xpos -= 2*tan(fabs(thet)) * dz; // because of the flip the tan(..) to be in the other direction
00330   }
00331   //the stereo modules are on the back of the normal ones...
00332   if(isStereo) {
00333     xpos = - 0.5*topFrameBotWidth + bl2*cos(detTilt) + dz*sin(fabs(thet)+detTilt)/cos(fabs(thet));
00334     xpos = -xpos;
00335     zpos = topFrameEndZ -topFrame2LHeight- 0.5*sin(detTilt)*(topFrameBotWidth - topFrame2Width)-dz*cos(detTilt+fabs(thet))/cos(fabs(thet))+bl2*sin(detTilt)-0.1*CLHEP::mm;
00336   }
00337   //position
00338   doPos(sideFrameLeft,xpos,ypos,zpos,waferRot, cpv);
00339 
00340   //right Frame
00341   name    = idName + "SideFrameRight";
00342   matname = DDName(DDSplit(sideFrameMat).first, DDSplit(sideFrameMat).second);
00343   matter  = DDMaterial(matname);
00344 
00345   h1 = 0.5 * sideFrameThick;
00346   dz = 0.5 * sideFrameRHeight;
00347   bl1 = bl2 = 0.5 * sideFrameRWidth;
00348   thet = sideFrameRtheta;
00349   if(isStereo) bl1 = 0.5 * sideFrameRWidthLow;
00350   solid = DDSolidFactory::trap(DDName(name,idNameSpace), dz, thet, 0, h1, bl1, 
00351                                bl1, 0, h1, bl2, bl2, 0);
00352   LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00353                       << " Trap made of " << matname << " of dimensions "
00354                       << dz << ", "<<thet<<", 0, " << h1 << ", " << bl1 << ", "
00355                       << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2
00356                       << ", 0";
00357   DDLogicalPart sideFrameRight(solid.ddname(), matter, solid);
00358   //translate
00359   xpos =  0.5*topFrameBotWidth -bl2- tan(fabs(thet)) * dz;
00360   ypos = sideFrameZ;
00361   zpos = topFrameEndZ -dz ;        
00362   if (isRing6){
00363     zpos *= -1;
00364     xpos += 2*tan(fabs(thet)) * dz; // because of the flip the tan(..) has to be in the other direction
00365   }
00366   if(isStereo){
00367     xpos = 0.5*topFrameBotWidth - bl2*cos(detTilt) - dz*sin(fabs(detTilt-fabs(thet)))/cos(fabs(thet));
00368     xpos = -xpos;
00369     zpos = topFrameEndZ -topFrame2RHeight+ 0.5*sin(detTilt)*(topFrameBotWidth - topFrame2Width)-dz*cos(detTilt-fabs(thet))/cos(fabs(thet))-bl2*sin(detTilt)-0.1*CLHEP::mm;
00370   }
00371   //position it
00372   doPos(sideFrameRight,xpos,ypos,zpos,waferRot, cpv);
00373 
00374 
00375   //Supplies Box(es)
00376   for (int i= 0; i < (int)(siFrSuppBoxWidth.size());i++){
00377     sprintf(buf,"%i",i);
00378     name    = idName + "SuppliesBox"+buf;
00379     matname = DDName(DDSplit(siFrSuppBoxMat).first, DDSplit(siFrSuppBoxMat).second);
00380     matter  = DDMaterial(matname);
00381     
00382     h1 = 0.5 * siFrSuppBoxThick;
00383     dz = 0.5 * siFrSuppBoxHeight[i];
00384     bl1 = bl2 = 0.5 * siFrSuppBoxWidth[i];
00385     thet = sideFrameRtheta;
00386     if(isStereo) thet = -atan(fabs(sideFrameRWidthLow-sideFrameRWidth)/(2*sideFrameRHeight)-tan(fabs(thet)));
00387                    // ^-- this calculates the lower left angel of the tipped trapezoid, which is the SideFframe...
00388     
00389     solid = DDSolidFactory::trap(DDName(name,idNameSpace), dz, thet,0, h1, bl1,
00390                                  bl1, 0, h1, bl2, bl2, 0);
00391     LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00392                         << " Trap made of " << matname << " of dimensions "
00393                         << dz << ", 0, 0, " << h1 << ", " << bl1 << ", "
00394                         << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2
00395                         << ", 0";
00396     DDLogicalPart siFrSuppBox(solid.ddname(), matter, solid);
00397     //translate
00398     xpos =  0.5*topFrameBotWidth  -sideFrameRWidth - bl1-siFrSuppBoxYPos[i]*tan(fabs(thet));
00399     ypos = sideFrameZ*(0.5+(siFrSuppBoxThick/sideFrameThick)); //via * so I do not have to worry about the sign of sideFrameZ
00400     zpos = topFrameEndZ - siFrSuppBoxYPos[i];        
00401     if (isRing6){ 
00402       xpos += 2*fabs(tan(thet))*  siFrSuppBoxYPos[i]; // the flipped issue again
00403       zpos *= -1;
00404     }
00405     if(isStereo){ 
00406       xpos = 0.5*topFrameBotWidth - (sideFrameRWidth+bl1)*cos(detTilt) -sin(fabs(detTilt-fabs(thet)))*(siFrSuppBoxYPos[i]+dz*(1/cos(thet)- cos(detTilt))+bl1*sin(detTilt));
00407       xpos =-xpos;
00408       zpos = topFrameEndZ - topFrame2RHeight - 0.5*sin(detTilt)*(topFrameBotWidth - topFrame2Width) - siFrSuppBoxYPos[i]-sin(detTilt)*sideFrameRWidth;
00409     }
00410     //position it;
00411     doPos(siFrSuppBox,xpos,ypos,zpos,waferRot,cpv);
00412   }
00413   //The Hybrid
00414   name    = idName + "Hybrid";
00415   matname = DDName(DDSplit(hybridMat).first, DDSplit(hybridMat).second);
00416   matter  = DDMaterial(matname);
00417   dx = 0.5 * hybridWidth;
00418   dy = 0.5 * hybridThick;
00419   dz        = 0.5 * hybridHeight;
00420   solid = DDSolidFactory::box(DDName(name, idNameSpace), dx, dy, dz);
00421   LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00422                                           << " Box made of " << matname << " of dimensions "
00423                                           << dx << ", " << dy << ", " << dz;
00424   DDLogicalPart hybrid(solid.ddname(), matter, solid);
00425 
00426   ypos = hybridZ;
00427   zpos = 0.5 * (-waferPosition + fullHeight + hybridHeight)+pitchHeight;
00428   if (isRing6)  zpos *=-1;
00429   //position it
00430   doPos(hybrid,0,ypos,zpos,"NULL", cpv);  
00431 
00432   // Wafer
00433   name    = idName + tag +"Wafer";
00434   matname = DDName(DDSplit(waferMat).first, DDSplit(waferMat).second);
00435   matter  = DDMaterial(matname);
00436   bl1     = 0.5 * dlBottom;
00437   bl2     = 0.5 * dlTop;
00438   h1      = 0.5 * waferThick;
00439   dz      = 0.5 * fullHeight;
00440   solid = DDSolidFactory::trap(DDName(name,idNameSpace), dz, 0, 0, h1, bl1, 
00441                                                            bl1, 0, h1, bl2, bl2, 0);
00442   LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name()
00443                         << " Trap made of " << matname << " of dimensions "
00444                         << dz << ", 0, 0, " << h1 << ", " << bl1 << ", "
00445                         << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
00446                         << bl2 << ", 0";
00447   DDLogicalPart wafer(solid.ddname(), matter, solid);
00448   
00449   ypos = activeZ;
00450   zpos =-0.5 * waferPosition;// former and incorrect topFrameHeight;
00451   if (isRing6) zpos *= -1;
00452   
00453   doPos(wafer,0,ypos,zpos,waferRot,cpv);
00454   
00455   // Active
00456   name    = idName + tag +"Active";
00457   matname = DDName(DDSplit(activeMat).first, DDSplit(activeMat).second);
00458   matter  = DDMaterial(matname);
00459   bl1    -= sideWidthBottom;
00460   bl2    -= sideWidthTop;
00461   dz      = 0.5 * (waferThick-backplaneThick); // inactive backplane
00462   h1      = 0.5 * activeHeight;
00463   if (isRing6) { //switch bl1 <->bl2
00464     tmp = bl2;  bl2 =bl1;       bl1 = tmp;
00465   }
00466   solid = DDSolidFactory::trap(DDName(name,idNameSpace), dz, 0, 0, h1, bl2, 
00467                                bl1, 0, h1, bl2, bl1, 0);
00468   LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00469                       << " Trap made of " << matname << " of dimensions "
00470                       << dz << ", 0, 0, " << h1 << ", " << bl2 << ", "
00471                       << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
00472                       << bl1 << ", 0";
00473   DDLogicalPart active(solid.ddname(), matter, solid);
00474   doPos(active, wafer, 1, -0.5 * backplaneThick,0,0, activeRot, cpv); // from the definition of the wafer local axes and doPos() routine
00475   //inactive part in rings > 3
00476   if(ringNo > 3){
00477     inactivePos -= fullHeight-activeHeight; //inactivePos is measured from the beginning of the _wafer_
00478     name    = idName + tag +"Inactive";
00479     matname = DDName(DDSplit(inactiveMat).first, DDSplit(inactiveMat).second);
00480     matter  = DDMaterial(matname);
00481     bl1     = 0.5*dlBottom-sideWidthBottom
00482               + ((0.5*dlTop-sideWidthTop-0.5*dlBottom+sideWidthBottom)/activeHeight)
00483                 *(activeHeight-inactivePos-inactiveDy);
00484     bl2    =  0.5*dlBottom-sideWidthBottom
00485               + ((0.5*dlTop-sideWidthTop-0.5*dlBottom+sideWidthBottom)/activeHeight)
00486                 *(activeHeight-inactivePos+inactiveDy);
00487     dz      = 0.5 * (waferThick-backplaneThick); // inactive backplane
00488     h1      = inactiveDy;
00489     if (isRing6) { //switch bl1 <->bl2
00490       tmp = bl2;        bl2 =bl1;       bl1 = tmp;
00491     }
00492     solid = DDSolidFactory::trap(DDName(name,idNameSpace), dz, 0, 0, h1, bl2, 
00493                                  bl1, 0, h1, bl2, bl1, 0);
00494     LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00495                         << " Trap made of " << matname << " of dimensions "
00496                         << dz << ", 0, 0, " << h1 << ", " << bl2 << ", "
00497                         << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
00498                         << bl1 << ", 0";  
00499     DDLogicalPart inactive(solid.ddname(), matter, solid);
00500     ypos = inactivePos - 0.5*activeHeight;
00501     doPos(inactive,active, 1, ypos,0,0, "NULL", cpv); // from the definition of the wafer local axes and doPos() routine
00502   }
00503   //Pitch Adapter
00504   name    = idName + "PA";
00505   matname = DDName(DDSplit(pitchMat).first, DDSplit(pitchMat).second);
00506   matter  = DDMaterial(matname);
00507   
00508   if (!isStereo) {
00509     dx      = 0.5 * pitchWidth;
00510     dy      = 0.5 * pitchThick;
00511     dz      = 0.5 * pitchHeight;
00512     solid   = DDSolidFactory::box(DDName(name, idNameSpace), dx, dy, dz);
00513     LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00514                         << " Box made of " << matname <<" of dimensions "
00515                         << dx << ", " << dy << ", " << dz;
00516   } else {
00517     dz      = 0.5 * pitchWidth;    
00518     h1      = 0.5 * pitchThick;
00519     bl1     = 0.5 * pitchHeight + 0.5 * dz * sin(detTilt);
00520     bl2     = 0.5 * pitchHeight - 0.5 * dz * sin(detTilt);
00521     double thet = atan((bl1-bl2)/(2.*dz));
00522     solid   = DDSolidFactory::trap(DDName(name,idNameSpace), dz, thet, 0, h1,
00523                                    bl1, bl1, 0, h1, bl2, bl2, 0);
00524     LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name()
00525                         << " Trap made of " << matname 
00526                         << " of dimensions " << dz << ", " << thet/CLHEP::deg
00527                         << ", 0, " << h1 << ", " << bl1 << ", " << bl1
00528                         << ", 0, " << h1 << ", " << bl2 << ", " << bl2
00529                         << ", 0";
00530   }
00531   xpos = 0;
00532   ypos = pitchZ;
00533   zpos = 0.5 * (-waferPosition + fullHeight + pitchHeight);
00534   if (isRing6) zpos *= -1;
00535   if(isStereo)    xpos    = 0.5 * fullHeight * sin(detTilt);
00536   
00537   DDLogicalPart pa(solid.ddname(), matter, solid);
00538   if(isStereo)doPos(pa, xpos, ypos,zpos, pitchRot, cpv);
00539   else        doPos(pa, xpos, ypos,zpos, "NULL", cpv);
00540   //Top of the frame
00541   name = idName + "TopFrame";
00542   matname = DDName(DDSplit(topFrameMat).first, DDSplit(topFrameMat).second);
00543   matter  = DDMaterial(matname);
00544   
00545   h1 = 0.5 * topFrameThick;
00546   dz = 0.5 * topFrameHeight;
00547   bl1 = 0.5 * topFrameBotWidth;
00548   bl2 = 0.5 * topFrameTopWidth;
00549   if (isRing6) {    // ring 6 faces the other way!
00550     bl1 = 0.5 * topFrameTopWidth;
00551     bl2 = 0.5 * topFrameBotWidth;
00552   }
00553   
00554   solid = DDSolidFactory::trap(DDName(name,idNameSpace), dz, 0, 0, h1, bl1, 
00555                                bl1,0, h1, bl2, bl2, 0);
00556   LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00557                       << " Trap made of " << matname << " of dimensions " 
00558                       << dz << ", 0, 0, " << h1 << ", " << bl1 << ", "  
00559                       << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2
00560                       << ", 0";
00561   DDLogicalPart topFrame(solid.ddname(), matter, solid);
00562   
00563   if(isStereo){ 
00564     name = idName + "TopFrame2";
00565     //additional object to build the not trapzoid geometry of the stereo topframes
00566     dz      = 0.5 * topFrame2Width;    
00567     h1      = 0.5 * topFrameThick;
00568     bl1     = 0.5 * topFrame2LHeight;
00569     bl2     = 0.5 * topFrame2RHeight;
00570     double thet = atan((bl1-bl2)/(2.*dz));
00571         
00572     solid   = DDSolidFactory::trap(DDName(name,idNameSpace), dz, thet, 0, h1,
00573                                    bl1, bl1, 0, h1, bl2, bl2, 0);
00574     LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name()
00575                         << " Trap made of " << matname << " of dimensions "
00576                         << dz << ", " << thet/CLHEP::deg << ", 0, " << h1 
00577                         << ", " << bl1 << ", " << bl1 << ", 0, " << h1 
00578                         << ", " << bl2 << ", " << bl2 << ", 0";
00579   }
00580   
00581   // Position the topframe
00582   ypos = topFrameZ;
00583   zpos = 0.5 * (-waferPosition + fullHeight - topFrameHeight)+ pitchHeight + hybridHeight;
00584   if(isRing6){
00585     zpos *=-1;
00586   }
00587 
00588   doPos(topFrame, 0,ypos,zpos,"NULL", cpv);
00589   if(isStereo){
00590     //create
00591     DDLogicalPart topFrame2(solid.ddname(), matter, solid);
00592     zpos -= 0.5*(topFrameHeight + 0.5*(topFrame2LHeight+topFrame2RHeight));
00593     doPos(topFrame2, 0,ypos,zpos,pitchRot, cpv);
00594   }
00595   
00596   //Si - Reencorcement
00597   for (int i= 0; i < (int)(siReenforceWidth.size());i++){
00598     char buf[5];
00599     sprintf(buf,"%i",i);
00600     name    = idName + "SiReenforce"+buf;
00601     matname = DDName(DDSplit(siReenforceMat).first, DDSplit(siReenforceMat).second);
00602     matter  = DDMaterial(matname);
00603     
00604     h1 = 0.5 * siReenforceThick;
00605     dz = 0.5 * siReenforceHeight[i];
00606     bl1 = bl2 = 0.5 * siReenforceWidth[i];
00607     
00608     solid = DDSolidFactory::trap(DDName(name,idNameSpace), dz, 0, 0, h1, bl1, 
00609                                  bl1, 0, h1, bl2, bl2, 0);
00610     LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00611                         << " Trap made of " << matname << " of dimensions "
00612                         << dz << ", 0, 0, " << h1 << ", " << bl1 << ", "
00613                         << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2
00614                         << ", 0";
00615     DDLogicalPart siReenforce(solid.ddname(), matter, solid);
00616     //translate
00617     xpos =0 ;
00618     ypos =  sideFrameZ;
00619     zpos = topFrameEndZ -dz -siReenforceYPos[i];
00620         
00621     if (isRing6)  zpos *= -1;
00622     if(isStereo){ 
00623       xpos = (-siReenforceYPos[i]+0.5*fullHeight)*sin(detTilt);
00624       //  thet = detTilt;
00625       //  if(topFrame2RHeight > topFrame2LHeight) thet *= -1;
00626       //    zpos -= topFrame2RHeight + sin(thet)*(sideFrameRWidth + 0.5*dlTop);
00627       zpos -= topFrame2RHeight + sin (fabs(detTilt))* 0.5*topFrame2Width;
00628     }
00629     doPos(siReenforce,xpos,ypos,zpos,waferRot, cpv);
00630   }
00631 
00632   //Bridge 
00633   if (bridgeMat != "None") {
00634     name    = idName + "Bridge";
00635     matname = DDName(DDSplit(bridgeMat).first, DDSplit(bridgeMat).second);
00636     matter  = DDMaterial(matname);
00637     bl2     = 0.5*bridgeSep + bridgeWidth;
00638     bl1     = bl2 - bridgeHeight * dxdif / dzdif;
00639     h1      = 0.5 * bridgeThick;
00640     dz      = 0.5 * bridgeHeight;
00641     solid = DDSolidFactory::trap(DDName(name,idNameSpace), dz, 0, 0, h1, bl1, 
00642                                  bl1, 0, h1, bl2, bl2, 0);
00643     LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name()
00644                         << " Trap made of " << matname << " of dimensions "
00645                         << dz << ", 0, 0, " << h1 << ", " << bl1 << ", "
00646                         << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2
00647                         << ", 0";
00648     DDLogicalPart bridge(solid.ddname(), matter, solid);
00649 
00650     name    = idName + "BridgeGap";
00651     matname = DDName(DDSplit(genMat).first, DDSplit(genMat).second);
00652     matter  = DDMaterial(matname);
00653     bl1     = 0.5*bridgeSep;
00654     solid = DDSolidFactory::box(DDName(name,idNameSpace), bl1, h1, dz);
00655     LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() 
00656                         << " Box made of " << matname << " of dimensions "
00657                         << bl1 << ", " << h1 << ", " << dz;
00658     DDLogicalPart bridgeGap(solid.ddname(), matter, solid);
00659    cpv.position(bridgeGap, bridge, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00660     LogDebug("TECGeom") << "DDTECModuleAlgo test: " << bridgeGap.name() 
00661                         << " number 1 positioned in " << bridge.name()
00662                         << " at (0,0,0) with no rotation";
00663   }
00664 
00665   LogDebug("TECGeom") << "<<== End of DDTECModuleAlgo construction ...";
00666 }