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 DDTrackerLinear : public DDAlgorithm {
0021 public:
0022
0023 DDTrackerLinear();
0024 ~DDTrackerLinear() 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 string idNameSpace;
0036 string childName;
0037 int number;
0038 int startcn;
0039 int incrcn;
0040 double theta;
0041 double phi;
0042 double offset;
0043 double delta;
0044 vector<double> centre;
0045 string rotMat;
0046 };
0047
0048 DDTrackerLinear::DDTrackerLinear() : startcn(1), incrcn(1) {
0049 LogDebug("TrackerGeom") << "DDTrackerLinear info: Creating an instance";
0050 }
0051
0052 DDTrackerLinear::~DDTrackerLinear() {}
0053
0054 void DDTrackerLinear::initialize(const DDNumericArguments& nArgs,
0055 const DDVectorArguments& vArgs,
0056 const DDMapArguments&,
0057 const DDStringArguments& sArgs,
0058 const DDStringVectorArguments&) {
0059 number = int(nArgs["Number"]);
0060 theta = nArgs["Theta"];
0061 phi = nArgs["Phi"];
0062 offset = nArgs["Offset"];
0063 delta = nArgs["Delta"];
0064 centre = vArgs["Center"];
0065 rotMat = sArgs["Rotation"];
0066 if (nArgs.find("StartCopyNo") != nArgs.end()) {
0067 startcn = size_t(nArgs["StartCopyNo"]);
0068 } else {
0069 startcn = 1;
0070 }
0071 if (nArgs.find("IncrCopyNo") != nArgs.end()) {
0072 incrcn = int(nArgs["IncrCopyNo"]);
0073 } else {
0074 incrcn = 1;
0075 }
0076
0077 idNameSpace = DDCurrentNamespace::ns();
0078 childName = sArgs["ChildName"];
0079 DDName parentName = parent().name();
0080 LogDebug("TrackerGeom") << "DDTrackerLinear debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
0081 << idNameSpace << "\tNumber " << number << "\tAxis (theta/phi) " << theta / CLHEP::deg << ", "
0082 << phi / CLHEP::deg << "\t(Offset/Delta) " << offset << ", " << delta << "\tCentre "
0083 << centre[0] << ", " << centre[1] << ", " << centre[2] << "\tRotation " << rotMat;
0084 }
0085
0086 void DDTrackerLinear::execute(DDCompactView& cpv) {
0087 DDName mother = parent().name();
0088 DDName child(DDSplit(childName).first, DDSplit(childName).second);
0089 DDTranslation direction(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
0090 DDTranslation base(centre[0], centre[1], centre[2]);
0091 string rotstr = DDSplit(rotMat).first;
0092 DDRotation rot;
0093 if (rotstr != "NULL") {
0094 string rotns = DDSplit(rotMat).second;
0095 rot = DDRotation(DDName(rotstr, rotns));
0096 }
0097 int ci = startcn;
0098 for (int i = 0; i < number; i++) {
0099 DDTranslation tran = base + (offset + double(i) * delta) * direction;
0100 cpv.position(child, mother, ci, tran, rot);
0101 LogDebug("TrackerGeom") << "DDTrackerLinear test: " << child << " number " << ci << " positioned in " << mother
0102 << " at " << tran << " with " << rot;
0103 ++ci;
0104 }
0105 }
0106
0107 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTrackerLinear, "track:DDTrackerLinear");