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 
14 #include "CLHEP/Units/GlobalSystemOfUnits.h"
15 
16 //#define EDM_ML_DEBUG
17 
19 #ifdef EDM_ML_DEBUG
20  edm::LogInfo("MuonGeom") << "DDGEMAngular test: Creating an instance";
21 #endif
22 }
23 
25 
27  const DDVectorArguments & ,
28  const DDMapArguments & ,
29  const DDStringArguments & sArgs,
30  const DDStringVectorArguments & ) {
31 
32  startAngle = nArgs["startAngle"];
33  stepAngle = nArgs["stepAngle"];
34  invert = int (nArgs["invert"]);
35  rPos = nArgs["rPosition"];
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") << "DDGEMAngular debug: Parameters for positioning-- "
42  << n << " copies in steps of " << stepAngle/CLHEP::deg
43  << " from " << startAngle/CLHEP::deg
44  << " (inversion flag " << invert << ") \trPos " << rPos
45  << " Zoffest " << zoffset << "\tStart and inremental "
46  << "copy nos " << startCopyNo << ", " << incrCopyNo;
47 #endif
48 
49  rotns = sArgs["RotNameSpace"];
51  childName = sArgs["ChildName"];
52 #ifdef EDM_ML_DEBUG
53  DDName parentName = parent().name();
54  edm::LogInfo("MuonGeom") << "DDGEMAngular debug: Parent " << parentName
55  << "\tChild " << childName << "\tNameSpace "
56  << idNameSpace << "\tRotation Namespace " << rotns;
57 #endif
58 }
59 
61 
62  double phi = startAngle;
63  int copyNo = startCopyNo;
64 
65  for (int ii=0; ii<n; ii++) {
66 
67  double phideg = phi/CLHEP::deg;
68  int iphi;
69  if (phideg > 0) iphi = int(phideg+0.1);
70  else iphi = int(phideg-0.1);
71  if (iphi >= 360) iphi -= 360;
72  phideg = iphi;
74  std::string rotstr("NULL");
75 
76  rotstr = "RG";
77  if (invert > 0) rotstr += "I";
78  if (phideg >=0 && phideg < 10) rotstr += "00";
79  else if (phideg < 100) rotstr += "0";
80  rotstr += std::to_string(phideg);
81  rotation = DDRotation(DDName(rotstr, rotns));
82  if (!rotation) {
83  double thetax = 90.0;
84  double phix = invert==0 ? (90.0+phideg) : (-90.0+phideg);
85  double thetay = invert==0 ? 0.0 : 180.0;
86  double phiz = phideg;
87 #ifdef EDM_ML_DEBUG
88  edm::LogInfo("MuonGeom") << "DDGEMAngular test: Creating a new rotation "
89  << DDName(rotstr, idNameSpace) << "\t "
90  << thetax << ", " << phix << ", " << thetay
91  << ", 0, " << thetax << ", " << phiz;
92 #endif
93  rotation = DDrot(DDName(rotstr, rotns), thetax*CLHEP::deg,
94  phix*CLHEP::deg, thetay*CLHEP::deg, 0*CLHEP::deg,
95  thetax*CLHEP::deg, phiz*CLHEP::deg);
96  }
97 
98  DDTranslation tran(rPos*cos(phideg*CLHEP::deg), rPos*sin(phideg*CLHEP::deg), zoffset);
99 
100  DDName parentName = parent().name();
101  cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
102 #ifdef EDM_ML_DEBUG
103  edm::LogInfo("MuonGeom") << "DDGEMAngular test: "
104  << DDName(childName, idNameSpace) << " number "
105  << copyNo << " positioned in " << parentName
106  << " at " << tran << " with " << rotstr << " "
107  << rotation;
108 #endif
109  phi += stepAngle;
110  copyNo += incrCopyNo;
111  }
112 }
~DDGEMAngular() override
Definition: DDGEMAngular.cc:24
std::string childName
Definition: DDGEMAngular.h:37
std::string rotns
Definition: DDGEMAngular.h:35
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDGEMAngular.cc:26
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
static std::string & ns()
std::string idNameSpace
Definition: DDGEMAngular.h:36
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:83
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
void execute(DDCompactView &cpv) override
Definition: DDGEMAngular.cc:60
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double stepAngle
Definition: DDGEMAngular.h:27
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
ii
Definition: cuy.py:589
double zoffset
Definition: DDGEMAngular.h:30
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
double startAngle
Definition: DDGEMAngular.h:26