File indexing completed on 2024-04-06 12:15:22
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 int startcn = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
0017 int incrcn = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
0018 vector<double> phi = args.value<vector<double> >("Phi");
0019 vector<double> zpos = args.value<vector<double> >("ZPos");
0020 int numcopies = args.find("NumCopies") ? args.value<int>("NumCopies") : int(phi.size());
0021 double radius = args.value<double>("Radius");
0022 double tilt = args.value<double>("Tilt");
0023
0024 if (numcopies != int(phi.size())) {
0025 edm::LogVerbatim("TrackerGeom") << "error: Parameter "
0026 << "NumCopies does not agree with the size "
0027 << "of the Phi vector. It was adjusted to "
0028 << "be the size of the Phi vector and may "
0029 << "lead to crashes or errors.";
0030 }
0031 edm::LogVerbatim("TrackerGeom") << "debug: Parameters for position"
0032 << "ing:: "
0033 << " Radius " << radius << " Tilt " << tilt << " Copies " << phi.size() << " at";
0034 for (int i = 0; i < (int)(phi.size()); i++)
0035 edm::LogVerbatim("TrackerGeom") << "\t[" << i << "] phi = " << phi[i] << " z = " << zpos[i];
0036 edm::LogVerbatim("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
0037 << ns.name();
0038
0039 double theta = 90._deg;
0040 int ci = startcn;
0041 for (int i = 0; i < numcopies; ++i) {
0042 double phix = phi[i] + tilt;
0043 double phiy = phix + 90._deg;
0044 double xpos = radius * cos(phi[i]);
0045 double ypos = radius * sin(phi[i]);
0046 Rotation3D rot = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
0047 Position tran(xpos, ypos, zpos[i]);
0048 mother.placeVolume(child, ci, Transform3D(rot, tran));
0049 edm::LogVerbatim("TrackerGeom") << "test: " << child.name() << " number " << ci << " positioned in "
0050 << mother.name() << " at " << tran << " with " << rot;
0051 ci = ci + incrcn;
0052 }
0053 return 1;
0054 }
0055
0056
0057 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerPhiAlgo, algorithm)