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