File indexing completed on 2023-03-17 13:03:07
0001
0002
0003
0004
0005
0006 #include <cmath>
0007 #include <algorithm>
0008 #include <map>
0009 #include <string>
0010 #include <vector>
0011
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 #include "FWCore/PluginManager/interface/PluginFactory.h"
0014 #include "DataFormats/Math/interface/angle_units.h"
0015 #include "DetectorDescription/Core/interface/DDTypes.h"
0016 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0017 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0018 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0019 #include "DetectorDescription/Core/interface/DDSplit.h"
0020 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0021
0022
0023 using namespace angle_units::operators;
0024
0025 class DDHCalTBZposAlgo : public DDAlgorithm {
0026 public:
0027
0028 DDHCalTBZposAlgo();
0029 ~DDHCalTBZposAlgo() override;
0030
0031 void initialize(const DDNumericArguments& nArgs,
0032 const DDVectorArguments& vArgs,
0033 const DDMapArguments& mArgs,
0034 const DDStringArguments& sArgs,
0035 const DDStringVectorArguments& vsArgs) override;
0036
0037 void execute(DDCompactView& cpv) override;
0038
0039 private:
0040 double eta;
0041 double theta;
0042 double shiftY;
0043 double shiftX;
0044 double zoffset;
0045 double dist;
0046 double tilt;
0047 int copyNumber;
0048
0049 std::string idNameSpace;
0050 std::string childName;
0051 };
0052
0053 DDHCalTBZposAlgo::DDHCalTBZposAlgo() {
0054 #ifdef EDM_ML_DEBUG
0055 edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Creating an instance";
0056 #endif
0057 }
0058
0059 DDHCalTBZposAlgo::~DDHCalTBZposAlgo() {}
0060
0061 void DDHCalTBZposAlgo::initialize(const DDNumericArguments& nArgs,
0062 const DDVectorArguments&,
0063 const DDMapArguments&,
0064 const DDStringArguments& sArgs,
0065 const DDStringVectorArguments&) {
0066 eta = nArgs["Eta"];
0067 theta = 2.0 * atan(exp(-eta));
0068 shiftX = nArgs["ShiftX"];
0069 shiftY = nArgs["ShiftY"];
0070 zoffset = nArgs["Zoffset"];
0071 dist = nArgs["Distance"];
0072 tilt = nArgs["TiltAngle"];
0073 copyNumber = int(nArgs["Number"]);
0074 edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parameters for position"
0075 << "ing--"
0076 << " Eta " << eta << "\tTheta " << convertRadToDeg(theta) << "\tShifts " << shiftX
0077 << ", " << shiftY << " along x, y "
0078 << "axes; \tZoffest " << zoffset << "\tRadial Distance " << dist << "\tTilt angle "
0079 << convertRadToDeg(tilt) << "\tcopyNumber " << copyNumber;
0080
0081 idNameSpace = DDCurrentNamespace::ns();
0082 childName = sArgs["ChildName"];
0083 #ifdef EDM_ML_DEBUG
0084 edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parent " << parent().name() << "\tChild " << childName
0085 << " NameSpace " << idNameSpace;
0086 #endif
0087 }
0088
0089 void DDHCalTBZposAlgo::execute(DDCompactView& cpv) {
0090 DDName mother = parent().name();
0091 DDName child(DDSplit(childName).first, DDSplit(childName).second);
0092
0093 double thetax = 90._deg - theta;
0094 double z = zoffset + dist * tan(thetax);
0095 double x = shiftX - shiftY * sin(tilt);
0096 double y = shiftY * cos(tilt);
0097 DDTranslation tran(x, y, z);
0098 DDRotation rot;
0099 if (tilt != 0) {
0100 std::string rotstr = "R" + formatAsDegrees(tilt);
0101 rot = DDRotation(DDName(rotstr, idNameSpace));
0102 if (!rot) {
0103 #ifdef EDM_ML_DEBUG
0104 edm::LogVerbatim("HCalGeom") << "DDHCalZposAlgo: Creating a rotation " << DDName(rotstr, idNameSpace) << "\t90, "
0105 << convertRadToDeg(tilt) << ",90," << (90 + convertRadToDeg(tilt)) << ", 0, 0";
0106 #endif
0107 rot = DDrot(DDName(rotstr, idNameSpace), 90._deg, tilt, 90._deg, (90._deg + tilt), 0.0, 0.0);
0108 }
0109 }
0110 cpv.position(child, mother, copyNumber, tran, rot);
0111 #ifdef EDM_ML_DEBUG
0112 edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: " << child << " number " << copyNumber << " positioned in "
0113 << mother << " at " << tran << " with " << rot;
0114 #endif
0115 }
0116
0117 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalTBZposAlgo, "hcal:DDHCalTBZposAlgo");