CMS 3D CMS Logo

DDPixBarLayerAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDPixBarLayerAlgo.cc
00003 // Description: Make one layer of pixel barrel detector
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/DDLogicalPart.h"
00013 #include "DetectorDescription/Core/interface/DDSolid.h"
00014 #include "DetectorDescription/Core/interface/DDMaterial.h"
00015 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00016 #include "DetectorDescription/Core/interface/DDSplit.h"
00017 #include "Geometry/TrackerCommonData/interface/DDPixBarLayerAlgo.h"
00018 #include "CLHEP/Units/PhysicalConstants.h"
00019 #include "CLHEP/Units/SystemOfUnits.h"
00020 
00021 
00022 DDPixBarLayerAlgo::DDPixBarLayerAlgo() {
00023   LogDebug("PixelGeom") <<"DDPixBarLayerAlgo info: Creating an instance";
00024 }
00025 
00026 DDPixBarLayerAlgo::~DDPixBarLayerAlgo() {}
00027 
00028 void DDPixBarLayerAlgo::initialize(const DDNumericArguments & nArgs,
00029                                    const DDVectorArguments & vArgs,
00030                                    const DDMapArguments & ,
00031                                    const DDStringArguments & sArgs,
00032                                    const DDStringVectorArguments & vsArgs) {
00033 
00034   idNameSpace = DDCurrentNamespace::ns();
00035   DDName parentName = parent().name();
00036 
00037   genMat    = sArgs["GeneralMaterial"];
00038   number    = int(nArgs["Ladders"]);
00039   layerDz   = nArgs["LayerDz"];
00040   sensorEdge= nArgs["SensorEdge"];
00041   coolDz    = nArgs["CoolDz"];
00042   coolWidth = nArgs["CoolWidth"];
00043   coolSide  = nArgs["CoolSide"];
00044   coolThick = nArgs["CoolThick"];
00045   coolDist  = nArgs["CoolDist"];
00046   coolMat   = sArgs["CoolMaterial"];
00047   tubeMat   = sArgs["CoolTubeMaterial"];
00048 
00049   LogDebug("PixelGeom") << "DDPixBarLayerAlgo debug: Parent " << parentName 
00050                         << " NameSpace " << idNameSpace << "\n"
00051                         << "\tLadders " << number << "\tGeneral Material " 
00052                         << genMat << "\tLength " << layerDz << "\tSensorEdge "
00053                         << sensorEdge << "\tSpecification of Cooling Pieces:\n"
00054                         << "\tLength " << coolDz << " Width " << coolWidth 
00055                         << " Side " << coolSide << " Thickness of Shell " 
00056                         << coolThick << " Radial distance " << coolDist 
00057                         << " Materials " << coolMat << ", " << tubeMat;
00058 
00059   ladder      = vsArgs["LadderName"];
00060   ladderWidth = vArgs["LadderWidth"];
00061   ladderThick = vArgs["LadderThick"];
00062   
00063   LogDebug("PixelGeom") << "DDPixBarLayerAlgo debug: Full Ladder " 
00064                         << ladder[0] << " width/thickness " << ladderWidth[0]
00065                         << ", " << ladderThick[0] << "\tHalf Ladder " 
00066                         << ladder[1] << " width/thickness " << ladderWidth[1]
00067                         << ", " << ladderThick[1];
00068 }
00069 
00070 void DDPixBarLayerAlgo::execute() {
00071 
00072   DDName      mother = parent().name();
00073   std::string idName = DDSplit(mother).first;
00074 
00075   double dphi = twopi/number;
00076   double d2   = 0.5*coolWidth;
00077   double d1   = d2 - coolSide*sin(0.5*dphi);
00078   double x1   = (d1+d2)/(2.*sin(0.5*dphi));
00079   double x2   = coolDist*sin(0.5*dphi);
00080   double rmin = (coolDist-0.5*(d1+d2))*cos(0.5*dphi)-0.5*ladderThick[0];
00081   double rmax = (coolDist+0.5*(d1+d2))*cos(0.5*dphi)+0.5*ladderThick[0];
00082   double rmxh = rmax - 0.5*ladderThick[0] + ladderThick[1];
00083   LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Rmin/Rmax " << rmin 
00084                         << ", " << rmax << " d1/d2 " << d1 << ", " << d2 
00085                         << " x1/x2 " << x1 << ", " << x2;
00086 
00087   double rtmi = rmin + 0.5*ladderThick[0] - ladderThick[1];
00088   double rtmx = sqrt(rmxh*rmxh+ladderWidth[1]*ladderWidth[1]);
00089   DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace),0.5*layerDz,
00090                                        rtmi, rtmx, 0, twopi);
00091   LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " 
00092                         << DDName(idName, idNameSpace) << " Tubs made of " 
00093                         << genMat << " from 0 to " << twopi/deg 
00094                         << " with Rin " << rtmi << " Rout " << rtmx 
00095                         << " ZHalf " << 0.5*layerDz;
00096   DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
00097   DDMaterial matter(matname);
00098   DDLogicalPart layer(solid.ddname(), matter, solid);
00099 
00100   double rr = 0.5*(rmax+rmin);
00101   double dr = 0.5*(rmax-rmin);
00102   double h1 = 0.5*coolSide*cos(0.5*dphi);
00103   std::string name = idName + "CoolTube";
00104   solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
00105                                h1, d2, d1, 0, h1, d2, d1, 0);
00106   LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " <<solid.name() 
00107                         << " Trap made of " << tubeMat << " of dimensions " 
00108                         << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2 
00109                         << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " 
00110                         << d1 << ", 0";
00111   matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
00112   DDLogicalPart coolTube(solid.ddname(), matter, solid);
00113 
00114   name = idName + "Coolant";
00115   h1  -= coolThick;
00116   d1  -= coolThick;
00117   d2  -= coolThick;
00118   solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
00119                                h1, d2, d1, 0, h1, d2, d1, 0);
00120   LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " <<solid.name() 
00121                         << " Trap made of " << coolMat << " of dimensions " 
00122                         << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2
00123                         << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " 
00124                         << d1 << ", 0";
00125   matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
00126   DDLogicalPart cool(solid.ddname(), matter, solid);
00127   DDpos (cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00128   LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << cool.name() 
00129                         << " number 1 positioned in " << coolTube.name() 
00130                         << " at (0,0,0) with no rotation";
00131 
00132   DDName ladderFull(DDSplit(ladder[0]).first, DDSplit(ladder[0]).second);
00133   DDName ladderHalf(DDSplit(ladder[1]).first, DDSplit(ladder[1]).second);
00134 
00135   int nphi=number/2, copy=1, iup=-1;
00136   double phi0 = 90*deg;
00137   for (int i=0; i<number; i++) {
00138         
00139     double phi = phi0 + i*dphi;
00140     double phix, phiy, rrr, xx;
00141     std::string rots;
00142     DDTranslation tran;
00143     DDRotation rot;
00144     if (i == 0 || i == nphi) {
00145       rrr  = rr + dr + 0.5*(ladderThick[1]-ladderThick[0]);
00146       xx   = (0.5*ladderWidth[1] - sensorEdge) * sin(phi);
00147       tran = DDTranslation(xx, rrr*sin(phi), 0);
00148       rots = idName + dbl_to_string(copy);
00149       phix = phi-90*deg;
00150       phiy = 90*deg+phix;
00151       LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
00152                             << "rotation: " << rots << "\t90., " << phix/deg 
00153                             << ", 90.," << phiy/deg << ", 0, 0";
00154       rot = DDrot(DDName(rots,idNameSpace), 90*deg, phix, 90*deg, phiy, 0.,0.);
00155       DDpos (ladderHalf, layer, copy, tran, rot);
00156       LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << ladderHalf 
00157                             << " number " << copy << " positioned in " 
00158                             << layer.name() << " at " << tran << " with " 
00159                             << rot;
00160       copy++;
00161       iup  = -1;
00162       rrr  = rr - dr - 0.5*(ladderThick[1]-ladderThick[0]);
00163       tran = DDTranslation(-xx, rrr*sin(phi), 0);
00164       rots = idName + dbl_to_string(copy);
00165       phix = phi+90*deg;
00166       phiy = 90*deg+phix;
00167       LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
00168                             << "rotation: " << rots << "\t90., " << phix/deg 
00169                             << ", 90.," << phiy/deg << ", 0, 0";
00170       rot = DDrot(DDName(rots,idNameSpace), 90*deg, phix, 90*deg, phiy, 0.,0.);
00171       DDpos (ladderHalf, layer, copy, tran, rot);
00172       LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << ladderHalf 
00173                             << " number " << copy << " positioned in " 
00174                             << layer.name() << " at " << tran << " with " 
00175                             << rot;
00176       copy++;
00177     } else {
00178       iup  =-iup;
00179       rrr  = rr + iup*dr;
00180       tran = DDTranslation(rrr*cos(phi), rrr*sin(phi), 0);
00181       rots = idName + dbl_to_string(copy);
00182       if (iup > 0) phix = phi-90*deg;
00183       else         phix = phi+90*deg;
00184       phiy = phix+90.*deg;
00185       LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
00186                             << "rotation: " << rots << "\t90., " << phix/deg 
00187                             << ", 90.," << phiy/deg << ", 0, 0";
00188       rot = DDrot(DDName(rots,idNameSpace), 90*deg, phix, 90*deg, phiy, 0.,0.);
00189       DDpos (ladderFull, layer, copy, tran, rot);
00190       LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << ladderFull 
00191                             << " number " << copy << " positioned in " 
00192                             << layer.name() << " at " << tran << " with " 
00193                             << rot;
00194       copy++;
00195     }
00196     rrr  = coolDist*cos(0.5*dphi);
00197     tran = DDTranslation(rrr*cos(phi)-x2*sin(phi), 
00198                          rrr*sin(phi)+x2*cos(phi), 0);
00199     rots = idName + dbl_to_string(i+100);
00200     phix = phi+0.5*dphi;
00201     if (iup > 0) phix += 180*deg;
00202     phiy = phix+90.*deg;
00203     LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
00204                           << "rotation: " << rots << "\t90., " << phix/deg 
00205                           << ", 90.," << phiy/deg << ", 0, 0";
00206     rot = DDrot(DDName(rots,idNameSpace), 90*deg, phix, 90*deg, phiy, 0.,0.);
00207     DDpos (coolTube, layer, i+1, tran, rot);
00208     LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: " << coolTube.name() 
00209                           << " number " << i+1 << " positioned in " 
00210                           << layer.name() << " at " << tran << " with "<< rot;
00211   }
00212 }

Generated on Tue Jun 9 17:37:33 2009 for CMSSW by  doxygen 1.5.4