This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
latex:tikz [2018/06/23 16:00] – [Flowchart] iwn | latex:tikz [2022/12/02 15:40] – [For-loops: Pseudorapidity 𝜂 and polar angle 𝜃] iwn | ||
---|---|---|---|
Line 4: | Line 4: | ||
'' | '' | ||
- | * [[https:// | + | * [[https:// |
- | * [[https:// | + | * [[https:// |
- | * [[http:// | + | * [[http:// |
- | * [[http:// | + | * The examples below and many more are also available on [[https:// |
- | + | * [[http:// | |
+ | * [[http:// | ||
+ | * For Feynman diagrams, please see [[latex: | ||
===== Control regions ===== | ===== Control regions ===== | ||
Line 110: | Line 111: | ||
===== Sets ===== | ===== Sets ===== | ||
- | Example | + | Another simple example |
<WRAP group>< | <WRAP group>< | ||
Line 146: | Line 147: | ||
===== Flowchart ===== | ===== Flowchart ===== | ||
- | Another simple example | + | Example |
<WRAP group>< | <WRAP group>< | ||
Line 167: | Line 168: | ||
\tuning(C, | \tuning(C, | ||
\tuning(Cl, | \tuning(Cl, | ||
- | \tuning(Cr, 2.3, 3, E\b A\b D\b G\b B\b E\b, standard E\b/half step down) | ||
\tuning(Bl, | \tuning(Bl, | ||
\tuning(Br, 1, 2, DADFAD, | \tuning(Br, 1, 2, DADFAD, | ||
Line 178: | Line 178: | ||
\draw[arrow] | \draw[arrow] | ||
\draw[sarrow] | \draw[sarrow] | ||
- | \draw[sarrow] | ||
\draw[sarrow,< | \draw[sarrow,< | ||
\draw[sarrow] | \draw[sarrow] | ||
Line 192: | Line 191: | ||
\\ \\ \\ \\ | \\ \\ \\ \\ | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | Example of a node with arrows to text below it ([[latex: | ||
+ | |||
+ | <WRAP group>< | ||
+ | <code latex> | ||
+ | \begin{tikzpicture}[yscale=0.8, | ||
+ | | ||
+ | % FIRST COLUMN | ||
+ | \node[anchor=west, | ||
+ | \node (L1) at (0.5,3) {\strut$jj\nu\nu$}; | ||
+ | \node (L2) at (0.5,2) {\strut bb$\nu\nu$}; | ||
+ | \node (L3) at (0.5,1) {\strut tt$\nu\nu$}; | ||
+ | \draw[->, | ||
+ | \draw[->, | ||
+ | \draw[->, | ||
+ | | ||
+ | % SECOND COLUMN | ||
+ | \begin{scope}[shift={(2.5, | ||
+ | \node[draw=myblue, | ||
+ | \node (M1) at (0.5,3) {\strut$jj\mu\mu$}; | ||
+ | \node (M2) at (0.5,2) {\strut bb$\tau\tau$, | ||
+ | \node (M3) at (0.5,1) {\strut tt$\tau\tau$}; | ||
+ | \draw[->, | ||
+ | \draw[->, | ||
+ | \draw[->, | ||
+ | \end{scope} | ||
+ | | ||
+ | % THIRD COLUMN | ||
+ | \begin{scope}[shift={(5.0, | ||
+ | \node[draw=myblue, | ||
+ | \node (R1) at (0.5,3) {\strut$jj\mu\nu$}; | ||
+ | \draw[->, | ||
+ | \end{scope} | ||
+ | | ||
+ | \end{tikzpicture} | ||
+ | </ | ||
+ | </ | ||
+ | \\ \\ \\ \\ | ||
+ | {{ latex: | ||
+ | \\ \\ \\ \\ | ||
+ | </ | ||
+ | |||
+ | |||
===== Atom models ===== | ===== Atom models ===== | ||
Line 345: | Line 389: | ||
</ | </ | ||
+ | Using a for-loop over two variables: | ||
+ | <WRAP group>< | ||
+ | <code latex> | ||
+ | \begin{tikzpicture}[scale=3] | ||
+ | | ||
+ | % limits | ||
+ | \def\R{1.2} % radius/ | ||
+ | | ||
+ | % axis labels | ||
+ | \node[scale=1, | ||
+ | \node[scale=1, | ||
+ | | ||
+ | % lines | ||
+ | \foreach \t/\e in {90/ | ||
+ | \pgfkeys{/ | ||
+ | \draw[->, | ||
+ | (0,0) -- (\t:\R) node[anchor=180+\t, | ||
+ | node[black, | ||
+ | } | ||
+ | | ||
+ | \end{tikzpicture} | ||
+ | </ | ||
+ | </ | ||
+ | \\ | ||
+ | {{ latex: | ||
+ | \\ | ||
+ | </ | ||
+ | Using for-loop and calculation + rounding: | ||
<WRAP group>< | <WRAP group>< | ||
<code latex> | <code latex> | ||
Line 351: | Line 423: | ||
| | ||
% limits | % limits | ||
- | \def\R{1.2} | + | \def\R{1.2} |
| | ||
% axis labels | % axis labels | ||
- | \node[scale=0.9,below=5pt,left=2pt] at (0,\R) {$y$}; | + | \node[scale=1,below left=1] at (0,\R) {$y$}; |
- | \node[scale=0.9,left=5pt, | + | \node[scale=1,below left=1] at (\R,0) {$z$}; |
| | ||
% lines | % lines | ||
- | \foreach \t/\e in {90/0,60/0.55,45/0.88,30/1.32,10/2.44,0/\infty}{ | + | |
- | \draw[->, | + | |
- | (0,0) -- ({\R*cos(\t)},{\R*sin(\t)}) | + | \ifnum \t = 0 |
- | | + | \def\e{+\infty} |
- | \node[fill=white, | + | \else |
+ | \pgfmathparse{-ln(tan(\t/ | ||
+ | %\pgfmathroundto{\pgfmathresult} % round without traling zeroes | ||
+ | \pgfmathroundtozerofill{\pgfmathresult} % round with trailing zeroes | ||
+ | \pgfmathsetmacro\e{\t==90? | ||
+ | \fi | ||
+ | \draw[->, | ||
+ | (0,0) -- (\t:\R) node[anchor=180+\t, | ||
+ | node[black, | ||
} | } | ||
- | | + | |
\end{tikzpicture} | \end{tikzpicture} | ||
</ | </ | ||
Line 756: | Line 836: | ||
===== 3D axis with spherical coordinates & CMS coordinate system ===== | ===== 3D axis with spherical coordinates & CMS coordinate system ===== | ||
- | This piece of code is based on [[https:// | + | This piece of code is based on [[https:// |
<WRAP group>< | <WRAP group>< | ||
Line 794: | Line 874: | ||
- | An example of rotating the 3D axes with the CMS conventional coordinate system by using the option '' | + | An example of rotating the 3D axes with the CMS conventional coordinate system by using the option '' |
<WRAP group>< | <WRAP group>< | ||
Line 864: | Line 944: | ||
\end{tikzpicture} | \end{tikzpicture} | ||
</ | </ | ||
- | |||
- | |||
- | |||
- | |||
Line 875: | Line 951: | ||
===== Tau lepton decay signatures ===== | ===== Tau lepton decay signatures ===== | ||
- | Inspiration from [[http:// | + | Inspiration from [[http:// |
\\ | \\ | ||
Line 931: | Line 1007: | ||
\\ | \\ | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
===== Higgs decay planes ===== | ===== Higgs decay planes ===== | ||
- | Decay planes of Higgs decay to measure the Higgs boson' | + | Decay planes of Higgs decay to measure the Higgs boson' |
<WRAP group>< | <WRAP group>< | ||
Line 948: | Line 1027: | ||
+ | |||
+ | ===== Impact parameters ===== | ||
+ | |||
+ | Examples of defining impact parameters in proton collisions ([[https:// | ||
+ | |||
+ | <WRAP group>< | ||
+ | {{latex: | ||
+ | </ | ||
+ | {{latex: | ||
+ | </ | ||
+ | {{latex: | ||
+ | </ | ||
===== Timelines and scales ===== | ===== Timelines and scales ===== | ||
- | Examples of a simple time or energy scale with labels and arrows ([[latex:tikz:timescales|full code]]). | + | Examples of a simple time or energy scale with labels and arrows ([[https://tikz.net/ |
<WRAP group>< | <WRAP group>< | ||
Line 968: | Line 1059: | ||
\\ | \\ | ||
</ | </ | ||
- | |||
Line 974: | Line 1064: | ||
===== Jets cones ===== | ===== Jets cones ===== | ||
- | Two examples of cones. Full code can be found [[latex:tikz:jet_cones|here]]. | + | Two examples of cones. Full code can be found [[https://tikz.net/ |
Line 1078: | Line 1168: | ||
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ | \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Top jets === | ||
+ | |||
+ | The full code can be found [[https:// | ||
+ | |||
+ | <WRAP group>< | ||
+ | {{ latex: | ||
+ | </ | ||
+ | {{latex: | ||
+ | </ | ||
+ | \\ \\ \\ \\ \\ | ||
+ | {{latex: | ||
+ | </ | ||
+ | |||
+ | <code latex> | ||
+ | \newcommand\jetcone[5][blue]{{ | ||
+ | \pgfmathanglebetweenpoints{\pgfpointanchor{# | ||
+ | \edef\ang{# | ||
+ | \edef\e{#5} | ||
+ | \edef\vang{\pgfmathresult} % angle of vector OV | ||
+ | \tikzmath{ | ||
+ | coordinate \C; | ||
+ | \C = (#2)-(#3); | ||
+ | \x = veclen(\Cx, | ||
+ | \y = tan(\ang)*(veclen(\Cx, | ||
+ | \a = veclen(\Cx, | ||
+ | \b = veclen(\Cx, | ||
+ | \angb = acos(sqrt(\e)*sin(\ang)); | ||
+ | } | ||
+ | \coordinate (tmpL) at ($(# | ||
+ | \draw[thin,# | ||
+ | (#3) ellipse({\a pt} and {\b pt}); | ||
+ | \draw[thin,# | ||
+ | (tmpL) arc(180-\angb: | ||
+ | -- ($(# | ||
+ | }} | ||
+ | |||
+ | \begin{tikzpicture} | ||
+ | \def\R{2.5} | ||
+ | \coordinate (O) at (0,0); | ||
+ | \coordinate (BJ) at ( 65:1.1*\R); % b jet 1 | ||
+ | \coordinate (J1) at ( 15:1.0*\R); % q jet 1 | ||
+ | \coordinate (J2) at (-20: | ||
+ | \jetcone[green!80!black]{O}{BJ}{14}{0.10} | ||
+ | \jetcone{O}{J1}{16}{0.08} | ||
+ | \jetcone{O}{J2}{16}{0.10} | ||
+ | \node[green!50!black] at (65: | ||
+ | \node[blue!80!black, | ||
+ | \end{tikzpicture} | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Jet vectors ===== | ||
+ | |||
+ | One can do some projections of jet and MET vectors to construct variables like MT2 in SUSY searches. The full code can be found [[https:// | ||
+ | |||
+ | <WRAP group>< | ||
+ | {{ latex: | ||
+ | </ | ||
+ | {{latex: | ||
+ | </ | ||
+ | |||
+ | <code latex> | ||
+ | \newcommand\jetcone[4]{ | ||
+ | \pgfmathanglebetweenpoints{\pgfpointanchor{# | ||
+ | \edef\tmpang{\pgfmathresult} | ||
+ | \coordinate (tmpC) at ($(# | ||
+ | \coordinate (tmpL) at ($(tmpC)+(\tmpang+90:# | ||
+ | \coordinate (tmpR) at ($(tmpC)+(\tmpang-90:# | ||
+ | \draw[cone, | ||
+ | %(tmpR) arc(90: | ||
+ | (tmpC) ellipse({# | ||
+ | \begin{scope} | ||
+ | \clip[rotate=\tmpang] (tmpR) -- (#1) -- (tmpL) arc(90: | ||
+ | \draw[vector] (#1) -- (#2); | ||
+ | \end{scope} | ||
+ | \draw[cone, | ||
+ | (tmpL) arc(90: | ||
+ | } | ||
+ | |||
+ | % MT2 | ||
+ | \begin{tikzpicture} | ||
+ | \def\R{2.8} | ||
+ | \coordinate (O) at (0,0); | ||
+ | \coordinate (J1) at (170:\R); % jet 1 pT | ||
+ | \coordinate (J2) at (-35:\R); % jet 2 pT | ||
+ | \coordinate (M1) at (130: | ||
+ | \coordinate (M2) at (-10: | ||
+ | \coordinate (M) at ($(M1)+(M2)$); | ||
+ | | ||
+ | % PTMISS | ||
+ | \draw[ptmiss, | ||
+ | \draw[ptmiss] (O) -- (M1) node[left=2, | ||
+ | \draw[ptmiss] (O) -- (M2) node[right=0] {$\ptmissX{2}$}; | ||
+ | \draw[ptmiss] (O) -- (M) node[above right=-1] {$\ptmiss$}; | ||
+ | | ||
+ | % JET CONES | ||
+ | %\draw[vector] (O) -- (J1); | ||
+ | %\draw[vector] (O) -- (J2); | ||
+ | %\cone{O}{J1}{0.3}{0.15} | ||
+ | \jetcone{O}{J1}{0.4}{0.08} | ||
+ | \jetcone{O}{J2}{0.4}{0.10} | ||
+ | \node[vector, | ||
+ | \node[vector, | ||
+ | | ||
+ | % CURLY BRACE | ||
+ | \draw[line width=0.5, | ||
+ | ($(J1)+(195: | ||
+ | \draw[line width=0.5, | ||
+ | ($(M2)+(10: | ||
+ | | ||
+ | \end{tikzpicture} | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Tangent to a circle or ellipse ===== | ||
+ | |||
+ | Some different methods of finding the tangent to a circle or ellipse in TikZ. | ||
+ | Using these methods a nice cone can be made. | ||
+ | The full code can be found [[https:// | ||
+ | |||
+ | |||
+ | <WRAP group>< | ||
+ | {{ latex: | ||
+ | </ | ||
+ | {{latex: | ||
+ | </ | ||
+ | |||
+ | <WRAP group>< | ||
+ | {{ latex: | ||
+ | </ | ||
+ | {{latex: | ||
+ | </ | ||
+ | |||
+ | <code latex> | ||
+ | % TANGENT to CIRCLE - known: r, q | ||
+ | \begin{tikzpicture} | ||
+ | \def\r{1.5} % radius | ||
+ | \def\q{4} % distance center-external point q = |OQ| | ||
+ | \def\x{{\r^2/ | ||
+ | \def\y{{\r*sqrt(1-(\r/ | ||
+ | \coordinate (O) at (0,0); % circle center O | ||
+ | \coordinate (Q) at (\q,0); % external point Q | ||
+ | \coordinate (P) at (\x,\y); % point of tangency, P | ||
+ | \draw[-> | ||
+ | \draw[-> | ||
+ | \draw[dashed] (\x,0) |- (0,\y); | ||
+ | \draw[myblue, | ||
+ | \draw[mygreen, | ||
+ | \draw[mygreen, | ||
+ | \rightAngle{Q}{P}{O}{0.40} | ||
+ | \fill[myred] (O) circle(0.05) node[below right] {O}; | ||
+ | \fill[myred] (Q) circle(0.05) node[below left] {Q}; | ||
+ | \fill[myred] (P) circle(0.05) node[above=3, | ||
+ | \end{tikzpicture} | ||
+ | |||
+ | % TANGENT to ELLIPSE - known: a, b, q | ||
+ | \begin{tikzpicture} | ||
+ | \def\a{1.5} % horizontal radius | ||
+ | \def\b{1.0} % vertical radius | ||
+ | \def\q{4} % distance center-external point q = |OQ| | ||
+ | \def\x{{\a^2/ | ||
+ | \def\y{{\b*sqrt(1-(\a/ | ||
+ | \coordinate (O) at (0,0); % circle center O | ||
+ | \coordinate (Q) at (\q,0); % external point Q | ||
+ | \coordinate (P) at (\x,\y); % point of tangency, P | ||
+ | \draw[-> | ||
+ | \draw[-> | ||
+ | \draw[dashed] (\x,0) |- (0,\y); | ||
+ | \draw[myblue, | ||
+ | \draw[mygreen, | ||
+ | \draw[mygreen, | ||
+ | \fill[myred] (O) circle(0.05) node[below right] {O}; | ||
+ | \fill[myred] (Q) circle(0.05) node[below left] {Q}; | ||
+ | \fill[myred] (P) circle(0.05) node[above=3, | ||
+ | \end{tikzpicture} | ||
+ | |||
+ | </ |