CMS 3D CMS Logo

DDHCalTestBeamAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalTestBeamAlgo.cc
3 // Description: Position inside the mother according to (eta,phi)
5 
6 #include <cmath>
7 #include <algorithm>
8 
14 
15 //#define EDM_ML_DEBUG
16 using namespace geant_units::operators;
17 
19 #ifdef EDM_ML_DEBUG
20  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Creating an instance";
21 #endif
22 }
23 
25 
27  const DDVectorArguments & ,
28  const DDMapArguments & ,
29  const DDStringArguments & sArgs,
30  const DDStringVectorArguments & ) {
31 
32  eta = nArgs["Eta"];
33  theta = 2.0*atan(exp(-eta));
34  phi = nArgs["Phi"];
35  distance = nArgs["Dist"];
36  distanceZ = nArgs["DistZ"];
37  dz = nArgs["Dz"];
38  copyNumber = int (nArgs["Number"]);
39  dist = (distance+distanceZ/sin(theta));
40 #ifdef EDM_ML_DEBUG
41  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Parameters for position"
42  << "ing--" << " Eta " << eta << "\tPhi "
43  << convertRadToDeg(phi) << "\tTheta "
44  << convertRadToDeg(theta) << "\tDistance "
45  << distance << "/" << distanceZ << "/"
46  << dist <<"\tDz " << dz <<"\tcopyNumber "
47  << copyNumber;
48 #endif
49  idNameSpace = DDCurrentNamespace::ns();
50  childName = sArgs["ChildName"];
51 #ifdef EDM_ML_DEBUG
52  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo:Parent "
53  << parent().name() << "\tChild " << childName
54  << " NameSpace " << idNameSpace;
55 #endif
56 }
57 
59 
60  double thetax = 90._deg + theta;
61  double sthx = sin(thetax);
62  if (std::abs(sthx)>1.e-12) sthx = 1./sthx;
63  else sthx = 1.;
64  double phix = atan2(sthx*cos(theta)*sin(phi),sthx*cos(theta)*cos(phi));
65  double thetay = 90._deg;
66  double phiy = 90._deg + phi;
67  double thetaz = theta;
68  double phiz = phi;
69 
71  std::string rotstr = childName;
72 #ifdef EDM_ML_DEBUG
73  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Creating a rotation "
74  << rotstr << "\t" << convertRadToDeg(thetax)
75  << "," << convertRadToDeg(phix) << ","
76  << convertRadToDeg(thetay) << ","
77  << convertRadToDeg(phiy) << ","
78  << convertRadToDeg(thetaz) <<","
79  << convertRadToDeg(phiz);
80 #endif
81  rotation = DDrot(DDName(rotstr, idNameSpace), thetax, phix, thetay, phiy,
82  thetaz, phiz);
83 
84  double r = dist*sin(theta);
85  double xpos = r*cos(phi);
86  double ypos = r*sin(phi);
87  double zpos = dist*cos(theta);
88  DDTranslation tran(xpos, ypos, zpos);
89 
90  DDName parentName = parent().name();
91  cpv.position(DDName(childName,idNameSpace), parentName, copyNumber, tran,
92  rotation);
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: "
95  << DDName(childName, idNameSpace) << " number "
96  << copyNumber << " positioned in " << parentName
97  << " at " << tran << " with " << rotation;
98 
99  xpos = (dist-dz)*sin(theta)*cos(phi);
100  ypos = (dist-dz)*sin(theta)*sin(phi);
101  zpos = (dist-dz)*cos(theta);
102 
103  edm::LogInfo("HCalGeom") << "DDHCalTestBeamAlgo: Suggested Beam position "
104  << "(" << xpos << ", " << ypos << ", " << zpos
105  << ") and (dist, eta, phi) = (" << (dist-dz) << ", "
106  << eta << ", " << phi << ")";
107 #endif
108 }
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
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
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
~DDHCalTestBeamAlgo() override
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:80
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
void execute(DDCompactView &cpv) override