CMS 3D CMS Logo

DDTECOptoHybAlgo.cc
Go to the documentation of this file.
1 // File: DDTECOptoHybAlgo.cc
3 // Description: Placing cooling pieces in the petal material of a TEC petal
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") << "DDTECOptoHybAlgo info: Creating an instance";
19 }
20 
22 
24  const DDVectorArguments & vArgs,
25  const DDMapArguments & ,
26  const DDStringArguments & sArgs,
27  const DDStringVectorArguments & ) {
28 
30  childName = sArgs["ChildName"];
31 
32  DDName parentName = parent().name();
33 
34  LogDebug("TECGeom") << "DDTECOptoHybAlgo debug: Parent " << parentName
35  << " Child " << childName << " NameSpace " <<idNameSpace;
36 
37  optoHeight = nArgs["OptoHeight"];
38  optoWidth = nArgs["OptoWidth"];
39  rpos = nArgs["Rpos"];
40  zpos = nArgs["Zpos"];
41  startCopyNo = int (nArgs["StartCopyNo"]);
42  angles = vArgs["Angles"];
43 
44  LogDebug("TECGeom") << "DDTECOptoHybAlgo debug: Height of the Hybrid "
45  << optoHeight << " and Width " << optoWidth
46  <<"Rpos " << rpos << " Zpos " << zpos
47  << " StartCopyNo " << startCopyNo << " Number "
48  << angles.size();
49 
50  for (int i = 0; i < (int)(angles.size()); i++)
51  LogDebug("TECGeom") << "\tAngles[" << i << "] = " << angles[i];
52 
53 }
54 
56 
57  LogDebug("TECGeom") << "==>> Constructing DDTECOptoHybAlgo...";
58 
59  DDName mother = parent().name();
61 
62  // given r positions are for the lower left corner
63  rpos += optoHeight/2;
64  int copyNo = startCopyNo;
65  for (double angle : angles) {
66  double phix = -angle;
67  // given phi positions are for the lower left corner
68  phix += asin(optoWidth/2/rpos);
69  double xpos = rpos * cos(phix);
70  double ypos = rpos * sin(phix);
71  DDTranslation tran(xpos, ypos, zpos);
72 
74  double phiy = phix + 90.*CLHEP::deg;
75  double phideg = phix/CLHEP::deg;
76  if (phideg != 0) {
77  std::string rotstr= DDSplit(childName).first + std::to_string(phideg*1000.);
78  rotation = DDRotation(DDName(rotstr, idNameSpace));
79  if (!rotation) {
80  double theta = 90.*CLHEP::deg;
81  LogDebug("TECGeom") << "DDTECOptoHybAlgo test: Creating a new "
82  << "rotation: " << rotstr << "\t90., "
83  << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg
84  << ", 0, 0";
85  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
86  0., 0.);
87  }
88  }
89 
90  cpv.position(child, mother, copyNo, tran, rotation);
91  LogDebug("TECGeom") << "DDTECOptoHybAlgo test " << child << " number "
92  << copyNo << " positioned in " << mother << " at "
93  << tran << " with " << rotation;
94  copyNo++;
95  }
96 
97  LogDebug("TECGeom") << "<<== End of DDTECOptoHybAlgo construction ...";
98 }
#define LogDebug(id)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
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
std::string idNameSpace
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
~DDTECOptoHybAlgo() override
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 execute(DDCompactView &cpv) override
std::string childName
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::vector< double > angles
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11