18 #include "CLHEP/Vector/ThreeVector.h"
19 #include "CLHEP/Vector/Rotation.h"
20 #include "CLHEP/Vector/RotationInterfaces.h"
21 #include "CLHEP/Units/GlobalPhysicalConstants.h"
22 #include "CLHEP/Units/GlobalSystemOfUnits.h"
130 int issueCopyNumber();
131 void computeNippleParameters(
double endcap);
142 if (nArgs.find(
"Endcap") != nArgs.end()) {
148 if (sArgs.find(
"FlagString") != sArgs.end()) {
149 flagString = sArgs[
"FlagString"];
150 flagSelector = sArgs[
"FlagSelector"];
152 flagString =
"YYYYYYYYYYYYYYYYYYYYYYYY";
156 if (sArgs.find(
"Child") != sArgs.end()) {
157 childName = sArgs[
"Child"];
162 if (vArgs.find(
"ChildTranslation") != vArgs.end()) {
163 childTranslationVector = vArgs[
"ChildTranslation"];
165 childTranslationVector = vector<double>(3, 0.);
168 if (sArgs.find(
"ChildRotation") != sArgs.end()) {
169 childRotationName = sArgs[
"ChildRotation"];
171 childRotationName =
"";
179 bladeAngle = 20. * CLHEP::deg;
181 bladeZShift = 6. * CLHEP::mm;
183 ancorRadius = 54.631 * CLHEP::mm;
187 jX = -16.25 * CLHEP::mm;
188 jY = 96.50 * CLHEP::mm;
189 jZ = 1.25 * CLHEP::mm;
190 kX = 16.25 * CLHEP::mm;
191 kY = 96.50 * CLHEP::mm;
192 kZ = -1.25 * CLHEP::mm;
196 nippleRotationZPlus =
nullptr;
197 nippleRotationZMinus =
nullptr;
198 nippleTranslationX = 0.;
199 nippleTranslationY = 0.;
200 nippleTranslationZ = 0.;
208 if (!nippleRotationZPlus) {
209 computeNippleParameters(1.);
210 computeNippleParameters(-1.);
212 if (childName.empty())
217 double effBladeAngle = -
endcap * bladeAngle;
218 double effBladeZShift =
endcap * bladeZShift;
227 CLHEP::HepRotation childRotMatrix = CLHEP::HepRotation();
228 if (!childRotationName.empty()) {
232 childRotation.
rotation().GetComponents(x, y, z);
233 CLHEP::HepRep3x3 tr(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), x.Z(), y.Z(), z.Z());
234 childRotMatrix = CLHEP::HepRotation(tr);
235 }
else if (childName ==
"pixfwdNipple:PixelForwardNippleZPlus") {
236 childRotMatrix = *nippleRotationZPlus;
237 }
else if (childName ==
"pixfwdNipple:PixelForwardNippleZMinus") {
238 childRotMatrix = *nippleRotationZMinus;
241 CLHEP::Hep3Vector childTranslation;
242 if (childName ==
"pixfwdNipple:PixelForwardNippleZPlus") {
243 childTranslation = CLHEP::Hep3Vector(nippleTranslationX, nippleTranslationY, nippleTranslationZ);
244 }
else if (childName ==
"pixfwdNipple:PixelForwardNippleZMinus") {
245 childTranslation = CLHEP::Hep3Vector(-nippleTranslationX, nippleTranslationY, nippleTranslationZ);
248 CLHEP::Hep3Vector(childTranslationVector[0], childTranslationVector[1], childTranslationVector[2]);
253 CLHEP::HepRotation bladeRotMatrix(CLHEP::Hep3Vector(0., 1., 0.), effBladeAngle);
257 double deltaPhi = (360. / nBlades) * CLHEP::deg;
258 int nQuarter = nBlades / 4;
259 double zShiftMax = effBladeZShift * ((nQuarter - 1) / 2.);
261 for (
int iBlade = 0; iBlade < nBlades; iBlade++) {
264 if (flagString[iBlade] != flagSelector[0])
266 int copy = issueCopyNumber();
270 double phi = (iBlade + 0.5) *
deltaPhi - 90. * CLHEP::deg;
271 int iQuarter = iBlade % nQuarter;
272 double zShift = -zShiftMax + iQuarter * effBladeZShift;
276 CLHEP::HepRotation rotMatrix(CLHEP::Hep3Vector(0., 0., 1.), phi);
277 rotMatrix *= bladeRotMatrix;
281 CLHEP::Hep3Vector translation = rotMatrix(childTranslation + CLHEP::Hep3Vector(0., ancorRadius, 0.));
282 translation += CLHEP::Hep3Vector(0., 0., zShift + zPlane);
287 string rotstr = mother.
name() +
DDSplit(childName).first + to_string(
copy);
291 rotMatrix *= childRotMatrix;
293 make_unique<DDRotationMatrix>(rotMatrix.xx(),
305 DDTranslation ddtran(translation.x(), translation.y(), translation.z());
313 if (copyNumbers.count(childName) == 0)
314 copyNumbers[childName] = 0;
315 return ++copyNumbers[childName];
321 double effBladeAngle =
endcap * bladeAngle;
323 CLHEP::Hep3Vector jC;
324 CLHEP::Hep3Vector kB;
325 string rotNameNippleToCover;
326 string rotNameCoverToNipple;
327 string rotNameNippleToBody;
330 jC = CLHEP::Hep3Vector(jX, jY + ancorRadius, jZ);
331 kB = CLHEP::Hep3Vector(kX, kY + ancorRadius, kZ);
332 rotNameNippleToCover =
"NippleToCoverZPlus";
333 rotNameCoverToNipple =
"CoverToNippleZPlus";
334 rotNameNippleToBody =
"NippleToBodyZPlus";
336 jC = CLHEP::Hep3Vector(-jX, jY + ancorRadius, jZ);
337 kB = CLHEP::Hep3Vector(-kX, kY + ancorRadius, kZ);
338 rotNameNippleToCover =
"NippleToCoverZMinus";
339 rotNameCoverToNipple =
"CoverToNippleZMinus";
340 rotNameNippleToBody =
"NippleToBodyZMinus";
345 CLHEP::Hep3Vector tCB(bladeZShift *
sin(effBladeAngle), 0., bladeZShift *
cos(effBladeAngle));
350 CLHEP::HepRotation rCB(CLHEP::Hep3Vector(1. *
sin(effBladeAngle), 0., 1. *
cos(effBladeAngle)),
deltaPhi);
354 CLHEP::Hep3Vector kC = rCB * (kB + tCB);
358 CLHEP::Hep3Vector jkC = kC - jC;
359 double jkLength = jkC.mag();
361 LogDebug(
"PixelGeom") <<
"+++++++++++++++ DDPixFwdBlades: "
362 <<
"JK Length " << jkLength * CLHEP::mm;
366 CLHEP::Hep3Vector nippleTranslation((kC + jC) / 2. - CLHEP::Hep3Vector(0., ancorRadius, 0.));
368 nippleTranslationX = nippleTranslation.x();
369 nippleTranslationY = nippleTranslation.y();
370 nippleTranslationZ = nippleTranslation.z();
372 LogDebug(
"PixelGeom") <<
"Child translation : " << nippleTranslation;
376 CLHEP::Hep3Vector vZ(0., 0., 1.);
377 CLHEP::Hep3Vector axis = vZ.cross(jkC);
378 double angleCover = vZ.angle(jkC);
379 LogDebug(
"PixelGeom") <<
" Angle to Cover: " << angleCover;
380 CLHEP::HepRotation* rpCN =
new CLHEP::HepRotation(axis, angleCover);
382 nippleRotationZPlus = rpCN;
384 nippleRotationZMinus = rpCN;
389 DDName(rotNameCoverToNipple,
"pixfwdNipple"),
390 make_unique<DDRotationMatrix>(
391 rpCN->xx(), rpCN->xy(), rpCN->xz(), rpCN->yx(), rpCN->yy(), rpCN->yz(), rpCN->zx(), rpCN->zy(), rpCN->zz()));
392 CLHEP::HepRotation rpNC(axis, -angleCover);
394 DDrot(
DDName(rotNameNippleToCover,
"pixfwdNipple"),
395 make_unique<DDRotationMatrix>(
396 rpNC.xx(), rpNC.xy(), rpNC.xz(), rpNC.yx(), rpNC.yy(), rpNC.yz(), rpNC.zx(), rpNC.zy(), rpNC.zz()));
400 CLHEP::HepRotation rpNB(rpNC * rCB);
403 make_unique<DDRotationMatrix>(
404 rpNB.xx(), rpNB.xy(), rpNB.xz(), rpNB.yx(), rpNB.yy(), rpNB.yz(), rpNB.zx(), rpNB.zy(), rpNB.zz()));
405 double angleBody = vZ.angle(rpNB * vZ);
406 LogDebug(
"PixelGeom") <<
" Angle to body : " << angleBody;