CMS 3D CMS Logo

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 
13 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 
16  LogDebug("HCalGeom") << "DDHCalAngular test: Creating an instance";
17 }
18 
20 
22  const DDVectorArguments & ,
23  const DDMapArguments & ,
24  const DDStringArguments & sArgs,
25  const DDStringVectorArguments & ) {
26 
27  startAngle = nArgs["startAngle"];
28  rangeAngle = nArgs["rangeAngle"];
29  shiftX = nArgs["shiftX"];
30  shiftY = nArgs["shiftY"];
31  zoffset = nArgs["zoffset"];
32  n = int (nArgs["n"]);
33  startCopyNo = int (nArgs["startCopyNo"]);
34  incrCopyNo = int (nArgs["incrCopyNo"]);
35  LogDebug("HCalGeom") << "DDHCalAngular debug: Parameters for positioning-- "
36  << n << " copies in " << rangeAngle/CLHEP::deg
37  << " from " << startAngle/CLHEP::deg << "\tShifts "
38  << shiftX << ", " << shiftY
39  << " along x, y axes; \tZoffest " << zoffset
40  << "\tStart and inremental copy nos " << startCopyNo
41  << ", " << incrCopyNo;
42 
43  rotns = sArgs["RotNameSpace"];
45  childName = sArgs["ChildName"];
46  DDName parentName = parent().name();
47  LogDebug("HCalGeom") << "DDHCalAngular debug: Parent " << parentName
48  << "\tChild " << childName << "\tNameSpace "
49  << idNameSpace << "\tRotation Namespace " << rotns;
50 }
51 
53 
54  double dphi = rangeAngle/n;
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  if (iphi != 0) {
70  rotstr = "R";
71  if (phideg >=0 && phideg < 100) rotstr = "R0";
72  rotstr = rotstr + std::to_string(phideg);
73  rotation = DDRotation(DDName(rotstr, rotns));
74  if (!rotation) {
75  LogDebug("HCalGeom") << "DDHCalAngular test: Creating a new rotation "
76  << DDName(rotstr, idNameSpace) << "\t90, "
77  << phideg << ", 90, " << (phideg+90) << ", 0, 0";
78  rotation = DDrot(DDName(rotstr, rotns), 90*CLHEP::deg,
79  phideg*CLHEP::deg, 90*CLHEP::deg,
80  (90+phideg)*CLHEP::deg, 0*CLHEP::deg, 0*CLHEP::deg);
81  }
82  }
83 
84  double xpos = shiftX*cos(phi) - shiftY*sin(phi);
85  double ypos = shiftX*sin(phi) + shiftY*cos(phi);
86  DDTranslation tran(xpos, ypos, zoffset);
87 
88  DDName parentName = parent().name();
89  cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation);
90  LogDebug("HCalGeom") << "DDHCalAngular test: "
91  << DDName(childName, idNameSpace) << " number "
92  << copyNo << " positioned in " << parentName << " at "
93  << tran << " with " << rotation;
94  phi += dphi;
95  copyNo += incrCopyNo;
96  }
97 }
#define LogDebug(id)
double startAngle
Definition: DDHCalAngular.h:26
std::string rotns
Definition: DDHCalAngular.h:35
double rangeAngle
Definition: DDHCalAngular.h:27
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()
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:67
std::string childName
Definition: DDHCalAngular.h:37
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void execute(DDCompactView &cpv) override
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
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
~DDHCalAngular() override
std::string idNameSpace
Definition: DDHCalAngular.h:36