// PosGen_ELLIE.cc // Contact person: Jeanne R Wilson // See PosGen_ELLIE.hh for more details //———————————————————————// #include #include #include using namespace std; #include #include #include using namespace RAT; PosGen_ELLIE::PosGen_ELLIE(const std::string& dbname) : GLG4PosGen( dbname ) { // Not yet initialised - call the Init function to setup on first event fInitDB=false; // Initialise the fibre to null - set either by state or as DB command fFibreID=""; } void PosGen_ELLIE::Init() { // This function should be run once on the first event (once DB all set up) warn << "PosGen_ELLIE::Init: Initialising simulation settings \n"; if(fFibreID==""){ // It hasn't been set as the state of the generator so load from DB DBLinkPtr lELLIE = DB::Get()->GetLink("ELLIE"); fFibreID = lELLIE->GetS("fibre_id"); } // Now get the info specific for this fibre DBLinkPtr lfibre; try{ lfibre = DB::Get()->GetLink("FIBRE", fFibreID); info << "PosGen_ELLIE::Init: Getting fibre info for " << fFibreID << "\n"; }catch(DBNotFoundError &e) { Log::Die("PosGen_ELLIE::Init: can't find ratdb FIBRE info for " + fFibreID); } // Positions fPosition.setX(lfibre->GetD("x")); fPosition.setY(lfibre->GetD("y")); fPosition.setZ(lfibre->GetD("z")); fInitDB = true; } void PosGen_ELLIE::BeginOfRun() { GLG4PosGen::BeginOfRun(); Init(); } void PosGen_ELLIE::GeneratePosition( G4ThreeVector& argResult ) { argResult = fPosition; } void PosGen_ELLIE::SetState( G4String newValues ) { newValues = trim(newValues); if(newValues.length() == 0)// Empty arg, print help { detail << "Format of argument to PosGen_ELLIE::SetState:" << endl << " \n\"fFibreID\" which is index of a ratdb FIBRE table" << " default will use value from ELLIE ratdb table " << endl; Log::Die("Please set correctly parameter for the PosGen_ELLIE "+GetState()); return; } else { fFibreID = newValues; debug << "Current state of this PosGen_ELLIE:\n\"" << GetState() << " \"\n"; } } G4String PosGen_ELLIE::GetState() const { // Get the position info here just for info DBLinkPtr lfibre; try{ lfibre = DB::Get()->GetLink("FIBRE", fFibreID); debug << "PosGen_ELLIE::GetState: Getting fibre info for " << fFibreID << "\n"; }catch(DBNotFoundError &e) { Log::Die("PosGen_ELLIE::GetState: can't find ratdb FIBRE info for " + fFibreID); } // Positions float x = lfibre->GetD("x"); float y = lfibre->GetD("y"); float z = lfibre->GetD("z"); stringstream result; result << fFibreID << "at (" << x << ", " << y << ", " << z << ")"; return result.str(); }