CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Geometry/MuonCommonData/plugins/DDMuonAngular.cc

Go to the documentation of this file.
00001 
00002 // File: DDMuonAngular.cc
00003 // Description: Position inside the mother according to (eta,phi) 
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/DDLogicalPart.h"
00012 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00013 #include "Geometry/MuonCommonData/plugins/DDMuonAngular.h"
00014 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00015 
00016 DDMuonAngular::DDMuonAngular() {
00017   edm::LogInfo("MuonGeom") << "DDMuonAngular test: Creating an instance";
00018 }
00019 
00020 DDMuonAngular::~DDMuonAngular() {}
00021 
00022 void DDMuonAngular::initialize(const DDNumericArguments & nArgs,
00023                                const DDVectorArguments & ,
00024                                const DDMapArguments & ,
00025                                const DDStringArguments & sArgs,
00026                                const DDStringVectorArguments & ) {
00027 
00028   startAngle  = nArgs["startAngle"];
00029   stepAngle   = nArgs["stepAngle"];
00030   zoffset     = nArgs["zoffset"];
00031   n           = int (nArgs["n"]);
00032   startCopyNo = int (nArgs["startCopyNo"]);
00033   incrCopyNo  = int (nArgs["incrCopyNo"]);
00034   edm::LogInfo("MuonGeom") << "DDMuonAngular debug: Parameters for positioning-- "
00035                        << n << " copies in steps of " << stepAngle/CLHEP::deg 
00036                        << " from " << startAngle/CLHEP::deg << " \tZoffest " 
00037                        << zoffset << "\tStart and inremental copy nos " 
00038                        << startCopyNo << ", " << incrCopyNo;
00039 
00040   rotns       = sArgs["RotNameSpace"];
00041   idNameSpace = DDCurrentNamespace::ns();
00042   childName   = sArgs["ChildName"]; 
00043   DDName parentName = parent().name(); 
00044   edm::LogInfo("MuonGeom") << "DDMuonAngular debug: Parent " << parentName 
00045                        << "\tChild " << childName << "\tNameSpace "
00046                        << idNameSpace << "\tRotation Namespace " << rotns;
00047 }
00048 
00049 void DDMuonAngular::execute(DDCompactView& cpv) {
00050 
00051   double phi    = startAngle;
00052   int    copyNo = startCopyNo;
00053 
00054   for (int ii=0; ii<n; ii++) {
00055 
00056     double phideg = phi/CLHEP::deg;
00057     int    iphi;
00058     if (phideg > 0)  iphi = int(phideg+0.1);
00059     else             iphi = int(phideg-0.1);
00060     if (iphi >= 360) iphi   -= 360;
00061     phideg = iphi;
00062     DDRotation rotation;
00063     std::string rotstr("NULL");
00064 
00065     if (iphi != 0) {
00066       rotstr = "R"; 
00067       if (phideg >=0 && phideg < 10) rotstr = "R00"; 
00068       else if (phideg < 100)         rotstr = "R0";
00069       rotstr = rotstr + dbl_to_string(phideg);
00070       rotation = DDRotation(DDName(rotstr, rotns)); 
00071       if (!rotation) {
00072         edm::LogInfo("MuonGeom") << "DDMuonAngular test: Creating a new rotation "
00073                              << DDName(rotstr, idNameSpace) << "\t90, " 
00074                              << phideg << ", 90, " << (phideg+90) << ", 0, 0";
00075         rotation = DDrot(DDName(rotstr, rotns), 90*CLHEP::deg, 
00076                          phideg*CLHEP::deg, 90*CLHEP::deg, 
00077                          (90+phideg)*CLHEP::deg, 0*CLHEP::deg,  0*CLHEP::deg);
00078       } 
00079     }
00080     
00081     DDTranslation tran(0, 0, zoffset);
00082   
00083     DDName parentName = parent().name(); 
00084     cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
00085     edm::LogInfo("MuonGeom") << "DDMuonAngular test: " 
00086                          << DDName(childName, idNameSpace) << " number " 
00087                          << copyNo << " positioned in " << parentName << " at "
00088                              << tran << " with " << rotstr << " " << rotation;
00089     phi    += stepAngle;
00090     copyNo += incrCopyNo;
00091   }
00092 }