CMS 3D CMS Logo

DDHGCalNoTaperEndcap.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <cmath>
3 
12 
13 //#define EDM_ML_DEBUG
14 using namespace geant_units::operators;
15 
17  edm::LogVerbatim("HGCalGeom")
18  << "DDHGCalNoTaperEndcap test: Creating an instance";
19 }
20 
22 
24  const DDVectorArguments& vArgs,
25  const DDMapArguments&,
26  const DDStringArguments& sArgs,
27  const DDStringVectorArguments&) {
28  m_tiltAngle = nArgs["tiltAngle"];
29  m_invert = int(nArgs["invert"]);
30  m_rMin = int(nArgs["rMin"]);
31  m_rMax = int(nArgs["rMax"]);
32  m_zoffset = nArgs["zoffset"];
33  m_xyoffset = nArgs["xyoffset"];
34  m_n = int(nArgs["n"]);
35  m_startCopyNo = int(nArgs["startCopyNo"]);
36  m_incrCopyNo = int(nArgs["incrCopyNo"]);
37  m_childName = sArgs["ChildName"];
38  m_idNameSpace = DDCurrentNamespace::ns();
39  edm::LogVerbatim("HGCalGeom")
40  << "DDHGCalNoTaperEndcap: NameSpace " << m_idNameSpace << "\tParent "
41  << parent().name();
42 }
43 
45  int lastCopyNo = m_startCopyNo;
46  lastCopyNo = createQuarter(cpv, 1, 1, lastCopyNo);
47  lastCopyNo = createQuarter(cpv, -1, 1, lastCopyNo);
48  lastCopyNo = createQuarter(cpv, -1, -1, lastCopyNo);
49  createQuarter(cpv, 1, -1, lastCopyNo);
50 }
51 
53  int yQuadrant, int startCopyNo) {
54  int copyNo = startCopyNo;
55  double tiltAngle = m_tiltAngle;
56  double xphi = xQuadrant * tiltAngle;
57  double yphi = yQuadrant * tiltAngle;
58  double theta = 90._deg;
59  double phiX = 0.0;
60  double phiY = theta;
61  double phiZ = 3 * theta;
62  double offsetZ = m_zoffset;
63  double offsetXY = m_xyoffset;
64 
65  double offsetX = xQuadrant * 0.5 * offsetXY;
66  double offsetY = yQuadrant * 0.5 * offsetXY;
67 
68 #ifdef EDM_ML_DEBUG
69  int rowmax(0), column(0);
70 #endif
71  while (std::abs(offsetX) < m_rMax) {
72 #ifdef EDM_ML_DEBUG
73  column++;
74  int row(0);
75 #endif
76  while (std::abs(offsetY) < m_rMax) {
77 #ifdef EDM_ML_DEBUG
78  row++;
79 #endif
80  double limit1 = sqrt((offsetX + 0.5 * xQuadrant * offsetXY) *
81  (offsetX + 0.5 * xQuadrant * offsetXY) +
82  (offsetY + 0.5 * yQuadrant * offsetXY) *
83  (offsetY + 0.5 * yQuadrant * offsetXY));
84  double limit2 = sqrt((offsetX - 0.5 * xQuadrant * offsetXY) *
85  (offsetX - 0.5 * xQuadrant * offsetXY) +
86  (offsetY - 0.5 * yQuadrant * offsetXY) *
87  (offsetY - 0.5 * yQuadrant * offsetXY));
88  // Make sure we do not add supermodules in rMin area
89  if (limit2 > m_rMin && limit1 < m_rMax) {
90 #ifdef EDM_ML_DEBUG
91  edm::LogVerbatim("HGCalGeom")
92  << m_childName << " copyNo = " << copyNo << " (" << column
93  << "," << row << "): offsetX,Y = " << offsetX << ","
94  << offsetY << " limit=" << limit1 << ":" << limit2
95  << " rMin, rMax = " << m_rMin << "," << m_rMax;
96 #endif
98  std::string rotstr("NULL");
99 
100  // Check if we've already created the rotation matrix
101  rotstr = "R";
102  rotstr += std::to_string(copyNo);
103  rotation = DDRotation(DDName(rotstr));
104  if (!rotation) {
105  rotation = DDrot(
106  DDName(rotstr, m_idNameSpace),
107  std::make_unique<DDRotationMatrix>(
108  *DDcreateRotationMatrix(theta, phiX, theta + yphi, phiY,
109  -yphi, phiZ) *
110  (*DDcreateRotationMatrix(theta + xphi, phiX, 90._deg,
111  90._deg, xphi, 0.0))));
112  }
113 
114  DDTranslation tran(offsetX, offsetY, offsetZ);
115  edm::LogVerbatim("HGCalGeom")
116  << "Module " << copyNo << ": location = " << tran << " Rotation "
117  << rotation;
118 
119  DDName parentName = parent().name();
120  cpv.position(DDName(m_childName), parentName, copyNo, tran, rotation);
121 
122  copyNo += m_incrCopyNo;
123  } else {
124 #ifdef EDM_ML_DEBUG
125  edm::LogVerbatim("HGCalGeom")
126  << " (" << column << "," << row << "): offsetX,Y = " << offsetX
127  << "," << offsetY << " is out of limit=" << limit1 << ":" << limit2
128  << " rMin, rMax = " << m_rMin << "," << m_rMax;
129 #endif
130  }
131 
132  yphi += yQuadrant * 2. * tiltAngle;
133  offsetY += yQuadrant * offsetXY;
134  }
135 #ifdef EDM_ML_DEBUG
136  if (row > rowmax) rowmax = row;
137 #endif
138  xphi += xQuadrant * 2. * tiltAngle;
139  yphi = yQuadrant * tiltAngle;
140  offsetY = yQuadrant * 0.5 * offsetXY;
141  offsetX += xQuadrant * offsetXY;
142  }
143 #ifdef EDM_ML_DEBUG
144  edm::LogVerbatim("HGCalGeom")
145  << rowmax << " rows and " << column << " columns in quadrant "
146  << xQuadrant << ":" << yQuadrant;
147 #endif
148  return copyNo;
149 }
Geom::Theta< T > theta() const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
T sqrt(T t)
Definition: SSEVec.h:18
~DDHGCalNoTaperEndcap(void) override
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
std::unique_ptr< DDRotationMatrix > DDcreateRotationMatrix(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
create a new DDRotationMatrix in the GEANT3 style.
Definition: DDRotation.cc:149
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
void execute(DDCompactView &cpv) override
int createQuarter(DDCompactView &cpv, int xQuadrant, int yQuadrant, int startCopyNo)