CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Geometry/TrackerCommonData/plugins/DDTECPhiAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTECPhiAlgo.cc
00003 // Description: Position n copies inside and outside Z at alternate 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/DDTECPhiAlgo.h"
00014 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00015 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00016 
00017 
00018 DDTECPhiAlgo::DDTECPhiAlgo() {
00019   LogDebug("TECGeom") << "DDTECPhiAlgo info: Creating an instance";
00020 }
00021 
00022 DDTECPhiAlgo::~DDTECPhiAlgo() {}
00023 
00024 void DDTECPhiAlgo::initialize(const DDNumericArguments & nArgs,
00025                               const DDVectorArguments & ,
00026                               const DDMapArguments & ,
00027                               const DDStringArguments & sArgs,
00028                               const DDStringVectorArguments & ) {
00029 
00030   startAngle = nArgs["StartAngle"];
00031   incrAngle  = nArgs["IncrAngle"];
00032   zIn        = nArgs["ZIn"];
00033   zOut       = nArgs["ZOut"];
00034   number     = int (nArgs["Number"]);
00035   startCopyNo= int (nArgs["StartCopyNo"]);
00036   incrCopyNo = int (nArgs["IncrCopyNo"]);
00037 
00038   LogDebug("TECGeom") << "DDTECPhiAlgo debug: Parameters for "
00039                       << "positioning--" << "\tStartAngle " 
00040                       << startAngle/CLHEP::deg << "\tIncrAngle " 
00041                       << incrAngle/CLHEP::deg << "\tZ in/out " << zIn << ", " 
00042                       << zOut         << "\tCopy Numbers " << number 
00043                       << " Start/Increment " << startCopyNo << ", " 
00044                       << incrCopyNo;
00045 
00046   idNameSpace = DDCurrentNamespace::ns();
00047   childName   = sArgs["ChildName"]; 
00048   DDName parentName = parent().name();
00049   LogDebug("TECGeom") << "DDTECPhiAlgo debug: Parent " << parentName 
00050                       << "\tChild " << childName << " NameSpace " 
00051                       << idNameSpace;
00052 }
00053 
00054 void DDTECPhiAlgo::execute(DDCompactView& cpv) {
00055 
00056   if (number > 0) {
00057     double theta  = 90.*CLHEP::deg;
00058     int    copyNo = startCopyNo;
00059 
00060     DDName mother = parent().name();
00061     DDName child(DDSplit(childName).first, DDSplit(childName).second);
00062     for (int i=0; i<number; i++) {
00063       double phix = startAngle + i*incrAngle;
00064       double phiy = phix + 90.*CLHEP::deg;
00065       double phideg = phix/CLHEP::deg;
00066   
00067       DDRotation rotation;
00068       std::string rotstr = DDSplit(childName).first+dbl_to_string(phideg*10.);
00069       rotation = DDRotation(DDName(rotstr, idNameSpace));
00070       if (!rotation) {
00071         LogDebug("TECGeom") << "DDTECPhiAlgo test: Creating a new "
00072                             << "rotation " << rotstr << "\t" 
00073                             << theta/CLHEP::deg << ", " << phix/CLHEP::deg 
00074                             << ", " << theta/CLHEP::deg << ", "
00075                             << phiy/CLHEP::deg << ", 0, 0";
00076         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00077                          0., 0.);
00078       }
00079         
00080       double zpos = zOut;
00081       if (i%2 == 0) zpos = zIn;
00082       DDTranslation tran(0., 0., zpos);
00083   
00084      cpv.position(child, mother, copyNo, tran, rotation);
00085       LogDebug("TECGeom") << "DDTECPhiAlgo test: " << child <<" number "
00086                           << copyNo << " positioned in " << mother <<" at "
00087                           << tran << " with " << rotation;
00088       copyNo += incrCopyNo;
00089     }
00090   }
00091 }