% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 3.
%
% Seth Brown, Ph.D.
% sethbrown@drbunsen.org
%
% Compiled with XeLaTeX
% Dependencies:
%   Fontin Sans font (http://www.exljbris.com/fontinsans.html)
%
\documentclass{beamer}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{times}
\usepackage[T1]{fontenc}
%\usepackage[mathscr]{eucal}
%\usepackage{mathptmx}
%\usepackage{mathrsfs}
\usepackage{hyperref}
\usepackage{color}
\usepackage{graphicx}
\usepackage{wasysym}
% \usepackage{pgfpagfes}
% \setbeameroption{show notes on second screen}
%\pgfpagesuselayout{4 on 1}[a4paper,border shrink=5mm,landscape]
\usepackage{xcolor}
%\usepackage[dvipsnames]{xcolor}
%\usepackage{amsfonts}
%\usepackage{amsmath}
% \usepackage[amssymb]{SIunits}
%\usepackage{natbib}
%\usepackage{amssymb}
\usepackage{hepparticles}
\usepackage{hepnicenames}
\usepackage{hepunits}
\usepackage{tikz}
\usepackage[english]{babel}
%%\usepackage{lmodern}
%\usepackage{feynmp}
% suppress navigation bar
\beamertemplatenavigationsymbolsempty
\usepackage[mathscr]{eucal}
\usepackage{mathrsfs}
\mode<presentation>
{
  \usetheme{bunsen}
  \setbeamercovered{transparent}
  \setbeamertemplate{items}[circle]
}
\newcommand{\Simley}[1]{%
\begin{tikzpicture}[scale=0.15]
    \newcommand*{\SmileyRadius}{1.0}%
    \draw [fill=brown!10] (0,0) circle (\SmileyRadius)% outside circle
        %node [yshift=-0.22*\SmileyRadius cm] {\tiny #1}% uncomment this to see the smile factor
        ;  

    \pgfmathsetmacro{\eyeX}{0.5*\SmileyRadius*cos(30)}
    \pgfmathsetmacro{\eyeY}{0.5*\SmileyRadius*sin(30)}
    \draw [fill=cyan,draw=none] (\eyeX,\eyeY) circle (0.15cm);
    \draw [fill=cyan,draw=none] (-\eyeX,\eyeY) circle (0.15cm);

    \pgfmathsetmacro{\xScale}{2*\eyeX/180}
    \pgfmathsetmacro{\yScale}{1.0*\eyeY}
    \draw[color=red, domain=-\eyeX:\eyeX]   
        plot ({\x},{
            -0.1+#1*0.15 % shift the smiley as smile decreases
            -#1*1.75*\yScale*(sin((\x+\eyeX)/\xScale))-\eyeY});
\end{tikzpicture}%
}%
% set fonts
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{code}{Verbatim}{fontsize=\small}
\DefineVerbatimEnvironment{example}{Verbatim}{fontsize=\small}
\usepackage{listings}
  \usepackage{courier}
 \lstset{
         basicstyle=\footnotesize\ttfamily, % Standardschrift
         %numbers=left,               % Ort der Zeilennummern
         numberstyle=\tiny,          % Stil der Zeilennummern
         %stepnumber=2,               % Abstand zwischen den Zeilennummern
         numbersep=5pt,              % Abstand der Nummern zum Text
         tabsize=2,                  % Groesse von Tabs
         extendedchars=true,         %
         breaklines=true,            % Zeilen werden Umgebrochen
         keywordstyle=\color{red},
    		frame=b,         
 %        keywordstyle=[1]\textbf,    % Stil der Keywords
 %        keywordstyle=[2]\textbf,    %
 %        keywordstyle=[3]\textbf,    %
 %        keywordstyle=[4]\textbf,   \sqrt{\sqrt{}} %
         stringstyle=\color{white}\ttfamily, % Farbe der String
         showspaces=false,           % Leerzeichen anzeigen ?
         showtabs=false,             % Tabs anzeigen ?
         xleftmargin=17pt,
         framexleftmargin=17pt,
         framexrightmargin=5pt,
         framexbottommargin=4pt,
         %backgroundcolor=\color{lightgray},
         showstringspaces=false      % Leerzeichen in Strings anzeigen ?        
 }
 \lstloadlanguages{% Check Dokumentation for further languages ...
         %[Visual]Basic
         %Pascal
         %C
         C++
         %XML
         %HTML
         %Java
 }
    %\DeclareCaptionFont{blue}{\color{blue}} 

  %\captionsetup[lstlisting]{singlelinecheck=false, labelfont={blue}, textfont={blue}}
  \usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox[cmyk]{0.43, 0.35, 0.35,0.01}{\parbox{\textwidth}{\hspace{15pt}#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white, singlelinecheck=false, margin=0pt, font={bf,footnotesize}}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}

%\usepackage{gfsartemisia-euler}
%\usepackage[T1]{fontenc}
\setbeamerfont{frametitle}{size=\LARGE,series=\bfseries}
\tikzstyle{decision} = [diamond, draw, fill=gray!20, 
    text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!10, 
    text width=5em, text centered, rounded corners, minimum height=2em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!10, node distance=3cm,
    minimum height=2em]

\tikzstyle{every picture}+=[remember picture]


\renewcommand{\PKs}{{\HepParticle{K}{S}{}\xspace}}
% color definitions
\usepackage{color}
\definecolor{uipoppy}{RGB}{225, 64, 5}
\definecolor{uipaleblue}{RGB}{96,123,139}
\definecolor{uiblack}{RGB}{0, 0, 0}

% caption styling
%\DeclareCaptionFont{uiblack}{\color{uiblack}}
%\DeclareCaptionFont{uipoppy}{\color{uipoppy}}
%\captionsetup{labelfont={uipoppy},textfont=uiblack}

% see the macros.tex file for definitions
\include{macros }

% title slide definition
\title{Final State Radiation correction in MC truth matching}
%\subtitle{a bias report}
\author{Marcin Chrz\k{a}szcz}
\institute[Institute of Nuclear Physics]
{
Institute of Nuclear Physics,
\newline Polish Academy of Science,
\newline and INFN sezione di Pisa
}


\date{$27^{th}$ February 2013}

%--------------------------------------------------------------------
%                           Introduction
%--------------------------------------------------------------------

\begin{document}



\setbeamertemplate{background}
{\includegraphics[width=\paperwidth,height=\paperheight]{frontpage_bg_mine}}
\setbeamertemplate{footline}[default]

\begin{frame}
\vspace{1.1cm}
\begin{columns}
\column{2.75in}
  \titlepage

  \begin{center}
    \includegraphics[height=1.0cm,keepaspectratio ]{pic/ifj.png}
   \hspace{1cm}
   \includegraphics[height=1.5cm]{pic/babar.jpg}
      \hspace{1cm}
   \includegraphics[height=1.0cm]{pic/INFN.jpg}
   \end{center}
  \vspace{10cm}
\column{2.0in}
\end{columns}
\end{frame}

%--------------------------------------------------------------------
%                          OUTLINE
%--------------------------------------------------------------------




\section[Outline]{}
\begin{frame}
\tableofcontents
\end{frame}







%-------------------------------------------------------------------
%                          Introduction
%-------------------------------------------------------------------
%
% Set the background for the rest of the slides.
% Insert infoline
\setbeamertemplate{background}
 {\includegraphics[width=\paperwidth,height=\paperheight]{slide_bg}}
\setbeamertemplate{footline}[bunsentheme]

\title{FSR correction in MC truth matching}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setbeamertemplate{background}
 {\includegraphics[width=\paperwidth,height=\paperheight]{slide_bg}}
\setbeamertemplate{footline}[bunsentheme]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Truth matching description }
\begin{frame}

\frametitle{How does truth matching work?}
{~}
\only<1>{
Let's say we what to study a decay of $\PDzero \to \pi K$. 
{~}
\begin{enumerate}

\item From $\pi$ and $\PDzero$ you construct the $\PDzero$ with background. 
\item At some point you may want to know how many actual $\PDzero$  survived the selection. Then you do in the code (or some module does it for you) mcFromReco(...).
\item However the number this function returns will be an underestimation of the actual number.
\item If FSR happen you will end up with a channel $\PDzero \to \pi K \gamma$, which software will not match with search channel: $\PDzero \to \pi K$.
\end{enumerate}
}

\only<2>{

How ever code does one thing for you:   
{~}
\begin{enumerate}

\item For example if you have a decay: $\tau^- \to \pi^+ \pi^- \pi^- \nu_{\tau}$ 
\item Of coz there is no $\nu$ BtaCandidate list  \Simley{1} .
\item Same thing was implemented for FSR correction. 
\item The new code should not create problems with the old modules etc.
\end{enumerate}
}


\end{frame}



\section{Code structure}
\begin{frame}

\frametitle{Cod structure}
\begin{columns}
\column{3.in}
\only<1>{
\begin{itemize}
\item The Top class is BtaMCAssoc, however the function is virtual \Simley{-0.5} 
\item It's also defined in BtaMcAssocGHit, BtaMcAssocMicro, BtaMcAssocQuality, BtaMcAssocQuality,  
BtaMcAssocGHit
\item They are distributed over the packages: BetaCoreTools, BetaMC and BetaMicroTruth.
\item Call mcFromReco is from BtaMcAssocMicro. Then it's checked that particle is a composite and if it is then mcFromRecoComposite is called. 
\end{itemize}

}

\only<2>{
The original code:
{~}
\lstinputlisting[label=samplecode,caption=Oryginal declaration:]{softcode/oryginal.cc}

}

\only<3>{

\lstinputlisting[label=samplecode,caption=Implement switch:]{softcode/swich.cc}
\begin{small}
Definition of those functions have to be changed in every inheritance class.  
\newline  There is a default argument set to false so earlier code written by others will not see the difference.
\end{small}
}

\only<4>{
How does the code work? For details see the backup slides. To make long story short:
\begin{itemize}
\item Software creates a std::map between daughters and mothers. 
\item If there is a missing particle in the candidate daughters list it checks if it is a $\gamma$. If it is than it ignores it and returns the correct pointer.  
\end{itemize}


}
\column{1in}
\begin{figure}[h] 
\begin{center} 
\mbox{
	{\includegraphics[scale=0.34]{pic/classBtaMcAssoc.png}}
}

\end{center}
\end{figure}

\end{columns}

\end{frame}


\section{Tests}

\begin{frame}\frametitle{Tests}
For $ \PDzero \to \pi K$ there exists a working code in the tutorial:

\center \href{https://bbr-wiki.slac.stanford.edu/bbr_wiki/index.php/Workbook_Tutorial/A_more_complex_example
}{LINK}
{~}
\end{frame}

\begin{frame}\frametitle{Before the modifications}
\begin{figure}[h] 
\begin{center} 
\mbox{
	{\includegraphics[scale=0.34]{pic/d0_old.png}}
}
\caption{183 events in data sample}
\end{center}
\end{figure}

\end{frame}


\begin{frame}\frametitle{After modifications and ignoreFSR==true}
\begin{figure}[h] 
\begin{center} 
\mbox{
	{\includegraphics[scale=0.25]{pic/do_new.png}}
}
\caption{230 events in data sample}
\end{center}
\end{figure}
\small{Many checks have been done (backup slides) to see if this is working properly. ie. if switched off it behaves exactly as previous code and  if switched on it really takes the correct particles.}
\end{frame}

\section{BtaTupleMaker}


\begin{frame}\frametitle{BtaTupleMaker}
\begin{itemize}
\item If someone uses BtaTupleMaker for ntuple production the BtaTupleMaker does the truth matching for him by calling mcFromReco.
\item Can ignore the FSR in the tcl file (if not set it is false by default and code acts exactly as previous):
\end{itemize}
\lstinputlisting[label=samplecode,caption=Implement switch:]{softcode/tuple.cc}


\end{frame}




\begin{frame}\frametitle{Summary}
\begin{itemize}
\item Code well tested.
\item Works well with ana52.
\item documented on wiki page: \href{https://bbr-wiki.slac.stanford.edu/bbr_wiki/index.php/IgnoreFSR}{CLIC}
\end{itemize}

Only thing that still needs to be done is to check if it works with ana53.


\end{frame}














%%%5  BACKUP!!!!!!!!!!!!!1
\begin{frame}
{~}
\Large{Thank you for your attention}
{~}
\end{frame}




\begin{frame}
{~}
\center \Large{BACKUP Slides}
{~}
\end{frame}


\begin{frame}
\only<1>{
\frametitle{Real code}
{~}
\lstinputlisting[label=samplecode,caption=Implement switch:]{softcode/code.cc}
}

\end{frame}


\begin{frame}\frametitle{Consistency test old vs new with FSR == false}
\begin{figure}[h] 
\begin{center} 
\mbox{
	{\includegraphics[scale=0.2]{pic/d0_old.png}}
		{\includegraphics[scale=0.2]{pic/d0_old.png}}	
}

\end{center}
\end{figure}
Spot the  difference \Simley{1}. They have the same number of events:  183.


\end{frame}

\begin{frame}\frametitle{Consistency test 2}
Do we really get truth D0 in ntuple? Of coz I checked the lund but this plots is nicer to show...

\begin{figure}[h] 
\begin{center} 
\mbox{
	{\includegraphics[scale=0.2]{pic/mc_mass.png}}
}

\end{center}
\end{figure}
I don't know different particle with mass so close do $\PDzero$ so i think I can declare it that it works.
\end{frame}

\end{document}
