File indexing completed on 2024-05-10 02:20:53
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "DetectorDescription/Core/interface/DDutils.h"
0011 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0012 #include "DetectorDescription/Core/interface/DDSplit.h"
0013 #include "DetectorDescription/Core/interface/DDTypes.h"
0014 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0015 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0016 #include <CLHEP/Units/GlobalPhysicalConstants.h>
0017 #include <CLHEP/Units/SystemOfUnits.h>
0018
0019 #include <cmath>
0020 #include <algorithm>
0021 #include <map>
0022 #include <string>
0023 #include <vector>
0024
0025 using namespace std;
0026
0027 class DDTECCoolAlgo : public DDAlgorithm {
0028 public:
0029
0030 DDTECCoolAlgo();
0031 ~DDTECCoolAlgo() override;
0032
0033 void initialize(const DDNumericArguments& nArgs,
0034 const DDVectorArguments& vArgs,
0035 const DDMapArguments& mArgs,
0036 const DDStringArguments& sArgs,
0037 const DDStringVectorArguments& vsArgs) override;
0038
0039 void execute(DDCompactView& cpv) override;
0040
0041 private:
0042 string idNameSpace;
0043 int startCopyNo;
0044 double rPosition;
0045 vector<double> phiPosition;
0046 vector<string> coolInsert;
0047 };
0048
0049 DDTECCoolAlgo::DDTECCoolAlgo() : phiPosition(0), coolInsert(0) {
0050 LogDebug("TECGeom") << "DDTECCoolAlgo info: Creating an instance";
0051 }
0052
0053 DDTECCoolAlgo::~DDTECCoolAlgo() {}
0054
0055 void DDTECCoolAlgo::initialize(const DDNumericArguments& nArgs,
0056 const DDVectorArguments& vArgs,
0057 const DDMapArguments&,
0058 const DDStringArguments& sArgs,
0059 const DDStringVectorArguments& vsArgs) {
0060 idNameSpace = DDCurrentNamespace::ns();
0061 startCopyNo = int(nArgs["StartCopyNo"]);
0062
0063 DDName parentName = parent().name();
0064 rPosition = nArgs["RPosition"];
0065 LogDebug("TECGeom") << "DDTECCoolAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace
0066 << " at radial Position " << rPosition;
0067 phiPosition = vArgs["PhiPosition"];
0068 coolInsert = vsArgs["CoolInsert"];
0069 if (phiPosition.size() == coolInsert.size()) {
0070 for (int i = 0; i < (int)(phiPosition.size()); i++)
0071 LogDebug("TECGeom") << "DDTECCoolAlgo debug: Insert[" << i << "]: " << coolInsert.at(i) << " at Phi "
0072 << phiPosition.at(i) / CLHEP::deg;
0073 } else {
0074 LogDebug("TECGeom") << "ERROR: Number of inserts does not match the numer of PhiPositions!";
0075 }
0076 LogDebug("TECGeom") << " Done creating instance of DDTECCoolAlgo ";
0077 }
0078
0079 void DDTECCoolAlgo::execute(DDCompactView& cpv) {
0080 LogDebug("TECGeom") << "==>> Constructing DDTECCoolAlgo...";
0081 int copyNo = startCopyNo;
0082
0083 for (int i = 0; i < (int)(coolInsert.size()); i++) {
0084
0085 DDName child = DDName(DDSplit(coolInsert.at(i)).first, DDSplit(coolInsert.at(i)).second);
0086 DDName mother = parent().name();
0087
0088 double xpos = rPosition * cos(phiPosition.at(i));
0089 double ypos = -rPosition * sin(phiPosition.at(i));
0090
0091 DDTranslation tran(xpos, ypos, 0.0);
0092 DDRotation rotation;
0093 cpv.position(child, mother, copyNo, tran, rotation);
0094 LogDebug("TECGeom") << "DDTECCoolAlgo test " << child << "[" << copyNo << "] positioned in " << mother << " at "
0095 << tran << " with " << rotation << " phi " << phiPosition.at(i) / CLHEP::deg << " r "
0096 << rPosition;
0097 copyNo++;
0098 }
0099 LogDebug("TECGeom") << "<<== End of DDTECCoolAlgo construction ...";
0100 }
0101
0102 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTECCoolAlgo, "track:DDTECCoolAlgo");