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 dd;
17 using namespace dd::operators;
18 
19 //#define EDM_ML_DEBUG
20 
22 #ifdef EDM_ML_DEBUG
23  edm::LogInfo("MuonGeom") << "DDGEMAngular test: Creating an instance";
24 #endif
25 }
26 
28 
30  const DDVectorArguments & ,
31  const DDMapArguments & ,
32  const DDStringArguments & sArgs,
33  const DDStringVectorArguments & ) {
34 
35  startAngle = nArgs["startAngle"];
36  stepAngle = nArgs["stepAngle"];
37  invert = int (nArgs["invert"]);
38  rPos = nArgs["rPosition"];
39  zoffset = nArgs["zoffset"];
40  n = int (nArgs["n"]);
41  startCopyNo = int (nArgs["startCopyNo"]);
42  incrCopyNo = int (nArgs["incrCopyNo"]);
43 #ifdef EDM_ML_DEBUG
44  edm::LogInfo("MuonGeom") << "DDGEMAngular debug: Parameters for positioning-- "
45  << n << " copies in steps of " << CONVERT_TO( stepAngle, deg )
46  << " from " << CONVERT_TO( startAngle, deg )
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  DDName parentName = parent().name();
57  edm::LogInfo("MuonGeom") << "DDGEMAngular debug: Parent " << parentName
58  << "\tChild " << childName << "\tNameSpace "
59  << idNameSpace << "\tRotation Namespace " << rotns;
60 #endif
61 }
62 
64 
65  double phi = startAngle;
66  int copyNo = startCopyNo;
67 
68  for (int ii=0; ii<n; ii++) {
69 
70  double phitmp = phi;
71  if (phitmp >= 2._pi) phitmp -= 2._pi;
73  std::string rotstr("RG");
74 
75  if (invert > 0) rotstr += "I";
76  rotstr += formatAsDegrees(phitmp);
77  rotation = DDRotation(DDName(rotstr, rotns));
78  if (!rotation) {
79  double thetax = 90.0_deg;
80  double phix = invert==0 ? (90.0_deg + phitmp) : (-90.0_deg + phitmp);
81  double thetay = invert==0 ? 0.0 : 180.0_deg;
82  double phiz = phitmp;
83 #ifdef EDM_ML_DEBUG
84  edm::LogInfo("MuonGeom") << "DDGEMAngular test: Creating a new rotation "
85  << DDName(rotstr, idNameSpace) << "\t "
86  << CONVERT_TO( thetax, deg ) << ", " << CONVERT_TO( phix, deg ) << ", " << CONVERT_TO( thetay, deg )
87  << ", 0, " << CONVERT_TO( thetax, deg )<< ", " << CONVERT_TO( phiz, deg );
88 #endif
89  rotation = DDrot(DDName(rotstr, rotns), thetax, phix, thetay, 0., thetax, phiz);
90  }
91 
92  DDTranslation tran(rPos*cos(phitmp), rPos*sin(phitmp), zoffset);
93 
94  DDName parentName = parent().name();
95  cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
96 #ifdef EDM_ML_DEBUG
97  edm::LogInfo("MuonGeom") << "DDGEMAngular test: "
98  << DDName(childName, idNameSpace) << " number "
99  << copyNo << " positioned in " << parentName
100  << " at " << tran << " with " << rotstr << " "
101  << rotation;
102 #endif
103  phi += stepAngle;
104  copyNo += incrCopyNo;
105  }
106 }
~DDGEMAngular() override
Definition: DDGEMAngular.cc:27
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDGEMAngular.cc:29
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define CONVERT_TO(_x, _y)
Definition: DDUnits.h:6
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
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:63
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)
Definition: DDUnits.h:8
constexpr long double _pi(M_PI)