KFPEmcCluster.cxx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //----------------------------------------------------------------------------
  2. // Implementation of the KFParticle class
  3. // .
  4. // @author I.Kisel, I.Kulakov, M.Zyzak
  5. // @version 1.0
  6. // @since 20.08.13
  7. //
  8. //
  9. // -= Copyright &copy ALICE HLT and CBM L1 Groups =-
  10. //____________________________________________________________________________
  11. #include "KFPEmcCluster.h"
  12. #include <iostream>
  13. void KFPEmcCluster::SetParameter(const float_v& value, int iP, int iTr)
  14. {
  15. /** Copies the SIMD vector "value" to the parameter vector KFPEmcCluster::fP[iP]
  16. ** starting at the position "iTr".
  17. ** \param[in] value - SIMD vector with the values to be stored
  18. ** \param[in] iP - number of the parameter vector
  19. ** \param[in] iTr - starting position in the parameter vector where the values should be stored
  20. **/
  21. if( (iTr+float_vLen) < Size())
  22. reinterpret_cast<float_v&>(fP[iP][iTr]) = value;
  23. else
  24. {
  25. const uint_v index(uint_v::IndexesFromZero());
  26. (reinterpret_cast<float_v&>(fP[iP][iTr])).gather(reinterpret_cast<const float*>(&value), index, simd_cast<float_m>(index<(Size() - iTr)));
  27. }
  28. }
  29. void KFPEmcCluster::SetCovariance(const float_v& value, int iC, int iTr)
  30. {
  31. /** Copies the SIMD vector "value" to the element of the covariance matrix vector KFPEmcCluster::fC[iC]
  32. ** starting at the position "iTr".
  33. ** \param[in] value - SIMD vector with the values to be stored
  34. ** \param[in] iC - number of the element of the covariance matrix
  35. ** \param[in] iTr - starting position in the parameter vector where the values should be stored
  36. **/
  37. if( (iTr+float_vLen) < Size())
  38. reinterpret_cast<float_v&>(fC[iC][iTr]) = value;
  39. else
  40. {
  41. const uint_v index(uint_v::IndexesFromZero());
  42. (reinterpret_cast<float_v&>(fC[iC][iTr])).gather(reinterpret_cast<const float*>(&value), index, simd_cast<float_m>(index<(Size() - iTr)));
  43. }
  44. }
  45. void KFPEmcCluster::Resize(const int n)
  46. {
  47. /** Resizes all vectors in the class to a given value.
  48. ** \param[in] n - new size of the vector
  49. **/
  50. for(int i=0; i<4; i++)
  51. fP[i].resize(n);
  52. for(int i=0; i<10; i++)
  53. fC[i].resize(n);
  54. fId.resize(n);
  55. }
  56. void KFPEmcCluster::Set(KFPEmcCluster& v, int vSize, int offset)
  57. {
  58. /** Copies "vSize" clusters from the KFPEmcCluster "v" to the current object.
  59. ** Tracks are put starting from the "offset" position.
  60. ** \param[in] v - external KFPEmcCluster with input clusters to be copied
  61. ** \param[in] vSize - number of clusters to be copied from "v"
  62. ** \param[in] offset - offset position in the current object, starting from which input clusters will be stored
  63. **/
  64. for(int iV=0; iV<vSize; iV++)
  65. {
  66. for(int i=0; i<4; i++)
  67. fP[i][offset+iV] = v.fP[i][iV];
  68. for(int i=0; i<10; i++)
  69. fC[i][offset+iV] = v.fC[i][iV];
  70. fId[offset+iV] = v.fId[iV];
  71. }
  72. }
  73. void KFPEmcCluster::SetTracks(const KFPEmcCluster& track, const kfvector_uint& trackIndex, const int nIndexes)
  74. {
  75. /** The current object is resised to "nIndexes", clusters with indices "trackIndex" are copied to the current object.
  76. ** \param[in] track - input vector of clusters
  77. ** \param[in] trackIndex - indices of clusters in a vector "track", which should be stored to the current object
  78. ** \param[in] nIndexes - number of clusters to be copied, defines the new size of the current object
  79. **/
  80. if(nIndexes == 0) return;
  81. Resize(nIndexes);
  82. for(int iP=0; iP<4; iP++)
  83. {
  84. int iElement = 0;
  85. for(iElement=0; iElement<nIndexes-float_vLen; iElement += float_vLen)
  86. {
  87. const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
  88. float_v& vec = reinterpret_cast<float_v&>(fP[iP][iElement]);
  89. vec.gather(&(track.fP[iP][0]), index);
  90. }
  91. const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
  92. float_v& vec = reinterpret_cast<float_v&>(fP[iP][iElement]);
  93. vec.gather(&(track.fP[iP][0]), index, simd_cast<float_m>(iElement+uint_v::IndexesFromZero()<nIndexes));
  94. }
  95. for(int iC=0; iC<10; iC++)
  96. {
  97. int iElement=0;
  98. for(iElement=0; iElement<nIndexes-float_vLen; iElement += float_vLen)
  99. {
  100. const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
  101. float_v& vec = reinterpret_cast<float_v&>(fC[iC][iElement]);
  102. vec.gather(&(track.fC[iC][0]), index);
  103. }
  104. const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
  105. float_v& vec = reinterpret_cast<float_v&>(fC[iC][iElement]);
  106. vec.gather(&(track.fC[iC][0]), index, simd_cast<float_m>(iElement+uint_v::IndexesFromZero()<nIndexes));
  107. }
  108. {
  109. int iElement=0;
  110. for(iElement=0; iElement<nIndexes-float_vLen; iElement += float_vLen)
  111. {
  112. const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
  113. int_v& vec = reinterpret_cast<int_v&>(fId[iElement]);
  114. vec.gather(&(track.fId[0]), index);
  115. }
  116. const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
  117. int_v& vec = reinterpret_cast<int_v&>(fId[iElement]);
  118. vec.gather(&(track.fId[0]), index, int_m(iElement+uint_v::IndexesFromZero()<nIndexes));
  119. }
  120. }
  121. void KFPEmcCluster::PrintTrack(int n)
  122. {
  123. /** Prints parameters of the cluster with index "n".
  124. ** \param[in] n - index of cluster to be printed
  125. **/
  126. for(int i=0; i<4; i++)
  127. std::cout << fP[i][n] << " ";
  128. std::cout << std::endl;
  129. for(int i=0; i<10; i++)
  130. std::cout << fC[i][n] << " ";
  131. std::cout << std::endl;
  132. std::cout << fId[n] << std::endl;
  133. }
  134. void KFPEmcCluster::PrintTracks()
  135. {
  136. /** Prints all field of the current object. **/
  137. std::cout << "NTracks " << Size() << std::endl;
  138. if( Size()==0 ) return;
  139. std::cout << "Parameters: " << std::endl;
  140. for(int iP=0; iP<4; iP++)
  141. {
  142. std::cout << " iP " << iP << ": ";
  143. for(int iTr=0; iTr<Size(); iTr++)
  144. std::cout << Parameter(iP)[iTr]<< " ";
  145. std::cout << std::endl;
  146. }
  147. std::cout << "Cov matrix: " << std::endl;
  148. for(int iC=0; iC<10; iC++)
  149. {
  150. std::cout << " iC " << iC << ": ";
  151. for(int iTr=0; iTr<Size(); iTr++)
  152. std::cout << Covariance(iC)[iTr]<< " ";
  153. std::cout << std::endl;
  154. }
  155. std::cout << "Id: " << std::endl;
  156. for(int iTr=0; iTr<Size(); iTr++)
  157. std::cout << Id()[iTr] << " ";
  158. std::cout << std::endl;
  159. }