CMS 3D CMS Logo

DDTECPhiAltAlgo.cc
Go to the documentation of this file.
1 // File: DDTECPhiAltAlgo.cc
3 // Description: Position n copies inside and outside Z 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("TECGeom") << "DDTECPhiAltAlgo info: Creating an instance";
19 }
20 
22 
24  const DDVectorArguments & ,
25  const DDMapArguments & ,
26  const DDStringArguments & sArgs,
27  const DDStringVectorArguments & ) {
28 
29  startAngle = nArgs["StartAngle"];
30  incrAngle = nArgs["IncrAngle"];
31  radius = nArgs["Radius"];
32  zIn = nArgs["ZIn"];
33  zOut = nArgs["ZOut"];
34  number = int (nArgs["Number"]);
35  startCopyNo= int (nArgs["StartCopyNo"]);
36  incrCopyNo = int (nArgs["IncrCopyNo"]);
37 
38  LogDebug("TECGeom") << "DDTECPhiAltAlgo debug: Parameters for "
39  << "positioning--" << "\tStartAngle "
40  << startAngle/CLHEP::deg << "\tIncrAngle "
41  << incrAngle/CLHEP::deg << "\tRadius " << radius
42  << "\tZ in/out " << zIn << ", " << zOut
43  << "\tCopy Numbers " << number << " Start/Increment "
44  << startCopyNo << ", " << incrCopyNo;
45 
47  childName = sArgs["ChildName"];
48  DDName parentName = parent().name();
49  LogDebug("TECGeom") << "DDTECPhiAltAlgo debug: Parent " << parentName
50  << "\tChild " << childName << " NameSpace "
51  << idNameSpace;
52 }
53 
55 
56  if (number > 0) {
57  double theta = 90.*CLHEP::deg;
58  int copyNo = startCopyNo;
59 
60  DDName mother = parent().name();
62  for (int i=0; i<number; i++) {
63  double phiz = startAngle + i*incrAngle;
64  double phix = phiz + 90.*CLHEP::deg;
65  double phideg = phiz/CLHEP::deg;
66 
68  std::string rotstr = DDSplit(childName).first + std::to_string(phideg*10.);
69  rotation = DDRotation(DDName(rotstr, idNameSpace));
70  if (!rotation) {
71  LogDebug("TECGeom") << "DDTECPhiAltAlgo test: Creating a new "
72  << "rotation " << rotstr << "\t"
73  << theta/CLHEP::deg << ", " << phix/CLHEP::deg
74  << ", 0, 0, " << theta/CLHEP::deg << ", "
75  << phiz/CLHEP::deg;
76  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, 0., 0.,
77  theta, phiz);
78  }
79 
80  double xpos = radius*cos(phiz);
81  double ypos = radius*sin(phiz);
82  double zpos;
83  if (i%2 == 0) zpos = zIn;
84  else zpos = zOut;
85  DDTranslation tran(xpos, ypos, zpos);
86 
87  cpv.position(child, mother, copyNo, tran, rotation);
88  LogDebug("TECGeom") << "DDTECPhiAltAlgo test: " << child <<" number "
89  << copyNo << " positioned in " << mother <<" at "
90  << tran << " with " << rotation;
91  copyNo += incrCopyNo;
92  }
93  }
94 }
#define LogDebug(id)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
static std::string & ns()
~DDTECPhiAltAlgo() override
std::string childName
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::string idNameSpace
void execute(DDCompactView &cpv) override