File indexing completed on 2024-04-06 12:15:21
0001 #include "DD4hep/DetFactoryHelper.h"
0002 #include "DataFormats/Math/interface/CMSUnits.h"
0003 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005
0006 using namespace std;
0007 using namespace dd4hep;
0008 using namespace cms;
0009 using namespace cms_units::operators;
0010
0011 static long algorithm(Detector& , cms::DDParsingContext& ctxt, xml_h e) {
0012 cms::DDNamespace ns(ctxt, e, true);
0013 DDAlgoArguments args(ctxt, e);
0014 Volume mother = ns.volume(args.parentName());
0015 Volume child = ns.volume(args.childName());
0016 double startAngle = args.value<double>("StartAngle");
0017 double incrAngle = args.value<double>("IncrAngle");
0018 double zIn = args.value<double>("ZIn");
0019 double zOut = args.value<double>("ZOut");
0020 int number = args.value<double>("Number");
0021 int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
0022 int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
0023
0024 edm::LogVerbatim("TECGeom") << "debug: Parameters for "
0025 << "positioning--"
0026 << "\tStartAngle " << convertRadToDeg(startAngle) << "\tIncrAngle "
0027 << convertRadToDeg(incrAngle) << "\tZ in/out " << zIn << ", " << zOut << "\tCopy Numbers "
0028 << number << " Start/Increment " << startCopyNo << ", " << incrCopyNo;
0029 edm::LogVerbatim("TECGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
0030 << ns.name();
0031
0032 if (number > 0) {
0033 double theta = 90._deg;
0034 int copyNo = startCopyNo;
0035 for (int i = 0; i < number; i++) {
0036 double phix = startAngle + i * incrAngle;
0037 double phiy = phix + 90._deg;
0038 Rotation3D rotation = makeRotation3D(theta, phix, theta, phiy, 0, 0);
0039 Position tran(0., 0., (i % 2 == 0) ? zIn : zOut);
0040 mother.placeVolume(child, copyNo, Transform3D(rotation, tran));
0041 edm::LogVerbatim("TECGeom") << "test: " << child.name() << " number " << copyNo << " positioned in "
0042 << mother.name() << " at " << tran << " with " << rotation;
0043 copyNo += incrCopyNo;
0044 }
0045 }
0046 return 1;
0047 }
0048
0049
0050 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECPhiAlgo, algorithm)