CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Geometry/TrackerCommonData/plugins/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/DDCurrentNamespace.h"
00012 #include "DetectorDescription/Core/interface/DDSplit.h"
00013 #include "Geometry/TrackerCommonData/plugins/DDTrackerAngular.h"
00014 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00015 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00016 
00017 
00018 DDTrackerAngular::DDTrackerAngular() {
00019   LogDebug("TrackerGeom") << "DDTrackerAngular info: Creating an instance";
00020 }
00021 
00022 DDTrackerAngular::~DDTrackerAngular() {}
00023 
00024 void DDTrackerAngular::initialize(const DDNumericArguments & nArgs,
00025                                   const DDVectorArguments & vArgs,
00026                                   const DDMapArguments & ,
00027                                   const DDStringArguments & sArgs,
00028                                   const DDStringVectorArguments & ) {
00029 
00030   n           = int(nArgs["N"]);
00031   startCopyNo = int(nArgs["StartCopyNo"]);
00032   incrCopyNo  = int(nArgs["IncrCopyNo"]);
00033   rangeAngle  = nArgs["RangeAngle"];
00034   startAngle  = nArgs["StartAngle"];
00035   radius      = nArgs["Radius"];
00036   center      = vArgs["Center"];
00037   
00038   if (fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg) { 
00039     delta    =   rangeAngle/double(n);
00040   } else {
00041     if (n > 1) {
00042       delta    =   rangeAngle/double(n-1);
00043     } else {
00044       delta = 0.;
00045     }
00046   }  
00047 
00048   LogDebug("TrackerGeom") << "DDTrackerAngular debug: Parameters for position"
00049                           << "ing:: n " << n << " Start, Range, Delta " 
00050                           << startAngle/CLHEP::deg << " " 
00051                           << rangeAngle/CLHEP::deg << " " << delta/CLHEP::deg
00052                           << " Radius " << radius << " Centre " << center[0] 
00053                           << ", " << 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(DDCompactView& cpv) {
00065 
00066   DDName mother = parent().name();
00067   DDName child(DDSplit(childName).first, DDSplit(childName).second);
00068   double theta  = 90.*CLHEP::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.*CLHEP::deg;
00074     double phideg = phix/CLHEP::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/CLHEP::deg << ", 90.," 
00084                                 << phiy/CLHEP::deg <<", 0, 0";
00085         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00086                          0., 0.);
00087       }
00088     }
00089         
00090     double xpos = radius*cos(phi) + center[0];
00091     double ypos = radius*sin(phi) + center[1];
00092     double zpos = center[2];
00093     DDTranslation tran(xpos, ypos, zpos);
00094   
00095    cpv.position(child, mother, copy, tran, rotation);
00096     LogDebug("TrackerGeom") << "DDTrackerAngular test " << child << " number " 
00097                             << copy << " positioned in " << mother << " at "
00098                             << tran  << " with " << rotation;
00099     copy += incrCopyNo;
00100     phi  += delta;
00101   }
00102 }