// Gen_UFO.cc // // Contact person: Mark Stringer // See Gen_UFO.hh for more details //———————————————————————// #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; namespace RAT { Gen_UFO::Gen_UFO() : GLG4Gen("UFO"),fStateStr(""),fMessenger(0) { // Set vertex generator to UFO fVertexGen = new VertexGen_UFO(); // Set position generator to UFO fPosGen = new PosGen_UFO(); // Default time generator fTimeGen = new GLG4TimeGen_Poisson(); // Default to no poisson fluctuations of number of photons per pulse fPoisson = false; } Gen_UFO::~Gen_UFO() { } void Gen_UFO::GenerateEvent(G4Event *event) { debug << "Gen_UFO::GenerateEvent: Generating UFO events with top level generator\n"; G4double t0 = NextTime(); G4ThreeVector pos; fPosGen->GeneratePosition(pos); debug << "Gen_UFO: time = " << t0 << " position = (" << pos.x() << ", " << pos.y() << ", " << pos.z() << ")\n"; fVertexGen->GeneratePrimaryVertex(event, pos, t0); } void Gen_UFO::ResetTime(double offset) { fNextTime = fTimeGen->GenerateEventTime() + offset; } void Gen_UFO::SetState(G4String /*state*/) { // Can't set state here yet } G4String Gen_UFO::GetState() const { return fStateStr; } void Gen_UFO::SetTimeGen(G4String state) { try { delete fTimeGen; fTimeGen = 0; // In case of exception in next line fTimeGen = RAT::GlobalFactory::New(state); info << "Gen_UFO::SetTimeGen: Setting UFO time generator to " << state << "\n"; } catch (RAT::FactoryUnknownID &unknown) { warn << "Gen_UFO: Unknown time generator \"" << unknown.id << "\"" << newline; } } void Gen_UFO::SetTimeState(G4String state) { if (fTimeGen){ fTimeGen->SetState(state); }else{ warn << "Gen_UFO::SetTimeState error: Cannot set time state, no time generator selected" << newline; } } G4String Gen_UFO::GetTimeState() const { if (fTimeGen) return fTimeGen->GetState(); else return G4String("Gen_UFO::GetTimeStat error: no time generator selected"); } void Gen_UFO::SetVertexState(G4String /*state*/) { warn << "Gen_UFO::SetVertexState error: Cannot set vertex state - fixed to VertexGen_UFO" << newline; } G4String Gen_UFO::GetVertexState() const { return G4String("Gen_UFO::GetVertexState: vertex generator fixed to VertexGen_UFO"); } void Gen_UFO::SetPosState(G4String /*state*/) { warn << "Gen_UFO::SetPosState error: Cannot set position state - fixed to PosGen_UFO" << newline; } G4String Gen_UFO::GetPosState() const { return G4String("Gen_UFO::GetPosState: position generator fixed to PosGen_UFO"); } void Gen_UFO::SetPoissonFluctuations(G4bool set) { fPoisson = set; if(fPoisson){ info << "Gen_UFO::SetPoissonFluctuations: Poisson fluctuation number of photons per pulse " <<"\n"; }else{ info << "Gen_UFO::SetPoissonFluctuations: Fixing number of photons per pulse \n"; } } } // namespace RAT