CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
14 #include "CLHEP/Units/GlobalPhysicalConstants.h"
15 #include "CLHEP/Units/GlobalSystemOfUnits.h"
16 
17 
19  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo info: Creating an instance";
20 }
21 
23 
25  const DDVectorArguments & ,
26  const DDMapArguments & ,
27  const DDStringArguments & sArgs,
28  const DDStringVectorArguments & ) {
29 
30  tilt = nArgs["Tilt"];
31  startAngle = nArgs["StartAngle"];
32  rangeAngle = nArgs["RangeAngle"];
33  radiusIn = nArgs["RadiusIn"];
34  radiusOut = nArgs["RadiusOut"];
35  zpos = nArgs["ZPosition"];
36  number = int (nArgs["Number"]);
37  startCopyNo= int (nArgs["StartCopyNo"]);
38  incrCopyNo = int (nArgs["IncrCopyNo"]);
39 
40  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parameters for "
41  << "positioning--" << " Tilt " << tilt
42  << "\tStartAngle " << startAngle/CLHEP::deg
43  << "\tRangeAngle " << rangeAngle/CLHEP::deg
44  << "\tRin " << radiusIn << "\tRout " << radiusOut
45  << "\t ZPos " << zpos << "\tCopy Numbers " << number
46  << " Start/Increment " << startCopyNo << ", "
47  << incrCopyNo;
48 
50  childName = sArgs["ChildName"];
51  DDName parentName = parent().name();
52  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parent " << parentName
53  << "\tChild " << childName << " NameSpace "
54  << idNameSpace;
55 }
56 
58 
59  if (number > 0) {
60  double theta = 90.*CLHEP::deg;
61  double dphi;
62  if (number == 1 || fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg)
63  dphi = rangeAngle/number;
64  else
65  dphi = rangeAngle/(number-1);
66  int copyNo = startCopyNo;
67 
68  DDName mother = parent().name();
70  for (int i=0; i<number; i++) {
71  double phi = startAngle + i*dphi;
72  double phix = phi - tilt + 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") << "DDTrackerPhiAltAlgo test: Creating a new"
82  << " rotation " << rotstr << "\t" << "90., "
83  << phix/CLHEP::deg << ", 90.,"
84  << phiy/CLHEP::deg << ", 0, 0";
85  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta,
86  phiy, 0., 0.);
87  }
88  }
89 
90  double xpos, ypos;
91  if (i%2 == 0) {
92  xpos = radiusIn*cos(phi);
93  ypos = radiusIn*sin(phi);
94  } else {
95  xpos = radiusOut*cos(phi);
96  ypos = radiusOut*sin(phi);
97  }
98  DDTranslation tran(xpos, ypos, zpos);
99 
100  cpv.position(child, mother, copyNo, tran, rotation);
101  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo test: " << child
102  << " number " << copyNo << " positioned in "
103  << mother << " at " << tran << " with "
104  << rotation;
105  copyNo += incrCopyNo;
106  }
107  }
108 }
#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:18
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
bool first
Definition: L1TdeRCT.cc:79
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)
Definition: DDAxes.h:10