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 geant_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");
PluginFactory.h
DDHCalAngular::idNameSpace
std::string idNameSpace
Definition: DDHCalAngular.cc:49
DDCurrentNamespace.h
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DDrot
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
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDHCalAngular::shiftY
double shiftY
Definition: DDHCalAngular.cc:41
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
formatAsDegreesInInteger
std::string formatAsDegreesInInteger(double radianVal)
Definition: DDTypes.cc:79
DDHCalAngular::startAngle
double startAngle
Definition: DDHCalAngular.cc:39
geant_units::operators
Definition: GeantUnits.h:18
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDHCalAngular::DDHCalAngular
DDHCalAngular()
Definition: DDHCalAngular.cc:53
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDHCalAngular::rotns
std::string rotns
Definition: DDHCalAngular.cc:48
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDHCalAngular::zoffset
double zoffset
Definition: DDHCalAngular.cc:43
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDHCalAngular
Definition: DDHCalAngular.cc:24
GeantUnits.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
DDHCalAngular::shiftX
double shiftX
Definition: DDHCalAngular.cc:42
createfilelist.int
int
Definition: createfilelist.py:10
DDLogicalPart.h
DDHCalAngular::incrCopyNo
int incrCopyNo
Definition: DDHCalAngular.cc:46
DDHCalAngular::childName
std::string childName
Definition: DDHCalAngular.cc:50
ReadMapType< double >
DDHCalAngular::~DDHCalAngular
~DDHCalAngular() override
Definition: DDHCalAngular.cc:59
DDAlgorithm.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDHCalAngular::rangeAngle
double rangeAngle
Definition: DDHCalAngular.cc:40
DDHCalAngular::startCopyNo
int startCopyNo
Definition: DDHCalAngular.cc:45
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDHCalAngular::n
int n
Definition: DDHCalAngular.cc:44
DDHCalAngular::execute
void execute(DDCompactView &cpv) override
Definition: DDHCalAngular.cc:91
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
cuy.ii
ii
Definition: cuy.py:590
DDHCalAngular::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHCalAngular.cc:61
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:76
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18