CMS 3D CMS Logo

DDTrackerPhiAltAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTrackerPhiAltAlgo.cc
00003 // Description: Position n copies inside and outside 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/DDPosPart.h"
00012 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00013 #include "DetectorDescription/Core/interface/DDSplit.h"
00014 #include "Geometry/TrackerCommonData/interface/DDTrackerPhiAltAlgo.h"
00015 #include "CLHEP/Units/PhysicalConstants.h"
00016 #include "CLHEP/Units/SystemOfUnits.h"
00017 
00018 
00019 DDTrackerPhiAltAlgo::DDTrackerPhiAltAlgo() {
00020   LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo info: Creating an instance";
00021 }
00022 
00023 DDTrackerPhiAltAlgo::~DDTrackerPhiAltAlgo() {}
00024 
00025 void DDTrackerPhiAltAlgo::initialize(const DDNumericArguments & nArgs,
00026                                      const DDVectorArguments & ,
00027                                      const DDMapArguments & ,
00028                                      const DDStringArguments & sArgs,
00029                                      const DDStringVectorArguments & ) {
00030 
00031   tilt       = nArgs["Tilt"];
00032   startAngle = nArgs["StartAngle"];
00033   rangeAngle = nArgs["RangeAngle"];
00034   radiusIn   = nArgs["RadiusIn"];
00035   radiusOut  = nArgs["RadiusOut"];
00036   zpos       = nArgs["ZPosition"];
00037   number     = int (nArgs["Number"]);
00038   startCopyNo= int (nArgs["StartCopyNo"]);
00039   incrCopyNo = int (nArgs["IncrCopyNo"]);
00040 
00041   LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parameters for "
00042                           << "positioning--" << " Tilt " << tilt 
00043                           << "\tStartAngle " << startAngle/deg 
00044                           << "\tRangeAngle " << rangeAngle/deg << "\tRin "
00045                           << radiusIn << "\tRout " << radiusOut << "\t ZPos "
00046                           << zpos << "\tCopy Numbers " << number 
00047                           << " Start/Increment " << startCopyNo << ", " 
00048                           << incrCopyNo;
00049 
00050   idNameSpace = DDCurrentNamespace::ns();
00051   childName   = sArgs["ChildName"]; 
00052   DDName parentName = parent().name();
00053   LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parent " << parentName
00054                           << "\tChild " << childName << " NameSpace " 
00055                           << idNameSpace;
00056 }
00057 
00058 void DDTrackerPhiAltAlgo::execute() {
00059 
00060   if (number > 0) {
00061     double theta  = 90.*deg;
00062     double dphi;
00063     if (number == 1 || fabs(rangeAngle-360.0*deg)<0.001*deg) 
00064       dphi = rangeAngle/number;
00065     else
00066       dphi = rangeAngle/(number-1);
00067     int copyNo = startCopyNo;
00068 
00069     DDName mother = parent().name();
00070     DDName child(DDSplit(childName).first, DDSplit(childName).second);
00071     for (int i=0; i<number; i++) {
00072       double phi  = startAngle + i*dphi;
00073       double phix = phi - tilt + 90.*deg;
00074       double phiy = phix + 90.*deg;
00075       double phideg = phix/deg;
00076   
00077       DDRotation rotation;
00078       if (phideg != 0) {
00079         std::string rotstr =DDSplit(childName).first+dbl_to_string(phideg*10.);
00080         rotation = DDRotation(DDName(rotstr, idNameSpace));
00081         if (!rotation) {
00082           LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo test: Creating a new"
00083                                   << " rotation " << rotstr << "\t" << "90., "
00084                                   << phix/deg << ", 90.," << phiy/deg 
00085                                   << ", 0, 0";
00086           rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta,
00087                            phiy, 0., 0.);
00088         }
00089       }
00090         
00091       double xpos, ypos;
00092       if (i%2 == 0) {
00093         xpos = radiusIn*cos(phi);
00094         ypos = radiusIn*sin(phi);
00095       } else {
00096         xpos = radiusOut*cos(phi);
00097         ypos = radiusOut*sin(phi);
00098       }
00099       DDTranslation tran(xpos, ypos, zpos);
00100   
00101       DDpos (child, mother, copyNo, tran, rotation);
00102       LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo test: " << child 
00103                               << " number " << copyNo << " positioned in " 
00104                               << mother << " at " << tran << " with " 
00105                               << rotation;
00106       copyNo += incrCopyNo;
00107     }
00108   }
00109 }

Generated on Tue Jun 9 17:37:33 2009 for CMSSW by  doxygen 1.5.4