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 (int i = 0; i < (int)(angles.size()); i++) {
66  double phix = -angles.at(i);
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)
virtual ~DDTECOptoHybAlgo()
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)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
std::string idNameSpace
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 execute(DDCompactView &cpv)
std::string childName
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 > angles