CMS 3D CMS Logo

DDHCalTBZposAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalTBZposAlgo.cc
3 // Description: Position inside the mother by shifting along Z given by eta
5 
6 #include <cmath>
7 #include <algorithm>
8 #include <map>
9 #include <string>
10 #include <vector>
11 
21 
22 //#define EDM_ML_DEBUG
23 using namespace angle_units::operators;
24 
25 class DDHCalTBZposAlgo : public DDAlgorithm {
26 public:
27  //Constructor and Destructor
29  ~DDHCalTBZposAlgo() override;
30 
31  void initialize(const DDNumericArguments& nArgs,
32  const DDVectorArguments& vArgs,
33  const DDMapArguments& mArgs,
34  const DDStringArguments& sArgs,
35  const DDStringVectorArguments& vsArgs) override;
36 
37  void execute(DDCompactView& cpv) override;
38 
39 private:
40  double eta; //Eta at which beam is focussed
41  double theta; //Corresponding theta value
42  double shiftY; //Shift along Y
43  double shiftX; //Shift along X
44  double zoffset; //Offset in z
45  double dist; //Radial distance
46  double tilt; //Tilt with respect to y-axis
47  int copyNumber; //Copy Number
48 
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") << "DDHCalTBZposAlgo: Creating an instance";
56 #endif
57 }
58 
60 
62  const DDVectorArguments&,
63  const DDMapArguments&,
64  const DDStringArguments& sArgs,
65  const DDStringVectorArguments&) {
66  eta = nArgs["Eta"];
67  theta = 2.0 * atan(exp(-eta));
68  shiftX = nArgs["ShiftX"];
69  shiftY = nArgs["ShiftY"];
70  zoffset = nArgs["Zoffset"];
71  dist = nArgs["Distance"];
72  tilt = nArgs["TiltAngle"];
73  copyNumber = int(nArgs["Number"]);
74  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parameters for position"
75  << "ing--"
76  << " Eta " << eta << "\tTheta " << convertRadToDeg(theta) << "\tShifts " << shiftX
77  << ", " << shiftY << " along x, y "
78  << "axes; \tZoffest " << zoffset << "\tRadial Distance " << dist << "\tTilt angle "
79  << convertRadToDeg(tilt) << "\tcopyNumber " << copyNumber;
80 
81  idNameSpace = DDCurrentNamespace::ns();
82  childName = sArgs["ChildName"];
83 #ifdef EDM_ML_DEBUG
84  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parent " << parent().name() << "\tChild " << childName
85  << " NameSpace " << idNameSpace;
86 #endif
87 }
88 
90  DDName mother = parent().name();
91  DDName child(DDSplit(childName).first, DDSplit(childName).second);
92 
93  double thetax = 90._deg - theta;
94  double z = zoffset + dist * tan(thetax);
95  double x = shiftX - shiftY * sin(tilt);
96  double y = shiftY * cos(tilt);
97  DDTranslation tran(x, y, z);
99  if (tilt != 0) {
100  std::string rotstr = "R" + formatAsDegrees(tilt);
101  rot = DDRotation(DDName(rotstr, idNameSpace));
102  if (!rot) {
103 #ifdef EDM_ML_DEBUG
104  edm::LogVerbatim("HCalGeom") << "DDHCalZposAlgo: Creating a rotation " << DDName(rotstr, idNameSpace) << "\t90, "
105  << convertRadToDeg(tilt) << ",90," << (90 + convertRadToDeg(tilt)) << ", 0, 0";
106 #endif
107  rot = DDrot(DDName(rotstr, idNameSpace), 90._deg, tilt, 90._deg, (90._deg + tilt), 0.0, 0.0);
108  }
109  }
110  cpv.position(child, mother, copyNumber, tran, rot);
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: " << child << " number " << copyNumber << " positioned in "
113  << mother << " at " << tran << " with " << rot;
114 #endif
115 }
116 
117 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalTBZposAlgo, "hcal:DDHCalTBZposAlgo");
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
std::string idNameSpace
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
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
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
~DDHCalTBZposAlgo() override
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.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
std::string childName
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:68
void execute(DDCompactView &cpv) override
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
float x
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
Geom::Theta< T > theta() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7