//====================================================================== // surfacePoint.cc: Demonstrates two bugs with VecGeom USolids // // Simple program to exercise G4VSolid::GetPointOnSurface() for a // cylinder. With standard Geant4, each run will have a different set // of random values, and the cylinder will have its top and bottom // faces populated uniformly. With USolids (VecGeom), every run will // be identical (use of std::rand() instead of Geant4 random engine), // and the cylinder will have points concentrated at the center of // each face (incorrect radial coordinate selection). // // 20220302 Michael Kelsey (TAMU) //====================================================================== #include "globals.hh" #include "G4PhysicalConstants.hh" #include "Randomize.hh" #include "G4Tubs.hh" #include "G4ThreeVector.hh" #include #include int main(int argc, char* argv[]) { // Get number of points from command line, or display usage if (argc < 2 || G4String(argv[1]) == "-h") { G4cout << "Usage: " << argv[0] << " " << G4endl; return 0; } G4int npoints = atoi(argv[1]); // Initialize Geant4 random engine with unique seeds every time CLHEP::HepRandom::setTheSeed(time(NULL)); // Generate points on surface of cylinder G4VSolid* cyl = new G4Tubs("Cylinder", 0., 1., 1., 0., twopi); G4cout << npoints << " surface points on " << cyl->GetName() << " (" << cyl->GetEntityType() << ")" << G4endl; G4ThreeVector pt; for (G4int i=0; iGetPointOnSurface(); G4cout << pt[0] << " " << pt[1] << " " << pt[2] << G4endl; } }