CMS 3D CMS Logo

DDHGCalNoTaperEndcap.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <algorithm>
3 #include <iostream>
4 
12 #include "CLHEP/Units/GlobalPhysicalConstants.h"
13 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 
15 //#define EDM_ML_DEBUG
16 
18  edm::LogInfo("HGCalGeom") << "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"];
39  edm::LogInfo("HGCalGeom") << "DDHGCalNoTaperEndcap: NameSpace " << m_idNameSpace
40  << "\tParent " << parent().name();
41 }
42 
44  int lastCopyNo = m_startCopyNo;
45  lastCopyNo = createQuarter( cpv, 1, 1, lastCopyNo );
46  lastCopyNo = createQuarter( cpv, -1, 1, lastCopyNo );
47  lastCopyNo = createQuarter( cpv, -1, -1, lastCopyNo );
48  createQuarter( cpv, 1, -1, lastCopyNo );
49 }
50 
51 int
52 DDHGCalNoTaperEndcap::createQuarter( DDCompactView& cpv, int xQuadrant, int yQuadrant, int startCopyNo ) {
53  int copyNo = startCopyNo;
54  double tiltAngle = m_tiltAngle;
55  double xphi = xQuadrant*tiltAngle;
56  double yphi = yQuadrant*tiltAngle;
57  double theta = 90.*CLHEP::deg;
58  double phiX = 0.0;
59  double phiY = theta;
60  double phiZ = 3*theta;
61  double offsetZ = m_zoffset;
62  double offsetXY = m_xyoffset;
63 
64  double offsetX = xQuadrant*0.5*offsetXY;
65  double offsetY = yQuadrant*0.5*offsetXY;
66 
67 #ifdef EDM_ML_DEBUG
68  int rowmax(0), column(0);
69 #endif
70  while (std::abs(offsetX) < m_rMax) {
71 #ifdef EDM_ML_DEBUG
72  column++;
73  int row(0);
74 #endif
75  while (std::abs(offsetY) < m_rMax) {
76 #ifdef EDM_ML_DEBUG
77  row++;
78 #endif
79  double limit1 = sqrt((offsetX+0.5*xQuadrant*offsetXY)*
80  (offsetX+0.5*xQuadrant*offsetXY) +
81  (offsetY+0.5*yQuadrant*offsetXY)*
82  (offsetY+0.5*yQuadrant*offsetXY) );
83  double limit2 = sqrt((offsetX-0.5*xQuadrant*offsetXY)*
84  (offsetX-0.5*xQuadrant*offsetXY) +
85  (offsetY-0.5*yQuadrant*offsetXY)*
86  (offsetY-0.5*yQuadrant*offsetXY) );
87  // Make sure we do not add supermodules in rMin area
88  if (limit2 > m_rMin && limit1 < m_rMax) {
89 #ifdef EDM_ML_DEBUG
90  std::cout << m_childName << " copyNo = " << copyNo << " (" << column
91  << "," << row << "): offsetX,Y = " << offsetX << ","
92  << offsetY << " limit=" << limit1 << ":" << limit2
93  << " rMin, rMax = " << m_rMin << "," << m_rMax << std::endl;
94 #endif
96  std::string rotstr( "NULL" );
97 
98  // Check if we've already created the rotation matrix
99  rotstr = "R";
100  rotstr += std::to_string(copyNo);
101  rotation = DDRotation(DDName(rotstr));
102  if (!rotation) {
103  rotation = DDrot(DDName(rotstr, m_idNameSpace),
104  new DDRotationMatrix( *DDcreateRotationMatrix( theta, phiX, theta + yphi, phiY, -yphi, phiZ )
105  * ( *DDcreateRotationMatrix( theta + xphi, phiX, 90.*CLHEP::deg, 90.*CLHEP::deg, xphi, 0.0 ))));
106  }
107 
108 
109  DDTranslation tran(offsetX, offsetY, offsetZ);
110  edm::LogInfo("HGCalGeom") << "Module " << copyNo << ": location = "
111  << tran << " Rotation " << rotation;
112 
113  DDName parentName = parent().name();
114  cpv.position(DDName(m_childName), parentName, copyNo, tran, rotation);
115 
116  copyNo += m_incrCopyNo;
117  } else {
118 #ifdef EDM_ML_DEBUG
119  std::cout << " (" << column << "," << row << "): offsetX,Y = "
120  << offsetX << "," << offsetY << " is out of limit=" << limit1
121  << ":" << limit2 << " rMin, rMax = " << m_rMin << ","
122  << m_rMax << std::endl;
123 #endif
124  }
125 
126  yphi += yQuadrant*2.*tiltAngle;
127  offsetY += yQuadrant*offsetXY;
128 
129  }
130 #ifdef EDM_ML_DEBUG
131  if (row > rowmax) rowmax = row;
132 #endif
133  xphi += xQuadrant*2.*tiltAngle;
134  yphi = yQuadrant*tiltAngle;
135  offsetY = yQuadrant*0.5*offsetXY;
136  offsetX += xQuadrant*offsetXY;
137 
138  }
139 #ifdef EDM_ML_DEBUG
140  std::cout << rowmax << " rows and " << column << " columns in quadrant "
141  << xQuadrant << ":" << yQuadrant << std::endl;
142 #endif
143  return copyNo;
144 }
145 
Geom::Theta< T > theta() const
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:15
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
virtual ~DDHGCalNoTaperEndcap(void)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:64
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
void execute(DDCompactView &cpv)
int createQuarter(DDCompactView &cpv, int xQuadrant, int yQuadrant, int startCopyNo)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
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:158