// PosGen_Laserball.cc // Contact person: Jose Maneira // See PosGen_Laserball.hh for more details //------------------------------------------------/// #include #include #include #include using namespace std; #include //#include //#include #include #include using namespace RAT; PosGen_Laserball::PosGen_Laserball(const std::string& dbname) : GLG4PosGen( dbname ) { // Not yet initialised - call the Init function to setup on first event fInitDB=false; } void PosGen_Laserball::BeginOfRun() { Init(); } void PosGen_Laserball::Init() { // This function should be run once on the first event (once DB all set up) warn << "PosGen_Laserball::Init: Initialising simulation settings \n"; // Load database values DBLinkPtr lLASERBALL = DB::Get()->GetLink("LASERBALL_SIMULATION"); fSimulationMode = lLASERBALL->GetI("simulation_mode"); if (fSimulationMode == 2.0 || fSimulationMode == 3.0) Log::Die("PosGen_LaserBall::Init: Loading position from Manip or Camera tables not implemented yet"); std::vector aPosition; aPosition = lLASERBALL->GetFArrayFromD("position"); fPosition.set(aPosition[0], aPosition[1], aPosition[2]); info << "PosGen_Laserball::Init: Setting position LASERBALL_SIMULATION table to "<< (float) fPosition.x() <<" " << (float) fPosition.y() << " "<< (float) fPosition.z()<<"\n"; fInitDB = true; } void PosGen_Laserball::GeneratePosition( G4ThreeVector& argResult ) { if(!fInitDB)Init(); argResult = fPosition; } void PosGen_Laserball::SetState( G4String newValues ) { Log::Die("SetState is deprecated, do not call it. Set all variables with /rat/db/set."); return; } G4String PosGen_Laserball::GetState() const { stringstream result; result << "Laserball at (" << fPosition.x() << ", " << fPosition.y() << ", " << fPosition.z() << ")"; return result.str(); }