CMS 3D CMS Logo

DDMuonAngular.cc
Go to the documentation of this file.
1 // File: DDMuonAngular.cc
3 // Description: Position inside the mother according to (eta,phi)
5 
6 #include <cmath>
7 #include <algorithm>
8 
14 
15 using namespace dd;
16 using namespace dd::operators;
17 
18 //#define EDM_ML_DEBUG
19 
21 #ifdef EDM_ML_DEBUG
22  edm::LogInfo("MuonGeom") << "DDMuonAngular test: 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  zoffset = nArgs["zoffset"];
37  n = int (nArgs["n"]);
38  startCopyNo = int (nArgs["startCopyNo"]);
39  incrCopyNo = int (nArgs["incrCopyNo"]);
40 #ifdef EDM_ML_DEBUG
41  edm::LogInfo("MuonGeom") << "DDMuonAngular debug: Parameters for positioning-- "
42  << n << " copies in steps of " << CONVERT_TO( stepAngle, deg )
43  << " from " << CONVERT_TO( startAngle, deg ) << " \tZoffest "
44  << zoffset << "\tStart and inremental copy nos "
45  << startCopyNo << ", " << incrCopyNo;
46 #endif
47  rotns = sArgs["RotNameSpace"];
48  idNameSpace = DDCurrentNamespace::ns();
49  childName = sArgs["ChildName"];
50 #ifdef EDM_ML_DEBUG
51  DDName parentName = parent().name();
52  edm::LogInfo("MuonGeom") << "DDMuonAngular debug: Parent " << parentName
53  << "\tChild " << childName << "\tNameSpace "
54  << idNameSpace << "\tRotation Namespace " << rotns;
55 #endif
56 }
57 
59 
60  double phi = startAngle;
61  int copyNo = startCopyNo;
62 
63  for (int ii=0; ii<n; ii++) {
64 
65  double phitmp = phi;
66  if (phitmp >= 2._pi) phitmp -= 2._pi;
68  std::string rotstr("NULL");
69 
70  if (std::abs(phitmp) >= 1.0_deg) {
71  rotstr = "R";
72  rotstr += formatAsDegrees(phitmp);
73  rotation = DDRotation(DDName(rotstr, rotns));
74  if (!rotation) {
75 #ifdef EDM_ML_DEBUG
76  edm::LogInfo("MuonGeom") << "DDMuonAngular test: Creating a new rotation "
77  << DDName(rotstr, idNameSpace) << "\t90, "
78  << CONVERT_TO( phitmp, deg ) << ", 90, " << CONVERT_TO(phitmp + 90._deg, deg) << ", 0, 0";
79 #endif
80  rotation = DDrot(DDName(rotstr, rotns), 90._deg, phitmp, 90._deg, 90._deg + phitmp, 0., 0.);
81  }
82  }
83 
84  DDTranslation tran(0, 0, zoffset);
85 
86  DDName parentName = parent().name();
87  cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
88 #ifdef EDM_ML_DEBUG
89  edm::LogInfo("MuonGeom") << "DDMuonAngular test: "
90  << DDName(childName, idNameSpace) << " number "
91  << copyNo << " positioned in " << parentName
92  << " at " << tran << " with " << rotstr << " "
93  << rotation;
94 #endif
95  phi += stepAngle;
96  copyNo += incrCopyNo;
97  }
98 }
#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
~DDMuonAngular() override
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
Abs< T >::type abs(const T &t)
Definition: Abs.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)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override