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 "DD4hep/Printout.h"
0003 #include "DataFormats/Math/interface/CMSUnits.h"
0004 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 
0007 #include <sstream>
0008 
0009 using namespace std;
0010 using namespace dd4hep;
0011 using namespace cms;
0012 using namespace cms_units::operators;
0013 
0014 static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
0015   cms::DDNamespace ns(ctxt, e, true);
0016   DDAlgoArguments args(ctxt, e);
0017   int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
0018   double rPosition = args.value<double>("RPosition");
0019   vector<double> phiPosition = args.value<vector<double> >("PhiPosition");
0020   vector<string> coolInsert = args.value<vector<string> >("CoolInsert");
0021   Volume mother = ns.volume(args.parentName());
0022 
0023   edm::LogVerbatim("TECGeom") << "DDTECCoolAlgo debug: Parent " << mother.name() << " NameSpace " << ns.name()
0024                               << " at radial Position " << rPosition;
0025   if (phiPosition.size() == coolInsert.size()) {
0026     for (int i = 0; i < (int)(phiPosition.size()); i++) {
0027       edm::LogVerbatim("TECGeom") << "DDTECCoolAlgo debug: Insert[" << i << "]: " << coolInsert.at(i) << " at Phi "
0028                                   << convertRadToDeg(phiPosition.at(i));
0029     }
0030   } else {
0031     edm::LogVerbatim("TECGeom") << "DDTECCoolAlgo ERROR: Number of inserts does not match the numer of PhiPositions!";
0032   }
0033 
0034   int copyNo = startCopyNo;
0035   // loop over the inserts to be placed
0036   for (int i = 0; i < (int)(coolInsert.size()); i++) {
0037     Volume child = ns.volume(ns.realName(coolInsert.at(i)));
0038     // get positions
0039     double xpos = rPosition * cos(phiPosition.at(i));
0040     double ypos = -rPosition * sin(phiPosition.at(i));
0041     // place inserts
0042     Position tran(xpos, ypos, 0.0);
0043     mother.placeVolume(child, copyNo, tran);
0044     edm::LogVerbatim("TECGeom") << "DDTECCoolAlgo test " << child.name() << "[" << copyNo << "] positioned in "
0045                                 << mother.name() << " at " << tran << " phi " << convertRadToDeg(phiPosition.at(i))
0046                                 << " r " << rPosition;
0047     copyNo++;
0048   }
0049   edm::LogVerbatim("TECGeom") << "DDTECCoolAlgo Finished....";
0050   return 1;
0051 }
0052 
0053 // first argument is the type from the xml file
0054 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECCoolAlgo, algorithm)