File indexing completed on 2023-03-17 11:05:18
0001 #include "DD4hep/DetFactoryHelper.h"
0002 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004
0005 using namespace std;
0006 using namespace dd4hep;
0007 using namespace cms;
0008
0009 static long algorithm(Detector& , cms::DDParsingContext& ctxt, xml_h e) {
0010 cms::DDNamespace ns(ctxt, e, true);
0011 DDAlgoArguments args(ctxt, e);
0012 int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
0013 int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
0014 Volume mother = ns.volume(args.parentName());
0015 Volume child = ns.volume(args.value<string>("ChildName"));
0016 vector<double> zvec = args.value<vector<double> >("ZPositions");
0017 vector<string> rotMat = args.value<vector<string> >("Rotations");
0018
0019 edm::LogVerbatim("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
0020 << ns.name() << "\tCopyNo (Start/Increment) " << startCopyNo << ", " << incrCopyNo
0021 << "\tNumber " << zvec.size();
0022 for (int i = 0; i < (int)(zvec.size()); i++)
0023 edm::LogVerbatim("TrackerGeom") << "\t[" << i << "]\tZ = " << zvec[i] << ", Rot.Matrix = " << rotMat[i];
0024
0025 for (int i = 0, copy = startCopyNo; i < (int)(zvec.size()); i++, copy += incrCopyNo) {
0026 Position tran(0, 0, zvec[i]);
0027 Rotation3D rot;
0028 rotMat[i] != "NULL"
0029 ? mother.placeVolume(child, copy, Transform3D(ns.rotation(rotMat[i]), tran))
0030 : mother.placeVolume(child, copy, tran);
0031 edm::LogVerbatim("TrackerGeom") << "test: " << child.name() << " number " << copy << " positioned in "
0032 << mother.name() << " at " << tran << " with " << rot;
0033 }
0034 return 1;
0035 }
0036
0037
0038 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerZPosAlgo, algorithm)