Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-11-24 03:48:22

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDRPDPosition.cc
0003 // Description: Position inside the mother according to phi
0004 ///////////////////////////////////////////////////////////////////////////////
0005 
0006 #include <algorithm>
0007 #include <sstream>
0008 #include <string>
0009 #include <vector>
0010 
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "FWCore/PluginManager/interface/PluginFactory.h"
0013 #include "DataFormats/Math/interface/GeantUnits.h"
0014 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0015 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0016 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0017 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0018 #include "DetectorDescription/Core/interface/DDSplit.h"
0019 #include "DetectorDescription/Core/interface/DDTypes.h"
0020 #include "DetectorDescription/Core/interface/DDutils.h"
0021 
0022 //#define EDM_ML_DEBUG
0023 
0024 class DDRPDPosition : public DDAlgorithm {
0025 public:
0026   //Constructor and Destructor
0027   DDRPDPosition();
0028 
0029   void initialize(const DDNumericArguments& nArgs,
0030                   const DDVectorArguments& vArgs,
0031                   const DDMapArguments& mArgs,
0032                   const DDStringArguments& sArgs,
0033                   const DDStringVectorArguments& vsArgs) override;
0034 
0035   void execute(DDCompactView& cpv) override;
0036 
0037 private:
0038   std::vector<double> xpos_;  //Positions along x-axis
0039   double ypos_;               //Position along y-axis
0040   double zpos_;               //Position along z-axis
0041   std::string childName_;     //Children name
0042 };
0043 
0044 DDRPDPosition::DDRPDPosition() { edm::LogVerbatim("ForwardGeom") << "DDRPDPosition test: Creating an instance"; }
0045 
0046 void DDRPDPosition::initialize(const DDNumericArguments& nArgs,
0047                                const DDVectorArguments& vArgs,
0048                                const DDMapArguments&,
0049                                const DDStringArguments& sArgs,
0050                                const DDStringVectorArguments&) {
0051   xpos_ = vArgs["positionX"];
0052   ypos_ = nArgs["positionY"];
0053   zpos_ = nArgs["positionZ"];
0054   childName_ = sArgs["ChildName"];
0055 #ifdef EDM_ML_DEBUG
0056   edm::LogVerbatim("ForwardGeom") << "DDRPDPosition: Parameters for positioning-- " << xpos_.size() << " copies of "
0057                                   << childName_ << " to be positioned inside " << parent().name() << " at y = " << ypos_
0058                                   << ", z = " << zpos_ << " and at x = (";
0059   std::ostringstream st1;
0060   for (const auto& x : xpos_)
0061     st1 << x << " ";
0062   edm::LogVerbatim("ForwardGeom") << st1.str() << ")";
0063 #endif
0064 }
0065 
0066 void DDRPDPosition::execute(DDCompactView& cpv) {
0067   DDName child(DDSplit(childName_).first, DDSplit(childName_).second);
0068   DDName parentName = parent().name();
0069   DDRotation rot;
0070 
0071   for (unsigned int jj = 0; jj < xpos_.size(); jj++) {
0072     DDTranslation tran(xpos_[jj], ypos_, zpos_);
0073 
0074     cpv.position(child, parentName, jj + 1, tran, rot);
0075 #ifdef EDM_ML_DEBUG
0076     edm::LogVerbatim("ForwardGeom") << "DDRPDPosition: " << child << " number " << jj + 1 << " positioned in "
0077                                     << parentName << " at " << tran << " with no rotation";
0078 #endif
0079   }
0080 }
0081 
0082 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDRPDPosition, "rpdalgo:DDRPDPosition");