CMS 3D CMS Logo

DDTrackerPhiAltAlgo.cc
Go to the documentation of this file.
1 // File: DDTrackerPhiAltAlgo.cc
3 // Description: Position n copies inside and outside at alternate 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") << "DDTrackerPhiAltAlgo info: Creating an instance";
19 }
20 
22 
24  const DDVectorArguments & ,
25  const DDMapArguments & ,
26  const DDStringArguments & sArgs,
27  const DDStringVectorArguments & ) {
28 
29  tilt = nArgs["Tilt"];
30  startAngle = nArgs["StartAngle"];
31  rangeAngle = nArgs["RangeAngle"];
32  radiusIn = nArgs["RadiusIn"];
33  radiusOut = nArgs["RadiusOut"];
34  zpos = nArgs["ZPosition"];
35  number = int (nArgs["Number"]);
36  startCopyNo= int (nArgs["StartCopyNo"]);
37  incrCopyNo = int (nArgs["IncrCopyNo"]);
38 
39  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parameters for "
40  << "positioning--" << " Tilt " << tilt
41  << "\tStartAngle " << startAngle/CLHEP::deg
42  << "\tRangeAngle " << rangeAngle/CLHEP::deg
43  << "\tRin " << radiusIn << "\tRout " << radiusOut
44  << "\t ZPos " << zpos << "\tCopy Numbers " << number
45  << " Start/Increment " << startCopyNo << ", "
46  << incrCopyNo;
47 
49  childName = sArgs["ChildName"];
50  DDName parentName = parent().name();
51  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parent " << parentName
52  << "\tChild " << childName << " NameSpace "
53  << idNameSpace;
54 }
55 
57 
58  if (number > 0) {
59  double theta = 90.*CLHEP::deg;
60  double dphi;
61  if (number == 1 || fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg)
62  dphi = rangeAngle/number;
63  else
64  dphi = rangeAngle/(number-1);
65  int copyNo = startCopyNo;
66 
67  DDName mother = parent().name();
69  for (int i=0; i<number; i++) {
70  double phi = startAngle + i*dphi;
71  double phix = phi - tilt + 90.*CLHEP::deg;
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") << "DDTrackerPhiAltAlgo test: Creating a new"
81  << " rotation " << rotstr << "\t" << "90., "
82  << phix/CLHEP::deg << ", 90.,"
83  << phiy/CLHEP::deg << ", 0, 0";
84  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta,
85  phiy, 0., 0.);
86  }
87  }
88 
89  double xpos, ypos;
90  if (i%2 == 0) {
91  xpos = radiusIn*cos(phi);
92  ypos = radiusIn*sin(phi);
93  } else {
94  xpos = radiusOut*cos(phi);
95  ypos = radiusOut*sin(phi);
96  }
97  DDTranslation tran(xpos, ypos, zpos);
98 
99  cpv.position(child, mother, copyNo, tran, rotation);
100  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo test: " << child
101  << " number " << copyNo << " positioned in "
102  << mother << " at " << tran << " with "
103  << rotation;
104  copyNo += incrCopyNo;
105  }
106  }
107 }
#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: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:64
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)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
void execute(DDCompactView &cpv)