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 geant_units::operators;
16 
17 //#define EDM_ML_DEBUG
18 
20 #ifdef EDM_ML_DEBUG
21  edm::LogVerbatim("MuonGeom") << "DDMuonAngular: Creating an instance";
22 #endif
23 }
24 
26 
28  const DDVectorArguments & ,
29  const DDMapArguments & ,
30  const DDStringArguments & sArgs,
31  const DDStringVectorArguments & ) {
32 
33  startAngle = nArgs["startAngle"];
34  stepAngle = nArgs["stepAngle"];
35  zoffset = nArgs["zoffset"];
36  n = int (nArgs["n"]);
37  startCopyNo = int (nArgs["startCopyNo"]);
38  incrCopyNo = int (nArgs["incrCopyNo"]);
39 #ifdef EDM_ML_DEBUG
40  edm::LogVerbatim("MuonGeom")
41  << "DDMuonAngular: Parameters for positioning-- " << n
42  << " copies in steps of " << convertRadToDeg( stepAngle )
43  << " from " << convertRadToDeg( startAngle ) << " \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  edm::LogVerbatim("MuonGeom")
52  << "DDMuonAngular debug: Parent " << parent().name()
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" + formatAsDegrees(phitmp);
72  rotation = DDRotation(DDName(rotstr, rotns));
73  if (!rotation) {
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("MuonGeom")
76  << "DDMuonAngular: Creating a new rotation "
77  << DDName(rotstr, idNameSpace) << "\t90, "
78  << convertRadToDeg( phitmp ) << ", 90, "
79  << convertRadToDeg( phitmp + 90._deg ) << ", 0, 0";
80 #endif
81  rotation = DDrot(DDName(rotstr, rotns), 90._deg, phitmp, 90._deg, 90._deg + phitmp, 0., 0.);
82  }
83  }
84 
85  DDTranslation tran(0, 0, zoffset);
86 
87  DDName parentName = parent().name();
88  cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("MuonGeom")
91  << "DDMuonAngular: " << DDName(childName, idNameSpace) << " number "
92  << copyNo << " positioned in " << parentName
93  << " at " << tran << " with " << rotstr << " " << rotation;
94 #endif
95  phi += stepAngle;
96  copyNo += incrCopyNo;
97  }
98 }
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
~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)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override