///////////////////////////////////////////////////////////////////////////////
/// \class RAT::Optics
///
/// \brief  Constructs the Optics
///
/// \author Phil G Jones <p.g.jones@qmul.ac.uk>
/// \author I Coulter <icoulter@hep.upenn.edu> -- contact person
///
/// REVISION HISTORY:\n
///     2013-07-30 : P G Jones - Refactor.\n
///     09-12-2015 : I Coulter - Fix so it reads in the SCINTMOD for alphas
///                              and neutrons
///
/// \details Loads material properties from ratdb and builds the geant4 optical
/// material properties.
///
///////////////////////////////////////////////////////////////////////////////
#ifndef __RAT_Optics__
#define __RAT_Optics__

#include <G4MaterialPropertyVector.hh>

#include <RAT/DB.hh>

#include <string>
#include <vector>

class G4MaterialPropertiesTable;

namespace RAT
{

class Optics
{
public:
  /// Load and construct optics
  static void LoadOptics();

  /// Load a single wavelength dependent property vector (useful outside of this class)
  ///
  /// @param[in] propertyName db field name for the property
  /// @param[in] dbTable that defines the property
  /// @return the material property vector
  static G4MaterialPropertyVector* LoadWavelengthPropertyVector( const std::string& propertyName,
                                                                 DBLinkPtr dbTable );

  /// Load a property vector (useful outside of this class)
  ///
  /// @param[in] propertyName db field name for the property
  /// @param[in] dbTable that defines the property
  /// @return the material property vector
  static G4MaterialPropertyVector* LoadPropertyVector( const std::string& propertyName,
                                                       DBLinkPtr dbTable );
private:
  /// Load the optical properties for the material name
  ///
  /// @param[in] name db field name for the property
  /// @param[in] dbTable that defines the property
  static void LoadOpticalProperties( const std::string& name,
                                     DBLinkPtr dbTable );

  /// Sum and rescale a property i.e. the optical attenuation lengths
  ///
  /// @param[in] dbTable that defines the material
  /// @param[in] propertiesTable for the material
  /// @param[in] property name
  static void RescaleProperty( DBLinkPtr dbTable,
                               G4MaterialPropertiesTable* propertiesTable,
                               const std::string& property );
};


} // namespace RAT

#endif