CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/SLHCUpgradeSimulations/Geometry/src/DDPixBarLayerUpgradeAlgoCoverage.cc

Go to the documentation of this file.
00001 
00002 // File: DDPixBarLayerUpgradeAlgoCoverage.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/DDPixBarLayerUpgradeAlgoCoverage.h"
00017 #include "CLHEP/Units/PhysicalConstants.h"
00018 #include "CLHEP/Units/SystemOfUnits.h"
00019 
00020 
00021 DDPixBarLayerUpgradeAlgoCoverage::DDPixBarLayerUpgradeAlgoCoverage() {
00022   LogDebug("PixelGeom") <<"DDPixBarLayerUpgradeAlgoCoverage info: Creating an instance";
00023 }
00024 
00025 DDPixBarLayerUpgradeAlgoCoverage::~DDPixBarLayerUpgradeAlgoCoverage() {}
00026 
00027 void DDPixBarLayerUpgradeAlgoCoverage::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 
00049   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage 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      = sArgs["LadderName"];
00060   ladderWidth = nArgs["LadderWidth"];
00061   ladderThick = nArgs["LadderThick"];
00062   activeWidth = nArgs["ActiveWidth"];
00063   outerFirst  = int(nArgs["OuterFirst"]);
00064  
00065   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage debug: Full Ladder " 
00066                         << ladder << " width/thickness " << ladderWidth
00067                         << ", " << ladderThick;
00068   std::cout << " LadderThick = " << ladderThick << std::endl;
00069   std::cout << " LadderWidth = " << ladderWidth << std::endl;
00070   std::cout << " ActiveWidth = " << activeWidth << std::endl;
00071 }
00072 
00073 void DDPixBarLayerUpgradeAlgoCoverage::execute(DDCompactView& cpv) {
00074 
00075   DDName      mother = parent().name();
00076   std::string idName = DDSplit(mother).first;
00077 
00078   // Keep a running tally to check that there are no phi gaps.
00079   double phi_coverage = 0.0;            // Running total of Phi coverage
00080   double dphi = CLHEP::twopi/number;
00081   double d2   = 0.5*coolWidth;
00082   double d1   = d2 - coolSide*sin(0.5*dphi);
00083   double x1   = (d1+d2)/(2.*sin(0.5*dphi));
00084   double x2   = coolDist*sin(0.5*dphi);
00085   double rmin = (coolDist-0.5*(d1+d2))*cos(0.5*dphi)-0.5*ladderThick;
00086   double rmax = (coolDist+0.5*(d1+d2))*cos(0.5*dphi)+0.5*ladderThick;
00087   double rmxh = rmax + 0.5*ladderThick;
00088   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: Rmin/Rmax " << rmin 
00089                         << ", " << rmax << " d1/d2 " << d1 << ", " << d2 
00090                         << " x1/x2 " << x1 << ", " << x2;
00091 
00092   double rtmi = rmin - 0.5*ladderThick;
00093   double rtmx = sqrt(rmxh*rmxh+ladderWidth*ladderWidth);
00094   DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace),0.5*layerDz,
00095                                        rtmi, rtmx, 0, CLHEP::twopi);
00096   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " 
00097                         << DDName(idName, idNameSpace) << " Tubs made of " 
00098                         << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
00099                         << " with Rin " << rtmi << " Rout " << rtmx 
00100                         << " ZHalf " << 0.5*layerDz;
00101   DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
00102   DDMaterial matter(matname);
00103   DDLogicalPart layer(solid.ddname(), matter, solid);
00104 
00105   double rr = 0.5*(rmax+rmin);
00106   double dr = 0.5*(rmax-rmin);
00107   double h1 = 0.5*coolSide*cos(0.5*dphi);
00108   std::string name = idName + "CoolTube";
00109   solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
00110                                h1, d2, d1, 0, h1, d2, d1, 0);
00111   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " <<solid.name() 
00112                         << " Trap made of " << tubeMat << " of dimensions " 
00113                         << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2 
00114                         << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " 
00115                         << d1 << ", 0";
00116   matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
00117   DDLogicalPart coolTube(solid.ddname(), matter, solid);
00118 
00119   name = idName + "Coolant";
00120   h1  -= coolThick;
00121   d1  -= coolThick;
00122   d2  -= coolThick;
00123   solid = DDSolidFactory::trap(DDName(name,idNameSpace), 0.5*coolDz, 0, 0,
00124                                h1, d2, d1, 0, h1, d2, d1, 0);
00125   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " <<solid.name() 
00126                         << " Trap made of " << coolMat << " of dimensions " 
00127                         << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2
00128                         << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " 
00129                         << d1 << ", 0";
00130   matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
00131   DDLogicalPart cool(solid.ddname(), matter, solid);
00132   cpv.position (cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00133   LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " << cool.name() 
00134                         << " number 1 positioned in " << coolTube.name() 
00135                         << " at (0,0,0) with no rotation";
00136 
00137   DDName ladderFull(DDSplit(ladder).first, DDSplit(ladder).second);
00138   int  copy=1, iup=(-1)*outerFirst;
00139   for (int i=1; i<number+1; i++) {
00140     double phi = i*dphi;
00141     double phix, phiy, rrr;
00142     std::string rots;
00143     DDTranslation tran;
00144     DDRotation rot;
00145     iup  =-iup;
00146     rrr  = rr + iup*dr;
00147     tran = DDTranslation(rrr*cos(phi), rrr*sin(phi), 0);
00148     rots = idName + dbl_to_string(copy);
00149     if (iup > 0) phix = phi-90*CLHEP::deg;
00150     else         phix = phi+90*CLHEP::deg;
00151     phiy = phix+90.*CLHEP::deg;
00152     LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage 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 (ladderFull, layer, copy, tran, rot);
00157     LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " << ladderFull 
00158                           << " number " << copy << " positioned in " 
00159                           << layer.name() << " at " << tran << " with " 
00160                           << rot;
00161     double phi_coverage_i=2*atan2((activeWidth/2.0),(rrr+(ladderThick/2.0)));
00162   //std::cout << " radius = " << rrr << " phi value " << phi_coverage_i << std::endl;
00163     phi_coverage += phi_coverage_i;
00164     copy++;
00165     rrr  = coolDist*cos(0.5*dphi);
00166     tran = DDTranslation(rrr*cos(phi)-x2*sin(phi), 
00167                          rrr*sin(phi)+x2*cos(phi), 0);
00168     rots = idName + dbl_to_string(i+100);
00169     phix = phi+0.5*dphi;
00170     if (iup > 0) phix += 180*CLHEP::deg;
00171     phiy = phix+90.*CLHEP::deg;
00172     LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: Creating a new "
00173                           << "rotation: " << rots << "\t90., " << phix/CLHEP::deg 
00174                           << ", 90.," << phiy/CLHEP::deg << ", 0, 0";
00175     rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
00176     cpv.position (coolTube, layer, i+1, tran, rot);
00177     LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgoCoverage test: " << coolTube.name() 
00178                           << " number " << i+1 << " positioned in " 
00179                           << layer.name() << " at " << tran << " with "<< rot;
00180   }
00181   std::cout<<"\nLayer covered "<<phi_coverage<<" radians in phi.   (2Pi="<<CLHEP::twopi<<")" << std::endl;
00182   if (phi_coverage>CLHEP::twopi) std::cout<<"\nPhi coverage is achieved"<< std::endl;
00183 }