// PosGen_FillRPower.cc // Contact person: M Mottram // See PosGen_FillRPower.hh for more details //———————————————————————// #include using namespace CLHEP; #include #include #include #include using namespace RAT; #include void PosGen_FillRPower::GeneratePosition( G4ThreeVector& argResult ) { const double phi = G4UniformRand() * 2.0 * pi; const double costheta = G4UniformRand() * 2.0 - 1.0; const double theta = acos( costheta ); const double radius = pow( ( G4UniformRand() * pow( fMaxDisplacement, fRPower ) ), 1./(fRPower)); argResult = G4ThreeVector( radius * cos( phi ) * sin( theta ), radius * sin( phi ) * sin( theta ), radius * costheta ); argResult += fPosition; } void PosGen_FillRPower::SetState( G4String newValues ) { newValues = util_strip_default(newValues); if( newValues.length() == 0 ) { warn << "PosGen_FillRPower::SetState: Should enter x y z rmax power (i.e. position, max radius, sampling power of R)" << newline; return; } std::istringstream is( newValues.c_str() ); // Get the position and normal double x, y, z; is >> x >> y >> z >> fMaxDisplacement >> fRPower; if( is.fail() ) Log::Die( "PosGen_FillRPower::SetState: Could not parse 5 floats from input string" ); fPosition = G4ThreeVector( x, y, z ); } G4String PosGen_FillRPower::GetState() const { return util_dformat( "%ld\t%ld\t%1d", fPosition.x(), fPosition.y(), fPosition.z() ); }