digraph fullchain {
    label="DUNE processing chain -- Wire-Cell parts"
    labelloc="top"

    // rankdir=LR

    // external
    DAQ[shape=hexagon]
    Kine[label="particle kinematics"]

    // data
    node[shape=ellipse]
    pds[label="PDS\nraw"]
    pds2[label="PDS\ncooked"]
    adc[label="TPC\nADC"]
    roi[label="Per-unit\nsignal-ROI"]
    img[label="Per-unit\n3D images"]
    clu[label="Per-unit\nTPC clusters"]
    clus[label="N-1 other units\nTPC clusters"]
    glu[label="Whole-module\nTPC clusters"]
    traj[label="cluster charge/light bundle"]
    part[label="particle kinematics\nreconstruction"]
    ndi[label="ND-LAr pixels*", color=gray]

    {rank=same pds2 glu}

    // proc
    node[shape=box]
    p1[label="PDS1: PDS processing"]
    LArG4[label="Geant4"]
    node[color=red]
    SIM[label="TPC SIM: drift+response+noise"]
    t1[label="TPC1: NF+SP"]
    t2[label="TPC2: 3D imaging"]
    t3[label="TPC3: 3D clustering"]
    m3[label="TPC4: cluster stitching*"]
    d3[label="flash matching*"]
    patrec[label="pattern recognition*"]

    subgraph cluster_gpucpu {
        label="CPU or GPU"
        node[shape=box]
        FFT
        DNNROI
        DNNClust[label="DNNClust*"]
        edge[style=invis]
        FFT->DNNROI->DNNClust
    }

    {rank=same t1 p1}
    {rank=same DAQ SIM}


    Kine->LArG4

    LArG4->pds
    pds->p1->pds2

    LArG4->SIM

    DAQ->pds
    DAQ->adc
    SIM->adc
    adc->t1
    t1->roi
    roi->t2
    t2->img
    img->t3
    t3->clu
    clu->m3
    clus->m3
    m3->glu
    glu->d3
    pds2->d3
    d3->traj
    traj->patrec
    patrec->part
    
    ndi->t3[style=dashed]

    SIM->FFT
    edge[constraint=false]
    t1->FFT
    t1->DNNROI
    t3->DNNClust

}
