CMS 3D CMS Logo

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