// PosGen_LineRotate.cc // Contact person:Matthew Mottram // See PosGen_LineRotate.hh for more details //———————————————————————// #include #include #include #include using namespace RAT; #include #include void PosGen_LineRotate::GeneratePosition( G4ThreeVector &argResult ) { G4double phi = G4UniformRand() * CLHEP::twopi; G4ThreeVector diff = fPoint2 - fPoint1; G4double scale = G4UniformRand(); argResult = fPoint1 + scale * diff; argResult.rotateZ(phi); } void PosGen_LineRotate::SetState( G4String newValues ) { newValues = util_strip_default(newValues); if (newValues.length() == 0) { // print help and current state G4cout << "Current state of this GLG4PosGen_LineRotate:\n" << " \"" << GetState() << "\"\n" << G4endl; G4cout << "Format of argument to PosGen_LineRotate::SetState: \n" << " \"x1_mm z1_mm x2_mm z2_mm\"" << G4endl; return; } std::istringstream is(newValues.c_str()); // set position G4double x1,z1, x2,z2; is >> x1 >> z1 >> x2 >> z2; if (is.fail()) Log::Die( "PosGen_LineRotate::SetState: Could not parse six floats from input string" ); fPoint1 = G4ThreeVector(x1,0.0,z1); fPoint2 = G4ThreeVector(x2,0.0,z2); } G4String PosGen_LineRotate::GetState() const { return util_dformat("%ld\t%ld -> %ld\t%ld", fPoint1.x(), fPoint1.z(), fPoint2.x(), fPoint2.z()); }