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/SystemOfUnits.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.;
204 edm::LogVerbatim(
"PixelGeom") <<
"DDPixFwdBlades: Initialize with endcap " <<
endcap <<
" FlagString " << flagString
205 <<
" FlagSelector " << flagSelector <<
" Child " << childName <<
" ChildTranslation " 206 << childTranslationVector[0] <<
":" << childTranslationVector[1] <<
":" 207 << childTranslationVector[2] <<
" ChildRotation " << childRotationName <<
" NameSpace " 208 << idNameSpace <<
"\n nBlades " << nBlades <<
" bladeAngle " << bladeAngle
209 <<
" zPlane " << zPlane <<
" bladeZShift " << bladeZShift <<
" ancorRadius " 210 << ancorRadius <<
" jX|jY|jZ " << jX <<
":" << jY <<
":" << jZ <<
" kX|kY|kZ " << kX
211 <<
":" << kY <<
":" << kZ;
217 if (!nippleRotationZPlus) {
218 computeNippleParameters(1.);
219 computeNippleParameters(-1.);
221 if (childName.empty())
226 double effBladeAngle = -
endcap * bladeAngle;
227 double effBladeZShift =
endcap * bladeZShift;
236 CLHEP::HepRotation childRotMatrix = CLHEP::HepRotation();
237 if (!childRotationName.empty()) {
241 childRotation.
rotation().GetComponents(
x, y, z);
242 CLHEP::HepRep3x3 tr(
x.X(), y.X(), z.X(),
x.Y(), y.Y(), z.Y(),
x.Z(), y.Z(), z.Z());
243 childRotMatrix = CLHEP::HepRotation(tr);
244 }
else if (childName ==
"pixfwdNipple:PixelForwardNippleZPlus") {
245 childRotMatrix = *nippleRotationZPlus;
246 }
else if (childName ==
"pixfwdNipple:PixelForwardNippleZMinus") {
247 childRotMatrix = *nippleRotationZMinus;
250 CLHEP::Hep3Vector childTranslation;
251 if (childName ==
"pixfwdNipple:PixelForwardNippleZPlus") {
252 childTranslation = CLHEP::Hep3Vector(nippleTranslationX, nippleTranslationY, nippleTranslationZ);
253 }
else if (childName ==
"pixfwdNipple:PixelForwardNippleZMinus") {
254 childTranslation = CLHEP::Hep3Vector(-nippleTranslationX, nippleTranslationY, nippleTranslationZ);
257 CLHEP::Hep3Vector(childTranslationVector[0], childTranslationVector[1], childTranslationVector[2]);
262 CLHEP::HepRotation bladeRotMatrix(CLHEP::Hep3Vector(0., 1., 0.), effBladeAngle);
266 double deltaPhi = (360. / nBlades) * CLHEP::deg;
267 int nQuarter = nBlades / 4;
268 double zShiftMax = effBladeZShift * ((nQuarter - 1) / 2.);
270 for (
int iBlade = 0; iBlade < nBlades; iBlade++) {
273 if (flagString[iBlade] != flagSelector[0])
275 int copy = issueCopyNumber();
279 double phi = (iBlade + 0.5) *
deltaPhi - 90. * CLHEP::deg;
280 int iQuarter = iBlade % nQuarter;
281 double zShift = -zShiftMax + iQuarter * effBladeZShift;
285 CLHEP::HepRotation rotMatrix(CLHEP::Hep3Vector(0., 0., 1.), phi);
286 rotMatrix *= bladeRotMatrix;
290 CLHEP::Hep3Vector translation = rotMatrix(childTranslation + CLHEP::Hep3Vector(0., ancorRadius, 0.));
291 translation += CLHEP::Hep3Vector(0., 0., zShift + zPlane);
301 rotMatrix *= childRotMatrix;
303 make_unique<DDRotationMatrix>(rotMatrix.xx(),
315 DDTranslation ddtran(translation.x(), translation.y(), translation.z());
318 <<
" with translation " << ddtran <<
" and rotation " <<
rotation;
325 if (copyNumbers.count(childName) == 0)
326 copyNumbers[childName] = 0;
327 return ++copyNumbers[childName];
333 double effBladeAngle =
endcap * bladeAngle;
335 CLHEP::Hep3Vector jC;
336 CLHEP::Hep3Vector kB;
337 string rotNameNippleToCover;
338 string rotNameCoverToNipple;
339 string rotNameNippleToBody;
342 jC = CLHEP::Hep3Vector(jX, jY + ancorRadius, jZ);
343 kB = CLHEP::Hep3Vector(kX, kY + ancorRadius, kZ);
344 rotNameNippleToCover =
"NippleToCoverZPlus";
345 rotNameCoverToNipple =
"CoverToNippleZPlus";
346 rotNameNippleToBody =
"NippleToBodyZPlus";
348 jC = CLHEP::Hep3Vector(-jX, jY + ancorRadius, jZ);
349 kB = CLHEP::Hep3Vector(-kX, kY + ancorRadius, kZ);
350 rotNameNippleToCover =
"NippleToCoverZMinus";
351 rotNameCoverToNipple =
"CoverToNippleZMinus";
352 rotNameNippleToBody =
"NippleToBodyZMinus";
357 CLHEP::Hep3Vector tCB(bladeZShift *
sin(effBladeAngle), 0., bladeZShift *
cos(effBladeAngle));
362 CLHEP::HepRotation rCB(CLHEP::Hep3Vector(1. *
sin(effBladeAngle), 0., 1. *
cos(effBladeAngle)),
deltaPhi);
366 CLHEP::Hep3Vector kC = rCB * (kB + tCB);
370 CLHEP::Hep3Vector jkC = kC - jC;
371 double jkLength = jkC.mag();
374 <<
"JK Length " << jkLength * CLHEP::mm;
378 CLHEP::Hep3Vector nippleTranslation((kC + jC) / 2. - CLHEP::Hep3Vector(0., ancorRadius, 0.));
380 nippleTranslationX = nippleTranslation.x();
381 nippleTranslationY = nippleTranslation.y();
382 nippleTranslationZ = nippleTranslation.z();
384 edm::LogVerbatim(
"PixelGeom") <<
"Child translation : " << nippleTranslation;
388 CLHEP::Hep3Vector vZ(0., 0., 1.);
389 CLHEP::Hep3Vector axis = vZ.cross(jkC);
390 double angleCover = vZ.angle(jkC);
392 CLHEP::HepRotation* rpCN =
new CLHEP::HepRotation(axis, angleCover);
394 nippleRotationZPlus = rpCN;
396 nippleRotationZMinus = rpCN;
401 DDName(rotNameCoverToNipple,
"pixfwdNipple"),
402 make_unique<DDRotationMatrix>(
403 rpCN->xx(), rpCN->xy(), rpCN->xz(), rpCN->yx(), rpCN->yy(), rpCN->yz(), rpCN->zx(), rpCN->zy(), rpCN->zz()));
404 CLHEP::HepRotation rpNC(axis, -angleCover);
405 edm::LogVerbatim(
"PixelGeom") <<
"DDPixFwdBlades::Defines " <<
DDName(rotNameCoverToNipple,
"pixfwdNipple")
407 DDrot(
DDName(rotNameNippleToCover,
"pixfwdNipple"),
408 make_unique<DDRotationMatrix>(
409 rpNC.xx(), rpNC.xy(), rpNC.xz(), rpNC.yx(), rpNC.yy(), rpNC.yz(), rpNC.zx(), rpNC.zy(), rpNC.zz()));
410 edm::LogVerbatim(
"PixelGeom") <<
"DDPixFwdBlades::Defines " <<
DDName(rotNameNippleToCover,
"pixfwdNipple")
415 CLHEP::HepRotation rpNB(rpNC * rCB);
418 make_unique<DDRotationMatrix>(
419 rpNB.xx(), rpNB.xy(), rpNB.xz(), rpNB.yx(), rpNB.yy(), rpNB.yz(), rpNB.zx(), rpNB.zy(), rpNB.zz()));
420 edm::LogVerbatim(
"PixelGeom") <<
"DDPixFwdBlades::Defines " <<
DDName(rotNameNippleToBody,
"pixfwdNipple") <<
" with " 422 double angleBody = vZ.angle(rpNB * vZ);
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
double nippleTranslationZ
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string ©no, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Sin< T >::type sin(const T &t)
void computeNippleParameters(double endcap)
DDName is used to identify DDD entities uniquely.
void execute(DDCompactView &cpv) override
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
static std::string to_string(const XMLCh *ch)
map< string, int > copyNumbers
Represents a uniquely identifyable rotation matrix.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
U second(std::pair< T, U > const &p)
const std::string & name() const
Returns the name.
Cos< T >::type cos(const T &t)
CLHEP::HepRotation * nippleRotationZMinus
CLHEP::HepRotation * nippleRotationZPlus
const DDRotationMatrix & rotation() const
Returns the read-only rotation-matrix.
#define DEFINE_EDM_PLUGIN(factory, type, name)
vector< double > childTranslationVector
~DDPixFwdBlades() override
a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector> ...
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override