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 
6 #include <cmath>
7 #include <algorithm>
8 
13 #include "CLHEP/Units/GlobalPhysicalConstants.h"
14 #include "CLHEP/Units/GlobalSystemOfUnits.h"
15 
16 
18  sideRod(0), sideRodX(0), sideRodY(0), sideRodZ(0), endRod1Y(0), endRod1Z(0),
19  clampX(0), clampZ(0), sideCoolX(0), sideCoolY(0), sideCoolZ(0),
20  endCoolY(0), endCoolZ(0),
21  optFibreX(0),optFibreZ(0),
22  sideClampX(0), sideClamp1DZ(0), sideClamp2DZ(0), moduleRot(0), moduleY(0),
23  moduleZ(0), connect(0), connectY(0), connectZ(0),
24  aohCopies(0), aohX(0), aohY(0), aohZ(0) {
25  LogDebug("TOBGeom") << "DDTOBRodAlgo info: Creating an instance";
26 }
27 
29 
31  const DDVectorArguments & vArgs,
32  const DDMapArguments & ,
33  const DDStringArguments & sArgs,
34  const DDStringVectorArguments & vsArgs) {
35 
36  central = sArgs["CentralName"];
37  shift = nArgs["Shift"];
39  DDName parentName = parent().name();
40  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: Parent " << parentName
41  << " Central " << central << " NameSpace "
42  << idNameSpace << "\tShift " << shift;
43 
44  sideRod = vsArgs["SideRodName"];
45  sideRodX = vArgs["SideRodX"];
46  sideRodY = vArgs["SideRodY"];
47  sideRodZ = vArgs["SideRodZ"];
48  for (int i=0; i<(int)(sideRod.size()); i++) {
49  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideRod[i]
50  << " to be positioned " << sideRodX.size()
51  <<" times at y = " << sideRodY[i] << " z = "
52  << sideRodZ[i] << " and x";
53  for (int j=0; j<(int)(sideRodX.size()); j++)
54  LogDebug("TOBGeom") << "\tsideRodX[" << i << "] = " << sideRodX[j];
55  }
56 
57  endRod1 = sArgs["EndRod1Name"];
58  endRod1Y = vArgs["EndRod1Y"];
59  endRod1Z = vArgs["EndRod1Z"];
60  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << endRod1 << " to be "
61  << "positioned " << endRod1Y.size() << " times at";
62  for (int i=0; i<(int)(endRod1Y.size()); i++)
63  LogDebug("TOBGeom") << "\t[" << i << "]\ty = " << endRod1Y[i]
64  << "\tz = " << endRod1Z[i];
65 
66  endRod2 = sArgs["EndRod2Name"];
67  endRod2Y = nArgs["EndRod2Y"];
68  endRod2Z = nArgs["EndRod2Z"];
69  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << endRod2 << " to be "
70  << "positioned at y = " << endRod2Y << " z = "
71  << endRod2Z;
72 
73  cable = sArgs["CableName"];
74  cableZ = nArgs["CableZ"];
75  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << cable << " to be "
76  << "positioned at z = " << cableZ;
77 
78  clamp = sArgs["ClampName"];
79  clampX = vArgs["ClampX"];
80  clampZ = vArgs["ClampZ"];
81  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << clamp << " to be "
82  << "positioned " << clampX.size() << " times at";
83  for (int i=0; i<(int)(clampX.size()); i++)
84  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << clampX[i] << "\tz = "
85  << clampZ[i];
86 
87  sideCool = sArgs["SideCoolName"];
88  sideCoolX = vArgs["SideCoolX"];
89  sideCoolY = vArgs["SideCoolY"];
90  sideCoolZ = vArgs["SideCoolZ"];
91  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideCool << " to be "
92  << "positioned " << sideCoolX.size() << " times at";
93  for (int i=0; i<(int)(sideCoolX.size()); i++)
94  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideCoolX[i]
95  << "\ty = " << sideCoolY[i]
96  << "\tz = " << sideCoolZ[i];
97 
98  endCool = sArgs["EndCoolName"];
99  endCoolY = nArgs["EndCoolY"];
100  endCoolZ = nArgs["EndCoolZ"];
101  endCoolRot = sArgs["EndCoolRot"];
102  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " <<endCool <<" to be "
103  << "positioned with " << endCoolRot << " rotation at"
104  << " y = " << endCoolY
105  << " z = " << endCoolZ;
106 
107  optFibre = sArgs["OptFibreName"];
108  optFibreX = vArgs["optFibreX"];
109  optFibreZ = vArgs["optFibreZ"];
110  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << optFibre << " to be "
111  << "positioned " << optFibreX.size() << " times at";
112  for (int i=0; i<(int)(optFibreX.size()); i++)
113  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << optFibreX[i]
114  << "\tz = " << optFibreZ[i];
115 
116  sideClamp1 = sArgs["SideClamp1Name"];
117  sideClampX = vArgs["SideClampX"];
118  sideClamp1DZ = vArgs["SideClamp1DZ"];
119  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideClamp1 << " to be "
120  << "positioned " << sideClampX.size() << " times at";
121  for (int i=0; i<(int)(sideClampX.size()); i++)
122  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i]
123  << "\tdz = " << sideClamp1DZ[i];
124 
125  sideClamp2 = sArgs["SideClamp2Name"];
126  sideClamp2DZ = vArgs["SideClamp2DZ"];
127  LogDebug("TOBGeom") << "DDTOBRodAlgo debug: " << sideClamp2 << " to be "
128  << "positioned " << sideClampX.size() << " times at";
129  for (int i=0; i<(int)(sideClampX.size()); i++)
130  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i]
131  << "\tdz = " << sideClamp2DZ[i];
132 
133  moduleRot = vsArgs["ModuleRot"];
134  module = sArgs["ModuleName"];
135  moduleY = vArgs["ModuleY"];
136  moduleZ = vArgs["ModuleZ"];
137  LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << module <<" positioned "
138  << moduleRot.size() << " times";
139  for (int i=0; i<(int)(moduleRot.size()); i++)
140  LogDebug("TOBGeom") << "\tRotation " << moduleRot[i] << "\ty = "
141  << moduleY[i] << "\tz = " << moduleZ[i];
142 
143  connect = vsArgs["ICCName"];
144  connectY = vArgs["ICCY"];
145  connectZ = vArgs["ICCZ"];
146  LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << connect.size()
147  << " ICC positioned with no rotation";
148  for (int i=0; i<(int)(connect.size()); i++)
149  LogDebug("TOBGeom") << "\t" << connect[i] << "\ty = " << connectY[i]
150  << "\tz = " << connectZ[i];
151 
152  aohName = sArgs["AOHName"];
153  aohCopies = vArgs["AOHCopies"];
154  aohX = vArgs["AOHx"];
155  aohY = vArgs["AOHy"];
156  aohZ = vArgs["AOHz"];
157  LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << aohName <<" AOH will be positioned on ICC's";
158  for (int i=0; i<(int)(aohCopies.size()); i++)
159  LogDebug("TOBGeom") << " copies " << aohCopies[i]
160  << "\tx = " << aohX[i]
161  << "\ty = " << aohY[i]
162  << "\tz = " << aohZ[i];
163 
164 }
165 
167 
168  LogDebug("TOBGeom") << "==>> Constructing DDTOBRodAlgo...";
169  DDName rodName = parent().name();
171 
172  // Side Rods
173  for (int i=0; i<(int)(sideRod.size()); i++) {
174  for (int j=0; j<(int)(sideRodX.size()); j++) {
176  DDName child(DDSplit(sideRod[i]).first, DDSplit(sideRod[i]).second);
177  cpv.position(child, rodName, j+1, r, DDRotation());
178  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
179  << j+1 << " positioned in " << rodName << " at "
180  << r << " with no rotation";
181  }
182  }
183 
184  // Clamps
185  for (int i=0; i<(int)(clampX.size()); i++) {
186  DDTranslation r(clampX[i], 0, shift+clampZ[i]);
187  DDName child(DDSplit(clamp).first, DDSplit(clamp).second);
188  cpv.position(child, rodName, i+1, r, DDRotation());
189  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
190  << i+1 << " positioned in " << rodName << " at "
191  << r << " with no rotation";
192  }
193 
194  // Side Cooling tubes
195  for (int i=0; i<(int)(sideCoolX.size()); i++) {
197  DDName child(DDSplit(sideCool).first, DDSplit(sideCool).second);
198  cpv.position(child, rodName, i+1, r, DDRotation());
199  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
200  << i+1 << " positioned in " << rodName << " at "
201  << r << " with no rotation";
202  }
203 
204  // Optical Fibres
205  for (int i=0; i<(int)(optFibreX.size()); i++) {
207  DDName child(DDSplit(optFibre).first, DDSplit(optFibre).second);
208  cpv.position(child, rodName, i+1, r, DDRotation());
209  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
210  << i+1 << " positioned in " << rodName << " at "
211  << r << " with no rotation";
212  }
213 
214  // Side Clamps
215  for (int i=0; i<(int)(sideClamp1DZ.size()); i++) {
216  int j = i/2;
218  DDName child(DDSplit(sideClamp1).first, DDSplit(sideClamp1).second);
219  cpv.position(child, rodName, i+1, r, DDRotation());
220  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
221  << i+1 << " positioned in " << rodName << " at "
222  << r << " with no rotation";
223  }
224  for (int i=0; i<(int)(sideClamp2DZ.size()); i++) {
225  int j = i/2;
227  DDName child(DDSplit(sideClamp2).first, DDSplit(sideClamp2).second);
228  cpv.position(child, rodName, i+1, r, DDRotation());
229  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
230  << i+1 << " positioned in " << rodName << " at "
231  << r << " with no rotation";
232  }
233 
234  // End Rods
235  for (int i=0; i<(int)(endRod1Y.size()); i++) {
237  DDName child(DDSplit(endRod1).first, DDSplit(endRod1).second);
238  cpv.position(child, centName, i+1, r, DDRotation());
239  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
240  << i+1 << " positioned in " << centName << " at "
241  << r << " with no rotation";
242  }
244  DDName child1(DDSplit(endRod2).first, DDSplit(endRod2).second);
245  cpv.position(child1, centName, 1, r1, DDRotation());
246  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child1 << " number 1 "
247  << "positioned in " << centName << " at " << r1
248  << " with no rotation";
249 
250  // End cooling tubes
252  std::string rotstr = DDSplit(endCoolRot).first;
253  std::string rotns = DDSplit(endCoolRot).second;
254  DDRotation rot2(DDName(rotstr,rotns));
255  DDName child2(DDSplit(endCool).first, DDSplit(endCool).second);
256  cpv.position(child2, centName, 1, r2, rot2);
257  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child2 << " number 1 "
258  << "positioned in " << centName << " at " << r2
259  << " with " << rot2;
260 
261  //Mother cable
262  DDTranslation r3(0, 0, shift+cableZ);
263  DDName child3(DDSplit(cable).first, DDSplit(cable).second);
264  cpv.position(child3, centName, 1, r3, DDRotation());
265  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child3 << " number 1 "
266  << "positioned in " << centName << " at " << r3
267  << " with no rotation";
268 
269  //Modules
270  for (int i=0; i<(int)(moduleRot.size()); i++) {
272  rotstr = DDSplit(moduleRot[i]).first;
273  DDRotation rot;
274  if (rotstr != "NULL") {
275  rotns = DDSplit(moduleRot[i]).second;
276  rot = DDRotation(DDName(rotstr, rotns));
277  }
278  DDName child(DDSplit(module).first, DDSplit(module).second);
279  cpv.position(child, centName, i+1, r, rot);
280  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
281  << i+1 << " positioned in " << centName << " at "
282  << r << " with " << rot;
283  }
284 
285  //Connectors (ICC, CCUM, ...)
286  for (int i=0; i<(int)(connect.size()); i++) {
288  DDName child(DDSplit(connect[i]).first, DDSplit(connect[i]).second);
289  cpv.position(child, centName, i+1, r, DDRotation());
290  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
291  << i+1 << " positioned in " << centName << " at "
292  << r << " with no rotation";
293  }
294 
295  //AOH (only on ICCs)
296  int copyNumber = 0;
297  for (int i=0; i<(int)(aohCopies.size()); i++) {
298  if(aohCopies[i] != 0) {
299  // first copy with (+aohX,+aohZ) translation
300  copyNumber++;
301  DDTranslation r(aohX[i] + 0, aohY[i] + connectY[i], aohZ[i] + shift+connectZ[i]);
302  DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
303  cpv.position(child, centName, copyNumber, r, DDRotation());
304  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
305  << copyNumber << " positioned in " << centName << " at "
306  << r << " with no rotation";
307  // if two copies add a copy with (-aohX,-aohZ) translation
308  if(aohCopies[i] == 2) {
309  copyNumber++;
310  DDTranslation r(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]);
311  DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
312  cpv.position(child, centName, copyNumber, r, DDRotation());
313  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
314  << copyNumber << " positioned in " << centName << " at "
315  << r << " with no rotation";
316  }
317  // if four copies add 3 copies with (-aohX,+aohZ) (-aohX,-aohZ) (+aohX,+aohZ) and translations
318  if(aohCopies[i] == 4) {
319  for (unsigned int j = 1; j<4; j++ ) {
320  copyNumber++;
321  switch(j) {
322  case 1:
323  {
324  DDTranslation r(-aohX[i] + 0, aohY[i] + connectY[i], +aohZ[i] + shift+connectZ[i]);
325  DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
326  cpv.position(child, centName, copyNumber, r, DDRotation());
327  break;
328  }
329  case 2:
330  {
331  DDTranslation r(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]);
332  DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
333  cpv.position(child, centName, copyNumber, r, DDRotation());
334  break;
335  }
336  case 3:
337  {
338  DDTranslation r(+aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift+connectZ[i]);
339  DDName child(DDSplit(aohName).first, DDSplit(aohName).second);
340  cpv.position(child, centName, copyNumber, r, DDRotation());
341  break;
342  }
343  }
344  LogDebug("TOBGeom") << "DDTOBRodAlgo test: " << child << " number "
345  << copyNumber << " positioned in " << centName << " at "
346  << r << " with no rotation";
347  }
348  }
349  }
350  }
351 
352  LogDebug("TOBGeom") << "<<== End of DDTOBRodAlgo construction ...";
353 }
#define LogDebug(id)
std::string sideClamp2
Definition: DDTOBRodAlgo.h:63
std::vector< double > sideRodZ
Definition: DDTOBRodAlgo.h:33
std::vector< double > sideCoolX
Definition: DDTOBRodAlgo.h:48
std::vector< std::string > sideRod
Definition: DDTOBRodAlgo.h:30
std::vector< double > sideClamp2DZ
Definition: DDTOBRodAlgo.h:64
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
Definition: DDTOBRodAlgo.cc:30
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
double endRod2Y
Definition: DDTOBRodAlgo.h:38
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
std::vector< double > optFibreX
Definition: DDTOBRodAlgo.h:57
std::string aohName
Definition: DDTOBRodAlgo.h:74
std::vector< double > connectZ
Definition: DDTOBRodAlgo.h:72
static std::string & ns()
std::vector< double > endRod1Y
Definition: DDTOBRodAlgo.h:35
type of data representation of DDCompactView
Definition: DDCompactView.h:90
std::vector< double > sideRodY
Definition: DDTOBRodAlgo.h:32
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:64
std::vector< double > aohX
Definition: DDTOBRodAlgo.h:76
virtual ~DDTOBRodAlgo()
Definition: DDTOBRodAlgo.cc:28
std::vector< double > moduleY
Definition: DDTOBRodAlgo.h:68
U second(std::pair< T, U > const &p)
std::vector< std::string > connect
Definition: DDTOBRodAlgo.h:70
std::string clamp
Definition: DDTOBRodAlgo.h:44
std::vector< double > clampZ
Definition: DDTOBRodAlgo.h:46
std::vector< double > optFibreZ
Definition: DDTOBRodAlgo.h:58
std::vector< double > sideClampX
Definition: DDTOBRodAlgo.h:61
double shift
Definition: DDTOBRodAlgo.h:29
std::string optFibre
Definition: DDTOBRodAlgo.h:56
void execute(DDCompactView &cpv)
std::vector< double > clampX
Definition: DDTOBRodAlgo.h:45
double endRod2Z
Definition: DDTOBRodAlgo.h:39
std::string endCoolRot
Definition: DDTOBRodAlgo.h:52
std::vector< double > sideClamp1DZ
Definition: DDTOBRodAlgo.h:62
std::string endRod1
Definition: DDTOBRodAlgo.h:34
std::vector< double > sideCoolZ
Definition: DDTOBRodAlgo.h:50
std::vector< double > aohCopies
Definition: DDTOBRodAlgo.h:75
double cableZ
Definition: DDTOBRodAlgo.h:42
std::vector< double > moduleZ
Definition: DDTOBRodAlgo.h:69
std::vector< double > connectY
Definition: DDTOBRodAlgo.h:71
edm::Handle< T > connect(const T *&ptr, edm::EDGetTokenT< T > token, const edm::Event &evt)
std::vector< double > aohY
Definition: DDTOBRodAlgo.h:77
std::string sideClamp1
Definition: DDTOBRodAlgo.h:60
std::vector< double > aohZ
Definition: DDTOBRodAlgo.h:78
double endCoolZ
Definition: DDTOBRodAlgo.h:54
std::string central
Definition: DDTOBRodAlgo.h:26
std::string idNameSpace
Definition: DDTOBRodAlgo.h:27
std::string cable
Definition: DDTOBRodAlgo.h:41
std::string endCool
Definition: DDTOBRodAlgo.h:51
std::vector< std::string > moduleRot
Definition: DDTOBRodAlgo.h:67
std::vector< double > sideCoolY
Definition: DDTOBRodAlgo.h:49
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
double endCoolY
Definition: DDTOBRodAlgo.h:53
std::vector< double > sideRodX
Definition: DDTOBRodAlgo.h:31
Definition: vlib.h:208
std::string sideCool
Definition: DDTOBRodAlgo.h:47
std::string endRod2
Definition: DDTOBRodAlgo.h:37
std::vector< double > endRod1Z
Definition: DDTOBRodAlgo.h:36