Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:23

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& /* description */, 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> xvec = args.value<vector<double> >("XPositions");   // X positions
0017   vector<double> yvec = args.value<vector<double> >("YPositions");   // Y positions
0018   vector<double> zvec = args.value<vector<double> >("ZPositions");   // Z positions
0019   vector<string> rotMat = args.value<vector<string> >("Rotations");  // Names of rotation matrices
0020 
0021   edm::LogVerbatim("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
0022                                   << ns.name() << "\tCopyNo (Start/Increment) " << startCopyNo << ", " << incrCopyNo
0023                                   << "\tNumber " << xvec.size() << ", " << yvec.size() << ", " << zvec.size();
0024   for (int i = 0; i < (int)(zvec.size()); i++) {
0025     edm::LogVerbatim("TrackerGeom") << "\t[" << i << "]\tX = " << xvec[i] << "\t[" << i << "]\tY = " << yvec[i] << "\t["
0026                                     << i << "]\tZ = " << zvec[i] << ", Rot.Matrix = " << rotMat[i];
0027   }
0028 
0029   for (int i = 0, copy = startCopyNo; i < (int)(zvec.size()); i++, copy += incrCopyNo) {
0030     Position tran(xvec[i], yvec[i], zvec[i]);
0031     Rotation3D rot;
0032     /* PlacedVolume pv = */ rotMat[i] != "NULL"
0033         ? mother.placeVolume(child, copy, Transform3D(ns.rotation(rotMat[i]), tran))
0034         : mother.placeVolume(child, tran);
0035     edm::LogVerbatim("TrackerGeom") << "test: " << child.name() << " number " << copy << " positioned in "
0036                                     << mother.name() << " at " << tran << " with " << rot;
0037   }
0038   return 1;
0039 }
0040 
0041 // first argument is the type from the xml file
0042 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerXYZPosAlgo, algorithm)