CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
15 #include "CLHEP/Units/GlobalPhysicalConstants.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
18 #include <string>
19 #include <vector>
20 
21 using namespace std;
22 
23 class DDTIDAxialCableAlgo : public DDAlgorithm {
24 public:
25  //Constructor and Destructor
27  ~DDTIDAxialCableAlgo() override;
28 
29  void initialize(const DDNumericArguments& nArgs,
30  const DDVectorArguments& vArgs,
31  const DDMapArguments& mArgs,
32  const DDStringArguments& sArgs,
33  const DDStringVectorArguments& vsArgs) override;
34 
35  void execute(DDCompactView& cpv) override;
36 
37 private:
38  double zBend; //Start z (at bending)........
39  double zEnd; //End z ........
40  double rMin; //Minimum radius ........
41  double rMax; //Maximum radius ........
42  double rTop; //Maximum radius (top)........
43  double width; //Angular width
44  double thick; //Thickness
45  vector<double> angles; //Phi Angles
46  vector<double> zposWheel; //Z position of wheels
47  vector<double> zposRing; //Z position of rings inside wheels
48 
49  string idNameSpace; //Namespace of this and ALL sub-parts
50  string childName; //Child name
51  string matIn; //Material name (for inner parts)
52  string matOut; //Material name (for outer part)
53 };
54 
55 DDTIDAxialCableAlgo::DDTIDAxialCableAlgo() { LogDebug("TIDGeom") << "DDTIDAxialCableAlgo info: Creating an instance"; }
56 
58 
60  const DDVectorArguments& vArgs,
61  const DDMapArguments&,
62  const DDStringArguments& sArgs,
63  const DDStringVectorArguments&) {
64  zBend = nArgs["ZBend"];
65  zEnd = nArgs["ZEnd"];
66  rMin = nArgs["RMin"];
67  rMax = nArgs["RMax"];
68  rTop = nArgs["RTop"];
69  width = nArgs["Width"];
70  thick = nArgs["Thick"];
71  angles = vArgs["Angles"];
72  zposWheel = vArgs["ZPosWheel"];
73  zposRing = vArgs["ZPosRing"];
74 
75  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo debug: Parameters for creating " << (zposWheel.size() + 2)
76  << " axial cables and position"
77  << "ing " << angles.size() << " copies in Service volume"
78  << "\n zBend " << zBend << " zEnd " << zEnd << " rMin " << rMin
79  << " rMax " << rMax << " Cable width " << width / CLHEP::deg << " thickness " << thick
80  << " with Angles";
81  for (int i = 0; i < (int)(angles.size()); i++)
82  LogDebug("TIDGeom") << "\tangles[" << i << "] = " << angles[i] / CLHEP::deg;
83  LogDebug("TIDGeom") << " Wheels " << zposWheel.size() << " at Z";
84  for (int i = 0; i < (int)(zposWheel.size()); i++)
85  LogDebug("TIDGeom") << "\tzposWheel[" << i << "] = " << zposWheel[i];
86  LogDebug("TIDGeom") << " each with " << zposRing.size() << " Rings at Z";
87  for (int i = 0; i < (int)(zposRing.size()); i++)
88  LogDebug("TIDGeom") << "\tzposRing[" << i << "] = " << zposRing[i];
89 
90  idNameSpace = DDCurrentNamespace::ns();
91  childName = sArgs["ChildName"];
92  matIn = sArgs["MaterialIn"];
93  matOut = sArgs["MaterialOut"];
94 
95  DDName parentName = parent().name();
96  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
97  << idNameSpace << "\tMaterial " << matIn << " and " << matOut;
98 }
99 
101  DDName mother = parent().name();
102  vector<DDName> logs;
103  double thk = thick / zposRing.size();
104  double r = rMin;
105  double thktot = 0;
106  double z;
107 
108  //Cables between the wheels
109  for (int k = 0; k < (int)(zposWheel.size()); k++) {
110  vector<double> pconZ, pconRmin, pconRmax;
111  for (int i = 0; i < (int)(zposRing.size()); i++) {
112  thktot += thk;
113  z = zposWheel[k] + zposRing[i] - 0.5 * thk;
114  if (i != 0) {
115  pconZ.emplace_back(z);
116  pconRmin.emplace_back(r);
117  pconRmax.emplace_back(rMax);
118  }
119  r = rMin;
120  pconZ.emplace_back(z);
121  pconRmin.emplace_back(r);
122  pconRmax.emplace_back(rMax);
123  z += thk;
124  pconZ.emplace_back(z);
125  pconRmin.emplace_back(r);
126  pconRmax.emplace_back(rMax);
127  r = rMax - thktot;
128  pconZ.emplace_back(z);
129  pconRmin.emplace_back(r);
130  pconRmax.emplace_back(rMax);
131  }
132  if (k >= ((int)(zposWheel.size()) - 1))
133  z = zBend;
134  else
135  z = zposWheel[k + 1] + zposRing[0] - 0.5 * thk;
136  pconZ.emplace_back(z);
137  pconRmin.emplace_back(r);
138  pconRmax.emplace_back(rMax);
139 
140  string name = childName + to_string(k);
141  DDSolid solid = DDSolidFactory::polycone(DDName(name, idNameSpace), -0.5 * width, width, pconZ, pconRmin, pconRmax);
142 
143  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: " << DDName(name, idNameSpace) << " Polycone made of " << matIn
144  << " from " << -0.5 * width / CLHEP::deg << " to " << 0.5 * width / CLHEP::deg << " and with "
145  << pconZ.size() << " sections ";
146  for (int i = 0; i < (int)(pconZ.size()); i++)
147  LogDebug("TIDGeom") << "\t[" << i << "]\tZ = " << pconZ[i] << "\tRmin = " << pconRmin[i]
148  << "\tRmax = " << pconRmax[i];
149 
150  DDName mat(DDSplit(matIn).first, DDSplit(matIn).second);
151  DDMaterial matter(mat);
152  DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
153  logs.emplace_back(DDName(name, idNameSpace));
154  }
155 
156  //Cable in the vertical part
157  vector<double> pconZ, pconRmin, pconRmax;
158  r = thktot * rMax / rTop;
159  z = zBend - thktot;
160  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: Thk " << thk << " Total " << thktot << " rMax " << rMax << " rTop "
161  << rTop << " dR " << r << " z " << z;
162  pconZ.emplace_back(z);
163  pconRmin.emplace_back(rMax);
164  pconRmax.emplace_back(rMax);
165  z = zBend - r;
166  pconZ.emplace_back(z);
167  pconRmin.emplace_back(rMax);
168  pconRmax.emplace_back(rTop);
169  pconZ.emplace_back(zBend);
170  pconRmin.emplace_back(rMax);
171  pconRmax.emplace_back(rTop);
172 
173  string name = childName + to_string(zposWheel.size());
174  DDSolid solid = DDSolidFactory::polycone(DDName(name, idNameSpace), -0.5 * width, width, pconZ, pconRmin, pconRmax);
175 
176  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: " << DDName(name, idNameSpace) << " Polycone made of " << matIn
177  << " from " << -0.5 * width / CLHEP::deg << " to " << 0.5 * width / CLHEP::deg << " and with "
178  << pconZ.size() << " sections ";
179  for (int i = 0; i < (int)(pconZ.size()); i++)
180  LogDebug("TIDGeom") << "\t[" << i << "]\tZ = " << pconZ[i] << "\tRmin = " << pconRmin[i]
181  << "\tRmax = " << pconRmax[i];
182 
183  DDMaterial matter(DDName(DDSplit(matIn).first, DDSplit(matIn).second));
184  DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
185  logs.emplace_back(DDName(name, idNameSpace));
186 
187  //Cable in the outer part
188  name = childName + to_string(zposWheel.size() + 1);
189  r = rTop - r;
190  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * (zEnd - zBend), r, rTop, -0.5 * width, width);
191  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << matOut
192  << " from " << -0.5 * width / CLHEP::deg << " to " << 0.5 * width / CLHEP::deg << " with Rin "
193  << r << " Rout " << rTop << " ZHalf " << 0.5 * (zEnd - zBend);
194  matter = DDMaterial(DDName(DDSplit(matOut).first, DDSplit(matOut).second));
195  genlogic = DDLogicalPart(DDName(name, idNameSpace), matter, solid);
196  logs.emplace_back(DDName(name, idNameSpace));
197 
198  //Position the cables
199  double theta = 90. * CLHEP::deg;
200  for (int i = 0; i < (int)(angles.size()); i++) {
201  double phix = angles[i];
202  double phiy = phix + 90. * CLHEP::deg;
203  double phideg = phix / CLHEP::deg;
204 
206  if (phideg != 0) {
207  string rotstr = childName + to_string(phideg * 10.);
208  rotation = DDRotation(DDName(rotstr, idNameSpace));
209  if (!rotation) {
210  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test: Creating a new "
211  << "rotation: " << rotstr << " " << theta / CLHEP::deg << ", " << phix / CLHEP::deg << ", "
212  << theta / CLHEP::deg << ", " << phiy / CLHEP::deg << ", 0, 0";
213  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
214  }
215  }
216 
217  for (int k = 0; k < (int)(logs.size()); k++) {
218  DDTranslation tran(0, 0, 0);
219  if (k == ((int)(logs.size()) - 1))
220  tran = DDTranslation(0, 0, 0.5 * (zEnd + zBend));
221  cpv.position(logs[k], mother, i + 1, tran, rotation);
222  LogDebug("TIDGeom") << "DDTIDAxialCableAlgo test " << logs[k] << " number " << i + 1 << " positioned in "
223  << mother << " at " << tran << " with " << rotation;
224  }
225  }
226 }
227 
228 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTIDAxialCableAlgo, "track:DDTIDAxialCableAlgo");
static AlgebraicMatrix initialize()
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
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:551
void execute(DDCompactView &cpv) override
Geom::Theta< T > theta() const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
vector< double > zposRing
U second(std::pair< T, U > const &p)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:667
vector< double > zposWheel
vector< double > angles
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
#define LogDebug(id)