\section{Ki\-Track\-:\-:Automaton Class Reference}
\label{classKiTrack_1_1Automaton}\index{Ki\-Track\-::\-Automaton@{Ki\-Track\-::\-Automaton}}


A class for the cellular automaton.  




{\ttfamily \#include $<$Automaton.\-h$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
{\bf $\sim$\-Automaton} ()\label{classKiTrack_1_1Automaton_ae1a1748477b89739ba8369074940f803}

\begin{DoxyCompactList}\small\item\em delete all the segments \end{DoxyCompactList}\item 
void {\bf add\-Segment} ({\bf Segment} $\ast$segment)
\begin{DoxyCompactList}\small\item\em Adds a segment to the automaton. \end{DoxyCompactList}\item 
void {\bf lengthen\-Segments} ()
\begin{DoxyCompactList}\small\item\em Lengthens the segments by one via adding the first hit of the next segment it is connected to to it. \end{DoxyCompactList}\item 
void {\bf add\-Criterion} ({\bf I\-Criterion} $\ast$criterion)
\begin{DoxyCompactList}\small\item\em Adds a criteria to the automaton. \end{DoxyCompactList}\item 
void {\bfseries add\-Criteria} (std\-::vector$<$ {\bf I\-Criterion} $\ast$ $>$ criteria)\label{classKiTrack_1_1Automaton_a699f632b7cddb2ed602dbd1d8a7df71b}

\item 
void {\bfseries clear\-Criteria} ()\label{classKiTrack_1_1Automaton_a29b5264b2cdf902bd49aec8465c9fb53}

\item 
void {\bf do\-Automaton} ()
\begin{DoxyCompactList}\small\item\em Does iteration until the states of the segments don't change anymore. \end{DoxyCompactList}\item 
void {\bf clean\-Bad\-States} ()
\begin{DoxyCompactList}\small\item\em Erases all segments that don't have a state corresponding to their layer. \end{DoxyCompactList}\item 
void {\bf clean\-Bad\-Connections} ()\label{classKiTrack_1_1Automaton_aa13d962e08c754957bd677c5b82a4fed}

\begin{DoxyCompactList}\small\item\em Erase alls connections between segments, that don't satisfy the criteria. \end{DoxyCompactList}\item 
void {\bf reset\-States} ()\label{classKiTrack_1_1Automaton_a0ee68fd73bb585d4e96e7600d9652e32}

\begin{DoxyCompactList}\small\item\em Resets all the states of the segmens to 0 by calling the reset\-State() method of the segment Also sets all segments back to active. \end{DoxyCompactList}\item 
std\-::vector$<$ std\-::vector$<$ {\bf I\-Hit} $\ast$ $>$ $>$ {\bf get\-Tracks} (unsigned min\-Hits=2)
\begin{DoxyCompactList}\small\item\em Get all the possible tracks in the automaton. \end{DoxyCompactList}\item 
std\-::vector$<$ std\-::vector$<$ {\bf I\-Hit} $\ast$ $>$ $>$ {\bf get\-Tracks\-Of\-Segment} ({\bf Segment} $\ast$segment, std\-::vector$<$ {\bf I\-Hit} $\ast$ $>$ hits, unsigned min\-Hits=2)
\begin{DoxyCompactList}\small\item\em Returns all the tracks starting from this segment. \end{DoxyCompactList}\item 
std\-::vector$<$ const {\bf Segment} $\ast$ $>$ {\bf get\-Segments} () const 
\item 
unsigned {\bfseries get\-Number\-Of\-Connections} ()\label{classKiTrack_1_1Automaton_a85474731b6a180411941c35f451c1c61}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
A class for the cellular automaton. 

For detailed info on the Cellular \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton} and its use for track reconstruction see {\tt Introduction to the Cellular Automaton}

\paragraph*{About the class }

This Cellular \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton} is specifically designed for track reconstruction, so it differs in the functionality from other Cellular Automata, like those used for simulation of biological cells.

The basic information on how the C\-A works and what it needs is describet in the pdf above. Here I'll only sum up the basics of this class.

The cells the Cellular \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton} deals with are here called segments as we deal with track reconstruction. These are the main information entities the C\-A deals with and therefore the most important member variable is a container of these segments. (For more details on the segments see the doxygen of the \doxyref{Segment}{p.}{classKiTrack_1_1Segment} class) To sum it up\-: Segments consist of hits. So they are a bit like tracks. Or if they only consist of one single hit (so called 1-\/hit-\/segments) then they are like hits. But there a few features that distinguish them from hits or tracks
\begin{DoxyItemize}
\item They can have parents and children. These are simply segments on top or below them. The idea is, that all segments on the inside are stored as children if they could belong to the same track. And the same for all segments on the outside possible belonging to the same track (the parents). So if we start at a segment and go to a child and on to a grandchild and so on, we follow a possible track. If we erase those connections we decrease the number of possible tracks.
\item Segments must have a layer marking where it is. (layer 0\-: inside, higher layers further outside). This is a feature needed by the \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton}. Because it is an algorithm with discrete entities, we need some sort of discrete ordering. (If we for example had a Cellular \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton} for simulation of 2 dimensional cells and we arranged the cells for example on a chessboard, we always know the next cells. Here we have a 1 dimensional situation so we use layers)
\item Segments have states\-: this is simply an integer number (an unsigned to be more precise). It is needed by the \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton} to find connections that go all the way through (see pdf!)
\end{DoxyItemize}

The Segments can be added via the \doxyref{add\-Segment()}{p.}{classKiTrack_1_1Automaton_a27db80286d146deed40882acebcc0646} method and are stored layerwise.

Once the Segments are all stored in the Cellular \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton} it can perform. Via the method \doxyref{do\-Automaton()}{p.}{classKiTrack_1_1Automaton_ac63f601c30e71ed2f109ecf58424bc4c} it raises the states of the Segments until no change happens anymore. When this is done Segments not connected all the way through can be discarded by the method \doxyref{clean\-Bad\-States()}{p.}{classKiTrack_1_1Automaton_a4e1cc49963438037a227f91f2849c742}. This reduces the number of possible tracks.

To get an initial Cellular \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton} to start with, the class \doxyref{Segment\-Builder}{p.}{classKiTrack_1_1SegmentBuilder} can be used. (It takes hits builds segments from them and establishes the first parent-\/child relations)

In order to sort out even more it is possible to go to longer segments. So instead of checking 1-\/hit-\/segments, we can have a look at 2-\/hit-\/segments or 3-\/hit-\/segments. (And sort out much more along the way) For this the method \doxyref{lengthen\-Segments()}{p.}{classKiTrack_1_1Automaton_ada2fb91f9e46838f396f2c05e4f12ae9} is used. It combines connected segments and creates segments from them, that are exactly one hit longer. And then it is again time for connecting them. (I distinguish here between connecting\-: \char`\"{}storing the link\char`\"{} and combining\-: \char`\"{}making 1 new segment out of two others\char`\"{})

When segments are connected only connections that make sense are made. This is really important! If we don't make assumptions here, what Segments could belong together (i.\-e. could form a sensible track) we get lost in combinatorics. For this the so called \doxyref{Criteria}{p.}{classKiTrack_1_1Criteria} are used. Via the method \doxyref{add\-Criterion()}{p.}{classKiTrack_1_1Automaton_add41ab340633e91e2f47fe7e7a39b374} (or add\-Criteria() ) they can be added to the Cellular \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton}. All a Criterion does (see the Criterion doxygen for more info) is to say whether two Segments would give a good match. These criteria can be anything that makes sense in distinguishing between real tracks and combinatorial background. For example if the segments are already long enough (already little tracks) one can compare the radius of their helices or the angle under which they meet and so on.

Once we have longer segments we can again use the \doxyref{do\-Automaton()}{p.}{classKiTrack_1_1Automaton_ac63f601c30e71ed2f109ecf58424bc4c} method and then \doxyref{clean\-Bad\-States()}{p.}{classKiTrack_1_1Automaton_a4e1cc49963438037a227f91f2849c742}. Then we lenghten them once more and so on.

Between two such runs, one should of course clear the old \doxyref{Criteria}{p.}{classKiTrack_1_1Criteria} with clear\-Criteria and reset the states of the Segments with \doxyref{reset\-States()}{p.}{classKiTrack_1_1Automaton_a0ee68fd73bb585d4e96e7600d9652e32}.

That's it. In the end, when nothing more is to be done in the Cellular \doxyref{Automaton}{p.}{classKiTrack_1_1Automaton}, we need to extract the track candidates, it found. This is done via the \doxyref{get\-Tracks()}{p.}{classKiTrack_1_1Automaton_af5ee8164d9a8957809c6c4959591e80d} method. 

\subsection{Member Function Documentation}
\index{Ki\-Track\-::\-Automaton@{Ki\-Track\-::\-Automaton}!add\-Criterion@{add\-Criterion}}
\index{add\-Criterion@{add\-Criterion}!KiTrack::Automaton@{Ki\-Track\-::\-Automaton}}
\subsubsection[{add\-Criterion}]{\setlength{\rightskip}{0pt plus 5cm}void Ki\-Track\-::\-Automaton\-::add\-Criterion (
\begin{DoxyParamCaption}
\item[{{\bf I\-Criterion} $\ast$}]{criterion}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classKiTrack_1_1Automaton_add41ab340633e91e2f47fe7e7a39b374}


Adds a criteria to the automaton. 

So it will be used, when the methods \doxyref{do\-Automaton()}{p.}{classKiTrack_1_1Automaton_ac63f601c30e71ed2f109ecf58424bc4c} or \doxyref{clean\-Bad\-Connections()}{p.}{classKiTrack_1_1Automaton_aa13d962e08c754957bd677c5b82a4fed} are called. \index{Ki\-Track\-::\-Automaton@{Ki\-Track\-::\-Automaton}!add\-Segment@{add\-Segment}}
\index{add\-Segment@{add\-Segment}!KiTrack::Automaton@{Ki\-Track\-::\-Automaton}}
\subsubsection[{add\-Segment}]{\setlength{\rightskip}{0pt plus 5cm}void Automaton\-::add\-Segment (
\begin{DoxyParamCaption}
\item[{{\bf Segment} $\ast$}]{segment}
\end{DoxyParamCaption}
)}\label{classKiTrack_1_1Automaton_a27db80286d146deed40882acebcc0646}


Adds a segment to the automaton. 

\textbackslash{} Take care to set the layer of the segment before adding! 

Referenced by Ki\-Track\-::\-Segment\-Builder\-::get1\-Seg\-Automaton().

\index{Ki\-Track\-::\-Automaton@{Ki\-Track\-::\-Automaton}!clean\-Bad\-States@{clean\-Bad\-States}}
\index{clean\-Bad\-States@{clean\-Bad\-States}!KiTrack::Automaton@{Ki\-Track\-::\-Automaton}}
\subsubsection[{clean\-Bad\-States}]{\setlength{\rightskip}{0pt plus 5cm}void Automaton\-::clean\-Bad\-States (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classKiTrack_1_1Automaton_a4e1cc49963438037a227f91f2849c742}


Erases all segments that don't have a state corresponding to their layer. 

After the automaton is performed every segment, that has a neighbor, that has a neighbor, that... ...that reaches layer 0 should have a state equal to its layer. All the others are not connected to layer 0. All those get deleted by this method. (Of course all the connections to them are erased as well) \index{Ki\-Track\-::\-Automaton@{Ki\-Track\-::\-Automaton}!do\-Automaton@{do\-Automaton}}
\index{do\-Automaton@{do\-Automaton}!KiTrack::Automaton@{Ki\-Track\-::\-Automaton}}
\subsubsection[{do\-Automaton}]{\setlength{\rightskip}{0pt plus 5cm}void Automaton\-::do\-Automaton (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classKiTrack_1_1Automaton_ac63f601c30e71ed2f109ecf58424bc4c}


Does iteration until the states of the segments don't change anymore. 

In one iteration all segments are checked, if they have a neighbor. A neighbor\-:
\begin{DoxyItemize}
\item has the same state
\item fulfills all the criteria (this is automatically provided, because in lengthen\-Segments only connections that fullfill the \doxyref{Criteria}{p.}{classKiTrack_1_1Criteria} are made)
\end{DoxyItemize}

If it has a neighbor its state will be raised by one at the end of the iteration. (At the end only in theory\-: in the program it will be during the iteration, but in a way, that it doesn't affect other segments)

When after an iteration the states didn't change, it stops. \index{Ki\-Track\-::\-Automaton@{Ki\-Track\-::\-Automaton}!get\-Segments@{get\-Segments}}
\index{get\-Segments@{get\-Segments}!KiTrack::Automaton@{Ki\-Track\-::\-Automaton}}
\subsubsection[{get\-Segments}]{\setlength{\rightskip}{0pt plus 5cm}std\-::vector$<$ const {\bf Segment} $\ast$ $>$ Automaton\-::get\-Segments (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}\label{classKiTrack_1_1Automaton_aaa8117daa44b08ae672d32ac223806e7}
\begin{DoxyReturn}{Returns}
All the segments currently saved in the automaton 
\end{DoxyReturn}
\index{Ki\-Track\-::\-Automaton@{Ki\-Track\-::\-Automaton}!get\-Tracks@{get\-Tracks}}
\index{get\-Tracks@{get\-Tracks}!KiTrack::Automaton@{Ki\-Track\-::\-Automaton}}
\subsubsection[{get\-Tracks}]{\setlength{\rightskip}{0pt plus 5cm}std\-::vector$<$ std\-::vector$<$ {\bf I\-Hit} $\ast$ $>$ $>$ Automaton\-::get\-Tracks (
\begin{DoxyParamCaption}
\item[{unsigned}]{min\-Hits = {\ttfamily 2}}
\end{DoxyParamCaption}
)}\label{classKiTrack_1_1Automaton_af5ee8164d9a8957809c6c4959591e80d}


Get all the possible tracks in the automaton. 

Tracks are built by starting from segments which don't have a parent (and are therefore the begin of a track). For all children they have a new own track is created. The children themselves have children again, so the tracks split up again. If we have for example a segment with 3 children, which each have 5 children, which each have 7 children, we will get 1$\ast$3$\ast$5$\ast$7=105 tracks.

\begin{DoxyReturn}{Returns}
All tracks that are possible with the given segments and their connections. Tracks are returned as a vector of hits. So the output will be a vector of a vector of hits
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em min\-Hits} & the minimum number of hits that a track needs to have. All possible tracks, that have less won't be considered as tracks and won't be returned. \\
\hline
\end{DoxyParams}


References get\-Tracks\-Of\-Segment().

\index{Ki\-Track\-::\-Automaton@{Ki\-Track\-::\-Automaton}!get\-Tracks\-Of\-Segment@{get\-Tracks\-Of\-Segment}}
\index{get\-Tracks\-Of\-Segment@{get\-Tracks\-Of\-Segment}!KiTrack::Automaton@{Ki\-Track\-::\-Automaton}}
\subsubsection[{get\-Tracks\-Of\-Segment}]{\setlength{\rightskip}{0pt plus 5cm}std\-::vector$<$ std\-::vector$<$ {\bf I\-Hit} $\ast$ $>$ $>$ Automaton\-::get\-Tracks\-Of\-Segment (
\begin{DoxyParamCaption}
\item[{{\bf Segment} $\ast$}]{segment, }
\item[{std\-::vector$<$ {\bf I\-Hit} $\ast$ $>$}]{hits, }
\item[{unsigned}]{min\-Hits = {\ttfamily 2}}
\end{DoxyParamCaption}
)}\label{classKiTrack_1_1Automaton_a3085c4fa13322139cc714541b0a3f418}


Returns all the tracks starting from this segment. 

It is a recursive method and gets invoked by get\-Tracks. 

Referenced by get\-Tracks().

\index{Ki\-Track\-::\-Automaton@{Ki\-Track\-::\-Automaton}!lengthen\-Segments@{lengthen\-Segments}}
\index{lengthen\-Segments@{lengthen\-Segments}!KiTrack::Automaton@{Ki\-Track\-::\-Automaton}}
\subsubsection[{lengthen\-Segments}]{\setlength{\rightskip}{0pt plus 5cm}void Automaton\-::lengthen\-Segments (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classKiTrack_1_1Automaton_ada2fb91f9e46838f396f2c05e4f12ae9}


Lengthens the segments by one via adding the first hit of the next segment it is connected to to it. 

Also connects those longer segments with each other. ( one becomes a parent and one a child ) Segments that don't have connected segments to use to get longer, will die here. 

References Ki\-Track\-::\-Segment\-::get\-Info(), and Ki\-Track\-::\-I\-Criterion\-::get\-Name().



The documentation for this class was generated from the following files\-:\begin{DoxyCompactItemize}
\item 
Automaton.\-h\item 
Automaton.\-cc\end{DoxyCompactItemize}
