Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-01 02:45:10

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   vector<string> moduleName = args.value<vector<string> >("ModuleName");  //Name of the module
0016   string iccName = args.value<string>("ICCName");                         //Name of the ICC
0017   int number = args.value<int>("Number");                                 //Number of copies
0018   double startAngle = args.value<double>("StartAngle");                   //Phi offset
0019   double rModule = args.value<double>("ModuleR");                         //Location of module in R
0020   vector<double> zModule = args.value<vector<double> >("ModuleZ");        //                   in Z
0021   double rICC = args.value<double>("ICCR");                               //Location of ICC    in R
0022   double sICC = args.value<double>("ICCShift");                           //Shift of ICC       per to R
0023   vector<double> zICC = args.value<vector<double> >("ICCZ");              //                   in Z
0024 
0025   edm::LogVerbatim("TIDGeom") << "Parent " << mother.name() << "\tModule " << moduleName[0] << ", " << moduleName[1]
0026                               << "\tICC " << iccName << "\tNameSpace " << ns.name();
0027   edm::LogVerbatim("TIDGeom") << "Parameters for positioning--"
0028                               << " StartAngle " << convertRadToDeg(startAngle) << " Copy Numbers " << number
0029                               << " Modules at R " << rModule << " Z " << zModule[0] << ", " << zModule[1]
0030                               << " ICCs at R " << rICC << " Z " << zICC[0] << ", " << zICC[1];
0031   double theta = 90._deg;
0032   double phiy = 0._deg;
0033   double dphi = 2_pi / number;
0034 
0035   //Loop over modules
0036   Volume icc = ns.volume(iccName);
0037   Volume mod0 = ns.volume(moduleName[0]);
0038   Volume mod1 = ns.volume(moduleName[1]);
0039   for (int i = 0; i < number; i++) {
0040     //First the module
0041     double phiz = startAngle + i * dphi;
0042     double xpos = rModule * cos(phiz);
0043     double ypos = rModule * sin(phiz);
0044     double zpos, thetay, phix;
0045     Volume module;
0046     if (i % 2 == 0) {
0047       phix = phiz + 90._deg;
0048       thetay = 0._deg;
0049       zpos = zModule[0];
0050       module = mod0;
0051     } else {
0052       phix = phiz - 90._deg;
0053       thetay = 180._deg;
0054       zpos = zModule[1];
0055       module = mod1;
0056     }
0057 
0058     // stereo face inside toward structure, rphi face outside
0059     phix = phix - 180._deg;
0060     thetay = thetay + 180._deg;
0061     //
0062     Position trmod(xpos, ypos, zpos);
0063     Rotation3D rotation = makeRotation3D(theta, phix, thetay, phiy, theta, phiz);
0064     // int copyNr = i+1;
0065     /* PlacedVolume pv = */ mother.placeVolume(module, i + 1, Transform3D(rotation, trmod));
0066     edm::LogVerbatim("TIDGeom") << module.name() << " number " << i + 1 << " positioned in " << mother.name() << " at "
0067                                 << trmod << " with " << rotation;
0068     //Now the ICC
0069     if (i % 2 == 0) {
0070       zpos = zICC[0];
0071       xpos = rICC * cos(phiz) + sICC * sin(phiz);
0072       ypos = rICC * sin(phiz) - sICC * cos(phiz);
0073     } else {
0074       zpos = zICC[1];
0075       xpos = rICC * cos(phiz) - sICC * sin(phiz);
0076       ypos = rICC * sin(phiz) + sICC * cos(phiz);
0077     }
0078     // int copyNr = i+1;
0079     Position tricc(xpos, ypos, zpos);
0080     /* PlacedVolume pv = */ mother.placeVolume(icc, i + 1, Transform3D(rotation, tricc));
0081     edm::LogVerbatim("TIDGeom") << icc.name() << " number " << i + 1 << " positioned in " << mother.name() << " at "
0082                                 << tricc << " with " << rotation;
0083   }
0084   return 1;
0085 }
0086 
0087 // first argument is the type from the xml file
0088 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIDRingAlgo, algorithm)