CMS 3D CMS Logo

DDPixFwdDiskAlgo.cc
Go to the documentation of this file.
1 // File: DDPixFwdDiskAlgo.cc
3 // Description: Position n copies at given z-values
5 
6 #include <cmath>
7 #include <algorithm>
8 
13 #include "CLHEP/Units/PhysicalConstants.h"
14 #include "CLHEP/Units/SystemOfUnits.h"
15 
17  LogDebug("TrackerGeom") <<"DDPixFwdDiskAlgo info: Creating an instance";
18 }
19 
21 
23  const DDVectorArguments & vArgs,
24  const DDMapArguments & ,
25  const DDStringArguments & sArgs,
26  const DDStringVectorArguments & vsArgs) {
27 
28  startCopyNo = int(nArgs["StartCopyNo"]);
29  nBlades = int(nArgs["NumberOfBlades"]);
30  bladeAngle = nArgs["BladeAngle"];
31  bladeTilt = nArgs["BladeTilt"];
32  zPlane = nArgs["BladeCommonZ"];
33  bladeZShift = vArgs["BladeZShift"];
34  anchorR = nArgs["AnchorRadius"];
35 
37  childName = sArgs["ChildName"];
38  rotName = sArgs["RotationName"];
39  flagString = sArgs["FlagString"];
40  DDName parentName = parent().name();
41  LogDebug("TrackerGeom") << "DDPixFwdDiskAlgo debug: Parent " << parentName
42  << "\tChild " << childName << " NameSpace "
43  << idNameSpace << "\tRot Name " << rotName
44  << "\tCopyNo (Start/Total) " << startCopyNo << ", "
45  << nBlades << "\tAngles " << bladeAngle/CLHEP::deg
46  << ", " << bladeTilt/CLHEP::deg << "\tZshifts "
47  << zPlane << "\tAmnchor Radius " << anchorR;
48 
49  for (int iBlade=0; iBlade<nBlades; ++iBlade) {
50  LogDebug("TrackerGeom") << "DDPixFwdDiskAlgo: Blade " << iBlade
51  << " flag " << flagString[iBlade] << " zshift "
52  << bladeZShift[iBlade];
53  }
54 }
55 
57 
58  int copy = startCopyNo;
59  DDName mother = parent().name();
61  std::string flagSelector = "Y";
62 
63  double deltaPhi = (360./nBlades)*CLHEP::deg;
64  std::string rotns = DDSplit(rotName).second;
65  for (int iBlade=0; iBlade<nBlades; ++iBlade) {
66 
67  if (flagString[iBlade] == flagSelector[0]) {
68  std::string rotstr = DDSplit(rotName).first + std::to_string(double(copy));
69 
70  double phi = (iBlade+0.5)*deltaPhi;
71 // double phi = (iBlade+0.5)*deltaPhi - 90.*CLHEP::deg;
72  double phix = std::atan2(std::sin(phi)*std::cos(bladeAngle),
74  double thetx= std::acos(-std::sin(bladeAngle));
75  double phiy = std::atan2((std::cos(phi)*std::cos(bladeTilt)+std::sin(phi)
77  (-std::sin(phi)*std::cos(bladeTilt)+std::cos(phi)
79  double thety= std::acos(std::cos(bladeAngle)*std::sin(bladeTilt));
80  double phiz = std::atan2((-std::cos(phi)*std::sin(bladeTilt)+std::sin(phi)
84  double thetz= std::acos(std::cos(bladeAngle)*std::cos(bladeTilt));
85  DDRotation rot = DDRotation(DDName(rotstr, rotns));
86  if (!rot) {
87  LogDebug("TrackerGeom") << "DDPixFwdDiskAlgo test: Creating a new "
88  << "rotation: " << rotstr << "\t"
89  << thetx/CLHEP::deg << ", " << phix/CLHEP::deg
90  << ", " << thety/CLHEP::deg << ", "
91  << phiy/CLHEP::deg << ", " << thetz/CLHEP::deg
92  << ", " << phiz/CLHEP::deg;
93  LogDebug("TrackerGeom") << "Rotation Matrix (" << phi/CLHEP::deg << ", " << bladeAngle/CLHEP::deg << ", " << bladeTilt/CLHEP::deg << ") " << std::cos(phi)*std::cos(bladeAngle) << ", " << (-std::sin(phi)*std::cos(bladeTilt)+std::cos(phi)*std::sin(bladeAngle)*std::sin(bladeTilt)) << ", " << (std::sin(phi)*std::sin(bladeTilt)+std::cos(phi)*std::sin(bladeAngle)*std::cos(bladeTilt)) << ", " << std::sin(phi)*std::cos(bladeAngle) << ", " << (std::cos(phi)*std::cos(bladeTilt)+std::sin(phi)*std::sin(bladeAngle)*std::sin(bladeTilt)) << ", " << (-std::cos(phi)*std::sin(bladeTilt)+std::sin(phi)*std::sin(bladeAngle)*std::cos(bladeTilt)) << ", " << -std::sin(bladeAngle) << ", " << std::cos(bladeAngle)*std::sin(bladeTilt) << ", " << std::cos(bladeAngle)*std::cos(bladeTilt);
94  rot = DDrot(DDName(rotstr, rotns), thetx,phix, thety,phiy, thetz,phiz);
95  }
96  double xpos = anchorR*(-std::sin(phi)*std::cos(bladeTilt)+std::cos(phi)
98  double ypos = anchorR*(std::cos(phi)*std::cos(bladeTilt)+std::sin(phi)
101  bladeZShift[iBlade];
102  DDTranslation tran(xpos, ypos, zpos);
103  cpv.position (child, mother, copy, tran, rot);
104  LogDebug("TrackerGeom") << "DDPixFwdDiskAlgo test: " << child
105  << " number " << copy << " positioned in "
106  << mother << " at " << tran << " with " << rot;
107  }
108  copy++;
109  }
110 }
#define LogDebug(id)
std::string flagString
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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:15
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
virtual ~DDPixFwdDiskAlgo()
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:64
U second(std::pair< T, U > const &p)
void execute(DDCompactView &cpv)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::string childName
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
std::string rotName
std::string idNameSpace
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
std::vector< double > bladeZShift