CMS 3D CMS Logo

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