CMS 3D CMS Logo

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