CMS 3D CMS Logo

DDTrackerAngular.cc
Go to the documentation of this file.
1 // File: DDTrackerAngular.cc
3 // Description: Position n copies at prescribed phi values
5 
6 #include <cmath>
7 #include <algorithm>
8 
13 #include "CLHEP/Units/GlobalPhysicalConstants.h"
14 #include "CLHEP/Units/GlobalSystemOfUnits.h"
15 
16 
18  LogDebug("TrackerGeom") << "DDTrackerAngular info: Creating an instance";
19 }
20 
22 
24  const DDVectorArguments & vArgs,
25  const DDMapArguments & ,
26  const DDStringArguments & sArgs,
27  const DDStringVectorArguments & ) {
28 
29  n = int(nArgs["N"]);
30  startCopyNo = int(nArgs["StartCopyNo"]);
31  incrCopyNo = int(nArgs["IncrCopyNo"]);
32  rangeAngle = nArgs["RangeAngle"];
33  startAngle = nArgs["StartAngle"];
34  radius = nArgs["Radius"];
35  center = vArgs["Center"];
36 
37  if (fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg) {
38  delta = rangeAngle/double(n);
39  } else {
40  if (n > 1) {
41  delta = rangeAngle/double(n-1);
42  } else {
43  delta = 0.;
44  }
45  }
46 
47  LogDebug("TrackerGeom") << "DDTrackerAngular debug: Parameters for position"
48  << "ing:: n " << n << " Start, Range, Delta "
49  << startAngle/CLHEP::deg << " "
50  << rangeAngle/CLHEP::deg << " " << delta/CLHEP::deg
51  << " Radius " << radius << " Centre " << center[0]
52  << ", " << center[1] << ", "<<center[2];
53 
55  childName = sArgs["ChildName"];
56 
57  DDName parentName = parent().name();
58  LogDebug("TrackerGeom") << "DDTrackerAngular debug: Parent " << parentName
59  << "\tChild " << childName << " NameSpace "
60  << idNameSpace;
61 }
62 
64 
65  DDName mother = parent().name();
67  double theta = 90.*CLHEP::deg;
68  int copy = startCopyNo;
69  double phi = startAngle;
70  for (int i=0; i<n; i++) {
71  double phix = phi;
72  double phiy = phix + 90.*CLHEP::deg;
73  double phideg = phix/CLHEP::deg;
74 
76  if (phideg != 0) {
77  std::string rotstr = DDSplit(childName).first + std::to_string(phideg*10.);
78  rotation = DDRotation(DDName(rotstr, idNameSpace));
79  if (!rotation) {
80  LogDebug("TrackerGeom") << "DDTrackerAngular test: Creating a new "
81  << "rotation: " << rotstr << "\t90., "
82  << phix/CLHEP::deg << ", 90.,"
83  << phiy/CLHEP::deg <<", 0, 0";
84  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
85  0., 0.);
86  }
87  }
88 
89  double xpos = radius*cos(phi) + center[0];
90  double ypos = radius*sin(phi) + center[1];
91  double zpos = center[2];
92  DDTranslation tran(xpos, ypos, zpos);
93 
94  cpv.position(child, mother, copy, tran, rotation);
95  LogDebug("TrackerGeom") << "DDTrackerAngular test " << child << " number "
96  << copy << " positioned in " << mother << " at "
97  << tran << " with " << rotation;
98  copy += incrCopyNo;
99  phi += delta;
100  }
101 }
#define LogDebug(id)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
def copy(args, dbName)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< double > center
Geom::Theta< T > theta() const
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)
std::string childName
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
~DDTrackerAngular() 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
void execute(DDCompactView &cpv) override
std::string idNameSpace