File indexing completed on 2023-10-25 10:04:29
0001 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0002 #include "DetectorDescription/Core/interface/DDSolid.h"
0003 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
0004 #include "DetectorDescription/Core/interface/CutTubs.h"
0005 #include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
0006 #include "cppunit/extensions/HelperMacros.h"
0007 #include <G4CutTubs.hh>
0008 #include <cmath>
0009 #include <limits>
0010 #include <string>
0011
0012 using namespace std;
0013
0014 class testCutTubs : public CppUnit::TestFixture {
0015 CPPUNIT_TEST_SUITE(testCutTubs);
0016 CPPUNIT_TEST(matched_g4_and_dd);
0017
0018 CPPUNIT_TEST_SUITE_END();
0019
0020 public:
0021 void matched_g4_and_dd(void);
0022 };
0023
0024 void testCutTubs::matched_g4_and_dd(void) {
0025 double rIn = 10. * cm;
0026 double rOut = 15. * cm;
0027 double zhalf = 20. * cm;
0028 double startPhi = 0. * deg;
0029 double deltaPhi = 90. * deg;
0030 string name("fred1");
0031
0032 array<double, 3> lowNorm = {{0, -0.7, -0.71}};
0033 array<double, 3> highNorm = {{0.7, 0, 0.71}};
0034
0035 G4CutTubs g4(name,
0036 rIn,
0037 rOut,
0038 zhalf,
0039 startPhi,
0040 deltaPhi,
0041 G4ThreeVector(lowNorm[0], lowNorm[1], lowNorm[2]),
0042 G4ThreeVector(highNorm[0], highNorm[1], highNorm[2]));
0043 DDI::CutTubs dd(
0044 zhalf, rIn, rOut, startPhi, deltaPhi, lowNorm[0], lowNorm[1], lowNorm[2], highNorm[0], highNorm[1], highNorm[2]);
0045 DDCutTubs dds = DDSolidFactory::cuttubs(name,
0046 zhalf,
0047 rIn,
0048 rOut,
0049 startPhi,
0050 deltaPhi,
0051 lowNorm[0],
0052 lowNorm[1],
0053 lowNorm[2],
0054 highNorm[0],
0055 highNorm[1],
0056 highNorm[2]);
0057 cout << endl;
0058 dd.stream(cout);
0059 cout << endl;
0060
0061 double g4v = g4.GetCubicVolume() / cm3;
0062 double ddv = dd.volume() / cm3;
0063 double ddsv = dds.volume() / cm3;
0064
0065 cout << "\tg4 volume = " << g4v << " cm3" << endl;
0066 cout << "\tdd volume = " << ddv << " cm3" << endl;
0067 cout << "\tDD Information: " << dds << " vol=" << ddsv << " cm3" << endl;
0068 }
0069
0070 CPPUNIT_TEST_SUITE_REGISTRATION(testCutTubs);