CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDHCalAngular.cc
Go to the documentation of this file.
1 // File: DDHCalAngular.cc
3 // Description: Position inside the mother according to (eta,phi)
5 
6 #include <cmath>
7 #include <algorithm>
8 
14 #include "CLHEP/Units/GlobalSystemOfUnits.h"
15 
17  LogDebug("HCalGeom") << "DDHCalAngular 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  rangeAngle = nArgs["rangeAngle"];
30  shiftX = nArgs["shiftX"];
31  shiftY = nArgs["shiftY"];
32  zoffset = nArgs["zoffset"];
33  n = int (nArgs["n"]);
34  startCopyNo = int (nArgs["startCopyNo"]);
35  incrCopyNo = int (nArgs["incrCopyNo"]);
36  LogDebug("HCalGeom") << "DDHCalAngular debug: Parameters for positioning-- "
37  << n << " copies in " << rangeAngle/CLHEP::deg
38  << " from " << startAngle/CLHEP::deg << "\tShifts "
39  << shiftX << ", " << shiftY
40  << " along x, y axes; \tZoffest " << zoffset
41  << "\tStart and inremental copy nos " << startCopyNo
42  << ", " << incrCopyNo;
43 
44  rotns = sArgs["RotNameSpace"];
46  childName = sArgs["ChildName"];
47  DDName parentName = parent().name();
48  LogDebug("HCalGeom") << "DDHCalAngular debug: Parent " << parentName
49  << "\tChild " << childName << "\tNameSpace "
50  << idNameSpace << "\tRotation Namespace " << rotns;
51 }
52 
54 
55  double dphi = rangeAngle/n;
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  if (iphi != 0) {
71  rotstr = "R";
72  if (phideg >=0 && phideg < 100) rotstr = "R0";
73  rotstr = rotstr + dbl_to_string(phideg);
74  rotation = DDRotation(DDName(rotstr, rotns));
75  if (!rotation) {
76  LogDebug("HCalGeom") << "DDHCalAngular test: Creating a new rotation "
77  << DDName(rotstr, idNameSpace) << "\t90, "
78  << phideg << ", 90, " << (phideg+90) << ", 0, 0";
79  rotation = DDrot(DDName(rotstr, rotns), 90*CLHEP::deg,
80  phideg*CLHEP::deg, 90*CLHEP::deg,
81  (90+phideg)*CLHEP::deg, 0*CLHEP::deg, 0*CLHEP::deg);
82  }
83  }
84 
85  double xpos = shiftX*cos(phi) - shiftY*sin(phi);
86  double ypos = shiftX*sin(phi) + shiftY*cos(phi);
87  DDTranslation tran(xpos, ypos, zoffset);
88 
89  DDName parentName = parent().name();
90  cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
91  LogDebug("HCalGeom") << "DDHCalAngular test: "
92  << DDName(childName, idNameSpace) << " number "
93  << copyNo << " positioned in " << parentName << " at "
94  << tran << " with " << rotation;
95  phi += dphi;
96  copyNo += incrCopyNo;
97  }
98 }
#define LogDebug(id)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
double startAngle
Definition: DDHCalAngular.h:26
list parent
Definition: dbtoconf.py:74
std::string rotns
Definition: DDHCalAngular.h:35
double rangeAngle
Definition: DDHCalAngular.h:27
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:18
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
type of data representation of DDCompactView
Definition: DDCompactView.h:77
virtual ~DDHCalAngular()
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
std::string childName
Definition: DDHCalAngular.h:37
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:93
std::string idNameSpace
Definition: DDHCalAngular.h:36
void execute(DDCompactView &cpv)
Definition: DDAxes.h:10