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 
15 
16 //#define EDM_ML_DEBUG
17 using namespace geant_units::operators;
18 
20 #ifdef EDM_ML_DEBUG
21  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Creating an instance";
22 #endif
23 }
24 
26 
28  const DDVectorArguments & ,
29  const DDMapArguments & ,
30  const DDStringArguments & sArgs,
31  const DDStringVectorArguments & ) {
32 
33  eta = nArgs["Eta"];
34  theta = 2.0*atan(exp(-eta));
35  shiftX = nArgs["ShiftX"];
36  shiftY = nArgs["ShiftY"];
37  zoffset = nArgs["Zoffset"];
38  dist = nArgs["Distance"];
39  tilt = nArgs["TiltAngle"];
40  copyNumber = int (nArgs["Number"]);
41  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parameters for position"
42  << "ing--" << " Eta " << eta << "\tTheta "
43  << convertRadToDeg(theta) << "\tShifts "
44  << shiftX << ", " << shiftY << " along x, y "
45  << "axes; \tZoffest " << zoffset
46  << "\tRadial Distance " << dist
47  << "\tTilt angle " << convertRadToDeg(tilt)
48  << "\tcopyNumber " << copyNumber;
49 
50  idNameSpace = DDCurrentNamespace::ns();
51  childName = sArgs["ChildName"];
52 #ifdef EDM_ML_DEBUG
53  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parent " <<parent().name()
54  << "\tChild " << childName << " NameSpace "
55  << idNameSpace;
56 #endif
57 }
58 
60 
61  DDName mother = parent().name();
62  DDName child(DDSplit(childName).first, DDSplit(childName).second);
63 
64  double thetax = 90._deg - theta;
65  double z = zoffset + dist*tan(thetax);
66  double x = shiftX - shiftY*sin(tilt);
67  double y = shiftY*cos(tilt);
68  DDTranslation tran(x,y,z);
70  if (tilt != 0) {
71  std::string rotstr = "R" + formatAsDegrees(tilt);
72  rot = DDRotation(DDName(rotstr, idNameSpace));
73  if (!rot) {
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HCalGeom") << "DDHCalZposAlgo: Creating a rotation "
76  << DDName(rotstr,idNameSpace) << "\t90, "
77  << convertRadToDeg(tilt) << ",90,"
78  << (90+convertRadToDeg(tilt)) << ", 0, 0";
79 #endif
80  rot = DDrot(DDName(rotstr, idNameSpace), 90._deg, tilt,
81  90._deg, (90._deg+tilt), 0.0, 0.0);
82  }
83  }
84  cpv.position(child, mother, copyNumber, tran, rot);
85 #ifdef EDM_ML_DEBUG
86  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: " << child << " number "
87  << copyNumber << " positioned in " << mother
88  << " at " << tran << " with " << rot;
89 #endif
90 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
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
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:80
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:75
void execute(DDCompactView &cpv) override
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3