// PosGen_PlaneRPower.cc // Contact person:Matt Mottram // See PosGen_PlaneRPower.hh for more details //———————————————————————// #include using namespace CLHEP; #include #include #include #include using namespace RAT; #include void PosGen_PlaneRPower::GeneratePosition( G4ThreeVector& argResult ) { const double theta = G4UniformRand() * 2.0 * pi; const double radius = G4UniformRand() * pow( fMaxDisplacement, fRPower ); argResult = ( cos( theta ) * fX + sin( theta ) * fY ) * pow( radius, 1./(fRPower) ); argResult += fPosition; } void PosGen_PlaneRPower::SetState( G4String newValues ) { newValues = util_strip_default(newValues); if( newValues.length() == 0 ) { warn << "PosGen_PlaneRPower::SetState: Should enter x y z nx ny nz rmax power (i.e. position, normal, max radius, sampling power of R)" << 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 >> fRPower; if( is.fail() ) Log::Die( "PosGen_PlaneRPower::SetState: Could not parse 8 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_PlaneRPower::GetState() const { return util_dformat( "%ld\t%ld\t%ld normal: %ld\t%ld\t%ld %d %d", fPosition.x(), fPosition.y(), fPosition.z(), fNormal.x(), fNormal.y(), fNormal.z(), fMaxDisplacement, fRPower ); }