Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ macro(add_target_property _target _prop _value)
endmacro(add_target_property)

if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT ${CMAKE_CXX_FLAGS} MATCHES "-std=")
set (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
endif ()
else ()
set (CMAKE_CXX_STANDARD 11)
if (NOT DEFINED CMAKE_CXX_STANDARD AND NOT ${CMAKE_CXX_FLAGS} MATCHES "-std=")
set (CMAKE_CXX_STANDARD 11)
endif()
endif ()

list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS} ${ROOTSYS})
Expand Down
19 changes: 7 additions & 12 deletions KFLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
#pragma link off all functions;

//KFParticle
#pragma link C++ class KFParticleBase+;
#pragma link C++ class KFParticle+;
#pragma link C++ class KFVertex+;
#pragma link C++ class KFPartEfficiencies+;
#pragma link C++ class KFMCParticle+;
#pragma link C++ class KFParticle+;
#pragma link C++ class KFParticleTest+;
#pragma link C++ class KFParticleBase + ;
#pragma link C++ class KFParticle + ;
#pragma link C++ class KFVertex + ;
#pragma link C++ class KFPartEfficiencies + ;
#pragma link C++ class KFMCParticle + ;
#pragma link C++ class KFParticle + ;
#pragma link C++ class KFParticleTest + ;

#endif





102 changes: 46 additions & 56 deletions KFParticle/KFPEmcCluster.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,33 @@
#include <iostream>

void KFPEmcCluster::SetParameter(const float_v& value, int iP, int iTr)
{
{
/** Copies the SIMD vector "value" to the parameter vector KFPEmcCluster::fP[iP]
** starting at the position "iTr".
** \param[in] value - SIMD vector with the values to be stored
** \param[in] iP - number of the parameter vector
** \param[in] iTr - starting position in the parameter vector where the values should be stored
**/
if( (iTr+float_vLen) < Size())
if ((iTr + float_vLen) < Size())
reinterpret_cast<float_v&>(fP[iP][iTr]) = value;
else
{
else {
const uint_v index(uint_v::IndexesFromZero());
(reinterpret_cast<float_v&>(fP[iP][iTr])).gather(reinterpret_cast<const float*>(&value), index, simd_cast<float_m>(index<(Size() - iTr)));
(reinterpret_cast<float_v&>(fP[iP][iTr])).gather(reinterpret_cast<const float*>(&value), index, simd_cast<float_m>(index < (Size() - iTr)));
}
}
void KFPEmcCluster::SetCovariance(const float_v& value, int iC, int iTr)
{
void KFPEmcCluster::SetCovariance(const float_v& value, int iC, int iTr)
{
/** Copies the SIMD vector "value" to the element of the covariance matrix vector KFPEmcCluster::fC[iC]
** starting at the position "iTr".
** \param[in] value - SIMD vector with the values to be stored
** \param[in] iC - number of the element of the covariance matrix
** \param[in] iTr - starting position in the parameter vector where the values should be stored
**/
if( (iTr+float_vLen) < Size())
if ((iTr + float_vLen) < Size())
reinterpret_cast<float_v&>(fC[iC][iTr]) = value;
else
{
else {
const uint_v index(uint_v::IndexesFromZero());
(reinterpret_cast<float_v&>(fC[iC][iTr])).gather(reinterpret_cast<const float*>(&value), index, simd_cast<float_m>(index<(Size() - iTr)));
(reinterpret_cast<float_v&>(fC[iC][iTr])).gather(reinterpret_cast<const float*>(&value), index, simd_cast<float_m>(index < (Size() - iTr)));
}
}

Expand All @@ -60,9 +58,9 @@ void KFPEmcCluster::Resize(const int n)
/** Resizes all vectors in the class to a given value.
** \param[in] n - new size of the vector
**/
for(int i=0; i<4; i++)
for (int i = 0; i < 4; i++)
fP[i].resize(n);
for(int i=0; i<10; i++)
for (int i = 0; i < 10; i++)
fC[i].resize(n);
fId.resize(n);
}
Expand All @@ -75,13 +73,12 @@ void KFPEmcCluster::Set(KFPEmcCluster& v, int vSize, int offset)
** \param[in] vSize - number of clusters to be copied from "v"
** \param[in] offset - offset position in the current object, starting from which input clusters will be stored
**/
for(int iV=0; iV<vSize; iV++)
{
for(int i=0; i<4; i++)
fP[i][offset+iV] = v.fP[i][iV];
for(int i=0; i<10; i++)
fC[i][offset+iV] = v.fC[i][iV];
fId[offset+iV] = v.fId[iV];
for (int iV = 0; iV < vSize; iV++) {
for (int i = 0; i < 4; i++)
fP[i][offset + iV] = v.fP[i][iV];
for (int i = 0; i < 10; i++)
fC[i][offset + iV] = v.fC[i][iV];
fId[offset + iV] = v.fId[iV];
}
}

Expand All @@ -93,48 +90,43 @@ void KFPEmcCluster::SetTracks(const KFPEmcCluster& track, const kfvector_uint& t
** \param[in] nIndexes - number of clusters to be copied, defines the new size of the current object
**/

if(nIndexes == 0) return;

if (nIndexes == 0)
return;

Resize(nIndexes);

for(int iP=0; iP<4; iP++)
{
for (int iP = 0; iP < 4; iP++) {
int iElement = 0;
for(iElement=0; iElement<nIndexes-float_vLen; iElement += float_vLen)
{
for (iElement = 0; iElement < nIndexes - float_vLen; iElement += float_vLen) {
const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
float_v& vec = reinterpret_cast<float_v&>(fP[iP][iElement]);
vec.gather(&(track.fP[iP][0]), index);
}
const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
float_v& vec = reinterpret_cast<float_v&>(fP[iP][iElement]);
vec.gather(&(track.fP[iP][0]), index, simd_cast<float_m>(iElement+uint_v::IndexesFromZero()<nIndexes));

vec.gather(&(track.fP[iP][0]), index, simd_cast<float_m>(iElement + uint_v::IndexesFromZero() < nIndexes));
}
for(int iC=0; iC<10; iC++)
{
int iElement=0;
for(iElement=0; iElement<nIndexes-float_vLen; iElement += float_vLen)
{
for (int iC = 0; iC < 10; iC++) {
int iElement = 0;
for (iElement = 0; iElement < nIndexes - float_vLen; iElement += float_vLen) {
const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
float_v& vec = reinterpret_cast<float_v&>(fC[iC][iElement]);
vec.gather(&(track.fC[iC][0]), index);
}
const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
float_v& vec = reinterpret_cast<float_v&>(fC[iC][iElement]);
vec.gather(&(track.fC[iC][0]), index, simd_cast<float_m>(iElement+uint_v::IndexesFromZero()<nIndexes));
vec.gather(&(track.fC[iC][0]), index, simd_cast<float_m>(iElement + uint_v::IndexesFromZero() < nIndexes));
}
{
int iElement=0;
for(iElement=0; iElement<nIndexes-float_vLen; iElement += float_vLen)
{
int iElement = 0;
for (iElement = 0; iElement < nIndexes - float_vLen; iElement += float_vLen) {
const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
int_v& vec = reinterpret_cast<int_v&>(fId[iElement]);
vec.gather(&(track.fId[0]), index);
}
const uint_v& index = reinterpret_cast<const uint_v&>(trackIndex[iElement]);
int_v& vec = reinterpret_cast<int_v&>(fId[iElement]);
vec.gather(&(track.fId[0]), index, int_m(iElement+uint_v::IndexesFromZero()<nIndexes));
vec.gather(&(track.fId[0]), index, int_m(iElement + uint_v::IndexesFromZero() < nIndexes));
}
}

Expand All @@ -143,44 +135,42 @@ void KFPEmcCluster::PrintTrack(int n)
/** Prints parameters of the cluster with index "n".
** \param[in] n - index of cluster to be printed
**/
for(int i=0; i<4; i++)
for (int i = 0; i < 4; i++)
std::cout << fP[i][n] << " ";
std::cout << std::endl;
for(int i=0; i<10; i++)
for (int i = 0; i < 10; i++)
std::cout << fC[i][n] << " ";
std::cout << std::endl;

std::cout << fId[n] << std::endl;
}

void KFPEmcCluster::PrintTracks()
{
/** Prints all field of the current object. **/

std::cout << "NTracks " << Size() << std::endl;
if( Size()==0 ) return;

if (Size() == 0)
return;

std::cout << "Parameters: " << std::endl;
for(int iP=0; iP<4; iP++)
{
for (int iP = 0; iP < 4; iP++) {
std::cout << " iP " << iP << ": ";
for(int iTr=0; iTr<Size(); iTr++)
std::cout << Parameter(iP)[iTr]<< " ";
for (int iTr = 0; iTr < Size(); iTr++)
std::cout << Parameter(iP)[iTr] << " ";
std::cout << std::endl;
}

std::cout << "Cov matrix: " << std::endl;
for(int iC=0; iC<10; iC++)
{
for (int iC = 0; iC < 10; iC++) {
std::cout << " iC " << iC << ": ";
for(int iTr=0; iTr<Size(); iTr++)
std::cout << Covariance(iC)[iTr]<< " ";
for (int iTr = 0; iTr < Size(); iTr++)
std::cout << Covariance(iC)[iTr] << " ";
std::cout << std::endl;
}

std::cout << "Id: " << std::endl;
for(int iTr=0; iTr<Size(); iTr++)
std::cout << Id()[iTr] << " ";
for (int iTr = 0; iTr < Size(); iTr++)
std::cout << Id()[iTr] << " ";
std::cout << std::endl;
}

84 changes: 40 additions & 44 deletions KFParticle/KFPEmcCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,88 +42,84 @@
class KFPEmcCluster
{
public:
KFPEmcCluster():fP(), fC(), fId() { }
virtual ~KFPEmcCluster() { }
KFPEmcCluster() : fP(), fC(), fId() {}
virtual ~KFPEmcCluster() {}

/**Returns size of the vectors. All data vectors have the same size. */
int Size() const { return fP[0].size(); }

void Resize(const int n);
void Set(KFPEmcCluster& v, int vSize, int offset);
void SetTracks(const KFPEmcCluster& track, const kfvector_uint& trackIndex, const int nIndexes);
const kfvector_float& X() const { return fP[0]; } ///< Returns constant reference to the vector with X coordinates.
const kfvector_float& Y() const { return fP[1]; } ///< Returns constant reference to the vector with Y coordinates.
const kfvector_float& Z() const { return fP[2]; } ///< Returns constant reference to the vector with Z coordinates.
const kfvector_float& E() const { return fP[3]; } ///< Returns constant reference to the vector with energy of the cluster.

const kfvector_float& Parameter(const int i) const { return fP[i]; } ///< Returns constant reference to the parameter vector with index "i".
const kfvector_float& Covariance(const int i) const { return fC[i]; } ///< Returns constant reference to the vector of the covariance matrix elements with index "i".
const kfvector_int& Id() const { return fId; } ///< Returns constant reference to the vector with unique id of the clusters.

//modifiers
void SetParameter (float value, int iP, int iTr) { fP[iP][iTr] = value; } ///< Sets the "value" of the parameter "iP" of the cluster with index "iTr".

const kfvector_float& X() const { return fP[0]; } ///< Returns constant reference to the vector with X coordinates.
const kfvector_float& Y() const { return fP[1]; } ///< Returns constant reference to the vector with Y coordinates.
const kfvector_float& Z() const { return fP[2]; } ///< Returns constant reference to the vector with Z coordinates.
const kfvector_float& E() const { return fP[3]; } ///< Returns constant reference to the vector with energy of the cluster.

const kfvector_float& Parameter(const int i) const { return fP[i]; } ///< Returns constant reference to the parameter vector with index "i".
const kfvector_float& Covariance(const int i) const { return fC[i]; } ///< Returns constant reference to the vector of the covariance matrix elements with index "i".
const kfvector_int& Id() const { return fId; } ///< Returns constant reference to the vector with unique id of the clusters.

//modifiers
void SetParameter(float value, int iP, int iTr) { fP[iP][iTr] = value; } ///< Sets the "value" of the parameter "iP" of the cluster with index "iTr".
void SetCovariance(float value, int iC, int iTr) { fC[iC][iTr] = value; } ///< Sets the "value" of the element of covariance matrix "iC" of the cluster with index "iTr".

void SetParameter (const float_v& value, int iP, int iTr);
void SetParameter(const float_v& value, int iP, int iTr);
void SetCovariance(const float_v& value, int iC, int iTr);

void SetId (int value, int iTr) { fId[iTr] = value; } ///< Sets the "value" of the id of the cluster with index "iTr".
void SetId(int value, int iTr) { fId[iTr] = value; } ///< Sets the "value" of the id of the cluster with index "iTr".

void PrintTrack(int n);
void PrintTracks();
KFPEmcCluster(const KFPEmcCluster& clusters): fId()

KFPEmcCluster(const KFPEmcCluster& clusters) : fId()
{
/** Copy-constructor. Makes one-to-one copy.*/
const int localSize = clusters.Size();

for(int i=0; i<4; i++)
{

for (int i = 0; i < 4; i++) {
fP[i].resize(localSize);
for(int n=0; n<localSize; n++)
for (int n = 0; n < localSize; n++)
fP[i][n] = clusters.fP[i][n];
}

for(int i=0; i<10; i++)
{
for (int i = 0; i < 10; i++) {
fC[i].resize(localSize);
for(int n=0; n<localSize; n++)
for (int n = 0; n < localSize; n++)
fC[i][n] = clusters.fC[i][n];
}

fId.resize(localSize);
for(int n=0; n<localSize; n++)
fId[n] = clusters.fId[n];
for (int n = 0; n < localSize; n++)
fId[n] = clusters.fId[n];
}
const KFPEmcCluster& operator = (const KFPEmcCluster& clusters)

const KFPEmcCluster& operator=(const KFPEmcCluster& clusters)
{
/** Operator to copy one KFPEmcCluster object to another. Makes one-to-one copy.*/
const int localSize = clusters.Size();

for(int i=0; i<4; i++)
{

for (int i = 0; i < 4; i++) {
fP[i].resize(localSize);
for(int n=0; n<localSize; n++)
for (int n = 0; n < localSize; n++)
fP[i][n] = clusters.fP[i][n];
}

for(int i=0; i<10; i++)
{
for (int i = 0; i < 10; i++) {
fC[i].resize(localSize);
for(int n=0; n<localSize; n++)
for (int n = 0; n < localSize; n++)
fC[i][n] = clusters.fC[i][n];
}

fId.resize(localSize);
for(int n=0; n<localSize; n++)
for (int n = 0; n < localSize; n++)
fId[n] = clusters.fId[n];

return *this;
}
private:

private:
kfvector_float fP[4]; ///< Coordinates of the cluster and energy: X, Y, Z, E.
kfvector_float fC[10]; ///< Covariance matrix of the parameters of the cluster.

Expand Down
Loading