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