CMS 3D CMS Logo

DDTECAxialCableAlgo.cc
Go to the documentation of this file.
1 // File: DDTECAxialCableAlgo.cc
3 // Description: Position n copies at prescribed phi values
5 
6 #include <cmath>
7 #include <algorithm>
8 
16 #include "CLHEP/Units/GlobalPhysicalConstants.h"
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
20  LogDebug("TECGeom") << "DDTECAxialCableAlgo info: Creating an instance";
21 }
22 
24 
26  const DDVectorArguments & vArgs,
27  const DDMapArguments & ,
28  const DDStringArguments & sArgs,
29  const DDStringVectorArguments & ) {
30 
31  n = int(nArgs["N"]);
32  rangeAngle = nArgs["RangeAngle"];
33  zStart = nArgs["ZStart"];
34  zEnd = nArgs["ZEnd"];
35  rMin = nArgs["RMin"];
36  rMax = nArgs["RMax"];
37  width = nArgs["Width"];
38  thickR = nArgs["ThickR"];
39  thickZ = nArgs["ThickZ"];
40  dZ = nArgs["DZ"];
41  startAngle = vArgs["StartAngle"];
42  zPos = vArgs["ZPos"];
43 
44  if (fabs(rangeAngle-360.0*CLHEP::deg)<0.001*CLHEP::deg) {
45  delta = rangeAngle/double(n);
46  } else {
47  if (n > 1) {
48  delta = rangeAngle/double(n-1);
49  } else {
50  delta = 0.;
51  }
52  }
53 
54  LogDebug("TECGeom") << "DDTECAxialCableAlgo debug: Parameters for creating "
55  << startAngle.size() << " axial cables and positioning "
56  << n << " copies in Service volume\n"
57  << " zStart " << zStart
58  << " zEnd " << zEnd << " rMin " << rMin << " rMax "
59  << rMax << " Cable width " << width/CLHEP::deg
60  << " thickness " << thickR << ", " << thickZ << " dZ "
61  << dZ << "\n Range, Delta "
62  << rangeAngle/CLHEP::deg << ", " << delta/CLHEP::deg;
63  for (int i=0; i<(int)(startAngle.size()); i++)
64  LogDebug("TECGeom") << " Cable " << i
65  << " from Z " << zPos[i] << " startAngle "
66  << startAngle[i]/CLHEP::deg;
68  childName = sArgs["ChildName"];
69  matName = sArgs["Material"];
70 
71  DDName parentName = parent().name();
72 
73  LogDebug("TECGeom") << "DDTECAxialCableAlgo debug: Parent " << parentName
74  << "\tChild " << childName << " NameSpace "
75  << idNameSpace << "\tMaterial " << matName;
76 }
77 
79 
80  DDName mother = parent().name();
81  double theta = 90.*CLHEP::deg;
82 
83  for (int k=0; k<(int)(startAngle.size()); k++) {
84 
85  int i;
86  double zv = zPos[k]-dZ-0.5*(zStart+zEnd);
87  std::vector<double> pconZ, pconRmin, pconRmax;
88  pconZ.push_back(zv);
89  pconRmin.push_back(rMin);
90  pconRmax.push_back(rMax);
91  pconZ.push_back(zv+thickZ);
92  pconRmin.push_back(rMin);
93  pconRmax.push_back(rMax);
94  pconZ.push_back(zv+thickZ);
95  pconRmin.push_back(rMax-thickR);
96  pconRmax.push_back(rMax);
97  zv = zPos[k]+dZ-0.5*(zStart+zEnd);
98  pconZ.push_back(zv-thickZ);
99  pconRmin.push_back(rMax-thickR);
100  pconRmax.push_back(rMax);
101  pconZ.push_back(zv-thickZ);
102  pconRmin.push_back(rMin);
103  pconRmax.push_back(rMax);
104  pconZ.push_back(zv);
105  pconRmin.push_back(rMin);
106  pconRmax.push_back(rMax);
107  pconZ.push_back(zv);
108  pconRmin.push_back(rMax-thickR);
109  pconRmax.push_back(rMax);
110  pconZ.push_back(0.5*(zEnd-zStart));
111  pconRmin.push_back(rMax-thickR);
112  pconRmax.push_back(rMax);
113 
114  std::string name = childName + std::to_string(k);
116  -0.5*width, width, pconZ,
117  pconRmin, pconRmax);
118 
119  LogDebug("TECGeom") << "DDTECAxialCableAlgo test: "
120  << DDName(name, idNameSpace) <<" Polycone made of "
121  << matName << " from " <<-0.5*width/CLHEP::deg <<" to "
122  << 0.5*width/CLHEP::deg << " and with " << pconZ.size()
123  << " sections ";
124  for (int ii = 0; ii <(int)(pconZ.size()); ii++)
125  LogDebug("TECGeom") << "\t" << "\tZ[" << ii << "] = " << pconZ[ii]
126  << "\tRmin[" << ii << "] = "<< pconRmin[ii]
127  << "\tRmax[" << ii << "] = " << pconRmax[ii];
129  DDMaterial matter(mat);
130  DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
131 
132  double phi = startAngle[k];
133  for (i=0; i<n; i++) {
134  double phix = phi;
135  double phiy = phix + 90.*CLHEP::deg;
136  double phideg = phix/CLHEP::deg;
137 
139  if (phideg != 0) {
140  std::string rotstr = childName + std::to_string(phideg*10.);
141  rotation = DDRotation(DDName(rotstr, idNameSpace));
142  if (!rotation) {
143  LogDebug("TECGeom") << "DDTECAxialCableAlgo test: Creating a new"
144  << " rotation: " << rotstr << "\t90., "
145  << phix/CLHEP::deg << ", 90.,"
146  << phiy/CLHEP::deg << ", 0, 0";
147  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta,
148  phiy, 0., 0.);
149  }
150  }
151 
152  DDTranslation tran(0,0,0);
153  cpv.position(DDName(name, idNameSpace), mother, i+1, tran, rotation);
154  LogDebug("TECGeom") << "DDTECAxialCableAlgo test "
155  << DDName(name, idNameSpace) << " number " << i+1
156  << " positioned in " << mother << " at " << tran
157  << " with " << rotation;
158 
159  phi += delta;
160  }
161  }
162 }
#define LogDebug(id)
std::vector< double > zPos
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
static DDSolid polycone(const DDName &name, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polycone (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:825
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()
std::vector< double > startAngle
type of data representation of DDCompactView
Definition: DDCompactView.h:90
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
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)
void execute(DDCompactView &cpv)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
ii
Definition: cuy.py:588
int k[5][pyjets_maxn]
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4