CMS 3D CMS Logo

DDTECOptoHybAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTECOptoHybAlgo.cc
00003 // Description: Placing cooling pieces in the petal material of a TEC petal
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/DDCurrentNamespace.h"
00013 #include "DetectorDescription/Core/interface/DDSplit.h"
00014 #include "Geometry/TrackerCommonData/interface/DDTECOptoHybAlgo.h"
00015 #include "CLHEP/Units/PhysicalConstants.h"
00016 #include "CLHEP/Units/SystemOfUnits.h"
00017 
00018 
00019 DDTECOptoHybAlgo::DDTECOptoHybAlgo(): angles(0) {
00020   LogDebug("TECGeom") << "DDTECOptoHybAlgo info: Creating an instance";
00021 }
00022 
00023 DDTECOptoHybAlgo::~DDTECOptoHybAlgo() {}
00024 
00025 void DDTECOptoHybAlgo::initialize(const DDNumericArguments & nArgs,
00026                                   const DDVectorArguments & vArgs,
00027                                   const DDMapArguments & ,
00028                                   const DDStringArguments & sArgs,
00029                                   const DDStringVectorArguments & ) {
00030 
00031   idNameSpace  = DDCurrentNamespace::ns();
00032   childName    = sArgs["ChildName"];
00033 
00034   DDName parentName = parent().name(); 
00035 
00036   LogDebug("TECGeom") << "DDTECOptoHybAlgo debug: Parent " << parentName 
00037                       << " Child " << childName << " NameSpace " <<idNameSpace;
00038 
00039   optoHeight     = nArgs["OptoHeight"];
00040   optoWidth      = nArgs["OptoWidth"];
00041   rpos           = nArgs["Rpos"];
00042   zpos           = nArgs["Zpos"];
00043   startCopyNo    = int (nArgs["StartCopyNo"]);
00044   angles         = vArgs["Angles"];
00045 
00046   LogDebug("TECGeom") << "DDTECOptoHybAlgo debug: Height of the Hybrid "
00047                       << optoHeight << " and Width " << optoWidth
00048                       <<"Rpos " << rpos << " Zpos " << zpos 
00049                       << " StartCopyNo " << startCopyNo << " Number " 
00050                       << angles.size();
00051 
00052   for (int i = 0; i < (int)(angles.size()); i++)
00053     LogDebug("TECGeom") << "\tAngles[" << i << "] = " << angles[i];
00054 
00055 }
00056 
00057 void DDTECOptoHybAlgo::execute() {
00058   
00059   LogDebug("TECGeom") << "==>> Constructing DDTECOptoHybAlgo...";
00060 
00061   DDName mother = parent().name();
00062   DDName child  = DDName(DDSplit(childName).first, DDSplit(childName).second);
00063 
00064   // given r positions are for the lower left corner
00065   rpos += optoHeight/2;
00066   int    copyNo = startCopyNo;
00067   for (int i = 0; i < (int)(angles.size()); i++) {
00068     double phix = -angles.at(i);
00069     // given phi positions are for the lower left corner
00070     phix += asin(optoWidth/2/rpos);
00071     double xpos = rpos * cos(phix);
00072     double ypos = rpos * sin(phix);
00073     DDTranslation tran(xpos, ypos, zpos);
00074 
00075     DDRotation rotation;
00076     double phiy = phix + 90.*deg;
00077     double phideg = phix/deg;
00078     if (phideg != 0) {
00079       std::string rotstr= DDSplit(childName).first+dbl_to_string(phideg*1000.);
00080       rotation = DDRotation(DDName(rotstr, idNameSpace));
00081       if (!rotation) {
00082         double theta = 90.*deg;
00083         LogDebug("TECGeom") << "DDTECOptoHybAlgo test: Creating a new "
00084                             << "rotation: " << rotstr << "\t90., " 
00085                             << phix/deg << ", 90.," << phiy/deg <<", 0, 0";
00086         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00087                          0., 0.);
00088       }
00089     }
00090 
00091     DDpos (child, mother, copyNo, tran, rotation);
00092     LogDebug("TECGeom") << "DDTECOptoHybAlgo test " << child << " number " 
00093                         << copyNo << " positioned in " << mother << " at "
00094                         << tran  << " with " << rotation;
00095     copyNo++;
00096   }
00097   
00098   LogDebug("TECGeom") << "<<== End of DDTECOptoHybAlgo construction ...";
00099 }

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