4

Here is a flowchart-type graphic that I would like to remake with TikZ. image

In principle, I know how to do these things, using \node (a) at (1,2) { text }; and \draw (a) -- (b); commands. However, I'm not very happy with that approach. I have the following concerns:

  • The graphic here is very busy, and I fear that I will get confused with all the nodes and arrows.
  • Sections of the flowchart are "inscribed" into other nodes - the colored nodes and arrows are always encapsulated within the grey nodes and arrows. I'm unsure about how to deal with this - should I make the "small" flowcharts tikzpictures inside nodes of the "outer" flowchart, or is there a more elegant solution? If I split this up into several tikzpictures, how would I make sure the alignment works out as intended?
  • The large node on the left is divided in "sections" with the dashed lines. What is the best way to go about this? Shall I draw the node (and the "sectioning") myself with draw ... rectangle ..., or is there some nice way to "subsection" a TikZ node?
  • The small colored nodes on the left are multicolored - how can one make such nodes with TikZ?

Any suggestions on how to create a busy flowchart like this one in a nice way that is easy to edit and reformat is greatly appreciated!

EDIT

I've started implementing the suggestions from the comments. I started with the left part of the graphic, which looks like this:

\usepackage[utf8]{inputenc}
\usepackage{tikz}
\newcommand\acr[1]{#1}

\usetikzlibrary{fit,positioning,calc}
\begin{document}
\tikzset{anacat/.style={anchor=north west,minimum height=1.5em,x=.3cm,y=.3cm,every node/.style={scale=0.4}}}
\tikzset{bin/.style={draw=black,anchor=west,text width=3cm}}
  \begin{tikzpicture}[x=1cm,y=2cm]
  \begin{scope}[at={(0,0)},local bounding box=Hyy,anacat]
    \node[rotate=90,anchor=north,align=center] at (-1,3) {$H\to\gamma\gamma$};
    \node[bin] at (0,0) {low $p_{\textrm{T}t}$};
    \node[bin] at (0,1) {high $p_{\textrm{T}t}$};
    \node[bin] at (0,2) {\acr{VBF} loose (\acr{MVA})};
    \node[bin] at (0,3) {\acr{VBF} tight (\acr{MVA})};
    \node[bin] at (0,4) {\acr{VH} leptonic};
    \node[bin] at (0,5) {$VH$ leptonic};
    \node[bin] at (0,6) {$t\bar{t}H$ leptonic};  
  \end{scope}
  \node[draw,dotted,fit=(Hyy)] {};
  \begin{scope}[at={($(Hyy.south)$)},local bounding box=HZZ,anacat]
    \node[rotate=90,anchor=north,align=center] at (-1,2) {$H\to ZZ$};
    \node[bin] at (0,0) {ggF $n_{j}=0$};
    \node[bin] at (0,1) {ggF $n_{j}=1$};
    \node[bin] at (0,2) {\acr{VBF} leptonic};
    \node[bin] at (0,3) {\acr{VH} leptonic};
    \node[bin] at (0,4) {\acr{VH} hadronic};
  \end{scope}
  \node[draw,dotted,fit=(HZZ)] {};
  \begin{scope}[at={($(HZZ.south)$)},local bounding box=HWW,anacat]
    \node[rotate=90,anchor=north,align=center] at (-1,2.5) {$H\to WW$};
    \node[bin] at (0,0) {ggF $n_{j}=0$};
    \node[bin] at (0,1) {ggF $n_{j}=1$};
    \node[bin] at (0,2) {ggF $n_{j}\geq 2$};
    \node[bin] at (0,3) {\acr{VBF} $n_{j}\geq 2$};
    \node[bin] at (0,4) {\acr{WH}};
    \node[bin] at (0,5) {\acr{ZH}};
  \end{scope}
  \node[draw,dotted,fit=(HWW)] {};
  \begin{scope}[at={($(HWW.south)$)},local bounding box=Hbb,anacat]
    \node[rotate=90,anchor=north,align=center] at (-1,2) {$H\to b\bar{b}$};
    \node[bin] at (0,1) {\acr{MVA} low $p_{\textrm{T}^V}$};
    \node[bin] at (0,2) {\acr{MVA} low $p_{\textrm{T}^V}$};
    \node[bin] at (0,3) {$\cdots$};
  \end{scope}
  \node[draw,dotted,fit=(Hbb)] {};
  \begin{scope}[at={($(Hbb.south)$)},local bounding box=Htt,anacat]
    \node[rotate=90,anchor=north,align=center] at (-1,1) {$H\to \tau\bar{\tau}$};
    \node[bin] at (0,1) {$\cdots$};
  \end{scope}
  \node[draw,dotted,fit=(Htt)] {};
\end{tikzpicture}

\end{document}

I'm trying to use the at=... syntax to facilitate relative positioning of the scopes, but it doesn't seem to work the way I intend. It currently looks like this:

broken left part

Is there any non-obvious interaction between relative positioning and the fit package?

carsten
  • 2,966
  • 1
    Maybe you should take a look at the tree and graph environment within tikz. For grouping, {scope} is a good option, that also allows you to set specific options for a limited set of commands. – Huang_d Jun 12 '17 at 15:29
  • 1
    For the grey rectangles surrounding other nodes, look at the fit library (nesting tikzpictures should be avoided if possible, I think). – Torbjørn T. Jun 12 '17 at 17:13
  • 1
    For the multicolored nodes, have a look at http://tex.stackexchange.com/questions/368908/tikz-only-fill-75-of-the-node-background-with-color/ – Torbjørn T. Jun 12 '17 at 17:15
  • 1
    See https://tex.stackexchange.com/questions/358740/drawing-system-architecture-in-tikz/358808?s=1|0.8308#358808 and https://tex.stackexchange.com/questions/362307/best-practice-for-creating-tikz-pictures-with-nested-elements/362328?s=2|0.0214#362328 – John Kormylo Jun 12 '17 at 19:01
  • thanks for all the helpful comments! I've started coding the graphic, but haven't been very successful so far. I've attached my attempts as an EDIT. – carsten Jun 13 '17 at 16:27

1 Answers1

7

I have created a couple of pics for the multicolored nodes:

  1. twocolors with 4 args respectively {first color/second color/proportion of the node colored with the first color/node text}
  2. threecolors with 6 args respectively {first color/second color/third color/proportion of the node colored with the first color/proportion of the node colored with the second color/node text}.

Moreover, I have used some tikz matrix to ease the node positioning.

The following is (something more than) a starting point, let me know if you have some difficulties in completing it.

I don't know how the node texts should be, hence I didn't care much about those.

The use of the macro \acr (which you have in your MWE) is not clear to me, at the moment it does... nothing!

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\newcommand{\acr}[1]{#1}% <--- what is this used for? 
\usetikzlibrary{fit,positioning,calc,matrix}
\usetikzlibrary{shapes,arrows.meta}

\begin{document}
    \tikzset{%
        bin/.style={draw=black, text width=3cm, thick, thick,text height=2ex,text depth=.5ex},
        dotbin/.style={draw=black, text width=3cm, thick},
        colbin/.style={text width=3cm, thick,text height=2ex,text depth=.5ex},
        littlebin/.style={draw=black, text width=2cm, thick},
        bigbin/.style={thick, minimum height=2.5cm, minimum width=1cm},
        graynode/.style={draw=gray, very thick, text width=1.5cm, minimum height=1.7cm,font=\large},    
        myarrow/.style={very thick, -latex},    
        pics/twocolors/.style args={#1/#2/#3/#4}{code={%          
                \node[bin, path picture={%
                    \fill[#1] (a.south west) rectangle ($(a.north west)!#3!(a.north east)$);
                    \fill[#2] ($(a.north west)!#3!(a.north east)$) rectangle (a.south east);
                }] (a) {#4};  
        }},
        pics/threecolors/.style args={#1/#2/#3/#4/#5/#6}{code={%          
                \node[bin, path picture={%
                    \fill[#1] (b.south west) rectangle ($(b.north west)!#4!(b.north east)$);
                    \fill[#2] ($(b.south west)!#4!(b.south east)$) rectangle ($(b.north west)!#5!(b.north east)$) ;
                    \fill[#3] ($(b.north west)!#5!(b.north east)$) rectangle (b.south east);
                }] (b) {#6};
        }},
    }
    \resizebox{\textwidth}{!}{% 
        \begin{tikzpicture}
        \matrix[row sep = 10pt] (M1) {%
            % h gamma gamma
            \pic {twocolors={blue/cyan/.75/low $p_{\textrm{T}t}$}}; \\
            \pic {threecolors={blue/cyan/orange/.10/.90/high $p_{\textrm{T}t}$}}; \\
            \pic {twocolors={orange/cyan/.60/\acr{VBF} loose (\acr{MVA})}}; \\
            \node[bin, fill=green]  {\acr{VH} leptonic};\\
            \pic {twocolors={purple/green/.80/$t\bar{t}H$ leptonic}}; \\
            \node[dotbin] {\dots};\\
        };
        \node[left =10pt of M1] (D1) {\rotatebox{90}{$H\to\gamma\gamma$}};
        % h zz
        \matrix[row sep = 4pt, below=10pt of M1.south east, anchor=north east] (M2) {%
            \node[littlebin, fill=blue]  {\dots};\\
            \node[littlebin, fill=blue]  {\dots};\\
            \node[littlebin, fill=orange]  {\dots};\\
        };
        \node[left =10pt of M2] {$H\to ZZ$};
        % h ww
        \matrix[row sep = 10pt,below=10pt of M2.south east, anchor=north east] (M3) {%
            \pic {twocolors={blue/cyan/.80/$=0$jet}}; \\
            \pic {twocolors={blue/cyan/.20/$=1$jet}}; \\
            \pic {twocolors={orange/cyan/.70/$\geq2$jet VBF cuts}}; \\
            \node[dotbin] {\dots};\\
        };
        \node[left =10pt of M3] (D3) {\rotatebox{90}{$H\to WW$}};
        % h bb
        \matrix[row sep = 10pt,below=10pt of M3] (M4) {%
            \node[bin, fill=green]  {MVA low $p_{T}V$};\\
            \node[bin, fill=green]  {MVA high $p_{T}V$};\\
            \node[dotbin] {\dots};\\
        };
        \node[left =10pt of M4] (D4) {\rotatebox{90}{$H\to b\bar{b}$}};
        % h tt
        \matrix[row sep = 4pt, below=10pt of M4, xshift=.5cm] (M5) {%
            \node[littlebin, fill=cyan]  {\dots};\\
            \node[littlebin, fill=orange]  {\dots};\\
            \node[littlebin, fill=green]  {\dots};\\
        };
        \node[left =10pt of M5] (D5) {$H\to \tau\tau$};
        \node[fit=(D1)(M1)(M5)] (firstblock) {};
        \node[fit=(D1)(M1)(M5), draw=gray, very thick] {};
        \foreach \n/\m in {1/2,2/3,3/4,4/5}{%
            \coordinate (M\n-M\m) at ($(M\n.south)!.5!(M\m.north)$);
            \draw[gray, dashed]  ($(firstblock.north east)!(M\n-M\m)!(firstblock.north east)$) -- (M\n-M\m) -- ($(firstblock.north west)!(M\n-M\m)!(firstblock.north west)$);
        } 
%
        \matrix[row sep =50pt, right=50pt of firstblock, anchor=center] (MA) {%
            \node[draw=blue, fill=cyan, bigbin] (MA-1) {\rotatebox{90}{\large $\sigma (ggF)$}};\\
            \node[draw=red, fill=orange, bigbin] (MA-2) {\rotatebox{90}{\large $\sigma (VBF)$}};\\
            \node[draw=olive, fill=green, bigbin] (MA-3) {\rotatebox{90}{\large $\sigma (VH)$}};\\
        };
        \matrix[row sep =20pt, right=30pt of MA-1] {%
            \node[draw=blue, fill=blue, colbin] (MB-1) {$=0-jet$};\\
            \node[draw=blue, fill=cyan, colbin] (MB-2) {$\geq 1$-jet};\\
            \node[draw=blue, fill=cyan, colbin] (MB-3) {$\geq 2$-jet VBF cuts};\\
        };
        \matrix[row sep =20pt, right=30pt of MA-2] {%
            \node[draw=red, fill=orange, colbin] (MC-1) {Rest};\\
            \node[draw=red, fill=orange, colbin] (MC-2) {$\geq 2$-jet VBF cuts};\\
            \node[draw=red, fill=orange, colbin] (MC-3) {high$-q^{2}$ BSM};\\
        };
        \matrix[row sep =20pt, right=30pt of MA-3] {%
            \node[draw=olive, fill=green, colbin] (MD-1) {low $p_{T}^{V}$};\\
            \node[draw=olive, fill=green, colbin] (MD-2) {high $p_{T}^{V}$};\\
            \node[draw=olive, fill=green, colbin] (MD-3) {very high $p_{T}^{V}$};\\
        };
        \node[above=38pt of MA.north west, anchor=south west,text height=3.5ex,text depth=.5ex] (topnode) {ratios of $\quad\Gamma_{\gamma\gamma}\quad \Gamma_{zz}\quad\Gamma_{ww}\quad\Gamma_{b\bar{b}}\quad\Gamma_{\tau\tau}\quad (\Gamma_{z_{\gamma}}\quad \Gamma_{\mu\mu})$};
        \matrix[row sep =4pt, right=30pt of MB-2] (MBB) {%
            \node[draw=blue, fill=cyan, littlebin] (MBB-1) {\dots};\\
            \node[draw=blue, fill=cyan, littlebin] (MBB-2) {\dots};\\
            \node[draw=blue, fill=cyan, littlebin] (MBB-3) {\dots};\\
        };
        \matrix[row sep =4pt, right=30pt of MB-3] {%
            \node[draw=blue, fill=cyan, littlebin] (MBC-1) {\dots};\\
            \node[draw=blue, fill=cyan, littlebin] (MBC-2) {\dots};\\
        };
        \matrix[column sep=36pt, below=40pt of MA.south west, anchor=north west,ampersand replacement=\&] (MD) {%
            \node[draw=blue, fill=purple, text width=1.2cm] {$\sigma(ttH)$}; \&
            \node {}; \&
            \node[draw=orange, fill=yellow, text width=1.2cm] {$\sigma(b\bar{b}H)$}; \&
            \node[draw=orange, fill=yellow, text width=1.2cm] {$\sigma(tH)$}; \\
        };
        \node[fit=(topnode)(MA)(MD)(MBB), draw=gray, very thick] (secondblock) {};
        \matrix[row sep=40pt, right=20pt of secondblock] (MR) {%
            \node[graynode] (MR-1) {$\mu_{i},k_{i}$}; \\
            \node[graynode] (MR-2) {$g_{k}$}; \\
            \node[graynode] (MR-3) {EFT\\coeff}; \\
            \node[graynode] (MR-4) {specific BSM}; \\[-14pt]
            \node[gray,text width=1.5cm, align=center] {\scalebox{3}{$\vdots$}}; \\
    };
    \draw[myarrow,gray] (firstblock) -- (secondblock);
    \foreach \n in {1,2,...,4}{%
        \draw[myarrow,gray] ($(secondblock.north east)!(MR-\n.west)!(secondblock.south east)$) -- (MR-\n.west);
    }
    \coordinate (top-top) at ($(topnode)!.5!(MB-1.north)$);
    \draw[gray, dashed]  ($(secondblock.north east)!(top-top)!(secondblock.north east)$) -- (top-top) -- ($(secondblock.north west)!(top-top)!(secondblock.north west)$);
    \draw[myarrow,blue] (MA-1) -- (MB-2);
    \draw[myarrow,blue] ($(MA-1.east)!.5!(MB-2.west)$) |- (MB-1);
    \draw[myarrow,blue] ($(MA-1.east)!.5!(MB-2.west)$) |- (MB-3);
    \draw[myarrow,blue] (MB-2) -- (MBB-2);
    \draw[myarrow,blue] ($(MB-2.east)!.5!(MBB-2.west)$) |- (MBB-1);
    \draw[myarrow,blue] ($(MB-2.east)!.5!(MBB-2.west)$) |- (MBB-3);
    \draw[myarrow,red] (MA-2) -- (MC-2);
    \draw[myarrow,red] ($(MA-2.east)!.5!(MC-2.west)$) |- (MC-1);
    \draw[myarrow,red] ($(MA-2.east)!.5!(MC-2.west)$) |- (MC-3);
    \draw[myarrow,olive] (MA-3) -- (MD-2);
    \draw[myarrow,olive] ($(MA-3.east)!.5!(MD-2.west)$) |- (MD-1);
    \draw[myarrow,olive] ($(MA-3.east)!.5!(MD-2.west)$) |- (MD-3);
    \coordinate (middle2little) at ($(MBC-1.west)!.5!(MBC-2.west)$);
    \coordinate (middlelittleless) at ($(MB-3.east)!.5!(middle2little)$);
    \draw[myarrow,blue] (MB-3.east) -- (middlelittleless) |- (MBC-1.west);
    \draw[myarrow,blue] (MB-3.east) -- (middlelittleless) |- (MBC-2.west);
    \end{tikzpicture}
    }
\end{document}

enter image description here

CarLaTeX
  • 62,716