\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}

\input{.common.tex}

% Heff with Theta and Theta*

\begin{document}


\begin{tikzpicture}[x=0.5cm,y=0.5cm]
    \node[ten] (M0) at (0,0) {};
    \node[mpo,below=of M0] (W0) {};
    \node[ten,below=of W0] (m0) {};
    \draw[leg] (M0) -- (W0);
    \draw[leg] (W0) -- (m0);
    \pgfmathsetmacro{\N}{9}
    \pgfmathsetmacro{\iMax}{\N-2}
    \foreach \i in {0,...,\iMax} {
        \pgfmathsetmacro{\j}{int(\i+1)}
        \node[ten, right=of M\i] (M\j) {}; % $M^{[\the\numexpr\i+1]}$
        \node[mpo, right=of W\i] (W\j) {}; % $W^{[\the\numexpr\i+1]}$
        \node[ten, right=of m\i] (m\j) {}; % $m^{[\the\numexpr\i+1]}$
        % horizontal
        \pgfmathparse{\j>5 || \j<3 || \j==4}
        \ifnum\pgfmathresult=1 \relax
          \draw[leg] (M\i) -- (M\j);
          \draw[leg] (m\i) -- (m\j);
        \fi
        \draw[leg] (W\i) -- (W\j);
        % vertical
        \pgfmathparse{\j>4 || \j<3}
        \ifnum\pgfmathresult=1 \relax
            \draw[leg] (M\j) -- (W\j);
            \draw[leg] (W\j) -- (m\j);
        \fi
    }
    % \pgfmathsetmacro{\dx}{0.3*\nodeDistance}
    % \pgfmathsetmacro{\dy}{0.3*\nodeDistance}
    \def\dx{0.4}
    \def\dy{0.4}

    % \node[draw, dashed, rounded corners=5pt, fit=(M0) (M2) (m0) (m2)] (group) {};
    \begin{scope}[on background layer]
      \draw[fill=\colorHeff,rounded corners=2] 
        ($(M0)+(-\dx, \dy)$) --
        ($(M2)+( \dx, \dy)$) --
        ($(W2)+( \dx, \dy)$) --
        ($(W5)+(-\dx, \dy)$) --
        ($(M5)+(-\dx, \dy)$) --
        ($(M8)+( \dx, \dy)$) --
        ($(m8)+( \dx,-\dy)$) --
        ($(m5)+(-\dx,-\dy)$) --
        ($(W5)+(-\dx,-\dy)$) --
        ($(W2)+( \dx,-\dy)$) --
        ($(m2)+( \dx,-\dy)$) --
        ($(m0)+(-\dx,-\dy)$) --
        cycle;

      \draw[fill=\colorTheta,rounded corners=2pt] 
        ($(M3)+(-\dx, \dy)$) -- 
        ($(M4)+( \dx, \dy)$) -- 
        ($(M4)+( \dx,-\dy)$) -- 
        ($(M3)+(-\dx,-\dy)$) -- 
        cycle;
      \draw[fill=\colorTheta,rounded corners=2pt] 
        ($(m3)+(-\dx, \dy)$) -- 
        ($(m4)+( \dx, \dy)$) -- 
        ($(m4)+( \dx,-\dy)$) -- 
        ($(m3)+(-\dx,-\dy)$) -- 
        cycle;
    \end{scope}
    % \draw node[above left=of M0] {} -- node[above right=of M2] {} -- node[above right=of W2] {};

    % \node[left=of W0] (Heff) {$H_\text{eff}$ = };
    \node[anchor=south,above=0.1 of M1] (Heff) {$H_\text{eff}$};
    \node[anchor=south] (Theta)  at ($(M3)+0.5*(M4)-0.5*(M3)+(0,0.4)$) {$\Theta$};
    \node[anchor=north] (ThetaC) at ($(m3)+0.5*(m4)-0.5*(m3)-(0,0.4)$) {$\overline{\Theta}$};
\end{tikzpicture}

\end{document}
