Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KFPEmcCluster.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KFPEmcCluster.cxx
1 /*
2  * This file is part of KFParticle package
3  * Copyright (C) 2007-2019 FIAS Frankfurt Institute for Advanced Studies
4  * 2007-2019 Goethe University of Frankfurt
5  * 2007-2019 Ivan Kisel <I.Kisel@compeng.uni-frankfurt.de>
6  * 2007-2019 Maksym Zyzak
7  *
8  * KFParticle is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * KFParticle is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #include "KFPEmcCluster.h"
23 #include <iostream>
24 
25 void KFPEmcCluster::SetParameter(const float_v& value, int iP, int iTr)
26 {
33  if( (iTr+float_vLen) < Size())
34  reinterpret_cast<float_v&>(fP[iP][iTr]) = value;
35  else
36  {
37  const uint_v index(uint_v::IndexesFromZero());
38  (reinterpret_cast<float_v&>(fP[iP][iTr])).gather(reinterpret_cast<const float*>(&value), index, simd_cast<float_m>(index<(Size() - iTr)));
39  }
40 }
41 void KFPEmcCluster::SetCovariance(const float_v& value, int iC, int iTr)
42 {
49  if( (iTr+float_vLen) < Size())
50  reinterpret_cast<float_v&>(fC[iC][iTr]) = value;
51  else
52  {
53  const uint_v index(uint_v::IndexesFromZero());
54  (reinterpret_cast<float_v&>(fC[iC][iTr])).gather(reinterpret_cast<const float*>(&value), index, simd_cast<float_m>(index<(Size() - iTr)));
55  }
56 }
57 
58 void KFPEmcCluster::Resize(const int n)
59 {
63  for(int i=0; i<4; i++)
64  fP[i].resize(n);
65  for(int i=0; i<10; i++)
66  fC[i].resize(n);
67  fId.resize(n);
68 }
69 
70 void KFPEmcCluster::Set(KFPEmcCluster& v, int vSize, int offset)
71 {
78  for(int iV=0; iV<vSize; iV++)
79  {
80  for(int i=0; i<4; i++)
81  fP[i][offset+iV] = v.fP[i][iV];
82  for(int i=0; i<10; i++)
83  fC[i][offset+iV] = v.fC[i][iV];
84  fId[offset+iV] = v.fId[iV];
85  }
86 }
87 
88 void KFPEmcCluster::SetTracks(const KFPEmcCluster& track, const kfvector_uint& trackIndex, const int nIndexes)
89 {
96  if(nIndexes == 0) return;
97 
98  Resize(nIndexes);
99 
100  for(int iP=0; iP<4; iP++)
101  {
102  int iElement = 0;
103  for(iElement=0; iElement<nIndexes-float_vLen; iElement += float_vLen)
104  {
105  const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
106  float_v& vec = reinterpret_cast<float_v&>(fP[iP][iElement]);
107  vec.gather(&(track.fP[iP][0]), index);
108  }
109  const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
110  float_v& vec = reinterpret_cast<float_v&>(fP[iP][iElement]);
111  vec.gather(&(track.fP[iP][0]), index, simd_cast<float_m>(iElement+uint_v::IndexesFromZero()<nIndexes));
112 
113  }
114  for(int iC=0; iC<10; iC++)
115  {
116  int iElement=0;
117  for(iElement=0; iElement<nIndexes-float_vLen; iElement += float_vLen)
118  {
119  const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
120  float_v& vec = reinterpret_cast<float_v&>(fC[iC][iElement]);
121  vec.gather(&(track.fC[iC][0]), index);
122  }
123  const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
124  float_v& vec = reinterpret_cast<float_v&>(fC[iC][iElement]);
125  vec.gather(&(track.fC[iC][0]), index, simd_cast<float_m>(iElement+uint_v::IndexesFromZero()<nIndexes));
126  }
127  {
128  int iElement=0;
129  for(iElement=0; iElement<nIndexes-float_vLen; iElement += float_vLen)
130  {
131  const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
132  int_v& vec = reinterpret_cast<int_v&>(fId[iElement]);
133  vec.gather(&(track.fId[0]), index);
134  }
135  const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
136  int_v& vec = reinterpret_cast<int_v&>(fId[iElement]);
137  vec.gather(&(track.fId[0]), index, int_m(iElement+uint_v::IndexesFromZero()<nIndexes));
138  }
139 }
140 
142 {
146  for(int i=0; i<4; i++)
147  std::cout << fP[i][n] << " ";
148  std::cout << std::endl;
149  for(int i=0; i<10; i++)
150  std::cout << fC[i][n] << " ";
151  std::cout << std::endl;
152 
153  std::cout << fId[n] << std::endl;
154 }
155 
157 {
160  std::cout << "NTracks " << Size() << std::endl;
161  if( Size()==0 ) return;
162 
163  std::cout << "Parameters: " << std::endl;
164  for(int iP=0; iP<4; iP++)
165  {
166  std::cout << " iP " << iP << ": ";
167  for(int iTr=0; iTr<Size(); iTr++)
168  std::cout << Parameter(iP)[iTr]<< " ";
169  std::cout << std::endl;
170  }
171 
172  std::cout << "Cov matrix: " << std::endl;
173  for(int iC=0; iC<10; iC++)
174  {
175  std::cout << " iC " << iC << ": ";
176  for(int iTr=0; iTr<Size(); iTr++)
177  std::cout << Covariance(iC)[iTr]<< " ";
178  std::cout << std::endl;
179  }
180 
181  std::cout << "Id: " << std::endl;
182  for(int iTr=0; iTr<Size(); iTr++)
183  std::cout << Id()[iTr] << " ";
184  std::cout << std::endl;
185 }
186