1313#include < string>
1414#include < cmath>
1515
16- int testMatrixPrecision () {
16+ int testMatrixPrecision ()
17+ {
1718 // Check if GDML is available
1819 if (TClass::GetClass (" TGDMLWrite" ) == nullptr ) {
1920 std::cout << " GDML not available, skipping test" << std::endl;
2021 return 0 ;
2122 }
2223
2324 // Create a simple geometry with a matrix that has high-precision values
24- TGeoManager* geom = new TGeoManager (" test" , " Precision test" );
25-
25+ TGeoManager * geom = new TGeoManager (" test" , " Precision test" );
26+
2627 TGeoMaterial *mat = new TGeoMaterial (" Vacuum" , 0 , 0 , 0 );
2728 TGeoMedium *med = new TGeoMedium (" Vacuum" , 1 , mat);
28-
29+
2930 TGeoVolume *top = geom->MakeBox (" TOP" , med, 100 , 100 , 100 );
3031 geom->SetTopVolume (top);
31-
32+
3233 // Create a box with a rotation matrix containing high-precision values
3334 TGeoVolume *box = geom->MakeBox (" BOX" , med, 10 , 10 , 10 );
34-
35+
3536 // Create a rotation with values that require high precision
3637 TGeoRotation *rot = new TGeoRotation (" rot1" , 30.123456789 , 45.987654321 , 60.111111111 );
37-
38+
3839 top->AddNode (box, 1 , rot);
39-
40+
4041 geom->CloseGeometry ();
41-
42+
4243 // Export to GDML
43- const char * outputFile = " test_precision.gdml" ;
44+ const char * outputFile = " test_precision.gdml" ;
4445 geom->Export (outputFile);
45-
46+
4647 // Read the exported file and check precision
4748 std::ifstream file (outputFile);
4849 if (!file.is_open ()) {
4950 std::cerr << " Failed to open exported GDML file" << std::endl;
5051 return 1 ;
5152 }
52-
53+
5354 std::string line;
5455 bool foundMatrix = false ;
5556 bool hasSufficientPrecision = false ;
56-
57+
5758 while (std::getline (file, line)) {
5859 // Look for matrix elements in the GDML file
5960 if (line.find (" <matrix" ) != std::string::npos) {
@@ -72,16 +73,17 @@ int testMatrixPrecision() {
7273 // With proper fFltPrecision, we should have more
7374 if (digitCount >= 6 ) {
7475 hasSufficientPrecision = true ;
75- std::cout << " Found matrix with sufficient precision: " << digitCount << " decimal places" << std::endl;
76+ std::cout << " Found matrix with sufficient precision: " << digitCount << " decimal places"
77+ << std::endl;
7678 break ;
7779 }
7880 }
7981 }
8082 }
8183 }
82-
84+
8385 file.close ();
84-
86+
8587 if (foundMatrix) {
8688 std::cout << " Matrix export found in GDML file" << std::endl;
8789 if (hasSufficientPrecision) {
@@ -98,6 +100,7 @@ int testMatrixPrecision() {
98100 }
99101}
100102
101- int main () {
103+ int main ()
104+ {
102105 return testMatrixPrecision ();
103106}
0 commit comments