CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Geometry/TrackerCommonData/src/DDTIDAxialCableAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTIDAxialCableAlgo.cc
00003 // Description: Create and position TID axial cables at prescribed phi values
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/interface/DDTIDAxialCableAlgo.h"
00017 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00018 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00019 
00020 
00021 DDTIDAxialCableAlgo::DDTIDAxialCableAlgo() {
00022   LogDebug("TIDGeom") << "DDTIDAxialCableAlgo info: Creating an instance";
00023 }
00024 
00025 DDTIDAxialCableAlgo::~DDTIDAxialCableAlgo() {}
00026 
00027 void DDTIDAxialCableAlgo::initialize(const DDNumericArguments & nArgs,
00028                                      const DDVectorArguments & vArgs,
00029                                      const DDMapArguments & ,
00030                                      const DDStringArguments & sArgs,
00031                                      const DDStringVectorArguments & ) {
00032 
00033   zBend       = nArgs["ZBend"];
00034   zEnd        = nArgs["ZEnd"];
00035   rMin        = nArgs["RMin"];
00036   rMax        = nArgs["RMax"];
00037   rTop        = nArgs["RTop"];
00038   width       = nArgs["Width"];
00039   thick       = nArgs["Thick"];
00040   angles      = vArgs["Angles"];
00041   zposWheel   = vArgs["ZPosWheel"];
00042   zposRing    = vArgs["ZPosRing"];
00043 
00044   LogDebug("TIDGeom") << "DDTIDAxialCableAlgo debug: Parameters for creating "
00045                       << (zposWheel.size()+2) << " axial cables and position"
00046                       << "ing " << angles.size() << " copies in Service volume"
00047                       << "\n                            zBend " << zBend 
00048                       << " zEnd " << zEnd << " rMin " << rMin << " rMax " 
00049                       << rMax << " Cable width " << width/CLHEP::deg 
00050                       << " thickness " << thick << " with Angles";
00051   for (int i=0; i<(int)(angles.size()); i++)
00052     LogDebug("TIDGeom") << "\tangles[" << i << "] = " << angles[i]/CLHEP::deg;
00053   LogDebug("TIDGeom") << "                          Wheels " 
00054                       << zposWheel.size() << " at Z";
00055   for (int i=0; i<(int)(zposWheel.size()); i++)
00056     LogDebug("TIDGeom") << "\tzposWheel[" << i <<"] = " << zposWheel[i];
00057   LogDebug("TIDGeom") << "                          each with " 
00058                       << zposRing.size() << " Rings at Z";
00059   for (int i=0; i<(int)(zposRing.size()); i++)
00060     LogDebug("TIDGeom") << "\tzposRing[" << i <<"] = " << zposRing[i];
00061 
00062   idNameSpace = DDCurrentNamespace::ns();
00063   childName   = sArgs["ChildName"]; 
00064   matIn       = sArgs["MaterialIn"]; 
00065   matOut      = sArgs["MaterialOut"]; 
00066 
00067   DDName parentName = parent().name();
00068   LogDebug("TIDGeom") << "DDTIDAxialCableAlgo debug: Parent " << parentName
00069                       << "\tChild " << childName << " NameSpace " 
00070                       << idNameSpace << "\tMaterial " << matIn << " and " 
00071                       << matOut;
00072 }
00073 
00074 void DDTIDAxialCableAlgo::execute(DDCompactView& cpv) {
00075 
00076   DDName mother = parent().name();
00077   std::vector<DDName> logs;
00078   double thk = thick/zposRing.size();
00079   double r   = rMin;
00080   double thktot = 0;
00081   double z;
00082 
00083   //Cables between the wheels
00084   for (int k=0; k<(int)(zposWheel.size()); k++) {
00085 
00086     std::vector<double> pconZ, pconRmin, pconRmax;
00087     for (int i=0; i<(int)(zposRing.size()); i++) {
00088       thktot += thk;
00089       z       = zposWheel[k] + zposRing[i] - 0.5*thk;
00090       if (i != 0) {
00091         pconZ.push_back(z);
00092         pconRmin.push_back(r);
00093         pconRmax.push_back(rMax);
00094       }
00095       r       = rMin;
00096       pconZ.push_back(z);
00097       pconRmin.push_back(r);
00098       pconRmax.push_back(rMax);
00099       z      += thk;
00100       pconZ.push_back(z);
00101       pconRmin.push_back(r);
00102       pconRmax.push_back(rMax);
00103       r       = rMax - thktot;
00104       pconZ.push_back(z);
00105       pconRmin.push_back(r);
00106       pconRmax.push_back(rMax);
00107     }
00108     if (k >= ((int)(zposWheel.size())-1)) z = zBend;
00109     else z = zposWheel[k+1] + zposRing[0] - 0.5*thk;
00110     pconZ.push_back(z);
00111     pconRmin.push_back(r);
00112     pconRmax.push_back(rMax);
00113     
00114     std::string name = childName + dbl_to_string(k);
00115     DDSolid solid = DDSolidFactory::polycone(DDName(name, idNameSpace),
00116                                              -0.5*width, width, pconZ, 
00117                                              pconRmin, pconRmax);
00118 
00119     LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: " 
00120                         << DDName(name,idNameSpace) << " Polycone made of "
00121                         << matIn << " from " << -0.5*width/CLHEP::deg << " to "
00122                         << 0.5*width/CLHEP::deg << " and with " << pconZ.size()
00123                         << " sections ";
00124     for (int i = 0; i <(int)(pconZ.size()); i++) 
00125       LogDebug("TIDGeom") <<  "\t[" << i  << "]\tZ = " << pconZ[i] 
00126                           << "\tRmin = "<< pconRmin[i] << "\tRmax = " 
00127                           << pconRmax[i];
00128 
00129     DDName mat(DDSplit(matIn).first, DDSplit(matIn).second); 
00130     DDMaterial matter(mat);
00131     DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
00132     logs.push_back(DDName(name, idNameSpace));
00133   }
00134 
00135   //Cable in the vertical part
00136   std::vector<double> pconZ, pconRmin, pconRmax;
00137   r = thktot*rMax/rTop;
00138   z = zBend - thktot;
00139   LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: Thk " << thk 
00140                       << " Total " << thktot << " rMax " << rMax 
00141                       << " rTop " << rTop << " dR " << r << " z " << z;
00142   pconZ.push_back(z);
00143   pconRmin.push_back(rMax);
00144   pconRmax.push_back(rMax);
00145   z = zBend - r;
00146   pconZ.push_back(z);
00147   pconRmin.push_back(rMax);
00148   pconRmax.push_back(rTop);
00149   pconZ.push_back(zBend);
00150   pconRmin.push_back(rMax);
00151   pconRmax.push_back(rTop);
00152 
00153   std::string name = childName + dbl_to_string(zposWheel.size());
00154   DDSolid solid = DDSolidFactory::polycone(DDName(name, idNameSpace),
00155                                            -0.5*width, width, pconZ, 
00156                                            pconRmin, pconRmax);
00157 
00158   LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: " 
00159                       << DDName(name, idNameSpace) << " Polycone made of "
00160                       << matIn << " from " << -0.5*width/CLHEP::deg << " to "
00161                       << 0.5*width/CLHEP::deg << " and with "  << pconZ.size()
00162                       << " sections ";
00163   for (int i = 0; i < (int)(pconZ.size()); i++) 
00164     LogDebug("TIDGeom") << "\t[" << i << "]\tZ = " << pconZ[i] 
00165                         << "\tRmin = "<< pconRmin[i] << "\tRmax = " 
00166                         << pconRmax[i];
00167 
00168   DDName mat(DDSplit(matIn).first, DDSplit(matIn).second); 
00169   DDMaterial matter(mat);
00170   DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
00171   logs.push_back(DDName(name, idNameSpace));
00172 
00173   //Cable in the outer part
00174   name = childName + dbl_to_string(zposWheel.size()+1);
00175   r    = rTop-r;
00176   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5*(zEnd-zBend),
00177                                r, rTop, -0.5*width, width);
00178   LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: " 
00179                       << DDName(name, idNameSpace) << " Tubs made of " 
00180                       << matOut << " from " << -0.5*width/CLHEP::deg << " to " 
00181                       << 0.5*width/CLHEP::deg << " with Rin " << r << " Rout " 
00182                       << rTop << " ZHalf " << 0.5*(zEnd-zBend);
00183   mat    = DDName(DDSplit(matOut).first, DDSplit(matOut).second);
00184   matter = DDMaterial(mat);
00185   genlogic = DDLogicalPart(DDName(name, idNameSpace), matter, solid);
00186   logs.push_back(DDName(name, idNameSpace));
00187 
00188   //Position the cables
00189   double theta = 90.*CLHEP::deg;
00190   for (int i=0; i<(int)(angles.size()); i++) {
00191     double phix = angles[i];
00192     double phiy = phix + 90.*CLHEP::deg;
00193     double phideg = phix/CLHEP::deg;
00194 
00195     DDRotation rotation;
00196     if (phideg != 0) {
00197       std::string rotstr = childName + dbl_to_string(phideg*10.);
00198       rotation = DDRotation(DDName(rotstr, idNameSpace));
00199       if (!rotation) {
00200         LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: Creating a new "
00201                             << "rotation: " << rotstr << " " 
00202                             << theta/CLHEP::deg << ", " << phix/CLHEP::deg 
00203                             << ", " << theta/CLHEP::deg << ", " 
00204                             << phiy/CLHEP::deg << ", 0, 0";
00205         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, 
00206                          phiy, 0., 0.);
00207       }
00208     }
00209     
00210     for (int k=0; k<(int)(logs.size()); k++) {
00211       DDTranslation tran(0,0,0);
00212       if (k == ((int)(logs.size())-1))
00213         tran = DDTranslation(0,0,0.5*(zEnd+zBend));
00214      cpv.position(logs[k], mother, i+1, tran, rotation);
00215       LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test " << logs[k] 
00216                           << " number " << i+1 << " positioned in "
00217                           << mother << " at " << tran << " with "
00218                           << rotation;
00219     }
00220   }
00221 }