CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Geometry/HcalAlgo/plugins/DDHCalAngular.cc

Go to the documentation of this file.
00001 
00002 // File: DDHCalAngular.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/HcalAlgo/plugins/DDHCalAngular.h"
00014 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00015 
00016 DDHCalAngular::DDHCalAngular() {
00017   LogDebug("HCalGeom") << "DDHCalAngular test: Creating an instance";
00018 }
00019 
00020 DDHCalAngular::~DDHCalAngular() {}
00021 
00022 void DDHCalAngular::initialize(const DDNumericArguments & nArgs,
00023                                const DDVectorArguments & ,
00024                                const DDMapArguments & ,
00025                                const DDStringArguments & sArgs,
00026                                const DDStringVectorArguments & ) {
00027 
00028   startAngle  = nArgs["startAngle"];
00029   rangeAngle  = nArgs["rangeAngle"];
00030   shiftX      = nArgs["shiftX"];
00031   shiftY      = nArgs["shiftY"];
00032   zoffset     = nArgs["zoffset"];
00033   n           = int (nArgs["n"]);
00034   startCopyNo = int (nArgs["startCopyNo"]);
00035   incrCopyNo  = int (nArgs["incrCopyNo"]);
00036   LogDebug("HCalGeom") << "DDHCalAngular debug: Parameters for positioning-- "
00037                        << n << " copies in " << rangeAngle/CLHEP::deg 
00038                        << " from " << startAngle/CLHEP::deg << "\tShifts " 
00039                        << shiftX << ", " << shiftY 
00040                        << " along x, y axes; \tZoffest " << zoffset
00041                        << "\tStart and inremental copy nos " << startCopyNo 
00042                        << ", " << incrCopyNo;
00043 
00044   rotns       = sArgs["RotNameSpace"];
00045   idNameSpace = DDCurrentNamespace::ns();
00046   childName   = sArgs["ChildName"]; 
00047   DDName parentName = parent().name(); 
00048   LogDebug("HCalGeom") << "DDHCalAngular debug: Parent " << parentName 
00049                        << "\tChild " << childName << "\tNameSpace "
00050                        << idNameSpace << "\tRotation Namespace " << rotns;
00051 }
00052 
00053 void DDHCalAngular::execute(DDCompactView& cpv) {
00054 
00055   double dphi   = rangeAngle/n;
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     if (iphi != 0) {
00071       rotstr = "R"; 
00072       if (phideg >=0 && phideg < 100) rotstr = "R0"; 
00073       rotstr = rotstr + dbl_to_string(phideg);
00074       rotation = DDRotation(DDName(rotstr, rotns)); 
00075       if (!rotation) {
00076         LogDebug("HCalGeom") << "DDHCalAngular test: Creating a new rotation "
00077                              << DDName(rotstr, idNameSpace) << "\t90, " 
00078                              << phideg << ", 90, " << (phideg+90) << ", 0, 0";
00079         rotation = DDrot(DDName(rotstr, rotns), 90*CLHEP::deg, 
00080                          phideg*CLHEP::deg, 90*CLHEP::deg, 
00081                          (90+phideg)*CLHEP::deg, 0*CLHEP::deg,  0*CLHEP::deg);
00082       } 
00083     }
00084     
00085     double xpos = shiftX*cos(phi) - shiftY*sin(phi);
00086     double ypos = shiftX*sin(phi) + shiftY*cos(phi);
00087     DDTranslation tran(xpos, ypos, zoffset);
00088   
00089     DDName parentName = parent().name(); 
00090    cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
00091     LogDebug("HCalGeom") << "DDHCalAngular test: " 
00092                          << DDName(childName, idNameSpace) << " number " 
00093                          << copyNo << " positioned in " << parentName << " at "
00094                          << tran << " with " << rotation;
00095     phi    += dphi;
00096     copyNo += incrCopyNo;
00097   }
00098 }