CMS 3D CMS Logo

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