Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 startcn = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
0013   int incrcn = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
0014   int number = args.value<int>("Number");
0015   double theta = args.value<double>("Theta");
0016   double phi = args.value<double>("Phi");
0017   double offset = args.value<double>("Offset");
0018   double delta = args.value<double>("Delta");
0019   vector<double> centre = args.value<vector<double> >("Center");
0020   string rotMat = args.value<string>("Rotation");
0021   Volume mother = ns.volume(args.parentName());
0022   Volume child = ns.volume(args.value<string>("ChildName"));
0023 
0024   edm::LogVerbatim("TrackerGeom") << "DDTrackerLinear +++ Executing Algorithm. rParent:" << mother.name();
0025   edm::LogVerbatim("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
0026                                   << ns.name() << "\tNumber " << number << "\tAxis (theta/phi) " << theta / dd4hep::deg
0027                                   << ", " << phi / dd4hep::deg << "\t(Offset/Delta) " << offset << ", " << delta
0028                                   << "\tCentre " << centre[0] << ", " << centre[1] << ", " << centre[2] << "\tRotation "
0029                                   << rotMat;
0030 
0031   Position direction(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
0032   Position base(centre[0], centre[1], centre[2]);
0033 
0034   const Rotation3D& rot = ns.rotation(rotMat);
0035 
0036   for (int i = 0, ci = startcn; i < number; i++, ci += incrcn) {
0037     Position tran = base + (offset + double(i) * delta) * direction;
0038     mother.placeVolume(child, ci, Transform3D(rot, tran));
0039 
0040     edm::LogVerbatim("TrackerGeom") << child.name() << " number " << ci << " positioned in " << mother.name() << " at "
0041                                     << tran << " with " << rot;
0042   }
0043   return cms::s_executed;
0044 }
0045 
0046 // first argument is the type from the xml file
0047 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerLinear, algorithm)