usersGuide.tex 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. \documentclass[8pt,a5paper, oldfontcommands]{memoir}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage[english]{babel}
  4. \usepackage{graphicx}
  5. \usepackage{color}
  6. \usepackage{float}
  7. \usepackage{url}
  8. \usepackage{listings}
  9. \usepackage{microtype}
  10. \setcounter{section}{0}
  11. \hoffset = 10pt
  12. %\voffset = -20pt
  13. \usepackage{lipsum}
  14. \renewcommand\thesection{\arabic{section}}
  15. \begin{document}
  16. \pagenumbering{gobble}% Remove page numbers (and reset to 1)
  17. \clearpage
  18. \thispagestyle{empty}
  19. \begin{huge}
  20. \textbf{Use of KFParticle with MPD}
  21. \end{huge}
  22. \begin{figure}[H]
  23. \centering
  24. \includegraphics[width=0.5\textwidth]{img/particlesInCollision.png}
  25. \includegraphics[width=0.5\textwidth]{img/mpd_addLogos.png}
  26. \end{figure}
  27. \begin{centering}
  28. \bf
  29. Contacts: \\
  30. Pavel Batyuk, VBLHEP, JINR, \url{pavel.batyuk@jinr.ru}
  31. \end{centering}
  32. \newpage
  33. \pagenumbering{Roman}
  34. \begin{normalsize}
  35. \tableofcontents
  36. \end{normalsize}
  37. \newpage
  38. \thispagestyle{plain}
  39. \pagenumbering{arabic}
  40. \section{Introduction}
  41. \thispagestyle{plain}
  42. KFParticle is a formalism specially developed for complete reconstruction of short-lived particles with their
  43. momentum $P$, energy $E$, mass $m$, lifetime $c\tau$, decay length $L$ and so on.
  44. Its main benefits are listed below:
  45. \begin{itemize}
  46. \item based on the Kalman filter mathematics idependent in sense of experimental setup (collider or fixed target)
  47. \item allows one reconstruction of decay chains (cascades)
  48. \item daughter and mother particles are described and considered the same way
  49. \item daughter particles are added to the mother particle independently
  50. \end{itemize}
  51. At the moment, the power abilities of KFParticle can be used in the MpdRoot software. It is embedded into MpdRoot as a module with all necessary dependencies
  52. and a first version of particle finder respectively to MPD that uses all the benefits by KFParticle, has been developed.
  53. The manual has a goal to share experience on how to use the main macroses aiming at production of output with its subsequent analysis in user's codes.
  54. It is not a finished job since the develpment (description) procedure is ongoing.
  55. \newpage
  56. \section{How to produce output for analysis?}
  57. \thispagestyle{plain}
  58. Right now, the package has one main macro to be used for starting the software (namely, to produce output).
  59. The macro can be found in the {\color{blue} macro/KFParticle/runKFParticle} directory of the MPD software.
  60. It is called {\color{blue} runKFParticleFinder.C} (see below in p. 6).
  61. It inherits all benefits from FairRoot to work in a ``task''-way mode processing passed events in chain.
  62. There are two options how user can pass input data to the macro. The most trivial one is that one passes a single file written either
  63. in the {\color{red} standard dst-format} or in the {\color{blue} MiniDst format}. The latter is fully supported by the software,
  64. but one has to take into account that MiniDst input should be produced with a code version where there is a correct parameterization of covariance matrix used.
  65. Looking at a "suitable'' file one sees the following parameterization of covariance matrix:
  66. \begin{figure}[H]
  67. \centering
  68. \includegraphics[width=0.4\textwidth]{img/covarMatrix.png}
  69. \caption{\bf Example how a correct parameterization of covariance matrix looks like}
  70. \end{figure}
  71. The second option how to provide input for the software looks more preferred since it works with a list of files. The passed list should have *.lis or *.list extension and the following format:
  72. \begin{figure}[H]
  73. \centering
  74. \includegraphics[width=0.5\textwidth]{img/exampleList.png}
  75. \caption{\bf Example of list (*.lis or *.list) to be passed to software}
  76. \end{figure}
  77. Each line contains a file identifier (file ID) and dst name (supported, surely, both formats as mentioned before). The identifier is considered to be obligatory since it allows one in subsequent analysis to get information on file name and, in particular, event number.
  78. The list is limited by five thousand (5000) lines (e.g. files) to be put inside.
  79. Also user should define an output file name and desirable number of events to process. The number of events in the case of a passed list means number of consecutive events
  80. (from the total number of events passed in the list) aimed to be processed. If the number is equal to zero, it means that the whole dataset is assumed to be processed.
  81. The macro also instantiates the Kalman filter since it is used for doing extrapolation of track parameters to the inner TPC shell.
  82. The main object of the software is called {\bf MpdKfParticleFinder} and represents itself a first {\bf version of particle finder approach based on the KFParticle formalism respectively to MPD}.
  83. Generally speaking, it is an interface to KFParticle that takes into account important things how to work with existing reconstruction output from the detector (namely, TPC at the moment).
  84. It does support of two existing dst formats in MPD and used track parameterization (see Fig.\ref{fig1}).
  85. \begin{figure}[H]
  86. \centering
  87. \includegraphics[width=0.6\textwidth]{img/trackParams.png}
  88. \caption{\bf Example of track parameterization in MPD}
  89. \label{fig1}
  90. \end{figure}
  91. The latter is the most important part of the particle finder.
  92. Also, a simple mechanism to select input tracks with desirable kinematical characteristics (transverse momentum, rapidity) is realized.
  93. A brief explanation of the main modificators to {\bf MpdKfParticleFinder} is given in the table. The modificators are set by default values in the software, but user has a possibility
  94. to reset them if necessary.
  95. \begin{table}[H]
  96. % \resizebox{\columnwidth}{!}{%
  97. \begin{tabular}{|c|l|}
  98. \hline
  99. Modifier & Explanation \\
  100. \hline
  101. \bf SetPidHypo(pdg1, pdg2) & {\color{blue} \bf Default values are 2212 and -211}\\
  102. & At the moment, it is possible to select \\
  103. & only one additional decay for analysis. \\
  104. & Setting (+211, -211) corresponds to \\
  105. & $K_{s}^{0} \rightarrow \pi^{+} + \pi^{-}$ \\
  106. & \color{red} \bf Temporary solution to change \\
  107. & \color{red} \bf in the future \\
  108. \hline
  109. \bf SetUseCuts(flag) & {\color{blue} \bf Default flag value is false.} \\
  110. & If set with true, it means that tracks \\
  111. & are chosen according to the established \\
  112. & values. The cuts are set by {\bf TrackCuts}. \\
  113. & At the moment, it is possible to define \\
  114. & values for pseudorapidity and transverse \\
  115. & momentum in sense of track acceptance.\\
  116. \hline
  117. \bf SetUseKFPerformance(flag) & {\color{blue} \bf Default flag value is false.} \\
  118. & Returning it to true gives opportunity \\
  119. & to produce QA histograms proposed by \\
  120. & KFParticle performance tools. \\
  121. & They seem to be very useful when \\
  122. & doing comparison between Monte Carlo \\
  123. & and reconstruction aiming at developing \\
  124. & cuts to suppress background and so on. \\
  125. & {\color{red} \bf Important note: it works just} \\
  126. & {\color{red} \bf with standard dst!!!} \\
  127. \hline
  128. \end{tabular}
  129. %}
  130. \end{table}
  131. \newpage
  132. \thispagestyle{plain}
  133. { \scriptsize
  134. \begin{lstlisting}[language=C++,basicstyle=\ttfamily,keywordstyle=\color{red}, commentstyle=\color{blue}]
  135. void runKFParticleFinder(TString in = "", TString out = "",
  136. Int_t nStartEvent = 0, Int_t nEvents = 0) {
  137. FairRunAna* fRun = new FairRunAna();
  138. FairRootFileSink* sink = new FairRootFileSink(out);
  139. fRun->SetSink(sink);
  140. MpdKalmanFilter *kalman = MpdKalmanFilter::Instance("KF");
  141. fRun->AddTask(kalman);
  142. MpdKfParticleFinder* pF = new MpdKfParticleFinder(in);
  143. // pF->SetUseCuts(kTRUE);
  144. // pF->SetUseKFPerformance(kTRUE);
  145. // Setters to specify what a two-particle decay we are looking for ...
  146. // pdg1, pdg2 to specify a decay. \Lambda^{0} is set by default
  147. // Available decays right now are:
  148. // \Lambda^{0} -> p + \pion^{-} and
  149. // \Kaon^{0}_{s} -> \pion^{+} + \pion^{-}
  150. // pF->SetPidHypo(+211, -211);
  151. fRun->AddTask(pF);
  152. fRun->Init();
  153. // Redefine established cuts if necessary ...
  154. // TrackCuts* cutsGot = partFinder->GetTrackCuts();
  155. // if (cutsGot) {
  156. // cutsGot->SetPtMin(.5);
  157. // cutsGot->SetPtMax(1.8);
  158. // cutsGot->SetAbsEta(1.);
  159. // }
  160. fRun->Run(nStartEvent, nStartEvent + nEvents);
  161. delete pF;
  162. }
  163. \end{lstlisting}
  164. }
  165. \newpage
  166. \section{How to read produced output?}
  167. \thispagestyle{plain}
  168. To use a result of work of particle finder one is refferred to {\color{blue} readKFParticleOutput.C} located, evedently, in the macro/KFParticle directory.
  169. The macro illustrates how to get output from the previous step and use it.
  170. Besides of decaying particles to be reconstructed, the software is able to perform reconstruction of primary vertex ($V_{p}$) of interaction. In the most general case,
  171. it allows (KFParticle) one to get more than one primary vertex reconstructed, but existing current setup of the software reconstructs one candidate to be primary vertex.
  172. At the moment, multiple vertices are not allowed to be reconstructed (particle finder).
  173. Below are given explanations for some parts of {\color{blue} readKFParticleOutput.C} considered to be useful for users in their analyses.
  174. { \footnotesize
  175. \begin{lstlisting}[language=C++,basicstyle=\ttfamily,keywordstyle=\color{red}, commentstyle=\color{blue}]
  176. ...
  177. // Getting information on reco file and event used ...
  178. // id of file in the list processed by runKFParticle.C
  179. Int_t fileId = eventHeader->GetInputFileId();
  180. // current event that corresponds to the same event in reco output
  181. Int_t evNum = eventHeader->GetMCEntryNumber();
  182. ...
  183. \end{lstlisting}
  184. }
  185. A couple of values {\color{blue} (fileId, evNum)} are important when linking output from the software to the source reconstructed data. {\color{blue} fileId} corresponds to those one
  186. defined in the list of files passed for analysis. So, taking into account this pair, one is able to get event {\color{blue} (evNum)} with all information from the source.
  187. Information on reconstructed primary vertex is written into output with {\color{red} KFVertex}
  188. { \tiny
  189. \begin{lstlisting}[language=C++,basicstyle=\ttfamily,keywordstyle=\color{red}, commentstyle=\color{blue}]
  190. ...
  191. // Getting reconstructed primary vertex in event ...
  192. // In general case, here should be a loop since we are able to reconstruct
  193. // more than one primary vertex ...
  194. // One vertes is set by default in macro/KFParticle/runKFParticleFinder.C
  195. // It means that primVertices->GetEntriesFast() is equal to 1
  196. for (Int_t iVertex = 0; iVertex < primVertices->GetEntriesFast(); iVertex++) {
  197. KFVertex* Vp = (KFVertex*) primVertices->UncheckedAt(iVertex);
  198. // To get a list of all possible accessors to written data, please,
  199. // look at KFParticle/KFParticle/KFVertex.h
  200. Float_t* covMatrix = Vp->CovarianceMatrix();
  201. // Getting components of reconstructed vertex ...
  202. Double_t X = Vp->GetX();
  203. Double_t Y = Vp->GetY();
  204. Double_t Z = Vp->GetZ();
  205. // X = Y = Z = 0. means that primary vertex
  206. // has not been reconstructed in event ...
  207. if (!X || !Y || !Z)
  208. continue;
  209. Int_t nContributors = Vp->GetNContributors();
  210. }
  211. ...
  212. \end{lstlisting}
  213. }
  214. The most important information that can be derived from the vertex section is three-dimensional coordinates of reconstructed vertex, number of participants used for the vertex reconstruction and,
  215. surely, covariance matrix of vertex fit. A full list of accessors to be used is available at {\color{red} \bf KFParticle/KFParticle/KFVertex.h}
  216. All necessary brief explanations are given there directly in the code when describing accessors.
  217. Reconstructed secondary candidates are written to output with a very widely and frequently used {\bf \color{red} KFParticle} inherited from the {\bf \color{red} KFParticleBase} class.
  218. A cycle illustrating how to get information on reconstructed secondaries is given below.
  219. To select candidates that, probably, are considered as particles we are interested in, one uses PDG hypothesis of interesting particle.
  220. So, to get, for example, $\Lambda^{0}$ candidates one has to do as follows:
  221. { \tiny
  222. \begin{lstlisting}[language=C++,basicstyle=\ttfamily,keywordstyle=\color{red}, commentstyle=\color{blue}]
  223. for (Int_t iSecondary = 0; iSecondary < recoSecondaries->GetEntriesFast(); iSecondary++) {
  224. KFParticle* particle = (KFParticle*) recoSecondaries->UncheckedAt(iSecondary);
  225. // To get a list of all possible accessors to written data, please,
  226. // look at KFParticle/KFParticle/KFParticle.h and KFParticle/KFParticle/KFParticleBase.h
  227. Int_t pdgHypo = particle->GetPDG();
  228. if (pdgHypo != pdg)
  229. continue;
  230. Double_t mass = particle->GetMass();
  231. Double_t Px = particle->GetPx();
  232. Double_t Py = particle->GetPy();
  233. Double_t Pz = particle->GetPz();
  234. Double_t pT = particle->GetPt();
  235. Double_t eta = particle->GetEta();
  236. }
  237. \end{lstlisting}
  238. }
  239. \thispagestyle{plain}
  240. {\bf \color {red} KFParticle} has a lot of accessors to parameters of reconstructed secondaries. It is possible to get {\bf \color{blue} mass, projection of momentum, rapidity, decay length} and many other characteristics of found secondaries.
  241. A full list of accessors with brief descriptions is given in {\bf \color{red} KFParticle/KFParticle/KFParticle.h} and {\bf \color{red} KFParticle/KFParticle/KFParticleBase.h}
  242. The most useful of them are planned to be marked and explained in Section~\ref{sec} in the nearest future.
  243. Another important option is related to possibility of getting indices of particles that form interesting decay channel of decaying particle.
  244. It is illustrated below how to do it. The feature works correctly just in case of standard dst used, since this case (at the moment, MiniDst does not support it yet)
  245. we are able to construct a full chain that allows one to pass through all necessary steps and, finally, to get index of mother particle to judge whether the found candidate is true or false
  246. assuming to be a desirable decaying particle.
  247. { \tiny
  248. \begin{lstlisting}[language=C++,basicstyle=\ttfamily,keywordstyle=\color{red}, commentstyle=\color{blue}]
  249. // It is possible to get indices of reconstructed tracks in standard / MiniDst.
  250. // Doing it for standard dst, one can get source Monte Carlo track to check
  251. // whether its mother is a desirable decaying particle we are looking for ...
  252. // (daughter id given by particle finder --> idx of reconstructed track -->
  253. // --> idx of corresponding MC track --> idx of mother particle)
  254. // To do it, one has to link standard dst to the macro in an usual way
  255. // fileId and evNum are available to get corresponding file, event and arrays
  256. // with reconstructed tracks
  257. const Double_t massThresh = 0.025;
  258. if (TMath::Abs(mass) < massThresh) {
  259. Int_t nDaugh = particle->NDaughters();
  260. vector <Int_t> daughters = particle->DaughterIds();
  261. for (Int_t iDaugh = 0; iDaugh < nDaugh; iDaugh++)
  262. cout << daughters[iDaugh] << " ";
  263. cout << endl;
  264. }
  265. \end{lstlisting}
  266. }
  267. \newpage
  268. \section{The most useful methods provided by {\bf \color{red} KFParticle} to be used in user's analysis}
  269. \label{sec}
  270. \thispagestyle{plain}
  271. {\bf The section is planned to be filled with descriptions of useful methods on how to use them correctly in user's analysis.}
  272. \end{document}