CMS 3D CMS Logo

DDGEMAngular.cc
Go to the documentation of this file.
1 // File: DDGEMAngular.cc
3 // Description: Position inside the mother according to (eta,phi)
5 
6 #include <cmath>
7 #include <algorithm>
8 #include <iostream>
9 
15 
16 using namespace geant_units::operators;
17 
18 //#define EDM_ML_DEBUG
19 
21 #ifdef EDM_ML_DEBUG
22  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: Creating an instance";
23 #endif
24 }
25 
27 
29  const DDVectorArguments & ,
30  const DDMapArguments & ,
31  const DDStringArguments & sArgs,
32  const DDStringVectorArguments & ) {
33 
34  startAngle = nArgs["startAngle"];
35  stepAngle = nArgs["stepAngle"];
36  invert = int (nArgs["invert"]);
37  rPos = nArgs["rPosition"];
38  zoffset = nArgs["zoffset"];
39  n = int (nArgs["n"]);
40  startCopyNo = int (nArgs["startCopyNo"]);
41  incrCopyNo = int (nArgs["incrCopyNo"]);
42 #ifdef EDM_ML_DEBUG
43  edm::LogVerbatim("MuonGeom")
44  << "DDGEMAngular: Parameters for positioning-- " << n
45  << " copies in steps of " << convertRadToDeg( stepAngle )
46  << " from " << convertRadToDeg( startAngle )
47  << " (inversion flag " << invert << ") \trPos " << rPos
48  << " Zoffest " << zoffset << "\tStart and inremental "
49  << "copy nos " << startCopyNo << ", " << incrCopyNo;
50 #endif
51 
52  rotns = sArgs["RotNameSpace"];
53  idNameSpace = DDCurrentNamespace::ns();
54  childName = sArgs["ChildName"];
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("MuonGeom")
57  << "DDGEMAngular: Parent " << parent().name() << "\tChild " << childName
58  << "\tNameSpace " << idNameSpace << "\tRotation Namespace " << rotns;
59 #endif
60 }
61 
63 
64  double phi = startAngle;
65  int copyNo = startCopyNo;
66 
67  for (int ii=0; ii<n; ii++) {
68 
69  double phitmp = phi;
70  if (phitmp >= 2._pi) phitmp -= 2._pi;
72  std::string rotstr("RG");
73 
74  if (invert > 0) rotstr += "I";
75  rotstr += formatAsDegrees(phitmp);
76  rotation = DDRotation(DDName(rotstr, rotns));
77  if (!rotation) {
78  double thetax = 90.0_deg;
79  double phix = invert==0 ? (90.0_deg + phitmp) : (-90.0_deg + phitmp);
80  double thetay = invert==0 ? 0.0 : 180.0_deg;
81  double phiz = phitmp;
82 #ifdef EDM_ML_DEBUG
83  edm::LogVerbatim("MuonGeom")
84  << "DDGEMAngular: Creating a new rotation "
85  << DDName(rotstr, idNameSpace) << "\t "
86  << convertRadToDeg( thetax ) << ", " << convertRadToDeg( phix ) <<", "
87  << convertRadToDeg( thetay ) << ", 0, " << convertRadToDeg( thetax )
88  << ", " << convertRadToDeg( phiz );
89 #endif
90  rotation = DDrot(DDName(rotstr, rotns), thetax, phix, thetay, 0., thetax, phiz);
91  }
92 
93  DDTranslation tran(rPos*cos(phitmp), rPos*sin(phitmp), zoffset);
94 
95  DDName parentName = parent().name();
96  cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
97 #ifdef EDM_ML_DEBUG
98  edm::LogVerbatim("MuonGeom")
99  << "DDGEMAngular: " << DDName(childName, idNameSpace) << " number "
100  << copyNo << " positioned in " << parentName
101  << " at " << tran << " with " << rotstr << " " << rotation;
102 #endif
103  phi += stepAngle;
104  copyNo += incrCopyNo;
105  }
106 }
~DDGEMAngular() override
Definition: DDGEMAngular.cc:26
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDGEMAngular.cc:28
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
void execute(DDCompactView &cpv) override
Definition: DDGEMAngular.cc:62
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:80
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:75
ii
Definition: cuy.py:590
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)