CMS 3D CMS Logo

DDTIDAxialCableAlgo.cc
Go to the documentation of this file.
1 // File: DDTIDAxialCableAlgo.cc
3 // Description: Create and position TID axial cables 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 
19 
21  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo info: Creating an instance";
22 }
23 
25 
27  const DDVectorArguments & vArgs,
28  const DDMapArguments & ,
29  const DDStringArguments & sArgs,
30  const DDStringVectorArguments & ) {
31 
32  zBend = nArgs["ZBend"];
33  zEnd = nArgs["ZEnd"];
34  rMin = nArgs["RMin"];
35  rMax = nArgs["RMax"];
36  rTop = nArgs["RTop"];
37  width = nArgs["Width"];
38  thick = nArgs["Thick"];
39  angles = vArgs["Angles"];
40  zposWheel = vArgs["ZPosWheel"];
41  zposRing = vArgs["ZPosRing"];
42 
43  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo debug: Parameters for creating "
44  << (zposWheel.size()+2) << " axial cables and position"
45  << "ing " << angles.size() << " copies in Service volume"
46  << "\n zBend " << zBend
47  << " zEnd " << zEnd << " rMin " << rMin << " rMax "
48  << rMax << " Cable width " << width/CLHEP::deg
49  << " thickness " << thick << " with Angles";
50  for (int i=0; i<(int)(angles.size()); i++)
51  LogDebug("TIDGeom") << "\tangles[" << i << "] = " << angles[i]/CLHEP::deg;
52  LogDebug("TIDGeom") << " Wheels "
53  << zposWheel.size() << " at Z";
54  for (int i=0; i<(int)(zposWheel.size()); i++)
55  LogDebug("TIDGeom") << "\tzposWheel[" << i <<"] = " << zposWheel[i];
56  LogDebug("TIDGeom") << " each with "
57  << zposRing.size() << " Rings at Z";
58  for (int i=0; i<(int)(zposRing.size()); i++)
59  LogDebug("TIDGeom") << "\tzposRing[" << i <<"] = " << zposRing[i];
60 
62  childName = sArgs["ChildName"];
63  matIn = sArgs["MaterialIn"];
64  matOut = sArgs["MaterialOut"];
65 
66  DDName parentName = parent().name();
67  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo debug: Parent " << parentName
68  << "\tChild " << childName << " NameSpace "
69  << idNameSpace << "\tMaterial " << matIn << " and "
70  << matOut;
71 }
72 
74 
75  DDName mother = parent().name();
76  std::vector<DDName> logs;
77  double thk = thick/zposRing.size();
78  double r = rMin;
79  double thktot = 0;
80  double z;
81 
82  //Cables between the wheels
83  for (int k=0; k<(int)(zposWheel.size()); k++) {
84 
85  std::vector<double> pconZ, pconRmin, pconRmax;
86  for (int i=0; i<(int)(zposRing.size()); i++) {
87  thktot += thk;
88  z = zposWheel[k] + zposRing[i] - 0.5*thk;
89  if (i != 0) {
90  pconZ.push_back(z);
91  pconRmin.push_back(r);
92  pconRmax.push_back(rMax);
93  }
94  r = rMin;
95  pconZ.push_back(z);
96  pconRmin.push_back(r);
97  pconRmax.push_back(rMax);
98  z += thk;
99  pconZ.push_back(z);
100  pconRmin.push_back(r);
101  pconRmax.push_back(rMax);
102  r = rMax - thktot;
103  pconZ.push_back(z);
104  pconRmin.push_back(r);
105  pconRmax.push_back(rMax);
106  }
107  if (k >= ((int)(zposWheel.size())-1)) z = zBend;
108  else z = zposWheel[k+1] + zposRing[0] - 0.5*thk;
109  pconZ.push_back(z);
110  pconRmin.push_back(r);
111  pconRmax.push_back(rMax);
112 
113  std::string name = childName + std::to_string(k);
115  -0.5*width, width, pconZ,
116  pconRmin, pconRmax);
117 
118  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: "
119  << DDName(name,idNameSpace) << " Polycone made of "
120  << matIn << " from " << -0.5*width/CLHEP::deg << " to "
121  << 0.5*width/CLHEP::deg << " and with " << pconZ.size()
122  << " sections ";
123  for (int i = 0; i <(int)(pconZ.size()); i++)
124  LogDebug("TIDGeom") << "\t[" << i << "]\tZ = " << pconZ[i]
125  << "\tRmin = "<< pconRmin[i] << "\tRmax = "
126  << pconRmax[i];
127 
129  DDMaterial matter(mat);
130  DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
131  logs.push_back(DDName(name, idNameSpace));
132  }
133 
134  //Cable in the vertical part
135  std::vector<double> pconZ, pconRmin, pconRmax;
136  r = thktot*rMax/rTop;
137  z = zBend - thktot;
138  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: Thk " << thk
139  << " Total " << thktot << " rMax " << rMax
140  << " rTop " << rTop << " dR " << r << " z " << z;
141  pconZ.push_back(z);
142  pconRmin.push_back(rMax);
143  pconRmax.push_back(rMax);
144  z = zBend - r;
145  pconZ.push_back(z);
146  pconRmin.push_back(rMax);
147  pconRmax.push_back(rTop);
148  pconZ.push_back(zBend);
149  pconRmin.push_back(rMax);
150  pconRmax.push_back(rTop);
151 
152  std::string name = childName + std::to_string(zposWheel.size());
154  -0.5*width, width, pconZ,
155  pconRmin, pconRmax);
156 
157  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: "
158  << DDName(name, idNameSpace) << " Polycone made of "
159  << matIn << " from " << -0.5*width/CLHEP::deg << " to "
160  << 0.5*width/CLHEP::deg << " and with " << pconZ.size()
161  << " sections ";
162  for (int i = 0; i < (int)(pconZ.size()); i++)
163  LogDebug("TIDGeom") << "\t[" << i << "]\tZ = " << pconZ[i]
164  << "\tRmin = "<< pconRmin[i] << "\tRmax = "
165  << pconRmax[i];
166 
168  DDMaterial matter(mat);
169  DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
170  logs.push_back(DDName(name, idNameSpace));
171 
172  //Cable in the outer part
173  name = childName + std::to_string(zposWheel.size()+1);
174  r = rTop-r;
175  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5*(zEnd-zBend),
176  r, rTop, -0.5*width, width);
177  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: "
178  << DDName(name, idNameSpace) << " Tubs made of "
179  << matOut << " from " << -0.5*width/CLHEP::deg << " to "
180  << 0.5*width/CLHEP::deg << " with Rin " << r << " Rout "
181  << rTop << " ZHalf " << 0.5*(zEnd-zBend);
182  mat = DDName(DDSplit(matOut).first, DDSplit(matOut).second);
183  matter = DDMaterial(mat);
184  genlogic = DDLogicalPart(DDName(name, idNameSpace), matter, solid);
185  logs.push_back(DDName(name, idNameSpace));
186 
187  //Position the cables
188  double theta = 90.*CLHEP::deg;
189  for (int i=0; i<(int)(angles.size()); i++) {
190  double phix = angles[i];
191  double phiy = phix + 90.*CLHEP::deg;
192  double phideg = phix/CLHEP::deg;
193 
195  if (phideg != 0) {
196  std::string rotstr = childName + std::to_string(phideg*10.);
197  rotation = DDRotation(DDName(rotstr, idNameSpace));
198  if (!rotation) {
199  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: Creating a new "
200  << "rotation: " << rotstr << " "
201  << theta/CLHEP::deg << ", " << phix/CLHEP::deg
202  << ", " << theta/CLHEP::deg << ", "
203  << phiy/CLHEP::deg << ", 0, 0";
204  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta,
205  phiy, 0., 0.);
206  }
207  }
208 
209  for (int k=0; k<(int)(logs.size()); k++) {
210  DDTranslation tran(0,0,0);
211  if (k == ((int)(logs.size())-1))
212  tran = DDTranslation(0,0,0.5*(zEnd+zBend));
213  cpv.position(logs[k], mother, i+1, tran, rotation);
214  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test " << logs[k]
215  << " number " << i+1 << " positioned in "
216  << mother << " at " << tran << " with "
217  << rotation;
218  }
219  }
220 }
#define LogDebug(id)
std::vector< double > zposWheel
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:714
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:16
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
A DDSolid represents the shape of a part.
Definition: DDSolid.h:37
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)
std::vector< double > angles
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:863
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
int k[5][pyjets_maxn]
void execute(DDCompactView &cpv)
std::vector< double > zposRing
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4