Warning, file /DD4hep/examples/DDCMS/src/plugins/DDTrackerAngular.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include "DD4hep/DetFactoryHelper.h"
0020 #include "DDCMS/DDCMSPlugins.h"
0021
0022 using namespace std;
0023 using namespace dd4hep;
0024 using namespace dd4hep::cms;
0025
0026 static long algorithm(Detector& ,
0027 ParsingContext& ctxt,
0028 xml_h e,
0029 SensitiveDetector& )
0030 {
0031 Namespace ns(ctxt,e,true);
0032 AlgoArguments args(ctxt, e);
0033
0034 int n = args.value<int>("N");
0035 int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
0036 int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
0037 double rangeAngle = args.value<double>("RangeAngle");
0038 double startAngle = args.value<double>("StartAngle");
0039 double radius = args.value<double>("Radius");
0040 vector<double> center = args.value<vector<double> >("Center");
0041 Volume mother = ns.volume(args.parentName());
0042 Volume child = ns.volume(args.value<string>("ChildName"));
0043
0044 double delta = 0e0;
0045
0046 if (fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg) {
0047 delta = rangeAngle/double(n);
0048 } else if (n > 1) {
0049 delta = rangeAngle/double(n-1);
0050 }
0051
0052 LogDebug("TrackerGeom") << "debug: Parameters for positioning:: n "
0053 << n << " Start, Range, Delta "
0054 << startAngle/CLHEP::deg << " "
0055 << rangeAngle/CLHEP::deg << " " << delta/CLHEP::deg
0056 << " Radius " << radius << " Centre " << center[0]
0057 << ", " << center[1] << ", "<<center[2];
0058 LogDebug("TrackerGeom") << "debug: Parent " << mother.name()
0059 << "\tChild " << child.name() << " NameSpace "
0060 << ns.name;
0061
0062 double theta = 90.*CLHEP::deg;
0063 int copy = startCopyNo;
0064 double phi = startAngle;
0065 for (int i=0; i<n; i++) {
0066 double phix = phi;
0067 double phiy = phix + 90.*CLHEP::deg;
0068 double phideg = phix/CLHEP::deg;
0069
0070 Rotation3D rotation;
0071 if (phideg != 0) {
0072 string rotstr = ns.ns_name(child.name()) + std::to_string(phideg*10.);
0073 auto irot = ctxt.rotations.find(ns.prepend(rotstr));
0074 if ( irot != ctxt.rotations.end() ) {
0075 rotation = ns.rotation(ns.prepend(rotstr));
0076 }
0077 else {
0078 LogDebug("TrackerGeom") << "Creating a new "
0079 << "rotation: " << rotstr << "\t90., "
0080 << phix/CLHEP::deg << ", 90.,"
0081 << phiy/CLHEP::deg <<", 0, 0";
0082 RotationZYX rot;
0083 rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.);
0084 }
0085 }
0086
0087 double xpos = radius*cos(phi) + center[0];
0088 double ypos = radius*sin(phi) + center[1];
0089 double zpos = center[2];
0090 Position tran(xpos, ypos, zpos);
0091 mother.placeVolume(child, copy, Transform3D(rotation,tran));
0092 LogDebug("TrackerGeom") << "test " << child.name() << " number "
0093 << copy << " positioned in " << mother.name() << " at "
0094 << tran << " with " << rotation;
0095 copy += incrCopyNo;
0096 phi += delta;
0097 }
0098 return 1;
0099 }
0100
0101
0102 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerAngular,algorithm)