CMS 3D CMS Logo

DDTrackerPhiAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTrackerPhiAlgo.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/DDTrackerPhiAlgo.h"
00015 #include "CLHEP/Units/PhysicalConstants.h"
00016 #include "CLHEP/Units/SystemOfUnits.h"
00017 
00018 
00019 DDTrackerPhiAlgo::DDTrackerPhiAlgo() : startcn(1), incrcn(1) {
00020   LogDebug("TrackerGeom") << "DDTrackerPhiAlgo info: Creating an instance";
00021 }
00022 
00023 DDTrackerPhiAlgo::~DDTrackerPhiAlgo() {}
00024 
00025 void DDTrackerPhiAlgo::initialize(const DDNumericArguments & nArgs,
00026                                   const DDVectorArguments & vArgs,
00027                                   const DDMapArguments & ,
00028                                   const DDStringArguments & sArgs,
00029                                   const DDStringVectorArguments & )  {
00030 
00031   if ( nArgs.find("StartCopyNo") != nArgs.end() ) {
00032     startcn = size_t(nArgs["StartCopyNo"]);
00033   }
00034   if ( nArgs.find("IncrCopyNo") != nArgs.end() ) {
00035     incrcn = int(nArgs["IncrCopyNo"]);
00036   }
00037 
00038   radius     = nArgs["Radius"];
00039   tilt       = nArgs["Tilt"];
00040   phi        = vArgs["Phi"];
00041   zpos       = vArgs["ZPos"];
00042 
00043   if ( nArgs.find("NumCopies") != nArgs.end() ) {
00044     numcopies = size_t(nArgs["NumCopies"]);
00045     if ( numcopies != phi.size() ) {
00046       edm::LogError("TrackerGeom") << "DDTrackerPhiAlgo error: Parameter NumCopies "
00047                                    << "does not agree with the size of the Phi "
00048                                    << "vector.  It was adjusted to be the size "
00049                                    << "of the Phi vector and may lead to crashes "
00050                                    << "or errors.";
00051     } 
00052   }
00053   numcopies = phi.size() - 1; // -1 for loop in execute.  seems almost redundant...
00054     
00055 
00056   LogDebug("TrackerGeom") << "DDTrackerPhiAlgo debug: Parameters for position"
00057                           << "ing:: " << " Radius " << radius << " Tilt " 
00058                           << tilt/deg << " Copies " << phi.size() << " at";
00059   for (int i=0; i<(int)(phi.size()); i++)
00060     LogDebug("TrackerGeom") << "\t[" << i << "] phi = " << phi[i]/deg 
00061                             << " z = " << zpos[i];
00062 
00063   idNameSpace = DDCurrentNamespace::ns();
00064   childName   = sArgs["ChildName"]; 
00065   DDName parentName = parent().name();
00066   LogDebug("TrackerGeom") <<  "DDTrackerPhiAlgo debug: Parent " << parentName
00067                           <<"\tChild " << childName << " NameSpace " 
00068                           << idNameSpace;
00069 }
00070 
00071 void DDTrackerPhiAlgo::execute() {
00072 
00073   DDName mother = parent().name();
00074   DDName child(DDSplit(childName).first, DDSplit(childName).second);
00075   double theta  = 90.*deg;
00076   int i = 0;
00077   for (size_t ci=startcn; ci<numcopies+1; ci = ci+incrcn) {
00078     double phix = phi[i] + tilt;
00079     double phiy = phix + 90.*deg;
00080     double phideg = phi[i]/deg;
00081 
00082     std::string rotstr = DDSplit(childName).first + dbl_to_string(phideg);
00083     DDRotation rotation = DDRotation(DDName(rotstr, idNameSpace));
00084     if (!rotation) {
00085       LogDebug("TrackerGeom") << "DDTrackerPhiAlgo test: Creating a new "
00086                               << "rotation: " << rotstr << "\t" << "90., "
00087                               << phix/deg << ", 90.," << phiy/deg << ", 0, 0";
00088       rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00089                        0., 0.);
00090     }
00091         
00092     double xpos = radius*cos(phi[i]);
00093     double ypos = radius*sin(phi[i]);
00094     DDTranslation tran(xpos, ypos, zpos[i]);
00095   
00096     DDpos (child, mother, ci, tran, rotation);
00097     LogDebug("TrackerGeom") << "DDTrackerPhiAlgo test: " << child << " number "
00098                             << i+1 << " positioned in " << mother << " at "
00099                             << tran  << " with " << rotation;
00100     ++i;
00101   }
00102 }

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