File indexing completed on 2023-03-17 11:05:22
0001
0002
0003
0004
0005
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0008 #include "DetectorDescription/Core/interface/DDSplit.h"
0009 #include "DetectorDescription/Core/interface/DDTypes.h"
0010 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0011 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0012 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0013 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0014
0015 #include <string>
0016 #include <vector>
0017
0018 using namespace std;
0019
0020 class DDTrackerPhiAltAlgo : public DDAlgorithm {
0021 public:
0022
0023 DDTrackerPhiAltAlgo();
0024 ~DDTrackerPhiAltAlgo() override;
0025
0026 void initialize(const DDNumericArguments& nArgs,
0027 const DDVectorArguments& vArgs,
0028 const DDMapArguments& mArgs,
0029 const DDStringArguments& sArgs,
0030 const DDStringVectorArguments& vsArgs) override;
0031
0032 void execute(DDCompactView& cpv) override;
0033
0034 private:
0035 double tilt;
0036 double startAngle;
0037 double rangeAngle;
0038 double radiusIn;
0039 double radiusOut;
0040 double zpos;
0041 int number;
0042 int startCopyNo;
0043 int incrCopyNo;
0044
0045 string idNameSpace;
0046 string childName;
0047 };
0048
0049 DDTrackerPhiAltAlgo::DDTrackerPhiAltAlgo() {
0050 LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo info: Creating an instance";
0051 }
0052
0053 DDTrackerPhiAltAlgo::~DDTrackerPhiAltAlgo() {}
0054
0055 void DDTrackerPhiAltAlgo::initialize(const DDNumericArguments& nArgs,
0056 const DDVectorArguments&,
0057 const DDMapArguments&,
0058 const DDStringArguments& sArgs,
0059 const DDStringVectorArguments&) {
0060 tilt = nArgs["Tilt"];
0061 startAngle = nArgs["StartAngle"];
0062 rangeAngle = nArgs["RangeAngle"];
0063 radiusIn = nArgs["RadiusIn"];
0064 radiusOut = nArgs["RadiusOut"];
0065 zpos = nArgs["ZPosition"];
0066 number = int(nArgs["Number"]);
0067 startCopyNo = int(nArgs["StartCopyNo"]);
0068 incrCopyNo = int(nArgs["IncrCopyNo"]);
0069
0070 LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parameters for "
0071 << "positioning--"
0072 << " Tilt " << tilt << "\tStartAngle " << startAngle / CLHEP::deg << "\tRangeAngle "
0073 << rangeAngle / CLHEP::deg << "\tRin " << radiusIn << "\tRout " << radiusOut << "\t ZPos "
0074 << zpos << "\tCopy Numbers " << number << " Start/Increment " << startCopyNo << ", "
0075 << incrCopyNo;
0076
0077 idNameSpace = DDCurrentNamespace::ns();
0078 childName = sArgs["ChildName"];
0079 DDName parentName = parent().name();
0080 LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parent " << parentName << "\tChild " << childName
0081 << " NameSpace " << idNameSpace;
0082 }
0083
0084 void DDTrackerPhiAltAlgo::execute(DDCompactView& cpv) {
0085 if (number > 0) {
0086 double theta = 90. * CLHEP::deg;
0087 double dphi;
0088 if (number == 1 || fabs(rangeAngle - 360.0 * CLHEP::deg) < 0.001 * CLHEP::deg)
0089 dphi = rangeAngle / number;
0090 else
0091 dphi = rangeAngle / (number - 1);
0092 int copyNo = startCopyNo;
0093
0094 DDName mother = parent().name();
0095 DDName child(DDSplit(childName).first, DDSplit(childName).second);
0096 for (int i = 0; i < number; i++) {
0097 double phi = startAngle + i * dphi;
0098 double phix = phi - tilt + 90. * CLHEP::deg;
0099 double phiy = phix + 90. * CLHEP::deg;
0100 double phideg = phix / CLHEP::deg;
0101
0102 DDRotation rotation;
0103 if (phideg != 0) {
0104 string rotstr = DDSplit(childName).first + to_string(phideg * 10.);
0105 rotation = DDRotation(DDName(rotstr, idNameSpace));
0106 if (!rotation) {
0107 LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo test: Creating a new"
0108 << " rotation " << rotstr << "\t"
0109 << "90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg << ", 0, 0";
0110 rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
0111 }
0112 }
0113
0114 double xpos, ypos;
0115 if (i % 2 == 0) {
0116 xpos = radiusIn * cos(phi);
0117 ypos = radiusIn * sin(phi);
0118 } else {
0119 xpos = radiusOut * cos(phi);
0120 ypos = radiusOut * sin(phi);
0121 }
0122 DDTranslation tran(xpos, ypos, zpos);
0123
0124 cpv.position(child, mother, copyNo, tran, rotation);
0125 LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo test: " << child << " number " << copyNo << " positioned in "
0126 << mother << " at " << tran << " with " << rotation;
0127 copyNo += incrCopyNo;
0128 }
0129 }
0130 }
0131
0132 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTrackerPhiAltAlgo, "track:DDTrackerPhiAltAlgo");