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