CMS 3D CMS Logo

DDTrackerAngular.cc

Go to the documentation of this file.
00001 
00002 // File: DDTrackerAngular.cc
00003 // Description: Position n copies 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/DDPosPart.h"
00012 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00013 #include "DetectorDescription/Core/interface/DDSplit.h"
00014 #include "Geometry/TrackerCommonData/interface/DDTrackerAngular.h"
00015 #include "CLHEP/Units/PhysicalConstants.h"
00016 #include "CLHEP/Units/SystemOfUnits.h"
00017 
00018 
00019 DDTrackerAngular::DDTrackerAngular() {
00020   LogDebug("TrackerGeom") << "DDTrackerAngular info: Creating an instance";
00021 }
00022 
00023 DDTrackerAngular::~DDTrackerAngular() {}
00024 
00025 void DDTrackerAngular::initialize(const DDNumericArguments & nArgs,
00026                                   const DDVectorArguments & vArgs,
00027                                   const DDMapArguments & ,
00028                                   const DDStringArguments & sArgs,
00029                                   const DDStringVectorArguments & ) {
00030 
00031   n           = int(nArgs["N"]);
00032   startCopyNo = int(nArgs["StartCopyNo"]);
00033   incrCopyNo  = int(nArgs["IncrCopyNo"]);
00034   rangeAngle  = nArgs["RangeAngle"];
00035   startAngle  = nArgs["StartAngle"];
00036   radius      = nArgs["Radius"];
00037   center      = vArgs["Center"];
00038   
00039   if (fabs(rangeAngle-360.0*deg)<0.001*deg) { 
00040     delta    =   rangeAngle/double(n);
00041   } else {
00042     if (n > 1) {
00043       delta    =   rangeAngle/double(n-1);
00044     } else {
00045       delta = 0.;
00046     }
00047   }  
00048 
00049   LogDebug("TrackerGeom") << "DDTrackerAngular debug: Parameters for position"
00050                           << "ing:: n " << n << " Start, Range, Delta " 
00051                           << startAngle/deg << " " << rangeAngle/deg << " " 
00052                           << delta/deg << " Radius " << radius << " Centre " 
00053                           << center[0] << ", " << center[1] << ", "<<center[2];
00054 
00055   idNameSpace = DDCurrentNamespace::ns();
00056   childName   = sArgs["ChildName"]; 
00057 
00058   DDName parentName = parent().name();
00059   LogDebug("TrackerGeom") << "DDTrackerAngular debug: Parent " << parentName 
00060                           << "\tChild " << childName << " NameSpace "
00061                           << idNameSpace;
00062 }
00063 
00064 void DDTrackerAngular::execute() {
00065 
00066   DDName mother = parent().name();
00067   DDName child(DDSplit(childName).first, DDSplit(childName).second);
00068   double theta  = 90.*deg;
00069   int    copy   = startCopyNo;
00070   double phi    = startAngle;
00071   for (int i=0; i<n; i++) {
00072     double phix = phi;
00073     double phiy = phix + 90.*deg;
00074     double phideg = phix/deg;
00075 
00076     DDRotation rotation;
00077     if (phideg != 0) {
00078       std::string rotstr = DDSplit(childName).first+dbl_to_string(phideg*10.);
00079       rotation = DDRotation(DDName(rotstr, idNameSpace));
00080       if (!rotation) {
00081         LogDebug("TrackerGeom") << "DDTrackerAngular test: Creating a new "
00082                                 << "rotation: " << rotstr << "\t90., " 
00083                                 << phix/deg << ", 90.," << phiy/deg <<", 0, 0";
00084         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00085                          0., 0.);
00086       }
00087     }
00088         
00089     double xpos = radius*cos(phi) + center[0];
00090     double ypos = radius*sin(phi) + center[1];
00091     double zpos = center[2];
00092     DDTranslation tran(xpos, ypos, zpos);
00093   
00094     DDpos (child, mother, copy, tran, rotation);
00095     LogDebug("TrackerGeom") << "DDTrackerAngular test " << child << " number " 
00096                             << copy << " positioned in " << mother << " at "
00097                             << tran  << " with " << rotation;
00098     copy += incrCopyNo;
00099     phi  += delta;
00100   }
00101 }

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