File indexing completed on 2024-05-10 02:20:55
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/SystemOfUnits.h>
0014
0015 #include <string>
0016 #include <vector>
0017
0018 using namespace std;
0019
0020 class DDTrackerAngular : public DDAlgorithm {
0021 public:
0022
0023 DDTrackerAngular();
0024 ~DDTrackerAngular() 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 int n;
0036 int startCopyNo;
0037 int incrCopyNo;
0038 double rangeAngle;
0039 double startAngle;
0040 double radius;
0041 vector<double> center;
0042 double delta;
0043
0044 string idNameSpace;
0045 string childName;
0046 };
0047
0048 DDTrackerAngular::DDTrackerAngular() { LogDebug("TrackerGeom") << "DDTrackerAngular info: Creating an instance"; }
0049
0050 DDTrackerAngular::~DDTrackerAngular() {}
0051
0052 void DDTrackerAngular::initialize(const DDNumericArguments& nArgs,
0053 const DDVectorArguments& vArgs,
0054 const DDMapArguments&,
0055 const DDStringArguments& sArgs,
0056 const DDStringVectorArguments&) {
0057 n = int(nArgs["N"]);
0058 startCopyNo = int(nArgs["StartCopyNo"]);
0059 incrCopyNo = int(nArgs["IncrCopyNo"]);
0060 rangeAngle = nArgs["RangeAngle"];
0061 startAngle = nArgs["StartAngle"];
0062 radius = nArgs["Radius"];
0063 center = vArgs["Center"];
0064
0065 if (fabs(rangeAngle - 360.0 * CLHEP::deg) < 0.001 * CLHEP::deg) {
0066 delta = rangeAngle / double(n);
0067 } else {
0068 if (n > 1) {
0069 delta = rangeAngle / double(n - 1);
0070 } else {
0071 delta = 0.;
0072 }
0073 }
0074
0075 LogDebug("TrackerGeom") << "DDTrackerAngular debug: Parameters for position"
0076 << "ing:: n " << n << " Start, Range, Delta " << startAngle / CLHEP::deg << " "
0077 << rangeAngle / CLHEP::deg << " " << delta / CLHEP::deg << " Radius " << radius << " Centre "
0078 << center[0] << ", " << center[1] << ", " << center[2];
0079
0080 idNameSpace = DDCurrentNamespace::ns();
0081 childName = sArgs["ChildName"];
0082
0083 DDName parentName = parent().name();
0084 LogDebug("TrackerGeom") << "DDTrackerAngular debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
0085 << idNameSpace;
0086 }
0087
0088 void DDTrackerAngular::execute(DDCompactView& cpv) {
0089 DDName mother = parent().name();
0090 DDName child(DDSplit(childName).first, DDSplit(childName).second);
0091 double theta = 90. * CLHEP::deg;
0092 int copy = startCopyNo;
0093 double phi = startAngle;
0094 for (int i = 0; i < n; i++) {
0095 double phix = phi;
0096 double phiy = phix + 90. * CLHEP::deg;
0097 double phideg = phix / CLHEP::deg;
0098
0099 DDRotation rotation;
0100 if (phideg != 0) {
0101 string rotstr = DDSplit(childName).first + to_string(phideg * 10.);
0102 rotation = DDRotation(DDName(rotstr, idNameSpace));
0103 if (!rotation) {
0104 LogDebug("TrackerGeom") << "DDTrackerAngular test: Creating a new "
0105 << "rotation: " << rotstr << "\t90., " << phix / CLHEP::deg << ", 90.,"
0106 << phiy / CLHEP::deg << ", 0, 0";
0107 rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
0108 }
0109 }
0110
0111 double xpos = radius * cos(phi) + center[0];
0112 double ypos = radius * sin(phi) + center[1];
0113 double zpos = center[2];
0114 DDTranslation tran(xpos, ypos, zpos);
0115
0116 cpv.position(child, mother, copy, tran, rotation);
0117 LogDebug("TrackerGeom") << "DDTrackerAngular test " << child << " number " << copy << " positioned in " << mother
0118 << " at " << tran << " with " << rotation;
0119 copy += incrCopyNo;
0120 phi += delta;
0121 }
0122 }
0123
0124 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTrackerAngular, "track:DDTrackerAngular");