58const int XmlVGM::GDMLWriter::fgkDefaultNumWidth = 10;
59const int XmlVGM::GDMLWriter::fgkDefaultNumPrecision = 4;
60const std::string XmlVGM::GDMLWriter::fgkSolidNameExtension =
"_s";
61const std::string XmlVGM::GDMLWriter::fgkIsotopeNameExtension =
"_i";
62const std::string XmlVGM::GDMLWriter::fgkElementNameExtension =
"_e";
63const char XmlVGM::GDMLWriter::fgkCharReplacement =
'_';
64const std::string XmlVGM::GDMLWriter::fgkNotAllowedChars =
" +-*/&<>%^";
65const std::string XmlVGM::GDMLWriter::fgkNotAllowedChars1 =
"0123456789";
66const double XmlVGM::GDMLWriter::fgkSTPTemperature = 273.15;
67const double XmlVGM::GDMLWriter::fgkSTPPressure = 101325;
68const double XmlVGM::GDMLWriter::fgkCarTolerance = 1e-10;
69const double XmlVGM::GDMLWriter::fgkAngTolerance = 1e-8;
73 const std::string& unitName,
const std::string& version)
78 fkBasicIndention(
" "),
79 fIndention(fkBasicIndention),
80 fNW(fgkDefaultNumWidth),
81 fNP(fgkDefaultNumPrecision),
90 fOutFile.width(fgkDefaultNumWidth);
91 fOutFile.precision(fgkDefaultNumPrecision);
111double XmlVGM::GDMLWriter::UpdateAngle(
double angle)
const
116 if (angle < -360. || angle > 360.) {
117 std::cerr <<
"+++ Warning +++: " << std::endl;
118 std::cerr <<
" XmlVGM::GDMLWriter::UpdateAngle:" << std::endl;
119 std::cerr <<
" Angle " << angle / AngleUnit()
120 <<
" is outside <-360., 360.>" << std::endl;
121 std::cerr <<
" It was converted to 0." << std::endl;
125 if (angle < 0.)
return angle + 360.;
131void XmlVGM::GDMLWriter::RegisterName(
const std::string& name,
bool warning)
137 if (fGDMLNames.find(name) == fGDMLNames.end())
138 fGDMLNames.insert(name);
140 std::cerr <<
"+++ Warning +++: " << std::endl;
141 std::cerr <<
" Duplicated name has occured: \"" << name <<
"\""
142 <<
" in geometry." << std::endl;
143 std::cerr <<
" Duplicated names are not allowed in GDML." << std::endl;
148void XmlVGM::GDMLWriter::WriteBooleanSolid(
158 std::string nameA =
StripName(lvName, fgkSolidNameExtension) +
"_constA";
159 std::string nameB =
StripName(lvName, fgkSolidNameExtension) +
"_constB";
160 WriteSolid(nameA, solidA,
"");
161 WriteSolid(nameB, solidB,
"");
164 nameA =
UpdateName(nameA, fgkSolidNameExtension);
165 nameB =
UpdateName(nameB, fgkSolidNameExtension);
170 std::string positionName = fMaps->AddBooleanPosition();
171 std::string rotationName = fMaps->AddBooleanRotation();
178 std::string element1;
179 std::string element6;
182 element1 =
"<intersection name=\"";
183 element6 =
"</intersection>";
186 element1 =
"<subtraction name=\"";
187 element6 =
"</subtraction>";
190 element1 =
"<union name=\"";
191 element6 =
"</union>";
196 std::string element2 =
"\" >";
197 std::string element3 =
"<first ref=\"";
198 std::string element4 =
"\" />";
199 std::string element5 =
"<second ref=\"";
200 std::string indention = fIndention + fkBasicIndention;
203 fOutFile << fIndention << element1 << lvName << element2 << std::endl
204 << indention << element3 << nameA << element4 << std::endl
205 << indention << element5 << nameB << element4 << std::endl;
207 fOutFile << fkBasicIndention;
208 WritePosition(positionName, transform);
210 fOutFile << fkBasicIndention;
211 WriteRotation(rotationName, invTransform);
213 fOutFile << fIndention << element6 << std::endl << std::endl;
217void XmlVGM::GDMLWriter::WriteBox(
218 std::string name,
double hx,
double hy,
double hz)
223 double x = hx / LengthUnit();
224 double y = hy / LengthUnit();
225 double z = hz / LengthUnit();
235 std::string quota =
"\"";
236 std::string element1 =
"<box lunit=\"cm\" aunit=\"degree\"";
237 std::string element2 =
"name=\"" + name + quota;
238 std::string element3 =
"x=\"";
239 std::string element4 =
"y=\"";
240 std::string element5 =
"z=\"";
241 std::string element6 =
"\" />";
242 std::string indention = fIndention + fkBasicIndention;
245 fOutFile << fIndention << element1 << std::endl
246 << indention << element2 << std::endl
247 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
248 << x << quota <<
" " << element4 << std::setw(fNW)
249 << std::setprecision(fNP) << y << quota <<
" " << element5
250 << std::setw(fNW) << std::setprecision(fNP) << z << element6
256void XmlVGM::GDMLWriter::WriteArb8(std::string name,
const VGM::IArb8* arb8)
269 std::string quota =
"\"";
270 std::string element1 =
"<arb8 lunit=\"cm\"";
271 std::string element2 =
"name=\"" + name + quota;
272 std::string element3 =
"dz=\"";
273 std::string element4 =
"v";
274 std::string element5 =
"x=\"";
275 std::string element6 =
"y=\"";
276 std::string element7 =
" />";
277 std::string indention = fIndention + fkBasicIndention;
280 fOutFile << fIndention << element1 << std::endl
281 << indention << element2 << std::endl
282 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
288 double dx = vertex.first / LengthUnit();
289 double dy = vertex.second / LengthUnit();
291 fOutFile << std::endl
292 << indention << element4 << std::setw(1) << i + 1 << element5
293 << std::setw(fNW) << std::setprecision(fNP) << dx << quota <<
" "
294 << element4 << std::setw(1) << i + 1 << element6 << std::setw(fNW)
295 << std::setprecision(fNP) << dy << quota;
297 fOutFile << element7 << std::endl << std::endl;
301void XmlVGM::GDMLWriter::WriteBox(std::string name,
const VGM::IBox* box)
309void XmlVGM::GDMLWriter::WriteCons(std::string name,
const VGM::ICons* cons)
319 double sphi = UpdateAngle(cons->
StartPhi()) / AngleUnit();
320 double dphi = UpdateAngle(cons->
DeltaPhi()) / AngleUnit();
328 std::string quota =
"\"";
329 std::string element1 =
"<cone lunit=\"cm\" aunit=\"degree\"";
330 std::string element2 =
"name=\"" + name + quota;
331 std::string element3 =
"z=\"";
332 std::string element4 =
"rmin1=\"";
333 std::string element5 =
"rmin2=\"";
334 std::string element6 =
"rmax1=\"";
335 std::string element7 =
"rmax2=\"";
336 std::string element8 =
"startphi=\"";
337 std::string element9 =
"deltaphi=\"";
338 std::string element10 =
"\" />";
339 std::string indention = fIndention + fkBasicIndention;
342 fOutFile << fIndention << element1 << std::endl
343 << indention << element2 << std::endl
344 << indention << element4 << std::setw(fNW) << std::setprecision(fNP)
345 << rmin1 << quota <<
" " << element5 << std::setw(fNW)
346 << std::setprecision(fNP) << rmin2 << quota <<
" " << element6
347 << std::setw(fNW) << std::setprecision(fNP) << rmax1 << quota <<
" "
348 << element7 << std::setw(fNW) << std::setprecision(fNP) << rmax2
349 << quota << std::endl
350 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
351 << hz << quota << std::endl
352 << indention << element8 << std::setw(fNW) << std::setprecision(fNP)
353 << sphi << quota <<
" " << element9 << std::setw(fNW)
354 << std::setprecision(fNP) << dphi << element10 << std::endl
359void XmlVGM::GDMLWriter::WriteCtubs(std::string name,
const VGM::ICtubs* ctubs)
366 double hz = ctubs->
ZHalfLength() / LengthUnit() * 2.;
367 double sphi = ctubs->
StartPhi() / AngleUnit();
368 double dphi = ctubs->
DeltaPhi() / AngleUnit();
369 double nxl = ctubs->
NxLow();
370 double nyl = ctubs->
NyLow();
371 double nzl = ctubs->
NzLow();
372 double nxh = ctubs->
NxHigh();
373 double nyh = ctubs->
NyHigh();
374 double nzh = ctubs->
NzHigh();
377 std::string quota =
"\"";
378 std::string element1 =
"<cutTube lunit=\"cm\" aunit=\"degree\"";
379 std::string element2 =
"name=\"" + name + quota;
380 std::string element3 =
"z=\"";
381 std::string element4 =
"rmin=\"";
382 std::string element5 =
"rmax=\"";
383 std::string element6 =
"startphi=\"";
384 std::string element7 =
"deltaphi=\"";
385 std::string element8 =
"lowX=\"";
386 std::string element9 =
"lowY=\"";
387 std::string element10 =
"lowZ=\"";
388 std::string element11 =
"highX=\"";
389 std::string element12 =
"highY=\"";
390 std::string element13 =
"highZ=\"";
391 std::string element14 =
"\" />";
392 std::string indention = fIndention + fkBasicIndention;
395 fOutFile << fIndention << element1 << std::endl
396 << indention << element2 << std::endl
397 << indention << element4 << std::setw(fNW) << std::setprecision(fNP)
398 << rmin << quota <<
" " << element5 << std::setw(fNW)
399 << std::setprecision(fNP) << rmax << quota <<
" " << element3
400 << std::setw(fNW) << std::setprecision(fNP) << hz << quota
402 << indention << element6 << std::setw(fNW) << std::setprecision(fNP)
403 << sphi << quota <<
" " << element7 << std::setw(fNW)
404 << std::setprecision(fNP) << dphi << quota << std::endl
405 << indention << element8 << std::setw(fNW) << std::setprecision(fNP)
406 << nxl << quota <<
" " << element9 << std::setw(fNW)
407 << std::setprecision(fNP) << nyl << quota <<
" " << element10
408 << std::setw(fNW) << std::setprecision(fNP) << nzl << quota
410 << indention << element11 << std::setw(fNW) << std::setprecision(fNP)
411 << nxh << quota <<
" " << element12 << std::setw(fNW)
412 << std::setprecision(fNP) << nyh << quota <<
" " << element13
413 << std::setw(fNW) << std::setprecision(fNP) << nzh << element14
419void XmlVGM::GDMLWriter::WriteEllipsoid(
425 double dx = ellipsoid->
XSemiAxis() / LengthUnit();
426 double dy = ellipsoid->
YSemiAxis() / LengthUnit();
427 double dz = ellipsoid->
ZSemiAxis() / LengthUnit();
428 double zbCut = ellipsoid->
ZBottomCut() / LengthUnit();
429 double ztCut = ellipsoid->
ZTopCut() / LengthUnit();
432 std::string quota =
"\"";
433 std::string element1 =
"<ellipsoid lunit=\"cm\" aunit=\"degree\"";
434 std::string element2 =
"name=\"" + name + quota;
435 std::string element3 =
"ax=\"";
436 std::string element4 =
"by=\"";
437 std::string element5 =
"cz=\"";
438 std::string element6 =
"zcut1=\"";
439 std::string element7 =
"zcut2=\"";
440 std::string element8 =
"\" />";
441 std::string indention = fIndention + fkBasicIndention;
444 fOutFile << fIndention << element1 << std::endl
445 << indention << element2 << std::endl
446 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
447 << dx << quota <<
" " << element4 << std::setw(fNW)
448 << std::setprecision(fNP) << dy << quota <<
" " << element5
449 << std::setw(fNW) << std::setprecision(fNP) << dz << quota <<
" "
450 << element6 << std::setw(fNW) << std::setprecision(fNP) << zbCut
451 << quota <<
" " << element7 << std::setw(fNW)
452 << std::setprecision(fNP) << ztCut << element8 << std::endl
457void XmlVGM::GDMLWriter::WriteEllipticalTube(
463 double dx = eltu->
Dx() / LengthUnit();
464 double dy = eltu->
Dy() / LengthUnit();
474 std::string quota =
"\"";
475 std::string element1 =
"<eltube lunit=\"cm\" aunit=\"degree\"";
476 std::string element2 =
"name=\"" + name + quota;
477 std::string element3 =
"dx=\"";
478 std::string element4 =
"dy=\"";
479 std::string element5 =
"dz=\"";
480 std::string element6 =
"\" />";
481 std::string indention = fIndention + fkBasicIndention;
484 fOutFile << fIndention << element1 << std::endl
485 << indention << element2 << std::endl
486 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
487 << dx << quota <<
" " << element4 << std::setw(fNW)
488 << std::setprecision(fNP) << dy << quota <<
" " << element5
489 << std::setw(fNW) << std::setprecision(fNP) << hz << element6
495void XmlVGM::GDMLWriter::WriteExtrudedSolid(
502 double* xvertArray =
new double[nofVertices];
503 double* yvertArray =
new double[nofVertices];
504 for (
int i = 0; i < nofVertices; i++) {
505 xvertArray[i] = extruded->
Vertex(i).first / LengthUnit();
506 yvertArray[i] = extruded->
Vertex(i).second / LengthUnit();
511 double* zArray =
new double[nofZSections];
512 double* xoffsetArray =
new double[nofZSections];
513 double* yoffsetArray =
new double[nofZSections];
514 double* scaleArray =
new double[nofZSections];
515 for (
int i = 0; i < nofZSections; i++) {
516 zArray[i] = extruded->
ZPosition(i) / LengthUnit();
517 xoffsetArray[i] = extruded->
Offset(i).first / LengthUnit();
518 yoffsetArray[i] = extruded->
Offset(i).second / LengthUnit();
519 scaleArray[i] = extruded->
Scale(i);
523 std::string quota =
"\"";
524 std::string element1 =
"<xtru lunit=\"cm\" aunit=\"degree\"";
525 std::string element2 =
"name=\"" + name + quota;
526 std::string element3 =
" >";
527 std::string element4 =
"<twoDimVertex x=\"";
528 std::string element5 =
"y=\"";
529 std::string element6 =
"\" />";
530 std::string element7 =
"<section zPosition=\"";
531 std::string element8 =
"zOrder=\"";
532 std::string element9 =
"xOffset=\"";
533 std::string element10 =
"yOffset=\"";
534 std::string element11 =
"scalingFactor=\"";
535 std::string element12 =
"</xtru>";
536 std::string indention = fIndention + fkBasicIndention;
539 fOutFile << fIndention << element1 << std::endl
540 << indention << element2 << element3 << std::endl;
543 for (
int i = 0; i < nofVertices; i++) {
544 fOutFile << indention << element4 << std::setw(fNW)
545 << std::setprecision(fNP) << xvertArray[i] << quota <<
" "
546 << element5 << std::setw(fNW) << std::setprecision(fNP)
547 << yvertArray[i] << element6 << std::endl;
551 for (
int i = 0; i < nofZSections; i++) {
552 fOutFile << indention << element7 << std::setw(fNW)
553 << std::setprecision(fNP) << zArray[i] << quota <<
" " << element8
554 << std::setw(3) << i << quota <<
" " << element9 << std::setw(fNW)
555 << std::setprecision(fNP) << xoffsetArray[i] << quota <<
" "
556 << element10 << std::setw(fNW) << std::setprecision(fNP)
557 << yoffsetArray[i] << quota <<
" " << element11 << std::setw(fNW)
558 << std::setprecision(fNP) << scaleArray[i] << element6
563 fOutFile << fIndention << element12 << std::endl << std::endl;
568 delete[] xoffsetArray;
569 delete[] yoffsetArray;
574void XmlVGM::GDMLWriter::WriteHype(std::string name,
const VGM::IHype* hype)
591 std::string quota =
"\"";
592 std::string element1 =
"<hype lunit=\"cm\" aunit=\"degree\"";
593 std::string element2 =
"name=\"" + name + quota;
594 std::string element3 =
"rmin=\"";
595 std::string element4 =
"rmax=\"";
596 std::string element5 =
"inst=\"";
597 std::string element6 =
"outst=\"";
598 std::string element7 =
"z=\"";
599 std::string element8 =
"\" />";
600 std::string indention = fIndention + fkBasicIndention;
603 fOutFile << fIndention << element1 << std::endl
604 << indention << element2 << std::endl
605 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
606 << rin << quota <<
" " << element4 << std::setw(fNW)
607 << std::setprecision(fNP) << rout << quota << std::endl
608 << indention << element5 << std::setw(fNW) << std::setprecision(fNP)
609 << stereoin << quota <<
" " << element6 << std::setw(fNW)
610 << std::setprecision(fNP) << stereoout << quota << std::endl
611 << indention << element7 << std::setw(fNW) << std::setprecision(fNP)
612 << dz << element8 << std::endl
617void XmlVGM::GDMLWriter::WriteMultiUnion(
623 std::vector<std::string> constNames;
624 for (
int i = 0; i < multiUnion->
NofSolids(); ++i) {
627 std::string constName =
629 WriteSolid(constName, constSolid,
"");
630 constName =
UpdateName(constName, fgkSolidNameExtension);
631 constNames.push_back(constName);
636 std::string element1 =
"<multiUnion name=\"";
637 std::string element2 =
"\">";
638 std::string element3 =
"<multiUnionNode name=\"node-";
639 std::string element4 =
"<solid ref=\"";
640 std::string element5 =
"\" />";
641 std::string element6 =
"<positionref ref=\"";
642 std::string element7 =
"<rotationref ref=\"";
643 std::string element8 =
"</multiUnionNode>";
644 std::string element9 =
"</multiUnion>";
647 fOutFile << fIndention << element1 << name << element2 << std::endl;
649 std::string indention = fIndention + fkBasicIndention;
650 std::string indention2 = indention + fkBasicIndention;
653 for (
int i = 0; i < multiUnion->
NofSolids(); ++i) {
654 fOutFile << indention << element3 << i << element2 << std::endl
655 << indention2 << element4 << constNames[i] << element5
659 std::string positionRef =
661 std::string rotationRef =
664 if (positionRef.size()) {
665 fOutFile << indention2 << element6 << positionRef << element5
669 if (rotationRef.size()) {
670 fOutFile << indention2 << element7 << rotationRef << element5
673 fOutFile << indention << element8 << std::endl;
675 fOutFile << fIndention << element9 << std::endl << std::endl;
679void XmlVGM::GDMLWriter::WritePara(std::string name,
const VGM::IPara* para)
687 double alpha = para->
Alpha() / AngleUnit();
688 double theta = UpdateAngle(para->
Theta()) / AngleUnit();
689 double phi = UpdateAngle(para->
Phi()) / AngleUnit();
699 std::string quota =
"\"";
700 std::string element1 =
"<para lunit=\"cm\" aunit=\"degree\"";
701 std::string element2 =
"name=\"" + name + quota;
702 std::string element3 =
"x=\"";
703 std::string element4 =
"y=\"";
704 std::string element5 =
"z=\"";
705 std::string element6 =
"alpha=\"";
706 std::string element7 =
"theta=\"";
707 std::string element8 =
"phi=\"";
708 std::string element9 =
"\" />";
709 std::string indention = fIndention + fkBasicIndention;
712 fOutFile << fIndention << element1 << std::endl
713 << indention << element2 << std::endl
714 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
715 << dx << quota <<
" " << element4 << std::setw(fNW)
716 << std::setprecision(fNP) << dy << quota <<
" " << element5
717 << std::setw(fNW) << std::setprecision(fNP) << dz << quota
719 << indention << element6 << std::setw(fNW) << std::setprecision(fNP)
720 << alpha << quota <<
" " << element7 << std::setw(fNW)
721 << std::setprecision(fNP) << theta << quota <<
" " << element8
722 << std::setw(fNW) << std::setprecision(fNP) << phi << element9
728void XmlVGM::GDMLWriter::WriteParaboloid(
735 double rhi = paraboloid->
RadiusPlusZ() / LengthUnit();
736 double dz = paraboloid->
ZHalfLength() / LengthUnit();
753 std::string quota =
"\"";
754 std::string element1 =
"<paraboloid lunit=\"cm\" aunit=\"degree\"";
755 std::string element2 =
"name=\"" + name + quota;
756 std::string element3 =
"rlo=\"";
757 std::string element4 =
"rhi=\"";
758 std::string element5 =
"dz=\"";
759 std::string element6 =
"\" />";
760 std::string indention = fIndention + fkBasicIndention;
763 fOutFile << fIndention << element1 << std::endl
764 << indention << element2 << std::endl
765 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
766 << rlo << quota <<
" " << element4 << std::setw(fNW)
767 << std::setprecision(fNP) << rhi << quota <<
" " << element5
768 << std::setw(fNW) << std::setprecision(fNP) << dz << element6
774void XmlVGM::GDMLWriter::WritePolycone(
780 double sphi = polycone->
StartPhi() / AngleUnit();
781 double dphi = polycone->
DeltaPhi() / AngleUnit();
785 double* rminArray =
new double[nofZPlanes];
786 double* rmaxArray =
new double[nofZPlanes];
787 double* zArray =
new double[nofZPlanes];
788 for (
int i = 0; i < nofZPlanes; i++) {
791 zArray[i] = polycone->
ZValues()[i] / LengthUnit();
795 std::string quota =
"\"";
796 std::string element1 =
"<polycone lunit=\"cm\" aunit=\"degree\"";
797 std::string element2 =
"name=\"" + name + quota;
798 std::string element3 =
"startphi=\"";
799 std::string element4 =
"deltaphi=\"";
800 std::string element5 =
"\" >";
801 std::string element6 =
"<zplane z=\"";
802 std::string element7 =
"rmin=\"";
803 std::string element8 =
"rmax=\"";
804 std::string element9 =
"\" />";
805 std::string element10 =
"</polycone>";
806 std::string indention = fIndention + fkBasicIndention;
809 fOutFile << fIndention << element1 << std::endl
810 << indention << element2 << std::endl
811 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
812 << sphi << quota <<
" " << element4 << std::setw(fNW)
813 << std::setprecision(fNP) << dphi << element5 << std::endl;
816 for (
int j = 0; j < nofZPlanes; j++) {
818 fOutFile << indention << element6 << std::setw(fNW)
819 << std::setprecision(fNP) << zArray[j] << quota <<
" " << element7
820 << std::setw(fNW) << std::setprecision(fNP) << rminArray[j]
821 << quota <<
" " << element8 << std::setw(fNW)
822 << std::setprecision(fNP) << rmaxArray[j] << element9 << std::endl;
826 fOutFile << fIndention << element10 << std::endl << std::endl;
834void XmlVGM::GDMLWriter::WritePolyhedra(
840 double sphi = UpdateAngle(polyhedra->
StartPhi()) / AngleUnit();
841 double dphi = UpdateAngle(polyhedra->
DeltaPhi()) / AngleUnit();
845 int nofSides = polyhedra->
NofSides();
846 double* rminArray =
new double[nofZPlanes];
847 double* rmaxArray =
new double[nofZPlanes];
848 double* zArray =
new double[nofZPlanes];
849 for (
int i = 0; i < nofZPlanes; i++) {
852 zArray[i] = polyhedra->
ZValues()[i] / LengthUnit();
856 std::string quota =
"\"";
857 std::string element1 =
"<polyhedra lunit=\"cm\" aunit=\"degree\"";
858 std::string element2 =
"name=\"" + name + quota;
859 std::string element3 =
"numsides=\"";
860 std::string element4 =
"startphi=\"";
861 std::string element5 =
"deltaphi=\"";
862 std::string element6 =
"\" >";
863 std::string element7 =
"<zplane z=\"";
864 std::string element8 =
"rmin=\"";
865 std::string element9 =
"rmax=\"";
866 std::string element10 =
"\" />";
867 std::string element11 =
"</polyhedra>";
868 std::string indention = fIndention + fkBasicIndention;
871 fOutFile << fIndention << element1 << std::endl
872 << indention << element2 << std::endl
873 << indention << element3 << nofSides << quota << std::endl
874 << indention << element4 << std::setw(fNW) << std::setprecision(fNP)
875 << sphi << quota <<
" " << element5 << std::setw(fNW)
876 << std::setprecision(fNP) << dphi << element6 << std::endl;
879 for (
int j = 0; j < nofZPlanes; j++) {
881 fOutFile << indention << element7 << std::setw(fNW)
882 << std::setprecision(fNP) << zArray[j] << quota <<
" " << element8
883 << std::setw(fNW) << std::setprecision(fNP) << rminArray[j]
884 << quota <<
" " << element9 << std::setw(fNW)
885 << std::setprecision(fNP) << rmaxArray[j] << element10
890 fOutFile << fIndention << element11 << std::endl << std::endl;
898void XmlVGM::GDMLWriter::WriteSphere(
904 double rmin = sphere->
InnerRadius() / LengthUnit();
905 double rmax = sphere->
OuterRadius() / LengthUnit();
906 double sphi = UpdateAngle(sphere->
StartPhi()) / AngleUnit();
907 double dphi = UpdateAngle(sphere->
DeltaPhi()) / AngleUnit();
908 double stheta = UpdateAngle(sphere->
StartTheta()) / AngleUnit();
909 double dtheta = UpdateAngle(sphere->
DeltaTheta()) / AngleUnit();
912 std::string quota =
"\"";
913 std::string element1 =
"<sphere lunit=\"cm\" aunit=\"degree\"";
914 std::string element2 =
"name=\"" + name + quota;
915 std::string element3 =
"rmin=\"";
916 std::string element4 =
"rmax=\"";
917 std::string element5 =
"startphi=\"";
918 std::string element6 =
"deltaphi=\"";
919 std::string element7 =
"starttheta=\"";
920 std::string element8 =
"deltatheta=\"";
921 std::string element9 =
"\" />";
922 std::string indention = fIndention + fkBasicIndention;
925 fOutFile << fIndention << element1 << std::endl
926 << indention << element2 << std::endl
927 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
928 << rmin << quota <<
" " << element4 << std::setw(fNW)
929 << std::setprecision(fNP) << rmax << quota << std::endl
930 << indention << element5 << std::setw(fNW) << std::setprecision(fNP)
931 << sphi << quota <<
" " << element6 << std::setw(fNW)
932 << std::setprecision(fNP) << dphi << quota <<
" " << element7
933 << std::setw(fNW) << std::setprecision(fNP) << stheta << quota
934 <<
" " << element8 << std::setw(fNW) << std::setprecision(fNP)
935 << dtheta << element9 << std::endl
940void XmlVGM::GDMLWriter::WriteTessellatedSolid(
946 std::string quota =
"\"";
947 std::string element1 =
"<tessellated name=\"" + name +
"\">";
948 std::string element2 =
"<triangular ";
949 std::string element3 =
"<quadrangular ";
950 std::string element4 =
" vertex";
951 std::string element5 =
"=\"";
952 std::string element6 =
"/>";
953 std::string element8 =
"</tessellated>";
954 std::string indention = fIndention + fkBasicIndention;
957 fOutFile << fIndention << element1 << std::endl;
960 for (
int i = 0; i < tessellated->
NofFacets(); ++i) {
962 if (nofVertices == 3)
963 fOutFile << indention << element2;
965 fOutFile << indention << element3;
967 for (
int j = 0; j < nofVertices; ++j) {
970 std::string positionRef = fMaps->FindPositionName(vertex);
972 fOutFile << element4 << std::setw(1) << j + 1 << element5 << positionRef
975 fOutFile << element6 << std::endl;
979 fOutFile << fIndention << element8 << std::endl << std::endl;
983void XmlVGM::GDMLWriter::WriteTorus(std::string name,
const VGM::ITorus* torus)
991 double sphi = UpdateAngle(torus->
StartPhi()) / AngleUnit();
992 double dphi = UpdateAngle(torus->
DeltaPhi()) / AngleUnit();
995 std::string quota =
"\"";
996 std::string element1 =
"<torus lunit=\"cm\" aunit=\"degree\"";
997 std::string element2 =
"name=\"" + name + quota;
998 std::string element3 =
"rmin=\"";
999 std::string element4 =
"rmax=\"";
1000 std::string element5 =
"rtor=\"";
1001 std::string element6 =
"startphi=\"";
1002 std::string element7 =
"deltaphi=\"";
1003 std::string element8 =
"\" />";
1004 std::string indention = fIndention + fkBasicIndention;
1007 fOutFile << fIndention << element1 << std::endl
1008 << indention << element2 << std::endl
1009 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
1010 << rmin << quota <<
" " << element4 << std::setw(fNW)
1011 << std::setprecision(fNP) << rmax << quota <<
" " << element5
1012 << std::setw(fNW) << std::setprecision(fNP) << rax << quota
1014 << indention << element6 << std::setw(fNW) << std::setprecision(fNP)
1015 << sphi << quota <<
" " << element7 << std::setw(fNW)
1016 << std::setprecision(fNP) << dphi << element8 << std::endl
1021void XmlVGM::GDMLWriter::WriteTrap(std::string name,
const VGM::ITrap* trap)
1027 double theta = UpdateAngle(trap->
Theta()) / AngleUnit();
1028 double phi = UpdateAngle(trap->
Phi()) / AngleUnit();
1032 double alpha1 = trap->
AlphaMinusZ() / AngleUnit();
1036 double alpha2 = trap->
AlphaPlusZ() / AngleUnit();
1050 std::string quota =
"\"";
1051 std::string element1 =
"<trap lunit=\"cm\" aunit=\"degree\"";
1052 std::string element2 =
"name=\"" + name + quota;
1053 std::string element3 =
"z=\"";
1054 std::string element4 =
"theta=\"";
1055 std::string element5 =
"phi=\"";
1056 std::string element6 =
"y1=\"";
1057 std::string element7 =
"x1=\"";
1058 std::string element8 =
"x2=\"";
1059 std::string element9 =
"alpha1=\"";
1060 std::string element10 =
"y2=\"";
1061 std::string element11 =
"x3=\"";
1062 std::string element12 =
"x4=\"";
1063 std::string element13 =
"alpha2=\"";
1064 std::string element14 =
"\" />";
1065 std::string indention = fIndention + fkBasicIndention;
1068 fOutFile << fIndention << element1 << std::endl
1069 << indention << element2 << std::endl
1070 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
1071 << dz << quota << std::endl
1072 << indention << element4 << std::setw(fNW) << std::setprecision(fNP)
1073 << theta << quota <<
" " << element5 << std::setw(fNW)
1074 << std::setprecision(fNP) << phi << quota << std::endl
1075 << indention << element6 << std::setw(fNW) << std::setprecision(fNP)
1076 << y1 << quota <<
" " << element7 << std::setw(fNW)
1077 << std::setprecision(fNP) << x1 << quota <<
" " << element8
1078 << std::setw(fNW) << std::setprecision(fNP) << x2 << quota <<
" "
1079 << element9 << std::setw(fNW) << std::setprecision(fNP) << alpha1
1080 << quota << std::endl
1081 << indention << element10 << std::setw(fNW) << std::setprecision(fNP)
1082 << y2 << quota <<
" " << element11 << std::setw(fNW)
1083 << std::setprecision(fNP) << x3 << quota <<
" " << element12
1084 << std::setw(fNW) << std::setprecision(fNP) << x4 << quota <<
" "
1085 << element13 << std::setw(fNW) << std::setprecision(fNP) << alpha2
1086 << element14 << std::endl
1091void XmlVGM::GDMLWriter::WriteTrd(std::string name,
const VGM::ITrd* trd)
1112 std::string quota =
"\"";
1113 std::string element1 =
"<trd lunit=\"cm\" aunit=\"degree\"";
1114 std::string element2 =
"name=\"" + name + quota;
1115 std::string element3 =
"x1=\"";
1116 std::string element4 =
"x2=\"";
1117 std::string element5 =
"y1=\"";
1118 std::string element6 =
"y2=\"";
1119 std::string element7 =
"z=\"";
1120 std::string element8 =
"\" />";
1121 std::string indention = fIndention + fkBasicIndention;
1124 fOutFile << fIndention << element1 << std::endl
1125 << indention << element2 << std::endl
1126 << indention << element3 << std::setw(fNW) << std::setprecision(fNP)
1127 << x1 << quota <<
" " << element4 << std::setw(fNW)
1128 << std::setprecision(fNP) << x2 << quota <<
" " << element5
1129 << std::setw(fNW) << std::setprecision(fNP) << y1 << quota <<
" "
1130 << element6 << std::setw(fNW) << std::setprecision(fNP) << y2
1131 << quota << std::endl
1132 << indention << element7 << std::setw(fNW) << std::setprecision(fNP)
1133 << hz << element8 << std::endl
1138void XmlVGM::GDMLWriter::WriteTubs(std::string name,
const VGM::ITubs* tubs)
1146 double sphi = UpdateAngle(tubs->
StartPhi()) / AngleUnit();
1147 double dphi = UpdateAngle(tubs->
DeltaPhi()) / AngleUnit();
1155 std::string quota =
"\"";
1156 std::string element1 =
"<tube lunit=\"cm\" aunit=\"degree\"";
1157 std::string element2 =
"name=\"" + name + quota;
1158 std::string element3 =
"z=\"";
1159 std::string element4 =
"rmin=\"";
1160 std::string element5 =
"rmax=\"";
1161 std::string element6 =
"startphi=\"";
1162 std::string element7 =
"deltaphi=\"";
1163 std::string element8 =
"\" />";
1164 std::string indention = fIndention + fkBasicIndention;
1167 fOutFile << fIndention << element1 << std::endl
1168 << indention << element2 << std::endl
1169 << indention << element4 << std::setw(fNW) << std::setprecision(fNP)
1170 << rmin << quota <<
" " << element5 << std::setw(fNW)
1171 << std::setprecision(fNP) << rmax << quota <<
" " << element3
1172 << std::setw(fNW) << std::setprecision(fNP) << hz << quota
1174 << indention << element6 << std::setw(fNW) << std::setprecision(fNP)
1175 << sphi << quota <<
" " << element7 << std::setw(fNW)
1176 << std::setprecision(fNP) << dphi << element8 << std::endl
1181void XmlVGM::GDMLWriter::WriteNotSupportedSolid(std::string name)
1187 std::string element1 =
"<!-- !!! unsupported shape !!! name= \"";
1188 std::string element2 =
"\" -->";
1189 std::string element3 =
"<!-- dummy box is written instead -->";
1192 fOutFile << fIndention << element1 << name << element2 << std::endl
1193 << fIndention << element3 << std::endl;
1196 WriteBox(name, 1.0, 1.0, 1.0);
1200void XmlVGM::GDMLWriter::WriteSimplePlacement(
const std::string& volumeName,
1201 const std::string& positionRef,
const std::string& rotationRef,
1211 std::string element0 =
"\"/>";
1212 std::string element1 =
"<physvol>";
1214 std::string element2 =
"<volumeref ref=\"";
1215 element2.append(name);
1216 element2.append(element0);
1218 std::string element3 =
"<positionref ref=\"";
1219 element3.append(positionRef);
1220 element3.append(element0);
1222 std::string element4 =
"<rotationref ref=\"";
1223 element4.append(rotationRef);
1224 element4.append(element0);
1226 std::string element5 =
"<scaleref ref=\"";
1227 element5.append(std::string(
"scale_0"));
1228 element5.append(element0);
1230 std::string element6 =
"</physvol>";
1232 std::string indention1 = fIndention + fkBasicIndention;
1233 std::string indention2 = fIndention + fkBasicIndention + fkBasicIndention;
1236 fOutFile << fIndention << element1 << std::endl
1237 << indention1 << element2 << std::endl
1238 << indention2 << element3 << std::endl
1239 << indention2 << element4 << std::endl;
1241 if (isReflection) fOutFile << indention2 << element5 << std::endl;
1243 fOutFile << fIndention << element6 << std::endl;
1247void XmlVGM::GDMLWriter::WriteMultiplePlacement(
const std::string& volumeName,
1248 VGM::Axis axis,
int nofReplicas,
double width,
double offset)
1252 std::string axisName;
1255 axisName =
"kXAxis";
1258 axisName =
"kYAxis";
1261 axisName =
"kZAxis";
1270 axisName =
"Undefined";
1273 axisName =
"Undefined";
1276 axisName =
"Undefined";
1285 width2 = width / LengthUnit();
1286 offset2 = offset / LengthUnit();
1290 width2 = width / AngleUnit();
1291 offset2 = offset / AngleUnit();
1298 std::string quota =
"\"";
1299 std::string element1 =
"<divisionvol unit=\"";
1300 std::string element2 =
"axis=\"";
1301 std::string element3 =
"number=\"";
1302 std::string element4 =
"offset=\"";
1303 std::string element5 =
"width=\"";
1304 std::string element6 =
"\">";
1306 std::string element7 =
"<volumeref ref=\"";
1307 std::string element8 =
"\"/>";
1308 std::string element9 =
"</divisionvol>";
1310 std::string indention1 = fIndention + fkBasicIndention;
1313 fOutFile << fIndention << element1 << unit << quota << std::endl
1314 << indention1 << element2 << axisName + quota <<
" " << element3
1315 << nofReplicas << quota <<
" " << element4 << std::setw(fNW + 1)
1316 << std::setprecision(fNP) << offset2 << quota <<
" " << element5
1317 << std::setw(fNW + 1) << std::setprecision(fNP) << width2 << element6
1319 << indention1 << element7 << volumeName << element8 << std::endl
1320 << fIndention << element9 << std::endl;
1332 fOutFile.open(filePath.data(), std::ios::out);
1335 std::cerr <<
" Cannot open " << filePath << std::endl;
1336 std::cerr <<
"** Exception: Aborting execution **" << std::endl;
1341 fOutFile.setf(std::ios::fixed, std::ios::floatfield);
1350 fOutFile <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" \?>"
1352 <<
"<gdml xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
1353 "xsi:noNamespaceSchemaLocation=\""
1355 <<
"http://service-spi.web.cern.ch/service-spi/app/releases/GDML/"
1356 "schema/gdml.xsd\">"
1374 std::string element1 =
"<define>";
1377 fOutFile << fIndention << element1 << std::endl;
1380 IncreaseIndention();
1395 std::string element =
"<materials>";
1398 fOutFile << fIndention << element << std::endl;
1401 IncreaseIndention();
1409 std::string element =
"<solids>";
1412 fOutFile << fIndention << element << std::endl;
1415 IncreaseIndention();
1423 std::string element =
"<structure>";
1426 fOutFile << fIndention << element << std::endl;
1429 IncreaseIndention();
1434 const std::string& name,
const std::string& materialName)
1440 std::string matName =
UpdateName(materialName);
1441 std::string sldName =
UpdateName(name, fgkSolidNameExtension);
1444 RegisterName(volName);
1446 std::string element1 =
"<volume name=\"";
1447 element1.append(volName);
1448 element1.append(
"\">");
1450 std::string element2 =
"<materialref ref=\"";
1451 element2.append(matName);
1452 element2.append(
"\"/>");
1454 std::string element3 =
"<solidref ref=\"";
1455 element3.append(sldName);
1456 element3.append(
"\"/>");
1458 std::string indention = fIndention + fkBasicIndention;
1461 fOutFile << fIndention << element1 << std::endl
1462 << indention << element2 << std::endl
1463 << indention << element3 << std::endl;
1466 IncreaseIndention();
1482 fOutFile <<
"</gdml>" << std::endl;
1492 std::string quota =
"\"";
1493 std::string element2 =
"<setup name=\"";
1494 element2.append(fUnitName);
1495 element2.append(quota);
1497 std::string element3 =
"version=\"";
1498 element3.append(fVersion);
1499 element3.append(quota);
1501 std::string element4 =
"<world ref=\"";
1502 element4.append(topVolume);
1503 element4.append(quota);
1505 std::string element5 =
"</setup>";
1506 std::string indention = fIndention + fkBasicIndention;
1510 fOutFile << fIndention << element2 << fkBasicIndention << element3 <<
">"
1512 << indention << element4 <<
"/>" << std::endl
1513 << fIndention << element5 << std::endl
1531 DecreaseIndention();
1533 std::string element1 =
"</define>";
1536 fOutFile << fIndention << element1 << std::endl;
1545 DecreaseIndention();
1548 std::string element =
"</materials>";
1551 fOutFile << fIndention << element << std::endl;
1560 DecreaseIndention();
1562 std::string element1 =
"</solids>";
1565 fOutFile << fIndention << element1 << std::endl;
1574 DecreaseIndention();
1576 std::string element =
"</structure>";
1579 fOutFile << fIndention << element << std::endl;
1588 DecreaseIndention();
1591 std::string element =
"</volume>";
1594 fOutFile << fIndention << element << std::endl;
1603 name.append(fgkIsotopeNameExtension);
1607 int theZ = isotope->
Z();
1608 int theN = isotope->
N();
1609 double theA = isotope->
A() / AtomicWeightUnit();
1613 if (theN == 0) theN = 1;
1616 std::string quota1 =
"\"";
1617 std::string quota2 =
"\" ";
1618 std::string element1 =
"<isotope name=\"";
1620 std::string element2 =
"Z=\"";
1621 std::string element3 =
"N=\"";
1622 std::string element4 =
"<atom type=\"A\" unit=\"g/mol\" value=\"";
1623 std::string element5 =
"\" />";
1624 std::string element6 =
"</isotope>";
1626 std::string indention = fIndention + fkBasicIndention;
1629 fOutFile << fIndention << element1 << name << quota1;
1630 for (
int i = 0; i < 10 - int(name.size()); i++) fOutFile <<
" ";
1632 SmartPut(fOutFile, fNW - 2, fNP, 0, element2, theZ, quota2);
1636 fOutFile << element3 << std::setw(3) << theN <<
"\" >" << std::endl;
1638 fOutFile << indention;
1639 SmartPut(fOutFile, fNW - 2, fNP, 0, element4, theA, element5);
1640 fOutFile << std::endl;
1642 fOutFile << fIndention << element6 << std::endl;
1650 std::string name =
UpdateName(element->
Name(), fgkElementNameExtension);
1654 std::string quota1 =
"\"";
1655 std::string quota2 =
"\" ";
1656 std::string element1 =
"<element name=\"";
1657 std::string element6 =
"\" />";
1658 std::string element7 =
"</element>";
1660 std::string indention = fIndention + fkBasicIndention;
1663 fOutFile << fIndention << element1 << name << quota2;
1668 std::string element2 =
">";
1669 std::string element3 =
"<fraction n=\"";
1670 std::string element4 =
"ref=\"";
1672 fOutFile << element2 << std::endl;
1673 for (
int i = 0; i < element->
NofIsotopes(); i++) {
1676 name2.append(fgkIsotopeNameExtension);
1679 fOutFile << indention;
1680 SmartPut(fOutFile, fNW - 2, fNP, 0, element3, natoms, quota2);
1681 fOutFile << element4 << name2 << element6 << std::endl;
1685 double theZ = element->
Z();
1687 double theA = element->
A() / AtomicWeightUnit();
1691 if (theZ == 0) theZ = 1;
1692 if (theN == 0) theN = 1;
1694 std::string element3 =
"Z=\"";
1695 std::string element4 =
"N=\"";
1696 std::string element5 =
"<atom type=\"A\" unit=\"g/mol\" value=\"";
1698 SmartPut(fOutFile, fNW - 2, fNP, 0, element3, theZ, quota2);
1701 fOutFile << element4 << std::setw(3) << theN <<
"\" >" << std::endl;
1703 fOutFile << indention;
1704 SmartPut(fOutFile, fNW - 2, fNP, 0, element5, theA, element6);
1705 fOutFile << std::endl;
1708 fOutFile << fIndention << element7 << std::endl;
1717 RegisterName(materialName);
1720 double density = material->
Density() / MassDensityUnit();
1722 switch (material->
State()) {
1734 state =
"undefined";
1736 double temperature = material->
Temperature() / TemperatureUnit();
1737 double pressure = material->
Pressure() / PressureUnit();
1740 std::string quota =
"\" ";
1741 std::string element1 =
"<material name=\"";
1742 element1.append(materialName);
1743 element1.append(quota);
1745 std::string element2 =
"state=\"";
1746 element2.append(state);
1747 element2.append(quota);
1748 element2.append(
">");
1750 std::string element3 =
"<D type=\"density\" unit=\"g/cm3\" value=\"";
1751 std::string element4 =
"<T type=\"temperature\" unit=\"K\" value=\"";
1752 std::string element5 =
"<P type=\"pressure\" unit=\"pascal\" value=\"";
1753 std::string element6 =
"<fraction n=\"";
1754 std::string element7 =
"ref=\"";
1755 std::string element8 =
"\"/>";
1756 std::string element9 =
"</material>";
1758 std::string indention = fIndention + fkBasicIndention;
1761 fOutFile << fIndention << element1 << element2 << std::endl;
1763 fOutFile << indention;
1764 SmartPut(fOutFile, fNW + 1, fNP, 0, element3, density, element8);
1765 fOutFile << std::endl;
1767 if (temperature != fgkSTPTemperature) {
1768 fOutFile << indention;
1769 SmartPut(fOutFile, fNW + 1, fNP, 0, element4, temperature, element8);
1770 fOutFile << std::endl;
1773 if (pressure != fgkSTPPressure) {
1774 fOutFile << indention;
1775 SmartPut(fOutFile, fNW + 1, fNP, 0, element5, pressure, element8);
1776 fOutFile << std::endl;
1779 for (
int i = 0; i < int(material->
NofElements()); i++) {
1781 std::string elementName =
1784 fOutFile << indention;
1785 SmartPut(fOutFile, fNW, fNP, 0, element6, fraction, quota);
1786 fOutFile << element7 << elementName << element8 << std::endl;
1789 fOutFile << fIndention << element9 << std::endl;
1799 std::string solidName =
UpdateName(volumeName, fgkSolidNameExtension);
1800 RegisterName(solidName);
1805 WriteArb8(solidName, arb8);
1810 WriteBox(solidName, box);
1815 WriteCons(solidName, cons);
1820 WriteCtubs(solidName, ctubs);
1826 WriteEllipsoid(solidName, ellipsoid);
1832 WriteEllipticalTube(solidName, eltu);
1838 WriteExtrudedSolid(solidName, extruded);
1843 WriteHype(solidName, hype);
1848 WritePara(solidName, para);
1854 WriteParaboloid(solidName, paraboloid);
1859 WritePolycone(solidName, polycone);
1865 WritePolyhedra(solidName, polyhedra);
1870 WriteSphere(solidName, sphere);
1876 WriteTessellatedSolid(solidName, tessellated);
1881 WriteTorus(solidName, torus);
1886 WriteTrap(solidName, trap);
1891 WriteTrd(solidName, trd);
1896 WriteTubs(solidName, tubs);
1902 WriteBooleanSolid(solidName,
boolean);
1908 WriteMultiUnion(solidName, multiUnion);
1913 WriteNotSupportedSolid(solidName);
1923 double x = transform[
VGM::kDx] / LengthUnit();
1924 double y = transform[
VGM::kDy] / LengthUnit();
1925 double z = transform[
VGM::kDz] / LengthUnit();
1928 std::string quota1 =
"\"";
1929 std::string quota2 =
"\" ";
1930 std::string element1 =
"<position name=";
1931 std::string posName =
AppendName(quota1 + name + quota1, 12);
1933 std::string element2 =
"x=\"";
1934 std::string element3 =
"y=\"";
1935 std::string element4 =
"z=\"";
1936 std::string element5 =
"\" unit=\"cm\" />";
1939 fOutFile << fIndention << element1 << posName;
1941 SmartPut(fOutFile, fNW + 1, fNP, fgkCarTolerance, element2, x, quota2);
1942 SmartPut(fOutFile, fNW + 1, fNP, fgkCarTolerance, element3, y, quota2);
1943 SmartPut(fOutFile, fNW + 1, fNP, fgkCarTolerance, element4, z,
"");
1945 fOutFile << element5 << std::endl;
1957 double angleX = invTransform[
VGM::kAngleX] / AngleUnit();
1958 double angleY = invTransform[
VGM::kAngleY] / AngleUnit();
1959 double angleZ = invTransform[
VGM::kAngleZ] / AngleUnit();
1962 std::string quota1 =
"\"";
1963 std::string quota2 =
"\" ";
1964 std::string element1 =
"<rotation name=";
1965 std::string rotName =
AppendName(quota1 + name + quota1, 12);
1967 std::string element2 =
"x=\"";
1968 std::string element3 =
"y=\"";
1969 std::string element4 =
"z=\"";
1970 std::string element5 =
"\" unit=\"degree\" />";
1973 fOutFile << fIndention << element1 << rotName;
1975 SmartPut(fOutFile, fNW + 1, fNP, fgkAngTolerance, element2, angleX, quota2);
1976 SmartPut(fOutFile, fNW + 1, fNP, fgkAngTolerance, element3, angleY, quota2);
1977 SmartPut(fOutFile, fNW + 1, fNP, fgkAngTolerance, element4, angleZ,
"");
1979 fOutFile << element5 << std::endl;
1988 double scaleX = 1.0;
1989 double scaleY = 1.0;
1990 double scaleZ = -1.0;
1993 std::string quota1 =
"\"";
1994 std::string quota2 =
"\" ";
1995 std::string element1 =
"<scale name=";
1996 std::string rotName =
AppendName(quota1 + name + quota1, 12);
1998 std::string element2 =
"x=\"";
1999 std::string element3 =
"y=\"";
2000 std::string element4 =
"z=\"";
2001 std::string element5 =
"\" />";
2004 fOutFile << fIndention << element1 << rotName;
2006 SmartPut(fOutFile, fNW + 1, fNP, 0, element2, scaleX, quota2);
2007 SmartPut(fOutFile, fNW + 1, fNP, 0, element3, scaleY, quota2);
2008 SmartPut(fOutFile, fNW + 1, fNP, 0, element4, scaleZ,
"");
2010 fOutFile << element5 << std::endl;
2025 std::string positionRef = fMaps->FindPositionName(transform);
2028 std::string rotationRef = fMaps->FindRotationName(transform);
2047 WriteSimplePlacement(
2048 placement.
Volume()->
Name(), positionRef, rotationRef, isReflection);
2060 if (halfGap != 0.) {
2061 std::cerr <<
"+++ Warning +++" << std::endl;
2062 std::cerr <<
" XmlVGM::Writer::WritePlacement: " << std::endl;
2063 std::cerr <<
" Multiple placement with a half gap is not supported. "
2065 std::cerr <<
" The half gap parameter will be ignored. " << std::endl;
2069 WriteMultiplePlacement(
2070 placement.
Volume()->
Name(), axis, nReplicas, width, offset);
2075 std::vector<VGM::Transform> transforms;
2076 std::vector<VGM::IVolume*> volumes;
2080 for (
size_t i=0; i<transforms.size(); ++i) {
2082 auto transform = transforms[i];
2085 std::string positionRef = fMaps->FindPositionName(transform);
2086 std::string rotationRef = fMaps->FindRotationName(transform);
2090 auto volumeName = volumes[i]->Name();
2092 WriteSimplePlacement(
2093 volumeName, positionRef, rotationRef, isReflection);
2097 std::cerr <<
"+++ Warning +++" << std::endl;
2098 std::cerr <<
" XmlVGM::GDMLExporter::ProcessVolume: " << std::endl;
2099 std::cerr <<
" Unknown placement type. " << std::endl;
2100 std::cerr <<
" Volume \"" << placement.
Name() <<
"\" was not converted."
2110 fOutFile << std::endl;
2118 fIndention.append(fkBasicIndention);
2126 fIndention.replace(fIndention.find(fkBasicIndention), 3,
"");
The VGM interface to Arb8 solids.
virtual double ZHalfLength() const =0
Return the half-length along the z axis in mm.
virtual int NofVertices() const =0
Return the number of vertices.
virtual TwoVector Vertex(int index) const =0
Return the index-th vertex.
The VGM interface to Boolean solids.
virtual ISolid * ConstituentSolidB() const =0
Return the second constituent solid.
virtual bool ToBeReflected() const =0
Return true if the solid has to be first reflected before being placed.
virtual ISolid * ConstituentSolidA() const =0
Return the first constituent solid.
virtual BooleanType BoolType() const =0
Return the Boolean type of this solid.
virtual Transform Displacement() const =0
Return the 3D displacement of the second constituent solid with respect to the first one.
The VGM interface to box solids.
virtual double ZHalfLength() const =0
Return the half-length along the z axis in mm.
virtual double YHalfLength() const =0
Return the half-length along the y axis in mm.
virtual double XHalfLength() const =0
Return the half-length along the x axis in mm.
The VGM interface to cons solids.
virtual double DeltaPhi() const =0
Return the opening phi angle of the segment in deg.
virtual double OuterRadiusPlusZ() const =0
Return the outer radius at -z in mm.
virtual double OuterRadiusMinusZ() const =0
Return the outer radius at -z in mm.
virtual double ZHalfLength() const =0
Return the half-length along the z axis in mm.
virtual double InnerRadiusMinusZ() const =0
Return the innner radius at -z in mm.
virtual double InnerRadiusPlusZ() const =0
Return the innner radius at +z in mm.
virtual double StartPhi() const =0
Return the starting phi angle of the segment in deg.
The VGM interface to cut tubs solids.
virtual double OuterRadius() const =0
Return the outside radius in mm.
virtual double NxHigh() const =0
X-component of the normal unit vector to the cut plane in +z.
virtual double ZHalfLength() const =0
Return the half-length along the z axis in m.
virtual double DeltaPhi() const =0
Return the opening angle of the segment in deg.
virtual double NyLow() const =0
Y-component of the normal unit vector to the cut plane in -z.
virtual double NzLow() const =0
Z-component of the normal unit vector to the cut plane in -z.
virtual double NzHigh() const =0
Z-component of the normal unit vector to the cut plane in +z.
virtual double InnerRadius() const =0
Return the inside radius in mm.
virtual double StartPhi() const =0
Return the starting angle of the segment in deg.
virtual double NxLow() const =0
X-component of the normal unit vector to the cut plane in -z.
virtual double NyHigh() const =0
Y-component of the normal unit vector to the cut plane in +z.
The VGM interface to elements.
virtual IIsotope * Isotope(int i) const =0
Return the i-th isotope constituing this element.
virtual int NofIsotopes() const =0
Return the number of isotopes constituing this element.
virtual double Z() const =0
Return the effective atomic number.
virtual double RelAbundance(int i) const =0
Return the relative abundance (the fraction of nb of atomes per volume) of the i-th isotope constitui...
virtual std::string Name() const =0
Return the name of this element.
virtual double A() const =0
Return the effective effective mass of a mole in g/mole.
virtual double N() const =0
Return the effective number of nucleons.
The VGM interface to ellipsoid solids.
virtual double ZBottomCut() const =0
Return the z bottom cut in mm.
virtual double ZSemiAxis() const =0
Return the semi-axis of the ellipse along z in mm.
virtual double ZTopCut() const =0
Return the z top cut in mm.
virtual double XSemiAxis() const =0
Return the semi-axis of the ellipse along x in mm.
virtual double YSemiAxis() const =0
Return the semi-axis of the ellipse along y in mm.
The VGM interface to elliptical tube solids.
virtual double Dx() const =0
Return the semi-axis of the ellipse along x in mm.
virtual double ZHalfLength() const =0
Return the half-length along the z axis in mm.
virtual double Dy() const =0
Return the semi-axis of the ellipse along y in mm.
The VGM interface to extruded solids.
virtual TwoVector Offset(int iz) const =0
Return the polygon offset in iz-th side.
virtual int NofZSections() const =0
Return the number of planes perpendicular to the z axis.
virtual double ZPosition(int iz) const =0
Return the z position of the iz-th plane in mm.
virtual int NofVertices() const =0
Return the number of vertices of outline polygon.
virtual TwoVector Vertex(int index) const =0
Return the index-th vertex of outline polygon.
virtual double Scale(int iz) const =0
Return the polygon scale in iz-th side.
The VGM interface to hyperboloid solids.
virtual double ZHalfLength() const =0
Return the half-length along the z axis in mm.
virtual double OuterStereoAngle() const =0
Return the inner stereo angle.
virtual double OuterRadius() const =0
Return the outer radius in mm.
virtual double InnerStereoAngle() const =0
Return the inner stereo angle.
virtual double InnerRadius() const =0
Return the inner radius in mm.
The VGM interface to elements.
virtual int N() const =0
Return the effective number of nucleons.
virtual double A() const =0
Return the effective effective mass of a mole in g/mole.
virtual int Z() const =0
Return the effective atomic number.
The VGM interface to materials.
virtual double Pressure() const =0
Return the density in atmosphere.
virtual IElement * Element(int iel) const =0
Return the i-th element constituing this material.
virtual double Density() const =0
Return the density in g/cm3.
virtual double Temperature() const =0
Return the temperature in kelvins.
virtual std::string Name() const =0
Return the name of this element.
virtual MaterialState State() const =0
Return the material state.
virtual double MassFraction(int iel) const =0
Return the mass fraction of the i-th element constituing this material.
virtual int NofElements() const =0
Return the number of elements constituing this material.
The VGM interface to Boolean solids.
virtual Transform Transformation(int index) const =0
Return the displacement of the ith constituent solid.
virtual int NofSolids() const =0
Return the number of constituent solids.
virtual ISolid * ConstituentSolid(int index) const =0
Return the i-th constituent solid.
The VGM interface to para solids.
virtual double Alpha() const =0
Return angle formed by the y axis and by the plane joining the centre of the faces parallel to the z-...
virtual double Theta() const =0
Return polar angle of the line joining the centres of the faces at -hz and +hz in deg.
virtual double YHalfLength() const =0
Return half-length along the y axis in mm.
virtual double ZHalfLength() const =0
Return half-length along the z axis in mm.
virtual double XHalfLength() const =0
Return half-length along the x axis in mm.
virtual double Phi() const =0
Return azimuthal angle of the line joining the centres of the faces at -hz and +hz in deg.
The VGM interface to paraboloid solids.
virtual double RadiusMinusZ() const =0
Return the radius at -z in mm.
virtual double RadiusPlusZ() const =0
Return the radius at +z in mm.
virtual double ZHalfLength() const =0
Return the half-length along the z axis in mm.
The VGM interface to positions of volumes.
virtual PlacementType Type() const =0
Return the type of this placement.
virtual Transform Transformation() const =0
Return the 3D transformation (if simple placement)
virtual bool MultiplePlacementData(VGM::Axis &axis, int &nofItems, double &width, double &offset, double &halfGap) const =0
Fill the multiple placement data if relevant and return true; return false if not multiple placement.
virtual bool ParameterisedPlacementData(std::vector< VGM::Transform > &transforms, std::vector< VGM::IVolume * > &volumes) const =0
Fill the parameterised placement data if relevant and return true; return false if not parameterised ...
virtual std::string Name() const =0
Return the name of this placement.
virtual IVolume * Volume() const =0
Return the associated volume.
The VGM interface to polycone solids.
virtual double StartPhi() const =0
Return starting phi angle of the segment in deg.
virtual int NofZPlanes() const =0
Return number of planes perpendicular to the z axis.
virtual double * ZValues() const =0
Return the array of z positions of the planes in mm.
virtual double DeltaPhi() const =0
Return opening phi angle of the segment in deg.
virtual double * InnerRadiusValues() const =0
Return the array of inner radius of the planes in mm.
virtual double * OuterRadiusValues() const =0
Return the array of outer radius of the planes in mm.
The VGM interface to polyhedra solids.
virtual double * OuterRadiusValues() const =0
Return the array of outer radius of the planes in mm.
virtual int NofSides() const =0
Return number of sides of the cross section between the given phi limits.
virtual double StartPhi() const =0
Return starting phi angle of the segment in deg.
virtual double * InnerRadiusValues() const =0
Return the array of innner radius of the planes in mm.
virtual double * ZValues() const =0
Return the array of z positions of the planes in mm.
virtual double DeltaPhi() const =0
Return opening phi angle of the segment in deg.
virtual int NofZPlanes() const =0
Return number of planes perpendicular to the z axis.
The VGM interface to solids.
virtual SolidType Type() const =0
Return the type of this solid.
virtual std::string Name() const =0
Return the name of this solid.
The VGM interface to sphere solids.
virtual double StartPhi() const =0
Return the starting azimuthal angle of the segment in deg.
virtual double DeltaPhi() const =0
Return the opening azimuthal angle of the segment in deg.
virtual double StartTheta() const =0
Return the starting polar angle of the segment in deg.
virtual double DeltaTheta() const =0
Return the opening polar angle of the segment in deg.
virtual double OuterRadius() const =0
Return the outside radius of the shell in mm.
virtual double InnerRadius() const =0
Return the inside radius of the shell in mm.
The VGM interface to extruded solids.
virtual int NofVertices(int ifacet) const =0
Return the number of vertices in the the ifacet-th facet.
virtual ThreeVector Vertex(int ifacet, int index) const =0
Return the index-th vertex in the ifacet-th facet.
virtual int NofFacets() const =0
Return the number of facets.
The VGM interface to torus solids.
virtual double OuterRadius() const =0
Return the outside radius of the torus in mm.
virtual double StartPhi() const =0
Return the starting phi angle of the segment in deg (with 0 being the +x axis)
virtual double AxialRadius() const =0
Return the axial (swept) radius of the torus in mm.
virtual double DeltaPhi() const =0
Return the opening phi angle of the segment in deg.
virtual double InnerRadius() const =0
Return the inside radius of the torus in mm.
The VGM interface to trap solids.
virtual double Phi() const =0
Return the azimuthal angle of the line joining the centres of the faces at -hz and +hz in deg.
virtual double XHalfLengthPlusZMinusY() const =0
Return the half-length along x of the side at -hy of the face at +hz in m.
virtual double AlphaPlusZ() const =0
Return the angle with respect to the y axis from the centre of the side at -hy to the centre at +hy o...
virtual double ZHalfLength() const =0
Return the half-length along the z axis in mm.
virtual double YHalfLengthMinusZ() const =0
Return the half-length along y of the face at -hz in mm.
virtual double XHalfLengthMinusZMinusY() const =0
Return the half-length along x of the side at -hy of the face at -hz in mm.
virtual double YHalfLengthPlusZ() const =0
Return the half-length along y of the face at +hz in m.
virtual double XHalfLengthPlusZPlusY() const =0
Return the half-length along x of the side at +hy of the face at +hz in m.
virtual double Theta() const =0
Return the polar angle of the line joining the centres of the faces at -hz and +hz in deg.
virtual double AlphaMinusZ() const =0
Return the angle with respect to the y axis from the centre of the side at -hy to the centre at +hy o...
virtual double XHalfLengthMinusZPlusY() const =0
Return the half-length along x of the side at +hy of the face at +hz in mm.
The VGM interface to trd solids.
virtual double XHalfLengthPlusZ() const =0
Return the half-length along x at the surface positioned at +hz in mm.
virtual double YHalfLengthPlusZ() const =0
Return thehalf-length along y at the surface positioned at +hz in mm.
virtual double XHalfLengthMinusZ() const =0
Return the half-length along x at the surface positioned at -hz in mm.
virtual double ZHalfLength() const =0
Return the half-length along the z axis in mm.
virtual double YHalfLengthMinusZ() const =0
Return the half-length along y at the surface positioned at -hz in mm.
The VGM interface to tubs solids.
virtual double ZHalfLength() const =0
Return the half-length along the z axis in m.
virtual double StartPhi() const =0
Return the starting angle of the segment in deg.
virtual double DeltaPhi() const =0
Return the opening angle of the segment in deg.
virtual double InnerRadius() const =0
Return the inside radius in mm.
virtual double OuterRadius() const =0
Return the outside radius in mm.
virtual std::string Name() const =0
Return the name of this volume.
The implementation of the interface for the XML writer that writes VGM geometry objects to XML define...
virtual void CloseMaterials()
Write materials definitions closing.
virtual void WriteRotation(const std::string &name, const VGM::Transform &transform)
Write rotation (from VGM transformation)
virtual void CloseStructure()
Write structure definition closing (if present)
virtual void OpenSolids()
Write solids definitions opening.
virtual void OpenPositions()
Write positions definitions opening.
virtual void WriteEmptyLine()
Write empty line.
virtual void CloseSolids()
Write materials definitions closing.
virtual void CloseFile()
Close output file.
virtual void OpenStructure()
Write structure definition opening (if present)
GDMLWriter(const std::string &unitName="unit1", const std::string &version="1.0")
virtual void WriteMaterial(const VGM::IMaterial *material)
Write VGM material.
virtual void WritePosition(const std::string &name, const VGM::Transform &transform)
Write position (from VGM transformation)
virtual void OpenMaterials()
Write materials definitions opening.
virtual void OpenComposition(const std::string &name, const std::string &materialName)
Write composition definition opening (if present)
virtual void IncreaseIndention()
Increase indention.
virtual void OpenRotations()
Write rotations definitions opening.
virtual void WritePlacement(const VGM::IPlacement &placement)
Write VGM placement.
virtual void DecreaseIndention()
Decrease indention.
virtual void CloseComposition()
Write composition definition closing (if present)
virtual void OpenSection(const std::string &topVolume)
Write the section opening (if present)
virtual void ClosePositions()
Write positions definitions closing.
virtual void OpenFile(std::string filePath)
Open output file.
virtual void WriteSolid(std::string lvName, const VGM::ISolid *solid, std::string)
Write VGM solid.
virtual void WriteScale(const std::string &name)
Write scale (from VGM transformation)
virtual void CloseDocument()
Write XML document closing.
virtual void OpenDocument()
Write XML document opening.
virtual void WriteElement(const VGM::IElement *element)
Write VGM element.
virtual void CloseSection(const std::string &topVolume)
Write the section closing (if present)
virtual void CloseRotations()
Write rotations definitions closing.
virtual void WriteIsotope(const VGM::IIsotope *isotope)
Write VGM isotope.
The interface for the XML writer that writes VGM geometry objects to XML:
bool HasReflection(const HepGeom::Transform3D &transform)
VGM::Transform Inverse(const VGM::Transform &transform)
std::vector< double > Transform
std::pair< double, double > TwoVector
std::vector< double > ThreeVector
@ kLiquid
Liquid material.
@ kUndefined
Undefined material state.
std::string IsotopeName(const VGM::IIsotope *isotope)
std::string AppendName(const std::string &name, int size)
std::string StripName(const std::string &name, const std::string &extension="")
std::ostream & SmartPut(std::ostream &out, int size, int precision, double tolerance, double number, const std::string &separator)
std::string UpdateName(const std::string &name, const std::string &extension="")