# How can i draw this circuit diagram?

I am trying to draw the following diagram using qcircuit package but failed to do so. Guide me how draw this diagram.

• Welcome to TeX.SE! When you are saying that you are trying: what did you try specifically and where did you get stuck? Please provide us with your attempt in form of a minimal working example, i.e. a minimal document that starts with \documentclass and ends with \end{document}. – user121799 Sep 9 '18 at 23:13
• Circuitikz (now) has some built in quantum components. See also tex.stackexchange.com/questions/199683/… – John Kormylo Sep 10 '18 at 3:41

I think the package has not yet implemented how to color the gates, at least nothing is mentioned in the manual;Just to learn and fun,an option in qcircuit code embedded in a tikz node , to add the color padding to the gate. Of course you can draw independently using tikz commands, with more colorful results.

RESULT:

MWE:

\documentclass[tikz,border=15pt]{standalone}
\usepackage{mathptmx}
\usepackage[braket,qm]{qcircuit}

\begin{document}
\begin{tikzpicture}
\fill[black!20](0,0)++(-21pt,-24pt) rectangle ++(25.8pt,45.5pt);
\node at (0,0) {
\Qcircuit @C=2em @R=2.5em {
\lstick{\ket{0}} &\qw & \multigate{1}{\enspace \textrm P \enspace} & \gate{U_2} & \qw\\
\hspace{-10pt}\ket{0}^{\otimes n}&{/\!/}\qw &\ghost{\enspace  \textrm P \enspace} & \ctrl{-1} & \qw \\
}
};
\end{tikzpicture}
\end{document}