CMS 3D CMS Logo

DDTOBRodAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
4 
5 using namespace std;
6 using namespace dd4hep;
7 using namespace cms;
8 
9 static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
10  cms::DDNamespace ns(ctxt, e, true);
11  DDAlgoArguments args(ctxt, e);
12  string parentName = args.parentName();
13  string central = args.str("CentralName"); // Name of the central piece
14 
15  double shift = args.dble("Shift"); // Shift in z
16  vector<string> sideRod = args.vecStr("SideRodName"); // Name of the Side Rod
17  vector<double> sideRodX = args.vecDble("SideRodX"); // x-positions
18  vector<double> sideRodY = args.vecDble("SideRodY"); // y-positions
19  vector<double> sideRodZ = args.vecDble("SideRodZ"); // z-positions
20  string endRod1 = args.str("EndRod1Name"); // Name of the End Rod of type 1
21  vector<double> endRod1Y = args.vecDble("EndRod1Y"); // y-positions
22  vector<double> endRod1Z = args.vecDble("EndRod1Z"); // z-positions
23  string endRod2 = args.str("EndRod2Name"); // Name of the End Rod of type 2
24  double endRod2Y = args.dble("EndRod2Y"); // y-position
25  double endRod2Z = args.dble("EndRod2Z"); // z-position
26 
27  string cable = args.str("CableName"); // Name of the Mother cable
28  double cableZ = args.dble("CableZ"); // z-position
29 
30  string clamp = args.str("ClampName"); // Name of the clamp
31  vector<double> clampX = args.vecDble("ClampX"); // x-positions
32  vector<double> clampZ = args.vecDble("ClampZ"); // z-positions
33  string sideCool = args.str("SideCoolName"); // Name of the Side Cooling Tube
34  vector<double> sideCoolX = args.vecDble("SideCoolX"); // x-positions
35  vector<double> sideCoolY =
36  args.vecDble("SideCoolY"); // y-positions to avoid overlap with the module (be at the same level of EndCool)
37  vector<double> sideCoolZ = args.vecDble("SideCoolZ"); // z-positions
38  string endCool = args.str("EndCoolName"); // Name of the End Cooling Tube
39  string endCoolRot = args.str("EndCoolRot"); // Rotation matrix name for end cool
40  double endCoolY = args.dble("EndCoolY"); // y-position to avoid overlap with the module
41  double endCoolZ = args.dble("EndCoolZ"); // z-position
42 
43  string optFibre = args.str("OptFibreName"); // Name of the Optical Fibre
44  vector<double> optFibreX = args.vecDble("optFibreX"); // x-positions
45  vector<double> optFibreZ = args.vecDble("optFibreZ"); // z-positions
46 
47  string sideClamp1 = args.str("SideClamp1Name"); // Name of the side clamp of type 1
48  vector<double> sideClampX = args.vecDble("SideClampX"); // x-positions
49  vector<double> sideClamp1DZ = args.vecDble("SideClamp1DZ"); // Delta(z)-positions
50  string sideClamp2 = args.str("SideClamp2Name"); // Name of the side clamp of type 2
51  vector<double> sideClamp2DZ = args.vecDble("SideClamp2DZ"); // Delta(z)-positions
52 
53  string module = args.str("ModuleName"); // Name of the detector modules
54  vector<string> moduleRot = args.vecStr("ModuleRot"); // Rotation matrix name for module
55  vector<double> moduleY = args.vecDble("ModuleY"); // y-positions
56  vector<double> moduleZ = args.vecDble("ModuleZ"); // z-positions
57  vector<string> connect = args.vecStr("ICCName");
58  ; // Name of the connectors
59  vector<double> connectY = args.vecDble("ICCY"); // y-positions
60  vector<double> connectZ = args.vecDble("ICCZ"); // z-positions
61 
62  string aohName = args.str("AOHName"); // AOH name
63  vector<double> aohCopies = args.vecDble("AOHCopies"); // AOH copies to be positioned on each ICC
64  vector<double> aohX = args.vecDble("AOHx"); // AOH translation with respect small-ICC center (X)
65  vector<double> aohY = args.vecDble("AOHy"); // AOH translation with respect small-ICC center (Y)
66  vector<double> aohZ = args.vecDble("AOHz"); // AOH translation with respect small-ICC center (Z)
67 
68  LogDebug("TOBGeom") << "Parent " << parentName << " Central " << central << " NameSpace " << ns.name() << "\tShift "
69  << shift;
70  for (int i = 0; i < (int)(sideRod.size()); i++) {
71  LogDebug("TOBGeom") << sideRod[i] << " to be positioned " << sideRodX.size() << " times at y = " << sideRodY[i]
72  << " z = " << sideRodZ[i] << " and x";
73  for (double j : sideRodX)
74  LogDebug("TOBGeom") << "\tsideRodX[" << i << "] = " << j;
75  }
76  LogDebug("TOBGeom") << endRod1 << " to be "
77  << "positioned " << endRod1Y.size() << " times at";
78  for (int i = 0; i < (int)(endRod1Y.size()); i++)
79  LogDebug("TOBGeom") << "\t[" << i << "]\ty = " << endRod1Y[i] << "\tz = " << endRod1Z[i];
80  LogDebug("TOBGeom") << endRod2 << " to be "
81  << "positioned at y = " << endRod2Y << " z = " << endRod2Z;
82  LogDebug("TOBGeom") << cable << " to be "
83  << "positioned at z = " << cableZ;
84  LogDebug("TOBGeom") << clamp << " to be "
85  << "positioned " << clampX.size() << " times at";
86  for (int i = 0; i < (int)(clampX.size()); i++)
87  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << clampX[i] << "\tz = " << clampZ[i];
88  LogDebug("TOBGeom") << sideCool << " to be "
89  << "positioned " << sideCoolX.size() << " times at";
90  for (int i = 0; i < (int)(sideCoolX.size()); i++)
91  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideCoolX[i] << "\ty = " << sideCoolY[i]
92  << "\tz = " << sideCoolZ[i];
93  LogDebug("TOBGeom") << endCool << " to be "
94  << "positioned with " << endCoolRot << " rotation at"
95  << " y = " << endCoolY << " z = " << endCoolZ;
96  LogDebug("TOBGeom") << optFibre << " to be "
97  << "positioned " << optFibreX.size() << " times at";
98  for (int i = 0; i < (int)(optFibreX.size()); i++)
99  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << optFibreX[i] << "\tz = " << optFibreZ[i];
100  LogDebug("TOBGeom") << sideClamp1 << " to be "
101  << "positioned " << sideClampX.size() << " times at";
102  for (int i = 0; i < (int)(sideClampX.size()); i++)
103  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] << "\tdz = " << sideClamp1DZ[i];
104  LogDebug("TOBGeom") << sideClamp2 << " to be "
105  << "positioned " << sideClampX.size() << " times at";
106  for (int i = 0; i < (int)(sideClampX.size()); i++)
107  LogDebug("TOBGeom") << "\t[" << i << "]\tx = " << sideClampX[i] << "\tdz = " << sideClamp2DZ[i];
108  LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << module << " positioned " << moduleRot.size() << " times";
109  for (int i = 0; i < (int)(moduleRot.size()); i++)
110  LogDebug("TOBGeom") << "\tRotation " << moduleRot[i] << "\ty = " << moduleY[i] << "\tz = " << moduleZ[i];
111  LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << connect.size() << " ICC positioned with no rotation";
112  for (int i = 0; i < (int)(connect.size()); i++)
113  LogDebug("TOBGeom") << "\t" << connect[i] << "\ty = " << connectY[i] << "\tz = " << connectZ[i];
114  LogDebug("TOBGeom") << "DDTOBRodAlgo debug:\t" << aohName << " AOH will be positioned on ICC's";
115  for (int i = 0; i < (int)(aohCopies.size()); i++)
116  LogDebug("TOBGeom") << " copies " << aohCopies[i] << "\tx = " << aohX[i] << "\ty = " << aohY[i]
117  << "\tz = " << aohZ[i];
118 
119  const string& centName = central;
120  string child;
121  const string& rodName = parentName;
122  Volume rod = ns.volume(rodName);
123 
124  // Side Rods
125  for (int i = 0; i < (int)(sideRod.size()); i++) {
126  for (int j = 0; j < (int)(sideRodX.size()); j++) {
127  Position r(sideRodX[j], sideRodY[i], sideRodZ[i]);
128  child = sideRod[i];
129  rod.placeVolume(ns.volume(child), j + 1, r);
130  LogDebug("TOBGeom") << child << " number " << j + 1 << " positioned in " << rodName << " at " << r
131  << " with no rotation";
132  }
133  }
134  // Clamps
135  for (int i = 0; i < (int)(clampX.size()); i++) {
136  Position r(clampX[i], 0, shift + clampZ[i]);
137  child = clamp;
138  rod.placeVolume(ns.volume(child), i + 1, r);
139  LogDebug("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
140  << " with no rotation";
141  }
142  // Side Cooling tubes
143  for (int i = 0; i < (int)(sideCoolX.size()); i++) {
144  Position r(sideCoolX[i], sideCoolY[i], shift + sideCoolZ[i]);
145  child = sideCool;
146  rod.placeVolume(ns.volume(child), i + 1, r);
147  LogDebug("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
148  << " with no rotation";
149  }
150  // Optical Fibres
151  for (int i = 0; i < (int)(optFibreX.size()); i++) {
152  Position r(optFibreX[i], 0, shift + optFibreZ[i]);
153  child = optFibre;
154  rod.placeVolume(ns.volume(child), i + 1, r);
155  LogDebug("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
156  << " with no rotation";
157  }
158 
159  // Side Clamps
160  for (int i = 0; i < (int)(sideClamp1DZ.size()); i++) {
161  int j = i / 2;
162  Position r(sideClampX[i], moduleY[j], shift + moduleZ[j] + sideClamp1DZ[i]);
163  child = sideClamp1;
164  rod.placeVolume(ns.volume(child), i + 1, r);
165  LogDebug("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
166  << " with no rotation";
167  }
168  for (int i = 0; i < (int)(sideClamp2DZ.size()); i++) {
169  int j = i / 2;
170  Position r(sideClampX[i], moduleY[j], shift + moduleZ[j] + sideClamp2DZ[i]);
171  child = sideClamp2;
172  rod.placeVolume(ns.volume(child), i + 1, r);
173  LogDebug("TOBGeom") << child << " number " << i + 1 << " positioned in " << rodName << " at " << r
174  << " with no rotation";
175  }
176 
177  Volume cent = ns.volume(centName);
178  // End Rods
179  for (int i = 0; i < (int)(endRod1Y.size()); i++) {
180  Position r(0, endRod1Y[i], shift + endRod1Z[i]);
181  child = endRod1;
182  cent.placeVolume(ns.volume(child), i + 1, r);
183  LogDebug("TOBGeom") << child << " number " << i + 1 << " positioned in " << centName << " at " << r
184  << " with no rotation";
185  }
186  Position r1(0, endRod2Y, shift + endRod2Z);
187  child = endRod2;
188  cent.placeVolume(ns.volume(child), 1, r1);
189  LogDebug("TOBGeom") << child << " number 1 "
190  << "positioned in " << centName << " at " << r1 << " with no rotation";
191 
192  // End cooling tubes
193  Position r2(0, endCoolY, shift + endCoolZ);
194  const Rotation3D& rot2 = ns.rotation(endCoolRot);
195  child = endCool;
196  cent.placeVolume(ns.volume(child), 1, Transform3D(rot2, r2));
197  LogDebug("TOBGeom") << child << " number 1 "
198  << "positioned in " << centName << " at " << r2 << " with " << rot2;
199 
200  //Mother cable
201  Position r3(0, 0, shift + cableZ);
202  child = cable;
203  cent.placeVolume(ns.volume(child), 1, r3);
204  LogDebug("TOBGeom") << child << " number 1 "
205  << "positioned in " << centName << " at " << r3 << " with no rotation";
206 
207  //Modules
208  for (int i = 0; i < (int)(moduleRot.size()); i++) {
209  Position r(0, moduleY[i], shift + moduleZ[i]);
210  const Rotation3D& rot = ns.rotation(moduleRot[i]);
211  child = module;
212  cent.placeVolume(ns.volume(child), i + 1, Transform3D(rot, r));
213  LogDebug("TOBGeom") << child << " number " << i + 1 << " positioned in " << centName << " at " << r << " with "
214  << rot;
215  }
216 
217  //Connectors (ICC, CCUM, ...)
218  for (int i = 0; i < (int)(connect.size()); i++) {
219  Position r(0, connectY[i], shift + connectZ[i]);
220  child = connect[i];
221  cent.placeVolume(ns.volume(child), i + 1, r);
222  LogDebug("TOBGeom") << child << " number " << i + 1 << " positioned in " << centName << " at " << r
223  << " with no rotation";
224  }
225 
226  //AOH (only on ICCs)
227  int copyNumber = 0;
228  for (int i = 0; i < (int)(aohCopies.size()); i++) {
229  if (aohCopies[i] != 0) {
230  // first copy with (+aohX,+aohZ) translation
231  copyNumber++;
232  Position r(aohX[i] + 0, aohY[i] + connectY[i], aohZ[i] + shift + connectZ[i]);
233  child = aohName;
234  cent.placeVolume(ns.volume(child), copyNumber, r);
235  LogDebug("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at " << r
236  << " with no rotation";
237  // if two copies add a copy with (-aohX,-aohZ) translation
238  if (aohCopies[i] == 2) {
239  copyNumber++;
240  r = Position(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift + connectZ[i]);
241  child = aohName;
242  cent.placeVolume(ns.volume(child), copyNumber, r);
243  LogDebug("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at " << r
244  << " with no rotation";
245  }
246  // if four copies add 3 copies with (-aohX,+aohZ) (-aohX,-aohZ) (+aohX,+aohZ) and translations
247  if (aohCopies[i] == 4) {
248  Position rr;
249  for (unsigned int j = 1; j < 4; j++) {
250  copyNumber++;
251  child = aohName;
252  switch (j) {
253  case 1:
254  rr = Position(-aohX[i] + 0, aohY[i] + connectY[i], +aohZ[i] + shift + connectZ[i]);
255  cent.placeVolume(ns.volume(child), copyNumber, rr); // copyNumber
256  break;
257  case 2:
258  rr = Position(-aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift + connectZ[i]);
259  cent.placeVolume(ns.volume(child), copyNumber, rr); // copyNumber
260  break;
261  case 3:
262  rr = Position(+aohX[i] + 0, aohY[i] + connectY[i], -aohZ[i] + shift + connectZ[i]);
263  cent.placeVolume(ns.volume(child), copyNumber, rr); // copyNumber
264  break;
265  }
266  LogDebug("TOBGeom") << child << " number " << copyNumber << " positioned in " << centName << " at " << rr
267  << " with no rotation";
268  }
269  }
270  }
271  }
272  LogDebug("TOBGeom") << "<<== End of DDTOBRodAlgo construction ...";
273  return 1;
274 }
275 
276 // first argument is the type from the xml file
277 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTOBRodAlgo, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
cms::DDParsingContext
Definition: DDParsingContext.h:13
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
cms::DDNamespace
Definition: DDNamespace.h:16
central
Definition: L1ECALPrefiringWeightProducer.cc:36
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDTOBRodAlgo.cc:9
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:75
cms::DDNamespace::rotation
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:125
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
DDPlugins.h
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
createfilelist.int
int
Definition: createfilelist.py:10
DBConfiguration_cff.connect
connect
Definition: DBConfiguration_cff.py:18
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
alignCSCRings.r
r
Definition: alignCSCRings.py:93
align::Detector
Definition: StructureType.h:86
std
Definition: JetResolutionObject.h:76
submitPVValidationJobs.child
child
Definition: submitPVValidationJobs.py:119
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
dd4hep
Definition: DDPlugins.h:8
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
child
Definition: simpleInheritance.h:11
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:205
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37