CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DDTotemAngular.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <algorithm>
3 #include <map>
4 #include <string>
5 #include <vector>
6 
16 
17 using namespace geant_units::operators;
18 
19 //#define EDM_ML_DEBUG
20 
21 class DDTotemAngular : public DDAlgorithm {
22 public:
23  //Constructor and Destructor
25 
26  void initialize(const DDNumericArguments& nArgs,
27  const DDVectorArguments& vArgs,
28  const DDMapArguments& mArgs,
29  const DDStringArguments& sArgs,
30  const DDStringVectorArguments& vsArgs) override;
31 
32  void execute(DDCompactView& cpv) override;
33 
34 private:
35  double startAngle_; //Start angle
36  double stepAngle_; //Step angle
37  double zoffset_; //Offset in z
38  double roffset_; //Offset in R
39  int n_; //Number of copies
40  int startCopyNo_; //Start copy Number
41  int incrCopyNo_; //Increment copy Number
42 
43  std::string rotns_; //Namespace for rotation matrix
44  std::string idNameSpace_; //Namespace of this and ALL sub-parts
45  std::string childName_; //Children name
46 };
47 
49 #ifdef EDM_ML_DEBUG
50  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: Creating an instance";
51 #endif
52 }
53 
55  const DDVectorArguments&,
56  const DDMapArguments&,
57  const DDStringArguments& sArgs,
58  const DDStringVectorArguments&) {
59  startAngle_ = nArgs["startAngle"];
60  stepAngle_ = nArgs["stepAngle"];
61  zoffset_ = nArgs["zoffset"];
62  roffset_ = nArgs["roffset"];
63  n_ = int(nArgs["n"]);
64  startCopyNo_ = int(nArgs["startCopyNo"]);
65  incrCopyNo_ = int(nArgs["incrCopyNo"]);
66 #ifdef EDM_ML_DEBUG
67  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: Parameters for positioning-- " << n_ << " copies in steps of "
68  << convertRadToDeg(stepAngle_) << " from " << convertRadToDeg(startAngle_)
69  << " \tZoffset " << zoffset_ << " \tRoffset " << roffset_
70  << "\tStart and inremental copy nos " << startCopyNo_ << ", " << incrCopyNo_;
71 #endif
72  rotns_ = sArgs["RotNameSpace"];
73  idNameSpace_ = DDCurrentNamespace::ns();
74  childName_ = sArgs["ChildName"];
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular debug: Parent " << parent().name() << "\tChild " << childName_
77  << "\tNameSpace " << idNameSpace_ << "\tRotation Namespace " << rotns_;
78 #endif
79 }
80 
82  double phi = startAngle_;
83  int copyNo = startCopyNo_;
84 
85  for (int ii = 0; ii < n_; ii++) {
86  Geom::Phi0To2pi<double> phitmp = phi;
88  std::string rotstr("NULL");
89 
90  rotstr = "RT" + formatAsDegrees(phitmp);
91  rotation = DDRotation(DDName(rotstr, rotns_));
92  if (!rotation) {
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: Creating a new rotation " << DDName(rotstr, rotns_)
95  << "\t90, " << convertRadToDeg(phitmp + 90._deg) << ", 0, 0, 90, "
96  << convertRadToDeg(phitmp);
97 #endif
98  rotation = DDrot(DDName(rotstr, rotns_), 90._deg, 90._deg + phitmp, 0., 0., 90._deg, phitmp);
99  }
100 
101  DDTranslation tran(roffset_ * cos(phi), roffset_ * sin(phi), zoffset_);
102 
103  DDName parentName = parent().name();
104  cpv.position(DDName(childName_, idNameSpace_), parentName, copyNo, tran, rotation);
105 #ifdef EDM_ML_DEBUG
106  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: " << DDName(childName_, idNameSpace_) << " number " << copyNo
107  << " positioned in " << parentName << " at " << tran << " with " << rotstr << " "
108  << rotation;
109 #endif
110  phi += stepAngle_;
111  copyNo += incrCopyNo_;
112  }
113 }
114 
115 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTotemAngular, "forward:DDTotemAngular");
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
std::string idNameSpace_
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::string rotns_
static std::string & ns()
int ii
Definition: cuy.py:589
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:68
void execute(DDCompactView &cpv) override
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::string childName_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Definition: Phi.h:52