Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:50:06

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 tilt = args.value<double>("Tilt");                                         //Tilt of the module
0017   double startAngle = args.value<double>("StartAngle");                             //offset in phi
0018   double rangeAngle = args.value<double>("RangeAngle");                             //Maximum range in phi
0019   double radiusIn = args.value<double>("RadiusIn");                                 //Inner radius
0020   double radiusOut = args.value<double>("RadiusOut");                               //Outer radius
0021   double zpos = args.value<double>("ZPosition");                                    //z position
0022   int number = args.value<int>("Number");                                           //Number of copies
0023   int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;  //Start copy number
0024   int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;     //Increment in copy number
0025 
0026   edm::LogVerbatim("TrackerGeom") << "Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
0027                                   << ns.name();
0028   edm::LogVerbatim("TrackerGeom") << "Parameters for positioning-- Tilt " << tilt << "\tStartAngle "
0029                                   << convertRadToDeg(startAngle) << "\tRangeAngle " << convertRadToDeg(rangeAngle)
0030                                   << "\tRin " << radiusIn << "\tRout " << radiusOut << "\t ZPos " << zpos
0031                                   << "\tCopy Numbers " << number << " Start/Increment " << startCopyNo << ", "
0032                                   << incrCopyNo;
0033 
0034   if (number > 0) {
0035     double theta = 90._deg;
0036     double dphi;
0037     if (number == 1 || fabs(rangeAngle - 360.0_deg) < 0.001_deg)
0038       dphi = rangeAngle / number;
0039     else
0040       dphi = rangeAngle / (number - 1);
0041     int copyNo = startCopyNo;
0042 
0043     for (int i = 0; i < number; i++) {
0044       double phi = startAngle + i * dphi;
0045       double phix = phi - tilt + 90._deg;
0046       double phiy = phix + 90._deg;
0047       double phideg = convertRadToDeg(phix);
0048 
0049       Rotation3D rotation;
0050       if (phideg != 0) {
0051         rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
0052       }
0053 
0054       double xpos, ypos;
0055       if (i % 2 == 0) {
0056         xpos = radiusIn * cos(phi);
0057         ypos = radiusIn * sin(phi);
0058       } else {
0059         xpos = radiusOut * cos(phi);
0060         ypos = radiusOut * sin(phi);
0061       }
0062       Position tran(xpos, ypos, zpos);
0063       /* PlacedVolume pv = */ mother.placeVolume(child, copyNo, Transform3D(rotation, tran));
0064       edm::LogVerbatim("TrackerGeom") << "" << child.name() << " number " << copyNo << " positioned in "
0065                                       << mother.name() << " at " << tran << " with " << rotation;
0066       copyNo += incrCopyNo;
0067     }
0068   }
0069   return 1;
0070 }
0071 
0072 // first argument is the type from the xml file
0073 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerPhiAltAlgo, algorithm)