Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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& /* description */, 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   double startAngle = args.value<double>("StartAngle");                             //Start angle
0017   double incrAngle = args.value<double>("IncrAngle");                               //Increment in angle
0018   double radius = args.value<double>("Radius");                                     //Radius
0019   double zIn = args.value<double>("ZIn");                                           //z position for the even ones
0020   double zOut = args.value<double>("ZOut");                                         //z position for the odd  ones
0021   int number = args.value<double>("Number");                                        //Number of copies
0022   int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;  //Start copy number
0023   int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;     //Increment in copy number
0024 
0025   edm::LogVerbatim("TECGeom") << "debug: Parameters for "
0026                               << "positioning--"
0027                               << "\tStartAngle " << convertRadToDeg(startAngle) << "\tIncrAngle "
0028                               << convertRadToDeg(incrAngle) << "\tZ in/out " << zIn << ", " << zOut << "\tCopy Numbers "
0029                               << number << " Start/Increment " << startCopyNo << ", " << incrCopyNo;
0030   edm::LogVerbatim("TECGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
0031                               << ns.name();
0032 
0033   if (number > 0) {
0034     double theta = 90._deg;
0035     int copyNo = startCopyNo;
0036     for (int i = 0; i < number; i++) {
0037       double phiz = startAngle + i * incrAngle;
0038       double phix = phiz + 90._deg;
0039       Rotation3D rotation = makeRotation3D(theta, phix, 0e0, 0e0, theta, phiz);
0040       Position tran(radius * cos(phiz), radius * sin(phiz), (i % 2 == 0) ? zIn : zOut);
0041       mother.placeVolume(child, copyNo, Transform3D(rotation, tran));
0042       edm::LogVerbatim("TECGeom") << "test: " << child.name() << " number " << copyNo << " positioned in "
0043                                   << mother.name() << " at " << tran << " with " << rotation;
0044       copyNo += incrCopyNo;
0045     }
0046   }
0047   return 1;
0048 }
0049 
0050 // first argument is the type from the xml file
0051 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECPhiAltAlgo, algorithm)