CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Geometry/MuonCommonData/plugins/DDGEMAngular.cc

Go to the documentation of this file.
00001 
00002 // File: DDGEMAngular.cc
00003 // Description: Position inside the mother according to (eta,phi) 
00005 
00006 #include <cmath>
00007 #include <algorithm>
00008 #include <iostream>
00009 
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "DetectorDescription/Base/interface/DDutils.h"
00012 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00013 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00014 #include "Geometry/MuonCommonData/plugins/DDGEMAngular.h"
00015 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00016 
00017 DDGEMAngular::DDGEMAngular() {
00018   edm::LogInfo("MuonGeom") << "DDGEMAngular test: Creating an instance";
00019 }
00020 
00021 DDGEMAngular::~DDGEMAngular() {}
00022 
00023 void DDGEMAngular::initialize(const DDNumericArguments & nArgs,
00024                                const DDVectorArguments & ,
00025                                const DDMapArguments & ,
00026                                const DDStringArguments & sArgs,
00027                                const DDStringVectorArguments & ) {
00028 
00029   startAngle  = nArgs["startAngle"];
00030   stepAngle   = nArgs["stepAngle"];
00031   invert      = int (nArgs["invert"]);
00032   rPos        = nArgs["rPosition"];
00033   zoffset     = nArgs["zoffset"];
00034   n           = int (nArgs["n"]);
00035   startCopyNo = int (nArgs["startCopyNo"]);
00036   incrCopyNo  = int (nArgs["incrCopyNo"]);
00037   edm::LogInfo("MuonGeom") << "DDGEMAngular debug: Parameters for positioning-- "
00038                        << n << " copies in steps of " << stepAngle/CLHEP::deg 
00039                        << " from " << startAngle/CLHEP::deg 
00040                        << " (inversion flag " << invert << ") \trPos " << rPos
00041                        << " Zoffest " << zoffset << "\tStart and inremental "
00042                        << "copy nos " << startCopyNo << ", " << incrCopyNo
00043                        << std::endl;
00044 
00045   rotns       = sArgs["RotNameSpace"];
00046   idNameSpace = DDCurrentNamespace::ns();
00047   childName   = sArgs["ChildName"]; 
00048   DDName parentName = parent().name(); 
00049   edm::LogInfo("MuonGeom") << "DDGEMAngular debug: Parent " << parentName 
00050                        << "\tChild " << childName << "\tNameSpace "
00051                        << idNameSpace << "\tRotation Namespace " << rotns << std::endl;
00052 }
00053 
00054 void DDGEMAngular::execute(DDCompactView& cpv) {
00055 
00056   double phi    = startAngle;
00057   int    copyNo = startCopyNo;
00058 
00059   for (int ii=0; ii<n; ii++) {
00060 
00061     double phideg = phi/CLHEP::deg;
00062     int    iphi;
00063     if (phideg > 0)  iphi = int(phideg+0.1);
00064     else             iphi = int(phideg-0.1);
00065     if (iphi >= 360) iphi   -= 360;
00066     phideg = iphi;
00067     DDRotation rotation;
00068     std::string rotstr("NULL");
00069 
00070     rotstr = "RG"; 
00071     if (invert > 0)                rotstr += "I";
00072     if (phideg >=0 && phideg < 10) rotstr += "00"; 
00073     else if (phideg < 100)         rotstr += "0";
00074     rotstr  += dbl_to_string(phideg);
00075     rotation = DDRotation(DDName(rotstr, rotns)); 
00076     if (!rotation) {
00077       double thetax = 90.0;
00078       double phix   = invert==0 ? (90.0+phideg) : (-90.0+phideg);
00079       double thetay = invert==0 ? 0.0 : 180.0;
00080       double phiz   = phideg;
00081       edm::LogInfo("MuonGeom") << "DDGEMAngular test: Creating a new rotation "
00082                              << DDName(rotstr, idNameSpace) << "\t " 
00083                              << thetax << ", " << phix << ", " << thetay
00084                              << ", 0, " << thetax << ", " << phiz << std::endl;
00085       rotation = DDrot(DDName(rotstr, rotns), thetax*CLHEP::deg, 
00086                        phix*CLHEP::deg, thetay*CLHEP::deg, 0*CLHEP::deg,
00087                        thetax*CLHEP::deg, phiz*CLHEP::deg);
00088     } 
00089     
00090     DDTranslation tran(rPos*cos(phideg*CLHEP::deg), rPos*sin(phideg*CLHEP::deg), zoffset);
00091   
00092     DDName parentName = parent().name(); 
00093     cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
00094     edm::LogInfo("MuonGeom") << "DDGEMAngular test: " 
00095                          << DDName(childName, idNameSpace) << " number " 
00096                          << copyNo << " positioned in " << parentName << " at "
00097                          << tran << " with " << rotstr << " " << rotation << "\n";
00098     phi    += stepAngle;
00099     copyNo += incrCopyNo;
00100   }
00101 }