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 
9 namespace std{} using namespace std;
14 #include "CLHEP/Units/GlobalSystemOfUnits.h"
15 
17  LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating an instance";
18 }
19 
21 
23  const DDVectorArguments & ,
24  const DDMapArguments & ,
25  const DDStringArguments & sArgs,
26  const DDStringVectorArguments & ) {
27 
28  eta = nArgs["Eta"];
29  theta = 2.0*atan(exp(-eta));
30  phi = nArgs["Phi"];
31  distance = nArgs["Dist"];
32  distanceZ = nArgs["DistZ"];
33  dz = nArgs["Dz"];
34  copyNumber = int (nArgs["Number"]);
35  dist = (distance+distanceZ/sin(theta));
36  LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parameters for position"
37  << "ing--" << " Eta " << eta << "\tPhi "
38  << phi/CLHEP::deg << "\tTheta " << theta/CLHEP::deg
39  << "\tDistance " << distance << "/" << distanceZ << "/"
40  << dist <<"\tDz " << dz <<"\tcopyNumber " << copyNumber;
41 
42  idNameSpace = DDCurrentNamespace::ns();
43  childName = sArgs["ChildName"];
44  DDName parentName = parent().name();
45  LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parent " << parentName
46  << "\tChild " << childName << " NameSpace "
47  << idNameSpace;
48 }
49 
51 
52  double thetax = 90.*CLHEP::deg + theta;
53  double sthx = sin(thetax);
54  if (abs(sthx)>1.e-12) sthx = 1./sthx;
55  else sthx = 1.;
56  double phix = atan2(sthx*cos(theta)*sin(phi),sthx*cos(theta)*cos(phi));
57  double thetay = 90.*CLHEP::deg;
58  double phiy = 90.*CLHEP::deg + phi;
59  double thetaz = theta;
60  double phiz = phi;
61 
63  string rotstr = childName;
64  LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating a new rotation "
65  << rotstr << "\t" << thetax/CLHEP::deg << ","
66  << phix/CLHEP::deg << "," << thetay/CLHEP::deg << ","
67  << phiy/CLHEP::deg << "," << thetaz/CLHEP::deg <<","
68  << phiz/CLHEP::deg;
69  rotation = DDrot(DDName(rotstr, idNameSpace), thetax, phix, thetay, phiy,
70  thetaz, phiz);
71 
72  double r = dist*sin(theta);
73  double xpos = r*cos(phi);
74  double ypos = r*sin(phi);
75  double zpos = dist*cos(theta);
76  DDTranslation tran(xpos, ypos, zpos);
77 
78  DDName parentName = parent().name();
79  cpv.position(DDName(childName,idNameSpace), parentName,copyNumber, tran,rotation);
80  LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: "
81  << DDName(childName, idNameSpace) << " number "
82  << copyNumber << " positioned in " << parentName
83  << " at " << tran << " with " << rotation;
84 
85  xpos = (dist-dz)*sin(theta)*cos(phi);
86  ypos = (dist-dz)*sin(theta)*sin(phi);
87  zpos = (dist-dz)*cos(theta);
88 
89  edm::LogInfo("HCalGeom") << "DDHCalTestBeamAlgo: Suggested Beam position "
90  << "(" << xpos << ", " << ypos << ", " << zpos
91  << ") and (dist, eta, phi) = (" << (dist-dz) << ", "
92  << eta << ", " << phi << ")";
93 }
#define LogDebug(id)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:64
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, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
void execute(DDCompactView &cpv)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)