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 
15 
16 //#define EDM_ML_DEBUG
17 using namespace geant_units::operators;
18 
20 #ifdef EDM_ML_DEBUG
21  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Creating an instance";
22 #endif
23 }
24 
26 
28  const DDVectorArguments & ,
29  const DDMapArguments & ,
30  const DDStringArguments & sArgs,
31  const DDStringVectorArguments & ) {
32 
33  startAngle = nArgs["startAngle"];
34  rangeAngle = nArgs["rangeAngle"];
35  shiftX = nArgs["shiftX"];
36  shiftY = nArgs["shiftY"];
37  zoffset = nArgs["zoffset"];
38  n = int (nArgs["n"]);
39  startCopyNo = int (nArgs["startCopyNo"]);
40  incrCopyNo = int (nArgs["incrCopyNo"]);
41 #ifdef EDM_ML_DEBUG
42  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Parameters for positioning "
43  << "-- " << n << " copies in "
44  << convertRadToDeg(rangeAngle) << " from "
45  << convertRadToDeg(startAngle) << "\tShifts "
46  << shiftX << ", " << shiftY
47  << " along x, y axes; \tZoffest " << zoffset
48  << "\tStart and inremental copy nos "
49  << startCopyNo << ", " << incrCopyNo;
50 #endif
51  rotns = sArgs["RotNameSpace"];
52  idNameSpace = DDCurrentNamespace::ns();
53  childName = sArgs["ChildName"];
54 #ifdef EDM_ML_DEBUG
55  DDName parentName = parent().name();
56  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Parent " << parentName
57  << "\tChild " << childName << "\tNameSpace "
58  << idNameSpace << "\tRotation Namespace "
59  << rotns;
60 #endif
61 }
62 
64 
65  double dphi = rangeAngle/n;
66  double phix = startAngle;
67  int copyNo = startCopyNo;
68  double theta = 90._deg;
69  for (int ii=0; ii<n; ii++) {
70  double phiy = phix + 90._deg;
72  std::string rotstr("NULL");
73 
74  static const double tol = 0.1;
75  if (std::abs(phix) > tol) {
76  rotstr = "R" + formatAsDegreesInInteger(phix);
77  rotation = DDRotation(DDName(rotstr, rotns));
78  if (!rotation) {
79 #ifdef EDM_ML_DEBUG
80  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Creating a rotation "
81  << DDName(rotstr, idNameSpace) << "\t90, "
82  << convertRadToDeg(phix) << ", 90, "
83  << (90+convertRadToDeg(phix)) << ", 0, 0";
84 #endif
85  rotation = DDrot(DDName(rotstr, rotns), theta, phix, theta, phiy, 0,0);
86  }
87  }
88 
89  double xpos = shiftX*cos(phix) - shiftY*sin(phix);
90  double ypos = shiftX*sin(phix) + shiftY*cos(phix);
91  DDTranslation tran(xpos, ypos, zoffset);
92 
93  DDName parentName = parent().name();
94  cpv.position(DDName(childName,idNameSpace),parentName,copyNo,tran,rotation);
95 #ifdef EDM_ML_DEBUG
96  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: "
97  << DDName(childName, idNameSpace)
98  << " number " << copyNo << " positioned in "
99  << parentName << " at " << tran << " with "
100  << rotation;
101 #endif
102  phix += dphi;
103  copyNo += incrCopyNo;
104  }
105 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
std::string formatAsDegreesInInteger(double radianVal)
Definition: DDTypes.cc:86
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:80
void execute(DDCompactView &cpv) override
ii
Definition: cuy.py:590
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