CMS 3D CMS Logo

DDRPDPosition.cc
Go to the documentation of this file.
1 // File: DDRPDPosition.cc
3 // Description: Position inside the mother according to phi
5 
6 #include <algorithm>
7 #include <sstream>
8 #include <string>
9 #include <vector>
10 
21 
22 //#define EDM_ML_DEBUG
23 
24 class DDRPDPosition : public DDAlgorithm {
25 public:
26  //Constructor and Destructor
27  DDRPDPosition();
28 
29  void initialize(const DDNumericArguments& nArgs,
30  const DDVectorArguments& vArgs,
31  const DDMapArguments& mArgs,
32  const DDStringArguments& sArgs,
33  const DDStringVectorArguments& vsArgs) override;
34 
35  void execute(DDCompactView& cpv) override;
36 
37 private:
38  std::vector<double> xpos_; //Positions along x-axis
39  double ypos_; //Position along y-axis
40  double zpos_; //Position along z-axis
41  std::string childName_; //Children name
42 };
43 
44 DDRPDPosition::DDRPDPosition() { edm::LogVerbatim("ForwardGeom") << "DDRPDPosition test: Creating an instance"; }
45 
47  const DDVectorArguments& vArgs,
48  const DDMapArguments&,
49  const DDStringArguments& sArgs,
50  const DDStringVectorArguments&) {
51  xpos_ = vArgs["positionX"];
52  ypos_ = nArgs["positionY"];
53  zpos_ = nArgs["positionZ"];
54  childName_ = sArgs["ChildName"];
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("ForwardGeom") << "DDRPDPosition: Parameters for positioning-- " << xpos_.size() << " copies of "
57  << childName_ << " to be positioned inside " << parent().name() << " at y = " << ypos_
58  << ", z = " << zpos_ << " and at x = (";
59  std::ostringstream st1;
60  for (const auto& x : xpos_)
61  st1 << x << " ";
62  edm::LogVerbatim("ForwardGeom") << st1.str() << ")";
63 #endif
64 }
65 
68  DDName parentName = parent().name();
70 
71  for (unsigned int jj = 0; jj < xpos_.size(); jj++) {
72  DDTranslation tran(xpos_[jj], ypos_, zpos_);
73 
74  cpv.position(child, parentName, jj + 1, tran, rot);
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("ForwardGeom") << "DDRPDPosition: " << child << " number " << jj + 1 << " positioned in "
77  << parentName << " at " << tran << " with no rotation";
78 #endif
79  }
80 }
81 
82 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDRPDPosition, "rpdalgo:DDRPDPosition");
Log< level::Info, true > LogVerbatim
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
std::vector< double > xpos_
void execute(DDCompactView &cpv) override
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
std::string childName_
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override