#include #include #include #include #include #include using namespace RAT; using namespace std; static void init(); /// Local function to fill the following static maps static map modelMap; static map surfaceFinishMap; static map surfaceTypeMap; map Surfaces::fsSurfaces; void Surfaces::LoadSurfaces() { if (modelMap.empty()) init(); DBLinkGroup surfaces = DB::Get()->GetLinkGroup("SURFACES"); DBLinkGroup::iterator iSurface; for (iSurface = surfaces.begin(); iSurface != surfaces.end(); ++iSurface) { const string name = iSurface->first; DBLinkPtr dbTable = iSurface->second; fsSurfaces[name] = new G4OpticalSurface(name); fsSurfaces[name]->SetMaterialPropertiesTable(new G4MaterialPropertiesTable()); string model; try { model = dbTable->GetS("model"); fsSurfaces[name]->SetModel(modelMap[model]); } catch (DBNotFoundError& e) { /* defaults to glisur */ model = "glisur"; } if (model == "glisur") { try { G4double polish = dbTable->GetD("polish"); fsSurfaces[name]->SetPolish(polish); } catch (DBNotFoundError& e) { /* defaults to 1.0 */ } } else if (model == "unified") { try { G4double sigma_alpha = dbTable->GetD("sigma_alpha"); fsSurfaces[name]->SetSigmaAlpha(sigma_alpha); } catch (DBNotFoundError& e) { /* defaults to ??? probably 0.0 */ } } try { string type = dbTable->GetS("surface_type"); fsSurfaces[name]->SetType(surfaceTypeMap[type]); } catch (DBNotFoundError& e) { /* defaults to dielectric_dielectric */ } try { string surfaceFinish = dbTable->GetS("surface_finish"); fsSurfaces[name]->SetFinish(surfaceFinishMap[surfaceFinish]); } catch (DBNotFoundError& e) { /* defaults to polished */ } LoadProperties( name, dbTable ); } } bool Surfaces::IsSurfaceProperty(const std::string& prop) { return prop == "RINDEX" || prop == "SPECULARLOBECONSTANT" || prop == "SPECULARSPIKECONSTANT" || prop == "BACKSCATTERCONSTANT" || prop == "REFLECTIVITY" || prop == "EFFICIENCY"; } void Surfaces::LoadProperties(const std::string& name, DBLinkPtr dbTable ) { vector properties; try { properties = dbTable->GetSArray( "PROPERTY_LIST" ); } catch (DBNotFoundError& e) { Log::Die( "Surfaces::LoadProperties: No PROPERTY_LIST for surface " + name ); } G4MaterialPropertiesTable* propertiesTable = fsSurfaces[name]->GetMaterialPropertiesTable(); for (vector::const_iterator iProperty = properties.begin(); iProperty != properties.end(); ++iProperty) { if (Surfaces::IsSurfaceProperty(*iProperty)) { propertiesTable->AddProperty(iProperty->c_str(), Optics::LoadWavelengthPropertyVector(*iProperty, dbTable) ); } else if (*iProperty == "KINDEX") { //Not a surface property, used by old PMT code propertiesTable->AddProperty(iProperty->c_str(), Optics::LoadWavelengthPropertyVector(*iProperty, dbTable)); } else if (*iProperty == "THICKNESS") { //Not a surface property, used by old PMT code propertiesTable->AddProperty(iProperty->c_str(), Optics::LoadPropertyVector(*iProperty, dbTable)); } else { Log::Die( "Surfaces::LoadProperties: Unknown property " + *iProperty ); } } } void init() { modelMap["glisur"] = glisur; modelMap["unified"] = unified; modelMap["LUT"] = LUT; surfaceFinishMap["polished"] = polished; surfaceFinishMap["polishedfrontpainted"] = polishedfrontpainted; surfaceFinishMap["polishedbackpainted"] = polishedbackpainted; surfaceFinishMap["ground"] = ground; surfaceFinishMap["groundfrontpainted"] = groundfrontpainted; surfaceFinishMap["groundbackpainted"] = groundbackpainted; surfaceFinishMap["polishedlumirrorair"] = polishedlumirrorair; surfaceFinishMap["polishedlumirrorglue"] = polishedlumirrorglue; surfaceFinishMap["polishedair"] = polishedair; surfaceFinishMap["polishedteflonair"] = polishedteflonair; surfaceFinishMap["polishedtioair"] = polishedtioair; surfaceFinishMap["polishedtyvekair"] = polishedtyvekair; surfaceFinishMap["polishedvm2000air"] = polishedvm2000air; surfaceFinishMap["polishedvm2000glue"] = polishedvm2000glue; surfaceFinishMap["etchedlumirrorair"] = etchedlumirrorair; surfaceFinishMap["etchedlumirrorglue"] = etchedlumirrorglue; surfaceFinishMap["etchedair"] = etchedair; surfaceFinishMap["etchedteflonair"] = etchedteflonair; surfaceFinishMap["etchedtioair"] = etchedtioair; surfaceFinishMap["etchedtyvekair"] = etchedtyvekair; surfaceFinishMap["etchedvm2000air"] = etchedvm2000air; surfaceFinishMap["etchedvm2000glue"] = etchedvm2000glue; surfaceFinishMap["groundlumirrorair"] = groundlumirrorair; surfaceFinishMap["groundlumirrorglue"] = groundlumirrorglue; surfaceFinishMap["groundair"] = groundair; surfaceFinishMap["groundteflonair"] = groundteflonair; surfaceFinishMap["groundtioair"] = groundtioair; surfaceFinishMap["groundtyvekair"] = groundtyvekair; surfaceFinishMap["groundvm2000air"] = groundvm2000air; surfaceFinishMap["groundvm2000glue"] = groundvm2000glue; surfaceTypeMap["dielectric_metal"] = dielectric_metal; surfaceTypeMap["dielectric_dielectric"] = dielectric_dielectric; surfaceTypeMap["dielectric_LUT"] = dielectric_LUT; surfaceTypeMap["firsov"] = firsov; surfaceTypeMap["x_ray"] = x_ray; }