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 #include <map>
9 #include <string>
10 #include <vector>
11 
20 
21 //#define EDM_ML_DEBUG
22 using namespace angle_units::operators;
23 
24 class DDHCalAngular : public DDAlgorithm {
25 public:
26  //Constructor and Destructor
27  DDHCalAngular();
28  ~DDHCalAngular() override;
29 
30  void initialize(const DDNumericArguments& nArgs,
31  const DDVectorArguments& vArgs,
32  const DDMapArguments& mArgs,
33  const DDStringArguments& sArgs,
34  const DDStringVectorArguments& vsArgs) override;
35 
36  void execute(DDCompactView& cpv) override;
37 
38 private:
39  double startAngle; //Start angle
40  double rangeAngle; //Range angle
41  double shiftY; //Shift along Y
42  double shiftX; //Shift along X
43  double zoffset; //Offset in z
44  int n; //Mumber of copies
45  int startCopyNo; //Start copy Number
46  int incrCopyNo; //Increment copy Number
47 
48  std::string rotns; //Namespace for rotation matrix
49  std::string idNameSpace; //Namespace of this and ALL sub-parts
50  std::string childName; //Children name
51 };
52 
54 #ifdef EDM_ML_DEBUG
55  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Creating an instance";
56 #endif
57 }
58 
60 
62  const DDVectorArguments&,
63  const DDMapArguments&,
64  const DDStringArguments& sArgs,
65  const DDStringVectorArguments&) {
66  startAngle = nArgs["startAngle"];
67  rangeAngle = nArgs["rangeAngle"];
68  shiftX = nArgs["shiftX"];
69  shiftY = nArgs["shiftY"];
70  zoffset = nArgs["zoffset"];
71  n = int(nArgs["n"]);
72  startCopyNo = int(nArgs["startCopyNo"]);
73  incrCopyNo = int(nArgs["incrCopyNo"]);
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Parameters for positioning "
76  << "-- " << n << " copies in " << convertRadToDeg(rangeAngle) << " from "
77  << convertRadToDeg(startAngle) << "\tShifts " << shiftX << ", " << shiftY
78  << " along x, y axes; \tZoffest " << zoffset << "\tStart and inremental copy nos "
79  << startCopyNo << ", " << incrCopyNo;
80 #endif
81  rotns = sArgs["RotNameSpace"];
82  idNameSpace = DDCurrentNamespace::ns();
83  childName = sArgs["ChildName"];
84 #ifdef EDM_ML_DEBUG
85  DDName parentName = parent().name();
86  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Parent " << parentName << "\tChild " << childName << "\tNameSpace "
87  << idNameSpace << "\tRotation Namespace " << rotns;
88 #endif
89 }
90 
92  double dphi = rangeAngle / n;
93  double phix = startAngle;
94  int copyNo = startCopyNo;
95  double theta = 90._deg;
96  for (int ii = 0; ii < n; ii++) {
97  double phiy = phix + 90._deg;
99  std::string rotstr("NULL");
100 
101  static const double tol = 0.1;
102  if (std::abs(phix) > tol) {
103  rotstr = "R" + formatAsDegreesInInteger(phix);
104  rotation = DDRotation(DDName(rotstr, rotns));
105  if (!rotation) {
106 #ifdef EDM_ML_DEBUG
107  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Creating a rotation " << DDName(rotstr, idNameSpace) << "\t90, "
108  << convertRadToDeg(phix) << ", 90, " << (90 + convertRadToDeg(phix)) << ", 0, 0";
109 #endif
110  rotation = DDrot(DDName(rotstr, rotns), theta, phix, theta, phiy, 0, 0);
111  }
112  }
113 
114  double xpos = shiftX * cos(phix) - shiftY * sin(phix);
115  double ypos = shiftX * sin(phix) + shiftY * cos(phix);
116  DDTranslation tran(xpos, ypos, zoffset);
117 
118  DDName parentName = parent().name();
119  cpv.position(DDName(childName, idNameSpace), parentName, copyNo, tran, rotation);
120 #ifdef EDM_ML_DEBUG
121  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: " << DDName(childName, idNameSpace) << " number " << copyNo
122  << " positioned in " << parentName << " at " << tran << " with " << rotation;
123 #endif
124  phix += dphi;
125  copyNo += incrCopyNo;
126  }
127 }
128 
129 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalAngular, "hcal:DDHCalAngular");
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
std::string rotns
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
std::string formatAsDegreesInInteger(double radianVal)
Definition: DDTypes.cc:79
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
std::string childName
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:67
void execute(DDCompactView &cpv) override
ii
Definition: cuy.py:589
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
~DDHCalAngular() override
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::string idNameSpace
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7