Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDPixPhase1FwdDiskAlgo.cc
0003 // Description: Position n copies at given z-values
0004 ///////////////////////////////////////////////////////////////////////////////
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0007 #include "DD4hep/DetFactoryHelper.h"
0008 #include "DD4hep/Printout.h"
0009 
0010 #include "DataFormats/Math/interface/CMSUnits.h"
0011 
0012 #include <sstream>
0013 
0014 using namespace cms_units::operators;  // _deg and convertRadToDeg
0015 
0016 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
0017   cms::DDNamespace ns(ctxt, e, true);
0018   cms::DDAlgoArguments args(ctxt, e);
0019 
0020   int nBlades;                      //Number of blades
0021   int startCopyNo;                  //Start Copy number
0022   double bladeAngle;                //Angle of blade rotation aroung y-axis
0023   double bladeTilt;                 //Tilt of the blade around x-axis
0024   double zPlane;                    //Common shift in z for all blades
0025   std::vector<double> bladeZShift;  //Shift in Z of individual blades
0026   double anchorR;                   //Distance of beam line to anchor point
0027 
0028   std::string childName;   //Child name
0029   std::string rotName;     //Name of the base rotation matrix
0030   std::string flagString;  //Flag if a blade is present
0031 
0032   dd4hep::Volume mother = ns.volume(args.parentName());
0033   dd4hep::PlacedVolume pv;
0034 
0035   startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 0;
0036   nBlades = args.value<int>("NumberOfBlades");
0037   bladeAngle = args.value<double>("BladeAngle");
0038 
0039   bladeTilt = -1. * args.value<double>("BladeTilt");
0040   zPlane = args.value<double>("BladeCommonZ");
0041   anchorR = args.value<double>("AnchorRadius");
0042 
0043   bladeZShift = args.value<std::vector<double> >("BladeZShift");
0044 
0045   childName = args.value<std::string>("ChildName");
0046   rotName = args.value<std::string>("RotationName");
0047   flagString = args.value<std::string>("FlagString");
0048 
0049   dd4hep::Volume child = ns.volume(childName);
0050 
0051   edm::LogVerbatim("PixelGeom") << "DDPixFwdDiskAlgo debug: Parent " << mother.name() << "\tChild " << child.name()
0052                                 << " NameSpace " << ns.name() << "\tRot Name " << rotName << "\tCopyNo (Start/Total) "
0053                                 << startCopyNo << ", " << nBlades << "\tAngles " << convertRadToDeg(bladeAngle) << ", "
0054                                 << convertRadToDeg(bladeTilt) << "\tZshifts " << zPlane << "\tAnchor Radius "
0055                                 << anchorR;
0056 
0057   for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
0058     edm::LogVerbatim("PixelGeom") << "DDPixFwdDiskAlgo: Blade " << iBlade << " flag " << flagString[iBlade]
0059                                   << " zshift " << bladeZShift[iBlade];
0060   }
0061 
0062   double deltaPhi = 360.0_deg / (double)nBlades;
0063   int copyNo = startCopyNo;
0064   std::string flagSelector = "Y";
0065 
0066   for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
0067     if (flagString[iBlade] == flagSelector[0]) {
0068       double phi = (iBlade + 0.5) * deltaPhi;
0069       double phiy = atan2(cos(phi), -sin(phi));
0070       double thety = acos(sin(bladeTilt));
0071       double phix = atan2(cos(bladeAngle) * sin(phi) + cos(phi) * sin(bladeTilt) * sin(bladeAngle),
0072                           cos(phi) * cos(bladeAngle) - sin(phi) * sin(bladeTilt) * sin(bladeAngle));
0073       double thetx = acos(-cos(bladeTilt) * sin(bladeAngle));
0074       double phiz = atan2(sin(phi) * sin(bladeAngle) - cos(phi) * cos(bladeAngle) * sin(bladeTilt),
0075                           cos(phi) * sin(bladeAngle) + cos(bladeAngle) * sin(phi) * sin(bladeTilt));
0076       double thetz = acos(cos(bladeTilt) * cos(bladeAngle));
0077 
0078       dd4hep::Rotation3D rot = cms::makeRotation3D(thetx, phix, thety, phiy, thetz, phiz);
0079 
0080       double xpos = -anchorR * sin(phi);
0081       double ypos = anchorR * cos(phi);
0082       double zpos = zPlane + bladeZShift[iBlade % nBlades];
0083 
0084       dd4hep::Position tran(xpos, ypos, zpos);
0085       pv = mother.placeVolume(child, copyNo, dd4hep::Transform3D(rot, tran));
0086     }
0087     copyNo++;
0088   }
0089   return cms::s_executed;
0090 }
0091 
0092 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDPixPhase1FwdDiskAlgo, algorithm)