CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/SLHCUpgradeSimulations/Geometry/src/DDPixBarLayerUpgradeAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDPixBarLayerUpgradeAlgo.cc
00003 // Description: Make one layer of pixel barrel detector for Upgrading.
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 "SLHCUpgradeSimulations/Geometry/interface/DDPixBarLayerUpgradeAlgo.h"
00017 #include "CLHEP/Units/PhysicalConstants.h"
00018 #include "CLHEP/Units/SystemOfUnits.h"
00019 
00020 
00021 DDPixBarLayerUpgradeAlgo::DDPixBarLayerUpgradeAlgo() {
00022   LogDebug("PixelGeom") <<"DDPixBarLayerUpgradeAlgo info: Creating an instance";
00023 }
00024 
00025 DDPixBarLayerUpgradeAlgo::~DDPixBarLayerUpgradeAlgo() {}
00026 
00027 void DDPixBarLayerUpgradeAlgo::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   coolDz    = nArgs["CoolDz"];
00040   coolThick = nArgs["CoolThick"];
00041   coolRadius= nArgs["CoolRadius"];
00042   coolDist  = nArgs["CoolDist"];
00043   cool1Offset = nArgs["Cool1Offset"];
00044   cool2Offset = nArgs["Cool2Offset"];
00045   coolMat   = sArgs["CoolMaterial"];
00046   tubeMat   = sArgs["CoolTubeMaterial"];
00047 
00048 
00049   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Parent " << parentName 
00050                         << " NameSpace " << idNameSpace << "\n"
00051                         << "\tLadders " << number << "\tGeneral Material " 
00052                         << genMat << "\tLength " << layerDz << "\tSpecification of Cooling Pieces:\n"
00053                         << "\tLength " << coolDz << " Thickness of Shell " 
00054                         << coolThick << " Radial distance " << coolDist 
00055                         << " Materials " << coolMat << ", " << tubeMat;
00056 
00057   ladder      = sArgs["LadderName"];
00058   ladderWidth = nArgs["LadderWidth"];
00059   ladderThick = nArgs["LadderThick"];
00060   ladderOffset = nArgs["LadderOffset"];
00061   outerFirst  = int(nArgs["OuterFirst"]);
00062  
00063   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Full Ladder " 
00064                         << ladder << " width/thickness " << ladderWidth
00065                         << ", " << ladderThick;
00066 }
00067 
00068 void DDPixBarLayerUpgradeAlgo::execute(DDCompactView& cpv) {
00069 
00070   DDName      mother = parent().name();
00071   std::string idName = DDSplit(mother).first;
00072 
00073   double dphi = CLHEP::twopi/number;
00074   double x2   = coolDist*sin(0.5*dphi);
00075   double rtmi = coolDist*cos(0.5*dphi)-(coolRadius+ladderThick);
00076   double rmxh = coolDist*cos(0.5*dphi)+(coolRadius+ladderThick+ladderOffset);
00077   double rtmx = sqrt(rmxh*rmxh+ladderWidth*ladderWidth/4);
00078   DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace),0.5*layerDz,
00079                                        rtmi, rtmx, 0, CLHEP::twopi);
00080   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " 
00081                         << DDName(idName, idNameSpace) << " Tubs made of " 
00082                         << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
00083                         << " with Rin " << rtmi << " Rout " << rtmx 
00084                         << " ZHalf " << 0.5*layerDz;
00085   DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
00086   DDMaterial matter(matname);
00087   DDLogicalPart layer(solid.ddname(), matter, solid);
00088 
00089   double dr = coolRadius+0.5*ladderThick;
00090   std::string name = idName + "CoolTube";
00091   solid = DDSolidFactory::tubs(DDName(name,idNameSpace), 0.5*coolDz,
00092                                0, coolRadius, 0, CLHEP::twopi);
00093   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " <<solid.name() 
00094                         << " Tubs made of " << tubeMat << " from 0 to " <<
00095                         CLHEP::twopi/CLHEP::deg << " with Rout " << coolRadius <<
00096                         " ZHalf " << 0.5*coolDz;                
00097   matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
00098   DDLogicalPart coolTube(solid.ddname(), matter, solid);
00099 
00100   name = idName + "Coolant";
00101   solid = DDSolidFactory::tubs(DDName(name,idNameSpace), 0.5*coolDz,
00102                                0, coolRadius-coolThick, 0, CLHEP::twopi);
00103   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " <<solid.name() 
00104                         << " Tubs made of " << tubeMat << " from 0 to " <<
00105                         CLHEP::twopi/CLHEP::deg << " with Rout " << coolRadius-coolThick <<
00106                         " ZHalf " << 0.5*coolDz;                
00107   matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
00108   DDLogicalPart cool(solid.ddname(), matter, solid);
00109   cpv.position (cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00110   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name() 
00111                         << " number 1 positioned in " << coolTube.name() 
00112                         << " at (0,0,0) with no rotation";
00113 
00114   DDName ladderFull(DDSplit(ladder).first, DDSplit(ladder).second);
00115   int  copy=1, iup=(-1)*outerFirst;
00116   int copyoffset=number+2;
00117   for (int i=1; i<number+1; i++) {
00118     double phi = i*dphi+90*CLHEP::deg-0.5*dphi; //to start with the interface ladder
00119     double phix, phiy, rrr, rrroffset;
00120     std::string rots;
00121     DDTranslation tran;
00122     DDRotation rot;
00123     iup  =-iup;
00124     if ((i==1)||(i==number/2+1)){
00125         dr=coolRadius+0.5*ladderThick+ladderOffset; //interface ladder offset
00126         }else{
00127         dr=coolRadius+0.5*ladderThick;
00128         }
00129     rrr = coolDist*cos(0.5*dphi)+iup*dr;
00130     tran = DDTranslation(rrr*cos(phi), rrr*sin(phi), 0);
00131     rots = idName + dbl_to_string(copy);
00132     if (iup > 0) phix = phi-90*CLHEP::deg;
00133     else         phix = phi+90*CLHEP::deg;
00134     phiy = phix+90.*CLHEP::deg;
00135     LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
00136                           << "rotation: " << rots << "\t90., " << phix/CLHEP::deg 
00137                           << ", 90.," << phiy/CLHEP::deg << ", 0, 0";
00138     rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
00139     cpv.position (ladderFull, layer, copy, tran, rot);
00140     LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << ladderFull 
00141                           << " number " << copy << " positioned in " 
00142                           << layer.name() << " at " << tran << " with " 
00143                           << rot;
00144     copy++;
00145     rrr  = coolDist*cos(0.5*dphi);
00146     tran = DDTranslation(rrr*cos(phi)-x2*sin(phi), 
00147                          rrr*sin(phi)+x2*cos(phi), 0);
00148     rots = idName + dbl_to_string(i+100);
00149     phix = phi+0.5*dphi;
00150     if (iup > 0) phix += 180*CLHEP::deg;
00151     phiy = phix+90.*CLHEP::deg;
00152     LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
00153                           << "rotation: " << rots << "\t90., " << phix/CLHEP::deg 
00154                           << ", 90.," << phiy/CLHEP::deg << ", 0, 0";
00155     rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
00156     cpv.position (coolTube, layer, i+1, tran, rot);
00157     if ((i==1)||(i==number/2+1)){
00158         rrroffset = coolDist*cos(0.5*dphi)+iup*ladderOffset;
00159         tran = DDTranslation(rrroffset*cos(phi)-cool1Offset*sin(phi), 
00160                 rrroffset*sin(phi)+cool1Offset*cos(phi), 0);
00161         cpv.position (coolTube, layer, copyoffset, tran, DDRotation());
00162         copyoffset++;
00163         tran = DDTranslation(rrroffset*cos(phi)-cool2Offset*sin(phi), 
00164                 rrroffset*sin(phi)+cool2Offset*cos(phi), 0);
00165         cpv.position (coolTube, layer, copyoffset, tran, DDRotation());
00166         copyoffset++;
00167         } 
00168    LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << coolTube.name() 
00169                           << " number " << i+1 << " positioned in " 
00170                           << layer.name() << " at " << tran << " with "<< rot;
00171   }
00172 }