def create_tomography_circuits(circuit, qreg, creg, tomoset):
    "\n    Add tomography measurement circuits to a QuantumProgram.\n\n    The quantum program must contain a circuit 'name', which is treated as a\n    state preparation circuit for state tomography, or as teh circuit being\n    measured for process tomography. This function then appends the circuit\n    with a set of measurements specified by the input `tomography_set`,\n    optionally it also prepends the circuit with state preparation circuits if\n    they are specified in the `tomography_set`.\n\n    For n-qubit tomography with a tomographically complete set of preparations\n    and measurements this results in $4^n 3^n$ circuits being added to the\n    quantum program.\n\n    Args:\n        circuit (QuantumCircuit): The circuit to be appended with tomography\n                                  state preparation and/or measurements.\n        qreg (QuantumRegister): the quantum register containing qubits to be\n                                measured.\n        creg (ClassicalRegister): the classical register containing bits to\n                                  store measurement outcomes.\n        tomoset (tomography_set): the dict of tomography configurations.\n\n    Returns:\n        list: A list of quantum tomography circuits for the input circuit.\n\n    Raises:\n        QiskitError: if circuit is not a valid QuantumCircuit\n\n    Example:\n        For a tomography set specifying state tomography of qubit-0 prepared\n        by a circuit 'circ' this would return:\n        ```\n        ['circ_meas_X(0)', 'circ_meas_Y(0)', 'circ_meas_Z(0)']\n        ```\n        For process tomography of the same circuit with preparation in the\n        SIC-POVM basis it would return:\n        ```\n        [\n            'circ_prep_S0(0)_meas_X(0)', 'circ_prep_S0(0)_meas_Y(0)',\n            'circ_prep_S0(0)_meas_Z(0)', 'circ_prep_S1(0)_meas_X(0)',\n            'circ_prep_S1(0)_meas_Y(0)', 'circ_prep_S1(0)_meas_Z(0)',\n            'circ_prep_S2(0)_meas_X(0)', 'circ_prep_S2(0)_meas_Y(0)',\n            'circ_prep_S2(0)_meas_Z(0)', 'circ_prep_S3(0)_meas_X(0)',\n            'circ_prep_S3(0)_meas_Y(0)', 'circ_prep_S3(0)_meas_Z(0)'\n        ]\n        ```\n    "
    if (not isinstance(circuit, QuantumCircuit)):
        raise QiskitError('Input circuit must be a QuantumCircuit object')
    dics = tomoset['circuits']
    labels = tomography_circuit_names(tomoset, circuit.name)
    tomography_circuits = []
    for (label, conf) in zip(labels, dics):
        tmp = circuit
        if ('prep' in conf):
            prep = QuantumCircuit(qreg, creg, name='tmp_prep')
            for (qubit, op) in conf['prep'].items():
                tomoset['prep_basis'].prep_gate(prep, qreg[qubit], op)
                prep.barrier(qreg[qubit])
            tmp = (prep + tmp)
        meas = QuantumCircuit(qreg, creg, name='tmp_meas')
        for (qubit, op) in conf['meas'].items():
            meas.barrier(qreg[qubit])
            tomoset['meas_basis'].meas_gate(meas, qreg[qubit], op)
            meas.measure(qreg[qubit], creg[qubit])
        tmp = (tmp + meas)
        tmp.name = label
        tomography_circuits.append(tmp)
    logger.info('>> created tomography circuits for "%s"', circuit.name)
    return tomography_circuits
Add tomography measurement circuits to a QuantumProgram.

The quantum program must contain a circuit 'name', which is treated as a
state preparation circuit for state tomography, or as teh circuit being
measured for process tomography. This function then appends the circuit
with a set of measurements specified by the input `tomography_set`,
optionally it also prepends the circuit with state preparation circuits if
they are specified in the `tomography_set`.

For n-qubit tomography with a tomographically complete set of preparations
and measurements this results in $4^n 3^n$ circuits being added to the
quantum program.

Args:
    circuit (QuantumCircuit): The circuit to be appended with tomography
                              state preparation and/or measurements.
    qreg (QuantumRegister): the quantum register containing qubits to be
                            measured.
    creg (ClassicalRegister): the classical register containing bits to
                              store measurement outcomes.
    tomoset (tomography_set): the dict of tomography configurations.

Returns:
    list: A list of quantum tomography circuits for the input circuit.

Raises:
    QiskitError: if circuit is not a valid QuantumCircuit

Example:
    For a tomography set specifying state tomography of qubit-0 prepared
    by a circuit 'circ' this would return:
    ```
    ['circ_meas_X(0)', 'circ_meas_Y(0)', 'circ_meas_Z(0)']
    ```
    For process tomography of the same circuit with preparation in the
    SIC-POVM basis it would return:
    ```
    [
        'circ_prep_S0(0)_meas_X(0)', 'circ_prep_S0(0)_meas_Y(0)',
        'circ_prep_S0(0)_meas_Z(0)', 'circ_prep_S1(0)_meas_X(0)',
        'circ_prep_S1(0)_meas_Y(0)', 'circ_prep_S1(0)_meas_Z(0)',
        'circ_prep_S2(0)_meas_X(0)', 'circ_prep_S2(0)_meas_Y(0)',
        'circ_prep_S2(0)_meas_Z(0)', 'circ_prep_S3(0)_meas_X(0)',
        'circ_prep_S3(0)_meas_Y(0)', 'circ_prep_S3(0)_meas_Z(0)'
    ]
    ```
def create_tomography_circuits(circuit, qreg, creg, tomoset):
    "\n    Add tomography measurement circuits to a QuantumProgram.\n\n    The quantum program must contain a circuit 'name', which is treated as a\n    state preparation circuit for state tomography, or as teh circuit being\n    measured for process tomography. This function then appends the circuit\n    with a set of measurements specified by the input `tomography_set`,\n    optionally it also prepends the circuit with state preparation circuits if\n    they are specified in the `tomography_set`.\n\n    For n-qubit tomography with a tomographically complete set of preparations\n    and measurements this results in $4^n 3^n$ circuits being added to the\n    quantum program.\n\n    Args:\n        circuit (QuantumCircuit): The circuit to be appended with tomography\n                                  state preparation and/or measurements.\n        qreg (QuantumRegister): the quantum register containing qubits to be\n                                measured.\n        creg (ClassicalRegister): the classical register containing bits to\n                                  store measurement outcomes.\n        tomoset (tomography_set): the dict of tomography configurations.\n\n    Returns:\n        list: A list of quantum tomography circuits for the input circuit.\n\n    Raises:\n        QiskitError: if circuit is not a valid QuantumCircuit\n\n    Example:\n        For a tomography set specifying state tomography of qubit-0 prepared\n        by a circuit 'circ' this would return:\n        ```\n        ['circ_meas_X(0)', 'circ_meas_Y(0)', 'circ_meas_Z(0)']\n        ```\n        For process tomography of the same circuit with preparation in the\n        SIC-POVM basis it would return:\n        ```\n        [\n            'circ_prep_S0(0)_meas_X(0)', 'circ_prep_S0(0)_meas_Y(0)',\n            'circ_prep_S0(0)_meas_Z(0)', 'circ_prep_S1(0)_meas_X(0)',\n            'circ_prep_S1(0)_meas_Y(0)', 'circ_prep_S1(0)_meas_Z(0)',\n            'circ_prep_S2(0)_meas_X(0)', 'circ_prep_S2(0)_meas_Y(0)',\n            'circ_prep_S2(0)_meas_Z(0)', 'circ_prep_S3(0)_meas_X(0)',\n            'circ_prep_S3(0)_meas_Y(0)', 'circ_prep_S3(0)_meas_Z(0)'\n        ]\n        ```\n    "
    if (not isinstance(circuit, QuantumCircuit)):
        raise QiskitError('Input circuit must be a QuantumCircuit object')
    dics = tomoset['circuits']
    labels = tomography_circuit_names(tomoset, circuit.name)
    tomography_circuits = []
    for (label, conf) in zip(labels, dics):
        tmp = circuit
        if ('prep' in conf):
            prep = QuantumCircuit(qreg, creg, name='tmp_prep')
            for (qubit, op) in conf['prep'].items():
                tomoset['prep_basis'].prep_gate(prep, qreg[qubit], op)
                prep.barrier(qreg[qubit])
            tmp = (prep + tmp)
        meas = QuantumCircuit(qreg, creg, name='tmp_meas')
        for (qubit, op) in conf['meas'].items():
            meas.barrier(qreg[qubit])
            tomoset['meas_basis'].meas_gate(meas, qreg[qubit], op)
            meas.measure(qreg[qubit], creg[qubit])
        tmp = (tmp + meas)
        tmp.name = label
        tomography_circuits.append(tmp)
    logger.info('>> created tomography circuits for "%s"', circuit.name)
    return tomography_circuits