Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:21:25

0001 #include <CLHEP/Units/SystemOfUnits.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 using CLHEP::cm;
0014 using CLHEP::cm3;
0015 using CLHEP::deg;
0016 
0017 class testCutTubs : public CppUnit::TestFixture {
0018   CPPUNIT_TEST_SUITE(testCutTubs);
0019   CPPUNIT_TEST(matched_g4_and_dd);
0020 
0021   CPPUNIT_TEST_SUITE_END();
0022 
0023 public:
0024   void matched_g4_and_dd(void);
0025 };
0026 
0027 void testCutTubs::matched_g4_and_dd(void) {
0028   double rIn = 10. * cm;
0029   double rOut = 15. * cm;
0030   double zhalf = 20. * cm;
0031   double startPhi = 0. * deg;
0032   double deltaPhi = 90. * deg;
0033   string name("fred1");
0034 
0035   array<double, 3> lowNorm = {{0, -0.7, -0.71}};
0036   array<double, 3> highNorm = {{0.7, 0, 0.71}};
0037 
0038   G4CutTubs g4(name,
0039                rIn,
0040                rOut,
0041                zhalf,
0042                startPhi,
0043                deltaPhi,
0044                G4ThreeVector(lowNorm[0], lowNorm[1], lowNorm[2]),
0045                G4ThreeVector(highNorm[0], highNorm[1], highNorm[2]));
0046   DDI::CutTubs dd(
0047       zhalf, rIn, rOut, startPhi, deltaPhi, lowNorm[0], lowNorm[1], lowNorm[2], highNorm[0], highNorm[1], highNorm[2]);
0048   DDCutTubs dds = DDSolidFactory::cuttubs(name,
0049                                           zhalf,
0050                                           rIn,
0051                                           rOut,
0052                                           startPhi,
0053                                           deltaPhi,
0054                                           lowNorm[0],
0055                                           lowNorm[1],
0056                                           lowNorm[2],
0057                                           highNorm[0],
0058                                           highNorm[1],
0059                                           highNorm[2]);
0060   cout << endl;
0061   dd.stream(cout);
0062   cout << endl;
0063 
0064   double g4v = g4.GetCubicVolume() / cm3;
0065   double ddv = dd.volume() / cm3;
0066   double ddsv = dds.volume() / cm3;
0067 
0068   cout << "\tg4 volume = " << g4v << " cm3" << endl;
0069   cout << "\tdd volume = " << ddv << " cm3" << endl;
0070   cout << "\tDD Information: " << dds << " vol=" << ddsv << " cm3" << endl;
0071 }
0072 
0073 CPPUNIT_TEST_SUITE_REGISTRATION(testCutTubs);