CMS 3D CMS Logo

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