CMS 3D CMS Logo

DDTOBRodAlgo.cc
Go to the documentation of this file.
1 // File: DDTOBRodAlgo.cc
3 // Description: Positioning constituents of a TOB rod
5 
12 
13 #include <string>
14 #include <vector>
15 
16 using namespace std;
17 
18 class DDTOBRodAlgo : public DDAlgorithm {
19 public:
20  //Constructor and Destructor
21  DDTOBRodAlgo();
22  ~DDTOBRodAlgo() override;
23 
24  void initialize(const DDNumericArguments& nArgs,
25  const DDVectorArguments& vArgs,
26  const DDMapArguments& mArgs,
27  const DDStringArguments& sArgs,
28  const DDStringVectorArguments& vsArgs) override;
29 
30  void execute(DDCompactView& cpv) override;
31 
32 private:
33  string central; // Name of the central piece
34  string idNameSpace; // Namespace of this and ALL sub-parts
35 
36  double shift; // Shift in z
37  vector<string> sideRod; // Name of the Side Rod
38  vector<double> sideRodX; // x-positions
39  vector<double> sideRodY; // y-positions
40  vector<double> sideRodZ; // z-positions
41  string endRod1; // Name of the End Rod of type 1
42  vector<double> endRod1Y; // y-positions
43  vector<double> endRod1Z; // z-positions
44  string endRod2; // Name of the End Rod of type 2
45  double endRod2Y; // y-position
46  double endRod2Z; // z-position
47 
48  string cable; // Name of the Mother cable
49  double cableZ; // z-position
50 
51  string clamp; // Name of the clamp
52  vector<double> clampX; // x-positions
53  vector<double> clampZ; // z-positions
54  string sideCool; // Name of the Side Cooling Tube
55  vector<double> sideCoolX; // x-positions
56  vector<double> sideCoolY; // y-positions to avoid overlap with the module (be at the same level of EndCool)
57  vector<double> sideCoolZ; // z-positions
58  string endCool; // Name of the End Cooling Tube
59  string endCoolRot; // Rotation matrix name for end cool
60  double endCoolY; // y-position to avoid overlap with the module
61  double endCoolZ; // z-position
62 
63  string optFibre; // Name of the Optical Fibre
64  vector<double> optFibreX; // x-positions
65  vector<double> optFibreZ; // z-positions
66 
67  string sideClamp1; // Name of the side clamp of type 1
68  vector<double> sideClampX; // x-positions
69  vector<double> sideClamp1DZ; // Delta(z)-positions
70  string sideClamp2; // Name of the side clamp of type 2
71  vector<double> sideClamp2DZ; // Delta(z)-positions
72 
73  string module; // Name of the detector modules
74  vector<string> moduleRot; // Rotation matrix name for module
75  vector<double> moduleY; // y-positions
76  vector<double> moduleZ; // z-positions
77  vector<string> connect; // Name of the connectors
78  vector<double> connectY; // y-positions
79  vector<double> connectZ; // z-positions
80 
81  string aohName; // AOH name
82  vector<double> aohCopies; // AOH copies to be positioned on each ICC
83  vector<double> aohX; // AOH translation with respect small-ICC center (X)
84  vector<double> aohY; // AOH translation with respect small-ICC center (Y)
85  vector<double> aohZ; // AOH translation with respect small-ICC center (Z)
86 };
87 
89  : sideRod(0),
90  sideRodX(0),
91  sideRodY(0),
92  sideRodZ(0),
93  endRod1Y(0),
94  endRod1Z(0),
95  clampX(0),
96  clampZ(0),
97  sideCoolX(0),
98  sideCoolY(0),
99  sideCoolZ(0),
100  endCoolY(0),
101  endCoolZ(0),
102  optFibreX(0),
103  optFibreZ(0),
104  sideClampX(0),
105  sideClamp1DZ(0),
106  sideClamp2DZ(0),
107  moduleRot(0),
108  moduleY(0),
109  moduleZ(0),
110  connect(0),
111  connectY(0),
112  connectZ(0),
113  aohCopies(0),
114  aohX(0),
115  aohY(0),
116  aohZ(0) {
117  LogDebug("TOBGeom") << "DDTOBRodAlgo info: Creating an instance";
118 }
119 
121 
123  const DDVectorArguments& vArgs,
124  const DDMapArguments&,
125  const DDStringArguments& sArgs,
126  const DDStringVectorArguments& vsArgs) {
127  central = sArgs["CentralName"];
128  shift = nArgs["Shift"];
130  DDName parentName = parent().name();
131  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: Parent " << parentName << " Central " << central << " NameSpace "
132  << idNameSpace << "\tShift " << shift;
133 
134  sideRod = vsArgs["SideRodName"];
135  sideRodX = vArgs["SideRodX"];
136  sideRodY = vArgs["SideRodY"];
137  sideRodZ = vArgs["SideRodZ"];
138  for (int i = 0; i < (int)(sideRod.size()); i++) {
139  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideRod[i] << " to be positioned " << sideRodX.size()
140  << " times at y = " << sideRodY[i] << " z = " << sideRodZ[i] << " and x";
141  for (double j : sideRodX)
142  LogDebug("TOBGeom") << "\tsideRodX[" << i << "] = " << j;
143  }
144 
145  endRod1 = sArgs["EndRod1Name"];
146  endRod1Y = vArgs["EndRod1Y"];
147  endRod1Z = vArgs["EndRod1Z"];
148  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << endRod1 << " to be "
149  << "positioned " << endRod1Y.size() << " times at";
150  for (int i = 0; i < (int)(endRod1Y.size()); i++)
151  LogDebug("TOBGeom") << "\t[" << i << "]\ty = " << endRod1Y[i] << "\tz = " << endRod1Z[i];
152 
153  endRod2 = sArgs["EndRod2Name"];
154  endRod2Y = nArgs["EndRod2Y"];
155  endRod2Z = nArgs["EndRod2Z"];
156  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << endRod2 << " to be "
157  << "positioned at y = " << endRod2Y << " z = " << endRod2Z;
158 
159  cable = sArgs["CableName"];
160  cableZ = nArgs["CableZ"];
161  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << cable << " to be "
162  << "positioned at z = " << cableZ;
163 
164  clamp = sArgs["ClampName"];
165  clampX = vArgs["ClampX"];
166  clampZ = vArgs["ClampZ"];
167  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << clamp << " to be "
168  << "positioned " << clampX.size() << " times at";
169  for (int i = 0; i < (int)(clampX.size()); i++)
170  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << clampX[i] << "\tz = " << clampZ[i];
171 
172  sideCool = sArgs["SideCoolName"];
173  sideCoolX = vArgs["SideCoolX"];
174  sideCoolY = vArgs["SideCoolY"];
175  sideCoolZ = vArgs["SideCoolZ"];
176  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideCool << " to be "
177  << "positioned " << sideCoolX.size() << " times at";
178  for (int i = 0; i < (int)(sideCoolX.size()); i++)
179  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideCoolX[i] << "\ty = " << sideCoolY[i]
180  << "\tz = " << sideCoolZ[i];
181 
182  endCool = sArgs["EndCoolName"];
183  endCoolY = nArgs["EndCoolY"];
184  endCoolZ = nArgs["EndCoolZ"];
185  endCoolRot = sArgs["EndCoolRot"];
186  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << endCool << " to be "
187  << "positioned with " << endCoolRot << " rotation at"
188  << " y = " << endCoolY << " z = " << endCoolZ;
189 
190  optFibre = sArgs["OptFibreName"];
191  optFibreX = vArgs["optFibreX"];
192  optFibreZ = vArgs["optFibreZ"];
193  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << optFibre << " to be "
194  << "positioned " << optFibreX.size() << " times at";
195  for (int i = 0; i < (int)(optFibreX.size()); i++)
196  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << optFibreX[i] << "\tz = " << optFibreZ[i];
197 
198  sideClamp1 = sArgs["SideClamp1Name"];
199  sideClampX = vArgs["SideClampX"];
200  sideClamp1DZ = vArgs["SideClamp1DZ"];
201  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideClamp1 << " to be "
202  << "positioned " << sideClampX.size() << " times at";
203  for (int i = 0; i < (int)(sideClampX.size()); i++)
204  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] << "\tdz = " << sideClamp1DZ[i];
205 
206  sideClamp2 = sArgs["SideClamp2Name"];
207  sideClamp2DZ = vArgs["SideClamp2DZ"];
208  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideClamp2 << " to be "
209  << "positioned " << sideClampX.size() << " times at";
210  for (int i = 0; i < (int)(sideClampX.size()); i++)
211  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] << "\tdz = " << sideClamp2DZ[i];
212 
213  moduleRot = vsArgs["ModuleRot"];
214  module = sArgs["ModuleName"];
215  moduleY = vArgs["ModuleY"];
216  moduleZ = vArgs["ModuleZ"];
217  LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << module << " positioned " << moduleRot.size() << " times";
218  for (int i = 0; i < (int)(moduleRot.size()); i++)
219  LogDebug("TOBGeom") << "\tRotation " << moduleRot[i] << "\ty = " << moduleY[i] << "\tz = " << moduleZ[i];
220 
221  connect = vsArgs["ICCName"];
222  connectY = vArgs["ICCY"];
223  connectZ = vArgs["ICCZ"];
224  LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << connect.size() << " ICC positioned with no rotation";
225  for (int i = 0; i < (int)(connect.size()); i++)
226  LogDebug("TOBGeom") << "\t" << connect[i] << "\ty = " << connectY[i] << "\tz = " << connectZ[i];
227 
228  aohName = sArgs["AOHName"];
229  aohCopies = vArgs["AOHCopies"];
230  aohX = vArgs["AOHx"];
231  aohY = vArgs["AOHy"];
232  aohZ = vArgs["AOHz"];
233  LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << aohName << " AOH will be positioned on ICC's";
234  for (int i = 0; i < (int)(aohCopies.size()); i++)
235  LogDebug("TOBGeom") << " copies " << aohCopies[i] << "\tx = " << aohX[i] << "\ty = " << aohY[i]
236  << "\tz = " << aohZ[i];
237 }
238 
240  LogDebug("TOBGeom") << "==>> Constructing DDTOBRodAlgo...";
241  DDName rodName = parent().name();
243 
244  // Side Rods
245  for (int i = 0; i < (int)(sideRod.size()); i++) {
246  for (int j = 0; j < (int)(sideRodX.size()); j++) {
249  cpv.position(child, rodName, j + 1, r, DDRotation());
250  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << j + 1 << " positioned in " << rodName
251  << " at " << r << " with no rotation";
252  }
253  }
254 
255  // Clamps
256  for (int i = 0; i < (int)(clampX.size()); i++) {
257  DDTranslation r(clampX[i], 0, shift + clampZ[i]);
259  cpv.position(child, rodName, i + 1, r, DDRotation());
260  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << i + 1 << " positioned in " << rodName
261  << " at " << r << " with no rotation";
262  }
263 
264  // Side Cooling tubes
265  for (int i = 0; i < (int)(sideCoolX.size()); i++) {
268  cpv.position(child, rodName, i + 1, r, DDRotation());
269  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << i + 1 << " positioned in " << rodName
270  << " at " << r << " with no rotation";
271  }
272 
273  // Optical Fibres
274  for (int i = 0; i < (int)(optFibreX.size()); i++) {
277  cpv.position(child, rodName, i + 1, r, DDRotation());
278  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << i + 1 << " positioned in " << rodName
279  << " at " << r << " with no rotation";
280  }
281 
282  // Side Clamps
283  for (int i = 0; i < (int)(sideClamp1DZ.size()); i++) {
284  int j = i / 2;
287  cpv.position(child, rodName, i + 1, r, DDRotation());
288  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << i + 1 << " positioned in " << rodName
289  << " at " << r << " with no rotation";
290  }
291  for (int i = 0; i < (int)(sideClamp2DZ.size()); i++) {
292  int j = i / 2;
295  cpv.position(child, rodName, i + 1, r, DDRotation());
296  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << i + 1 << " positioned in " << rodName
297  << " at " << r << " with no rotation";
298  }
299 
300  // End Rods
301  for (int i = 0; i < (int)(endRod1Y.size()); i++) {
304  cpv.position(child, centName, i + 1, r, DDRotation());
305  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << i + 1 << " positioned in " << centName
306  << " at " << r << " with no rotation";
307  }
310  cpv.position(child1, centName, 1, r1, DDRotation());
311  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child1 << " number 1 "
312  << "positioned in " << centName << " at " << r1 << " with no rotation";
313 
314  // End cooling tubes
316  string rotstr = DDSplit(endCoolRot).first;
317  string rotns = DDSplit(endCoolRot).second;
318  DDRotation rot2(DDName(rotstr, rotns));
320  cpv.position(child2, centName, 1, r2, rot2);
321  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child2 << " number 1 "
322  << "positioned in " << centName << " at " << r2 << " with " << rot2;
323 
324  //Mother cable
325  DDTranslation r3(0, 0, shift + cableZ);
327  cpv.position(child3, centName, 1, r3, DDRotation());
328  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child3 << " number 1 "
329  << "positioned in " << centName << " at " << r3 << " with no rotation";
330 
331  //Modules
332  for (int i = 0; i < (int)(moduleRot.size()); i++) {
334  rotstr = DDSplit(moduleRot[i]).first;
335  DDRotation rot;
336  if (rotstr != "NULL") {
337  rotns = DDSplit(moduleRot[i]).second;
338  rot = DDRotation(DDName(rotstr, rotns));
339  }
341  cpv.position(child, centName, i + 1, r, rot);
342  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << i + 1 << " positioned in " << centName
343  << " at " << r << " with " << rot;
344  }
345 
346  //Connectors (ICC, CCUM, ...)
347  for (int i = 0; i < (int)(connect.size()); i++) {
350  cpv.position(child, centName, i + 1, r, DDRotation());
351  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << i + 1 << " positioned in " << centName
352  << " at " << r << " with no rotation";
353  }
354 
355  //AOH (only on ICCs)
356  int copyNumber = 0;
357  for (int i = 0; i < (int)(aohCopies.size()); i++) {
358  if (aohCopies[i] != 0) {
359  // first copy with (+aohX,+aohZ) translation
360  copyNumber++;
361  DDTranslation r(aohX[i] + 0, aohY[i] + connectY[i], aohZ[i] + shift + connectZ[i]);
363  cpv.position(child, centName, copyNumber, r, DDRotation());
364  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << copyNumber << " positioned in " << centName
365  << " at " << r << " with no rotation";
366  // if two copies add a copy with (-aohX,-aohZ) translation
367  if (aohCopies[i] == 2) {
368  copyNumber++;
369  DDTranslation r(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift + connectZ[i]);
371  cpv.position(child, centName, copyNumber, r, DDRotation());
372  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << copyNumber << " positioned in "
373  << centName << " at " << r << " with no rotation";
374  }
375  // if four copies add 3 copies with (-aohX,+aohZ) (-aohX,-aohZ) (+aohX,+aohZ) and translations
376  if (aohCopies[i] == 4) {
377  for (unsigned int j = 1; j < 4; j++) {
378  copyNumber++;
379  switch (j) {
380  case 1: {
381  DDTranslation r(-aohX[i] + 0, aohY[i] + connectY[i], +aohZ[i] + shift + connectZ[i]);
383  cpv.position(child, centName, copyNumber, r, DDRotation());
384  break;
385  }
386  case 2: {
387  DDTranslation r(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift + connectZ[i]);
389  cpv.position(child, centName, copyNumber, r, DDRotation());
390  break;
391  }
392  case 3: {
393  DDTranslation r(+aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift + connectZ[i]);
395  cpv.position(child, centName, copyNumber, r, DDRotation());
396  break;
397  }
398  }
399  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number " << copyNumber << " positioned in "
400  << centName << " at " << r << " with no rotation";
401  }
402  }
403  }
404  }
405 
406  LogDebug("TOBGeom") << "<<== End of DDTOBRodAlgo construction ...";
407 }
408 
409 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTOBRodAlgo, "track:DDTOBRodAlgo");
static AlgebraicMatrix initialize()
void execute(DDCompactView &cpv) override
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
string idNameSpace
Definition: DDTOBRodAlgo.cc:34
string sideClamp1
Definition: DDTOBRodAlgo.cc:67
vector< string > sideRod
Definition: DDTOBRodAlgo.cc:37
vector< double > aohZ
Definition: DDTOBRodAlgo.cc:85
vector< double > optFibreZ
Definition: DDTOBRodAlgo.cc:65
double endRod2Y
Definition: DDTOBRodAlgo.cc:45
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
vector< double > connectZ
Definition: DDTOBRodAlgo.cc:79
static std::string & ns()
vector< double > aohCopies
Definition: DDTOBRodAlgo.cc:82
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
string endCool
Definition: DDTOBRodAlgo.cc:58
vector< double > sideRodY
Definition: DDTOBRodAlgo.cc:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
vector< double > sideRodZ
Definition: DDTOBRodAlgo.cc:40
string endRod1
Definition: DDTOBRodAlgo.cc:41
U second(std::pair< T, U > const &p)
vector< double > sideClamp2DZ
Definition: DDTOBRodAlgo.cc:71
vector< double > connectY
Definition: DDTOBRodAlgo.cc:78
string endRod2
Definition: DDTOBRodAlgo.cc:44
string aohName
Definition: DDTOBRodAlgo.cc:81
vector< double > moduleY
Definition: DDTOBRodAlgo.cc:75
vector< double > clampZ
Definition: DDTOBRodAlgo.cc:53
vector< double > aohY
Definition: DDTOBRodAlgo.cc:84
vector< double > aohX
Definition: DDTOBRodAlgo.cc:83
vector< double > moduleZ
Definition: DDTOBRodAlgo.cc:76
vector< double > sideCoolY
Definition: DDTOBRodAlgo.cc:56
vector< double > sideCoolZ
Definition: DDTOBRodAlgo.cc:57
vector< double > endRod1Y
Definition: DDTOBRodAlgo.cc:42
double endRod2Z
Definition: DDTOBRodAlgo.cc:46
vector< double > optFibreX
Definition: DDTOBRodAlgo.cc:64
string central
Definition: DDTOBRodAlgo.cc:33
~DDTOBRodAlgo() override
vector< double > sideRodX
Definition: DDTOBRodAlgo.cc:38
vector< double > sideClamp1DZ
Definition: DDTOBRodAlgo.cc:69
string optFibre
Definition: DDTOBRodAlgo.cc:63
vector< double > sideClampX
Definition: DDTOBRodAlgo.cc:68
string sideCool
Definition: DDTOBRodAlgo.cc:54
double endCoolZ
Definition: DDTOBRodAlgo.cc:61
string sideClamp2
Definition: DDTOBRodAlgo.cc:70
vector< double > endRod1Z
Definition: DDTOBRodAlgo.cc:43
#define DEFINE_EDM_PLUGIN(factory, type, name)
double endCoolY
Definition: DDTOBRodAlgo.cc:60
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
string endCoolRot
Definition: DDTOBRodAlgo.cc:59
vector< double > sideCoolX
Definition: DDTOBRodAlgo.cc:55
vector< double > clampX
Definition: DDTOBRodAlgo.cc:52
vector< string > moduleRot
Definition: DDTOBRodAlgo.cc:74
#define LogDebug(id)
vector< string > connect
Definition: DDTOBRodAlgo.cc:77