CMS 3D CMS Logo

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