// PosGen_Plane.cc // Contact person:Matthew Mottram // See PosGen_Plane.hh for more details //———————————————————————// #include #include #include #include using namespace RAT; #include using namespace CLHEP; #include void PosGen_Plane::GeneratePosition( G4ThreeVector& argResult ) { const double theta = G4UniformRand() * twopi; const double radius = G4UniformRand() * fMaxDisplacement * fMaxDisplacement; argResult = ( cos( theta ) * fX + sin( theta ) * fY ) * sqrt( radius ); argResult += fPosition; } void PosGen_Plane::SetState( G4String newValues ) { newValues = util_strip_default(newValues); if( newValues.length() == 0 ) { warn << "PosGen_Plane::SetState: Should enter x y z nx ny nz max i.e. position normal displacement" << newline; return; } std::istringstream is( newValues.c_str() ); // Get the position and normal double x, y, z, nx, ny, nz; is >> x >> y >> z >> nx >> ny >> nz >> fMaxDisplacement; if( is.fail() ) Log::Die( "PosGen_Plane::SetState: Could not parse 7 floats from input string" ); fPosition = G4ThreeVector( x, y, z ); fNormal = G4ThreeVector( nx, ny, nz ); fX = fNormal.orthogonal().unit(); fY = fNormal.cross( fX ).unit(); } G4String PosGen_Plane::GetState() const { return util_dformat( "%ld\t%ld\t%ld normal: %ld\t%ld\t%ld %d", fPosition.x(), fPosition.y(), fPosition.z(), fNormal.x(), fNormal.y(), fNormal.z(), fMaxDisplacement ); }