Go to the documentation of this file.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/DDCurrentNamespace.h"
00012 #include "DetectorDescription/Core/interface/DDSplit.h"
00013 #include "Geometry/TrackerCommonData/interface/DDTECPhiAltAlgo.h"
00014 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00015 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00016
00017
00018 DDTECPhiAltAlgo::DDTECPhiAltAlgo() {
00019 LogDebug("TECGeom") << "DDTECPhiAltAlgo info: Creating an instance";
00020 }
00021
00022 DDTECPhiAltAlgo::~DDTECPhiAltAlgo() {}
00023
00024 void DDTECPhiAltAlgo::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 radius = nArgs["Radius"];
00033 zIn = nArgs["ZIn"];
00034 zOut = nArgs["ZOut"];
00035 number = int (nArgs["Number"]);
00036 startCopyNo= int (nArgs["StartCopyNo"]);
00037 incrCopyNo = int (nArgs["IncrCopyNo"]);
00038
00039 LogDebug("TECGeom") << "DDTECPhiAltAlgo debug: Parameters for "
00040 << "positioning--" << "\tStartAngle "
00041 << startAngle/CLHEP::deg << "\tIncrAngle "
00042 << incrAngle/CLHEP::deg << "\tRadius " << radius
00043 << "\tZ in/out " << zIn << ", " << zOut
00044 << "\tCopy Numbers " << number << " Start/Increment "
00045 << startCopyNo << ", " << incrCopyNo;
00046
00047 idNameSpace = DDCurrentNamespace::ns();
00048 childName = sArgs["ChildName"];
00049 DDName parentName = parent().name();
00050 LogDebug("TECGeom") << "DDTECPhiAltAlgo debug: Parent " << parentName
00051 << "\tChild " << childName << " NameSpace "
00052 << idNameSpace;
00053 }
00054
00055 void DDTECPhiAltAlgo::execute(DDCompactView& cpv) {
00056
00057 if (number > 0) {
00058 double theta = 90.*CLHEP::deg;
00059 int copyNo = startCopyNo;
00060
00061 DDName mother = parent().name();
00062 DDName child(DDSplit(childName).first, DDSplit(childName).second);
00063 for (int i=0; i<number; i++) {
00064 double phiz = startAngle + i*incrAngle;
00065 double phix = phiz + 90.*CLHEP::deg;
00066 double phideg = phiz/CLHEP::deg;
00067
00068 DDRotation rotation;
00069 std::string rotstr = DDSplit(childName).first+dbl_to_string(phideg*10.);
00070 rotation = DDRotation(DDName(rotstr, idNameSpace));
00071 if (!rotation) {
00072 LogDebug("TECGeom") << "DDTECPhiAltAlgo test: Creating a new "
00073 << "rotation " << rotstr << "\t"
00074 << theta/CLHEP::deg << ", " << phix/CLHEP::deg
00075 << ", 0, 0, " << theta/CLHEP::deg << ", "
00076 << phiz/CLHEP::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 cpv.position(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 }