CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDTrackerAngularV1.cc
Go to the documentation of this file.
1 // File: DDTrackerAngularV1.cc
3 // Description: Position n copies at prescribed phi values
5 
6 #include <cmath>
7 #include <algorithm>
8 
14 #include "CLHEP/Units/GlobalPhysicalConstants.h"
15 #include "CLHEP/Units/GlobalSystemOfUnits.h"
16 
17 
19  LogDebug("TrackerGeom") << "DDTrackerAngularV1 info: Creating an instance";
20 }
21 
23 
25  const DDVectorArguments & vArgs,
26  const DDMapArguments & ,
27  const DDStringArguments & sArgs,
28  const DDStringVectorArguments & ) {
29 
30  n = int(nArgs["N"]);
31  startCopyNo = int(nArgs["StartCopyNo"]);
32  incrCopyNo = int(nArgs["IncrCopyNo"]);
33  rangeAngle = nArgs["RangeAngle"];
34  startAngle = nArgs["StartAngle"];
35  radius = nArgs["Radius"];
36  center = vArgs["Center"];
37 
38  if (fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg) {
39  delta = rangeAngle/double(n);
40  } else {
41  if (n > 1) {
42  delta = rangeAngle/double(n-1);
43  } else {
44  delta = 0.;
45  }
46  }
47 
48  LogDebug("TrackerGeom") << "DDTrackerAngularV1 debug: Parameters for position"
49  << "ing:: n " << n << " Start, Range, Delta "
50  << startAngle/CLHEP::deg << " "
51  << rangeAngle/CLHEP::deg << " " << delta/CLHEP::deg
52  << " Radius " << radius << " Centre " << center[0]
53  << ", " << center[1] << ", "<<center[2];
54 
56  childName = sArgs["ChildName"];
57 
58  DDName parentName = parent().name();
59  LogDebug("TrackerGeom") << "DDTrackerAngularV1 debug: Parent " << parentName
60  << "\tChild " << childName << " NameSpace "
61  << idNameSpace;
62 }
63 
65 
66  DDName mother = parent().name();
68  double theta = 90.*CLHEP::deg;
69  int copy = startCopyNo;
70  double phi = startAngle;
71  for (int i=0; i<n; i++) {
72  double phix = phi + 90.*CLHEP::deg;
73  double phiy = phix + 90.*CLHEP::deg;
74  double phideg = phix/CLHEP::deg;
75 
77  if (phideg != 0) {
78  std::string rotstr = DDSplit(childName).first+dbl_to_string(phideg*10.);
79  rotation = DDRotation(DDName(rotstr, idNameSpace));
80  if (!rotation) {
81  LogDebug("TrackerGeom") << "DDTrackerAngularV1 test: Creating a new "
82  << "rotation: " << rotstr << "\t90., "
83  << phix/CLHEP::deg << ", 90.,"
84  << phiy/CLHEP::deg <<", 0, 0";
85  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
86  0., 0.);
87  }
88  }
89 
90  double xpos = radius*cos(phi) + center[0];
91  double ypos = radius*sin(phi) + center[1];
92  double zpos = center[2];
93  DDTranslation tran(xpos, ypos, zpos);
94 
95  cpv.position(child, mother, copy, tran, rotation);
96  LogDebug("TrackerGeom") << "DDTrackerAngularV1 test " << child << " number "
97  << copy << " positioned in " << mother << " at "
98  << tran << " with " << rotation;
99  copy += incrCopyNo;
100  phi += delta;
101  }
102 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
list parent
Definition: dbtoconf.py:74
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:14
static std::string & ns()
std::string dbl_to_string(const double &in)
Converts only the integer part of a double to a string.
Definition: DDutils.cc:12
type of data representation of DDCompactView
Definition: DDCompactView.h:77
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
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)
void execute(DDCompactView &cpv)
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 > center