CMS 3D CMS Logo

DDTECPhiAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTECPhiAlgo.cc
00003 // Description: Position n copies inside and outside Z at alternate 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/DDPosPart.h"
00012 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00013 #include "DetectorDescription/Core/interface/DDSplit.h"
00014 #include "Geometry/TrackerCommonData/interface/DDTECPhiAlgo.h"
00015 #include "CLHEP/Units/PhysicalConstants.h"
00016 #include "CLHEP/Units/SystemOfUnits.h"
00017 
00018 
00019 DDTECPhiAlgo::DDTECPhiAlgo() {
00020   LogDebug("TECGeom") << "DDTECPhiAlgo info: Creating an instance";
00021 }
00022 
00023 DDTECPhiAlgo::~DDTECPhiAlgo() {}
00024 
00025 void DDTECPhiAlgo::initialize(const DDNumericArguments & nArgs,
00026                               const DDVectorArguments & ,
00027                               const DDMapArguments & ,
00028                               const DDStringArguments & sArgs,
00029                               const DDStringVectorArguments & ) {
00030 
00031   startAngle = nArgs["StartAngle"];
00032   incrAngle  = nArgs["IncrAngle"];
00033   zIn        = nArgs["ZIn"];
00034   zOut       = nArgs["ZOut"];
00035   number     = int (nArgs["Number"]);
00036   startCopyNo= int (nArgs["StartCopyNo"]);
00037   incrCopyNo = int (nArgs["IncrCopyNo"]);
00038 
00039   LogDebug("TECGeom") << "DDTECPhiAlgo debug: Parameters for "
00040                       << "positioning--" << "\tStartAngle " 
00041                       << startAngle/deg << "\tIncrAngle " << incrAngle/deg
00042                       << "\tZ in/out " << zIn << ", " << zOut 
00043                       << "\tCopy Numbers " << number << " Start/Increment " 
00044                       << startCopyNo << ", " << incrCopyNo;
00045 
00046   idNameSpace = DDCurrentNamespace::ns();
00047   childName   = sArgs["ChildName"]; 
00048   DDName parentName = parent().name();
00049   LogDebug("TECGeom") << "DDTECPhiAlgo debug: Parent " << parentName 
00050                       << "\tChild " << childName << " NameSpace " 
00051                       << idNameSpace;
00052 }
00053 
00054 void DDTECPhiAlgo::execute() {
00055 
00056   if (number > 0) {
00057     double theta  = 90.*deg;
00058     int    copyNo = startCopyNo;
00059 
00060     DDName mother = parent().name();
00061     DDName child(DDSplit(childName).first, DDSplit(childName).second);
00062     for (int i=0; i<number; i++) {
00063       double phix = startAngle + i*incrAngle;
00064       double phiy = phix + 90.*deg;
00065       double phideg = phix/deg;
00066   
00067       DDRotation rotation;
00068       std::string rotstr = DDSplit(childName).first+dbl_to_string(phideg*10.);
00069       rotation = DDRotation(DDName(rotstr, idNameSpace));
00070       if (!rotation) {
00071         LogDebug("TECGeom") << "DDTECPhiAlgo test: Creating a new "
00072                             << "rotation " << rotstr << "\t" << theta/deg
00073                             << ", " << phix/deg << ", " << theta/deg << ", "
00074                             << phiy/deg << ", 0, 0";
00075         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00076                          0., 0.);
00077       }
00078         
00079       double zpos = zOut;
00080       if (i%2 == 0) zpos = zIn;
00081       DDTranslation tran(0., 0., zpos);
00082   
00083       DDpos (child, mother, copyNo, tran, rotation);
00084       LogDebug("TECGeom") << "DDTECPhiAlgo test: " << child <<" number "
00085                           << copyNo << " positioned in " << mother <<" at "
00086                           << tran << " with " << rotation;
00087       copyNo += incrCopyNo;
00088     }
00089   }
00090 }

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