definitions:
  name: "Custom Sputter Deposition (SPS) Schemas"
  sections:
    # ----------------------------------------------------
    # 1. GEOMETRY SECTION
    # ----------------------------------------------------
    MandatoryGeometry:
      base_sections:
        - "nomad.datamodel.metainfo.basesections.Section"
      quantities:
        diameter:
          type: np.float64
          unit: "meter"
          description: "The diameter size parameter"
          default: "0.0"
          a_eln:
            component: "NumberEditQuantity"
            defaultDisplayUnit: "millimeter"

    # ----------------------------------------------------
    # 2. CUSTOM SOURCE SECTION
    # ----------------------------------------------------
    SputterSource:
      base_sections:
        - "nomad_material_processing.vapor_deposition.general.VaporDepositionSource"
      quantities:
        sputtering_technique:
          type:
            type_kind: Enum
            type_data:
              - "DC"
              - "RF"
              - "Hybrid"
          description: "Power delivery method for the sputtering gun."
          default: "DC"
          a_eln:
            component: "EnumEditQuantity"
        cathode_voltage:
          type: np.float64
          shape: ["*"]
          unit: "volt"
          a_eln:
            component: "NumberEditQuantity"
          m_annotations:
            tabular:
              name: "Turbos:RHEED current [A]" # Mapped example column
        cathode_current:
          type: np.float64
          shape: ["*"]
          unit: "ampere"
          a_eln:
            component: "NumberEditQuantity"
      sub_sections:
        target_size:
          section: "#MandatoryGeometry"
          min_count: 1

    # ----------------------------------------------------
    # 3. ENVIRONMENT SECTION (Gases & Working Pressure)
    # ----------------------------------------------------
    MandatoryGas:
      base_sections:
        - "nomad.datamodel.metainfo.basesections.PureSubstanceSection"
      quantities:
        name:
          type: str
          default: "Argon"
          a_eln:
            component: "StringEditQuantity"

    MandatoryGasFlow:
      base_sections:
        - "nomad_material_processing.vapor_deposition.general.GasFlow"
      quantities:
        # Array quantity mapped to CSV Argon flow
        ar_flow_rate:
          type: np.float64
          shape: ["*"]
          unit: "cm**3 / minute" # sccm equivalent
          a_eln:
            component: "NumberEditQuantity"
          m_annotations:
            tabular:
              name: "Mass flows:Ar (reading) [sccm]"
        # Array quantity mapped to CSV Nitrogen flow
        n2_flow_rate:
          type: np.float64
          shape: ["*"]
          unit: "cm**3 / minute"
          a_eln:
            component: "NumberEditQuantity"
          m_annotations:
            tabular:
              name: "Mass flows:N2 (reading) [sccm]"
      sub_sections:
        gas:
          section: "#MandatoryGas"
          min_count: 1

    SputterChamberEnvironment:
      base_sections:
        - "nomad_material_processing.vapor_deposition.general.ChamberEnvironment"
      quantities:
        # Array quantity mapped to CSV Process Pressure
        process_pressure:
          type: np.float64
          shape: ["*"]
          unit: "mbar"
          a_eln:
            component: "NumberEditQuantity"
          m_annotations:
            tabular:
              name: "Pressures:Process [mbar]"
      sub_sections:
        gas_flow:
          section: "#MandatoryGasFlow"
          repeats: true
          min_count: 1

    # ----------------------------------------------------
    # 4. SAMPLE PARAMETERS SECTION
    # ----------------------------------------------------
    SputterSampleParameters:
      base_sections:
        - "nomad_material_processing.vapor_deposition.general.SampleParameters"
      quantities:
        distance_to_source:
          type: np.float64
          unit: "meter"
          default: "0.0"
          description: "Substrate position / Distance to source"
          a_eln:
            component: "NumberEditQuantity"
            defaultDisplayUnit: "millimeter"
      sub_sections:
        substrate:
          section: "nomad_material_processing.general.ThinFilmStackReference"
          min_count: 1
        substrate_size:
          section: "#MandatoryGeometry"
          min_count: 1

    # ----------------------------------------------------
    # 5. STEP SECTION
    # ----------------------------------------------------
    SputterStep:
      base_sections:
        - "nomad_material_processing.vapor_deposition.general.VaporDepositionStep"
      quantities:
        duration:
          type: np.float64
          unit: "second"
          default: "0.0"
          description: "Deposition time"
          a_eln:
            component: "NumberEditQuantity"
        substrate_rotation_speed:
          type: np.float64
          shape: ["*"]
          unit: "rpm"
          a_eln:
            component: "NumberEditQuantity"
      sub_sections:
        sources:
          section: "#SputterSource"
          repeats: true
          min_count: 1
        environment:
          section: "#SputterChamberEnvironment"
          min_count: 1
        sample_parameters:
          section: "#SputterSampleParameters"
          repeats: true
          min_count: 1

    # ----------------------------------------------------
    # 6. MAIN SPUTTER DEPOSITION ENTRY POINT
    # ----------------------------------------------------
    SputterDeposition:
      base_sections:
        - "nomad_material_processing.vapor_deposition.pvd.general.PhysicalVaporDeposition"
        - "nomad.parsing.tabular.TableData"
        - "nomad.datamodel.data.EntryData"

      a_eln:
        hide: ["method"]
      quantities:
        name:
          type: str
          default: "Sputter Deposition Entry"
          description: "Name of the sputter deposition entry"
          a_eln:
            component: "StringEditQuantity"
        lab_id:
          type: str
          a_eln:
            component: "StringEditQuantity"
            label: "Sample ID"
      data_file:
        type: str
        m_annotations:
          tabular_parser:
            parsing_options:
              comment: "#"
            mapping_options:
              - mapping_mode: column
                file_mode: current_entry
                sections:
                  - "#root"
          browser:
            adaptor: "RawFileAdaptor"
          eln:
            component: "FileEditQuantity"
      sub_sections:
        steps:
          section: "#SputterStep"
          repeats: true
