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
0013 #include <string>
0014 #include <vector>
0015
0016 using namespace std;
0017
0018 class DDTrackerZPosAlgo : public DDAlgorithm {
0019 public:
0020
0021 DDTrackerZPosAlgo();
0022 ~DDTrackerZPosAlgo() override;
0023
0024 void initialize(const DDNumericArguments& nArgs,
0025 const DDVectorArguments& vArgs,
0026 const DDMapArguments& mArgs,
0027 const DDStringArguments& sArgs,
0028 const DDStringVectorArguments& vsArgs) override;
0029
0030 void execute(DDCompactView& cpv) override;
0031
0032 private:
0033 vector<double> zvec;
0034 vector<string> rotMat;
0035
0036 string idNameSpace;
0037 string childName;
0038 int startCopyNo;
0039 int incrCopyNo;
0040 };
0041
0042 DDTrackerZPosAlgo::DDTrackerZPosAlgo() { LogDebug("TrackerGeom") << "DDTrackerZPosAlgo info: Creating an instance"; }
0043
0044 DDTrackerZPosAlgo::~DDTrackerZPosAlgo() {}
0045
0046 void DDTrackerZPosAlgo::initialize(const DDNumericArguments& nArgs,
0047 const DDVectorArguments& vArgs,
0048 const DDMapArguments&,
0049 const DDStringArguments& sArgs,
0050 const DDStringVectorArguments& vsArgs) {
0051 startCopyNo = int(nArgs["StartCopyNo"]);
0052 incrCopyNo = int(nArgs["IncrCopyNo"]);
0053 zvec = vArgs["ZPositions"];
0054 rotMat = vsArgs["Rotations"];
0055
0056 idNameSpace = DDCurrentNamespace::ns();
0057 childName = sArgs["ChildName"];
0058 DDName parentName = parent().name();
0059 LogDebug("TrackerGeom") << "DDTrackerZPosAlgo debug: Parent " << parentName << "\tChild " << childName
0060 << " NameSpace " << idNameSpace << "\tCopyNo (Start/Increment) " << startCopyNo << ", "
0061 << incrCopyNo << "\tNumber " << zvec.size();
0062 for (int i = 0; i < (int)(zvec.size()); i++) {
0063 LogDebug("TrackerGeom") << "\t[" << i << "]\tZ = " << zvec[i] << ", Rot.Matrix = " << rotMat[i];
0064 }
0065 }
0066
0067 void DDTrackerZPosAlgo::execute(DDCompactView& cpv) {
0068 int copy = startCopyNo;
0069 DDName mother = parent().name();
0070 DDName child(DDSplit(childName).first, DDSplit(childName).second);
0071
0072 for (int i = 0; i < (int)(zvec.size()); i++) {
0073 DDTranslation tran(0, 0, zvec[i]);
0074 string rotstr = DDSplit(rotMat[i]).first;
0075 DDRotation rot;
0076 if (rotstr != "NULL") {
0077 string rotns = DDSplit(rotMat[i]).second;
0078 rot = DDRotation(DDName(rotstr, rotns));
0079 }
0080 cpv.position(child, mother, copy, tran, rot);
0081 LogDebug("TrackerGeom") << "DDTrackerZPosAlgo test: " << child << " number " << copy << " positioned in " << mother
0082 << " at " << tran << " with " << rot;
0083 copy += incrCopyNo;
0084 }
0085 }
0086
0087 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTrackerZPosAlgo, "track:DDTrackerZPosAlgo");