From 10e10dab71190a9bbfedc38c7e54a32c936f990e Mon Sep 17 00:00:00 2001 From: shahoian Date: Fri, 25 Dec 2020 19:09:55 +0100 Subject: [PATCH 1/3] Do not override explicitly -std=+ccXX option if set externally --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fbd90c..dffa254 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) From 979d356f41582199e3a415a96daff2ecd50ee4e3 Mon Sep 17 00:00:00 2001 From: sgorbuno Date: Thu, 25 Feb 2021 13:49:21 +0000 Subject: [PATCH 2/3] auto-reformat all the code with clang-format --- KFLinkDef.h | 19 +- KFParticle/KFPEmcCluster.cxx | 102 +- KFParticle/KFPEmcCluster.h | 84 +- KFParticle/KFPInputData.h | 246 +- KFParticle/KFPSimdAllocator.h | 82 +- KFParticle/KFPTrack.cxx | 69 +- KFParticle/KFPTrack.h | 178 +- KFParticle/KFPTrackVector.cxx | 337 +- KFParticle/KFPTrackVector.h | 469 +- KFParticle/KFPVertex.cxx | 8 +- KFParticle/KFPVertex.h | 77 +- KFParticle/KFParticle.cxx | 367 +- KFParticle/KFParticle.h | 867 ++-- KFParticle/KFParticleBase.cxx | 3736 +++++++------- KFParticle/KFParticleBase.h | 308 +- KFParticle/KFParticleBaseSIMD.cxx | 4392 +++++++++-------- KFParticle/KFParticleBaseSIMD.h | 350 +- KFParticle/KFParticleDatabase.cxx | 85 +- KFParticle/KFParticleDatabase.h | 175 +- KFParticle/KFParticleDef.h | 177 +- KFParticle/KFParticleField.h | 102 +- KFParticle/KFParticleFinder.cxx | 3099 ++++++------ KFParticle/KFParticleFinder.h | 394 +- KFParticle/KFParticlePVReconstructor.cxx | 278 +- KFParticle/KFParticlePVReconstructor.h | 80 +- KFParticle/KFParticleSIMD.cxx | 816 +-- KFParticle/KFParticleSIMD.h | 838 ++-- KFParticle/KFParticleTopoReconstructor.cxx | 1071 ++-- KFParticle/KFParticleTopoReconstructor.h | 162 +- KFParticle/KFVertex.cxx | 123 +- KFParticle/KFVertex.h | 52 +- KFParticlePerformance/KFMCCounter.h | 79 +- KFParticlePerformance/KFMCParticle.cxx | 7 +- KFParticlePerformance/KFMCParticle.h | 59 +- KFParticlePerformance/KFMCTrack.h | 81 +- KFParticlePerformance/KFMCVertex.cxx | 16 +- KFParticlePerformance/KFMCVertex.h | 66 +- KFParticlePerformance/KFPVEfficiencies.h | 150 +- KFParticlePerformance/KFPartEfficiencies.h | 1747 +++---- KFParticlePerformance/KFPartMatch.h | 28 +- .../KFParticlePerformanceBase.cxx | 901 ++-- .../KFParticlePerformanceBase.h | 163 +- KFParticlePerformance/KFTopoPerformance.cxx | 2191 ++++---- KFParticlePerformance/KFTopoPerformance.h | 95 +- KFParticleTest/KFParticleTest.cxx | 241 +- KFParticleTest/KFParticleTest.h | 13 +- 46 files changed, 12602 insertions(+), 12378 deletions(-) diff --git a/KFLinkDef.h b/KFLinkDef.h index 3d82f75..d51285b 100644 --- a/KFLinkDef.h +++ b/KFLinkDef.h @@ -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 - - - - - diff --git a/KFParticle/KFPEmcCluster.cxx b/KFParticle/KFPEmcCluster.cxx index ab3f714..9a3f768 100644 --- a/KFParticle/KFPEmcCluster.cxx +++ b/KFParticle/KFPEmcCluster.cxx @@ -23,35 +23,33 @@ #include 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(fP[iP][iTr]) = value; - else - { + else { const uint_v index(uint_v::IndexesFromZero()); - (reinterpret_cast(fP[iP][iTr])).gather(reinterpret_cast(&value), index, simd_cast(index<(Size() - iTr))); + (reinterpret_cast(fP[iP][iTr])).gather(reinterpret_cast(&value), index, simd_cast(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(fC[iC][iTr]) = value; - else - { + else { const uint_v index(uint_v::IndexesFromZero()); - (reinterpret_cast(fC[iC][iTr])).gather(reinterpret_cast(&value), index, simd_cast(index<(Size() - iTr))); + (reinterpret_cast(fC[iC][iTr])).gather(reinterpret_cast(&value), index, simd_cast(index < (Size() - iTr))); } } @@ -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); } @@ -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(trackIndex[iElement]); float_v& vec = reinterpret_cast(fP[iP][iElement]); vec.gather(&(track.fP[iP][0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); float_v& vec = reinterpret_cast(fP[iP][iElement]); - vec.gather(&(track.fP[iP][0]), index, simd_cast(iElement+uint_v::IndexesFromZero()(iElement + uint_v::IndexesFromZero() < nIndexes)); } - for(int iC=0; iC<10; iC++) - { - int iElement=0; - for(iElement=0; iElement(trackIndex[iElement]); float_v& vec = reinterpret_cast(fC[iC][iElement]); vec.gather(&(track.fC[iC][0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); float_v& vec = reinterpret_cast(fC[iC][iElement]); - vec.gather(&(track.fC[iC][0]), index, simd_cast(iElement+uint_v::IndexesFromZero()(iElement + uint_v::IndexesFromZero() < nIndexes)); } { - int iElement=0; - for(iElement=0; iElement(trackIndex[iElement]); int_v& vec = reinterpret_cast(fId[iElement]); vec.gather(&(track.fId[0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); int_v& vec = reinterpret_cast(fId[iElement]); - vec.gather(&(track.fId[0]), index, int_m(iElement+uint_v::IndexesFromZero()> fBz; ifile >> nSets; - for(int iSet=0; iSet> nTracks; fTracks[iSet].Resize(nTracks); - - for(int iP=0; iP<6; iP++) - { + + for (int iP = 0; iP < 6; iP++) { float value; - for(int iTr=0; iTr> value; fTracks[iSet].SetParameter(value, iP, iTr); } } - for(int iC=0; iC<21; iC++) - { + for (int iC = 0; iC < 21; iC++) { float value; - for(int iTr=0; iTr> value; fTracks[iSet].SetCovariance(value, iC, iTr); } } int tmpInt; - for(int iTr=0; iTr> tmpInt; fTracks[iSet].SetId(tmpInt, iTr); } - - for(int iTr=0; iTr> tmpInt; fTracks[iSet].SetPDG(tmpInt, iTr); } - for(int iTr=0; iTr> tmpInt; fTracks[iSet].SetQ(tmpInt, iTr); } - - for(int iTr=0; iTr> tmpInt; fTracks[iSet].SetPVIndex(tmpInt, iTr); } - + ifile >> tmpInt; fTracks[iSet].SetLastElectron(tmpInt); ifile >> tmpInt; - fTracks[iSet].SetLastMuon (tmpInt); + fTracks[iSet].SetLastMuon(tmpInt); ifile >> tmpInt; - fTracks[iSet].SetLastPion (tmpInt); + fTracks[iSet].SetLastPion(tmpInt); ifile >> tmpInt; - fTracks[iSet].SetLastKaon (tmpInt); + fTracks[iSet].SetLastKaon(tmpInt); ifile >> tmpInt; - fTracks[iSet].SetLastProton (tmpInt); + fTracks[iSet].SetLastProton(tmpInt); } int nPV; - ifile>>nPV; + ifile >> nPV; fPV.resize(nPV); - for(unsigned int iPV=0; iPV < fPV.size(); iPV++) - { - for(int iP=0; iP<3; iP++) + for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { + for (int iP = 0; iP < 3; iP++) ifile >> fPV[iPV].Parameter(iP); - - for(int iC=0; iC<6; iC++) + + for (int iC = 0; iC < 6; iC++) ifile >> fPV[iPV].Covariance(iC); } - + ifile.close(); return 1; } - + void SetDataToVector(int* data, int& dataSize) { /** Stores information to the memory under pointer "data". @@ -184,41 +172,37 @@ class KFPInputData ** \param[out] dataSize - size of the stored memory in "int" (or bloks of 4 bytes, or 32 bits) **/ dataSize = NInputSets + 1 + 1; //sizes of the track vectors and pv vector, and field - for(int iSet=0; iSet(data[NInputSets+1]); + + float& field = reinterpret_cast(data[NInputSets + 1]); field = fBz; - - int offset = NInputSets+2; - - for(int iSet=0; iSet(data[offset + iPV]); tmpFloat = fPV[iPV].Parameter(iP); } offset += fPV.size(); } - - for(int iC=0; iC<6; iC++) - { - for(unsigned int iPV=0; iPV(data[offset + iPV]); tmpFloat = fPV[iPV].Covariance(iC); } offset += fPV.size(); - } + } } void ReadDataFromVector(int* data) @@ -226,94 +210,88 @@ class KFPInputData /** Reads input data from the given memory. ** \param[in] data - pointer to the memory with the input data **/ - int offset = NInputSets+2; - for(int iSet=0; iSet(data[NInputSets+1]); + + float& field = reinterpret_cast(data[NInputSets + 1]); fBz = field; - + fPV.resize(data[NInputSets]); - - for(int iP=0; iP<3; iP++) - { - for(unsigned int iPV=0; iPV(data[offset + iPV]); fPV[iPV].Parameter(iP) = tmpFloat; } offset += fPV.size(); } - - for(int iC=0; iC<6; iC++) - { - for(unsigned int iPV=0; iPV(data[offset + iPV]); fPV[iPV].Covariance(iC) = tmpFloat; } offset += fPV.size(); - } + } } - + void Print() { /**Prints all fields of the current object.*/ - for(int iSet=0; iSet& GetPV() const { return fPV; } ///< Returns vector with primary vertices. - const KFPInputData& operator = (const KFPInputData& data) + const KFPInputData& operator=(const KFPInputData& data) { /** Copies input data from object "data" to the current object. Returns the current object. \param[in] data - input data*/ - for(int i=0; i fPV; ///< Vector with primary vertices. - float fBz; ///< Constant homogenious one-component magnetic field Bz. + float fBz; ///< Constant homogenious one-component magnetic field Bz. } __attribute__((aligned(sizeof(float_v)))); /** @class KFPInputDataArray @@ -341,18 +319,21 @@ class KFPInputData ** objects of this structure is disabled. **/ -struct KFPInputDataArray{ - KFPInputDataArray():fInput(0){}; - virtual ~KFPInputDataArray() { if(fInput) delete [] fInput; } +struct KFPInputDataArray { + KFPInputDataArray() : fInput(0){}; + virtual ~KFPInputDataArray() + { + if (fInput) + delete[] fInput; + } + + KFPInputData* fInput; ///< Pointer to the array of the input data objects. - KFPInputData *fInput; ///< Pointer to the array of the input data objects. - private: - const KFPInputDataArray& operator = (const KFPInputDataArray&); - KFPInputDataArray(const KFPInputDataArray&); + const KFPInputDataArray& operator=(const KFPInputDataArray&); + KFPInputDataArray(const KFPInputDataArray&); }; - /** @class KFPLinkedList ** @brief Structure to creat a linked list of the input data. ** @author M.Zyzak, I.Kisel @@ -364,17 +345,16 @@ struct KFPInputDataArray{ ** at the device side (Intel Xeon Phi). **/ -struct KFPLinkedList -{ - void *operator new(size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new[](size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new(size_t size, void *ptr) { return ::operator new(size, ptr);} ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new[](size_t size, void *ptr) { return ::operator new(size, ptr);} ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void operator delete(void *ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release - void operator delete[](void *ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release - +struct KFPLinkedList { + void* operator new(size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new[](size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new(size_t size, void* ptr) { return ::operator new(size, ptr); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new[](size_t size, void* ptr) { return ::operator new(size, ptr); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void operator delete(void* ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release + void operator delete[](void* ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release + KFPInputData data __attribute__((aligned(sizeof(float_v)))); ///< Input data for KF Particle Finder \see KFPInputData. - KFPLinkedList* next; ///< Link to the nex object in the linked list. + KFPLinkedList* next; ///< Link to the nex object in the linked list. } __attribute__((aligned(sizeof(float_v)))); #endif diff --git a/KFParticle/KFPSimdAllocator.h b/KFParticle/KFPSimdAllocator.h index 1703afe..20a13c4 100644 --- a/KFParticle/KFPSimdAllocator.h +++ b/KFParticle/KFPSimdAllocator.h @@ -32,15 +32,16 @@ **/ template -class KFPSimdAllocator { +class KFPSimdAllocator +{ public: - // type definitions - typedef T value_type; - typedef T* pointer; + // type definitions + typedef T value_type; + typedef T* pointer; typedef const T* const_pointer; - typedef T& reference; + typedef T& reference; typedef const T& const_reference; - typedef std::size_t size_type; + typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; /** @class rebind @@ -55,65 +56,74 @@ class KFPSimdAllocator { }; /** Return address of "value". */ - pointer address (reference value) const { + pointer address(reference value) const + { return &value; } /** Return address of "value". */ - const_pointer address (const_reference value) const { + const_pointer address(const_reference value) const + { return &value; } /* constructors and destructor * - nothing to do because the allocator has no state */ - KFPSimdAllocator() throw() { } - KFPSimdAllocator(const KFPSimdAllocator&) throw() { } + KFPSimdAllocator() throw() {} + KFPSimdAllocator(const KFPSimdAllocator&) throw() {} template - KFPSimdAllocator (const KFPSimdAllocator&) throw() { } - virtual ~KFPSimdAllocator() throw() { } + KFPSimdAllocator(const KFPSimdAllocator&) throw() + { + } + virtual ~KFPSimdAllocator() throw() {} /** Return maximum number of elements that can be allocated. */ - size_type max_size () const throw() { + size_type max_size() const throw() + { return std::numeric_limits::max() / sizeof(T); } /** Allocate but don't initialize num elements of type T. */ - pointer allocate (size_type num, const void* = 0) { -// print message and allocate memory with global new - pointer ret = reinterpret_cast( /*T::*/operator new(num*sizeof(T)) ); + pointer allocate(size_type num, const void* = 0) + { + // print message and allocate memory with global new + pointer ret = reinterpret_cast(/*T::*/ operator new(num * sizeof(T))); return ret; } /** Initialize elements of allocated storage "p" with an empty element. */ - void construct (pointer p) { - // initialize memory with placement new - new(p) T(); + void construct(pointer p) + { + // initialize memory with placement new + new (p) T(); } - + /** Initialize elements of allocated storage "p" with value "value". */ - void construct (pointer p, const T& value) { - new(p) T(value); + void construct(pointer p, const T& value) + { + new (p) T(value); } /** Destroy elements of initialized storage "p". */ - void destroy (pointer p) { - // destroy objects by calling their destructor + void destroy(pointer p) + { + // destroy objects by calling their destructor p->~T(); } /** Deallocate storage p of deleted elements. */ - void deallocate (pointer p, size_type num) { - // print message and deallocate memory with global delete - /*T::*/operator delete(static_cast(p), num*sizeof(T)); - + void deallocate(pointer p, size_type num) + { + // print message and deallocate memory with global delete + /*T::*/ operator delete(static_cast(p), num * sizeof(T)); } - void *operator new(size_t size, void *ptr) { return ::operator new(size, ptr);} ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new[](size_t size, void *ptr) { return ::operator new(size, ptr);} ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new(size_t size) { return _mm_malloc(size, sizeof(Vc::float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new[](size_t size) { return _mm_malloc(size, sizeof(Vc::float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void operator delete(void *ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release - void operator delete[](void *ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release -}; // KFPSimdAllocator - + void* operator new(size_t size, void* ptr) { return ::operator new(size, ptr); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new[](size_t size, void* ptr) { return ::operator new(size, ptr); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new(size_t size) { return _mm_malloc(size, sizeof(Vc::float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new[](size_t size) { return _mm_malloc(size, sizeof(Vc::float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void operator delete(void* ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release + void operator delete[](void* ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release +}; // KFPSimdAllocator + #endif //KFPSimdAllocator diff --git a/KFParticle/KFPTrack.cxx b/KFParticle/KFPTrack.cxx index a0043e0..7afe5e8 100644 --- a/KFParticle/KFPTrack.cxx +++ b/KFParticle/KFPTrack.cxx @@ -25,7 +25,7 @@ ClassImp(KFPTrack); #endif -void KFPTrack::RotateXY( float alpha ) +void KFPTrack::RotateXY(float alpha) { /** Rotates the parameters of the track on an angle alpha in the XY plane. ** Can be used in case of the transforamtion of the coordinate system. @@ -40,8 +40,8 @@ void KFPTrack::RotateXY( float alpha ) \endverbatim ** \param[in] alpha - rotation angle **/ - const float cA = cos( alpha ); - const float sA = sin( alpha ); + const float cA = cos(alpha); + const float sA = sin(alpha); //float J[6][6] = { { cA, -sA, 0, 0, 0, 0 }, // X // { sA, cA, 0, 0, 0, 0 }, // Y @@ -50,45 +50,44 @@ void KFPTrack::RotateXY( float alpha ) // { 0, 0, 0, sA, cA, 0 }, // Py // { 0, 0, 0, 0, 0, 1 } }; // Pz - const float x = GetX(), y = GetY(); + const float x = GetX(), y = GetY(); - SetX( -(x*sA + y*cA) ); - SetY( x*cA - y*sA ); + SetX(-(x * sA + y * cA)); + SetY(x * cA - y * sA); - const float px = GetPx(), py = GetPy(); + const float px = GetPx(), py = GetPy(); - SetPx( -(px*sA + py*cA) ); - SetPy( px*cA - py*sA ); + SetPx(-(px * sA + py * cA)); + SetPy(px * cA - py * sA); float cov[21]; - for(int iC=0; iC<21; iC++) + for (int iC = 0; iC < 21; iC++) cov[iC] = fC[iC]; - fC[0] = cA*cA* cov[2] + 2* cA* cov[1]* sA + cov[0]*sA* sA; - - fC[1] = -(cA*cA * cov[1]) + cA* (-cov[0] + cov[2])* sA + cov[1]*sA* sA; - fC[2] = cA*cA* cov[0] - 2* cA* cov[1]* sA + cov[2]*sA* sA; - - fC[3] = -(cA* cov[4]) - cov[3]* sA; - fC[4] = cA* cov[3] - cov[4]* sA; - fC[5] = cov[5]; - - fC[6] = cA*cA* cov[11] + cA *(cov[10] + cov[7])* sA + cov[6]*sA* sA; - fC[7] = -(cA*cA * cov[10]) + cA* (cov[11] - cov[6])* sA + cov[7] *sA*sA; - fC[8] = -(cA *cov[12]) - cov[8] *sA; - fC[9] = cA*cA* cov[14] + 2 *cA* cov[13]* sA + cov[9]* sA*sA; + fC[0] = cA * cA * cov[2] + 2 * cA * cov[1] * sA + cov[0] * sA * sA; - fC[10] = -(cA*cA* cov[7]) + cA* (cov[11] - cov[6])* sA + cov[10]*sA* sA; - fC[11] = cA*cA* cov[6] - cA* (cov[10] + cov[7]) *sA + cov[11]*sA* sA; - fC[12] = cA* cov[8] - cov[12]* sA; - fC[13] = -(cA*cA* cov[13]) + cA* (cov[14] - cov[9])* sA + cov[13]* sA*sA; - fC[14] = cA*cA* cov[9] - 2* cA* cov[13]* sA + cov[14]* sA*sA; - - fC[15] = -(cA* cov[16]) - cov[15]* sA; - fC[16] = cA* cov[15] - cov[16]* sA; - fC[17] = cov[17]; - fC[18] = -(cA* cov[19]) - cov[18]* sA; - fC[19] = cA* cov[18] - cov[19]* sA; - fC[20] = cov[20]; + fC[1] = -(cA * cA * cov[1]) + cA * (-cov[0] + cov[2]) * sA + cov[1] * sA * sA; + fC[2] = cA * cA * cov[0] - 2 * cA * cov[1] * sA + cov[2] * sA * sA; + + fC[3] = -(cA * cov[4]) - cov[3] * sA; + fC[4] = cA * cov[3] - cov[4] * sA; + fC[5] = cov[5]; + + fC[6] = cA * cA * cov[11] + cA * (cov[10] + cov[7]) * sA + cov[6] * sA * sA; + fC[7] = -(cA * cA * cov[10]) + cA * (cov[11] - cov[6]) * sA + cov[7] * sA * sA; + fC[8] = -(cA * cov[12]) - cov[8] * sA; + fC[9] = cA * cA * cov[14] + 2 * cA * cov[13] * sA + cov[9] * sA * sA; + fC[10] = -(cA * cA * cov[7]) + cA * (cov[11] - cov[6]) * sA + cov[10] * sA * sA; + fC[11] = cA * cA * cov[6] - cA * (cov[10] + cov[7]) * sA + cov[11] * sA * sA; + fC[12] = cA * cov[8] - cov[12] * sA; + fC[13] = -(cA * cA * cov[13]) + cA * (cov[14] - cov[9]) * sA + cov[13] * sA * sA; + fC[14] = cA * cA * cov[9] - 2 * cA * cov[13] * sA + cov[14] * sA * sA; + + fC[15] = -(cA * cov[16]) - cov[15] * sA; + fC[16] = cA * cov[15] - cov[16] * sA; + fC[17] = cov[17]; + fC[18] = -(cA * cov[19]) - cov[18] * sA; + fC[19] = cA * cov[18] - cov[19] * sA; + fC[20] = cov[20]; } diff --git a/KFParticle/KFPTrack.h b/KFParticle/KFPTrack.h index 6de0e21..f3b8c7c 100644 --- a/KFParticle/KFPTrack.h +++ b/KFParticle/KFPTrack.h @@ -36,58 +36,88 @@ #include #include "TObject.h" -class KFPTrack +class KFPTrack #ifdef __ROOT__ -: public TObject + : public TObject #endif { -public: - KFPTrack():fChi2(-1.f), fQ(0), fNDF(-1), fId(-1) { } - virtual ~KFPTrack() { } + public: + KFPTrack() : fChi2(-1.f), fQ(0), fNDF(-1), fId(-1) {} + virtual ~KFPTrack() {} - int GetID() const { return fId; } ///< Returns Id of the track. - - bool GetXYZPxPyPz(float *p) const + int GetID() const { return fId; } ///< Returns Id of the track. + + bool GetXYZPxPyPz(float* p) const { /** Fills an array p with the parameters of the track. ** \param[out] p - array where { X, Y, Z, Px, Py, Pz } are copied **/ - for(int i=0; i<6; i++) + for (int i = 0; i < 6; i++) p[i] = fP[i]; return 1; } - bool GetCovarianceXYZPxPyPz(float cv[21]) const + bool GetCovarianceXYZPxPyPz(float cv[21]) const { /** Copies the covariance matrix of the track to the array of floats. ** \param[out] cv[21] - the output array, where the covariance matrix is copied **/ - for (int i=0; i<21; i++) + for (int i = 0; i < 21; i++) cv[i] = fC[i]; return 1; } - bool GetCovarianceXYZPxPyPz(double cv[21]) const + bool GetCovarianceXYZPxPyPz(double cv[21]) const { /** Copies the covariance matrix of the track to the array of doubles. ** \param[out] cv[21] - the output array, where the covariance matrix is copied **/ - for (int i=0; i<21; i++) + for (int i = 0; i < 21; i++) cv[i] = fC[i]; return 1; } /** Copies position of the track to the output array of floats. \param[out] position - the output array with the position of the track **/ - void GetXYZ(float *position) const {position[0] = fP[0]; position[1] = fP[1]; position[2] = fP[2];} + void GetXYZ(float* position) const + { + position[0] = fP[0]; + position[1] = fP[1]; + position[2] = fP[2]; + } /** Copies 3 momentum components of the track to the output array of floats. \param[out] position - the output array with the momentum of the track **/ - void GetPxPyPz(float *position) const {position[0] = fP[3]; position[1] = fP[4]; position[2] = fP[5];} + void GetPxPyPz(float* position) const + { + position[0] = fP[3]; + position[1] = fP[4]; + position[2] = fP[5]; + } /** Copies position of the track to the output array of floats. \param[out] position - the output array with the position of the track **/ - void XvYvZv(float *position) const {position[0] = fP[0]; position[1] = fP[1]; position[2] = fP[2];} + void XvYvZv(float* position) const + { + position[0] = fP[0]; + position[1] = fP[1]; + position[2] = fP[2]; + } /** Copies 3 momentum components of the track to the output array of floats. \param[out] position - the output array with the momentum of the track **/ - void PxPyPz(float *position) const {position[0] = fP[3]; position[1] = fP[4]; position[2] = fP[5];} + void PxPyPz(float* position) const + { + position[0] = fP[3]; + position[1] = fP[4]; + position[2] = fP[5]; + } /** Copies position of the track to the output array of doubles. \param[out] position - the output array with the position of the track **/ - void XvYvZv(double *position) const {position[0] = fP[0]; position[1] = fP[1]; position[2] = fP[2];} + void XvYvZv(double* position) const + { + position[0] = fP[0]; + position[1] = fP[1]; + position[2] = fP[2]; + } /** Copies 3 momentum components of the track to the output array of doubles. \param[out] position - the output array with the momentum of the track **/ - void PxPyPz(double *position) const {position[0] = fP[3]; position[1] = fP[4]; position[2] = fP[5];} + void PxPyPz(double* position) const + { + position[0] = fP[3]; + position[1] = fP[4]; + position[2] = fP[5]; + } float GetX() const { return fP[0]; } ///< Returns X coordinate of the track. float GetY() const { return fP[1]; } ///< Returns Y coordinate of the track. @@ -96,46 +126,46 @@ class KFPTrack float GetPy() const { return fP[4]; } ///< Returns Py component of the momentum of the track. float GetPz() const { return fP[5]; } ///< Returns Pz component of the momentum of the track. - float GetPt() const { return sqrt(fP[3]*fP[3]+fP[4]*fP[4]); } ///< Returns Pt - transverse momentum of the track. - float GetP() const { return sqrt(fP[3]*fP[3]+fP[4]*fP[4]+fP[5]*fP[5]); } ///< Returns P - momentum of the track. + float GetPt() const { return sqrt(fP[3] * fP[3] + fP[4] * fP[4]); } ///< Returns Pt - transverse momentum of the track. + float GetP() const { return sqrt(fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]); } ///< Returns P - momentum of the track. - void GetCovarianceMatrix(float *covmatrix) + void GetCovarianceMatrix(float* covmatrix) { /** Copies the covariance matrix of the track to the array of floats. ** \param[out] covmatrix[21] - the output array, where the covariance matrix is copied **/ - for (int i=0; i<21; i++) + for (int i = 0; i < 21; i++) covmatrix[i] = fC[i]; } float GetParameter(int i) const { return fP[i]; } ///< Returns parameter "i" of the track. \param[in] i - index of the parameter to be returned float GetCovariance(int i) const { return fC[i]; } ///< Returns element of the covariance matrix "i" of the track. \param[in] i - index of the element to be returned - int Charge() const { return fQ; } ///< Returns charge of the track. - float GetChi2perNDF() const { return fChi2/fNDF; } ///< Returns Chi2/NDF of the track, NDF is a number of degrees of freedom. - float GetChi2() const { return fChi2; } ///< Returns Chi2 of the track. - int GetNDF() const { return fNDF; } ///< Returns number of degrees of freedom of the track. + int Charge() const { return fQ; } ///< Returns charge of the track. + float GetChi2perNDF() const { return fChi2 / fNDF; } ///< Returns Chi2/NDF of the track, NDF is a number of degrees of freedom. + float GetChi2() const { return fChi2; } ///< Returns Chi2 of the track. + int GetNDF() const { return fNDF; } ///< Returns number of degrees of freedom of the track. - const float * GetTrack() const { return fP; } ///< Returns a pointer to the array of track parameters. - const float * GetCovMatrix() const { return fC; } ///< Returns a pointer to the array of the covariance matrix elements stored in a lower triangular form. + const float* GetTrack() const { return fP; } ///< Returns a pointer to the array of track parameters. + const float* GetCovMatrix() const { return fC; } ///< Returns a pointer to the array of the covariance matrix elements stored in a lower triangular form. - void SetParameters(const float *position) + void SetParameters(const float* position) { /** Sets parameters { X, Y, Z, Px, Py, Pz } of the track from the input array of floats. ** \param[in] position - input array with the track parameters **/ - for(int i=0; i<6; i++) + for (int i = 0; i < 6; i++) fP[i] = position[i]; } - void SetParameters(double *position) - { + void SetParameters(double* position) + { /** Sets parameters { X, Y, Z, Px, Py, Pz } of the track from the input array of doubles. ** \param[in] position - input array with the track parameters **/ - for(int i=0; i<6; i++) + for (int i = 0; i < 6; i++) fP[i] = position[i]; } - void SetParameters(float x, float y, float z, float px, float py, float pz) - { + void SetParameters(float x, float y, float z, float px, float py, float pz) + { /** Sets parameters { X, Y, Z, Px, Py, Pz } of the track. ** \param[in] x - X coordinate to be set ** \param[in] y - Y coordinate to be set @@ -144,78 +174,88 @@ class KFPTrack ** \param[in] Py - Py momentum component to be set ** \param[in] Pz - Pz momentum component to be set **/ - fP[0] = x; fP[1] = y; fP[2] = z; - fP[3] = px; fP[4] = py; fP[5] = pz; + fP[0] = x; + fP[1] = y; + fP[2] = z; + fP[3] = px; + fP[4] = py; + fP[5] = pz; } - void SetXYZ(float x, float y, float z) - { + void SetXYZ(float x, float y, float z) + { /** Sets position { X, Y, Z } of the track. ** \param[in] x - X coordinate to be set ** \param[in] y - Y coordinate to be set ** \param[in] z - Z coordinate to be set **/ - fP[0] = x; fP[1] = y; fP[2] = z; + fP[0] = x; + fP[1] = y; + fP[2] = z; } - void SetPxPyPz(float px, float py, float pz) - { + void SetPxPyPz(float px, float py, float pz) + { /** Sets momentum { Px, Py, Pz } of the track. ** \param[in] Px - Px momentum component to be set ** \param[in] Py - Py momentum component to be set ** \param[in] Pz - Pz momentum component to be set **/ - fP[3] = px; fP[4] = py; fP[5] = pz; + fP[3] = px; + fP[4] = py; + fP[5] = pz; } - void SetID(int id) {fId = id;} ///< Sets Id of the track. + void SetID(int id) { fId = id; } ///< Sets Id of the track. - void SetX(float x) { fP[0] = x; } ///< Sets X coordinate of the track. - void SetY(float y) { fP[1] = y; } ///< Sets Y coordinate of the track. - void SetZ(float z) { fP[2] = z; } ///< Sets Z coordinate of the track. - void SetPx(float px) { fP[3] = px; } ///< Sets Px component of the track momentum. - void SetPy(float py) { fP[4] = py; } ///< Sets Py component of the track momentum. - void SetPz(float pz) { fP[5] = pz; } ///< Sets Pz component of the track momentum. - void SetCharge(int q) { fQ = q; } ///< Sets charge of the track. - void SetChi2(float chi) { fChi2 = chi; } ///< Sets a value of the track Chi2. - void SetNDF(int ndf) { fNDF = ndf; } ///< Sets a value of the number of degrees of freedom. + void SetX(float x) { fP[0] = x; } ///< Sets X coordinate of the track. + void SetY(float y) { fP[1] = y; } ///< Sets Y coordinate of the track. + void SetZ(float z) { fP[2] = z; } ///< Sets Z coordinate of the track. + void SetPx(float px) { fP[3] = px; } ///< Sets Px component of the track momentum. + void SetPy(float py) { fP[4] = py; } ///< Sets Py component of the track momentum. + void SetPz(float pz) { fP[5] = pz; } ///< Sets Pz component of the track momentum. + void SetCharge(int q) { fQ = q; } ///< Sets charge of the track. + void SetChi2(float chi) { fChi2 = chi; } ///< Sets a value of the track Chi2. + void SetNDF(int ndf) { fNDF = ndf; } ///< Sets a value of the number of degrees of freedom. - void SetCovarianceMatrix(const float *C) + void SetCovarianceMatrix(const float* C) { /** Sets the covariance matrix from the input array of floats. ** \param[in] C[21] - array with the input elements of the covariance matrix stored in the lower triangular form **/ - for (int i=0; i<21; i++) + for (int i = 0; i < 21; i++) fC[i] = C[i]; } - void SetCovarianceMatrix(const double *C) + void SetCovarianceMatrix(const double* C) { /** Sets the covariance matrix from the input array of doubles. ** \param[in] C[21] - array with the input elements of the covariance matrix stored in the lower triangular form **/ - for (int i=0; i<21; i++) + for (int i = 0; i < 21; i++) fC[i] = C[i]; } - + /** Sets an element of the covariance matrix with index "i". \param[in] c - value to be set \param[in] i - index of the element */ - void SetCovariance(const int i, const float c) { fC[i]=c; } - - void RotateXY( float alpha ); // rotate on alpha in XY plane. Should be useful for CS change + void SetCovariance(const int i, const float c) { fC[i] = c; } + + void RotateXY(float alpha); // rotate on alpha in XY plane. Should be useful for CS change - int Id() const { return fId; } ///< Returns Id of the track. - void SetId( int id ){ fId = id; } ///< Sets Id of the track. + int Id() const { return fId; } ///< Returns Id of the track. + void SetId(int id) { fId = id; } ///< Sets Id of the track. #ifdef NonhomogeneousField - const float* GetFieldCoeff() const { return fieldRegion; } ///< Returns array of the coefficients for field approximation. + const float* GetFieldCoeff() const + { + return fieldRegion; + } ///< Returns array of the coefficients for field approximation. /** Sets a field coefficient with index "i". \param[in] c - value to be set \param[in] i - index of the element */ - void SetFieldCoeff(float c, int i) { fieldRegion[i] = c; } + void SetFieldCoeff(float c, int i) { fieldRegion[i] = c; } #endif private: - float fP[6]; ///< Parameters of the track: { X, Y, Z, Px, Py, Pz }. float fC[21]; ///< Covariance matrix of the track parameters. Stored in the lower triangular form. float fChi2; ///< Chi-square of the track fit. char fQ; ///< Charge of the track. short fNDF; ///< Number of degree of freedom of the fit. int fId; ///< Id of the track. - + #ifdef NonhomogeneousField /** \brief Approximation of the magnetic field along the track trajectory. ** Each component (Bx, By, Bz) is approximated with the parabola depending on Z coordinate. Is defined in case of #ifdef NonhomogeneousField. @@ -223,7 +263,7 @@ class KFPTrack float fieldRegion[10]; #endif #ifdef __ROOT__ - ClassDef(KFPTrack,1) + ClassDef(KFPTrack, 1) #endif }; diff --git a/KFParticle/KFPTrackVector.cxx b/KFParticle/KFPTrackVector.cxx index f441ab6..183e40c 100644 --- a/KFParticle/KFPTrackVector.cxx +++ b/KFParticle/KFPTrackVector.cxx @@ -23,74 +23,73 @@ #include void KFPTrackVector::SetParameter(const float_v& value, int iP, int iTr) -{ +{ /** Copies the SIMD vector "value" to the parameter vector KFPTrackVector::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 **/ -// gather caused errors at XeonPhi, temporarly replaced with the simple copying -// if( (iTr+float_vLen) < Size()) -// reinterpret_cast(fP[iP][iTr]) = value; -// else -// { -// const uint_v index(uint_v::IndexesFromZero()); -// (reinterpret_cast(fP[iP][iTr])).gather(reinterpret_cast(&value), index, float_m(index<(Size() - iTr))); -// } - - if( (iTr+float_vLen) < Size()) + // gather caused errors at XeonPhi, temporarly replaced with the simple copying + // if( (iTr+float_vLen) < Size()) + // reinterpret_cast(fP[iP][iTr]) = value; + // else + // { + // const uint_v index(uint_v::IndexesFromZero()); + // (reinterpret_cast(fP[iP][iTr])).gather(reinterpret_cast(&value), index, float_m(index<(Size() - iTr))); + // } + + if ((iTr + float_vLen) < Size()) reinterpret_cast(fP[iP][iTr]) = value; else - for(int i=0; i= Size()) continue; - fP[iP][iTr+i] = value[i]; - } + for (int i = 0; i < float_v::Size; i++) { + if (iTr + i >= Size()) + continue; + fP[iP][iTr + i] = value[i]; + } } -void KFPTrackVector::SetCovariance(const float_v& value, int iC, int iTr) -{ +void KFPTrackVector::SetCovariance(const float_v& value, int iC, int iTr) +{ /** Copies the SIMD vector "value" to the element of the covariance matrix vector KFPTrackVector::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 **/ -// gather caused errors at XeonPhi, temporarly replaced with the simple copying -// if( (iTr+float_vLen) < Size()) -// reinterpret_cast(fC[iC][iTr]) = value; -// else -// { -// const uint_v index(uint_v::IndexesFromZero()); -// (reinterpret_cast(fC[iC][iTr])).gather(reinterpret_cast(&value), index, float_m(index<(Size() - iTr))); -// } - - if( (iTr+float_vLen) < Size()) + // gather caused errors at XeonPhi, temporarly replaced with the simple copying + // if( (iTr+float_vLen) < Size()) + // reinterpret_cast(fC[iC][iTr]) = value; + // else + // { + // const uint_v index(uint_v::IndexesFromZero()); + // (reinterpret_cast(fC[iC][iTr])).gather(reinterpret_cast(&value), index, float_m(index<(Size() - iTr))); + // } + + if ((iTr + float_vLen) < Size()) reinterpret_cast(fC[iC][iTr]) = value; else - for(int i=0; i= Size()) continue; - fC[iC][iTr+i] = value[i]; - } + for (int i = 0; i < float_v::Size; i++) { + if (iTr + i >= Size()) + continue; + fC[iC][iTr + i] = value[i]; + } } - void KFPTrackVector::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<6; i++) + for (int i = 0; i < 6; i++) fP[i].resize(n); - for(int i=0; i<21; i++) + for (int i = 0; i < 21; i++) fC[i].resize(n); #ifdef NonhomogeneousField - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) fField[i].resize(n); #endif -// fChi2.resize(n); -// fNDF.resize(n); + // fChi2.resize(n); + // fNDF.resize(n); fId.resize(n); fPDG.resize(n); fQ.resize(n); @@ -106,23 +105,22 @@ void KFPTrackVector::Set(KFPTrackVector& v, int vSize, int offset) ** \param[in] vSize - number of tracks to be copied from "v" ** \param[in] offset - offset position in the current object, starting from which input tracks will be stored **/ - for(int iV=0; iV(trackIndex[iElement]); float_v& vec = reinterpret_cast(fP[iP][iElement]); vec.gather(&(track.fP[iP][0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); float_v& vec = reinterpret_cast(fP[iP][iElement]); - vec.gather(&(track.fP[iP][0]), index, simd_cast(iElement+uint_v::IndexesFromZero()(iElement + uint_v::IndexesFromZero() < nIndexes)); } - for(int iC=0; iC<21; iC++) - { - int iElement=0; - for(iElement=0; iElement(trackIndex[iElement]); float_v& vec = reinterpret_cast(fC[iC][iElement]); vec.gather(&(track.fC[iC][0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); float_v& vec = reinterpret_cast(fC[iC][iElement]); - vec.gather(&(track.fC[iC][0]), index, simd_cast(iElement+uint_v::IndexesFromZero()(iElement + uint_v::IndexesFromZero() < nIndexes)); } #ifdef NonhomogeneousField - for(int iP=0; iP<10; iP++) - { + for (int iP = 0; iP < 10; iP++) { int iElement = 0; - for(iElement=0; iElement(trackIndex[iElement]); float_v& vec = reinterpret_cast(fField[iP][iElement]); vec.gather(&(track.fField[iP][0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); float_v& vec = reinterpret_cast(fField[iP][iElement]); - vec.gather(&(track.fField[iP][0]), index, simd_cast(iElement+uint_v::IndexesFromZero()(iElement + uint_v::IndexesFromZero() < nIndexes)); } #endif { - int iElement=0; - for(iElement=0; iElement(trackIndex[iElement]); int_v& vec = reinterpret_cast(fId[iElement]); vec.gather(&(track.fId[0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); int_v& vec = reinterpret_cast(fId[iElement]); - vec.gather(&(track.fId[0]), index, int_m(iElement+uint_v::IndexesFromZero()(trackIndex[iElement]); int_v& vec = reinterpret_cast(fPDG[iElement]); vec.gather(&(track.fPDG[0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); int_v& vec = reinterpret_cast(fPDG[iElement]); - vec.gather(&(track.fPDG[0]), index, int_m(iElement+uint_v::IndexesFromZero()(trackIndex[iElement]); int_v& vec = reinterpret_cast(fQ[iElement]); vec.gather(&(track.fQ[0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); int_v& vec = reinterpret_cast(fQ[iElement]); - vec.gather(&(track.fQ[0]), index, int_m(iElement+uint_v::IndexesFromZero()(trackIndex[iElement]); int_v& vec = reinterpret_cast(fPVIndex[iElement]); vec.gather(&(track.fPVIndex[0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); int_v& vec = reinterpret_cast(fPVIndex[iElement]); - vec.gather(&(track.fPVIndex[0]), index, int_m(iElement+uint_v::IndexesFromZero()(trackIndex[iElement]); int_v& vec = reinterpret_cast(fNPixelHits[iElement]); vec.gather(&(track.fNPixelHits[0]), index); } const uint_v& index = reinterpret_cast(trackIndex[iElement]); int_v& vec = reinterpret_cast(fNPixelHits[iElement]); - vec.gather(&(track.fNPixelHits[0]), index, int_m(iElement+uint_v::IndexesFromZero()(fP[0][firstElement]); const float_v yInit = reinterpret_cast(fP[1][firstElement]); float_v& x = reinterpret_cast(fP[0][firstElement]); float_v& y = reinterpret_cast(fP[1][firstElement]); - - x = -(xInit*sA + yInit*cA); - y = xInit*cA - yInit*sA; + + x = -(xInit * sA + yInit * cA); + y = xInit * cA - yInit * sA; const float_v pxInit = reinterpret_cast(fP[3][firstElement]); const float_v pyInit = reinterpret_cast(fP[4][firstElement]); float_v& px = reinterpret_cast(fP[3][firstElement]); float_v& py = reinterpret_cast(fP[4][firstElement]); - - px = -(pxInit*sA + pyInit*cA); - py = pxInit*cA - pyInit*sA; + + px = -(pxInit * sA + pyInit * cA); + py = pxInit * cA - pyInit * sA; float_v cov[21]; - for(int iC=0; iC<21; iC++) + for (int iC = 0; iC < 21; iC++) cov[iC] = reinterpret_cast(fC[iC][firstElement]); - reinterpret_cast(fC[0][firstElement]) = cA*cA* cov[2] + 2* cA* cov[1]* sA + cov[0]*sA* sA; - - reinterpret_cast(fC[1][firstElement]) = -(cA*cA * cov[1]) + cA* (-cov[0] + cov[2])* sA + cov[1]*sA* sA; - reinterpret_cast(fC[2][firstElement]) = cA*cA* cov[0] - 2* cA* cov[1]* sA + cov[2]*sA* sA; - - reinterpret_cast(fC[3][firstElement]) = -(cA* cov[4]) - cov[3]* sA; - reinterpret_cast(fC[4][firstElement]) = cA* cov[3] - cov[4]* sA; -// reinterpret_cast(fC[5][firstElement]) = cov[5]; - - reinterpret_cast(fC[6][firstElement]) = cA*cA* cov[11] + cA *(cov[10] + cov[7])* sA + cov[6]*sA* sA; - reinterpret_cast(fC[7][firstElement]) = -(cA*cA * cov[10]) + cA* (cov[11] - cov[6])* sA + cov[7] *sA*sA; - reinterpret_cast(fC[8][firstElement]) = -(cA *cov[12]) - cov[8] *sA; - reinterpret_cast(fC[9][firstElement]) = cA*cA* cov[14] + 2 *cA* cov[13]* sA + cov[9]* sA*sA; - - reinterpret_cast(fC[10][firstElement]) = -(cA*cA* cov[7]) + cA* (cov[11] - cov[6])* sA + cov[10]*sA* sA; - reinterpret_cast(fC[11][firstElement]) = cA*cA* cov[6] - cA* (cov[10] + cov[7]) *sA + cov[11]*sA* sA; - reinterpret_cast(fC[12][firstElement]) = cA* cov[8] - cov[12]* sA; - reinterpret_cast(fC[13][firstElement]) = -(cA*cA* cov[13]) + cA* (cov[14] - cov[9])* sA + cov[13]* sA*sA; - reinterpret_cast(fC[14][firstElement]) = cA*cA* cov[9] - 2* cA* cov[13]* sA + cov[14]* sA*sA; - - reinterpret_cast(fC[15][firstElement]) = -(cA* cov[16]) - cov[15]* sA; - reinterpret_cast(fC[16][firstElement]) = cA* cov[15] - cov[16]* sA; -// reinterpret_cast(fC[17][firstElement]) = cov[17]; - reinterpret_cast(fC[18][firstElement]) = -(cA* cov[19]) - cov[18]* sA; - reinterpret_cast(fC[19][firstElement]) = cA* cov[18] - cov[19]* sA; -// reinterpret_cast(fC[20][firstElement]) = cov[20]; -} // RotateXY + reinterpret_cast(fC[0][firstElement]) = cA * cA * cov[2] + 2 * cA * cov[1] * sA + cov[0] * sA * sA; + + reinterpret_cast(fC[1][firstElement]) = -(cA * cA * cov[1]) + cA * (-cov[0] + cov[2]) * sA + cov[1] * sA * sA; + reinterpret_cast(fC[2][firstElement]) = cA * cA * cov[0] - 2 * cA * cov[1] * sA + cov[2] * sA * sA; + + reinterpret_cast(fC[3][firstElement]) = -(cA * cov[4]) - cov[3] * sA; + reinterpret_cast(fC[4][firstElement]) = cA * cov[3] - cov[4] * sA; + // reinterpret_cast(fC[5][firstElement]) = cov[5]; + + reinterpret_cast(fC[6][firstElement]) = cA * cA * cov[11] + cA * (cov[10] + cov[7]) * sA + cov[6] * sA * sA; + reinterpret_cast(fC[7][firstElement]) = -(cA * cA * cov[10]) + cA * (cov[11] - cov[6]) * sA + cov[7] * sA * sA; + reinterpret_cast(fC[8][firstElement]) = -(cA * cov[12]) - cov[8] * sA; + reinterpret_cast(fC[9][firstElement]) = cA * cA * cov[14] + 2 * cA * cov[13] * sA + cov[9] * sA * sA; + reinterpret_cast(fC[10][firstElement]) = -(cA * cA * cov[7]) + cA * (cov[11] - cov[6]) * sA + cov[10] * sA * sA; + reinterpret_cast(fC[11][firstElement]) = cA * cA * cov[6] - cA * (cov[10] + cov[7]) * sA + cov[11] * sA * sA; + reinterpret_cast(fC[12][firstElement]) = cA * cov[8] - cov[12] * sA; + reinterpret_cast(fC[13][firstElement]) = -(cA * cA * cov[13]) + cA * (cov[14] - cov[9]) * sA + cov[13] * sA * sA; + reinterpret_cast(fC[14][firstElement]) = cA * cA * cov[9] - 2 * cA * cov[13] * sA + cov[14] * sA * sA; + + reinterpret_cast(fC[15][firstElement]) = -(cA * cov[16]) - cov[15] * sA; + reinterpret_cast(fC[16][firstElement]) = cA * cov[15] - cov[16] * sA; + // reinterpret_cast(fC[17][firstElement]) = cov[17]; + reinterpret_cast(fC[18][firstElement]) = -(cA * cov[19]) - cov[18] * sA; + reinterpret_cast(fC[19][firstElement]) = cA * cov[18] - cov[19] * sA; + // reinterpret_cast(fC[20][firstElement]) = cov[20]; +} // RotateXY void KFPTrackVector::PrintTrack(int n) { /** Prints parameters of the track with index "n". ** \param[in] n - index of track to be printed **/ - for(int i=0; i<6; i++) + for (int i = 0; i < 6; i++) std::cout << fP[i][n] << " "; std::cout << std::endl; - - for(int i=0; i<21; i++) + + for (int i = 0; i < 21; i++) std::cout << fC[i][n] << " "; std::cout << std::endl; - - std::cout << fId[n] << " " << fPDG[n] << " " << fQ[n] << " " << fPVIndex[n] << " " << fNPixelHits[n] << std::endl; + + std::cout << fId[n] << " " << fPDG[n] << " " << fQ[n] << " " << fPVIndex[n] << " " << fNPixelHits[n] << std::endl; } void KFPTrackVector::Print() { /** 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<6; iP++) - { + for (int iP = 0; iP < 6; iP++) { std::cout << " iP " << iP << ": "; - for(int iTr=0; iTr. */ - #include "KFParticle.h" #include "KFParticleDatabase.h" @@ -31,24 +30,23 @@ ClassImp(KFParticle); #endif - #ifdef HomogeneousField -float KFParticle::fgBz = -5.; //* Bz compoment of the magnetic field +float KFParticle::fgBz = -5.; //* Bz compoment of the magnetic field #endif -KFParticle::KFParticle( const KFParticle &d1, const KFParticle &d2 ): KFParticleBase() +KFParticle::KFParticle(const KFParticle& d1, const KFParticle& d2) : KFParticleBase() { /** Constructs a particle from two input daughter particles ** \param[in] d1 - the first daughter particle ** \param[in] d2 - the second daughter particle **/ KFParticle mother; - mother+= d1; - mother+= d2; + mother += d1; + mother += d2; *this = mother; } -void KFParticle::Create( const float Param[], const float Cov[], Int_t Charge, float mass ) +void KFParticle::Create(const float Param[], const float Cov[], Int_t Charge, float mass) { /** Constructor from a "cartesian" track, mass hypothesis should be provided ** \param[in] Param[6] = { X, Y, Z, Px, Py, Pz } - position and momentum @@ -65,12 +63,13 @@ void KFParticle::Create( const float Param[], const float Cov[], Int_t Charge, f ** \param[in] mass - the mass hypothesis **/ float C[21]; - for( int i=0; i<21; i++ ) C[i] = Cov[i]; - - KFParticleBase::Initialize( Param, C, Charge, mass ); + for (int i = 0; i < 21; i++) + C[i] = Cov[i]; + + KFParticleBase::Initialize(Param, C, Charge, mass); } -void KFParticle::Create( const Double_t Param[], const Double_t Cov[], Int_t Charge, float mass ) +void KFParticle::Create(const Double_t Param[], const Double_t Cov[], Int_t Charge, float mass) { /** Constructor from a "cartesian" track, mass hypothesis should be provided ** \param[in] Param[6] = { X, Y, Z, Px, Py, Pz } - position and momentum @@ -87,14 +86,16 @@ void KFParticle::Create( const Double_t Param[], const Double_t Cov[], Int_t Cha ** \param[in] mass - the mass hypothesis **/ float P[6]; - for(int i=0; i<6; i++ ) P[i] = Param[i]; + for (int i = 0; i < 6; i++) + P[i] = Param[i]; float C[21]; - for( int i=0; i<21; i++ ) C[i] = Cov[i]; - - KFParticleBase::Initialize( P, C, Charge, mass ); + for (int i = 0; i < 21; i++) + C[i] = Cov[i]; + + KFParticleBase::Initialize(P, C, Charge, mass); } -KFParticle::KFParticle( const KFPTrack &track, const int PID ): KFParticleBase() +KFParticle::KFParticle(const KFPTrack& track, const int PID) : KFParticleBase() { /** Constructor from a track in the KF Particle format, PID hypothesis should be provided ** \param[in] track - KFPTrack containing 6 parameters: { X, Y, Z, Px, Py, Pz } and their errors @@ -102,38 +103,38 @@ KFParticle::KFParticle( const KFPTrack &track, const int PID ): KFParticleBase() **/ track.XvYvZv(fP); - track.PxPyPz(fP+3); + track.PxPyPz(fP + 3); fQ = track.Charge(); - track.GetCovarianceXYZPxPyPz( fC ); + track.GetCovarianceXYZPxPyPz(fC); float mass = KFParticleDatabase::Instance()->GetMass(PID); - Create(fP,fC,fQ,mass); + Create(fP, fC, fQ, mass); fChi2 = track.GetChi2(); fNDF = track.GetNDF(); SetPDG(PID); #ifdef NonhomogeneousField - for(int iF=0; iF<10; iF++) - SetFieldCoeff( track.GetFieldCoeff()[iF], iF); + for (int iF = 0; iF < 10; iF++) + SetFieldCoeff(track.GetFieldCoeff()[iF], iF); #endif } -KFParticle::KFParticle( const KFPVertex &vertex ): KFParticleBase() +KFParticle::KFParticle(const KFPVertex& vertex) : KFParticleBase() { /** Constructor from a vertex in the KF Particle format ** \param[in] vertex - KFPVertex containing 3 parameters: { X, Y, Z } and their errors **/ - vertex.GetXYZ( fP ); - vertex.GetCovarianceMatrix( fC ); + vertex.GetXYZ(fP); + vertex.GetCovarianceMatrix(fC); fChi2 = vertex.GetChi2(); - fNDF = 2*vertex.GetNContributors() - 3; + fNDF = 2 * vertex.GetNContributors() - 3; fQ = 0; fAtProductionVertex = 0; fSFromDecay = 0; } -Bool_t KFParticle::GetDistanceFromVertexXY( const float vtx[], const float Cv[], float &val, float &err ) const +Bool_t KFParticle::GetDistanceFromVertexXY(const float vtx[], const float Cv[], float& val, float& err) const { /** Calculates the DCA distance from a vertex together with the error in the XY plane. ** Returns "true" if calculation is failed, "false" if both value and the error are well defined. @@ -144,42 +145,42 @@ Bool_t KFParticle::GetDistanceFromVertexXY( const float vtx[], const float Cv[], **/ Bool_t ret = 0; - + float mP[8]; float mC[36]; float dsdr[6] = {0.f}; const float dS = GetDStoPoint(vtx, dsdr); - Transport( dS, dsdr, mP, mC ); + Transport(dS, dsdr, mP, mC); float dx = mP[0] - vtx[0]; float dy = mP[1] - vtx[1]; float px = mP[3]; float py = mP[4]; - float pt = sqrt(px*px + py*py); - float ex=0, ey=0; - if( pt<1.e-4 ){ + float pt = sqrt(px * px + py * py); + float ex = 0, ey = 0; + if (pt < 1.e-4) { ret = 1; pt = 1.; val = 1.e4; - } else{ - ex = px/pt; - ey = py/pt; - val = dy*ex - dx*ey; + } else { + ex = px / pt; + ey = py / pt; + val = dy * ex - dx * ey; } float h0 = -ey; float h1 = ex; - float h3 = (dy*ey + dx*ex)*ey/pt; - float h4 = -(dy*ey + dx*ex)*ex/pt; - - err = - h0*(h0*GetCovariance(0,0) + h1*GetCovariance(0,1) + h3*GetCovariance(0,3) + h4*GetCovariance(0,4) ) + - h1*(h0*GetCovariance(1,0) + h1*GetCovariance(1,1) + h3*GetCovariance(1,3) + h4*GetCovariance(1,4) ) + - h3*(h0*GetCovariance(3,0) + h1*GetCovariance(3,1) + h3*GetCovariance(3,3) + h4*GetCovariance(3,4) ) + - h4*(h0*GetCovariance(4,0) + h1*GetCovariance(4,1) + h3*GetCovariance(4,3) + h4*GetCovariance(4,4) ); - - if( Cv ){ - err+= h0*(h0*Cv[0] + h1*Cv[1] ) + h1*(h0*Cv[1] + h1*Cv[2] ); + float h3 = (dy * ey + dx * ex) * ey / pt; + float h4 = -(dy * ey + dx * ex) * ex / pt; + + err = + h0 * (h0 * GetCovariance(0, 0) + h1 * GetCovariance(0, 1) + h3 * GetCovariance(0, 3) + h4 * GetCovariance(0, 4)) + + h1 * (h0 * GetCovariance(1, 0) + h1 * GetCovariance(1, 1) + h3 * GetCovariance(1, 3) + h4 * GetCovariance(1, 4)) + + h3 * (h0 * GetCovariance(3, 0) + h1 * GetCovariance(3, 1) + h3 * GetCovariance(3, 3) + h4 * GetCovariance(3, 4)) + + h4 * (h0 * GetCovariance(4, 0) + h1 * GetCovariance(4, 1) + h3 * GetCovariance(4, 3) + h4 * GetCovariance(4, 4)); + + if (Cv) { + err += h0 * (h0 * Cv[0] + h1 * Cv[1]) + h1 * (h0 * Cv[1] + h1 * Cv[2]); } err = sqrt(fabs(err)); @@ -187,7 +188,7 @@ Bool_t KFParticle::GetDistanceFromVertexXY( const float vtx[], const float Cv[], return ret; } -Bool_t KFParticle::GetDistanceFromVertexXY( const float vtx[], float &val, float &err ) const +Bool_t KFParticle::GetDistanceFromVertexXY(const float vtx[], float& val, float& err) const { /** Calculates the DCA distance from a vertex together with the error in the XY plane. ** Returns "true" if calculation is failed, "false" if both value and the error are well defined. @@ -195,11 +196,10 @@ Bool_t KFParticle::GetDistanceFromVertexXY( const float vtx[], float &val, float ** \param[out] val - the distance in the XY plane to the vertex ** \param[out] err - the error of the calculated distance, takes into account errors of the particle only **/ - return GetDistanceFromVertexXY( vtx, 0, val, err ); + return GetDistanceFromVertexXY(vtx, 0, val, err); } - -Bool_t KFParticle::GetDistanceFromVertexXY( const KFParticle &Vtx, float &val, float &err ) const +Bool_t KFParticle::GetDistanceFromVertexXY(const KFParticle& Vtx, float& val, float& err) const { /** Calculates the DCA distance from a vertex in the KFParticle format together with the error in the XY plane. ** Returns "true" if calculation is failed, "false" if both value and the error are well defined. @@ -208,11 +208,11 @@ Bool_t KFParticle::GetDistanceFromVertexXY( const KFParticle &Vtx, float &val, f ** \param[out] err - the error of the calculated distance, takes into account errors of the particle and vertex **/ - return GetDistanceFromVertexXY( Vtx.fP, Vtx.fC, val, err ); + return GetDistanceFromVertexXY(Vtx.fP, Vtx.fC, val, err); } #ifdef HomogeneousField -Bool_t KFParticle::GetDistanceFromVertexXY( const KFPVertex &Vtx, float &val, float &err ) const +Bool_t KFParticle::GetDistanceFromVertexXY(const KFPVertex& Vtx, float& val, float& err) const { /** Calculates the DCA distance from a vertex in the KFPVertex format together with the error in the XY plane. ** Returns "true" if calculation is failed, "false" if both value and the error are well defined. @@ -221,87 +221,86 @@ Bool_t KFParticle::GetDistanceFromVertexXY( const KFPVertex &Vtx, float &val, fl ** \param[out] err - the error of the calculated distance, takes into account errors of the particle and vertex **/ - return GetDistanceFromVertexXY( KFParticle(Vtx), val, err ); + return GetDistanceFromVertexXY(KFParticle(Vtx), val, err); } #endif -float KFParticle::GetDistanceFromVertexXY( const float vtx[] ) const +float KFParticle::GetDistanceFromVertexXY(const float vtx[]) const { /** Returns the DCA distance from a vertex in the XY plane. ** \param[in] vtx[2] - { X, Y } coordinates of the vertex **/ float val, err; - GetDistanceFromVertexXY( vtx, 0, val, err ); + GetDistanceFromVertexXY(vtx, 0, val, err); return val; } -float KFParticle::GetDistanceFromVertexXY( const KFParticle &Vtx ) const +float KFParticle::GetDistanceFromVertexXY(const KFParticle& Vtx) const { /** Returns the DCA distance from a vertex in the KFParticle format in the XY plane. ** \param[in] Vtx - the vertex in the KFParticle format **/ - return GetDistanceFromVertexXY( Vtx.fP ); + return GetDistanceFromVertexXY(Vtx.fP); } #ifdef HomogeneousField -float KFParticle::GetDistanceFromVertexXY( const KFPVertex &Vtx ) const +float KFParticle::GetDistanceFromVertexXY(const KFPVertex& Vtx) const { /** Returns the DCA distance from a vertex in the KFParticle format in the XY plane. ** \param[in] Vtx - the vertex in the KFPVertex format **/ - return GetDistanceFromVertexXY( KFParticle(Vtx).fP ); + return GetDistanceFromVertexXY(KFParticle(Vtx).fP); } #endif -float KFParticle::GetDistanceFromParticleXY( const KFParticle &p ) const +float KFParticle::GetDistanceFromParticleXY(const KFParticle& p) const { /** Returns the DCA distance between the current and the second particles in the XY plane. ** \param[in] p - the second particle **/ - + float dsdr[4][6]; float dS[2]; - GetDStoParticle( p, dS, dsdr ); + GetDStoParticle(p, dS, dsdr); float mP[8], mC[36], mP1[8], mC1[36]; - Transport( dS[0], dsdr[0], mP, mC ); - p.Transport( dS[1], dsdr[3], mP1, mC1 ); - float dx = mP[0]-mP1[0]; - float dy = mP[1]-mP1[1]; - return sqrt(dx*dx+dy*dy); + Transport(dS[0], dsdr[0], mP, mC); + p.Transport(dS[1], dsdr[3], mP1, mC1); + float dx = mP[0] - mP1[0]; + float dy = mP[1] - mP1[1]; + return sqrt(dx * dx + dy * dy); } -float KFParticle::GetDeviationFromParticleXY( const KFParticle &p ) const +float KFParticle::GetDeviationFromParticleXY(const KFParticle& p) const { /** Returns sqrt(Chi2/ndf) deviation from other particle in the XY plane. ** \param[in] p - the second particle **/ - + float dsdr[4][6]; float dS[2]; - GetDStoParticle( p, dS, dsdr ); + GetDStoParticle(p, dS, dsdr); float mP[8], mC[36], mP1[8], mC1[36]; - Transport( dS[0], dsdr[0], mP, mC ); - p.Transport( dS[1], dsdr[3], mP1, mC1 ); + Transport(dS[0], dsdr[0], mP, mC); + p.Transport(dS[1], dsdr[3], mP1, mC1); - float d[2]={ mP[0]-mP1[0], mP[1]-mP1[1] }; + float d[2] = {mP[0] - mP1[0], mP[1] - mP1[1]}; - float sigmaS = .1+10.*sqrt( (d[0]*d[0]+d[1]*d[1] )/ - (mP1[3]*mP1[3]+mP1[4]*mP1[4] ) ); + float sigmaS = .1 + 10. * sqrt((d[0] * d[0] + d[1] * d[1]) / + (mP1[3] * mP1[3] + mP1[4] * mP1[4])); - float h[2] = { mP1[3]*sigmaS, mP1[4]*sigmaS }; - - mC1[0] +=h[0]*h[0]; - mC1[1] +=h[1]*h[0]; - mC1[2] +=h[1]*h[1]; + float h[2] = {mP1[3] * sigmaS, mP1[4] * sigmaS}; - return GetDeviationFromVertexXY( mP1, mC1 )*sqrt(2./1.); -} + mC1[0] += h[0] * h[0]; + mC1[1] += h[1] * h[0]; + mC1[2] += h[1] * h[1]; + return GetDeviationFromVertexXY(mP1, mC1) * sqrt(2. / 1.); +} -float KFParticle::GetDeviationFromVertexXY( const float vtx[], const float Cv[] ) const +float KFParticle::GetDeviationFromVertexXY(const float vtx[], const float Cv[]) const { /** Returns sqrt(Chi2/ndf) deviation from the vertex in the XY plane. ** \param[in] vtx[2] - { X, Y } coordinates of the vertex @@ -309,30 +308,31 @@ float KFParticle::GetDeviationFromVertexXY( const float vtx[], const float Cv[] **/ float val, err; - Bool_t problem = GetDistanceFromVertexXY( vtx, Cv, val, err ); - if( problem || err<1.e-20 ) return 1.e4; - else return val/err; + Bool_t problem = GetDistanceFromVertexXY(vtx, Cv, val, err); + if (problem || err < 1.e-20) + return 1.e4; + else + return val / err; } - -float KFParticle::GetDeviationFromVertexXY( const KFParticle &Vtx ) const +float KFParticle::GetDeviationFromVertexXY(const KFParticle& Vtx) const { /** Returns sqrt(Chi2/ndf) deviation from the vertex in the KFParticle format in the XY plane. ** \param[in] Vtx - the vertex in the KFParticle format **/ - return GetDeviationFromVertexXY( Vtx.fP, Vtx.fC ); + return GetDeviationFromVertexXY(Vtx.fP, Vtx.fC); } #ifdef HomogeneousField -float KFParticle::GetDeviationFromVertexXY( const KFPVertex &Vtx ) const +float KFParticle::GetDeviationFromVertexXY(const KFPVertex& Vtx) const { /** Returns sqrt(Chi2/ndf) deviation from the vertex in the KFPVertex format in the XY plane. ** \param[in] Vtx - the vertex in the KFPVertex format **/ KFParticle v(Vtx); - return GetDeviationFromVertexXY( v.fP, v.fC ); + return GetDeviationFromVertexXY(v.fP, v.fC); } #endif @@ -344,73 +344,79 @@ void KFParticle::GetParametersAtPoint(const float* point, const float* pointCov, ** \param[out] m[8] - the parameters of the particle at the DCA point ** \param[out] mV[36] - the covariance matrix of the particle at the DCA point, accounts the covariance matrix of the point as well **/ - + float dsdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; float dS = GetDStoPoint(point, dsdr); float dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0, 0, 0}; - + float F[36], F1[36]; - for(int i2=0; i2<36; i2++){ + for (int i2 = 0; i2 < 36; i2++) { mV[i2] = 0.f; - F[i2] = 0.f; + F[i2] = 0.f; F1[i2] = 0.f; } Transport(dS, dsdr, m, mV, dsdp, F, F1); - + float V1Tmp[36]; - for(int i=0; i<36; i++) + for (int i = 0; i < 36; i++) V1Tmp[i] = 0.f; KFParticle::MultQSQt(F1, pointCov, V1Tmp, 6); - - for(int iC=0; iC<21; iC++) + + for (int iC = 0; iC < 21; iC++) mV[iC] += V1Tmp[iC]; } -float KFParticle::GetAngle ( const KFParticle &p ) const +float KFParticle::GetAngle(const KFParticle& p) const { /** Returns the opening angle between the current and the second particle in 3D. ** \param[in] p - the second particle **/ - + float dsdr[4][6]; float dS[2]; - GetDStoParticle( p, dS, dsdr ); + GetDStoParticle(p, dS, dsdr); float mP[8], mC[36], mP1[8], mC1[36]; - Transport( dS[0], dsdr[0], mP, mC ); - p.Transport( dS[1], dsdr[3], mP1, mC1 ); - float n = sqrt( mP[3]*mP[3] + mP[4]*mP[4] + mP[5]*mP[5] ); - float n1= sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] + mP1[5]*mP1[5] ); - n*=n1; + Transport(dS[0], dsdr[0], mP, mC); + p.Transport(dS[1], dsdr[3], mP1, mC1); + float n = sqrt(mP[3] * mP[3] + mP[4] * mP[4] + mP[5] * mP[5]); + float n1 = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4] + mP1[5] * mP1[5]); + n *= n1; float a = 0; - if( n>1.e-8 ) a = ( mP[3]*mP1[3] + mP[4]*mP1[4] + mP[5]*mP1[5] )/n; - if (fabs(a)<1.) a = acos(a); - else a = (a>=0) ?0 :3.14; + if (n > 1.e-8) + a = (mP[3] * mP1[3] + mP[4] * mP1[4] + mP[5] * mP1[5]) / n; + if (fabs(a) < 1.) + a = acos(a); + else + a = (a >= 0) ? 0 : 3.14; return a; } -float KFParticle::GetAngleXY( const KFParticle &p ) const +float KFParticle::GetAngleXY(const KFParticle& p) const { /** Returns the opening angle between the current and the second particle in the XY plane. ** \param[in] p - the second particle **/ - + float dsdr[4][6]; float dS[2]; - GetDStoParticle( p, dS, dsdr ); + GetDStoParticle(p, dS, dsdr); float mP[8], mC[36], mP1[8], mC1[36]; - Transport( dS[0], dsdr[0], mP, mC ); - p.Transport( dS[1], dsdr[3], mP1, mC1 ); - float n = sqrt( mP[3]*mP[3] + mP[4]*mP[4] ); - float n1= sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] ); - n*=n1; + Transport(dS[0], dsdr[0], mP, mC); + p.Transport(dS[1], dsdr[3], mP1, mC1); + float n = sqrt(mP[3] * mP[3] + mP[4] * mP[4]); + float n1 = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4]); + n *= n1; float a = 0; - if( n>1.e-8 ) a = ( mP[3]*mP1[3] + mP[4]*mP1[4] )/n; - if (fabs(a)<1.) a = acos(a); - else a = (a>=0) ?0 :3.14; + if (n > 1.e-8) + a = (mP[3] * mP1[3] + mP[4] * mP1[4]) / n; + if (fabs(a) < 1.) + a = acos(a); + else + a = (a >= 0) ? 0 : 3.14; return a; } -float KFParticle::GetAngleRZ( const KFParticle &p ) const +float KFParticle::GetAngleRZ(const KFParticle& p) const { /** Returns the opening angle between the current and the second particle in the RZ plane, R = sqrt(X*X+Y*Y). ** \param[in] p - the second particle @@ -418,80 +424,83 @@ float KFParticle::GetAngleRZ( const KFParticle &p ) const float dsdr[4][6]; float dS[2]; - GetDStoParticle( p, dS, dsdr ); + GetDStoParticle(p, dS, dsdr); float mP[8], mC[36], mP1[8], mC1[36]; - Transport( dS[0], dsdr[0], mP, mC ); - p.Transport( dS[1], dsdr[3], mP1, mC1 ); - float nr = sqrt( mP[3]*mP[3] + mP[4]*mP[4] ); - float n1r= sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] ); - float n = sqrt( nr*nr + mP[5]*mP[5] ); - float n1= sqrt( n1r*n1r + mP1[5]*mP1[5] ); - n*=n1; + Transport(dS[0], dsdr[0], mP, mC); + p.Transport(dS[1], dsdr[3], mP1, mC1); + float nr = sqrt(mP[3] * mP[3] + mP[4] * mP[4]); + float n1r = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4]); + float n = sqrt(nr * nr + mP[5] * mP[5]); + float n1 = sqrt(n1r * n1r + mP1[5] * mP1[5]); + n *= n1; float a = 0; - if( n>1.e-8 ) a = ( nr*n1r +mP[5]*mP1[5])/n; - if (fabs(a)<1.) a = acos(a); - else a = (a>=0) ?0 :3.14; + if (n > 1.e-8) + a = (nr * n1r + mP[5] * mP1[5]) / n; + if (fabs(a) < 1.) + a = acos(a); + else + a = (a >= 0) ? 0 : 3.14; return a; } -float KFParticle::GetPseudoProperDecayTime( const KFParticle &pV, const float& mass, float* timeErr2 ) const -{ +float KFParticle::GetPseudoProperDecayTime(const KFParticle& pV, const float& mass, float* timeErr2) const +{ /** Returns the Pseudo Proper Time of the decay = (r*pt) / |pt| * M/|pt| ** \param[in] pV - the creation point of the particle ** \param[in] mass - the mass of the particle ** \param[out] timeErr2 - error of the returned value, if null pointer is provided - is not calculated **/ - - const float ipt2 = 1/( Px()*Px() + Py()*Py() ); - const float mipt2 = mass*ipt2; + + const float ipt2 = 1 / (Px() * Px() + Py() * Py()); + const float mipt2 = mass * ipt2; const float dx = X() - pV.X(); const float dy = Y() - pV.Y(); - if ( timeErr2 ) { - // -- calculate error = sigma(f(r)) = f'Cf' - // r = {x,y,px,py,x_pV,y_pV} - // df/dr = { px*m/pt^2, - // py*m/pt^2, - // ( x - x_pV )*m*(1/pt^2 - 2(px/pt^2)^2), - // ( y - y_pV )*m*(1/pt^2 - 2(py/pt^2)^2), - // -px*m/pt^2, - // -py*m/pt^2 } - const float f0 = Px()*mipt2; - const float f1 = Py()*mipt2; - const float mipt2derivative = mipt2*(1-2*Px()*Px()*ipt2); - const float f2 = dx*mipt2derivative; - const float f3 = -dy*mipt2derivative; + if (timeErr2) { + // -- calculate error = sigma(f(r)) = f'Cf' + // r = {x,y,px,py,x_pV,y_pV} + // df/dr = { px*m/pt^2, + // py*m/pt^2, + // ( x - x_pV )*m*(1/pt^2 - 2(px/pt^2)^2), + // ( y - y_pV )*m*(1/pt^2 - 2(py/pt^2)^2), + // -px*m/pt^2, + // -py*m/pt^2 } + const float f0 = Px() * mipt2; + const float f1 = Py() * mipt2; + const float mipt2derivative = mipt2 * (1 - 2 * Px() * Px() * ipt2); + const float f2 = dx * mipt2derivative; + const float f3 = -dy * mipt2derivative; const float f4 = -f0; const float f5 = -f1; - const float& mC00 = GetCovariance(0,0); - const float& mC10 = GetCovariance(0,1); - const float& mC11 = GetCovariance(1,1); - const float& mC20 = GetCovariance(3,0); - const float& mC21 = GetCovariance(3,1); - const float& mC22 = GetCovariance(3,3); - const float& mC30 = GetCovariance(4,0); - const float& mC31 = GetCovariance(4,1); - const float& mC32 = GetCovariance(4,3); - const float& mC33 = GetCovariance(4,4); - const float& mC44 = pV.GetCovariance(0,0); - const float& mC54 = pV.GetCovariance(1,0); - const float& mC55 = pV.GetCovariance(1,1); + const float& mC00 = GetCovariance(0, 0); + const float& mC10 = GetCovariance(0, 1); + const float& mC11 = GetCovariance(1, 1); + const float& mC20 = GetCovariance(3, 0); + const float& mC21 = GetCovariance(3, 1); + const float& mC22 = GetCovariance(3, 3); + const float& mC30 = GetCovariance(4, 0); + const float& mC31 = GetCovariance(4, 1); + const float& mC32 = GetCovariance(4, 3); + const float& mC33 = GetCovariance(4, 4); + const float& mC44 = pV.GetCovariance(0, 0); + const float& mC54 = pV.GetCovariance(1, 0); + const float& mC55 = pV.GetCovariance(1, 1); *timeErr2 = - f5*mC55*f5 + - f5*mC54*f4 + - f4*mC44*f4 + - f3*mC33*f3 + - f3*mC32*f2 + - f3*mC31*f1 + - f3*mC30*f0 + - f2*mC22*f2 + - f2*mC21*f1 + - f2*mC20*f0 + - f1*mC11*f1 + - f1*mC10*f0 + - f0*mC00*f0; + f5 * mC55 * f5 + + f5 * mC54 * f4 + + f4 * mC44 * f4 + + f3 * mC33 * f3 + + f3 * mC32 * f2 + + f3 * mC31 * f1 + + f3 * mC30 * f0 + + f2 * mC22 * f2 + + f2 * mC21 * f1 + + f2 * mC20 * f0 + + f1 * mC11 * f1 + + f1 * mC10 * f0 + + f0 * mC00 * f0; } - return ( dx*Px() + dy*Py() )*mipt2; + return (dx * Px() + dy * Py()) * mipt2; } diff --git a/KFParticle/KFParticle.h b/KFParticle/KFParticle.h index 06f01c4..74f8b01 100644 --- a/KFParticle/KFParticle.h +++ b/KFParticle/KFParticle.h @@ -49,53 +49,51 @@ class KFPVertex; ** to other particles and vertices, get deviations from them in terms of errors, etc. **/ -class KFParticle :public KFParticleBase +class KFParticle : public KFParticleBase { - - public: + public: //* //* INITIALIZATION //* //* Set magnetic field for all particles #ifdef HomogeneousField - static void SetField( float Bz ); + static void SetField(float Bz); #endif //* Constructor (empty) - KFParticle():KFParticleBase(){ ; } + KFParticle() : KFParticleBase() { ; } //* Destructor (empty) - virtual ~KFParticle(){ ; } + virtual ~KFParticle() { ; } //* Construction of mother particle by its 2-3-4 daughters - KFParticle( const KFParticle &d1, const KFParticle &d2 ); + KFParticle(const KFParticle& d1, const KFParticle& d2); - KFParticle( const KFParticle &d1, const KFParticle &d2, - const KFParticle &d3 ); + KFParticle(const KFParticle& d1, const KFParticle& d2, + const KFParticle& d3); - KFParticle( const KFParticle &d1, const KFParticle &d2, - const KFParticle &d3, const KFParticle &d4 ); - - //* Initialisation from "cartesian" coordinates ( X Y Z Px Py Pz ) - //* Parameters, covariance matrix, charge and PID hypothesis should be provided + KFParticle(const KFParticle& d1, const KFParticle& d2, + const KFParticle& d3, const KFParticle& d4); - void Create( const float Param[], const float Cov[], Int_t Charge, float mass /*Int_t PID*/ ); - void Create( const Double_t Param[], const Double_t Cov[], Int_t Charge, float mass /*Int_t PID*/ ); + //* Initialisation from "cartesian" coordinates ( X Y Z Px Py Pz ) + //* Parameters, covariance matrix, charge and PID hypothesis should be provided - //* Initialisation from ALICE track, PID hypothesis shoould be provided + void Create(const float Param[], const float Cov[], Int_t Charge, float mass /*Int_t PID*/); + void Create(const Double_t Param[], const Double_t Cov[], Int_t Charge, float mass /*Int_t PID*/); - KFParticle( const KFPTrack &track, const int PID ); + //* Initialisation from ALICE track, PID hypothesis shoould be provided + KFParticle(const KFPTrack& track, const int PID); - //* Initialisation from VVertex + //* Initialisation from VVertex - KFParticle( const KFPVertex &vertex ); + KFParticle(const KFPVertex& vertex); - //* Initialise covariance matrix and set current parameters to 0.0 + //* Initialise covariance matrix and set current parameters to 0.0 void Initialize(); @@ -103,220 +101,222 @@ class KFParticle :public KFParticleBase //* ACCESSORS //* - //* Simple accessors + //* Simple accessors - float GetX () const ; ///< Retruns X coordinate of the particle, fP[0]. - float GetY () const ; ///< Retruns Y coordinate of the particle, fP[1]. - float GetZ () const ; ///< Retruns Z coordinate of the particle, fP[2]. - float GetPx () const ; ///< Retruns X component of the momentum, fP[3]. - float GetPy () const ; ///< Retruns Y component of the momentum, fP[4]. - float GetPz () const ; ///< Retruns Z component of the momentum, fP[5]. - float GetE () const ; ///< Returns energy of the particle, fP[6]. - float GetS () const ; ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. - char GetQ () const ; ///< Returns charge of the particle. - float GetChi2 () const ; ///< Returns Chi2 of the fit. - Int_t GetNDF () const ; ///< Returns number of decrease of freedom. + float GetX() const; ///< Retruns X coordinate of the particle, fP[0]. + float GetY() const; ///< Retruns Y coordinate of the particle, fP[1]. + float GetZ() const; ///< Retruns Z coordinate of the particle, fP[2]. + float GetPx() const; ///< Retruns X component of the momentum, fP[3]. + float GetPy() const; ///< Retruns Y component of the momentum, fP[4]. + float GetPz() const; ///< Retruns Z component of the momentum, fP[5]. + float GetE() const; ///< Returns energy of the particle, fP[6]. + float GetS() const; ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. + char GetQ() const; ///< Returns charge of the particle. + float GetChi2() const; ///< Returns Chi2 of the fit. + Int_t GetNDF() const; ///< Returns number of decrease of freedom. Bool_t GetAtProductionVertex() const { return fAtProductionVertex; } ///< Returns a flag which shows if the particle is located at the production point - void SetAtProductionVertex(Bool_t b) { fAtProductionVertex = b; } ///< Set a flag that particle is at the production point + void SetAtProductionVertex(Bool_t b) { fAtProductionVertex = b; } ///< Set a flag that particle is at the production point #ifdef NonhomogeneousField - const float* GetFieldCoeff() const { return fieldRegion; } ///< Returns the field approximation for the current particle + const float* GetFieldCoeff() const + { + return fieldRegion; + } ///< Returns the field approximation for the current particle void SetFieldCoeff(float c, int i) { fieldRegion[i] = c; } ///< Sets the field coefficient with index i. #endif - const float& X () const { return fP[0]; } ///< Retruns X coordinate of the particle, fP[0]. - const float& Y () const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. - const float& Z () const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. - const float& Px () const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. - const float& Py () const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. - const float& Pz () const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. - const float& E () const { return fP[6]; } ///< Returns energy of the particle, fP[6]. - const float& S () const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. - const char& Q () const { return fQ; } ///< Returns charge of the particle. - const float& Chi2 () const { return fChi2; } ///< Returns Chi2 of the fit. - const Int_t& NDF () const { return fNDF; } ///< Returns number of decrease of freedom. - - float GetParameter ( int i ) const ; ///< Returns P[i] parameter. - float GetCovariance( int i ) const ; ///< Returns C[i] element of the covariance matrix in the lower triangular form. - float GetCovariance( int i, int j ) const ; ///< Returns C[i,j] element of the covariance matrix. + const float& X() const + { + return fP[0]; + } ///< Retruns X coordinate of the particle, fP[0]. + const float& Y() const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. + const float& Z() const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. + const float& Px() const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. + const float& Py() const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. + const float& Pz() const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. + const float& E() const { return fP[6]; } ///< Returns energy of the particle, fP[6]. + const float& S() const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. + const char& Q() const { return fQ; } ///< Returns charge of the particle. + const float& Chi2() const { return fChi2; } ///< Returns Chi2 of the fit. + const Int_t& NDF() const { return fNDF; } ///< Returns number of decrease of freedom. + + float GetParameter(int i) const; ///< Returns P[i] parameter. + float GetCovariance(int i) const; ///< Returns C[i] element of the covariance matrix in the lower triangular form. + float GetCovariance(int i, int j) const; ///< Returns C[i,j] element of the covariance matrix. //* Accessors with calculations, value returned w/o error flag - - float GetP () const; ///< Returns momentum - float GetPt () const; ///< Returns transverse momentum - float GetEta () const; ///< Returns pseudorapidity - float GetPhi () const; ///< Returns the azimuthal angle phi - float GetMomentum () const; ///< Returns momentum - float GetMass () const; ///< Returns mass - float GetDecayLength () const; ///< Returns decay length - float GetDecayLengthXY () const; ///< Returns decay length in XY - float GetLifeTime () const; ///< Returns life time ctau [cm] - float GetR () const; ///< Returns distance to the origin of the coordinate system {0,0,0} + + float GetP() const; ///< Returns momentum + float GetPt() const; ///< Returns transverse momentum + float GetEta() const; ///< Returns pseudorapidity + float GetPhi() const; ///< Returns the azimuthal angle phi + float GetMomentum() const; ///< Returns momentum + float GetMass() const; ///< Returns mass + float GetDecayLength() const; ///< Returns decay length + float GetDecayLengthXY() const; ///< Returns decay length in XY + float GetLifeTime() const; ///< Returns life time ctau [cm] + float GetR() const; ///< Returns distance to the origin of the coordinate system {0,0,0} //* Accessors to estimated errors - float GetErrX () const ; ///< Returns the error of X of current position - float GetErrY () const ; ///< Returns the error of Y of current position - float GetErrZ () const ; ///< Returns the error of Z of current position - float GetErrPx () const ; ///< Returns the error of X-compoment of the particle momentum - float GetErrPy () const ; ///< Returns the error of Y-compoment of the particle momentum - float GetErrPz () const ; ///< Returns the error of Z-compoment of the particle momentum - float GetErrE () const ; ///< Returns the error of energy - float GetErrS () const ; ///< Returns the error of decay length / momentum - float GetErrP () const ; ///< Returns the error of momentum - float GetErrPt () const ; ///< Returns the error of transverse momentum - float GetErrEta () const ; ///< Returns the error of pseudorapidity - float GetErrPhi () const ; ///< Returns the error of the azimuthal angle phi - float GetErrMomentum () const ; ///< Returns the error of momentum - float GetErrMass () const ; ///< Returns the error of mass - float GetErrDecayLength () const ; ///< Returns the error of decay length - float GetErrDecayLengthXY () const ; ///< Returns the error of decay length in XY - float GetErrLifeTime () const ; ///< Returns the error of life time - float GetErrR () const ; ///< Returns the error of distance to the origin of the coordinate system {0,0,0} + float GetErrX() const; ///< Returns the error of X of current position + float GetErrY() const; ///< Returns the error of Y of current position + float GetErrZ() const; ///< Returns the error of Z of current position + float GetErrPx() const; ///< Returns the error of X-compoment of the particle momentum + float GetErrPy() const; ///< Returns the error of Y-compoment of the particle momentum + float GetErrPz() const; ///< Returns the error of Z-compoment of the particle momentum + float GetErrE() const; ///< Returns the error of energy + float GetErrS() const; ///< Returns the error of decay length / momentum + float GetErrP() const; ///< Returns the error of momentum + float GetErrPt() const; ///< Returns the error of transverse momentum + float GetErrEta() const; ///< Returns the error of pseudorapidity + float GetErrPhi() const; ///< Returns the error of the azimuthal angle phi + float GetErrMomentum() const; ///< Returns the error of momentum + float GetErrMass() const; ///< Returns the error of mass + float GetErrDecayLength() const; ///< Returns the error of decay length + float GetErrDecayLengthXY() const; ///< Returns the error of decay length in XY + float GetErrLifeTime() const; ///< Returns the error of life time + float GetErrR() const; ///< Returns the error of distance to the origin of the coordinate system {0,0,0} //* Accessors with calculations( &value, &estimated sigma ) - //* error flag returned (0 means no error during calculations) - - int GetP ( float &P, float &SigmaP ) const ; //* momentum - int GetPt ( float &Pt, float &SigmaPt ) const ; //* transverse momentum - int GetEta ( float &Eta, float &SigmaEta ) const ; //* pseudorapidity - int GetPhi ( float &Phi, float &SigmaPhi ) const ; //* phi - int GetMomentum ( float &P, float &SigmaP ) const ; //* momentum - int GetMass ( float &M, float &SigmaM ) const ; //* mass - int GetDecayLength ( float &L, float &SigmaL ) const ; //* decay length - int GetDecayLengthXY ( float &L, float &SigmaL ) const ; //* decay length in XY - int GetLifeTime ( float &T, float &SigmaT ) const ; //* life time - int GetR ( float &R, float &SigmaR ) const ; //* R - float GetRapidity() const { return 0.5*log((fP[6] + fP[5])/(fP[6] - fP[5])); } ///< Returns rapidity of the particle - float GetTheta() const { return atan2(GetPt(),fP[5]); } ///< Returns the polar angle in RZ - + //* error flag returned (0 means no error during calculations) + + int GetP(float& P, float& SigmaP) const; //* momentum + int GetPt(float& Pt, float& SigmaPt) const; //* transverse momentum + int GetEta(float& Eta, float& SigmaEta) const; //* pseudorapidity + int GetPhi(float& Phi, float& SigmaPhi) const; //* phi + int GetMomentum(float& P, float& SigmaP) const; //* momentum + int GetMass(float& M, float& SigmaM) const; //* mass + int GetDecayLength(float& L, float& SigmaL) const; //* decay length + int GetDecayLengthXY(float& L, float& SigmaL) const; //* decay length in XY + int GetLifeTime(float& T, float& SigmaT) const; //* life time + int GetR(float& R, float& SigmaR) const; //* R + float GetRapidity() const { return 0.5 * log((fP[6] + fP[5]) / (fP[6] - fP[5])); } ///< Returns rapidity of the particle + float GetTheta() const { return atan2(GetPt(), fP[5]); } ///< Returns the polar angle in RZ //* //* MODIFIERS //* - - float & X () ; ///< Modifier of X coordinate of the particle, fP[0]. - float & Y () ; ///< Modifier of Y coordinate of the particle, fP[1]. - float & Z () ; ///< Modifier of Z coordinate of the particle, fP[2]. - float & Px () ; ///< Modifier of X component of the momentum, fP[3]. - float & Py () ; ///< Modifier of Y component of the momentum, fP[4]. - float & Pz () ; ///< Modifier of Z component of the momentum, fP[5]. - float & E () ; ///< Modifier of energy of the particle, fP[6]. - float & S () ; ///< Modifier of dS=l/p, l - decay length, fP[7], defined if production vertex is set. - char & Q () ; ///< Modifier of charge of the particle. - float & Chi2 () ; ///< Modifier of Chi2 of the fit. - Int_t & NDF () ; ///< Modifier of number of decrease of freedom. - - float & Parameter ( int i ) ; ///< Modifier of P[i] parameter. - float & Covariance( int i ) ; ///< Modifier of C[i] element of the covariance matrix in the lower triangular form. - float & Covariance( int i, int j ) ; ///< Modifier of C[i,j] element of the covariance matrix. - float * Parameters () ; ///< Returns pointer to the parameters fP - float * CovarianceMatrix() ; ///< Returns pointer to the covariance matrix fC - - //* + + float& X(); ///< Modifier of X coordinate of the particle, fP[0]. + float& Y(); ///< Modifier of Y coordinate of the particle, fP[1]. + float& Z(); ///< Modifier of Z coordinate of the particle, fP[2]. + float& Px(); ///< Modifier of X component of the momentum, fP[3]. + float& Py(); ///< Modifier of Y component of the momentum, fP[4]. + float& Pz(); ///< Modifier of Z component of the momentum, fP[5]. + float& E(); ///< Modifier of energy of the particle, fP[6]. + float& S(); ///< Modifier of dS=l/p, l - decay length, fP[7], defined if production vertex is set. + char& Q(); ///< Modifier of charge of the particle. + float& Chi2(); ///< Modifier of Chi2 of the fit. + Int_t& NDF(); ///< Modifier of number of decrease of freedom. + + float& Parameter(int i); ///< Modifier of P[i] parameter. + float& Covariance(int i); ///< Modifier of C[i] element of the covariance matrix in the lower triangular form. + float& Covariance(int i, int j); ///< Modifier of C[i,j] element of the covariance matrix. + float* Parameters(); ///< Returns pointer to the parameters fP + float* CovarianceMatrix(); ///< Returns pointer to the covariance matrix fC + + //* //* CONSTRUCTION OF THE PARTICLE BY ITS DAUGHTERS AND MOTHER //* USING THE KALMAN FILTER METHOD //* + //* Add daughter to the particle - //* Add daughter to the particle - - void AddDaughter( const KFParticle &Daughter ); + void AddDaughter(const KFParticle& Daughter); //* Add daughter via += operator: ex.{ D0; D0+=Pion; D0+= Kaon; } - void operator +=( const KFParticle &Daughter ); + void operator+=(const KFParticle& Daughter); - //* Everything in one go + //* Everything in one go - void Construct( const KFParticle *vDaughters[], int nDaughters, - const KFParticle *ProdVtx=0, float Mass=-1 ); + void Construct(const KFParticle* vDaughters[], int nDaughters, + const KFParticle* ProdVtx = 0, float Mass = -1); //* //* TRANSPORT - //* + //* //* ( main transportation parameter is S = SignedPath/Momentum ) //* ( parameters of decay & production vertices are stored locally ) //* - //* Transport the particle close to xyz[] point + //* Transport the particle close to xyz[] point - void TransportToPoint( const float xyz[] ); + void TransportToPoint(const float xyz[]); - //* Transport the particle close to VVertex + //* Transport the particle close to VVertex #ifdef HomogeneousField - void TransportToVertex( const KFPVertex &v ); + void TransportToVertex(const KFPVertex& v); #endif - //* Transport the particle close to another particle p - void TransportToParticle( const KFParticle &p ); - - //* Get dS to a certain space point - float GetDStoPoint( const float xyz[3], float dsdr[6] ) const ; - - //* Get dS to other particle p (dSp for particle p also returned) - void GetDStoParticle( const KFParticleBase &p, float dS[2], float dsdr[4][6] ) const ; - - - //* + //* Transport the particle close to another particle p + void TransportToParticle(const KFParticle& p); + + //* Get dS to a certain space point + float GetDStoPoint(const float xyz[3], float dsdr[6]) const; + + //* Get dS to other particle p (dSp for particle p also returned) + void GetDStoParticle(const KFParticleBase& p, float dS[2], float dsdr[4][6]) const; + + //* //* OTHER UTILITIES //* - + //* Calculate distance from another object [cm] in XY-plane - Bool_t GetDistanceFromVertexXY( const float vtx[], float &val, float &err ) const ; - Bool_t GetDistanceFromVertexXY( const float vtx[], const float Cv[], float &val, float &err ) const ; - Bool_t GetDistanceFromVertexXY( const KFParticle &Vtx, float &val, float &err ) const ; + Bool_t GetDistanceFromVertexXY(const float vtx[], float& val, float& err) const; + Bool_t GetDistanceFromVertexXY(const float vtx[], const float Cv[], float& val, float& err) const; + Bool_t GetDistanceFromVertexXY(const KFParticle& Vtx, float& val, float& err) const; #ifdef HomogeneousField - Bool_t GetDistanceFromVertexXY( const KFPVertex &Vtx, float &val, float &err ) const ; + Bool_t GetDistanceFromVertexXY(const KFPVertex& Vtx, float& val, float& err) const; #endif - float GetDistanceFromVertexXY( const float vtx[] ) const ; - float GetDistanceFromVertexXY( const KFParticle &Vtx ) const ; + float GetDistanceFromVertexXY(const float vtx[]) const; + float GetDistanceFromVertexXY(const KFParticle& Vtx) const; #ifdef HomogeneousField - float GetDistanceFromVertexXY( const KFPVertex &Vtx ) const ; + float GetDistanceFromVertexXY(const KFPVertex& Vtx) const; #endif - float GetDistanceFromParticleXY( const KFParticle &p ) const ; + float GetDistanceFromParticleXY(const KFParticle& p) const; //* Calculate sqrt(Chi2/ndf) deviation from another object in XY plane //* ( v = [xyz]-vertex, Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix ) - float GetDeviationFromVertexXY( const float v[], const float Cv[]=0 ) const ; - float GetDeviationFromVertexXY( const KFParticle &Vtx ) const ; + float GetDeviationFromVertexXY(const float v[], const float Cv[] = 0) const; + float GetDeviationFromVertexXY(const KFParticle& Vtx) const; #ifdef HomogeneousField - float GetDeviationFromVertexXY( const KFPVertex &Vtx ) const ; + float GetDeviationFromVertexXY(const KFPVertex& Vtx) const; #endif - float GetDeviationFromParticleXY( const KFParticle &p ) const ; + float GetDeviationFromParticleXY(const KFParticle& p) const; //* Get parameters at an arbitrary reconstructed point taking into account its errors void GetParametersAtPoint(const float* point, const float* pointCov, float* m, float* mV); - + //* Calculate opennig angle between two particles - float GetAngle ( const KFParticle &p ) const ; - float GetAngleXY( const KFParticle &p ) const ; - float GetAngleRZ( const KFParticle &p ) const ; + float GetAngle(const KFParticle& p) const; + float GetAngleXY(const KFParticle& p) const; + float GetAngleRZ(const KFParticle& p) const; - float GetPseudoProperDecayTime( const KFParticle &primVertex, const float& mass, float* timeErr2 = 0 ) const; + float GetPseudoProperDecayTime(const KFParticle& primVertex, const float& mass, float* timeErr2 = 0) const; - void GetFieldValue( const float xyz[], float B[] ) const ; + void GetFieldValue(const float xyz[], float B[]) const; - void Transport( float dS, const float* dsdr, float P[], float C[], float* dsdr1=0, float* F=0, float* F1=0 ) const ; + void Transport(float dS, const float* dsdr, float P[], float C[], float* dsdr1 = 0, float* F = 0, float* F1 = 0) const; - protected: - + protected: //* //* INTERNAL STUFF - //* + //* - //* Method to access ALICE field + //* Method to access ALICE field #ifdef HomogeneousField static float GetFieldAlice(); #endif - + private: #ifdef HomogeneousField - static float fgBz; ///< Bz compoment of the magnetic field (is defined in case of #ifdef HomogeneousField) + static float fgBz; ///< Bz compoment of the magnetic field (is defined in case of #ifdef HomogeneousField) #endif #ifdef NonhomogeneousField /** \brief Approximation of the magnetic field along the track trajectory. @@ -324,14 +324,12 @@ class KFParticle :public KFParticleBase **/ float fieldRegion[10]; #endif - + #ifndef KFParticleStandalone - ClassDef( KFParticle, 3 ) + ClassDef(KFParticle, 3) #endif }; - - //--------------------------------------------------------------------- // // Inline implementation of the KFParticle methods @@ -339,8 +337,8 @@ class KFParticle :public KFParticleBase //--------------------------------------------------------------------- #ifdef HomogeneousField -inline void KFParticle::SetField( float Bz ) -{ +inline void KFParticle::SetField(float Bz) +{ /** Sets the constant homogemeous one-component magnetic field Bz (is defined in case of #ifdef HomogeneousField). ** \param[in] Bz - Z-component of the magnetic field **/ @@ -348,9 +346,9 @@ inline void KFParticle::SetField( float Bz ) } #endif -inline KFParticle::KFParticle( const KFParticle &d1, - const KFParticle &d2, - const KFParticle &d3 ) +inline KFParticle::KFParticle(const KFParticle& d1, + const KFParticle& d2, + const KFParticle& d3) { /** Constructs a particle from three input daughter particles ** \param[in] d1 - the first daughter particle @@ -358,16 +356,16 @@ inline KFParticle::KFParticle( const KFParticle &d1, ** \param[in] d3 - the third daughter particle **/ KFParticle mother; - mother+= d1; - mother+= d2; - mother+= d3; + mother += d1; + mother += d2; + mother += d3; *this = mother; } -inline KFParticle::KFParticle( const KFParticle &d1, - const KFParticle &d2, - const KFParticle &d3, - const KFParticle &d4 ) +inline KFParticle::KFParticle(const KFParticle& d1, + const KFParticle& d2, + const KFParticle& d3, + const KFParticle& d4) { /** Constructs a particle from four input daughter particles ** \param[in] d1 - the first daughter particle @@ -376,337 +374,374 @@ inline KFParticle::KFParticle( const KFParticle &d1, ** \param[in] d4 - the fourth daughter particle **/ KFParticle mother; - mother+= d1; - mother+= d2; - mother+= d3; - mother+= d4; + mother += d1; + mother += d2; + mother += d3; + mother += d4; *this = mother; } - inline void KFParticle::Initialize() -{ +{ /** Calls KFParticleBase::Initialize()*/ - KFParticleBase::Initialize(); + KFParticleBase::Initialize(); } -inline float KFParticle::GetX () const -{ - return KFParticleBase::GetX(); +inline float KFParticle::GetX() const +{ + return KFParticleBase::GetX(); } -inline float KFParticle::GetY () const -{ - return KFParticleBase::GetY(); +inline float KFParticle::GetY() const +{ + return KFParticleBase::GetY(); } -inline float KFParticle::GetZ () const -{ - return KFParticleBase::GetZ(); +inline float KFParticle::GetZ() const +{ + return KFParticleBase::GetZ(); } -inline float KFParticle::GetPx () const -{ - return KFParticleBase::GetPx(); +inline float KFParticle::GetPx() const +{ + return KFParticleBase::GetPx(); } -inline float KFParticle::GetPy () const -{ - return KFParticleBase::GetPy(); +inline float KFParticle::GetPy() const +{ + return KFParticleBase::GetPy(); } -inline float KFParticle::GetPz () const -{ - return KFParticleBase::GetPz(); +inline float KFParticle::GetPz() const +{ + return KFParticleBase::GetPz(); } -inline float KFParticle::GetE () const -{ - return KFParticleBase::GetE(); +inline float KFParticle::GetE() const +{ + return KFParticleBase::GetE(); } -inline float KFParticle::GetS () const -{ - return KFParticleBase::GetS(); +inline float KFParticle::GetS() const +{ + return KFParticleBase::GetS(); } -inline char KFParticle::GetQ () const -{ - return KFParticleBase::GetQ(); +inline char KFParticle::GetQ() const +{ + return KFParticleBase::GetQ(); } -inline float KFParticle::GetChi2 () const -{ - return KFParticleBase::GetChi2(); +inline float KFParticle::GetChi2() const +{ + return KFParticleBase::GetChi2(); } -inline Int_t KFParticle::GetNDF () const -{ - return KFParticleBase::GetNDF(); +inline Int_t KFParticle::GetNDF() const +{ + return KFParticleBase::GetNDF(); } -inline float KFParticle::GetParameter ( int i ) const -{ - return KFParticleBase::GetParameter(i); +inline float KFParticle::GetParameter(int i) const +{ + return KFParticleBase::GetParameter(i); } -inline float KFParticle::GetCovariance( int i ) const -{ - return KFParticleBase::GetCovariance(i); +inline float KFParticle::GetCovariance(int i) const +{ + return KFParticleBase::GetCovariance(i); } -inline float KFParticle::GetCovariance( int i, int j ) const -{ - return KFParticleBase::GetCovariance(i,j); +inline float KFParticle::GetCovariance(int i, int j) const +{ + return KFParticleBase::GetCovariance(i, j); } - -inline float KFParticle::GetP () const +inline float KFParticle::GetP() const { float par, err; - if( KFParticleBase::GetMomentum( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetMomentum(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetPt () const +inline float KFParticle::GetPt() const { float par, err; - if( KFParticleBase::GetPt( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetPt(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetEta () const +inline float KFParticle::GetEta() const { float par, err; - if( KFParticleBase::GetEta( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetEta(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetPhi () const +inline float KFParticle::GetPhi() const { float par, err; - if( KFParticleBase::GetPhi( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetPhi(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetMomentum () const +inline float KFParticle::GetMomentum() const { float par, err; - if( KFParticleBase::GetMomentum( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetMomentum(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetMass () const +inline float KFParticle::GetMass() const { float par, err; - if( KFParticleBase::GetMass( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetMass(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetDecayLength () const +inline float KFParticle::GetDecayLength() const { float par, err; - if( KFParticleBase::GetDecayLength( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetDecayLength(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetDecayLengthXY () const +inline float KFParticle::GetDecayLengthXY() const { float par, err; - if( KFParticleBase::GetDecayLengthXY( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetDecayLengthXY(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetLifeTime () const +inline float KFParticle::GetLifeTime() const { float par, err; - if( KFParticleBase::GetLifeTime( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetLifeTime(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetR () const +inline float KFParticle::GetR() const { float par, err; - if( KFParticleBase::GetR( par, err ) ) return 0; - else return par; + if (KFParticleBase::GetR(par, err)) + return 0; + else + return par; } -inline float KFParticle::GetErrX () const +inline float KFParticle::GetErrX() const { - return sqrt(fabs( GetCovariance(0,0) )); + return sqrt(fabs(GetCovariance(0, 0))); } -inline float KFParticle::GetErrY () const +inline float KFParticle::GetErrY() const { - return sqrt(fabs( GetCovariance(1,1) )); + return sqrt(fabs(GetCovariance(1, 1))); } -inline float KFParticle::GetErrZ () const +inline float KFParticle::GetErrZ() const { - return sqrt(fabs( GetCovariance(2,2) )); + return sqrt(fabs(GetCovariance(2, 2))); } -inline float KFParticle::GetErrPx () const +inline float KFParticle::GetErrPx() const { - return sqrt(fabs( GetCovariance(3,3) )); + return sqrt(fabs(GetCovariance(3, 3))); } -inline float KFParticle::GetErrPy () const +inline float KFParticle::GetErrPy() const { - return sqrt(fabs( GetCovariance(4,4) )); + return sqrt(fabs(GetCovariance(4, 4))); } -inline float KFParticle::GetErrPz () const +inline float KFParticle::GetErrPz() const { - return sqrt(fabs( GetCovariance(5,5) )); + return sqrt(fabs(GetCovariance(5, 5))); } -inline float KFParticle::GetErrE () const +inline float KFParticle::GetErrE() const { - return sqrt(fabs( GetCovariance(6,6) )); + return sqrt(fabs(GetCovariance(6, 6))); } -inline float KFParticle::GetErrS () const +inline float KFParticle::GetErrS() const { - return sqrt(fabs( GetCovariance(7,7) )); + return sqrt(fabs(GetCovariance(7, 7))); } -inline float KFParticle::GetErrP () const +inline float KFParticle::GetErrP() const { float par, err; - if( KFParticleBase::GetMomentum( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetMomentum(par, err)) + return 1.e10; + else + return err; } -inline float KFParticle::GetErrPt () const +inline float KFParticle::GetErrPt() const { float par, err; - if( KFParticleBase::GetPt( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetPt(par, err)) + return 1.e10; + else + return err; } -inline float KFParticle::GetErrEta () const +inline float KFParticle::GetErrEta() const { float par, err; - if( KFParticleBase::GetEta( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetEta(par, err)) + return 1.e10; + else + return err; } -inline float KFParticle::GetErrPhi () const +inline float KFParticle::GetErrPhi() const { float par, err; - if( KFParticleBase::GetPhi( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetPhi(par, err)) + return 1.e10; + else + return err; } -inline float KFParticle::GetErrMomentum () const +inline float KFParticle::GetErrMomentum() const { float par, err; - if( KFParticleBase::GetMomentum( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetMomentum(par, err)) + return 1.e10; + else + return err; } -inline float KFParticle::GetErrMass () const +inline float KFParticle::GetErrMass() const { float par, err; - if( KFParticleBase::GetMass( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetMass(par, err)) + return 1.e10; + else + return err; } -inline float KFParticle::GetErrDecayLength () const +inline float KFParticle::GetErrDecayLength() const { float par, err; - if( KFParticleBase::GetDecayLength( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetDecayLength(par, err)) + return 1.e10; + else + return err; } -inline float KFParticle::GetErrDecayLengthXY () const +inline float KFParticle::GetErrDecayLengthXY() const { float par, err; - if( KFParticleBase::GetDecayLengthXY( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetDecayLengthXY(par, err)) + return 1.e10; + else + return err; } -inline float KFParticle::GetErrLifeTime () const +inline float KFParticle::GetErrLifeTime() const { float par, err; - if( KFParticleBase::GetLifeTime( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetLifeTime(par, err)) + return 1.e10; + else + return err; } -inline float KFParticle::GetErrR () const +inline float KFParticle::GetErrR() const { float par, err; - if( KFParticleBase::GetR( par, err ) ) return 1.e10; - else return err; + if (KFParticleBase::GetR(par, err)) + return 1.e10; + else + return err; } - -inline int KFParticle::GetP( float &P, float &SigmaP ) const +inline int KFParticle::GetP(float& P, float& SigmaP) const { /** Calculates particle momentum and its error. If they are well defined returns 0, otherwise 1. ** \param[out] P - momentum of the particle ** \param[out] SigmaP - its error **/ - return KFParticleBase::GetMomentum( P, SigmaP ); + return KFParticleBase::GetMomentum(P, SigmaP); } -inline int KFParticle::GetPt( float &Pt, float &SigmaPt ) const +inline int KFParticle::GetPt(float& Pt, float& SigmaPt) const { /** Calculates particle transverse momentum and its error. If they are well defined returns 0, otherwise 1. ** \param[out] Pt - transverse momentum of the particle ** \param[out] SigmaPt - its error **/ - return KFParticleBase::GetPt( Pt, SigmaPt ); + return KFParticleBase::GetPt(Pt, SigmaPt); } -inline int KFParticle::GetEta( float &Eta, float &SigmaEta ) const +inline int KFParticle::GetEta(float& Eta, float& SigmaEta) const { /** Calculates particle pseudorapidity and its error. If they are well defined returns 0, otherwise 1. ** \param[out] Eta - pseudorapidity of the particle ** \param[out] SigmaEta - its error **/ - return KFParticleBase::GetEta( Eta, SigmaEta ); + return KFParticleBase::GetEta(Eta, SigmaEta); } -inline int KFParticle::GetPhi( float &Phi, float &SigmaPhi ) const +inline int KFParticle::GetPhi(float& Phi, float& SigmaPhi) const { /** Calculates particle polar angle at the current point and its error. If they are well defined returns 0, otherwise 1. ** \param[out] Phi - polar angle of the particle ** \param[out] SigmaPhi - its error **/ - return KFParticleBase::GetPhi( Phi, SigmaPhi ); + return KFParticleBase::GetPhi(Phi, SigmaPhi); } -inline int KFParticle::GetMomentum( float &P, float &SigmaP ) const +inline int KFParticle::GetMomentum(float& P, float& SigmaP) const { /** Calculates particle momentum and its error. If they are well defined returns 0, otherwise 1. ** \param[out] P - momentum of the particle ** \param[out] SigmaP - its error **/ - return KFParticleBase::GetMomentum( P, SigmaP ); + return KFParticleBase::GetMomentum(P, SigmaP); } -inline int KFParticle::GetMass( float &M, float &SigmaM ) const +inline int KFParticle::GetMass(float& M, float& SigmaM) const { /** Calculates the mass of the particle and its error. If they are well defined returns 0, otherwise 1. ** \param[out] M - mass of the particle ** \param[out] SigmaM - its error **/ - return KFParticleBase::GetMass( M, SigmaM ); + return KFParticleBase::GetMass(M, SigmaM); } -inline int KFParticle::GetDecayLength( float &L, float &SigmaL ) const +inline int KFParticle::GetDecayLength(float& L, float& SigmaL) const { /** Calculates the decay length of the particle in the laboratory system and its error. If they are well defined returns 0, otherwise 1. ** The production point should be set before calling this function. ** \param[out] L - the decay length ** \param[out] SigmaL - its error **/ - return KFParticleBase::GetDecayLength( L, SigmaL ); + return KFParticleBase::GetDecayLength(L, SigmaL); } -inline int KFParticle::GetDecayLengthXY( float &L, float &SigmaL ) const +inline int KFParticle::GetDecayLengthXY(float& L, float& SigmaL) const { /** Calculates the projection in the XY plane of the decay length of the particle in the laboratory ** system and its error. If they are well defined returns 0, otherwise 1. @@ -714,10 +749,10 @@ inline int KFParticle::GetDecayLengthXY( float &L, float &SigmaL ) const ** \param[out] L - the decay length ** \param[out] SigmaL - its error **/ - return KFParticleBase::GetDecayLengthXY( L, SigmaL ); + return KFParticleBase::GetDecayLengthXY(L, SigmaL); } -inline int KFParticle::GetLifeTime( float &T, float &SigmaT ) const +inline int KFParticle::GetLifeTime(float& T, float& SigmaT) const { /** Calculates the lifetime times speed of life (ctau) [cm] of the particle in the ** center of mass frame and its error. If they are well defined returns 0, otherwise 1. @@ -725,113 +760,111 @@ inline int KFParticle::GetLifeTime( float &T, float &SigmaT ) const ** \param[out] T - lifetime of the particle [cm] ** \param[out] SigmaT - its error **/ - return KFParticleBase::GetLifeTime( T, SigmaT ); + return KFParticleBase::GetLifeTime(T, SigmaT); } -inline int KFParticle::GetR( float &R, float &SigmaR ) const +inline int KFParticle::GetR(float& R, float& SigmaR) const { /** Calculates the distance to the point {0,0,0} and its error. If they are well defined returns 0, otherwise 1. ** \param[out] R - polar angle of the particle ** \param[out] SigmaR - its error **/ - return KFParticleBase::GetR( R, SigmaR ); + return KFParticleBase::GetR(R, SigmaR); } -inline float & KFParticle::X() -{ - return KFParticleBase::X(); +inline float& KFParticle::X() +{ + return KFParticleBase::X(); } -inline float & KFParticle::Y() -{ - return KFParticleBase::Y(); +inline float& KFParticle::Y() +{ + return KFParticleBase::Y(); } -inline float & KFParticle::Z() -{ - return KFParticleBase::Z(); +inline float& KFParticle::Z() +{ + return KFParticleBase::Z(); } -inline float & KFParticle::Px() -{ - return KFParticleBase::Px(); +inline float& KFParticle::Px() +{ + return KFParticleBase::Px(); } -inline float & KFParticle::Py() -{ - return KFParticleBase::Py(); +inline float& KFParticle::Py() +{ + return KFParticleBase::Py(); } -inline float & KFParticle::Pz() -{ - return KFParticleBase::Pz(); +inline float& KFParticle::Pz() +{ + return KFParticleBase::Pz(); } -inline float & KFParticle::E() -{ - return KFParticleBase::E(); +inline float& KFParticle::E() +{ + return KFParticleBase::E(); } -inline float & KFParticle::S() -{ - return KFParticleBase::S(); +inline float& KFParticle::S() +{ + return KFParticleBase::S(); } -inline char & KFParticle::Q() -{ - return KFParticleBase::Q(); +inline char& KFParticle::Q() +{ + return KFParticleBase::Q(); } -inline float & KFParticle::Chi2() -{ - return KFParticleBase::Chi2(); +inline float& KFParticle::Chi2() +{ + return KFParticleBase::Chi2(); } -inline Int_t & KFParticle::NDF() -{ - return KFParticleBase::NDF(); +inline Int_t& KFParticle::NDF() +{ + return KFParticleBase::NDF(); } -inline float & KFParticle::Parameter ( int i ) -{ +inline float& KFParticle::Parameter(int i) +{ return KFParticleBase::Parameter(i); } -inline float & KFParticle::Covariance( int i ) -{ +inline float& KFParticle::Covariance(int i) +{ return KFParticleBase::Covariance(i); } -inline float & KFParticle::Covariance( int i, int j ) -{ - return KFParticleBase::Covariance(i,j); +inline float& KFParticle::Covariance(int i, int j) +{ + return KFParticleBase::Covariance(i, j); } -inline float * KFParticle::Parameters () +inline float* KFParticle::Parameters() { return fP; } -inline float * KFParticle::CovarianceMatrix() +inline float* KFParticle::CovarianceMatrix() { return fC; } - -inline void KFParticle::operator +=( const KFParticle &Daughter ) +inline void KFParticle::operator+=(const KFParticle& Daughter) { /** Operator to add daughter to the current particle. Calls AddDaughter() function. ** \param[in] Daughter - the daughter particle **/ #ifdef NonhomogeneousField - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) SetFieldCoeff(Daughter.GetFieldCoeff()[i], i); #endif - KFParticleBase::operator +=( Daughter ); + KFParticleBase::operator+=(Daughter); } - -inline void KFParticle::AddDaughter( const KFParticle &Daughter ) +inline void KFParticle::AddDaughter(const KFParticle& Daughter) { /** Adds daughter to the current particle. Depending on the selected construction method uses: \n ** 1) Either simplifyed fast mathematics which consideres momentum and energy as @@ -846,15 +879,15 @@ inline void KFParticle::AddDaughter( const KFParticle &Daughter ) ** \param[in] Daughter - the daughter particle **/ #ifdef NonhomogeneousField - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) SetFieldCoeff(Daughter.GetFieldCoeff()[i], i); #endif - KFParticleBase::AddDaughter( Daughter ); + KFParticleBase::AddDaughter(Daughter); } -inline void KFParticle::Construct( const KFParticle *vDaughters[], int nDaughters, - const KFParticle *ProdVtx, float Mass ) -{ +inline void KFParticle::Construct(const KFParticle* vDaughters[], int nDaughters, + const KFParticle* ProdVtx, float Mass) +{ /** Constructs a short-lived particle from a set of daughter particles:\n ** 1) all parameters of the "this" objects are initialised;\n ** 2) daughters are added one after another;\n @@ -864,45 +897,45 @@ inline void KFParticle::Construct( const KFParticle *vDaughters[], int nDaughter ** \param[in] nDaughters - number of daughter particles in the input array ** \param[in] Parent - optional parrent particle ** \param[in] Mass - optional mass hypothesis - **/ + **/ #ifdef NonhomogeneousField - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) SetFieldCoeff(vDaughters[0]->GetFieldCoeff()[i], i); #endif - KFParticleBase::Construct( ( const KFParticleBase**)vDaughters, nDaughters, - ( const KFParticleBase*)ProdVtx, Mass ); + KFParticleBase::Construct((const KFParticleBase**)vDaughters, nDaughters, + (const KFParticleBase*)ProdVtx, Mass); } -inline void KFParticle::TransportToPoint( const float xyz[] ) -{ +inline void KFParticle::TransportToPoint(const float xyz[]) +{ /** Transports particle to the distance of closest approach to the point xyz. ** \param[in] xyz[3] - point, where particle should be transported **/ float dsdr[6] = {0.f}; float dS = GetDStoPoint(xyz, dsdr); - TransportToDS( dS, dsdr ); + TransportToDS(dS, dsdr); } #ifdef HomogeneousField -inline void KFParticle::TransportToVertex( const KFPVertex &v ) -{ +inline void KFParticle::TransportToVertex(const KFPVertex& v) +{ /** Transports particle to the distance of closest approach to the vertex v. ** \param[in] v - vertex, where particle should be transported **/ - TransportToPoint( KFParticle(v).fP ); + TransportToPoint(KFParticle(v).fP); } #endif -inline void KFParticle::TransportToParticle( const KFParticle &p ) -{ +inline void KFParticle::TransportToParticle(const KFParticle& p) +{ /** Transports particle to the distance of closest approach to the particle p. ** \param[in] p - particle, to which the current particle should be transported. **/ float dsdr[4][6]; float dS[2]; - GetDStoParticle( p, dS, dsdr ); - TransportToDS( dS[0], dsdr[0] ); + GetDStoParticle(p, dS, dsdr); + TransportToDS(dS[0], dsdr[0]); } -inline float KFParticle::GetDStoPoint( const float xyz[], float* dsdr ) const +inline float KFParticle::GetDStoPoint(const float xyz[], float* dsdr) const { /** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n @@ -916,55 +949,55 @@ inline float KFParticle::GetDStoPoint( const float xyz[], float* dsdr ) const ** to other coordinate system (see GetDStoPointBy() function), otherwise fP are used **/ #ifdef HomogeneousField - return KFParticleBase::GetDStoPointBz( GetFieldAlice(), xyz, dsdr ); + return KFParticleBase::GetDStoPointBz(GetFieldAlice(), xyz, dsdr); #endif #ifdef NonhomogeneousField - return KFParticleBase::GetDStoPointCBM( xyz, dsdr ); + return KFParticleBase::GetDStoPointCBM(xyz, dsdr); #endif } #ifdef HomogeneousField inline float KFParticle::GetFieldAlice() -{ +{ /** Returns value of the constant homogemeous one-component magnetic field Bz, (is defined in case of #ifdef HomogeneousField). */ - return fgBz; + return fgBz; } #endif #ifdef HomogeneousField -inline void KFParticle::GetFieldValue( const float * /*xyz*/, float B[] ) const -{ +inline void KFParticle::GetFieldValue(const float* /*xyz*/, float B[]) const +{ /** Calculates the Bx, By, Bz components at the point xyz using approximation of the ** magnetic field along the particle trajectory. ** \param[in] xyz[3] - X, Y, Z coordiantes of the point where the magnetic field should be calculated ** \param[out] B[3] - value of X, Y, Z components of the calculated magnetic field at the given point **/ - + B[0] = B[1] = 0; B[2] = GetFieldAlice(); } #endif #ifdef NonhomogeneousField -inline void KFParticle::GetFieldValue( const float xyz[], float B[] ) const +inline void KFParticle::GetFieldValue(const float xyz[], float B[]) const { /** Calculates the Bx, By, Bz components at the point xyz using approximation of the ** magnetic field along the particle trajectory. ** \param[in] xyz[3] - X, Y, Z coordiantes of the point where the magnetic field should be calculated ** \param[out] B[3] - value of X, Y, Z components of the calculated magnetic field at the given point **/ - - const float dz = (xyz[2]-fieldRegion[9]); - const float dz2 = dz*dz; - B[0] = fieldRegion[0] + fieldRegion[1]*dz + fieldRegion[2]*dz2; - B[1] = fieldRegion[3] + fieldRegion[4]*dz + fieldRegion[5]*dz2; - B[2] = fieldRegion[6] + fieldRegion[7]*dz + fieldRegion[8]*dz2; + const float dz = (xyz[2] - fieldRegion[9]); + const float dz2 = dz * dz; + + B[0] = fieldRegion[0] + fieldRegion[1] * dz + fieldRegion[2] * dz2; + B[1] = fieldRegion[3] + fieldRegion[4] * dz + fieldRegion[5] * dz2; + B[2] = fieldRegion[6] + fieldRegion[7] * dz + fieldRegion[8] * dz2; } #endif -inline void KFParticle::GetDStoParticle( const KFParticleBase &p, float dS[2], float dsdr[4][6] ) const -{ +inline void KFParticle::GetDStoParticle(const KFParticleBase& p, float dS[2], float dsdr[4][6]) const +{ /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n ** 2) p - momentum of the particle \n @@ -982,14 +1015,14 @@ inline void KFParticle::GetDStoParticle( const KFParticleBase &p, float dS[2], f ** \param[out] dsdr[4][6] - partial derivatives of the parameters dS[0] and dS[1] over the state vectors of the both particles **/ #ifdef HomogeneousField - KFParticleBase::GetDStoParticleBz( GetFieldAlice(), p, dS, dsdr ) ; + KFParticleBase::GetDStoParticleBz(GetFieldAlice(), p, dS, dsdr); #endif #ifdef NonhomogeneousField - KFParticleBase::GetDStoParticleCBM( p, dS, dsdr ) ; + KFParticleBase::GetDStoParticleCBM(p, dS, dsdr); #endif } -inline void KFParticle::Transport( float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1 ) const +inline void KFParticle::Transport(float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1) const { /** Transports the parameters and their covariance matrix of the current particle ** on a length defined by the transport parameter dS = l/p, where l is the signed distance and p is @@ -1012,13 +1045,13 @@ inline void KFParticle::Transport( float dS, const float* dsdr, float P[], float ** \param[out] F[36] - optional parameter, transport jacobian, 6x6 matrix F = d(fP new)/d(fP old) ** \param[out] F1[36] - optional parameter, corelation 6x6 matrix betweeen the current particle and particle or vertex ** with the state vector r1, to which the current particle is being transported, F1 = d(fP new)/d(r1) - **/ + **/ #ifdef HomogeneousField - KFParticleBase::TransportBz( GetFieldAlice(), dS, dsdr, P, C, dsdr1, F, F1 ); + KFParticleBase::TransportBz(GetFieldAlice(), dS, dsdr, P, C, dsdr1, F, F1); #endif #ifdef NonhomogeneousField - KFParticleBase::TransportCBM( dS, dsdr, P, C, dsdr1, F, F1 ); + KFParticleBase::TransportCBM(dS, dsdr, P, C, dsdr1, F, F1); #endif } -#endif +#endif diff --git a/KFParticle/KFParticleBase.cxx b/KFParticle/KFParticleBase.cxx index a7ffc4b..8059c55 100644 --- a/KFParticle/KFParticleBase.cxx +++ b/KFParticle/KFParticleBase.cxx @@ -20,7 +20,6 @@ * along with this program. If not, see . */ - #include "KFParticleBase.h" #include @@ -34,20 +33,19 @@ ClassImp(KFParticleBase) #include "TRVector.h" #include -KFParticleBase::KFParticleBase() :fChi2(0), fSFromDecay(0), SumDaughterMass(0), fMassHypo(-1), fNDF(-3), - fId(-1), fParentID(0), fIdTruth(0), fQuality(0), fIdParentMcVx(0), fAtProductionVertex(0), - fQ(0), fConstructMethod(0), fPDG(0), fDaughtersIds() -{ + KFParticleBase::KFParticleBase() : fChi2(0), fSFromDecay(0), SumDaughterMass(0), fMassHypo(-1), fNDF(-3), fId(-1), fParentID(0), fIdTruth(0), fQuality(0), fIdParentMcVx(0), fAtProductionVertex(0), fQ(0), fConstructMethod(0), fPDG(0), fDaughtersIds() +{ static Bool_t first = kTRUE; if (first) { first = kFALSE; KFParticleBase::Class()->IgnoreTObjectStreamer(); } - //* Constructor + //* Constructor Clear(); } -void KFParticleBase::Clear(Option_t *option) { +void KFParticleBase::Clear(Option_t* option) +{ Initialize(); fIdTruth = 0; fQuality = 0; @@ -55,45 +53,63 @@ void KFParticleBase::Clear(Option_t *option) { fParentID = 0; } -void KFParticleBase::Print(Option_t *opt) const { +void KFParticleBase::Print(Option_t* opt) const +{ std::cout << *this << std::endl; if (opt && (opt[0] == 'a' || opt[0] == 'A')) { - TRVector P(8,fP); std::cout << "par. " << P << std::endl; - TRSymMatrix C(8,fC); std::cout << "cov. " << C << std::endl; - + TRVector P(8, fP); + std::cout << "par. " << P << std::endl; + TRSymMatrix C(8, fC); + std::cout << "cov. " << C << std::endl; } } -std::ostream& operator<<(std::ostream& os, const KFParticleBase& particle) { - static const Char_t *vn[14] = {"x","y","z","px","py","pz","E","S","M","t","p","Q","Chi2","NDF"}; - os << Form("p(%4i,%4i,%4i)",particle.Id(),particle.GetParentID(),particle.IdParentMcVx()); +std::ostream& operator<<(std::ostream& os, const KFParticleBase& particle) +{ + static const Char_t* vn[14] = {"x", "y", "z", "px", "py", "pz", "E", "S", "M", "t", "p", "Q", "Chi2", "NDF"}; + os << Form("p(%4i,%4i,%4i)", particle.Id(), particle.GetParentID(), particle.IdParentMcVx()); for (Int_t i = 0; i < 8; i++) { - if (i == 6) continue; // E - if (i == 7 && particle.GetParameter(i) <= 0.0) continue; // S - if (particle.GetParameter(i) == 0. && particle.GetCovariance(i,i) == 0) continue; - if (particle.GetCovariance(i,i) > 0) - os << Form(" %s:%8.3f+/-%6.3f", vn[i], particle.GetParameter(i), TMath::Sqrt(particle.GetCovariance(i,i))); - else + if (i == 6) + continue; // E + if (i == 7 && particle.GetParameter(i) <= 0.0) + continue; // S + if (particle.GetParameter(i) == 0. && particle.GetCovariance(i, i) == 0) + continue; + if (particle.GetCovariance(i, i) > 0) + os << Form(" %s:%8.3f+/-%6.3f", vn[i], particle.GetParameter(i), TMath::Sqrt(particle.GetCovariance(i, i))); + else os << Form(" %s:%8.3f", vn[i], particle.GetParameter(i)); } float Mtp[3] = {0.f, 0.f, 0.f}, MtpErr[3] = {0.f, 0.f, 0.f}; - particle.GetMass(Mtp[0], MtpErr[0]); if (MtpErr[0] < 1e-7 || MtpErr[0] > 1e10) MtpErr[0] = -13; - particle.GetLifeTime(Mtp[1], MtpErr[1]); if (MtpErr[1] <= 0 || MtpErr[1] > 1e10) MtpErr[1] = -13; - particle.GetMomentum(Mtp[2], MtpErr[2]); if (MtpErr[2] <= 0 || MtpErr[2] > 1e10) MtpErr[2] = -13; + particle.GetMass(Mtp[0], MtpErr[0]); + if (MtpErr[0] < 1e-7 || MtpErr[0] > 1e10) + MtpErr[0] = -13; + particle.GetLifeTime(Mtp[1], MtpErr[1]); + if (MtpErr[1] <= 0 || MtpErr[1] > 1e10) + MtpErr[1] = -13; + particle.GetMomentum(Mtp[2], MtpErr[2]); + if (MtpErr[2] <= 0 || MtpErr[2] > 1e10) + MtpErr[2] = -13; for (Int_t i = 8; i < 11; i++) { - if (i == 9 && Mtp[i-8] <= 0.0) continue; // t - if (MtpErr[i-8] > 0 && MtpErr[i-8] < 9e2) os << Form(" %s:%8.3f+/-%7.3f", vn[i],Mtp[i-8],MtpErr[i-8]); - else os << Form(" %s:%8.3f", vn[i],Mtp[i-8]); + if (i == 9 && Mtp[i - 8] <= 0.0) + continue; // t + if (MtpErr[i - 8] > 0 && MtpErr[i - 8] < 9e2) + os << Form(" %s:%8.3f+/-%7.3f", vn[i], Mtp[i - 8], MtpErr[i - 8]); + else + os << Form(" %s:%8.3f", vn[i], Mtp[i - 8]); } - os << Form(" pdg:%5i Q:%2i chi2/NDF :%8.2f/%2i",particle.GetPDG(),particle.GetQ(),particle.GetChi2(),particle.GetNDF()); - if (particle.IdTruth()) os << Form(" IdT:%4i/%3i",particle.IdTruth(),particle.QaTruth()); + os << Form(" pdg:%5i Q:%2i chi2/NDF :%8.2f/%2i", particle.GetPDG(), particle.GetQ(), particle.GetChi2(), particle.GetNDF()); + if (particle.IdTruth()) + os << Form(" IdT:%4i/%3i", particle.IdTruth(), particle.QaTruth()); int nd = particle.NDaughters(); if (nd > 1) { os << " ND: " << nd << ":"; - if (nd > 3) nd = 3; + if (nd > 3) + nd = 3; for (int d = 0; d < nd; d++) { os << particle.DaughterIds()[d]; - if (d < nd-1) os << ","; + if (d < nd - 1) + os << ","; } } return os; @@ -101,9 +117,8 @@ std::ostream& operator<<(std::ostream& os, const KFParticleBase& particle) { #endif #ifndef __ROOT__ -KFParticleBase::KFParticleBase() : fChi2(0), fSFromDecay(0), - SumDaughterMass(0), fMassHypo(-1), fNDF(-3), fId(-1), fAtProductionVertex(0), fQ(0), fConstructMethod(0), fPDG(0), fDaughtersIds() -{ +KFParticleBase::KFParticleBase() : fChi2(0), fSFromDecay(0), SumDaughterMass(0), fMassHypo(-1), fNDF(-3), fId(-1), fAtProductionVertex(0), fQ(0), fConstructMethod(0), fPDG(0), fDaughtersIds() +{ /** The default constructor, initialises the parameters by: \n ** 1) all parameters are set to 0; \n ** 2) all elements of the covariance matrix are set to 0 except Cxx=Cyy=Czz=100; \n @@ -115,7 +130,7 @@ KFParticleBase::KFParticleBase() : fChi2(0), fSFromDecay(0), } #endif -void KFParticleBase::Initialize( const float Param[], const float Cov[], Int_t Charge, float Mass ) +void KFParticleBase::Initialize(const float Param[], const float Cov[], Int_t Charge, float Mass) { /** Sets the parameters of the particle: ** @@ -133,11 +148,12 @@ void KFParticleBase::Initialize( const float Param[], const float Cov[], Int_t C ** \param[in] mass - the mass hypothesis **/ + for (Int_t i = 0; i < 6; i++) + fP[i] = Param[i]; + for (Int_t i = 0; i < 21; i++) + fC[i] = Cov[i]; - for( Int_t i=0; i<6 ; i++ ) fP[i] = Param[i]; - for( Int_t i=0; i<21; i++ ) fC[i] = Cov[i]; - - float energy = sqrt( Mass*Mass + fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]); + float energy = sqrt(Mass * Mass + fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]); fP[6] = energy; fP[7] = 0; fQ = Charge; @@ -146,21 +162,21 @@ void KFParticleBase::Initialize( const float Param[], const float Cov[], Int_t C fAtProductionVertex = 0; fSFromDecay = 0; - float energyInv = 1./energy; - float - h0 = fP[3]*energyInv, - h1 = fP[4]*energyInv, - h2 = fP[5]*energyInv; - - fC[21] = h0*fC[ 6] + h1*fC[10] + h2*fC[15]; - fC[22] = h0*fC[ 7] + h1*fC[11] + h2*fC[16]; - fC[23] = h0*fC[ 8] + h1*fC[12] + h2*fC[17]; - fC[24] = h0*fC[ 9] + h1*fC[13] + h2*fC[18]; - fC[25] = h0*fC[13] + h1*fC[14] + h2*fC[19]; - fC[26] = h0*fC[18] + h1*fC[19] + h2*fC[20]; - fC[27] = ( h0*h0*fC[ 9] + h1*h1*fC[14] + h2*h2*fC[20] - + 2*(h0*h1*fC[13] + h0*h2*fC[18] + h1*h2*fC[19] ) ); - for( Int_t i=28; i<36; i++ ) fC[i] = 0; + float energyInv = 1. / energy; + float + h0 = fP[3] * energyInv, + h1 = fP[4] * energyInv, + h2 = fP[5] * energyInv; + + fC[21] = h0 * fC[6] + h1 * fC[10] + h2 * fC[15]; + fC[22] = h0 * fC[7] + h1 * fC[11] + h2 * fC[16]; + fC[23] = h0 * fC[8] + h1 * fC[12] + h2 * fC[17]; + fC[24] = h0 * fC[9] + h1 * fC[13] + h2 * fC[18]; + fC[25] = h0 * fC[13] + h1 * fC[14] + h2 * fC[19]; + fC[26] = h0 * fC[18] + h1 * fC[19] + h2 * fC[20]; + fC[27] = (h0 * h0 * fC[9] + h1 * h1 * fC[14] + h2 * h2 * fC[20] + 2 * (h0 * h1 * fC[13] + h0 * h2 * fC[18] + h1 * h2 * fC[19])); + for (Int_t i = 28; i < 36; i++) + fC[i] = 0; fC[35] = 1.; SumDaughterMass = Mass; @@ -177,12 +193,14 @@ void KFParticleBase::Initialize() ** 5) NDF = -3, since 3 parameters should be fitted: X, Y, Z. **/ - for( Int_t i=0; i<8; i++) fP[i] = 0; - for(Int_t i=0;i<36;++i) fC[i]=0.; + for (Int_t i = 0; i < 8; i++) + fP[i] = 0; + for (Int_t i = 0; i < 36; ++i) + fC[i] = 0.; fC[0] = fC[2] = fC[5] = 100.; fC[35] = 1.; - fNDF = -3; - fChi2 = 0.; + fNDF = -3; + fChi2 = 0.; fQ = 0; fSFromDecay = 0; fAtProductionVertex = 0; @@ -190,7 +208,7 @@ void KFParticleBase::Initialize() fMassHypo = -1; } -Int_t KFParticleBase::GetMomentum( float &p, float &error ) const +Int_t KFParticleBase::GetMomentum(float& p, float& error) const { /** Calculates particle momentum and its error. If they are well defined returns 0, otherwise 1. ** \param[out] p - momentum of the particle @@ -200,70 +218,71 @@ Int_t KFParticleBase::GetMomentum( float &p, float &error ) const float x = fP[3]; float y = fP[4]; float z = fP[5]; - float x2 = x*x; - float y2 = y*y; - float z2 = z*z; - float p2 = x2+y2+z2; + float x2 = x * x; + float y2 = y * y; + float z2 = z * z; + float p2 = x2 + y2 + z2; p = sqrt(p2); - error = (x2*fC[9]+y2*fC[14]+z2*fC[20] + 2*(x*y*fC[13]+x*z*fC[18]+y*z*fC[19]) ); - if( error>1.e-16 && p>1.e-4 ){ - error = sqrt(error)/p; + error = (x2 * fC[9] + y2 * fC[14] + z2 * fC[20] + 2 * (x * y * fC[13] + x * z * fC[18] + y * z * fC[19])); + if (error > 1.e-16 && p > 1.e-4) { + error = sqrt(error) / p; return 0; } error = 1.e8; return 1; } -Int_t KFParticleBase::GetPt( float &pt, float &error ) const +Int_t KFParticleBase::GetPt(float& pt, float& error) const { /** Calculates particle transverse momentum and its error. If they are well defined returns 0, otherwise 1. ** \param[out] pt - transverse momentum of the particle ** \param[out] error - its error **/ - + float px = fP[3]; float py = fP[4]; - float px2 = px*px; - float py2 = py*py; - float pt2 = px2+py2; + float px2 = px * px; + float py2 = py * py; + float pt2 = px2 + py2; pt = sqrt(pt2); - error = (px2*fC[9] + py2*fC[14] + 2*px*py*fC[13] ); - if( error>0 && pt>1.e-4 ){ - error = sqrt(error)/pt; + error = (px2 * fC[9] + py2 * fC[14] + 2 * px * py * fC[13]); + if (error > 0 && pt > 1.e-4) { + error = sqrt(error) / pt; return 0; } error = 1.e10; return 1; } -Int_t KFParticleBase::GetEta( float &eta, float &error ) const +Int_t KFParticleBase::GetEta(float& eta, float& error) const { /** Calculates particle pseudorapidity and its error. If they are well defined returns 0, otherwise 1. ** \param[out] eta - pseudorapidity of the particle ** \param[out] error - its error **/ - + float px = fP[3]; float py = fP[4]; float pz = fP[5]; - float pt2 = px*px + py*py; - float p2 = pt2 + pz*pz; + float pt2 = px * px + py * py; + float p2 = pt2 + pz * pz; float p = sqrt(p2); float a = p + pz; float b = p - pz; eta = 1.e10; - if( b > 1.e-8 ){ - float c = a/b; - if( c>1.e-8 ) eta = 0.5*log(c); - } - float h3 = -px*pz; - float h4 = -py*pz; - float pt4 = pt2*pt2; - float p2pt4 = p2*pt4; - error = (h3*h3*fC[9] + h4*h4*fC[14] + pt4*fC[20] + 2*( h3*(h4*fC[13] + fC[18]*pt2) + pt2*h4*fC[19] ) ); - - if( error>0 && p2pt4>1.e-10 ){ - error = sqrt(error/p2pt4); + if (b > 1.e-8) { + float c = a / b; + if (c > 1.e-8) + eta = 0.5 * log(c); + } + float h3 = -px * pz; + float h4 = -py * pz; + float pt4 = pt2 * pt2; + float p2pt4 = p2 * pt4; + error = (h3 * h3 * fC[9] + h4 * h4 * fC[14] + pt4 * fC[20] + 2 * (h3 * (h4 * fC[13] + fC[18] * pt2) + pt2 * h4 * fC[19])); + + if (error > 0 && p2pt4 > 1.e-10) { + error = sqrt(error / p2pt4); return 0; } @@ -271,81 +290,75 @@ Int_t KFParticleBase::GetEta( float &eta, float &error ) const return 1; } -Int_t KFParticleBase::GetPhi( float &phi, float &error ) const +Int_t KFParticleBase::GetPhi(float& phi, float& error) const { /** Calculates particle polar angle at the current point and its error. If they are well defined returns 0, otherwise 1. ** \param[out] phi - polar angle of the particle ** \param[out] error - its error **/ - + float px = fP[3]; float py = fP[4]; - float px2 = px*px; - float py2 = py*py; + float px2 = px * px; + float py2 = py * py; float pt2 = px2 + py2; - phi = atan2(py,px); - error = (py2*fC[9] + px2*fC[14] - 2*px*py*fC[13] ); - if( error>0 && pt2>1.e-4 ){ - error = sqrt(error)/pt2; + phi = atan2(py, px); + error = (py2 * fC[9] + px2 * fC[14] - 2 * px * py * fC[13]); + if (error > 0 && pt2 > 1.e-4) { + error = sqrt(error) / pt2; return 0; } error = 1.e10; return 1; } -Int_t KFParticleBase::GetR( float &r, float &error ) const +Int_t KFParticleBase::GetR(float& r, float& error) const { /** Calculates the distance to the point {0,0,0} and its error. If they are well defined returns 0, otherwise 1. ** \param[out] r - polar angle of the particle ** \param[out] error - its error **/ - + float x = fP[0]; float y = fP[1]; - float x2 = x*x; - float y2 = y*y; + float x2 = x * x; + float y2 = y * y; r = sqrt(x2 + y2); - error = (x2*fC[0] + y2*fC[2] - 2*x*y*fC[1] ); - if( error>0 && r>1.e-4 ){ - error = sqrt(error)/r; + error = (x2 * fC[0] + y2 * fC[2] - 2 * x * y * fC[1]); + if (error > 0 && r > 1.e-4) { + error = sqrt(error) / r; return 0; } error = 1.e10; return 1; } -Int_t KFParticleBase::GetMass( float &m, float &error ) const +Int_t KFParticleBase::GetMass(float& m, float& error) const { /** Calculates the mass of the particle and its error. If they are well defined returns 0, otherwise 1. ** \param[out] m - mass of the particle ** \param[out] error - its error **/ - + // s = sigma^2 of m2/2 - float s = ( fP[3]*fP[3]*fC[9] + fP[4]*fP[4]*fC[14] + fP[5]*fP[5]*fC[20] - + fP[6]*fP[6]*fC[27] - + 2*( + fP[3]*fP[4]*fC[13] + fP[5]*(fP[3]*fC[18] + fP[4]*fC[19]) - - fP[6]*( fP[3]*fC[24] + fP[4]*fC[25] + fP[5]*fC[26] ) ) - ); + float s = (fP[3] * fP[3] * fC[9] + fP[4] * fP[4] * fC[14] + fP[5] * fP[5] * fC[20] + fP[6] * fP[6] * fC[27] + 2 * (+fP[3] * fP[4] * fC[13] + fP[5] * (fP[3] * fC[18] + fP[4] * fC[19]) - fP[6] * (fP[3] * fC[24] + fP[4] * fC[25] + fP[5] * fC[26]))); - float m2 = (fP[6]*fP[6] - fP[3]*fP[3] - fP[4]*fP[4] - fP[5]*fP[5]); + float m2 = (fP[6] * fP[6] - fP[3] * fP[3] - fP[4] * fP[4] - fP[5] * fP[5]); - if(m2<0.) - { + if (m2 < 0.) { error = 1.e3; m = -sqrt(-m2); return 1; } - m = sqrt(m2); - if( m>1.e-6 ){ - if( s >= 0 ) { - error = sqrt(s)/m; + m = sqrt(m2); + if (m > 1.e-6) { + if (s >= 0) { + error = sqrt(s) / m; return 0; } - } - else { + } else { error = 0.; return 0; } @@ -354,28 +367,25 @@ Int_t KFParticleBase::GetMass( float &m, float &error ) const return 1; } - -Int_t KFParticleBase::GetDecayLength( float &l, float &error ) const +Int_t KFParticleBase::GetDecayLength(float& l, float& error) const { /** Calculates the decay length of the particle in the laboratory system and its error. If they are well defined returns 0, otherwise 1. ** The production point should be set before calling this function. ** \param[out] l - the decay length ** \param[out] error - its error **/ - + float x = fP[3]; float y = fP[4]; float z = fP[5]; float t = fP[7]; - float x2 = x*x; - float y2 = y*y; - float z2 = z*z; - float p2 = x2+y2+z2; - l = t*sqrt(p2); - if( p2>1.e-4){ - error = p2*fC[35] + t*t/p2*(x2*fC[9]+y2*fC[14]+z2*fC[20] - + 2*(x*y*fC[13]+x*z*fC[18]+y*z*fC[19]) ) - + 2*t*(x*fC[31]+y*fC[32]+z*fC[33]); + float x2 = x * x; + float y2 = y * y; + float z2 = z * z; + float p2 = x2 + y2 + z2; + l = t * sqrt(p2); + if (p2 > 1.e-4) { + error = p2 * fC[35] + t * t / p2 * (x2 * fC[9] + y2 * fC[14] + z2 * fC[20] + 2 * (x * y * fC[13] + x * z * fC[18] + y * z * fC[19])) + 2 * t * (x * fC[31] + y * fC[32] + z * fC[33]); error = sqrt(fabs(error)); return 0; } @@ -383,7 +393,7 @@ Int_t KFParticleBase::GetDecayLength( float &l, float &error ) const return 1; } -Int_t KFParticleBase::GetDecayLengthXY( float &l, float &error ) const +Int_t KFParticleBase::GetDecayLengthXY(float& l, float& error) const { /** Calculates the projection in the XY plane of the decay length of the particle in the laboratory ** system and its error. If they are well defined returns 0, otherwise 1. @@ -391,17 +401,16 @@ Int_t KFParticleBase::GetDecayLengthXY( float &l, float &error ) const ** \param[out] l - the decay length ** \param[out] error - its error **/ - + float x = fP[3]; float y = fP[4]; float t = fP[7]; - float x2 = x*x; - float y2 = y*y; - float pt2 = x2+y2; - l = t*sqrt(pt2); - if( pt2>1.e-4){ - error = pt2*fC[35] + t*t/pt2*(x2*fC[9]+y2*fC[14] + 2*x*y*fC[13] ) - + 2*t*(x*fC[31]+y*fC[32]); + float x2 = x * x; + float y2 = y * y; + float pt2 = x2 + y2; + l = t * sqrt(pt2); + if (pt2 > 1.e-4) { + error = pt2 * fC[35] + t * t / pt2 * (x2 * fC[9] + y2 * fC[14] + 2 * x * y * fC[13]) + 2 * t * (x * fC[31] + y * fC[32]); error = sqrt(fabs(error)); return 0; } @@ -409,8 +418,7 @@ Int_t KFParticleBase::GetDecayLengthXY( float &l, float &error ) const return 1; } - -Int_t KFParticleBase::GetLifeTime( float &ctau, float &error ) const +Int_t KFParticleBase::GetLifeTime(float& ctau, float& error) const { /** Calculates the lifetime times speed of life (ctau) [cm] of the particle in the ** center of mass frame and its error. If they are well defined returns 0, otherwise 1. @@ -418,31 +426,30 @@ Int_t KFParticleBase::GetLifeTime( float &ctau, float &error ) const ** \param[out] ctau - lifetime of the particle [cm] ** \param[out] error - its error **/ - + float m, dm; - GetMass( m, dm ); - float cTM = (-fP[3]*fC[31] - fP[4]*fC[32] - fP[5]*fC[33] + fP[6]*fC[34]); - ctau = fP[7]*m; - error = m*m*fC[35] + 2*fP[7]*cTM + fP[7]*fP[7]*dm*dm; - if( error > 0 ){ - error = sqrt( error ); + GetMass(m, dm); + float cTM = (-fP[3] * fC[31] - fP[4] * fC[32] - fP[5] * fC[33] + fP[6] * fC[34]); + ctau = fP[7] * m; + error = m * m * fC[35] + 2 * fP[7] * cTM + fP[7] * fP[7] * dm * dm; + if (error > 0) { + error = sqrt(error); return 0; } error = 1.e20; return 1; } - -void KFParticleBase::operator +=( const KFParticleBase &Daughter ) +void KFParticleBase::operator+=(const KFParticleBase& Daughter) { /** Operator to add daughter to the current particle. Calls AddDaughter() function. ** \param[in] Daughter - the daughter particle **/ - - AddDaughter( Daughter ); + + AddDaughter(Daughter); } -bool KFParticleBase::GetMeasurement( const KFParticleBase& daughter, float m[], float V[], float D[3][3] ) +bool KFParticleBase::GetMeasurement(const KFParticleBase& daughter, float m[], float V[], float D[3][3]) { /** Obtains the measurements from the current particle and the daughter to be added for the Kalman filter ** mathematics. If these are two first daughters they are transported to the point of the closest approach, @@ -456,164 +463,144 @@ bool KFParticleBase::GetMeasurement( const KFParticleBase& daughter, float m[], ** \param[out] V[36] - the output covariance matrix of the daughter parameters, takes into account the correlation ** \param[out] D[3][3] - the correlation matrix between the current and daughter particles **/ - - if(fNDF == -1) - { - float ds[2] = {0.f,0.f}; + + if (fNDF == -1) { + float ds[2] = {0.f, 0.f}; float dsdr[4][6]; float F1[36], F2[36], F3[36], F4[36]; - for(int i1=0; i1<36; i1++) - { + for (int i1 = 0; i1 < 36; i1++) { F1[i1] = 0; F2[i1] = 0; F3[i1] = 0; F4[i1] = 0; } - GetDStoParticle( daughter, ds, dsdr ); - - if( fabs(ds[0]*fP[5]) > 1000.f || fabs(ds[1]*daughter.fP[5]) > 1000.f) + GetDStoParticle(daughter, ds, dsdr); + + if (fabs(ds[0] * fP[5]) > 1000.f || fabs(ds[1] * daughter.fP[5]) > 1000.f) return 0; float V0Tmp[36] = {0.}; float V1Tmp[36] = {0.}; float C[36]; - for(int iC=0; iC<36; iC++) + for (int iC = 0; iC < 36; iC++) C[iC] = fC[iC]; - - Transport(ds[0], dsdr[0], fP, fC, dsdr[1], F1, F2); - daughter.Transport(ds[1], dsdr[3], m, V, dsdr[2], F4, F3); - + + Transport(ds[0], dsdr[0], fP, fC, dsdr[1], F1, F2); + daughter.Transport(ds[1], dsdr[3], m, V, dsdr[2], F4, F3); + MultQSQt(F2, daughter.fC, V0Tmp, 6); MultQSQt(F3, C, V1Tmp, 6); - - for(int iC=0; iC<21; iC++) - { + + for (int iC = 0; iC < 21; iC++) { fC[iC] += V0Tmp[iC]; - V[iC] += V1Tmp[iC]; + V[iC] += V1Tmp[iC]; } - + float C1F1T[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { C1F1T[i][j] = 0; - for(int k=0; k<6; k++) - { - C1F1T[i][j] += C[IJ(i,k)] * F1[j*6+k]; + for (int k = 0; k < 6; k++) { + C1F1T[i][j] += C[IJ(i, k)] * F1[j * 6 + k]; } } float F3C1F1T[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { F3C1F1T[i][j] = 0; - for(int k=0; k<6; k++) - { - F3C1F1T[i][j] += F3[i*6+k] * C1F1T[k][j]; + for (int k = 0; k < 6; k++) { + F3C1F1T[i][j] += F3[i * 6 + k] * C1F1T[k][j]; } } float C2F2T[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { C2F2T[i][j] = 0; - for(int k=0; k<6; k++) - { - C2F2T[i][j] += daughter.fC[IJ(i,k)] * F2[j*6+k]; + for (int k = 0; k < 6; k++) { + C2F2T[i][j] += daughter.fC[IJ(i, k)] * F2[j * 6 + k]; } } - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { D[i][j] = F3C1F1T[i][j]; - for(int k=0; k<6; k++) - { - D[i][j] += F4[i*6+k] * C2F2T[k][j]; + for (int k = 0; k < 6; k++) { + D[i][j] += F4[i * 6 + k] * C2F2T[k][j]; } - } - } - else - { + } + } else { float dsdr[6]; float dS = daughter.GetDStoPoint(fP, dsdr); - + float dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0, 0, 0}; - + float F[36], F1[36]; - for(int i2=0; i2<36; i2++) - { - F[i2] = 0; + for (int i2 = 0; i2 < 36; i2++) { + F[i2] = 0; F1[i2] = 0; } daughter.Transport(dS, dsdr, m, V, dsdp, F, F1); - -// float V1Tmp[36] = {0.}; -// MultQSQt(F1, fC, V1Tmp, 6); - -// for(int iC=0; iC<21; iC++) -// V[iC] += V1Tmp[iC]; - + + // float V1Tmp[36] = {0.}; + // MultQSQt(F1, fC, V1Tmp, 6); + + // for(int iC=0; iC<21; iC++) + // V[iC] += V1Tmp[iC]; + float VFT[3][6]; - for(int i=0; i<3; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 6; j++) { VFT[i][j] = 0; - for(int k=0; k<3; k++) - { - VFT[i][j] += fC[IJ(i,k)] * F1[j*6+k]; + for (int k = 0; k < 3; k++) { + VFT[i][j] += fC[IJ(i, k)] * F1[j * 6 + k]; } } - + float FVFT[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { FVFT[i][j] = 0; - for(int k=0; k<3; k++) - { - FVFT[i][j] += F1[i*6+k] * VFT[k][j]; + for (int k = 0; k < 3; k++) { + FVFT[i][j] += F1[i * 6 + k] * VFT[k][j]; } } - - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { D[i][j] = 0; - for(int k=0; k<3; k++) - { - D[i][j] += fC[IJ(j,k)] * F1[i*6+k]; + for (int k = 0; k < 3; k++) { + D[i][j] += fC[IJ(j, k)] * F1[i * 6 + k]; } } - + V[0] += FVFT[0][0]; V[1] += FVFT[1][0]; V[2] += FVFT[1][1]; V[3] += FVFT[2][0]; V[4] += FVFT[2][1]; V[5] += FVFT[2][2]; - -// if(fNDF > 100) -// { -// float dx = fP[0] - m[0]; -// float dy = fP[1] - m[1]; -// float dz = fP[2] - m[2]; -// float sigmaS = 3.f*sqrt( (dx*dx + dy*dy + dz*dz) / (m[3]*m[3] + m[4]*m[4] + m[5]*m[5]) ); -// -// float h[3] = { m[3]*sigmaS, m[4]*sigmaS, m[5]*sigmaS }; -// V[0]+= h[0]*h[0]; -// V[1]+= h[1]*h[0]; -// V[2]+= h[1]*h[1]; -// V[3]+= h[2]*h[0]; -// V[4]+= h[2]*h[1]; -// V[5]+= h[2]*h[2]; -// } - } - + + // if(fNDF > 100) + // { + // float dx = fP[0] - m[0]; + // float dy = fP[1] - m[1]; + // float dz = fP[2] - m[2]; + // float sigmaS = 3.f*sqrt( (dx*dx + dy*dy + dz*dz) / (m[3]*m[3] + m[4]*m[4] + m[5]*m[5]) ); + // + // float h[3] = { m[3]*sigmaS, m[4]*sigmaS, m[5]*sigmaS }; + // V[0]+= h[0]*h[0]; + // V[1]+= h[1]*h[0]; + // V[2]+= h[1]*h[1]; + // V[3]+= h[2]*h[0]; + // V[4]+= h[2]*h[1]; + // V[5]+= h[2]*h[2]; + // } + } + return 1; } -void KFParticleBase::AddDaughter( const KFParticleBase &Daughter ) +void KFParticleBase::AddDaughter(const KFParticleBase& Daughter) { /** Adds daughter to the current particle. Depending on the selected construction method uses: \n ** 1) Either simplifyed fast mathematics which consideres momentum and energy as @@ -627,28 +614,30 @@ void KFParticleBase::AddDaughter( const KFParticleBase &Daughter ) ** AddDaughterWithEnergyFitMC() function. ** \param[in] Daughter - the daughter particle **/ - - if( fNDF<-1 ){ // first daughter -> just copy - fNDF = -1; - fQ = Daughter.GetQ(); - for( Int_t i=0; i<7; i++) fP[i] = Daughter.fP[i]; - for( Int_t i=0; i<28; i++) fC[i] = Daughter.fC[i]; + + if (fNDF < -1) { // first daughter -> just copy + fNDF = -1; + fQ = Daughter.GetQ(); + for (Int_t i = 0; i < 7; i++) + fP[i] = Daughter.fP[i]; + for (Int_t i = 0; i < 28; i++) + fC[i] = Daughter.fC[i]; fSFromDecay = 0; fMassHypo = Daughter.fMassHypo; SumDaughterMass = Daughter.SumDaughterMass; return; } - if(static_cast(fConstructMethod) == 0) + if (static_cast(fConstructMethod) == 0) AddDaughterWithEnergyFit(Daughter); - else if(static_cast(fConstructMethod) == 2) + else if (static_cast(fConstructMethod) == 2) AddDaughterWithEnergyFitMC(Daughter); SumDaughterMass += Daughter.SumDaughterMass; fMassHypo = -1; } -void KFParticleBase::AddDaughterWithEnergyFit( const KFParticleBase &Daughter ) +void KFParticleBase::AddDaughterWithEnergyFit(const KFParticleBase& Daughter) { /** Adds daughter to the current particle. Uses simplifyed fast mathematics which consideres momentum ** and energy as independent variables and thus ignores constraint on the fixed mass. @@ -660,68 +649,80 @@ void KFParticleBase::AddDaughterWithEnergyFit( const KFParticleBase &Daughter ) Int_t maxIter = 1; - for( Int_t iter=0; iter 1e9) + return; + // if(fNDF > 100 && dChi2 > 9) return; - float dChi2 = (mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0] - + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1] - + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2]; - if (dChi2 > 1e9) return; -// if(fNDF > 100 && dChi2 > 9) return; - float K[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { K[i][j] = 0; - for(int k=0; k<3; k++) - K[i][j] += fC[IJ(i,k)] * mS[IJ(k,j)]; + for (int k = 0; k < 3; k++) + K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; } - + //* CHt = CH' - D' float mCHt0[7], mCHt1[7], mCHt2[7]; - mCHt0[0]=fC[ 0] ; mCHt1[0]=fC[ 1] ; mCHt2[0]=fC[ 3] ; - mCHt0[1]=fC[ 1] ; mCHt1[1]=fC[ 2] ; mCHt2[1]=fC[ 4] ; - mCHt0[2]=fC[ 3] ; mCHt1[2]=fC[ 4] ; mCHt2[2]=fC[ 5] ; - mCHt0[3]=fC[ 6]-mV[ 6]; mCHt1[3]=fC[ 7]-mV[ 7]; mCHt2[3]=fC[ 8]-mV[ 8]; - mCHt0[4]=fC[10]-mV[10]; mCHt1[4]=fC[11]-mV[11]; mCHt2[4]=fC[12]-mV[12]; - mCHt0[5]=fC[15]-mV[15]; mCHt1[5]=fC[16]-mV[16]; mCHt2[5]=fC[17]-mV[17]; - mCHt0[6]=fC[21]-mV[21]; mCHt1[6]=fC[22]-mV[22]; mCHt2[6]=fC[23]-mV[23]; - + mCHt0[0] = fC[0]; + mCHt1[0] = fC[1]; + mCHt2[0] = fC[3]; + mCHt0[1] = fC[1]; + mCHt1[1] = fC[2]; + mCHt2[1] = fC[4]; + mCHt0[2] = fC[3]; + mCHt1[2] = fC[4]; + mCHt2[2] = fC[5]; + mCHt0[3] = fC[6] - mV[6]; + mCHt1[3] = fC[7] - mV[7]; + mCHt2[3] = fC[8] - mV[8]; + mCHt0[4] = fC[10] - mV[10]; + mCHt1[4] = fC[11] - mV[11]; + mCHt2[4] = fC[12] - mV[12]; + mCHt0[5] = fC[15] - mV[15]; + mCHt1[5] = fC[16] - mV[16]; + mCHt2[5] = fC[17] - mV[17]; + mCHt0[6] = fC[21] - mV[21]; + mCHt1[6] = fC[22] - mV[22]; + mCHt2[6] = fC[23] - mV[23]; + //* Kalman gain K = mCH'*S - + float k0[7], k1[7], k2[7]; - - for(Int_t i=0;i<7;++i){ - k0[i] = mCHt0[i]*mS[0] + mCHt1[i]*mS[1] + mCHt2[i]*mS[3]; - k1[i] = mCHt0[i]*mS[1] + mCHt1[i]*mS[2] + mCHt2[i]*mS[4]; - k2[i] = mCHt0[i]*mS[3] + mCHt1[i]*mS[4] + mCHt2[i]*mS[5]; + + for (Int_t i = 0; i < 7; ++i) { + k0[i] = mCHt0[i] * mS[0] + mCHt1[i] * mS[1] + mCHt2[i] * mS[3]; + k1[i] = mCHt0[i] * mS[1] + mCHt1[i] * mS[2] + mCHt2[i] * mS[4]; + k2[i] = mCHt0[i] * mS[3] + mCHt1[i] * mS[4] + mCHt2[i] * mS[5]; } //* Add the daughter momentum to the particle momentum - - fP[ 3] += m[ 3]; - fP[ 4] += m[ 4]; - fP[ 5] += m[ 5]; - fP[ 6] += m[ 6]; - - fC[ 9] += mV[ 9]; + + fP[3] += m[3]; + fP[4] += m[4]; + fP[5] += m[5]; + fP[6] += m[6]; + + fC[9] += mV[9]; fC[13] += mV[13]; fC[14] += mV[14]; fC[18] += mV[18]; @@ -731,69 +732,62 @@ void KFParticleBase::AddDaughterWithEnergyFit( const KFParticleBase &Daughter ) fC[25] += mV[25]; fC[26] += mV[26]; fC[27] += mV[27]; - - - //* New estimation of the vertex position r += K*zeta - - for(Int_t i=0;i<7;++i) - fP[i] = fP[i] + k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]; - + + //* New estimation of the vertex position r += K*zeta + + for (Int_t i = 0; i < 7; ++i) + fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + //* New covariance matrix C -= K*(mCH')' - for(Int_t i=0, k=0;i<7;++i){ - for(Int_t j=0;j<=i;++j,++k){ - fC[k] = fC[k] - (k0[i]*mCHt0[j] + k1[i]*mCHt1[j] + k2[i]*mCHt2[j] ); + for (Int_t i = 0, k = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) { + fC[k] = fC[k] - (k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]); } } float K2[3][3]; - for(int i=0; i<3; i++) - { - for(int j=0; j<3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) K2[i][j] = -K[j][i]; K2[i][i] += 1; } float A[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { A[i][j] = 0; - for(int k=0; k<3; k++) - { + for (int k = 0; k < 3; k++) { A[i][j] += D[i][k] * K2[k][j]; } } - + double M[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { M[i][j] = 0; - for(int k=0; k<3; k++) - { + for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } - fC[0] += 2*M[0][0]; + fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; - fC[2] += 2*M[1][1]; + fC[2] += 2 * M[1][1]; fC[3] += M[0][2] + M[2][0]; fC[4] += M[1][2] + M[2][1]; - fC[5] += 2*M[2][2]; - - //* Calculate Chi^2 + fC[5] += 2 * M[2][2]; - fNDF += 2; - fQ += Daughter.GetQ(); - fSFromDecay = 0; - fChi2 += dChi2; + //* Calculate Chi^2 + fNDF += 2; + fQ += Daughter.GetQ(); + fSFromDecay = 0; + fChi2 += dChi2; } } -void KFParticleBase::SubtractDaughter( const KFParticleBase &Daughter ) +void KFParticleBase::SubtractDaughter(const KFParticleBase& Daughter) { /** Subtracts a daughter particle from the mother particle. The mathematics is ** similar to AddDaughterWithEnergyFit() but momentum is subtracted. @@ -803,61 +797,72 @@ void KFParticleBase::SubtractDaughter( const KFParticleBase &Daughter ) float m[8], mV[36]; float D[3][3]; - if(! GetMeasurement(Daughter, m, mV, D) ) + if (!GetMeasurement(Daughter, m, mV, D)) return; - - float mS[6]= { fC[0]+mV[0], - fC[1]+mV[1], fC[2]+mV[2], - fC[3]+mV[3], fC[4]+mV[4], fC[5]+mV[5] }; - + + float mS[6] = {fC[0] + mV[0], + fC[1] + mV[1], fC[2] + mV[2], + fC[3] + mV[3], fC[4] + mV[4], fC[5] + mV[5]}; + InvertCholetsky3(mS); //* Residual (measured - estimated) - float zeta[3] = { m[0]-fP[0], m[1]-fP[1], m[2]-fP[2] }; + float zeta[3] = {m[0] - fP[0], m[1] - fP[1], m[2] - fP[2]}; + + float dChi2 = (mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]; - float dChi2 = (mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0] - + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1] - + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2]; - float K[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { K[i][j] = 0; - for(int k=0; k<3; k++) - K[i][j] += fC[IJ(i,k)] * mS[IJ(k,j)]; + for (int k = 0; k < 3; k++) + K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; } - + //* CHt = CH' - D' float mCHt0[7], mCHt1[7], mCHt2[7]; - mCHt0[0]=fC[ 0] ; mCHt1[0]=fC[ 1] ; mCHt2[0]=fC[ 3] ; - mCHt0[1]=fC[ 1] ; mCHt1[1]=fC[ 2] ; mCHt2[1]=fC[ 4] ; - mCHt0[2]=fC[ 3] ; mCHt1[2]=fC[ 4] ; mCHt2[2]=fC[ 5] ; - mCHt0[3]=fC[ 6]+mV[ 6]; mCHt1[3]=fC[ 7]+mV[ 7]; mCHt2[3]=fC[ 8]+mV[ 8]; - mCHt0[4]=fC[10]+mV[10]; mCHt1[4]=fC[11]+mV[11]; mCHt2[4]=fC[12]+mV[12]; - mCHt0[5]=fC[15]+mV[15]; mCHt1[5]=fC[16]+mV[16]; mCHt2[5]=fC[17]+mV[17]; - mCHt0[6]=fC[21]+mV[21]; mCHt1[6]=fC[22]+mV[22]; mCHt2[6]=fC[23]+mV[23]; + mCHt0[0] = fC[0]; + mCHt1[0] = fC[1]; + mCHt2[0] = fC[3]; + mCHt0[1] = fC[1]; + mCHt1[1] = fC[2]; + mCHt2[1] = fC[4]; + mCHt0[2] = fC[3]; + mCHt1[2] = fC[4]; + mCHt2[2] = fC[5]; + mCHt0[3] = fC[6] + mV[6]; + mCHt1[3] = fC[7] + mV[7]; + mCHt2[3] = fC[8] + mV[8]; + mCHt0[4] = fC[10] + mV[10]; + mCHt1[4] = fC[11] + mV[11]; + mCHt2[4] = fC[12] + mV[12]; + mCHt0[5] = fC[15] + mV[15]; + mCHt1[5] = fC[16] + mV[16]; + mCHt2[5] = fC[17] + mV[17]; + mCHt0[6] = fC[21] + mV[21]; + mCHt1[6] = fC[22] + mV[22]; + mCHt2[6] = fC[23] + mV[23]; //* Kalman gain K = mCH'*S - + float k0[7], k1[7], k2[7]; - - for(Int_t i=0;i<7;++i){ - k0[i] = mCHt0[i]*mS[0] + mCHt1[i]*mS[1] + mCHt2[i]*mS[3]; - k1[i] = mCHt0[i]*mS[1] + mCHt1[i]*mS[2] + mCHt2[i]*mS[4]; - k2[i] = mCHt0[i]*mS[3] + mCHt1[i]*mS[4] + mCHt2[i]*mS[5]; + + for (Int_t i = 0; i < 7; ++i) { + k0[i] = mCHt0[i] * mS[0] + mCHt1[i] * mS[1] + mCHt2[i] * mS[3]; + k1[i] = mCHt0[i] * mS[1] + mCHt1[i] * mS[2] + mCHt2[i] * mS[4]; + k2[i] = mCHt0[i] * mS[3] + mCHt1[i] * mS[4] + mCHt2[i] * mS[5]; } //* Add the daughter momentum to the particle momentum - - fP[ 3] -= m[ 3]; - fP[ 4] -= m[ 4]; - fP[ 5] -= m[ 5]; - fP[ 6] -= m[ 6]; - fC[ 9] += mV[ 9]; + fP[3] -= m[3]; + fP[4] -= m[4]; + fP[5] -= m[5]; + fP[6] -= m[6]; + + fC[9] += mV[9]; fC[13] += mV[13]; fC[14] += mV[14]; fC[18] += mV[18]; @@ -867,68 +872,61 @@ void KFParticleBase::SubtractDaughter( const KFParticleBase &Daughter ) fC[25] += mV[25]; fC[26] += mV[26]; fC[27] += mV[27]; - //* New estimation of the vertex position r += K*zeta - - for(Int_t i=0;i<7;++i) - fP[i] = fP[i] + k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]; - + + for (Int_t i = 0; i < 7; ++i) + fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + //* New covariance matrix C -= K*(mCH')' - for(Int_t i=0, k=0;i<7;++i){ - for(Int_t j=0;j<=i;++j,++k){ - fC[k] = fC[k] - (k0[i]*mCHt0[j] + k1[i]*mCHt1[j] + k2[i]*mCHt2[j] ); + for (Int_t i = 0, k = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) { + fC[k] = fC[k] - (k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]); } } float K2[3][3]; - for(int i=0; i<3; i++) - { - for(int j=0; j<3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) K2[i][j] = -K[j][i]; K2[i][i] += 1; } float A[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { A[i][j] = 0; - for(int k=0; k<3; k++) - { - A[i][j] += D[i][k] * K2[k][j]; + for (int k = 0; k < 3; k++) { + A[i][j] += D[i][k] * K2[k][j]; } } - + double M[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { M[i][j] = 0; - for(int k=0; k<3; k++) - { - M[i][j] += K[i][k] * A[k][j]; + for (int k = 0; k < 3; k++) { + M[i][j] += K[i][k] * A[k][j]; } } - fC[0] += 2*M[0][0]; + fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; - fC[2] += 2*M[1][1]; + fC[2] += 2 * M[1][1]; fC[3] += M[0][2] + M[2][0]; fC[4] += M[1][2] + M[2][1]; - fC[5] += 2*M[2][2]; + fC[5] += 2 * M[2][2]; - //* Calculate Chi^2 + //* Calculate Chi^2 - fNDF += 2; - fQ += Daughter.GetQ(); - fSFromDecay = 0; - fChi2 += dChi2; + fNDF += 2; + fQ += Daughter.GetQ(); + fSFromDecay = 0; + fChi2 += dChi2; } - -void KFParticleBase::AddDaughterWithEnergyFitMC( const KFParticleBase &Daughter ) +void KFParticleBase::AddDaughterWithEnergyFitMC(const KFParticleBase& Daughter) { /** Adds daughter to the current particle. Uses slower but correct mathematics ** which requires that the masses of daughter particles @@ -938,156 +936,182 @@ void KFParticleBase::AddDaughterWithEnergyFitMC( const KFParticleBase &Daughter Int_t maxIter = 1; - for( Int_t iter=0; iter update the particle //* VHt = VH' - + float mVHt0[7], mVHt1[7], mVHt2[7]; - - mVHt0[0]=mV[ 0] ; mVHt1[0]=mV[ 1] ; mVHt2[0]=mV[ 3] ; - mVHt0[1]=mV[ 1] ; mVHt1[1]=mV[ 2] ; mVHt2[1]=mV[ 4] ; - mVHt0[2]=mV[ 3] ; mVHt1[2]=mV[ 4] ; mVHt2[2]=mV[ 5] ; - mVHt0[3]=mV[ 6] ; mVHt1[3]=mV[ 7] ; mVHt2[3]=mV[ 8] ; - mVHt0[4]=mV[10] ; mVHt1[4]=mV[11] ; mVHt2[4]=mV[12] ; - mVHt0[5]=mV[15] ; mVHt1[5]=mV[16] ; mVHt2[5]=mV[17] ; - mVHt0[6]=mV[21] ; mVHt1[6]=mV[22] ; mVHt2[6]=mV[23] ; - + + mVHt0[0] = mV[0]; + mVHt1[0] = mV[1]; + mVHt2[0] = mV[3]; + mVHt0[1] = mV[1]; + mVHt1[1] = mV[2]; + mVHt2[1] = mV[4]; + mVHt0[2] = mV[3]; + mVHt1[2] = mV[4]; + mVHt2[2] = mV[5]; + mVHt0[3] = mV[6]; + mVHt1[3] = mV[7]; + mVHt2[3] = mV[8]; + mVHt0[4] = mV[10]; + mVHt1[4] = mV[11]; + mVHt2[4] = mV[12]; + mVHt0[5] = mV[15]; + mVHt1[5] = mV[16]; + mVHt2[5] = mV[17]; + mVHt0[6] = mV[21]; + mVHt1[6] = mV[22]; + mVHt2[6] = mV[23]; + //* Kalman gain Km = mCH'*S - + float km0[7], km1[7], km2[7]; - - for(Int_t i=0;i<7;++i){ - km0[i] = mVHt0[i]*mS[0] + mVHt1[i]*mS[1] + mVHt2[i]*mS[3]; - km1[i] = mVHt0[i]*mS[1] + mVHt1[i]*mS[2] + mVHt2[i]*mS[4]; - km2[i] = mVHt0[i]*mS[3] + mVHt1[i]*mS[4] + mVHt2[i]*mS[5]; + + for (Int_t i = 0; i < 7; ++i) { + km0[i] = mVHt0[i] * mS[0] + mVHt1[i] * mS[1] + mVHt2[i] * mS[3]; + km1[i] = mVHt0[i] * mS[1] + mVHt1[i] * mS[2] + mVHt2[i] * mS[4]; + km2[i] = mVHt0[i] * mS[3] + mVHt1[i] * mS[4] + mVHt2[i] * mS[5]; } - for(Int_t i=0;i<7;++i) - fP[i] = fP[i] + k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]; + for (Int_t i = 0; i < 7; ++i) + fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; - for(Int_t i=0;i<7;++i) - m[i] = m[i] - km0[i]*zeta[0] - km1[i]*zeta[1] - km2[i]*zeta[2]; + for (Int_t i = 0; i < 7; ++i) + m[i] = m[i] - km0[i] * zeta[0] - km1[i] * zeta[1] - km2[i] * zeta[2]; - for(Int_t i=0, k=0;i<7;++i){ - for(Int_t j=0;j<=i;++j,++k){ - fC[k] = fC[k] - (k0[i]*mCHt0[j] + k1[i]*mCHt1[j] + k2[i]*mCHt2[j] ); + for (Int_t i = 0, k = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) { + fC[k] = fC[k] - (k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]); } } - for(Int_t i=0, k=0;i<7;++i){ - for(Int_t j=0;j<=i;++j,++k){ - mV[k] = mV[k] - (km0[i]*mVHt0[j] + km1[i]*mVHt1[j] + km2[i]*mVHt2[j] ); + for (Int_t i = 0, k = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) { + mV[k] = mV[k] - (km0[i] * mVHt0[j] + km1[i] * mVHt1[j] + km2[i] * mVHt2[j]); } } float mDf[7][7]; - for(Int_t i=0;i<7;++i){ - for(Int_t j=0;j<7;++j){ - mDf[i][j] = (km0[i]*mCHt0[j] + km1[i]*mCHt1[j] + km2[i]*mCHt2[j] ); + for (Int_t i = 0; i < 7; ++i) { + for (Int_t j = 0; j < 7; ++j) { + mDf[i][j] = (km0[i] * mCHt0[j] + km1[i] * mCHt1[j] + km2[i] * mCHt2[j]); } } float mJ1[7][7], mJ2[7][7]; - for(Int_t iPar1=0; iPar1<7; iPar1++) - { - for(Int_t iPar2=0; iPar2<7; iPar2++) - { + for (Int_t iPar1 = 0; iPar1 < 7; iPar1++) { + for (Int_t iPar2 = 0; iPar2 < 7; iPar2++) { mJ1[iPar1][iPar2] = 0; mJ2[iPar1][iPar2] = 0; } } - float mMassParticle = fP[6]*fP[6] - (fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]); - float mMassDaughter = m[6]*m[6] - (m[3]*m[3] + m[4]*m[4] + m[5]*m[5]); - if(mMassParticle > 0) mMassParticle = sqrt(mMassParticle); - if(mMassDaughter > 0) mMassDaughter = sqrt(mMassDaughter); + float mMassParticle = fP[6] * fP[6] - (fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]); + float mMassDaughter = m[6] * m[6] - (m[3] * m[3] + m[4] * m[4] + m[5] * m[5]); + if (mMassParticle > 0) + mMassParticle = sqrt(mMassParticle); + if (mMassDaughter > 0) + mMassDaughter = sqrt(mMassDaughter); - if( fMassHypo > -0.5) - SetMassConstraint(fP,fC,mJ1,fMassHypo); - else if((mMassParticle < SumDaughterMass) || (fP[6]<0) ) - SetMassConstraint(fP,fC,mJ1,SumDaughterMass); + if (fMassHypo > -0.5) + SetMassConstraint(fP, fC, mJ1, fMassHypo); + else if ((mMassParticle < SumDaughterMass) || (fP[6] < 0)) + SetMassConstraint(fP, fC, mJ1, SumDaughterMass); - if(Daughter.fMassHypo > -0.5) - SetMassConstraint(m,mV,mJ2,Daughter.fMassHypo); - else if((mMassDaughter < Daughter.SumDaughterMass) || (m[6] < 0) ) - SetMassConstraint(m,mV,mJ2,Daughter.SumDaughterMass); + if (Daughter.fMassHypo > -0.5) + SetMassConstraint(m, mV, mJ2, Daughter.fMassHypo); + else if ((mMassDaughter < Daughter.SumDaughterMass) || (m[6] < 0)) + SetMassConstraint(m, mV, mJ2, Daughter.SumDaughterMass); float mDJ[7][7]; - for(Int_t i=0; i<7; i++) { - for(Int_t j=0; j<7; j++) { + for (Int_t i = 0; i < 7; i++) { + for (Int_t j = 0; j < 7; j++) { mDJ[i][j] = 0; - for(Int_t k=0; k<7; k++) { - mDJ[i][j] += mDf[i][k]*mJ1[j][k]; + for (Int_t k = 0; k < 7; k++) { + mDJ[i][j] += mDf[i][k] * mJ1[j][k]; } } } - for(Int_t i=0; i<7; ++i){ - for(Int_t j=0; j<7; ++j){ - mDf[i][j]=0; - for(Int_t l=0; l<7; l++){ - mDf[i][j] += mJ2[i][l]*mDJ[l][j]; + for (Int_t i = 0; i < 7; ++i) { + for (Int_t j = 0; j < 7; ++j) { + mDf[i][j] = 0; + for (Int_t l = 0; l < 7; l++) { + mDf[i][j] += mJ2[i][l] * mDJ[l][j]; } } } //* Add the daughter momentum to the particle momentum - fP[ 3] += m[ 3]; - fP[ 4] += m[ 4]; - fP[ 5] += m[ 5]; - fP[ 6] += m[ 6]; + fP[3] += m[3]; + fP[4] += m[4]; + fP[5] += m[5]; + fP[6] += m[6]; - fC[ 9] += mV[ 9]; + fC[9] += mV[9]; fC[13] += mV[13]; fC[14] += mV[14]; fC[18] += mV[18]; @@ -1098,66 +1122,72 @@ void KFParticleBase::AddDaughterWithEnergyFitMC( const KFParticleBase &Daughter fC[26] += mV[26]; fC[27] += mV[27]; - fC[6 ] += mDf[3][0]; fC[7 ] += mDf[3][1]; fC[8 ] += mDf[3][2]; - fC[10] += mDf[4][0]; fC[11] += mDf[4][1]; fC[12] += mDf[4][2]; - fC[15] += mDf[5][0]; fC[16] += mDf[5][1]; fC[17] += mDf[5][2]; - fC[21] += mDf[6][0]; fC[22] += mDf[6][1]; fC[23] += mDf[6][2]; - - fC[9 ] += mDf[3][3] + mDf[3][3]; - fC[13] += mDf[4][3] + mDf[3][4]; fC[14] += mDf[4][4] + mDf[4][4]; - fC[18] += mDf[5][3] + mDf[3][5]; fC[19] += mDf[5][4] + mDf[4][5]; fC[20] += mDf[5][5] + mDf[5][5]; - fC[24] += mDf[6][3] + mDf[3][6]; fC[25] += mDf[6][4] + mDf[4][6]; fC[26] += mDf[6][5] + mDf[5][6]; fC[27] += mDf[6][6] + mDf[6][6]; + fC[6] += mDf[3][0]; + fC[7] += mDf[3][1]; + fC[8] += mDf[3][2]; + fC[10] += mDf[4][0]; + fC[11] += mDf[4][1]; + fC[12] += mDf[4][2]; + fC[15] += mDf[5][0]; + fC[16] += mDf[5][1]; + fC[17] += mDf[5][2]; + fC[21] += mDf[6][0]; + fC[22] += mDf[6][1]; + fC[23] += mDf[6][2]; + + fC[9] += mDf[3][3] + mDf[3][3]; + fC[13] += mDf[4][3] + mDf[3][4]; + fC[14] += mDf[4][4] + mDf[4][4]; + fC[18] += mDf[5][3] + mDf[3][5]; + fC[19] += mDf[5][4] + mDf[4][5]; + fC[20] += mDf[5][5] + mDf[5][5]; + fC[24] += mDf[6][3] + mDf[3][6]; + fC[25] += mDf[6][4] + mDf[4][6]; + fC[26] += mDf[6][5] + mDf[5][6]; + fC[27] += mDf[6][6] + mDf[6][6]; - float K2[3][3]; - for(int i=0; i<3; i++) - { - for(int j=0; j<3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) K2[i][j] = -K[j][i]; K2[i][i] += 1; } float A[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { A[i][j] = 0; - for(int k=0; k<3; k++) - { + for (int k = 0; k < 3; k++) { A[i][j] += D[i][k] * K2[k][j]; } } - + double M[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { M[i][j] = 0; - for(int k=0; k<3; k++) - { + for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } - fC[0] += 2*M[0][0]; + fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; - fC[2] += 2*M[1][1]; + fC[2] += 2 * M[1][1]; fC[3] += M[0][2] + M[2][0]; fC[4] += M[1][2] + M[2][1]; - fC[5] += 2*M[2][2]; - - //* Calculate Chi^2 + fC[5] += 2 * M[2][2]; + + //* Calculate Chi^2 - fNDF += 2; - fQ += Daughter.GetQ(); - fSFromDecay = 0; - fChi2 += (mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0] - + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1] - + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2]; + fNDF += 2; + fQ += Daughter.GetQ(); + fSFromDecay = 0; + fChi2 += (mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]; } } -void KFParticleBase::SetProductionVertex( const KFParticleBase &Vtx ) +void KFParticleBase::SetProductionVertex(const KFParticleBase& Vtx) { /** Adds a vertex as a point-like measurement to the current particle. ** The eights parameter of the state vector is filled with the decay @@ -1166,184 +1196,180 @@ void KFParticleBase::SetProductionVertex( const KFParticleBase &Vtx ) ** at the position of the production vertex. ** \param[in] Vtx - the assumed producation vertex **/ - + const float *m = Vtx.fP, *mV = Vtx.fC; float decayPoint[3] = {fP[0], fP[1], fP[2]}; - float decayPointCov[6] = { fC[0], fC[1], fC[2], fC[3], fC[4], fC[5] }; + float decayPointCov[6] = {fC[0], fC[1], fC[2], fC[3], fC[4], fC[5]}; float D[6][6]; - for(int iD1=0; iD1<6; iD1++) - for(int iD2=0; iD2<6; iD2++) + for (int iD1 = 0; iD1 < 6; iD1++) + for (int iD2 = 0; iD2 < 6; iD2++) D[iD1][iD2] = 0.f; - Bool_t noS = ( fC[35]<=0 ); // no decay length allowed + Bool_t noS = (fC[35] <= 0); // no decay length allowed - if( noS ){ + if (noS) { TransportToDecayVertex(); fP[7] = 0; fC[28] = fC[29] = fC[30] = fC[31] = fC[32] = fC[33] = fC[34] = fC[35] = 0; - } - else - { + } else { float dsdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; float dS = GetDStoPoint(Vtx.fP, dsdr); - + float dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0, 0, 0}; - + float F[36], F1[36]; - for(int i2=0; i2<36; i2++) - { - F[i2] = 0; + for (int i2 = 0; i2 < 36; i2++) { + F[i2] = 0; F1[i2] = 0; } - Transport( dS, dsdr, fP, fC, dsdp, F, F1 ); - + Transport(dS, dsdr, fP, fC, dsdp, F, F1); + float CTmp[36] = {0.}; MultQSQt(F1, mV, CTmp, 6); - - for(int iC=0; iC<6; iC++) + + for (int iC = 0; iC < 6; iC++) fC[iC] += CTmp[iC]; - - for(int i=0; i<6; i++) - for(int j=0; j<3; j++) - { + + for (int i = 0; i < 6; i++) + for (int j = 0; j < 3; j++) { D[i][j] = 0; - for(int k=0; k<3; k++) - { - D[i][j] += mV[IJ(j,k)] * F1[i*6+k]; + for (int k = 0; k < 3; k++) { + D[i][j] += mV[IJ(j, k)] * F1[i * 6 + k]; } } } - float mS[6] = { fC[0] + mV[0], - fC[1] + mV[1], fC[2] + mV[2], - fC[3] + mV[3], fC[4] + mV[4], fC[5] + mV[5] }; + float mS[6] = {fC[0] + mV[0], + fC[1] + mV[1], fC[2] + mV[2], + fC[3] + mV[3], fC[4] + mV[4], fC[5] + mV[5]}; InvertCholetsky3(mS); - - float res[3] = { m[0] - X(), m[1] - Y(), m[2] - Z() }; - - float K[3][6]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + + float res[3] = {m[0] - X(), m[1] - Y(), m[2] - Z()}; + + float K[3][6]; + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { K[i][j] = 0; - for(int k=0; k<3; k++) - K[i][j] += fC[IJ(i,k)] * mS[IJ(k,j)]; + for (int k = 0; k < 3; k++) + K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; } - + float mCHt0[7], mCHt1[7], mCHt2[7]; - mCHt0[0]=fC[ 0]; mCHt1[0]=fC[ 1]; mCHt2[0]=fC[ 3]; - mCHt0[1]=fC[ 1]; mCHt1[1]=fC[ 2]; mCHt2[1]=fC[ 4]; - mCHt0[2]=fC[ 3]; mCHt1[2]=fC[ 4]; mCHt2[2]=fC[ 5]; - mCHt0[3]=fC[ 6]; mCHt1[3]=fC[ 7]; mCHt2[3]=fC[ 8]; - mCHt0[4]=fC[10]; mCHt1[4]=fC[11]; mCHt2[4]=fC[12]; - mCHt0[5]=fC[15]; mCHt1[5]=fC[16]; mCHt2[5]=fC[17]; - mCHt0[6]=fC[21]; mCHt1[6]=fC[22]; mCHt2[6]=fC[23]; - + mCHt0[0] = fC[0]; + mCHt1[0] = fC[1]; + mCHt2[0] = fC[3]; + mCHt0[1] = fC[1]; + mCHt1[1] = fC[2]; + mCHt2[1] = fC[4]; + mCHt0[2] = fC[3]; + mCHt1[2] = fC[4]; + mCHt2[2] = fC[5]; + mCHt0[3] = fC[6]; + mCHt1[3] = fC[7]; + mCHt2[3] = fC[8]; + mCHt0[4] = fC[10]; + mCHt1[4] = fC[11]; + mCHt2[4] = fC[12]; + mCHt0[5] = fC[15]; + mCHt1[5] = fC[16]; + mCHt2[5] = fC[17]; + mCHt0[6] = fC[21]; + mCHt1[6] = fC[22]; + mCHt2[6] = fC[23]; + float k0[7], k1[7], k2[7]; - for(Int_t i=0;i<7;++i){ - k0[i] = mCHt0[i]*mS[0] + mCHt1[i]*mS[1] + mCHt2[i]*mS[3]; - k1[i] = mCHt0[i]*mS[1] + mCHt1[i]*mS[2] + mCHt2[i]*mS[4]; - k2[i] = mCHt0[i]*mS[3] + mCHt1[i]*mS[4] + mCHt2[i]*mS[5]; - } - - for(Int_t i=0;i<7;++i) - fP[i] = fP[i] + k0[i]*res[0] + k1[i]*res[1] + k2[i]*res[2]; - - for(Int_t i=0, k=0;i<7;++i){ - for(Int_t j=0;j<=i;++j,++k){ - fC[k] = fC[k] - (k0[i]*mCHt0[j] + k1[i]*mCHt1[j] + k2[i]*mCHt2[j] ); + for (Int_t i = 0; i < 7; ++i) { + k0[i] = mCHt0[i] * mS[0] + mCHt1[i] * mS[1] + mCHt2[i] * mS[3]; + k1[i] = mCHt0[i] * mS[1] + mCHt1[i] * mS[2] + mCHt2[i] * mS[4]; + k2[i] = mCHt0[i] * mS[3] + mCHt1[i] * mS[4] + mCHt2[i] * mS[5]; + } + + for (Int_t i = 0; i < 7; ++i) + fP[i] = fP[i] + k0[i] * res[0] + k1[i] * res[1] + k2[i] * res[2]; + + for (Int_t i = 0, k = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) { + fC[k] = fC[k] - (k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]); } } float K2[3][3]; - for(int i=0; i<3; i++) - { - for(int j=0; j<3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) K2[i][j] = -K[j][i]; K2[i][i] += 1; } float A[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { A[i][j] = 0; - for(int k=0; k<3; k++) - { + for (int k = 0; k < 3; k++) { A[i][j] += D[k][i] * K2[k][j]; } } - + double M[3][3]; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { M[i][j] = 0; - for(int k=0; k<3; k++) - { + for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } - - fC[0] += 2*M[0][0]; + + fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; - fC[2] += 2*M[1][1]; + fC[2] += 2 * M[1][1]; fC[3] += M[0][2] + M[2][0]; fC[4] += M[1][2] + M[2][1]; - fC[5] += 2*M[2][2]; - - fChi2 += (mS[0]*res[0] + mS[1]*res[1] + mS[3]*res[2])*res[0] - + (mS[1]*res[0] + mS[2]*res[1] + mS[4]*res[2])*res[1] - + (mS[3]*res[0] + mS[4]*res[1] + mS[5]*res[2])*res[2]; + fC[5] += 2 * M[2][2]; + + fChi2 += (mS[0] * res[0] + mS[1] * res[1] + mS[3] * res[2]) * res[0] + (mS[1] * res[0] + mS[2] * res[1] + mS[4] * res[2]) * res[1] + (mS[3] * res[0] + mS[4] * res[1] + mS[5] * res[2]) * res[2]; fNDF += 2; - - if( noS ){ + + if (noS) { fP[7] = 0; fC[28] = fC[29] = fC[30] = fC[31] = fC[32] = fC[33] = fC[34] = fC[35] = 0; fSFromDecay = 0; - } - else - { + } else { float dsdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; - fP[7] = GetDStoPoint(decayPoint, dsdr); - + fP[7] = GetDStoPoint(decayPoint, dsdr); + float dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0, 0, 0}; float F[36], F1[36]; - for(int i2=0; i2<36; i2++) - { - F[i2] = 0; + for (int i2 = 0; i2 < 36; i2++) { + F[i2] = 0; F1[i2] = 0; } - float tmpP[8], tmpC[36]; - Transport( fP[7], dsdr, tmpP, tmpC, dsdp, F, F1 ); - + float tmpP[8], tmpC[36]; + Transport(fP[7], dsdr, tmpP, tmpC, dsdp, F, F1); + fC[35] = 0; - for(int iDsDr=0; iDsDr<6; iDsDr++) - { + for (int iDsDr = 0; iDsDr < 6; iDsDr++) { float dsdrC = 0, dsdpV = 0; - - for(int k=0; k<6; k++) - dsdrC += dsdr[k] * fC[IJ(k,iDsDr)]; // (-dsdr[k])*fC[k,j] - - fC[iDsDr+28] = dsdrC; - fC[35] += dsdrC*dsdr[iDsDr] ; - if(iDsDr < 3) - { - for(int k=0; k<3; k++) - dsdpV -= dsdr[k] * decayPointCov[IJ(k,iDsDr)]; // - fC[35] -= dsdpV*dsdr[iDsDr]; + + for (int k = 0; k < 6; k++) + dsdrC += dsdr[k] * fC[IJ(k, iDsDr)]; // (-dsdr[k])*fC[k,j] + + fC[iDsDr + 28] = dsdrC; + fC[35] += dsdrC * dsdr[iDsDr]; + if (iDsDr < 3) { + for (int k = 0; k < 3; k++) + dsdpV -= dsdr[k] * decayPointCov[IJ(k, iDsDr)]; // + fC[35] -= dsdpV * dsdr[iDsDr]; } - } + } fSFromDecay = -fP[7]; } - + fAtProductionVertex = 1; } -void KFParticleBase::SetMassConstraint( float *mP, float *mC, float mJ[7][7], float mass ) +void KFParticleBase::SetMassConstraint(float* mP, float* mC, float mJ[7][7], float mass) { /** Sets the exact nonlinear mass constraint on the state vector mP with the covariance matrix mC. ** \param[in,out] mP - the state vector to be modified @@ -1351,92 +1377,94 @@ void KFParticleBase::SetMassConstraint( float *mP, float *mC, float mJ[7][7], fl ** \param[in,out] mJ - the Jacobian between initial and modified parameters ** \param[in] mass - the mass to be set on the state vector mP **/ - + //* Set nonlinear mass constraint (Mass) on the state vector mP with a covariance matrix mC. - - const float energy2 = mP[6]*mP[6], p2 = mP[3]*mP[3]+mP[4]*mP[4]+mP[5]*mP[5], mass2 = mass*mass; - const float a = energy2 - p2 + 2.*mass2; - const float b = -2.*(energy2 + p2); + const float energy2 = mP[6] * mP[6], p2 = mP[3] * mP[3] + mP[4] * mP[4] + mP[5] * mP[5], mass2 = mass * mass; + + const float a = energy2 - p2 + 2. * mass2; + const float b = -2. * (energy2 + p2); const float c = energy2 - p2 - mass2; float lambda = 0; - if(fabs(b) > 1.e-10) lambda = -c / b; + if (fabs(b) > 1.e-10) + lambda = -c / b; - float d = 4.*energy2*p2 - mass2*(energy2-p2-2.*mass2); - if(d>=0 && fabs(a) > 1.e-10) lambda = (energy2 + p2 - sqrt(d))/a; + float d = 4. * energy2 * p2 - mass2 * (energy2 - p2 - 2. * mass2); + if (d >= 0 && fabs(a) > 1.e-10) + lambda = (energy2 + p2 - sqrt(d)) / a; - if(mP[6] < 0) //If energy < 0 we need a lambda < 0 + if (mP[6] < 0) //If energy < 0 we need a lambda < 0 lambda = -1000000.; //Empirical, a better solution should be found - Int_t iIter=0; - for(iIter=0; iIter<100; iIter++) - { - float lambda2 = lambda*lambda; - float lambda4 = lambda2*lambda2; + Int_t iIter = 0; + for (iIter = 0; iIter < 100; iIter++) { + float lambda2 = lambda * lambda; + float lambda4 = lambda2 * lambda2; float lambda0 = lambda; - float f = -mass2 * lambda4 + a*lambda2 + b*lambda + c; - float df = -4.*mass2 * lambda2*lambda + 2.*a*lambda + b; - if(fabs(df) < 1.e-10) break; - lambda -= f/df; - if(fabs(lambda0 - lambda) < 1.e-8) break; - } - - const float lpi = 1./(1. + lambda); - const float lmi = 1./(1. - lambda); - const float lp2i = lpi*lpi; - const float lm2i = lmi*lmi; - - float lambda2 = lambda*lambda; - - float dfl = -4.*mass2 * lambda2*lambda + 2.*a*lambda + b; - float dfx[7] = {0};//,0,0,0}; - dfx[0] = -2.*(1. + lambda)*(1. + lambda)*mP[3]; - dfx[1] = -2.*(1. + lambda)*(1. + lambda)*mP[4]; - dfx[2] = -2.*(1. + lambda)*(1. + lambda)*mP[5]; - dfx[3] = 2.*(1. - lambda)*(1. - lambda)*mP[6]; - float dlx[4] = {1,1,1,1}; - if(fabs(dfl) > 1.e-10 ) - { - for(int i=0; i<4; i++) + float f = -mass2 * lambda4 + a * lambda2 + b * lambda + c; + float df = -4. * mass2 * lambda2 * lambda + 2. * a * lambda + b; + if (fabs(df) < 1.e-10) + break; + lambda -= f / df; + if (fabs(lambda0 - lambda) < 1.e-8) + break; + } + + const float lpi = 1. / (1. + lambda); + const float lmi = 1. / (1. - lambda); + const float lp2i = lpi * lpi; + const float lm2i = lmi * lmi; + + float lambda2 = lambda * lambda; + + float dfl = -4. * mass2 * lambda2 * lambda + 2. * a * lambda + b; + float dfx[7] = {0}; //,0,0,0}; + dfx[0] = -2. * (1. + lambda) * (1. + lambda) * mP[3]; + dfx[1] = -2. * (1. + lambda) * (1. + lambda) * mP[4]; + dfx[2] = -2. * (1. + lambda) * (1. + lambda) * mP[5]; + dfx[3] = 2. * (1. - lambda) * (1. - lambda) * mP[6]; + float dlx[4] = {1, 1, 1, 1}; + if (fabs(dfl) > 1.e-10) { + for (int i = 0; i < 4; i++) dlx[i] = -dfx[i] / dfl; } - float dxx[4] = {mP[3]*lm2i, mP[4]*lm2i, mP[5]*lm2i, -mP[6]*lp2i}; + float dxx[4] = {mP[3] * lm2i, mP[4] * lm2i, mP[5] * lm2i, -mP[6] * lp2i}; - for(Int_t i=0; i<7; i++) - for(Int_t j=0; j<7; j++) - mJ[i][j]=0; + for (Int_t i = 0; i < 7; i++) + for (Int_t j = 0; j < 7; j++) + mJ[i][j] = 0; mJ[0][0] = 1.; mJ[1][1] = 1.; mJ[2][2] = 1.; - for(Int_t i=3; i<7; i++) - for(Int_t j=3; j<7; j++) - mJ[i][j] = dlx[j-3]*dxx[i-3]; + for (Int_t i = 3; i < 7; i++) + for (Int_t j = 3; j < 7; j++) + mJ[i][j] = dlx[j - 3] * dxx[i - 3]; - for(Int_t i=3; i<6; i++) + for (Int_t i = 3; i < 6; i++) mJ[i][i] += lmi; mJ[6][6] += lpi; float mCJ[7][7]; - for(Int_t i=0; i<7; i++) { - for(Int_t j=0; j<7; j++) { + for (Int_t i = 0; i < 7; i++) { + for (Int_t j = 0; j < 7; j++) { mCJ[i][j] = 0; - for(Int_t k=0; k<7; k++) { - mCJ[i][j] += mC[IJ(i,k)]*mJ[j][k]; + for (Int_t k = 0; k < 7; k++) { + mCJ[i][j] += mC[IJ(i, k)] * mJ[j][k]; } } } - for(Int_t i=0; i<7; ++i){ - for(Int_t j=0; j<=i; ++j){ - mC[IJ(i,j)]=0; - for(Int_t l=0; l<7; l++){ - mC[IJ(i,j)] += mJ[i][l]*mCJ[l][j]; + for (Int_t i = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j) { + mC[IJ(i, j)] = 0; + for (Int_t l = 0; l < 7; l++) { + mC[IJ(i, j)] += mJ[i][l] * mCJ[l][j]; } } } @@ -1447,7 +1475,7 @@ void KFParticleBase::SetMassConstraint( float *mP, float *mC, float mJ[7][7], fl mP[6] *= lpi; } -void KFParticleBase::SetNonlinearMassConstraint( float mass ) +void KFParticleBase::SetNonlinearMassConstraint(float mass) { /** Sets the exact nonlinear mass constraint on the current particle. ** \param[in] mass - the mass to be set on the particle @@ -1456,23 +1484,23 @@ void KFParticleBase::SetNonlinearMassConstraint( float mass ) const float& px = fP[3]; const float& py = fP[4]; const float& pz = fP[5]; - const float& energy = fP[6]; - - const float residual = (energy*energy - px*px - py*py - pz*pz) - mass*mass; - const float dm2 = float(4.f) * ( px*px*fC[9] + py*py*fC[14] + pz*pz*fC[20] + energy*energy*fC[27] + - float(2.f) * ( px*py*fC[13] + pz*(px*fC[18]+py*fC[19]) - energy*(px*fC[24]+py*fC[25]+pz*fC[26]) ) ); - const float dChi2 = residual*residual / dm2; + const float& energy = fP[6]; + + const float residual = (energy * energy - px * px - py * py - pz * pz) - mass * mass; + const float dm2 = float(4.f) * (px * px * fC[9] + py * py * fC[14] + pz * pz * fC[20] + energy * energy * fC[27] + + float(2.f) * (px * py * fC[13] + pz * (px * fC[18] + py * fC[19]) - energy * (px * fC[24] + py * fC[25] + pz * fC[26]))); + const float dChi2 = residual * residual / dm2; fChi2 += dChi2; - fNDF += 1; - + fNDF += 1; + float mJ[7][7]; - SetMassConstraint( fP, fC, mJ, mass ); + SetMassConstraint(fP, fC, mJ, mass); fMassHypo = mass; SumDaughterMass = mass; } -void KFParticleBase::SetMassConstraint( float Mass, float SigmaMass ) -{ +void KFParticleBase::SetMassConstraint(float Mass, float SigmaMass) +{ /** Sets linearised mass constraint on the current particle. The constraint can be set with ** an uncertainty. ** \param[in] Mass - the mass to be set on the state vector mP @@ -1482,78 +1510,81 @@ void KFParticleBase::SetMassConstraint( float Mass, float SigmaMass ) fMassHypo = Mass; SumDaughterMass = Mass; - float m2 = Mass*Mass; // measurement, weighted by Mass - float s2 = m2*SigmaMass*SigmaMass; // sigma^2 + float m2 = Mass * Mass; // measurement, weighted by Mass + float s2 = m2 * SigmaMass * SigmaMass; // sigma^2 - float p2 = fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]; - float e0 = sqrt(m2+p2); + float p2 = fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]; + float e0 = sqrt(m2 + p2); float mH[8]; mH[0] = mH[1] = mH[2] = 0.; - mH[3] = -2*fP[3]; - mH[4] = -2*fP[4]; - mH[5] = -2*fP[5]; - mH[6] = 2*fP[6];//e0; - mH[7] = 0; - - float zeta = e0*e0 - e0*fP[6]; - zeta = m2 - (fP[6]*fP[6]-p2); - - float mCHt[8], s2_est=0; - for( Int_t i=0; i<8; ++i ){ + mH[3] = -2 * fP[3]; + mH[4] = -2 * fP[4]; + mH[5] = -2 * fP[5]; + mH[6] = 2 * fP[6]; //e0; + mH[7] = 0; + + float zeta = e0 * e0 - e0 * fP[6]; + zeta = m2 - (fP[6] * fP[6] - p2); + + float mCHt[8], s2_est = 0; + for (Int_t i = 0; i < 8; ++i) { mCHt[i] = 0.0; - for (Int_t j=0;j<8;++j) mCHt[i] += Cij(i,j)*mH[j]; - s2_est += mH[i]*mCHt[i]; + for (Int_t j = 0; j < 8; ++j) + mCHt[i] += Cij(i, j) * mH[j]; + s2_est += mH[i] * mCHt[i]; } - - if( s2_est<1.e-20 ) return; // calculated mass error is already 0, - // the particle can not be constrained on mass - float w2 = 1./( s2 + s2_est ); - fChi2 += zeta*zeta*w2; - fNDF += 1; - for( Int_t i=0, ii=0; i<8; ++i ){ - float ki = mCHt[i]*w2; - fP[i]+= ki*zeta; - for(Int_t j=0;j<=i;++j) fC[ii++] -= ki*mCHt[j]; + if (s2_est < 1.e-20) + return; // calculated mass error is already 0, + // the particle can not be constrained on mass + + float w2 = 1. / (s2 + s2_est); + fChi2 += zeta * zeta * w2; + fNDF += 1; + for (Int_t i = 0, ii = 0; i < 8; ++i) { + float ki = mCHt[i] * w2; + fP[i] += ki * zeta; + for (Int_t j = 0; j <= i; ++j) + fC[ii++] -= ki * mCHt[j]; } } - void KFParticleBase::SetNoDecayLength() -{ +{ /** Sets constraint on the zero decay length. When the production point is set ** the measurement from this particle is created at the decay point. **/ - + TransportToDecayVertex(); float h[8]; h[0] = h[1] = h[2] = h[3] = h[4] = h[5] = h[6] = 0; - h[7] = 1; + h[7] = 1; float zeta = 0 - fP[7]; - for(Int_t i=0;i<8;++i) zeta -= h[i]*(fP[i]-fP[i]); - - float s = fC[35]; - if( s>1.e-20 ){ - s = 1./s; - fChi2 += zeta*zeta*s; - fNDF += 1; - for( Int_t i=0, ii=0; i<7; ++i ){ - float ki = fC[28+i]*s; - fP[i]+= ki*zeta; - for(Int_t j=0;j<=i;++j) fC[ii++] -= ki*fC[28+j]; + for (Int_t i = 0; i < 8; ++i) + zeta -= h[i] * (fP[i] - fP[i]); + + float s = fC[35]; + if (s > 1.e-20) { + s = 1. / s; + fChi2 += zeta * zeta * s; + fNDF += 1; + for (Int_t i = 0, ii = 0; i < 7; ++i) { + float ki = fC[28 + i] * s; + fP[i] += ki * zeta; + for (Int_t j = 0; j <= i; ++j) + fC[ii++] -= ki * fC[28 + j]; } } fP[7] = 0; fC[28] = fC[29] = fC[30] = fC[31] = fC[32] = fC[33] = fC[34] = fC[35] = 0; } - -void KFParticleBase::Construct( const KFParticleBase* vDaughters[], Int_t nDaughters, - const KFParticleBase *Parent, float Mass ) -{ +void KFParticleBase::Construct(const KFParticleBase* vDaughters[], Int_t nDaughters, + const KFParticleBase* Parent, float Mass) +{ /** Constructs a short-lived particle from a set of daughter particles:\n ** 1) all parameters of the "this" objects are initialised;\n ** 2) daughters are added one after another;\n @@ -1566,59 +1597,62 @@ void KFParticleBase::Construct( const KFParticleBase* vDaughters[], Int_t nDaugh **/ const int maxIter = 1; - for( Int_t iter=0; iter=0 ) SetMassConstraint( Mass ); - if( Parent ) SetProductionVertex( *Parent ); + if (Mass >= 0) + SetMassConstraint(Mass); + if (Parent) + SetProductionVertex(*Parent); } void KFParticleBase::TransportToDecayVertex() { /** Transports the particle to its decay vertex */ float dsdr[6] = {0.f}; - if( fSFromDecay != 0 ) TransportToDS( -fSFromDecay, dsdr ); + if (fSFromDecay != 0) + TransportToDS(-fSFromDecay, dsdr); fAtProductionVertex = 0; } void KFParticleBase::TransportToProductionVertex() { /** Transports the particle to its production vertex */ - float dsdr[6] = {0.f}; - if( fSFromDecay != -fP[7] ) TransportToDS( -fSFromDecay-fP[7], dsdr ); + float dsdr[6] = {0.f}; + if (fSFromDecay != -fP[7]) + TransportToDS(-fSFromDecay - fP[7], dsdr); fAtProductionVertex = 1; } - -void KFParticleBase::TransportToDS( float dS, const float* dsdr ) -{ +void KFParticleBase::TransportToDS(float dS, const float* dsdr) +{ /** Transport the particle on a certain distane. The distance is defined by the dS=l/p parameter, where \n ** 1) l - signed distance;\n ** 2) p - momentum of the particle. \n ** \param[in] dS = l/p - distance normalised to the momentum of the particle to be transported on ** \param[in] dsdr[6] = ds/dr partial derivatives of the parameter dS over the state vector of the current particle **/ - - Transport( dS, dsdr, fP, fC ); - fSFromDecay+= dS; -} + Transport(dS, dsdr, fP, fC); + fSFromDecay += dS; +} -float KFParticleBase::GetDStoPointLine( const float xyz[3], float dsdr[6] ) const +float KFParticleBase::GetDStoPointLine(const float xyz[3], float dsdr[6]) const { /** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n @@ -1628,24 +1662,24 @@ float KFParticleBase::GetDStoPointLine( const float xyz[3], float dsdr[6] ) cons ** \param[in] xyz[3] - point where particle should be transported ** \param[out] dsdr[6] = ds/dr partial derivatives of the parameter dS over the state vector of the current particle **/ - - float p2 = fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]; - if( p2<1.e-4 ) p2 = 1; - - const float& a = fP[3]*(xyz[0]-fP[0]) + fP[4]*(xyz[1]-fP[1]) + fP[5]*(xyz[2]-fP[2]); - dsdr[0] = -fP[3]/p2; - dsdr[1] = -fP[4]/p2; - dsdr[2] = -fP[5]/p2; - dsdr[3] = ((xyz[0]-fP[0])*p2 - 2.f* fP[3]*a)/(p2*p2); - dsdr[4] = ((xyz[1]-fP[1])*p2 - 2.f* fP[4]*a)/(p2*p2); - dsdr[5] = ((xyz[2]-fP[2])*p2 - 2.f* fP[5]*a)/(p2*p2); - - return a/p2; -} + float p2 = fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]; + if (p2 < 1.e-4) + p2 = 1; + + const float& a = fP[3] * (xyz[0] - fP[0]) + fP[4] * (xyz[1] - fP[1]) + fP[5] * (xyz[2] - fP[2]); + dsdr[0] = -fP[3] / p2; + dsdr[1] = -fP[4] / p2; + dsdr[2] = -fP[5] / p2; + dsdr[3] = ((xyz[0] - fP[0]) * p2 - 2.f * fP[3] * a) / (p2 * p2); + dsdr[4] = ((xyz[1] - fP[1]) * p2 - 2.f * fP[4] * a) / (p2 * p2); + dsdr[5] = ((xyz[2] - fP[2]) * p2 - 2.f * fP[5] * a) / (p2 * p2); -float KFParticleBase::GetDStoPointBz( float B, const float xyz[3], float dsdr[6], const float* param) const -{ + return a / p2; +} + +float KFParticleBase::GetDStoPointBz(float B, const float xyz[3], float dsdr[6], const float* param) const +{ /** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n ** 2) p - momentum of the particle; \n @@ -1657,124 +1691,119 @@ float KFParticleBase::GetDStoPointBz( float B, const float xyz[3], float dsdr[6] ** \param[in] param - optional parameter, is used in case if the parameters of the particle are rotated ** to other coordinate system (see GetDStoPointBy() function), otherwise fP are used **/ - - if(!param) + + if (!param) param = fP; - - const float& x = param[0]; - const float& y = param[1]; - const float& z = param[2]; + + const float& x = param[0]; + const float& y = param[1]; + const float& z = param[2]; const float& px = param[3]; const float& py = param[4]; const float& pz = param[5]; - + const float kCLight = 0.000299792458f; - float bq = B*fQ*kCLight; - float pt2 = px*px + py*py; - float p2 = pt2 + pz*pz; - + float bq = B * fQ * kCLight; + float pt2 = px * px + py * py; + float p2 = pt2 + pz * pz; + float dx = xyz[0] - x; - float dy = xyz[1] - y; - float dz = xyz[2] - z; - float a = dx*px+dy*py; + float dy = xyz[1] - y; + float dz = xyz[2] - z; + float a = dx * px + dy * py; float dS(0.f); - - float abq = bq*a; + + float abq = bq * a; const float LocalSmall = 1.e-8f; - bool mask = ( fabs(bq)1.e-4f) - { - dS = (a + dz*pz)/p2; - - dsdr[0] = -px/p2; - dsdr[1] = -py/p2; - dsdr[2] = -pz/p2; - dsdr[3] = (dx*p2 - 2.f* px *(a + dz *pz))/(p2*p2); - dsdr[4] = (dy*p2 - 2.f* py *(a + dz *pz))/(p2*p2); - dsdr[5] = (dz*p2 - 2.f* pz *(a + dz *pz))/(p2*p2); - } - if(mask) - { + bool mask = (fabs(bq) < LocalSmall); + if (mask && p2 > 1.e-4f) { + dS = (a + dz * pz) / p2; + + dsdr[0] = -px / p2; + dsdr[1] = -py / p2; + dsdr[2] = -pz / p2; + dsdr[3] = (dx * p2 - 2.f * px * (a + dz * pz)) / (p2 * p2); + dsdr[4] = (dy * p2 - 2.f * py * (a + dz * pz)) / (p2 * p2); + dsdr[5] = (dz * p2 - 2.f * pz * (a + dz * pz)) / (p2 * p2); + } + if (mask) { return dS; } - - dS = atan2( abq, pt2 + bq*(dy*px -dx*py) )/bq; - float bs= bq*dS; + dS = atan2(abq, pt2 + bq * (dy * px - dx * py)) / bq; + + float bs = bq * dS; float s = sin(bs), c = cos(bs); - if(fabs(bq) < LocalSmall) + if (fabs(bq) < LocalSmall) bq = LocalSmall; - float bbq = bq*(dx*py - dy*px) - pt2; + float bbq = bq * (dx * py - dy * px) - pt2; - float den = (abq*abq + bbq*bbq); + float den = (abq * abq + bbq * bbq); den = den < LocalSmall ? LocalSmall : den; - dsdr[0] = (px*bbq - py*abq)/den; - dsdr[1] = (px*abq + py*bbq)/den; + dsdr[0] = (px * bbq - py * abq) / den; + dsdr[1] = (px * abq + py * bbq) / den; dsdr[2] = 0; - dsdr[3] = -(dx*bbq + dy*abq + 2.f*px*a)/den; - dsdr[4] = (dx*abq - dy*bbq - 2.f*py*a)/den; + dsdr[3] = -(dx * bbq + dy * abq + 2.f * px * a) / den; + dsdr[4] = (dx * abq - dy * bbq - 2.f * py * a) / den; dsdr[5] = 0; - + float sz(0.f); - float cCoeff = (bbq*c - abq*s) - pz*pz ; - if(fabs(cCoeff) > LocalSmall) - sz = (dS*pz - dz)*pz / cCoeff; + float cCoeff = (bbq * c - abq * s) - pz * pz; + if (fabs(cCoeff) > LocalSmall) + sz = (dS * pz - dz) * pz / cCoeff; float dcdr[6] = {0.f}; - dcdr[0] = -bq*py*c - bbq*s*bq*dsdr[0] + px*bq*s - abq*c*bq*dsdr[0]; - dcdr[1] = bq*px*c - bbq*s*bq*dsdr[1] + py*bq*s - abq*c*bq*dsdr[1]; - dcdr[3] = (-bq*dy-2*px)*c - bbq*s*bq*dsdr[3] - dx*bq*s - abq*c*bq*dsdr[3]; - dcdr[4] = ( bq*dx-2*py)*c - bbq*s*bq*dsdr[4] - dy*bq*s - abq*c*bq*dsdr[4]; - dcdr[5] = -2*pz; - - for(int iP=0; iP<6; iP++) - dsdr[iP] += pz*pz/cCoeff*dsdr[iP] - sz/cCoeff*dcdr[iP]; - dsdr[2] += pz/cCoeff; - dsdr[5] += (2.f*pz*dS - dz)/cCoeff; - + dcdr[0] = -bq * py * c - bbq * s * bq * dsdr[0] + px * bq * s - abq * c * bq * dsdr[0]; + dcdr[1] = bq * px * c - bbq * s * bq * dsdr[1] + py * bq * s - abq * c * bq * dsdr[1]; + dcdr[3] = (-bq * dy - 2 * px) * c - bbq * s * bq * dsdr[3] - dx * bq * s - abq * c * bq * dsdr[3]; + dcdr[4] = (bq * dx - 2 * py) * c - bbq * s * bq * dsdr[4] - dy * bq * s - abq * c * bq * dsdr[4]; + dcdr[5] = -2 * pz; + + for (int iP = 0; iP < 6; iP++) + dsdr[iP] += pz * pz / cCoeff * dsdr[iP] - sz / cCoeff * dcdr[iP]; + dsdr[2] += pz / cCoeff; + dsdr[5] += (2.f * pz * dS - dz) / cCoeff; + dS += sz; - - bs= bq*dS; + + bs = bq * dS; s = sin(bs), c = cos(bs); - + float sB, cB; - const float kOvSqr6 = 1.f/sqrt(float(6.f)); + const float kOvSqr6 = 1.f / sqrt(float(6.f)); - if(LocalSmall < fabs(bs)) - { - sB = s/bq; - cB = (1.f-c)/bq; - } - else - { - sB = (1.f-bs*kOvSqr6)*(1.f+bs*kOvSqr6)*dS; - cB = .5f*sB*bs; + if (LocalSmall < fabs(bs)) { + sB = s / bq; + cB = (1.f - c) / bq; + } else { + sB = (1.f - bs * kOvSqr6) * (1.f + bs * kOvSqr6) * dS; + cB = .5f * sB * bs; } float p[5]; - p[0] = x + sB*px + cB*py; - p[1] = y - cB*px + sB*py; - p[2] = z + dS*pz; - p[3] = c*px + s*py; - p[4] = -s*px + c*py; + p[0] = x + sB * px + cB * py; + p[1] = y - cB * px + sB * py; + p[2] = z + dS * pz; + p[3] = c * px + s * py; + p[4] = -s * px + c * py; dx = xyz[0] - p[0]; dy = xyz[1] - p[1]; dz = xyz[2] - p[2]; - a = dx*p[3]+dy*p[4] + dz*pz; - abq = bq*a; + a = dx * p[3] + dy * p[4] + dz * pz; + abq = bq * a; + + dS += atan2(abq, p2 + bq * (dy * p[3] - dx * p[4])) / bq; - dS += atan2( abq, p2 + bq*(dy*p[3] -dx*p[4]) )/bq; - return dS; } -float KFParticleBase::GetDStoPointBy( float By, const float xyz[3], float dsdr[6] ) const -{ +float KFParticleBase::GetDStoPointBy(float By, const float xyz[3], float dsdr[6]) const +{ /** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n ** 2) p - momentum of the particle; \n @@ -1787,25 +1816,25 @@ float KFParticleBase::GetDStoPointBy( float By, const float xyz[3], float dsdr[6 ** \param[in] xyz[3] - point, to which particle should be transported ** \param[out] dsdr[6] = ds/dr - partial derivatives of the parameter dS over the state vector of the current particle **/ - - const float param[6] = { fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4] }; - const float point[3] = { xyz[0], -xyz[2], xyz[1] }; - + + const float param[6] = {fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4]}; + const float point[3] = {xyz[0], -xyz[2], xyz[1]}; + float dsdrBz[6] = {0.f}; - + const float dS = GetDStoPointBz(By, point, dsdrBz, param); - dsdr[0] = dsdrBz[0]; - dsdr[1] = dsdrBz[2]; + dsdr[0] = dsdrBz[0]; + dsdr[1] = dsdrBz[2]; dsdr[2] = -dsdrBz[1]; - dsdr[3] = dsdrBz[3]; - dsdr[4] = dsdrBz[5]; + dsdr[3] = dsdrBz[3]; + dsdr[4] = dsdrBz[5]; dsdr[5] = -dsdrBz[4]; - + return dS; } -float KFParticleBase::GetDStoPointB( const float* B, const float xyz[3], float dsdr[6] ) const -{ +float KFParticleBase::GetDStoPointB(const float* B, const float xyz[3], float dsdr[6]) const +{ /** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n ** 2) p - momentum of the particle; \n @@ -1822,45 +1851,44 @@ float KFParticleBase::GetDStoPointB( const float* B, const float xyz[3], float d const float& Bx = B[0]; const float& By = B[1]; const float& Bz = B[2]; - - const float& Bxz = sqrt(Bx*Bx + Bz*Bz); - const float& Br = sqrt(Bx*Bx + By*By + Bz*Bz); - + + const float& Bxz = sqrt(Bx * Bx + Bz * Bz); + const float& Br = sqrt(Bx * Bx + By * By + Bz * Bz); + float cosA = 1; float sinA = 0; - if(fabs(Bxz) > 1.e-8f) - { - cosA = Bz/Bxz; - sinA = Bx/Bxz; - } - - const float& sinP = By/Br; - const float& cosP = Bxz/Br; - - const float param[6] = { cosA*fP[0] - sinA*fP[2], - -sinA*sinP*fP[0] + cosP*fP[1] - cosA*sinP*fP[2], - cosP*sinA*fP[0] + sinP*fP[1] + cosA*cosP*fP[2], - cosA*fP[3] - sinA*fP[5], - -sinA*sinP*fP[3] + cosP*fP[4] - cosA*sinP*fP[5], - cosP*sinA*fP[3] + sinP*fP[4] + cosA*cosP*fP[5]}; - const float point[3] = { cosA*xyz[0] - sinA*xyz[2], - -sinA*sinP*xyz[0] + cosP*xyz[1] - cosA*sinP*xyz[2], - cosP*sinA*xyz[0] + sinP*xyz[1] + cosA*cosP*xyz[2] }; - + if (fabs(Bxz) > 1.e-8f) { + cosA = Bz / Bxz; + sinA = Bx / Bxz; + } + + const float& sinP = By / Br; + const float& cosP = Bxz / Br; + + const float param[6] = {cosA * fP[0] - sinA * fP[2], + -sinA * sinP * fP[0] + cosP * fP[1] - cosA * sinP * fP[2], + cosP * sinA * fP[0] + sinP * fP[1] + cosA * cosP * fP[2], + cosA * fP[3] - sinA * fP[5], + -sinA * sinP * fP[3] + cosP * fP[4] - cosA * sinP * fP[5], + cosP * sinA * fP[3] + sinP * fP[4] + cosA * cosP * fP[5]}; + const float point[3] = {cosA * xyz[0] - sinA * xyz[2], + -sinA * sinP * xyz[0] + cosP * xyz[1] - cosA * sinP * xyz[2], + cosP * sinA * xyz[0] + sinP * xyz[1] + cosA * cosP * xyz[2]}; + float dsdrBz[6] = {0.f}; - + const float dS = GetDStoPointBz(Br, point, dsdrBz, param); - dsdr[0] = dsdrBz[0]*cosA - dsdrBz[1]*sinA*sinP + dsdrBz[2]*sinA*cosP; - dsdr[1] = dsdrBz[1]*cosP + dsdrBz[2]*sinP; - dsdr[2] = -dsdrBz[0]*sinA - dsdrBz[1]*cosA*sinP + dsdrBz[2]*cosA*cosP; - dsdr[3] = dsdrBz[3]*cosA - dsdrBz[4]*sinA*sinP + dsdrBz[5]*sinA*cosP; - dsdr[4] = dsdrBz[4]*cosP + dsdrBz[5]*sinP; - dsdr[5] = -dsdrBz[3]*sinA - dsdrBz[4]*cosA*sinP + dsdrBz[5]*cosA*cosP; - + dsdr[0] = dsdrBz[0] * cosA - dsdrBz[1] * sinA * sinP + dsdrBz[2] * sinA * cosP; + dsdr[1] = dsdrBz[1] * cosP + dsdrBz[2] * sinP; + dsdr[2] = -dsdrBz[0] * sinA - dsdrBz[1] * cosA * sinP + dsdrBz[2] * cosA * cosP; + dsdr[3] = dsdrBz[3] * cosA - dsdrBz[4] * sinA * sinP + dsdrBz[5] * sinA * cosP; + dsdr[4] = dsdrBz[4] * cosP + dsdrBz[5] * sinP; + dsdr[5] = -dsdrBz[3] * sinA - dsdrBz[4] * cosA * sinP + dsdrBz[5] * cosA * cosP; + return dS; } -float KFParticleBase::GetDStoPointCBM( const float xyz[3], float dsdr[6] ) const +float KFParticleBase::GetDStoPointCBM(const float xyz[3], float dsdr[6]) const { /** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n @@ -1875,14 +1903,14 @@ float KFParticleBase::GetDStoPointCBM( const float xyz[3], float dsdr[6] ) const float dS = 0; float fld[3]; - GetFieldValue( fP, fld ); - dS = GetDStoPointBy( fld[1], xyz, dsdr ); - + GetFieldValue(fP, fld); + dS = GetDStoPointBy(fld[1], xyz, dsdr); + return dS; } -void KFParticleBase::GetDStoParticleBz( float Bz, const KFParticleBase &p, float dS[2], float dsdr[4][6], const float* param1, const float* param2 ) const -{ +void KFParticleBase::GetDStoParticleBz(float Bz, const KFParticleBase& p, float dS[2], float dsdr[4][6], const float* param1, const float* param2) const +{ /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n ** 2) p - momentum of the particle; \n @@ -1905,31 +1933,29 @@ void KFParticleBase::GetDStoParticleBz( float Bz, const KFParticleBase &p, float ** \param[in] param2 - optional parameter, is used in case if the parameters of the second particles are rotated ** to other coordinate system (see GetDStoParticleBy() function), otherwise p.fP are used **/ - - if(!param1) - { + + if (!param1) { param1 = fP; param2 = p.fP; } //* Get dS to another particle for Bz field - const float kOvSqr6 = 1.f/sqrt(float(6.f)); + const float kOvSqr6 = 1.f / sqrt(float(6.f)); const float kCLight = 0.000299792458f; //in XY plane - //first root - const float& bq1 = Bz*fQ*kCLight; - const float& bq2 = Bz*p.fQ*kCLight; + //first root + const float& bq1 = Bz * fQ * kCLight; + const float& bq2 = Bz * p.fQ * kCLight; const bool& isStraight1 = fabs(bq1) < 1.e-8f; const bool& isStraight2 = fabs(bq2) < 1.e-8f; - - if( isStraight1 && isStraight2 ) - { + + if (isStraight1 && isStraight2) { GetDStoParticleLine(p, dS, dsdr); return; } - + const float& px1 = param1[3]; const float& py1 = param1[4]; const float& pz1 = param1[5]; @@ -1938,8 +1964,8 @@ void KFParticleBase::GetDStoParticleBz( float Bz, const KFParticleBase &p, float const float& py2 = param2[4]; const float& pz2 = param2[5]; - const float& pt12 = px1*px1 + py1*py1; - const float& pt22 = px2*px2 + py2*py2; + const float& pt12 = px1 * px1 + py1 * py1; + const float& pt22 = px2 * px2 + py2 * py2; const float& x01 = param1[0]; const float& y01 = param1[1]; @@ -1949,512 +1975,457 @@ void KFParticleBase::GetDStoParticleBz( float Bz, const KFParticleBase &p, float const float& y02 = param2[1]; const float& z02 = param2[2]; - float dS1[2] = {0.f}, dS2[2]={0.f}; - + float dS1[2] = {0.f}, dS2[2] = {0.f}; + const float& dx0 = (x01 - x02); const float& dy0 = (y01 - y02); - const float& dr02 = dx0*dx0 + dy0*dy0; - const float& drp1 = dx0*px1 + dy0*py1; - const float& dxyp1 = dx0*py1 - dy0*px1; - const float& drp2 = dx0*px2 + dy0*py2; - const float& dxyp2 = dx0*py2 - dy0*px2; - const float& p1p2 = px1*px2 + py1*py2; - const float& dp1p2 = px1*py2 - px2*py1; - - const float& k11 = (bq2*drp1 - dp1p2); - const float& k21 = (bq1*(bq2*dxyp1 - p1p2) + bq2*pt12); - const float& k12 = ((bq1*drp2 - dp1p2)); - const float& k22 = (bq2*(bq1*dxyp2 + p1p2) - bq1*pt22); - - const float& kp = (dxyp1*bq2 - dxyp2*bq1 - p1p2); - const float& kd = dr02/2.f*bq1*bq2 + kp; - const float& c1 = -(bq1*kd + pt12*bq2); - const float& c2 = bq2*kd + pt22*bq1; - - float d1 = pt12*pt22 - kd*kd; - if(d1<0.f) + const float& dr02 = dx0 * dx0 + dy0 * dy0; + const float& drp1 = dx0 * px1 + dy0 * py1; + const float& dxyp1 = dx0 * py1 - dy0 * px1; + const float& drp2 = dx0 * px2 + dy0 * py2; + const float& dxyp2 = dx0 * py2 - dy0 * px2; + const float& p1p2 = px1 * px2 + py1 * py2; + const float& dp1p2 = px1 * py2 - px2 * py1; + + const float& k11 = (bq2 * drp1 - dp1p2); + const float& k21 = (bq1 * (bq2 * dxyp1 - p1p2) + bq2 * pt12); + const float& k12 = ((bq1 * drp2 - dp1p2)); + const float& k22 = (bq2 * (bq1 * dxyp2 + p1p2) - bq1 * pt22); + + const float& kp = (dxyp1 * bq2 - dxyp2 * bq1 - p1p2); + const float& kd = dr02 / 2.f * bq1 * bq2 + kp; + const float& c1 = -(bq1 * kd + pt12 * bq2); + const float& c2 = bq2 * kd + pt22 * bq1; + + float d1 = pt12 * pt22 - kd * kd; + if (d1 < 0.f) d1 = float(0.f); - d1 = sqrt( d1 ); - float d2 = pt12*pt22 - kd*kd; - if(d2<0.f) + d1 = sqrt(d1); + float d2 = pt12 * pt22 - kd * kd; + if (d2 < 0.f) d2 = float(0.f); - d2 = sqrt( d2 ); - + d2 = sqrt(d2); + // find two points of closest approach in XY plane - + float dS1dR1[2][6]; float dS2dR2[2][6]; float dS1dR2[2][6]; float dS2dR1[2][6]; - float dk11dr1[6] = {bq2*px1, bq2*py1, 0, bq2*dx0 - py2, bq2*dy0 + px2, 0}; - float dk11dr2[6] = {-bq2*px1, -bq2*py1, 0, py1, -px1, 0}; - float dk12dr1[6] = {bq1*px2, bq1*py2, 0, -py2, px2, 0}; - float dk12dr2[6] = {-bq1*px2, -bq1*py2, 0, bq1*dx0 + py1, bq1*dy0 - px1, 0}; - float dk21dr1[6] = {bq1*bq2*py1, -bq1*bq2*px1, 0, 2*bq2*px1 + bq1*(-(bq2*dy0) - px2), 2*bq2*py1 + bq1*(bq2*dx0 - py2), 0}; - float dk21dr2[6] = {-(bq1*bq2*py1), bq1*bq2*px1, 0, -(bq1*px1), -(bq1*py1), 0}; - float dk22dr1[6] = {bq1*bq2*py2, -(bq1*bq2*px2), 0, bq2*px2, bq2*py2, 0}; - float dk22dr2[6] = {-(bq1*bq2*py2), bq1*bq2*px2, 0, bq2*(-(bq1*dy0) + px1) - 2*bq1*px2, bq2*(bq1*dx0 + py1) - 2*bq1*py2, 0}; - - float dkddr1[6] = {bq1*bq2*dx0 + bq2*py1 - bq1*py2, bq1*bq2*dy0 - bq2*px1 + bq1*px2, 0, -bq2*dy0 - px2, bq2*dx0 - py2, 0}; - float dkddr2[6] = {-bq1*bq2*dx0 - bq2*py1 + bq1*py2, -bq1*bq2*dy0 + bq2*px1 - bq1*px2, 0, bq1*dy0 - px1, -bq1*dx0 - py1, 0}; - - float dc1dr1[6] = {-(bq1*(bq1*bq2*dx0 + bq2*py1 - bq1*py2)), -(bq1*(bq1*bq2*dy0 - bq2*px1 + bq1*px2)), 0, -2*bq2*px1 - bq1*(-(bq2*dy0) - px2), -2*bq2*py1 - bq1*(bq2*dx0 - py2), 0}; - float dc1dr2[6] = {-(bq1*(-(bq1*bq2*dx0) - bq2*py1 + bq1*py2)), -(bq1*(-(bq1*bq2*dy0) + bq2*px1 - bq1*px2)), 0, -(bq1*(bq1*dy0 - px1)), -(bq1*(-(bq1*dx0) - py1)), 0}; - - float dc2dr1[6] = {bq2*(bq1*bq2*dx0 + bq2*py1 - bq1*py2), bq2*(bq1*bq2*dy0 - bq2*px1 + bq1*px2), 0, bq2*(-(bq2*dy0) - px2), bq2*(bq2*dx0 - py2), 0}; - float dc2dr2[6] = {bq2*(-(bq1*bq2*dx0) - bq2*py1 + bq1*py2), bq2*(-(bq1*bq2*dy0) + bq2*px1 - bq1*px2), 0, bq2*(bq1*dy0 - px1) + 2*bq1*px2, bq2*(-(bq1*dx0) - py1) + 2*bq1*py2, 0}; - - float dd1dr1[6] = {0,0,0,0,0,0}; - float dd1dr2[6] = {0,0,0,0,0,0}; - if(d1>0) - { - for(int i=0; i<6; i++) - { - dd1dr1[i] = -kd/d1*dkddr1[i]; - dd1dr2[i] = -kd/d1*dkddr2[i]; + float dk11dr1[6] = {bq2 * px1, bq2 * py1, 0, bq2 * dx0 - py2, bq2 * dy0 + px2, 0}; + float dk11dr2[6] = {-bq2 * px1, -bq2 * py1, 0, py1, -px1, 0}; + float dk12dr1[6] = {bq1 * px2, bq1 * py2, 0, -py2, px2, 0}; + float dk12dr2[6] = {-bq1 * px2, -bq1 * py2, 0, bq1 * dx0 + py1, bq1 * dy0 - px1, 0}; + float dk21dr1[6] = {bq1 * bq2 * py1, -bq1 * bq2 * px1, 0, 2 * bq2 * px1 + bq1 * (-(bq2 * dy0) - px2), 2 * bq2 * py1 + bq1 * (bq2 * dx0 - py2), 0}; + float dk21dr2[6] = {-(bq1 * bq2 * py1), bq1 * bq2 * px1, 0, -(bq1 * px1), -(bq1 * py1), 0}; + float dk22dr1[6] = {bq1 * bq2 * py2, -(bq1 * bq2 * px2), 0, bq2 * px2, bq2 * py2, 0}; + float dk22dr2[6] = {-(bq1 * bq2 * py2), bq1 * bq2 * px2, 0, bq2 * (-(bq1 * dy0) + px1) - 2 * bq1 * px2, bq2 * (bq1 * dx0 + py1) - 2 * bq1 * py2, 0}; + + float dkddr1[6] = {bq1 * bq2 * dx0 + bq2 * py1 - bq1 * py2, bq1 * bq2 * dy0 - bq2 * px1 + bq1 * px2, 0, -bq2 * dy0 - px2, bq2 * dx0 - py2, 0}; + float dkddr2[6] = {-bq1 * bq2 * dx0 - bq2 * py1 + bq1 * py2, -bq1 * bq2 * dy0 + bq2 * px1 - bq1 * px2, 0, bq1 * dy0 - px1, -bq1 * dx0 - py1, 0}; + + float dc1dr1[6] = {-(bq1 * (bq1 * bq2 * dx0 + bq2 * py1 - bq1 * py2)), -(bq1 * (bq1 * bq2 * dy0 - bq2 * px1 + bq1 * px2)), 0, -2 * bq2 * px1 - bq1 * (-(bq2 * dy0) - px2), -2 * bq2 * py1 - bq1 * (bq2 * dx0 - py2), 0}; + float dc1dr2[6] = {-(bq1 * (-(bq1 * bq2 * dx0) - bq2 * py1 + bq1 * py2)), -(bq1 * (-(bq1 * bq2 * dy0) + bq2 * px1 - bq1 * px2)), 0, -(bq1 * (bq1 * dy0 - px1)), -(bq1 * (-(bq1 * dx0) - py1)), 0}; + + float dc2dr1[6] = {bq2 * (bq1 * bq2 * dx0 + bq2 * py1 - bq1 * py2), bq2 * (bq1 * bq2 * dy0 - bq2 * px1 + bq1 * px2), 0, bq2 * (-(bq2 * dy0) - px2), bq2 * (bq2 * dx0 - py2), 0}; + float dc2dr2[6] = {bq2 * (-(bq1 * bq2 * dx0) - bq2 * py1 + bq1 * py2), bq2 * (-(bq1 * bq2 * dy0) + bq2 * px1 - bq1 * px2), 0, bq2 * (bq1 * dy0 - px1) + 2 * bq1 * px2, bq2 * (-(bq1 * dx0) - py1) + 2 * bq1 * py2, 0}; + + float dd1dr1[6] = {0, 0, 0, 0, 0, 0}; + float dd1dr2[6] = {0, 0, 0, 0, 0, 0}; + if (d1 > 0) { + for (int i = 0; i < 6; i++) { + dd1dr1[i] = -kd / d1 * dkddr1[i]; + dd1dr2[i] = -kd / d1 * dkddr2[i]; } - dd1dr1[3] += px1/d1*pt22; dd1dr1[4] += py1/d1*pt22; - dd1dr2[3] += px2/d1*pt12; dd1dr2[4] += py2/d1*pt12; - } - - if(!isStraight1) - { - dS1[0] = atan2( bq1*(k11*c1 + k21*d1), (bq1*k11*d1*bq1 - k21*c1) )/bq1; - dS1[1] = atan2( bq1*(k11*c1 - k21*d1), (-bq1*k11*d1*bq1 - k21*c1) )/bq1; - - float a = bq1*(k11*c1 + k21*d1); - float b = bq1*k11*d1*bq1 - k21*c1; - for(int iP=0; iP<6; iP++) - { - if(( b*b + a*a ) > 0) - { - const float dadr1 = bq1*( dk11dr1[iP]*c1 + k11*dc1dr1[iP] + dk21dr1[iP]*d1 + k21*dd1dr1[iP] ); - const float dadr2 = bq1*( dk11dr2[iP]*c1 + k11*dc1dr2[iP] + dk21dr2[iP]*d1 + k21*dd1dr2[iP] ); - const float dbdr1 = bq1*bq1*( dk11dr1[iP]*d1 + k11*dd1dr1[iP] ) - ( dk21dr1[iP]*c1 + k21*dc1dr1[iP] ); - const float dbdr2 = bq1*bq1*( dk11dr2[iP]*d1 + k11*dd1dr2[iP] ) - ( dk21dr2[iP]*c1 + k21*dc1dr2[iP] ); - - dS1dR1[0][iP] = 1/bq1 * 1/( b*b + a*a ) * ( dadr1*b - dbdr1*a ); - dS1dR2[0][iP] = 1/bq1 * 1/( b*b + a*a ) * ( dadr2*b - dbdr2*a ); - } - else - { + dd1dr1[3] += px1 / d1 * pt22; + dd1dr1[4] += py1 / d1 * pt22; + dd1dr2[3] += px2 / d1 * pt12; + dd1dr2[4] += py2 / d1 * pt12; + } + + if (!isStraight1) { + dS1[0] = atan2(bq1 * (k11 * c1 + k21 * d1), (bq1 * k11 * d1 * bq1 - k21 * c1)) / bq1; + dS1[1] = atan2(bq1 * (k11 * c1 - k21 * d1), (-bq1 * k11 * d1 * bq1 - k21 * c1)) / bq1; + + float a = bq1 * (k11 * c1 + k21 * d1); + float b = bq1 * k11 * d1 * bq1 - k21 * c1; + for (int iP = 0; iP < 6; iP++) { + if ((b * b + a * a) > 0) { + const float dadr1 = bq1 * (dk11dr1[iP] * c1 + k11 * dc1dr1[iP] + dk21dr1[iP] * d1 + k21 * dd1dr1[iP]); + const float dadr2 = bq1 * (dk11dr2[iP] * c1 + k11 * dc1dr2[iP] + dk21dr2[iP] * d1 + k21 * dd1dr2[iP]); + const float dbdr1 = bq1 * bq1 * (dk11dr1[iP] * d1 + k11 * dd1dr1[iP]) - (dk21dr1[iP] * c1 + k21 * dc1dr1[iP]); + const float dbdr2 = bq1 * bq1 * (dk11dr2[iP] * d1 + k11 * dd1dr2[iP]) - (dk21dr2[iP] * c1 + k21 * dc1dr2[iP]); + + dS1dR1[0][iP] = 1 / bq1 * 1 / (b * b + a * a) * (dadr1 * b - dbdr1 * a); + dS1dR2[0][iP] = 1 / bq1 * 1 / (b * b + a * a) * (dadr2 * b - dbdr2 * a); + } else { dS1dR1[0][iP] = 0; dS1dR2[0][iP] = 0; } } - - a = bq1*(k11*c1 - k21*d1); - b = -bq1*k11*d1*bq1 - k21*c1; - for(int iP=0; iP<6; iP++) - { - if(( b*b + a*a ) > 0) - { - const float dadr1 = bq1*( dk11dr1[iP]*c1 + k11*dc1dr1[iP] - (dk21dr1[iP]*d1 + k21*dd1dr1[iP]) ); - const float dadr2 = bq1*( dk11dr2[iP]*c1 + k11*dc1dr2[iP] - (dk21dr2[iP]*d1 + k21*dd1dr2[iP]) ); - const float dbdr1 = -bq1*bq1*( dk11dr1[iP]*d1 + k11*dd1dr1[iP] ) - ( dk21dr1[iP]*c1 + k21*dc1dr1[iP] ); - const float dbdr2 = -bq1*bq1*( dk11dr2[iP]*d1 + k11*dd1dr2[iP] ) - ( dk21dr2[iP]*c1 + k21*dc1dr2[iP] ); - - dS1dR1[1][iP] = 1/bq1 * 1/( b*b + a*a ) * ( dadr1*b - dbdr1*a ); - dS1dR2[1][iP] = 1/bq1 * 1/( b*b + a*a ) * ( dadr2*b - dbdr2*a ); - } - else - { + + a = bq1 * (k11 * c1 - k21 * d1); + b = -bq1 * k11 * d1 * bq1 - k21 * c1; + for (int iP = 0; iP < 6; iP++) { + if ((b * b + a * a) > 0) { + const float dadr1 = bq1 * (dk11dr1[iP] * c1 + k11 * dc1dr1[iP] - (dk21dr1[iP] * d1 + k21 * dd1dr1[iP])); + const float dadr2 = bq1 * (dk11dr2[iP] * c1 + k11 * dc1dr2[iP] - (dk21dr2[iP] * d1 + k21 * dd1dr2[iP])); + const float dbdr1 = -bq1 * bq1 * (dk11dr1[iP] * d1 + k11 * dd1dr1[iP]) - (dk21dr1[iP] * c1 + k21 * dc1dr1[iP]); + const float dbdr2 = -bq1 * bq1 * (dk11dr2[iP] * d1 + k11 * dd1dr2[iP]) - (dk21dr2[iP] * c1 + k21 * dc1dr2[iP]); + + dS1dR1[1][iP] = 1 / bq1 * 1 / (b * b + a * a) * (dadr1 * b - dbdr1 * a); + dS1dR2[1][iP] = 1 / bq1 * 1 / (b * b + a * a) * (dadr2 * b - dbdr2 * a); + } else { dS1dR1[1][iP] = 0; dS1dR2[1][iP] = 0; } } } - if(!isStraight2) - { - dS2[0] = atan2( (bq2*k12*c2 + k22*d2*bq2), (bq2*k12*d2*bq2 - k22*c2) )/bq2; - dS2[1] = atan2( (bq2*k12*c2 - k22*d2*bq2), (-bq2*k12*d2*bq2 - k22*c2) )/bq2; - - float a = bq2*(k12*c2 + k22*d2); - float b = bq2*k12*d2*bq2 - k22*c2; - for(int iP=0; iP<6; iP++) - { - if(( b*b + a*a ) > 0) - { - const float dadr1 = bq2*( dk12dr1[iP]*c2 + k12*dc2dr1[iP] + dk22dr1[iP]*d1 + k22*dd1dr1[iP] ); - const float dadr2 = bq2*( dk12dr2[iP]*c2 + k12*dc2dr2[iP] + dk22dr2[iP]*d1 + k22*dd1dr2[iP] ); - const float dbdr1 = bq2*bq2*( dk12dr1[iP]*d1 + k12*dd1dr1[iP] ) - (dk22dr1[iP]*c2 + k22*dc2dr1[iP]); - const float dbdr2 = bq2*bq2*( dk12dr2[iP]*d1 + k12*dd1dr2[iP] ) - (dk22dr2[iP]*c2 + k22*dc2dr2[iP]); - - dS2dR1[0][iP] = 1/bq2 * 1/( b*b + a*a ) * ( dadr1*b - dbdr1*a ); - dS2dR2[0][iP] = 1/bq2 * 1/( b*b + a*a ) * ( dadr2*b - dbdr2*a ); - } - else - { + if (!isStraight2) { + dS2[0] = atan2((bq2 * k12 * c2 + k22 * d2 * bq2), (bq2 * k12 * d2 * bq2 - k22 * c2)) / bq2; + dS2[1] = atan2((bq2 * k12 * c2 - k22 * d2 * bq2), (-bq2 * k12 * d2 * bq2 - k22 * c2)) / bq2; + + float a = bq2 * (k12 * c2 + k22 * d2); + float b = bq2 * k12 * d2 * bq2 - k22 * c2; + for (int iP = 0; iP < 6; iP++) { + if ((b * b + a * a) > 0) { + const float dadr1 = bq2 * (dk12dr1[iP] * c2 + k12 * dc2dr1[iP] + dk22dr1[iP] * d1 + k22 * dd1dr1[iP]); + const float dadr2 = bq2 * (dk12dr2[iP] * c2 + k12 * dc2dr2[iP] + dk22dr2[iP] * d1 + k22 * dd1dr2[iP]); + const float dbdr1 = bq2 * bq2 * (dk12dr1[iP] * d1 + k12 * dd1dr1[iP]) - (dk22dr1[iP] * c2 + k22 * dc2dr1[iP]); + const float dbdr2 = bq2 * bq2 * (dk12dr2[iP] * d1 + k12 * dd1dr2[iP]) - (dk22dr2[iP] * c2 + k22 * dc2dr2[iP]); + + dS2dR1[0][iP] = 1 / bq2 * 1 / (b * b + a * a) * (dadr1 * b - dbdr1 * a); + dS2dR2[0][iP] = 1 / bq2 * 1 / (b * b + a * a) * (dadr2 * b - dbdr2 * a); + } else { dS2dR1[0][iP] = 0; dS2dR2[0][iP] = 0; } } - - a = bq2*(k12*c2 - k22*d2); - b = -bq2*k12*d2*bq2 - k22*c2; - for(int iP=0; iP<6; iP++) - { - if(( b*b + a*a ) > 0) - { - const float dadr1 = bq2*( dk12dr1[iP]*c2 + k12*dc2dr1[iP] - (dk22dr1[iP]*d1 + k22*dd1dr1[iP]) ); - const float dadr2 = bq2*( dk12dr2[iP]*c2 + k12*dc2dr2[iP] - (dk22dr2[iP]*d1 + k22*dd1dr2[iP]) ); - const float dbdr1 = -bq2*bq2*( dk12dr1[iP]*d1 + k12*dd1dr1[iP] ) - (dk22dr1[iP]*c2 + k22*dc2dr1[iP]); - const float dbdr2 = -bq2*bq2*( dk12dr2[iP]*d1 + k12*dd1dr2[iP] ) - (dk22dr2[iP]*c2 + k22*dc2dr2[iP]); - - dS2dR1[1][iP] = 1/bq2 * 1/( b*b + a*a ) * ( dadr1*b - dbdr1*a ); - dS2dR2[1][iP] = 1/bq2 * 1/( b*b + a*a ) * ( dadr2*b - dbdr2*a ); - } - else - { + + a = bq2 * (k12 * c2 - k22 * d2); + b = -bq2 * k12 * d2 * bq2 - k22 * c2; + for (int iP = 0; iP < 6; iP++) { + if ((b * b + a * a) > 0) { + const float dadr1 = bq2 * (dk12dr1[iP] * c2 + k12 * dc2dr1[iP] - (dk22dr1[iP] * d1 + k22 * dd1dr1[iP])); + const float dadr2 = bq2 * (dk12dr2[iP] * c2 + k12 * dc2dr2[iP] - (dk22dr2[iP] * d1 + k22 * dd1dr2[iP])); + const float dbdr1 = -bq2 * bq2 * (dk12dr1[iP] * d1 + k12 * dd1dr1[iP]) - (dk22dr1[iP] * c2 + k22 * dc2dr1[iP]); + const float dbdr2 = -bq2 * bq2 * (dk12dr2[iP] * d1 + k12 * dd1dr2[iP]) - (dk22dr2[iP] * c2 + k22 * dc2dr2[iP]); + + dS2dR1[1][iP] = 1 / bq2 * 1 / (b * b + a * a) * (dadr1 * b - dbdr1 * a); + dS2dR2[1][iP] = 1 / bq2 * 1 / (b * b + a * a) * (dadr2 * b - dbdr2 * a); + } else { dS2dR1[1][iP] = 0; dS2dR2[1][iP] = 0; } } } - if(isStraight1 && (pt12>0.f) ) - { - dS1[0] = (k11*c1 + k21*d1)/(- k21*c1); - dS1[1] = (k11*c1 - k21*d1)/(- k21*c1); - - float a = k11*c1 + k21*d1; - float b = -k21*c1; - - for(int iP=0; iP<6; iP++) - { - if(b*b > 0) - { - const float dadr1 = ( dk11dr1[iP]*c1 + k11*dc1dr1[iP] + dk21dr1[iP]*d1 + k21*dd1dr1[iP] ); - const float dadr2 = ( dk11dr2[iP]*c1 + k11*dc1dr2[iP] + dk21dr2[iP]*d1 + k21*dd1dr2[iP] ); - const float dbdr1 = -( dk21dr1[iP]*c1 + k21*dc1dr1[iP] ); - const float dbdr2 = -( dk21dr2[iP]*c1 + k21*dc1dr2[iP] ); - - dS1dR1[0][iP] = dadr1/b - dbdr1*a/(b*b) ; - dS1dR2[0][iP] = dadr2/b - dbdr2*a/(b*b) ; - } - else - { + if (isStraight1 && (pt12 > 0.f)) { + dS1[0] = (k11 * c1 + k21 * d1) / (-k21 * c1); + dS1[1] = (k11 * c1 - k21 * d1) / (-k21 * c1); + + float a = k11 * c1 + k21 * d1; + float b = -k21 * c1; + + for (int iP = 0; iP < 6; iP++) { + if (b * b > 0) { + const float dadr1 = (dk11dr1[iP] * c1 + k11 * dc1dr1[iP] + dk21dr1[iP] * d1 + k21 * dd1dr1[iP]); + const float dadr2 = (dk11dr2[iP] * c1 + k11 * dc1dr2[iP] + dk21dr2[iP] * d1 + k21 * dd1dr2[iP]); + const float dbdr1 = -(dk21dr1[iP] * c1 + k21 * dc1dr1[iP]); + const float dbdr2 = -(dk21dr2[iP] * c1 + k21 * dc1dr2[iP]); + + dS1dR1[0][iP] = dadr1 / b - dbdr1 * a / (b * b); + dS1dR2[0][iP] = dadr2 / b - dbdr2 * a / (b * b); + } else { dS1dR1[0][iP] = 0; dS1dR2[0][iP] = 0; } } - - a = k11*c1 - k21*d1; - for(int iP=0; iP<6; iP++) - { - if(b*b > 0) - { - const float dadr1 = ( dk11dr1[iP]*c1 + k11*dc1dr1[iP] - dk21dr1[iP]*d1 - k21*dd1dr1[iP] ); - const float dadr2 = ( dk11dr2[iP]*c1 + k11*dc1dr2[iP] - dk21dr2[iP]*d1 - k21*dd1dr2[iP] ); - const float dbdr1 = -( dk21dr1[iP]*c1 + k21*dc1dr1[iP] ); - const float dbdr2 = -( dk21dr2[iP]*c1 + k21*dc1dr2[iP] ); - - dS1dR1[1][iP] = dadr1/b - dbdr1*a/(b*b) ; - dS1dR2[1][iP] = dadr2/b - dbdr2*a/(b*b) ; - } - else - { + + a = k11 * c1 - k21 * d1; + for (int iP = 0; iP < 6; iP++) { + if (b * b > 0) { + const float dadr1 = (dk11dr1[iP] * c1 + k11 * dc1dr1[iP] - dk21dr1[iP] * d1 - k21 * dd1dr1[iP]); + const float dadr2 = (dk11dr2[iP] * c1 + k11 * dc1dr2[iP] - dk21dr2[iP] * d1 - k21 * dd1dr2[iP]); + const float dbdr1 = -(dk21dr1[iP] * c1 + k21 * dc1dr1[iP]); + const float dbdr2 = -(dk21dr2[iP] * c1 + k21 * dc1dr2[iP]); + + dS1dR1[1][iP] = dadr1 / b - dbdr1 * a / (b * b); + dS1dR2[1][iP] = dadr2 / b - dbdr2 * a / (b * b); + } else { dS1dR1[1][iP] = 0; dS1dR2[1][iP] = 0; } } } - if(isStraight2 && (pt22>0.f) ) - { - dS2[0] = (k12*c2 + k22*d2)/(- k22*c2); - dS2[1] = (k12*c2 - k22*d2)/(- k22*c2); - - float a = k12*c2 + k22*d1; - float b = -k22*c2; - - for(int iP=0; iP<6; iP++) - { - if(b*b > 0) - { - const float dadr1 = ( dk12dr1[iP]*c2 + k12*dc2dr1[iP] + dk22dr1[iP]*d1 + k22*dd1dr1[iP] ); - const float dadr2 = ( dk12dr2[iP]*c2 + k12*dc2dr2[iP] + dk22dr2[iP]*d1 + k22*dd1dr2[iP] ); - const float dbdr1 = -( dk22dr1[iP]*c2 + k22*dc2dr1[iP] ); - const float dbdr2 = -( dk22dr2[iP]*c2 + k22*dc2dr2[iP] ); - - dS2dR1[0][iP] = dadr1/b - dbdr1*a/(b*b) ; - dS2dR2[0][iP] = dadr2/b - dbdr2*a/(b*b) ; - } - else - { + if (isStraight2 && (pt22 > 0.f)) { + dS2[0] = (k12 * c2 + k22 * d2) / (-k22 * c2); + dS2[1] = (k12 * c2 - k22 * d2) / (-k22 * c2); + + float a = k12 * c2 + k22 * d1; + float b = -k22 * c2; + + for (int iP = 0; iP < 6; iP++) { + if (b * b > 0) { + const float dadr1 = (dk12dr1[iP] * c2 + k12 * dc2dr1[iP] + dk22dr1[iP] * d1 + k22 * dd1dr1[iP]); + const float dadr2 = (dk12dr2[iP] * c2 + k12 * dc2dr2[iP] + dk22dr2[iP] * d1 + k22 * dd1dr2[iP]); + const float dbdr1 = -(dk22dr1[iP] * c2 + k22 * dc2dr1[iP]); + const float dbdr2 = -(dk22dr2[iP] * c2 + k22 * dc2dr2[iP]); + + dS2dR1[0][iP] = dadr1 / b - dbdr1 * a / (b * b); + dS2dR2[0][iP] = dadr2 / b - dbdr2 * a / (b * b); + } else { dS2dR1[0][iP] = 0; dS2dR2[0][iP] = 0; } } - - a = k12*c2 - k22*d1; - for(int iP=0; iP<6; iP++) - { - if(b*b > 0) - { - const float dadr1 = ( dk12dr1[iP]*c2 + k12*dc2dr1[iP] - dk22dr1[iP]*d1 - k22*dd1dr1[iP] ); - const float dadr2 = ( dk12dr2[iP]*c2 + k12*dc2dr2[iP] - dk22dr2[iP]*d1 - k22*dd1dr2[iP] ); - const float dbdr1 = -( dk22dr1[iP]*c2 + k22*dc2dr1[iP] ); - const float dbdr2 = -( dk22dr2[iP]*c2 + k22*dc2dr2[iP] ); - - dS2dR1[1][iP] = dadr1/b - dbdr1*a/(b*b) ; - dS2dR2[1][iP] = dadr2/b - dbdr2*a/(b*b) ; - } - else - { + + a = k12 * c2 - k22 * d1; + for (int iP = 0; iP < 6; iP++) { + if (b * b > 0) { + const float dadr1 = (dk12dr1[iP] * c2 + k12 * dc2dr1[iP] - dk22dr1[iP] * d1 - k22 * dd1dr1[iP]); + const float dadr2 = (dk12dr2[iP] * c2 + k12 * dc2dr2[iP] - dk22dr2[iP] * d1 - k22 * dd1dr2[iP]); + const float dbdr1 = -(dk22dr1[iP] * c2 + k22 * dc2dr1[iP]); + const float dbdr2 = -(dk22dr2[iP] * c2 + k22 * dc2dr2[iP]); + + dS2dR1[1][iP] = dadr1 / b - dbdr1 * a / (b * b); + dS2dR2[1][iP] = dadr2 / b - dbdr2 * a / (b * b); + } else { dS2dR1[1][iP] = 0; dS2dR2[1][iP] = 0; } } } - + //select a point which is close to the primary vertex (with the smallest r) - + float dr2[2]; - for(int iP = 0; iP<2; iP++) - { - const float& bs1 = bq1*dS1[iP]; - const float& bs2 = bq2*dS2[iP]; + for (int iP = 0; iP < 2; iP++) { + const float& bs1 = bq1 * dS1[iP]; + const float& bs2 = bq2 * dS2[iP]; float sss = sin(bs1), ccc = cos(bs1); - + const bool& bs1Big = fabs(bs1) > 1.e-8f; const bool& bs2Big = fabs(bs2) > 1.e-8f; - + float sB(0.f), cB(0.f); - if(bs1Big) - { - sB = sss/bq1; - cB = (1.f-ccc)/bq1; + if (bs1Big) { + sB = sss / bq1; + cB = (1.f - ccc) / bq1; + } else { + sB = ((1.f - bs1 * kOvSqr6) * (1.f + bs1 * kOvSqr6) * dS1[iP]); + cB = .5f * sB * bs1; } - else - { - sB = ((1.f-bs1*kOvSqr6)*(1.f+bs1*kOvSqr6)*dS1[iP]); - cB = .5f*sB*bs1; - } - - const float& x1 = param1[0] + sB*px1 + cB*py1; - const float& y1 = param1[1] - cB*px1 + sB*py1; - const float& z1 = param1[2] + dS1[iP]*param1[5]; + + const float& x1 = param1[0] + sB * px1 + cB * py1; + const float& y1 = param1[1] - cB * px1 + sB * py1; + const float& z1 = param1[2] + dS1[iP] * param1[5]; sss = sin(bs2), ccc = cos(bs2); - if(bs2Big) - { - sB = sss/bq2; - cB = (1.f-ccc)/bq2; - } - else - { - sB = ((1.f-bs2*kOvSqr6)*(1.f+bs2*kOvSqr6)*dS2[iP]); - cB = .5f*sB*bs2; + if (bs2Big) { + sB = sss / bq2; + cB = (1.f - ccc) / bq2; + } else { + sB = ((1.f - bs2 * kOvSqr6) * (1.f + bs2 * kOvSqr6) * dS2[iP]); + cB = .5f * sB * bs2; } - const float& x2 = param2[0] + sB*px2 + cB*py2; - const float& y2 = param2[1] - cB*px2 + sB*py2; - const float& z2 = param2[2] + dS2[iP]*param2[5]; + const float& x2 = param2[0] + sB * px2 + cB * py2; + const float& y2 = param2[1] - cB * px2 + sB * py2; + const float& z2 = param2[2] + dS2[iP] * param2[5]; - float dx = (x1-x2); - float dy = (y1-y2); - float dz = (z1-z2); - - dr2[iP] = dx*dx + dy*dy + dz*dz; + float dx = (x1 - x2); + float dy = (y1 - y2); + float dz = (z1 - z2); + + dr2[iP] = dx * dx + dy * dy + dz * dz; } - + const bool isFirstRoot = dr2[0] < dr2[1]; - if(isFirstRoot) - { - dS[0] = dS1[0]; + if (isFirstRoot) { + dS[0] = dS1[0]; dS[1] = dS2[0]; - - for(int iP=0; iP<6; iP++) - { + + for (int iP = 0; iP < 6; iP++) { dsdr[0][iP] = dS1dR1[0][iP]; dsdr[1][iP] = dS1dR2[0][iP]; dsdr[2][iP] = dS2dR1[0][iP]; dsdr[3][iP] = dS2dR2[0][iP]; } - } - else - { - dS[0] = dS1[1]; + } else { + dS[0] = dS1[1]; dS[1] = dS2[1]; - - for(int iP=0; iP<6; iP++) - { + + for (int iP = 0; iP < 6; iP++) { dsdr[0][iP] = dS1dR1[1][iP]; dsdr[1][iP] = dS1dR2[1][iP]; - dsdr[2][iP] = dS2dR1[1][iP]; + dsdr[2][iP] = dS2dR1[1][iP]; dsdr[3][iP] = dS2dR2[1][iP]; - } + } } - + //find correct parts of helices -// int n1(0); -// int n2(0); -// float dzMin = fabs( (z01-z02) + dS[0]*pz1 - dS[1]*pz2 ); -// const float pi2(6.283185307f); - + // int n1(0); + // int n2(0); + // float dzMin = fabs( (z01-z02) + dS[0]*pz1 - dS[1]*pz2 ); + // const float pi2(6.283185307f); + //TODO optimise for loops for neutral particles -// const float& i1Float = -bq1/pi2*(z01/pz1+dS[0]); -// for(int di1=-1; di1<=1; di1++) -// { -// int i1(0); -// if(!isStraight1) -// i1 = int(i1Float) + di1; -// -// const float& i2Float = ( ((z01-z02) + (dS[0]+pi2*i1/bq1)*pz1)/pz2 - dS[1]) * bq2/pi2; -// for(int di2 = -1; di2<=1; di2++) -// { -// int i2(0); -// if(!isStraight2) -// i2 = int(i2Float) + di2; -// -// const float& z1 = z01 + (dS[0]+pi2*i1/bq1)*pz1; -// const float& z2 = z02 + (dS[1]+pi2*i2/bq2)*pz2; -// const float& dz = fabs( z1-z2 ); -// -// if(dz < dzMin) -// { -// n1 = i1; -// n2 = i2; -// dzMin = dz; -// } -// } -// } -// -// if(!isStraight1) -// dS[0] += float(n1)*pi2/bq1; -// if(!isStraight2) -// dS[1] += float(n2)*pi2/bq2; + // const float& i1Float = -bq1/pi2*(z01/pz1+dS[0]); + // for(int di1=-1; di1<=1; di1++) + // { + // int i1(0); + // if(!isStraight1) + // i1 = int(i1Float) + di1; + // + // const float& i2Float = ( ((z01-z02) + (dS[0]+pi2*i1/bq1)*pz1)/pz2 - dS[1]) * bq2/pi2; + // for(int di2 = -1; di2<=1; di2++) + // { + // int i2(0); + // if(!isStraight2) + // i2 = int(i2Float) + di2; + // + // const float& z1 = z01 + (dS[0]+pi2*i1/bq1)*pz1; + // const float& z2 = z02 + (dS[1]+pi2*i2/bq2)*pz2; + // const float& dz = fabs( z1-z2 ); + // + // if(dz < dzMin) + // { + // n1 = i1; + // n2 = i2; + // dzMin = dz; + // } + // } + // } + // + // if(!isStraight1) + // dS[0] += float(n1)*pi2/bq1; + // if(!isStraight2) + // dS[1] += float(n2)*pi2/bq2; //Line correction { - const float& bs1 = bq1*dS[0]; - const float& bs2 = bq2*dS[1]; + const float& bs1 = bq1 * dS[0]; + const float& bs2 = bq2 * dS[1]; float sss = sin(bs1), ccc = cos(bs1); - + const bool& bs1Big = fabs(bs1) > 1.e-8f; const bool& bs2Big = fabs(bs2) > 1.e-8f; - + float sB(0.f), cB(0.f); - if(bs1Big) - { - sB = sss/bq1; - cB = (1.f-ccc)/bq1; + if (bs1Big) { + sB = sss / bq1; + cB = (1.f - ccc) / bq1; + } else { + sB = ((1.f - bs1 * kOvSqr6) * (1.f + bs1 * kOvSqr6) * dS[0]); + cB = .5f * sB * bs1; } - else - { - sB = ((1.f-bs1*kOvSqr6)*(1.f+bs1*kOvSqr6)*dS[0]); - cB = .5f*sB*bs1; - } - - const float& x1 = x01 + sB*px1 + cB*py1; - const float& y1 = y01 - cB*px1 + sB*py1; - const float& z1 = z01 + dS[0]*pz1; - const float& ppx1 = ccc*px1 + sss*py1; - const float& ppy1 = -sss*px1 + ccc*py1; + + const float& x1 = x01 + sB * px1 + cB * py1; + const float& y1 = y01 - cB * px1 + sB * py1; + const float& z1 = z01 + dS[0] * pz1; + const float& ppx1 = ccc * px1 + sss * py1; + const float& ppy1 = -sss * px1 + ccc * py1; const float& ppz1 = pz1; - + float sss1 = sin(bs2), ccc1 = cos(bs2); float sB1(0.f), cB1(0.f); - if(bs2Big) - { - sB1 = sss1/bq2; - cB1 = (1.f-ccc1)/bq2; - } - else - { - sB1 = ((1.f-bs2*kOvSqr6)*(1.f+bs2*kOvSqr6)*dS[1]); - cB1 = .5f*sB1*bs2; + if (bs2Big) { + sB1 = sss1 / bq2; + cB1 = (1.f - ccc1) / bq2; + } else { + sB1 = ((1.f - bs2 * kOvSqr6) * (1.f + bs2 * kOvSqr6) * dS[1]); + cB1 = .5f * sB1 * bs2; } - const float& x2 = x02 + sB1*px2 + cB1*py2; - const float& y2 = y02 - cB1*px2 + sB1*py2; - const float& z2 = z02 + dS[1]*pz2; - const float& ppx2 = ccc1*px2 + sss1*py2; - const float& ppy2 = -sss1*px2 + ccc1*py2; + const float& x2 = x02 + sB1 * px2 + cB1 * py2; + const float& y2 = y02 - cB1 * px2 + sB1 * py2; + const float& z2 = z02 + dS[1] * pz2; + const float& ppx2 = ccc1 * px2 + sss1 * py2; + const float& ppy2 = -sss1 * px2 + ccc1 * py2; const float& ppz2 = pz2; - const float& p12 = ppx1*ppx1 + ppy1*ppy1 + ppz1*ppz1; - const float& p22 = ppx2*ppx2 + ppy2*ppy2 + ppz2*ppz2; - const float& lp1p2 = ppx1*ppx2 + ppy1*ppy2 + ppz1*ppz2; + const float& p12 = ppx1 * ppx1 + ppy1 * ppy1 + ppz1 * ppz1; + const float& p22 = ppx2 * ppx2 + ppy2 * ppy2 + ppz2 * ppz2; + const float& lp1p2 = ppx1 * ppx2 + ppy1 * ppy2 + ppz1 * ppz2; const float& dx = (x2 - x1); const float& dy = (y2 - y1); const float& dz = (z2 - z1); - - const float& ldrp1 = ppx1*dx + ppy1*dy + ppz1*dz; - const float& ldrp2 = ppx2*dx + ppy2*dy + ppz2*dz; - float detp = lp1p2*lp1p2 - p12*p22; - if( fabs(detp)<1.e-4 ) detp = 1; //TODO correct!!! - + const float& ldrp1 = ppx1 * dx + ppy1 * dy + ppz1 * dz; + const float& ldrp2 = ppx2 * dx + ppy2 * dy + ppz2 * dz; + + float detp = lp1p2 * lp1p2 - p12 * p22; + if (fabs(detp) < 1.e-4) + detp = 1; //TODO correct!!! + //dsdr calculation - const float a1 = ldrp2*lp1p2 - ldrp1*p22; - const float a2 = ldrp2*p12 - ldrp1*lp1p2; - const float lp1p2_ds0 = bq1*( ppx2*ppy1 - ppy2*ppx1); - const float lp1p2_ds1 = bq2*( ppx1*ppy2 - ppy1*ppx2); - const float ldrp1_ds0 = -p12 + bq1*(ppy1*dx - ppx1*dy); - const float ldrp1_ds1 = lp1p2; + const float a1 = ldrp2 * lp1p2 - ldrp1 * p22; + const float a2 = ldrp2 * p12 - ldrp1 * lp1p2; + const float lp1p2_ds0 = bq1 * (ppx2 * ppy1 - ppy2 * ppx1); + const float lp1p2_ds1 = bq2 * (ppx1 * ppy2 - ppy1 * ppx2); + const float ldrp1_ds0 = -p12 + bq1 * (ppy1 * dx - ppx1 * dy); + const float ldrp1_ds1 = lp1p2; const float ldrp2_ds0 = -lp1p2; - const float ldrp2_ds1 = p22 + bq2*(ppy2*dx - ppx2*dy); - const float detp_ds0 = 2*lp1p2*lp1p2_ds0; - const float detp_ds1 = 2*lp1p2*lp1p2_ds1; - const float a1_ds0 = ldrp2_ds0*lp1p2 + ldrp2*lp1p2_ds0 - ldrp1_ds0*p22; - const float a1_ds1 = ldrp2_ds1*lp1p2 + ldrp2*lp1p2_ds1 - ldrp1_ds1*p22; - const float a2_ds0 = ldrp2_ds0*p12 - ldrp1_ds0*lp1p2 - ldrp1*lp1p2_ds0; - const float a2_ds1 = ldrp2_ds1*p12 - ldrp1_ds1*lp1p2 - ldrp1*lp1p2_ds1; - - const float dsl1ds0 = a1_ds0/detp - a1*detp_ds0/(detp*detp); - const float dsl1ds1 = a1_ds1/detp - a1*detp_ds1/(detp*detp); - const float dsl2ds0 = a2_ds0/detp - a2*detp_ds0/(detp*detp); - const float dsl2ds1 = a2_ds1/detp - a2*detp_ds1/(detp*detp); - + const float ldrp2_ds1 = p22 + bq2 * (ppy2 * dx - ppx2 * dy); + const float detp_ds0 = 2 * lp1p2 * lp1p2_ds0; + const float detp_ds1 = 2 * lp1p2 * lp1p2_ds1; + const float a1_ds0 = ldrp2_ds0 * lp1p2 + ldrp2 * lp1p2_ds0 - ldrp1_ds0 * p22; + const float a1_ds1 = ldrp2_ds1 * lp1p2 + ldrp2 * lp1p2_ds1 - ldrp1_ds1 * p22; + const float a2_ds0 = ldrp2_ds0 * p12 - ldrp1_ds0 * lp1p2 - ldrp1 * lp1p2_ds0; + const float a2_ds1 = ldrp2_ds1 * p12 - ldrp1_ds1 * lp1p2 - ldrp1 * lp1p2_ds1; + + const float dsl1ds0 = a1_ds0 / detp - a1 * detp_ds0 / (detp * detp); + const float dsl1ds1 = a1_ds1 / detp - a1 * detp_ds1 / (detp * detp); + const float dsl2ds0 = a2_ds0 / detp - a2 * detp_ds0 / (detp * detp); + const float dsl2ds1 = a2_ds1 / detp - a2 * detp_ds1 / (detp * detp); + float dsldr[4][6]; - for(int iP=0; iP<6; iP++) - { - dsldr[0][iP] = dsl1ds0*dsdr[0][iP] + dsl1ds1*dsdr[2][iP]; - dsldr[1][iP] = dsl1ds0*dsdr[1][iP] + dsl1ds1*dsdr[3][iP]; - dsldr[2][iP] = dsl2ds0*dsdr[0][iP] + dsl2ds1*dsdr[2][iP]; - dsldr[3][iP] = dsl2ds0*dsdr[1][iP] + dsl2ds1*dsdr[3][iP]; + for (int iP = 0; iP < 6; iP++) { + dsldr[0][iP] = dsl1ds0 * dsdr[0][iP] + dsl1ds1 * dsdr[2][iP]; + dsldr[1][iP] = dsl1ds0 * dsdr[1][iP] + dsl1ds1 * dsdr[3][iP]; + dsldr[2][iP] = dsl2ds0 * dsdr[0][iP] + dsl2ds1 * dsdr[2][iP]; + dsldr[3][iP] = dsl2ds0 * dsdr[1][iP] + dsl2ds1 * dsdr[3][iP]; } - - for(int iDS=0; iDS<4; iDS++) - for(int iP=0; iP<6; iP++) + + for (int iDS = 0; iDS < 4; iDS++) + for (int iP = 0; iP < 6; iP++) dsdr[iDS][iP] += dsldr[iDS][iP]; - - const float lp1p2_dr0[6] = {0, 0, 0, ccc*ppx2 - ppy2*sss, ccc*ppy2 + ppx2*sss, pz2}; - const float lp1p2_dr1[6] = {0, 0, 0, ccc1*ppx1 - ppy1*sss1, ccc1*ppy1 + ppx1*sss1, pz1}; - const float ldrp1_dr0[6] = {-ppx1, -ppy1, -pz1, cB*ppy1 - ppx1*sB + ccc*dx - sss*dy, -cB*ppx1-ppy1*sB + sss*dx + ccc*dy, -dS[0]*pz1 + dz}; - const float ldrp1_dr1[6] = { ppx1, ppy1, pz1, -cB1*ppy1 + ppx1*sB1, cB1*ppx1 + ppy1*sB1, dS[1]*pz1}; - const float ldrp2_dr0[6] = {-ppx2, -ppy2, -pz2, cB*ppy2 - ppx2*sB, -cB*ppx2-ppy2*sB, -dS[0]*pz2}; - const float ldrp2_dr1[6] = {ppx2, ppy2, pz2, -cB1*ppy2 + ppx2*sB1 + ccc1*dx- sss1*dy, cB1*ppx2 + ppy2*sB1 + sss1*dx + ccc1*dy, dz + dS[1]*pz2}; - const float p12_dr0[6] = {0, 0, 0, 2*px1, 2*py1, 2*pz1}; - const float p22_dr1[6] = {0, 0, 0, 2*px2, 2*py2, 2*pz2}; + + const float lp1p2_dr0[6] = {0, 0, 0, ccc * ppx2 - ppy2 * sss, ccc * ppy2 + ppx2 * sss, pz2}; + const float lp1p2_dr1[6] = {0, 0, 0, ccc1 * ppx1 - ppy1 * sss1, ccc1 * ppy1 + ppx1 * sss1, pz1}; + const float ldrp1_dr0[6] = {-ppx1, -ppy1, -pz1, cB * ppy1 - ppx1 * sB + ccc * dx - sss * dy, -cB * ppx1 - ppy1 * sB + sss * dx + ccc * dy, -dS[0] * pz1 + dz}; + const float ldrp1_dr1[6] = {ppx1, ppy1, pz1, -cB1 * ppy1 + ppx1 * sB1, cB1 * ppx1 + ppy1 * sB1, dS[1] * pz1}; + const float ldrp2_dr0[6] = {-ppx2, -ppy2, -pz2, cB * ppy2 - ppx2 * sB, -cB * ppx2 - ppy2 * sB, -dS[0] * pz2}; + const float ldrp2_dr1[6] = {ppx2, ppy2, pz2, -cB1 * ppy2 + ppx2 * sB1 + ccc1 * dx - sss1 * dy, cB1 * ppx2 + ppy2 * sB1 + sss1 * dx + ccc1 * dy, dz + dS[1] * pz2}; + const float p12_dr0[6] = {0, 0, 0, 2 * px1, 2 * py1, 2 * pz1}; + const float p22_dr1[6] = {0, 0, 0, 2 * px2, 2 * py2, 2 * pz2}; float a1_dr0[6], a1_dr1[6], a2_dr0[6], a2_dr1[6], detp_dr0[6], detp_dr1[6]; - for(int iP=0; iP<6; iP++) - { - a1_dr0[iP] = ldrp2_dr0[iP]*lp1p2 + ldrp2*lp1p2_dr0[iP] - ldrp1_dr0[iP]*p22; - a1_dr1[iP] = ldrp2_dr1[iP]*lp1p2 + ldrp2*lp1p2_dr1[iP] - ldrp1_dr1[iP]*p22 - ldrp1*p22_dr1[iP]; - a2_dr0[iP] = ldrp2_dr0[iP]*p12 + ldrp2*p12_dr0[iP] - ldrp1_dr0[iP]*lp1p2 - ldrp1*lp1p2_dr0[iP]; - a2_dr1[iP] = ldrp2_dr1[iP]*p12 - ldrp1_dr1[iP]*lp1p2 - ldrp1*lp1p2_dr1[iP]; - detp_dr0[iP] = 2*lp1p2*lp1p2_dr0[iP] - p12_dr0[iP]*p22; - detp_dr1[iP] = 2*lp1p2*lp1p2_dr1[iP] - p12*p22_dr1[iP]; - - dsdr[0][iP] += a1_dr0[iP]/detp - a1*detp_dr0[iP]/(detp*detp); - dsdr[1][iP] += a1_dr1[iP]/detp - a1*detp_dr1[iP]/(detp*detp); - dsdr[2][iP] += a2_dr0[iP]/detp - a2*detp_dr0[iP]/(detp*detp); - dsdr[3][iP] += a2_dr1[iP]/detp - a2*detp_dr1[iP]/(detp*detp); + for (int iP = 0; iP < 6; iP++) { + a1_dr0[iP] = ldrp2_dr0[iP] * lp1p2 + ldrp2 * lp1p2_dr0[iP] - ldrp1_dr0[iP] * p22; + a1_dr1[iP] = ldrp2_dr1[iP] * lp1p2 + ldrp2 * lp1p2_dr1[iP] - ldrp1_dr1[iP] * p22 - ldrp1 * p22_dr1[iP]; + a2_dr0[iP] = ldrp2_dr0[iP] * p12 + ldrp2 * p12_dr0[iP] - ldrp1_dr0[iP] * lp1p2 - ldrp1 * lp1p2_dr0[iP]; + a2_dr1[iP] = ldrp2_dr1[iP] * p12 - ldrp1_dr1[iP] * lp1p2 - ldrp1 * lp1p2_dr1[iP]; + detp_dr0[iP] = 2 * lp1p2 * lp1p2_dr0[iP] - p12_dr0[iP] * p22; + detp_dr1[iP] = 2 * lp1p2 * lp1p2_dr1[iP] - p12 * p22_dr1[iP]; + + dsdr[0][iP] += a1_dr0[iP] / detp - a1 * detp_dr0[iP] / (detp * detp); + dsdr[1][iP] += a1_dr1[iP] / detp - a1 * detp_dr1[iP] / (detp * detp); + dsdr[2][iP] += a2_dr0[iP] / detp - a2 * detp_dr0[iP] / (detp * detp); + dsdr[3][iP] += a2_dr1[iP] / detp - a2 * detp_dr1[iP] / (detp * detp); } - - dS[0] += (ldrp2*lp1p2 - ldrp1*p22) /detp; - dS[1] += (ldrp2*p12 - ldrp1*lp1p2)/detp; - } + + dS[0] += (ldrp2 * lp1p2 - ldrp1 * p22) / detp; + dS[1] += (ldrp2 * p12 - ldrp1 * lp1p2) / detp; + } } -void KFParticleBase::GetDStoParticleBy( float B, const KFParticleBase &p, float dS[2], float dsdr[4][6] ) const -{ +void KFParticleBase::GetDStoParticleBy(float B, const KFParticleBase& p, float dS[2], float dsdr[4][6]) const +{ /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n ** 2) p - momentum of the particle; \n @@ -2475,29 +2446,28 @@ void KFParticleBase::GetDStoParticleBy( float B, const KFParticleBase &p, float ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) ** \param[out] dsdr[4][6] - partial derivatives of the parameters dS[0] and dS[1] over the state vectors of the both particles **/ - - const float param1[6] = { fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4] }; - const float param2[6] = { p.fP[0], -p.fP[2], p.fP[1], p.fP[3], -p.fP[5], p.fP[4] }; - + + const float param1[6] = {fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4]}; + const float param2[6] = {p.fP[0], -p.fP[2], p.fP[1], p.fP[3], -p.fP[5], p.fP[4]}; + float dsdrBz[4][6]; - for(int i1=0; i1<4; i1++) - for(int i2=0; i2<6; i2++) + for (int i1 = 0; i1 < 4; i1++) + for (int i2 = 0; i2 < 6; i2++) dsdrBz[i1][i2] = 0; - + GetDStoParticleBz(B, p, dS, dsdrBz, param1, param2); - - for(int iDs=0; iDs<4; iDs++) - { - dsdr[iDs][0] = dsdrBz[iDs][0]; - dsdr[iDs][1] = dsdrBz[iDs][2]; + + for (int iDs = 0; iDs < 4; iDs++) { + dsdr[iDs][0] = dsdrBz[iDs][0]; + dsdr[iDs][1] = dsdrBz[iDs][2]; dsdr[iDs][2] = -dsdrBz[iDs][1]; - dsdr[iDs][3] = dsdrBz[iDs][3]; - dsdr[iDs][4] = dsdrBz[iDs][5]; + dsdr[iDs][3] = dsdrBz[iDs][3]; + dsdr[iDs][4] = dsdrBz[iDs][5]; dsdr[iDs][5] = -dsdrBz[iDs][4]; } } -void KFParticleBase::GetDStoParticleLine( const KFParticleBase &p, float dS[2], float dsdr[4][6] ) const +void KFParticleBase::GetDStoParticleLine(const KFParticleBase& p, float dS[2], float dsdr[4][6]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -2515,20 +2485,21 @@ void KFParticleBase::GetDStoParticleLine( const KFParticleBase &p, float dS[2], ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) ** \param[out] dsdr[4][6] - partial derivatives of the parameters dS[0] and dS[1] over the state vectors of the both particles **/ - - float p12 = fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]; - float p22 = p.fP[3]*p.fP[3] + p.fP[4]*p.fP[4] + p.fP[5]*p.fP[5]; - float p1p2 = fP[3]*p.fP[3] + fP[4]*p.fP[4] + fP[5]*p.fP[5]; - float drp1 = fP[3]*(p.fP[0]-fP[0]) + fP[4]*(p.fP[1]-fP[1]) + fP[5]*(p.fP[2]-fP[2]); - float drp2 = p.fP[3]*(p.fP[0]-fP[0]) + p.fP[4]*(p.fP[1]-fP[1]) + p.fP[5]*(p.fP[2]-fP[2]); + float p12 = fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]; + float p22 = p.fP[3] * p.fP[3] + p.fP[4] * p.fP[4] + p.fP[5] * p.fP[5]; + float p1p2 = fP[3] * p.fP[3] + fP[4] * p.fP[4] + fP[5] * p.fP[5]; + + float drp1 = fP[3] * (p.fP[0] - fP[0]) + fP[4] * (p.fP[1] - fP[1]) + fP[5] * (p.fP[2] - fP[2]); + float drp2 = p.fP[3] * (p.fP[0] - fP[0]) + p.fP[4] * (p.fP[1] - fP[1]) + p.fP[5] * (p.fP[2] - fP[2]); + + float detp = p1p2 * p1p2 - p12 * p22; + if (fabs(detp) < 1.e-4) + detp = 1; //TODO correct!!! - float detp = p1p2*p1p2 - p12*p22; - if( fabs(detp)<1.e-4 ) detp = 1; //TODO correct!!! + dS[0] = (drp2 * p1p2 - drp1 * p22) / detp; + dS[1] = (drp2 * p12 - drp1 * p1p2) / detp; - dS[0] = (drp2*p1p2 - drp1*p22) /detp; - dS[1] = (drp2*p12 - drp1*p1p2)/detp; - const float x01 = fP[0]; const float y01 = fP[1]; const float z01 = fP[2]; @@ -2542,42 +2513,40 @@ void KFParticleBase::GetDStoParticleLine( const KFParticleBase &p, float dS[2], const float px2 = p.fP[3]; const float py2 = p.fP[4]; const float pz2 = p.fP[5]; - + const float drp1_dr1[6] = {-px1, -py1, -pz1, -x01 + x02, -y01 + y02, -z01 + z02}; const float drp1_dr2[6] = {px1, py1, pz1, 0, 0, 0}; const float drp2_dr1[6] = {-px2, -py2, -pz2, 0, 0, 0}; const float drp2_dr2[6] = {px2, py2, pz2, -x01 + x02, -y01 + y02, -z01 + z02}; const float dp1p2_dr1[6] = {0, 0, 0, px2, py2, pz2}; const float dp1p2_dr2[6] = {0, 0, 0, px1, py1, pz1}; - const float dp12_dr1[6] = {0, 0, 0, 2*px1, 2*py1, 2*pz1}; + const float dp12_dr1[6] = {0, 0, 0, 2 * px1, 2 * py1, 2 * pz1}; const float dp12_dr2[6] = {0, 0, 0, 0, 0, 0}; const float dp22_dr1[6] = {0, 0, 0, 0, 0, 0}; - const float dp22_dr2[6] = {0, 0, 0, 2*px2, 2*py2, 2*pz2}; - const float ddetp_dr1[6] = {0, 0, 0, -2*p22*px1 + 2*p1p2*px2, -2*p22*py1 + 2*p1p2*py2, -2*p22*pz1 + 2*p1p2*pz2}; - const float ddetp_dr2[6] = {0, 0, 0, 2*p1p2*px1 - 2*p12*px2, 2*p1p2*py1 - 2*p12*py2, 2*p1p2*pz1 - 2*p12*pz2}; - - + const float dp22_dr2[6] = {0, 0, 0, 2 * px2, 2 * py2, 2 * pz2}; + const float ddetp_dr1[6] = {0, 0, 0, -2 * p22 * px1 + 2 * p1p2 * px2, -2 * p22 * py1 + 2 * p1p2 * py2, -2 * p22 * pz1 + 2 * p1p2 * pz2}; + const float ddetp_dr2[6] = {0, 0, 0, 2 * p1p2 * px1 - 2 * p12 * px2, 2 * p1p2 * py1 - 2 * p12 * py2, 2 * p1p2 * pz1 - 2 * p12 * pz2}; + float da1_dr1[6], da1_dr2[6], da2_dr1[6], da2_dr2[6]; - - const float a1 = drp2*p1p2 - drp1*p22; - const float a2 = drp2*p12 - drp1*p1p2; - for(int i=0; i<6; i++) - { - da1_dr1[i] = drp2_dr1[i]*p1p2 + drp2*dp1p2_dr1[i] - drp1_dr1[i]*p22 - drp1*dp22_dr1[i]; - da1_dr2[i] = drp2_dr2[i]*p1p2 + drp2*dp1p2_dr2[i] - drp1_dr2[i]*p22 - drp1*dp22_dr2[i]; - - da2_dr1[i] = drp2_dr1[i]*p12 + drp2*dp12_dr1[i] - drp1_dr1[i]*p1p2 - drp1*dp1p2_dr1[i]; - da2_dr2[i] = drp2_dr2[i]*p12 + drp2*dp12_dr2[i] - drp1_dr2[i]*p1p2 - drp1*dp1p2_dr2[i]; - - dsdr[0][i] = da1_dr1[i]/detp - a1/(detp*detp)*ddetp_dr1[i]; - dsdr[1][i] = da1_dr2[i]/detp - a1/(detp*detp)*ddetp_dr2[i]; - - dsdr[2][i] = da2_dr1[i]/detp - a2/(detp*detp)*ddetp_dr1[i]; - dsdr[3][i] = da2_dr2[i]/detp - a2/(detp*detp)*ddetp_dr2[i]; + + const float a1 = drp2 * p1p2 - drp1 * p22; + const float a2 = drp2 * p12 - drp1 * p1p2; + for (int i = 0; i < 6; i++) { + da1_dr1[i] = drp2_dr1[i] * p1p2 + drp2 * dp1p2_dr1[i] - drp1_dr1[i] * p22 - drp1 * dp22_dr1[i]; + da1_dr2[i] = drp2_dr2[i] * p1p2 + drp2 * dp1p2_dr2[i] - drp1_dr2[i] * p22 - drp1 * dp22_dr2[i]; + + da2_dr1[i] = drp2_dr1[i] * p12 + drp2 * dp12_dr1[i] - drp1_dr1[i] * p1p2 - drp1 * dp1p2_dr1[i]; + da2_dr2[i] = drp2_dr2[i] * p12 + drp2 * dp12_dr2[i] - drp1_dr2[i] * p1p2 - drp1 * dp1p2_dr2[i]; + + dsdr[0][i] = da1_dr1[i] / detp - a1 / (detp * detp) * ddetp_dr1[i]; + dsdr[1][i] = da1_dr2[i] / detp - a1 / (detp * detp) * ddetp_dr2[i]; + + dsdr[2][i] = da2_dr1[i] / detp - a2 / (detp * detp) * ddetp_dr1[i]; + dsdr[3][i] = da2_dr2[i] / detp - a2 / (detp * detp) * ddetp_dr2[i]; } } -void KFParticleBase::GetDStoParticleCBM( const KFParticleBase &p, float dS[2], float dsdr[4][6] ) const +void KFParticleBase::GetDStoParticleCBM(const KFParticleBase& p, float dS[2], float dsdr[4][6]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -2599,22 +2568,22 @@ void KFParticleBase::GetDStoParticleCBM( const KFParticleBase &p, float dS[2], f ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) ** \param[out] dsdr[4][6] - partial derivatives of the parameters dS[0] and dS[1] over the state vectors of the both particles **/ - + float fld[3]; - GetFieldValue( fP, fld ); - - const float& bq1 = fld[1]*fQ; - const float& bq2 = fld[1]*p.fQ; + GetFieldValue(fP, fld); + + const float& bq1 = fld[1] * fQ; + const float& bq2 = fld[1] * p.fQ; const bool& isStraight1 = fabs(bq1) < 1.e-8f; const bool& isStraight2 = fabs(bq2) < 1.e-8f; - - if( isStraight1 && isStraight2 ) + + if (isStraight1 && isStraight2) GetDStoParticleLine(p, dS, dsdr); else GetDStoParticleBy(fld[1], p, dS, dsdr); } -void KFParticleBase::TransportCBM( float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1) const +void KFParticleBase::TransportCBM(float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1) const { /** Transports the parameters and their covariance matrix of the current particle assuming CBM-like nonhomogeneous ** magnetic field on the length defined by the transport parameter dS = l/p, where l is the signed distance and p is @@ -2637,29 +2606,30 @@ void KFParticleBase::TransportCBM( float dS, const float* dsdr, float P[], float ** with the state vector r1, to which the current particle is being transported, F1 = d(fP new)/d(r1) **/ - if( fQ==0 ){ - TransportLine( dS, dsdr, P, C, dsdr1, F, F1 ); + if (fQ == 0) { + TransportLine(dS, dsdr, P, C, dsdr1, F, F1); return; } - if( fabs(dS*fP[5]) > 1000.f ) dS = 0; - + if (fabs(dS * fP[5]) > 1000.f) + dS = 0; + const float kCLight = 0.000299792458; - float c = fQ*kCLight; + float c = fQ * kCLight; + + // construct coefficients - // construct coefficients + float + px = fP[3], + py = fP[4], + pz = fP[5]; - float - px = fP[3], - py = fP[4], - pz = fP[5]; - - float sx=0, sy=0, sz=0, syy=0, syz=0, syyy=0, ssx=0, ssy=0, ssz=0, ssyy=0, ssyz=0, ssyyy=0; + float sx = 0, sy = 0, sz = 0, syy = 0, syz = 0, syyy = 0, ssx = 0, ssy = 0, ssz = 0, ssyy = 0, ssyz = 0, ssyyy = 0; { // get field integrals - float fld[3][3]; + float fld[3][3]; float p0[3], p1[3], p2[3]; // line track approximation @@ -2667,130 +2637,170 @@ void KFParticleBase::TransportCBM( float dS, const float* dsdr, float P[], float p0[0] = fP[0]; p0[1] = fP[1]; p0[2] = fP[2]; - - p2[0] = fP[0] + px*dS; - p2[1] = fP[1] + py*dS; - p2[2] = fP[2] + pz*dS; - - p1[0] = 0.5*(p0[0]+p2[0]); - p1[1] = 0.5*(p0[1]+p2[1]); - p1[2] = 0.5*(p0[2]+p2[2]); + + p2[0] = fP[0] + px * dS; + p2[1] = fP[1] + py * dS; + p2[2] = fP[2] + pz * dS; + + p1[0] = 0.5 * (p0[0] + p2[0]); + p1[1] = 0.5 * (p0[1] + p2[1]); + p1[2] = 0.5 * (p0[2] + p2[2]); // first order track approximation { - GetFieldValue( p0, fld[0] ); - GetFieldValue( p1, fld[1] ); - GetFieldValue( p2, fld[2] ); + GetFieldValue(p0, fld[0]); + GetFieldValue(p1, fld[1]); + GetFieldValue(p2, fld[2]); - float ssy1 = ( 7*fld[0][1] + 6*fld[1][1]-fld[2][1] )*c*dS*dS/96.; - float ssy2 = ( fld[0][1] + 2*fld[1][1] )*c*dS*dS/6.; + float ssy1 = (7 * fld[0][1] + 6 * fld[1][1] - fld[2][1]) * c * dS * dS / 96.; + float ssy2 = (fld[0][1] + 2 * fld[1][1]) * c * dS * dS / 6.; - p1[0] -= ssy1*pz; - p1[2] += ssy1*px; - p2[0] -= ssy2*pz; - p2[2] += ssy2*px; + p1[0] -= ssy1 * pz; + p1[2] += ssy1 * px; + p2[0] -= ssy2 * pz; + p2[2] += ssy2 * px; } - GetFieldValue( p0, fld[0] ); - GetFieldValue( p1, fld[1] ); - GetFieldValue( p2, fld[2] ); - - sx = c*( fld[0][0] + 4*fld[1][0] + fld[2][0] )*dS/6.; - sy = c*( fld[0][1] + 4*fld[1][1] + fld[2][1] )*dS/6.; - sz = c*( fld[0][2] + 4*fld[1][2] + fld[2][2] )*dS/6.; - - ssx = c*( fld[0][0] + 2*fld[1][0])*dS*dS/6.; - ssy = c*( fld[0][1] + 2*fld[1][1])*dS*dS/6.; - ssz = c*( fld[0][2] + 2*fld[1][2])*dS*dS/6.; - - float c2[3][3] = { { 5, -4, -1},{ 44, 80, -4},{ 11, 44, 5} }; // /=360. - float cc2[3][3] = { { 38, 8, -4},{ 148, 208, -20},{ 3, 36, 3} }; // /=2520. - for(Int_t n=0; n<3; n++) - for(Int_t m=0; m<3; m++) - { - syz += c2[n][m]*fld[n][1]*fld[m][2]; - ssyz += cc2[n][m]*fld[n][1]*fld[m][2]; + GetFieldValue(p0, fld[0]); + GetFieldValue(p1, fld[1]); + GetFieldValue(p2, fld[2]); + + sx = c * (fld[0][0] + 4 * fld[1][0] + fld[2][0]) * dS / 6.; + sy = c * (fld[0][1] + 4 * fld[1][1] + fld[2][1]) * dS / 6.; + sz = c * (fld[0][2] + 4 * fld[1][2] + fld[2][2]) * dS / 6.; + + ssx = c * (fld[0][0] + 2 * fld[1][0]) * dS * dS / 6.; + ssy = c * (fld[0][1] + 2 * fld[1][1]) * dS * dS / 6.; + ssz = c * (fld[0][2] + 2 * fld[1][2]) * dS * dS / 6.; + + float c2[3][3] = {{5, -4, -1}, {44, 80, -4}, {11, 44, 5}}; // /=360. + float cc2[3][3] = {{38, 8, -4}, {148, 208, -20}, {3, 36, 3}}; // /=2520. + for (Int_t n = 0; n < 3; n++) + for (Int_t m = 0; m < 3; m++) { + syz += c2[n][m] * fld[n][1] * fld[m][2]; + ssyz += cc2[n][m] * fld[n][1] * fld[m][2]; } - - syz *= c*c*dS*dS/360.; - ssyz *= c*c*dS*dS*dS/2520.; - - syy = c*( fld[0][1] + 4*fld[1][1] + fld[2][1] )*dS; - syyy = syy*syy*syy / 1296; - syy = syy*syy/72; - - ssyy = ( fld[0][1]*( 38*fld[0][1] + 156*fld[1][1] - fld[2][1] )+ - fld[1][1]*( 208*fld[1][1] +16*fld[2][1] )+ - fld[2][1]*( 3*fld[2][1] ) - )*dS*dS*dS*c*c/2520.; - ssyyy = - ( - fld[0][1]*( fld[0][1]*( 85*fld[0][1] + 526*fld[1][1] - 7*fld[2][1] )+ - fld[1][1]*( 1376*fld[1][1] +84*fld[2][1] )+ - fld[2][1]*( 19*fld[2][1] ) )+ - fld[1][1]*( fld[1][1]*( 1376*fld[1][1] +256*fld[2][1] )+ - fld[2][1]*( 62*fld[2][1] ) )+ - fld[2][1]*fld[2][1] *( 3*fld[2][1] ) - )*dS*dS*dS*dS*c*c*c/90720.; - + + syz *= c * c * dS * dS / 360.; + ssyz *= c * c * dS * dS * dS / 2520.; + + syy = c * (fld[0][1] + 4 * fld[1][1] + fld[2][1]) * dS; + syyy = syy * syy * syy / 1296; + syy = syy * syy / 72; + + ssyy = (fld[0][1] * (38 * fld[0][1] + 156 * fld[1][1] - fld[2][1]) + + fld[1][1] * (208 * fld[1][1] + 16 * fld[2][1]) + + fld[2][1] * (3 * fld[2][1])) * + dS * dS * dS * c * c / 2520.; + ssyyy = + (fld[0][1] * (fld[0][1] * (85 * fld[0][1] + 526 * fld[1][1] - 7 * fld[2][1]) + + fld[1][1] * (1376 * fld[1][1] + 84 * fld[2][1]) + + fld[2][1] * (19 * fld[2][1])) + + fld[1][1] * (fld[1][1] * (1376 * fld[1][1] + 256 * fld[2][1]) + + fld[2][1] * (62 * fld[2][1])) + + fld[2][1] * fld[2][1] * (3 * fld[2][1])) * + dS * dS * dS * dS * c * c * c / 90720.; } float mJ[8][8]; - for( Int_t i=0; i<8; i++ ) for( Int_t j=0; j<8; j++) mJ[i][j]=0; - - mJ[0][0]=1; mJ[0][1]=0; mJ[0][2]=0; mJ[0][3]=dS-ssyy; mJ[0][4]=ssx; mJ[0][5]=ssyyy-ssy; - mJ[1][0]=0; mJ[1][1]=1; mJ[1][2]=0; mJ[1][3]=-ssz; mJ[1][4]=dS; mJ[1][5]=ssx+ssyz; - mJ[2][0]=0; mJ[2][1]=0; mJ[2][2]=1; mJ[2][3]=ssy-ssyyy; mJ[2][4]=-ssx; mJ[2][5]=dS-ssyy; - - mJ[3][0]=0; mJ[3][1]=0; mJ[3][2]=0; mJ[3][3]=1-syy; mJ[3][4]=sx; mJ[3][5]=syyy-sy; - mJ[4][0]=0; mJ[4][1]=0; mJ[4][2]=0; mJ[4][3]=-sz; mJ[4][4]=1; mJ[4][5]=sx+syz; - mJ[5][0]=0; mJ[5][1]=0; mJ[5][2]=0; mJ[5][3]=sy-syyy; mJ[5][4]=-sx; mJ[5][5]=1-syy; + for (Int_t i = 0; i < 8; i++) + for (Int_t j = 0; j < 8; j++) + mJ[i][j] = 0; + + mJ[0][0] = 1; + mJ[0][1] = 0; + mJ[0][2] = 0; + mJ[0][3] = dS - ssyy; + mJ[0][4] = ssx; + mJ[0][5] = ssyyy - ssy; + mJ[1][0] = 0; + mJ[1][1] = 1; + mJ[1][2] = 0; + mJ[1][3] = -ssz; + mJ[1][4] = dS; + mJ[1][5] = ssx + ssyz; + mJ[2][0] = 0; + mJ[2][1] = 0; + mJ[2][2] = 1; + mJ[2][3] = ssy - ssyyy; + mJ[2][4] = -ssx; + mJ[2][5] = dS - ssyy; + + mJ[3][0] = 0; + mJ[3][1] = 0; + mJ[3][2] = 0; + mJ[3][3] = 1 - syy; + mJ[3][4] = sx; + mJ[3][5] = syyy - sy; + mJ[4][0] = 0; + mJ[4][1] = 0; + mJ[4][2] = 0; + mJ[4][3] = -sz; + mJ[4][4] = 1; + mJ[4][5] = sx + syz; + mJ[5][0] = 0; + mJ[5][1] = 0; + mJ[5][2] = 0; + mJ[5][3] = sy - syyy; + mJ[5][4] = -sx; + mJ[5][5] = 1 - syy; mJ[6][6] = mJ[7][7] = 1; - - P[0] = fP[0] + mJ[0][3]*px + mJ[0][4]*py + mJ[0][5]*pz; - P[1] = fP[1] + mJ[1][3]*px + mJ[1][4]*py + mJ[1][5]*pz; - P[2] = fP[2] + mJ[2][3]*px + mJ[2][4]*py + mJ[2][5]*pz; - P[3] = mJ[3][3]*px + mJ[3][4]*py + mJ[3][5]*pz; - P[4] = mJ[4][3]*px + mJ[4][4]*py + mJ[4][5]*pz; - P[5] = mJ[5][3]*px + mJ[5][4]*py + mJ[5][5]*pz; + + P[0] = fP[0] + mJ[0][3] * px + mJ[0][4] * py + mJ[0][5] * pz; + P[1] = fP[1] + mJ[1][3] * px + mJ[1][4] * py + mJ[1][5] * pz; + P[2] = fP[2] + mJ[2][3] * px + mJ[2][4] * py + mJ[2][5] * pz; + P[3] = mJ[3][3] * px + mJ[3][4] * py + mJ[3][5] * pz; + P[4] = mJ[4][3] * px + mJ[4][4] * py + mJ[4][5] * pz; + P[5] = mJ[5][3] * px + mJ[5][4] * py + mJ[5][5] * pz; P[6] = fP[6]; P[7] = fP[7]; float mJds[6][6]; - for( Int_t i=0; i<6; i++ ) for( Int_t j=0; j<6; j++) mJds[i][j]=0; - - if(fabs(dS)>0) - { - mJds[0][3]= 1 - 3*ssyy/dS; mJds[0][4]= 2*ssx/dS; mJds[0][5]= (4.f*ssyyy-2*ssy)/dS; - mJds[1][3]= -2.f*ssz/dS; mJds[1][4]= 1; mJds[1][5]= (2.f*ssx + 3.*ssyz)/dS; - mJds[2][3]= (2.f*ssy-4.f*ssyyy)/dS; mJds[2][4]=-2*ssx/dS; mJds[2][5]= 1 - 3.f*ssyy/dS; - - mJds[3][3]= -2.f*syy/dS; mJds[3][4]= sx/dS; mJds[3][5]= 3.f*syyy/dS - sy/dS; - mJds[4][3]= -sz/dS; mJds[4][4]=0; mJds[4][5] = sx/dS + 2.f*syz/dS; - mJds[5][3]= sy/dS - 3.f*syyy/dS; mJds[5][4]=-sx/dS; mJds[5][5]= -2.f*syy/dS; - } - - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - mJ[i1][i2] += mJds[i1][3]*px*dsdr[i2] + mJds[i1][4]*py*dsdr[i2] + mJds[i1][5]*pz*dsdr[i2]; - - MultQSQt( mJ[0], fC, C, 8); - - if(F) - { - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - F[i*6+j] = mJ[i][j]; - - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - F1[i1*6 + i2] = mJds[i1][3]*px*dsdr1[i2] + mJds[i1][4]*py*dsdr1[i2] + mJds[i1][5]*pz*dsdr1[i2]; + for (Int_t i = 0; i < 6; i++) + for (Int_t j = 0; j < 6; j++) + mJds[i][j] = 0; + + if (fabs(dS) > 0) { + mJds[0][3] = 1 - 3 * ssyy / dS; + mJds[0][4] = 2 * ssx / dS; + mJds[0][5] = (4.f * ssyyy - 2 * ssy) / dS; + mJds[1][3] = -2.f * ssz / dS; + mJds[1][4] = 1; + mJds[1][5] = (2.f * ssx + 3. * ssyz) / dS; + mJds[2][3] = (2.f * ssy - 4.f * ssyyy) / dS; + mJds[2][4] = -2 * ssx / dS; + mJds[2][5] = 1 - 3.f * ssyy / dS; + + mJds[3][3] = -2.f * syy / dS; + mJds[3][4] = sx / dS; + mJds[3][5] = 3.f * syyy / dS - sy / dS; + mJds[4][3] = -sz / dS; + mJds[4][4] = 0; + mJds[4][5] = sx / dS + 2.f * syz / dS; + mJds[5][3] = sy / dS - 3.f * syyy / dS; + mJds[5][4] = -sx / dS; + mJds[5][5] = -2.f * syy / dS; + } + + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + + MultQSQt(mJ[0], fC, C, 8); + + if (F) { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) + F[i * 6 + j] = mJ[i][j]; + + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; } } - -void KFParticleBase::TransportBz( float Bz, float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1 ) const -{ +void KFParticleBase::TransportBz(float Bz, float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1) const +{ /** Transports the parameters and their covariance matrix of the current particle assuming constant homogeneous ** magnetic field Bz on the length defined by the transport parameter dS = l/p, where l is the signed distance and p is ** the momentum of the current particle. The obtained parameters and covariance matrix are stored to the arrays P and @@ -2811,128 +2821,137 @@ void KFParticleBase::TransportBz( float Bz, float dS, const float* dsdr, float P ** \param[out] F[36] - optional parameter, transport jacobian, 6x6 matrix F = d(fP new)/d(fP old) ** \param[out] F1[36] - optional parameter, corelation 6x6 matrix betweeen the current particle and particle or vertex ** with the state vector r1, to which the current particle is being transported, F1 = d(fP new)/d(r1) - **/ - + **/ + const float kCLight = 0.000299792458; - Bz = Bz*fQ*kCLight; - float bs= Bz*dS; + Bz = Bz * fQ * kCLight; + float bs = Bz * dS; float s = sin(bs), c = cos(bs); float sB, cB; - if( fabs(bs)>1.e-10){ - sB= s/Bz; - cB= (1-c)/Bz; - }else{ - const float kOvSqr6 = 1./sqrt(6.); - sB = (1.-bs*kOvSqr6)*(1.+bs*kOvSqr6)*dS; - cB = .5*sB*bs; - } - + if (fabs(bs) > 1.e-10) { + sB = s / Bz; + cB = (1 - c) / Bz; + } else { + const float kOvSqr6 = 1. / sqrt(6.); + sB = (1. - bs * kOvSqr6) * (1. + bs * kOvSqr6) * dS; + cB = .5 * sB * bs; + } + float px = fP[3]; float py = fP[4]; float pz = fP[5]; - P[0] = fP[0] + sB*px + cB*py; - P[1] = fP[1] - cB*px + sB*py; - P[2] = fP[2] + dS*pz; - P[3] = c*px + s*py; - P[4] = -s*px + c*py; + P[0] = fP[0] + sB * px + cB * py; + P[1] = fP[1] - cB * px + sB * py; + P[2] = fP[2] + dS * pz; + P[3] = c * px + s * py; + P[4] = -s * px + c * py; P[5] = fP[5]; P[6] = fP[6]; P[7] = fP[7]; float mJ[8][8]; - for( Int_t i=0; i<8; i++ ) for( Int_t j=0; j<8; j++) mJ[i][j]=0; - - for(int i=0; i<8; i++) mJ[i][i]=1; - mJ[0][3] = sB; mJ[0][4] = cB; - mJ[1][3] = -cB; mJ[1][4] = sB; + for (Int_t i = 0; i < 8; i++) + for (Int_t j = 0; j < 8; j++) + mJ[i][j] = 0; + + for (int i = 0; i < 8; i++) + mJ[i][i] = 1; + mJ[0][3] = sB; + mJ[0][4] = cB; + mJ[1][3] = -cB; + mJ[1][4] = sB; mJ[2][5] = dS; - mJ[3][3] = c; mJ[3][4] = s; - mJ[4][3] = -s; mJ[4][4] = c; - - + mJ[3][3] = c; + mJ[3][4] = s; + mJ[4][3] = -s; + mJ[4][4] = c; + float mJds[6][6]; - for( Int_t i=0; i<6; i++ ) for( Int_t j=0; j<6; j++) mJds[i][j]=0; - mJds[0][3] = c; mJds[0][4] = s; - mJds[1][3] = -s; mJds[1][4] = c; + for (Int_t i = 0; i < 6; i++) + for (Int_t j = 0; j < 6; j++) + mJds[i][j] = 0; + mJds[0][3] = c; + mJds[0][4] = s; + mJds[1][3] = -s; + mJds[1][4] = c; mJds[2][5] = 1; - mJds[3][3] = -Bz*s; mJds[3][4] = Bz*c; - mJds[4][3] = -Bz*c; mJds[4][4] = -Bz*s; - - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - mJ[i1][i2] += mJds[i1][3]*px*dsdr[i2] + mJds[i1][4]*py*dsdr[i2] + mJds[i1][5]*pz*dsdr[i2]; - - MultQSQt( mJ[0], fC, C, 8); - - if(F) - { - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - F[i*6+j] = mJ[i][j]; + mJds[3][3] = -Bz * s; + mJds[3][4] = Bz * c; + mJds[4][3] = -Bz * c; + mJds[4][4] = -Bz * s; + + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + + MultQSQt(mJ[0], fC, C, 8); - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - F1[i1*6 + i2] = mJds[i1][3]*px*dsdr1[i2] + mJds[i1][4]*py*dsdr1[i2] + mJds[i1][5]*pz*dsdr1[i2]; + if (F) { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) + F[i * 6 + j] = mJ[i][j]; + + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; } } - -float KFParticleBase::GetDistanceFromVertex( const KFParticleBase &Vtx ) const +float KFParticleBase::GetDistanceFromVertex(const KFParticleBase& Vtx) const { /** Returns the DCA distance from vertex in the KFParticle format in 3D. ** \param[in] Vtx - the vertex in the KFParticle format **/ - return GetDistanceFromVertex( Vtx.fP ); + return GetDistanceFromVertex(Vtx.fP); } -float KFParticleBase::GetDistanceFromVertex( const float vtx[] ) const +float KFParticleBase::GetDistanceFromVertex(const float vtx[]) const { /** Returns the DCA distance from vertex in 3D. ** \param[in] vtx[3] - the vertex coordinates {X, Y, Z} **/ - - float mP[8], mC[36]; - + + float mP[8], mC[36]; + float dsdr[6] = {0.f}; const float dS = GetDStoPoint(vtx, dsdr); - - Transport( dS, dsdr, mP, mC ); - float d[3]={ vtx[0]-mP[0], vtx[1]-mP[1], vtx[2]-mP[2]}; - return sqrt( d[0]*d[0]+d[1]*d[1]+d[2]*d[2] ); + + Transport(dS, dsdr, mP, mC); + float d[3] = {vtx[0] - mP[0], vtx[1] - mP[1], vtx[2] - mP[2]}; + return sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); } -float KFParticleBase::GetDistanceFromParticle( const KFParticleBase &p ) +float KFParticleBase::GetDistanceFromParticle(const KFParticleBase& p) const -{ +{ /** Returns the DCA distance from another particle p. ** \param[in] p - the second particle **/ - + float dsdr[4][6]; float dS[2]; - GetDStoParticle( p, dS, dsdr ); + GetDStoParticle(p, dS, dsdr); float mP[8], mC[36], mP1[8], mC1[36]; - Transport( dS[0], dsdr[0], mP, mC ); - p.Transport( dS[1], dsdr[3], mP1, mC1 ); - float dx = mP[0]-mP1[0]; - float dy = mP[1]-mP1[1]; - float dz = mP[2]-mP1[2]; - return sqrt(dx*dx+dy*dy+dz*dz); + Transport(dS[0], dsdr[0], mP, mC); + p.Transport(dS[1], dsdr[3], mP1, mC1); + float dx = mP[0] - mP1[0]; + float dy = mP[1] - mP1[1]; + float dz = mP[2] - mP1[2]; + return sqrt(dx * dx + dy * dy + dz * dz); } -float KFParticleBase::GetDeviationFromVertex( const KFParticleBase &Vtx ) const +float KFParticleBase::GetDeviationFromVertex(const KFParticleBase& Vtx) const { /** Returns Chi2 deviation of the current particle from the vertex in the KFParticle format in 3D. ** \param[in] Vtx - the vertex in KFPartcile format **/ - return GetDeviationFromVertex( Vtx.fP, Vtx.fC ); + return GetDeviationFromVertex(Vtx.fP, Vtx.fC); } - -float KFParticleBase::GetDeviationFromVertex( const float v[], const float Cv[] ) const +float KFParticleBase::GetDeviationFromVertex(const float v[], const float Cv[]) const { /** Returns Chi2 deviation of the current particle from the vertex v with the covariance matrix Cv in 3D. ** \param[in] v[3] - coordinates of the vertex {X, Y, Z} @@ -2941,38 +2960,32 @@ float KFParticleBase::GetDeviationFromVertex( const float v[], const float Cv[] float mP[8]; float mC[36]; - float dsdr[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; + float dsdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; const float dS = GetDStoPoint(v, dsdr); float dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0, 0, 0}; float F[36], F1[36]; - for(int i2=0; i2<36; i2++) - { - F[i2] = 0; + for (int i2 = 0; i2 < 36; i2++) { + F[i2] = 0; F1[i2] = 0; } - Transport( dS, dsdr, mP, mC, dsdp, F, F1 ); + Transport(dS, dsdr, mP, mC, dsdp, F, F1); - if(Cv) - { + if (Cv) { float VFT[3][6]; - for(int i=0; i<3; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 6; j++) { VFT[i][j] = 0; - for(int k=0; k<3; k++) - { - VFT[i][j] += Cv[IJ(i,k)] * F1[j*6+k]; + for (int k = 0; k < 3; k++) { + VFT[i][j] += Cv[IJ(i, k)] * F1[j * 6 + k]; } } - + float FVFT[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { FVFT[i][j] = 0; - for(int k=0; k<3; k++) - { - FVFT[i][j] += F1[i*6+k] * VFT[k][j]; + for (int k = 0; k < 3; k++) { + FVFT[i][j] += F1[i * 6 + k] * VFT[k][j]; } } mC[0] += FVFT[0][0] + Cv[0]; @@ -2982,122 +2995,117 @@ float KFParticleBase::GetDeviationFromVertex( const float v[], const float Cv[] mC[4] += FVFT[2][1] + Cv[4]; mC[5] += FVFT[2][2] + Cv[5]; } - + InvertCholetsky3(mC); - - float d[3]={ v[0]-mP[0], v[1]-mP[1], v[2]-mP[2]}; - return ( ( mC[0]*d[0] + mC[1]*d[1] + mC[3]*d[2])*d[0] - +(mC[1]*d[0] + mC[2]*d[1] + mC[4]*d[2])*d[1] - +(mC[3]*d[0] + mC[4]*d[1] + mC[5]*d[2])*d[2] ); -} + float d[3] = {v[0] - mP[0], v[1] - mP[1], v[2] - mP[2]}; + return ((mC[0] * d[0] + mC[1] * d[1] + mC[3] * d[2]) * d[0] + (mC[1] * d[0] + mC[2] * d[1] + mC[4] * d[2]) * d[1] + (mC[3] * d[0] + mC[4] * d[1] + mC[5] * d[2]) * d[2]); +} -float KFParticleBase::GetDeviationFromParticle( const KFParticleBase &p ) const -{ +float KFParticleBase::GetDeviationFromParticle(const KFParticleBase& p) const +{ /** Returns Chi2 deviation of the current particle from another particle in 3D. ** \param[in] p - the second particle **/ - - float ds[2] = {0.f,0.f}; + + float ds[2] = {0.f, 0.f}; float dsdr[4][6]; float F1[36], F2[36], F3[36], F4[36]; - for(int i1=0; i1<36; i1++) - { + for (int i1 = 0; i1 < 36; i1++) { F1[i1] = 0; F2[i1] = 0; F3[i1] = 0; F4[i1] = 0; } - GetDStoParticle( p, ds, dsdr ); - + GetDStoParticle(p, ds, dsdr); + float V0Tmp[36] = {0.}; float V1Tmp[36] = {0.}; - float mP1[8], mC1[36]; - float mP2[8], mC2[36]; - - Transport(ds[0], dsdr[0], mP1, mC1, dsdr[1], F1, F2); + float mP2[8], mC2[36]; + + Transport(ds[0], dsdr[0], mP1, mC1, dsdr[1], F1, F2); p.Transport(ds[1], dsdr[3], mP2, mC2, dsdr[2], F4, F3); - + MultQSQt(F2, p.fC, V0Tmp, 6); - MultQSQt(F3, fC, V1Tmp, 6); - - for(int iC=0; iC<6; iC++) - mC1[iC] += V0Tmp[iC] + mC2[iC] + V1Tmp[iC]; + MultQSQt(F3, fC, V1Tmp, 6); - float d[3]={ mP2[0]-mP1[0], mP2[1]-mP1[1], mP2[2]-mP1[2]}; - - return ( ( mC1[0]*d[0] + mC1[1]*d[1] + mC1[3]*d[2])*d[0] - +(mC1[1]*d[0] + mC1[2]*d[1] + mC1[4]*d[2])*d[1] - +(mC1[3]*d[0] + mC1[4]*d[1] + mC1[5]*d[2])*d[2] ); -} + for (int iC = 0; iC < 6; iC++) + mC1[iC] += V0Tmp[iC] + mC2[iC] + V1Tmp[iC]; + float d[3] = {mP2[0] - mP1[0], mP2[1] - mP1[1], mP2[2] - mP1[2]}; + return ((mC1[0] * d[0] + mC1[1] * d[1] + mC1[3] * d[2]) * d[0] + (mC1[1] * d[0] + mC1[2] * d[1] + mC1[4] * d[2]) * d[1] + (mC1[3] * d[0] + mC1[4] * d[1] + mC1[5] * d[2]) * d[2]); +} -void KFParticleBase::SubtractFromVertex( KFParticleBase &Vtx ) const +void KFParticleBase::SubtractFromVertex(KFParticleBase& Vtx) const { /** Subtract the current particle from vertex Vtx using the Kalman filter mathematics. ** \param[in] Vtx - vertex from which particle should be subtracted **/ - + float m[8]; float mCm[36]; float D[3][3]; - Vtx.GetMeasurement( *this, m, mCm, D ); - //* - - float mS[6] = { mCm[0] - Vtx.fC[0] + (D[0][0] + D[0][0]), - mCm[1] - Vtx.fC[1] + (D[1][0] + D[0][1]), mCm[2] - Vtx.fC[2] + (D[1][1] + D[1][1]), - mCm[3] - Vtx.fC[3] + (D[2][0] + D[0][2]), mCm[4] - Vtx.fC[4] + (D[1][2] + D[2][1]), mCm[5] - Vtx.fC[5] + (D[2][2] + D[2][2]) }; - InvertCholetsky3(mS); - + Vtx.GetMeasurement(*this, m, mCm, D); + //* + + float mS[6] = {mCm[0] - Vtx.fC[0] + (D[0][0] + D[0][0]), + mCm[1] - Vtx.fC[1] + (D[1][0] + D[0][1]), mCm[2] - Vtx.fC[2] + (D[1][1] + D[1][1]), + mCm[3] - Vtx.fC[3] + (D[2][0] + D[0][2]), mCm[4] - Vtx.fC[4] + (D[1][2] + D[2][1]), mCm[5] - Vtx.fC[5] + (D[2][2] + D[2][2])}; + InvertCholetsky3(mS); + //* Residual (measured - estimated) - - float zeta[3] = { m[0]-Vtx.fP[0], m[1]-Vtx.fP[1], m[2]-Vtx.fP[2] }; - + + float zeta[3] = {m[0] - Vtx.fP[0], m[1] - Vtx.fP[1], m[2] - Vtx.fP[2]}; + //* mCHt = mCH' - D' - + float mCHt0[3], mCHt1[3], mCHt2[3]; - - mCHt0[0]=Vtx.fC[ 0] ; mCHt1[0]=Vtx.fC[ 1] ; mCHt2[0]=Vtx.fC[ 3] ; - mCHt0[1]=Vtx.fC[ 1] ; mCHt1[1]=Vtx.fC[ 2] ; mCHt2[1]=Vtx.fC[ 4] ; - mCHt0[2]=Vtx.fC[ 3] ; mCHt1[2]=Vtx.fC[ 4] ; mCHt2[2]=Vtx.fC[ 5] ; - + + mCHt0[0] = Vtx.fC[0]; + mCHt1[0] = Vtx.fC[1]; + mCHt2[0] = Vtx.fC[3]; + mCHt0[1] = Vtx.fC[1]; + mCHt1[1] = Vtx.fC[2]; + mCHt2[1] = Vtx.fC[4]; + mCHt0[2] = Vtx.fC[3]; + mCHt1[2] = Vtx.fC[4]; + mCHt2[2] = Vtx.fC[5]; + //* Kalman gain K = mCH'*S - + float k0[3], k1[3], k2[3]; - - for(Int_t i=0;i<3;++i){ - k0[i] = mCHt0[i]*mS[0] + mCHt1[i]*mS[1] + mCHt2[i]*mS[3]; - k1[i] = mCHt0[i]*mS[1] + mCHt1[i]*mS[2] + mCHt2[i]*mS[4]; - k2[i] = mCHt0[i]*mS[3] + mCHt1[i]*mS[4] + mCHt2[i]*mS[5]; + + for (Int_t i = 0; i < 3; ++i) { + k0[i] = mCHt0[i] * mS[0] + mCHt1[i] * mS[1] + mCHt2[i] * mS[3]; + k1[i] = mCHt0[i] * mS[1] + mCHt1[i] * mS[2] + mCHt2[i] * mS[4]; + k2[i] = mCHt0[i] * mS[3] + mCHt1[i] * mS[4] + mCHt2[i] * mS[5]; } - + //* New estimation of the vertex position r += K*zeta - - float dChi2 = ((mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0] - + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1] - + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2]); - - for(Int_t i=0;i<3;++i) - Vtx.fP[i] -= k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]; - + + float dChi2 = ((mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]); + + for (Int_t i = 0; i < 3; ++i) + Vtx.fP[i] -= k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + //* New covariance matrix C -= K*(mCH')' - - for(Int_t i=0, k=0;i<3;++i){ - for(Int_t j=0;j<=i;++j,++k) - Vtx.fC[k] += k0[i]*mCHt0[j] + k1[i]*mCHt1[j] + k2[i]*mCHt2[j]; + + for (Int_t i = 0, k = 0; i < 3; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) + Vtx.fC[k] += k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]; } - - //* Calculate Chi^2 - Vtx.fNDF -= 2; + //* Calculate Chi^2 + + Vtx.fNDF -= 2; Vtx.fChi2 -= dChi2; } -void KFParticleBase::SubtractFromParticle( KFParticleBase &Vtx ) const +void KFParticleBase::SubtractFromParticle(KFParticleBase& Vtx) const { /** Subtract the current particle from another particle Vtx using the Kalman filter mathematics. ** The function is depricated and is kept for compatibility reasons. Should be replaced with SubtractDaughter(). @@ -3108,47 +3116,61 @@ void KFParticleBase::SubtractFromParticle( KFParticleBase &Vtx ) const float mV[36]; float D[3][3]; - Vtx.GetMeasurement( *this, m, mV, D ); + Vtx.GetMeasurement(*this, m, mV, D); - float mS[6] = { mV[0] - Vtx.fC[0] + (D[0][0] + D[0][0]), - mV[1] - Vtx.fC[1] + (D[1][0] + D[0][1]), mV[2] - Vtx.fC[2] + (D[1][1] + D[1][1]), - mV[3] - Vtx.fC[3] + (D[2][0] + D[0][2]), mV[4] - Vtx.fC[4] + (D[1][2] + D[2][1]), mV[5] - Vtx.fC[5] + (D[2][2] + D[2][2]) }; + float mS[6] = {mV[0] - Vtx.fC[0] + (D[0][0] + D[0][0]), + mV[1] - Vtx.fC[1] + (D[1][0] + D[0][1]), mV[2] - Vtx.fC[2] + (D[1][1] + D[1][1]), + mV[3] - Vtx.fC[3] + (D[2][0] + D[0][2]), mV[4] - Vtx.fC[4] + (D[1][2] + D[2][1]), mV[5] - Vtx.fC[5] + (D[2][2] + D[2][2])}; InvertCholetsky3(mS); //* Residual (measured - estimated) - float zeta[3] = { m[0]-Vtx.fP[0], m[1]-Vtx.fP[1], m[2]-Vtx.fP[2] }; + float zeta[3] = {m[0] - Vtx.fP[0], m[1] - Vtx.fP[1], m[2] - Vtx.fP[2]}; //* CHt = CH' - D' float mCHt0[7], mCHt1[7], mCHt2[7]; - mCHt0[0]=mV[ 0] ; mCHt1[0]=mV[ 1] ; mCHt2[0]=mV[ 3] ; - mCHt0[1]=mV[ 1] ; mCHt1[1]=mV[ 2] ; mCHt2[1]=mV[ 4] ; - mCHt0[2]=mV[ 3] ; mCHt1[2]=mV[ 4] ; mCHt2[2]=mV[ 5] ; - mCHt0[3]=Vtx.fC[ 6]-mV[ 6]; mCHt1[3]=Vtx.fC[ 7]-mV[ 7]; mCHt2[3]=Vtx.fC[ 8]-mV[ 8]; - mCHt0[4]=Vtx.fC[10]-mV[10]; mCHt1[4]=Vtx.fC[11]-mV[11]; mCHt2[4]=Vtx.fC[12]-mV[12]; - mCHt0[5]=Vtx.fC[15]-mV[15]; mCHt1[5]=Vtx.fC[16]-mV[16]; mCHt2[5]=Vtx.fC[17]-mV[17]; - mCHt0[6]=Vtx.fC[21]-mV[21]; mCHt1[6]=Vtx.fC[22]-mV[22]; mCHt2[6]=Vtx.fC[23]-mV[23]; + mCHt0[0] = mV[0]; + mCHt1[0] = mV[1]; + mCHt2[0] = mV[3]; + mCHt0[1] = mV[1]; + mCHt1[1] = mV[2]; + mCHt2[1] = mV[4]; + mCHt0[2] = mV[3]; + mCHt1[2] = mV[4]; + mCHt2[2] = mV[5]; + mCHt0[3] = Vtx.fC[6] - mV[6]; + mCHt1[3] = Vtx.fC[7] - mV[7]; + mCHt2[3] = Vtx.fC[8] - mV[8]; + mCHt0[4] = Vtx.fC[10] - mV[10]; + mCHt1[4] = Vtx.fC[11] - mV[11]; + mCHt2[4] = Vtx.fC[12] - mV[12]; + mCHt0[5] = Vtx.fC[15] - mV[15]; + mCHt1[5] = Vtx.fC[16] - mV[16]; + mCHt2[5] = Vtx.fC[17] - mV[17]; + mCHt0[6] = Vtx.fC[21] - mV[21]; + mCHt1[6] = Vtx.fC[22] - mV[22]; + mCHt2[6] = Vtx.fC[23] - mV[23]; //* Kalman gain K = mCH'*S - + float k0[7], k1[7], k2[7]; - - for(Int_t i=0;i<7;++i){ - k0[i] = mCHt0[i]*mS[0] + mCHt1[i]*mS[1] + mCHt2[i]*mS[3]; - k1[i] = mCHt0[i]*mS[1] + mCHt1[i]*mS[2] + mCHt2[i]*mS[4]; - k2[i] = mCHt0[i]*mS[3] + mCHt1[i]*mS[4] + mCHt2[i]*mS[5]; + + for (Int_t i = 0; i < 7; ++i) { + k0[i] = mCHt0[i] * mS[0] + mCHt1[i] * mS[1] + mCHt2[i] * mS[3]; + k1[i] = mCHt0[i] * mS[1] + mCHt1[i] * mS[2] + mCHt2[i] * mS[4]; + k2[i] = mCHt0[i] * mS[3] + mCHt1[i] * mS[4] + mCHt2[i] * mS[5]; } - //* Add the daughter momentum to the particle momentum - - Vtx.fP[ 3] -= m[ 3]; - Vtx.fP[ 4] -= m[ 4]; - Vtx.fP[ 5] -= m[ 5]; - Vtx.fP[ 6] -= m[ 6]; - - Vtx.fC[ 9] -= mV[ 9]; + //* Add the daughter momentum to the particle momentum + + Vtx.fP[3] -= m[3]; + Vtx.fP[4] -= m[4]; + Vtx.fP[5] -= m[5]; + Vtx.fP[6] -= m[6]; + + Vtx.fC[9] -= mV[9]; Vtx.fC[13] -= mV[13]; Vtx.fC[14] -= mV[14]; Vtx.fC[18] -= mV[18]; @@ -3159,39 +3181,37 @@ void KFParticleBase::SubtractFromParticle( KFParticleBase &Vtx ) const Vtx.fC[26] -= mV[26]; Vtx.fC[27] -= mV[27]; - //* New estimation of the vertex position r += K*zeta - - for(Int_t i=0;i<3;++i) - Vtx.fP[i] = m[i] - (k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]); - for(Int_t i=3;i<7;++i) - Vtx.fP[i] = Vtx.fP[i] - (k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]); + //* New estimation of the vertex position r += K*zeta - //* New covariance matrix C -= K*(mCH')' + for (Int_t i = 0; i < 3; ++i) + Vtx.fP[i] = m[i] - (k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]); + for (Int_t i = 3; i < 7; ++i) + Vtx.fP[i] = Vtx.fP[i] - (k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]); - float ffC[28] = {-mV[ 0], - -mV[ 1], -mV[ 2], - -mV[ 3], -mV[ 4], -mV[ 5], - mV[ 6], mV[ 7], mV[ 8], Vtx.fC[ 9], - mV[10], mV[11], mV[12], Vtx.fC[13], Vtx.fC[14], - mV[15], mV[16], mV[17], Vtx.fC[18], Vtx.fC[19], Vtx.fC[20], - mV[21], mV[22], mV[23], Vtx.fC[24], Vtx.fC[25], Vtx.fC[26], Vtx.fC[27] }; - - for(Int_t i=0, k=0;i<7;++i){ - for(Int_t j=0;j<=i;++j,++k){ - Vtx.fC[k] = ffC[k] + (k0[i]*mCHt0[j] + k1[i]*mCHt1[j] + k2[i]*mCHt2[j] ); + //* New covariance matrix C -= K*(mCH')' + + float ffC[28] = {-mV[0], + -mV[1], -mV[2], + -mV[3], -mV[4], -mV[5], + mV[6], mV[7], mV[8], Vtx.fC[9], + mV[10], mV[11], mV[12], Vtx.fC[13], Vtx.fC[14], + mV[15], mV[16], mV[17], Vtx.fC[18], Vtx.fC[19], Vtx.fC[20], + mV[21], mV[22], mV[23], Vtx.fC[24], Vtx.fC[25], Vtx.fC[26], Vtx.fC[27]}; + + for (Int_t i = 0, k = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) { + Vtx.fC[k] = ffC[k] + (k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]); } } - //* Calculate Chi^2 - Vtx.fNDF -= 2; - Vtx.fQ -= GetQ(); - Vtx.fSFromDecay = 0; - Vtx.fChi2 -= ((mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0] - + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1] - + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2]); + //* Calculate Chi^2 + Vtx.fNDF -= 2; + Vtx.fQ -= GetQ(); + Vtx.fSFromDecay = 0; + Vtx.fChi2 -= ((mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]); } -void KFParticleBase::TransportLine( float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1 ) const +void KFParticleBase::TransportLine(float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1) const { /** Transports the parameters and their covariance matrix of the current particle assuming the straight line trajectory ** on the length defined by the transport parameter dS = l/p, where l is the signed distance and p is @@ -3213,55 +3233,88 @@ void KFParticleBase::TransportLine( float dS, const float* dsdr, float P[], floa ** \param[out] F1[36] - optional parameter, corelation 6x6 matrix betweeen the current particle and particle or vertex ** with the state vector r1, to which the current particle is being transported, F1 = d(fP new)/d(r1) **/ - + float mJ[8][8]; - for( Int_t i=0; i<8; i++ ) for( Int_t j=0; j<8; j++) mJ[i][j]=0; - - mJ[0][0]=1; mJ[0][1]=0; mJ[0][2]=0; mJ[0][3]=dS; mJ[0][4]=0; mJ[0][5]=0; - mJ[1][0]=0; mJ[1][1]=1; mJ[1][2]=0; mJ[1][3]=0; mJ[1][4]=dS; mJ[1][5]=0; - mJ[2][0]=0; mJ[2][1]=0; mJ[2][2]=1; mJ[2][3]=0; mJ[2][4]=0; mJ[2][5]=dS; - - mJ[3][0]=0; mJ[3][1]=0; mJ[3][2]=0; mJ[3][3]=1; mJ[3][4]=0; mJ[3][5]=0; - mJ[4][0]=0; mJ[4][1]=0; mJ[4][2]=0; mJ[4][3]=0; mJ[4][4]=1; mJ[4][5]=0; - mJ[5][0]=0; mJ[5][1]=0; mJ[5][2]=0; mJ[5][3]=0; mJ[5][4]=0; mJ[5][5]=1; + for (Int_t i = 0; i < 8; i++) + for (Int_t j = 0; j < 8; j++) + mJ[i][j] = 0; + + mJ[0][0] = 1; + mJ[0][1] = 0; + mJ[0][2] = 0; + mJ[0][3] = dS; + mJ[0][4] = 0; + mJ[0][5] = 0; + mJ[1][0] = 0; + mJ[1][1] = 1; + mJ[1][2] = 0; + mJ[1][3] = 0; + mJ[1][4] = dS; + mJ[1][5] = 0; + mJ[2][0] = 0; + mJ[2][1] = 0; + mJ[2][2] = 1; + mJ[2][3] = 0; + mJ[2][4] = 0; + mJ[2][5] = dS; + + mJ[3][0] = 0; + mJ[3][1] = 0; + mJ[3][2] = 0; + mJ[3][3] = 1; + mJ[3][4] = 0; + mJ[3][5] = 0; + mJ[4][0] = 0; + mJ[4][1] = 0; + mJ[4][2] = 0; + mJ[4][3] = 0; + mJ[4][4] = 1; + mJ[4][5] = 0; + mJ[5][0] = 0; + mJ[5][1] = 0; + mJ[5][2] = 0; + mJ[5][3] = 0; + mJ[5][4] = 0; + mJ[5][5] = 1; mJ[6][6] = mJ[7][7] = 1; - + float px = fP[3], py = fP[4], pz = fP[5]; - - P[0] = fP[0] + dS*fP[3]; - P[1] = fP[1] + dS*fP[4]; - P[2] = fP[2] + dS*fP[5]; + + P[0] = fP[0] + dS * fP[3]; + P[1] = fP[1] + dS * fP[4]; + P[2] = fP[2] + dS * fP[5]; P[3] = fP[3]; P[4] = fP[4]; P[5] = fP[5]; P[6] = fP[6]; P[7] = fP[7]; - + float mJds[6][6]; - for( Int_t i=0; i<6; i++ ) for( Int_t j=0; j<6; j++) mJds[i][j]=0; - - mJds[0][3]= 1; - mJds[1][4]= 1; - mJds[2][5]= 1; - - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - mJ[i1][i2] += mJds[i1][3]*px*dsdr[i2] + mJds[i1][4]*py*dsdr[i2] + mJds[i1][5]*pz*dsdr[i2]; - MultQSQt( mJ[0], fC, C, 8); - - if(F) - { - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - F[i*6+j] = mJ[i][j]; + for (Int_t i = 0; i < 6; i++) + for (Int_t j = 0; j < 6; j++) + mJds[i][j] = 0; + + mJds[0][3] = 1; + mJds[1][4] = 1; + mJds[2][5] = 1; + + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + MultQSQt(mJ[0], fC, C, 8); + + if (F) { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) + F[i * 6 + j] = mJ[i][j]; - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - F1[i1*6 + i2] = mJds[i1][3]*px*dsdr1[i2] + mJds[i1][4]*py*dsdr1[i2] + mJds[i1][5]*pz*dsdr1[i2]; + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; } } -void KFParticleBase::GetArmenterosPodolanski(KFParticleBase& positive, KFParticleBase& negative, float QtAlfa[2] ) +void KFParticleBase::GetArmenterosPodolanski(KFParticleBase& positive, KFParticleBase& negative, float QtAlfa[2]) { /** Calculates parameters for the Armenteros-Podolanski plot for two particles. ** Example how to use:\n @@ -3284,19 +3337,21 @@ void KFParticleBase::GetArmenterosPodolanski(KFParticleBase& positive, KFParticl float spx = positive.GetPx() + negative.GetPx(); float spy = positive.GetPy() + negative.GetPy(); float spz = positive.GetPz() + negative.GetPz(); - float sp = sqrt(spx*spx + spy*spy + spz*spz); - if( sp == 0.0) return; + float sp = sqrt(spx * spx + spy * spy + spz * spz); + if (sp == 0.0) + return; float pn, pln, plp; - pn = sqrt(negative.GetPx()*negative.GetPx() + negative.GetPy()*negative.GetPy() + negative.GetPz()*negative.GetPz()); -// pp = sqrt(positive.GetPx()*positive.GetPx() + positive.GetPy()*positive.GetPy() + positive.GetPz()*positive.GetPz()); - pln = (negative.GetPx()*spx+negative.GetPy()*spy+negative.GetPz()*spz)/sp; - plp = (positive.GetPx()*spx+positive.GetPy()*spy+positive.GetPz()*spz)/sp; + pn = sqrt(negative.GetPx() * negative.GetPx() + negative.GetPy() * negative.GetPy() + negative.GetPz() * negative.GetPz()); + // pp = sqrt(positive.GetPx()*positive.GetPx() + positive.GetPy()*positive.GetPy() + positive.GetPz()*positive.GetPz()); + pln = (negative.GetPx() * spx + negative.GetPy() * spy + negative.GetPz() * spz) / sp; + plp = (positive.GetPx() * spx + positive.GetPy() * spy + positive.GetPz() * spz) / sp; - if( pn == 0.0) return; - float ptm = (1.-((pln/pn)*(pln/pn))); - qt= (ptm>=0.)? pn*sqrt(ptm) :0; - alpha = (plp-pln)/(plp+pln); + if (pn == 0.0) + return; + float ptm = (1. - ((pln / pn) * (pln / pn))); + qt = (ptm >= 0.) ? pn * sqrt(ptm) : 0; + alpha = (plp - pln) / (plp + pln); QtAlfa[0] = qt; QtAlfa[1] = alpha; @@ -3318,50 +3373,54 @@ void KFParticleBase::RotateXY(float angle, float Vtx[3]) float c = cos(angle); float s = sin(angle); - float mA[8][ 8]; - for( Int_t i=0; i<8; i++ ){ - for( Int_t j=0; j<8; j++){ + float mA[8][8]; + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mA[i][j] = 0; } } - for( int i=0; i<8; i++ ){ + for (int i = 0; i < 8; i++) { mA[i][i] = 1; } - mA[0][0] = c; mA[0][1] = s; - mA[1][0] = -s; mA[1][1] = c; - mA[3][3] = c; mA[3][4] = s; - mA[4][3] = -s; mA[4][4] = c; + mA[0][0] = c; + mA[0][1] = s; + mA[1][0] = -s; + mA[1][1] = c; + mA[3][3] = c; + mA[3][4] = s; + mA[4][3] = -s; + mA[4][4] = c; float mAC[8][8]; float mAp[8]; - for( Int_t i=0; i<8; i++ ){ + for (Int_t i = 0; i < 8; i++) { mAp[i] = 0; - for( Int_t k=0; k<8; k++){ - mAp[i]+=mA[i][k] * fP[k]; + for (Int_t k = 0; k < 8; k++) { + mAp[i] += mA[i][k] * fP[k]; } } - for( Int_t i=0; i<8; i++){ + for (Int_t i = 0; i < 8; i++) { fP[i] = mAp[i]; } - for( Int_t i=0; i<8; i++ ){ - for( Int_t j=0; j<8; j++ ){ + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mAC[i][j] = 0; - for( Int_t k=0; k<8; k++ ){ - mAC[i][j]+= mA[i][k] * GetCovariance(k,j); + for (Int_t k = 0; k < 8; k++) { + mAC[i][j] += mA[i][k] * GetCovariance(k, j); } } } - for( Int_t i=0; i<8; i++ ){ - for( Int_t j=0; j<=i; j++ ){ + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j <= i; j++) { float xx = 0; - for( Int_t k=0; k<8; k++){ - xx+= mAC[i][k]*mA[j][k]; + for (Int_t k = 0; k < 8; k++) { + xx += mAC[i][k] * mA[j][k]; } - Covariance(i,j) = xx; + Covariance(i, j) = xx; } } @@ -3375,61 +3434,56 @@ void KFParticleBase::InvertCholetsky3(float a[6]) /** Inverts symmetric 3x3 matrix a using modified Choletsky decomposition. The result is stored to the same matrix a. ** \param[in,out] a - 3x3 symmetric matrix **/ - + float d[3], uud, u[3][3]; - for(int i=0; i<3; i++) - { - d[i]=0; - for(int j=0; j<3; j++) - u[i][j]=0; + for (int i = 0; i < 3; i++) { + d[i] = 0; + for (int j = 0; j < 3; j++) + u[i][j] = 0; } - for(int i=0; i<3 ; i++) - { - uud=0; - for(int j=0; j. */ - #ifndef KFPARTICLEBASE_H #define KFPARTICLEBASE_H @@ -45,220 +44,221 @@ ** Contains the main mathematics of the KF Particle . Will be merged with the KFParticle class. **/ -class KFParticleBase :public TObject { - - public: +class KFParticleBase : public TObject +{ + public: /** ** Abstract methods are defined in the KFParticle class - **/ + **/ /** Virtual method to access the magnetic field**/ virtual void GetFieldValue(const float xyz[], float B[]) const = 0; - + /** Virtual method to get extrapolation parameter dS=l/p to . Is defined in KFParticle.**/ - virtual float GetDStoPoint( const float xyz[3], float dsdr[6] ) const = 0; - - float GetDStoPointLine( const float xyz[3], float dsdr[6] ) const; - float GetDStoPointBz( float B, const float xyz[3], float dsdr[6], const float* param=0) const; - float GetDStoPointBy( float By, const float xyz[3], float dsdr[6] ) const; - float GetDStoPointB( const float* B, const float xyz[3], float dsdr[6] ) const; - float GetDStoPointCBM( const float xyz[3], float dsdr[6] ) const; + virtual float GetDStoPoint(const float xyz[3], float dsdr[6]) const = 0; + + float GetDStoPointLine(const float xyz[3], float dsdr[6]) const; + float GetDStoPointBz(float B, const float xyz[3], float dsdr[6], const float* param = 0) const; + float GetDStoPointBy(float By, const float xyz[3], float dsdr[6]) const; + float GetDStoPointB(const float* B, const float xyz[3], float dsdr[6]) const; + float GetDStoPointCBM(const float xyz[3], float dsdr[6]) const; /** Virtual method to get extrapolation parameter dS=l/p to another particle. Is defined in KFParticle.**/ - virtual void GetDStoParticle( const KFParticleBase &p, float dS[2], float dsdr[4][6] ) const = 0; - - void GetDStoParticleLine( const KFParticleBase &p, float dS[2], float dsdr[4][6] ) const ; - void GetDStoParticleBz( float Bz, const KFParticleBase &p, float dS[2], float dsdr[4][6], const float* param1=0, const float* param2=0 ) const ; - void GetDStoParticleBy( float B, const KFParticleBase &p, float dS[2], float dsdr[4][6] ) const ; - void GetDStoParticleCBM( const KFParticleBase &p, float dS[2], float dsdr[4][6] ) const ; - - /** Virtual method to transport a particle on a certain distance along the trajectory. Is defined in KFParticle.**/ - virtual void Transport( float dS, const float dsdr[6], float P[], float C[], float* dsdr1=0, float* F=0, float* F1=0 ) const = 0; + virtual void GetDStoParticle(const KFParticleBase& p, float dS[2], float dsdr[4][6]) const = 0; + + void GetDStoParticleLine(const KFParticleBase& p, float dS[2], float dsdr[4][6]) const; + void GetDStoParticleBz(float Bz, const KFParticleBase& p, float dS[2], float dsdr[4][6], const float* param1 = 0, const float* param2 = 0) const; + void GetDStoParticleBy(float B, const KFParticleBase& p, float dS[2], float dsdr[4][6]) const; + void GetDStoParticleCBM(const KFParticleBase& p, float dS[2], float dsdr[4][6]) const; + /** Virtual method to transport a particle on a certain distance along the trajectory. Is defined in KFParticle.**/ + virtual void Transport(float dS, const float dsdr[6], float P[], float C[], float* dsdr1 = 0, float* F = 0, float* F1 = 0) const = 0; KFParticleBase(); virtual ~KFParticleBase() { ; } ///< The default destructor. - void Initialize( const float Param[], const float Cov[], Int_t Charge, float Mass ); + void Initialize(const float Param[], const float Cov[], Int_t Charge, float Mass); void Initialize(); - void SetConstructMethod(Int_t m) {fConstructMethod = m;} ///< Defines the construction method for the current particle (see description of fConstructMethod). - void SetMassHypo(float m) { fMassHypo = m;} ///< Sets the mass hypothesis to the particle, is used when fConstructMethod = 2. - const float& GetMassHypo() const { return fMassHypo; } ///< Returns the mass hypothesis. - const float& GetSumDaughterMass() const {return SumDaughterMass;} ///< Returns the sum of masses of the daughters. + void SetConstructMethod(Int_t m) { fConstructMethod = m; } ///< Defines the construction method for the current particle (see description of fConstructMethod). + void SetMassHypo(float m) { fMassHypo = m; } ///< Sets the mass hypothesis to the particle, is used when fConstructMethod = 2. + const float& GetMassHypo() const { return fMassHypo; } ///< Returns the mass hypothesis. + const float& GetSumDaughterMass() const { return SumDaughterMass; } ///< Returns the sum of masses of the daughters. //* //* ACCESSORS //* - //* Simple accessors - - float GetX () const { return fP[0]; } ///< Retruns X coordinate of the particle, fP[0]. - float GetY () const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. - float GetZ () const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. - float GetPx () const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. - float GetPy () const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. - float GetPz () const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. - float GetE () const { return fP[6]; } ///< Returns energy of the particle, fP[6]. - float GetS () const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. - char GetQ () const { return fQ; } ///< Returns charge of the particle. - float GetChi2 () const { return fChi2; } ///< Returns Chi2 of the fit. - Int_t GetNDF () const { return fNDF; } ///< Returns number of decrease of freedom. - - const float& X () const { return fP[0]; } ///< Retruns X coordinate of the particle, fP[0]. - const float& Y () const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. - const float& Z () const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. - const float& Px () const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. - const float& Py () const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. - const float& Pz () const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. - const float& E () const { return fP[6]; } ///< Returns energy of the particle, fP[6]. - const float& S () const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. - const char& Q () const { return fQ; } ///< Returns charge of the particle. - const float& Chi2 () const { return fChi2; } ///< Returns Chi2 of the fit. - const Int_t& NDF () const { return fNDF; } ///< Returns number of decrease of freedom. - - float GetParameter ( Int_t i ) const { return fP[i]; } ///< Returns P[i] parameter. - float GetCovariance( Int_t i ) const { return fC[i]; } ///< Returns C[i] element of the covariance matrix in the lower triangular form. - float GetCovariance( Int_t i, Int_t j ) const { return fC[IJ(i,j)]; } ///< Returns C[i,j] element of the covariance matrix. + //* Simple accessors + + float GetX() const { return fP[0]; } ///< Retruns X coordinate of the particle, fP[0]. + float GetY() const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. + float GetZ() const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. + float GetPx() const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. + float GetPy() const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. + float GetPz() const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. + float GetE() const { return fP[6]; } ///< Returns energy of the particle, fP[6]. + float GetS() const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. + char GetQ() const { return fQ; } ///< Returns charge of the particle. + float GetChi2() const { return fChi2; } ///< Returns Chi2 of the fit. + Int_t GetNDF() const { return fNDF; } ///< Returns number of decrease of freedom. + + const float& X() const { return fP[0]; } ///< Retruns X coordinate of the particle, fP[0]. + const float& Y() const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. + const float& Z() const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. + const float& Px() const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. + const float& Py() const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. + const float& Pz() const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. + const float& E() const { return fP[6]; } ///< Returns energy of the particle, fP[6]. + const float& S() const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. + const char& Q() const { return fQ; } ///< Returns charge of the particle. + const float& Chi2() const { return fChi2; } ///< Returns Chi2 of the fit. + const Int_t& NDF() const { return fNDF; } ///< Returns number of decrease of freedom. + + float GetParameter(Int_t i) const { return fP[i]; } ///< Returns P[i] parameter. + float GetCovariance(Int_t i) const { return fC[i]; } ///< Returns C[i] element of the covariance matrix in the lower triangular form. + float GetCovariance(Int_t i, Int_t j) const { return fC[IJ(i, j)]; } ///< Returns C[i,j] element of the covariance matrix. //* Accessors with calculations( &value, &estimated sigma ) - //* error flag returned (0 means no error during calculations) - - Int_t GetMomentum ( float &p, float &error ) const ; - Int_t GetPt ( float &pt, float &error ) const ; - Int_t GetEta ( float &eta, float &error ) const ; - Int_t GetPhi ( float &phi, float &error ) const ; - Int_t GetMass ( float &m, float &error ) const ; - Int_t GetDecayLength ( float &l, float &error ) const ; - Int_t GetDecayLengthXY ( float &l, float &error ) const ; - Int_t GetLifeTime ( float &ctau,float &error ) const ; - Int_t GetR ( float &r, float &error ) const ; + //* error flag returned (0 means no error during calculations) + + Int_t GetMomentum(float& p, float& error) const; + Int_t GetPt(float& pt, float& error) const; + Int_t GetEta(float& eta, float& error) const; + Int_t GetPhi(float& phi, float& error) const; + Int_t GetMass(float& m, float& error) const; + Int_t GetDecayLength(float& l, float& error) const; + Int_t GetDecayLengthXY(float& l, float& error) const; + Int_t GetLifeTime(float& ctau, float& error) const; + Int_t GetR(float& r, float& error) const; //* //* MODIFIERS //* - - float & X () { return fP[0]; } ///< Modifier of X coordinate of the particle, fP[0]. - float & Y () { return fP[1]; } ///< Modifier of Y coordinate of the particle, fP[1]. - float & Z () { return fP[2]; } ///< Modifier of Z coordinate of the particle, fP[2]. - float & Px () { return fP[3]; } ///< Modifier of X component of the momentum, fP[3]. - float & Py () { return fP[4]; } ///< Modifier of Y component of the momentum, fP[4]. - float & Pz () { return fP[5]; } ///< Modifier of Z component of the momentum, fP[5]. - float & E () { return fP[6]; } ///< Modifier of energy of the particle, fP[6]. - float & S () { return fP[7]; } ///< Modifier of dS=l/p, l - decay length, fP[7], defined if production vertex is set. - char & Q () { return fQ; } ///< Modifier of charge of the particle. - float & Chi2 () { return fChi2; } ///< Modifier of Chi2 of the fit. - Int_t & NDF () { return fNDF; } ///< Modifier of number of decrease of freedom. - - float & Parameter ( Int_t i ) { return fP[i]; } ///< Modifier of P[i] parameter. - float & Covariance( Int_t i ) { return fC[i]; } ///< Modifier of C[i] element of the covariance matrix in the lower triangular form. - float & Covariance( Int_t i, Int_t j ) { return fC[IJ(i,j)]; } ///< Modifier of C[i,j] element of the covariance matrix. - - - //* + + float& X() { return fP[0]; } ///< Modifier of X coordinate of the particle, fP[0]. + float& Y() { return fP[1]; } ///< Modifier of Y coordinate of the particle, fP[1]. + float& Z() { return fP[2]; } ///< Modifier of Z coordinate of the particle, fP[2]. + float& Px() { return fP[3]; } ///< Modifier of X component of the momentum, fP[3]. + float& Py() { return fP[4]; } ///< Modifier of Y component of the momentum, fP[4]. + float& Pz() { return fP[5]; } ///< Modifier of Z component of the momentum, fP[5]. + float& E() { return fP[6]; } ///< Modifier of energy of the particle, fP[6]. + float& S() { return fP[7]; } ///< Modifier of dS=l/p, l - decay length, fP[7], defined if production vertex is set. + char& Q() { return fQ; } ///< Modifier of charge of the particle. + float& Chi2() { return fChi2; } ///< Modifier of Chi2 of the fit. + Int_t& NDF() { return fNDF; } ///< Modifier of number of decrease of freedom. + + float& Parameter(Int_t i) { return fP[i]; } ///< Modifier of P[i] parameter. + float& Covariance(Int_t i) { return fC[i]; } ///< Modifier of C[i] element of the covariance matrix in the lower triangular form. + float& Covariance(Int_t i, Int_t j) { return fC[IJ(i, j)]; } ///< Modifier of C[i,j] element of the covariance matrix. + + //* //* CONSTRUCTION OF THE PARTICLE BY ITS DAUGHTERS AND MOTHER //* USING THE KALMAN FILTER METHOD //* + //* Simple way to add daughter ex. D0+= Pion; - //* Simple way to add daughter ex. D0+= Pion; - - void operator +=( const KFParticleBase &Daughter ); + void operator+=(const KFParticleBase& Daughter); - //* Add daughter track to the particle + //* Add daughter track to the particle - void AddDaughter( const KFParticleBase &Daughter ); - void SubtractDaughter( const KFParticleBase &Daughter ); + void AddDaughter(const KFParticleBase& Daughter); + void SubtractDaughter(const KFParticleBase& Daughter); - void AddDaughterWithEnergyFit( const KFParticleBase &Daughter ); - void AddDaughterWithEnergyFitMC( const KFParticleBase &Daughter ); + void AddDaughterWithEnergyFit(const KFParticleBase& Daughter); + void AddDaughterWithEnergyFitMC(const KFParticleBase& Daughter); - //* Set production vertex + //* Set production vertex - void SetProductionVertex( const KFParticleBase &Vtx ); + void SetProductionVertex(const KFParticleBase& Vtx); - //* Set mass constraint + //* Set mass constraint - void SetNonlinearMassConstraint( float Mass ); - void SetMassConstraint( float Mass, float SigmaMass = 0 ); + void SetNonlinearMassConstraint(float Mass); + void SetMassConstraint(float Mass, float SigmaMass = 0); //* Set no decay length for resonances void SetNoDecayLength(); + //* Everything in one go - //* Everything in one go - - void Construct( const KFParticleBase *vDaughters[], Int_t nDaughters, const KFParticleBase *ProdVtx=0, float Mass=-1 ); + void Construct(const KFParticleBase* vDaughters[], Int_t nDaughters, const KFParticleBase* ProdVtx = 0, float Mass = -1); //Transport functions void TransportToDecayVertex(); void TransportToProductionVertex(); - void TransportToDS( float dS, const float* dsdr ); - void TransportBz( float Bz, float dS, const float* dsdr, float P[], float C[], float* dsdr1=0, float* F=0, float* F1=0 ) const; - void TransportCBM( float dS, const float* dsdr, float P[], float C[], float* dsdr1=0, float* F=0, float* F1=0 ) const; + void TransportToDS(float dS, const float* dsdr); + void TransportBz(float Bz, float dS, const float* dsdr, float P[], float C[], float* dsdr1 = 0, float* F = 0, float* F1 = 0) const; + void TransportCBM(float dS, const float* dsdr, float P[], float C[], float* dsdr1 = 0, float* F = 0, float* F1 = 0) const; - //* + //* //* OTHER UTILITIES //* //* Calculate distance from another object [cm] - float GetDistanceFromVertex( const float vtx[] ) const; - float GetDistanceFromVertex( const KFParticleBase &Vtx ) const; - float GetDistanceFromParticle( const KFParticleBase &p ) const; + float GetDistanceFromVertex(const float vtx[]) const; + float GetDistanceFromVertex(const KFParticleBase& Vtx) const; + float GetDistanceFromParticle(const KFParticleBase& p) const; //* Calculate sqrt(Chi2/ndf) deviation from vertex //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix - float GetDeviationFromVertex( const float v[], const float Cv[]=0 ) const; - float GetDeviationFromVertex( const KFParticleBase &Vtx ) const; - float GetDeviationFromParticle( const KFParticleBase &p ) const; + float GetDeviationFromVertex(const float v[], const float Cv[] = 0) const; + float GetDeviationFromVertex(const KFParticleBase& Vtx) const; + float GetDeviationFromParticle(const KFParticleBase& p) const; - void SubtractFromVertex( KFParticleBase &Vtx ) const; - void SubtractFromParticle( KFParticleBase &Vtx ) const; + void SubtractFromVertex(KFParticleBase& Vtx) const; + void SubtractFromParticle(KFParticleBase& Vtx) const; - static void GetArmenterosPodolanski(KFParticleBase& positive, KFParticleBase& negative, float QtAlfa[2] ); + static void GetArmenterosPodolanski(KFParticleBase& positive, KFParticleBase& negative, float QtAlfa[2]); void RotateXY(float angle, float Vtx[3]); - int Id() const { return fId; } ///< Returns Id of the particle. - int NDaughters() const { return fDaughtersIds.size(); } ///< Returns number of daughter particles. + int Id() const { return fId; } ///< Returns Id of the particle. + int NDaughters() const { return fDaughtersIds.size(); } ///< Returns number of daughter particles. const std::vector& DaughterIds() const { return fDaughtersIds; } ///< Returns the vector with the indices of daughter particles. - void CleanDaughtersId() { fDaughtersIds.clear(); } ///< Cleans the vector with the indices of daughter particles. - - void SetId( int id ) { fId = id; } ///< Sets the Id of the particle. After the construction of a particle should be set by user. - void AddDaughterId( int id ) { fDaughtersIds.push_back(id); } ///< Adds index of the daughter particle. + void CleanDaughtersId() { fDaughtersIds.clear(); } ///< Cleans the vector with the indices of daughter particles. + + void SetId(int id) { fId = id; } ///< Sets the Id of the particle. After the construction of a particle should be set by user. + void AddDaughterId(int id) { fDaughtersIds.push_back(id); } ///< Adds index of the daughter particle. - void SetPDG ( int pdg ) { fPDG = pdg; } ///< Sets the PDG hypothesis. - int GetPDG () const { return fPDG; } ///< Returns the PDG hypothesis. + void SetPDG(int pdg) { fPDG = pdg; } ///< Sets the PDG hypothesis. + int GetPDG() const { return fPDG; } ///< Returns the PDG hypothesis. #ifdef __ROOT__ //for the STAR experiment - virtual void Print(Option_t *opt="") const; - Int_t IdTruth() const { return fIdTruth;} - Int_t QaTruth() const { return fQuality; } - Int_t IdParentMcVx() const {return fIdParentMcVx;} - Int_t IdParentVx() const {return IdParentMcVx();} - void SetParentID(Int_t id=0) {fParentID = id;} - Int_t GetParentID() const {return fParentID;} - void SetIdParentMcVx(Int_t id) {fIdParentMcVx = id;} - void SetIdTruth(Int_t idtru,Int_t qatru=0) {fIdTruth = (UShort_t) idtru; fQuality = (UShort_t) qatru;} - virtual void Clear(Option_t * /*option*/ =""); + virtual void Print(Option_t* opt = "") const; + Int_t IdTruth() const { return fIdTruth; } + Int_t QaTruth() const { return fQuality; } + Int_t IdParentMcVx() const { return fIdParentMcVx; } + Int_t IdParentVx() const { return IdParentMcVx(); } + void SetParentID(Int_t id = 0) { fParentID = id; } + Int_t GetParentID() const { return fParentID; } + void SetIdParentMcVx(Int_t id) { fIdParentMcVx = id; } + void SetIdTruth(Int_t idtru, Int_t qatru = 0) + { + fIdTruth = (UShort_t)idtru; + fQuality = (UShort_t)qatru; + } + virtual void Clear(Option_t* /*option*/ = ""); #endif static void InvertCholetsky3(float a[6]); - static void MultQSQt( const float Q[], const float S[], float SOut[], const int kN ); + static void MultQSQt(const float Q[], const float S[], float SOut[], const int kN); protected: /** Converts a pair of indices {i,j} of the covariance matrix to one index corresponding to the triangular form. */ - static Int_t IJ( Int_t i, Int_t j ){ - return ( j<=i ) ? i*(i+1)/2+j :j*(j+1)/2+i; + static Int_t IJ(Int_t i, Int_t j) + { + return (j <= i) ? i * (i + 1) / 2 + j : j * (j + 1) / 2 + i; } /** Return an element of the covariance matrix with {i,j} indices. */ - float & Cij( Int_t i, Int_t j ){ return fC[IJ(i,j)]; } - void TransportLine( float S, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1 ) const ; - bool GetMeasurement( const KFParticleBase& daughter, float m[], float V[], float D[3][3] ) ; - void SetMassConstraint( float *mP, float *mC, float mJ[7][7], float mass ); + float& Cij(Int_t i, Int_t j) { return fC[IJ(i, j)]; } + void TransportLine(float S, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1) const; + bool GetMeasurement(const KFParticleBase& daughter, float m[], float V[], float D[3][3]); + void SetMassConstraint(float* mP, float* mC, float mJ[7][7], float mass); float fP[8]; ///< Particle parameters { X, Y, Z, Px, Py, Pz, E, S[=DecayLength/P]}. float fC[36]; ///< Low-triangle covariance matrix of fP. @@ -267,36 +267,36 @@ class KFParticleBase :public TObject { float SumDaughterMass; ///< Sum of the daughter particles masses. Needed to set the constraint on the minimum mass during particle construction. float fMassHypo; ///< The mass hypothesis, used for the constraints during particle construction. Int_t fNDF; ///< Number of degrees of freedom. - int fId; ///< Id of the particle. -#ifdef __ROOT__ //for the STAR experiment - Short_t fParentID; ///< Id of the parent particle. - Short_t fIdTruth; ///< MC track id. - Short_t fQuality; ///< quality of this information (percentage of hits coming from the above MC track). - Short_t fIdParentMcVx; ///< for track and McTrack for vertex. + int fId; ///< Id of the particle. +#ifdef __ROOT__ //for the STAR experiment + Short_t fParentID; ///< Id of the parent particle. + Short_t fIdTruth; ///< MC track id. + Short_t fQuality; ///< quality of this information (percentage of hits coming from the above MC track). + Short_t fIdParentMcVx; ///< for track and McTrack for vertex. #endif Bool_t fAtProductionVertex; ///< Flag shows if particle is at the production point. - char fQ; ///< The charge of the particle in the units of the elementary charge. - + char fQ; ///< The charge of the particle in the units of the elementary charge. + /** \brief Determines the method for the particle construction. \n ** 0 - Energy considered as an independent veriable, fitted independently from momentum, without any constraints on mass \n ** 2 - Energy considered as an independent variable, fitted independently from momentum, with constraints on mass of daughter particle **/ - char fConstructMethod; + char fConstructMethod; int fPDG; ///< The PDG hypothesis assigned to the particle. - + /** \brief A vector with ids of the daughter particles: \n ** 1) if particle is created from a track - the index of the track, in this case the size of the vector is always equal to one; \n ** 2) if particle is constructed from other particles - indices of these particles in the same array. **/ std::vector fDaughtersIds; - + #ifndef KFParticleStandalone - ClassDef( KFParticleBase, 3 ) + ClassDef(KFParticleBase, 3) #endif }; #ifdef __ROOT__ //for the STAR experiment -std::ostream& operator<<(std::ostream& os, KFParticleBase const & particle); +std::ostream& operator<<(std::ostream& os, KFParticleBase const& particle); #endif -#endif +#endif diff --git a/KFParticle/KFParticleBaseSIMD.cxx b/KFParticle/KFParticleBaseSIMD.cxx index 94c1802..8b57c72 100644 --- a/KFParticle/KFParticleBaseSIMD.cxx +++ b/KFParticle/KFParticleBaseSIMD.cxx @@ -19,15 +19,13 @@ * along with this program. If not, see . */ - #include "KFParticleBaseSIMD.h" #include static const float_v small = 1.e-20f; -KFParticleBaseSIMD::KFParticleBaseSIMD() :fQ(0), fNDF(-3), fChi2(0.f), fSFromDecay(0.f), - SumDaughterMass(0.f), fMassHypo(-1.f), fId(-1), fAtProductionVertex(0), fPDG(0), fConstructMethod(0), fDaughterIds() -{ +KFParticleBaseSIMD::KFParticleBaseSIMD() : fQ(0), fNDF(-3), fChi2(0.f), fSFromDecay(0.f), SumDaughterMass(0.f), fMassHypo(-1.f), fId(-1), fAtProductionVertex(0), fPDG(0), fConstructMethod(0), fDaughterIds() +{ /** The default constructor, initialises the parameters by: \n ** 1) all parameters are set to 0; \n ** 2) all elements of the covariance matrix are set to 0 except Cxx=Cyy=Czz=100; \n @@ -38,7 +36,7 @@ KFParticleBaseSIMD::KFParticleBaseSIMD() :fQ(0), fNDF(-3), fChi2(0.f), fSFromDec Initialize(); } -void KFParticleBaseSIMD::Initialize( const float_v Param[], const float_v Cov[], int_v Charge, float_v Mass ) +void KFParticleBaseSIMD::Initialize(const float_v Param[], const float_v Cov[], int_v Charge, float_v Mass) { /** Sets the parameters of the particle: ** \param[in] Param[6] = { X, Y, Z, Px, Py, Pz } - position and momentum @@ -55,10 +53,12 @@ void KFParticleBaseSIMD::Initialize( const float_v Param[], const float_v Cov[], ** \param[in] mass - the mass hypothesis **/ - for( Int_t i=0; i<6 ; i++ ) fP[i] = Param[i]; - for( Int_t i=0; i<21; i++ ) fC[i] = Cov[i]; + for (Int_t i = 0; i < 6; i++) + fP[i] = Param[i]; + for (Int_t i = 0; i < 21; i++) + fC[i] = Cov[i]; - float_v energy = sqrt( Mass*Mass + fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]); + float_v energy = sqrt(Mass * Mass + fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]); fP[6] = energy; fP[7] = 0; fQ = Charge; @@ -67,21 +67,21 @@ void KFParticleBaseSIMD::Initialize( const float_v Param[], const float_v Cov[], fAtProductionVertex = 0; fSFromDecay = 0; - float_v energyInv = 1.f/energy; - float_v - h0 = fP[3]*energyInv, - h1 = fP[4]*energyInv, - h2 = fP[5]*energyInv; - - fC[21] = h0*fC[ 6] + h1*fC[10] + h2*fC[15]; - fC[22] = h0*fC[ 7] + h1*fC[11] + h2*fC[16]; - fC[23] = h0*fC[ 8] + h1*fC[12] + h2*fC[17]; - fC[24] = h0*fC[ 9] + h1*fC[13] + h2*fC[18]; - fC[25] = h0*fC[13] + h1*fC[14] + h2*fC[19]; - fC[26] = h0*fC[18] + h1*fC[19] + h2*fC[20]; - fC[27] = ( h0*h0*fC[ 9] + h1*h1*fC[14] + h2*h2*fC[20] - + 2*(h0*h1*fC[13] + h0*h2*fC[18] + h1*h2*fC[19] ) ); - for( Int_t i=28; i<36; i++ ) fC[i] = 0.f; + float_v energyInv = 1.f / energy; + float_v + h0 = fP[3] * energyInv, + h1 = fP[4] * energyInv, + h2 = fP[5] * energyInv; + + fC[21] = h0 * fC[6] + h1 * fC[10] + h2 * fC[15]; + fC[22] = h0 * fC[7] + h1 * fC[11] + h2 * fC[16]; + fC[23] = h0 * fC[8] + h1 * fC[12] + h2 * fC[17]; + fC[24] = h0 * fC[9] + h1 * fC[13] + h2 * fC[18]; + fC[25] = h0 * fC[13] + h1 * fC[14] + h2 * fC[19]; + fC[26] = h0 * fC[18] + h1 * fC[19] + h2 * fC[20]; + fC[27] = (h0 * h0 * fC[9] + h1 * h1 * fC[14] + h2 * h2 * fC[20] + 2 * (h0 * h1 * fC[13] + h0 * h2 * fC[18] + h1 * h2 * fC[19])); + for (Int_t i = 28; i < 36; i++) + fC[i] = 0.f; fC[35] = 1.f; SumDaughterMass = Mass; @@ -97,13 +97,15 @@ void KFParticleBaseSIMD::Initialize() ** 4) chi2 is set to 0; \n ** 5) NDF = -3, since 3 parameters should be fitted: X, Y, Z. **/ - - for( Int_t i=0; i<8; i++) fP[i] = 0.f; - for(Int_t i=0;i<36;++i) fC[i]=0.f; + + for (Int_t i = 0; i < 8; i++) + fP[i] = 0.f; + for (Int_t i = 0; i < 36; ++i) + fC[i] = 0.f; fC[0] = fC[2] = fC[5] = 100.f; fC[35] = 1.f; - fNDF = -3; - fChi2 = 0.f; + fNDF = -3; + fChi2 = 0.f; fQ = 0; fSFromDecay = 0.f; fAtProductionVertex = 0; @@ -111,23 +113,23 @@ void KFParticleBaseSIMD::Initialize() fMassHypo = -1; } -float_m KFParticleBaseSIMD::GetMomentum( float_v &p, float_v &error ) const +float_m KFParticleBaseSIMD::GetMomentum(float_v& p, float_v& error) const { /** Calculates particle momentum and its error. If they are well defined the corresponding element of the ** return mask is set to 0, otherwise 1. ** \param[out] p - momentum of the particle ** \param[out] error - its error **/ - + float_v x = fP[3]; float_v y = fP[4]; float_v z = fP[5]; - float_v x2 = x*x; - float_v y2 = y*y; - float_v z2 = z*z; - float_v p2 = x2+y2+z2; + float_v x2 = x * x; + float_v y2 = y * y; + float_v z2 = z * z; + float_v p2 = x2 + y2 + z2; p = sqrt(p2); - error = (x2*fC[9]+y2*fC[14]+z2*fC[20] + 2*(x*y*fC[13]+x*z*fC[18]+y*z*fC[19]) ); + error = (x2 * fC[9] + y2 * fC[14] + z2 * fC[20] + 2 * (x * y * fC[13] + x * z * fC[18] + y * z * fC[19])); const float_v LocalSmall = 1.e-4f; float_m mask = (0.f < error) && (LocalSmall < abs(p)); error(!mask) = 1.e20f; @@ -135,7 +137,7 @@ float_m KFParticleBaseSIMD::GetMomentum( float_v &p, float_v &error ) const return (!mask); } -float_m KFParticleBaseSIMD::GetPt( float_v &pt, float_v &error ) const +float_m KFParticleBaseSIMD::GetPt(float_v& pt, float_v& error) const { /** Calculates particle transverse momentum and its error. If they are well defined the corresponding element of the ** return mask is set to 0, otherwise 1. @@ -145,131 +147,126 @@ float_m KFParticleBaseSIMD::GetPt( float_v &pt, float_v &error ) const float_v px = fP[3]; float_v py = fP[4]; - float_v px2 = px*px; - float_v py2 = py*py; - float_v pt2 = px2+py2; + float_v px2 = px * px; + float_v py2 = py * py; + float_v pt2 = px2 + py2; pt = sqrt(pt2); - error = (px2*fC[9] + py2*fC[14] + 2*px*py*fC[13] ); + error = (px2 * fC[9] + py2 * fC[14] + 2 * px * py * fC[13]); const float_v LocalSmall = 1.e-4f; - float_m mask = ( (0.f < error) && (LocalSmall < abs(pt))); + float_m mask = ((0.f < error) && (LocalSmall < abs(pt))); error(!mask) = 1.e20f; error = sqrt(error); return (!mask); } -float_m KFParticleBaseSIMD::GetEta( float_v &eta, float_v &error ) const +float_m KFParticleBaseSIMD::GetEta(float_v& eta, float_v& error) const { /** Calculates particle pseudorapidity and its error. If they are well defined the corresponding element of the ** return mask is set to 0, otherwise 1. ** \param[out] eta - pseudorapidity of the particle ** \param[out] error - its error **/ - + const float_v BIG = 1.e8f; const float_v LocalSmall = 1.e-8f; float_v px = fP[3]; float_v py = fP[4]; float_v pz = fP[5]; - float_v pt2 = px*px + py*py; - float_v p2 = pt2 + pz*pz; + float_v pt2 = px * px + py * py; + float_v p2 = pt2 + pz * pz; float_v p = sqrt(p2); float_v a = p + pz; float_v b = p - pz; eta = BIG; float_v c = 0.f; - c(b > LocalSmall) = (a/b); - float_v logc = 0.5f*KFPMath::Log(c); - eta(LocalSmall LocalSmall) = (a / b); + float_v logc = 0.5f * KFPMath::Log(c); + eta(LocalSmall < abs(c)) = logc; - float_v h3 = -px*pz; - float_v h4 = -py*pz; - float_v pt4 = pt2*pt2; - float_v p2pt4 = p2*pt4; - error = (h3*h3*fC[9] + h4*h4*fC[14] + pt4*fC[20] + 2*( h3*(h4*fC[13] + fC[18]*pt2) + pt2*h4*fC[19] ) ); + float_v h3 = -px * pz; + float_v h4 = -py * pz; + float_v pt4 = pt2 * pt2; + float_v p2pt4 = p2 * pt4; + error = (h3 * h3 * fC[9] + h4 * h4 * fC[14] + pt4 * fC[20] + 2 * (h3 * (h4 * fC[13] + fC[18] * pt2) + pt2 * h4 * fC[19])); float_m mask = ((LocalSmall < abs(p2pt4)) && (0.f < error)); - error(mask) = sqrt(error/p2pt4); + error(mask) = sqrt(error / p2pt4); error(!mask) = BIG; return (!mask); } -float_m KFParticleBaseSIMD::GetPhi( float_v &phi, float_v &error ) const +float_m KFParticleBaseSIMD::GetPhi(float_v& phi, float_v& error) const { /** Calculates particle polar angle at the current point and its error. If they are well defined the corresponding element of the ** return mask is set to 0, otherwise 1. ** \param[out] phi - polar angle of the particle ** \param[out] error - its error **/ - + float_v px = fP[3]; float_v py = fP[4]; - float_v px2 = px*px; - float_v py2 = py*py; + float_v px2 = px * px; + float_v py2 = py * py; float_v pt2 = px2 + py2; - phi = KFPMath::ATan2(py,px); - error = (py2*fC[9] + px2*fC[14] - float_v(2.f)*px*py*fC[13] ); + phi = KFPMath::ATan2(py, px); + error = (py2 * fC[9] + px2 * fC[14] - float_v(2.f) * px * py * fC[13]); float_m mask = (0.f < error) && (1.e-4f < pt2); - error(mask) = sqrt(error)/pt2; + error(mask) = sqrt(error) / pt2; error(!mask) = 1.e10f; return !mask; } -float_m KFParticleBaseSIMD::GetR( float_v &r, float_v &error ) const +float_m KFParticleBaseSIMD::GetR(float_v& r, float_v& error) const { /** Calculates the distance to the point {0,0,0} and its error. If they are well defined the corresponding element of the ** return mask is set to 0, otherwise 1. ** \param[out] r - polar angle of the particle ** \param[out] error - its error **/ - + float_v x = fP[0]; float_v y = fP[1]; - float_v x2 = x*x; - float_v y2 = y*y; + float_v x2 = x * x; + float_v y2 = y * y; r = sqrt(x2 + y2); - error = (x2*fC[0] + y2*fC[2] - float_v(2.f)*x*y*fC[1] ); + error = (x2 * fC[0] + y2 * fC[2] - float_v(2.f) * x * y * fC[1]); float_m mask = (0.f < error) && (1.e-4f < r); - error(mask) = sqrt(error)/r; - error(!mask ) = 1.e10f; + error(mask) = sqrt(error) / r; + error(!mask) = 1.e10f; return !mask; } -float_m KFParticleBaseSIMD::GetMass( float_v &m, float_v &error ) const +float_m KFParticleBaseSIMD::GetMass(float_v& m, float_v& error) const { /** Calculates the mass of the particle and its error. If they are well defined the corresponding element of the ** return mask is set to 0, otherwise 1. ** \param[out] m - mass of the particle ** \param[out] error - its error - **/ + **/ const float_v BIG = 1.e8f; const float_v LocalSmall = 1.e-8f; - float_v s = ( fP[3]*fP[3]*fC[9] + fP[4]*fP[4]*fC[14] + fP[5]*fP[5]*fC[20] - + fP[6]*fP[6]*fC[27] - + float_v(2.f)*( + fP[3]*fP[4]*fC[13] + fP[5]*(fP[3]*fC[18] + fP[4]*fC[19]) - - fP[6]*( fP[3]*fC[24] + fP[4]*fC[25] + fP[5]*fC[26] ) ) - ); + float_v s = (fP[3] * fP[3] * fC[9] + fP[4] * fP[4] * fC[14] + fP[5] * fP[5] * fC[20] + fP[6] * fP[6] * fC[27] + float_v(2.f) * (+fP[3] * fP[4] * fC[13] + fP[5] * (fP[3] * fC[18] + fP[4] * fC[19]) - fP[6] * (fP[3] * fC[24] + fP[4] * fC[25] + fP[5] * fC[26]))); - float_v m2 = (fP[6]*fP[6] - fP[3]*fP[3] - fP[4]*fP[4] - fP[5]*fP[5]); + float_v m2 = (fP[6] * fP[6] - fP[3] * fP[3] - fP[4] * fP[4] - fP[5] * fP[5]); float_m mask = 0.f <= m2; m(mask) = sqrt(m2); m(!mask) = -sqrt(-m2); mask = (mask && (0.f <= s) && (LocalSmall < m)); - error(mask) = sqrt(s)/m; + error(mask) = sqrt(s) / m; error(!mask) = BIG; return !mask; } - -float_m KFParticleBaseSIMD::GetDecayLength( float_v &l, float_v &error ) const +float_m KFParticleBaseSIMD::GetDecayLength(float_v& l, float_v& error) const { /** Calculates the decay length of the particle in the laboratory system and its error. If they are well defined the corresponding element of the ** return mask is set to 0, otherwise 1. @@ -277,22 +274,20 @@ float_m KFParticleBaseSIMD::GetDecayLength( float_v &l, float_v &error ) const ** \param[out] l - the decay length ** \param[out] error - its error **/ - + const float_v BIG = 1.e20f; float_v x = fP[3]; float_v y = fP[4]; float_v z = fP[5]; float_v t = fP[7]; - float_v x2 = x*x; - float_v y2 = y*y; - float_v z2 = z*z; - float_v p2 = x2+y2+z2; - l = t*sqrt(p2); + float_v x2 = x * x; + float_v y2 = y * y; + float_v z2 = z * z; + float_v p2 = x2 + y2 + z2; + l = t * sqrt(p2); - error = p2*fC[35] + t*t/p2*(x2*fC[9]+y2*fC[14]+z2*fC[20] - + float_v(2.f)*(x*y*fC[13]+x*z*fC[18]+y*z*fC[19]) ) - + float_v(2.f)*t*(x*fC[31]+y*fC[32]+z*fC[33]); + error = p2 * fC[35] + t * t / p2 * (x2 * fC[9] + y2 * fC[14] + z2 * fC[20] + float_v(2.f) * (x * y * fC[13] + x * z * fC[18] + y * z * fC[19])) + float_v(2.f) * t * (x * fC[31] + y * fC[32] + z * fC[33]); float_m mask = ((1.e-4f) < p2); error(mask) = sqrt(abs(error)); @@ -300,7 +295,7 @@ float_m KFParticleBaseSIMD::GetDecayLength( float_v &l, float_v &error ) const return !mask; } -float_m KFParticleBaseSIMD::GetDecayLengthXY( float_v &l, float_v &error ) const +float_m KFParticleBaseSIMD::GetDecayLengthXY(float_v& l, float_v& error) const { /** Calculates the projection in the XY plane of the decay length of the particle in the laboratory ** system and its error. If they are well defined the corresponding element of the @@ -309,26 +304,24 @@ float_m KFParticleBaseSIMD::GetDecayLengthXY( float_v &l, float_v &error ) const ** \param[out] l - the decay length ** \param[out] error - its error **/ - + const float_v BIG = 1.e8f; float_v x = fP[3]; float_v y = fP[4]; float_v t = fP[7]; - float_v x2 = x*x; - float_v y2 = y*y; - float_v pt2 = x2+y2; - l = t*sqrt(pt2); + float_v x2 = x * x; + float_v y2 = y * y; + float_v pt2 = x2 + y2; + l = t * sqrt(pt2); - error = pt2*fC[35] + t*t/pt2*(x2*fC[9]+y2*fC[14] + 2*x*y*fC[13] ) - + float_v(2.f)*t*(x*fC[31]+y*fC[32]); + error = pt2 * fC[35] + t * t / pt2 * (x2 * fC[9] + y2 * fC[14] + 2 * x * y * fC[13]) + float_v(2.f) * t * (x * fC[31] + y * fC[32]); float_m mask = ((1.e-4f) < pt2); error(mask) = sqrt(abs(error)); error(!mask) = BIG; return !mask; } - -float_m KFParticleBaseSIMD::GetLifeTime( float_v &tauC, float_v &error ) const +float_m KFParticleBaseSIMD::GetLifeTime(float_v& tauC, float_v& error) const { /** Calculates the lifetime times speed of life (ctau) [cm] of the particle in the ** center of mass frame and its error. If they are well defined the corresponding element of the @@ -337,31 +330,30 @@ float_m KFParticleBaseSIMD::GetLifeTime( float_v &tauC, float_v &error ) const ** \param[out] ctau - lifetime of the particle [cm] ** \param[out] error - its error **/ - + const float_v BIG = 1.e20f; float_v m, dm; - GetMass( m, dm ); - float_v cTM = (-fP[3]*fC[31] - fP[4]*fC[32] - fP[5]*fC[33] + fP[6]*fC[34]); - tauC = fP[7]*m; - error = m*m*fC[35] + 2*fP[7]*cTM + fP[7]*fP[7]*dm*dm; + GetMass(m, dm); + float_v cTM = (-fP[3] * fC[31] - fP[4] * fC[32] - fP[5] * fC[33] + fP[6] * fC[34]); + tauC = fP[7] * m; + error = m * m * fC[35] + 2 * fP[7] * cTM + fP[7] * fP[7] * dm * dm; float_m mask = (0.f < error); error(mask) = sqrt(error); error(!mask) = BIG; return !mask; } - -void KFParticleBaseSIMD::operator +=( const KFParticleBaseSIMD &Daughter ) +void KFParticleBaseSIMD::operator+=(const KFParticleBaseSIMD& Daughter) { /** Operator to add daughter to the current particle. Calls AddDaughter() function. ** \param[in] Daughter - the daughter particle **/ - - AddDaughter( Daughter ); + + AddDaughter(Daughter); } -void KFParticleBaseSIMD::GetMeasurement( const KFParticleBaseSIMD& daughter, float_v m[], float_v V[], float_v D[3][3] ) +void KFParticleBaseSIMD::GetMeasurement(const KFParticleBaseSIMD& daughter, float_v m[], float_v V[], float_v D[3][3]) { /** Obtains the measurements from the current particle and the daughter to be added for the Kalman filter ** mathematics. If these are two first daughters they are transported to the point of the closest approach, @@ -375,133 +367,113 @@ void KFParticleBaseSIMD::GetMeasurement( const KFParticleBaseSIMD& daughter, flo ** \param[out] V[36] - the output covariance matrix of the daughter parameters, takes into account the correlation ** \param[out] D[3][3] - the correlation matrix between the current and daughter particles **/ - - if(fNDF[0] == -1) - { - float_v ds[2] = {0.f,0.f}; + + if (fNDF[0] == -1) { + float_v ds[2] = {0.f, 0.f}; float_v dsdr[4][6]; float_v F1[36], F2[36], F3[36], F4[36]; - for(int i1=0; i1<36; i1++) - { + for (int i1 = 0; i1 < 36; i1++) { F1[i1] = 0; F2[i1] = 0; F3[i1] = 0; F4[i1] = 0; } - GetDStoParticle( daughter, ds, dsdr ); - - float_v V0Tmp[36] ; - float_v V1Tmp[36] ; + GetDStoParticle(daughter, ds, dsdr); + + float_v V0Tmp[36]; + float_v V1Tmp[36]; float_v C[36]; - for(int iC=0; iC<36; iC++) + for (int iC = 0; iC < 36; iC++) C[iC] = fC[iC]; - - Transport(ds[0], dsdr[0], fP, fC, dsdr[1], F1, F2); - daughter.Transport(ds[1], dsdr[3], m, V, dsdr[2], F4, F3); + + Transport(ds[0], dsdr[0], fP, fC, dsdr[1], F1, F2); + daughter.Transport(ds[1], dsdr[3], m, V, dsdr[2], F4, F3); MultQSQt(F2, daughter.fC, V0Tmp, 6); MultQSQt(F3, C, V1Tmp, 6); - - for(int iC=0; iC<21; iC++) - { + + for (int iC = 0; iC < 21; iC++) { fC[iC] += V0Tmp[iC]; - V[iC] += V1Tmp[iC]; + V[iC] += V1Tmp[iC]; } - + float_v C1F1T[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { C1F1T[i][j] = 0; - for(int k=0; k<6; k++) - { - C1F1T[i][j] += C[IJ(i,k)] * F1[j*6+k]; + for (int k = 0; k < 6; k++) { + C1F1T[i][j] += C[IJ(i, k)] * F1[j * 6 + k]; } } float_v F3C1F1T[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { F3C1F1T[i][j] = 0; - for(int k=0; k<6; k++) - { - F3C1F1T[i][j] += F3[i*6+k] * C1F1T[k][j]; + for (int k = 0; k < 6; k++) { + F3C1F1T[i][j] += F3[i * 6 + k] * C1F1T[k][j]; } } float_v C2F2T[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { C2F2T[i][j] = 0; - for(int k=0; k<6; k++) - { - C2F2T[i][j] += daughter.fC[IJ(i,k)] * F2[j*6+k]; + for (int k = 0; k < 6; k++) { + C2F2T[i][j] += daughter.fC[IJ(i, k)] * F2[j * 6 + k]; } } - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { D[i][j] = F3C1F1T[i][j]; - for(int k=0; k<6; k++) - { - D[i][j] += F4[i*6+k] * C2F2T[k][j]; + for (int k = 0; k < 6; k++) { + D[i][j] += F4[i * 6 + k] * C2F2T[k][j]; } - } - } - else - { + } + } else { float_v dsdr[6]; float_v dS = daughter.GetDStoPoint(fP, dsdr); - + float_v dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0.f, 0.f, 0.f}; - + float_v F[36], F1[36]; - for(int i2=0; i2<36; i2++) - { - F[i2] = 0; + for (int i2 = 0; i2 < 36; i2++) { + F[i2] = 0; F1[i2] = 0; } daughter.Transport(dS, dsdr, m, V, dsdp, F, F1); - -// float_v V1Tmp[36] = {0.}; -// MultQSQt(F1, fC, V1Tmp, 6); - -// for(int iC=0; iC<21; iC++) -// V[iC] += V1Tmp[iC]; - + + // float_v V1Tmp[36] = {0.}; + // MultQSQt(F1, fC, V1Tmp, 6); + + // for(int iC=0; iC<21; iC++) + // V[iC] += V1Tmp[iC]; + float_v VFT[3][6]; - for(int i=0; i<3; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 6; j++) { VFT[i][j] = 0; - for(int k=0; k<3; k++) - { - VFT[i][j] += fC[IJ(i,k)] * F1[j*6+k]; + for (int k = 0; k < 3; k++) { + VFT[i][j] += fC[IJ(i, k)] * F1[j * 6 + k]; } } - + float_v FVFT[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { FVFT[i][j] = 0; - for(int k=0; k<3; k++) - { - FVFT[i][j] += F1[i*6+k] * VFT[k][j]; + for (int k = 0; k < 3; k++) { + FVFT[i][j] += F1[i * 6 + k] * VFT[k][j]; } } - - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - { + + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { D[i][j] = 0; - for(int k=0; k<3; k++) - { - D[i][j] += fC[IJ(j,k)] * F1[i*6+k]; + for (int k = 0; k < 3; k++) { + D[i][j] += fC[IJ(j, k)] * F1[i * 6 + k]; } } - + V[0] += FVFT[0][0]; V[1] += FVFT[1][0]; V[2] += FVFT[1][1]; @@ -511,7 +483,7 @@ void KFParticleBaseSIMD::GetMeasurement( const KFParticleBaseSIMD& daughter, flo } } -void KFParticleBaseSIMD::AddDaughter( const KFParticleBaseSIMD &Daughter ) +void KFParticleBaseSIMD::AddDaughter(const KFParticleBaseSIMD& Daughter) { /** Adds daughter to the current particle. Depending on the selected construction method uses: \n ** 1) Either simplifyed fast mathematics which consideres momentum and energy as @@ -525,30 +497,32 @@ void KFParticleBaseSIMD::AddDaughter( const KFParticleBaseSIMD &Daughter ) ** AddDaughterWithEnergyFitMC() function. ** \param[in] Daughter - the daughter particle **/ - - AddDaughterId( Daughter.Id() ); - - if( int(fNDF[0])<-1 ){ // first daughter -> just copy - fNDF = -1; - fQ = Daughter.GetQ(); - for( Int_t i=0; i<7; i++ ) fP[i] = Daughter.fP[i]; - for( Int_t i=0; i<28; i++ ) fC[i] = Daughter.fC[i]; + + AddDaughterId(Daughter.Id()); + + if (int(fNDF[0]) < -1) { // first daughter -> just copy + fNDF = -1; + fQ = Daughter.GetQ(); + for (Int_t i = 0; i < 7; i++) + fP[i] = Daughter.fP[i]; + for (Int_t i = 0; i < 28; i++) + fC[i] = Daughter.fC[i]; fSFromDecay = 0; fMassHypo = Daughter.fMassHypo; SumDaughterMass = Daughter.SumDaughterMass; return; } - if(fConstructMethod == 0) + if (fConstructMethod == 0) AddDaughterWithEnergyFit(Daughter); - else if(fConstructMethod == 2) + else if (fConstructMethod == 2) AddDaughterWithEnergyFitMC(Daughter); SumDaughterMass += Daughter.SumDaughterMass; fMassHypo = -1.f; } -void KFParticleBaseSIMD::AddDaughterWithEnergyFit( const KFParticleBaseSIMD &Daughter ) +void KFParticleBaseSIMD::AddDaughterWithEnergyFit(const KFParticleBaseSIMD& Daughter) { /** Adds daughter to the current particle. Uses simplifyed fast mathematics which consideres momentum ** and energy as independent variables and thus ignores constraint on the fixed mass. @@ -560,59 +534,72 @@ void KFParticleBaseSIMD::AddDaughterWithEnergyFit( const KFParticleBaseSIMD &Dau Int_t maxIter = 1; - for( Int_t iter=0; iter update the particle //* VHt = VH' - + float_v mVHt0[7], mVHt1[7], mVHt2[7]; - - mVHt0[0]=mV[ 0] ; mVHt1[0]=mV[ 1] ; mVHt2[0]=mV[ 3] ; - mVHt0[1]=mV[ 1] ; mVHt1[1]=mV[ 2] ; mVHt2[1]=mV[ 4] ; - mVHt0[2]=mV[ 3] ; mVHt1[2]=mV[ 4] ; mVHt2[2]=mV[ 5] ; - mVHt0[3]=mV[ 6] ; mVHt1[3]=mV[ 7] ; mVHt2[3]=mV[ 8] ; - mVHt0[4]=mV[10] ; mVHt1[4]=mV[11] ; mVHt2[4]=mV[12] ; - mVHt0[5]=mV[15] ; mVHt1[5]=mV[16] ; mVHt2[5]=mV[17] ; - mVHt0[6]=mV[21] ; mVHt1[6]=mV[22] ; mVHt2[6]=mV[23] ; - + + mVHt0[0] = mV[0]; + mVHt1[0] = mV[1]; + mVHt2[0] = mV[3]; + mVHt0[1] = mV[1]; + mVHt1[1] = mV[2]; + mVHt2[1] = mV[4]; + mVHt0[2] = mV[3]; + mVHt1[2] = mV[4]; + mVHt2[2] = mV[5]; + mVHt0[3] = mV[6]; + mVHt1[3] = mV[7]; + mVHt2[3] = mV[8]; + mVHt0[4] = mV[10]; + mVHt1[4] = mV[11]; + mVHt2[4] = mV[12]; + mVHt0[5] = mV[15]; + mVHt1[5] = mV[16]; + mVHt2[5] = mV[17]; + mVHt0[6] = mV[21]; + mVHt1[6] = mV[22]; + mVHt2[6] = mV[23]; + //* Kalman gain Km = mCH'*S - + float_v km0[7], km1[7], km2[7]; - - for(Int_t i=0;i<7;++i){ - km0[i] = mVHt0[i]*mS[0] + mVHt1[i]*mS[1] + mVHt2[i]*mS[3]; - km1[i] = mVHt0[i]*mS[1] + mVHt1[i]*mS[2] + mVHt2[i]*mS[4]; - km2[i] = mVHt0[i]*mS[3] + mVHt1[i]*mS[4] + mVHt2[i]*mS[5]; + + for (Int_t i = 0; i < 7; ++i) { + km0[i] = mVHt0[i] * mS[0] + mVHt1[i] * mS[1] + mVHt2[i] * mS[3]; + km1[i] = mVHt0[i] * mS[1] + mVHt1[i] * mS[2] + mVHt2[i] * mS[4]; + km2[i] = mVHt0[i] * mS[3] + mVHt1[i] * mS[4] + mVHt2[i] * mS[5]; } - for(Int_t i=0;i<7;++i) - fP[i] = fP[i] + k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]; + for (Int_t i = 0; i < 7; ++i) + fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; - for(Int_t i=0;i<7;++i) - m[i] = m[i] - km0[i]*zeta[0] - km1[i]*zeta[1] - km2[i]*zeta[2]; + for (Int_t i = 0; i < 7; ++i) + m[i] = m[i] - km0[i] * zeta[0] - km1[i] * zeta[1] - km2[i] * zeta[2]; - for(Int_t i=0, k=0;i<7;++i){ - for(Int_t j=0;j<=i;++j,++k){ - fC[k] = fC[k] - (k0[i]*mCHt0[j] + k1[i]*mCHt1[j] + k2[i]*mCHt2[j] ); + for (Int_t i = 0, k = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) { + fC[k] = fC[k] - (k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]); } } - for(Int_t i=0, k=0;i<7;++i){ - for(Int_t j=0;j<=i;++j,++k){ - mV[k] = mV[k] - (km0[i]*mVHt0[j] + km1[i]*mVHt1[j] + km2[i]*mVHt2[j] ); + for (Int_t i = 0, k = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) { + mV[k] = mV[k] - (km0[i] * mVHt0[j] + km1[i] * mVHt1[j] + km2[i] * mVHt2[j]); } } float_v mDf[7][7]; - for(Int_t i=0;i<7;++i){ - for(Int_t j=0;j<7;++j){ - mDf[i][j] = (km0[i]*mCHt0[j] + km1[i]*mCHt1[j] + km2[i]*mCHt2[j] ); + for (Int_t i = 0; i < 7; ++i) { + for (Int_t j = 0; j < 7; ++j) { + mDf[i][j] = (km0[i] * mCHt0[j] + km1[i] * mCHt1[j] + km2[i] * mCHt2[j]); } } float_v mJ1[7][7], mJ2[7][7]; - for(Int_t iPar1=0; iPar1<7; iPar1++) - { - for(Int_t iPar2=0; iPar2<7; iPar2++) - { + for (Int_t iPar1 = 0; iPar1 < 7; iPar1++) { + for (Int_t iPar2 = 0; iPar2 < 7; iPar2++) { mJ1[iPar1][iPar2] = 0; mJ2[iPar1][iPar2] = 0; } } - float_v mMassParticle = fP[6]*fP[6] - (fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]); - float_v mMassDaughter = m[6]*m[6] - (m[3]*m[3] + m[4]*m[4] + m[5]*m[5]); + float_v mMassParticle = fP[6] * fP[6] - (fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]); + float_v mMassDaughter = m[6] * m[6] - (m[3] * m[3] + m[4] * m[4] + m[5] * m[5]); mMassParticle(mMassParticle > 0.f) = sqrt(mMassParticle); mMassParticle(mMassParticle <= 0.f) = 0.f; mMassDaughter(mMassDaughter > 0.f) = sqrt(mMassDaughter); mMassDaughter(mMassDaughter <= 0.f) = 0.f; float_m mask1 = fMassHypo > -0.5f; - float_m mask2 = (!mask1) && ( (mMassParticle < SumDaughterMass) || (fP[6]<0.f)) ; - SetMassConstraint(fP,fC,mJ1,fMassHypo, mask1); - SetMassConstraint(fP,fC,mJ1,SumDaughterMass, mask2); + float_m mask2 = (!mask1) && ((mMassParticle < SumDaughterMass) || (fP[6] < 0.f)); + SetMassConstraint(fP, fC, mJ1, fMassHypo, mask1); + SetMassConstraint(fP, fC, mJ1, SumDaughterMass, mask2); float_m mask3 = Daughter.fMassHypo > -0.5f; - float_m mask4 = ( (!mask3) && ( (mMassDaughter float_v(1.e-10f)) = -c/b ; + lambda(abs(b) > float_v(1.e-10f)) = -c / b; - float_v d = 4.f*energy2*p2 - mass2*(energy2-p2-2.f*mass2); - float_m qMask = (d >= 0.f) && (abs(a) > (1.e-10f)) ; - lambda(qMask) = (energy2 + p2 - sqrt(d))/a; + float_v d = 4.f * energy2 * p2 - mass2 * (energy2 - p2 - 2.f * mass2); + float_m qMask = (d >= 0.f) && (abs(a) > (1.e-10f)); + lambda(qMask) = (energy2 + p2 - sqrt(d)) / a; - lambda(mP[6]<0.f) = -1000000.f; + lambda(mP[6] < 0.f) = -1000000.f; - Int_t iIter=0; - for(iIter=0; iIter<100; iIter++) - { - float_v lambda2 = lambda*lambda; - float_v lambda4 = lambda2*lambda2; + Int_t iIter = 0; + for (iIter = 0; iIter < 100; iIter++) { + float_v lambda2 = lambda * lambda; + float_v lambda4 = lambda2 * lambda2; -// float_v lambda0 = lambda; + // float_v lambda0 = lambda; - float_v f = -mass2 * lambda4 + a*lambda2 + b*lambda + c; - float_v df = -4.f*mass2 * lambda2*lambda + 2.f*a*lambda + b; - lambda(abs(df) > float_v(1.e-10f)) -= f/df; -// if(TMath::Abs(lambda0 - lambda) < 1.e-8) break; + float_v f = -mass2 * lambda4 + a * lambda2 + b * lambda + c; + float_v df = -4.f * mass2 * lambda2 * lambda + 2.f * a * lambda + b; + lambda(abs(df) > float_v(1.e-10f)) -= f / df; + // if(TMath::Abs(lambda0 - lambda) < 1.e-8) break; } - const float_v lpi = 1.f/(1.f + lambda); - const float_v lmi = 1.f/(1.f - lambda); - const float_v lp2i = lpi*lpi; - const float_v lm2i = lmi*lmi; + const float_v lpi = 1.f / (1.f + lambda); + const float_v lmi = 1.f / (1.f - lambda); + const float_v lp2i = lpi * lpi; + const float_v lm2i = lmi * lmi; - float_v lambda2 = lambda*lambda; + float_v lambda2 = lambda * lambda; - float_v dfl = -4.f*mass2 * lambda2*lambda + 2.f*a*lambda + b; - float_v dfx[4] = {0.f,0.f,0.f,0.f}; - dfx[0] = -2.f*(1.f + lambda)*(1.f + lambda)*mP[3]; - dfx[1] = -2.f*(1.f + lambda)*(1.f + lambda)*mP[4]; - dfx[2] = -2.f*(1.f + lambda)*(1.f + lambda)*mP[5]; - dfx[3] = 2.f*(1.f - lambda)*(1.f - lambda)*mP[6]; - float_v dlx[4] = {1.f,1.f,1.f,1.f}; + float_v dfl = -4.f * mass2 * lambda2 * lambda + 2.f * a * lambda + b; + float_v dfx[4] = {0.f, 0.f, 0.f, 0.f}; + dfx[0] = -2.f * (1.f + lambda) * (1.f + lambda) * mP[3]; + dfx[1] = -2.f * (1.f + lambda) * (1.f + lambda) * mP[4]; + dfx[2] = -2.f * (1.f + lambda) * (1.f + lambda) * mP[5]; + dfx[3] = 2.f * (1.f - lambda) * (1.f - lambda) * mP[6]; + float_v dlx[4] = {1.f, 1.f, 1.f, 1.f}; - for(int i=0; i<4; i++) + for (int i = 0; i < 4; i++) dlx[i](abs(dfl) > float_v(1.e-10f)) = -dfx[i] / dfl; - float_v dxx[4] = {mP[3]*lm2i, mP[4]*lm2i, mP[5]*lm2i, -mP[6]*lp2i}; + float_v dxx[4] = {mP[3] * lm2i, mP[4] * lm2i, mP[5] * lm2i, -mP[6] * lp2i}; - for(Int_t i=0; i<7; i++) - for(Int_t j=0; j<7; j++) - mJ[i][j]=0; + for (Int_t i = 0; i < 7; i++) + for (Int_t j = 0; j < 7; j++) + mJ[i][j] = 0; mJ[0][0] = 1.; mJ[1][1] = 1.; mJ[2][2] = 1.; - for(Int_t i=3; i<7; i++) - for(Int_t j=3; j<7; j++) - mJ[i][j] = dlx[j-3]*dxx[i-3]; + for (Int_t i = 3; i < 7; i++) + for (Int_t j = 3; j < 7; j++) + mJ[i][j] = dlx[j - 3] * dxx[i - 3]; - for(Int_t i=3; i<6; i++) + for (Int_t i = 3; i < 6; i++) mJ[i][i] += lmi; mJ[6][6] += lpi; float_v mCJ[7][7]; - for(Int_t i=0; i<7; i++) { - for(Int_t j=0; j<7; j++) { + for (Int_t i = 0; i < 7; i++) { + for (Int_t j = 0; j < 7; j++) { mCJ[i][j] = 0; - for(Int_t k=0; k<7; k++) { - mCJ[i][j] += mC[IJ(i,k)]*mJ[j][k]; + for (Int_t k = 0; k < 7; k++) { + mCJ[i][j] += mC[IJ(i, k)] * mJ[j][k]; } } } - for(Int_t i=0; i<7; ++i){ - for(Int_t j=0; j<=i; ++j){ - mC[IJ(i,j)](mask) = 0.f; - for(Int_t l=0; l<7; l++){ - mC[IJ(i,j)](mask) += mJ[i][l]*mCJ[l][j]; + for (Int_t i = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j) { + mC[IJ(i, j)](mask) = 0.f; + for (Int_t l = 0; l < 7; l++) { + mC[IJ(i, j)](mask) += mJ[i][l] * mCJ[l][j]; } } } @@ -1333,114 +1342,117 @@ void KFParticleBaseSIMD::SetMassConstraint( float_v *mP, float_v *mC, float_v mJ mP[6](mask) *= lpi; } -void KFParticleBaseSIMD::SetNonlinearMassConstraint( float_v mass ) +void KFParticleBaseSIMD::SetNonlinearMassConstraint(float_v mass) { /** Sets the exact nonlinear mass constraint on the current particle. ** \param[in] mass - the mass to be set on the particle **/ - + const float_v& px = fP[3]; const float_v& py = fP[4]; const float_v& pz = fP[5]; - const float_v& energy = fP[6]; - - const float_v residual = (energy*energy - px*px - py*py - pz*pz) - mass*mass; - const float_v dm2 = float_v(4.f) * ( fC[9]*px*px + fC[14]*py*py + fC[20]*pz*pz + fC[27]*energy*energy + - float_v(2.f) * ( (fC[13]*py + fC[18]*pz - fC[24]*energy)*px + (fC[19]*pz - fC[25]*energy)*py - fC[26]*pz*energy) ); - const float_v dChi2 = residual*residual / dm2; + const float_v& energy = fP[6]; + + const float_v residual = (energy * energy - px * px - py * py - pz * pz) - mass * mass; + const float_v dm2 = float_v(4.f) * (fC[9] * px * px + fC[14] * py * py + fC[20] * pz * pz + fC[27] * energy * energy + + float_v(2.f) * ((fC[13] * py + fC[18] * pz - fC[24] * energy) * px + (fC[19] * pz - fC[25] * energy) * py - fC[26] * pz * energy)); + const float_v dChi2 = residual * residual / dm2; fChi2 += dChi2; - fNDF += 1; - + fNDF += 1; + float_v mJ[7][7]; - SetMassConstraint( fP, fC, mJ, mass, float_m(true) ); + SetMassConstraint(fP, fC, mJ, mass, float_m(true)); fMassHypo = mass; SumDaughterMass = mass; } -void KFParticleBaseSIMD::SetMassConstraint( float_v Mass, float_v SigmaMass ) -{ +void KFParticleBaseSIMD::SetMassConstraint(float_v Mass, float_v SigmaMass) +{ /** Sets linearised mass constraint on the current particle. The constraint can be set with ** an uncertainty. ** \param[in] Mass - the mass to be set on the state vector mP ** \param[in] SigmaMass - uncertainty of the constraint **/ - + fMassHypo = Mass; SumDaughterMass = Mass; - float_v m2 = Mass*Mass; // measurement, weighted by Mass - float_v s2 = m2*SigmaMass*SigmaMass; // sigma^2 + float_v m2 = Mass * Mass; // measurement, weighted by Mass + float_v s2 = m2 * SigmaMass * SigmaMass; // sigma^2 - float_v p2 = fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]; - float_v e0 = sqrt(m2+p2); + float_v p2 = fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]; + float_v e0 = sqrt(m2 + p2); float_v mH[8]; mH[0] = mH[1] = mH[2] = 0.f; - mH[3] = -2.f*fP[3]; - mH[4] = -2.f*fP[4]; - mH[5] = -2.f*fP[5]; - mH[6] = 2.f*fP[6];//e0; - mH[7] = 0.f; - - float_v zeta = e0*e0 - e0*fP[6]; - zeta = m2 - (fP[6]*fP[6]-p2); - - float_v mCHt[8], s2_est=0.f; - for( Int_t i=0; i<8; ++i ){ + mH[3] = -2.f * fP[3]; + mH[4] = -2.f * fP[4]; + mH[5] = -2.f * fP[5]; + mH[6] = 2.f * fP[6]; //e0; + mH[7] = 0.f; + + float_v zeta = e0 * e0 - e0 * fP[6]; + zeta = m2 - (fP[6] * fP[6] - p2); + + float_v mCHt[8], s2_est = 0.f; + for (Int_t i = 0; i < 8; ++i) { mCHt[i] = 0.0f; - for (Int_t j=0;j<8;++j) mCHt[i] += Cij(i,j)*mH[j]; - s2_est += mH[i]*mCHt[i]; + for (Int_t j = 0; j < 8; ++j) + mCHt[i] += Cij(i, j) * mH[j]; + s2_est += mH[i] * mCHt[i]; } - -//TODO add protection -// if( s2_est<1.e-20 ) return; // calculated mass error is already 0, - // the particle can not be constrained on mass - - float_v w2 = 1.f/( s2 + s2_est ); - fChi2 += zeta*zeta*w2; - fNDF += 1; - for( Int_t i=0, ii=0; i<8; ++i ){ - float_v ki = mCHt[i]*w2; - fP[i]+= ki*zeta; - for(Int_t j=0;j<=i;++j) fC[ii++] -= ki*mCHt[j]; + + //TODO add protection + // if( s2_est<1.e-20 ) return; // calculated mass error is already 0, + // the particle can not be constrained on mass + + float_v w2 = 1.f / (s2 + s2_est); + fChi2 += zeta * zeta * w2; + fNDF += 1; + for (Int_t i = 0, ii = 0; i < 8; ++i) { + float_v ki = mCHt[i] * w2; + fP[i] += ki * zeta; + for (Int_t j = 0; j <= i; ++j) + fC[ii++] -= ki * mCHt[j]; } } - void KFParticleBaseSIMD::SetNoDecayLength() -{ +{ /** Sets constraint on the zero decay length. When the production point is set ** the measurement from this particle is created at the decay point. **/ - + TransportToDecayVertex(); float_v h[8]; h[0] = h[1] = h[2] = h[3] = h[4] = h[5] = h[6] = 0.f; - h[7] = 1.f; + h[7] = 1.f; float_v zeta = 0.f - fP[7]; - for(Int_t i=0;i<8;++i) zeta -= h[i]*(fP[i]-fP[i]); - - float_v s = fC[35]; -// if( s>1.e-20 ) //TODO add protection + for (Int_t i = 0; i < 8; ++i) + zeta -= h[i] * (fP[i] - fP[i]); + + float_v s = fC[35]; + // if( s>1.e-20 ) //TODO add protection { - s = 1.f/s; - fChi2 += zeta*zeta*s; - fNDF += 1; - for( Int_t i=0, ii=0; i<7; ++i ){ - float_v ki = fC[28+i]*s; - fP[i]+= ki*zeta; - for(Int_t j=0;j<=i;++j) fC[ii++] -= ki*fC[28+j]; + s = 1.f / s; + fChi2 += zeta * zeta * s; + fNDF += 1; + for (Int_t i = 0, ii = 0; i < 7; ++i) { + float_v ki = fC[28 + i] * s; + fP[i] += ki * zeta; + for (Int_t j = 0; j <= i; ++j) + fC[ii++] -= ki * fC[28 + j]; } } fP[7] = 0.f; fC[28] = fC[29] = fC[30] = fC[31] = fC[32] = fC[33] = fC[34] = fC[35] = 0.f; } -void KFParticleBaseSIMD::Construct( const KFParticleBaseSIMD* vDaughters[], Int_t nDaughters, - const KFParticleBaseSIMD *Parent, Float_t Mass ) -{ +void KFParticleBaseSIMD::Construct(const KFParticleBaseSIMD* vDaughters[], Int_t nDaughters, + const KFParticleBaseSIMD* Parent, Float_t Mass) +{ /** Constructs a short-lived particle from a set of daughter particles:\n ** 1) all parameters of the "this" objects are initialised;\n ** 2) daughters are added one after another;\n @@ -1451,65 +1463,69 @@ void KFParticleBaseSIMD::Construct( const KFParticleBaseSIMD* vDaughters[], Int_ ** \param[in] Parent - optional parrent particle ** \param[in] Mass - optional mass hypothesis **/ - + const int maxIter = 1; - for( Int_t iter=0; iter=0 ) SetMassConstraint( Mass ); - if( Parent ) SetProductionVertex( *Parent ); + if (Mass >= 0) + SetMassConstraint(Mass); + if (Parent) + SetProductionVertex(*Parent); } void KFParticleBaseSIMD::TransportToDecayVertex() { - /** Transports the particle to its decay vertex */ - float_v dsdr[6] = {float_v(Vc::Zero),float_v(Vc::Zero),float_v(Vc::Zero),float_v(Vc::Zero),float_v(Vc::Zero),float_v(Vc::Zero)}; - if( !( (abs(fSFromDecay) < float_v(1.e-6f)).isFull() ) ) TransportToDS( -fSFromDecay, dsdr ); + /** Transports the particle to its decay vertex */ + float_v dsdr[6] = {float_v(Vc::Zero), float_v(Vc::Zero), float_v(Vc::Zero), float_v(Vc::Zero), float_v(Vc::Zero), float_v(Vc::Zero)}; + if (!((abs(fSFromDecay) < float_v(1.e-6f)).isFull())) + TransportToDS(-fSFromDecay, dsdr); fAtProductionVertex = 0; } void KFParticleBaseSIMD::TransportToProductionVertex() { /** Transports the particle to its production vertex */ - float_v dsdr[6] = {float_v(Vc::Zero),float_v(Vc::Zero),float_v(Vc::Zero),float_v(Vc::Zero),float_v(Vc::Zero),float_v(Vc::Zero)}; - if( !( (abs(fSFromDecay + fP[7]) < float_v(1.e-6f)).isFull() ) ) TransportToDS( -fSFromDecay-fP[7], dsdr ); + float_v dsdr[6] = {float_v(Vc::Zero), float_v(Vc::Zero), float_v(Vc::Zero), float_v(Vc::Zero), float_v(Vc::Zero), float_v(Vc::Zero)}; + if (!((abs(fSFromDecay + fP[7]) < float_v(1.e-6f)).isFull())) + TransportToDS(-fSFromDecay - fP[7], dsdr); fAtProductionVertex = 1; } - -void KFParticleBaseSIMD::TransportToDS( float_v dS, const float_v* dsdr ) -{ +void KFParticleBaseSIMD::TransportToDS(float_v dS, const float_v* dsdr) +{ /** Transport the particle on a certain distane. The distance is defined by the dS=l/p parameter, where \n ** 1) l - signed distance;\n ** 2) p - momentum of the particle. \n ** \param[in] dS = l/p - distance normalised to the momentum of the particle to be transported on ** \param[in] dsdr[6] = ds/dr partial derivatives of the parameter dS over the state vector of the current particle **/ - - Transport( dS, dsdr, fP, fC ); - fSFromDecay+= dS; + + Transport(dS, dsdr, fP, fC); + fSFromDecay += dS; } -void KFParticleBaseSIMD::TransportToDSLine( float_v dS, const float_v* dsdr ) -{ +void KFParticleBaseSIMD::TransportToDSLine(float_v dS, const float_v* dsdr) +{ /** Transport the particle on a certain distane assuming the linear trajectory. ** The distance is defined by the dS=l/p parameter, where \n ** 1) l - signed distance;\n @@ -1517,12 +1533,12 @@ void KFParticleBaseSIMD::TransportToDSLine( float_v dS, const float_v* dsdr ) ** \param[in] dS = l/p - distance normalised to the momentum of the particle to be transported on ** \param[in] dsdr[6] = ds/dr partial derivatives of the parameter dS over the state vector of the current particle **/ - - TransportLine( dS, dsdr, fP, fC ); - fSFromDecay+= dS; + + TransportLine(dS, dsdr, fP, fC); + fSFromDecay += dS; } -void KFParticleBaseSIMD::GetDistanceToVertexLine( const KFParticleBaseSIMD &Vertex, float_v &l, float_v &dl, float_m *isParticleFromVertex ) const +void KFParticleBaseSIMD::GetDistanceToVertexLine(const KFParticleBaseSIMD& Vertex, float_v& l, float_v& dl, float_m* isParticleFromVertex) const { /** Calculates the distance between the particle position and the vertex together with the error. ** Errors of both particle and vertex are taken into account. Also optionally checks if partcile @@ -1534,38 +1550,37 @@ void KFParticleBaseSIMD::GetDistanceToVertexLine( const KFParticleBaseSIMD &Vert ** \param[out] isParticleFromVertex - mask which shows if particle is flying in the direction from the vertex **/ - float_v c[6] = {Vertex.fC[0]+fC[0], Vertex.fC[1]+fC[1], Vertex.fC[2]+fC[2], - Vertex.fC[3]+fC[3], Vertex.fC[4]+fC[4], Vertex.fC[5]+fC[5]}; + float_v c[6] = {Vertex.fC[0] + fC[0], Vertex.fC[1] + fC[1], Vertex.fC[2] + fC[2], + Vertex.fC[3] + fC[3], Vertex.fC[4] + fC[4], Vertex.fC[5] + fC[5]}; - float_v dx = (Vertex.fP[0]-fP[0]); - float_v dy = (Vertex.fP[1]-fP[1]); - float_v dz = (Vertex.fP[2]-fP[2]); + float_v dx = (Vertex.fP[0] - fP[0]); + float_v dy = (Vertex.fP[1] - fP[1]); + float_v dz = (Vertex.fP[2] - fP[2]); - l = sqrt( dx*dx + dy*dy + dz*dz ); - dl = c[0]*dx*dx + c[2]*dy*dy + c[5]*dz*dz + 2*(c[1]*dx*dy + c[3]*dx*dz + c[4]*dy*dz); + l = sqrt(dx * dx + dy * dy + dz * dz); + dl = c[0] * dx * dx + c[2] * dy * dy + c[5] * dz * dz + 2 * (c[1] * dx * dy + c[3] * dx * dz + c[4] * dy * dz); l(abs(l) < 1.e-8f) = 1.e-8f; - float_m ok = float_v(Vc::Zero)<=dl; + float_m ok = float_v(Vc::Zero) <= dl; dl(!ok) = 1.e8f; - dl(ok) = sqrt( dl )/l; - - if(isParticleFromVertex) - { - *isParticleFromVertex = ok && ( l(fQ)*kCLight; - float_v pt2 = param[3]*param[3] + param[4]*param[4]; - float_v p2 = pt2 + param[5]*param[5]; - + float_v bq = B * simd_cast(fQ) * kCLight; + float_v pt2 = param[3] * param[3] + param[4] * param[4]; + float_v p2 = pt2 + param[5] * param[5]; + float_v dx = xyz[0] - param[0]; - float_v dy = xyz[1] - param[1]; - float_v dz = xyz[2] - param[2]; - float_v a = dx*param[3]+dy*param[4]; + float_v dy = xyz[1] - param[1]; + float_v dz = xyz[2] - param[2]; + float_v a = dx * param[3] + dy * param[4]; float_v dS(Vc::Zero); - - float_v abq = bq*a; + + float_v abq = bq * a; const float_v LocalSmall = 1.e-8f; - float_m mask = ( abs(bq)1.e-4f)) = (a + dz*pz)/p2; - - dsdr[0](mask && float_m(p2>1.e-4f)) = -px/p2; - dsdr[1](mask && float_m(p2>1.e-4f)) = -py/p2; - dsdr[2](mask && float_m(p2>1.e-4f)) = -pz/p2; - dsdr[3](mask && float_m(p2>1.e-4f)) = (dx*p2 - 2.f* px *(a + dz *pz))/(p2*p2); - dsdr[4](mask && float_m(p2>1.e-4f)) = (dy*p2 - 2.f* py *(a + dz *pz))/(p2*p2); - dsdr[5](mask && float_m(p2>1.e-4f)) = (dz*p2 - 2.f* pz *(a + dz *pz))/(p2*p2); - - if(mask.isFull()) + float_m mask = (abs(bq) < LocalSmall); + if (!((!mask).isFull())) { + dS(mask && float_m(p2 > 1.e-4f)) = (a + dz * pz) / p2; + + dsdr[0](mask && float_m(p2 > 1.e-4f)) = -px / p2; + dsdr[1](mask && float_m(p2 > 1.e-4f)) = -py / p2; + dsdr[2](mask && float_m(p2 > 1.e-4f)) = -pz / p2; + dsdr[3](mask && float_m(p2 > 1.e-4f)) = (dx * p2 - 2.f * px * (a + dz * pz)) / (p2 * p2); + dsdr[4](mask && float_m(p2 > 1.e-4f)) = (dy * p2 - 2.f * py * (a + dz * pz)) / (p2 * p2); + dsdr[5](mask && float_m(p2 > 1.e-4f)) = (dz * p2 - 2.f * pz * (a + dz * pz)) / (p2 * p2); + + if (mask.isFull()) return dS; } - - dS(!mask) = KFPMath::ATan2( abq, pt2 + bq*(dy*px -dx*py) )/bq; - float_v bs= bq*dS; + dS(!mask) = KFPMath::ATan2(abq, pt2 + bq * (dy * px - dx * py)) / bq; + + float_v bs = bq * dS; float_v s = sin(bs), c = cos(bs); bq(abs(bq) < LocalSmall) = LocalSmall; - float_v bbq = bq*(dx*py - dy*px) - pt2; - - dsdr[0](!mask) = (px*bbq - py*abq)/(abq*abq + bbq*bbq); - dsdr[1](!mask) = (px*abq + py*bbq)/(abq*abq + bbq*bbq); + float_v bbq = bq * (dx * py - dy * px) - pt2; + + dsdr[0](!mask) = (px * bbq - py * abq) / (abq * abq + bbq * bbq); + dsdr[1](!mask) = (px * abq + py * bbq) / (abq * abq + bbq * bbq); dsdr[2](!mask) = 0; - dsdr[3](!mask) = -(dx*bbq + dy*abq + 2.f*px*a)/(abq*abq + bbq*bbq); - dsdr[4](!mask) = (dx*abq - dy*bbq - 2.f*py*a)/(abq*abq + bbq*bbq); + dsdr[3](!mask) = -(dx * bbq + dy * abq + 2.f * px * a) / (abq * abq + bbq * bbq); + dsdr[4](!mask) = (dx * abq - dy * bbq - 2.f * py * a) / (abq * abq + bbq * bbq); dsdr[5](!mask) = 0; - + float_v sz(Vc::Zero); - float_v cCoeff = (bbq*c - abq*s) - pz*pz ; - sz(abs(cCoeff) > 1.e-8f) = (dS*pz - dz)*pz / cCoeff; - - float_v dcdr[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; - dcdr[0] = -bq*py*c - bbq*s*bq*dsdr[0] + px*bq*s - abq*c*bq*dsdr[0]; - dcdr[1] = bq*px*c - bbq*s*bq*dsdr[1] + py*bq*s - abq*c*bq*dsdr[1]; - dcdr[3] = (-bq*dy-2*px)*c - bbq*s*bq*dsdr[3] - dx*bq*s - abq*c*bq*dsdr[3]; - dcdr[4] = ( bq*dx-2*py)*c - bbq*s*bq*dsdr[4] - dy*bq*s - abq*c*bq*dsdr[4]; - dcdr[5] = -2*pz; - - for(int iP=0; iP<6; iP++) - dsdr[iP](!mask) += pz*pz/cCoeff*dsdr[iP] - sz/cCoeff*dcdr[iP]; - - dsdr[2](!mask) += pz/cCoeff; - dsdr[5](!mask) += (2.f*pz*dS - dz)/cCoeff; - + float_v cCoeff = (bbq * c - abq * s) - pz * pz; + sz(abs(cCoeff) > 1.e-8f) = (dS * pz - dz) * pz / cCoeff; + + float_v dcdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; + dcdr[0] = -bq * py * c - bbq * s * bq * dsdr[0] + px * bq * s - abq * c * bq * dsdr[0]; + dcdr[1] = bq * px * c - bbq * s * bq * dsdr[1] + py * bq * s - abq * c * bq * dsdr[1]; + dcdr[3] = (-bq * dy - 2 * px) * c - bbq * s * bq * dsdr[3] - dx * bq * s - abq * c * bq * dsdr[3]; + dcdr[4] = (bq * dx - 2 * py) * c - bbq * s * bq * dsdr[4] - dy * bq * s - abq * c * bq * dsdr[4]; + dcdr[5] = -2 * pz; + + for (int iP = 0; iP < 6; iP++) + dsdr[iP](!mask) += pz * pz / cCoeff * dsdr[iP] - sz / cCoeff * dcdr[iP]; + + dsdr[2](!mask) += pz / cCoeff; + dsdr[5](!mask) += (2.f * pz * dS - dz) / cCoeff; + dS(!mask) += sz; - - bs= bq*dS; + + bs = bq * dS; s = sin(bs); c = cos(bs); - + float_v sB, cB; - const float_v kOvSqr6 = 1.f/sqrt(float_v(6.f)); + const float_v kOvSqr6 = 1.f / sqrt(float_v(6.f)); - sB(LocalSmall < abs(bs)) = s/bq; - sB(LocalSmall >= abs(bs)) = (1.f-bs*kOvSqr6)*(1.f+bs*kOvSqr6)*dS; - cB(LocalSmall < abs(bs)) = (1.f-c)/bq; - cB(LocalSmall >= abs(bs)) = .5f*sB*bs; + sB(LocalSmall < abs(bs)) = s / bq; + sB(LocalSmall >= abs(bs)) = (1.f - bs * kOvSqr6) * (1.f + bs * kOvSqr6) * dS; + cB(LocalSmall < abs(bs)) = (1.f - c) / bq; + cB(LocalSmall >= abs(bs)) = .5f * sB * bs; float_v p[5]; - p[0] = x + sB*px + cB*py; - p[1] = y - cB*px + sB*py; - p[2] = z + dS*pz; - p[3] = c*px + s*py; - p[4] = -s*px + c*py; + p[0] = x + sB * px + cB * py; + p[1] = y - cB * px + sB * py; + p[2] = z + dS * pz; + p[3] = c * px + s * py; + p[4] = -s * px + c * py; dx = xyz[0] - p[0]; dy = xyz[1] - p[1]; dz = xyz[2] - p[2]; - a = dx*p[3]+dy*p[4] + dz*pz; + a = dx * p[3] + dy * p[4] + dz * pz; + + abq = bq * a; - abq = bq*a; + dS(!mask) += KFPMath::ATan2(abq, p2 + bq * (dy * p[3] - dx * p[4])) / bq; - dS(!mask) += KFPMath::ATan2( abq, p2 + bq*(dy*p[3] -dx*p[4]) )/bq; - return dS; } -float_v KFParticleBaseSIMD::GetDStoPointBy( float_v By, const float_v xyz[3], float_v dsdr[6] ) +float_v KFParticleBaseSIMD::GetDStoPointBy(float_v By, const float_v xyz[3], float_v dsdr[6]) const -{ +{ /** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n ** 2) p - momentum of the particle; \n @@ -1726,24 +1740,24 @@ float_v KFParticleBaseSIMD::GetDStoPointBy( float_v By, const float_v xyz[3], fl ** \param[in] xyz[3] - point, to which particle should be transported ** \param[out] dsdr[6] = ds/dr - partial derivatives of the parameter dS over the state vector of the current particle **/ - - const float_v param[6] = { fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4] }; - const float_v point[3] = { xyz[0], -xyz[2], xyz[1] }; - - float_v dsdrBz[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; + + const float_v param[6] = {fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4]}; + const float_v point[3] = {xyz[0], -xyz[2], xyz[1]}; + + float_v dsdrBz[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; const float_v dS = GetDStoPointBz(By, point, dsdrBz, param); - dsdr[0] = dsdrBz[0]; - dsdr[1] = dsdrBz[2]; + dsdr[0] = dsdrBz[0]; + dsdr[1] = dsdrBz[2]; dsdr[2] = -dsdrBz[1]; - dsdr[3] = dsdrBz[3]; - dsdr[4] = dsdrBz[5]; + dsdr[3] = dsdrBz[3]; + dsdr[4] = dsdrBz[5]; dsdr[5] = -dsdrBz[4]; - + return dS; } -float_v KFParticleBaseSIMD::GetDStoPointCBM( const float_v xyz[3], float_v dsdr[6] ) const +float_v KFParticleBaseSIMD::GetDStoPointCBM(const float_v xyz[3], float_v dsdr[6]) const { /** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n @@ -1755,21 +1769,21 @@ float_v KFParticleBaseSIMD::GetDStoPointCBM( const float_v xyz[3], float_v dsdr[ ** \param[in] xyz[3] - point, to which particle should be transported ** \param[out] dsdr[6] = ds/dr partial derivatives of the parameter dS over the state vector of the current particle **/ - + float_v dS(Vc::Zero); float_v fld[3]; - GetFieldValue( fP, fld ); - dS = GetDStoPointBy( fld[1],xyz, dsdr ); - - dS(abs(dS)>1.E3f) = 0.f; + GetFieldValue(fP, fld); + dS = GetDStoPointBy(fld[1], xyz, dsdr); + + dS(abs(dS) > 1.E3f) = 0.f; return dS; } -void KFParticleBaseSIMD::GetDStoParticleBz( float_v B, const KFParticleBaseSIMD &p, - float_v dS[2], float_v dsdr[4][6], const float_v* param1, const float_v* param2 ) const -{ +void KFParticleBaseSIMD::GetDStoParticleBz(float_v B, const KFParticleBaseSIMD& p, + float_v dS[2], float_v dsdr[4][6], const float_v* param1, const float_v* param2) const +{ /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n ** 2) p - momentum of the particle; \n @@ -1792,31 +1806,29 @@ void KFParticleBaseSIMD::GetDStoParticleBz( float_v B, const KFParticleBaseSIMD ** \param[in] param2 - optional parameter, is used in case if the parameters of the second particles are rotated ** to other coordinate system (see GetDStoParticleBy() function), otherwise p.fP are used **/ - - if(!param1) - { + + if (!param1) { param1 = fP; param2 = p.fP; } //* Get dS to another particle for Bz field - const float_v kOvSqr6 = 1.f/sqrt(float_v(6.f)); + const float_v kOvSqr6 = 1.f / sqrt(float_v(6.f)); const float_v kCLight = 0.000299792458f; //in XY plane - //first root - const float_v& bq1 = B*simd_cast(fQ)*kCLight; - const float_v& bq2 = B*simd_cast(p.fQ)*kCLight; + //first root + const float_v& bq1 = B * simd_cast(fQ) * kCLight; + const float_v& bq2 = B * simd_cast(p.fQ) * kCLight; const float_m& isStraight1 = abs(bq1) < float_v(1.e-8f); const float_m& isStraight2 = abs(bq2) < float_v(1.e-8f); - - if( isStraight1.isFull() && isStraight2.isFull() ) - { + + if (isStraight1.isFull() && isStraight2.isFull()) { GetDStoParticleLine(p, dS, dsdr); return; } - + const float_v& px1 = param1[3]; const float_v& py1 = param1[4]; const float_v& pz1 = param1[5]; @@ -1825,8 +1837,8 @@ void KFParticleBaseSIMD::GetDStoParticleBz( float_v B, const KFParticleBaseSIMD const float_v& py2 = param2[4]; const float_v& pz2 = param2[5]; - const float_v& pt12 = px1*px1 + py1*py1; - const float_v& pt22 = px2*px2 + py2*py2; + const float_v& pt12 = px1 * px1 + py1 * py1; + const float_v& pt22 = px2 * px2 + py2 * py2; const float_v& x01 = param1[0]; const float_v& y01 = param1[1]; @@ -1836,333 +1848,319 @@ void KFParticleBaseSIMD::GetDStoParticleBz( float_v B, const KFParticleBaseSIMD const float_v& y02 = param2[1]; const float_v& z02 = param2[2]; - float_v dS1[2] = {0.f, 0.f}, dS2[2]={0.f, 0.f}; - + float_v dS1[2] = {0.f, 0.f}, dS2[2] = {0.f, 0.f}; + const float_v& dx0 = (x01 - x02); const float_v& dy0 = (y01 - y02); - const float_v& dr02 = dx0*dx0 + dy0*dy0; - const float_v& drp1 = dx0*px1 + dy0*py1; - const float_v& dxyp1 = dx0*py1 - dy0*px1; - const float_v& drp2 = dx0*px2 + dy0*py2; - const float_v& dxyp2 = dx0*py2 - dy0*px2; - const float_v& p1p2 = px1*px2 + py1*py2; - const float_v& dp1p2 = px1*py2 - px2*py1; - - const float_v& k11 = (bq2*drp1 - dp1p2); - const float_v& k21 = (bq1*(bq2*dxyp1 - p1p2) + bq2*pt12); - const float_v& k12 = ((bq1*drp2 - dp1p2)); - const float_v& k22 = (bq2*(bq1*dxyp2 + p1p2) - bq1*pt22); - - const float_v& kp = (dxyp1*bq2 - dxyp2*bq1 - p1p2); - const float_v& kd = dr02/2.f*bq1*bq2 + kp; - const float_v& c1 = -(bq1*kd + pt12*bq2); - const float_v& c2 = bq2*kd + pt22*bq1; - - float_v d1 = pt12*pt22 - kd*kd; + const float_v& dr02 = dx0 * dx0 + dy0 * dy0; + const float_v& drp1 = dx0 * px1 + dy0 * py1; + const float_v& dxyp1 = dx0 * py1 - dy0 * px1; + const float_v& drp2 = dx0 * px2 + dy0 * py2; + const float_v& dxyp2 = dx0 * py2 - dy0 * px2; + const float_v& p1p2 = px1 * px2 + py1 * py2; + const float_v& dp1p2 = px1 * py2 - px2 * py1; + + const float_v& k11 = (bq2 * drp1 - dp1p2); + const float_v& k21 = (bq1 * (bq2 * dxyp1 - p1p2) + bq2 * pt12); + const float_v& k12 = ((bq1 * drp2 - dp1p2)); + const float_v& k22 = (bq2 * (bq1 * dxyp2 + p1p2) - bq1 * pt22); + + const float_v& kp = (dxyp1 * bq2 - dxyp2 * bq1 - p1p2); + const float_v& kd = dr02 / 2.f * bq1 * bq2 + kp; + const float_v& c1 = -(bq1 * kd + pt12 * bq2); + const float_v& c2 = bq2 * kd + pt22 * bq1; + + float_v d1 = pt12 * pt22 - kd * kd; d1(d1 < float_v(Vc::Zero)) = float_v(Vc::Zero); - d1 = sqrt( d1 ); - float_v d2 = pt12*pt22 - kd*kd; + d1 = sqrt(d1); + float_v d2 = pt12 * pt22 - kd * kd; d2(d2 < float_v(Vc::Zero)) = float_v(Vc::Zero); - d2 = sqrt( d2 ); - + d2 = sqrt(d2); + float_v dS1dR1[2][6]; float_v dS2dR2[2][6]; float_v dS1dR2[2][6]; float_v dS2dR1[2][6]; - float_v dk11dr1[6] = {bq2*px1, bq2*py1, 0.f, bq2*dx0 - py2, bq2*dy0 + px2, 0.f}; - float_v dk11dr2[6] = {-bq2*px1, -bq2*py1, 0.f, py1, -px1, 0.f}; - float_v dk12dr1[6] = {bq1*px2, bq1*py2, 0.f, -py2, px2, 0.f}; - float_v dk12dr2[6] = {-bq1*px2, -bq1*py2, 0.f, bq1*dx0 + py1, bq1*dy0 - px1, 0.f}; - float_v dk21dr1[6] = {bq1*bq2*py1, -bq1*bq2*px1, 0.f, 2.f*bq2*px1 + bq1*(-(bq2*dy0) - px2), 2.f*bq2*py1 + bq1*(bq2*dx0 - py2), 0.f}; - float_v dk21dr2[6] = {-(bq1*bq2*py1), bq1*bq2*px1, 0.f, -(bq1*px1), -(bq1*py1), 0.f}; - float_v dk22dr1[6] = {bq1*bq2*py2, -(bq1*bq2*px2), 0.f, bq2*px2, bq2*py2, 0.f}; - float_v dk22dr2[6] = {-(bq1*bq2*py2), bq1*bq2*px2, 0.f, bq2*(-(bq1*dy0) + px1) - 2.f*bq1*px2, bq2*(bq1*dx0 + py1) - 2.f*bq1*py2, 0.f}; - - float_v dkddr1[6] = {bq1*bq2*dx0 + bq2*py1 - bq1*py2, bq1*bq2*dy0 - bq2*px1 + bq1*px2, 0.f, -bq2*dy0 - px2, bq2*dx0 - py2, 0.f}; - float_v dkddr2[6] = {-bq1*bq2*dx0 - bq2*py1 + bq1*py2, -bq1*bq2*dy0 + bq2*px1 - bq1*px2, 0.f, bq1*dy0 - px1, -bq1*dx0 - py1, 0.f}; - - float_v dc1dr1[6] = {-(bq1*(bq1*bq2*dx0 + bq2*py1 - bq1*py2)), -(bq1*(bq1*bq2*dy0 - bq2*px1 + bq1*px2)), 0.f, -2.f*bq2*px1 - bq1*(-(bq2*dy0) - px2), -2.f*bq2*py1 - bq1*(bq2*dx0 - py2), 0.f}; - float_v dc1dr2[6] = {-(bq1*(-(bq1*bq2*dx0) - bq2*py1 + bq1*py2)), -(bq1*(-(bq1*bq2*dy0) + bq2*px1 - bq1*px2)), 0.f, -(bq1*(bq1*dy0 - px1)), -(bq1*(-(bq1*dx0) - py1)), 0.f}; - - float_v dc2dr1[6] = {bq2*(bq1*bq2*dx0 + bq2*py1 - bq1*py2), bq2*(bq1*bq2*dy0 - bq2*px1 + bq1*px2), 0.f, bq2*(-(bq2*dy0) - px2), bq2*(bq2*dx0 - py2), 0.f}; - float_v dc2dr2[6] = {bq2*(-(bq1*bq2*dx0) - bq2*py1 + bq1*py2), bq2*(-(bq1*bq2*dy0) + bq2*px1 - bq1*px2), 0.f, bq2*(bq1*dy0 - px1) + 2.f*bq1*px2, bq2*(-(bq1*dx0) - py1) + 2.f*bq1*py2, 0.f}; - - float_v dd1dr1[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; - float_v dd1dr2[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; + float_v dk11dr1[6] = {bq2 * px1, bq2 * py1, 0.f, bq2 * dx0 - py2, bq2 * dy0 + px2, 0.f}; + float_v dk11dr2[6] = {-bq2 * px1, -bq2 * py1, 0.f, py1, -px1, 0.f}; + float_v dk12dr1[6] = {bq1 * px2, bq1 * py2, 0.f, -py2, px2, 0.f}; + float_v dk12dr2[6] = {-bq1 * px2, -bq1 * py2, 0.f, bq1 * dx0 + py1, bq1 * dy0 - px1, 0.f}; + float_v dk21dr1[6] = {bq1 * bq2 * py1, -bq1 * bq2 * px1, 0.f, 2.f * bq2 * px1 + bq1 * (-(bq2 * dy0) - px2), 2.f * bq2 * py1 + bq1 * (bq2 * dx0 - py2), 0.f}; + float_v dk21dr2[6] = {-(bq1 * bq2 * py1), bq1 * bq2 * px1, 0.f, -(bq1 * px1), -(bq1 * py1), 0.f}; + float_v dk22dr1[6] = {bq1 * bq2 * py2, -(bq1 * bq2 * px2), 0.f, bq2 * px2, bq2 * py2, 0.f}; + float_v dk22dr2[6] = {-(bq1 * bq2 * py2), bq1 * bq2 * px2, 0.f, bq2 * (-(bq1 * dy0) + px1) - 2.f * bq1 * px2, bq2 * (bq1 * dx0 + py1) - 2.f * bq1 * py2, 0.f}; + + float_v dkddr1[6] = {bq1 * bq2 * dx0 + bq2 * py1 - bq1 * py2, bq1 * bq2 * dy0 - bq2 * px1 + bq1 * px2, 0.f, -bq2 * dy0 - px2, bq2 * dx0 - py2, 0.f}; + float_v dkddr2[6] = {-bq1 * bq2 * dx0 - bq2 * py1 + bq1 * py2, -bq1 * bq2 * dy0 + bq2 * px1 - bq1 * px2, 0.f, bq1 * dy0 - px1, -bq1 * dx0 - py1, 0.f}; + + float_v dc1dr1[6] = {-(bq1 * (bq1 * bq2 * dx0 + bq2 * py1 - bq1 * py2)), -(bq1 * (bq1 * bq2 * dy0 - bq2 * px1 + bq1 * px2)), 0.f, -2.f * bq2 * px1 - bq1 * (-(bq2 * dy0) - px2), -2.f * bq2 * py1 - bq1 * (bq2 * dx0 - py2), 0.f}; + float_v dc1dr2[6] = {-(bq1 * (-(bq1 * bq2 * dx0) - bq2 * py1 + bq1 * py2)), -(bq1 * (-(bq1 * bq2 * dy0) + bq2 * px1 - bq1 * px2)), 0.f, -(bq1 * (bq1 * dy0 - px1)), -(bq1 * (-(bq1 * dx0) - py1)), 0.f}; + + float_v dc2dr1[6] = {bq2 * (bq1 * bq2 * dx0 + bq2 * py1 - bq1 * py2), bq2 * (bq1 * bq2 * dy0 - bq2 * px1 + bq1 * px2), 0.f, bq2 * (-(bq2 * dy0) - px2), bq2 * (bq2 * dx0 - py2), 0.f}; + float_v dc2dr2[6] = {bq2 * (-(bq1 * bq2 * dx0) - bq2 * py1 + bq1 * py2), bq2 * (-(bq1 * bq2 * dy0) + bq2 * px1 - bq1 * px2), 0.f, bq2 * (bq1 * dy0 - px1) + 2.f * bq1 * px2, bq2 * (-(bq1 * dx0) - py1) + 2.f * bq1 * py2, 0.f}; + + float_v dd1dr1[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; + float_v dd1dr2[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; { - for(int i=0; i<6; i++) - { - dd1dr1[i](d1>0.f) = -kd/d1*dkddr1[i]; - dd1dr2[i](d1>0.f) = -kd/d1*dkddr2[i]; + for (int i = 0; i < 6; i++) { + dd1dr1[i](d1 > 0.f) = -kd / d1 * dkddr1[i]; + dd1dr2[i](d1 > 0.f) = -kd / d1 * dkddr2[i]; } - dd1dr1[3](d1>0.f) += px1/d1*pt22; dd1dr1[4](d1>0.f) += py1/d1*pt22; - dd1dr2[3](d1>0.f) += px2/d1*pt12; dd1dr2[4](d1>0.f) += py2/d1*pt12; + dd1dr1[3](d1 > 0.f) += px1 / d1 * pt22; + dd1dr1[4](d1 > 0.f) += py1 / d1 * pt22; + dd1dr2[3](d1 > 0.f) += px2 / d1 * pt12; + dd1dr2[4](d1 > 0.f) += py2 / d1 * pt12; } // find two points of closest approach in XY plane - if( ! ( (!isStraight1).isEmpty() ) ) - { - dS1[0](!isStraight1) = KFPMath::ATan2( (bq1*k11*c1 + k21*d1*bq1), (bq1*k11*d1*bq1 - k21*c1) )/bq1; - dS1[1](!isStraight1) = KFPMath::ATan2( (bq1*k11*c1 - k21*d1*bq1), (-bq1*k11*d1*bq1 - k21*c1) )/bq1; - - float_v a = bq1*(k11*c1 + k21*d1); - float_v b = bq1*k11*d1*bq1 - k21*c1; - for(int iP=0; iP<6; iP++) - { - const float_v dadr1 = bq1*( dk11dr1[iP]*c1 + k11*dc1dr1[iP] + dk21dr1[iP]*d1 + k21*dd1dr1[iP] ); - const float_v dadr2 = bq1*( dk11dr2[iP]*c1 + k11*dc1dr2[iP] + dk21dr2[iP]*d1 + k21*dd1dr2[iP] ); - const float_v dbdr1 = bq1*bq1*( dk11dr1[iP]*d1 + k11*dd1dr1[iP] ) - ( dk21dr1[iP]*c1 + k21*dc1dr1[iP] ); - const float_v dbdr2 = bq1*bq1*( dk11dr2[iP]*d1 + k11*dd1dr2[iP] ) - ( dk21dr2[iP]*c1 + k21*dc1dr2[iP] ); - - dS1dR1[0][iP](!isStraight1) = 1/bq1 * 1/( b*b + a*a ) * ( dadr1*b - dbdr1*a ); - dS1dR2[0][iP](!isStraight1) = 1/bq1 * 1/( b*b + a*a ) * ( dadr2*b - dbdr2*a ); + if (!((!isStraight1).isEmpty())) { + dS1[0](!isStraight1) = KFPMath::ATan2((bq1 * k11 * c1 + k21 * d1 * bq1), (bq1 * k11 * d1 * bq1 - k21 * c1)) / bq1; + dS1[1](!isStraight1) = KFPMath::ATan2((bq1 * k11 * c1 - k21 * d1 * bq1), (-bq1 * k11 * d1 * bq1 - k21 * c1)) / bq1; + + float_v a = bq1 * (k11 * c1 + k21 * d1); + float_v b = bq1 * k11 * d1 * bq1 - k21 * c1; + for (int iP = 0; iP < 6; iP++) { + const float_v dadr1 = bq1 * (dk11dr1[iP] * c1 + k11 * dc1dr1[iP] + dk21dr1[iP] * d1 + k21 * dd1dr1[iP]); + const float_v dadr2 = bq1 * (dk11dr2[iP] * c1 + k11 * dc1dr2[iP] + dk21dr2[iP] * d1 + k21 * dd1dr2[iP]); + const float_v dbdr1 = bq1 * bq1 * (dk11dr1[iP] * d1 + k11 * dd1dr1[iP]) - (dk21dr1[iP] * c1 + k21 * dc1dr1[iP]); + const float_v dbdr2 = bq1 * bq1 * (dk11dr2[iP] * d1 + k11 * dd1dr2[iP]) - (dk21dr2[iP] * c1 + k21 * dc1dr2[iP]); + + dS1dR1[0][iP](!isStraight1) = 1 / bq1 * 1 / (b * b + a * a) * (dadr1 * b - dbdr1 * a); + dS1dR2[0][iP](!isStraight1) = 1 / bq1 * 1 / (b * b + a * a) * (dadr2 * b - dbdr2 * a); } - - a = bq1*(k11*c1 - k21*d1); - b = -bq1*k11*d1*bq1 - k21*c1; - for(int iP=0; iP<6; iP++) - { - const float_v dadr1 = bq1*( dk11dr1[iP]*c1 + k11*dc1dr1[iP] - (dk21dr1[iP]*d1 + k21*dd1dr1[iP]) ); - const float_v dadr2 = bq1*( dk11dr2[iP]*c1 + k11*dc1dr2[iP] - (dk21dr2[iP]*d1 + k21*dd1dr2[iP]) ); - const float_v dbdr1 = -bq1*bq1*( dk11dr1[iP]*d1 + k11*dd1dr1[iP] ) - ( dk21dr1[iP]*c1 + k21*dc1dr1[iP] ); - const float_v dbdr2 = -bq1*bq1*( dk11dr2[iP]*d1 + k11*dd1dr2[iP] ) - ( dk21dr2[iP]*c1 + k21*dc1dr2[iP] ); - - dS1dR1[1][iP](!isStraight1) = 1/bq1 * 1/( b*b + a*a ) * ( dadr1*b - dbdr1*a ); - dS1dR2[1][iP](!isStraight1) = 1/bq1 * 1/( b*b + a*a ) * ( dadr2*b - dbdr2*a ); + + a = bq1 * (k11 * c1 - k21 * d1); + b = -bq1 * k11 * d1 * bq1 - k21 * c1; + for (int iP = 0; iP < 6; iP++) { + const float_v dadr1 = bq1 * (dk11dr1[iP] * c1 + k11 * dc1dr1[iP] - (dk21dr1[iP] * d1 + k21 * dd1dr1[iP])); + const float_v dadr2 = bq1 * (dk11dr2[iP] * c1 + k11 * dc1dr2[iP] - (dk21dr2[iP] * d1 + k21 * dd1dr2[iP])); + const float_v dbdr1 = -bq1 * bq1 * (dk11dr1[iP] * d1 + k11 * dd1dr1[iP]) - (dk21dr1[iP] * c1 + k21 * dc1dr1[iP]); + const float_v dbdr2 = -bq1 * bq1 * (dk11dr2[iP] * d1 + k11 * dd1dr2[iP]) - (dk21dr2[iP] * c1 + k21 * dc1dr2[iP]); + + dS1dR1[1][iP](!isStraight1) = 1 / bq1 * 1 / (b * b + a * a) * (dadr1 * b - dbdr1 * a); + dS1dR2[1][iP](!isStraight1) = 1 / bq1 * 1 / (b * b + a * a) * (dadr2 * b - dbdr2 * a); } } - if( ! ( (!isStraight2).isEmpty() ) ) - { - dS2[0](!isStraight2) = KFPMath::ATan2( (bq2*k12*c2 + k22*d2*bq2), (bq2*k12*d2*bq2 - k22*c2) )/bq2; - dS2[1](!isStraight2) = KFPMath::ATan2( (bq2*k12*c2 - k22*d2*bq2), (-bq2*k12*d2*bq2 - k22*c2) )/bq2; - - float_v a = bq2*(k12*c2 + k22*d2); - float_v b = bq2*k12*d2*bq2 - k22*c2; - for(int iP=0; iP<6; iP++) - { - const float_v dadr1 = bq2*( dk12dr1[iP]*c2 + k12*dc2dr1[iP] + dk22dr1[iP]*d1 + k22*dd1dr1[iP] ); - const float_v dadr2 = bq2*( dk12dr2[iP]*c2 + k12*dc2dr2[iP] + dk22dr2[iP]*d1 + k22*dd1dr2[iP] ); - const float_v dbdr1 = bq2*bq2*( dk12dr1[iP]*d1 + k12*dd1dr1[iP] ) - (dk22dr1[iP]*c2 + k22*dc2dr1[iP]); - const float_v dbdr2 = bq2*bq2*( dk12dr2[iP]*d1 + k12*dd1dr2[iP] ) - (dk22dr2[iP]*c2 + k22*dc2dr2[iP]); - - dS2dR1[0][iP](!isStraight2) = 1/bq2 * 1/( b*b + a*a ) * ( dadr1*b - dbdr1*a ); - dS2dR2[0][iP](!isStraight2) = 1/bq2 * 1/( b*b + a*a ) * ( dadr2*b - dbdr2*a ); + if (!((!isStraight2).isEmpty())) { + dS2[0](!isStraight2) = KFPMath::ATan2((bq2 * k12 * c2 + k22 * d2 * bq2), (bq2 * k12 * d2 * bq2 - k22 * c2)) / bq2; + dS2[1](!isStraight2) = KFPMath::ATan2((bq2 * k12 * c2 - k22 * d2 * bq2), (-bq2 * k12 * d2 * bq2 - k22 * c2)) / bq2; + + float_v a = bq2 * (k12 * c2 + k22 * d2); + float_v b = bq2 * k12 * d2 * bq2 - k22 * c2; + for (int iP = 0; iP < 6; iP++) { + const float_v dadr1 = bq2 * (dk12dr1[iP] * c2 + k12 * dc2dr1[iP] + dk22dr1[iP] * d1 + k22 * dd1dr1[iP]); + const float_v dadr2 = bq2 * (dk12dr2[iP] * c2 + k12 * dc2dr2[iP] + dk22dr2[iP] * d1 + k22 * dd1dr2[iP]); + const float_v dbdr1 = bq2 * bq2 * (dk12dr1[iP] * d1 + k12 * dd1dr1[iP]) - (dk22dr1[iP] * c2 + k22 * dc2dr1[iP]); + const float_v dbdr2 = bq2 * bq2 * (dk12dr2[iP] * d1 + k12 * dd1dr2[iP]) - (dk22dr2[iP] * c2 + k22 * dc2dr2[iP]); + + dS2dR1[0][iP](!isStraight2) = 1 / bq2 * 1 / (b * b + a * a) * (dadr1 * b - dbdr1 * a); + dS2dR2[0][iP](!isStraight2) = 1 / bq2 * 1 / (b * b + a * a) * (dadr2 * b - dbdr2 * a); } - - a = bq2*(k12*c2 - k22*d2); - b = -bq2*k12*d2*bq2 - k22*c2; - for(int iP=0; iP<6; iP++) - { - const float_v dadr1 = bq2*( dk12dr1[iP]*c2 + k12*dc2dr1[iP] - (dk22dr1[iP]*d1 + k22*dd1dr1[iP]) ); - const float_v dadr2 = bq2*( dk12dr2[iP]*c2 + k12*dc2dr2[iP] - (dk22dr2[iP]*d1 + k22*dd1dr2[iP]) ); - const float_v dbdr1 = -bq2*bq2*( dk12dr1[iP]*d1 + k12*dd1dr1[iP] ) - (dk22dr1[iP]*c2 + k22*dc2dr1[iP]); - const float_v dbdr2 = -bq2*bq2*( dk12dr2[iP]*d1 + k12*dd1dr2[iP] ) - (dk22dr2[iP]*c2 + k22*dc2dr2[iP]); - - dS2dR1[1][iP](!isStraight2) = 1/bq2 * 1/( b*b + a*a ) * ( dadr1*b - dbdr1*a ); - dS2dR2[1][iP](!isStraight2) = 1/bq2 * 1/( b*b + a*a ) * ( dadr2*b - dbdr2*a ); + + a = bq2 * (k12 * c2 - k22 * d2); + b = -bq2 * k12 * d2 * bq2 - k22 * c2; + for (int iP = 0; iP < 6; iP++) { + const float_v dadr1 = bq2 * (dk12dr1[iP] * c2 + k12 * dc2dr1[iP] - (dk22dr1[iP] * d1 + k22 * dd1dr1[iP])); + const float_v dadr2 = bq2 * (dk12dr2[iP] * c2 + k12 * dc2dr2[iP] - (dk22dr2[iP] * d1 + k22 * dd1dr2[iP])); + const float_v dbdr1 = -bq2 * bq2 * (dk12dr1[iP] * d1 + k12 * dd1dr1[iP]) - (dk22dr1[iP] * c2 + k22 * dc2dr1[iP]); + const float_v dbdr2 = -bq2 * bq2 * (dk12dr2[iP] * d1 + k12 * dd1dr2[iP]) - (dk22dr2[iP] * c2 + k22 * dc2dr2[iP]); + + dS2dR1[1][iP](!isStraight2) = 1 / bq2 * 1 / (b * b + a * a) * (dadr1 * b - dbdr1 * a); + dS2dR2[1][iP](!isStraight2) = 1 / bq2 * 1 / (b * b + a * a) * (dadr2 * b - dbdr2 * a); } } - if( ! ( isStraight1.isEmpty() ) ) - { - dS1[0](isStraight1 && (pt12>float_v(Vc::Zero)) ) = (k11*c1 + k21*d1)/(- k21*c1); - dS1[1](isStraight1 && (pt12>float_v(Vc::Zero)) ) = (k11*c1 - k21*d1)/(- k21*c1); - - float_v a = k11*c1 + k21*d1; - float_v b = -k21*c1; - - for(int iP=0; iP<6; iP++) - { - const float_v dadr1 = ( dk11dr1[iP]*c1 + k11*dc1dr1[iP] + dk21dr1[iP]*d1 + k21*dd1dr1[iP] ); - const float_v dadr2 = ( dk11dr2[iP]*c1 + k11*dc1dr2[iP] + dk21dr2[iP]*d1 + k21*dd1dr2[iP] ); - const float_v dbdr1 = -( dk21dr1[iP]*c1 + k21*dc1dr1[iP] ); - const float_v dbdr2 = -( dk21dr2[iP]*c1 + k21*dc1dr2[iP] ); - - dS1dR1[0][iP](isStraight1 && (pt12>float_v(Vc::Zero)) ) = dadr1/b - dbdr1*a/(b*b) ; - dS1dR2[0][iP](isStraight1 && (pt12>float_v(Vc::Zero)) ) = dadr2/b - dbdr2*a/(b*b) ; + if (!(isStraight1.isEmpty())) { + dS1[0](isStraight1 && (pt12 > float_v(Vc::Zero))) = (k11 * c1 + k21 * d1) / (-k21 * c1); + dS1[1](isStraight1 && (pt12 > float_v(Vc::Zero))) = (k11 * c1 - k21 * d1) / (-k21 * c1); + + float_v a = k11 * c1 + k21 * d1; + float_v b = -k21 * c1; + + for (int iP = 0; iP < 6; iP++) { + const float_v dadr1 = (dk11dr1[iP] * c1 + k11 * dc1dr1[iP] + dk21dr1[iP] * d1 + k21 * dd1dr1[iP]); + const float_v dadr2 = (dk11dr2[iP] * c1 + k11 * dc1dr2[iP] + dk21dr2[iP] * d1 + k21 * dd1dr2[iP]); + const float_v dbdr1 = -(dk21dr1[iP] * c1 + k21 * dc1dr1[iP]); + const float_v dbdr2 = -(dk21dr2[iP] * c1 + k21 * dc1dr2[iP]); + + dS1dR1[0][iP](isStraight1 && (pt12 > float_v(Vc::Zero))) = dadr1 / b - dbdr1 * a / (b * b); + dS1dR2[0][iP](isStraight1 && (pt12 > float_v(Vc::Zero))) = dadr2 / b - dbdr2 * a / (b * b); } - - a = k11*c1 - k21*d1; - for(int iP=0; iP<6; iP++) - { - const float_v dadr1 = ( dk11dr1[iP]*c1 + k11*dc1dr1[iP] - dk21dr1[iP]*d1 - k21*dd1dr1[iP] ); - const float_v dadr2 = ( dk11dr2[iP]*c1 + k11*dc1dr2[iP] - dk21dr2[iP]*d1 - k21*dd1dr2[iP] ); - const float_v dbdr1 = -( dk21dr1[iP]*c1 + k21*dc1dr1[iP] ); - const float_v dbdr2 = -( dk21dr2[iP]*c1 + k21*dc1dr2[iP] ); - - dS1dR1[1][iP](isStraight1 && (pt12>float_v(Vc::Zero)) ) = dadr1/b - dbdr1*a/(b*b) ; - dS1dR2[1][iP](isStraight1 && (pt12>float_v(Vc::Zero)) ) = dadr2/b - dbdr2*a/(b*b) ; + + a = k11 * c1 - k21 * d1; + for (int iP = 0; iP < 6; iP++) { + const float_v dadr1 = (dk11dr1[iP] * c1 + k11 * dc1dr1[iP] - dk21dr1[iP] * d1 - k21 * dd1dr1[iP]); + const float_v dadr2 = (dk11dr2[iP] * c1 + k11 * dc1dr2[iP] - dk21dr2[iP] * d1 - k21 * dd1dr2[iP]); + const float_v dbdr1 = -(dk21dr1[iP] * c1 + k21 * dc1dr1[iP]); + const float_v dbdr2 = -(dk21dr2[iP] * c1 + k21 * dc1dr2[iP]); + + dS1dR1[1][iP](isStraight1 && (pt12 > float_v(Vc::Zero))) = dadr1 / b - dbdr1 * a / (b * b); + dS1dR2[1][iP](isStraight1 && (pt12 > float_v(Vc::Zero))) = dadr2 / b - dbdr2 * a / (b * b); } } - if( ! ( isStraight2.isEmpty() ) ) - { - dS2[0](isStraight2 && (pt22>float_v(Vc::Zero)) ) = (k12*c2 + k22*d2)/(- k22*c2); - dS2[1](isStraight2 && (pt22>float_v(Vc::Zero)) ) = (k12*c2 - k22*d2)/(- k22*c2); - - float_v a = k12*c2 + k22*d1; - float_v b = -k22*c2; - - for(int iP=0; iP<6; iP++) - { - const float_v dadr1 = ( dk12dr1[iP]*c2 + k12*dc2dr1[iP] + dk22dr1[iP]*d1 + k22*dd1dr1[iP] ); - const float_v dadr2 = ( dk12dr2[iP]*c2 + k12*dc2dr2[iP] + dk22dr2[iP]*d1 + k22*dd1dr2[iP] ); - const float_v dbdr1 = -( dk22dr1[iP]*c2 + k22*dc2dr1[iP] ); - const float_v dbdr2 = -( dk22dr2[iP]*c2 + k22*dc2dr2[iP] ); - - dS2dR1[0][iP](isStraight2 && (pt22>float_v(Vc::Zero)) ) = dadr1/b - dbdr1*a/(b*b) ; - dS2dR2[0][iP](isStraight2 && (pt22>float_v(Vc::Zero)) ) = dadr2/b - dbdr2*a/(b*b) ; + if (!(isStraight2.isEmpty())) { + dS2[0](isStraight2 && (pt22 > float_v(Vc::Zero))) = (k12 * c2 + k22 * d2) / (-k22 * c2); + dS2[1](isStraight2 && (pt22 > float_v(Vc::Zero))) = (k12 * c2 - k22 * d2) / (-k22 * c2); + + float_v a = k12 * c2 + k22 * d1; + float_v b = -k22 * c2; + + for (int iP = 0; iP < 6; iP++) { + const float_v dadr1 = (dk12dr1[iP] * c2 + k12 * dc2dr1[iP] + dk22dr1[iP] * d1 + k22 * dd1dr1[iP]); + const float_v dadr2 = (dk12dr2[iP] * c2 + k12 * dc2dr2[iP] + dk22dr2[iP] * d1 + k22 * dd1dr2[iP]); + const float_v dbdr1 = -(dk22dr1[iP] * c2 + k22 * dc2dr1[iP]); + const float_v dbdr2 = -(dk22dr2[iP] * c2 + k22 * dc2dr2[iP]); + + dS2dR1[0][iP](isStraight2 && (pt22 > float_v(Vc::Zero))) = dadr1 / b - dbdr1 * a / (b * b); + dS2dR2[0][iP](isStraight2 && (pt22 > float_v(Vc::Zero))) = dadr2 / b - dbdr2 * a / (b * b); } - - a = k12*c2 - k22*d1; - for(int iP=0; iP<6; iP++) - { - const float_v dadr1 = ( dk12dr1[iP]*c2 + k12*dc2dr1[iP] - dk22dr1[iP]*d1 - k22*dd1dr1[iP] ); - const float_v dadr2 = ( dk12dr2[iP]*c2 + k12*dc2dr2[iP] - dk22dr2[iP]*d1 - k22*dd1dr2[iP] ); - const float_v dbdr1 = -( dk22dr1[iP]*c2 + k22*dc2dr1[iP] ); - const float_v dbdr2 = -( dk22dr2[iP]*c2 + k22*dc2dr2[iP] ); - - dS2dR1[1][iP](isStraight2 && (pt22>float_v(Vc::Zero)) ) = dadr1/b - dbdr1*a/(b*b) ; - dS2dR2[1][iP](isStraight2 && (pt22>float_v(Vc::Zero)) ) = dadr2/b - dbdr2*a/(b*b) ; + + a = k12 * c2 - k22 * d1; + for (int iP = 0; iP < 6; iP++) { + const float_v dadr1 = (dk12dr1[iP] * c2 + k12 * dc2dr1[iP] - dk22dr1[iP] * d1 - k22 * dd1dr1[iP]); + const float_v dadr2 = (dk12dr2[iP] * c2 + k12 * dc2dr2[iP] - dk22dr2[iP] * d1 - k22 * dd1dr2[iP]); + const float_v dbdr1 = -(dk22dr1[iP] * c2 + k22 * dc2dr1[iP]); + const float_v dbdr2 = -(dk22dr2[iP] * c2 + k22 * dc2dr2[iP]); + + dS2dR1[1][iP](isStraight2 && (pt22 > float_v(Vc::Zero))) = dadr1 / b - dbdr1 * a / (b * b); + dS2dR2[1][iP](isStraight2 && (pt22 > float_v(Vc::Zero))) = dadr2 / b - dbdr2 * a / (b * b); } } - + //select a point which is close to the primary vertex (with the smallest r) - + float_v dr2[2]; - for(int iP = 0; iP<2; iP++) - { - const float_v& bs1 = bq1*dS1[iP]; - const float_v& bs2 = bq2*dS2[iP]; + for (int iP = 0; iP < 2; iP++) { + const float_v& bs1 = bq1 * dS1[iP]; + const float_v& bs2 = bq2 * dS2[iP]; float_v sss = sin(bs1), ccc = cos(bs1); - + const float_m& bs1Big = abs(bs1) > 1.e-8f; const float_m& bs2Big = abs(bs2) > 1.e-8f; - + float_v sB(Vc::Zero), cB(Vc::Zero); - sB(bs1Big) = sss/bq1; - sB(!bs1Big) = ((1.f-bs1*kOvSqr6)*(1.f+bs1*kOvSqr6)*dS1[iP]); - cB(bs1Big) = (1.f-ccc)/bq1; - cB(!bs1Big) = .5f*sB*bs1; - - const float_v& x1 = param1[0] + sB*px1 + cB*py1; - const float_v& y1 = param1[1] - cB*px1 + sB*py1; - const float_v& z1 = param1[2] + dS1[iP]*param1[5]; - - sss = sin(bs2); ccc = cos(bs2); - - sB(bs2Big) = sss/bq2; - sB(!bs2Big) = ((1.f-bs2*kOvSqr6)*(1.f+bs2*kOvSqr6)*dS2[iP]); - cB(bs2Big) = (1.f-ccc)/bq2; - cB(!bs2Big) = .5f*sB*bs2; - - const float_v& x2 = param2[0] + sB*px2 + cB*py2; - const float_v& y2 = param2[1] - cB*px2 + sB*py2; - const float_v& z2 = param2[2] + dS2[iP]*param2[5]; - - float_v dx = (x1-x2); - float_v dy = (y1-y2); - float_v dz = (z1-z2); - - dr2[iP] = dx*dx + dy*dy + dz*dz; + sB(bs1Big) = sss / bq1; + sB(!bs1Big) = ((1.f - bs1 * kOvSqr6) * (1.f + bs1 * kOvSqr6) * dS1[iP]); + cB(bs1Big) = (1.f - ccc) / bq1; + cB(!bs1Big) = .5f * sB * bs1; + + const float_v& x1 = param1[0] + sB * px1 + cB * py1; + const float_v& y1 = param1[1] - cB * px1 + sB * py1; + const float_v& z1 = param1[2] + dS1[iP] * param1[5]; + + sss = sin(bs2); + ccc = cos(bs2); + + sB(bs2Big) = sss / bq2; + sB(!bs2Big) = ((1.f - bs2 * kOvSqr6) * (1.f + bs2 * kOvSqr6) * dS2[iP]); + cB(bs2Big) = (1.f - ccc) / bq2; + cB(!bs2Big) = .5f * sB * bs2; + + const float_v& x2 = param2[0] + sB * px2 + cB * py2; + const float_v& y2 = param2[1] - cB * px2 + sB * py2; + const float_v& z2 = param2[2] + dS2[iP] * param2[5]; + + float_v dx = (x1 - x2); + float_v dy = (y1 - y2); + float_v dz = (z1 - z2); + + dr2[iP] = dx * dx + dy * dy + dz * dz; } - + float_v pointParam[2][8]; float_v pointCov[2][36]; - - float_v dsdrM1[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; - for(int iP=0; iP<6; iP++) - dsdrM1[iP] = (dS1dR1[0][iP] + dS1dR1[1][iP])/2.f; + + float_v dsdrM1[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; + for (int iP = 0; iP < 6; iP++) + dsdrM1[iP] = (dS1dR1[0][iP] + dS1dR1[1][iP]) / 2.f; Transport((dS1[0] + dS1[1]) / 2.f, dsdrM1, pointParam[0], pointCov[0]); - float_v dsdrM2[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; - for(int iP=0; iP<6; iP++) - dsdrM2[iP] = (dS2dR2[0][iP] + dS2dR2[1][iP])/2.f; + float_v dsdrM2[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; + for (int iP = 0; iP < 6; iP++) + dsdrM2[iP] = (dS2dR2[0][iP] + dS2dR2[1][iP]) / 2.f; p.Transport((dS2[0] + dS2[1]) / 2.f, dsdrM2, pointParam[1], pointCov[1]); - - const float_v drPoint[3] = { pointParam[0][0] - pointParam[1][0], pointParam[0][1] - pointParam[1][1], pointParam[0][2] - pointParam[1][2] } ; - const float_v covPoint[6] = { pointCov[0][0] + pointCov[1][0], - pointCov[0][1] + pointCov[1][1], - pointCov[0][2] + pointCov[1][2], - pointCov[0][3] + pointCov[1][3], - pointCov[0][4] + pointCov[1][4], - pointCov[0][5] + pointCov[1][5] }; - float_v dr2Points = drPoint[0]*drPoint[0] + drPoint[1]*drPoint[1] + drPoint[2]*drPoint[2]; - float_v dr2PointCov = drPoint[0]*drPoint[0]*covPoint[0] + drPoint[1]*drPoint[1]*covPoint[2] + drPoint[2]*drPoint[2]*covPoint[5] + - 2.f*( drPoint[0]*drPoint[1]*covPoint[1] + drPoint[0]*drPoint[2]*covPoint[3] + drPoint[1]*drPoint[2]*covPoint[4] ); - const float_m isMiddlePoint = (dr2Points*dr2Points < 25.f*dr2PointCov);// && (abs(fPDG)==int_v(11)) && (abs(p.fPDG)==int_v(11)); + + const float_v drPoint[3] = {pointParam[0][0] - pointParam[1][0], pointParam[0][1] - pointParam[1][1], pointParam[0][2] - pointParam[1][2]}; + const float_v covPoint[6] = {pointCov[0][0] + pointCov[1][0], + pointCov[0][1] + pointCov[1][1], + pointCov[0][2] + pointCov[1][2], + pointCov[0][3] + pointCov[1][3], + pointCov[0][4] + pointCov[1][4], + pointCov[0][5] + pointCov[1][5]}; + float_v dr2Points = drPoint[0] * drPoint[0] + drPoint[1] * drPoint[1] + drPoint[2] * drPoint[2]; + float_v dr2PointCov = drPoint[0] * drPoint[0] * covPoint[0] + drPoint[1] * drPoint[1] * covPoint[2] + drPoint[2] * drPoint[2] * covPoint[5] + + 2.f * (drPoint[0] * drPoint[1] * covPoint[1] + drPoint[0] * drPoint[2] * covPoint[3] + drPoint[1] * drPoint[2] * covPoint[4]); + const float_m isMiddlePoint = (dr2Points * dr2Points < 25.f * dr2PointCov); // && (abs(fPDG)==int_v(11)) && (abs(p.fPDG)==int_v(11)); const float_m isFirstRoot = (dr2[0] < dr2[1]) & (!isMiddlePoint); - - // if(!(isFirstRoot.isEmpty())) + + // if(!(isFirstRoot.isEmpty())) { - dS[0](isFirstRoot) = dS1[0]; + dS[0](isFirstRoot) = dS1[0]; dS[1](isFirstRoot) = dS2[0]; - - for(int iP=0; iP<6; iP++) - { + + for (int iP = 0; iP < 6; iP++) { dsdr[0][iP](isFirstRoot) = dS1dR1[0][iP]; dsdr[1][iP](isFirstRoot) = dS1dR2[0][iP]; dsdr[2][iP](isFirstRoot) = dS2dR1[0][iP]; dsdr[3][iP](isFirstRoot) = dS2dR2[0][iP]; } } - // if( !( (!isFirstRoot).isEmpty() ) ) + // if( !( (!isFirstRoot).isEmpty() ) ) { - dS[0](!isFirstRoot) = dS1[1]; - dS[1](!isFirstRoot) = dS2[1]; - - for(int iP=0; iP<6; iP++) - { + dS[0](!isFirstRoot) = dS1[1]; + dS[1](!isFirstRoot) = dS2[1]; + + for (int iP = 0; iP < 6; iP++) { dsdr[0][iP](!isFirstRoot) = dS1dR1[1][iP]; dsdr[1][iP](!isFirstRoot) = dS1dR2[1][iP]; - dsdr[2][iP](!isFirstRoot) = dS2dR1[1][iP]; + dsdr[2][iP](!isFirstRoot) = dS2dR1[1][iP]; dsdr[3][iP](!isFirstRoot) = dS2dR2[1][iP]; - } + } } - // if(!(isMiddlePoint.isEmpty())) + // if(!(isMiddlePoint.isEmpty())) { dS[0](isMiddlePoint) = (dS1[0] + dS1[1]) / 2.f; dS[1](isMiddlePoint) = (dS2[0] + dS2[1]) / 2.f; - - for(int iP=0; iP<6; iP++) - { - dsdr[0][iP](isMiddlePoint) = (dS1dR1[1][iP] + dS1dR1[0][iP])/2.f; - dsdr[1][iP](isMiddlePoint) = (dS1dR2[1][iP] + dS1dR2[0][iP])/2.f; - dsdr[2][iP](isMiddlePoint) = (dS2dR1[1][iP] + dS2dR1[0][iP])/2.f; - dsdr[3][iP](isMiddlePoint) = (dS2dR2[1][iP] + dS2dR2[0][iP])/2.f; - } + + for (int iP = 0; iP < 6; iP++) { + dsdr[0][iP](isMiddlePoint) = (dS1dR1[1][iP] + dS1dR1[0][iP]) / 2.f; + dsdr[1][iP](isMiddlePoint) = (dS1dR2[1][iP] + dS1dR2[0][iP]) / 2.f; + dsdr[2][iP](isMiddlePoint) = (dS2dR1[1][iP] + dS2dR1[0][iP]) / 2.f; + dsdr[3][iP](isMiddlePoint) = (dS2dR2[1][iP] + dS2dR2[0][iP]) / 2.f; + } } - + //find correct parts of helices int_v n1(Vc::Zero); int_v n2(Vc::Zero); -// float_v dzMin = abs( (z01-z02) + dS[0]*pz1 - dS[1]*pz2 ); + // float_v dzMin = abs( (z01-z02) + dS[0]*pz1 - dS[1]*pz2 ); const float_v pi2(6.283185307f); - -// //TODO optimise for loops for neutral particles -// const float_v& i1Float = -bq1/pi2*(z01/pz1+dS[0]); -// for(int di1=-1; di1<=1; di1++) -// { -// int_v i1(Vc::Zero); -// i1(int_m(!isStraight1)) = int_v(i1Float) + di1; -// -// const float_v& i2Float = ( ((z01-z02) + (dS[0]+pi2*i1/bq1)*pz1)/pz2 - dS[1]) * bq2/pi2; -// for(int di2 = -1; di2<=1; di2++) -// { -// int_v i2(Vc::Zero); -// i2(int_m(!isStraight2)) = int_v(i2Float) + di2; -// -// const float_v& z1 = z01 + (dS[0]+pi2*i1/bq1)*pz1; -// const float_v& z2 = z02 + (dS[1]+pi2*i2/bq2)*pz2; -// const float_v& dz = abs( z1-z2 ); -// -// n1(int_m(dz < dzMin)) = i1; -// n2(int_m(dz < dzMin)) = i2; -// dzMin(dz < dzMin) = dz; -// } -// } -// -// dS[0](!isStraight1) += float_v(n1)*pi2/bq1; -// dS[1](!isStraight2) += float_v(n2)*pi2/bq2; + + // //TODO optimise for loops for neutral particles + // const float_v& i1Float = -bq1/pi2*(z01/pz1+dS[0]); + // for(int di1=-1; di1<=1; di1++) + // { + // int_v i1(Vc::Zero); + // i1(int_m(!isStraight1)) = int_v(i1Float) + di1; + // + // const float_v& i2Float = ( ((z01-z02) + (dS[0]+pi2*i1/bq1)*pz1)/pz2 - dS[1]) * bq2/pi2; + // for(int di2 = -1; di2<=1; di2++) + // { + // int_v i2(Vc::Zero); + // i2(int_m(!isStraight2)) = int_v(i2Float) + di2; + // + // const float_v& z1 = z01 + (dS[0]+pi2*i1/bq1)*pz1; + // const float_v& z2 = z02 + (dS[1]+pi2*i2/bq2)*pz2; + // const float_v& dz = abs( z1-z2 ); + // + // n1(int_m(dz < dzMin)) = i1; + // n2(int_m(dz < dzMin)) = i2; + // dzMin(dz < dzMin) = dz; + // } + // } + // + // dS[0](!isStraight1) += float_v(n1)*pi2/bq1; + // dS[1](!isStraight2) += float_v(n2)*pi2/bq2; //add a correction on z-coordinate #if 0 @@ -2337,121 +2335,119 @@ void KFParticleBaseSIMD::GetDStoParticleBz( float_v B, const KFParticleBaseSIMD //Line correction { - const float_v& bs1 = bq1*dS[0]; - const float_v& bs2 = bq2*dS[1]; + const float_v& bs1 = bq1 * dS[0]; + const float_v& bs2 = bq2 * dS[1]; float_v sss = sin(bs1), ccc = cos(bs1); - + const float_m& bs1Big = abs(bs1) > 1.e-8f; const float_m& bs2Big = abs(bs2) > 1.e-8f; - + float_v sB(0.f), cB(0.f); - sB(bs1Big) = sss/bq1; - cB(bs1Big) = (1.f-ccc)/bq1; - sB(!bs1Big) = ((1.f-bs1*kOvSqr6)*(1.f+bs1*kOvSqr6)*dS[0]); - cB(!bs1Big) = .5f*sB*bs1; - - const float_v& x1 = x01 + sB*px1 + cB*py1; - const float_v& y1 = y01 - cB*px1 + sB*py1; - const float_v& z1 = z01 + dS[0]*pz1; - const float_v& ppx1 = ccc*px1 + sss*py1; - const float_v& ppy1 = -sss*px1 + ccc*py1; + sB(bs1Big) = sss / bq1; + cB(bs1Big) = (1.f - ccc) / bq1; + sB(!bs1Big) = ((1.f - bs1 * kOvSqr6) * (1.f + bs1 * kOvSqr6) * dS[0]); + cB(!bs1Big) = .5f * sB * bs1; + + const float_v& x1 = x01 + sB * px1 + cB * py1; + const float_v& y1 = y01 - cB * px1 + sB * py1; + const float_v& z1 = z01 + dS[0] * pz1; + const float_v& ppx1 = ccc * px1 + sss * py1; + const float_v& ppy1 = -sss * px1 + ccc * py1; const float_v& ppz1 = pz1; - + float_v sss1 = sin(bs2), ccc1 = cos(bs2); float_v sB1(0.f), cB1(0.f); - sB1(bs2Big) = sss1/bq2; - cB1(bs2Big) = (1.f-ccc1)/bq2; - sB1(!bs2Big) = ((1.f-bs2*kOvSqr6)*(1.f+bs2*kOvSqr6)*dS[1]); - cB1(!bs2Big) = .5f*sB1*bs2; - - const float_v& x2 = x02 + sB1*px2 + cB1*py2; - const float_v& y2 = y02 - cB1*px2 + sB1*py2; - const float_v& z2 = z02 + dS[1]*pz2; - const float_v& ppx2 = ccc1*px2 + sss1*py2; - const float_v& ppy2 = -sss1*px2 + ccc1*py2; + sB1(bs2Big) = sss1 / bq2; + cB1(bs2Big) = (1.f - ccc1) / bq2; + sB1(!bs2Big) = ((1.f - bs2 * kOvSqr6) * (1.f + bs2 * kOvSqr6) * dS[1]); + cB1(!bs2Big) = .5f * sB1 * bs2; + + const float_v& x2 = x02 + sB1 * px2 + cB1 * py2; + const float_v& y2 = y02 - cB1 * px2 + sB1 * py2; + const float_v& z2 = z02 + dS[1] * pz2; + const float_v& ppx2 = ccc1 * px2 + sss1 * py2; + const float_v& ppy2 = -sss1 * px2 + ccc1 * py2; const float_v& ppz2 = pz2; - const float_v& p12 = ppx1*ppx1 + ppy1*ppy1 + ppz1*ppz1; - const float_v& p22 = ppx2*ppx2 + ppy2*ppy2 + ppz2*ppz2; - const float_v& lp1p2 = ppx1*ppx2 + ppy1*ppy2 + ppz1*ppz2; + const float_v& p12 = ppx1 * ppx1 + ppy1 * ppy1 + ppz1 * ppz1; + const float_v& p22 = ppx2 * ppx2 + ppy2 * ppy2 + ppz2 * ppz2; + const float_v& lp1p2 = ppx1 * ppx2 + ppy1 * ppy2 + ppz1 * ppz2; const float_v& dx = (x2 - x1); const float_v& dy = (y2 - y1); const float_v& dz = (z2 - z1); - - const float_v& ldrp1 = ppx1*dx + ppy1*dy + ppz1*dz; - const float_v& ldrp2 = ppx2*dx + ppy2*dy + ppz2*dz; - float_v detp = lp1p2*lp1p2 - p12*p22; - detp(abs(detp)<1.e-4f) = 1; //TODO correct!!! - + const float_v& ldrp1 = ppx1 * dx + ppy1 * dy + ppz1 * dz; + const float_v& ldrp2 = ppx2 * dx + ppy2 * dy + ppz2 * dz; + + float_v detp = lp1p2 * lp1p2 - p12 * p22; + detp(abs(detp) < 1.e-4f) = 1; //TODO correct!!! + //dsdr calculation - const float_v a1 = ldrp2*lp1p2 - ldrp1*p22; - const float_v a2 = ldrp2*p12 - ldrp1*lp1p2; - const float_v lp1p2_ds0 = bq1*( ppx2*ppy1 - ppy2*ppx1); - const float_v lp1p2_ds1 = bq2*( ppx1*ppy2 - ppy1*ppx2); - const float_v ldrp1_ds0 = -p12 + bq1*(ppy1*dx - ppx1*dy); - const float_v ldrp1_ds1 = lp1p2; + const float_v a1 = ldrp2 * lp1p2 - ldrp1 * p22; + const float_v a2 = ldrp2 * p12 - ldrp1 * lp1p2; + const float_v lp1p2_ds0 = bq1 * (ppx2 * ppy1 - ppy2 * ppx1); + const float_v lp1p2_ds1 = bq2 * (ppx1 * ppy2 - ppy1 * ppx2); + const float_v ldrp1_ds0 = -p12 + bq1 * (ppy1 * dx - ppx1 * dy); + const float_v ldrp1_ds1 = lp1p2; const float_v ldrp2_ds0 = -lp1p2; - const float_v ldrp2_ds1 = p22 + bq2*(ppy2*dx - ppx2*dy); - const float_v detp_ds0 = 2.f*lp1p2*lp1p2_ds0; - const float_v detp_ds1 = 2.f*lp1p2*lp1p2_ds1; - const float_v a1_ds0 = ldrp2_ds0*lp1p2 + ldrp2*lp1p2_ds0 - ldrp1_ds0*p22; - const float_v a1_ds1 = ldrp2_ds1*lp1p2 + ldrp2*lp1p2_ds1 - ldrp1_ds1*p22; - const float_v a2_ds0 = ldrp2_ds0*p12 - ldrp1_ds0*lp1p2 - ldrp1*lp1p2_ds0; - const float_v a2_ds1 = ldrp2_ds1*p12 - ldrp1_ds1*lp1p2 - ldrp1*lp1p2_ds1; - - const float_v dsl1ds0 = a1_ds0/detp - a1*detp_ds0/(detp*detp); - const float_v dsl1ds1 = a1_ds1/detp - a1*detp_ds1/(detp*detp); - const float_v dsl2ds0 = a2_ds0/detp - a2*detp_ds0/(detp*detp); - const float_v dsl2ds1 = a2_ds1/detp - a2*detp_ds1/(detp*detp); - + const float_v ldrp2_ds1 = p22 + bq2 * (ppy2 * dx - ppx2 * dy); + const float_v detp_ds0 = 2.f * lp1p2 * lp1p2_ds0; + const float_v detp_ds1 = 2.f * lp1p2 * lp1p2_ds1; + const float_v a1_ds0 = ldrp2_ds0 * lp1p2 + ldrp2 * lp1p2_ds0 - ldrp1_ds0 * p22; + const float_v a1_ds1 = ldrp2_ds1 * lp1p2 + ldrp2 * lp1p2_ds1 - ldrp1_ds1 * p22; + const float_v a2_ds0 = ldrp2_ds0 * p12 - ldrp1_ds0 * lp1p2 - ldrp1 * lp1p2_ds0; + const float_v a2_ds1 = ldrp2_ds1 * p12 - ldrp1_ds1 * lp1p2 - ldrp1 * lp1p2_ds1; + + const float_v dsl1ds0 = a1_ds0 / detp - a1 * detp_ds0 / (detp * detp); + const float_v dsl1ds1 = a1_ds1 / detp - a1 * detp_ds1 / (detp * detp); + const float_v dsl2ds0 = a2_ds0 / detp - a2 * detp_ds0 / (detp * detp); + const float_v dsl2ds1 = a2_ds1 / detp - a2 * detp_ds1 / (detp * detp); + float_v dsldr[4][6]; - for(int iP=0; iP<6; iP++) - { - dsldr[0][iP] = dsl1ds0*dsdr[0][iP] + dsl1ds1*dsdr[2][iP]; - dsldr[1][iP] = dsl1ds0*dsdr[1][iP] + dsl1ds1*dsdr[3][iP]; - dsldr[2][iP] = dsl2ds0*dsdr[0][iP] + dsl2ds1*dsdr[2][iP]; - dsldr[3][iP] = dsl2ds0*dsdr[1][iP] + dsl2ds1*dsdr[3][iP]; + for (int iP = 0; iP < 6; iP++) { + dsldr[0][iP] = dsl1ds0 * dsdr[0][iP] + dsl1ds1 * dsdr[2][iP]; + dsldr[1][iP] = dsl1ds0 * dsdr[1][iP] + dsl1ds1 * dsdr[3][iP]; + dsldr[2][iP] = dsl2ds0 * dsdr[0][iP] + dsl2ds1 * dsdr[2][iP]; + dsldr[3][iP] = dsl2ds0 * dsdr[1][iP] + dsl2ds1 * dsdr[3][iP]; } - - for(int iDS=0; iDS<4; iDS++) - for(int iP=0; iP<6; iP++) + + for (int iDS = 0; iDS < 4; iDS++) + for (int iP = 0; iP < 6; iP++) dsdr[iDS][iP] += dsldr[iDS][iP]; - - const float_v lp1p2_dr0[6] = {0.f, 0.f, 0.f, ccc*ppx2 - ppy2*sss, ccc*ppy2 + ppx2*sss, pz2}; - const float_v lp1p2_dr1[6] = {0.f, 0.f, 0.f, ccc1*ppx1 - ppy1*sss1, ccc1*ppy1 + ppx1*sss1, pz1}; - const float_v ldrp1_dr0[6] = {-ppx1, -ppy1, -pz1, cB*ppy1 - ppx1*sB + ccc*dx - sss*dy, -cB*ppx1-ppy1*sB + sss*dx + ccc*dy, -dS[0]*pz1 + dz}; - const float_v ldrp1_dr1[6] = { ppx1, ppy1, pz1, -cB1*ppy1 + ppx1*sB1, cB1*ppx1 + ppy1*sB1, dS[1]*pz1}; - const float_v ldrp2_dr0[6] = {-ppx2, -ppy2, -pz2, cB*ppy2 - ppx2*sB, -cB*ppx2-ppy2*sB, -dS[0]*pz2}; - const float_v ldrp2_dr1[6] = { ppx2, ppy2, pz2, -cB1*ppy2 + ppx2*sB1 + ccc1*dx- sss1*dy, cB1*ppx2 + ppy2*sB1 + sss1*dx + ccc1*dy, dz + dS[1]*pz2}; - const float_v p12_dr0[6] = {0.f, 0.f, 0.f, 2.f*px1, 2.f*py1, 2.f*pz1}; - const float_v p22_dr1[6] = {0.f, 0.f, 0.f, 2.f*px2, 2.f*py2, 2.f*pz2}; + + const float_v lp1p2_dr0[6] = {0.f, 0.f, 0.f, ccc * ppx2 - ppy2 * sss, ccc * ppy2 + ppx2 * sss, pz2}; + const float_v lp1p2_dr1[6] = {0.f, 0.f, 0.f, ccc1 * ppx1 - ppy1 * sss1, ccc1 * ppy1 + ppx1 * sss1, pz1}; + const float_v ldrp1_dr0[6] = {-ppx1, -ppy1, -pz1, cB * ppy1 - ppx1 * sB + ccc * dx - sss * dy, -cB * ppx1 - ppy1 * sB + sss * dx + ccc * dy, -dS[0] * pz1 + dz}; + const float_v ldrp1_dr1[6] = {ppx1, ppy1, pz1, -cB1 * ppy1 + ppx1 * sB1, cB1 * ppx1 + ppy1 * sB1, dS[1] * pz1}; + const float_v ldrp2_dr0[6] = {-ppx2, -ppy2, -pz2, cB * ppy2 - ppx2 * sB, -cB * ppx2 - ppy2 * sB, -dS[0] * pz2}; + const float_v ldrp2_dr1[6] = {ppx2, ppy2, pz2, -cB1 * ppy2 + ppx2 * sB1 + ccc1 * dx - sss1 * dy, cB1 * ppx2 + ppy2 * sB1 + sss1 * dx + ccc1 * dy, dz + dS[1] * pz2}; + const float_v p12_dr0[6] = {0.f, 0.f, 0.f, 2.f * px1, 2.f * py1, 2.f * pz1}; + const float_v p22_dr1[6] = {0.f, 0.f, 0.f, 2.f * px2, 2.f * py2, 2.f * pz2}; float_v a1_dr0[6], a1_dr1[6], a2_dr0[6], a2_dr1[6], detp_dr0[6], detp_dr1[6]; - for(int iP=0; iP<6; iP++) - { - a1_dr0[iP] = ldrp2_dr0[iP]*lp1p2 + ldrp2*lp1p2_dr0[iP] - ldrp1_dr0[iP]*p22; - a1_dr1[iP] = ldrp2_dr1[iP]*lp1p2 + ldrp2*lp1p2_dr1[iP] - ldrp1_dr1[iP]*p22 - ldrp1*p22_dr1[iP]; - a2_dr0[iP] = ldrp2_dr0[iP]*p12 + ldrp2*p12_dr0[iP] - ldrp1_dr0[iP]*lp1p2 - ldrp1*lp1p2_dr0[iP]; - a2_dr1[iP] = ldrp2_dr1[iP]*p12 - ldrp1_dr1[iP]*lp1p2 - ldrp1*lp1p2_dr1[iP]; - detp_dr0[iP] = 2.f*lp1p2*lp1p2_dr0[iP] - p12_dr0[iP]*p22; - detp_dr1[iP] = 2.f*lp1p2*lp1p2_dr1[iP] - p12*p22_dr1[iP]; - - dsdr[0][iP] += a1_dr0[iP]/detp - a1*detp_dr0[iP]/(detp*detp); - dsdr[1][iP] += a1_dr1[iP]/detp - a1*detp_dr1[iP]/(detp*detp); - dsdr[2][iP] += a2_dr0[iP]/detp - a2*detp_dr0[iP]/(detp*detp); - dsdr[3][iP] += a2_dr1[iP]/detp - a2*detp_dr1[iP]/(detp*detp); + for (int iP = 0; iP < 6; iP++) { + a1_dr0[iP] = ldrp2_dr0[iP] * lp1p2 + ldrp2 * lp1p2_dr0[iP] - ldrp1_dr0[iP] * p22; + a1_dr1[iP] = ldrp2_dr1[iP] * lp1p2 + ldrp2 * lp1p2_dr1[iP] - ldrp1_dr1[iP] * p22 - ldrp1 * p22_dr1[iP]; + a2_dr0[iP] = ldrp2_dr0[iP] * p12 + ldrp2 * p12_dr0[iP] - ldrp1_dr0[iP] * lp1p2 - ldrp1 * lp1p2_dr0[iP]; + a2_dr1[iP] = ldrp2_dr1[iP] * p12 - ldrp1_dr1[iP] * lp1p2 - ldrp1 * lp1p2_dr1[iP]; + detp_dr0[iP] = 2.f * lp1p2 * lp1p2_dr0[iP] - p12_dr0[iP] * p22; + detp_dr1[iP] = 2.f * lp1p2 * lp1p2_dr1[iP] - p12 * p22_dr1[iP]; + + dsdr[0][iP] += a1_dr0[iP] / detp - a1 * detp_dr0[iP] / (detp * detp); + dsdr[1][iP] += a1_dr1[iP] / detp - a1 * detp_dr1[iP] / (detp * detp); + dsdr[2][iP] += a2_dr0[iP] / detp - a2 * detp_dr0[iP] / (detp * detp); + dsdr[3][iP] += a2_dr1[iP] / detp - a2 * detp_dr1[iP] / (detp * detp); } - - dS[0] += (ldrp2*lp1p2 - ldrp1*p22) /detp; - dS[1] += (ldrp2*p12 - ldrp1*lp1p2)/detp; + + dS[0] += (ldrp2 * lp1p2 - ldrp1 * p22) / detp; + dS[1] += (ldrp2 * p12 - ldrp1 * lp1p2) / detp; } } -void KFParticleBaseSIMD::GetDStoParticleBz( float_v B, const KFParticleBaseSIMD &p, - float_v dS[2], const float_v* param1, const float_v* param2 ) const -{ +void KFParticleBaseSIMD::GetDStoParticleBz(float_v B, const KFParticleBaseSIMD& p, + float_v dS[2], const float_v* param1, const float_v* param2) const +{ /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n ** 2) p - momentum of the particle; \n @@ -2466,31 +2462,29 @@ void KFParticleBaseSIMD::GetDStoParticleBz( float_v B, const KFParticleBaseSIMD ** \param[in] param2 - optional parameter, is used in case if the parameters of the second particles are rotated ** to other coordinate system (see GetDStoParticleBy() function), otherwise p.fP are used **/ - - if(!param1) - { + + if (!param1) { param1 = fP; param2 = p.fP; } //* Get dS to another particle for Bz field - const float_v kOvSqr6 = 1.f/sqrt(float_v(6.f)); + const float_v kOvSqr6 = 1.f / sqrt(float_v(6.f)); const float_v kCLight = 0.000299792458f; //in XY plane - //first root - const float_v& bq1 = B*simd_cast(fQ)*kCLight; - const float_v& bq2 = B*simd_cast(p.fQ)*kCLight; + //first root + const float_v& bq1 = B * simd_cast(fQ) * kCLight; + const float_v& bq2 = B * simd_cast(p.fQ) * kCLight; const float_m& isStraight1 = abs(bq1) < float_v(1.e-8f); const float_m& isStraight2 = abs(bq2) < float_v(1.e-8f); - - if( isStraight1.isFull() && isStraight2.isFull() ) - { + + if (isStraight1.isFull() && isStraight2.isFull()) { GetDStoParticleLine(p, dS); return; } - + const float_v& px1 = param1[3]; const float_v& py1 = param1[4]; const float_v& pz1 = param1[5]; @@ -2499,8 +2493,8 @@ void KFParticleBaseSIMD::GetDStoParticleBz( float_v B, const KFParticleBaseSIMD const float_v& py2 = param2[4]; const float_v& pz2 = param2[5]; - const float_v& pt12 = px1*px1 + py1*py1; - const float_v& pt22 = px2*px2 + py2*py2; + const float_v& pt12 = px1 * px1 + py1 * py1; + const float_v& pt22 = px2 * px2 + py2 * py2; const float_v& x01 = param1[0]; const float_v& y01 = param1[1]; @@ -2510,200 +2504,195 @@ void KFParticleBaseSIMD::GetDStoParticleBz( float_v B, const KFParticleBaseSIMD const float_v& y02 = param2[1]; const float_v& z02 = param2[2]; - float_v dS1[2] = {0.f, 0.f}, dS2[2]={0.f, 0.f}; - + float_v dS1[2] = {0.f, 0.f}, dS2[2] = {0.f, 0.f}; + const float_v& dx0 = (x01 - x02); const float_v& dy0 = (y01 - y02); - const float_v& dr02 = dx0*dx0 + dy0*dy0; - const float_v& drp1 = dx0*px1 + dy0*py1; - const float_v& dxyp1 = dx0*py1 - dy0*px1; - const float_v& drp2 = dx0*px2 + dy0*py2; - const float_v& dxyp2 = dx0*py2 - dy0*px2; - const float_v& p1p2 = px1*px2 + py1*py2; - const float_v& dp1p2 = px1*py2 - px2*py1; - - const float_v& k11 = (bq2*drp1 - dp1p2); - const float_v& k21 = (bq1*(bq2*dxyp1 - p1p2) + bq2*pt12); - const float_v& k12 = ((bq1*drp2 - dp1p2)); - const float_v& k22 = (bq2*(bq1*dxyp2 + p1p2) - bq1*pt22); - - const float_v& kp = (dxyp1*bq2 - dxyp2*bq1 - p1p2); - const float_v& kd = dr02/2.f*bq1*bq2 + kp; - const float_v& c1 = -(bq1*kd + pt12*bq2); - const float_v& c2 = bq2*kd + pt22*bq1; - - float_v d1 = pt12*pt22 - kd*kd; + const float_v& dr02 = dx0 * dx0 + dy0 * dy0; + const float_v& drp1 = dx0 * px1 + dy0 * py1; + const float_v& dxyp1 = dx0 * py1 - dy0 * px1; + const float_v& drp2 = dx0 * px2 + dy0 * py2; + const float_v& dxyp2 = dx0 * py2 - dy0 * px2; + const float_v& p1p2 = px1 * px2 + py1 * py2; + const float_v& dp1p2 = px1 * py2 - px2 * py1; + + const float_v& k11 = (bq2 * drp1 - dp1p2); + const float_v& k21 = (bq1 * (bq2 * dxyp1 - p1p2) + bq2 * pt12); + const float_v& k12 = ((bq1 * drp2 - dp1p2)); + const float_v& k22 = (bq2 * (bq1 * dxyp2 + p1p2) - bq1 * pt22); + + const float_v& kp = (dxyp1 * bq2 - dxyp2 * bq1 - p1p2); + const float_v& kd = dr02 / 2.f * bq1 * bq2 + kp; + const float_v& c1 = -(bq1 * kd + pt12 * bq2); + const float_v& c2 = bq2 * kd + pt22 * bq1; + + float_v d1 = pt12 * pt22 - kd * kd; d1(d1 < float_v(Vc::Zero)) = float_v(Vc::Zero); - d1 = sqrt( d1 ); - float_v d2 = pt12*pt22 - kd*kd; + d1 = sqrt(d1); + float_v d2 = pt12 * pt22 - kd * kd; d2(d2 < float_v(Vc::Zero)) = float_v(Vc::Zero); - d2 = sqrt( d2 ); + d2 = sqrt(d2); // find two points of closest approach in XY plane - if( ! ( (!isStraight1).isEmpty() ) ) - { - dS1[0](!isStraight1) = KFPMath::ATan2( (bq1*k11*c1 + k21*d1*bq1), (bq1*k11*d1*bq1 - k21*c1) )/bq1; - dS1[1](!isStraight1) = KFPMath::ATan2( (bq1*k11*c1 - k21*d1*bq1), (-bq1*k11*d1*bq1 - k21*c1) )/bq1; + if (!((!isStraight1).isEmpty())) { + dS1[0](!isStraight1) = KFPMath::ATan2((bq1 * k11 * c1 + k21 * d1 * bq1), (bq1 * k11 * d1 * bq1 - k21 * c1)) / bq1; + dS1[1](!isStraight1) = KFPMath::ATan2((bq1 * k11 * c1 - k21 * d1 * bq1), (-bq1 * k11 * d1 * bq1 - k21 * c1)) / bq1; } - if( ! ( (!isStraight2).isEmpty() ) ) - { - dS2[0](!isStraight2) = KFPMath::ATan2( (bq2*k12*c2 + k22*d2*bq2), (bq2*k12*d2*bq2 - k22*c2) )/bq2; - dS2[1](!isStraight2) = KFPMath::ATan2( (bq2*k12*c2 - k22*d2*bq2), (-bq2*k12*d2*bq2 - k22*c2) )/bq2; + if (!((!isStraight2).isEmpty())) { + dS2[0](!isStraight2) = KFPMath::ATan2((bq2 * k12 * c2 + k22 * d2 * bq2), (bq2 * k12 * d2 * bq2 - k22 * c2)) / bq2; + dS2[1](!isStraight2) = KFPMath::ATan2((bq2 * k12 * c2 - k22 * d2 * bq2), (-bq2 * k12 * d2 * bq2 - k22 * c2)) / bq2; } - if( ! ( isStraight1.isEmpty() ) ) - { - dS1[0](isStraight1 && (pt12>float_v(Vc::Zero)) ) = (k11*c1 + k21*d1)/(- k21*c1); - dS1[1](isStraight1 && (pt12>float_v(Vc::Zero)) ) = (k11*c1 - k21*d1)/(- k21*c1); + if (!(isStraight1.isEmpty())) { + dS1[0](isStraight1 && (pt12 > float_v(Vc::Zero))) = (k11 * c1 + k21 * d1) / (-k21 * c1); + dS1[1](isStraight1 && (pt12 > float_v(Vc::Zero))) = (k11 * c1 - k21 * d1) / (-k21 * c1); } - if( ! ( isStraight2.isEmpty() ) ) - { - dS2[0](isStraight2 && (pt22>float_v(Vc::Zero)) ) = (k12*c2 + k22*d2)/(- k22*c2); - dS2[1](isStraight2 && (pt22>float_v(Vc::Zero)) ) = (k12*c2 - k22*d2)/(- k22*c2); + if (!(isStraight2.isEmpty())) { + dS2[0](isStraight2 && (pt22 > float_v(Vc::Zero))) = (k12 * c2 + k22 * d2) / (-k22 * c2); + dS2[1](isStraight2 && (pt22 > float_v(Vc::Zero))) = (k12 * c2 - k22 * d2) / (-k22 * c2); } - + //select a point which is close to the primary vertex (with the smallest r) - + float_v dr2[2]; - for(int iP = 0; iP<2; iP++) - { - const float_v& bs1 = bq1*dS1[iP]; - const float_v& bs2 = bq2*dS2[iP]; + for (int iP = 0; iP < 2; iP++) { + const float_v& bs1 = bq1 * dS1[iP]; + const float_v& bs2 = bq2 * dS2[iP]; float_v sss = KFPMath::Sin(bs1), ccc = KFPMath::Cos(bs1); - + const float_m& bs1Big = abs(bs1) > 1.e-8f; const float_m& bs2Big = abs(bs2) > 1.e-8f; - + float_v sB(Vc::Zero), cB(Vc::Zero); - sB(bs1Big) = sss/bq1; - sB(!bs1Big) = ((1.f-bs1*kOvSqr6)*(1.f+bs1*kOvSqr6)*dS1[iP]); - cB(bs1Big) = (1.f-ccc)/bq1; - cB(!bs1Big) = .5f*sB*bs1; - - const float_v& x1 = param1[0] + sB*px1 + cB*py1; - const float_v& y1 = param1[1] - cB*px1 + sB*py1; - const float_v& z1 = param1[2] + dS1[iP]*param1[5]; - - sss = KFPMath::Sin(bs2); ccc = KFPMath::Cos(bs2); - - sB(bs2Big) = sss/bq2; - sB(!bs2Big) = ((1.f-bs2*kOvSqr6)*(1.f+bs2*kOvSqr6)*dS2[iP]); - cB(bs2Big) = (1.f-ccc)/bq2; - cB(!bs2Big) = .5f*sB*bs2; - - const float_v& x2 = param2[0] + sB*px2 + cB*py2; - const float_v& y2 = param2[1] - cB*px2 + sB*py2; - const float_v& z2 = param2[2] + dS2[iP]*param2[5]; - - float_v dx = (x1-x2); - float_v dy = (y1-y2); - float_v dz = (z1-z2); - - dr2[iP] = dx*dx + dy*dy + dz*dz; + sB(bs1Big) = sss / bq1; + sB(!bs1Big) = ((1.f - bs1 * kOvSqr6) * (1.f + bs1 * kOvSqr6) * dS1[iP]); + cB(bs1Big) = (1.f - ccc) / bq1; + cB(!bs1Big) = .5f * sB * bs1; + + const float_v& x1 = param1[0] + sB * px1 + cB * py1; + const float_v& y1 = param1[1] - cB * px1 + sB * py1; + const float_v& z1 = param1[2] + dS1[iP] * param1[5]; + + sss = KFPMath::Sin(bs2); + ccc = KFPMath::Cos(bs2); + + sB(bs2Big) = sss / bq2; + sB(!bs2Big) = ((1.f - bs2 * kOvSqr6) * (1.f + bs2 * kOvSqr6) * dS2[iP]); + cB(bs2Big) = (1.f - ccc) / bq2; + cB(!bs2Big) = .5f * sB * bs2; + + const float_v& x2 = param2[0] + sB * px2 + cB * py2; + const float_v& y2 = param2[1] - cB * px2 + sB * py2; + const float_v& z2 = param2[2] + dS2[iP] * param2[5]; + + float_v dx = (x1 - x2); + float_v dy = (y1 - y2); + float_v dz = (z1 - z2); + + dr2[iP] = dx * dx + dy * dy + dz * dz; } - - + const float_m isFirstRoot = (dr2[0] < dr2[1]); - - // if(!(isFirstRoot.isEmpty())) + + // if(!(isFirstRoot.isEmpty())) { - dS[0](isFirstRoot) = dS1[0]; - dS[1](isFirstRoot) = dS2[0]; + dS[0](isFirstRoot) = dS1[0]; + dS[1](isFirstRoot) = dS2[0]; } - // if( !( (!isFirstRoot).isEmpty() ) ) + // if( !( (!isFirstRoot).isEmpty() ) ) { - dS[0](!isFirstRoot) = dS1[1]; - dS[1](!isFirstRoot) = dS2[1]; + dS[0](!isFirstRoot) = dS1[1]; + dS[1](!isFirstRoot) = dS2[1]; } - + //find correct parts of helices int_v n1(Vc::Zero); int_v n2(Vc::Zero); -// float_v dzMin = abs( (z01-z02) + dS[0]*pz1 - dS[1]*pz2 ); + // float_v dzMin = abs( (z01-z02) + dS[0]*pz1 - dS[1]*pz2 ); const float_v pi2(6.283185307f); - -// //TODO optimise for loops for neutral particles -// const float_v& i1Float = -bq1/pi2*(z01/pz1+dS[0]); -// for(int di1=-1; di1<=1; di1++) -// { -// int_v i1(Vc::Zero); -// i1(int_m(!isStraight1)) = int_v(i1Float) + di1; -// -// const float_v& i2Float = ( ((z01-z02) + (dS[0]+pi2*i1/bq1)*pz1)/pz2 - dS[1]) * bq2/pi2; -// for(int di2 = -1; di2<=1; di2++) -// { -// int_v i2(Vc::Zero); -// i2(int_m(!isStraight2)) = int_v(i2Float) + di2; -// -// const float_v& z1 = z01 + (dS[0]+pi2*i1/bq1)*pz1; -// const float_v& z2 = z02 + (dS[1]+pi2*i2/bq2)*pz2; -// const float_v& dz = abs( z1-z2 ); -// -// n1(int_m(dz < dzMin)) = i1; -// n2(int_m(dz < dzMin)) = i2; -// dzMin(dz < dzMin) = dz; -// } -// } -// -// dS[0](!isStraight1) += float_v(n1)*pi2/bq1; -// dS[1](!isStraight2) += float_v(n2)*pi2/bq2; + + // //TODO optimise for loops for neutral particles + // const float_v& i1Float = -bq1/pi2*(z01/pz1+dS[0]); + // for(int di1=-1; di1<=1; di1++) + // { + // int_v i1(Vc::Zero); + // i1(int_m(!isStraight1)) = int_v(i1Float) + di1; + // + // const float_v& i2Float = ( ((z01-z02) + (dS[0]+pi2*i1/bq1)*pz1)/pz2 - dS[1]) * bq2/pi2; + // for(int di2 = -1; di2<=1; di2++) + // { + // int_v i2(Vc::Zero); + // i2(int_m(!isStraight2)) = int_v(i2Float) + di2; + // + // const float_v& z1 = z01 + (dS[0]+pi2*i1/bq1)*pz1; + // const float_v& z2 = z02 + (dS[1]+pi2*i2/bq2)*pz2; + // const float_v& dz = abs( z1-z2 ); + // + // n1(int_m(dz < dzMin)) = i1; + // n2(int_m(dz < dzMin)) = i2; + // dzMin(dz < dzMin) = dz; + // } + // } + // + // dS[0](!isStraight1) += float_v(n1)*pi2/bq1; + // dS[1](!isStraight2) += float_v(n2)*pi2/bq2; //Line correction { - const float_v& bs1 = bq1*dS[0]; - const float_v& bs2 = bq2*dS[1]; + const float_v& bs1 = bq1 * dS[0]; + const float_v& bs2 = bq2 * dS[1]; float_v sss = KFPMath::Sin(bs1), ccc = KFPMath::Cos(bs1); - + const float_m& bs1Big = abs(bs1) > 1.e-8f; const float_m& bs2Big = abs(bs2) > 1.e-8f; - + float_v sB(0.f), cB(0.f); - sB(bs1Big) = sss/bq1; - cB(bs1Big) = (1.f-ccc)/bq1; - sB(!bs1Big) = ((1.f-bs1*kOvSqr6)*(1.f+bs1*kOvSqr6)*dS[0]); - cB(!bs1Big) = .5f*sB*bs1; - - const float_v& x1 = x01 + sB*px1 + cB*py1; - const float_v& y1 = y01 - cB*px1 + sB*py1; - const float_v& z1 = z01 + dS[0]*pz1; - const float_v& ppx1 = ccc*px1 + sss*py1; - const float_v& ppy1 = -sss*px1 + ccc*py1; + sB(bs1Big) = sss / bq1; + cB(bs1Big) = (1.f - ccc) / bq1; + sB(!bs1Big) = ((1.f - bs1 * kOvSqr6) * (1.f + bs1 * kOvSqr6) * dS[0]); + cB(!bs1Big) = .5f * sB * bs1; + + const float_v& x1 = x01 + sB * px1 + cB * py1; + const float_v& y1 = y01 - cB * px1 + sB * py1; + const float_v& z1 = z01 + dS[0] * pz1; + const float_v& ppx1 = ccc * px1 + sss * py1; + const float_v& ppy1 = -sss * px1 + ccc * py1; const float_v& ppz1 = pz1; - + float_v sss1 = KFPMath::Sin(bs2), ccc1 = KFPMath::Cos(bs2); float_v sB1(0.f), cB1(0.f); - sB1(bs2Big) = sss1/bq2; - cB1(bs2Big) = (1.f-ccc1)/bq2; - sB1(!bs2Big) = ((1.f-bs2*kOvSqr6)*(1.f+bs2*kOvSqr6)*dS[1]); - cB1(!bs2Big) = .5f*sB1*bs2; - - const float_v& x2 = x02 + sB1*px2 + cB1*py2; - const float_v& y2 = y02 - cB1*px2 + sB1*py2; - const float_v& z2 = z02 + dS[1]*pz2; - const float_v& ppx2 = ccc1*px2 + sss1*py2; - const float_v& ppy2 = -sss1*px2 + ccc1*py2; + sB1(bs2Big) = sss1 / bq2; + cB1(bs2Big) = (1.f - ccc1) / bq2; + sB1(!bs2Big) = ((1.f - bs2 * kOvSqr6) * (1.f + bs2 * kOvSqr6) * dS[1]); + cB1(!bs2Big) = .5f * sB1 * bs2; + + const float_v& x2 = x02 + sB1 * px2 + cB1 * py2; + const float_v& y2 = y02 - cB1 * px2 + sB1 * py2; + const float_v& z2 = z02 + dS[1] * pz2; + const float_v& ppx2 = ccc1 * px2 + sss1 * py2; + const float_v& ppy2 = -sss1 * px2 + ccc1 * py2; const float_v& ppz2 = pz2; - const float_v& p12 = ppx1*ppx1 + ppy1*ppy1 + ppz1*ppz1; - const float_v& p22 = ppx2*ppx2 + ppy2*ppy2 + ppz2*ppz2; - const float_v& lp1p2 = ppx1*ppx2 + ppy1*ppy2 + ppz1*ppz2; + const float_v& p12 = ppx1 * ppx1 + ppy1 * ppy1 + ppz1 * ppz1; + const float_v& p22 = ppx2 * ppx2 + ppy2 * ppy2 + ppz2 * ppz2; + const float_v& lp1p2 = ppx1 * ppx2 + ppy1 * ppy2 + ppz1 * ppz2; const float_v& dx = (x2 - x1); const float_v& dy = (y2 - y1); const float_v& dz = (z2 - z1); - - const float_v& ldrp1 = ppx1*dx + ppy1*dy + ppz1*dz; - const float_v& ldrp2 = ppx2*dx + ppy2*dy + ppz2*dz; - float_v detp = lp1p2*lp1p2 - p12*p22; - detp(abs(detp)<1.e-4f) = 1; //TODO correct!!! - - dS[0] += (ldrp2*lp1p2 - ldrp1*p22) /detp; - dS[1] += (ldrp2*p12 - ldrp1*lp1p2)/detp; + const float_v& ldrp1 = ppx1 * dx + ppy1 * dy + ppz1 * dz; + const float_v& ldrp2 = ppx2 * dx + ppy2 * dy + ppz2 * dz; + + float_v detp = lp1p2 * lp1p2 - p12 * p22; + detp(abs(detp) < 1.e-4f) = 1; //TODO correct!!! + + dS[0] += (ldrp2 * lp1p2 - ldrp1 * p22) / detp; + dS[1] += (ldrp2 * p12 - ldrp1 * lp1p2) / detp; } } -void KFParticleBaseSIMD::GetDStoParticleBy( float_v B, const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] ) const +void KFParticleBaseSIMD::GetDStoParticleBy(float_v B, const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -2725,29 +2714,28 @@ void KFParticleBaseSIMD::GetDStoParticleBy( float_v B, const KFParticleBaseSIMD ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) ** \param[out] dsdr[4][6] - partial derivatives of the parameters dS[0] and dS[1] over the state vectors of the both particles **/ - - const float_v param1[6] = { fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4] }; - const float_v param2[6] = { p.fP[0], -p.fP[2], p.fP[1], p.fP[3], -p.fP[5], p.fP[4] }; - + + const float_v param1[6] = {fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4]}; + const float_v param2[6] = {p.fP[0], -p.fP[2], p.fP[1], p.fP[3], -p.fP[5], p.fP[4]}; + float_v dsdrBz[4][6]; - for(int i1=0; i1<4; i1++) - for(int i2=0; i2<6; i2++) + for (int i1 = 0; i1 < 4; i1++) + for (int i2 = 0; i2 < 6; i2++) dsdrBz[i1][i2] = 0.f; - + GetDStoParticleBz(B, p, dS, dsdrBz, param1, param2); - - for(int iDs=0; iDs<4; iDs++) - { - dsdr[iDs][0] = dsdrBz[iDs][0]; - dsdr[iDs][1] = dsdrBz[iDs][2]; + + for (int iDs = 0; iDs < 4; iDs++) { + dsdr[iDs][0] = dsdrBz[iDs][0]; + dsdr[iDs][1] = dsdrBz[iDs][2]; dsdr[iDs][2] = -dsdrBz[iDs][1]; - dsdr[iDs][3] = dsdrBz[iDs][3]; - dsdr[iDs][4] = dsdrBz[iDs][5]; + dsdr[iDs][3] = dsdrBz[iDs][3]; + dsdr[iDs][4] = dsdrBz[iDs][5]; dsdr[iDs][5] = -dsdrBz[iDs][4]; } } -void KFParticleBaseSIMD::GetDStoParticleBy( float_v B, const KFParticleBaseSIMD &p, float_v dS[2] ) const +void KFParticleBaseSIMD::GetDStoParticleBy(float_v B, const KFParticleBaseSIMD& p, float_v dS[2]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -2760,14 +2748,14 @@ void KFParticleBaseSIMD::GetDStoParticleBy( float_v B, const KFParticleBaseSIMD ** \param[in] p - second particle ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) **/ - - const float_v param1[6] = { fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4] }; - const float_v param2[6] = { p.fP[0], -p.fP[2], p.fP[1], p.fP[3], -p.fP[5], p.fP[4] }; - + + const float_v param1[6] = {fP[0], -fP[2], fP[1], fP[3], -fP[5], fP[4]}; + const float_v param2[6] = {p.fP[0], -p.fP[2], p.fP[1], p.fP[3], -p.fP[5], p.fP[4]}; + GetDStoParticleBz(B, p, dS, param1, param2); } -void KFParticleBaseSIMD::GetDStoParticleB( float_v B[3], const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] ) const +void KFParticleBaseSIMD::GetDStoParticleB(float_v B[3], const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -2789,56 +2777,54 @@ void KFParticleBaseSIMD::GetDStoParticleB( float_v B[3], const KFParticleBaseSIM ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) ** \param[out] dsdr[4][6] - partial derivatives of the parameters dS[0] and dS[1] over the state vectors of the both particles **/ - + const float_v& Bx = B[0]; const float_v& By = B[1]; const float_v& Bz = B[2]; - - const float_v& Bxz = sqrt(Bx*Bx + Bz*Bz); - const float_v& Br = sqrt(Bx*Bx + By*By + Bz*Bz); - + + const float_v& Bxz = sqrt(Bx * Bx + Bz * Bz); + const float_v& Br = sqrt(Bx * Bx + By * By + Bz * Bz); + float_v cosA = 1.f; float_v sinA = 0.f; - cosA( abs(Bxz) > 1.e-8f ) = Bz/Bxz; - sinA( abs(Bxz) > 1.e-8f ) = Bx/Bxz; - - const float_v& sinP = By/Br; - const float_v& cosP = Bxz/Br; - - - const float_v param1[6] = { cosA*fP[0] - sinA*fP[2], - -sinA*sinP*fP[0] + cosP*fP[1] - cosA*sinP*fP[2], - cosP*sinA*fP[0] + sinP*fP[1] + cosA*cosP*fP[2], - cosA*fP[3] - sinA*fP[5], - -sinA*sinP*fP[3] + cosP*fP[4] - cosA*sinP*fP[5], - cosP*sinA*fP[3] + sinP*fP[4] + cosA*cosP*fP[5]}; - const float_v param2[6] = { cosA*p.fP[0] - sinA*p.fP[2], - -sinA*sinP*p.fP[0] + cosP*p.fP[1] - cosA*sinP*p.fP[2], - cosP*sinA*p.fP[0] + sinP*p.fP[1] + cosA*cosP*p.fP[2], - cosA*p.fP[3] - sinA*p.fP[5], - -sinA*sinP*p.fP[3] + cosP*p.fP[4] - cosA*sinP*p.fP[5], - cosP*sinA*p.fP[3] + sinP*p.fP[4] + cosA*cosP*p.fP[5]}; + cosA(abs(Bxz) > 1.e-8f) = Bz / Bxz; + sinA(abs(Bxz) > 1.e-8f) = Bx / Bxz; + + const float_v& sinP = By / Br; + const float_v& cosP = Bxz / Br; + + const float_v param1[6] = {cosA * fP[0] - sinA * fP[2], + -sinA * sinP * fP[0] + cosP * fP[1] - cosA * sinP * fP[2], + cosP * sinA * fP[0] + sinP * fP[1] + cosA * cosP * fP[2], + cosA * fP[3] - sinA * fP[5], + -sinA * sinP * fP[3] + cosP * fP[4] - cosA * sinP * fP[5], + cosP * sinA * fP[3] + sinP * fP[4] + cosA * cosP * fP[5]}; + const float_v param2[6] = {cosA * p.fP[0] - sinA * p.fP[2], + -sinA * sinP * p.fP[0] + cosP * p.fP[1] - cosA * sinP * p.fP[2], + cosP * sinA * p.fP[0] + sinP * p.fP[1] + cosA * cosP * p.fP[2], + cosA * p.fP[3] - sinA * p.fP[5], + -sinA * sinP * p.fP[3] + cosP * p.fP[4] - cosA * sinP * p.fP[5], + cosP * sinA * p.fP[3] + sinP * p.fP[4] + cosA * cosP * p.fP[5]}; float_v dsdrBz[4][6]; - for(int i1=0; i1<4; i1++) - for(int i2=0; i2<6; i2++) + for (int i1 = 0; i1 < 4; i1++) + for (int i2 = 0; i2 < 6; i2++) dsdrBz[i1][i2] = 0.f; - + GetDStoParticleBz(Br, p, dS, dsdrBz, param1, param2); - - for(int iDs=0; iDs<4; iDs++) - { - dsdr[iDs][0] = dsdrBz[iDs][0]*cosA - dsdrBz[iDs][1]*sinA*sinP + dsdrBz[iDs][2]*sinA*cosP; - dsdr[iDs][1] = dsdrBz[iDs][1]*cosP + dsdrBz[iDs][2]*sinP; - dsdr[iDs][2] = -dsdrBz[iDs][0]*sinA - dsdrBz[iDs][1]*cosA*sinP + dsdrBz[iDs][2]*cosA*cosP; - dsdr[iDs][3] = dsdrBz[iDs][3]*cosA - dsdrBz[iDs][4]*sinA*sinP + dsdrBz[iDs][5]*sinA*cosP; - dsdr[iDs][4] = dsdrBz[iDs][4]*cosP + dsdrBz[iDs][5]*sinP; - dsdr[iDs][5] = -dsdrBz[iDs][3]*sinA - dsdrBz[iDs][4]*cosA*sinP + dsdrBz[iDs][5]*cosA*cosP; + + for (int iDs = 0; iDs < 4; iDs++) { + dsdr[iDs][0] = dsdrBz[iDs][0] * cosA - dsdrBz[iDs][1] * sinA * sinP + dsdrBz[iDs][2] * sinA * cosP; + dsdr[iDs][1] = dsdrBz[iDs][1] * cosP + dsdrBz[iDs][2] * sinP; + dsdr[iDs][2] = -dsdrBz[iDs][0] * sinA - dsdrBz[iDs][1] * cosA * sinP + dsdrBz[iDs][2] * cosA * cosP; + dsdr[iDs][3] = dsdrBz[iDs][3] * cosA - dsdrBz[iDs][4] * sinA * sinP + dsdrBz[iDs][5] * sinA * cosP; + dsdr[iDs][4] = dsdrBz[iDs][4] * cosP + dsdrBz[iDs][5] * sinP; + dsdr[iDs][5] = -dsdrBz[iDs][3] * sinA - dsdrBz[iDs][4] * cosA * sinP + dsdrBz[iDs][5] * cosA * cosP; } } -void KFParticleBaseSIMD::GetDStoParticleB( float_v B[3], const KFParticleBaseSIMD &p, float_v dS[2] ) const +void KFParticleBaseSIMD::GetDStoParticleB(float_v B[3], const KFParticleBaseSIMD& p, float_v dS[2]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -2851,41 +2837,40 @@ void KFParticleBaseSIMD::GetDStoParticleB( float_v B[3], const KFParticleBaseSIM ** \param[in] p - second particle ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) **/ - + const float_v& Bx = B[0]; const float_v& By = B[1]; const float_v& Bz = B[2]; - - const float_v& Bxz = sqrt(Bx*Bx + Bz*Bz); - const float_v& Br = sqrt(Bx*Bx + By*By + Bz*Bz); - + + const float_v& Bxz = sqrt(Bx * Bx + Bz * Bz); + const float_v& Br = sqrt(Bx * Bx + By * By + Bz * Bz); + float_v cosA = 1.f; float_v sinA = 0.f; - cosA( abs(Bxz) > 1.e-8f ) = Bz/Bxz; - sinA( abs(Bxz) > 1.e-8f ) = Bx/Bxz; - - const float_v& sinP = By/Br; - const float_v& cosP = Bxz/Br; - - - const float_v param1[6] = { cosA*fP[0] - sinA*fP[2], - -sinA*sinP*fP[0] + cosP*fP[1] - cosA*sinP*fP[2], - cosP*sinA*fP[0] + sinP*fP[1] + cosA*cosP*fP[2], - cosA*fP[3] - sinA*fP[5], - -sinA*sinP*fP[3] + cosP*fP[4] - cosA*sinP*fP[5], - cosP*sinA*fP[3] + sinP*fP[4] + cosA*cosP*fP[5]}; - const float_v param2[6] = { cosA*p.fP[0] - sinA*p.fP[2], - -sinA*sinP*p.fP[0] + cosP*p.fP[1] - cosA*sinP*p.fP[2], - cosP*sinA*p.fP[0] + sinP*p.fP[1] + cosA*cosP*p.fP[2], - cosA*p.fP[3] - sinA*p.fP[5], - -sinA*sinP*p.fP[3] + cosP*p.fP[4] - cosA*sinP*p.fP[5], - cosP*sinA*p.fP[3] + sinP*p.fP[4] + cosA*cosP*p.fP[5]}; + cosA(abs(Bxz) > 1.e-8f) = Bz / Bxz; + sinA(abs(Bxz) > 1.e-8f) = Bx / Bxz; + + const float_v& sinP = By / Br; + const float_v& cosP = Bxz / Br; + + const float_v param1[6] = {cosA * fP[0] - sinA * fP[2], + -sinA * sinP * fP[0] + cosP * fP[1] - cosA * sinP * fP[2], + cosP * sinA * fP[0] + sinP * fP[1] + cosA * cosP * fP[2], + cosA * fP[3] - sinA * fP[5], + -sinA * sinP * fP[3] + cosP * fP[4] - cosA * sinP * fP[5], + cosP * sinA * fP[3] + sinP * fP[4] + cosA * cosP * fP[5]}; + const float_v param2[6] = {cosA * p.fP[0] - sinA * p.fP[2], + -sinA * sinP * p.fP[0] + cosP * p.fP[1] - cosA * sinP * p.fP[2], + cosP * sinA * p.fP[0] + sinP * p.fP[1] + cosA * cosP * p.fP[2], + cosA * p.fP[3] - sinA * p.fP[5], + -sinA * sinP * p.fP[3] + cosP * p.fP[4] - cosA * sinP * p.fP[5], + cosP * sinA * p.fP[3] + sinP * p.fP[4] + cosA * cosP * p.fP[5]}; GetDStoParticleBz(Br, p, dS, param1, param2); } -void KFParticleBaseSIMD::GetDStoParticleLine( const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] ) const +void KFParticleBaseSIMD::GetDStoParticleLine(const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -2903,20 +2888,20 @@ void KFParticleBaseSIMD::GetDStoParticleLine( const KFParticleBaseSIMD &p, float ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) ** \param[out] dsdr[4][6] - partial derivatives of the parameters dS[0] and dS[1] over the state vectors of the both particles **/ - - float_v p12 = fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]; - float_v p22 = p.fP[3]*p.fP[3] + p.fP[4]*p.fP[4] + p.fP[5]*p.fP[5]; - float_v p1p2 = fP[3]*p.fP[3] + fP[4]*p.fP[4] + fP[5]*p.fP[5]; - float_v drp1 = fP[3]*(p.fP[0]-fP[0]) + fP[4]*(p.fP[1]-fP[1]) + fP[5]*(p.fP[2]-fP[2]); - float_v drp2 = p.fP[3]*(p.fP[0]-fP[0]) + p.fP[4]*(p.fP[1]-fP[1]) + p.fP[5]*(p.fP[2]-fP[2]); + float_v p12 = fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]; + float_v p22 = p.fP[3] * p.fP[3] + p.fP[4] * p.fP[4] + p.fP[5] * p.fP[5]; + float_v p1p2 = fP[3] * p.fP[3] + fP[4] * p.fP[4] + fP[5] * p.fP[5]; + + float_v drp1 = fP[3] * (p.fP[0] - fP[0]) + fP[4] * (p.fP[1] - fP[1]) + fP[5] * (p.fP[2] - fP[2]); + float_v drp2 = p.fP[3] * (p.fP[0] - fP[0]) + p.fP[4] * (p.fP[1] - fP[1]) + p.fP[5] * (p.fP[2] - fP[2]); - float_v detp = p1p2*p1p2 - p12*p22; - detp( abs(detp)(fQ); - const float_v& bq2 = fld[1]*simd_cast(p.fQ); + const float_v& bq1 = fld[1] * simd_cast(fQ); + const float_v& bq2 = fld[1] * simd_cast(p.fQ); const float_m& isStraight1 = abs(bq1) < float_v(1.e-8f); const float_m& isStraight2 = abs(bq2) < float_v(1.e-8f); - - if( isStraight1.isFull() && isStraight2.isFull() ) + + if (isStraight1.isFull() && isStraight2.isFull()) GetDStoParticleLine(p, dS, dsdr); else GetDStoParticleBy(fld[1], p, dS, dsdr); } -void KFParticleBaseSIMD::GetDStoParticleCBM( const KFParticleBaseSIMD &p, float_v dS[2] ) const +void KFParticleBaseSIMD::GetDStoParticleCBM(const KFParticleBaseSIMD& p, float_v dS[2]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -3041,23 +3024,23 @@ void KFParticleBaseSIMD::GetDStoParticleCBM( const KFParticleBaseSIMD &p, float_ ** \param[in] p - second particle ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) **/ - + float_v fld[3]; - GetFieldValue( fP, fld ); + GetFieldValue(fP, fld); - const float_v& bq1 = fld[1]*simd_cast(fQ); - const float_v& bq2 = fld[1]*simd_cast(p.fQ); + const float_v& bq1 = fld[1] * simd_cast(fQ); + const float_v& bq2 = fld[1] * simd_cast(p.fQ); const float_m& isStraight1 = abs(bq1) < float_v(1.e-8f); const float_m& isStraight2 = abs(bq2) < float_v(1.e-8f); - - if( isStraight1.isFull() && isStraight2.isFull() ) + + if (isStraight1.isFull() && isStraight2.isFull()) GetDStoParticleLine(p, dS); else GetDStoParticleBy(fld[1], p, dS); } -void KFParticleBaseSIMD::TransportCBM( float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1, float_v* F, float_v* F1 ) const -{ +void KFParticleBaseSIMD::TransportCBM(float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1, float_v* F, float_v* F1) const +{ /** Transports the parameters and their covariance matrix of the current particle assuming CBM-like nonhomogeneous ** magnetic field on the length defined by the transport parameter dS = l/p, where l is the signed distance and p is ** the momentum of the current particle. The obtained parameters and covariance matrix are stored to the arrays P and @@ -3078,28 +3061,28 @@ void KFParticleBaseSIMD::TransportCBM( float_v dS, const float_v* dsdr, float_v ** \param[out] F1[36] - optional parameter, corelation 6x6 matrix betweeen the current particle and particle or vertex ** with the state vector r1, to which the current particle is being transported, F1 = d(fP new)/d(r1) **/ - - if( (fQ == int_v(Vc::Zero)).isFull() ){ - TransportLine( dS, dsdr, P, C, dsdr1, F, F1 ); + + if ((fQ == int_v(Vc::Zero)).isFull()) { + TransportLine(dS, dsdr, P, C, dsdr1, F, F1); return; } const float_v kCLight = 0.000299792458f; - float_v c = simd_cast(fQ)*kCLight; + float_v c = simd_cast(fQ) * kCLight; - // construct coefficients + // construct coefficients - float_v - px = fP[3], - py = fP[4], - pz = fP[5]; - - float_v sx=0.f, sy=0.f, sz=0.f, syy=0.f, syz=0.f, syyy=0.f, ssx=0.f, ssy=0.f, ssz=0.f, ssyy=0.f, ssyz=0.f, ssyyy=0.f; + float_v + px = fP[3], + py = fP[4], + pz = fP[5]; + + float_v sx = 0.f, sy = 0.f, sz = 0.f, syy = 0.f, syz = 0.f, syyy = 0.f, ssx = 0.f, ssy = 0.f, ssz = 0.f, ssyy = 0.f, ssyz = 0.f, ssyyy = 0.f; { // get field integrals - float_v fld[3][3]; + float_v fld[3][3]; float_v p0[3], p1[3], p2[3]; // line track approximation @@ -3107,161 +3090,203 @@ void KFParticleBaseSIMD::TransportCBM( float_v dS, const float_v* dsdr, float_v p0[0] = fP[0]; p0[1] = fP[1]; p0[2] = fP[2]; - - p2[0] = fP[0] + px*dS; - p2[1] = fP[1] + py*dS; - p2[2] = fP[2] + pz*dS; - - p1[0] = 0.5f*(p0[0]+p2[0]); - p1[1] = 0.5f*(p0[1]+p2[1]); - p1[2] = 0.5f*(p0[2]+p2[2]); + + p2[0] = fP[0] + px * dS; + p2[1] = fP[1] + py * dS; + p2[2] = fP[2] + pz * dS; + + p1[0] = 0.5f * (p0[0] + p2[0]); + p1[1] = 0.5f * (p0[1] + p2[1]); + p1[2] = 0.5f * (p0[2] + p2[2]); // first order track approximation { - GetFieldValue( p0, fld[0] ); - GetFieldValue( p1, fld[1] ); - GetFieldValue( p2, fld[2] ); + GetFieldValue(p0, fld[0]); + GetFieldValue(p1, fld[1]); + GetFieldValue(p2, fld[2]); - float_v ssy1 = ( 7.f*fld[0][1] + 6.f*fld[1][1]-fld[2][1] )*c*dS*dS/96.f; - float_v ssy2 = ( fld[0][1] + 2.f*fld[1][1] )*c*dS*dS/6.f; + float_v ssy1 = (7.f * fld[0][1] + 6.f * fld[1][1] - fld[2][1]) * c * dS * dS / 96.f; + float_v ssy2 = (fld[0][1] + 2.f * fld[1][1]) * c * dS * dS / 6.f; - p1[0] -= ssy1*pz; - p1[2] += ssy1*px; - p2[0] -= ssy2*pz; - p2[2] += ssy2*px; + p1[0] -= ssy1 * pz; + p1[2] += ssy1 * px; + p2[0] -= ssy2 * pz; + p2[2] += ssy2 * px; } - GetFieldValue( p0, fld[0] ); - GetFieldValue( p1, fld[1] ); - GetFieldValue( p2, fld[2] ); + GetFieldValue(p0, fld[0]); + GetFieldValue(p1, fld[1]); + GetFieldValue(p2, fld[2]); - for(int iF1=0; iF1<3; iF1++) - for(int iF2=0; iF2<3; iF2++) + for (int iF1 = 0; iF1 < 3; iF1++) + for (int iF2 = 0; iF2 < 3; iF2++) fld[iF1][iF2](abs(fld[iF1][iF2]) > float_v(100.f)) = 0.f; - sx = c*( fld[0][0] + 4*fld[1][0] + fld[2][0] )*dS/6.f; - sy = c*( fld[0][1] + 4*fld[1][1] + fld[2][1] )*dS/6.f; - sz = c*( fld[0][2] + 4*fld[1][2] + fld[2][2] )*dS/6.f; - - ssx = c*( fld[0][0] + 2*fld[1][0])*dS*dS/6.f; - ssy = c*( fld[0][1] + 2*fld[1][1])*dS*dS/6.f; - ssz = c*( fld[0][2] + 2*fld[1][2])*dS*dS/6.f; - - float_v c2[3][3] = { { 5.f, -4.f, -1.f},{ 44.f, 80.f, -4.f},{ 11.f, 44.f, 5.f} }; // /=360. - float_v cc2[3][3] = { { 38.f, 8.f, -4.f},{ 148.f, 208.f, -20.f},{ 3.f, 36.f, 3.f} }; // /=2520. - for(Int_t n=0; n<3; n++) - for(Int_t m=0; m<3; m++) - { - syz += c2[n][m]*fld[n][1]*fld[m][2]; - ssyz += cc2[n][m]*fld[n][1]*fld[m][2]; - } - - syz *= c*c*dS*dS/360.f; - ssyz *= c*c*dS*dS*dS/2520.f; - - syy = c*( fld[0][1] + 4.f*fld[1][1] + fld[2][1] )*dS; - syyy = syy*syy*syy / 1296.f; - syy = syy*syy/72.f; - - ssyy = ( fld[0][1]*( 38.f*fld[0][1] + 156.f*fld[1][1] - fld[2][1] )+ - fld[1][1]*( 208.f*fld[1][1] +16.f*fld[2][1] )+ - fld[2][1]*( 3.f*fld[2][1] ) - )*dS*dS*dS*c*c/2520.f; - ssyyy = - ( - fld[0][1]*( fld[0][1]*( 85.f*fld[0][1] + 526.f*fld[1][1] - 7.f*fld[2][1] )+ - fld[1][1]*( 1376.f*fld[1][1] +84.f*fld[2][1] )+ - fld[2][1]*( 19.f*fld[2][1] ) )+ - fld[1][1]*( fld[1][1]*( 1376.f*fld[1][1] +256.f*fld[2][1] )+ - fld[2][1]*( 62.f*fld[2][1] ) )+ - fld[2][1]*fld[2][1] *( 3.f*fld[2][1] ) - )*dS*dS*dS*dS*c*c*c/90720.f; - + sx = c * (fld[0][0] + 4 * fld[1][0] + fld[2][0]) * dS / 6.f; + sy = c * (fld[0][1] + 4 * fld[1][1] + fld[2][1]) * dS / 6.f; + sz = c * (fld[0][2] + 4 * fld[1][2] + fld[2][2]) * dS / 6.f; + + ssx = c * (fld[0][0] + 2 * fld[1][0]) * dS * dS / 6.f; + ssy = c * (fld[0][1] + 2 * fld[1][1]) * dS * dS / 6.f; + ssz = c * (fld[0][2] + 2 * fld[1][2]) * dS * dS / 6.f; + + float_v c2[3][3] = {{5.f, -4.f, -1.f}, {44.f, 80.f, -4.f}, {11.f, 44.f, 5.f}}; // /=360. + float_v cc2[3][3] = {{38.f, 8.f, -4.f}, {148.f, 208.f, -20.f}, {3.f, 36.f, 3.f}}; // /=2520. + for (Int_t n = 0; n < 3; n++) + for (Int_t m = 0; m < 3; m++) { + syz += c2[n][m] * fld[n][1] * fld[m][2]; + ssyz += cc2[n][m] * fld[n][1] * fld[m][2]; + } + + syz *= c * c * dS * dS / 360.f; + ssyz *= c * c * dS * dS * dS / 2520.f; + + syy = c * (fld[0][1] + 4.f * fld[1][1] + fld[2][1]) * dS; + syyy = syy * syy * syy / 1296.f; + syy = syy * syy / 72.f; + + ssyy = (fld[0][1] * (38.f * fld[0][1] + 156.f * fld[1][1] - fld[2][1]) + + fld[1][1] * (208.f * fld[1][1] + 16.f * fld[2][1]) + + fld[2][1] * (3.f * fld[2][1])) * + dS * dS * dS * c * c / 2520.f; + ssyyy = + (fld[0][1] * (fld[0][1] * (85.f * fld[0][1] + 526.f * fld[1][1] - 7.f * fld[2][1]) + + fld[1][1] * (1376.f * fld[1][1] + 84.f * fld[2][1]) + + fld[2][1] * (19.f * fld[2][1])) + + fld[1][1] * (fld[1][1] * (1376.f * fld[1][1] + 256.f * fld[2][1]) + + fld[2][1] * (62.f * fld[2][1])) + + fld[2][1] * fld[2][1] * (3.f * fld[2][1])) * + dS * dS * dS * dS * c * c * c / 90720.f; } -// float_v mJ[11]; -// -// mJ[0]=dS-ssyy; mJ[1]=ssx; mJ[2]=ssyyy-ssy; -// mJ[3]=-ssz; mJ[4]=dS; mJ[5]=ssx+ssyz; -// -// mJ[6]=1-syy; mJ[7]=sx; mJ[8]=syyy-sy; -// mJ[9]=-sz; mJ[10]=sx+syz; -// -// -// -// P[0] = fP[0] + mJ[0]*px + mJ[1]*py + mJ[2]*pz; -// P[1] = fP[1] + mJ[3]*px + mJ[4]*py + mJ[5]*pz; -// P[2] = fP[2] - mJ[2]*px - mJ[1]*py + mJ[0]*pz; -// P[3] = mJ[6]*px + mJ[7]*py + mJ[8]*pz; -// P[4] = mJ[9]*px + py + mJ[10]*pz; -// P[5] = -mJ[8]*px - mJ[7]*py + mJ[6]*pz; -// P[6] = fP[6]; -// P[7] = fP[7]; - -// if(C!=fC) -// { -// for(int iC=0; iC<36; iC++) -// C[iC] = fC[iC]; -// } -// -// multQSQt1( mJ, C); + // float_v mJ[11]; + // + // mJ[0]=dS-ssyy; mJ[1]=ssx; mJ[2]=ssyyy-ssy; + // mJ[3]=-ssz; mJ[4]=dS; mJ[5]=ssx+ssyz; + // + // mJ[6]=1-syy; mJ[7]=sx; mJ[8]=syyy-sy; + // mJ[9]=-sz; mJ[10]=sx+syz; + // + // + // + // P[0] = fP[0] + mJ[0]*px + mJ[1]*py + mJ[2]*pz; + // P[1] = fP[1] + mJ[3]*px + mJ[4]*py + mJ[5]*pz; + // P[2] = fP[2] - mJ[2]*px - mJ[1]*py + mJ[0]*pz; + // P[3] = mJ[6]*px + mJ[7]*py + mJ[8]*pz; + // P[4] = mJ[9]*px + py + mJ[10]*pz; + // P[5] = -mJ[8]*px - mJ[7]*py + mJ[6]*pz; + // P[6] = fP[6]; + // P[7] = fP[7]; + + // if(C!=fC) + // { + // for(int iC=0; iC<36; iC++) + // C[iC] = fC[iC]; + // } + // + // multQSQt1( mJ, C); float_v mJ[8][8]; - for( Int_t i=0; i<8; i++ ) for( Int_t j=0; j<8; j++) mJ[i][j]=0; - - mJ[0][0]=1; mJ[0][1]=0; mJ[0][2]=0; mJ[0][3]=dS-ssyy; mJ[0][4]=ssx; mJ[0][5]=ssyyy-ssy; - mJ[1][0]=0; mJ[1][1]=1; mJ[1][2]=0; mJ[1][3]=-ssz; mJ[1][4]=dS; mJ[1][5]=ssx+ssyz; - mJ[2][0]=0; mJ[2][1]=0; mJ[2][2]=1; mJ[2][3]=ssy-ssyyy; mJ[2][4]=-ssx; mJ[2][5]=dS-ssyy; - - mJ[3][0]=0; mJ[3][1]=0; mJ[3][2]=0; mJ[3][3]=1-syy; mJ[3][4]=sx; mJ[3][5]=syyy-sy; - mJ[4][0]=0; mJ[4][1]=0; mJ[4][2]=0; mJ[4][3]=-sz; mJ[4][4]=1; mJ[4][5]=sx+syz; - mJ[5][0]=0; mJ[5][1]=0; mJ[5][2]=0; mJ[5][3]=sy-syyy; mJ[5][4]=-sx; mJ[5][5]=1-syy; + for (Int_t i = 0; i < 8; i++) + for (Int_t j = 0; j < 8; j++) + mJ[i][j] = 0; + + mJ[0][0] = 1; + mJ[0][1] = 0; + mJ[0][2] = 0; + mJ[0][3] = dS - ssyy; + mJ[0][4] = ssx; + mJ[0][5] = ssyyy - ssy; + mJ[1][0] = 0; + mJ[1][1] = 1; + mJ[1][2] = 0; + mJ[1][3] = -ssz; + mJ[1][4] = dS; + mJ[1][5] = ssx + ssyz; + mJ[2][0] = 0; + mJ[2][1] = 0; + mJ[2][2] = 1; + mJ[2][3] = ssy - ssyyy; + mJ[2][4] = -ssx; + mJ[2][5] = dS - ssyy; + + mJ[3][0] = 0; + mJ[3][1] = 0; + mJ[3][2] = 0; + mJ[3][3] = 1 - syy; + mJ[3][4] = sx; + mJ[3][5] = syyy - sy; + mJ[4][0] = 0; + mJ[4][1] = 0; + mJ[4][2] = 0; + mJ[4][3] = -sz; + mJ[4][4] = 1; + mJ[4][5] = sx + syz; + mJ[5][0] = 0; + mJ[5][1] = 0; + mJ[5][2] = 0; + mJ[5][3] = sy - syyy; + mJ[5][4] = -sx; + mJ[5][5] = 1 - syy; mJ[6][6] = mJ[7][7] = 1; - - P[0] = fP[0] + mJ[0][3]*px + mJ[0][4]*py + mJ[0][5]*pz; - P[1] = fP[1] + mJ[1][3]*px + mJ[1][4]*py + mJ[1][5]*pz; - P[2] = fP[2] + mJ[2][3]*px + mJ[2][4]*py + mJ[2][5]*pz; - P[3] = mJ[3][3]*px + mJ[3][4]*py + mJ[3][5]*pz; - P[4] = mJ[4][3]*px + mJ[4][4]*py + mJ[4][5]*pz; - P[5] = mJ[5][3]*px + mJ[5][4]*py + mJ[5][5]*pz; + + P[0] = fP[0] + mJ[0][3] * px + mJ[0][4] * py + mJ[0][5] * pz; + P[1] = fP[1] + mJ[1][3] * px + mJ[1][4] * py + mJ[1][5] * pz; + P[2] = fP[2] + mJ[2][3] * px + mJ[2][4] * py + mJ[2][5] * pz; + P[3] = mJ[3][3] * px + mJ[3][4] * py + mJ[3][5] * pz; + P[4] = mJ[4][3] * px + mJ[4][4] * py + mJ[4][5] * pz; + P[5] = mJ[5][3] * px + mJ[5][4] * py + mJ[5][5] * pz; P[6] = fP[6]; P[7] = fP[7]; float_v mJds[6][6]; - for( Int_t i=0; i<6; i++ ) for( Int_t j=0; j<6; j++) mJds[i][j]=0; - - mJds[0][3]= 1.f; - mJds[1][4]= 1.f; - mJds[2][5]= 1.f; - - mJds[0][3](abs(dS)>0.f)= 1.f - 3.f*ssyy/dS; mJds[0][4](abs(dS)>0.f)= 2.f*ssx/dS; mJds[0][5](abs(dS)>0.f)= (4.f*ssyyy-2.f*ssy)/dS; - mJds[1][3](abs(dS)>0.f)= -2.f*ssz/dS; mJds[1][4](abs(dS)>0.f)= 1.f; mJds[1][5](abs(dS)>0.f)= (2.f*ssx + 3.f*ssyz)/dS; - mJds[2][3](abs(dS)>0.f)= (2.f*ssy-4.f*ssyyy)/dS; mJds[2][4](abs(dS)>0.f)=-2.f*ssx/dS; mJds[2][5](abs(dS)>0.f)= 1.f - 3.f*ssyy/dS; - - mJds[3][3](abs(dS)>0.f)= -2.f*syy/dS; mJds[3][4](abs(dS)>0.f)= sx/dS; mJds[3][5](abs(dS)>0.f)= 3.f*syyy/dS - sy/dS; - mJds[4][3](abs(dS)>0.f)= -sz/dS; mJds[4][4](abs(dS)>0.f)=0.f; mJds[4][5](abs(dS)>0.f) = sx/dS + 2.f*syz/dS; - mJds[5][3](abs(dS)>0.f)= sy/dS - 3.f*syyy/dS; mJds[5][4](abs(dS)>0.f)=-sx/dS; mJds[5][5](abs(dS)>0.f)= -2.f*syy/dS; - - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - mJ[i1][i2] += mJds[i1][3]*px*dsdr[i2] + mJds[i1][4]*py*dsdr[i2] + mJds[i1][5]*pz*dsdr[i2]; - - MultQSQt( mJ[0], fC, C, 8); - - if(F) - { - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - F[i*6+j] = mJ[i][j]; - - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - F1[i1*6 + i2] = mJds[i1][3]*px*dsdr1[i2] + mJds[i1][4]*py*dsdr1[i2] + mJds[i1][5]*pz*dsdr1[i2]; + for (Int_t i = 0; i < 6; i++) + for (Int_t j = 0; j < 6; j++) + mJds[i][j] = 0; + + mJds[0][3] = 1.f; + mJds[1][4] = 1.f; + mJds[2][5] = 1.f; + + mJds[0][3](abs(dS) > 0.f) = 1.f - 3.f * ssyy / dS; + mJds[0][4](abs(dS) > 0.f) = 2.f * ssx / dS; + mJds[0][5](abs(dS) > 0.f) = (4.f * ssyyy - 2.f * ssy) / dS; + mJds[1][3](abs(dS) > 0.f) = -2.f * ssz / dS; + mJds[1][4](abs(dS) > 0.f) = 1.f; + mJds[1][5](abs(dS) > 0.f) = (2.f * ssx + 3.f * ssyz) / dS; + mJds[2][3](abs(dS) > 0.f) = (2.f * ssy - 4.f * ssyyy) / dS; + mJds[2][4](abs(dS) > 0.f) = -2.f * ssx / dS; + mJds[2][5](abs(dS) > 0.f) = 1.f - 3.f * ssyy / dS; + + mJds[3][3](abs(dS) > 0.f) = -2.f * syy / dS; + mJds[3][4](abs(dS) > 0.f) = sx / dS; + mJds[3][5](abs(dS) > 0.f) = 3.f * syyy / dS - sy / dS; + mJds[4][3](abs(dS) > 0.f) = -sz / dS; + mJds[4][4](abs(dS) > 0.f) = 0.f; + mJds[4][5](abs(dS) > 0.f) = sx / dS + 2.f * syz / dS; + mJds[5][3](abs(dS) > 0.f) = sy / dS - 3.f * syyy / dS; + mJds[5][4](abs(dS) > 0.f) = -sx / dS; + mJds[5][5](abs(dS) > 0.f) = -2.f * syy / dS; + + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + + MultQSQt(mJ[0], fC, C, 8); + + if (F) { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) + F[i * 6 + j] = mJ[i][j]; + + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; } } -void KFParticleBaseSIMD::TransportCBM( float_v dS, float_v P[] ) const -{ +void KFParticleBaseSIMD::TransportCBM(float_v dS, float_v P[]) const +{ /** Transports the parameters of the current particle assuming CBM-like nonhomogeneous ** magnetic field on the length defined by the transport parameter dS = l/p, where l is the signed distance and p is ** the momentum of the current particle. The obtained parameters and covariance matrix are stored to the array P. @@ -3269,28 +3294,28 @@ void KFParticleBaseSIMD::TransportCBM( float_v dS, float_v P[] ) const ** case the particle parameters will be modified. ** \param[in] dS - transport parameter which defines the distance to which particle should be transported ** \param[out] P[8] - array, where transported parameters should be stored - **/ - if( (fQ == int_v(Vc::Zero)).isFull() ){ - TransportLine( dS, P ); + **/ + if ((fQ == int_v(Vc::Zero)).isFull()) { + TransportLine(dS, P); return; } const float_v kCLight = 0.000299792458f; - float_v c = simd_cast(fQ)*kCLight; + float_v c = simd_cast(fQ) * kCLight; - // construct coefficients + // construct coefficients - float_v - px = fP[3], - py = fP[4], - pz = fP[5]; - - float_v sx=0.f, sy=0.f, sz=0.f, syy=0.f, syz=0.f, syyy=0.f, ssx=0.f, ssy=0.f, ssz=0.f, ssyy=0.f, ssyz=0.f, ssyyy=0.f; + float_v + px = fP[3], + py = fP[4], + pz = fP[5]; + + float_v sx = 0.f, sy = 0.f, sz = 0.f, syy = 0.f, syz = 0.f, syyy = 0.f, ssx = 0.f, ssy = 0.f, ssz = 0.f, ssyy = 0.f, ssyz = 0.f, ssyyy = 0.f; { // get field integrals - float_v fld[3][3]; + float_v fld[3][3]; float_v p0[3], p1[3], p2[3]; // line track approximation @@ -3298,102 +3323,131 @@ void KFParticleBaseSIMD::TransportCBM( float_v dS, float_v P[] ) const p0[0] = fP[0]; p0[1] = fP[1]; p0[2] = fP[2]; - - p2[0] = fP[0] + px*dS; - p2[1] = fP[1] + py*dS; - p2[2] = fP[2] + pz*dS; - - p1[0] = 0.5f*(p0[0]+p2[0]); - p1[1] = 0.5f*(p0[1]+p2[1]); - p1[2] = 0.5f*(p0[2]+p2[2]); + + p2[0] = fP[0] + px * dS; + p2[1] = fP[1] + py * dS; + p2[2] = fP[2] + pz * dS; + + p1[0] = 0.5f * (p0[0] + p2[0]); + p1[1] = 0.5f * (p0[1] + p2[1]); + p1[2] = 0.5f * (p0[2] + p2[2]); // first order track approximation { - GetFieldValue( p0, fld[0] ); - GetFieldValue( p1, fld[1] ); - GetFieldValue( p2, fld[2] ); + GetFieldValue(p0, fld[0]); + GetFieldValue(p1, fld[1]); + GetFieldValue(p2, fld[2]); - float_v ssy1 = ( 7.f*fld[0][1] + 6.f*fld[1][1]-fld[2][1] )*c*dS*dS/96.f; - float_v ssy2 = ( fld[0][1] + 2.f*fld[1][1] )*c*dS*dS/6.f; + float_v ssy1 = (7.f * fld[0][1] + 6.f * fld[1][1] - fld[2][1]) * c * dS * dS / 96.f; + float_v ssy2 = (fld[0][1] + 2.f * fld[1][1]) * c * dS * dS / 6.f; - p1[0] -= ssy1*pz; - p1[2] += ssy1*px; - p2[0] -= ssy2*pz; - p2[2] += ssy2*px; + p1[0] -= ssy1 * pz; + p1[2] += ssy1 * px; + p2[0] -= ssy2 * pz; + p2[2] += ssy2 * px; } - GetFieldValue( p0, fld[0] ); - GetFieldValue( p1, fld[1] ); - GetFieldValue( p2, fld[2] ); + GetFieldValue(p0, fld[0]); + GetFieldValue(p1, fld[1]); + GetFieldValue(p2, fld[2]); - for(int iF1=0; iF1<3; iF1++) - for(int iF2=0; iF2<3; iF2++) + for (int iF1 = 0; iF1 < 3; iF1++) + for (int iF2 = 0; iF2 < 3; iF2++) fld[iF1][iF2](abs(fld[iF1][iF2]) > float_v(100.f)) = 0.f; - sx = c*( fld[0][0] + 4*fld[1][0] + fld[2][0] )*dS/6.f; - sy = c*( fld[0][1] + 4*fld[1][1] + fld[2][1] )*dS/6.f; - sz = c*( fld[0][2] + 4*fld[1][2] + fld[2][2] )*dS/6.f; - - ssx = c*( fld[0][0] + 2*fld[1][0])*dS*dS/6.f; - ssy = c*( fld[0][1] + 2*fld[1][1])*dS*dS/6.f; - ssz = c*( fld[0][2] + 2*fld[1][2])*dS*dS/6.f; - - float_v c2[3][3] = { { 5.f, -4.f, -1.f},{ 44.f, 80.f, -4.f},{ 11.f, 44.f, 5.f} }; // /=360. - float_v cc2[3][3] = { { 38.f, 8.f, -4.f},{ 148.f, 208.f, -20.f},{ 3.f, 36.f, 3.f} }; // /=2520. - for(Int_t n=0; n<3; n++) - for(Int_t m=0; m<3; m++) - { - syz += c2[n][m]*fld[n][1]*fld[m][2]; - ssyz += cc2[n][m]*fld[n][1]*fld[m][2]; - } - - syz *= c*c*dS*dS/360.f; - ssyz *= c*c*dS*dS*dS/2520.f; - - syy = c*( fld[0][1] + 4.f*fld[1][1] + fld[2][1] )*dS; - syyy = syy*syy*syy / 1296.f; - syy = syy*syy/72.f; - - ssyy = ( fld[0][1]*( 38.f*fld[0][1] + 156.f*fld[1][1] - fld[2][1] )+ - fld[1][1]*( 208.f*fld[1][1] +16.f*fld[2][1] )+ - fld[2][1]*( 3.f*fld[2][1] ) - )*dS*dS*dS*c*c/2520.f; - ssyyy = - ( - fld[0][1]*( fld[0][1]*( 85.f*fld[0][1] + 526.f*fld[1][1] - 7.f*fld[2][1] )+ - fld[1][1]*( 1376.f*fld[1][1] +84.f*fld[2][1] )+ - fld[2][1]*( 19.f*fld[2][1] ) )+ - fld[1][1]*( fld[1][1]*( 1376.f*fld[1][1] +256.f*fld[2][1] )+ - fld[2][1]*( 62.f*fld[2][1] ) )+ - fld[2][1]*fld[2][1] *( 3.f*fld[2][1] ) - )*dS*dS*dS*dS*c*c*c/90720.f; - + sx = c * (fld[0][0] + 4 * fld[1][0] + fld[2][0]) * dS / 6.f; + sy = c * (fld[0][1] + 4 * fld[1][1] + fld[2][1]) * dS / 6.f; + sz = c * (fld[0][2] + 4 * fld[1][2] + fld[2][2]) * dS / 6.f; + + ssx = c * (fld[0][0] + 2 * fld[1][0]) * dS * dS / 6.f; + ssy = c * (fld[0][1] + 2 * fld[1][1]) * dS * dS / 6.f; + ssz = c * (fld[0][2] + 2 * fld[1][2]) * dS * dS / 6.f; + + float_v c2[3][3] = {{5.f, -4.f, -1.f}, {44.f, 80.f, -4.f}, {11.f, 44.f, 5.f}}; // /=360. + float_v cc2[3][3] = {{38.f, 8.f, -4.f}, {148.f, 208.f, -20.f}, {3.f, 36.f, 3.f}}; // /=2520. + for (Int_t n = 0; n < 3; n++) + for (Int_t m = 0; m < 3; m++) { + syz += c2[n][m] * fld[n][1] * fld[m][2]; + ssyz += cc2[n][m] * fld[n][1] * fld[m][2]; + } + + syz *= c * c * dS * dS / 360.f; + ssyz *= c * c * dS * dS * dS / 2520.f; + + syy = c * (fld[0][1] + 4.f * fld[1][1] + fld[2][1]) * dS; + syyy = syy * syy * syy / 1296.f; + syy = syy * syy / 72.f; + + ssyy = (fld[0][1] * (38.f * fld[0][1] + 156.f * fld[1][1] - fld[2][1]) + + fld[1][1] * (208.f * fld[1][1] + 16.f * fld[2][1]) + + fld[2][1] * (3.f * fld[2][1])) * + dS * dS * dS * c * c / 2520.f; + ssyyy = + (fld[0][1] * (fld[0][1] * (85.f * fld[0][1] + 526.f * fld[1][1] - 7.f * fld[2][1]) + + fld[1][1] * (1376.f * fld[1][1] + 84.f * fld[2][1]) + + fld[2][1] * (19.f * fld[2][1])) + + fld[1][1] * (fld[1][1] * (1376.f * fld[1][1] + 256.f * fld[2][1]) + + fld[2][1] * (62.f * fld[2][1])) + + fld[2][1] * fld[2][1] * (3.f * fld[2][1])) * + dS * dS * dS * dS * c * c * c / 90720.f; } float_v mJ[8][8]; - for( Int_t i=0; i<8; i++ ) for( Int_t j=0; j<8; j++) mJ[i][j]=0; - - mJ[0][0]=1; mJ[0][1]=0; mJ[0][2]=0; mJ[0][3]=dS-ssyy; mJ[0][4]=ssx; mJ[0][5]=ssyyy-ssy; - mJ[1][0]=0; mJ[1][1]=1; mJ[1][2]=0; mJ[1][3]=-ssz; mJ[1][4]=dS; mJ[1][5]=ssx+ssyz; - mJ[2][0]=0; mJ[2][1]=0; mJ[2][2]=1; mJ[2][3]=ssy-ssyyy; mJ[2][4]=-ssx; mJ[2][5]=dS-ssyy; - - mJ[3][0]=0; mJ[3][1]=0; mJ[3][2]=0; mJ[3][3]=1-syy; mJ[3][4]=sx; mJ[3][5]=syyy-sy; - mJ[4][0]=0; mJ[4][1]=0; mJ[4][2]=0; mJ[4][3]=-sz; mJ[4][4]=1; mJ[4][5]=sx+syz; - mJ[5][0]=0; mJ[5][1]=0; mJ[5][2]=0; mJ[5][3]=sy-syyy; mJ[5][4]=-sx; mJ[5][5]=1-syy; + for (Int_t i = 0; i < 8; i++) + for (Int_t j = 0; j < 8; j++) + mJ[i][j] = 0; + + mJ[0][0] = 1; + mJ[0][1] = 0; + mJ[0][2] = 0; + mJ[0][3] = dS - ssyy; + mJ[0][4] = ssx; + mJ[0][5] = ssyyy - ssy; + mJ[1][0] = 0; + mJ[1][1] = 1; + mJ[1][2] = 0; + mJ[1][3] = -ssz; + mJ[1][4] = dS; + mJ[1][5] = ssx + ssyz; + mJ[2][0] = 0; + mJ[2][1] = 0; + mJ[2][2] = 1; + mJ[2][3] = ssy - ssyyy; + mJ[2][4] = -ssx; + mJ[2][5] = dS - ssyy; + + mJ[3][0] = 0; + mJ[3][1] = 0; + mJ[3][2] = 0; + mJ[3][3] = 1 - syy; + mJ[3][4] = sx; + mJ[3][5] = syyy - sy; + mJ[4][0] = 0; + mJ[4][1] = 0; + mJ[4][2] = 0; + mJ[4][3] = -sz; + mJ[4][4] = 1; + mJ[4][5] = sx + syz; + mJ[5][0] = 0; + mJ[5][1] = 0; + mJ[5][2] = 0; + mJ[5][3] = sy - syyy; + mJ[5][4] = -sx; + mJ[5][5] = 1 - syy; mJ[6][6] = mJ[7][7] = 1; - - P[0] = fP[0] + mJ[0][3]*px + mJ[0][4]*py + mJ[0][5]*pz; - P[1] = fP[1] + mJ[1][3]*px + mJ[1][4]*py + mJ[1][5]*pz; - P[2] = fP[2] + mJ[2][3]*px + mJ[2][4]*py + mJ[2][5]*pz; - P[3] = mJ[3][3]*px + mJ[3][4]*py + mJ[3][5]*pz; - P[4] = mJ[4][3]*px + mJ[4][4]*py + mJ[4][5]*pz; - P[5] = mJ[5][3]*px + mJ[5][4]*py + mJ[5][5]*pz; + + P[0] = fP[0] + mJ[0][3] * px + mJ[0][4] * py + mJ[0][5] * pz; + P[1] = fP[1] + mJ[1][3] * px + mJ[1][4] * py + mJ[1][5] * pz; + P[2] = fP[2] + mJ[2][3] * px + mJ[2][4] * py + mJ[2][5] * pz; + P[3] = mJ[3][3] * px + mJ[3][4] * py + mJ[3][5] * pz; + P[4] = mJ[4][3] * px + mJ[4][4] * py + mJ[4][5] * pz; + P[5] = mJ[5][3] * px + mJ[5][4] * py + mJ[5][5] * pz; P[6] = fP[6]; P[7] = fP[7]; } -void KFParticleBaseSIMD::TransportBz( float_v Bz, float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1, float_v* F, float_v* F1 ) const -{ +void KFParticleBaseSIMD::TransportBz(float_v Bz, float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1, float_v* F, float_v* F1) const +{ /** Transports the parameters and their covariance matrix of the current particle assuming constant homogeneous ** magnetic field Bz on the length defined by the transport parameter dS = l/p, where l is the signed distance and p is ** the momentum of the current particle. The obtained parameters and covariance matrix are stored to the arrays P and @@ -3414,76 +3468,87 @@ void KFParticleBaseSIMD::TransportBz( float_v Bz, float_v dS, const float_v* dsd ** \param[out] F[36] - optional parameter, transport jacobian, 6x6 matrix F = d(fP new)/d(fP old) ** \param[out] F1[36] - optional parameter, corelation 6x6 matrix betweeen the current particle and particle or vertex ** with the state vector r1, to which the current particle is being transported, F1 = d(fP new)/d(r1) - **/ - + **/ + const float_v kCLight = 0.000299792458f; - Bz = Bz*simd_cast(fQ)*kCLight; - float_v bs= Bz*dS; + Bz = Bz * simd_cast(fQ) * kCLight; + float_v bs = Bz * dS; float_v s = sin(bs), c = cos(bs); float_v sB(Vc::Zero), cB(Vc::Zero); - const float_v kOvSqr6 = 1.f/sqrt(float_v(6.f)); + const float_v kOvSqr6 = 1.f / sqrt(float_v(6.f)); const float_v LocalSmall = 1.e-10f; Bz(abs(bs) <= LocalSmall) = LocalSmall; - sB(LocalSmall < abs(bs)) = s/Bz; - sB(LocalSmall >= abs(bs)) = (1.f-bs*kOvSqr6)*(1.f+bs*kOvSqr6)*dS; - cB(LocalSmall < abs(bs)) = (1.f-c)/Bz; - cB(LocalSmall >= abs(bs)) = .5f*sB*bs; - + sB(LocalSmall < abs(bs)) = s / Bz; + sB(LocalSmall >= abs(bs)) = (1.f - bs * kOvSqr6) * (1.f + bs * kOvSqr6) * dS; + cB(LocalSmall < abs(bs)) = (1.f - c) / Bz; + cB(LocalSmall >= abs(bs)) = .5f * sB * bs; + float_v px = fP[3]; float_v py = fP[4]; float_v pz = fP[5]; - P[0] = fP[0] + sB*px + cB*py; - P[1] = fP[1] - cB*px + sB*py; - P[2] = fP[2] + dS*pz; - P[3] = c*px + s*py; - P[4] = -s*px + c*py; + P[0] = fP[0] + sB * px + cB * py; + P[1] = fP[1] - cB * px + sB * py; + P[2] = fP[2] + dS * pz; + P[3] = c * px + s * py; + P[4] = -s * px + c * py; P[5] = fP[5]; P[6] = fP[6]; P[7] = fP[7]; float_v mJ[8][8]; - for( Int_t i=0; i<8; i++ ) for( Int_t j=0; j<8; j++) mJ[i][j]=0; - - for(int i=0; i<8; i++) mJ[i][i]=1; - mJ[0][3] = sB; mJ[0][4] = cB; - mJ[1][3] = -cB; mJ[1][4] = sB; + for (Int_t i = 0; i < 8; i++) + for (Int_t j = 0; j < 8; j++) + mJ[i][j] = 0; + + for (int i = 0; i < 8; i++) + mJ[i][i] = 1; + mJ[0][3] = sB; + mJ[0][4] = cB; + mJ[1][3] = -cB; + mJ[1][4] = sB; mJ[2][5] = dS; - mJ[3][3] = c; mJ[3][4] = s; - mJ[4][3] = -s; mJ[4][4] = c; - - + mJ[3][3] = c; + mJ[3][4] = s; + mJ[4][3] = -s; + mJ[4][4] = c; + float_v mJds[6][6]; - for( Int_t i=0; i<6; i++ ) for( Int_t j=0; j<6; j++) mJds[i][j]=0; - mJds[0][3] = c; mJds[0][4] = s; - mJds[1][3] = -s; mJds[1][4] = c; + for (Int_t i = 0; i < 6; i++) + for (Int_t j = 0; j < 6; j++) + mJds[i][j] = 0; + mJds[0][3] = c; + mJds[0][4] = s; + mJds[1][3] = -s; + mJds[1][4] = c; mJds[2][5] = 1; - mJds[3][3] = -Bz*s; mJds[3][4] = Bz*c; - mJds[4][3] = -Bz*c; mJds[4][4] = -Bz*s; - - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - mJ[i1][i2] += mJds[i1][3]*px*dsdr[i2] + mJds[i1][4]*py*dsdr[i2] + mJds[i1][5]*pz*dsdr[i2]; - - MultQSQt( mJ[0], fC, C, 8); - - if(F) - { - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - F[i*6+j] = mJ[i][j]; + mJds[3][3] = -Bz * s; + mJds[3][4] = Bz * c; + mJds[4][3] = -Bz * c; + mJds[4][4] = -Bz * s; - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - F1[i1*6 + i2] = mJds[i1][3]*px*dsdr1[i2] + mJds[i1][4]*py*dsdr1[i2] + mJds[i1][5]*pz*dsdr1[i2]; + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + + MultQSQt(mJ[0], fC, C, 8); + + if (F) { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) + F[i * 6 + j] = mJ[i][j]; + + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; } } -void KFParticleBaseSIMD::TransportBz( float_v Bz, float_v dS, float_v P[] ) const -{ +void KFParticleBaseSIMD::TransportBz(float_v Bz, float_v dS, float_v P[]) const +{ /** Transports the parameters of the current particle assuming constant homogeneous ** magnetic field Bz on the length defined by the transport parameter dS = l/p, where l is the signed distance and p is ** the momentum of the current particle. The obtained parameters are stored to the array P. @@ -3492,91 +3557,88 @@ void KFParticleBaseSIMD::TransportBz( float_v Bz, float_v dS, float_v P[] ) cons ** \param[in] Bz - z-component of the constant homogeneous magnetic field Bz ** \param[in] dS - transport parameter which defines the distance to which particle should be transported ** \param[out] P[8] - array, where transported parameters should be stored - **/ - + **/ + const float_v kCLight = 0.000299792458f; - Bz = Bz*simd_cast(fQ)*kCLight; - float_v bs= Bz*dS; + Bz = Bz * simd_cast(fQ) * kCLight; + float_v bs = Bz * dS; float_v s = KFPMath::Sin(bs), c = KFPMath::Cos(bs); float_v sB(Vc::Zero), cB(Vc::Zero); - const float_v kOvSqr6 = 1.f/sqrt(float_v(6.f)); + const float_v kOvSqr6 = 1.f / sqrt(float_v(6.f)); const float_v LocalSmall = 1.e-10f; Bz(abs(bs) <= LocalSmall) = LocalSmall; - sB(LocalSmall < abs(bs)) = s/Bz; - sB(LocalSmall >= abs(bs)) = (1.f-bs*kOvSqr6)*(1.f+bs*kOvSqr6)*dS; - cB(LocalSmall < abs(bs)) = (1.f-c)/Bz; - cB(LocalSmall >= abs(bs)) = .5f*sB*bs; - + sB(LocalSmall < abs(bs)) = s / Bz; + sB(LocalSmall >= abs(bs)) = (1.f - bs * kOvSqr6) * (1.f + bs * kOvSqr6) * dS; + cB(LocalSmall < abs(bs)) = (1.f - c) / Bz; + cB(LocalSmall >= abs(bs)) = .5f * sB * bs; + float_v px = fP[3]; float_v py = fP[4]; float_v pz = fP[5]; - P[0] = fP[0] + sB*px + cB*py; - P[1] = fP[1] - cB*px + sB*py; - P[2] = fP[2] + dS*pz; - P[3] = c*px + s*py; - P[4] = -s*px + c*py; + P[0] = fP[0] + sB * px + cB * py; + P[1] = fP[1] - cB * px + sB * py; + P[2] = fP[2] + dS * pz; + P[3] = c * px + s * py; + P[4] = -s * px + c * py; P[5] = fP[5]; P[6] = fP[6]; P[7] = fP[7]; } - - -float_v KFParticleBaseSIMD::GetDistanceFromVertex( const KFParticleBaseSIMD &Vtx ) const +float_v KFParticleBaseSIMD::GetDistanceFromVertex(const KFParticleBaseSIMD& Vtx) const { /** Returns the DCA distance from vertex in the KFParticle format in 3D. ** \param[in] Vtx - the vertex in the KFParticle format **/ - - return GetDistanceFromVertex( Vtx.fP ); + + return GetDistanceFromVertex(Vtx.fP); } -float_v KFParticleBaseSIMD::GetDistanceFromVertex( const float_v vtx[] ) const +float_v KFParticleBaseSIMD::GetDistanceFromVertex(const float_v vtx[]) const { /** Returns the DCA distance from vertex in 3D. ** \param[in] vtx[3] - the vertex coordinates {X, Y, Z} **/ - - float_v mP[8], mC[36]; - float_v dsdr[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; + + float_v mP[8], mC[36]; + float_v dsdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; const float_v dS = GetDStoPoint(vtx, dsdr); - Transport( dS, dsdr, mP, mC ); - float_v d[3]={ vtx[0]-mP[0], vtx[1]-mP[1], vtx[2]-mP[2]}; - return sqrt( d[0]*d[0]+d[1]*d[1]+d[2]*d[2] ); + Transport(dS, dsdr, mP, mC); + float_v d[3] = {vtx[0] - mP[0], vtx[1] - mP[1], vtx[2] - mP[2]}; + return sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); } -float_v KFParticleBaseSIMD::GetDistanceFromParticle( const KFParticleBaseSIMD &p ) const -{ +float_v KFParticleBaseSIMD::GetDistanceFromParticle(const KFParticleBaseSIMD& p) const +{ /** Returns the DCA distance from another particle p. ** \param[in] p - the second particle **/ - + float_v dS[2]; - GetDStoParticleFast( p, dS ); + GetDStoParticleFast(p, dS); float_v mP[8], mP1[8]; - TransportFast( dS[0], mP ); - p.TransportFast( dS[1], mP1 ); - float_v dx = mP[0]-mP1[0]; - float_v dy = mP[1]-mP1[1]; - float_v dz = mP[2]-mP1[2]; - return sqrt(dx*dx+dy*dy+dz*dz); + TransportFast(dS[0], mP); + p.TransportFast(dS[1], mP1); + float_v dx = mP[0] - mP1[0]; + float_v dy = mP[1] - mP1[1]; + float_v dz = mP[2] - mP1[2]; + return sqrt(dx * dx + dy * dy + dz * dz); } -float_v KFParticleBaseSIMD::GetDeviationFromVertex( const KFParticleBaseSIMD &Vtx ) const +float_v KFParticleBaseSIMD::GetDeviationFromVertex(const KFParticleBaseSIMD& Vtx) const { /** Returns Chi2 deviation of the current particle from the vertex in the KFParticle format in 3D. ** \param[in] Vtx - the vertex in KFPartcile format **/ - - return GetDeviationFromVertex( Vtx.fP, Vtx.fC ); -} + return GetDeviationFromVertex(Vtx.fP, Vtx.fC); +} -float_v KFParticleBaseSIMD::GetDeviationFromVertex( const float_v v[], const float_v Cv[] ) const +float_v KFParticleBaseSIMD::GetDeviationFromVertex(const float_v v[], const float_v Cv[]) const { /** Returns Chi2 deviation of the current particle from the vertex v with the covariance matrix Cv in 3D. ** \param[in] v[3] - coordinates of the vertex {X, Y, Z} @@ -3585,38 +3647,32 @@ float_v KFParticleBaseSIMD::GetDeviationFromVertex( const float_v v[], const flo float_v mP[8]; float_v mC[36]; - float_v dsdr[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; + float_v dsdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; const float_v dS = GetDStoPoint(v, dsdr); float_v dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0.f, 0.f, 0.f}; float_v F[36], F1[36]; - for(int i2=0; i2<36; i2++) - { - F[i2] = 0.f; + for (int i2 = 0; i2 < 36; i2++) { + F[i2] = 0.f; F1[i2] = 0.f; } - Transport( dS, dsdr, mP, mC, dsdp, F, F1 ); + Transport(dS, dsdr, mP, mC, dsdp, F, F1); - if(Cv) - { + if (Cv) { float_v VFT[3][6]; - for(int i=0; i<3; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 6; j++) { VFT[i][j] = 0; - for(int k=0; k<3; k++) - { - VFT[i][j] += Cv[IJ(i,k)] * F1[j*6+k]; + for (int k = 0; k < 3; k++) { + VFT[i][j] += Cv[IJ(i, k)] * F1[j * 6 + k]; } } - + float_v FVFT[6][6]; - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) { FVFT[i][j] = 0; - for(int k=0; k<3; k++) - { - FVFT[i][j] += F1[i*6+k] * VFT[k][j]; + for (int k = 0; k < 3; k++) { + FVFT[i][j] += F1[i * 6 + k] * VFT[k][j]; } } mC[0] += FVFT[0][0] + Cv[0]; @@ -3626,170 +3682,182 @@ float_v KFParticleBaseSIMD::GetDeviationFromVertex( const float_v v[], const flo mC[4] += FVFT[2][1] + Cv[4]; mC[5] += FVFT[2][2] + Cv[5]; } - + InvertCholetsky3(mC); - - float_v d[3]={ v[0]-mP[0], v[1]-mP[1], v[2]-mP[2]}; - return ( ( mC[0]*d[0] + mC[1]*d[1] + mC[3]*d[2])*d[0] - +(mC[1]*d[0] + mC[2]*d[1] + mC[4]*d[2])*d[1] - +(mC[3]*d[0] + mC[4]*d[1] + mC[5]*d[2])*d[2] ); + float_v d[3] = {v[0] - mP[0], v[1] - mP[1], v[2] - mP[2]}; + + return ((mC[0] * d[0] + mC[1] * d[1] + mC[3] * d[2]) * d[0] + (mC[1] * d[0] + mC[2] * d[1] + mC[4] * d[2]) * d[1] + (mC[3] * d[0] + mC[4] * d[1] + mC[5] * d[2]) * d[2]); } -float_v KFParticleBaseSIMD::GetDeviationFromParticle( const KFParticleBaseSIMD &p ) const -{ +float_v KFParticleBaseSIMD::GetDeviationFromParticle(const KFParticleBaseSIMD& p) const +{ /** Returns Chi2 deviation of the current particle from another particle in 3D. ** \param[in] p - the second particle **/ - - float_v ds[2] = {0.f,0.f}; + + float_v ds[2] = {0.f, 0.f}; float_v dsdr[4][6]; float_v F1[36], F2[36], F3[36], F4[36]; - for(int i1=0; i1<36; i1++) - { + for (int i1 = 0; i1 < 36; i1++) { F1[i1] = 0; F2[i1] = 0; F3[i1] = 0; F4[i1] = 0; } - GetDStoParticle( p, ds, dsdr ); - - float_v V0Tmp[36] ; - float_v V1Tmp[36] ; + GetDStoParticle(p, ds, dsdr); + + float_v V0Tmp[36]; + float_v V1Tmp[36]; - float_v mP1[8], mC1[36]; - float_v mP2[8], mC2[36]; - - Transport(ds[0], dsdr[0], mP1, mC1, dsdr[1], F1, F2); + float_v mP2[8], mC2[36]; + + Transport(ds[0], dsdr[0], mP1, mC1, dsdr[1], F1, F2); p.Transport(ds[1], dsdr[3], mP2, mC2, dsdr[2], F4, F3); - + MultQSQt(F2, p.fC, V0Tmp, 6); - MultQSQt(F3, fC, V1Tmp, 6); - - for(int iC=0; iC<6; iC++) + MultQSQt(F3, fC, V1Tmp, 6); + + for (int iC = 0; iC < 6; iC++) mC1[iC] += V0Tmp[iC] + mC2[iC] + V1Tmp[iC]; - float_v d[3]={ mP2[0]-mP1[0], mP2[1]-mP1[1], mP2[2]-mP1[2]}; - - return ( ( mC1[0]*d[0] + mC1[1]*d[1] + mC1[3]*d[2])*d[0] - +(mC1[1]*d[0] + mC1[2]*d[1] + mC1[4]*d[2])*d[1] - +(mC1[3]*d[0] + mC1[4]*d[1] + mC1[5]*d[2])*d[2] ); + float_v d[3] = {mP2[0] - mP1[0], mP2[1] - mP1[1], mP2[2] - mP1[2]}; + + return ((mC1[0] * d[0] + mC1[1] * d[1] + mC1[3] * d[2]) * d[0] + (mC1[1] * d[0] + mC1[2] * d[1] + mC1[4] * d[2]) * d[1] + (mC1[3] * d[0] + mC1[4] * d[1] + mC1[5] * d[2]) * d[2]); } -void KFParticleBaseSIMD::SubtractFromVertex( KFParticleBaseSIMD &Vtx ) const +void KFParticleBaseSIMD::SubtractFromVertex(KFParticleBaseSIMD& Vtx) const { /** Subtract the current particle from vertex Vtx using the Kalman filter mathematics. ** \param[in] Vtx - vertex from which particle should be subtracted **/ - + float_v m[8]; float_v mCm[36]; float_v D[3][3]; - Vtx.GetMeasurement( *this, m, mCm, D ); - //* - - float_v mS[6] = { mCm[0] - Vtx.fC[0] + (D[0][0] + D[0][0]), - mCm[1] - Vtx.fC[1] + (D[1][0] + D[0][1]), mCm[2] - Vtx.fC[2] + (D[1][1] + D[1][1]), - mCm[3] - Vtx.fC[3] + (D[2][0] + D[0][2]), mCm[4] - Vtx.fC[4] + (D[1][2] + D[2][1]), mCm[5] - Vtx.fC[5] + (D[2][2] + D[2][2]) }; - InvertCholetsky3(mS); - + Vtx.GetMeasurement(*this, m, mCm, D); + //* + + float_v mS[6] = {mCm[0] - Vtx.fC[0] + (D[0][0] + D[0][0]), + mCm[1] - Vtx.fC[1] + (D[1][0] + D[0][1]), mCm[2] - Vtx.fC[2] + (D[1][1] + D[1][1]), + mCm[3] - Vtx.fC[3] + (D[2][0] + D[0][2]), mCm[4] - Vtx.fC[4] + (D[1][2] + D[2][1]), mCm[5] - Vtx.fC[5] + (D[2][2] + D[2][2])}; + InvertCholetsky3(mS); + //* Residual (measured - estimated) - - float_v zeta[3] = { m[0]-Vtx.fP[0], m[1]-Vtx.fP[1], m[2]-Vtx.fP[2] }; - + + float_v zeta[3] = {m[0] - Vtx.fP[0], m[1] - Vtx.fP[1], m[2] - Vtx.fP[2]}; + //* mCHt = mCH' - D' - + float_v mCHt0[3], mCHt1[3], mCHt2[3]; - - mCHt0[0]=Vtx.fC[ 0] ; mCHt1[0]=Vtx.fC[ 1] ; mCHt2[0]=Vtx.fC[ 3] ; - mCHt0[1]=Vtx.fC[ 1] ; mCHt1[1]=Vtx.fC[ 2] ; mCHt2[1]=Vtx.fC[ 4] ; - mCHt0[2]=Vtx.fC[ 3] ; mCHt1[2]=Vtx.fC[ 4] ; mCHt2[2]=Vtx.fC[ 5] ; - + + mCHt0[0] = Vtx.fC[0]; + mCHt1[0] = Vtx.fC[1]; + mCHt2[0] = Vtx.fC[3]; + mCHt0[1] = Vtx.fC[1]; + mCHt1[1] = Vtx.fC[2]; + mCHt2[1] = Vtx.fC[4]; + mCHt0[2] = Vtx.fC[3]; + mCHt1[2] = Vtx.fC[4]; + mCHt2[2] = Vtx.fC[5]; + //* Kalman gain K = mCH'*S - + float_v k0[3], k1[3], k2[3]; - - for(Int_t i=0;i<3;++i){ - k0[i] = mCHt0[i]*mS[0] + mCHt1[i]*mS[1] + mCHt2[i]*mS[3]; - k1[i] = mCHt0[i]*mS[1] + mCHt1[i]*mS[2] + mCHt2[i]*mS[4]; - k2[i] = mCHt0[i]*mS[3] + mCHt1[i]*mS[4] + mCHt2[i]*mS[5]; + + for (Int_t i = 0; i < 3; ++i) { + k0[i] = mCHt0[i] * mS[0] + mCHt1[i] * mS[1] + mCHt2[i] * mS[3]; + k1[i] = mCHt0[i] * mS[1] + mCHt1[i] * mS[2] + mCHt2[i] * mS[4]; + k2[i] = mCHt0[i] * mS[3] + mCHt1[i] * mS[4] + mCHt2[i] * mS[5]; } - + //* New estimation of the vertex position r += K*zeta - - float_v dChi2 = ((mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0] - + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1] - + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2]); - for(Int_t i=0;i<3;++i) - Vtx.fP[i] -= k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]; - + float_v dChi2 = ((mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]); + + for (Int_t i = 0; i < 3; ++i) + Vtx.fP[i] -= k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + //* New covariance matrix C -= K*(mCH')' - - for(Int_t i=0, k=0;i<3;++i){ - for(Int_t j=0;j<=i;++j,++k) - Vtx.fC[k] += k0[i]*mCHt0[j] + k1[i]*mCHt1[j] + k2[i]*mCHt2[j]; + + for (Int_t i = 0, k = 0; i < 3; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) + Vtx.fC[k] += k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]; } - - //* Calculate Chi^2 - Vtx.fNDF -= 2; + //* Calculate Chi^2 + + Vtx.fNDF -= 2; Vtx.fChi2 -= dChi2; } -void KFParticleBaseSIMD::SubtractFromParticle( KFParticleBaseSIMD &Vtx ) const +void KFParticleBaseSIMD::SubtractFromParticle(KFParticleBaseSIMD& Vtx) const { /** Subtract the current particle from another particle Vtx using the Kalman filter mathematics. ** The function is depricated and is kept for compatibility reasons. Should be replaced with SubtractDaughter(). ** \param[in] Vtx - particle from which the current particle should be subtracted **/ - + float_v m[8]; float_v mV[36]; float_v D[3][3]; - Vtx.GetMeasurement( *this, m, mV, D ); + Vtx.GetMeasurement(*this, m, mV, D); - float_v mS[6] = { mV[0] - Vtx.fC[0] + (D[0][0] + D[0][0]), - mV[1] - Vtx.fC[1] + (D[1][0] + D[0][1]), mV[2] - Vtx.fC[2] + (D[1][1] + D[1][1]), - mV[3] - Vtx.fC[3] + (D[2][0] + D[0][2]), mV[4] - Vtx.fC[4] + (D[1][2] + D[2][1]), mV[5] - Vtx.fC[5] + (D[2][2] + D[2][2]) }; + float_v mS[6] = {mV[0] - Vtx.fC[0] + (D[0][0] + D[0][0]), + mV[1] - Vtx.fC[1] + (D[1][0] + D[0][1]), mV[2] - Vtx.fC[2] + (D[1][1] + D[1][1]), + mV[3] - Vtx.fC[3] + (D[2][0] + D[0][2]), mV[4] - Vtx.fC[4] + (D[1][2] + D[2][1]), mV[5] - Vtx.fC[5] + (D[2][2] + D[2][2])}; InvertCholetsky3(mS); //* Residual (measured - estimated) - float_v zeta[3] = { m[0]-Vtx.fP[0], m[1]-Vtx.fP[1], m[2]-Vtx.fP[2] }; + float_v zeta[3] = {m[0] - Vtx.fP[0], m[1] - Vtx.fP[1], m[2] - Vtx.fP[2]}; //* CHt = CH' - D' float_v mCHt0[7], mCHt1[7], mCHt2[7]; - mCHt0[0]=mV[ 0] ; mCHt1[0]=mV[ 1] ; mCHt2[0]=mV[ 3] ; - mCHt0[1]=mV[ 1] ; mCHt1[1]=mV[ 2] ; mCHt2[1]=mV[ 4] ; - mCHt0[2]=mV[ 3] ; mCHt1[2]=mV[ 4] ; mCHt2[2]=mV[ 5] ; - mCHt0[3]=Vtx.fC[ 6]-mV[ 6]; mCHt1[3]=Vtx.fC[ 7]-mV[ 7]; mCHt2[3]=Vtx.fC[ 8]-mV[ 8]; - mCHt0[4]=Vtx.fC[10]-mV[10]; mCHt1[4]=Vtx.fC[11]-mV[11]; mCHt2[4]=Vtx.fC[12]-mV[12]; - mCHt0[5]=Vtx.fC[15]-mV[15]; mCHt1[5]=Vtx.fC[16]-mV[16]; mCHt2[5]=Vtx.fC[17]-mV[17]; - mCHt0[6]=Vtx.fC[21]-mV[21]; mCHt1[6]=Vtx.fC[22]-mV[22]; mCHt2[6]=Vtx.fC[23]-mV[23]; + mCHt0[0] = mV[0]; + mCHt1[0] = mV[1]; + mCHt2[0] = mV[3]; + mCHt0[1] = mV[1]; + mCHt1[1] = mV[2]; + mCHt2[1] = mV[4]; + mCHt0[2] = mV[3]; + mCHt1[2] = mV[4]; + mCHt2[2] = mV[5]; + mCHt0[3] = Vtx.fC[6] - mV[6]; + mCHt1[3] = Vtx.fC[7] - mV[7]; + mCHt2[3] = Vtx.fC[8] - mV[8]; + mCHt0[4] = Vtx.fC[10] - mV[10]; + mCHt1[4] = Vtx.fC[11] - mV[11]; + mCHt2[4] = Vtx.fC[12] - mV[12]; + mCHt0[5] = Vtx.fC[15] - mV[15]; + mCHt1[5] = Vtx.fC[16] - mV[16]; + mCHt2[5] = Vtx.fC[17] - mV[17]; + mCHt0[6] = Vtx.fC[21] - mV[21]; + mCHt1[6] = Vtx.fC[22] - mV[22]; + mCHt2[6] = Vtx.fC[23] - mV[23]; //* Kalman gain K = mCH'*S - + float_v k0[7], k1[7], k2[7]; - - for(Int_t i=0;i<7;++i){ - k0[i] = mCHt0[i]*mS[0] + mCHt1[i]*mS[1] + mCHt2[i]*mS[3]; - k1[i] = mCHt0[i]*mS[1] + mCHt1[i]*mS[2] + mCHt2[i]*mS[4]; - k2[i] = mCHt0[i]*mS[3] + mCHt1[i]*mS[4] + mCHt2[i]*mS[5]; + + for (Int_t i = 0; i < 7; ++i) { + k0[i] = mCHt0[i] * mS[0] + mCHt1[i] * mS[1] + mCHt2[i] * mS[3]; + k1[i] = mCHt0[i] * mS[1] + mCHt1[i] * mS[2] + mCHt2[i] * mS[4]; + k2[i] = mCHt0[i] * mS[3] + mCHt1[i] * mS[4] + mCHt2[i] * mS[5]; } - //* Add the daughter momentum to the particle momentum - - Vtx.fP[ 3] -= m[ 3]; - Vtx.fP[ 4] -= m[ 4]; - Vtx.fP[ 5] -= m[ 5]; - Vtx.fP[ 6] -= m[ 6]; - - Vtx.fC[ 9] -= mV[ 9]; + //* Add the daughter momentum to the particle momentum + + Vtx.fP[3] -= m[3]; + Vtx.fP[4] -= m[4]; + Vtx.fP[5] -= m[5]; + Vtx.fP[6] -= m[6]; + + Vtx.fC[9] -= mV[9]; Vtx.fC[13] -= mV[13]; Vtx.fC[14] -= mV[14]; Vtx.fC[18] -= mV[18]; @@ -3800,39 +3868,37 @@ void KFParticleBaseSIMD::SubtractFromParticle( KFParticleBaseSIMD &Vtx ) const Vtx.fC[26] -= mV[26]; Vtx.fC[27] -= mV[27]; - //* New estimation of the vertex position r += K*zeta - - for(Int_t i=0;i<3;++i) - Vtx.fP[i] = m[i] - (k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]); - for(Int_t i=3;i<7;++i) - Vtx.fP[i] = Vtx.fP[i] - (k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]); + //* New estimation of the vertex position r += K*zeta - //* New covariance matrix C -= K*(mCH')' + for (Int_t i = 0; i < 3; ++i) + Vtx.fP[i] = m[i] - (k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]); + for (Int_t i = 3; i < 7; ++i) + Vtx.fP[i] = Vtx.fP[i] - (k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]); + + //* New covariance matrix C -= K*(mCH')' - float_v ffC[28] = {-mV[ 0], - -mV[ 1], -mV[ 2], - -mV[ 3], -mV[ 4], -mV[ 5], - mV[ 6], mV[ 7], mV[ 8], Vtx.fC[ 9], - mV[10], mV[11], mV[12], Vtx.fC[13], Vtx.fC[14], - mV[15], mV[16], mV[17], Vtx.fC[18], Vtx.fC[19], Vtx.fC[20], - mV[21], mV[22], mV[23], Vtx.fC[24], Vtx.fC[25], Vtx.fC[26], Vtx.fC[27] }; - - for(Int_t i=0, k=0;i<7;++i){ - for(Int_t j=0;j<=i;++j,++k){ - Vtx.fC[k] = ffC[k] + (k0[i]*mCHt0[j] + k1[i]*mCHt1[j] + k2[i]*mCHt2[j] ); + float_v ffC[28] = {-mV[0], + -mV[1], -mV[2], + -mV[3], -mV[4], -mV[5], + mV[6], mV[7], mV[8], Vtx.fC[9], + mV[10], mV[11], mV[12], Vtx.fC[13], Vtx.fC[14], + mV[15], mV[16], mV[17], Vtx.fC[18], Vtx.fC[19], Vtx.fC[20], + mV[21], mV[22], mV[23], Vtx.fC[24], Vtx.fC[25], Vtx.fC[26], Vtx.fC[27]}; + + for (Int_t i = 0, k = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j, ++k) { + Vtx.fC[k] = ffC[k] + (k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]); } } - //* Calculate Chi^2 - Vtx.fNDF -= 2; - Vtx.fQ -= GetQ(); - Vtx.fSFromDecay = 0; - Vtx.fChi2 -= ((mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0] - + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1] - + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2]); + //* Calculate Chi^2 + Vtx.fNDF -= 2; + Vtx.fQ -= GetQ(); + Vtx.fSFromDecay = 0; + Vtx.fChi2 -= ((mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]); } -void KFParticleBaseSIMD::TransportLine( float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1, float_v* F, float_v* F1 ) const +void KFParticleBaseSIMD::TransportLine(float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1, float_v* F, float_v* F1) const { /** Transports the parameters and their covariance matrix of the current particle assuming the straight line trajectory ** on the length defined by the transport parameter dS = l/p, where l is the signed distance and p is @@ -3854,55 +3920,88 @@ void KFParticleBaseSIMD::TransportLine( float_v dS, const float_v* dsdr, float_v ** \param[out] F1[36] - optional parameter, corelation 6x6 matrix betweeen the current particle and particle or vertex ** with the state vector r1, to which the current particle is being transported, F1 = d(fP new)/d(r1) **/ - + float_v mJ[8][8]; - for( Int_t i=0; i<8; i++ ) for( Int_t j=0; j<8; j++) mJ[i][j]=0; - - mJ[0][0]=1; mJ[0][1]=0; mJ[0][2]=0; mJ[0][3]=dS; mJ[0][4]=0; mJ[0][5]=0; - mJ[1][0]=0; mJ[1][1]=1; mJ[1][2]=0; mJ[1][3]=0; mJ[1][4]=dS; mJ[1][5]=0; - mJ[2][0]=0; mJ[2][1]=0; mJ[2][2]=1; mJ[2][3]=0; mJ[2][4]=0; mJ[2][5]=dS; - - mJ[3][0]=0; mJ[3][1]=0; mJ[3][2]=0; mJ[3][3]=1; mJ[3][4]=0; mJ[3][5]=0; - mJ[4][0]=0; mJ[4][1]=0; mJ[4][2]=0; mJ[4][3]=0; mJ[4][4]=1; mJ[4][5]=0; - mJ[5][0]=0; mJ[5][1]=0; mJ[5][2]=0; mJ[5][3]=0; mJ[5][4]=0; mJ[5][5]=1; + for (Int_t i = 0; i < 8; i++) + for (Int_t j = 0; j < 8; j++) + mJ[i][j] = 0; + + mJ[0][0] = 1; + mJ[0][1] = 0; + mJ[0][2] = 0; + mJ[0][3] = dS; + mJ[0][4] = 0; + mJ[0][5] = 0; + mJ[1][0] = 0; + mJ[1][1] = 1; + mJ[1][2] = 0; + mJ[1][3] = 0; + mJ[1][4] = dS; + mJ[1][5] = 0; + mJ[2][0] = 0; + mJ[2][1] = 0; + mJ[2][2] = 1; + mJ[2][3] = 0; + mJ[2][4] = 0; + mJ[2][5] = dS; + + mJ[3][0] = 0; + mJ[3][1] = 0; + mJ[3][2] = 0; + mJ[3][3] = 1; + mJ[3][4] = 0; + mJ[3][5] = 0; + mJ[4][0] = 0; + mJ[4][1] = 0; + mJ[4][2] = 0; + mJ[4][3] = 0; + mJ[4][4] = 1; + mJ[4][5] = 0; + mJ[5][0] = 0; + mJ[5][1] = 0; + mJ[5][2] = 0; + mJ[5][3] = 0; + mJ[5][4] = 0; + mJ[5][5] = 1; mJ[6][6] = mJ[7][7] = 1; - + float_v px = fP[3], py = fP[4], pz = fP[5]; - - P[0] = fP[0] + dS*fP[3]; - P[1] = fP[1] + dS*fP[4]; - P[2] = fP[2] + dS*fP[5]; + + P[0] = fP[0] + dS * fP[3]; + P[1] = fP[1] + dS * fP[4]; + P[2] = fP[2] + dS * fP[5]; P[3] = fP[3]; P[4] = fP[4]; P[5] = fP[5]; P[6] = fP[6]; P[7] = fP[7]; - + float_v mJds[6][6]; - for( Int_t i=0; i<6; i++ ) for( Int_t j=0; j<6; j++) mJds[i][j]=0; - - mJds[0][3]= 1; - mJds[1][4]= 1; - mJds[2][5]= 1; - - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - mJ[i1][i2] += mJds[i1][3]*px*dsdr[i2] + mJds[i1][4]*py*dsdr[i2] + mJds[i1][5]*pz*dsdr[i2]; - MultQSQt( mJ[0], fC, C, 8); - - if(F) - { - for(int i=0; i<6; i++) - for(int j=0; j<6; j++) - F[i*6+j] = mJ[i][j]; + for (Int_t i = 0; i < 6; i++) + for (Int_t j = 0; j < 6; j++) + mJds[i][j] = 0; + + mJds[0][3] = 1; + mJds[1][4] = 1; + mJds[2][5] = 1; + + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + MultQSQt(mJ[0], fC, C, 8); + + if (F) { + for (int i = 0; i < 6; i++) + for (int j = 0; j < 6; j++) + F[i * 6 + j] = mJ[i][j]; - for(int i1=0; i1<6; i1++) - for(int i2=0; i2<6; i2++) - F1[i1*6 + i2] = mJds[i1][3]*px*dsdr1[i2] + mJds[i1][4]*py*dsdr1[i2] + mJds[i1][5]*pz*dsdr1[i2]; + for (int i1 = 0; i1 < 6; i1++) + for (int i2 = 0; i2 < 6; i2++) + F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; } } -void KFParticleBaseSIMD::TransportLine( float_v dS, float_v P[] ) const +void KFParticleBaseSIMD::TransportLine(float_v dS, float_v P[]) const { /** Transports the parameters of the current particle assuming the straight line trajectory ** on the length defined by the transport parameter dS = l/p, where l is the signed distance and p is @@ -3912,18 +4011,18 @@ void KFParticleBaseSIMD::TransportLine( float_v dS, float_v P[] ) const ** \param[in] dS - transport parameter which defines the distance to which particle should be transported ** \param[out] P[8] - array, where transported parameters should be stored **/ - - P[0] = fP[0] + dS*fP[3]; - P[1] = fP[1] + dS*fP[4]; - P[2] = fP[2] + dS*fP[5]; + + P[0] = fP[0] + dS * fP[3]; + P[1] = fP[1] + dS * fP[4]; + P[2] = fP[2] + dS * fP[5]; P[3] = fP[3]; P[4] = fP[4]; P[5] = fP[5]; P[6] = fP[6]; - P[7] = fP[7]; + P[7] = fP[7]; } -void KFParticleBaseSIMD::GetArmenterosPodolanski(KFParticleBaseSIMD& positive, KFParticleBaseSIMD& negative, float_v QtAlfa[2] ) +void KFParticleBaseSIMD::GetArmenterosPodolanski(KFParticleBaseSIMD& positive, KFParticleBaseSIMD& negative, float_v QtAlfa[2]) { /** Calculates parameters for the Armenteros-Podolanski plot for two particles. ** Example how to use:\n @@ -3946,19 +4045,19 @@ void KFParticleBaseSIMD::GetArmenterosPodolanski(KFParticleBaseSIMD& positive, K float_v spx = positive.GetPx() + negative.GetPx(); float_v spy = positive.GetPy() + negative.GetPy(); float_v spz = positive.GetPz() + negative.GetPz(); - float_v sp = sqrt(spx*spx + spy*spy + spz*spz); - float_m mask = float_m( abs(sp) < float_v(1.e-10f)); + float_v sp = sqrt(spx * spx + spy * spy + spz * spz); + float_m mask = float_m(abs(sp) < float_v(1.e-10f)); float_v pn, pp, pln, plp; - pn = sqrt(negative.GetPx()*negative.GetPx() + negative.GetPy()*negative.GetPy() + negative.GetPz()*negative.GetPz()); - pp = sqrt(positive.GetPx()*positive.GetPx() + positive.GetPy()*positive.GetPy() + positive.GetPz()*positive.GetPz()); - pln = (negative.GetPx()*spx+negative.GetPy()*spy+negative.GetPz()*spz)/sp; - plp = (positive.GetPx()*spx+positive.GetPy()*spy+positive.GetPz()*spz)/sp; + pn = sqrt(negative.GetPx() * negative.GetPx() + negative.GetPy() * negative.GetPy() + negative.GetPz() * negative.GetPz()); + pp = sqrt(positive.GetPx() * positive.GetPx() + positive.GetPy() * positive.GetPy() + positive.GetPz() * positive.GetPz()); + pln = (negative.GetPx() * spx + negative.GetPy() * spy + negative.GetPz() * spz) / sp; + plp = (positive.GetPx() * spx + positive.GetPy() * spy + positive.GetPz() * spz) / sp; - mask = float_m(mask & float_m( abs(pn) < float_v(1.E-10f))); - float_v ptm = (1.f-((pln/pn)*(pln/pn))); - qt(ptm >= 0.f) = pn*sqrt(ptm); - alpha = (plp-pln)/(plp+pln); + mask = float_m(mask & float_m(abs(pn) < float_v(1.E-10f))); + float_v ptm = (1.f - ((pln / pn) * (pln / pn))); + qt(ptm >= 0.f) = pn * sqrt(ptm); + alpha = (plp - pln) / (plp + pln); QtAlfa[0](mask) = qt; QtAlfa[1](mask) = alpha; @@ -3979,51 +4078,55 @@ void KFParticleBaseSIMD::RotateXY(float_v angle, float_v Vtx[3]) // Rotate the kf particle float_v s = sin(angle); float_v c = cos(angle); - - float_v mA[8][ 8]; - for( Int_t i=0; i<8; i++ ){ - for( Int_t j=0; j<8; j++){ + + float_v mA[8][8]; + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mA[i][j] = 0; } } - for( int i=0; i<8; i++ ){ + for (int i = 0; i < 8; i++) { mA[i][i] = 1; } - mA[0][0] = c; mA[0][1] = s; - mA[1][0] = -s; mA[1][1] = c; - mA[3][3] = c; mA[3][4] = s; - mA[4][3] = -s; mA[4][4] = c; + mA[0][0] = c; + mA[0][1] = s; + mA[1][0] = -s; + mA[1][1] = c; + mA[3][3] = c; + mA[3][4] = s; + mA[4][3] = -s; + mA[4][4] = c; float_v mAC[8][8]; float_v mAp[8]; - for( Int_t i=0; i<8; i++ ){ + for (Int_t i = 0; i < 8; i++) { mAp[i] = 0; - for( Int_t k=0; k<8; k++){ - mAp[i]+=mA[i][k] * fP[k]; + for (Int_t k = 0; k < 8; k++) { + mAp[i] += mA[i][k] * fP[k]; } } - for( Int_t i=0; i<8; i++){ + for (Int_t i = 0; i < 8; i++) { fP[i] = mAp[i]; } - for( Int_t i=0; i<8; i++ ){ - for( Int_t j=0; j<8; j++ ){ + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mAC[i][j] = 0; - for( Int_t k=0; k<8; k++ ){ - mAC[i][j]+= mA[i][k] * GetCovariance(k,j); + for (Int_t k = 0; k < 8; k++) { + mAC[i][j] += mA[i][k] * GetCovariance(k, j); } } } - for( Int_t i=0; i<8; i++ ){ - for( Int_t j=0; j<=i; j++ ){ + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j <= i; j++) { float_v xx = 0.f; - for( Int_t k=0; k<8; k++){ - xx+= mAC[i][k]*mA[j][k]; + for (Int_t k = 0; k < 8; k++) { + xx += mAC[i][k] * mA[j][k]; } - Covariance(i,j) = xx; + Covariance(i, j) = xx; } } @@ -4039,58 +4142,52 @@ void KFParticleBaseSIMD::InvertCholetsky3(float_v a[6]) **/ float_v d[3], uud, u[3][3]; - for(int i=0; i<3; i++) - { - d[i]=0.f; - for(int j=0; j<3; j++) - u[i][j]=0.f; + for (int i = 0; i < 3; i++) { + d[i] = 0.f; + for (int j = 0; j < 3; j++) + u[i][j] = 0.f; } - for(int i=0; i<3 ; i++) - { - uud=0.f; - for(int j=0; j. */ - #ifndef KFParticleBaseSIMD_H #define KFParticleBaseSIMD_H @@ -42,281 +41,278 @@ ** The functionality of the vectorised and scalar classes is the same. **/ -class KFParticleBaseSIMD { - +class KFParticleBaseSIMD +{ + public: - //* - //* ABSTRACT METHODS HAVE TO BE DEFINED IN USER CLASS - //* -#if __GNUC__ && ( defined(ENVIRONMENT32) || GCC_VERSION < 40300 ) + //* ABSTRACT METHODS HAVE TO BE DEFINED IN USER CLASS + //* +#if __GNUC__ && (defined(ENVIRONMENT32) || GCC_VERSION < 40300) #else - - void *operator new(size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new[](size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new(size_t size, void *ptr) { return ::operator new(size, ptr);} ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new[](size_t size, void *ptr) { return ::operator new(size, ptr);} ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void operator delete(void *ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release - void operator delete[](void *ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release - -#endif - + + void* operator new(size_t size) + { + return _mm_malloc(size, sizeof(float_v)); + } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new[](size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new(size_t size, void* ptr) { return ::operator new(size, ptr); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new[](size_t size, void* ptr) { return ::operator new(size, ptr); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void operator delete(void* ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release + void operator delete[](void* ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release + +#endif + /** Virtual method to access the magnetic field**/ virtual void GetFieldValue(const float_v xyz[], float_v B[]) const = 0; - - //* Virtual methods needed for particle transportation - //* One can use particular implementations for collider (only Bz component) - //* geometry and for fixed-target (CBM-like) geometry which are provided below + + //* Virtual methods needed for particle transportation + //* One can use particular implementations for collider (only Bz component) + //* geometry and for fixed-target (CBM-like) geometry which are provided below //* in TRANSPORT section - - //* Get dS to xyz[] space point - /** Virtual method to get extrapolation parameter dS=l/p to . Is defined in KFParticleSIMD.**/ - virtual float_v GetDStoPoint( const float_v xyz[3], float_v dsdr[6] ) const = 0; - - float_v GetDStoPointLine( const float_v xyz[3], float_v dsdr[6] ) const; - float_v GetDStoPointBz( float_v Bz, const float_v xyz[3], float_v dsdr[6], const float_v* param = 0 ) const; - float_v GetDStoPointBy( float_v By, const float_v xyz[3], float_v dsdr[6] ) const; - float_v GetDStoPointCBM( const float_v xyz[3], float_v dsdr[6] ) const; + //* Get dS to xyz[] space point + + /** Virtual method to get extrapolation parameter dS=l/p to . Is defined in KFParticleSIMD.**/ + virtual float_v GetDStoPoint(const float_v xyz[3], float_v dsdr[6]) const = 0; + + float_v GetDStoPointLine(const float_v xyz[3], float_v dsdr[6]) const; + float_v GetDStoPointBz(float_v Bz, const float_v xyz[3], float_v dsdr[6], const float_v* param = 0) const; + float_v GetDStoPointBy(float_v By, const float_v xyz[3], float_v dsdr[6]) const; + float_v GetDStoPointCBM(const float_v xyz[3], float_v dsdr[6]) const; /** Virtual method to get extrapolation parameter dS=l/p and ds/dr partial derivatives to another particle. Is defined in KFParticleSIMD.**/ - virtual void GetDStoParticle( const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] ) const = 0; + virtual void GetDStoParticle(const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const = 0; /** Virtual method to get extrapolation parameter dS=l/p to another particle. Is defined in KFParticleSIMD.**/ - virtual void GetDStoParticleFast( const KFParticleBaseSIMD &p, float_v dS[2] ) const = 0; - - void GetDStoParticleLine( const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] ) const ; - void GetDStoParticleLine( const KFParticleBaseSIMD &p, float_v dS[2] ) const ; - void GetDStoParticleBz( float_v Bz, const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6], const float_v* param1 =0, const float_v* param2 =0 ) const ; - void GetDStoParticleBz( float_v Bz, const KFParticleBaseSIMD &p, float_v dS[2], const float_v* param1 =0, const float_v* param2 =0 ) const ; - void GetDStoParticleBy( float_v B, const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] ) const ; - void GetDStoParticleBy( float_v B, const KFParticleBaseSIMD &p, float_v dS[2] ) const ; - void GetDStoParticleB( float_v B[3], const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] ) const; - void GetDStoParticleB( float_v B[3], const KFParticleBaseSIMD &p, float_v dS[2] ) const; - void GetDStoParticleCBM( const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] ) const ; - void GetDStoParticleCBM( const KFParticleBaseSIMD &p, float_v dS[2] ) const ; - + virtual void GetDStoParticleFast(const KFParticleBaseSIMD& p, float_v dS[2]) const = 0; + + void GetDStoParticleLine(const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const; + void GetDStoParticleLine(const KFParticleBaseSIMD& p, float_v dS[2]) const; + void GetDStoParticleBz(float_v Bz, const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6], const float_v* param1 = 0, const float_v* param2 = 0) const; + void GetDStoParticleBz(float_v Bz, const KFParticleBaseSIMD& p, float_v dS[2], const float_v* param1 = 0, const float_v* param2 = 0) const; + void GetDStoParticleBy(float_v B, const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const; + void GetDStoParticleBy(float_v B, const KFParticleBaseSIMD& p, float_v dS[2]) const; + void GetDStoParticleB(float_v B[3], const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const; + void GetDStoParticleB(float_v B[3], const KFParticleBaseSIMD& p, float_v dS[2]) const; + void GetDStoParticleCBM(const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const; + void GetDStoParticleCBM(const KFParticleBaseSIMD& p, float_v dS[2]) const; + /** Virtual method to transport a particle parameters and covariance matrix on a certain distance along the trajectory. Is defined in KFParticleSIMD.**/ - virtual void Transport( float_v dS, const float_v dsdr[6], float_v P[], float_v C[], float_v* dsdr1=0, float_v* F=0, float_v* F1=0 ) const = 0; + virtual void Transport(float_v dS, const float_v dsdr[6], float_v P[], float_v C[], float_v* dsdr1 = 0, float_v* F = 0, float_v* F1 = 0) const = 0; /** Virtual method to transport a particle parameters on a certain distance along the trajectory. Is defined in KFParticleSIMD.**/ - virtual void TransportFast( float_v dS, float_v P[] ) const = 0; - - + virtual void TransportFast(float_v dS, float_v P[]) const = 0; //* //* INITIALIZATION //* - //* Constructor + //* Constructor KFParticleBaseSIMD(); - //* Destructor + //* Destructor virtual ~KFParticleBaseSIMD() { ; } ///< The default destructor. - void Initialize( const float_v Param[], const float_v Cov[], int_v Charge, float_v Mass ); + void Initialize(const float_v Param[], const float_v Cov[], int_v Charge, float_v Mass); void Initialize(); - void SetConstructMethod(Int_t m) {fConstructMethod = m;} ///< Defines the construction method for the current particle (see description of fConstructMethod). - void SetMassHypo(float_v m) { fMassHypo = m;} ///< Sets the mass hypothesis to the particle, is used when fConstructMethod = 2. - const float_v& GetMassHypo() const { return fMassHypo; } ///< Returns the mass hypothesis. - const float_v& GetSumDaughterMass() const {return SumDaughterMass;} ///< Returns the sum of masses of the daughters. + void SetConstructMethod(Int_t m) { fConstructMethod = m; } ///< Defines the construction method for the current particle (see description of fConstructMethod). + void SetMassHypo(float_v m) { fMassHypo = m; } ///< Sets the mass hypothesis to the particle, is used when fConstructMethod = 2. + const float_v& GetMassHypo() const { return fMassHypo; } ///< Returns the mass hypothesis. + const float_v& GetSumDaughterMass() const { return SumDaughterMass; } ///< Returns the sum of masses of the daughters. //* //* ACCESSORS //* - //* Simple accessors - - float_v GetX () const { return fP[0]; } ///< Returns the sum of masses of the daughters - float_v GetY () const { return fP[1]; } ///< Returns the sum of masses of the daughters - float_v GetZ () const { return fP[2]; } ///< Returns the sum of masses of the daughters - float_v GetPx () const { return fP[3]; } ///< Returns the sum of masses of the daughters - float_v GetPy () const { return fP[4]; } ///< Returns the sum of masses of the daughters - float_v GetPz () const { return fP[5]; } ///< Returns the sum of masses of the daughters - float_v GetE () const { return fP[6]; } ///< Returns the sum of masses of the daughters - float_v GetS () const { return fP[7]; } ///< Returns the sum of masses of the daughters - int_v GetQ () const { return fQ; } ///< Returns the sum of masses of the daughters - float_v GetChi2 () const { return fChi2; } ///< Returns the sum of masses of the daughters - int_v GetNDF () const { return fNDF; } ///< Returns the sum of masses of the daughters - - const float_v& X () const { return fP[0]; } ///< Retruns X coordinate of the particle, fP[0]. - const float_v& Y () const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. - const float_v& Z () const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. - const float_v& Px () const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. - const float_v& Py () const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. - const float_v& Pz () const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. - const float_v& E () const { return fP[6]; } ///< Returns energy of the particle, fP[6]. - const float_v& S () const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. - const int_v& Q () const { return fQ; } ///< Returns charge of the particle. - const float_v& Chi2 () const { return fChi2; } ///< Returns Chi2 of the fit. - const int_v& NDF () const { return fNDF; } ///< Returns number of decrease of freedom. - - float_v GetParameter ( Int_t i ) const { return fP[i]; } ///< Returns P[i] parameter. - float_v GetCovariance( Int_t i ) const { return fC[i]; } ///< Returns C[i] element of the covariance matrix in the lower triangular form. - float_v GetCovariance( Int_t i, Int_t j ) const { return fC[IJ(i,j)]; } ///< Returns C[i,j] element of the covariance matrix. + //* Simple accessors + + float_v GetX() const { return fP[0]; } ///< Returns the sum of masses of the daughters + float_v GetY() const { return fP[1]; } ///< Returns the sum of masses of the daughters + float_v GetZ() const { return fP[2]; } ///< Returns the sum of masses of the daughters + float_v GetPx() const { return fP[3]; } ///< Returns the sum of masses of the daughters + float_v GetPy() const { return fP[4]; } ///< Returns the sum of masses of the daughters + float_v GetPz() const { return fP[5]; } ///< Returns the sum of masses of the daughters + float_v GetE() const { return fP[6]; } ///< Returns the sum of masses of the daughters + float_v GetS() const { return fP[7]; } ///< Returns the sum of masses of the daughters + int_v GetQ() const { return fQ; } ///< Returns the sum of masses of the daughters + float_v GetChi2() const { return fChi2; } ///< Returns the sum of masses of the daughters + int_v GetNDF() const { return fNDF; } ///< Returns the sum of masses of the daughters + + const float_v& X() const { return fP[0]; } ///< Retruns X coordinate of the particle, fP[0]. + const float_v& Y() const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. + const float_v& Z() const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. + const float_v& Px() const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. + const float_v& Py() const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. + const float_v& Pz() const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. + const float_v& E() const { return fP[6]; } ///< Returns energy of the particle, fP[6]. + const float_v& S() const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. + const int_v& Q() const { return fQ; } ///< Returns charge of the particle. + const float_v& Chi2() const { return fChi2; } ///< Returns Chi2 of the fit. + const int_v& NDF() const { return fNDF; } ///< Returns number of decrease of freedom. + + float_v GetParameter(Int_t i) const { return fP[i]; } ///< Returns P[i] parameter. + float_v GetCovariance(Int_t i) const { return fC[i]; } ///< Returns C[i] element of the covariance matrix in the lower triangular form. + float_v GetCovariance(Int_t i, Int_t j) const { return fC[IJ(i, j)]; } ///< Returns C[i,j] element of the covariance matrix. //* Accessors with calculations( &value, &estimated sigma ) - //* error flag returned (0 means no error during calculations) - - float_m GetMomentum ( float_v &p, float_v &error ) const ; - float_m GetPt ( float_v &pt, float_v &error ) const ; - float_m GetEta ( float_v &eta, float_v &error ) const ; - float_m GetPhi ( float_v &phi, float_v &error ) const ; - float_m GetMass ( float_v &m, float_v &error ) const ; - float_m GetDecayLength ( float_v &l, float_v &error ) const ; - float_m GetDecayLengthXY ( float_v &l, float_v &error ) const ; - float_m GetLifeTime ( float_v &ctau, float_v &error ) const ; - float_m GetR ( float_v &r, float_v &error ) const ; + //* error flag returned (0 means no error during calculations) + + float_m GetMomentum(float_v& p, float_v& error) const; + float_m GetPt(float_v& pt, float_v& error) const; + float_m GetEta(float_v& eta, float_v& error) const; + float_m GetPhi(float_v& phi, float_v& error) const; + float_m GetMass(float_v& m, float_v& error) const; + float_m GetDecayLength(float_v& l, float_v& error) const; + float_m GetDecayLengthXY(float_v& l, float_v& error) const; + float_m GetLifeTime(float_v& ctau, float_v& error) const; + float_m GetR(float_v& r, float_v& error) const; //* //* MODIFIERS //* - - float_v & X () { return fP[0]; } ///< Modifier of X coordinate of the particle, fP[0]. - float_v & Y () { return fP[1]; } ///< Modifier of Y coordinate of the particle, fP[1]. - float_v & Z () { return fP[2]; } ///< Modifier of Z coordinate of the particle, fP[2]. - float_v & Px () { return fP[3]; } ///< Modifier of X component of the momentum, fP[3]. - float_v & Py () { return fP[4]; } ///< Modifier of Y component of the momentum, fP[4]. - float_v & Pz () { return fP[5]; } ///< Modifier of Z component of the momentum, fP[5]. - float_v & E () { return fP[6]; } ///< Modifier of energy of the particle, fP[6]. - float_v & S () { return fP[7]; } ///< Modifier of dS=l/p, l - decay length, fP[7], defined if production vertex is set. - int_v & Q () { return fQ; } ///< Modifier of charge of the particle. - float_v & Chi2 () { return fChi2; } ///< Modifier of Chi2 of the fit. - int_v & NDF () { return fNDF; } ///< Modifier of number of decrease of freedom. - - float_v & Parameter ( Int_t i ) { return fP[i]; } ///< Modifier of P[i] parameter. - float_v & Covariance( Int_t i ) { return fC[i]; } ///< Modifier of C[i] element of the covariance matrix in the lower triangular form. - float_v & Covariance( Int_t i, Int_t j ) { return fC[IJ(i,j)]; } ///< Modifier of C[i,j] element of the covariance matrix. - - - //* + + float_v& X() { return fP[0]; } ///< Modifier of X coordinate of the particle, fP[0]. + float_v& Y() { return fP[1]; } ///< Modifier of Y coordinate of the particle, fP[1]. + float_v& Z() { return fP[2]; } ///< Modifier of Z coordinate of the particle, fP[2]. + float_v& Px() { return fP[3]; } ///< Modifier of X component of the momentum, fP[3]. + float_v& Py() { return fP[4]; } ///< Modifier of Y component of the momentum, fP[4]. + float_v& Pz() { return fP[5]; } ///< Modifier of Z component of the momentum, fP[5]. + float_v& E() { return fP[6]; } ///< Modifier of energy of the particle, fP[6]. + float_v& S() { return fP[7]; } ///< Modifier of dS=l/p, l - decay length, fP[7], defined if production vertex is set. + int_v& Q() { return fQ; } ///< Modifier of charge of the particle. + float_v& Chi2() { return fChi2; } ///< Modifier of Chi2 of the fit. + int_v& NDF() { return fNDF; } ///< Modifier of number of decrease of freedom. + + float_v& Parameter(Int_t i) { return fP[i]; } ///< Modifier of P[i] parameter. + float_v& Covariance(Int_t i) { return fC[i]; } ///< Modifier of C[i] element of the covariance matrix in the lower triangular form. + float_v& Covariance(Int_t i, Int_t j) { return fC[IJ(i, j)]; } ///< Modifier of C[i,j] element of the covariance matrix. + + //* //* CONSTRUCTION OF THE PARTICLE BY ITS DAUGHTERS AND MOTHER //* USING THE KALMAN FILTER METHOD //* + //* Simple way to add daughter ex. D0+= Pion; - //* Simple way to add daughter ex. D0+= Pion; - - void operator +=( const KFParticleBaseSIMD &Daughter ); + void operator+=(const KFParticleBaseSIMD& Daughter); - //* Add daughter track to the particle + //* Add daughter track to the particle - void AddDaughter( const KFParticleBaseSIMD &Daughter ); - void SubtractDaughter( const KFParticleBaseSIMD &Daughter ); + void AddDaughter(const KFParticleBaseSIMD& Daughter); + void SubtractDaughter(const KFParticleBaseSIMD& Daughter); - void AddDaughterWithEnergyFit( const KFParticleBaseSIMD &Daughter ); - void AddDaughterWithEnergyFitMC( const KFParticleBaseSIMD &Daughter ); + void AddDaughterWithEnergyFit(const KFParticleBaseSIMD& Daughter); + void AddDaughterWithEnergyFitMC(const KFParticleBaseSIMD& Daughter); //with mass constrained - //* Set production vertex + //* Set production vertex - void SetProductionVertex( const KFParticleBaseSIMD &Vtx ); + void SetProductionVertex(const KFParticleBaseSIMD& Vtx); - //* Set mass constraint + //* Set mass constraint - void SetNonlinearMassConstraint( float_v Mass ); - void SetMassConstraint( float_v Mass, float_v SigmaMass = float_v(0.f) ); + void SetNonlinearMassConstraint(float_v Mass); + void SetMassConstraint(float_v Mass, float_v SigmaMass = float_v(0.f)); //* Set no decay length for resonances void SetNoDecayLength(); + //* Everything in one go - //* Everything in one go - - void Construct( const KFParticleBaseSIMD *vDaughters[], Int_t nDaughters, const KFParticleBaseSIMD *ProdVtx=0, Float_t Mass=-1 ); - + void Construct(const KFParticleBaseSIMD* vDaughters[], Int_t nDaughters, const KFParticleBaseSIMD* ProdVtx = 0, Float_t Mass = -1); //* //* TRANSPORT - //* + //* //* ( main transportation parameter is S = SignedPath/Momentum ) //* ( parameters of decay & production vertices are stored locally ) //* - - //* Transport the particle to its decay vertex + //* Transport the particle to its decay vertex void TransportToDecayVertex(); - //* Transport the particle to its production vertex + //* Transport the particle to its production vertex void TransportToProductionVertex(); - //* Transport the particle on dS parameter (SignedPath/Momentum) + //* Transport the particle on dS parameter (SignedPath/Momentum) - void TransportToDS( float_v dS, const float_v* dsdr ); - void TransportToDSLine( float_v dS, const float_v* dsdr ); - //* Particular extrapolators one can use - void TransportBz( float_v Bz, float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1=0, float_v* F=0, float_v* F1=0 ) const; - void TransportBz( float_v Bz, float_v dS, float_v P[] ) const; - void TransportCBM( float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1=0, float_v* F=0, float_v* F1=0 ) const; - void TransportCBM( float_v dS, float_v P[] ) const; + void TransportToDS(float_v dS, const float_v* dsdr); + void TransportToDSLine(float_v dS, const float_v* dsdr); + //* Particular extrapolators one can use + void TransportBz(float_v Bz, float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1 = 0, float_v* F = 0, float_v* F1 = 0) const; + void TransportBz(float_v Bz, float_v dS, float_v P[]) const; + void TransportCBM(float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1 = 0, float_v* F = 0, float_v* F1 = 0) const; + void TransportCBM(float_v dS, float_v P[]) const; - //* + //* //* OTHER UTILITIES //* //* Calculate distance from another object [cm] - float_v GetDistanceFromVertex( const float_v vtx[] ) const; - float_v GetDistanceFromVertex( const KFParticleBaseSIMD &Vtx ) const; - float_v GetDistanceFromParticle( const KFParticleBaseSIMD &p ) const; + float_v GetDistanceFromVertex(const float_v vtx[]) const; + float_v GetDistanceFromVertex(const KFParticleBaseSIMD& Vtx) const; + float_v GetDistanceFromParticle(const KFParticleBaseSIMD& p) const; //* Calculate CAMath::Sqrt(Chi2/ndf) deviation from vertex //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix - float_v GetDeviationFromVertex( const float_v v[], - const float_v Cv[]=0 ) const; - float_v GetDeviationFromVertex( const KFParticleBaseSIMD &Vtx ) const; - float_v GetDeviationFromParticle( const KFParticleBaseSIMD &p ) const; + float_v GetDeviationFromVertex(const float_v v[], + const float_v Cv[] = 0) const; + float_v GetDeviationFromVertex(const KFParticleBaseSIMD& Vtx) const; + float_v GetDeviationFromParticle(const KFParticleBaseSIMD& p) const; - //* Subtract the particle from the vertex + //* Subtract the particle from the vertex - void SubtractFromVertex( KFParticleBaseSIMD &Vtx ) const; - void SubtractFromParticle( KFParticleBaseSIMD &Vtx ) const; + void SubtractFromVertex(KFParticleBaseSIMD& Vtx) const; + void SubtractFromParticle(KFParticleBaseSIMD& Vtx) const; - static void GetArmenterosPodolanski(KFParticleBaseSIMD& positive, KFParticleBaseSIMD& negative, float_v QtAlfa[2] ); + static void GetArmenterosPodolanski(KFParticleBaseSIMD& positive, KFParticleBaseSIMD& negative, float_v QtAlfa[2]); void RotateXY(float_v angle, float_v Vtx[3]); - int_v Id() const { return fId; } ///< Returns Id of the particle. - int NDaughters() const { return fDaughterIds.size(); } ///< Returns number of daughter particles. - std::vector & DaughterIds() { return fDaughterIds; } ///< Returns the vector with the indices of daughter particles. + int_v Id() const { return fId; } ///< Returns Id of the particle. + int NDaughters() const { return fDaughterIds.size(); } ///< Returns number of daughter particles. + std::vector& DaughterIds() { return fDaughterIds; } ///< Returns the vector with the indices of daughter particles. int_v GetDaughterId(int iD) const { return fDaughterIds[iD]; } ///< Returns the daughter Id with the index iD. - - void SetId( int_v id ){ fId = id; } ///< Sets the Id of the particle. After the construction of a particle should be set by user. - void SetNDaughters( int n ) { fDaughterIds.reserve(n); } ///< Reserves the size of the vector with daughter Ids to n - void AddDaughterId( int_v id ){ fDaughterIds.push_back(id); } ///< Adds index of the daughter particle. - void CleanDaughtersId() { fDaughterIds.clear(); } ///< Cleans the vector with the indices of daughter particles. - void SetPDG ( int pdg ) { fPDG = pdg; } ///< Sets the PDG hypothesis common for all elements of the SIMD vector. - void SetPDG ( int_v& pdg ) { fPDG = pdg; } ///< Sets the PDG hypothesis individual for each entry of the SIMD vector. - const int_v& GetPDG () const { return fPDG; } ///< Returns the PDG hypothesis. - const int_v& PDG () const { return fPDG; } ///< Returns the PDG hypothesis. + void SetId(int_v id) { fId = id; } ///< Sets the Id of the particle. After the construction of a particle should be set by user. + void SetNDaughters(int n) { fDaughterIds.reserve(n); } ///< Reserves the size of the vector with daughter Ids to n + void AddDaughterId(int_v id) { fDaughterIds.push_back(id); } ///< Adds index of the daughter particle. + void CleanDaughtersId() { fDaughterIds.clear(); } ///< Cleans the vector with the indices of daughter particles. + + void SetPDG(int pdg) { fPDG = pdg; } ///< Sets the PDG hypothesis common for all elements of the SIMD vector. + void SetPDG(int_v& pdg) { fPDG = pdg; } ///< Sets the PDG hypothesis individual for each entry of the SIMD vector. + const int_v& GetPDG() const { return fPDG; } ///< Returns the PDG hypothesis. + const int_v& PDG() const { return fPDG; } ///< Returns the PDG hypothesis. - void GetDistanceToVertexLine( const KFParticleBaseSIMD &Vertex, float_v &l, float_v &dl, float_m *isParticleFromVertex = 0 ) const; + void GetDistanceToVertexLine(const KFParticleBaseSIMD& Vertex, float_v& l, float_v& dl, float_m* isParticleFromVertex = 0) const; - static void MultQSQt( const float_v Q[], const float_v S[], float_v SOut[], const int kN ); + static void MultQSQt(const float_v Q[], const float_v S[], float_v SOut[], const int kN); protected: /** Converts a pair of indices {i,j} of the covariance matrix to one index corresponding to the triangular form. */ - static Int_t IJ( Int_t i, Int_t j ){ - return ( j<=i ) ? i*(i+1)/2+j :j*(j+1)/2+i; + static Int_t IJ(Int_t i, Int_t j) + { + return (j <= i) ? i * (i + 1) / 2 + j : j * (j + 1) / 2 + i; } /** Return an element of the covariance matrix with {i,j} indices. */ - float_v & Cij( Int_t i, Int_t j ){ return fC[IJ(i,j)]; } + float_v& Cij(Int_t i, Int_t j) { return fC[IJ(i, j)]; } - void TransportLine( float_v S, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1=0, float_v* F=0, float_v* F1=0 ) const ; - void TransportLine( float_v S, float_v P[] ) const ; + void TransportLine(float_v S, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1 = 0, float_v* F = 0, float_v* F1 = 0) const; + void TransportLine(float_v S, float_v P[]) const; static void InvertCholetsky3(float_v a[6]); - void GetMeasurement( const KFParticleBaseSIMD& daughter, float_v m[], float_v V[], float_v D[3][3] ) ; + void GetMeasurement(const KFParticleBaseSIMD& daughter, float_v m[], float_v V[], float_v D[3][3]); //* Mass constraint function. is needed for the nonlinear mass constraint and a fit with mass constraint - void SetMassConstraint( float_v *mP, float_v *mC, float_v mJ[7][7], float_v mass, float_m mask ); + void SetMassConstraint(float_v* mP, float_v* mC, float_v mJ[7][7], float_v mass, float_m mask); float_v fP[8]; ///< Particle parameters { X, Y, Z, Px, Py, Pz, E, S[=DecayLength/P]}. float_v fC[36]; ///< Low-triangle covariance matrix of fP. @@ -342,4 +338,4 @@ class KFParticleBaseSIMD { } __attribute__((aligned(sizeof(float_v)))); -#endif +#endif diff --git a/KFParticle/KFParticleDatabase.cxx b/KFParticle/KFParticleDatabase.cxx index e5e8b41..d3986fa 100644 --- a/KFParticle/KFParticleDatabase.cxx +++ b/KFParticle/KFParticleDatabase.cxx @@ -23,30 +23,29 @@ KFParticleDatabase* KFParticleDatabase::fDatabase = 0; -KFParticleDatabase::KFParticleDatabase(): - fMassPi0PDG(0.13498), +KFParticleDatabase::KFParticleDatabase() : fMassPi0PDG(0.13498), #ifdef PANDA_STT - fMassPi0PDGSigma(0.009), + fMassPi0PDGSigma(0.009), #elif defined ALICE_ITS - fMassPi0PDGSigma(0.006), + fMassPi0PDGSigma(0.006), #elif defined STAR_HFT - fMassPi0PDGSigma(0.006), + fMassPi0PDGSigma(0.006), #elif defined CBM - fMassPi0PDGSigma(0.006), -#else - fMassPi0PDGSigma(0.006), + fMassPi0PDGSigma(0.006), +#else + fMassPi0PDGSigma(0.006), #endif - fMassD0PDG(1.86484), + fMassD0PDG(1.86484), #ifdef CBM - fMassD0PDGSigma(0.0145), + fMassD0PDGSigma(0.0145), #else - fMassD0PDGSigma(0.0154), + fMassD0PDGSigma(0.0154), #endif - fMassDPlusPDG(1.86962), + fMassDPlusPDG(1.86962), #ifdef CBM - fMassDPlusPDGSigma(0.0145) + fMassDPlusPDGSigma(0.0145) #else - fMassDPlusPDGSigma(0.0115) + fMassDPlusPDGSigma(0.0115) #endif { /** The default constructor. Initialises masses and widths of the peaks. @@ -65,43 +64,43 @@ KFParticleDatabase::KFParticleDatabase(): fMass[10] = 1.18937; fMass[11] = 1.32171; fMass[12] = 1.67245; - + fMassSecPDG[0] = 0.497614; //K0 fMassSecPDG[1] = 1.115683; //Lambda - fMassSecPDG[2] = 1.32171; //Xi - fMassSecPDG[3] = 0; //gamma - fMassSecPDG[4] = 1.67245; //Omega - fMassSecPDG[5] = 2.99339; //H3L - fMassSecPDG[6] = 3.93070; //He4L - fMassSecPDG[7] = 4.86824; //He5L - + fMassSecPDG[2] = 1.32171; //Xi + fMassSecPDG[3] = 0; //gamma + fMassSecPDG[4] = 1.67245; //Omega + fMassSecPDG[5] = 2.99339; //H3L + fMassSecPDG[6] = 3.93070; //He4L + fMassSecPDG[7] = 4.86824; //He5L + #ifdef PANDA_STT - fMassSecPDGSigma[0]=12.0e-3; //K0 TODO tune - fMassSecPDGSigma[1]=2.7e-3; //Lambda - fMassSecPDGSigma[2]=2.8e-3; //Xi TODO tune + fMassSecPDGSigma[0] = 12.0e-3; //K0 TODO tune + fMassSecPDGSigma[1] = 2.7e-3; //Lambda + fMassSecPDGSigma[2] = 2.8e-3; //Xi TODO tune #elif defined ALICE_ITS - fMassSecPDGSigma[0]=17.7e-3; - fMassSecPDGSigma[1]=5.9e-3; - fMassSecPDGSigma[2]=7.3e-3; + fMassSecPDGSigma[0] = 17.7e-3; + fMassSecPDGSigma[1] = 5.9e-3; + fMassSecPDGSigma[2] = 7.3e-3; #elif defined STAR_HFT - fMassSecPDGSigma[0]=17.7e-3; - fMassSecPDGSigma[1]=5.9e-3; - fMassSecPDGSigma[2]=7.3e-3; + fMassSecPDGSigma[0] = 17.7e-3; + fMassSecPDGSigma[1] = 5.9e-3; + fMassSecPDGSigma[2] = 7.3e-3; #elif defined CBM - fMassSecPDGSigma[0]=3.7e-3; //2.2e-3; - fMassSecPDGSigma[1]=1.5e-3; //1.2e-3; - fMassSecPDGSigma[2]=2.0e-3; + fMassSecPDGSigma[0] = 3.7e-3; //2.2e-3; + fMassSecPDGSigma[1] = 1.5e-3; //1.2e-3; + fMassSecPDGSigma[2] = 2.0e-3; #else //STAR - fMassSecPDGSigma[0]=4.9e-3; - fMassSecPDGSigma[1]=2.1e-3; - fMassSecPDGSigma[2]=2.1e-3; + fMassSecPDGSigma[0] = 4.9e-3; + fMassSecPDGSigma[1] = 2.1e-3; + fMassSecPDGSigma[2] = 2.1e-3; #endif - fMassSecPDGSigma[3]=6.0e-3; //TODO tune //Gamma - fMassSecPDGSigma[4]=2.1e-3; //Omega - fMassSecPDGSigma[5]=3.0e-3; //H3L - fMassSecPDGSigma[6]=3.0e-3; //He4L - fMassSecPDGSigma[7]=3.0e-3; //He5L - + fMassSecPDGSigma[3] = 6.0e-3; //TODO tune //Gamma + fMassSecPDGSigma[4] = 2.1e-3; //Omega + fMassSecPDGSigma[5] = 3.0e-3; //H3L + fMassSecPDGSigma[6] = 3.0e-3; //He4L + fMassSecPDGSigma[7] = 3.0e-3; //He5L + fDatabase = this; } diff --git a/KFParticle/KFParticleDatabase.h b/KFParticle/KFParticleDatabase.h index 57828c8..17230eb 100644 --- a/KFParticle/KFParticleDatabase.h +++ b/KFParticle/KFParticleDatabase.h @@ -19,7 +19,6 @@ * along with this program. If not, see . */ - #ifndef KFParticleDatabase_H #define KFParticleDatabase_H @@ -42,7 +41,7 @@ class KFParticleDatabase public: KFParticleDatabase(); - virtual ~KFParticleDatabase() {}; + virtual ~KFParticleDatabase(){}; float GetMass(const int pdg) const { @@ -51,25 +50,54 @@ class KFParticleDatabase ** \param[in] pdg - the input PDG code **/ int pdgIndex = 2; - switch ( abs(pdg) ) - { - case 11: pdgIndex = 0; break; - case 13: pdgIndex = 1; break; - case 19: pdgIndex = 1; break; - case 211: pdgIndex = 2; break; - case 321: pdgIndex = 3; break; - case 2212: pdgIndex = 4; break; - case 1000010020: pdgIndex = 5; break; - case 1000010030: pdgIndex = 6; break; - case 1000020030: pdgIndex = 7; break; - case 1000020040: pdgIndex = 8; break; - case 3112: pdgIndex = 9; break; - case 3222: pdgIndex = 10; break; - case 3312: pdgIndex = 11; break; - case 3334: pdgIndex = 12; break; - default: pdgIndex = 2; break; + switch (abs(pdg)) { + case 11: + pdgIndex = 0; + break; + case 13: + pdgIndex = 1; + break; + case 19: + pdgIndex = 1; + break; + case 211: + pdgIndex = 2; + break; + case 321: + pdgIndex = 3; + break; + case 2212: + pdgIndex = 4; + break; + case 1000010020: + pdgIndex = 5; + break; + case 1000010030: + pdgIndex = 6; + break; + case 1000020030: + pdgIndex = 7; + break; + case 1000020040: + pdgIndex = 8; + break; + case 3112: + pdgIndex = 9; + break; + case 3222: + pdgIndex = 10; + break; + case 3312: + pdgIndex = 11; + break; + case 3334: + pdgIndex = 12; + break; + default: + pdgIndex = 2; + break; } - + return fMass[pdgIndex]; } @@ -80,20 +108,20 @@ class KFParticleDatabase ** \param[in] pdg - the input PDG codes of a set of particles in the SIMD-vector format **/ Vc::int_v pdgIndex(2); - pdgIndex(Vc::abs(pdg) == 11) = 0; - pdgIndex(Vc::abs(pdg) == 13) = 1; - pdgIndex(Vc::abs(pdg) == 19) = 1; - pdgIndex(Vc::abs(pdg) == 211) = 2; - pdgIndex(Vc::abs(pdg) == 321) = 3; - pdgIndex(Vc::abs(pdg) == 2212) = 4; + pdgIndex(Vc::abs(pdg) == 11) = 0; + pdgIndex(Vc::abs(pdg) == 13) = 1; + pdgIndex(Vc::abs(pdg) == 19) = 1; + pdgIndex(Vc::abs(pdg) == 211) = 2; + pdgIndex(Vc::abs(pdg) == 321) = 3; + pdgIndex(Vc::abs(pdg) == 2212) = 4; pdgIndex(Vc::abs(pdg) == 1000010020) = 5; pdgIndex(Vc::abs(pdg) == 1000010030) = 6; pdgIndex(Vc::abs(pdg) == 1000020030) = 7; pdgIndex(Vc::abs(pdg) == 1000020040) = 8; - pdgIndex(Vc::abs(pdg) == 3112) = 9; - pdgIndex(Vc::abs(pdg) == 3222) = 10; - pdgIndex(Vc::abs(pdg) == 3312) = 11; - pdgIndex(Vc::abs(pdg) == 3334) = 12; + pdgIndex(Vc::abs(pdg) == 3112) = 9; + pdgIndex(Vc::abs(pdg) == 3222) = 10; + pdgIndex(Vc::abs(pdg) == 3312) = 11; + pdgIndex(Vc::abs(pdg) == 3334) = 12; Vc::float_v mass(fMass, pdgIndex); return mass; } @@ -107,9 +135,9 @@ class KFParticleDatabase ** \param[out] massMotherPDG - the output table mass for the given PDG code ** \param[out] massMotherPDGSigma - expected width of the corresponding peak **/ - + Vc::int_v pdgIndex(0); - pdgIndex(pdg == 310) = 0; + pdgIndex(pdg == 310) = 0; pdgIndex(Vc::abs(pdg) == 3122) = 1; pdgIndex(Vc::abs(pdg) == 3312) = 2; pdgIndex(pdg == 22) = 3; @@ -117,11 +145,11 @@ class KFParticleDatabase pdgIndex(Vc::abs(pdg) == 3004) = 5; pdgIndex(Vc::abs(pdg) == 3006) = 6; pdgIndex(Vc::abs(pdg) == 3007) = 7; - + massMotherPDG.gather(fMassSecPDG, pdgIndex); massMotherPDGSigma.gather(fMassSecPDGSigma, pdgIndex); } - + void GetMotherMass(const int pdg, float& massMotherPDG, float& massMotherPDGSigma) const { /** Returns scalar float variables with the mass of the short-lived particle with the given PDG code @@ -131,33 +159,50 @@ class KFParticleDatabase ** \param[out] massMotherPDG - the output table mass for the given PDG code ** \param[out] massMotherPDGSigma - expected width of the corresponding peak **/ - + int pdgIndex = 2; - switch ( abs(pdg) ) - { - case 310: pdgIndex = 0; break; - case 3122: pdgIndex = 1; break; - case 3312: pdgIndex = 2; break; - case 22: pdgIndex = 3; break; - case 3334: pdgIndex = 4; break; - case 3004: pdgIndex = 5; break; - case 3006: pdgIndex = 6; break; - case 3007: pdgIndex = 7; break; - default: pdgIndex = 0; break; + switch (abs(pdg)) { + case 310: + pdgIndex = 0; + break; + case 3122: + pdgIndex = 1; + break; + case 3312: + pdgIndex = 2; + break; + case 22: + pdgIndex = 3; + break; + case 3334: + pdgIndex = 4; + break; + case 3004: + pdgIndex = 5; + break; + case 3006: + pdgIndex = 6; + break; + case 3007: + pdgIndex = 7; + break; + default: + pdgIndex = 0; + break; } - + massMotherPDG = fMassSecPDG[pdgIndex]; massMotherPDGSigma = fMassSecPDGSigma[pdgIndex]; } - - const float& GetPi0Mass() const { return fMassPi0PDG; } ///< Returns the table PDG pi0 mass. - const float& GetPi0MassSigma() const { return fMassPi0PDGSigma; } ///< Returns expected width of the pi0 peak. - const float& GetD0Mass() const { return fMassD0PDG; } ///< Returns the table PDG D0 mass. - const float& GetD0MassSigma() const { return fMassD0PDGSigma; } ///< Returns expected width of the D0 peak. - const float& GetDPlusMass() const { return fMassDPlusPDG; } ///< Returns the table PDG D+ mass. - const float& GetDPlusMassSigma() const { return fMassDPlusPDGSigma; } ///< Returns expected width of the D+ peak. - - static const KFParticleDatabase* Instance() { return fDatabase; } ///< Returns a pointer to the singleton object. + + const float& GetPi0Mass() const { return fMassPi0PDG; } ///< Returns the table PDG pi0 mass. + const float& GetPi0MassSigma() const { return fMassPi0PDGSigma; } ///< Returns expected width of the pi0 peak. + const float& GetD0Mass() const { return fMassD0PDG; } ///< Returns the table PDG D0 mass. + const float& GetD0MassSigma() const { return fMassD0PDGSigma; } ///< Returns expected width of the D0 peak. + const float& GetDPlusMass() const { return fMassDPlusPDG; } ///< Returns the table PDG D+ mass. + const float& GetDPlusMassSigma() const { return fMassDPlusPDGSigma; } ///< Returns expected width of the D+ peak. + + static const KFParticleDatabase* Instance() { return fDatabase; } ///< Returns a pointer to the singleton object. private: /** Table PDG masses of particles, which can be registered by the tracking detector directly: \n @@ -171,15 +216,15 @@ class KFParticleDatabase /** Expected widths of peaks of short-lived particles, which are used for reconstruction of the decay trees: \n ** [ 0] - K0s; \n [ 1] - Lambda; \n [ 2] - Xi; \n [ 3] - gamma; \n [ 4] - Omega; \n [ 5] - H3Lambda; \n [ 6] - He4Lambda; \n [ 7] - He5Lambda. */ float fMassSecPDGSigma[8]; - - float fMassPi0PDG; ///< Table mass of pi0 - float fMassPi0PDGSigma; ///< Expected width of the pi0 peak - - float fMassD0PDG; ///< Table mass of D0 - float fMassD0PDGSigma; ///< Expected width of the D0 peak - float fMassDPlusPDG; ///< Table mass of D+ - float fMassDPlusPDGSigma; ///< Expected width of the D+ peak - + + float fMassPi0PDG; ///< Table mass of pi0 + float fMassPi0PDGSigma; ///< Expected width of the pi0 peak + + float fMassD0PDG; ///< Table mass of D0 + float fMassD0PDGSigma; ///< Expected width of the D0 peak + float fMassDPlusPDG; ///< Table mass of D+ + float fMassDPlusPDGSigma; ///< Expected width of the D+ peak + static KFParticleDatabase* fDatabase; ///< A singleton object. }; diff --git a/KFParticle/KFParticleDef.h b/KFParticle/KFParticleDef.h index b3dd834..69de6e2 100644 --- a/KFParticle/KFParticleDef.h +++ b/KFParticle/KFParticleDef.h @@ -19,7 +19,6 @@ * along with this program. If not, see . */ - #ifndef KFParticleDef_H #define KFParticleDef_H @@ -38,28 +37,35 @@ #include #include #include -using ::Vc::float_v; +using ::Vc::asin; +using ::Vc::atan2; +using ::Vc::double_m; using ::Vc::double_v; +using ::Vc::float_m; using ::Vc::float_v; +using ::Vc::int_m; using ::Vc::int_v; +using ::Vc::isfinite; +using ::Vc::round; +using ::Vc::uint_m; using ::Vc::uint_v; using ::Vc::VectorAlignment; -using ::Vc::double_m; -using ::Vc::float_m; -using ::Vc::int_m; -using ::Vc::uint_m; -using ::Vc::atan2; -using ::Vc::asin; -using ::Vc::round; -using ::Vc::isfinite; #ifdef VC_VERSION_NUMBER -#if VC_VERSION_NUMBER < VC_VERSION_CHECK(1,0,0) -template To simd_cast(From &&x) { return static_cast(x); } +#if VC_VERSION_NUMBER < VC_VERSION_CHECK(1, 0, 0) +template +To simd_cast(From&& x) +{ + return static_cast(x); +} #endif #elif defined(Vc_VERSION_NUMBER) -#if Vc_VERSION_NUMBER < Vc_VERSION_CHECK(1,0,0) -template To simd_cast(From &&x) { return static_cast(x); } +#if Vc_VERSION_NUMBER < Vc_VERSION_CHECK(1, 0, 0) +template +To simd_cast(From&& x) +{ + return static_cast(x); +} #endif #endif @@ -74,76 +80,85 @@ typedef double Double_t; #include "Rtypes.h" #endif -#include "KFPSimdAllocator.h" -typedef std::vector > kfvector_floatv; +#include "KFPSimdAllocator.h" +typedef std::vector> kfvector_floatv; -typedef std::vector > kfvector_float; -typedef std::vector > kfvector_int; -typedef std::vector > kfvector_uint; +typedef std::vector> kfvector_float; +typedef std::vector> kfvector_int; +typedef std::vector> kfvector_uint; namespace KFPMath { - static inline __attribute__((always_inline)) float_v Sin ( const float_v &phi ) - { - const float_v pi(3.1415926535897932f); - const float_v nTurnsF = (phi + pi) / (float_v(2.f)*pi); - int_v nTurns = simd_cast( nTurnsF ); - nTurns( (nTurns<=int_v(Vc::Zero)) && simd_cast(phi<-pi)) -= 1; - - const float_v& x = phi - simd_cast(nTurns)*(float_v(2.f)*pi); - - const float_v& B = 4.f/pi; - const float_v& C = -B/pi; - - float_v y = (B + C * Vc::abs(x)) * x; - - const float_v& P = 0.218f; - y = P * (y * Vc::abs(y) - y) + y; - - return y; - } - static inline __attribute__((always_inline)) float_v Cos ( const float_v &phi ) - { - return Sin( phi + 1.570796326795f ); //x + pi/2 - } - static inline __attribute__((always_inline)) float_v ATan2( const float_v &y, const float_v &x ) - { - const float_v pi(3.1415926535897932f); - const float_v zero(Vc::Zero); - - const float_m &xZero = (x == zero); - const float_m &yZero = (y == zero); - const float_m &xNeg = (x < zero); - const float_m &yNeg = (y < zero); - - const float_v &absX = Vc::abs(x); - const float_v &absY = Vc::abs(y); - - float_v a = absY / absX; - const float_m >_tan_3pi_8 = (a > float_v(2.414213562373095f)); - const float_m >_tan_pi_8 = (a > float_v(0.4142135623730950f)) && (!gt_tan_3pi_8); - float_v b(Vc::Zero); - b(gt_tan_3pi_8) = pi/2.f; - b(gt_tan_pi_8) = pi/4.f; - a(gt_tan_3pi_8) = (-1.f / a); - a(gt_tan_pi_8) = ((absY - absX) / (absY + absX)) ; - const float_v &a2 = a * a; - b += (((8.05374449538e-2f * a2 - - 1.38776856032E-1f) * a2 - + 1.99777106478E-1f) * a2 - - 3.33329491539E-1f) * a2 * a - + a; - b(xNeg ^ yNeg) = -b; - b(xNeg && !yNeg) = (b+pi); - b(xNeg && yNeg) = (b-pi); - b(xZero && yZero) = zero; - b(xZero && yNeg) = (-pi/2.f); - return b; - } - template static inline __attribute__((always_inline)) - typename Vc::Vector::Mask Finite(const Vc::Vector &x) { return Vc::isfinite( x ); } - template static inline __attribute__((always_inline)) T Log ( const T &x ) { return std::log( x ); } - template static inline __attribute__((always_inline)) T ACos( const T &x ) { return (3.1415926535897f/2.f - asin( x )); } +static inline __attribute__((always_inline)) float_v Sin(const float_v& phi) +{ + const float_v pi(3.1415926535897932f); + const float_v nTurnsF = (phi + pi) / (float_v(2.f) * pi); + int_v nTurns = simd_cast(nTurnsF); + nTurns((nTurns <= int_v(Vc::Zero)) && simd_cast(phi < -pi)) -= 1; + + const float_v& x = phi - simd_cast(nTurns) * (float_v(2.f) * pi); + + const float_v& B = 4.f / pi; + const float_v& C = -B / pi; + + float_v y = (B + C * Vc::abs(x)) * x; + + const float_v& P = 0.218f; + y = P * (y * Vc::abs(y) - y) + y; + + return y; +} +static inline __attribute__((always_inline)) float_v Cos(const float_v& phi) +{ + return Sin(phi + 1.570796326795f); //x + pi/2 } +static inline __attribute__((always_inline)) float_v ATan2(const float_v& y, const float_v& x) +{ + const float_v pi(3.1415926535897932f); + const float_v zero(Vc::Zero); + + const float_m& xZero = (x == zero); + const float_m& yZero = (y == zero); + const float_m& xNeg = (x < zero); + const float_m& yNeg = (y < zero); + + const float_v& absX = Vc::abs(x); + const float_v& absY = Vc::abs(y); + + float_v a = absY / absX; + const float_m& gt_tan_3pi_8 = (a > float_v(2.414213562373095f)); + const float_m& gt_tan_pi_8 = (a > float_v(0.4142135623730950f)) && (!gt_tan_3pi_8); + float_v b(Vc::Zero); + b(gt_tan_3pi_8) = pi / 2.f; + b(gt_tan_pi_8) = pi / 4.f; + a(gt_tan_3pi_8) = (-1.f / a); + a(gt_tan_pi_8) = ((absY - absX) / (absY + absX)); + const float_v& a2 = a * a; + b += (((8.05374449538e-2f * a2 - 1.38776856032E-1f) * a2 + 1.99777106478E-1f) * a2 - 3.33329491539E-1f) * a2 * a + a; + b(xNeg ^ yNeg) = -b; + b(xNeg && !yNeg) = (b + pi); + b(xNeg && yNeg) = (b - pi); + b(xZero && yZero) = zero; + b(xZero && yNeg) = (-pi / 2.f); + return b; +} +template +static inline __attribute__((always_inline)) +typename Vc::Vector::Mask + Finite(const Vc::Vector& x) +{ + return Vc::isfinite(x); +} +template +static inline __attribute__((always_inline)) T Log(const T& x) +{ + return std::log(x); +} +template +static inline __attribute__((always_inline)) T ACos(const T& x) +{ + return (3.1415926535897f / 2.f - asin(x)); +} +} // namespace KFPMath -#endif +#endif diff --git a/KFParticle/KFParticleField.h b/KFParticle/KFParticleField.h index 1b57d47..a3c5080 100644 --- a/KFParticle/KFParticleField.h +++ b/KFParticle/KFParticleField.h @@ -39,29 +39,30 @@ class KFParticleFieldValue { public: - KFParticleFieldValue():x(0.f),y(0.f),z(0.f){}; - - float_v x; ///< Bx component of the magnetic field - float_v y; ///< By component of the magnetic field - float_v z; ///< Bz component of the magnetic field + KFParticleFieldValue() : x(0.f), y(0.f), z(0.f){}; - void Combine( KFParticleFieldValue &B, float_v w ) + float_v x; ///< Bx component of the magnetic field + float_v y; ///< By component of the magnetic field + float_v z; ///< Bz component of the magnetic field + + void Combine(KFParticleFieldValue& B, float_v w) { /** Function allows to combine the current magntic field measurement with another measurement ** weighted by "w" ** \param[in] B - another field measurement to be combined with the current value ** \param[in] w - weight of the measurement being added **/ - x+= w*( B.x - x ); - y+= w*( B.y - y ); - z+= w*( B.z - z ); + x += w * (B.x - x); + y += w * (B.y - y); + z += w * (B.z - z); } /** Operator to print components of the magnetic field in order Bx, By, Bz. ** \param[in] out - output stream where the values will be printed ** \param[in] B - field vecrot to be printed **/ - friend std::ostream& operator<<(std::ostream& out, KFParticleFieldValue &B){ + friend std::ostream& operator<<(std::ostream& out, KFParticleFieldValue& B) + { return out << B.x[0] << " | " << B.y[0] << " | " << B.z[0]; }; }; @@ -81,13 +82,13 @@ class KFParticleFieldValue class KFParticleFieldRegion { public: - KFParticleFieldRegion() {}; + KFParticleFieldRegion(){}; KFParticleFieldRegion(const float field[10]) { /** Sets current vectorised representation of the magnetic field approximation from the scalar input array. ** \param[in] field[10] - the scalar input array with the magnetic field approximation **/ - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) fField[i] = field[i]; } @@ -95,19 +96,19 @@ class KFParticleFieldRegion { /** Returns a magnetic field vector calculated using current parametrisation at the given Z coordinate. ** \param[in] z - value of the Z coordinate, where magnetic field should be calculated. - **/ - float_v dz = (z-fField[9]); - float_v dz2 = dz*dz; + **/ + float_v dz = (z - fField[9]); + float_v dz2 = dz * dz; KFParticleFieldValue B; - B.x = fField[0] + fField[1]*dz + fField[2]*dz2; - B.y = fField[3] + fField[4]*dz + fField[5]*dz2; - B.z = fField[6] + fField[7]*dz + fField[8]*dz2; + B.x = fField[0] + fField[1] * dz + fField[2] * dz2; + B.y = fField[3] + fField[4] * dz + fField[5] * dz2; + B.z = fField[6] + fField[7] * dz + fField[8] * dz2; return B; } - - void Set( const KFParticleFieldValue &B0, const float_v B0z, - const KFParticleFieldValue &B1, const float_v B1z, - const KFParticleFieldValue &B2, const float_v B2z ) + + void Set(const KFParticleFieldValue& B0, const float_v B0z, + const KFParticleFieldValue& B1, const float_v B1z, + const KFParticleFieldValue& B2, const float_v B2z) { /** Approximates the magnetic field with the parabolas using three points along the particle trajectory. ** \param[in] B0 - magnetic field vector at the first point @@ -118,34 +119,34 @@ class KFParticleFieldRegion ** \param[in] B2z - Z position of the third point **/ fField[9] = B0z; - float_v dz1 = B1z-B0z, dz2 = B2z-B0z; - float_v det = 1.f/(float_v(dz1*dz2*(dz2-dz1))); - float_v w21 = -dz2*det; - float_v w22 = dz1*det; - float_v w11 = -dz2*w21; - float_v w12 = -dz1*w22; - + float_v dz1 = B1z - B0z, dz2 = B2z - B0z; + float_v det = 1.f / (float_v(dz1 * dz2 * (dz2 - dz1))); + float_v w21 = -dz2 * det; + float_v w22 = dz1 * det; + float_v w11 = -dz2 * w21; + float_v w12 = -dz1 * w22; + float_v dB1 = B1.x - B0.x; float_v dB2 = B2.x - B0.x; fField[0] = B0.x; - fField[1] = dB1*w11 + dB2*w12 ; - fField[2] = dB1*w21 + dB2*w22 ; - + fField[1] = dB1 * w11 + dB2 * w12; + fField[2] = dB1 * w21 + dB2 * w22; + dB1 = B1.y - B0.y; dB2 = B2.y - B0.y; fField[3] = B0.y; - fField[4] = dB1*w11 + dB2*w12 ; - fField[5] = dB1*w21 + dB2*w22 ; + fField[4] = dB1 * w11 + dB2 * w12; + fField[5] = dB1 * w21 + dB2 * w22; dB1 = B1.z - B0.z; dB2 = B2.z - B0.z; fField[6] = B0.z; - fField[7] = dB1*w11 + dB2*w12 ; - fField[8] = dB1*w21 + dB2*w22 ; + fField[7] = dB1 * w11 + dB2 * w12; + fField[8] = dB1 * w21 + dB2 * w22; } - void Set( const KFParticleFieldValue &B0, const float_v B0z, - const KFParticleFieldValue &B1, const float_v B1z ) + void Set(const KFParticleFieldValue& B0, const float_v B0z, + const KFParticleFieldValue& B1, const float_v B1z) { /** Approximates the magnetic field with the strainght line using two points. ** \param[in] B0 - magnetic field vector at the first point @@ -154,37 +155,37 @@ class KFParticleFieldRegion ** \param[in] B1z - Z position of the second point **/ fField[9] = B0z; - float_v dzi = 1.f/(float_v( B1z - B0z)); + float_v dzi = 1.f / (float_v(B1z - B0z)); fField[0] = B0.x; fField[3] = B0.y; fField[6] = B0.z; - fField[1] = ( B1.x - B0.x )*dzi; - fField[4] = ( B1.y - B0.y )*dzi; - fField[7] = ( B1.z - B0.z )*dzi; + fField[1] = (B1.x - B0.x) * dzi; + fField[4] = (B1.y - B0.y) * dzi; + fField[7] = (B1.z - B0.z) * dzi; fField[2] = fField[5] = fField[8] = 0.f; } - - void SetOneEntry( const float* field, int iEntry=0 ) + + void SetOneEntry(const float* field, int iEntry = 0) { /** Sets one element of the SIMD vector with index iEntry. ** \param[in] field - a scalar input array with the approximation of the magnetic field ** \param[in] iEntry - entry number of the current SIMD vectors to be set with the input approximation **/ - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) fField[i][iEntry] = field[i]; } - - void SetOneEntry( const int i0, const KFParticleFieldRegion &f1, const int i1 ) + + void SetOneEntry(const int i0, const KFParticleFieldRegion& f1, const int i1) { /** Copies the field approximation from the vector f1 with index i1 to the SIMD vector elemets of the current object with index i0. ** \param[in] i0 - index of the SIMD vector elements of the current field approximation to be set ** \param[in] f1 - input approximation of the magnetic field ** \param[in] i1 - index of the SIMD vector elements of the input approximation to be copied to the current object **/ - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) fField[i][i0] = f1.fField[i][i1]; } - + /** The coefficients of the field approximation: \n ** cx0 = fField[0], cx1 = fField[1], cx2 = fField[2] - coefficients of the Bx approximation; \n ** cy0 = fField[3], cy1 = fField[4], cy2 = fField[5] - coefficients of the By approximation; \n @@ -194,8 +195,7 @@ class KFParticleFieldRegion ** By(z) = cy0 + cy1*(z-z0) + cy2*(z-z0)^2 \n ** Bz(z) = cz0 + cz1*(z-z0) + cz2*(z-z0)^2 **/ - float_v fField[10]; + float_v fField[10]; }; - #endif diff --git a/KFParticle/KFParticleFinder.cxx b/KFParticle/KFParticleFinder.cxx index ab3740e..646181c 100644 --- a/KFParticle/KFParticleFinder.cxx +++ b/KFParticle/KFParticleFinder.cxx @@ -27,60 +27,71 @@ using std::vector; #include "KFParticleDatabase.h" #include "KFPEmcCluster.h" -KFParticleFinder::KFParticleFinder(): - fNPV(-1),fNThreads(1),fDistanceCut(1.f),fLCut(-5.f),fCutCharmPt(0.2f),fCutCharmChiPrim(85.f),fCutLVMPt(0.0f),fCutLVMP(0.0f),fCutJPsiPt(1.0f), - fD0(0), fD0bar(0), fD04(0), fD04bar(0), fD0KK(0), fD0pipi(0), fDPlus(0), fDMinus(0), - fDPlus3Pi(0), fDMinus3Pi(0), fDsPlusK2Pi(0), fDsMinusK2Pi(0), fLcPlusP2Pi(0), fLcMinusP2Pi(0), - fLPi(0), fLPiPIndex(0), fHe3Pi(0), fHe3PiBar(0), fHe4Pi(0), fHe4PiBar(0), - fHe4L(0), fHe5L(0), fLLn(0), fH5LL(0), - fSecCandidates(), fPrimCandidates(), fPrimCandidatesTopo(),fPrimCandidatesTopoMass(), - fEmcClusters(0), fMixedEventAnalysis(0), fDecayReconstructionList() +KFParticleFinder::KFParticleFinder() : fNPV(-1), fNThreads(1), fDistanceCut(1.f), fLCut(-5.f), fCutCharmPt(0.2f), fCutCharmChiPrim(85.f), fCutLVMPt(0.0f), fCutLVMP(0.0f), fCutJPsiPt(1.0f), fD0(0), fD0bar(0), fD04(0), fD04bar(0), fD0KK(0), fD0pipi(0), fDPlus(0), fDMinus(0), fDPlus3Pi(0), fDMinus3Pi(0), fDsPlusK2Pi(0), fDsMinusK2Pi(0), fLcPlusP2Pi(0), fLcMinusP2Pi(0), fLPi(0), fLPiPIndex(0), fHe3Pi(0), fHe3PiBar(0), fHe4Pi(0), fHe4PiBar(0), fHe4L(0), fHe5L(0), fLLn(0), fH5LL(0), fSecCandidates(), fPrimCandidates(), fPrimCandidatesTopo(), fPrimCandidatesTopoMass(), fEmcClusters(0), fMixedEventAnalysis(0), fDecayReconstructionList() { /** The default constructor. Initialises all cuts to the default values. **/ //Cuts //track + track //chi2_prim chi2_geo ldl - fCuts2D[0] = 3.f; fCuts2D[1] = 3.f; fCuts2D[2] = 5.f; + fCuts2D[0] = 3.f; + fCuts2D[1] = 3.f; + fCuts2D[2] = 5.f; //cuts to select primary and secondary particles //mass chi2_topo ldl #ifdef PANDA_STT - fSecCuts[0] = 3.f; fSecCuts[1] = -3.f; fSecCuts[2] = 10.f; -#else - fSecCuts[0] = 3.f; fSecCuts[1] = 5.f; fSecCuts[2] = 10.f; + fSecCuts[0] = 3.f; + fSecCuts[1] = -3.f; + fSecCuts[2] = 10.f; +#else + fSecCuts[0] = 3.f; + fSecCuts[1] = 5.f; + fSecCuts[2] = 10.f; #endif - + #ifdef __ROOT__ fCutCharmChiPrim = 8; #endif - + //track + particle // ldl chi2_topo chi2_geo - fCutsTrackV0[0][0] = 5; fCutsTrackV0[0][1] = 5; fCutsTrackV0[0][2] = 6; //Xi, Omega - fCutsTrackV0[1][0] = 5; fCutsTrackV0[1][1] = 5; fCutsTrackV0[1][2] = 6; //Charm, H0, Sigma+ - fCutsTrackV0[2][0] = -100.; fCutsTrackV0[2][1] = 10000.; fCutsTrackV0[2][2] = 3; //resonances - + fCutsTrackV0[0][0] = 5; + fCutsTrackV0[0][1] = 5; + fCutsTrackV0[0][2] = 6; //Xi, Omega + fCutsTrackV0[1][0] = 5; + fCutsTrackV0[1][1] = 5; + fCutsTrackV0[1][2] = 6; //Charm, H0, Sigma+ + fCutsTrackV0[2][0] = -100.; + fCutsTrackV0[2][1] = 10000.; + fCutsTrackV0[2][2] = 3; //resonances + //charm //chi2 l/dl chi2_topo - fCutsCharm[0] = 3.f; fCutsCharm[1] = 10.f; fCutsCharm[2] = 3.f; //D0 -> pi+ K- - + fCutsCharm[0] = 3.f; + fCutsCharm[1] = 10.f; + fCutsCharm[2] = 3.f; //D0 -> pi+ K- + //cuts on particles reconstructed from short-lived particles //ldl, chi2_topo chi2_geo //H0 -> Lambda Lambda, Xi0 -> Lambda pi0 - fCutsPartPart[0][0] = 10; fCutsPartPart[0][1] = 3; fCutsPartPart[0][2] = 3; + fCutsPartPart[0][0] = 10; + fCutsPartPart[0][1] = 3; + fCutsPartPart[0][2] = 3; //Sigma0 -> Lambda Gamma, pi0 -> Gamma Gamma, K* -> K pi0, Sigma*0 -> Lambda pi0, Xi* -> Xi pi0 - fCutsPartPart[1][0] = -10; fCutsPartPart[1][1] = 3; fCutsPartPart[1][2] = 3; + fCutsPartPart[1][0] = -10; + fCutsPartPart[1][1] = 3; + fCutsPartPart[1][2] = 3; } //________________________________________________________________________________ -void KFParticleFinder::Init(int nPV) +void KFParticleFinder::Init(int nPV) { /** Initialises the new event: all vectors with temporary candidates are cleaned, the number of ** primary vertices is set to "nPV", vectors with primary candidates are resized correspondingly. ** \param[in] nPV - number of primary vertices in the event which will be processed **/ - + fNPV = nPV; -// Particles.reserve(vRTracks.size() + nPart); + // Particles.reserve(vRTracks.size() + nPart); fD0.clear(); fD0bar.clear(); @@ -106,30 +117,27 @@ void KFParticleFinder::Init(int nPV) fHe5L.clear(); fLLn.clear(); fH5LL.clear(); - - for(int iCandidates=0; iCandidates& Particles, - std::vector >& PrimVtx, int nPV) + std::vector>& PrimVtx, int nPV) { /** The main interface which runs reconstruction of short-lived particles:\n ** 1) a new event is initialised; \n @@ -155,70 +163,67 @@ void KFParticleFinder::FindParticles(KFPTrackVector* vRTracks, kfvector_float* C ** \param[in] PrimVtx - vector with primary vertices. ** \param[in] nPV - number of the input primary vertices. **/ - + Init(nPV); - const int nPartPrim = vRTracks[2].NPions() * vRTracks[3].NKaons() + - vRTracks[3].NPions() * vRTracks[2].NKaons() + - vRTracks[2].NKaons() * vRTracks[3].NKaons() + - vRTracks[2].NKaons() * vRTracks[3].NProtons() + - vRTracks[3].NKaons() * vRTracks[2].NProtons() + - vRTracks[2].NElectrons() * vRTracks[3].NElectrons() + + const int nPartPrim = vRTracks[2].NPions() * vRTracks[3].NKaons() + + vRTracks[3].NPions() * vRTracks[2].NKaons() + + vRTracks[2].NKaons() * vRTracks[3].NKaons() + + vRTracks[2].NKaons() * vRTracks[3].NProtons() + + vRTracks[3].NKaons() * vRTracks[2].NProtons() + + vRTracks[2].NElectrons() * vRTracks[3].NElectrons() + vRTracks[2].NMuons() * vRTracks[3].NMuons(); const int nPart = vRTracks[0].NPions() * vRTracks[1].NPions() + vRTracks[0].NPions() * vRTracks[1].NProtons() + vRTracks[1].NPions() * vRTracks[0].NProtons() + nPartPrim; int nEmcClusters = 0; - if(fEmcClusters) + if (fEmcClusters) nEmcClusters = fEmcClusters->Size(); vector vGammaPrimEmc; - int nPartEstimation = nPart+vRTracks[0].Size()+vRTracks[1].Size()+vRTracks[2].Size()+vRTracks[3].Size() + nEmcClusters; + int nPartEstimation = nPart + vRTracks[0].Size() + vRTracks[1].Size() + vRTracks[2].Size() + vRTracks[3].Size() + nEmcClusters; - if(nPartEstimation < 100000) + if (nPartEstimation < 100000) Particles.reserve(nPartEstimation); //* Finds particles (K0s and Lambda) from a given set of tracks { KFPTrack kfTrack; - for(int iV=0; iV<4; iV++) - { - for(int iTr=0; iTr < vRTracks[iV].Size(); iTr++) - { + for (int iV = 0; iV < 4; iV++) { + for (int iTr = 0; iTr < vRTracks[iV].Size(); iTr++) { vRTracks[iV].GetTrack(kfTrack, iTr); int pdg = vRTracks[iV].PDG()[iTr]; - if( pdg == 19 ) pdg = 13; - if( pdg ==-19 ) pdg = -13; + if (pdg == 19) + pdg = 13; + if (pdg == -19) + pdg = -13; KFParticle tmp(kfTrack, pdg); tmp.SetPDG(pdg); tmp.SetId(Particles.size()); - vRTracks[iV].SetId(Particles.size(),iTr); - if(vRTracks[iV+4].Size() > 0) - vRTracks[iV+4].SetId(Particles.size(),iTr); - tmp.AddDaughterId( kfTrack.Id() ); + vRTracks[iV].SetId(Particles.size(), iTr); + if (vRTracks[iV + 4].Size() > 0) + vRTracks[iV + 4].SetId(Particles.size(), iTr); + tmp.AddDaughterId(kfTrack.Id()); #ifdef NonhomogeneousField - for(int iF=0; iF<10; iF++) - tmp.SetFieldCoeff( vRTracks[iV].FieldCoefficient(iF)[iTr], iF); + for (int iF = 0; iF < 10; iF++) + tmp.SetFieldCoeff(vRTracks[iV].FieldCoefficient(iF)[iTr], iF); #endif Particles.push_back(tmp); } } - if(fEmcClusters) - { + if (fEmcClusters) { KFParticleSIMD tmpGammaSIMD; KFParticle tmpGamma; - - for(int iEmc=0; iEmc < fEmcClusters->Size(); iEmc += float_vLen) - { + + for (int iEmc = 0; iEmc < fEmcClusters->Size(); iEmc += float_vLen) { const int NClustersVec = (iEmc + float_vLen < fEmcClusters->Size()) ? float_vLen : (fEmcClusters->Size() - iEmc); tmpGammaSIMD.Load(*fEmcClusters, iEmc, PrimVtx[0]); - for(int iV=0; iVId()[iEmc+iV]); + tmpGamma.AddDaughterId(fEmcClusters->Id()[iEmc + iV]); Particles.push_back(tmpGamma); vGammaPrimEmc.push_back(tmpGamma); } @@ -226,379 +231,369 @@ void KFParticleFinder::FindParticles(KFPTrackVector* vRTracks, kfvector_float* C } } - - Find2DaughterDecay(vRTracks, ChiToPrimVtx, Particles, PrimVtx, fCuts2D, fSecCuts, fPrimCandidates, fSecCandidates); - if(!fMixedEventAnalysis) - { + if (!fMixedEventAnalysis) { //Construct two-particle background from positive primary tracks for subtraction from the resonance spectra ConstructPrimaryBG(vRTracks, Particles, PrimVtx, fCuts2D, fSecCuts, fPrimCandidates, fSecCandidates); - - for(int iPV=0; iPV Lambda pi-, Omega- -> Lambda K- FindTrackV0Decay(fSecCandidates[1], 3122, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastKaon(), - Particles, PrimVtx, -1, &(ChiToPrimVtx[1]), &fPrimCandidates[5]); + Particles, PrimVtx, -1, &(ChiToPrimVtx[1]), &fPrimCandidates[5]); //Xi+ -> Lambda pi+, Omega+ -> Lambda K+ FindTrackV0Decay(fSecCandidates[2], -3122, vRTracks[0], 1, vRTracks[0].FirstPion(), vRTracks[0].LastKaon(), - Particles, PrimVtx, -1, &(ChiToPrimVtx[0]), &fPrimCandidates[6]); + Particles, PrimVtx, -1, &(ChiToPrimVtx[0]), &fPrimCandidates[6]); - for(int iPV=0; iPV K0 pi+ - for(int iPV=0; iPV K0 pi- - for(int iPV=0; iPV Lambda pi+ - for(int iPV=0; iPV Lambda pi-, Xi*- -> Lambda K- - for(int iPV=0; iPV Lambda_bar pi- - for(int iPV=0; iPV Lambda_bar pi+, Xi*+ -> Lambda_bar + K+ - for(int iPV=0; iPV Xi- pi+ - for(int iPV=0; iPV Xi+ pi- - for(int iPV=0; iPV Xi- pi+ K- - for(int iPV=0; iPV Xi+ pi- K+ - for(int iPV=0; iPV He3 p pi- - FindTrackV0Decay(fHe3Pi , 3004, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), Particles, PrimVtx, -1, 0, 0, &fHe4L); + FindTrackV0Decay(fHe3Pi, 3004, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), Particles, PrimVtx, -1, 0, 0, &fHe4L); //LLn -> H3L pi- - FindTrackV0Decay(fHe3Pi , 3004, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastPion(), Particles, PrimVtx, -1, 0 ); + FindTrackV0Decay(fHe3Pi, 3004, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastPion(), Particles, PrimVtx, -1, 0); //He4L_bar -> He3_bar p- pi+ - FindTrackV0Decay(fHe3PiBar,-3004, vRTracks[1], -1, vRTracks[1].FirstProton(), vRTracks[1].LastProton(), Particles, PrimVtx, -1, 0); + FindTrackV0Decay(fHe3PiBar, -3004, vRTracks[1], -1, vRTracks[1].FirstProton(), vRTracks[1].LastProton(), Particles, PrimVtx, -1, 0); //He5L -> He4 p pi- - FindTrackV0Decay(fHe4Pi , 3005, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), Particles, PrimVtx, -1, 0, 0, &fHe5L); + FindTrackV0Decay(fHe4Pi, 3005, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), Particles, PrimVtx, -1, 0, 0, &fHe5L); //He5L_bar -> He4_bar p- pi+ - FindTrackV0Decay(fHe4PiBar,-3005, vRTracks[1], -1, vRTracks[1].FirstProton(), vRTracks[1].LastProton(), Particles, PrimVtx, -1, 0); + FindTrackV0Decay(fHe4PiBar, -3005, vRTracks[1], -1, vRTracks[1].FirstProton(), vRTracks[1].LastProton(), Particles, PrimVtx, -1, 0); //H4LL -> He4L pi- - FindTrackV0Decay(fHe4L , 3006, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastPion(), Particles, PrimVtx, -1, 0 ); + FindTrackV0Decay(fHe4L, 3006, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastPion(), Particles, PrimVtx, -1, 0); //H5LL -> He5L pi- - FindTrackV0Decay(fHe5L , 3007, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastPion(), Particles, PrimVtx, -1, 0 ); + FindTrackV0Decay(fHe5L, 3007, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastPion(), Particles, PrimVtx, -1, 0); //H4LL -> H3L p pi- - FindTrackV0Decay(fLLn , 3203, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), Particles, PrimVtx, -1, 0 ); + FindTrackV0Decay(fLLn, 3203, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), Particles, PrimVtx, -1, 0); //He6LL -> He5L p pi- - FindTrackV0Decay(fH5LL , 3010, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), Particles, PrimVtx, -1, 0 ); + FindTrackV0Decay(fH5LL, 3010, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), Particles, PrimVtx, -1, 0); // Charm //LambdaC -> pi+ K- p, Ds+ -> pi+ K- K+, D+ -> pi+ K- pi+ FindTrackV0Decay(fD0, 421, vRTracks[0], 1, vRTracks[0].FirstPion(), vRTracks[0].LastProton(), - Particles, PrimVtx, -1, &(ChiToPrimVtx[0])); + Particles, PrimVtx, -1, &(ChiToPrimVtx[0])); //LambdaC_bar -> pi- K+ p-, Ds- -> pi- K+ K-, D- -> pi- K+ pi- FindTrackV0Decay(fD0bar, -421, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastProton(), - Particles, PrimVtx, -1, &(ChiToPrimVtx[1])); + Particles, PrimVtx, -1, &(ChiToPrimVtx[1])); //D0->pi+ K- pi+ pi- FindTrackV0Decay(fDPlus, 411, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastPion(), - Particles, PrimVtx, -1, &(ChiToPrimVtx[1])); + Particles, PrimVtx, -1, &(ChiToPrimVtx[1])); //D0_bar->pi- K+ pi- pi+ FindTrackV0Decay(fDMinus, -411, vRTracks[0], 1, vRTracks[0].FirstPion(), vRTracks[0].LastPion(), - Particles, PrimVtx, -1, &(ChiToPrimVtx[0])); + Particles, PrimVtx, -1, &(ChiToPrimVtx[0])); //B+ -> D0_bar pi+, B+ -> D0_bar K+ FindTrackV0Decay(fD0bar, -421, vRTracks[0], 1, vRTracks[0].FirstPion(), vRTracks[0].LastKaon(), - Particles, PrimVtx, -1, &(ChiToPrimVtx[0])); + Particles, PrimVtx, -1, &(ChiToPrimVtx[0])); //B- -> D0 pi-, B- -> D0 K- FindTrackV0Decay(fD0, 421, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastKaon(), Particles, PrimVtx, -1, &(ChiToPrimVtx[1])); //B0 -> D- pi+, B0 -> D- K+ FindTrackV0Decay(fDMinus, -419, vRTracks[0], 1, vRTracks[0].FirstPion(), vRTracks[0].LastKaon(), - Particles, PrimVtx, -1, &(ChiToPrimVtx[0])); + Particles, PrimVtx, -1, &(ChiToPrimVtx[0])); //B0_bar -> D+ pi-, B0_bar -> D+ K- FindTrackV0Decay(fDPlus, 419, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastKaon(), Particles, PrimVtx, -1, &(ChiToPrimVtx[1])); //D0 -> pi+ K- - SelectParticles(Particles,fD0,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fD0, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //D0_bar -> pi+ K- - SelectParticles(Particles,fD0bar,PrimVtx,fCutsCharm[2],fCutsCharm[1], - KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); + SelectParticles(Particles, fD0bar, PrimVtx, fCutsCharm[2], fCutsCharm[1], + KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //D*+->D0 pi+ - for(int iPV=0; iPV D0_bar pi- - for(int iPV=0; iPV pi+ K- pi+ pi- - SelectParticles(Particles,fD04,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fD04, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //D0_bar -> pi- K+ pi- pi+ - SelectParticles(Particles,fD04bar,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fD04bar, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //D*+->D0 pi+ - for(int iPV=0; iPV D0_bar pi- - for(int iPV=0; iPVGetDPlusMass(), KFParticleDatabase::Instance()->GetDPlusMassSigma(), fSecCuts[0]); //D- - SelectParticles(Particles,fDMinus,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fDMinus, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetDPlusMass(), KFParticleDatabase::Instance()->GetDPlusMassSigma(), fSecCuts[0]); //D*0->D+ pi- - for(int iPV=0; iPVD- pi+ - for(int iPV=0; iPV K0 pi+ pi- - for(int iPV=0; iPV K0 K+ K- - for(int iPV=0; iPV p pi+ pi-, Ds+ -> K+ pi+ pi-, D+ -> pi+ pi+ pi- FindTrackV0Decay(fD0pipi, 420, vRTracks[0], 1, vRTracks[0].FirstPion(), vRTracks[0].LastProton(), Particles, PrimVtx, -1, &(ChiToPrimVtx[0])); //LambdaC_bar -> p_bar pi+ pi-, Ds- -> K- pi+ pi-, D- -> pi+ pi- pi- - FindTrackV0Decay(fD0pipi, 420, vRTracks[1],-1, vRTracks[1].FirstPion(), vRTracks[1].LastProton(), + FindTrackV0Decay(fD0pipi, 420, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastProton(), Particles, PrimVtx, -1, &(ChiToPrimVtx[1])); - + //D+ -> K0 pi+ pi+ pi- - for(int iPV=0; iPV K0 pi+ pi- pi- - for(int iPV=0; iPV Lambda pi+ pi+ pi- - for(int iPV=0; iPV Lambda_bar pi+ pi- pi- - for(int iPV=0; iPV Xi- pi+ pi+ pi- - for(int iPV=0; iPV Xi+ pi+ pi- pi- - for(int iPV=0; iPV K0 K+ pi+ pi- - for(int iPV=0; iPV K0 K- pi+ pi- - for(int iPV=0; iPV p K0 pi+ pi- - for(int iPV=0; iPV p- K0 pi+ pi- - for(int iPV=0; iPV pi+ pi- - SelectParticles(Particles,fD0pipi,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fD0pipi, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //D0 -> K+ K- - SelectParticles(Particles,fD0KK,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fD0KK, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //D+ -> pi+ pi+ pi- - SelectParticles(Particles,fDPlus3Pi,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fDPlus3Pi, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetDPlusMass(), KFParticleDatabase::Instance()->GetDPlusMassSigma(), fSecCuts[0]); //D- -> pi+ pi- pi- - SelectParticles(Particles,fDMinus3Pi,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fDMinus3Pi, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetDPlusMass(), KFParticleDatabase::Instance()->GetDPlusMassSigma(), fSecCuts[0]); - //Ds+ -> K+ pi+ pi-, - SelectParticles(Particles,fDsPlusK2Pi,PrimVtx,fCutsCharm[2],fCutsCharm[1], + //Ds+ -> K+ pi+ pi-, + SelectParticles(Particles, fDsPlusK2Pi, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //Ds- -> K- pi+ pi- - SelectParticles(Particles,fDsMinusK2Pi,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fDsMinusK2Pi, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //LambdaC -> p pi+ pi- - SelectParticles(Particles,fLcPlusP2Pi,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fLcPlusP2Pi, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //LambdaC_bar -> p_bar pi+ pi- - SelectParticles(Particles,fLcMinusP2Pi,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fLcMinusP2Pi, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); - - + //D+ -> K0 pi+ - for(int iPV=0; iPV K0 pi- - for(int iPV=0; iPV K0 K+ - for(int iPV=0; iPV K0 K- - for(int iPV=0; iPV Lambda pi+ - for(int iPV=0; iPV Lambda_bar pi- - for(int iPV=0; iPV p K0s - for(int iPV=0; iPV p_bar K0s - for(int iPV=0; iPV Lambda Lambda CombinePartPart(fSecCandidates[1], fSecCandidates[1], Particles, PrimVtx, fCutsPartPart[0], -1, 3000, 1, 1); //H0 -> Lambda p pi- FindTrackV0Decay(fLPi, 3002, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), - Particles, PrimVtx, -1); + Particles, PrimVtx, -1); //Sigma0 -> Lambda Gamma - for(int iPV=0; iPV Lambda_bar Gamma - for(int iPV=0; iPV gamma gamma const float& mPi0 = KFParticleDatabase::Instance()->GetPi0Mass(); const float& mPi0Sigma = KFParticleDatabase::Instance()->GetPi0MassSigma(); CombinePartPart(fSecCandidates[3], fSecCandidates[3], Particles, PrimVtx, fCutsPartPart[1], -1, 111, 1, 0, &fPrimCandidates[4], &fSecCandidates[4], mPi0, mPi0Sigma); - for(int iPV=0; iPV pi0 pi0 pi0 //TODO implement this //Sigma+ -> p pi0 - FindTrackV0Decay(fSecCandidates[4], 111, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), - Particles, PrimVtx, -1); + FindTrackV0Decay(fSecCandidates[4], 111, vRTracks[0], 1, vRTracks[0].FirstProton(), vRTracks[0].LastProton(), + Particles, PrimVtx, -1); //Sigma+_bar -> p- pi0 FindTrackV0Decay(fSecCandidates[4], 111, vRTracks[1], -1, vRTracks[1].FirstProton(), vRTracks[1].LastProton(), - Particles, PrimVtx, -1); + Particles, PrimVtx, -1); //Xi0 -> Lambda pi0 CombinePartPart(fSecCandidates[4], fSecCandidates[1], Particles, PrimVtx, fCutsPartPart[0], -1, 3322); //Xi0_bar -> Lambda_bar pi0 CombinePartPart(fSecCandidates[4], fSecCandidates[2], Particles, PrimVtx, fCutsPartPart[0], -1, -3322); //K*+ -> K+ pi0 - for(int iPV=0; iPV K- pi0 - for(int iPV=0; iPV K0 pi0 - for(int iPV=0; iPV Lambda pi0 - for(int iPV=0; iPV Lambda_bar pi0 - for(int iPV=0; iPV Xi- pi0 - for(int iPV=0; iPV Xi+ pi0 - for(int iPV=0; iPV Lambda Lambda_bar - for(int iPV=0; iPV Xi- Xi+ - for(int iPV=0; iPV Omega- Omega+ - for(int iPV=0; iPV gamma gamma, EMC -// vector< vector > vPi0PrimEmc(1); -// vector vPi0SecEmc; -// vector< vector > vD0PrimEmc(1); -// CombinePartPart(vGammaPrimEmc, vGammaPrimEmc, Particles, PrimVtx, fCutsPartPart[1], 0, 111, 1, 0, &vPi0PrimEmc, &vPi0SecEmc, mPi0, mPi0Sigma); -// -// //D+ -> K0 pi+ -// FindTrackV0Decay(fSecCandidates[0], 310, vRTracks[0], 1, vRTracks[0].FirstPion(), vRTracks[0].LastPion(), Particles, PrimVtx, -1/*, &(ChiToPrimVtx[0])*/); -// //D0 -> K0 pi+ pi- -// FindTrackV0Decay(fK0PiPlus, 100411, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastPion(), Particles, PrimVtx, -1/*, &(ChiToPrimVtx[0])*/); -// //D0 -> K0 pi+ pi- pi0 -// CombinePartPart(fK0PiPi, vPi0PrimEmc[0], Particles, PrimVtx, fCutsPartPart[1], -1, 428, 0, 0, &vD0PrimEmc, 0, -// KFParticleDatabase::Instance()->GetD0Mass(), 0.025); -// -// for(int iPV=0; iPV<1; iPV++ ) -// { -// ExtrapolateToPV(vPi0PrimEmc[iPV],PrimVtx[iPV]); -// ExtrapolateToPV(vD0PrimEmc[iPV],PrimVtx[iPV]); -// } -// //D0* -> D0 pi0 -// CombinePartPart(vD0PrimEmc[0], vPi0PrimEmc[0], Particles, PrimVtx, fCutsPartPart[1], 0, 10428); -// } - } - else - { + // if(fEmcClusters) + // { + // //pi0 -> gamma gamma, EMC + // vector< vector > vPi0PrimEmc(1); + // vector vPi0SecEmc; + // vector< vector > vD0PrimEmc(1); + // CombinePartPart(vGammaPrimEmc, vGammaPrimEmc, Particles, PrimVtx, fCutsPartPart[1], 0, 111, 1, 0, &vPi0PrimEmc, &vPi0SecEmc, mPi0, mPi0Sigma); + // + // //D+ -> K0 pi+ + // FindTrackV0Decay(fSecCandidates[0], 310, vRTracks[0], 1, vRTracks[0].FirstPion(), vRTracks[0].LastPion(), Particles, PrimVtx, -1/*, &(ChiToPrimVtx[0])*/); + // //D0 -> K0 pi+ pi- + // FindTrackV0Decay(fK0PiPlus, 100411, vRTracks[1], -1, vRTracks[1].FirstPion(), vRTracks[1].LastPion(), Particles, PrimVtx, -1/*, &(ChiToPrimVtx[0])*/); + // //D0 -> K0 pi+ pi- pi0 + // CombinePartPart(fK0PiPi, vPi0PrimEmc[0], Particles, PrimVtx, fCutsPartPart[1], -1, 428, 0, 0, &vD0PrimEmc, 0, + // KFParticleDatabase::Instance()->GetD0Mass(), 0.025); + // + // for(int iPV=0; iPV<1; iPV++ ) + // { + // ExtrapolateToPV(vPi0PrimEmc[iPV],PrimVtx[iPV]); + // ExtrapolateToPV(vD0PrimEmc[iPV],PrimVtx[iPV]); + // } + // //D0* -> D0 pi0 + // CombinePartPart(vD0PrimEmc[0], vPi0PrimEmc[0], Particles, PrimVtx, fCutsPartPart[1], 0, 10428); + // } + } else { //D0 -> pi+ K- - SelectParticles(Particles,fD0,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fD0, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); //D0_bar -> pi+ K- - SelectParticles(Particles,fD0bar,PrimVtx,fCutsCharm[2],fCutsCharm[1], + SelectParticles(Particles, fD0bar, PrimVtx, fCutsCharm[2], fCutsCharm[1], KFParticleDatabase::Instance()->GetD0Mass(), KFParticleDatabase::Instance()->GetD0MassSigma(), fSecCuts[0]); } } @@ -611,27 +606,24 @@ void KFParticleFinder::ExtrapolateToPV(vector& vParticles, KFParticl **/ KFParticle* parts[float_vLen]; KFParticle tmpPart[float_vLen]; - - for(int iv=0; iv& Particles, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float* cuts, const int_v& pvIndex, const float* secCuts, @@ -657,9 +649,8 @@ inline void KFParticleFinder::ConstructV0(KFPTrackVector* vTracks, const float_v& massMotherPDGSigma, KFParticleSIMD& motherPrimSecCand, int& nPrimSecCand, - vector< vector >* vMotherPrim, - vector* vMotherSec - ) + vector>* vMotherPrim, + vector* vMotherSec) { /** Combines two SIMD vectors of particles into 2-daughter candidate. ** \param[in] vRTracks - pointer to the array with vectors of tracks:\n @@ -695,173 +686,160 @@ inline void KFParticleFinder::ConstructV0(KFPTrackVector* vTracks, ** \param[out] vMotherPrim - array with output primary candidates if any. ** \param[out] vMotherSec - array with output secondary candidates if any. **/ - float_m isPrimary(simd_cast(pvIndex>-1)); + float_m isPrimary(simd_cast(pvIndex > -1)); int_v trackId; - KFParticleSIMD posDaughter(vTracks[iTrTypePos],idPosDaughters, daughterPosPDG); - trackId.gather( &(vTracks[iTrTypePos].Id()[0]), idPosDaughters ); + KFParticleSIMD posDaughter(vTracks[iTrTypePos], idPosDaughters, daughterPosPDG); + trackId.gather(&(vTracks[iTrTypePos].Id()[0]), idPosDaughters); posDaughter.SetId(trackId); - KFParticleSIMD negDaughter(vTracks[iTrTypeNeg],idNegDaughters, daughterNegPDG); - trackId.gather( &(vTracks[iTrTypeNeg].Id()[0]), idNegDaughters ); - negDaughter.SetId(trackId); + KFParticleSIMD negDaughter(vTracks[iTrTypeNeg], idNegDaughters, daughterNegPDG); + trackId.gather(&(vTracks[iTrTypeNeg].Id()[0]), idNegDaughters); + negDaughter.SetId(trackId); #ifdef CBM - float_v ds[2] = {0.f,0.f}; + float_v ds[2] = {0.f, 0.f}; float_v dsdr[4][6]; - negDaughter.GetDStoParticle( posDaughter, ds, dsdr ); + negDaughter.GetDStoParticle(posDaughter, ds, dsdr); negDaughter.TransportToDS(ds[0], dsdr[0]); posDaughter.TransportToDS(ds[1], dsdr[3]); #endif const KFParticleSIMD* vDaughtersPointer[2] = {&negDaughter, &posDaughter}; mother.Construct(vDaughtersPointer, 2, 0); - + float_m saveParticle(simd_cast(int_v::IndexesFromZero() < int(NTracks))); float_v chi2Cut = cuts[1]; - float_v ldlCut = cuts[2]; - if( !(simd_cast(abs(mother.PDG()) == 421 || abs(mother.PDG()) == 426 || abs(mother.PDG()) == 420)).isEmpty() ) - { - chi2Cut( simd_cast(abs(mother.PDG()) == 421 || abs(mother.PDG()) == 426 || abs(mother.PDG()) == 420) ) = fCutsCharm[0]; - ldlCut( simd_cast(abs(mother.PDG()) == 421 || abs(mother.PDG()) == 426 || abs(mother.PDG()) == 420) ) = -1;//fCutsCharm[1]; + float_v ldlCut = cuts[2]; + if (!(simd_cast(abs(mother.PDG()) == 421 || abs(mother.PDG()) == 426 || abs(mother.PDG()) == 420)).isEmpty()) { + chi2Cut(simd_cast(abs(mother.PDG()) == 421 || abs(mother.PDG()) == 426 || abs(mother.PDG()) == 420)) = fCutsCharm[0]; + ldlCut(simd_cast(abs(mother.PDG()) == 421 || abs(mother.PDG()) == 426 || abs(mother.PDG()) == 420)) = -1; //fCutsCharm[1]; } - - saveParticle &= (mother.Chi2()/simd_cast(mother.NDF()) < chi2Cut ); + + saveParticle &= (mother.Chi2() / simd_cast(mother.NDF()) < chi2Cut); saveParticle &= KFPMath::Finite(mother.GetChi2()); saveParticle &= (mother.GetChi2() > 0.0f); saveParticle &= (mother.GetChi2() == mother.GetChi2()); - if( saveParticle.isEmpty() ) return; - + if (saveParticle.isEmpty()) + return; + float_v lMin(1.e8f); float_v ldlMin(1.e8f); float_m isParticleFromVertex(false); - for(int iP=0; iP ldlCut) || float_m(isPrimary) ); - + saveParticle &= ((float_m(!isPrimary) && ldlMin > ldlCut) || float_m(isPrimary)); + saveParticle &= (float_m(!isPrimary) && isParticleFromVertex) || isPrimary; - if( saveParticle.isEmpty() ) return; - - float_m isK0 = saveParticle && simd_cast(mother.PDG() == int_v(310)); + if (saveParticle.isEmpty()) + return; + + float_m isK0 = saveParticle && simd_cast(mother.PDG() == int_v(310)); float_m isLambda = saveParticle && simd_cast(abs(mother.PDG()) == int_v(3122)); - float_m isGamma = saveParticle && simd_cast(mother.PDG() == int_v(22)); + float_m isGamma = saveParticle && simd_cast(mother.PDG() == int_v(22)); float_m isHyperNuclei = saveParticle && simd_cast(abs(mother.PDG()) > 3000 && abs(mother.PDG()) < 3104); - - saveParticle &= ( ((isK0 || isLambda || isHyperNuclei) && lMin > float_v(fLCut)) || !(isK0 || isLambda || isHyperNuclei) ); + + saveParticle &= (((isK0 || isLambda || isHyperNuclei) && lMin > float_v(fLCut)) || !(isK0 || isLambda || isHyperNuclei)); float_m saveMother(false); - - if( !(isK0.isEmpty()) || !(isLambda.isEmpty()) || !(isGamma.isEmpty())) - { + + if (!(isK0.isEmpty()) || !(isLambda.isEmpty()) || !(isGamma.isEmpty())) { float_v mass, errMass; mother.GetMass(mass, errMass); saveMother = saveParticle; - saveMother &= (abs(mass - massMotherPDG)/massMotherPDGSigma) < secCuts[0]; + saveMother &= (abs(mass - massMotherPDG) / massMotherPDGSigma) < secCuts[0]; saveMother &= ((ldlMin > secCuts[2]) && !isGamma) || isGamma; saveMother &= (isK0 || isLambda || isGamma); } - - for(int iv=0; ivfCutLVMPt*fCutLVMPt) && (posPt2 >fCutLVMPt*fCutLVMPt) ) - { + if (mother.PDG()[iv] == 22 && isPrimary[iv]) { + float negPt2 = negDaughter.Px()[iv] * negDaughter.Px()[iv] + negDaughter.Py()[iv] * negDaughter.Py()[iv]; + float posPt2 = posDaughter.Px()[iv] * posDaughter.Px()[iv] + posDaughter.Py()[iv] * posDaughter.Py()[iv]; + + if ((negPt2 > fCutLVMPt * fCutLVMPt) && (posPt2 > fCutLVMPt * fCutLVMPt)) { mother_temp.SetPDG(100113); mother_temp.SetId(Particles.size()); Particles.push_back(mother_temp); - - if( (negPt2 >fCutJPsiPt*fCutJPsiPt) && (posPt2 >fCutJPsiPt*fCutJPsiPt) ) - { + + if ((negPt2 > fCutJPsiPt * fCutJPsiPt) && (posPt2 > fCutJPsiPt * fCutJPsiPt)) { mother_temp.SetPDG(443); mother_temp.SetId(Particles.size()); Particles.push_back(mother_temp); } - } + } } - if( mother.PDG()[iv] == 200113 ) - { - float negPt2 = negDaughter.Px()[iv]*negDaughter.Px()[iv] + negDaughter.Py()[iv]*negDaughter.Py()[iv]; - float posPt2 = posDaughter.Px()[iv]*posDaughter.Px()[iv] + posDaughter.Py()[iv]*posDaughter.Py()[iv]; - - if( (negPt2 >fCutJPsiPt*fCutJPsiPt) && (posPt2 >fCutJPsiPt*fCutJPsiPt) && (abs(daughterPosPDG[iv]) == 13) && (abs(daughterNegPDG[iv]) == 13)) - { + if (mother.PDG()[iv] == 200113) { + float negPt2 = negDaughter.Px()[iv] * negDaughter.Px()[iv] + negDaughter.Py()[iv] * negDaughter.Py()[iv]; + float posPt2 = posDaughter.Px()[iv] * posDaughter.Px()[iv] + posDaughter.Py()[iv] * posDaughter.Py()[iv]; + + if ((negPt2 > fCutJPsiPt * fCutJPsiPt) && (posPt2 > fCutJPsiPt * fCutJPsiPt) && (abs(daughterPosPDG[iv]) == 13) && (abs(daughterNegPDG[iv]) == 13)) { mother_temp.SetPDG(100443); mother_temp.SetId(Particles.size()); Particles.push_back(mother_temp); - } + } } - - if(saveMother[iv]) - { + + if (saveMother[iv]) { mother.SetId(motherId); - motherPrimSecCand.SetOneEntry(nPrimSecCand,mother,iv); + motherPrimSecCand.SetOneEntry(nPrimSecCand, mother, iv); nPrimSecCand++; - if(nPrimSecCand==float_vLen) - { - SaveV0PrimSecCand(motherPrimSecCand,nPrimSecCand,mother_temp,PrimVtx,secCuts,vMotherPrim,vMotherSec); + if (nPrimSecCand == float_vLen) { + SaveV0PrimSecCand(motherPrimSecCand, nPrimSecCand, mother_temp, PrimVtx, secCuts, vMotherPrim, vMotherSec); nPrimSecCand = 0; } } @@ -871,9 +849,9 @@ inline void KFParticleFinder::ConstructV0(KFPTrackVector* vTracks, inline void KFParticleFinder::SaveV0PrimSecCand(KFParticleSIMD& mother, int& NParticles, KFParticle& mother_temp, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float* secCuts, - vector< vector >* vMotherPrim, + vector>* vMotherPrim, vector* vMotherSec) { /** The function which decides if primary and secondary candidates found by KFParticleFinder::ConstructV0() @@ -886,84 +864,77 @@ inline void KFParticleFinder::SaveV0PrimSecCand(KFParticleSIMD& mother, ** \param[out] vMotherPrim - array with output primary candidates if any. ** \param[out] vMotherSec - array with output secondary candidates if any. **/ - + KFParticleSIMD motherTopo; float_v massMotherPDG, massMotherPDGSigma; - + float_m isSec(false); float_m isPrim(false); vector iPrimVert[float_vLen]; - KFParticleDatabase::Instance()->GetMotherMass(mother.PDG(),massMotherPDG,massMotherPDGSigma); - - float_m isK0 = simd_cast(mother.PDG() == int_v(310)); - float_m isLambda = simd_cast(abs(mother.PDG()) == int_v(3122)); - float_m isGamma = simd_cast(mother.PDG() == int_v(22)); + KFParticleDatabase::Instance()->GetMotherMass(mother.PDG(), massMotherPDG, massMotherPDGSigma); + + float_m isK0 = simd_cast(mother.PDG() == int_v(310)); + float_m isLambda = simd_cast(abs(mother.PDG()) == int_v(3122)); + float_m isGamma = simd_cast(mother.PDG() == int_v(22)); - int_v arrayIndex(-1); //for saving primary candidates; + int_v arrayIndex(-1); //for saving primary candidates; - arrayIndex(mother.PDG() == int_v(310)) = 0; - arrayIndex(mother.PDG() == int_v(3122)) = 1; + arrayIndex(mother.PDG() == int_v(310)) = 0; + arrayIndex(mother.PDG() == int_v(3122)) = 1; arrayIndex(mother.PDG() == int_v(-3122)) = 2; - arrayIndex(mother.PDG() == int_v(22)) = 3; + arrayIndex(mother.PDG() == int_v(22)) = 3; float_m isPrimaryPart(false); float_v chi2TopoMin = 1.e4f; - - for(int iP=0; iP< fNPV; iP++) - { + + for (int iP = 0; iP < fNPV; iP++) { motherTopo = mother; motherTopo.SetProductionVertex(PrimVtx[iP]); - - const float_v& motherTopoChi2Ndf = motherTopo.GetChi2()/simd_cast(motherTopo.GetNDF()); + + const float_v& motherTopoChi2Ndf = motherTopo.GetChi2() / simd_cast(motherTopo.GetNDF()); chi2TopoMin(motherTopoChi2Ndf < chi2TopoMin) = motherTopoChi2Ndf; - const float_m isPrimaryPartLocal = ( motherTopoChi2Ndf < secCuts[1] ); - if(isPrimaryPartLocal.isEmpty()) continue; + const float_m isPrimaryPartLocal = (motherTopoChi2Ndf < secCuts[1]); + if (isPrimaryPartLocal.isEmpty()) + continue; isPrimaryPart |= isPrimaryPartLocal; - for(int iV=0; iV& Particles, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float* cuts, const float* secCuts, - vector< vector >* vMotherPrim, - vector* vMotherSec ) + vector>* vMotherPrim, + vector* vMotherSec) { /** Reconstructs all 2-daughter decays. ** \param[in] vRTracks - pointer to the array with vectors of tracks:\n @@ -1000,96 +971,111 @@ void KFParticleFinder::Find2DaughterDecay(KFPTrackVector* vTracks, kfvector_floa kfvector_floatv l(fNPV), dl(fNPV); KFParticleSIMD daughterNeg, daughterPos; - + // for secondary V0 unsigned int nBufEntry = 0; uint_v idNegDaughters; uint_v idPosDaughters; int_v daughterPosPDG(-1); int_v daughterNegPDG(-1); - + int_v pvIndexMother(-1); - + float_v massMotherPDG(Vc::Zero), massMotherPDGSigma(Vc::Zero); int_v V0PDG(Vc::Zero); KFParticleSIMD motherPrimSecCand; - int nPrimSecCand =0; - - int trTypeIndexPos[2] = {0,2}; - int trTypeIndexNeg[2] = {1,3}; + int nPrimSecCand = 0; - for( int iTrTypeNeg = 0; iTrTypeNeg<2; iTrTypeNeg++) - { - KFPTrackVector& negTracks = vTracks[ trTypeIndexNeg[iTrTypeNeg] ]; - - for(int iTrTypePos=0; iTrTypePos<2; iTrTypePos++) - { - KFPTrackVector& posTracks = vTracks[ trTypeIndexPos[iTrTypePos] ]; + int trTypeIndexPos[2] = {0, 2}; + int trTypeIndexNeg[2] = {1, 3}; + + for (int iTrTypeNeg = 0; iTrTypeNeg < 2; iTrTypeNeg++) { + KFPTrackVector& negTracks = vTracks[trTypeIndexNeg[iTrTypeNeg]]; + + for (int iTrTypePos = 0; iTrTypePos < 2; iTrTypePos++) { + KFPTrackVector& posTracks = vTracks[trTypeIndexPos[iTrTypePos]]; int_v negTracksSize = negTracks.Size(); int nPositiveTracks = posTracks.Size(); - + //track categories int nTC = 5; int startTCPos[5] = {0}; int endTCPos[5] = {0}; int startTCNeg[5] = {0}; int endTCNeg[5] = {0}; - - if((iTrTypeNeg == 0) && (iTrTypePos == 0)) - { + + if ((iTrTypeNeg == 0) && (iTrTypePos == 0)) { // Secondary particles nTC = 5; // e- - startTCPos[0] = 0; endTCPos[0] = nPositiveTracks; //posTracks.LastElectron(); - startTCNeg[0] = 0; endTCNeg[0] = negTracksSize[0]; //negTracks.LastElectron(); + startTCPos[0] = 0; + endTCPos[0] = nPositiveTracks; //posTracks.LastElectron(); + startTCNeg[0] = 0; + endTCNeg[0] = negTracksSize[0]; //negTracks.LastElectron(); //mu- - startTCPos[1] = 0; endTCPos[1] = 0; - startTCNeg[1] = 0; endTCNeg[1] = 0; + startTCPos[1] = 0; + endTCPos[1] = 0; + startTCNeg[1] = 0; + endTCNeg[1] = 0; //pi- + ghosts - startTCPos[2] = posTracks.FirstPion(); endTCPos[2] = nPositiveTracks; - startTCNeg[2] = negTracks.FirstPion(); endTCNeg[2] = negTracks.LastPion(); + startTCPos[2] = posTracks.FirstPion(); + endTCPos[2] = nPositiveTracks; + startTCNeg[2] = negTracks.FirstPion(); + endTCNeg[2] = negTracks.LastPion(); //K- - startTCPos[3] = posTracks.FirstPion(); endTCPos[3] = posTracks.LastKaon(); - startTCNeg[3] = negTracks.FirstKaon(); endTCNeg[3] = negTracks.LastKaon(); + startTCPos[3] = posTracks.FirstPion(); + endTCPos[3] = posTracks.LastKaon(); + startTCNeg[3] = negTracks.FirstKaon(); + endTCNeg[3] = negTracks.LastKaon(); //p-, d-, t-, he3-, he4- - startTCPos[4] = posTracks.FirstPion(); endTCPos[4] = posTracks.LastPion(); - startTCNeg[4] = negTracks.FirstProton(); endTCNeg[4] = negTracksSize[0]; + startTCPos[4] = posTracks.FirstPion(); + endTCPos[4] = posTracks.LastPion(); + startTCNeg[4] = negTracks.FirstProton(); + endTCNeg[4] = negTracksSize[0]; } - - if( iTrTypeNeg != iTrTypePos ) - { + + if (iTrTypeNeg != iTrTypePos) { //Mixed particles - only gamma -> e+ e- nTC = 1; - startTCPos[0] = 0; endTCPos[0] = nPositiveTracks; //posTracks.LastElectron(); - startTCNeg[0] = 0; endTCNeg[0] = negTracksSize[0]; //negTracks.LastElectron(); + startTCPos[0] = 0; + endTCPos[0] = nPositiveTracks; //posTracks.LastElectron(); + startTCNeg[0] = 0; + endTCNeg[0] = negTracksSize[0]; //negTracks.LastElectron(); } - - if((iTrTypeNeg == 1) && (iTrTypePos == 1)) - { + + if ((iTrTypeNeg == 1) && (iTrTypePos == 1)) { //primary particles nTC = 5; // e- - startTCPos[0] = 0; endTCPos[0] = nPositiveTracks; //posTracks.LastElectron(); - startTCNeg[0] = 0; endTCNeg[0] = negTracksSize[0]; //negTracks.LastElectron(); + startTCPos[0] = 0; + endTCPos[0] = nPositiveTracks; //posTracks.LastElectron(); + startTCNeg[0] = 0; + endTCNeg[0] = negTracksSize[0]; //negTracks.LastElectron(); //mu- - startTCPos[1] = posTracks.FirstMuon(); endTCPos[1] = posTracks.LastMuon(); - startTCNeg[1] = negTracks.FirstMuon(); endTCNeg[1] = negTracks.LastMuon(); + startTCPos[1] = posTracks.FirstMuon(); + endTCPos[1] = posTracks.LastMuon(); + startTCNeg[1] = negTracks.FirstMuon(); + endTCNeg[1] = negTracks.LastMuon(); //pi- + ghosts - startTCPos[2] = posTracks.FirstPion(); endTCPos[2] = posTracks.LastProton(); - startTCNeg[2] = negTracks.FirstPion(); endTCNeg[2] = negTracks.LastPion(); + startTCPos[2] = posTracks.FirstPion(); + endTCPos[2] = posTracks.LastProton(); + startTCNeg[2] = negTracks.FirstPion(); + endTCNeg[2] = negTracks.LastPion(); //K- - startTCPos[3] = posTracks.FirstPion(); endTCPos[3] = nPositiveTracks; - startTCNeg[3] = negTracks.FirstKaon(); endTCNeg[3] = negTracks.LastKaon(); + startTCPos[3] = posTracks.FirstPion(); + endTCPos[3] = nPositiveTracks; + startTCNeg[3] = negTracks.FirstKaon(); + endTCNeg[3] = negTracks.LastKaon(); //p- - startTCPos[4] = posTracks.FirstPion(); endTCPos[4] = posTracks.LastProton(); - startTCNeg[4] = negTracks.FirstProton(); endTCNeg[4] = negTracks.LastProton(); + startTCPos[4] = posTracks.FirstPion(); + endTCPos[4] = posTracks.LastProton(); + startTCNeg[4] = negTracks.FirstProton(); + endTCNeg[4] = negTracks.LastProton(); } - - for(int iTC=0; iTC(negTracks.PDG()[iTrN]); int_v negPVIndex = reinterpret_cast(negTracks.PVIndex()[iTrN]); int_v negNPixelHits = reinterpret_cast(negTracks.NPixelHits()[iTrN]); - + int_v trackPdgNeg = negPDG; int_m activeNeg = (negPDG != -1); -#ifdef CBM - if( !((negPDG == -1).isEmpty()) ) - { - trackPdgNeg(negPVIndex<0 && (negPDG == -1) ) = -211; - - activeNeg |= int_m(negPVIndex < 0) && int_m(negPDG == -1) ; +#ifdef CBM + if (!((negPDG == -1).isEmpty())) { + trackPdgNeg(negPVIndex < 0 && (negPDG == -1)) = -211; + + activeNeg |= int_m(negPVIndex < 0) && int_m(negPDG == -1); } -#endif +#endif activeNeg &= (int_v::IndexesFromZero() < int(NTracksNeg)); - + daughterNeg.Load(negTracks, iTrN, negPDG); - + float_v chiPrimNeg(Vc::Zero); float_v chiPrimPos(Vc::Zero); - - if( (iTrTypeNeg == 0) && (iTrTypePos == 0) ) - chiPrimNeg = reinterpret_cast( ChiToPrimVtx[trTypeIndexNeg[iTrTypeNeg]][iTrN]); - - for(int iTrP=startTCPos[iTC]; iTrP < endTCPos[iTC]; iTrP += float_vLen) - { + + if ((iTrTypeNeg == 0) && (iTrTypePos == 0)) + chiPrimNeg = reinterpret_cast(ChiToPrimVtx[trTypeIndexNeg[iTrTypeNeg]][iTrN]); + + for (int iTrP = startTCPos[iTC]; iTrP < endTCPos[iTC]; iTrP += float_vLen) { const int NTracks = (iTrP + float_vLen < nPositiveTracks) ? float_vLen : (nPositiveTracks - iTrP); const int_v& posPDG = reinterpret_cast(posTracks.PDG()[iTrP]); - const int_v& posPVIndex = reinterpret_cast(posTracks.PVIndex()[iTrP]); + const int_v& posPVIndex = reinterpret_cast(posTracks.PVIndex()[iTrP]); const int_v& posNPixelHits = reinterpret_cast(posTracks.NPixelHits()[iTrP]); const int_m& isPosSecondary = (posPVIndex < 0); daughterPos.Load(posTracks, iTrP, posPDG); - - if( (iTrTypeNeg == 0) && (iTrTypePos == 0) ) - chiPrimPos = reinterpret_cast( ChiToPrimVtx[trTypeIndexPos[iTrTypePos]][iTrP]); - - for(int iRot = 0; iRot0) + + if ((iTrTypeNeg == 0) && (iTrTypePos == 0)) + chiPrimPos = reinterpret_cast(ChiToPrimVtx[trTypeIndexPos[iTrTypePos]][iTrP]); + + for (int iRot = 0; iRot < float_vLen; iRot++) { + // if(iRot>0) { negPDG = negPDG.rotated(1); negPVIndex = negPVIndex.rotated(1); negNPixelHits = negNPixelHits.rotated(1); negInd = negInd.rotated(1); trackPdgNeg = trackPdgNeg.rotated(1); - + daughterNeg.Rotate(); chiPrimNeg = chiPrimNeg.rotated(1); - activeNeg = ( (negPDG != -1) || ( (negPVIndex < 0) && (negPDG == -1) ) ) && (negInd < negTracksSize); + activeNeg = ((negPDG != -1) || ((negPVIndex < 0) && (negPDG == -1))) && (negInd < negTracksSize); } - const int_m& isSecondary = int_m( negPVIndex < 0 ) && isPosSecondary; - const int_m& isPrimary = int_m( negPVIndex >= 0 ) && (!isPosSecondary); - + const int_m& isSecondary = int_m(negPVIndex < 0) && isPosSecondary; + const int_m& isPrimary = int_m(negPVIndex >= 0) && (!isPosSecondary); + float_m closeDaughters = simd_cast(activeNeg && (int_v::IndexesFromZero() < int_v(NTracks))); - - if(closeDaughters.isEmpty() && (iTC != 0)) continue; - - + + if (closeDaughters.isEmpty() && (iTC != 0)) + continue; + int_v trackPdgPos[2]; int_m active[2]; @@ -1162,270 +1145,244 @@ void KFParticleFinder::Find2DaughterDecay(KFPTrackVector* vTracks, kfvector_floa active[0] &= ((isPrimary && (posPVIndex == negPVIndex)) || !(isPrimary)); active[1] = int_m(false); - + trackPdgPos[0] = posPDG; #ifdef CBM int nPDGPos = 2; - if( (posPDG == -1).isEmpty() && (posPDG > 1000000000).isEmpty() && (posPDG == 211).isEmpty() ) - { + if ((posPDG == -1).isEmpty() && (posPDG > 1000000000).isEmpty() && (posPDG == 211).isEmpty()) { nPDGPos = 1; - } - else - { + } else { trackPdgPos[0](isSecondary && posPDG == -1) = 211; trackPdgPos[1] = 2212; - + active[0] |= isSecondary && int_m(posPDG == -1); - active[1] = isSecondary && (int_m(posPDG == -1) || (posPDG > 1000000000) || (posPDG == 211)); + active[1] = isSecondary && (int_m(posPDG == -1) || (posPDG > 1000000000) || (posPDG == 211)); } #else int nPDGPos = 1; #endif active[0] &= simd_cast(closeDaughters); active[1] &= simd_cast(closeDaughters); - - if(iTC==0) - { + + if (iTC == 0) { nPDGPos = 1; active[0] = (negInd < negTracksSize) && (int_v::IndexesFromZero() < int_v(NTracks)); } - for(int iPDGPos=0; iPDGPos e+ e- - } - else if(iTC==1) - { - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 13 || abs(trackPdgPos[iPDGPos])==19) - && (int_m(abs(trackPdgNeg) == 13) || int_m(abs(trackPdgNeg) == 19)) ) = 200113; //rho -> mu+ mu- - } - else if(iTC==2) - { - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 211) ) = 310; //K0 -> pi+ pi- - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 2212) && int_m(abs(trackPdgNeg) == 211) ) = 3122; //Lambda -> p+ pi- - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 1000010020) && int_m(abs(trackPdgNeg) == 211) ) = 3003; //LambdaN -> d+ pi- - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 1000010030) && int_m(abs(trackPdgNeg) == 211) ) = 3103; //LambdaNN -> t+ pi- - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 1000020030) && int_m(abs(trackPdgNeg) == 211) ) = 3004; //H3Lambda -> He3+ pi- - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 1000020040) && int_m(abs(trackPdgNeg) == 211) ) = 3005; //H4Lambda -> He4+ pi- - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 321) && int_m(abs(trackPdgNeg) == 211) ) = -421; //D0_bar -> pi- K+ - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 321) && int_m(abs(trackPdgNeg) == 211) ) = 313; //K*0 -> K+ pi- - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 211) ) = 113; //rho -> pi+ pi- - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 2212) && int_m(abs(trackPdgNeg) == 211) ) = 2114; //Delta0 -> p pi- - } - else if(iTC==3) - { - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 321) ) = 421; //D0 -> pi+ K- - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 321) && int_m(abs(trackPdgNeg) == 321) ) = 426; //D0 -> K+ K- - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 321) ) = -313; //K*0_bar -> K- pi+ - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 2212) && int_m(abs(trackPdgNeg) == 321) ) = 3124; //Lambda* -> p K- - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 321) && int_m(abs(trackPdgNeg) == 321) ) = 333; //phi -> K+ K- - } - else if(iTC==4) - { - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 2212) ) = -3122; //Lambda_bar -> p- pi+ - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 1000010020) ) = -3003; //LambdaN_bar -> d- pi+ - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 1000010030) ) = -3103; //LambdaNN_bar -> t- pi+ - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 1000020030) ) = -3004; //H3Lambda_bar -> He3- pi+ - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 1000020040) ) = -3005; //H4Lambda_bar -> He4- pi+ - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 321) && int_m(abs(trackPdgNeg) == 2212) ) = -3124; //Lambda*_bar -> p- K+ - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 2212) && int_m(abs(trackPdgNeg) == 2212) ) = 200443; //JPsi -> p- p - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 2212) ) = -2114; //Delta0_bar -> p- pi+ + + if (!fMixedEventAnalysis) { + if (iTC == 0) { + motherPDG((abs(trackPdgPos[iPDGPos]) == 11) || int_m(abs(trackPdgNeg) == 11) || isSecondary) = 22; //gamma -> e+ e- + } else if (iTC == 1) { + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 13 || abs(trackPdgPos[iPDGPos]) == 19) && (int_m(abs(trackPdgNeg) == 13) || int_m(abs(trackPdgNeg) == 19))) = 200113; //rho -> mu+ mu- + } else if (iTC == 2) { + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 211)) = 310; //K0 -> pi+ pi- + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 2212) && int_m(abs(trackPdgNeg) == 211)) = 3122; //Lambda -> p+ pi- + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 1000010020) && int_m(abs(trackPdgNeg) == 211)) = 3003; //LambdaN -> d+ pi- + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 1000010030) && int_m(abs(trackPdgNeg) == 211)) = 3103; //LambdaNN -> t+ pi- + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 1000020030) && int_m(abs(trackPdgNeg) == 211)) = 3004; //H3Lambda -> He3+ pi- + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 1000020040) && int_m(abs(trackPdgNeg) == 211)) = 3005; //H4Lambda -> He4+ pi- + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 321) && int_m(abs(trackPdgNeg) == 211)) = -421; //D0_bar -> pi- K+ + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 321) && int_m(abs(trackPdgNeg) == 211)) = 313; //K*0 -> K+ pi- + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 211)) = 113; //rho -> pi+ pi- + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 2212) && int_m(abs(trackPdgNeg) == 211)) = 2114; //Delta0 -> p pi- + } else if (iTC == 3) { + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 321)) = 421; //D0 -> pi+ K- + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 321) && int_m(abs(trackPdgNeg) == 321)) = 426; //D0 -> K+ K- + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 321)) = -313; //K*0_bar -> K- pi+ + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 2212) && int_m(abs(trackPdgNeg) == 321)) = 3124; //Lambda* -> p K- + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 321) && int_m(abs(trackPdgNeg) == 321)) = 333; //phi -> K+ K- + } else if (iTC == 4) { + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 2212)) = -3122; //Lambda_bar -> p- pi+ + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 1000010020)) = -3003; //LambdaN_bar -> d- pi+ + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 1000010030)) = -3103; //LambdaNN_bar -> t- pi+ + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 1000020030)) = -3004; //H3Lambda_bar -> He3- pi+ + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 1000020040)) = -3005; //H4Lambda_bar -> He4- pi+ + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 321) && int_m(abs(trackPdgNeg) == 2212)) = -3124; //Lambda*_bar -> p- K+ + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 2212) && int_m(abs(trackPdgNeg) == 2212)) = 200443; //JPsi -> p- p + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 2212)) = -2114; //Delta0_bar -> p- pi+ } + } else { + if (iTC == 0) + motherPDG((abs(trackPdgPos[iPDGPos]) == 11) && int_m(abs(trackPdgNeg) == 11)) = 22; //gamma -> e+ e- + else if (iTC == 1) + motherPDG(isPrimary && (abs(trackPdgPos[iPDGPos]) == 13 || abs(trackPdgPos[iPDGPos]) == 19) && (int_m(abs(trackPdgNeg) == 13) || int_m(abs(trackPdgNeg) == 19))) = 200113; //rho -> mu+ mu- + else if (iTC == 2) + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 321) && int_m(abs(trackPdgNeg) == 211)) = -421; //D0_bar -> pi- K+ + else if (iTC == 3) + motherPDG(isSecondary && (abs(trackPdgPos[iPDGPos]) == 211) && int_m(abs(trackPdgNeg) == 321)) = 421; //D0 -> pi+ K- } - else - { - if(iTC==0) - motherPDG( (abs(trackPdgPos[iPDGPos])== 11) && int_m(abs(trackPdgNeg) == 11) ) = 22; //gamma -> e+ e- - else if(iTC==1) - motherPDG( isPrimary && (abs(trackPdgPos[iPDGPos])== 13 || abs(trackPdgPos[iPDGPos])==19) - && (int_m(abs(trackPdgNeg) == 13) || int_m(abs(trackPdgNeg) == 19)) ) = 200113; //rho -> mu+ mu- - else if(iTC==2) - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 321) && int_m(abs(trackPdgNeg) == 211) ) = -421; //D0_bar -> pi- K+ - else if(iTC==3) - motherPDG( isSecondary && (abs(trackPdgPos[iPDGPos])== 211) && int_m(abs(trackPdgNeg) == 321) ) = 421; //D0 -> pi+ K- - } - - if( (iTrTypeNeg == 0) && (iTrTypePos == 0) ) - { + + if ((iTrTypeNeg == 0) && (iTrTypePos == 0)) { float_v chiprimCut = fCuts2D[0]; - chiprimCut( simd_cast(abs(motherPDG) == 421 || abs(motherPDG) == 426) ) = fCutCharmChiPrim; + chiprimCut(simd_cast(abs(motherPDG) == 421 || abs(motherPDG) == 426)) = fCutCharmChiPrim; active[iPDGPos] &= simd_cast(chiPrimNeg > chiprimCut && chiPrimPos > chiprimCut); } - + active[iPDGPos] &= (motherPDG != -1); - if(!(fDecayReconstructionList.empty())) - { - for(int iV=0; iV(dr < float_v(fDistanceCut)); - if(active[iPDGPos].isEmpty()) continue; - - float_v p1p2 = posParameters[3]*negParameters[3] + posParameters[4]*negParameters[4] + posParameters[5]*negParameters[5]; - float_v p12 = posParameters[3]*posParameters[3] + posParameters[4]*posParameters[4] + posParameters[5]*posParameters[5]; - float_v p22 = negParameters[3]*negParameters[3] + negParameters[4]*negParameters[4] + negParameters[5]*negParameters[5]; + if (active[iPDGPos].isEmpty()) + continue; + + float_v p1p2 = posParameters[3] * negParameters[3] + posParameters[4] * negParameters[4] + posParameters[5] * negParameters[5]; + float_v p12 = posParameters[3] * posParameters[3] + posParameters[4] * posParameters[4] + posParameters[5] * posParameters[5]; + float_v p22 = negParameters[3] * negParameters[3] + negParameters[4] * negParameters[4] + negParameters[5] * negParameters[5]; active[iPDGPos] &= simd_cast(p1p2 > -p12); active[iPDGPos] &= simd_cast(p1p2 > -p22); } - - const float_v& ptNeg2 = daughterNeg.Px()*daughterNeg.Px() + daughterNeg.Py()*daughterNeg.Py(); - const float_v& ptPos2 = daughterPos.Px()*daughterPos.Px() + daughterPos.Py()*daughterPos.Py(); - if( !((abs(motherPDG) == 421 || abs(motherPDG) == 426).isEmpty()) ) - { - active[iPDGPos] &= ( (abs(motherPDG) == 421 || abs(motherPDG) == 426) && - simd_cast(ptNeg2 >= fCutCharmPt*fCutCharmPt) && - simd_cast(ptPos2 >= fCutCharmPt*fCutCharmPt) && + + const float_v& ptNeg2 = daughterNeg.Px() * daughterNeg.Px() + daughterNeg.Py() * daughterNeg.Py(); + const float_v& ptPos2 = daughterPos.Px() * daughterPos.Px() + daughterPos.Py() * daughterPos.Py(); + if (!((abs(motherPDG) == 421 || abs(motherPDG) == 426).isEmpty())) { + active[iPDGPos] &= ((abs(motherPDG) == 421 || abs(motherPDG) == 426) && + simd_cast(ptNeg2 >= fCutCharmPt * fCutCharmPt) && + simd_cast(ptPos2 >= fCutCharmPt * fCutCharmPt) && simd_cast(chiPrimNeg > fCutCharmChiPrim) && simd_cast(chiPrimPos > fCutCharmChiPrim) && - int_m(negNPixelHits >= int_v(3)) && int_m(posNPixelHits >= int_v(3)) ) - || (!(abs(motherPDG) == 421 || abs(motherPDG) == 426)); + int_m(negNPixelHits >= int_v(3)) && int_m(posNPixelHits >= int_v(3))) || + (!(abs(motherPDG) == 421 || abs(motherPDG) == 426)); } - - if(active[iPDGPos].isEmpty()) continue; - for(int iV=0; iVGetMotherMass(V0PDG,massMotherPDG,massMotherPDGSigma); - mother.SetPDG( V0PDG ); - ConstructV0(vTracks, trTypeIndexPos[iTrTypePos], trTypeIndexNeg[iTrTypeNeg], + if (int(nBufEntry) == float_vLen) { + KFParticleDatabase::Instance()->GetMotherMass(V0PDG, massMotherPDG, massMotherPDGSigma); + mother.SetPDG(V0PDG); + ConstructV0(vTracks, trTypeIndexPos[iTrTypePos], trTypeIndexNeg[iTrTypeNeg], idPosDaughters, idNegDaughters, daughterPosPDG, daughterNegPDG, mother, mother_temp, nBufEntry, l, dl, Particles, PrimVtx, cuts, pvIndexMother, secCuts, massMotherPDG, massMotherPDGSigma, motherPrimSecCand, nPrimSecCand, vMotherPrim, vMotherSec); - nBufEntry = 0; + nBufEntry = 0; } - + //TODO optimize this part of code for D-mesons - if(motherPDG[iV] == 310 && - (fDecayReconstructionList.empty() || - (!(fDecayReconstructionList.empty()) && !(fDecayReconstructionList.find(420) == fDecayReconstructionList.end()) ) ) && - negNPixelHits[iV] >= 3 && posNPixelHits[iV] >= 3 && - chiPrimNeg[iV] > fCutCharmChiPrim && chiPrimPos[iV] > fCutCharmChiPrim && - ptNeg2[iV] >= fCutCharmPt*fCutCharmPt && ptPos2[iV] >= fCutCharmPt*fCutCharmPt ) - { - idPosDaughters[nBufEntry] = iTrP+iV; + if (motherPDG[iV] == 310 && + (fDecayReconstructionList.empty() || + (!(fDecayReconstructionList.empty()) && !(fDecayReconstructionList.find(420) == fDecayReconstructionList.end()))) && + negNPixelHits[iV] >= 3 && posNPixelHits[iV] >= 3 && + chiPrimNeg[iV] > fCutCharmChiPrim && chiPrimPos[iV] > fCutCharmChiPrim && + ptNeg2[iV] >= fCutCharmPt * fCutCharmPt && ptPos2[iV] >= fCutCharmPt * fCutCharmPt) { + idPosDaughters[nBufEntry] = iTrP + iV; idNegDaughters[nBufEntry] = negInd[iV]; - + daughterPosPDG[nBufEntry] = trackPdgPos[iPDGPos][iV]; daughterNegPDG[nBufEntry] = trackPdgNeg[iV]; - + pvIndexMother[nBufEntry] = isPrimary[iV] ? negPVIndex[iV] : -1; - + V0PDG[nBufEntry] = 420; - + nBufEntry++; - if(int(nBufEntry) == float_vLen) - { - KFParticleDatabase::Instance()->GetMotherMass(V0PDG,massMotherPDG,massMotherPDGSigma); - mother.SetPDG( V0PDG ); - ConstructV0(vTracks, trTypeIndexPos[iTrTypePos], trTypeIndexNeg[iTrTypeNeg], + if (int(nBufEntry) == float_vLen) { + KFParticleDatabase::Instance()->GetMotherMass(V0PDG, massMotherPDG, massMotherPDGSigma); + mother.SetPDG(V0PDG); + ConstructV0(vTracks, trTypeIndexPos[iTrTypePos], trTypeIndexNeg[iTrTypeNeg], idPosDaughters, idNegDaughters, daughterPosPDG, daughterNegPDG, mother, mother_temp, nBufEntry, l, dl, Particles, PrimVtx, cuts, pvIndexMother, secCuts, massMotherPDG, massMotherPDGSigma, motherPrimSecCand, nPrimSecCand, vMotherPrim, vMotherSec); - nBufEntry = 0; + nBufEntry = 0; } } - - }//iV - }//iPDGPos - }//iRot - }//iTrP - }//iTrN - - if( nBufEntry>0 ) - { - for(int iV=nBufEntry; iV 0) { + for (int iV = nBufEntry; iV < float_vLen; iV++) { idPosDaughters[iV] = idPosDaughters[0]; idNegDaughters[iV] = idNegDaughters[0]; } - KFParticleDatabase::Instance()->GetMotherMass(V0PDG,massMotherPDG,massMotherPDGSigma); - mother.SetPDG( V0PDG ); + KFParticleDatabase::Instance()->GetMotherMass(V0PDG, massMotherPDG, massMotherPDGSigma); + mother.SetPDG(V0PDG); - ConstructV0(vTracks, trTypeIndexPos[iTrTypePos], trTypeIndexNeg[iTrTypeNeg], + ConstructV0(vTracks, trTypeIndexPos[iTrTypePos], trTypeIndexNeg[iTrTypeNeg], idPosDaughters, idNegDaughters, daughterPosPDG, daughterNegPDG, mother, mother_temp, nBufEntry, l, dl, Particles, PrimVtx, cuts, pvIndexMother, secCuts, massMotherPDG, massMotherPDGSigma, motherPrimSecCand, nPrimSecCand, vMotherPrim, vMotherSec); - nBufEntry = 0; + nBufEntry = 0; } - - if(nPrimSecCand>0) - { - SaveV0PrimSecCand(motherPrimSecCand,nPrimSecCand,mother_temp,PrimVtx,secCuts,vMotherPrim,vMotherSec); + + if (nPrimSecCand > 0) { + SaveV0PrimSecCand(motherPrimSecCand, nPrimSecCand, mother_temp, PrimVtx, secCuts, vMotherPrim, vMotherSec); nPrimSecCand = 0; } - }//iTC - }//iTrTypeNeg - }//iTrTypePos + } //iTC + } //iTrTypeNeg + } //iTrTypePos } void KFParticleFinder::ConstructPrimaryBG(KFPTrackVector* vTracks, vector& Particles, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float* cuts, const float* secCuts, - vector< vector >* vMotherPrim, - vector* vMotherSec ) + vector>* vMotherPrim, + vector* vMotherSec) { /** Constructs same-sign background candidates for 2-daughter resonances. ** \param[in] vRTracks - pointer to the array with vectors of tracks:\n @@ -1457,134 +1414,128 @@ void KFParticleFinder::ConstructPrimaryBG(KFPTrackVector* vTracks, uint_v idPosDaughters; int_v daughterPosPDG(-1); int_v daughterNegPDG(-1); - + int_v pvIndexMother(-1); - + float_v massMotherPDG(Vc::Zero), massMotherPDGSigma(Vc::Zero); int_v V0PDG(Vc::Zero); KFParticleSIMD motherPrimSecCand; - int nPrimSecCand =0; - - for(int iSet=2; iSet<4; iSet++) - { + int nPrimSecCand = 0; + + for (int iSet = 2; iSet < 4; iSet++) { int signPDG = 1; - if(iSet == 3) + if (iSet == 3) signPDG = -1; - + KFPTrackVector& positivePrimaryTracks = vTracks[iSet]; int nPositiveTracks = positivePrimaryTracks.Size(); - for(int iTrN = positivePrimaryTracks.FirstPion(); iTrN < positivePrimaryTracks.LastProton(); iTrN += float_vLen) - { + for (int iTrN = positivePrimaryTracks.FirstPion(); iTrN < positivePrimaryTracks.LastProton(); iTrN += float_vLen) { int_v negPDG = positivePrimaryTracks.PDG()[iTrN]; int_v negPVIndex = positivePrimaryTracks.PVIndex()[iTrN]; - + int_m activeNeg = (negPDG != -1); - for(int iTrP = iTrN+1; iTrP < positivePrimaryTracks.LastProton(); iTrP += float_vLen) - { + for (int iTrP = iTrN + 1; iTrP < positivePrimaryTracks.LastProton(); iTrP += float_vLen) { const int NTracks = (iTrP + float_vLen < nPositiveTracks) ? float_vLen : (nPositiveTracks - iTrP); - int_v posPDG(0); // = reinterpret_cast(positivePrimaryTracks.PDG()[iTrP]); - int_v posPVIndex(0); // = reinterpret_cast(positivePrimaryTracks.PVIndex()[iTrP]); - for(int iV=0; iV(positivePrimaryTracks.PDG()[iTrP]); + int_v posPVIndex(0); // = reinterpret_cast(positivePrimaryTracks.PVIndex()[iTrP]); + for (int iV = 0; iV < NTracks; iV++) { + posPDG[iV] = positivePrimaryTracks.PDG()[iTrP + iV]; + posPVIndex[iV] = positivePrimaryTracks.PVIndex()[iTrP + iV]; } int_m active = (activeNeg && (int_v::IndexesFromZero() < int_v(NTracks))); - if(active.isEmpty()) continue; - + if (active.isEmpty()) + continue; + active &= (posPDG != int_v(-1)); active &= (posPVIndex == negPVIndex); - - if(active.isEmpty()) continue; - + + if (active.isEmpty()) + continue; + //detetrmine a pdg code of the mother particle - + int_v motherPDG(-1); - - motherPDG( (abs(posPDG)== 211) && int_m(abs(negPDG) == 211) ) = signPDG*9001; //pi+pi+ - motherPDG( (abs(posPDG)== 321) && int_m(abs(negPDG) == 211) ) = signPDG*9002; //pi+K+ - motherPDG( (abs(posPDG)== 211) && int_m(abs(negPDG) == 321) ) = signPDG*9002; //pi+K+ - motherPDG( (abs(posPDG)== 211) && int_m(abs(negPDG) == 2212) ) = signPDG*2224; //pi+p - motherPDG( (abs(posPDG)== 2212) && int_m(abs(negPDG) == 211) ) = signPDG*2224; //pi+p - motherPDG( (abs(posPDG)== 321) && int_m(abs(negPDG) == 321) ) = signPDG*9003; //K+K+ - motherPDG( (abs(posPDG)== 321) && int_m(abs(negPDG) == 2212) ) = signPDG*9004; //K+p - motherPDG( (abs(posPDG)== 2212) && int_m(abs(negPDG) == 321) ) = signPDG*9004; //K+p - + + motherPDG((abs(posPDG) == 211) && int_m(abs(negPDG) == 211)) = signPDG * 9001; //pi+pi+ + motherPDG((abs(posPDG) == 321) && int_m(abs(negPDG) == 211)) = signPDG * 9002; //pi+K+ + motherPDG((abs(posPDG) == 211) && int_m(abs(negPDG) == 321)) = signPDG * 9002; //pi+K+ + motherPDG((abs(posPDG) == 211) && int_m(abs(negPDG) == 2212)) = signPDG * 2224; //pi+p + motherPDG((abs(posPDG) == 2212) && int_m(abs(negPDG) == 211)) = signPDG * 2224; //pi+p + motherPDG((abs(posPDG) == 321) && int_m(abs(negPDG) == 321)) = signPDG * 9003; //K+K+ + motherPDG((abs(posPDG) == 321) && int_m(abs(negPDG) == 2212)) = signPDG * 9004; //K+p + motherPDG((abs(posPDG) == 2212) && int_m(abs(negPDG) == 321)) = signPDG * 9004; //K+p + active &= (motherPDG != -1); - if(!(fDecayReconstructionList.empty())) - { - for(int iV=0; iVGetMotherMass(V0PDG,massMotherPDG,massMotherPDGSigma); - mother.SetPDG( V0PDG ); - ConstructV0(vTracks, iSet, iSet, + if (int(nBufEntry) == float_vLen) { + KFParticleDatabase::Instance()->GetMotherMass(V0PDG, massMotherPDG, massMotherPDGSigma); + mother.SetPDG(V0PDG); + ConstructV0(vTracks, iSet, iSet, idPosDaughters, idNegDaughters, daughterPosPDG, daughterNegPDG, mother, mother_temp, nBufEntry, l, dl, Particles, PrimVtx, cuts, pvIndexMother, secCuts, massMotherPDG, massMotherPDGSigma, motherPrimSecCand, nPrimSecCand, vMotherPrim, vMotherSec); - nBufEntry = 0; + nBufEntry = 0; } - }//iV - }//iTrP - - if( nBufEntry>0 ) - { - for(int iV=nBufEntry; iV 0) { + for (int iV = nBufEntry; iV < float_vLen; iV++) { idPosDaughters[iV] = idPosDaughters[0]; idNegDaughters[iV] = idNegDaughters[0]; } - KFParticleDatabase::Instance()->GetMotherMass(V0PDG,massMotherPDG,massMotherPDGSigma); - mother.SetPDG( V0PDG ); + KFParticleDatabase::Instance()->GetMotherMass(V0PDG, massMotherPDG, massMotherPDGSigma); + mother.SetPDG(V0PDG); - ConstructV0(vTracks, iSet, iSet, + ConstructV0(vTracks, iSet, iSet, idPosDaughters, idNegDaughters, daughterPosPDG, daughterNegPDG, mother, mother_temp, nBufEntry, l, dl, Particles, PrimVtx, cuts, pvIndexMother, secCuts, massMotherPDG, massMotherPDGSigma, motherPrimSecCand, nPrimSecCand, vMotherPrim, vMotherSec); - nBufEntry = 0; + nBufEntry = 0; } - - if(nPrimSecCand>0) - { - SaveV0PrimSecCand(motherPrimSecCand,nPrimSecCand,mother_temp,PrimVtx,secCuts,vMotherPrim,vMotherSec); + + if (nPrimSecCand > 0) { + SaveV0PrimSecCand(motherPrimSecCand, nPrimSecCand, mother_temp, PrimVtx, secCuts, vMotherPrim, vMotherSec); nPrimSecCand = 0; } } @@ -1596,18 +1547,18 @@ void KFParticleFinder::ConstructTrackV0Cand(KFPTrackVector& vTracks, int_v& trackPDG, KFParticle* vV0[], KFParticleSIMD& mother, - std::vector >& motherTopo, + std::vector>& motherTopo, KFParticle& mother_temp, const unsigned short nElements, kfvector_floatv& l, kfvector_floatv& dl, std::vector& Particles, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float_v* cuts, const int_v& pvIndex, const float_v& massMotherPDG, const float_v& massMotherPDGSigma, - std::vector< std::vector >* vMotherPrim, + std::vector>* vMotherPrim, std::vector* vMotherSec) { /** Constructs a candidate from a track and already reconstructed particle candidate. @@ -1631,48 +1582,45 @@ void KFParticleFinder::ConstructTrackV0Cand(KFPTrackVector& vTracks, ** \param[out] vMotherPrim - array with output primary candidates if any. If pointer is set to NULL - not filled. ** \param[out] vMotherSec - array with output secondary candidates if any. If pointer is set to NULL - not filled. **/ - - float_m isPrimary(simd_cast(pvIndex>-1)); - - int_v trackId( &(vTracks.Id()[0]), idTracks ); - KFParticleSIMD V0(vV0,nElements); + + float_m isPrimary(simd_cast(pvIndex > -1)); + + int_v trackId(&(vTracks.Id()[0]), idTracks); + KFParticleSIMD V0(vV0, nElements); KFParticleSIMD track(vTracks, idTracks, trackPDG); track.SetId(trackId); - - float_m isSameParticle = simd_cast((abs(mother.PDG()) == int_v(4122)) || - (abs(mother.PDG()) == int_v(114122)) || - (abs(mother.PDG()) == int_v(204122)) || - (abs(mother.PDG()) == int_v(504122)) || - (abs(mother.PDG()) == int_v(404122)) || - (abs(mother.PDG()) == int_v(425)) || - (abs(mother.PDG()) == int_v(427)) || - (abs(mother.PDG()) == int_v(200411)) || - (abs(mother.PDG()) == int_v(300411)) || - (abs(mother.PDG()) == int_v(300431)) || - (abs(mother.PDG()) == int_v(400431)) || - (abs(mother.PDG()) == int_v(411)) || - (abs(mother.PDG()) == int_v(431)) || - (abs(mother.PDG()) == int_v(429)) || + + float_m isSameParticle = simd_cast((abs(mother.PDG()) == int_v(4122)) || + (abs(mother.PDG()) == int_v(114122)) || + (abs(mother.PDG()) == int_v(204122)) || + (abs(mother.PDG()) == int_v(504122)) || + (abs(mother.PDG()) == int_v(404122)) || + (abs(mother.PDG()) == int_v(425)) || + (abs(mother.PDG()) == int_v(427)) || + (abs(mother.PDG()) == int_v(200411)) || + (abs(mother.PDG()) == int_v(300411)) || + (abs(mother.PDG()) == int_v(300431)) || + (abs(mother.PDG()) == int_v(400431)) || + (abs(mother.PDG()) == int_v(411)) || + (abs(mother.PDG()) == int_v(431)) || + (abs(mother.PDG()) == int_v(429)) || (abs(mother.PDG()) == int_v(1003334)) || - (abs(mother.PDG()) == int_v(3001)) || - (abs(mother.PDG()) == int_v(3006)) || - (abs(mother.PDG()) == int_v(3007)) || - (abs(mother.PDG()) == int_v(3009)) || - (abs(mother.PDG()) == int_v(3011)) ); - if( isSameParticle.isEmpty() ) - { + (abs(mother.PDG()) == int_v(3001)) || + (abs(mother.PDG()) == int_v(3006)) || + (abs(mother.PDG()) == int_v(3007)) || + (abs(mother.PDG()) == int_v(3009)) || + (abs(mother.PDG()) == int_v(3011))); + if (isSameParticle.isEmpty()) { #ifdef CBM - float_v ds[2] = {0.f,0.f}; + float_v ds[2] = {0.f, 0.f}; float_v dsdr[4][6]; - track.GetDStoParticle( V0, ds, dsdr ); + track.GetDStoParticle(V0, ds, dsdr); track.TransportToDS(ds[0], dsdr[0]); V0.TransportToDS(ds[1], dsdr[3]); #endif const KFParticleSIMD* vDaughtersPointer[2] = {&track, &V0}; mother.Construct(vDaughtersPointer, 2, 0); - } - else - { + } else { int_v motherPDG = mother.PDG(); mother = V0; mother.SetPDG(motherPDG); @@ -1681,103 +1629,105 @@ void KFParticleFinder::ConstructTrackV0Cand(KFPTrackVector& vTracks, } float_m active = simd_cast(int_v::IndexesFromZero() < int(nElements)); - + float_m saveParticle(active); - saveParticle &= (mother.Chi2()/simd_cast(mother.NDF()) < cuts[2] ); + saveParticle &= (mother.Chi2() / simd_cast(mother.NDF()) < cuts[2]); saveParticle &= KFPMath::Finite(mother.GetChi2()); saveParticle &= (mother.GetChi2() > 0.0f); saveParticle &= (mother.GetChi2() == mother.GetChi2()); - if( saveParticle.isEmpty() ) { return; } + if (saveParticle.isEmpty()) { + return; + } int_m isSameTrack(false); - for(unsigned int iD=0; iD(isSameTrack)); - if( saveParticle.isEmpty() ) { return; } - + for (unsigned int iD = 0; iD < V0.DaughterIds().size(); iD++) + isSameTrack |= (int_v(V0.DaughterIds()[iD]) == int_v(trackId)); + + saveParticle &= (!simd_cast(isSameTrack)); + if (saveParticle.isEmpty()) { + return; + } + float_v lMin(1.e8f); float_v ldlMin(1.e8f); float_m isParticleFromVertex(false); - for(int iP=0; iP cuts[0]) || float_m(isPrimary) ); + saveParticle &= ((float_m(!isPrimary) && ldlMin > cuts[0]) || float_m(isPrimary)); int_m setLCut = abs(mother.PDG()) == 3312 || abs(mother.PDG()) == 3334 || abs(mother.PDG()) == 3001; - saveParticle &= ( (simd_cast(setLCut) && lMin > float_v(fLCut)) || simd_cast(!setLCut) ); + saveParticle &= ((simd_cast(setLCut) && lMin > float_v(fLCut)) || simd_cast(!setLCut)); ldlMin = 1.e8f; - for(int iP=0; iP iPrimVert[float_vLen]; float_m isPrimaryPart(false); - for(int iP=0; iP(motherTopo[iP].GetNDF()); - const float_m isPrimaryPartLocal = ( motherTopoChi2Ndf < cuts[1] ); + for (int iP = 0; iP < fNPV; iP++) { + const float_v& motherTopoChi2Ndf = motherTopo[iP].GetChi2() / simd_cast(motherTopo[iP].GetNDF()); + const float_m isPrimaryPartLocal = (motherTopoChi2Ndf < cuts[1]); isPrimaryPart |= isPrimaryPartLocal; - for(int iV=0; iVNDaughters(); iD++) - mother_temp.AddDaughterId( vV0[iv]->DaughterIds()[iD] ); + for (int iD = 0; iD < vV0[iv]->NDaughters(); iD++) + mother_temp.AddDaughterId(vV0[iv]->DaughterIds()[iD]); mother_temp.AddDaughterId(trackId[iv]); } - - if( mother.PDG()[iv] == 411 ) - { + + if (mother.PDG()[iv] == 411) { fDPlus.push_back(mother_temp); continue; } - if( mother.PDG()[iv] == -411 ) - { + if (mother.PDG()[iv] == -411) { fDMinus.push_back(mother_temp); continue; } - if( mother.PDG()[iv] == 300411 ) - { + if (mother.PDG()[iv] == 300411) { fDPlus3Pi.push_back(mother_temp); continue; } - if( mother.PDG()[iv] == -300411 ) - { + if (mother.PDG()[iv] == -300411) { fDMinus3Pi.push_back(mother_temp); continue; } - if( mother.PDG()[iv] == 400431 ) - { + if (mother.PDG()[iv] == 400431) { fDsPlusK2Pi.push_back(mother_temp); continue; } - if( mother.PDG()[iv] == -400431 ) - { + if (mother.PDG()[iv] == -400431) { fDsMinusK2Pi.push_back(mother_temp); continue; } - if( mother.PDG()[iv] == 504122 ) - { + if (mother.PDG()[iv] == 504122) { fLcPlusP2Pi.push_back(mother_temp); continue; } - if( mother.PDG()[iv] == -504122 ) - { + if (mother.PDG()[iv] == -504122) { fLcMinusP2Pi.push_back(mother_temp); continue; } -// if( mother.PDG()[iv] == 427 ) -// { -// fK0PiPi.push_back(mother_temp); -// continue; -// } - - if( mother.PDG()[iv] == 429 ) - { + // if( mother.PDG()[iv] == 427 ) + // { + // fK0PiPi.push_back(mother_temp); + // continue; + // } + + if (mother.PDG()[iv] == 429) { fD04.push_back(mother_temp); continue; } - if( mother.PDG()[iv] == -429 ) - { + if (mother.PDG()[iv] == -429) { fD04bar.push_back(mother_temp); continue; } - - if( mother.PDG()[iv] == 3203 ) + + if (mother.PDG()[iv] == 3203) fLLn.push_back(mother_temp); - if( mother.PDG()[iv] == 3010 ) + if (mother.PDG()[iv] == 3010) fH5LL.push_back(mother_temp); - + mother_temp.SetId(Particles.size()); - if(!(isPrimaryPart[iv])) - { - if( vMotherSec ) - { + if (!(isPrimaryPart[iv])) { + if (vMotherSec) { float mass, errMass; mother_temp.GetMass(mass, errMass); - if(abs(mother.PDG()[iv]) == 3324) - { + if (abs(mother.PDG()[iv]) == 3324) { vMotherSec->push_back(mother_temp); - } - else - { - if( (fabs(mass - massMotherPDG[iv])/massMotherPDGSigma[iv]) <= 3 ) - { + } else { + if ((fabs(mass - massMotherPDG[iv]) / massMotherPDGSigma[iv]) <= 3) { KFParticle mother_sec = mother_temp; mother_sec.SetNonlinearMassConstraint(massMotherPDG[iv]); vMotherSec->push_back(mother_temp); } } } - if(!(mother.PDG()[iv] == 3006 || mother.PDG()[iv] == 3007)) + if (!(mother.PDG()[iv] == 3006 || mother.PDG()[iv] == 3007)) continue; } - + //check Ds+ and Lc+ candidates not to be D+ -// if(abs(mother_temp.GetPDG())==431 || abs(mother_temp.GetPDG())==4122) -// { -// KFPTrack dPionTrack; -// vTracks.GetTrack(dPionTrack, idTracks[iv]); -// KFParticle dPion(dPionTrack, 211); -// -// KFParticle dMeson = *vV0[iv]; -// dMeson += dPion; -// float dMass, dMassError; -// dMeson.GetMass(dMass, dMassError); -// if(fabs(dMass - KFParticleDatabase::Instance()->GetDPlusMass())/KFParticleDatabase::Instance()->GetDPlusMassSigma() < 3) continue; -// } - - if(abs(mother.GetPDG()[iv]) == 521 || abs(mother.GetPDG()[iv]) == 529 || abs(mother.GetPDG()[iv]) == 511 || abs(mother.GetPDG()[iv]) == 519) - { + // if(abs(mother_temp.GetPDG())==431 || abs(mother_temp.GetPDG())==4122) + // { + // KFPTrack dPionTrack; + // vTracks.GetTrack(dPionTrack, idTracks[iv]); + // KFParticle dPion(dPionTrack, 211); + // + // KFParticle dMeson = *vV0[iv]; + // dMeson += dPion; + // float dMass, dMassError; + // dMeson.GetMass(dMass, dMassError); + // if(fabs(dMass - KFParticleDatabase::Instance()->GetDPlusMass())/KFParticleDatabase::Instance()->GetDPlusMassSigma() < 3) continue; + // } + + if (abs(mother.GetPDG()[iv]) == 521 || abs(mother.GetPDG()[iv]) == 529 || abs(mother.GetPDG()[iv]) == 511 || abs(mother.GetPDG()[iv]) == 519) { KFParticle daughter_temp = *vV0[iv]; float massPDG = KFParticleDatabase::Instance()->GetDPlusMass(); float massSigmaPDG = KFParticleDatabase::Instance()->GetDPlusMassSigma(); - if(abs(mother.GetPDG()[iv]) == 521 || abs(mother.GetPDG()[iv]) == 529) - { + if (abs(mother.GetPDG()[iv]) == 521 || abs(mother.GetPDG()[iv]) == 529) { massPDG = KFParticleDatabase::Instance()->GetD0Mass(); massSigmaPDG = KFParticleDatabase::Instance()->GetD0MassSigma(); } float mass, dm; - daughter_temp.GetMass(mass,dm); - if( (fabs(mass - massPDG)/massSigmaPDG) > 3 ) continue; - -// KFParticleSIMD daughter_tempSIMD(daughter_temp); -// daughter_tempSIMD.SetProductionVertex(PrimVtx[0]); -// if(daughter_tempSIMD.GetChi2()[0]/daughter_tempSIMD.GetNDF()[0] < 3. ) continue; - + daughter_temp.GetMass(mass, dm); + if ((fabs(mass - massPDG) / massSigmaPDG) > 3) + continue; + + // KFParticleSIMD daughter_tempSIMD(daughter_temp); + // daughter_tempSIMD.SetProductionVertex(PrimVtx[0]); + // if(daughter_tempSIMD.GetChi2()[0]/daughter_tempSIMD.GetNDF()[0] < 3. ) continue; + daughter_temp.SetId(Particles.size()); daughter_temp.SetPDG(-1); - mother_temp.SetId(Particles.size()+1); + mother_temp.SetId(Particles.size() + 1); mother_temp.CleanDaughtersId(); mother_temp.AddDaughterId(Particles.size()); mother_temp.AddDaughterId(trackId[iv]); @@ -1929,39 +1861,36 @@ void KFParticleFinder::ConstructTrackV0Cand(KFPTrackVector& vTracks, } Particles.push_back(mother_temp); - if( abs(mother.GetPDG()[iv]) == 3334 ) //Omega- + if (abs(mother.GetPDG()[iv]) == 3334) //Omega- { float mass, errMass; mother_temp.GetMass(mass, errMass); - - vector< vector >* motherVector = &fPrimCandidates[7]; - if( mother.GetPDG()[iv] == 3334 ) + + vector>* motherVector = &fPrimCandidates[7]; + if (mother.GetPDG()[iv] == 3334) motherVector = &fPrimCandidates[8]; - + mother_temp.SetNonlinearMassConstraint(massMotherPDG[iv]); - if( (fabs(mass - massMotherPDG[iv])/massMotherPDGSigma[iv]) <= 3 ) - for(unsigned int iP=0; iP& vV0, const int q, const int firstTrack, const int lastTrack, - vector& Particles, - std::vector >& PrimVtx, + vector& Particles, + std::vector>& PrimVtx, int v0PVIndex, kfvector_float* ChiToPrimVtx, - vector< vector >* vMotherPrim, + vector>* vMotherPrim, vector* vMotherSec) { /** Combines tracks and already reconstructed particle candidate of certain type in the next candidate. @@ -1995,14 +1924,15 @@ void KFParticleFinder::FindTrackV0Decay(vector& vV0, ** \param[out] vMotherPrim - array with output primary candidates. ** \param[out] vMotherSec - array with output secondary candidates. **/ - - if( (vV0.size() < 1) || ((lastTrack-firstTrack) < 1) ) return; + + if ((vV0.size() < 1) || ((lastTrack - firstTrack) < 1)) + return; KFParticle mother_temp; KFParticle* v0Pointer[float_v::Size]; KFParticleSIMD mother, track; - std::vector > motherTopo(fNPV); + std::vector> motherTopo(fNPV); kfvector_floatv l(fNPV), dl(fNPV); @@ -2013,421 +1943,432 @@ void KFParticleFinder::FindTrackV0Decay(vector& vV0, float_v dS; uint_v idTrack; int_v trackPDGMother(-1); - + int_v pvIndexMother(-1); - + float_v massMotherPDG(Vc::Zero), massMotherPDGSigma(Vc::Zero); int_v motherParticlePDG(Vc::Zero); -// Particles.reserve(Particles.size() + vV0.size()); + // Particles.reserve(Particles.size() + vV0.size()); - bool isCharm = ((abs(V0PDG) == 421) || (abs(V0PDG) == 411) || (abs(V0PDG) == 429) || (abs(V0PDG) == 420) || (abs(V0PDG) == 419)) && (v0PVIndex<0); + bool isCharm = ((abs(V0PDG) == 421) || (abs(V0PDG) == 411) || (abs(V0PDG) == 429) || (abs(V0PDG) == 420) || (abs(V0PDG) == 419)) && (v0PVIndex < 0); - for(unsigned int iV0=0; iV0 < vV0.size(); iV0++) - { + for (unsigned int iV0 = 0; iV0 < vV0.size(); iV0++) { int iNegDaughter = vV0[iV0].DaughterIds()[0]; int iPosDaughter = vV0[iV0].DaughterIds()[1]; - - for(int iTr=firstTrack; iTr < lastTrack; iTr += float_vLen) - { + + for (int iTr = firstTrack; iTr < lastTrack; iTr += float_vLen) { const int NTracks = (iTr + float_vLen < lastTrack) ? float_vLen : (lastTrack - iTr); const int_v& trackPDG = reinterpret_cast(vTracks.PDG()[iTr]); - const int_v& trackPVIndex = reinterpret_cast(vTracks.PVIndex()[iTr]); - + const int_v& trackPVIndex = reinterpret_cast(vTracks.PVIndex()[iTr]); + const int_m& isTrackSecondary = (trackPVIndex < 0); - const int_m& isSecondary = int_m( v0PVIndex < 0 ) && isTrackSecondary; - const int_m& isPrimary = int_m( v0PVIndex >= 0 ) && (!isTrackSecondary); + const int_m& isSecondary = int_m(v0PVIndex < 0) && isTrackSecondary; + const int_m& isPrimary = int_m(v0PVIndex >= 0) && (!isTrackSecondary); const int_m& isSamePV = (isPrimary && (v0PVIndex == trackPVIndex)) || !(isPrimary); float_m closeDaughters = simd_cast(isSamePV) && simd_cast(int_v::IndexesFromZero() < int(NTracks)); -// if(v0PVIndex < 0) -// { -// KFParticleSIMD v0(vV0[iV0]); -// track.Load(vTracks, iTr, trackPDG); - -// float_v dsV0, dsTrack; -// float_v dsdrV0[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; -// float_v dsdrTrack[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; -// float_v par1[8], cov1[36], par2[8], cov2[36]; -// v0.GetDStoParticle(track, dsV0, dsTrack); -// v0.Transport(dsV0, dsdrV0, par1, cov1); -// track.Transport(dsTrack, dsdrTrack, par2, cov2); -// -// const float_v& dx = par1[0] - par2[0]; -// const float_v& dy = par1[1] - par2[1]; -// const float_v& dz = par1[2] - par2[2]; -// const float_v& r2 = dx*dx + dy*dy + dz*dz; -// -// const float_v vtx[3] = {(par1[0] + par2[0])/2.f, -// (par1[1] + par2[1])/2.f, -// (par1[2] + par2[2])/2.f, }; -// -// v0.CorrectErrorsOnS(par1, vtx, cov1); -// track.CorrectErrorsOnS(par2, vtx, cov2); -// -// const float_v cov[6] = {cov1[0]+cov2[0], -// cov1[1]+cov2[1], -// cov1[2]+cov2[2], -// cov1[3]+cov2[3], -// cov1[4]+cov2[4], -// cov1[5]+cov2[5] }; -// const float_v& err2 = cov[0]*dx*dx + cov[2]*dy*dy + cov[5]*dz*dz + 2.f*( cov[1]*dx*dy + cov[3]*dx*dz + cov[4]*dy*dz ); -// -// closeDaughters &= ( (r2 < float_v(1.f)) && (r2*r2/err2) < float_v(3.f) && isSecondary); -// closeDaughters &= v0.GetDeviationFromParticle(track) < float_v(10.f); -// } - - if(v0PVIndex < 0) - { + // if(v0PVIndex < 0) + // { + // KFParticleSIMD v0(vV0[iV0]); + // track.Load(vTracks, iTr, trackPDG); + + // float_v dsV0, dsTrack; + // float_v dsdrV0[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; + // float_v dsdrTrack[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; + // float_v par1[8], cov1[36], par2[8], cov2[36]; + // v0.GetDStoParticle(track, dsV0, dsTrack); + // v0.Transport(dsV0, dsdrV0, par1, cov1); + // track.Transport(dsTrack, dsdrTrack, par2, cov2); + // + // const float_v& dx = par1[0] - par2[0]; + // const float_v& dy = par1[1] - par2[1]; + // const float_v& dz = par1[2] - par2[2]; + // const float_v& r2 = dx*dx + dy*dy + dz*dz; + // + // const float_v vtx[3] = {(par1[0] + par2[0])/2.f, + // (par1[1] + par2[1])/2.f, + // (par1[2] + par2[2])/2.f, }; + // + // v0.CorrectErrorsOnS(par1, vtx, cov1); + // track.CorrectErrorsOnS(par2, vtx, cov2); + // + // const float_v cov[6] = {cov1[0]+cov2[0], + // cov1[1]+cov2[1], + // cov1[2]+cov2[2], + // cov1[3]+cov2[3], + // cov1[4]+cov2[4], + // cov1[5]+cov2[5] }; + // const float_v& err2 = cov[0]*dx*dx + cov[2]*dy*dy + cov[5]*dz*dz + 2.f*( cov[1]*dx*dy + cov[3]*dx*dz + cov[4]*dy*dz ); + // + // closeDaughters &= ( (r2 < float_v(1.f)) && (r2*r2/err2) < float_v(3.f) && isSecondary); + // closeDaughters &= v0.GetDeviationFromParticle(track) < float_v(10.f); + // } + + if (v0PVIndex < 0) { KFParticleSIMD v0(vV0[iV0]); track.Load(vTracks, iTr, trackPDG); closeDaughters &= v0.GetDistanceFromParticle(track) < float_v(fDistanceCut); - if(closeDaughters.isEmpty()) continue; + if (closeDaughters.isEmpty()) + continue; } - + int_v trackPdgPos[2]; int_m active[2]; int nPDGPos = 2; - + active[0] = simd_cast(closeDaughters); active[1] = (trackPDG == -1) && isSecondary && simd_cast(closeDaughters); - + trackPdgPos[0] = trackPDG; - - if( (trackPDG == -1).isEmpty() || (abs(V0PDG) == 421) || (abs(V0PDG) == 411) ) - { + + if ((trackPDG == -1).isEmpty() || (abs(V0PDG) == 421) || (abs(V0PDG) == 411)) { nPDGPos = 1; + } else { + trackPdgPos[0](trackPDG == -1) = q * 211; + nPDGPos = 1; //TODO + trackPdgPos[1](isSecondary) = q * 321; } - else - { - trackPdgPos[0](trackPDG == -1) = q*211; - nPDGPos = 1;//TODO - trackPdgPos[1](isSecondary) = q*321; - } - for(int iPDGPos=0; iPDGPos(vTracks.Id()[iTr]); - int_m isDMeson = isSecondary && int_m(trackPdgPos[iPDGPos] == 211); - active[iPDGPos] &= (!(isDMeson)) || (isDMeson && ( id > iPosDaughter) ); - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = -521; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -321) ) = -529; - motherPDG( isPrimary && int_m(trackPdgPos[iPDGPos] == 211) ) = 10411; - } - else if(V0PDG == -421) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = -411; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -321) ) = -431; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] ==-2212) ) = -4122; + int_m isDMeson = isSecondary && int_m(trackPdgPos[iPDGPos] == 211); + active[iPDGPos] &= (!(isDMeson)) || (isDMeson && (id > iPosDaughter)); + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = -521; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -321)) = -529; + motherPDG(isPrimary && int_m(trackPdgPos[iPDGPos] == 211)) = 10411; + } else if (V0PDG == -421) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = -411; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -321)) = -431; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -2212)) = -4122; const int_v& id = reinterpret_cast(vTracks.Id()[iTr]); int_m isDMeson = isSecondary && int_m(trackPdgPos[iPDGPos] == -211); - active[iPDGPos] &= (!(isDMeson)) || (isDMeson && ( id > iNegDaughter) ); - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 211) ) = 521; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 321) ) = 529; - motherPDG( isPrimary && int_m(trackPdgPos[iPDGPos] == -211) ) = -10411; - } - else if(V0PDG == 420 && q>0) - { - motherPDG( isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 211) ) = 300411; - motherPDG( isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 321) ) = 400431; - motherPDG( isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 2212) ) = 504122; + active[iPDGPos] &= (!(isDMeson)) || (isDMeson && (id > iNegDaughter)); + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 211)) = 521; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 321)) = 529; + motherPDG(isPrimary && int_m(trackPdgPos[iPDGPos] == -211)) = -10411; + } else if (V0PDG == 420 && q > 0) { + motherPDG(isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 211)) = 300411; + motherPDG(isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 321)) = 400431; + motherPDG(isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 2212)) = 504122; const int_v& id = reinterpret_cast(vTracks.Id()[iTr]); - int_m isDMeson = isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 211); - active[iPDGPos] &= (!(isDMeson)) || (isDMeson && ( id > iPosDaughter) ); - } - else if(V0PDG == 420 && q<0) - { - motherPDG( isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 211) ) = -300411; - motherPDG( isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 321) ) = -400431; - motherPDG( isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 2212) ) = -504122; + int_m isDMeson = isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 211); + active[iPDGPos] &= (!(isDMeson)) || (isDMeson && (id > iPosDaughter)); + } else if (V0PDG == 420 && q < 0) { + motherPDG(isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 211)) = -300411; + motherPDG(isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 321)) = -400431; + motherPDG(isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 2212)) = -504122; const int_v& id = reinterpret_cast(vTracks.Id()[iTr]); - int_m isDMeson = isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 211); - active[iPDGPos] &= (!(isDMeson)) || (isDMeson && ( id > iNegDaughter) ); - } - else if(V0PDG == 411) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = 429; - motherPDG( isPrimary && int_m(trackPdgPos[iPDGPos] == -211) ) = 10421; - } - else if(V0PDG == -411) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 211) ) = -429; - motherPDG( isPrimary && int_m(trackPdgPos[iPDGPos] == 211) ) = -10421; - } - else if(V0PDG == 419) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = -511; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -321) ) = -519; - } - else if(V0PDG == -419) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 211) ) = 511; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 321) ) = 519; - } - else if(V0PDG == 429) - motherPDG( isPrimary && int_m(trackPdgPos[iPDGPos] == 211) ) = 20411; - else if(V0PDG == -429) - motherPDG( isPrimary && int_m(trackPdgPos[iPDGPos] == -211) ) = -20411; - else if( V0PDG == 3002 ) - { + int_m isDMeson = isSecondary && int_m(abs(trackPdgPos[iPDGPos]) == 211); + active[iPDGPos] &= (!(isDMeson)) || (isDMeson && (id > iNegDaughter)); + } else if (V0PDG == 411) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = 429; + motherPDG(isPrimary && int_m(trackPdgPos[iPDGPos] == -211)) = 10421; + } else if (V0PDG == -411) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 211)) = -429; + motherPDG(isPrimary && int_m(trackPdgPos[iPDGPos] == 211)) = -10421; + } else if (V0PDG == 419) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = -511; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -321)) = -519; + } else if (V0PDG == -419) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 211)) = 511; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 321)) = 519; + } else if (V0PDG == 429) + motherPDG(isPrimary && int_m(trackPdgPos[iPDGPos] == 211)) = 20411; + else if (V0PDG == -429) + motherPDG(isPrimary && int_m(trackPdgPos[iPDGPos] == -211)) = -20411; + else if (V0PDG == 3002) { const int_v& id = reinterpret_cast(vTracks.Id()[iTr]); int_m isSameProton = (id == fLPiPIndex[iV0]); - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 2212) && (!isSameProton)) = 3001; - } - else if( V0PDG == 100411 ) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = 425; - } - else if( V0PDG == 100431 ) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -321) ) = 427; - } - else if( V0PDG == 425) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 211) ) = 200411; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = -200411; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 321) ) = 300431; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -321) ) = -300431; - } - else if( V0PDG == 111 ) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 2212) ) = 3222; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -2212) ) = -3222; - motherPDG( isPrimary && int_m(trackPdgPos[iPDGPos] == 321) ) = 100323; - motherPDG( isPrimary && int_m(trackPdgPos[iPDGPos] == -321) ) = -100323; - } - else if( V0PDG == 3004 ) - { - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 2212) ) = 3006; - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = 3203; - } - else if( V0PDG == -3004 ) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -2212) ) = -3006; - else if( V0PDG == 3005 ) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 2212) ) = 3007; - else if( V0PDG == -3005 ) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -2212) ) = -3007; - else if( V0PDG == 3006 ) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = 3008; - else if( V0PDG == 3007 ) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = 3010; - else if( V0PDG == 3203 ) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 2212) ) = 3009; - else if( V0PDG == 3010 ) - { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 2212) && (!isSameProton)) = 3001; + } else if (V0PDG == 100411) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = 425; + } else if (V0PDG == 100431) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -321)) = 427; + } else if (V0PDG == 425) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 211)) = 200411; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = -200411; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 321)) = 300431; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -321)) = -300431; + } else if (V0PDG == 111) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 2212)) = 3222; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -2212)) = -3222; + motherPDG(isPrimary && int_m(trackPdgPos[iPDGPos] == 321)) = 100323; + motherPDG(isPrimary && int_m(trackPdgPos[iPDGPos] == -321)) = -100323; + } else if (V0PDG == 3004) { + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 2212)) = 3006; + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = 3203; + } else if (V0PDG == -3004) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -2212)) = -3006; + else if (V0PDG == 3005) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 2212)) = 3007; + else if (V0PDG == -3005) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -2212)) = -3007; + else if (V0PDG == 3006) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = 3008; + else if (V0PDG == 3007) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = 3010; + else if (V0PDG == 3203) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 2212)) = 3009; + else if (V0PDG == 3010) { const int_v& id = reinterpret_cast(vTracks.Id()[iTr]); int_m isSameProton = (id == Particles[vV0[iV0].DaughterIds()[1]].DaughterIds()[2]); - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 2212) && (!isSameProton)) = 3011; - } - else if(V0PDG == 304122) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 211) ) = 314122; - else if(V0PDG == -304122) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = -314122; - else if(V0PDG == 314122) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = 404122; - else if(V0PDG == -314122) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 211) ) = -404122; - else if(V0PDG == 104122) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 211) ) = 114122; - else if(V0PDG == -104122) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = -114122; - else if(V0PDG == 114122) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == -211) ) = 204122; - else if(V0PDG == -114122) - motherPDG( isSecondary && int_m(trackPdgPos[iPDGPos] == 211) ) = -204122; - + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 2212) && (!isSameProton)) = 3011; + } else if (V0PDG == 304122) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 211)) = 314122; + else if (V0PDG == -304122) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = -314122; + else if (V0PDG == 314122) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = 404122; + else if (V0PDG == -314122) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 211)) = -404122; + else if (V0PDG == 104122) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 211)) = 114122; + else if (V0PDG == -104122) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = -114122; + else if (V0PDG == 114122) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == -211)) = 204122; + else if (V0PDG == -114122) + motherPDG(isSecondary && int_m(trackPdgPos[iPDGPos] == 211)) = -204122; + active[iPDGPos] &= (motherPDG != -1); - if(!(fDecayReconstructionList.empty())) - { - for(int iV=0; iV(reinterpret_cast((*ChiToPrimVtx)[iTr]) > float_v(fCuts2D[0])) ) ); - - if(active[iPDGPos].isEmpty()) continue; - - if(isCharm) - { + if (ChiToPrimVtx) + active[iPDGPos] &= (!((abs(motherPDG) == 3334 || abs(motherPDG) == 3312)) || + ((abs(motherPDG) == 3334 || abs(motherPDG) == 3312) && simd_cast(reinterpret_cast((*ChiToPrimVtx)[iTr]) > float_v(fCuts2D[0])))); + + if (active[iPDGPos].isEmpty()) + continue; + + if (isCharm) { track.Load(vTracks, iTr, trackPDG); - const float_v& trackPt = track.Px()*track.Px() + track.Py()*track.Py(); + const float_v& trackPt = track.Px() * track.Px() + track.Py() * track.Py(); const int_v& nPixelHits = reinterpret_cast(vTracks.NPixelHits()[iTr]); - - active[iPDGPos] &= simd_cast(trackPt >= fCutCharmPt*fCutCharmPt) && simd_cast(reinterpret_cast((*ChiToPrimVtx)[iTr]) > fCutCharmChiPrim ) && int_m(nPixelHits >= int_v(3)); + + active[iPDGPos] &= simd_cast(trackPt >= fCutCharmPt * fCutCharmPt) && simd_cast(reinterpret_cast((*ChiToPrimVtx)[iTr]) > fCutCharmChiPrim) && int_m(nPixelHits >= int_v(3)); } { int_m isCharmParticle = (abs(motherPDG) == 104122) || (abs(motherPDG) == 204122) || (abs(motherPDG) == 304122) || (abs(motherPDG) == 404122) || - (abs(motherPDG) == 425) || - (abs(motherPDG) == 426) || - (abs(motherPDG) == 427) || + (abs(motherPDG) == 425) || + (abs(motherPDG) == 426) || + (abs(motherPDG) == 427) || (abs(motherPDG) == 100411) || (abs(motherPDG) == 200411) || (abs(motherPDG) == 100431) || - (abs(motherPDG) == 300431) ; - - if(!(isCharmParticle.isEmpty())) - { + (abs(motherPDG) == 300431); + + if (!(isCharmParticle.isEmpty())) { track.Load(vTracks, iTr, trackPDG); - const float_v& trackPt = track.Px()*track.Px() + track.Py()*track.Py(); + const float_v& trackPt = track.Px() * track.Px() + track.Py() * track.Py(); const int_v& nPixelHits = reinterpret_cast(vTracks.NPixelHits()[iTr]); - - active[iPDGPos] &= ( (simd_cast(trackPt >= fCutCharmPt*fCutCharmPt) && simd_cast(reinterpret_cast((*ChiToPrimVtx)[iTr]) > fCutCharmChiPrim ) && (nPixelHits >= int_v(3)) ) && isCharmParticle ) || (!isCharmParticle); + + active[iPDGPos] &= ((simd_cast(trackPt >= fCutCharmPt * fCutCharmPt) && simd_cast(reinterpret_cast((*ChiToPrimVtx)[iTr]) > fCutCharmChiPrim) && (nPixelHits >= int_v(3))) && isCharmParticle) || (!isCharmParticle); } } - - for(int iV=0; iVGetMotherMass(motherPDG[iV],massMother,massMotherSigma); + KFParticleDatabase::Instance()->GetMotherMass(motherPDG[iV], massMother, massMotherSigma); massMotherPDG[nBufEntry] = massMother; massMotherPDGSigma[nBufEntry] = massMotherSigma; motherParticlePDG[nBufEntry] = motherPDG[iV]; - + int motherType = 0; - switch (abs(motherPDG[iV])) - { - case 3312: motherType = 0; break; //Xi - case 3334: motherType = 0; break; //Omega - case 4122: motherType = 1; break; //LambdaC - case 104122: motherType = 1; break; //LambdaC - case 304122: motherType = 1; break; //LambdaC - case 504122: motherType = 1; break; //LambdaC - case 425: motherType = 1; break; //D0 - case 426: motherType = 1; break; //D0 - case 427: motherType = 1; break; //D0 - case 100411: motherType = 1; break; //D+ - case 300411: motherType = 1; break; //D+ - case 100431: motherType = 1; break; //Ds+ - case 400431: motherType = 1; break; //Ds+ - case 431: motherType = 1; break; //Ds+- - case 411: motherType = 1; break; //D+- - case 428: motherType = 1; break; //D0 - case 429: motherType = 1; break; //D0 - case 521: motherType = 1; break; //B+ - case 529: motherType = 1; break; //B+ - case 511: motherType = 1; break; //B0 - case 519: motherType = 1; break; //B0 - case 3001: motherType = 1; break; //H0 - case 3222: motherType = 1; break; //Sigma+ - case 3006: motherType = 1; break; //He4L - case 3007: motherType = 1; break; //He5L - case 3008: motherType = 1; break; //H4LL - case 3009: motherType = 1; break; //H4LL - case 3011: motherType = 1; break; //He6LL - default: motherType = 2; break; //resonances + switch (abs(motherPDG[iV])) { + case 3312: + motherType = 0; + break; //Xi + case 3334: + motherType = 0; + break; //Omega + case 4122: + motherType = 1; + break; //LambdaC + case 104122: + motherType = 1; + break; //LambdaC + case 304122: + motherType = 1; + break; //LambdaC + case 504122: + motherType = 1; + break; //LambdaC + case 425: + motherType = 1; + break; //D0 + case 426: + motherType = 1; + break; //D0 + case 427: + motherType = 1; + break; //D0 + case 100411: + motherType = 1; + break; //D+ + case 300411: + motherType = 1; + break; //D+ + case 100431: + motherType = 1; + break; //Ds+ + case 400431: + motherType = 1; + break; //Ds+ + case 431: + motherType = 1; + break; //Ds+- + case 411: + motherType = 1; + break; //D+- + case 428: + motherType = 1; + break; //D0 + case 429: + motherType = 1; + break; //D0 + case 521: + motherType = 1; + break; //B+ + case 529: + motherType = 1; + break; //B+ + case 511: + motherType = 1; + break; //B0 + case 519: + motherType = 1; + break; //B0 + case 3001: + motherType = 1; + break; //H0 + case 3222: + motherType = 1; + break; //Sigma+ + case 3006: + motherType = 1; + break; //He4L + case 3007: + motherType = 1; + break; //He5L + case 3008: + motherType = 1; + break; //H4LL + case 3009: + motherType = 1; + break; //H4LL + case 3011: + motherType = 1; + break; //He6LL + default: + motherType = 2; + break; //resonances } - for(int iCut=0; iCut<3; iCut++) + for (int iCut = 0; iCut < 3; iCut++) cuts[iCut][nBufEntry] = fCutsTrackV0[motherType][iCut]; nBufEntry++; - if(int(nBufEntry) == float_vLen) - { - mother.SetPDG( motherParticlePDG ); - ConstructTrackV0Cand(vTracks, + if (int(nBufEntry) == float_vLen) { + mother.SetPDG(motherParticlePDG); + ConstructTrackV0Cand(vTracks, idTrack, trackPDGMother, v0Pointer, mother, motherTopo, mother_temp, nBufEntry, l, dl, Particles, PrimVtx, cuts, pvIndexMother, massMotherPDG, massMotherPDGSigma, vMotherPrim, vMotherSec); - nBufEntry = 0; + nBufEntry = 0; } - }//iV - }//iPDGPos - }//iTr + } //iV + } //iPDGPos + } //iTr } - if(nBufEntry > 0) - { - for(int iV=nBufEntry; iV 0) { + for (int iV = nBufEntry; iV < float_vLen; iV++) idTrack[iV] = idTrack[0]; - - mother.SetPDG( motherParticlePDG ); - ConstructTrackV0Cand(vTracks, - idTrack, trackPDGMother, v0Pointer, - mother, motherTopo, mother_temp, - nBufEntry, l, dl, Particles, PrimVtx, - cuts, pvIndexMother, massMotherPDG, - massMotherPDGSigma, vMotherPrim, vMotherSec); - nBufEntry = 0; + + mother.SetPDG(motherParticlePDG); + ConstructTrackV0Cand(vTracks, + idTrack, trackPDGMother, v0Pointer, + mother, motherTopo, mother_temp, + nBufEntry, l, dl, Particles, PrimVtx, + cuts, pvIndexMother, massMotherPDG, + massMotherPDGSigma, vMotherPrim, vMotherSec); + nBufEntry = 0; } } void KFParticleFinder::SelectParticles(vector& Particles, vector& vCandidates, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float& cutChi2Topo, const float& cutLdL, const float& mass, @@ -2449,90 +2390,92 @@ void KFParticleFinder::SelectParticles(vector& Particles, **/ KFParticle* cand[float_vLen]; int nCand = vCandidates.size(); - + vector newCandidates; kfvector_floatv l(fNPV), dl(fNPV); - for(int iC=0; iC < nCand; iC += float_vLen) - { + for (int iC = 0; iC < nCand; iC += float_vLen) { int nEntries = (iC + float_vLen < nCand) ? float_vLen : (nCand - iC); - for(int iv=0; iv(int_v::IndexesFromZero() < int(nEntries))); float_v lMin(1.e8f); float_v ldlMin(1.e8f); float_m isParticleFromVertex(false); - for(int iP=0; iP cutLdL; saveParticle &= (lMin < 200.f); saveParticle &= isParticleFromVertex; - if( saveParticle.isEmpty() ) continue; + if (saveParticle.isEmpty()) + continue; KFParticleSIMD* candTopo = new KFParticleSIMD[fNPV]; - for(int iP=0; iP 0.0f)) continue; - if(!(candTopo[iP].GetChi2()[iv]==candTopo[iP].GetChi2()[iv])) continue; - - if(float(candTopo[iP].GetChi2()[iv])/float(candTopo[iP].GetNDF()[iv]) <= cutChi2Topo ) + for (int iP = 0; iP < fNPV; iP++) { + if (!(KFPMath::Finite(candTopo[iP].GetChi2())[iv])) + continue; + if (!(candTopo[iP].GetChi2()[iv] > 0.0f)) + continue; + if (!(candTopo[iP].GetChi2()[iv] == candTopo[iP].GetChi2()[iv])) + continue; + + if (float(candTopo[iP].GetChi2()[iv]) / float(candTopo[iP].GetNDF()[iv]) <= cutChi2Topo) isPrimary = 1; } - if(!isPrimary) + if (!isPrimary) continue; - vCandidates[iC+iv].SetId(Particles.size()); - Particles.push_back(vCandidates[iC+iv]); - + vCandidates[iC + iv].SetId(Particles.size()); + Particles.push_back(vCandidates[iC + iv]); + float m, dm; - vCandidates[iC+iv].GetMass(m,dm); - if( (fabs(m - mass)/massErr) > massCut ) continue; + vCandidates[iC + iv].GetMass(m, dm); + if ((fabs(m - mass) / massErr) > massCut) + continue; - vCandidates[iC+iv].SetNonlinearMassConstraint(mass); - newCandidates.push_back(vCandidates[iC+iv]); + vCandidates[iC + iv].SetNonlinearMassConstraint(mass); + newCandidates.push_back(vCandidates[iC + iv]); } - if(candTopo) delete [] candTopo; + if (candTopo) + delete[] candTopo; } - + vCandidates = newCandidates; } void KFParticleFinder::CombinePartPart(vector& particles1, vector& particles2, vector& Particles, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float* cuts, int iPV, const int MotherPDG, bool isSameInputPart, bool saveOnlyPrimary, - vector< vector >* vMotherPrim, + vector>* vMotherPrim, vector* vMotherSec, float massMotherPDG, float massMotherPDGSigma) @@ -2552,13 +2495,15 @@ void KFParticleFinder::CombinePartPart(vector& particles1, ** \param[in] massMotherPDG - PDG table mass for the mother particle, is used for selection of primary and secondary candidates. ** \param[in] massMotherPDGSigma - sigma of the peak width, is used for selection of primary and secondary candidates. **/ - if( (particles1.size() == 0) || (particles2.size() == 0) ) return; - if(!(fDecayReconstructionList.empty()) && (fDecayReconstructionList.find(MotherPDG) == fDecayReconstructionList.end())) return; + if ((particles1.size() == 0) || (particles2.size() == 0)) + return; + if (!(fDecayReconstructionList.empty()) && (fDecayReconstructionList.find(MotherPDG) == fDecayReconstructionList.end())) + return; KFParticle mother_temp; KFParticleSIMD mother; - KFParticleSIMD *motherTopo = new KFParticleSIMD[fNPV]; - mother.SetPDG( MotherPDG ); + KFParticleSIMD* motherTopo = new KFParticleSIMD[fNPV]; + mother.SetPDG(MotherPDG); kfvector_floatv l(fNPV), dl(fNPV); @@ -2567,201 +2512,197 @@ void KFParticleFinder::CombinePartPart(vector& particles1, bool isPrimary = (iPV >= 0); bool isCharm = (MotherPDG == 425) || - (MotherPDG == 427) || + (MotherPDG == 427) || (abs(MotherPDG) == 200411) || (abs(MotherPDG) == 404122) || - (abs(MotherPDG) == 4132) || + (abs(MotherPDG) == 4132) || (abs(MotherPDG) == 300431) || (abs(MotherPDG) == 204122); - - for(unsigned int iP1=0; iP1 < particles1.size(); iP1++) - { + + for (unsigned int iP1 = 0; iP1 < particles1.size(); iP1++) { KFParticleSIMD vDaughters[2] = {KFParticleSIMD(particles1[iP1]), KFParticleSIMD()}; - unsigned int startIndex=0; - if(isSameInputPart) startIndex=iP1+1; - for(int iP2=startIndex; iP2 < nPart2; iP2 += float_vLen) - { + unsigned int startIndex = 0; + if (isSameInputPart) + startIndex = iP1 + 1; + for (int iP2 = startIndex; iP2 < nPart2; iP2 += float_vLen) { int nElements = (iP2 + float_vLen < nPart2) ? float_vLen : (nPart2 - iP2); float_m active(simd_cast(int_v::IndexesFromZero() < int(nElements))); - for(int iv=0; ivId()[0]; -// uint_v gammaIndex1( (unsigned int)0); -// uint_v gammaIndex2( (unsigned int)0); -// for(int iv=0; ivGetPi0Mass(); -// const float& mPi0Sigma = KFParticleDatabase::Instance()->GetPi0MassSigma(); -// active &= (abs(mass - mPi0)/mPi0Sigma) < 3.f; -// vDaughters[1].SetNonlinearMassConstraint(mPi0); -// if(active.isEmpty()) continue; -// } - - if(isCharm) - { - mother = vDaughters[0]; + for (int iv = 0; iv < nElements; iv++) + tmpPart2[iv] = &particles2[iP2 + iv]; + + vDaughters[1] = KFParticleSIMD(tmpPart2, nElements); + + // if( reconstructPi0 ) + // { + // int indexOffset = fEmcClusters->Id()[0]; + // uint_v gammaIndex1( (unsigned int)0); + // uint_v gammaIndex2( (unsigned int)0); + // for(int iv=0; ivGetPi0Mass(); + // const float& mPi0Sigma = KFParticleDatabase::Instance()->GetPi0MassSigma(); + // active &= (abs(mass - mPi0)/mPi0Sigma) < 3.f; + // vDaughters[1].SetNonlinearMassConstraint(mPi0); + // if(active.isEmpty()) continue; + // } + + if (isCharm) { + mother = vDaughters[0]; mother += vDaughters[1]; - mother.SetPDG( MotherPDG ); - } - else - { + mother.SetPDG(MotherPDG); + } else { const KFParticleSIMD* vDaughtersPointer[2] = {&vDaughters[0], &vDaughters[1]}; mother.Construct(vDaughtersPointer, 2, 0); } - + float_m saveParticle(active); - saveParticle &= (mother.Chi2()/simd_cast(mother.NDF()) < cuts[2] ); + saveParticle &= (mother.Chi2() / simd_cast(mother.NDF()) < cuts[2]); saveParticle &= KFPMath::Finite(mother.GetChi2()); saveParticle &= (mother.GetChi2() >= 0.0f); saveParticle &= (mother.GetChi2() == mother.GetChi2()); - - if( saveParticle.isEmpty() ) { continue; } + + if (saveParticle.isEmpty()) { + continue; + } int_m isSameTrack(false); - for(unsigned int iD=0; iD(isSameTrack)); - if( saveParticle.isEmpty() ) { continue; } - + for (unsigned int iD = 0; iD < vDaughters[0].DaughterIds().size(); iD++) + for (unsigned int iD1 = 0; iD1 < vDaughters[1].DaughterIds().size(); iD1++) + isSameTrack |= (int_v(vDaughters[0].DaughterIds()[iD]) == int_v(vDaughters[1].DaughterIds()[iD1])); + saveParticle &= (!simd_cast(isSameTrack)); + if (saveParticle.isEmpty()) { + continue; + } + float_v lMin(1.e8f); float_v ldlMin(1.e8f); float_m isParticleFromVertex(false); - for(int iP=0; iP -1) && (iP !=iPV) ) continue; + for (int iP = 0; iP < fNPV; iP++) { + if ((iPV > -1) && (iP != iPV)) + continue; float_m isParticleFromVertexLocal; mother.GetDistanceToVertexLine(PrimVtx[iP], l[iP], dl[iP], &isParticleFromVertexLocal); isParticleFromVertex |= isParticleFromVertexLocal; - float_v ldl = (l[iP]/dl[iP]); - lMin( (l[iP] < lMin) && active) = l[iP]; - ldlMin( (ldl < ldlMin) && active) = ldl; + float_v ldl = (l[iP] / dl[iP]); + lMin((l[iP] < lMin) && active) = l[iP]; + ldlMin((ldl < ldlMin) && active) = ldl; } - saveParticle &= ( (float_m(!isPrimary) && ldlMin > cuts[0]) || float_m(isPrimary) ); + saveParticle &= ((float_m(!isPrimary) && ldlMin > cuts[0]) || float_m(isPrimary)); saveParticle &= (lMin < 200.f); - + int_m setLCut = abs(mother.PDG()) == 3000; - saveParticle &= ( (simd_cast(setLCut) && lMin > float_v(fLCut)) || simd_cast(!setLCut) ); + saveParticle &= ((simd_cast(setLCut) && lMin > float_v(fLCut)) || simd_cast(!setLCut)); -// if(isPrimary && (float(ldlMin > 3) )) continue; - saveParticle &= ((float_m(!isPrimary) && isParticleFromVertex) || float_m(isPrimary) ); - if( saveParticle.isEmpty() ) { continue; } + // if(isPrimary && (float(ldlMin > 3) )) continue; + saveParticle &= ((float_m(!isPrimary) && isParticleFromVertex) || float_m(isPrimary)); + if (saveParticle.isEmpty()) { + continue; + } float_m isSameParticle(isPrimary || isCharm); - if(!((isSameParticle).isFull())) - { + if (!((isSameParticle).isFull())) { float_m isParticleFromVertexLocal; float_v l1, dl1; vDaughters[0].GetDistanceToVertexLine(mother, l1, dl1, &isParticleFromVertexLocal); - - saveParticle &= ( isSameParticle || ((!isSameParticle) && isParticleFromVertexLocal)); - if( saveParticle.isEmpty() ) { continue; } + + saveParticle &= (isSameParticle || ((!isSameParticle) && isParticleFromVertexLocal)); + if (saveParticle.isEmpty()) { + continue; + } } - - for(int iP=0; iP -1) && (iP !=iPV) ) continue; + + for (int iP = 0; iP < fNPV; iP++) { + if ((iPV > -1) && (iP != iPV)) + continue; motherTopo[iP] = mother; motherTopo[iP].SetProductionVertex(PrimVtx[iP]); } - + vector iPrimVert[float_vLen]; float_m isPrimaryPart(false); - for(int iP=0; iP -1) && (iP !=iPV) ) continue; - const float_v& motherTopoChi2Ndf = motherTopo[iP].GetChi2()/simd_cast(motherTopo[iP].GetNDF()); - const float_m isPrimaryPartLocal = ( motherTopoChi2Ndf < float_v(cuts[1]) ); + for (int iP = 0; iP < fNPV; iP++) { + if ((iPV > -1) && (iP != iPV)) + continue; + const float_v& motherTopoChi2Ndf = motherTopo[iP].GetChi2() / simd_cast(motherTopo[iP].GetNDF()); + const float_m isPrimaryPartLocal = (motherTopoChi2Ndf < float_v(cuts[1])); isPrimaryPart |= isPrimaryPartLocal; - for(int iV=0; iVId()); } - - if(saveOnlyPrimary) - { - if(isPrimaryPart[iv]) - { + + if (saveOnlyPrimary) { + if (isPrimaryPart[iv]) { mother_temp.SetId(Particles.size()); Particles.push_back(mother_temp); } - } - else - { + } else { mother_temp.SetId(Particles.size()); Particles.push_back(mother_temp); } - - if(vMotherPrim || vMotherSec) - { + + if (vMotherPrim || vMotherSec) { float mass, errMass; mother_temp.GetMass(mass, errMass); - if( (fabs(mass - massMotherPDG)/massMotherPDGSigma) > 3.f ) continue; + if ((fabs(mass - massMotherPDG) / massMotherPDGSigma) > 3.f) + continue; mother_temp.SetNonlinearMassConstraint(massMotherPDG); - - if(MotherPDG == 428) - { + + if (MotherPDG == 428) { mother_temp.CleanDaughtersId(); - for(int iD=0; iD < tmpPart2[iv]->NDaughters(); iD++) - mother_temp.AddDaughterId( tmpPart2[iv]->DaughterIds()[iD] ); - for(int iD=0; iD < particles1[iP1].NDaughters(); iD++) - mother_temp.AddDaughterId( particles1[iP1].DaughterIds()[iD] ); + for (int iD = 0; iD < tmpPart2[iv]->NDaughters(); iD++) + mother_temp.AddDaughterId(tmpPart2[iv]->DaughterIds()[iD]); + for (int iD = 0; iD < particles1[iP1].NDaughters(); iD++) + mother_temp.AddDaughterId(particles1[iP1].DaughterIds()[iD]); } - - if(vMotherSec && (!(isPrimaryPart[iv])) ) + + if (vMotherSec && (!(isPrimaryPart[iv]))) vMotherSec->push_back(mother_temp); - if(vMotherPrim) - for(unsigned int iP=0; iP& Particles) @@ -2784,58 +2725,59 @@ void KFParticleFinder::NeutralDaughterDecay(KFPTrackVector* vTracks, uint_v idMotherTrack; uint_v idChargedDaughter; int_v ChargedDaughterPDG(-1); - - int_v pvIndexMother(-1); - + + int_v pvIndexMother(-1); + int outNeutralDaughterPDG[4][5]; //[iTC][iHypothesis] int outMotherPDG[4][5]; - - int trTypeIndexMother[2] = {6,7}; - int trTypeIndexDaughter[2] = {0,1}; - for( int iTrTypeDaughter = 0; iTrTypeDaughter<2; iTrTypeDaughter++) - { - KFPTrackVector& DaughterTracks = vTracks[ trTypeIndexDaughter[iTrTypeDaughter] ]; - KFPTrackVector& MotherTracks = vTracks[ trTypeIndexMother[iTrTypeDaughter] ]; + int trTypeIndexMother[2] = {6, 7}; + int trTypeIndexDaughter[2] = {0, 1}; + + for (int iTrTypeDaughter = 0; iTrTypeDaughter < 2; iTrTypeDaughter++) { + KFPTrackVector& DaughterTracks = vTracks[trTypeIndexDaughter[iTrTypeDaughter]]; + KFPTrackVector& MotherTracks = vTracks[trTypeIndexMother[iTrTypeDaughter]]; int_v DaughterTracksSize = DaughterTracks.Size(); int MotherTracksSize = MotherTracks.Size(); //track categories int nTC = 4; - int startTCMother[4] = {0,0,0,0}; - int endTCMother[4] = {0,0,0,0}; - int startTCDaughter[4] = {0,0,0,0}; - int endTCDaughter[4] = {0,0,0,0}; + int startTCMother[4] = {0, 0, 0, 0}; + int endTCMother[4] = {0, 0, 0, 0}; + int startTCDaughter[4] = {0, 0, 0, 0}; + int endTCDaughter[4] = {0, 0, 0, 0}; nTC = 4; - vector nMotherHypothesis(nTC,0); - vector< vector > motherPDGHypothesis(nTC); - vector< vector > neutralDaughterMassHypothesis(nTC); - + vector nMotherHypothesis(nTC, 0); + vector> motherPDGHypothesis(nTC); + vector> neutralDaughterMassHypothesis(nTC); //mu+, mu- - startTCMother[0] = 0; endTCMother[0] = MotherTracksSize; - startTCDaughter[0] = DaughterTracks.FirstMuon(); endTCDaughter[0] = DaughterTracks.LastMuon(); + startTCMother[0] = 0; + endTCMother[0] = MotherTracksSize; + startTCDaughter[0] = DaughterTracks.FirstMuon(); + endTCDaughter[0] = DaughterTracks.LastMuon(); nMotherHypothesis[0] = 2; - motherPDGHypothesis[0].push_back(211); motherPDGHypothesis[0].push_back(321); neutralDaughterMassHypothesis[0].push_back(0.); neutralDaughterMassHypothesis[0].push_back(0.); - outNeutralDaughterPDG[0][0]=-7000014; - outNeutralDaughterPDG[0][1]=-8000014; + outNeutralDaughterPDG[0][0] = -7000014; + outNeutralDaughterPDG[0][1] = -8000014; - outMotherPDG[0][0]=-7000211; - outMotherPDG[0][1]=-7000321; + outMotherPDG[0][0] = -7000211; + outMotherPDG[0][1] = -7000321; //Pi+, Pi- - startTCMother[1] = 0; endTCMother[1] = MotherTracksSize; - startTCDaughter[1] = DaughterTracks.FirstPion(); endTCDaughter[1] = DaughterTracks.LastPion(); + startTCMother[1] = 0; + endTCMother[1] = MotherTracksSize; + startTCDaughter[1] = DaughterTracks.FirstPion(); + endTCDaughter[1] = DaughterTracks.LastPion(); nMotherHypothesis[1] = 5; @@ -2844,59 +2786,59 @@ void KFParticleFinder::NeutralDaughterDecay(KFPTrackVector* vTracks, motherPDGHypothesis[1].push_back(3312); motherPDGHypothesis[1].push_back(3334); motherPDGHypothesis[1].push_back(321); - + neutralDaughterMassHypothesis[1].push_back(0.939565); neutralDaughterMassHypothesis[1].push_back(0.939565); neutralDaughterMassHypothesis[1].push_back(1.115683); neutralDaughterMassHypothesis[1].push_back(1.31486); neutralDaughterMassHypothesis[1].push_back(0.1349766); - - outNeutralDaughterPDG[1][0]= 7002112; - outNeutralDaughterPDG[1][1]=-8002112; - outNeutralDaughterPDG[1][2]= 7003122; - outNeutralDaughterPDG[1][3]= 7003322; - outNeutralDaughterPDG[1][4]=-9000111; - - outMotherPDG[1][0]= 7003112; - outMotherPDG[1][1]=-7003222; - outMotherPDG[1][2]= 7003312; - outMotherPDG[1][3]= 7003334; - outMotherPDG[1][4]=-9000321; - + + outNeutralDaughterPDG[1][0] = 7002112; + outNeutralDaughterPDG[1][1] = -8002112; + outNeutralDaughterPDG[1][2] = 7003122; + outNeutralDaughterPDG[1][3] = 7003322; + outNeutralDaughterPDG[1][4] = -9000111; + + outMotherPDG[1][0] = 7003112; + outMotherPDG[1][1] = -7003222; + outMotherPDG[1][2] = 7003312; + outMotherPDG[1][3] = 7003334; + outMotherPDG[1][4] = -9000321; + //K+, K- - startTCMother[2] = 0; endTCMother[2] = MotherTracksSize; - startTCDaughter[2] = DaughterTracks.FirstKaon(); endTCDaughter[2] = DaughterTracks.LastKaon(); + startTCMother[2] = 0; + endTCMother[2] = MotherTracksSize; + startTCDaughter[2] = DaughterTracks.FirstKaon(); + endTCDaughter[2] = DaughterTracks.LastKaon(); nMotherHypothesis[2] = 1; - + motherPDGHypothesis[2].push_back(3334); - + neutralDaughterMassHypothesis[2].push_back(1.115683); - - outNeutralDaughterPDG[2][0]= 8003122; - - outMotherPDG[2][0]= 8003334; + + outNeutralDaughterPDG[2][0] = 8003122; + + outMotherPDG[2][0] = 8003334; //p+, p- - startTCMother[3] = 0; endTCMother[3] = MotherTracksSize; - startTCDaughter[3] = DaughterTracks.FirstProton(); endTCDaughter[3] = DaughterTracks.LastProton(); + startTCMother[3] = 0; + endTCMother[3] = MotherTracksSize; + startTCDaughter[3] = DaughterTracks.FirstProton(); + endTCDaughter[3] = DaughterTracks.LastProton(); nMotherHypothesis[3] = 1; - + motherPDGHypothesis[3].push_back(3222); - + neutralDaughterMassHypothesis[3].push_back(0.1349766); - - outNeutralDaughterPDG[3][0]=-8000111; - - outMotherPDG[3][0]=-8003222; - - - - for(int iTC=0; iTC(DaughterTracks.PDG()[iTrD]); int_v DaughterPVIndex = reinterpret_cast(DaughterTracks.PVIndex()[iTrD]); int_v daughterId = reinterpret_cast(DaughterTracks.Id()[iTrD]); - + int_v trackPdgDaughter = DaughterPDG; int_m activeDaughter = (DaughterPDG != -1); - - if( !((DaughterPDG == -1).isEmpty()) ) - { - trackPdgDaughter(DaughterPVIndex<0 && (DaughterPDG == -1) ) = 211; - -// activeDaughter |= int_m(DaughterPVIndex < 0) && int_m(DaughterPDG == -1) ; + + if (!((DaughterPDG == -1).isEmpty())) { + trackPdgDaughter(DaughterPVIndex < 0 && (DaughterPDG == -1)) = 211; + + // activeDaughter |= int_m(DaughterPVIndex < 0) && int_m(DaughterPDG == -1) ; } - + activeDaughter = (int_v::IndexesFromZero() < int(NTracksDaughter)); - + ChargedDaughter.Load(DaughterTracks, iTrD, DaughterPDG); ChargedDaughter.SetId(daughterId); - for(unsigned short iTrM=startTCMother[iTC]; iTrM < endTCMother[iTC]; iTrM += float_vLen) - { + for (unsigned short iTrM = startTCMother[iTC]; iTrM < endTCMother[iTC]; iTrM += float_vLen) { const unsigned short NTracks = (iTrM + float_vLen < MotherTracksSize) ? float_vLen : (MotherTracksSize - iTrM); //const int_v& MotherPDG = reinterpret_cast(MotherTracks.PDG()[iTrM]); - //const int_v& MotherPVIndex = reinterpret_cast(MotherTracks.PVIndex()[iTrM]); - const int_v& motherTrackId = reinterpret_cast(MotherTracks.Id()[iTrM]); - - for(int iRot = 0; iRot0) - { + //const int_v& MotherPVIndex = reinterpret_cast(MotherTracks.PVIndex()[iTrM]); + const int_v& motherTrackId = reinterpret_cast(MotherTracks.Id()[iTrM]); + + for (int iRot = 0; iRot < float_vLen; iRot++) { + if (iRot > 0) { DaughterPDG = DaughterPDG.rotated(1); DaughterPVIndex = DaughterPVIndex.rotated(1); DaughterInd = DaughterInd.rotated(1); trackPdgDaughter = trackPdgDaughter.rotated(1); - + ChargedDaughter.Rotate(); activeDaughter = /*( (DaughterPDG != -1) || ( (DaughterPVIndex < 0) && (DaughterPDG == -1) ) ) &&*/ (DaughterInd < DaughterTracksSize); } - + int_v trackPdgMother; - if(iTC==0) - activeDaughter &= abs(DaughterPDG)==13; - if(iTC==1) - activeDaughter &= abs(DaughterPDG)==211; - if(iTC==2) - activeDaughter &= abs(DaughterPDG)==321; - if(iTC==3) - activeDaughter &= abs(DaughterPDG)==2212; - if (activeDaughter.isEmpty()) continue; - - - for(int iHypothesis=0; iHypothesis(zCD >= (zMother - float_v(0.5f))); - if( active.isEmpty() ) continue; - + if (active.isEmpty()) + continue; + KFParticleSIMD neutralDaughter = MotherTrack; //energy of the mother particle should be greater then of the daughter particle active &= simd_cast(neutralDaughter.E() > ChargedDaughter.E()); - if( active.isEmpty() ) continue; - + if (active.isEmpty()) + continue; + neutralDaughter.AddDaughterId(motherTrackId); neutralDaughter.NDF() = -1; neutralDaughter.Chi2() = 0.f; neutralDaughter.SubtractDaughter(ChargedDaughter); - + //decay point shoud be between mother and daughter tracks active &= simd_cast(neutralDaughter.Z() >= zMother - float_v(10.0f)); active &= simd_cast(neutralDaughter.Z() <= zCD + float_v(10.0f)); //set cut on chi2 of the fit of the neutral daughter active &= simd_cast(neutralDaughter.NDF() >= int_v(Vc::Zero)); - active &= simd_cast(neutralDaughter.Chi2()/simd_cast(neutralDaughter.NDF()) <= fCuts2D[1]); + active &= simd_cast(neutralDaughter.Chi2() / simd_cast(neutralDaughter.NDF()) <= fCuts2D[1]); //fit should converge active &= simd_cast(neutralDaughter.Chi2() >= float_v(Vc::Zero)); active &= simd_cast(neutralDaughter.Chi2() == neutralDaughter.Chi2()); - if( active.isEmpty() ) continue; - + if (active.isEmpty()) + continue; + //kill particle-candidates produced by clones - active &= simd_cast( neutralDaughter.GetRapidity()<6.f && neutralDaughter.GetRapidity()>0.f); - if ((iTC==1 && iHypothesis<4) || iTC==2) - active &= simd_cast( !( (neutralDaughter.GetPt())<0.5f && neutralDaughter.GetRapidity()<0.5f ) ); - if (iTC==3) - active &= simd_cast( !( (neutralDaughter.GetPt())<0.2f && neutralDaughter.GetRapidity()<1.f ) ); - if( active.isEmpty() ) continue; - + active &= simd_cast(neutralDaughter.GetRapidity() < 6.f && neutralDaughter.GetRapidity() > 0.f); + if ((iTC == 1 && iHypothesis < 4) || iTC == 2) + active &= simd_cast(!((neutralDaughter.GetPt()) < 0.5f && neutralDaughter.GetRapidity() < 0.5f)); + if (iTC == 3) + active &= simd_cast(!((neutralDaughter.GetPt()) < 0.2f && neutralDaughter.GetRapidity() < 1.f)); + if (active.isEmpty()) + continue; + KFParticleSIMD neutralDaughterUnconstr = neutralDaughter; neutralDaughter.SetNonlinearMassConstraint(neutralDaughterMassHypothesis[iTC][iHypothesis]); - + const KFParticleSIMD* daughters[2] = {&neutralDaughter, &ChargedDaughter}; KFParticleSIMD mother; mother.Construct(daughters, 2); - + //decay point shoud be between mother and daughter tracks active &= simd_cast(mother.Z() >= zMother); active &= simd_cast(mother.Z() <= zCD); //set cut on chi2 of the fit of the mother particle active &= simd_cast(mother.NDF() >= int_v(Vc::Zero)); - active &= simd_cast(mother.Chi2()/simd_cast(mother.NDF()) <= fCuts2D[1]); + active &= simd_cast(mother.Chi2() / simd_cast(mother.NDF()) <= fCuts2D[1]); //fit should converge active &= simd_cast(mother.Chi2() >= float_v(Vc::Zero)); active &= simd_cast(mother.Chi2() == mother.Chi2()); - if( active.isEmpty() ) continue; + if (active.isEmpty()) + continue; + + for (int iV = 0; iV < NTracks; iV++) { + if (!active[iV]) + continue; - for(int iV=0; iV -1) - { - if(iPV >= 0 && iPV -1) { + if (iPV >= 0 && iPV < fNPV) { + if (candidate.NDF() == 2) fPrimCandidates[iSet][iPV].push_back(candidate); - if(candidate.NDF() == 3) + if (candidate.NDF() == 3) fPrimCandidatesTopo[iSet][iPV].push_back(candidate); - if(candidate.NDF() == 4) + if (candidate.NDF() == 4) fPrimCandidatesTopoMass[iSet][iPV].push_back(candidate); - } - else if(iPV < 0) - { + } else if (iPV < 0) { fSecCandidates[iSet].push_back(candidate); } } @@ -3104,20 +3053,18 @@ void KFParticleFinder::SetNPV(int nPV) ** with primary candidates correspondingly. ** \param[in] nPV - number of the primary vertices in the event to be set. **/ - + fNPV = nPV; - - for(int iCandidates=0; iCandidates. */ - #ifndef KFParticleFinder_h #define KFParticleFinder_h @@ -47,86 +46,84 @@ class KFPEmcCluster; class KFParticleFinder { public: - KFParticleFinder(); - virtual ~KFParticleFinder() {}; - + virtual ~KFParticleFinder(){}; + void Init(int nPV); - void SetNThreads(short int n) { fNThreads = n;} ///< Sets the number of threads to by run in parallel. Currently not used. + void SetNThreads(short int n) { fNThreads = n; } ///< Sets the number of threads to by run in parallel. Currently not used. void FindParticles(KFPTrackVector* vRTracks, kfvector_float* ChiToPrimVtx, - std::vector& Particles, std::vector >& PrimVtx, int nPV); + std::vector& Particles, std::vector>& PrimVtx, int nPV); void ExtrapolateToPV(std::vector& vParticles, KFParticleSIMD& PrimVtx); - + inline void ConstructV0(KFPTrackVector* vTracks, - int iTrTypePos, - int iTrTypeNeg, - uint_v& idPosDaughters, - uint_v& idNegDaughters, - int_v& daughterPosPDG, - int_v& daughterNegPDG, - KFParticleSIMD& mother, - KFParticle& mother_temp, - const unsigned short NTracks, - kfvector_floatv& l, - kfvector_floatv& dl, - std::vector& Particles, - std::vector >& PrimVtx, - const float* cuts, - const int_v& pvIndex, - const float* secCuts, - const float_v& massMotherPDG, - const float_v& massMotherPDGSigma, - KFParticleSIMD& motherPrimSecCand, - int& nPrimSecCand, - std::vector< std::vector >* vMotherPrim = 0, - std::vector* vMotherSec = 0 - ) __attribute__((always_inline)); - - void SaveV0PrimSecCand(KFParticleSIMD& mother, - int& NParticles, + int iTrTypePos, + int iTrTypeNeg, + uint_v& idPosDaughters, + uint_v& idNegDaughters, + int_v& daughterPosPDG, + int_v& daughterNegPDG, + KFParticleSIMD& mother, KFParticle& mother_temp, - std::vector >& PrimVtx, + const unsigned short NTracks, + kfvector_floatv& l, + kfvector_floatv& dl, + std::vector& Particles, + std::vector>& PrimVtx, + const float* cuts, + const int_v& pvIndex, const float* secCuts, - std::vector< std::vector >* vMotherPrim, - std::vector* vMotherSec); - + const float_v& massMotherPDG, + const float_v& massMotherPDGSigma, + KFParticleSIMD& motherPrimSecCand, + int& nPrimSecCand, + std::vector>* vMotherPrim = 0, + std::vector* vMotherSec = 0) __attribute__((always_inline)); + + void SaveV0PrimSecCand(KFParticleSIMD& mother, + int& NParticles, + KFParticle& mother_temp, + std::vector>& PrimVtx, + const float* secCuts, + std::vector>* vMotherPrim, + std::vector* vMotherSec); + void ConstructTrackV0Cand(KFPTrackVector& vTracks, - uint_v& idTracks, - int_v& trackPDG, - KFParticle* vV0[], - KFParticleSIMD& mother, - std::vector >& motherTopo, - KFParticle& mother_temp, - const unsigned short nElements, - kfvector_floatv& l, - kfvector_floatv& dl, - std::vector& Particles, - std::vector >& PrimVtx, - const float_v* cuts, - const int_v& pvIndex, - const float_v& massMotherPDG, - const float_v& massMotherPDGSigma, - std::vector< std::vector >* vMotherPrim, - std::vector* vMotherSec); + uint_v& idTracks, + int_v& trackPDG, + KFParticle* vV0[], + KFParticleSIMD& mother, + std::vector>& motherTopo, + KFParticle& mother_temp, + const unsigned short nElements, + kfvector_floatv& l, + kfvector_floatv& dl, + std::vector& Particles, + std::vector>& PrimVtx, + const float_v* cuts, + const int_v& pvIndex, + const float_v& massMotherPDG, + const float_v& massMotherPDGSigma, + std::vector>* vMotherPrim, + std::vector* vMotherSec); void Find2DaughterDecay(KFPTrackVector* vTracks, kfvector_float* ChiToPrimVtx, std::vector& Particles, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float* cuts, const float* secCuts, - std::vector< std::vector >* vMotherPrim, - std::vector* vMotherSec ); - + std::vector>* vMotherPrim, + std::vector* vMotherSec); + void ConstructPrimaryBG(KFPTrackVector* vTracks, std::vector& Particles, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float* cuts, const float* secCuts, - std::vector< std::vector >* vMotherPrim, - std::vector* vMotherSec ); - + std::vector>* vMotherPrim, + std::vector* vMotherSec); + void NeutralDaughterDecay(KFPTrackVector* vTracks, std::vector& Particles); void FindTrackV0Decay(std::vector& vV0, @@ -135,183 +132,184 @@ class KFParticleFinder const int q, const int firstTrack, const int lastTrack, - std::vector& Particles, - std::vector >& PrimVtx, + std::vector& Particles, + std::vector>& PrimVtx, int v0PVIndex = -1, kfvector_float* ChiToPrimVtx = 0, - std::vector< std::vector >* vMotherPrim = 0, + std::vector>* vMotherPrim = 0, std::vector* vMotherSec = 0); void SelectParticles(std::vector& Particles, std::vector& vCandidates, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float& cutChi2Topo, const float& cutLdL, const float& mass, const float& massErr, const float& massCut); - + void CombinePartPart(std::vector& particles1, std::vector& particles2, std::vector& Particles, - std::vector >& PrimVtx, + std::vector>& PrimVtx, const float* cuts, int iPV, const int MotherPDG, bool isSameInputPart = 0, bool saveOnlyPrimary = 1, - std::vector< std::vector >* vMotherPrim = 0, + std::vector>* vMotherPrim = 0, std::vector* vMotherSec = 0, float massMotherPDG = 0.f, float massMotherPDGSigma = 0.f); //Set Emc clusters containing gammas void SetEmcClusters(KFPEmcCluster* clusters) { fEmcClusters = clusters; } ///< Set a pointer to the gamma-clusters from the electromagnetic calorimeter. - + // Mixed Event Analysis void SetMixedEventAnalysis() { fMixedEventAnalysis = 1; } ///< Switch KFParticleFinder to the mixed event mode. - + //Get secondary particles with the mass constraint /** Returns number of sets of vectors with secondary candidates for different decays. */ - static int GetNSecondarySets() { return fNSecCandidatesSets; } + static int GetNSecondarySets() { return fNSecCandidatesSets; } /** Returns a pointer to array with sets of vectors with secondary candidates for different decays. */ - const std::vector* GetSecondaryCandidates() const { return fSecCandidates; } + const std::vector* GetSecondaryCandidates() const { return fSecCandidates; } /** Returns a constant reference to the vector with secondary candidates for \f$K_s^0\rightarrow\pi^+\pi^-\f$. **/ - const std::vector& GetSecondaryK0() const { return fSecCandidates[0]; } + const std::vector& GetSecondaryK0() const { return fSecCandidates[0]; } /** Returns a constant reference to the vector with secondary candidates for \f$\Lambda\rightarrow p\pi^-\f$. **/ - const std::vector& GetSecondaryLambda() const { return fSecCandidates[1]; } + const std::vector& GetSecondaryLambda() const { return fSecCandidates[1]; } /** Returns a constant reference to the vector with secondary candidates for \f$\overline{\Lambda}\rightarrow \overline{p}\pi^+\f$. **/ const std::vector& GetSecondaryAntiLambda() const { return fSecCandidates[2]; } /** Returns a constant reference to the vector with secondary candidates for \f$\gamma\rightarrow e^+e^-\f$ conversion. **/ - const std::vector& GetSecondaryGamma() const { return fSecCandidates[3]; } + const std::vector& GetSecondaryGamma() const { return fSecCandidates[3]; } /** Returns a constant reference to the vector with secondary candidates for \f$\pi^0\rightarrow \gamma\gamma\f$. **/ - const std::vector& GetSecondaryPi0() const { return fSecCandidates[4]; } - + const std::vector& GetSecondaryPi0() const { return fSecCandidates[4]; } + //Get primary particles with the mass constraint /** Returns number of sets of vectors with primary candidates for different decays. */ static int GetNPrimarySets() { return fNPrimCandidatesTopoSets; } /** Returns a pointer to array with sets of vectors with primary candidates for different decays. */ - const std::vector< std::vector >* GetPrimaryCandidates() const { return fPrimCandidates; } + const std::vector>* GetPrimaryCandidates() const { return fPrimCandidates; } /** Returns a constant reference to the vector with primary candidates for \f$K_s^0\rightarrow\pi^+\pi^-\f$. **/ - const std::vector< std::vector >& GetPrimaryK0() const { return fPrimCandidates[0]; } + const std::vector>& GetPrimaryK0() const { return fPrimCandidates[0]; } /** Returns a constant reference to the vector with primary candidates for \f$\Lambda\rightarrow p\pi^-\f$. **/ - const std::vector< std::vector >& GetPrimaryLambda() const { return fPrimCandidates[1]; } + const std::vector>& GetPrimaryLambda() const { return fPrimCandidates[1]; } /** Returns a constant reference to the vector with primary candidates for \f$\overline{\Lambda}\rightarrow \overline{p}\pi^+\f$. **/ - const std::vector< std::vector >& GetPrimaryAntiLambda() const { return fPrimCandidates[2]; } + const std::vector>& GetPrimaryAntiLambda() const { return fPrimCandidates[2]; } /** Returns a constant reference to the vector with primary candidates for \f$\gamma\rightarrow e^+e^-\f$ conversion. **/ - const std::vector< std::vector >& GetPrimaryGamma() const { return fPrimCandidates[3]; } + const std::vector>& GetPrimaryGamma() const { return fPrimCandidates[3]; } /** Returns a constant reference to the vector with primary candidates for \f$\pi^0\rightarrow \gamma\gamma\f$. **/ - const std::vector< std::vector >& GetPrimaryPi0() const { return fPrimCandidates[4]; } + const std::vector>& GetPrimaryPi0() const { return fPrimCandidates[4]; } /** Returns a constant reference to the vector with secondary candidates for \f$\Xi^-\rightarrow \Lambda\pi^-\f$. **/ - const std::vector< std::vector >& GetPrimaryXi() const { return fPrimCandidates[5]; } + const std::vector>& GetPrimaryXi() const { return fPrimCandidates[5]; } /** Returns a constant reference to the vector with secondary candidates for \f$\overline{\Xi}^-\rightarrow \overline{\Lambda}\pi^+\f$. **/ - const std::vector< std::vector >& GetPrimaryAntiXi() const { return fPrimCandidates[6]; } + const std::vector>& GetPrimaryAntiXi() const { return fPrimCandidates[6]; } /** Returns a constant reference to the vector with secondary candidates for \f$\Omega^-\rightarrow \Lambda K^-\f$. **/ - const std::vector< std::vector >& GetPrimaryOmega() const { return fPrimCandidates[7]; } + const std::vector>& GetPrimaryOmega() const { return fPrimCandidates[7]; } /** Returns a constant reference to the vector with secondary candidates for \f$\overline{\Omega}^-\rightarrow \overline{\Lambda} K^+\f$. **/ - const std::vector< std::vector >& GetPrimaryAntiOmega() const { return fPrimCandidates[8]; } - + const std::vector>& GetPrimaryAntiOmega() const { return fPrimCandidates[8]; } + //Get primary particles with the topologigal constraint /** Returns a pointer to array with sets of vectors with primary candidates for different decays with topological constraint set on. */ - const std::vector< std::vector >* GetPrimaryTopoCandidates() const { return fPrimCandidatesTopo; } + const std::vector>* GetPrimaryTopoCandidates() const { return fPrimCandidatesTopo; } /** Returns a constant reference to the vector with primary candidates for \f$K_s^0\rightarrow\pi^+\pi^-\f$ ** with topological constraint set on. **/ - const std::vector< std::vector >& GetPrimaryTopoK0() const { return fPrimCandidatesTopo[0]; } + const std::vector>& GetPrimaryTopoK0() const { return fPrimCandidatesTopo[0]; } /** Returns a constant reference to the vector with primary candidates for \f$\Lambda\rightarrow p\pi^-\f$ ** with topological constraint set on. **/ - const std::vector< std::vector >& GetPrimaryTopoLambda() const { return fPrimCandidatesTopo[1]; } + const std::vector>& GetPrimaryTopoLambda() const { return fPrimCandidatesTopo[1]; } /** Returns a constant reference to the vector with primary candidates for \f$\overline{\Lambda}\rightarrow \overline{p}\pi^+\f$ ** with topological constraint set on. **/ - const std::vector< std::vector >& GetPrimaryTopoAntiLambda() const { return fPrimCandidatesTopo[2]; } + const std::vector>& GetPrimaryTopoAntiLambda() const { return fPrimCandidatesTopo[2]; } /** Returns a constant reference to the vector with primary candidates for \f$\gamma\rightarrow e^+e^-\f$ conversion ** with topological constraint set on. **/ - const std::vector< std::vector >& GetPrimaryTopoGamma() const { return fPrimCandidatesTopo[3]; } + const std::vector>& GetPrimaryTopoGamma() const { return fPrimCandidatesTopo[3]; } /** Returns a constant reference to the vector with primary candidates for \f$\pi^0\rightarrow \gamma\gamma\f$ ** with topological constraint set on. **/ - const std::vector< std::vector >& GetPrimaryTopoPi0() const { return fPrimCandidatesTopo[4]; } + const std::vector>& GetPrimaryTopoPi0() const { return fPrimCandidatesTopo[4]; } /** Returns a constant reference to the vector with secondary candidates for \f$\Xi^-\rightarrow \Lambda\pi^-\f$ ** with topological constraint set on. **/ - const std::vector< std::vector >& GetPrimaryTopoXi() const { return fPrimCandidatesTopo[5]; } + const std::vector>& GetPrimaryTopoXi() const { return fPrimCandidatesTopo[5]; } /** Returns a constant reference to the vector with secondary candidates for \f$\overline{\Xi}^-\rightarrow \overline{\Lambda}\pi^+\f$ ** with topological constraint set on. **/ - const std::vector< std::vector >& GetPrimaryTopoAntiXi() const { return fPrimCandidatesTopo[6]; } + const std::vector>& GetPrimaryTopoAntiXi() const { return fPrimCandidatesTopo[6]; } /** Returns a constant reference to the vector with secondary candidates for \f$\Omega^-\rightarrow \Lambda K^-\f$ ** with topological constraint set on. **/ - const std::vector< std::vector >& GetPrimaryTopoOmega() const { return fPrimCandidatesTopo[7]; } + const std::vector>& GetPrimaryTopoOmega() const { return fPrimCandidatesTopo[7]; } /** Returns a constant reference to the vector with secondary candidates for \f$\overline{\Omega}^-\rightarrow \overline{\Lambda} K^+\f$ ** with topological constraint set on. **/ - const std::vector< std::vector >& GetPrimaryTopoAntiOmega() const { return fPrimCandidatesTopo[8]; } + const std::vector>& GetPrimaryTopoAntiOmega() const { return fPrimCandidatesTopo[8]; } //Get primary particles with the topologigal and mass constraint /** Returns a pointer to array with sets of vectors with primary candidates for different decays with topological and mass constraints set on. */ - const std::vector< std::vector >* GetPrimaryTopoMassCandidates() const { return fPrimCandidatesTopoMass; } + const std::vector>* GetPrimaryTopoMassCandidates() const { return fPrimCandidatesTopoMass; } /** Returns a constant reference to the vector with primary candidates for \f$K_s^0\rightarrow\pi^+\pi^-\f$ ** with topological and mass constraints set on. **/ - const std::vector< std::vector >& GetPrimaryTopoMassK0() const { return fPrimCandidatesTopoMass[0]; } + const std::vector>& GetPrimaryTopoMassK0() const { return fPrimCandidatesTopoMass[0]; } /** Returns a constant reference to the vector with primary candidates for \f$\Lambda\rightarrow p\pi^-\f$ ** with topological and mass constraints set on. **/ - const std::vector< std::vector >& GetPrimaryTopoMassLambda() const { return fPrimCandidatesTopoMass[1]; } + const std::vector>& GetPrimaryTopoMassLambda() const { return fPrimCandidatesTopoMass[1]; } /** Returns a constant reference to the vector with primary candidates for \f$\overline{\Lambda}\rightarrow \overline{p}\pi^+\f$ ** with topological and mass constraints set on. **/ - const std::vector< std::vector >& GetPrimaryTopoMassAntiLambda() const { return fPrimCandidatesTopoMass[2]; } + const std::vector>& GetPrimaryTopoMassAntiLambda() const { return fPrimCandidatesTopoMass[2]; } /** Returns a constant reference to the vector with primary candidates for \f$\gamma\rightarrow e^+e^-\f$ conversion ** with topological and mass constraints set on. **/ - const std::vector< std::vector >& GetPrimaryTopoMassGamma() const { return fPrimCandidatesTopoMass[3]; } + const std::vector>& GetPrimaryTopoMassGamma() const { return fPrimCandidatesTopoMass[3]; } /** Returns a constant reference to the vector with primary candidates for \f$\pi^0\rightarrow \gamma\gamma\f$ ** with topological and mass constraints set on. **/ - const std::vector< std::vector >& GetPrimaryTopoMassPi0() const { return fPrimCandidatesTopoMass[4]; } + const std::vector>& GetPrimaryTopoMassPi0() const { return fPrimCandidatesTopoMass[4]; } /** Returns a constant reference to the vector with secondary candidates for \f$\Xi^-\rightarrow \Lambda\pi^-\f$ ** with topological and mass constraints set on. **/ - const std::vector< std::vector >& GetPrimaryTopoMassXi() const { return fPrimCandidatesTopoMass[5]; } + const std::vector>& GetPrimaryTopoMassXi() const { return fPrimCandidatesTopoMass[5]; } /** Returns a constant reference to the vector with secondary candidates for \f$\overline{\Xi}^-\rightarrow \overline{\Lambda}\pi^+\f$ ** with topological and mass constraints set on. **/ - const std::vector< std::vector >& GetPrimaryTopoMassAntiXi() const { return fPrimCandidatesTopoMass[6]; } + const std::vector>& GetPrimaryTopoMassAntiXi() const { return fPrimCandidatesTopoMass[6]; } /** Returns a constant reference to the vector with secondary candidates for \f$\Omega^-\rightarrow \Lambda K^-\f$ ** with topological and mass constraints set on. **/ - const std::vector< std::vector >& GetPrimaryTopoMassOmega() const { return fPrimCandidatesTopoMass[7]; } + const std::vector>& GetPrimaryTopoMassOmega() const { return fPrimCandidatesTopoMass[7]; } /** Returns a constant reference to the vector with secondary candidates for \f$\overline{\Omega}^-\rightarrow \overline{\Lambda} K^+\f$ ** with topological and mass constraints set on. **/ - const std::vector< std::vector >& GetPrimaryTopoMassAntiOmega() const { return fPrimCandidatesTopoMass[8]; } - + const std::vector>& GetPrimaryTopoMassAntiOmega() const { return fPrimCandidatesTopoMass[8]; } + void AddCandidate(const KFParticle& candidate, int iPV = -1); void SetNPV(int nPV); - + //Functionality to change cuts, all cuts have default values set in the constructor void SetMaxDistanceBetweenParticlesCut(float cut) { fDistanceCut = cut; } ///< Sets cut on the distance between secondary tracks at the DCA point. - void SetLCut(float cut) { fLCut = cut; } ///< Sets cut on the distance to the primary vertex from the decay vertex. - + void SetLCut(float cut) { fLCut = cut; } ///< Sets cut on the distance to the primary vertex from the decay vertex. + void SetChiPrimaryCut2D(float cut) { fCuts2D[0] = cut; } ///< Sets cut on \f$\chi^2_{prim}\f$ of each track for 2-daughter decays. - void SetChi2Cut2D(float cut) { fCuts2D[1] = cut; } ///< Sets cut on \f$\chi^2_{geo}\f$ for 2-daughter decays. - void SetLdLCut2D(float cut) { fCuts2D[2] = cut; } ///< Sets cut on \f$l/\Delta l\f$ for 2-daughter decays. - + void SetChi2Cut2D(float cut) { fCuts2D[1] = cut; } ///< Sets cut on \f$\chi^2_{geo}\f$ for 2-daughter decays. + void SetLdLCut2D(float cut) { fCuts2D[2] = cut; } ///< Sets cut on \f$l/\Delta l\f$ for 2-daughter decays. + /** \brief Sets cuts on selection of secondary and primary candidates: \f$\sigma_{M}\f$, \f$\chi^2_{topo}\f$, \f$l/\Delta l\f$. */ - void SetSecondaryCuts(const float sigmaMass = 3.f, const float chi2Topo = 5.f, const float ldl = 10.f) { + void SetSecondaryCuts(const float sigmaMass = 3.f, const float chi2Topo = 5.f, const float ldl = 10.f) + { fSecCuts[0] = sigmaMass; fSecCuts[1] = chi2Topo; fSecCuts[2] = ldl; } - - void SetLdLCutXiOmega(float cut) { fCutsTrackV0[0][0] = cut; } ///< Sets \f$l/\Delta l\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. + + void SetLdLCutXiOmega(float cut) { fCutsTrackV0[0][0] = cut; } ///< Sets \f$l/\Delta l\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. void SetChi2TopoCutXiOmega(float cut) { fCutsTrackV0[0][1] = cut; } ///< Sets \f$\chi^2_{topo}\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. - void SetChi2CutXiOmega(float cut) { fCutsTrackV0[0][2] = cut; } ///< Sets \f$\chi^2_{geo}\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. + void SetChi2CutXiOmega(float cut) { fCutsTrackV0[0][2] = cut; } ///< Sets \f$\chi^2_{geo}\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. void SetChi2TopoCutResonances(float cut) { fCutsTrackV0[2][1] = cut; } ///< Sets \f$\chi^2_{topo}\f$ cut for resonances. - void SetChi2CutResonances(float cut) { fCutsTrackV0[2][2] = cut; } ///< Sets \f$\chi^2_{geo}\f$ cut for resonances. + void SetChi2CutResonances(float cut) { fCutsTrackV0[2][2] = cut; } ///< Sets \f$\chi^2_{geo}\f$ cut for resonances. void SetPtCutLMVM(float cut) { fCutLVMPt = cut; } ///< Sets the cut on transverse momentum of each daughter track of low mass vector mesons. - void SetPCutLMVM(float cut) { fCutLVMP = cut; } ///< Sets the cut on momentum of each daughter track of low mass vector mesons in dimuon channel. + void SetPCutLMVM(float cut) { fCutLVMP = cut; } ///< Sets the cut on momentum of each daughter track of low mass vector mesons in dimuon channel. void SetPtCutJPsi(float cut) { fCutJPsiPt = cut; } ///< Sets the cut on transverse momentum of each daughter track of \f$J/\psi\f$. - - void SetPtCutCharm(float cut) { fCutCharmPt = cut; } ///< Sets the cut on transverse momentum of each daughter track of open charm particles. - void SetChiPrimaryCutCharm(float cut) { fCutCharmChiPrim = cut; } ///< Sets cut on \f$\chi^2_{prim}\f$ of each track for open charm particles. - void SetLdLCutCharmManybodyDecays(float cut) { fCutsTrackV0[1][0] = cut; } ///< Sets \f$l/\Delta l\f$ cut for open charm with >=3 daughters. + + void SetPtCutCharm(float cut) { fCutCharmPt = cut; } ///< Sets the cut on transverse momentum of each daughter track of open charm particles. + void SetChiPrimaryCutCharm(float cut) { fCutCharmChiPrim = cut; } ///< Sets cut on \f$\chi^2_{prim}\f$ of each track for open charm particles. + void SetLdLCutCharmManybodyDecays(float cut) { fCutsTrackV0[1][0] = cut; } ///< Sets \f$l/\Delta l\f$ cut for open charm with >=3 daughters. void SetChi2TopoCutCharmManybodyDecays(float cut) { fCutsTrackV0[1][1] = cut; } ///< Sets \f$\chi^2_{topo}\f$ cut for open charm with >=3 daughters. - void SetChi2CutCharmManybodyDecays(float cut) { fCutsTrackV0[1][2] = cut; } ///< Sets \f$\chi^2_{geo}\f$ cut for open charm with >=3 daughters. + void SetChi2CutCharmManybodyDecays(float cut) { fCutsTrackV0[1][2] = cut; } ///< Sets \f$\chi^2_{geo}\f$ cut for open charm with >=3 daughters. - void SetLdLCutCharm2D(float cut) { fCutsCharm[1] = cut; } ///< Sets \f$l/\Delta l\f$ cut for open charm with 2 daughters. + void SetLdLCutCharm2D(float cut) { fCutsCharm[1] = cut; } ///< Sets \f$l/\Delta l\f$ cut for open charm with 2 daughters. void SetChi2TopoCutCharm2D(float cut) { fCutsCharm[2] = cut; } ///< Sets \f$\chi^2_{topo}\f$ cut for open charm with 2 daughters. - void SetChi2CutCharm2D(float cut) { fCutsCharm[0] = cut; } ///< Sets \f$\chi^2_{geo}\f$ cut for open charm with 2 daughters. - + void SetChi2CutCharm2D(float cut) { fCutsCharm[0] = cut; } ///< Sets \f$\chi^2_{geo}\f$ cut for open charm with 2 daughters. + void CopyCuts(const KFParticleFinder* finder) { /** Copies all cuts from the external KFParticleFinder "finder" to the current object. @@ -319,111 +317,110 @@ class KFParticleFinder **/ fDistanceCut = finder->fDistanceCut; fLCut = finder->fLCut; - for(int iCut=0; iCut<3; iCut++) + for (int iCut = 0; iCut < 3; iCut++) fCuts2D[iCut] = finder->fCuts2D[iCut]; - for(int iCut=0; iCut<3; iCut++) + for (int iCut = 0; iCut < 3; iCut++) fSecCuts[iCut] = finder->fSecCuts[iCut]; - for(int iCut=0; iCut<3; iCut++) - for(int jCut=0; jCut<3; jCut++) + for (int iCut = 0; iCut < 3; iCut++) + for (int jCut = 0; jCut < 3; jCut++) fCutsTrackV0[iCut][jCut] = finder->fCutsTrackV0[iCut][jCut]; - for(int iCut=0; iCut<2; iCut++) - for(int jCut=0; jCut<3; jCut++) + for (int iCut = 0; iCut < 2; iCut++) + for (int jCut = 0; jCut < 3; jCut++) fCutsPartPart[iCut][jCut] = finder->fCutsPartPart[iCut][jCut]; fCutCharmPt = finder->fCutCharmPt; fCutCharmChiPrim = finder->fCutCharmChiPrim; - for(int iCut=0; iCut<3; iCut++) - fCutsCharm[iCut] = finder->fCutsCharm[iCut]; + for (int iCut = 0; iCut < 3; iCut++) + fCutsCharm[iCut] = finder->fCutsCharm[iCut]; fCutLVMPt = finder->fCutLVMPt; fCutLVMP = finder->fCutLVMP; fCutJPsiPt = finder->fCutJPsiPt; } - + //Functionality to check the cuts float GetMaxDistanceBetweenParticlesCut() const { return fDistanceCut; } ///< Returns cut on the distance between secondary tracks at the DCA point. - float GetLCut() const { return fLCut; } ///< Returns cut on the distance to the primary vertex from the decay vertex. - + float GetLCut() const { return fLCut; } ///< Returns cut on the distance to the primary vertex from the decay vertex. + float GetChiPrimaryCut2D() const { return fCuts2D[0]; } ///< Returns cut on \f$\chi^2_{prim}\f$ of each track for 2-daughter decays. - float GetChi2Cut2D() const { return fCuts2D[1]; } ///< Returns cut on \f$\chi^2_{geo}\f$ for 2-daughter decays. - float GetLdLCut2D() const { return fCuts2D[2]; } ///< Returns cut on \f$l/\Delta l\f$ for 2-daughter decays. - + float GetChi2Cut2D() const { return fCuts2D[1]; } ///< Returns cut on \f$\chi^2_{geo}\f$ for 2-daughter decays. + float GetLdLCut2D() const { return fCuts2D[2]; } ///< Returns cut on \f$l/\Delta l\f$ for 2-daughter decays. + float GetSecondarySigmaMassCut() const { return fSecCuts[0]; } ///< Returns \f$\sigma_{M}\f$ cut for selection of primary and secondary candidates. - float GetSecondaryChi2TopoCut() const { return fSecCuts[1]; } ///< Returns \f$\chi^2_{topo}\f$ cut for selection of primary and secondary candidates. - float GetSecondaryLdLCut() const { return fSecCuts[2]; } ///< Returns \f$l/\Delta l\f$ cut for selection of primary and secondary candidates. - - float GetLdLCutXiOmega() const { return fCutsTrackV0[0][0]; } ///< Returns \f$l/\Delta l\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. + float GetSecondaryChi2TopoCut() const { return fSecCuts[1]; } ///< Returns \f$\chi^2_{topo}\f$ cut for selection of primary and secondary candidates. + float GetSecondaryLdLCut() const { return fSecCuts[2]; } ///< Returns \f$l/\Delta l\f$ cut for selection of primary and secondary candidates. + + float GetLdLCutXiOmega() const { return fCutsTrackV0[0][0]; } ///< Returns \f$l/\Delta l\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. float GetChi2TopoCutXiOmega() const { return fCutsTrackV0[0][1]; } ///< Returns \f$\chi^2_{topo}\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. - float GetChi2CutXiOmega() const { return fCutsTrackV0[0][2]; } ///< Returns \f$\chi^2_{geo}\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. + float GetChi2CutXiOmega() const { return fCutsTrackV0[0][2]; } ///< Returns \f$\chi^2_{geo}\f$ cut for \f$\Xi\f$ and \f$\Omega\f$. float GetChi2TopoCutResonances() const { return fCutsTrackV0[2][1]; } ///< Returns \f$\chi^2_{topo}\f$ cut for resonances. - float GetChi2CutResonances() const { return fCutsTrackV0[2][2]; } ///< Returns \f$\chi^2_{geo}\f$ cut for resonances. + float GetChi2CutResonances() const { return fCutsTrackV0[2][2]; } ///< Returns \f$\chi^2_{geo}\f$ cut for resonances. float GetPtCutLMVM() const { return fCutLVMPt; } ///< Returns cut on transverse momentum of each daughter track of low mass vector mesons. - float GetPCutLMVM() const { return fCutLVMP; } ///< Returns cut on momentum of each daughter track of low mass vector mesons in dimuon channel. + float GetPCutLMVM() const { return fCutLVMP; } ///< Returns cut on momentum of each daughter track of low mass vector mesons in dimuon channel. float GetPtCutJPsi() const { return fCutJPsiPt; } ///< Returns cut on transverse momentum of each daughter track of \f$J/\psi\f$. - - float GetPtCutCharm() const { return fCutCharmPt; } ///< Returns the cut on transverse momentum of each daughter track of open charm particles. - float GetChiPrimaryCutCharm() const { return fCutCharmChiPrim; } ///< Returns cut on \f$\chi^2_{prim}\f$ of each track for open charm particles. - float GetLdLCutCharmManybodyDecays() const { return fCutsTrackV0[1][0]; } ///< Returns \f$l/\Delta l\f$ cut for open charm with >=3 daughters. + + float GetPtCutCharm() const { return fCutCharmPt; } ///< Returns the cut on transverse momentum of each daughter track of open charm particles. + float GetChiPrimaryCutCharm() const { return fCutCharmChiPrim; } ///< Returns cut on \f$\chi^2_{prim}\f$ of each track for open charm particles. + float GetLdLCutCharmManybodyDecays() const { return fCutsTrackV0[1][0]; } ///< Returns \f$l/\Delta l\f$ cut for open charm with >=3 daughters. float GetChi2TopoCutCharmManybodyDecays() const { return fCutsTrackV0[1][1]; } ///< Returns \f$\chi^2_{topo}\f$ cut for open charm with >=3 daughters. - float GetChi2CutCharmManybodyDecays() const { return fCutsTrackV0[1][2]; } ///< Returns \f$\chi^2_{geo}\f$ cut for open charm with >=3 daughters. + float GetChi2CutCharmManybodyDecays() const { return fCutsTrackV0[1][2]; } ///< Returns \f$\chi^2_{geo}\f$ cut for open charm with >=3 daughters. - float GetLdLCutCharm2D() const { return fCutsCharm[1]; } ///< Returns \f$l/\Delta l\f$ cut for open charm with 2 daughters. + float GetLdLCutCharm2D() const { return fCutsCharm[1]; } ///< Returns \f$l/\Delta l\f$ cut for open charm with 2 daughters. float GetChi2TopoCutCharm2D() const { return fCutsCharm[2]; } ///< Returns \f$\chi^2_{topo}\f$ cut for open charm with 2 daughters. - float GetChi2CutCharm2D() const { return fCutsCharm[0]; } ///< Returns \f$\chi^2_{geo}\f$ cut for open charm with 2 daughters. - + float GetChi2CutCharm2D() const { return fCutsCharm[0]; } ///< Returns \f$\chi^2_{geo}\f$ cut for open charm with 2 daughters. + /** Add decay to the reconstruction list. If at least one is added - only those channels are considered which are in the list. Otherwise ** all decays are reconstructed. ** \param[in] pdg - PDG code of the decay which should be reconstructed **/ void AddDecayToReconstructionList(int pdg) { fDecayReconstructionList[pdg] = true; } - const std::map GetReconstructionList() const { return fDecayReconstructionList; } ///< Returns list of decays to be reconstructed. - void SetReconstructionList(const std::map& decays) { fDecayReconstructionList = decays; } ///< Set enitre reconstruction list + const std::map GetReconstructionList() const { return fDecayReconstructionList; } ///< Returns list of decays to be reconstructed. + void SetReconstructionList(const std::map& decays) { fDecayReconstructionList = decays; } ///< Set enitre reconstruction list private: + short int fNPV; ///< Number of primary vertex candidates in the event. + short int fNThreads; ///< Number of threads to be run in parallel. Currently is not used. - short int fNPV; ///< Number of primary vertex candidates in the event. - short int fNThreads; ///< Number of threads to be run in parallel. Currently is not used. - float fDistanceCut; ///< Cut on the distance between secondary tracks at the DCA point, is soft and used to speed up the algorithm only. - float fLCut; ///< Cut on the distance to the primary vertex from the decay vertex. Is applied to \f$K^0_s\f$, \f$\Lambda\f$, \f$\Xi\f$, \f$\Omega\f$, hypernuclei and dibaryons. + float fLCut; ///< Cut on the distance to the primary vertex from the decay vertex. Is applied to \f$K^0_s\f$, \f$\Lambda\f$, \f$\Xi\f$, \f$\Omega\f$, hypernuclei and dibaryons. - float fCuts2D[3]; ///< Cuts on 2-daughter decays: \f$\chi^2_{prim}\f$, \f$\chi^2_{geo}\f$, \f$l/\Delta l\f$ + float fCuts2D[3]; ///< Cuts on 2-daughter decays: \f$\chi^2_{prim}\f$, \f$\chi^2_{geo}\f$, \f$l/\Delta l\f$ float fSecCuts[3]; ///< Cuts to select secondary and primary particle candidates: \f$\sigma_{M}\f$, \f$\chi^2_{topo}\f$, \f$l/\Delta l\f$ /** \brief Cuts on the combination of track and short-lived particle candidate: \f$l/\Delta l\f$, \f$\chi^2_{topo}\f$, \f$\chi^2_{geo}\f$. ** Three sets of cuts are defined: 1) for \f$\Xi\f$ and \f$\Omega\f$, 2) for hypernuclei and open charm, 3) for resonances. **/ - float fCutsTrackV0[3][3]; + float fCutsTrackV0[3][3]; /** \brief Cuts on the combination of two short-lived particle candidates: \f$l/\Delta l\f$, \f$\chi^2_{topo}\f$, \f$\chi^2_{geo}\f$. ** Two sets are defined: 1) for particles that fly away from the primary vertex and 2) for resonances. **/ float fCutsPartPart[2][3]; - + //cuts on open charm particles with 2 daughters - float fCutCharmPt; ///< Cut on transverse momentum of the track for open charm reconstruction. + float fCutCharmPt; ///< Cut on transverse momentum of the track for open charm reconstruction. float fCutCharmChiPrim; ///< Cut on the \f$\chi^2_{prim}\f$ deviation of the track from the primary vertex for open charm reconstruction. - float fCutsCharm[3]; ///< Cuts on reconstructed 2-daughter charm candidates: \f$\chi^2_{geo}\f$, \f$l/\Delta l\f$, \f$\chi^2_{topo}\f$. - + float fCutsCharm[3]; ///< Cuts on reconstructed 2-daughter charm candidates: \f$\chi^2_{geo}\f$, \f$l/\Delta l\f$, \f$\chi^2_{topo}\f$. + //cuts on LVM float fCutLVMPt; ///< Cut on transverse momentum of daughter tracks for low mass vector mesons. float fCutLVMP; ///< Cut on momentum of low mass vector mesons in dimuon channel. - + //cuts on J/Psi float fCutJPsiPt; ///< Cut on transverse momentum of daughter tracks for \f$J/\psi\f$. - + //vectors with temporary particles for charm reconstruction - std::vector fD0; ///K-pi+ candidates. - std::vector fD0bar; ///K+pi- candidates. - std::vector fD04; ///K-pi+pi+pi- candidates. - std::vector fD04bar; ///K+pi+pi-pi- candidates. - std::vector fD0KK; ///K+K- candidates. - std::vector fD0pipi; ///pi+pi- candidates. - std::vector fDPlus; ///K-pi+pi+ candidates. - std::vector fDMinus; ///K+pi-pi- candidates. - std::vector fDPlus3Pi; ///pi+pi+pi- candidates. - std::vector fDMinus3Pi; ///pi+pi-pi- candidates. - std::vector fDsPlusK2Pi; ///K+pi+pi- candidates. - std::vector fDsMinusK2Pi;///K-pi+pi- candidates. - std::vector fLcPlusP2Pi; ///p pi+pi- candidates. - std::vector fLcMinusP2Pi;///p-pi+pi- candidates. - + std::vector fD0; ///K-pi+ candidates. + std::vector fD0bar; ///K+pi- candidates. + std::vector fD04; ///K-pi+pi+pi- candidates. + std::vector fD04bar; ///K+pi+pi-pi- candidates. + std::vector fD0KK; ///K+K- candidates. + std::vector fD0pipi; ///pi+pi- candidates. + std::vector fDPlus; ///K-pi+pi+ candidates. + std::vector fDMinus; ///K+pi-pi- candidates. + std::vector fDPlus3Pi; ///pi+pi+pi- candidates. + std::vector fDMinus3Pi; ///pi+pi-pi- candidates. + std::vector fDsPlusK2Pi; ///K+pi+pi- candidates. + std::vector fDsMinusK2Pi; ///K-pi+pi- candidates. + std::vector fLcPlusP2Pi; ///p pi+pi- candidates. + std::vector fLcMinusP2Pi; ///p-pi+pi- candidates. + //vectors with temporary particles for H0 std::vector fLPi; ///< Temporary Lambda pi+ combinations std::vector fLPiPIndex; ///< Index of the proton in Labmda for Lambda pi+ combinations @@ -435,7 +432,7 @@ class KFParticleFinder std::vector fHe5L; ///< Vector with temporary He4_Lambda->He4 p pi- candidates std::vector fLLn; ///< Vector with temporary H3_Lambda pi- candidates std::vector fH5LL; ///< Vector with temporary H5_LL->He5_Lambda pi- candidates - + //vectors of candidates with the mass constraint static const int fNSecCandidatesSets = 5; ///< Number of sets of secondary particle candidates. /** \brief Array of vectors with secondary candidates: 0) \f$K_s^0\f$, 1) \f$\Lambda\f$, 2) \f$\overline{\Lambda}\f$, 3) \f$\gamma\f$, 4) \f$\pi^0\f$. */ @@ -444,27 +441,26 @@ class KFParticleFinder /** \brief Array of vectors with primary candidates for each primary vertex: ** 0) \f$K_s^0\f$, 1) \f$\Lambda\f$, 2) \f$\overline{\Lambda}\f$, 3) \f$\gamma\f$, 4) \f$\pi^0\f$, ** 5) \f$\Xi^-\f$, 6) \f$\overline{\Xi}^+\f$, 7) \f$\Omega^-\f$, 8) \f$\overline{\Omega}^+\f$, 9) \f$\Xi^{0*}\f$, 10) \f$\overline{\Xi}^{0*}\f$. */ - std::vector< std::vector > fPrimCandidates[fNPrimCandidatesSets]; // - static const int fNPrimCandidatesTopoSets = 9; ///< Number of sets of primary particle candidates with topological constraint. + std::vector> fPrimCandidates[fNPrimCandidatesSets]; // + static const int fNPrimCandidatesTopoSets = 9; ///< Number of sets of primary particle candidates with topological constraint. /** \brief Array of vectors with primary candidates for each primary vertex with a topological constraint set: ** 0) \f$K_s^0\f$, 1) \f$\Lambda\f$, 2) \f$\overline{\Lambda}\f$, 3) \f$\gamma\f$, 4) \f$\pi^0\f$, ** 5) \f$\Xi^-\f$, 6) \f$\overline{\Xi}^+\f$, 7) \f$\Omega^-\f$, 8) \f$\overline{\Omega}^+\f$. */ - std::vector< std::vector > fPrimCandidatesTopo[fNPrimCandidatesTopoSets]; + std::vector> fPrimCandidatesTopo[fNPrimCandidatesTopoSets]; /** \brief Array of vectors with primary candidates for each primary vertex with a topological and mass constraints set: ** 0) \f$K_s^0\f$, 1) \f$\Lambda\f$, 2) \f$\overline{\Lambda}\f$, 3) \f$\gamma\f$, 4) \f$\pi^0\f$, ** 5) \f$\Xi^-\f$, 6) \f$\overline{\Xi}^+\f$, 7) \f$\Omega^-\f$, 8) \f$\overline{\Omega}^+\f$. */ - std::vector< std::vector > fPrimCandidatesTopoMass[fNPrimCandidatesTopoSets]; - + std::vector> fPrimCandidatesTopoMass[fNPrimCandidatesTopoSets]; + KFPEmcCluster* fEmcClusters; ///< Pointer to the input gamma-clusters from the electromagnetic calorimeter. bool fMixedEventAnalysis; ///< Flag defines if the mixed event analysis is run. In mixed event mode limited number of decays is reconstructed. - + /** \brief Map defines if the reconstruction of the decay with a certain PDG hypothesis should be run. If the map is empty - all decays are reconstructed. If at least one decay is added - only those decays will be reconstructed which are specified in the list. **/ - std::map fDecayReconstructionList; - - KFParticleFinder(const KFParticleFinder&); ///< Copying is disabled for this class. + std::map fDecayReconstructionList; + + KFParticleFinder(const KFParticleFinder&); ///< Copying is disabled for this class. KFParticleFinder& operator=(const KFParticleFinder&); ///< Copying is disabled for this class. }; #endif /* !KFParticleFinder_h */ - diff --git a/KFParticle/KFParticlePVReconstructor.cxx b/KFParticle/KFParticlePVReconstructor.cxx index 787645b..80f5186 100644 --- a/KFParticle/KFParticlePVReconstructor.cxx +++ b/KFParticle/KFParticlePVReconstructor.cxx @@ -25,7 +25,7 @@ using std::vector; -void KFParticlePVReconstructor::Init(KFPTrackVector *tracks, int nParticles) +void KFParticlePVReconstructor::Init(KFPTrackVector* tracks, int nParticles) { /** The function initialises an input for the search of primary vertices:\n ** 1) it receives as an input an array with tracks;\n @@ -45,77 +45,80 @@ void KFParticlePVReconstructor::Init(KFPTrackVector *tracks, int nParticles) ** \param[in] tracks - a pointer to the KFPTrackVector with input tracks ** \param[in] nParticles - number of the input tracks **/ - + fNParticles = nParticles; fParticles.resize(fNParticles); fWeight.resize(fNParticles); - - float C[3] = {0,0,0}; - int nC[3] = {0,0,0}; - + + float C[3] = {0, 0, 0}; + int nC[3] = {0, 0, 0}; + KFPTrack track; - for ( int iTr = 0; iTr < fNParticles; iTr++ ) { - tracks->GetTrack(track,iTr); - fParticles[iTr] = KFParticle( track, 211 ); + for (int iTr = 0; iTr < fNParticles; iTr++) { + tracks->GetTrack(track, iTr); + fParticles[iTr] = KFParticle(track, 211); fParticles[iTr].AddDaughterId(track.Id()); - float zeroPoint[3]{0,0,0}; + float zeroPoint[3]{0, 0, 0}; fParticles[iTr].TransportToPoint(zeroPoint); - - for(int iC=0; iC<3; iC++) - { - if(!(fParticles[0].Covariance(iC,iC)==fParticles[0].Covariance(iC,iC))) continue; - if(fParticles[0].Covariance(iC,iC) < 10.f && fParticles[0].Covariance(iC,iC) > 0.f ) - { - C[iC] += fParticles[0].Covariance(iC,iC); + + for (int iC = 0; iC < 3; iC++) { + if (!(fParticles[0].Covariance(iC, iC) == fParticles[0].Covariance(iC, iC))) + continue; + if (fParticles[0].Covariance(iC, iC) < 10.f && fParticles[0].Covariance(iC, iC) > 0.f) { + C[iC] += fParticles[0].Covariance(iC, iC); nC[iC]++; } } } - + fPrimVertices.clear(); fClusters.clear(); - + float pvEstimation[3] = {0.}; float pvEstimationTr[3] = {0.}; float parTmp[8] = {0.}; float covTmp[36] = {0.}; - - for(int iC=0; iC<3; iC++) - { - if(nC[iC] >0) + + for (int iC = 0; iC < 3; iC++) { + if (nC[iC] > 0) C[iC] /= nC[iC]; else C[iC] = 1.e-2; } - - for(int iIter=0; iIter<3; iIter++) - { - C[0]*=100.f; C[1]*=100.f; C[2]*=100.f; - for ( int iTr = 0; iTr < fNParticles; iTr++ ) { + + for (int iIter = 0; iIter < 3; iIter++) { + C[0] *= 100.f; + C[1] *= 100.f; + C[2] *= 100.f; + for (int iTr = 0; iTr < fNParticles; iTr++) { float ds = 0.f; float dsdr[6] = {0.f}; - if(iIter>0) + if (iIter > 0) ds = fParticles[iTr].GetDStoPoint(pvEstimationTr, dsdr); - fParticles[iTr].Transport( ds, dsdr, parTmp, covTmp); - - float r2 = parTmp[0]*parTmp[0] + parTmp[1]*parTmp[1]; - if(!(r2==r2)) continue; - if(r2 > 25 ) continue; - - const float V[3] = {covTmp[0], covTmp[2], covTmp[5]}; - - for(int iComp=0; iComp<3; iComp++) - { - float K = C[iComp]/(C[iComp]+V[iComp]); - if (fabs(V[iComp]) < 1.e-8) continue; - if(C[iComp] > 16*V[iComp]) - K = 1.f - V[iComp]/C[iComp]; - const float dzeta = parTmp[iComp]-pvEstimation[iComp]; - if(K!=K) continue; - if(K<0. || K>0.999) continue; - pvEstimation[iComp] += K*dzeta; - C[iComp] -= K*C[iComp]; + fParticles[iTr].Transport(ds, dsdr, parTmp, covTmp); + + float r2 = parTmp[0] * parTmp[0] + parTmp[1] * parTmp[1]; + if (!(r2 == r2)) + continue; + if (r2 > 25) + continue; + + const float V[3] = {covTmp[0], covTmp[2], covTmp[5]}; + + for (int iComp = 0; iComp < 3; iComp++) { + float K = C[iComp] / (C[iComp] + V[iComp]); + if (fabs(V[iComp]) < 1.e-8) + continue; + if (C[iComp] > 16 * V[iComp]) + K = 1.f - V[iComp] / C[iComp]; + const float dzeta = parTmp[iComp] - pvEstimation[iComp]; + if (K != K) + continue; + if (K < 0. || K > 0.999) + continue; + pvEstimation[iComp] += K * dzeta; + C[iComp] -= K * C[iComp]; } } pvEstimationTr[0] = pvEstimation[0]; @@ -123,23 +126,22 @@ void KFParticlePVReconstructor::Init(KFPTrackVector *tracks, int nParticles) pvEstimationTr[2] = pvEstimation[2]; } - for(int iP=0; iP 0.f) - fWeight[iP] = 1.f/sqrt(fWeight[iP]); + fWeight[iP] = fParticles[iP].CovarianceMatrix()[0] + fParticles[iP].CovarianceMatrix()[2] + fParticles[iP].CovarianceMatrix()[5]; + + if (fWeight[iP] > 0.f) + fWeight[iP] = 1.f / sqrt(fWeight[iP]); else fWeight[iP] = -100; - - if( (fParticles[iP].X()*fParticles[iP].X() + fParticles[iP].Y()*fParticles[iP].Y()) > 100.f ) fWeight[iP] = -100.f; + + if ((fParticles[iP].X() * fParticles[iP].X() + fParticles[iP].Y() * fParticles[iP].Y()) > 100.f) + fWeight[iP] = -100.f; } } // void KFParticlePVReconstructor::Init -void KFParticlePVReconstructor::FindPrimaryClusters( int cutNDF ) +void KFParticlePVReconstructor::FindPrimaryClusters(int cutNDF) { /** The functions searches for a set of clusters of particles - candidates for the primary ** vertex:\n @@ -160,170 +162,159 @@ void KFParticlePVReconstructor::FindPrimaryClusters( int cutNDF ) ** the PV-candidate is rejected **/ - if( IsBeamLine() ) + if (IsBeamLine()) cutNDF += 2; - + vector notUsedTracks(fNParticles); - vector *notUsedTracksPtr = ¬UsedTracks; + vector* notUsedTracksPtr = ¬UsedTracks; int nNotUsedTracks = fNParticles; vector notUsedTracksNew(fNParticles); - vector *notUsedTracksNewPtr = ¬UsedTracksNew; + vector* notUsedTracksNewPtr = ¬UsedTracksNew; int nNotUsedTracksNew = 0; - for(int iTr=0; iTr0) - { + + while (nNotUsedTracks > 0) { short int bestTrack = 0; float bestWeight = -1.f; - for(unsigned short int iTr = 0; iTr < nNotUsedTracks; iTr++) - { - unsigned short int &curTrack = (*notUsedTracksPtr)[iTr]; - - if (fWeight[curTrack] > bestWeight) - { + for (unsigned short int iTr = 0; iTr < nNotUsedTracks; iTr++) { + unsigned short int& curTrack = (*notUsedTracksPtr)[iTr]; + + if (fWeight[curTrack] > bestWeight) { bestWeight = fWeight[curTrack]; bestTrack = curTrack; } } - if(bestWeight < 0.f) break; - + if (bestWeight < 0.f) + break; + KFParticleCluster cluster; cluster.fTracks.reserve(nNotUsedTracks); - const float *rBest = fParticles[bestTrack].Parameters(); - const float *covBest = fParticles[bestTrack].CovarianceMatrix(); + const float* rBest = fParticles[bestTrack].Parameters(); + const float* covBest = fParticles[bestTrack].CovarianceMatrix(); float rVertex[3] = {0.f}; float covVertex[6] = {0.f}; float weightVertex = 0.f; - for(unsigned short int iTr = 0; iTr < nNotUsedTracks; iTr++) - { - unsigned short int &curTrack = (*notUsedTracksPtr)[iTr]; + for (unsigned short int iTr = 0; iTr < nNotUsedTracks; iTr++) { + unsigned short int& curTrack = (*notUsedTracksPtr)[iTr]; float chi2deviation = fParticles[curTrack].GetDeviationFromVertex(rBest, covBest); - if( ( chi2deviation < fChi2CutPreparation && chi2deviation >= 0 && fWeight[curTrack] > -1.f) || curTrack == bestTrack) - { - for(int iP=0; iP<3; iP++) + if ((chi2deviation < fChi2CutPreparation && chi2deviation >= 0 && fWeight[curTrack] > -1.f) || curTrack == bestTrack) { + for (int iP = 0; iP < 3; iP++) rVertex[iP] += fWeight[curTrack] * fParticles[curTrack].Parameters()[iP]; - + float weight2 = fWeight[curTrack] * fWeight[curTrack]; - for(int iC=0; iC<6; iC++) - covVertex[iC] += weight2 *fParticles[curTrack].CovarianceMatrix()[iC]; + for (int iC = 0; iC < 6; iC++) + covVertex[iC] += weight2 * fParticles[curTrack].CovarianceMatrix()[iC]; weightVertex += fWeight[curTrack]; cluster.fTracks.push_back(curTrack); - } - else - { + } else { (*notUsedTracksNewPtr)[nNotUsedTracksNew] = curTrack; nNotUsedTracksNew++; } } - - vector *notUsedTracksPtrSave = notUsedTracksPtr; + + vector* notUsedTracksPtrSave = notUsedTracksPtr; notUsedTracksPtr = notUsedTracksNewPtr; notUsedTracksNewPtr = notUsedTracksPtrSave; - + nNotUsedTracks = nNotUsedTracksNew; nNotUsedTracksNew = 0; - if(cluster.fTracks.size() < 2) continue; - if((cluster.fTracks.size() < 3) && (fNParticles>3)) continue; - - for(int iP=0; iP<3; iP++) - cluster.fP[iP] = rVertex[iP]/weightVertex; + if (cluster.fTracks.size() < 2) + continue; + if ((cluster.fTracks.size() < 3) && (fNParticles > 3)) + continue; - for(int iC=0; iC<6; iC++) - cluster.fC[iC] = covVertex[iC]/(weightVertex*weightVertex); + for (int iP = 0; iP < 3; iP++) + cluster.fP[iP] = rVertex[iP] / weightVertex; + for (int iC = 0; iC < 6; iC++) + cluster.fC[iC] = covVertex[iC] / (weightVertex * weightVertex); int nPrimCand = cluster.fTracks.size(); // 1 is reserved for a beam line int nTracks = cluster.fTracks.size(); - - const KFParticle **pParticles = new const KFParticle*[nPrimCand+1]; // tmp array - for ( int iP = 0; iP < nPrimCand; iP++ ) - pParticles[iP] = &fParticles[ cluster.fTracks[iP] ]; + const KFParticle** pParticles = new const KFParticle*[nPrimCand + 1]; // tmp array - if( IsBeamLine() ) - { + for (int iP = 0; iP < nPrimCand; iP++) + pParticles[iP] = &fParticles[cluster.fTracks[iP]]; + + if (IsBeamLine()) { pParticles[nPrimCand] = &fBeamLine; nPrimCand++; } - - - // find prim vertex + + // find prim vertex KFVertex primVtx; - if(fNParticles>1) - { + if (fNParticles > 1) { // construct PV candidate from a cluster - bool *vFlags = new bool[nPrimCand]; // flags returned by the vertex finder - for(int iFl=0; iFl clearClusterInd; clearClusterInd.reserve(cluster.fTracks.size()); - for ( int iP = 0; iP < nTracks; iP++ ){ - if(cluster.fTracks[iP] == bestTrack) { + for (int iP = 0; iP < nTracks; iP++) { + if (cluster.fTracks[iP] == bestTrack) { clearClusterInd.push_back(cluster.fTracks[iP]); continue; } - if(vFlags[iP]) + if (vFlags[iP]) clearClusterInd.push_back(cluster.fTracks[iP]); - else - { + else { (*notUsedTracksPtr)[nNotUsedTracks] = cluster.fTracks[iP]; nNotUsedTracks++; } } - - for(unsigned short int iTr = 0; iTr < nNotUsedTracks; iTr++) - { - unsigned short int &curTrack = (*notUsedTracksPtr)[iTr]; - if( fParticles[curTrack].GetDeviationFromVertex(primVtx)= cutNDF && ((cluster.fTracks.size()>0.1f*fNParticles && fNParticles > 30) || fNParticles<=30 ) ) //at least 2 particles + if (primVtx.GetNDF() >= cutNDF && ((cluster.fTracks.size() > 0.1f * fNParticles && fNParticles > 30) || fNParticles <= 30)) //at least 2 particles #else - if( primVtx.GetNDF() >= cutNDF) + if (primVtx.GetNDF() >= cutNDF) #endif { fPrimVertices.push_back(primVtx); fClusters.push_back(cluster); } - - if(vFlags) delete [] vFlags; + + if (vFlags) + delete[] vFlags; } - if(pParticles) delete [] pParticles; + if (pParticles) + delete[] pParticles; } } @@ -333,35 +324,34 @@ void KFParticlePVReconstructor::ReconstructPrimVertex() ** For this it calls KFParticlePVReconstructor::FindPrimaryClusters(), ** if no vertex is found empty primary vertex is used. **/ - + FindPrimaryClusters(); - if ( fPrimVertices.size() == 0 ) - { - float X=0,Y=0,Z=0; + if (fPrimVertices.size() == 0) { + float X = 0, Y = 0, Z = 0; KFPVertex primVtx_tmp; primVtx_tmp.SetXYZ(X, Y, Z); - primVtx_tmp.SetCovarianceMatrix( 0, 0, 0, 0, 0, 0 ); + primVtx_tmp.SetCovarianceMatrix(0, 0, 0, 0, 0, 0); primVtx_tmp.SetNContributors(0); primVtx_tmp.SetChi2(-100); fPrimVertices.push_back(primVtx_tmp); - + KFParticleCluster cluster; fClusters.push_back(cluster); } } -void KFParticlePVReconstructor::AddPV(const KFVertex &pv, const vector &tracks) -{ +void KFParticlePVReconstructor::AddPV(const KFVertex& pv, const vector& tracks) +{ fPrimVertices.push_back(pv); KFParticleCluster cluster; cluster.fTracks = tracks; fClusters.push_back(cluster); } -void KFParticlePVReconstructor::AddPV(const KFVertex &pv) +void KFParticlePVReconstructor::AddPV(const KFVertex& pv) { fPrimVertices.push_back(pv); KFParticleCluster cluster; diff --git a/KFParticle/KFParticlePVReconstructor.h b/KFParticle/KFParticlePVReconstructor.h index 045b3cb..ab01673 100644 --- a/KFParticle/KFParticlePVReconstructor.h +++ b/KFParticle/KFParticlePVReconstructor.h @@ -19,7 +19,6 @@ * along with this program. If not, see . */ - #ifndef KFParticlePVReconstructor_H #define KFParticlePVReconstructor_H @@ -42,54 +41,71 @@ class KFPTrackVector; ** primary vertices. **/ -class KFParticlePVReconstructor{ +class KFParticlePVReconstructor +{ public: - KFParticlePVReconstructor():fParticles(0), fNParticles(0), fWeight(0.f), fBeamLine(), fIsBeamLine(0), fClusters(0), fPrimVertices(0), fChi2CutPreparation(100), fChi2Cut(16) {}; + KFParticlePVReconstructor() : fParticles(0), fNParticles(0), fWeight(0.f), fBeamLine(), fIsBeamLine(0), fClusters(0), fPrimVertices(0), fChi2CutPreparation(100), fChi2Cut(16){}; virtual ~KFParticlePVReconstructor(){}; - - void Init(KFPTrackVector *tracks, int nParticles); - + + void Init(KFPTrackVector* tracks, int nParticles); + void ReconstructPrimVertex(); - int NPrimaryVertices() const { return fPrimVertices.size(); } ///< Returns number of the found candidates for the primary vertex. - KFParticle &GetPrimVertex(int iPV=0) { return fPrimVertices[iPV]; } ///< Returns primary vertex candidate in KFParticle with index "iPV". - KFVertex &GetPrimKFVertex(int iPV=0) { return fPrimVertices[iPV]; } ///< Returns primary vertex candidate in KFVertex with index "iPV". - std::vector& GetPVTrackIndexArray(int iPV=0) { return fClusters[iPV].fTracks; } ///< Returns vector with track indices from a cluster with index "iPV". - KFParticle &GetParticle(int i){ assert( i < fNParticles ); return fParticles[i]; } ///< Returns input particle with index "i". - - void SetBeamLine(KFParticle& p) { fBeamLine = p; fIsBeamLine = 1; } ///< Sets the beam line position and direction, sets corresponding flag to "true". + int NPrimaryVertices() const { return fPrimVertices.size(); } ///< Returns number of the found candidates for the primary vertex. + KFParticle& GetPrimVertex(int iPV = 0) { return fPrimVertices[iPV]; } ///< Returns primary vertex candidate in KFParticle with index "iPV". + KFVertex& GetPrimKFVertex(int iPV = 0) { return fPrimVertices[iPV]; } ///< Returns primary vertex candidate in KFVertex with index "iPV". + std::vector& GetPVTrackIndexArray(int iPV = 0) { return fClusters[iPV].fTracks; } ///< Returns vector with track indices from a cluster with index "iPV". + KFParticle& GetParticle(int i) + { + assert(i < fNParticles); + return fParticles[i]; + } ///< Returns input particle with index "i". + + void SetBeamLine(KFParticle& p) + { + fBeamLine = p; + fIsBeamLine = 1; + } ///< Sets the beam line position and direction, sets corresponding flag to "true". bool IsBeamLine() const { return fIsBeamLine; } ///< Check if the beam line is set. - + /** Adds externally found primary vertex to the list together with the cluster of ** tracks from this vertex. ** \param[in] pv - external primary vertex ** \param[in] tracks - vector with indices of tracks associated with the provided primary vertex. **/ - void AddPV(const KFVertex &pv, const std::vector &tracks); + void AddPV(const KFVertex& pv, const std::vector& tracks); /** Adds externally found primary vertex to the list. ** \param[in] pv - external primary vertex **/ - void AddPV(const KFVertex &pv); - void CleanPV() { fClusters.clear(); fPrimVertices.clear(); } ///< Clean vectors with primary vertex candidates and corresponding clusters. + void AddPV(const KFVertex& pv); + void CleanPV() + { + fClusters.clear(); + fPrimVertices.clear(); + } ///< Clean vectors with primary vertex candidates and corresponding clusters. /** \brief Sets cut fChi2Cut on chi2-deviation of primary tracks from the vertex candidate to "chi2" ** and a soft preparation cut fChi2CutPreparation to "10*chi2". */ - void SetChi2PrimaryCut(float chi2) { fChi2Cut = chi2; fChi2CutPreparation = chi2*5; } - + void SetChi2PrimaryCut(float chi2) + { + fChi2Cut = chi2; + fChi2CutPreparation = chi2 * 5; + } + private: - KFParticlePVReconstructor &operator=(KFParticlePVReconstructor &); ///< Is not defined. Deny copying of the objects of this class. - KFParticlePVReconstructor(KFParticlePVReconstructor &); ///< Is not defined. Deny copying of the objects of this class. + KFParticlePVReconstructor& operator=(KFParticlePVReconstructor&); ///< Is not defined. Deny copying of the objects of this class. + KFParticlePVReconstructor(KFParticlePVReconstructor&); ///< Is not defined. Deny copying of the objects of this class. - void FindPrimaryClusters( int cutNDF = 1); + void FindPrimaryClusters(int cutNDF = 1); std::vector fParticles; ///< Array of the input particles constructed from tracks. int fNParticles; ///< Number of the input particles. std::vector fWeight; ///< Vector with weights of each track, the weight is defined in KFParticlePVReconstructor::Init(). - + KFParticle fBeamLine; ///< Position and direction of the beam line. bool fIsBeamLine; ///< Flag showing if the beam line is set. - + /** @class KFParticleCluster ** @brief A helper structure for reconstruction of a primary vertex. ** @author I.Kisel, M.Zyzak @@ -99,19 +115,17 @@ class KFParticlePVReconstructor{ ** which are then provided to KFVertex object for fit. **/ struct KFParticleCluster { - KFParticleCluster():fTracks(0) {}; + KFParticleCluster() : fTracks(0){}; std::vector fTracks; ///< List of tracks in a cluster. - float fP[3]; ///< Estimation of the vertex position based on the current cluster: {X, Y, Z}. - float fC[6]; ///< Estimated errors of the position approximation. + float fP[3]; ///< Estimation of the vertex position based on the current cluster: {X, Y, Z}. + float fC[6]; ///< Estimated errors of the position approximation. }; - std::vector< KFParticleCluster > fClusters; ///< Vector with clusters to be used for fit of a primary vertex. - std::vector fPrimVertices; ///< Vector with reconstructed candidates for a primary vertex. - + std::vector fClusters; ///< Vector with clusters to be used for fit of a primary vertex. + std::vector fPrimVertices; ///< Vector with reconstructed candidates for a primary vertex. + float fChi2CutPreparation; ///< A soft cut on the chi2-deviation which is used to form a cluster. float fChi2Cut; ///< Cut on the chi2-deviation of the tracks to the primary vertex \see KFVertex::ConstructPrimaryVertex(), where it is used. -}; // class KFParticlePVReconstructor - +}; // class KFParticlePVReconstructor #endif // KFParticlePVReconstructor_H - diff --git a/KFParticle/KFParticleSIMD.cxx b/KFParticle/KFParticleSIMD.cxx index 82a8064..41f3422 100644 --- a/KFParticle/KFParticleSIMD.cxx +++ b/KFParticle/KFParticleSIMD.cxx @@ -19,33 +19,32 @@ * along with this program. If not, see . */ - - #include "KFParticleSIMD.h" #include "KFParticle.h" #include "KFParticleDatabase.h" #ifdef HomogeneousField -float_v KFParticleSIMD::fgBz = -5.f; //* Bz compoment of the magnetic field +float_v KFParticleSIMD::fgBz = -5.f; //* Bz compoment of the magnetic field #endif -KFParticleSIMD::KFParticleSIMD( const KFParticleSIMD &d1, const KFParticleSIMD &d2 ): KFParticleBaseSIMD() +KFParticleSIMD::KFParticleSIMD(const KFParticleSIMD& d1, const KFParticleSIMD& d2) : KFParticleBaseSIMD() #ifdef NonhomogeneousField -, fField() + , + fField() #endif { /** Constructs a particle from two input daughter particles ** \param[in] d1 - the first daughter particle ** \param[in] d2 - the second daughter particle **/ - + KFParticleSIMD mother; - mother+= d1; - mother+= d2; + mother += d1; + mother += d2; *this = mother; } -void KFParticleSIMD::Create( const float_v Param[], const float_v Cov[], int_v Charge, float_v mass /*Int_t PID*/ ) +void KFParticleSIMD::Create(const float_v Param[], const float_v Cov[], int_v Charge, float_v mass /*Int_t PID*/) { /** Constructor from a "cartesian" track, mass hypothesis should be provided ** @@ -62,84 +61,86 @@ void KFParticleSIMD::Create( const float_v Param[], const float_v Cov[], int_v C ** \param[in] Charge - charge of the particle in elementary charge units ** \param[in] mass - the mass hypothesis **/ - + float_v C[21]; - for( int i=0; i<21; i++ ) C[i] = Cov[i]; - - KFParticleBaseSIMD::Initialize( Param, C, Charge, mass ); + for (int i = 0; i < 21; i++) + C[i] = Cov[i]; + + KFParticleBaseSIMD::Initialize(Param, C, Charge, mass); } -KFParticleSIMD::KFParticleSIMD( const KFPTrack *track, Int_t PID ): KFParticleBaseSIMD() +KFParticleSIMD::KFParticleSIMD(const KFPTrack* track, Int_t PID) : KFParticleBaseSIMD() #ifdef NonhomogeneousField -, fField() + , + fField() #endif { /** Constructor of the particle from an array of tracks. ** \param[in] track - pointer to the array of n=float_vLen tracks ** \param[in] PID - the PID hypothesis common for all elements of the SIMD vector **/ - + Double_t r[3]; Double_t C[21]; - for(Int_t iPart = 0; iPartGetMass(PID); - Create(fP,fC,fQ,mass); + Create(fP, fC, fQ, mass); - for(Int_t iPart = 0; iPartGetMass(*pdg); - Create(fP,fC,fQ,mass); + Create(fP, fC, fQ, mass); fChi2 = Track.GetChi2(); fNDF = Track.GetNDF(); } -KFParticleSIMD::KFParticleSIMD(KFPTrackVector &track, int n, const Int_t *pdg): KFParticleBaseSIMD() +KFParticleSIMD::KFParticleSIMD(KFPTrackVector& track, int n, const Int_t* pdg) : KFParticleBaseSIMD() #ifdef NonhomogeneousField -, fField() + , + fField() #endif { /** Constructor of the particle from a single track with index "n" stored in the KFPTrackVector format. @@ -148,25 +149,25 @@ KFParticleSIMD::KFParticleSIMD(KFPTrackVector &track, int n, const Int_t *pdg): ** \param[in] n - index of the track to be used ** \param[in] pdg - pointer to the pdg hypothesis **/ - - for(int i=0; i<6; i++) + + for (int i = 0; i < 6; i++) fP[i] = track.Parameter(i)[n]; - for(int i=0; i<21; i++) + for (int i = 0; i < 21; i++) fC[i] = track.Covariance(i)[n]; #ifdef NonhomogeneousField - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) fField.fField[i] = track.FieldCoefficient(i)[n]; #endif fQ = track.Q()[n]; float_v mass = KFParticleDatabase::Instance()->GetMass(*pdg); - Create(fP,fC,fQ,mass); + Create(fP, fC, fQ, mass); } - -KFParticleSIMD::KFParticleSIMD(KFPTrack* Track[], int NTracks, const Int_t *pdg): KFParticleBaseSIMD() +KFParticleSIMD::KFParticleSIMD(KFPTrack* Track[], int NTracks, const Int_t* pdg) : KFParticleBaseSIMD() #ifdef NonhomogeneousField -, fField() + , + fField() #endif { /** Constructor of the particle from an array tracks. @@ -177,46 +178,45 @@ KFParticleSIMD::KFParticleSIMD(KFPTrack* Track[], int NTracks, const Int_t *pdg) Create(Track, NTracks, pdg); } -void KFParticleSIMD::Create(KFPTrack* Track[], int NTracks, const Int_t *pdg) +void KFParticleSIMD::Create(KFPTrack* Track[], int NTracks, const Int_t* pdg) { /** Create a particle from from an array tracks. ** \param[in] Track - an array of pointers to tracks in the KFPTrack format ** \param[in] NTracks - number of tracks in the arry ** \param[in] pdg - pointer to the pdg hypothesis common for all elements of the SIMD vector **/ - + Double_t r[3]; Double_t C[21]; - for(Int_t iPart = 0; iPartXvYvZv(r); - for(Int_t i=0; i<3; i++) + for (Int_t i = 0; i < 3; i++) fP[i][iEntry] = r[i]; Track[iEntry]->PxPyPz(r); - for(Int_t i=0; i<3; i++) - fP[i+3][iEntry] = r[i]; + for (Int_t i = 0; i < 3; i++) + fP[i + 3][iEntry] = r[i]; fQ[iEntry] = Track[iEntry]->Charge(); - Track[iEntry]->GetCovarianceXYZPxPyPz( C ); - for(Int_t i=0; i<21; i++) + Track[iEntry]->GetCovarianceXYZPxPyPz(C); + for (Int_t i = 0; i < 21; i++) fC[i][iEntry] = C[i]; } float_v mass = KFParticleDatabase::Instance()->GetMass(*pdg); - Create(fP,fC,fQ,mass); + Create(fP, fC, fQ, mass); - for(Int_t iPart = 0; iPartGetChi2(); fNDF[iEntry] = Track[iEntry]->GetNDF(); } } -KFParticleSIMD::KFParticleSIMD(KFPTrackVector &track, uint_v& index, const int_v& pdg): KFParticleBaseSIMD() +KFParticleSIMD::KFParticleSIMD(KFPTrackVector& track, uint_v& index, const int_v& pdg) : KFParticleBaseSIMD() #ifdef NonhomogeneousField -, fField() + , + fField() #endif { /** Constructor of the particle from a set of tracks with random indices "index" stored in the KFPTrackVector format. @@ -224,11 +224,11 @@ KFParticleSIMD::KFParticleSIMD(KFPTrackVector &track, uint_v& index, const int_v ** \param[in] index - indices of the tracks to be converted to the KFParticleSIMD object ** \param[in] pdg - a SIMD vector with an individual pdg hypothesis for each element **/ - + Create(track, index, pdg); } -void KFParticleSIMD::Create(KFPTrackVector &track, uint_v& index, const int_v& pdg) +void KFParticleSIMD::Create(KFPTrackVector& track, uint_v& index, const int_v& pdg) { /** Create a particle from a set of tracks with indices "index" stored in the KFPTrackVector format. ** The function should be used in case if indices are random. If they are aligned please use function Load() @@ -237,24 +237,24 @@ void KFParticleSIMD::Create(KFPTrackVector &track, uint_v& index, const int_v& p ** \param[in] index - indices of the tracks to be converted to the KFParticleSIMD object ** \param[in] pdg - a SIMD vector with an individual pdg hypothesis for each element **/ - - for(int i=0; i<6; i++) + + for (int i = 0; i < 6; i++) fP[i].gather(&(track.Parameter(i)[0]), index); - for(int i=0; i<21; i++) + for (int i = 0; i < 21; i++) fC[i].gather(&(track.Covariance(i)[0]), index); #ifdef NonhomogeneousField - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) fField.fField[i].gather(&(track.FieldCoefficient(i)[0]), index); #endif - + // fPDG.gather(&(track.PDG()[0]), index); fQ.gather(&(track.Q()[0]), index); float_v mass = KFParticleDatabase::Instance()->GetMass(pdg); - Create(fP,fC,fQ,mass); + Create(fP, fC, fQ, mass); } -void KFParticleSIMD::Load(KFPTrackVector &track, int index, const int_v& pdg) +void KFParticleSIMD::Load(KFPTrackVector& track, int index, const int_v& pdg) { /** Create a particle from a set of consequetive tracks stored in the KFPTrackVector format ** starting from the index "index". @@ -262,42 +262,43 @@ void KFParticleSIMD::Load(KFPTrackVector &track, int index, const int_v& pdg) ** \param[in] index - index of the first track ** \param[in] pdg - a SIMD vector with an individual pdg hypothesis for each element **/ - - for(int i=0; i<6; i++) + + for (int i = 0; i < 6; i++) fP[i] = reinterpret_cast(track.Parameter(i)[index]); - for(int i=0; i<21; i++) + for (int i = 0; i < 21; i++) fC[i] = reinterpret_cast(track.Covariance(i)[index]); #ifdef NonhomogeneousField - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) fField.fField[i] = reinterpret_cast(track.FieldCoefficient(i)[index]); #endif - + // fPDG.gather(&(track.PDG()[0]), index); fQ = reinterpret_cast(track.Q()[index]); float_v mass = KFParticleDatabase::Instance()->GetMass(pdg); - Create(fP,fC,fQ,mass); + Create(fP, fC, fQ, mass); } void KFParticleSIMD::Rotate() { /** Rotates the entries of each SIMD vector of the data members. */ - - for(int i=0; i<7; i++) + + for (int i = 0; i < 7; i++) fP[i] = fP[i].rotated(1); - for(int i=0; i<27; i++) + for (int i = 0; i < 27; i++) fC[i] = fC[i].rotated(1); #ifdef NonhomogeneousField - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) fField.fField[i] = fField.fField[i].rotated(1); #endif fQ = fQ.rotated(1); fId = fId.rotated(1); } -KFParticleSIMD::KFParticleSIMD(KFPEmcCluster &track, uint_v& index, const KFParticleSIMD& vertexGuess): KFParticleBaseSIMD() +KFParticleSIMD::KFParticleSIMD(KFPEmcCluster& track, uint_v& index, const KFParticleSIMD& vertexGuess) : KFParticleBaseSIMD() #ifdef NonhomogeneousField -, fField() + , + fField() #endif { /** Constructor of gamma particles from a set of clusters of the electromagnetic calorimeter (EMC) @@ -306,11 +307,11 @@ KFParticleSIMD::KFParticleSIMD(KFPEmcCluster &track, uint_v& index, const KFPart ** \param[in] index - indices of the clusters to be converted to the KFParticleSIMD object ** \param[in] vertexGuess - vertex guess for estimation of the momentum of created gamma particles **/ - + Create(track, index, vertexGuess); } -void KFParticleSIMD::Create(KFPEmcCluster &track, uint_v& index, const KFParticleSIMD& vertexGuess) +void KFParticleSIMD::Create(KFPEmcCluster& track, uint_v& index, const KFParticleSIMD& vertexGuess) { /** Creates gamma particles from a set of clusters of the electromagnetic calorimeter (EMC) ** with random indices "index". The vertex hypothesis should be provided for the estimation of the momentum. @@ -318,68 +319,80 @@ void KFParticleSIMD::Create(KFPEmcCluster &track, uint_v& index, const KFParticl ** \param[in] index - indices of the clusters to be converted to the KFParticleSIMD object ** \param[in] vertexGuess - vertex guess for estimation of the momentum of created gamma particles **/ - - for(int i=0; i<3; i++) + + for (int i = 0; i < 3; i++) fP[i].gather(&(track.Parameter(i)[0]), index); fP[6].gather(&(track.Parameter(3)[0]), index); - + const float_v& dx = fP[0] - vertexGuess.fP[0]; const float_v& dy = fP[1] - vertexGuess.fP[1]; const float_v& dz = fP[2] - vertexGuess.fP[2]; - const float_v& dl2 = dx*dx + dy*dy + dz*dz; + const float_v& dl2 = dx * dx + dy * dy + dz * dz; const float_v& dl = sqrt(dl2); fP[0] = vertexGuess.fP[0]; fP[1] = vertexGuess.fP[1]; fP[2] = vertexGuess.fP[2]; - - fP[3] = dx/dl * fP[6]; - fP[4] = dy/dl * fP[6]; - fP[5] = dz/dl * fP[6]; - + + fP[3] = dx / dl * fP[6]; + fP[4] = dy / dl * fP[6]; + fP[5] = dz / dl * fP[6]; + float_v V[10]; - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) V[i].gather(&(track.Covariance(i)[0]), index); - + float_v J[7][4]; - for(int i=0; i<7; i++) - for(int j=0; j<4; j++) + for (int i = 0; i < 7; i++) + for (int j = 0; j < 4; j++) J[i][j] = 0.f; - J[0][0] = 1.f; J[1][1] = 1.f; J[2][2] = 1.f; J[6][3] = 1.f; - J[3][0] = fP[6]/dl * (1.f - dx*dx/dl2); J[3][1] = -dx*dy*fP[6]/(dl*dl2); J[3][2] = -dx*dz*fP[6]/(dl*dl2); J[3][3] = dx/dl; - J[4][0] = -dx*dy*fP[6]/(dl*dl2); J[4][1] = fP[6]/dl * (1.f - dy*dy/dl2); J[4][2] = -dy*dz*fP[6]/(dl*dl2); J[4][3] = dy/dl; - J[5][0] = -dx*dz*fP[6]/(dl*dl2); J[5][1] = -dy*dz*fP[6]/(dl*dl2); J[5][2] = fP[6]/dl * (1.f - dz*dz/dl2); J[5][3] = dz/dl; - + J[0][0] = 1.f; + J[1][1] = 1.f; + J[2][2] = 1.f; + J[6][3] = 1.f; + J[3][0] = fP[6] / dl * (1.f - dx * dx / dl2); + J[3][1] = -dx * dy * fP[6] / (dl * dl2); + J[3][2] = -dx * dz * fP[6] / (dl * dl2); + J[3][3] = dx / dl; + J[4][0] = -dx * dy * fP[6] / (dl * dl2); + J[4][1] = fP[6] / dl * (1.f - dy * dy / dl2); + J[4][2] = -dy * dz * fP[6] / (dl * dl2); + J[4][3] = dy / dl; + J[5][0] = -dx * dz * fP[6] / (dl * dl2); + J[5][1] = -dy * dz * fP[6] / (dl * dl2); + J[5][2] = fP[6] / dl * (1.f - dz * dz / dl2); + J[5][3] = dz / dl; + float_v VJT[4][7]; // V*J^T - for(Int_t i=0; i<4; i++) - { - for(Int_t j=0; j<7; j++) - { + for (Int_t i = 0; i < 4; i++) { + for (Int_t j = 0; j < 7; j++) { VJT[i][j] = 0.f; - for(Int_t k=0; k<4; k++) - VJT[i][j] += V[IJ(i,k)]*J[j][k]; + for (Int_t k = 0; k < 4; k++) + VJT[i][j] += V[IJ(i, k)] * J[j][k]; } } //Calculate the covariance matrix of the particle fC - for( Int_t i=0; i<36; i++ ) fC[i] = 0.f; - - for(Int_t i=0; i<7; ++i) - for(Int_t j=0; j<=i; ++j) - for(Int_t l=0; l<4; l++) - fC[IJ(i,j)]+= J[i][l]*VJT[l][j]; + for (Int_t i = 0; i < 36; i++) + fC[i] = 0.f; + + for (Int_t i = 0; i < 7; ++i) + for (Int_t j = 0; j <= i; ++j) + for (Int_t l = 0; l < 4; l++) + fC[IJ(i, j)] += J[i][l] * VJT[l][j]; fC[35] = 1.f; - + fQ = int_v(Vc::Zero); fNDF = 0; fChi2 = 0; - + SumDaughterMass = float_v(Vc::Zero); fMassHypo = float_v(Vc::Zero); } -KFParticleSIMD::KFParticleSIMD(KFPEmcCluster &track, int index, const KFParticleSIMD& vertexGuess): KFParticleBaseSIMD() +KFParticleSIMD::KFParticleSIMD(KFPEmcCluster& track, int index, const KFParticleSIMD& vertexGuess) : KFParticleBaseSIMD() #ifdef NonhomogeneousField -, fField() + , + fField() #endif { /** Constructr gamma particles from a set of consequetive clusters of the electromagnetic calorimeter (EMC) @@ -388,11 +401,11 @@ KFParticleSIMD::KFParticleSIMD(KFPEmcCluster &track, int index, const KFParticle ** \param[in] index - index of the first EMC cluster ** \param[in] vertexGuess - vertex guess for estimation of the momentum of created gamma particles **/ - + Load(track, index, vertexGuess); } -void KFParticleSIMD::Load(KFPEmcCluster &track, int index, const KFParticleSIMD& vertexGuess) +void KFParticleSIMD::Load(KFPEmcCluster& track, int index, const KFParticleSIMD& vertexGuess) { /** Create gamma particles from a set of consequetive clusters of the electromagnetic calorimeter (EMC) ** starting from the index "index". The vertex hypothesis should be provided for the estimation of the momentum. @@ -400,84 +413,96 @@ void KFParticleSIMD::Load(KFPEmcCluster &track, int index, const KFParticleSIMD& ** \param[in] index - index of the first EMC cluster ** \param[in] vertexGuess - vertex guess for estimation of the momentum of created gamma particles **/ - - for(int i=0; i<3; i++) + + for (int i = 0; i < 3; i++) fP[i] = reinterpret_cast(track.Parameter(i)[index]); fP[6] = reinterpret_cast(track.Parameter(3)[index]); const float_v& dx = fP[0] - vertexGuess.fP[0]; const float_v& dy = fP[1] - vertexGuess.fP[1]; const float_v& dz = fP[2] - vertexGuess.fP[2]; - const float_v& dl2 = dx*dx + dy*dy + dz*dz; + const float_v& dl2 = dx * dx + dy * dy + dz * dz; const float_v& dl = sqrt(dl2); fP[0] = vertexGuess.fP[0]; fP[1] = vertexGuess.fP[1]; fP[2] = vertexGuess.fP[2]; - - fP[3] = dx/dl * fP[6]; - fP[4] = dy/dl * fP[6]; - fP[5] = dz/dl * fP[6]; - + + fP[3] = dx / dl * fP[6]; + fP[4] = dy / dl * fP[6]; + fP[5] = dz / dl * fP[6]; + float_v V[10]; - for(int i=0; i<10; i++) + for (int i = 0; i < 10; i++) V[i] = reinterpret_cast(track.Covariance(i)[index]); - + float_v J[7][4]; - for(int i=0; i<7; i++) - for(int j=0; j<4; j++) + for (int i = 0; i < 7; i++) + for (int j = 0; j < 4; j++) J[i][j] = 0.f; - J[0][0] = 1.f; J[1][1] = 1.f; J[2][2] = 1.f; J[6][3] = 1.f; - J[3][0] = fP[6]/dl * (1.f - dx*dx/dl2); J[3][1] = -dx*dy*fP[6]/(dl*dl2); J[3][2] = -dx*dz*fP[6]/(dl*dl2); J[3][3] = dx/dl; - J[4][0] = -dx*dy*fP[6]/(dl*dl2); J[4][1] = fP[6]/dl * (1.f - dy*dy/dl2); J[4][2] = -dy*dz*fP[6]/(dl*dl2); J[4][3] = dy/dl; - J[5][0] = -dx*dz*fP[6]/(dl*dl2); J[5][1] = -dy*dz*fP[6]/(dl*dl2); J[5][2] = fP[6]/dl * (1.f - dz*dz/dl2); J[5][3] = dz/dl; - + J[0][0] = 1.f; + J[1][1] = 1.f; + J[2][2] = 1.f; + J[6][3] = 1.f; + J[3][0] = fP[6] / dl * (1.f - dx * dx / dl2); + J[3][1] = -dx * dy * fP[6] / (dl * dl2); + J[3][2] = -dx * dz * fP[6] / (dl * dl2); + J[3][3] = dx / dl; + J[4][0] = -dx * dy * fP[6] / (dl * dl2); + J[4][1] = fP[6] / dl * (1.f - dy * dy / dl2); + J[4][2] = -dy * dz * fP[6] / (dl * dl2); + J[4][3] = dy / dl; + J[5][0] = -dx * dz * fP[6] / (dl * dl2); + J[5][1] = -dy * dz * fP[6] / (dl * dl2); + J[5][2] = fP[6] / dl * (1.f - dz * dz / dl2); + J[5][3] = dz / dl; + float_v VJT[4][7]; // V*J^T - for(Int_t i=0; i<4; i++) - { - for(Int_t j=0; j<7; j++) - { + for (Int_t i = 0; i < 4; i++) { + for (Int_t j = 0; j < 7; j++) { VJT[i][j] = 0.f; - for(Int_t k=0; k<4; k++) - VJT[i][j] += V[IJ(i,k)]*J[j][k]; + for (Int_t k = 0; k < 4; k++) + VJT[i][j] += V[IJ(i, k)] * J[j][k]; } } //Calculate the covariance matrix of the particle fC - for( Int_t i=0; i<36; i++ ) fC[i] = 0.f; - - for(Int_t i=0; i<7; ++i) - for(Int_t j=0; j<=i; ++j) - for(Int_t l=0; l<4; l++) - fC[IJ(i,j)]+= J[i][l]*VJT[l][j]; + for (Int_t i = 0; i < 36; i++) + fC[i] = 0.f; + + for (Int_t i = 0; i < 7; ++i) + for (Int_t j = 0; j <= i; ++j) + for (Int_t l = 0; l < 4; l++) + fC[IJ(i, j)] += J[i][l] * VJT[l][j]; fC[35] = 1.f; - + fQ = int_v(Vc::Zero); fNDF = 0; fChi2 = 0; - + SumDaughterMass = float_v(Vc::Zero); fMassHypo = float_v(Vc::Zero); } -KFParticleSIMD::KFParticleSIMD( const KFPVertex &vertex ): KFParticleBaseSIMD() +KFParticleSIMD::KFParticleSIMD(const KFPVertex& vertex) : KFParticleBaseSIMD() #ifdef NonhomogeneousField -, fField() + , + fField() #endif { /** Copies a vertex in KFPVertex into each element of the vectorised KFParticle ** \param[in] vertex - vertex to b converted **/ - + Double_t r[3]; Double_t C[21]; - vertex.GetXYZ( r ); - for(Int_t i=0; i<3; i++) + vertex.GetXYZ(r); + for (Int_t i = 0; i < 3; i++) fP[i] = r[i]; - vertex.GetCovarianceMatrix( C ); - for(Int_t i=0; i<21; i++) + vertex.GetCovarianceMatrix(C); + for (Int_t i = 0; i < 21; i++) fC[i] = C[i]; fChi2 = vertex.GetChi2(); - fNDF = 2*vertex.GetNContributors() - 3; + fNDF = 2 * vertex.GetNContributors() - 3; fQ = int_v(Vc::Zero); fAtProductionVertex = 0; fSFromDecay = 0; @@ -490,51 +515,52 @@ void KFParticleSIMD::SetOneEntry(int iEntry, KFParticleSIMD& part, int iEntryPar ** \param[in] part - particle, element of which should be copied to the current particle ** \param[in] iEntryPart - index of the element of particle part, which should be copied to the current particle **/ - - for( int i = 0; i < 7; ++i ) + + for (int i = 0; i < 7; ++i) fP[i][iEntry] = part.Parameters()[i][iEntryPart]; - for( int i = 0; i < 36; ++i ) + for (int i = 0; i < 36; ++i) fC[i][iEntry] = part.CovarianceMatrix()[i][iEntryPart]; - + fQ[iEntry] = part.Q()[iEntryPart]; fNDF[iEntry] = part.NDF()[iEntryPart]; fChi2[iEntry] = part.Chi2()[iEntryPart]; - -// fSFromDecay[iEntry] = part.fSFromDecay[iEntryPart]; -// SumDaughterMass[iEntry] = part.SumDaughterMass[iEntryPart]; -// fMassHypo[iEntry] = part.fMassHypo[iEntryPart]; + + // fSFromDecay[iEntry] = part.fSFromDecay[iEntryPart]; + // SumDaughterMass[iEntry] = part.SumDaughterMass[iEntryPart]; + // fMassHypo[iEntry] = part.fMassHypo[iEntryPart]; fId[iEntry] = part.Id()[iEntryPart]; fPDG[iEntry] = part.GetPDG()[iEntryPart]; - - if(iEntry==0) - fDaughterIds.resize( part.NDaughters(), int_v(-1) ); - - for(int iD=0; iDNDaughters(); - for ( int ie = 1; ie < nPart; ie++ ) { - const KFParticle &part = *(parts[ie]); + for (int ie = 1; ie < nPart; ie++) { + const KFParticle& part = *(parts[ie]); ok &= part.NDaughters() == nD; } if (!ok) { @@ -542,21 +568,21 @@ KFParticleSIMD::KFParticleSIMD(KFParticle* parts[], const int nPart): KFParticle exit(1); } } - fDaughterIds.resize( (parts[0])->NDaughters(), int_v(-1) ); + fDaughterIds.resize((parts[0])->NDaughters(), int_v(-1)); - for ( int iPart = 0; iPart < float_vLen; iPart++ ) { - Int_t iEntry = (iPart < nPart) ? iPart : 0; - KFParticle &part = *(parts[iEntry]); + for (int iPart = 0; iPart < float_vLen; iPart++) { + Int_t iEntry = (iPart < nPart) ? iPart : 0; + KFParticle& part = *(parts[iEntry]); fId[iEntry] = part.Id(); - for(int iD=0; iD(1.e-8f)); - a(mask) = ( mP[3]*mP1[3] + mP[4]*mP1[4] + mP[5]*mP1[5] )/n; - mask = ( abs(a) < float_v(1.f)); - float_m aPos = (a>=float_v(Vc::Zero)); + float_m mask = (n > (1.e-8f)); + a(mask) = (mP[3] * mP1[3] + mP[4] * mP1[4] + mP[5] * mP1[5]) / n; + mask = (abs(a) < float_v(1.f)); + float_m aPos = (a >= float_v(Vc::Zero)); a(mask) = KFPMath::ACos(a); a((!mask) && aPos) = float_v(Vc::Zero); a((!mask) && (!aPos)) = 3.1415926535f; return a; } -float_v KFParticleSIMD::GetAngleXY( const KFParticleSIMD &p ) const +float_v KFParticleSIMD::GetAngleXY(const KFParticleSIMD& p) const { /** Returns the opening angle between the current and the second particle in the XY plane. ** \param[in] p - the second particle **/ - - float_v ds[2] = {0.f,0.f}; + + float_v ds[2] = {0.f, 0.f}; float_v dsdr[4][6]; - GetDStoParticle( p, ds, dsdr ); + GetDStoParticle(p, ds, dsdr); float_v mP[8], mC[36], mP1[8], mC1[36]; - Transport( ds[0], dsdr[0], mP, mC ); - p.Transport( ds[1], dsdr[3], mP1, mC1 ); - float_v n = sqrt( mP[3]*mP[3] + mP[4]*mP[4] ); - float_v n1= sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] ); - n*=n1; + Transport(ds[0], dsdr[0], mP, mC); + p.Transport(ds[1], dsdr[3], mP1, mC1); + float_v n = sqrt(mP[3] * mP[3] + mP[4] * mP[4]); + float_v n1 = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4]); + n *= n1; float_v a(Vc::Zero); - float_m mask = (n>(1.e-8f)); - a = ( mP[3]*mP1[3] + mP[4]*mP1[4] )/n; + float_m mask = (n > (1.e-8f)); + a = (mP[3] * mP1[3] + mP[4] * mP1[4]) / n; a(!mask) = 0.f; - mask = ( abs(a) < float_v(1.f)); - float_m aPos = (a>=float_v(Vc::Zero)); + mask = (abs(a) < float_v(1.f)); + float_m aPos = (a >= float_v(Vc::Zero)); a(mask) = KFPMath::ACos(a); a((!mask) && aPos) = float_v(Vc::Zero); a((!mask) && (!aPos)) = 3.1415926535f; return a; } -float_v KFParticleSIMD::GetAngleRZ( const KFParticleSIMD &p ) const +float_v KFParticleSIMD::GetAngleRZ(const KFParticleSIMD& p) const { /** Returns the opening angle between the current and the second particle in the RZ plane, R = sqrt(X*X+Y*Y). ** \param[in] p - the second particle **/ - - float_v ds[2] = {0.f,0.f}; + + float_v ds[2] = {0.f, 0.f}; float_v dsdr[4][6]; - GetDStoParticle( p, ds, dsdr ); + GetDStoParticle(p, ds, dsdr); float_v mP[8], mC[36], mP1[8], mC1[36]; - Transport( ds[0], dsdr[0], mP, mC ); - p.Transport( ds[1], dsdr[3], mP1, mC1 ); - float_v nr = sqrt( mP[3]*mP[3] + mP[4]*mP[4] ); - float_v n1r= sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] ); - float_v n = sqrt( nr*nr + mP[5]*mP[5] ); - float_v n1= sqrt( n1r*n1r + mP1[5]*mP1[5] ); - n*=n1; + Transport(ds[0], dsdr[0], mP, mC); + p.Transport(ds[1], dsdr[3], mP1, mC1); + float_v nr = sqrt(mP[3] * mP[3] + mP[4] * mP[4]); + float_v n1r = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4]); + float_v n = sqrt(nr * nr + mP[5] * mP[5]); + float_v n1 = sqrt(n1r * n1r + mP1[5] * mP1[5]); + n *= n1; float_v a(Vc::Zero); - float_m mask = (n>(1.e-8f)); - a(mask) = ( nr*n1r +mP[5]*mP1[5])/n; - mask = ( abs(a) < float_v(Vc::Zero)); - float_m aPos = (a>=float_v(Vc::Zero)); + float_m mask = (n > (1.e-8f)); + a(mask) = (nr * n1r + mP[5] * mP1[5]) / n; + mask = (abs(a) < float_v(Vc::Zero)); + float_m aPos = (a >= float_v(Vc::Zero)); a(mask) = KFPMath::ACos(a); a((!mask) && aPos) = float_v(Vc::Zero); a((!mask) && (!aPos)) = 3.1415926535f; return a; } -float_v KFParticleSIMD::GetPseudoProperDecayTime( const KFParticleSIMD &pV, const float_v& mass, float_v* timeErr2 ) const -{ +float_v KFParticleSIMD::GetPseudoProperDecayTime(const KFParticleSIMD& pV, const float_v& mass, float_v* timeErr2) const +{ /** Returns the Pseudo Proper Time of the decay = (r*pt) / |pt| * M/|pt| ** ** \param[in] pV - the creation point of the particle ** \param[in] mass - the mass of the particle ** \param[out] timeErr2 - error of the returned value, if null pointer is provided - is not calculated **/ - - const float_v ipt2 = 1/( Px()*Px() + Py()*Py() ); - const float_v mipt2 = mass*ipt2; + + const float_v ipt2 = 1 / (Px() * Px() + Py() * Py()); + const float_v mipt2 = mass * ipt2; const float_v dx = X() - pV.X(); const float_v dy = Y() - pV.Y(); - if ( timeErr2 ) { - // -- calculate error = sigma(f(r)) = f'Cf' - // r = {x,y,px,py,x_pV,y_pV} - // df/dr = { px*m/pt^2, - // py*m/pt^2, - // ( x - x_pV )*m*(1/pt^2 - 2(px/pt^2)^2), - // ( y - y_pV )*m*(1/pt^2 - 2(py/pt^2)^2), - // -px*m/pt^2, - // -py*m/pt^2 } - const float_v f0 = Px()*mipt2; - const float_v f1 = Py()*mipt2; - const float_v mipt2derivative = mipt2*(1-2*Px()*Px()*ipt2); - const float_v f2 = dx*mipt2derivative; - const float_v f3 = -dy*mipt2derivative; + if (timeErr2) { + // -- calculate error = sigma(f(r)) = f'Cf' + // r = {x,y,px,py,x_pV,y_pV} + // df/dr = { px*m/pt^2, + // py*m/pt^2, + // ( x - x_pV )*m*(1/pt^2 - 2(px/pt^2)^2), + // ( y - y_pV )*m*(1/pt^2 - 2(py/pt^2)^2), + // -px*m/pt^2, + // -py*m/pt^2 } + const float_v f0 = Px() * mipt2; + const float_v f1 = Py() * mipt2; + const float_v mipt2derivative = mipt2 * (1 - 2 * Px() * Px() * ipt2); + const float_v f2 = dx * mipt2derivative; + const float_v f3 = -dy * mipt2derivative; const float_v f4 = -f0; const float_v f5 = -f1; - const float_v& mC00 = GetCovariance(0,0); - const float_v& mC10 = GetCovariance(0,1); - const float_v& mC11 = GetCovariance(1,1); - const float_v& mC20 = GetCovariance(3,0); - const float_v& mC21 = GetCovariance(3,1); - const float_v& mC22 = GetCovariance(3,3); - const float_v& mC30 = GetCovariance(4,0); - const float_v& mC31 = GetCovariance(4,1); - const float_v& mC32 = GetCovariance(4,3); - const float_v& mC33 = GetCovariance(4,4); - const float_v& mC44 = pV.GetCovariance(0,0); - const float_v& mC54 = pV.GetCovariance(1,0); - const float_v& mC55 = pV.GetCovariance(1,1); + const float_v& mC00 = GetCovariance(0, 0); + const float_v& mC10 = GetCovariance(0, 1); + const float_v& mC11 = GetCovariance(1, 1); + const float_v& mC20 = GetCovariance(3, 0); + const float_v& mC21 = GetCovariance(3, 1); + const float_v& mC22 = GetCovariance(3, 3); + const float_v& mC30 = GetCovariance(4, 0); + const float_v& mC31 = GetCovariance(4, 1); + const float_v& mC32 = GetCovariance(4, 3); + const float_v& mC33 = GetCovariance(4, 4); + const float_v& mC44 = pV.GetCovariance(0, 0); + const float_v& mC54 = pV.GetCovariance(1, 0); + const float_v& mC55 = pV.GetCovariance(1, 1); *timeErr2 = - f5*mC55*f5 + - f5*mC54*f4 + - f4*mC44*f4 + - f3*mC33*f3 + - f3*mC32*f2 + - f3*mC31*f1 + - f3*mC30*f0 + - f2*mC22*f2 + - f2*mC21*f1 + - f2*mC20*f0 + - f1*mC11*f1 + - f1*mC10*f0 + - f0*mC00*f0; + f5 * mC55 * f5 + + f5 * mC54 * f4 + + f4 * mC44 * f4 + + f3 * mC33 * f3 + + f3 * mC32 * f2 + + f3 * mC31 * f1 + + f3 * mC30 * f0 + + f2 * mC22 * f2 + + f2 * mC21 * f1 + + f2 * mC20 * f0 + + f1 * mC11 * f1 + + f1 * mC10 * f0 + + f0 * mC00 * f0; } - return ( dx*Px() + dy*Py() )*mipt2; + return (dx * Px() + dy * Py()) * mipt2; } -void KFParticleSIMD::GetKFParticle(KFParticle &Part, int iPart) +void KFParticleSIMD::GetKFParticle(KFParticle& Part, int iPart) { /** Copies an entry "iPart" of the current vectorised particle to the scalar KFParticle object. ** \param[out] Part - an output scalar particle, where element "iPart" will be copied ** \param[in] iPart - index of the element to be copied to the scalar particle **/ - + Part.SetId(static_cast(Id()[iPart])); Part.CleanDaughtersId(); - for( unsigned int i = 0; i < DaughterIds().size(); i++ ) + for (unsigned int i = 0; i < DaughterIds().size(); i++) Part.AddDaughterId(static_cast(DaughterIds()[i][iPart])); - Part.SetPDG( static_cast(GetPDG()[iPart]) ); + Part.SetPDG(static_cast(GetPDG()[iPart])); - for(int iP=0; iP<8; iP++) + for (int iP = 0; iP < 8; iP++) Part.Parameters()[iP] = Parameters()[iP][iPart]; - for(int iC=0; iC<36; iC++) + for (int iC = 0; iC < 36; iC++) Part.CovarianceMatrix()[iC] = CovarianceMatrix()[iC][iPart]; Part.NDF() = static_cast(GetNDF()[iPart]); Part.Chi2() = GetChi2()[iPart]; - Part.Q() = GetQ()[iPart]; + Part.Q() = GetQ()[iPart]; Part.SetAtProductionVertex(fAtProductionVertex); #ifdef NonhomogeneousField - for(int iF=0; iF<10; iF++) + for (int iF = 0; iF < 10; iF++) Part.SetFieldCoeff(fField.fField[iF][iPart], iF); #endif } @@ -1040,7 +1054,7 @@ void KFParticleSIMD::GetKFParticle(KFParticle* Part, int nPart) ** \param[out] Part - an output array of scalar particles ** \param[in] nPart - number of elements to be copied to the array of scalar objects **/ - - for(int i=0; i. */ - //#define NonhomogeneousField // #define HomogeneousField @@ -56,27 +55,26 @@ class KFParticle; ** to other particles and vertices, get deviations from them in terms of errors, etc. **/ -class KFParticleSIMD :public KFParticleBaseSIMD +class KFParticleSIMD : public KFParticleBaseSIMD { - - public: - void *operator new(size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new[](size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new(size_t size, void *ptr) { return ::operator new(size, ptr);} ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void *operator new[](size_t size, void *ptr) { return ::operator new(size, ptr);} ///< new operator for allocation of the SIMD-alligned dynamic memory allocation - void operator delete(void *ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release - void operator delete[](void *ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release + public: + void* operator new(size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new[](size_t size) { return _mm_malloc(size, sizeof(float_v)); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new(size_t size, void* ptr) { return ::operator new(size, ptr); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void* operator new[](size_t size, void* ptr) { return ::operator new(size, ptr); } ///< new operator for allocation of the SIMD-alligned dynamic memory allocation + void operator delete(void* ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release + void operator delete[](void* ptr, size_t) { _mm_free(ptr); } ///< delete operator for the SIMD-alligned dynamic memory release //* //* INITIALIZATION //* //* Set magnetic field for all particles #ifdef HomogeneousField - static void SetField( float_v Bz ); ///< Set Bz field. + static void SetField(float_v Bz); ///< Set Bz field. #endif #ifdef NonhomogeneousField - void SetField(const KFParticleFieldRegion &field) + void SetField(const KFParticleFieldRegion& field) { /** Set the field approximation along the particle trajectory ** \param[in] field - approximation of each component of the magnetic field with the parabola alnog the particle trajectory @@ -86,272 +84,271 @@ class KFParticleSIMD :public KFParticleBaseSIMD #endif //* Constructor (empty) - KFParticleSIMD():KFParticleBaseSIMD() + KFParticleSIMD() : KFParticleBaseSIMD() #ifdef NonhomogeneousField - , fField() + , + fField() #endif - { ; } + { + ; + } //* Destructor (empty) - virtual ~KFParticleSIMD(){ ; } + virtual ~KFParticleSIMD() { ; } //* Construction of mother particle by its 2-3-4 daughters - KFParticleSIMD( const KFParticleSIMD &d1, const KFParticleSIMD &d2 ); - KFParticleSIMD( const KFParticleSIMD &d1, const KFParticleSIMD &d2, const KFParticleSIMD &d3 ); - KFParticleSIMD( const KFParticleSIMD &d1, const KFParticleSIMD &d2, const KFParticleSIMD &d3, const KFParticleSIMD &d4 ); + KFParticleSIMD(const KFParticleSIMD& d1, const KFParticleSIMD& d2); + KFParticleSIMD(const KFParticleSIMD& d1, const KFParticleSIMD& d2, const KFParticleSIMD& d3); + KFParticleSIMD(const KFParticleSIMD& d1, const KFParticleSIMD& d2, const KFParticleSIMD& d3, const KFParticleSIMD& d4); - //* Initialisation from "cartesian" coordinates ( X Y Z Px Py Pz ) - //* Parameters, covariance matrix, charge and PID hypothesis should be provided + //* Initialisation from "cartesian" coordinates ( X Y Z Px Py Pz ) + //* Parameters, covariance matrix, charge and PID hypothesis should be provided - void Create( const float_v Param[], const float_v Cov[], int_v Charge, float_v mass /*Int_t PID*/ ); + void Create(const float_v Param[], const float_v Cov[], int_v Charge, float_v mass /*Int_t PID*/); void SetOneEntry(int iEntry, KFParticleSIMD& part, int iEntryPart); - KFParticleSIMD( const KFPTrack *track, Int_t PID ); - KFParticleSIMD( KFPTrack* Track[], int NTracks, const Int_t *pdg=0 ); - KFParticleSIMD( KFPTrackVector &track, uint_v& index, const int_v& pdg ); + KFParticleSIMD(const KFPTrack* track, Int_t PID); + KFParticleSIMD(KFPTrack* Track[], int NTracks, const Int_t* pdg = 0); + KFParticleSIMD(KFPTrackVector& track, uint_v& index, const int_v& pdg); - void Create(KFPTrack* Track[], int NTracks, const Int_t *pdg=0); - void Create(KFPTrackVector &track, uint_v& index, const int_v& pdg); - void Load(KFPTrackVector &track, int index, const int_v& pdg); + void Create(KFPTrack* Track[], int NTracks, const Int_t* pdg = 0); + void Create(KFPTrackVector& track, uint_v& index, const int_v& pdg); + void Load(KFPTrackVector& track, int index, const int_v& pdg); void Rotate(); - KFParticleSIMD(KFPTrack &Track, const Int_t *pdg=0); - KFParticleSIMD(KFPTrackVector &track, int n, const Int_t *pdg=0); + KFParticleSIMD(KFPTrack& Track, const Int_t* pdg = 0); + KFParticleSIMD(KFPTrackVector& track, int n, const Int_t* pdg = 0); - KFParticleSIMD( KFPEmcCluster &track, uint_v& index, const KFParticleSIMD& vertexGuess ); - KFParticleSIMD( KFPEmcCluster &track, int index, const KFParticleSIMD& vertexGuess ); - void Create( KFPEmcCluster &track, uint_v& index, const KFParticleSIMD& vertexGuess ); - void Load( KFPEmcCluster &track, int index, const KFParticleSIMD& vertexGuess ); + KFParticleSIMD(KFPEmcCluster& track, uint_v& index, const KFParticleSIMD& vertexGuess); + KFParticleSIMD(KFPEmcCluster& track, int index, const KFParticleSIMD& vertexGuess); + void Create(KFPEmcCluster& track, uint_v& index, const KFParticleSIMD& vertexGuess); + void Load(KFPEmcCluster& track, int index, const KFParticleSIMD& vertexGuess); - - //* Initialisation from VVertex + //* Initialisation from VVertex - KFParticleSIMD( const KFPVertex &vertex ); - KFParticleSIMD( KFParticle* part[], const int nPart = 0 ); - KFParticleSIMD( KFParticle &part ); + KFParticleSIMD(const KFPVertex& vertex); + KFParticleSIMD(KFParticle* part[], const int nPart = 0); + KFParticleSIMD(KFParticle& part); //* //* ACCESSORS //* - //* Simple accessors - - float_v GetX () const ; ///< Retruns X coordinate of the particle, fP[0]. - float_v GetY () const ; ///< Retruns Y coordinate of the particle, fP[1]. - float_v GetZ () const ; ///< Retruns Z coordinate of the particle, fP[2]. - float_v GetPx () const ; ///< Retruns X component of the momentum, fP[3]. - float_v GetPy () const ; ///< Retruns Y component of the momentum, fP[4]. - float_v GetPz () const ; ///< Retruns Z component of the momentum, fP[5]. - float_v GetE () const ; ///< Returns energy of the particle, fP[6]. - float_v GetS () const ; ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. - int_v GetQ () const ; ///< Returns charge of the particle. - float_v GetChi2 () const ; ///< Returns Chi2 of the fit. - int_v GetNDF () const ; ///< Returns number of decrease of freedom. - - Bool_t GetAtProductionVertex() const { return fAtProductionVertex; } ///< Returns a flag which shows if the particle is located at the production point - - const float_v& X () const { return fP[0]; } ///< Retruns X coordinate of the particle, fP[0]. - const float_v& Y () const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. - const float_v& Z () const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. - const float_v& Px () const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. - const float_v& Py () const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. - const float_v& Pz () const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. - const float_v& E () const { return fP[6]; } ///< Returns energy of the particle, fP[6]. - const float_v& S () const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. - const int_v & Q () const { return fQ; } ///< Returns charge of the particle. - const float_v& Chi2 () const { return fChi2; } ///< Returns Chi2 of the fit. - const int_v& NDF () const { return fNDF; } ///< Returns number of decrease of freedom. - - float_v GetParameter ( int i ) const ; ///< Returns P[i] parameter. - float_v GetCovariance( int i ) const ; ///< Returns C[i] element of the covariance matrix in the lower triangular form. - float_v GetCovariance( int i, int j ) const ; ///< Returns C[i,j] element of the covariance matrix. + //* Simple accessors + + float_v GetX() const; ///< Retruns X coordinate of the particle, fP[0]. + float_v GetY() const; ///< Retruns Y coordinate of the particle, fP[1]. + float_v GetZ() const; ///< Retruns Z coordinate of the particle, fP[2]. + float_v GetPx() const; ///< Retruns X component of the momentum, fP[3]. + float_v GetPy() const; ///< Retruns Y component of the momentum, fP[4]. + float_v GetPz() const; ///< Retruns Z component of the momentum, fP[5]. + float_v GetE() const; ///< Returns energy of the particle, fP[6]. + float_v GetS() const; ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. + int_v GetQ() const; ///< Returns charge of the particle. + float_v GetChi2() const; ///< Returns Chi2 of the fit. + int_v GetNDF() const; ///< Returns number of decrease of freedom. + + Bool_t GetAtProductionVertex() const { return fAtProductionVertex; } ///< Returns a flag which shows if the particle is located at the production point + + const float_v& X() const { return fP[0]; } ///< Retruns X coordinate of the particle, fP[0]. + const float_v& Y() const { return fP[1]; } ///< Retruns Y coordinate of the particle, fP[1]. + const float_v& Z() const { return fP[2]; } ///< Retruns Z coordinate of the particle, fP[2]. + const float_v& Px() const { return fP[3]; } ///< Retruns X component of the momentum, fP[3]. + const float_v& Py() const { return fP[4]; } ///< Retruns Y component of the momentum, fP[4]. + const float_v& Pz() const { return fP[5]; } ///< Retruns Z component of the momentum, fP[5]. + const float_v& E() const { return fP[6]; } ///< Returns energy of the particle, fP[6]. + const float_v& S() const { return fP[7]; } ///< Returns dS=l/p, l - decay length, fP[7], defined if production vertex is set. + const int_v& Q() const { return fQ; } ///< Returns charge of the particle. + const float_v& Chi2() const { return fChi2; } ///< Returns Chi2 of the fit. + const int_v& NDF() const { return fNDF; } ///< Returns number of decrease of freedom. + + float_v GetParameter(int i) const; ///< Returns P[i] parameter. + float_v GetCovariance(int i) const; ///< Returns C[i] element of the covariance matrix in the lower triangular form. + float_v GetCovariance(int i, int j) const; ///< Returns C[i,j] element of the covariance matrix. //* Accessors with calculations, value returned w/o error flag - - float_v GetP () const; ///< Returns momentum - float_v GetPt () const; ///< Returns transverse momentum - float_v GetEta () const; ///< Returns pseudorapidity - float_v GetPhi () const; ///< Returns the azimuthal angle phi - float_v GetMomentum () const; ///< Returns momentum - float_v GetMass () const; ///< Returns mass - float_v GetDecayLength () const; ///< Returns decay length - float_v GetDecayLengthXY () const; ///< Returns decay length in XY - float_v GetLifeTime () const; ///< Returns life time ctau [cm] - float_v GetR () const; ///< Returns distance to the origin of the coordinate system {0,0,0} - float_v GetRapidity() const { return float_v(0.5f)*log((fP[6] + fP[5])/(fP[6] - fP[5])); } ///< Returns rapidity of the particle - - //* Accessors to estimated errors - float_v GetErrX () const ; ///< Returns the error of X of current position - float_v GetErrY () const ; ///< Returns the error of Y of current position - float_v GetErrZ () const ; ///< Returns the error of Z of current position - float_v GetErrPx () const ; ///< Returns the error of X-compoment of the particle momentum - float_v GetErrPy () const ; ///< Returns the error of Y-compoment of the particle momentum - float_v GetErrPz () const ; ///< Returns the error of Z-compoment of the particle momentum - float_v GetErrE () const ; ///< Returns the error of energy - float_v GetErrS () const ; ///< Returns the error of decay length / momentum - float_v GetErrP () const ; ///< Returns the error of momentum - float_v GetErrPt () const ; ///< Returns the error of transverse momentum - float_v GetErrEta () const ; ///< Returns the error of pseudorapidity - float_v GetErrPhi () const ; ///< Returns the error of the azimuthal angle phi - float_v GetErrMomentum () const ; ///< Returns the error of momentum - float_v GetErrMass () const ; ///< Returns the error of mass - float_v GetErrDecayLength () const ; ///< Returns the error of decay length - float_v GetErrDecayLengthXY () const ; ///< Returns the error of decay length in XY - float_v GetErrLifeTime () const ; ///< Returns the error of life time - float_v GetErrR () const ; ///< Returns the error of distance to the origin of the coordinate system {0,0,0} + float_v GetP() const; ///< Returns momentum + float_v GetPt() const; ///< Returns transverse momentum + float_v GetEta() const; ///< Returns pseudorapidity + float_v GetPhi() const; ///< Returns the azimuthal angle phi + float_v GetMomentum() const; ///< Returns momentum + float_v GetMass() const; ///< Returns mass + float_v GetDecayLength() const; ///< Returns decay length + float_v GetDecayLengthXY() const; ///< Returns decay length in XY + float_v GetLifeTime() const; ///< Returns life time ctau [cm] + float_v GetR() const; ///< Returns distance to the origin of the coordinate system {0,0,0} + float_v GetRapidity() const { return float_v(0.5f) * log((fP[6] + fP[5]) / (fP[6] - fP[5])); } ///< Returns rapidity of the particle - //* Accessors with calculations( &value, &estimated sigma ) - //* error flag returned (0 means no error during calculations) + //* Accessors to estimated errors - float_m GetP ( float_v &P, float_v &SigmaP ) const ; //* momentum - float_m GetPt ( float_v &Pt, float_v &SigmaPt ) const ; //* transverse momentum - float_m GetEta ( float_v &Eta, float_v &SigmaEta ) const ; //* pseudorapidity - float_m GetPhi ( float_v &Phi, float_v &SigmaPhi ) const ; //* phi - float_m GetMomentum ( float_v &P, float_v &SigmaP ) const ; //* momentum - float_m GetMass ( float_v &M, float_v &SigmaM ) const ; //* mass - float_m GetDecayLength ( float_v &L, float_v &SigmaL ) const ; //* decay length - float_m GetDecayLengthXY ( float_v &L, float_v &SigmaL ) const ; //* decay length in XY - float_m GetLifeTime ( float_v &T, float_v &SigmaT ) const ; //* life time - float_m GetR ( float_v &R, float_v &SigmaR ) const ; //* R + float_v GetErrX() const; ///< Returns the error of X of current position + float_v GetErrY() const; ///< Returns the error of Y of current position + float_v GetErrZ() const; ///< Returns the error of Z of current position + float_v GetErrPx() const; ///< Returns the error of X-compoment of the particle momentum + float_v GetErrPy() const; ///< Returns the error of Y-compoment of the particle momentum + float_v GetErrPz() const; ///< Returns the error of Z-compoment of the particle momentum + float_v GetErrE() const; ///< Returns the error of energy + float_v GetErrS() const; ///< Returns the error of decay length / momentum + float_v GetErrP() const; ///< Returns the error of momentum + float_v GetErrPt() const; ///< Returns the error of transverse momentum + float_v GetErrEta() const; ///< Returns the error of pseudorapidity + float_v GetErrPhi() const; ///< Returns the error of the azimuthal angle phi + float_v GetErrMomentum() const; ///< Returns the error of momentum + float_v GetErrMass() const; ///< Returns the error of mass + float_v GetErrDecayLength() const; ///< Returns the error of decay length + float_v GetErrDecayLengthXY() const; ///< Returns the error of decay length in XY + float_v GetErrLifeTime() const; ///< Returns the error of life time + float_v GetErrR() const; ///< Returns the error of distance to the origin of the coordinate system {0,0,0} + //* Accessors with calculations( &value, &estimated sigma ) + //* error flag returned (0 means no error during calculations) + + float_m GetP(float_v& P, float_v& SigmaP) const; //* momentum + float_m GetPt(float_v& Pt, float_v& SigmaPt) const; //* transverse momentum + float_m GetEta(float_v& Eta, float_v& SigmaEta) const; //* pseudorapidity + float_m GetPhi(float_v& Phi, float_v& SigmaPhi) const; //* phi + float_m GetMomentum(float_v& P, float_v& SigmaP) const; //* momentum + float_m GetMass(float_v& M, float_v& SigmaM) const; //* mass + float_m GetDecayLength(float_v& L, float_v& SigmaL) const; //* decay length + float_m GetDecayLengthXY(float_v& L, float_v& SigmaL) const; //* decay length in XY + float_m GetLifeTime(float_v& T, float_v& SigmaT) const; //* life time + float_m GetR(float_v& R, float_v& SigmaR) const; //* R //* //* MODIFIERS //* - - float_v & X () ; ///< Modifier of X coordinate of the particle, fP[0]. - float_v & Y () ; ///< Modifier of Y coordinate of the particle, fP[1]. - float_v & Z () ; ///< Modifier of Z coordinate of the particle, fP[2]. - float_v & Px () ; ///< Modifier of X component of the momentum, fP[3]. - float_v & Py () ; ///< Modifier of Y component of the momentum, fP[4]. - float_v & Pz () ; ///< Modifier of Z component of the momentum, fP[5]. - float_v & E () ; ///< Modifier of energy of the particle, fP[6]. - float_v & S () ; ///< Modifier of dS=l/p, l - decay length, fP[7], defined if production vertex is set. - int_v & Q () ; ///< Modifier of charge of the particle. - float_v & Chi2 () ; ///< Modifier of Chi2 of the fit. - int_v & NDF () ; ///< Modifier of number of decrease of freedom. - - float_v & Parameter ( int i ) ; ///< Modifier of P[i] parameter. - float_v & Covariance( int i ) ; ///< Modifier of C[i] element of the covariance matrix in the lower triangular form. - float_v & Covariance( int i, int j ) ; ///< Modifier of C[i,j] element of the covariance matrix. - float_v * Parameters () ; ///< Returns pointer to the parameters fP - float_v * CovarianceMatrix() ; ///< Returns pointer to the covariance matrix fC - - void GetKFParticle( KFParticle &Part, int iPart = 0); - void GetKFParticle( KFParticle *Part, int nPart = 0); - - //* + + float_v& X(); ///< Modifier of X coordinate of the particle, fP[0]. + float_v& Y(); ///< Modifier of Y coordinate of the particle, fP[1]. + float_v& Z(); ///< Modifier of Z coordinate of the particle, fP[2]. + float_v& Px(); ///< Modifier of X component of the momentum, fP[3]. + float_v& Py(); ///< Modifier of Y component of the momentum, fP[4]. + float_v& Pz(); ///< Modifier of Z component of the momentum, fP[5]. + float_v& E(); ///< Modifier of energy of the particle, fP[6]. + float_v& S(); ///< Modifier of dS=l/p, l - decay length, fP[7], defined if production vertex is set. + int_v& Q(); ///< Modifier of charge of the particle. + float_v& Chi2(); ///< Modifier of Chi2 of the fit. + int_v& NDF(); ///< Modifier of number of decrease of freedom. + + float_v& Parameter(int i); ///< Modifier of P[i] parameter. + float_v& Covariance(int i); ///< Modifier of C[i] element of the covariance matrix in the lower triangular form. + float_v& Covariance(int i, int j); ///< Modifier of C[i,j] element of the covariance matrix. + float_v* Parameters(); ///< Returns pointer to the parameters fP + float_v* CovarianceMatrix(); ///< Returns pointer to the covariance matrix fC + + void GetKFParticle(KFParticle& Part, int iPart = 0); + void GetKFParticle(KFParticle* Part, int nPart = 0); + + //* //* CONSTRUCTION OF THE PARTICLE BY ITS DAUGHTERS AND MOTHER //* USING THE KALMAN FILTER METHOD //* + //* Add daughter to the particle - //* Add daughter to the particle - - void AddDaughter( const KFParticleSIMD &Daughter ); + void AddDaughter(const KFParticleSIMD& Daughter); //* Add daughter via += operator: ex.{ D0; D0+=Pion; D0+= Kaon; } - void operator +=( const KFParticleSIMD &Daughter ); + void operator+=(const KFParticleSIMD& Daughter); - //* Everything in one go + //* Everything in one go - void Construct( const KFParticleSIMD *vDaughters[], int nDaughters, - const KFParticleSIMD *ProdVtx=0, Float_t Mass=-1 ); + void Construct(const KFParticleSIMD* vDaughters[], int nDaughters, + const KFParticleSIMD* ProdVtx = 0, Float_t Mass = -1); //* //* TRANSPORT - //* + //* //* ( main transportation parameter is S = SignedPath/Momentum ) //* ( parameters of decay & production vertices are stored locally ) //* - //* Transport the particle close to xyz[] point + //* Transport the particle close to xyz[] point - void TransportToPoint( const float_v xyz[] ); + void TransportToPoint(const float_v xyz[]); - //* Transport the particle close to VVertex + //* Transport the particle close to VVertex #ifdef HomogeneousField - void TransportToVertex( const KFPVertex &v ); + void TransportToVertex(const KFPVertex& v); #endif - //* Transport the particle close to another particle p + //* Transport the particle close to another particle p - void TransportToParticle( const KFParticleSIMD &p ); + void TransportToParticle(const KFParticleSIMD& p); - //* Get dS to a certain space point + //* Get dS to a certain space point - float_v GetDStoPoint( const float_v xyz[3], float_v dsdr[6] ) const ; - - //* Get dS to other particle p (dSp for particle p also returned) + float_v GetDStoPoint(const float_v xyz[3], float_v dsdr[6]) const; - void GetDStoParticle( const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] ) const ; - void GetDStoParticleFast( const KFParticleBaseSIMD &p, float_v dS[2] ) const ; - //* + //* Get dS to other particle p (dSp for particle p also returned) + + void GetDStoParticle(const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const; + void GetDStoParticleFast(const KFParticleBaseSIMD& p, float_v dS[2]) const; + //* //* OTHER UTILITIES //* - + //* Calculate distance from another object [cm] in XY-plane - float_m GetDistanceFromVertexXY( const float_v vtx[], float_v &val, float_v &err ) const ; - float_m GetDistanceFromVertexXY( const float_v vtx[], const float_v Cv[], float_v &val, float_v &err ) const ; - float_m GetDistanceFromVertexXY( const KFParticleSIMD &Vtx, float_v &val, float_v &err ) const ; + float_m GetDistanceFromVertexXY(const float_v vtx[], float_v& val, float_v& err) const; + float_m GetDistanceFromVertexXY(const float_v vtx[], const float_v Cv[], float_v& val, float_v& err) const; + float_m GetDistanceFromVertexXY(const KFParticleSIMD& Vtx, float_v& val, float_v& err) const; #ifdef HomogeneousField - float_m GetDistanceFromVertexXY( const KFPVertex &Vtx, float_v &val, float_v &err ) const ; + float_m GetDistanceFromVertexXY(const KFPVertex& Vtx, float_v& val, float_v& err) const; #endif - float_v GetDistanceFromVertexXY( const float_v vtx[] ) const ; - float_v GetDistanceFromVertexXY( const KFParticleSIMD &Vtx ) const ; + float_v GetDistanceFromVertexXY(const float_v vtx[]) const; + float_v GetDistanceFromVertexXY(const KFParticleSIMD& Vtx) const; #ifdef HomogeneousField - float_v GetDistanceFromVertexXY( const KFPVertex &Vtx ) const ; + float_v GetDistanceFromVertexXY(const KFPVertex& Vtx) const; #endif - float_v GetDistanceFromParticleXY( const KFParticleSIMD &p ) const ; + float_v GetDistanceFromParticleXY(const KFParticleSIMD& p) const; //* Calculate sqrt(Chi2/ndf) deviation from another object in XY plane //* ( v = [xyz]-vertex, Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix ) - float_v GetDeviationFromVertexXY( const float_v v[], const float_v Cv[]=0 ) const ; - float_v GetDeviationFromVertexXY( const KFParticleSIMD &Vtx ) const ; + float_v GetDeviationFromVertexXY(const float_v v[], const float_v Cv[] = 0) const; + float_v GetDeviationFromVertexXY(const KFParticleSIMD& Vtx) const; #ifdef HomogeneousField - float_v GetDeviationFromVertexXY( const KFPVertex &Vtx ) const ; + float_v GetDeviationFromVertexXY(const KFPVertex& Vtx) const; #endif - float_v GetDeviationFromParticleXY( const KFParticleSIMD &p ) const ; + float_v GetDeviationFromParticleXY(const KFParticleSIMD& p) const; //* Calculate opennig angle between two particles - float_v GetAngle ( const KFParticleSIMD &p ) const ; - float_v GetAngleXY( const KFParticleSIMD &p ) const ; - float_v GetAngleRZ( const KFParticleSIMD &p ) const ; - - // * Pseudo Proper Time of decay = (r*pt) / |pt| * M/|pt| - // @primVertex - primary vertex - // @mass - mass of the mother particle (in the case of "Hb -> JPsi" it would be JPsi mass) - // @*timeErr2 - squared error of the decay time. If timeErr2 = 0 it isn't calculated - float_v GetPseudoProperDecayTime( const KFParticleSIMD &primVertex, const float_v& mass, float_v* timeErr2 = 0 ) const; - - void GetFieldValue( const float_v xyz[], float_v B[] ) const ; - - void Transport( float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1=0, float_v* F=0, float_v* F1=0 ) const ; - void TransportFast( float_v dS, float_v P[] ) const ; - - protected: - + float_v GetAngle(const KFParticleSIMD& p) const; + float_v GetAngleXY(const KFParticleSIMD& p) const; + float_v GetAngleRZ(const KFParticleSIMD& p) const; + + // * Pseudo Proper Time of decay = (r*pt) / |pt| * M/|pt| + // @primVertex - primary vertex + // @mass - mass of the mother particle (in the case of "Hb -> JPsi" it would be JPsi mass) + // @*timeErr2 - squared error of the decay time. If timeErr2 = 0 it isn't calculated + float_v GetPseudoProperDecayTime(const KFParticleSIMD& primVertex, const float_v& mass, float_v* timeErr2 = 0) const; + + void GetFieldValue(const float_v xyz[], float_v B[]) const; + + void Transport(float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1 = 0, float_v* F = 0, float_v* F1 = 0) const; + void TransportFast(float_v dS, float_v P[]) const; + + protected: //* //* INTERNAL STUFF - //* + //* - //* Method to access ALICE field + //* Method to access ALICE field #ifdef HomogeneousField static float_v GetFieldAlice(); #endif - //* Other methods required by the abstract KFParticleBaseSIMD class - + //* Other methods required by the abstract KFParticleBaseSIMD class + private: #ifdef HomogeneousField - static float_v fgBz; ///< Bz compoment of the magnetic field (is defined in case of #ifdef HomogeneousField) + static float_v fgBz; ///< Bz compoment of the magnetic field (is defined in case of #ifdef HomogeneousField) #endif #ifdef NonhomogeneousField /** \brief Approximation of the magnetic field along the track trajectory. @@ -361,8 +358,6 @@ class KFParticleSIMD :public KFParticleBaseSIMD #endif }; - - //--------------------------------------------------------------------- // // Inline implementation of the KFParticleSIMD methods @@ -370,8 +365,8 @@ class KFParticleSIMD :public KFParticleBaseSIMD //--------------------------------------------------------------------- #ifdef HomogeneousField -inline void KFParticleSIMD::SetField( float_v Bz ) -{ +inline void KFParticleSIMD::SetField(float_v Bz) +{ /** Sets the constant homogemeous one-component magnetic field Bz (is defined in case of #ifdef HomogeneousField). ** \param[in] Bz - Z-component of the magnetic field **/ @@ -379,11 +374,12 @@ inline void KFParticleSIMD::SetField( float_v Bz ) } #endif -inline KFParticleSIMD::KFParticleSIMD( const KFParticleSIMD &d1, - const KFParticleSIMD &d2, - const KFParticleSIMD &d3 ): KFParticleBaseSIMD() +inline KFParticleSIMD::KFParticleSIMD(const KFParticleSIMD& d1, + const KFParticleSIMD& d2, + const KFParticleSIMD& d3) : KFParticleBaseSIMD() #ifdef NonhomogeneousField - , fField() + , + fField() #endif { /** Constructs a particle from three input daughter particles @@ -391,20 +387,21 @@ inline KFParticleSIMD::KFParticleSIMD( const KFParticleSIMD &d1, ** \param[in] d2 - the second daughter particle ** \param[in] d3 - the third daughter particle **/ - + KFParticleSIMD mother; - mother+= d1; - mother+= d2; - mother+= d3; + mother += d1; + mother += d2; + mother += d3; *this = mother; } -inline KFParticleSIMD::KFParticleSIMD( const KFParticleSIMD &d1, - const KFParticleSIMD &d2, - const KFParticleSIMD &d3, - const KFParticleSIMD &d4 ): KFParticleBaseSIMD() +inline KFParticleSIMD::KFParticleSIMD(const KFParticleSIMD& d1, + const KFParticleSIMD& d2, + const KFParticleSIMD& d3, + const KFParticleSIMD& d4) : KFParticleBaseSIMD() #ifdef NonhomogeneousField - , fField() + , + fField() #endif { /** Constructs a particle from four input daughter particles @@ -413,352 +410,350 @@ inline KFParticleSIMD::KFParticleSIMD( const KFParticleSIMD &d1, ** \param[in] d3 - the third daughter particle ** \param[in] d4 - the fourth daughter particle **/ - + KFParticleSIMD mother; - mother+= d1; - mother+= d2; - mother+= d3; - mother+= d4; + mother += d1; + mother += d2; + mother += d3; + mother += d4; *this = mother; } -inline float_v KFParticleSIMD::GetX () const -{ - return KFParticleBaseSIMD::GetX(); +inline float_v KFParticleSIMD::GetX() const +{ + return KFParticleBaseSIMD::GetX(); } -inline float_v KFParticleSIMD::GetY () const -{ - return KFParticleBaseSIMD::GetY(); +inline float_v KFParticleSIMD::GetY() const +{ + return KFParticleBaseSIMD::GetY(); } -inline float_v KFParticleSIMD::GetZ () const -{ - return KFParticleBaseSIMD::GetZ(); +inline float_v KFParticleSIMD::GetZ() const +{ + return KFParticleBaseSIMD::GetZ(); } -inline float_v KFParticleSIMD::GetPx () const -{ - return KFParticleBaseSIMD::GetPx(); +inline float_v KFParticleSIMD::GetPx() const +{ + return KFParticleBaseSIMD::GetPx(); } -inline float_v KFParticleSIMD::GetPy () const -{ - return KFParticleBaseSIMD::GetPy(); +inline float_v KFParticleSIMD::GetPy() const +{ + return KFParticleBaseSIMD::GetPy(); } -inline float_v KFParticleSIMD::GetPz () const -{ - return KFParticleBaseSIMD::GetPz(); +inline float_v KFParticleSIMD::GetPz() const +{ + return KFParticleBaseSIMD::GetPz(); } -inline float_v KFParticleSIMD::GetE () const -{ - return KFParticleBaseSIMD::GetE(); +inline float_v KFParticleSIMD::GetE() const +{ + return KFParticleBaseSIMD::GetE(); } -inline float_v KFParticleSIMD::GetS () const -{ - return KFParticleBaseSIMD::GetS(); +inline float_v KFParticleSIMD::GetS() const +{ + return KFParticleBaseSIMD::GetS(); } -inline int_v KFParticleSIMD::GetQ () const -{ - return KFParticleBaseSIMD::GetQ(); +inline int_v KFParticleSIMD::GetQ() const +{ + return KFParticleBaseSIMD::GetQ(); } -inline float_v KFParticleSIMD::GetChi2 () const -{ - return KFParticleBaseSIMD::GetChi2(); +inline float_v KFParticleSIMD::GetChi2() const +{ + return KFParticleBaseSIMD::GetChi2(); } -inline int_v KFParticleSIMD::GetNDF () const -{ - return KFParticleBaseSIMD::GetNDF(); +inline int_v KFParticleSIMD::GetNDF() const +{ + return KFParticleBaseSIMD::GetNDF(); } -inline float_v KFParticleSIMD::GetParameter ( int i ) const -{ - return KFParticleBaseSIMD::GetParameter(i); +inline float_v KFParticleSIMD::GetParameter(int i) const +{ + return KFParticleBaseSIMD::GetParameter(i); } -inline float_v KFParticleSIMD::GetCovariance( int i ) const -{ - return KFParticleBaseSIMD::GetCovariance(i); +inline float_v KFParticleSIMD::GetCovariance(int i) const +{ + return KFParticleBaseSIMD::GetCovariance(i); } -inline float_v KFParticleSIMD::GetCovariance( int i, int j ) const -{ - return KFParticleBaseSIMD::GetCovariance(i,j); +inline float_v KFParticleSIMD::GetCovariance(int i, int j) const +{ + return KFParticleBaseSIMD::GetCovariance(i, j); } - -inline float_v KFParticleSIMD::GetP () const +inline float_v KFParticleSIMD::GetP() const { float_v par, err; - KFParticleBaseSIMD::GetMomentum( par, err ); + KFParticleBaseSIMD::GetMomentum(par, err); return par; } -inline float_v KFParticleSIMD::GetPt () const +inline float_v KFParticleSIMD::GetPt() const { float_v par, err; - KFParticleBaseSIMD::GetPt( par, err ) ; + KFParticleBaseSIMD::GetPt(par, err); return par; } -inline float_v KFParticleSIMD::GetEta () const +inline float_v KFParticleSIMD::GetEta() const { float_v par, err; - KFParticleBaseSIMD::GetEta( par, err ); + KFParticleBaseSIMD::GetEta(par, err); return par; } -inline float_v KFParticleSIMD::GetPhi () const +inline float_v KFParticleSIMD::GetPhi() const { float_v par, err; - KFParticleSIMD::GetPhi( par, err ); + KFParticleSIMD::GetPhi(par, err); return par; } -inline float_v KFParticleSIMD::GetMomentum () const +inline float_v KFParticleSIMD::GetMomentum() const { float_v par, err; - KFParticleSIMD::GetMomentum( par, err ); + KFParticleSIMD::GetMomentum(par, err); return par; } -inline float_v KFParticleSIMD::GetMass () const +inline float_v KFParticleSIMD::GetMass() const { float_v par, err; - KFParticleSIMD::GetMass( par, err ); + KFParticleSIMD::GetMass(par, err); return par; } -inline float_v KFParticleSIMD::GetDecayLength () const +inline float_v KFParticleSIMD::GetDecayLength() const { float_v par, err; - KFParticleSIMD::GetDecayLength( par, err ); + KFParticleSIMD::GetDecayLength(par, err); return par; } -inline float_v KFParticleSIMD::GetDecayLengthXY () const +inline float_v KFParticleSIMD::GetDecayLengthXY() const { float_v par, err; - KFParticleSIMD::GetDecayLengthXY( par, err ); + KFParticleSIMD::GetDecayLengthXY(par, err); return par; } -inline float_v KFParticleSIMD::GetLifeTime () const +inline float_v KFParticleSIMD::GetLifeTime() const { float_v par, err; - KFParticleSIMD::GetLifeTime( par, err ); + KFParticleSIMD::GetLifeTime(par, err); return par; } -inline float_v KFParticleSIMD::GetR () const +inline float_v KFParticleSIMD::GetR() const { float_v par, err; - KFParticleSIMD::GetR( par, err ); + KFParticleSIMD::GetR(par, err); return par; } -inline float_v KFParticleSIMD::GetErrX () const +inline float_v KFParticleSIMD::GetErrX() const { - return sqrt(abs( GetCovariance(0,0) )); + return sqrt(abs(GetCovariance(0, 0))); } -inline float_v KFParticleSIMD::GetErrY () const +inline float_v KFParticleSIMD::GetErrY() const { - return sqrt(abs( GetCovariance(1,1) )); + return sqrt(abs(GetCovariance(1, 1))); } -inline float_v KFParticleSIMD::GetErrZ () const +inline float_v KFParticleSIMD::GetErrZ() const { - return sqrt(abs( GetCovariance(2,2) )); + return sqrt(abs(GetCovariance(2, 2))); } -inline float_v KFParticleSIMD::GetErrPx () const +inline float_v KFParticleSIMD::GetErrPx() const { - return sqrt(abs( GetCovariance(3,3) )); + return sqrt(abs(GetCovariance(3, 3))); } -inline float_v KFParticleSIMD::GetErrPy () const +inline float_v KFParticleSIMD::GetErrPy() const { - return sqrt(abs( GetCovariance(4,4) )); + return sqrt(abs(GetCovariance(4, 4))); } -inline float_v KFParticleSIMD::GetErrPz () const +inline float_v KFParticleSIMD::GetErrPz() const { - return sqrt(abs( GetCovariance(5,5) )); + return sqrt(abs(GetCovariance(5, 5))); } -inline float_v KFParticleSIMD::GetErrE () const +inline float_v KFParticleSIMD::GetErrE() const { - return sqrt(abs( GetCovariance(6,6) )); + return sqrt(abs(GetCovariance(6, 6))); } -inline float_v KFParticleSIMD::GetErrS () const +inline float_v KFParticleSIMD::GetErrS() const { - return sqrt(abs( GetCovariance(7,7) )); + return sqrt(abs(GetCovariance(7, 7))); } -inline float_v KFParticleSIMD::GetErrP () const +inline float_v KFParticleSIMD::GetErrP() const { float_v par, err; - float_m mask = KFParticleSIMD::GetMomentum( par, err ); + float_m mask = KFParticleSIMD::GetMomentum(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } -inline float_v KFParticleSIMD::GetErrPt () const +inline float_v KFParticleSIMD::GetErrPt() const { float_v par, err; - float_m mask = KFParticleSIMD::GetPt( par, err ); + float_m mask = KFParticleSIMD::GetPt(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } -inline float_v KFParticleSIMD::GetErrEta () const +inline float_v KFParticleSIMD::GetErrEta() const { float_v par, err; - float_m mask = KFParticleSIMD::GetEta( par, err ); + float_m mask = KFParticleSIMD::GetEta(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } -inline float_v KFParticleSIMD::GetErrPhi () const +inline float_v KFParticleSIMD::GetErrPhi() const { float_v par, err; - float_m mask = KFParticleSIMD::GetPhi( par, err ); + float_m mask = KFParticleSIMD::GetPhi(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } -inline float_v KFParticleSIMD::GetErrMomentum () const +inline float_v KFParticleSIMD::GetErrMomentum() const { float_v par, err; - float_m mask = KFParticleSIMD::GetMomentum( par, err ); + float_m mask = KFParticleSIMD::GetMomentum(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } -inline float_v KFParticleSIMD::GetErrMass () const +inline float_v KFParticleSIMD::GetErrMass() const { float_v par, err; - float_m mask = KFParticleSIMD::GetMass( par, err ); + float_m mask = KFParticleSIMD::GetMass(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } -inline float_v KFParticleSIMD::GetErrDecayLength () const +inline float_v KFParticleSIMD::GetErrDecayLength() const { float_v par, err; - float_m mask = KFParticleSIMD::GetDecayLength( par, err ); + float_m mask = KFParticleSIMD::GetDecayLength(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } -inline float_v KFParticleSIMD::GetErrDecayLengthXY () const +inline float_v KFParticleSIMD::GetErrDecayLengthXY() const { float_v par, err; - float_m mask = KFParticleSIMD::GetDecayLengthXY( par, err ); + float_m mask = KFParticleSIMD::GetDecayLengthXY(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } -inline float_v KFParticleSIMD::GetErrLifeTime () const +inline float_v KFParticleSIMD::GetErrLifeTime() const { float_v par, err; - float_m mask = KFParticleSIMD::GetLifeTime( par, err ); + float_m mask = KFParticleSIMD::GetLifeTime(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } -inline float_v KFParticleSIMD::GetErrR () const +inline float_v KFParticleSIMD::GetErrR() const { float_v par, err; - float_m mask = KFParticleSIMD::GetR( par, err ); + float_m mask = KFParticleSIMD::GetR(par, err); float_v ret(1.e10f); ret(!mask) = err; return ret; } - -inline float_m KFParticleSIMD::GetP( float_v &P, float_v &SigmaP ) const +inline float_m KFParticleSIMD::GetP(float_v& P, float_v& SigmaP) const { /** Calculates particle momentum and its error. If they are well defined returns 0, otherwise 1. ** \param[out] P - momentum of the particle ** \param[out] SigmaP - its error **/ - return KFParticleBaseSIMD::GetMomentum( P, SigmaP ); + return KFParticleBaseSIMD::GetMomentum(P, SigmaP); } -inline float_m KFParticleSIMD::GetPt( float_v &Pt, float_v &SigmaPt ) const +inline float_m KFParticleSIMD::GetPt(float_v& Pt, float_v& SigmaPt) const { /** Calculates particle transverse momentum and its error. If they are well defined returns 0, otherwise 1. ** \param[out] Pt - transverse momentum of the particle ** \param[out] SigmaPt - its error **/ - return KFParticleBaseSIMD::GetPt( Pt, SigmaPt ); + return KFParticleBaseSIMD::GetPt(Pt, SigmaPt); } -inline float_m KFParticleSIMD::GetEta( float_v &Eta, float_v &SigmaEta ) const +inline float_m KFParticleSIMD::GetEta(float_v& Eta, float_v& SigmaEta) const { /** Calculates particle pseudorapidity and its error. If they are well defined returns 0, otherwise 1. ** \param[out] Eta - pseudorapidity of the particle ** \param[out] SigmaEta - its error **/ - return KFParticleBaseSIMD::GetEta( Eta, SigmaEta ); + return KFParticleBaseSIMD::GetEta(Eta, SigmaEta); } -inline float_m KFParticleSIMD::GetPhi( float_v &Phi, float_v &SigmaPhi ) const +inline float_m KFParticleSIMD::GetPhi(float_v& Phi, float_v& SigmaPhi) const { /** Calculates particle polar angle at the current point and its error. If they are well defined returns 0, otherwise 1. ** \param[out] Phi - polar angle of the particle ** \param[out] SigmaPhi - its error **/ - return KFParticleBaseSIMD::GetPhi( Phi, SigmaPhi ); + return KFParticleBaseSIMD::GetPhi(Phi, SigmaPhi); } -inline float_m KFParticleSIMD::GetMomentum( float_v &P, float_v &SigmaP ) const +inline float_m KFParticleSIMD::GetMomentum(float_v& P, float_v& SigmaP) const { /** Calculates particle momentum and its error. If they are well defined returns 0, otherwise 1. ** \param[out] P - momentum of the particle ** \param[out] SigmaP - its error **/ - return KFParticleBaseSIMD::GetMomentum( P, SigmaP ); + return KFParticleBaseSIMD::GetMomentum(P, SigmaP); } -inline float_m KFParticleSIMD::GetMass( float_v &M, float_v &SigmaM ) const +inline float_m KFParticleSIMD::GetMass(float_v& M, float_v& SigmaM) const { /** Calculates the mass of the particle and its error. If they are well defined returns 0, otherwise 1. ** \param[out] M - mass of the particle ** \param[out] SigmaM - its error **/ - return KFParticleBaseSIMD::GetMass( M, SigmaM ); + return KFParticleBaseSIMD::GetMass(M, SigmaM); } -inline float_m KFParticleSIMD::GetDecayLength( float_v &L, float_v &SigmaL ) const +inline float_m KFParticleSIMD::GetDecayLength(float_v& L, float_v& SigmaL) const { /** Calculates the decay length of the particle in the laboratory system and its error. If they are well defined returns 0, otherwise 1. ** The production point should be set before calling this function. ** \param[out] L - the decay length ** \param[out] SigmaL - its error **/ - return KFParticleBaseSIMD::GetDecayLength( L, SigmaL ); + return KFParticleBaseSIMD::GetDecayLength(L, SigmaL); } -inline float_m KFParticleSIMD::GetDecayLengthXY( float_v &L, float_v &SigmaL ) const +inline float_m KFParticleSIMD::GetDecayLengthXY(float_v& L, float_v& SigmaL) const { /** Calculates the projection in the XY plane of the decay length of the particle in the laboratory ** system and its error. If they are well defined returns 0, otherwise 1. @@ -766,10 +761,10 @@ inline float_m KFParticleSIMD::GetDecayLengthXY( float_v &L, float_v &SigmaL ) c ** \param[out] L - the decay length ** \param[out] SigmaL - its error **/ - return KFParticleBaseSIMD::GetDecayLengthXY( L, SigmaL ); + return KFParticleBaseSIMD::GetDecayLengthXY(L, SigmaL); } -inline float_m KFParticleSIMD::GetLifeTime( float_v &T, float_v &SigmaT ) const +inline float_m KFParticleSIMD::GetLifeTime(float_v& T, float_v& SigmaT) const { /** Calculates the lifetime times speed of life (ctau) [cm] of the particle in the ** center of mass frame and its error. If they are well defined returns 0, otherwise 1. @@ -777,100 +772,99 @@ inline float_m KFParticleSIMD::GetLifeTime( float_v &T, float_v &SigmaT ) const ** \param[out] T - lifetime of the particle [cm] ** \param[out] SigmaT - its error **/ - return KFParticleBaseSIMD::GetLifeTime( T, SigmaT ); + return KFParticleBaseSIMD::GetLifeTime(T, SigmaT); } -inline float_m KFParticleSIMD::GetR( float_v &R, float_v &SigmaR ) const +inline float_m KFParticleSIMD::GetR(float_v& R, float_v& SigmaR) const { /** Calculates the distance to the point {0,0,0} and its error. If they are well defined returns 0, otherwise 1. ** \param[out] R - polar angle of the particle ** \param[out] SigmaR - its error **/ - return KFParticleBaseSIMD::GetR( R, SigmaR ); + return KFParticleBaseSIMD::GetR(R, SigmaR); } -inline float_v & KFParticleSIMD::X() -{ - return KFParticleBaseSIMD::X(); +inline float_v& KFParticleSIMD::X() +{ + return KFParticleBaseSIMD::X(); } -inline float_v & KFParticleSIMD::Y() -{ - return KFParticleBaseSIMD::Y(); +inline float_v& KFParticleSIMD::Y() +{ + return KFParticleBaseSIMD::Y(); } -inline float_v & KFParticleSIMD::Z() -{ - return KFParticleBaseSIMD::Z(); +inline float_v& KFParticleSIMD::Z() +{ + return KFParticleBaseSIMD::Z(); } -inline float_v & KFParticleSIMD::Px() -{ - return KFParticleBaseSIMD::Px(); +inline float_v& KFParticleSIMD::Px() +{ + return KFParticleBaseSIMD::Px(); } -inline float_v & KFParticleSIMD::Py() -{ - return KFParticleBaseSIMD::Py(); +inline float_v& KFParticleSIMD::Py() +{ + return KFParticleBaseSIMD::Py(); } -inline float_v & KFParticleSIMD::Pz() -{ - return KFParticleBaseSIMD::Pz(); +inline float_v& KFParticleSIMD::Pz() +{ + return KFParticleBaseSIMD::Pz(); } -inline float_v & KFParticleSIMD::E() -{ - return KFParticleBaseSIMD::E(); +inline float_v& KFParticleSIMD::E() +{ + return KFParticleBaseSIMD::E(); } -inline float_v & KFParticleSIMD::S() -{ - return KFParticleBaseSIMD::S(); +inline float_v& KFParticleSIMD::S() +{ + return KFParticleBaseSIMD::S(); } -inline int_v & KFParticleSIMD::Q() -{ - return KFParticleBaseSIMD::Q(); +inline int_v& KFParticleSIMD::Q() +{ + return KFParticleBaseSIMD::Q(); } -inline float_v & KFParticleSIMD::Chi2() -{ - return KFParticleBaseSIMD::Chi2(); +inline float_v& KFParticleSIMD::Chi2() +{ + return KFParticleBaseSIMD::Chi2(); } -inline int_v & KFParticleSIMD::NDF() -{ - return KFParticleBaseSIMD::NDF(); +inline int_v& KFParticleSIMD::NDF() +{ + return KFParticleBaseSIMD::NDF(); } -inline float_v & KFParticleSIMD::Parameter ( int i ) -{ +inline float_v& KFParticleSIMD::Parameter(int i) +{ return KFParticleBaseSIMD::Parameter(i); } -inline float_v & KFParticleSIMD::Covariance( int i ) -{ +inline float_v& KFParticleSIMD::Covariance(int i) +{ return KFParticleBaseSIMD::Covariance(i); } -inline float_v & KFParticleSIMD::Covariance( int i, int j ) -{ - return KFParticleBaseSIMD::Covariance(i,j); +inline float_v& KFParticleSIMD::Covariance(int i, int j) +{ + return KFParticleBaseSIMD::Covariance(i, j); } -inline float_v * KFParticleSIMD::Parameters () +inline float_v* KFParticleSIMD::Parameters() { return fP; } -inline float_v * KFParticleSIMD::CovarianceMatrix() +inline float_v* KFParticleSIMD::CovarianceMatrix() { return fC; } - -inline void KFParticleSIMD::operator +=( const KFParticleSIMD &Daughter ) +inline void KFParticleSIMD::operator+=(const KFParticleSIMD& Daughter) { /** Operator to add daughter to the current particle. Calls AddDaughter() function. ** \param[in] Daughter - the daughter particle @@ -878,11 +872,10 @@ inline void KFParticleSIMD::operator +=( const KFParticleSIMD &Daughter ) #ifdef NonhomogeneousField fField = Daughter.fField; #endif - KFParticleBaseSIMD::operator +=( Daughter ); + KFParticleBaseSIMD::operator+=(Daughter); } - -inline void KFParticleSIMD::AddDaughter( const KFParticleSIMD &Daughter ) +inline void KFParticleSIMD::AddDaughter(const KFParticleSIMD& Daughter) { /** Adds daughter to the current particle. Depending on the selected construction method uses: \n ** 1) Either simplifyed fast mathematics which consideres momentum and energy as @@ -899,11 +892,11 @@ inline void KFParticleSIMD::AddDaughter( const KFParticleSIMD &Daughter ) #ifdef NonhomogeneousField fField = Daughter.fField; #endif - KFParticleBaseSIMD::AddDaughter( Daughter ); + KFParticleBaseSIMD::AddDaughter(Daughter); } -inline void KFParticleSIMD::Construct( const KFParticleSIMD *vDaughters[], int nDaughters, - const KFParticleSIMD *ProdVtx, Float_t Mass ) +inline void KFParticleSIMD::Construct(const KFParticleSIMD* vDaughters[], int nDaughters, + const KFParticleSIMD* ProdVtx, Float_t Mass) { /** Constructs a short-lived particle from a set of daughter particles:\n ** 1) all parameters of the "this" objects are initialised;\n @@ -914,45 +907,45 @@ inline void KFParticleSIMD::Construct( const KFParticleSIMD *vDaughters[], int n ** \param[in] nDaughters - number of daughter particles in the input array ** \param[in] Parent - optional parrent particle ** \param[in] Mass - optional mass hypothesis - **/ + **/ #ifdef NonhomogeneousField fField = vDaughters[0]->fField; #endif - KFParticleBaseSIMD::Construct( ( const KFParticleBaseSIMD**)vDaughters, nDaughters, - ( const KFParticleBaseSIMD*)ProdVtx, Mass ); + KFParticleBaseSIMD::Construct((const KFParticleBaseSIMD**)vDaughters, nDaughters, + (const KFParticleBaseSIMD*)ProdVtx, Mass); } -inline void KFParticleSIMD::TransportToPoint( const float_v xyz[] ) +inline void KFParticleSIMD::TransportToPoint(const float_v xyz[]) { /** Transports particle to the distance of closest approach to the point xyz. ** \param[in] xyz[3] - point, where particle should be transported **/ - - float_v dsdr[6] = {0.f,0.f,0.f,0.f,0.f,0.f}; + + float_v dsdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; const float_v dS = GetDStoPoint(xyz, dsdr); - TransportToDS( dS, dsdr ); + TransportToDS(dS, dsdr); } #ifdef HomogeneousField -inline void KFParticleSIMD::TransportToVertex( const KFPVertex &v ) +inline void KFParticleSIMD::TransportToVertex(const KFPVertex& v) { /** Transports particle to the distance of closest approach to the vertex v. ** \param[in] v - vertex, where particle should be transported **/ - TransportToPoint( KFParticleSIMD(v).fP ); + TransportToPoint(KFParticleSIMD(v).fP); } #endif -inline void KFParticleSIMD::TransportToParticle( const KFParticleSIMD &p ) -{ +inline void KFParticleSIMD::TransportToParticle(const KFParticleSIMD& p) +{ /** Transports particle to the distance of closest approach to the particle p. ** \param[in] p - particle, to which the current particle should be transported. **/ float_v dsdr[4][6]; float_v dS[2]; - GetDStoParticle( p, dS, dsdr ); - TransportToDS( dS[0], dsdr[0] ); + GetDStoParticle(p, dS, dsdr); + TransportToDS(dS[0], dsdr[0]); } -inline float_v KFParticleSIMD::GetDStoPoint( const float_v xyz[3], float_v dsdr[6] ) const +inline float_v KFParticleSIMD::GetDStoPoint(const float_v xyz[3], float_v dsdr[6]) const { /** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n @@ -966,37 +959,36 @@ inline float_v KFParticleSIMD::GetDStoPoint( const float_v xyz[3], float_v dsdr[ ** to other coordinate system (see GetDStoPointBy() function), otherwise fP are used **/ #ifdef HomogeneousField - return KFParticleBaseSIMD::GetDStoPointBz( GetFieldAlice(), xyz, dsdr ); + return KFParticleBaseSIMD::GetDStoPointBz(GetFieldAlice(), xyz, dsdr); #endif #ifdef NonhomogeneousField - return KFParticleBaseSIMD::GetDStoPointCBM( xyz, dsdr ); + return KFParticleBaseSIMD::GetDStoPointCBM(xyz, dsdr); #endif } - #ifdef HomogeneousField inline float_v KFParticleSIMD::GetFieldAlice() -{ +{ /** Returns value of the constant homogemeous one-component magnetic field Bz, (is defined in case of #ifdef HomogeneousField). */ - return fgBz; + return fgBz; } #endif #ifdef HomogeneousField -inline void KFParticleSIMD::GetFieldValue( const float_v * /*xyz*/, float_v B[] ) const -{ +inline void KFParticleSIMD::GetFieldValue(const float_v* /*xyz*/, float_v B[]) const +{ /** Calculates the Bx, By, Bz components at the point xyz using approximation of the ** magnetic field along the particle trajectory. ** \param[in] xyz[3] - X, Y, Z coordiantes of the point where the magnetic field should be calculated ** \param[out] B[3] - value of X, Y, Z components of the calculated magnetic field at the given point - **/ + **/ B[0] = B[1] = 0; B[2] = GetFieldAlice(); } #endif #ifdef NonhomogeneousField -inline void KFParticleSIMD::GetFieldValue( const float_v xyz[], float_v B[] ) const +inline void KFParticleSIMD::GetFieldValue(const float_v xyz[], float_v B[]) const { /** Calculates the Bx, By, Bz components at the point xyz using approximation of the ** magnetic field along the particle trajectory. @@ -1010,7 +1002,7 @@ inline void KFParticleSIMD::GetFieldValue( const float_v xyz[], float_v B[] ) co } #endif -inline void KFParticleSIMD::GetDStoParticle( const KFParticleBaseSIMD &p, float_v dS[2], float_v dsdr[4][6] )const +inline void KFParticleSIMD::GetDStoParticle(const KFParticleBaseSIMD& p, float_v dS[2], float_v dsdr[4][6]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -1029,14 +1021,14 @@ inline void KFParticleSIMD::GetDStoParticle( const KFParticleBaseSIMD &p, float_ ** \param[out] dsdr[4][6] - partial derivatives of the parameters dS[0] and dS[1] over the state vectors of the both particles **/ #ifdef HomogeneousField - KFParticleBaseSIMD::GetDStoParticleBz( GetFieldAlice(), p, dS, dsdr ) ; + KFParticleBaseSIMD::GetDStoParticleBz(GetFieldAlice(), p, dS, dsdr); #endif #ifdef NonhomogeneousField - KFParticleBaseSIMD::GetDStoParticleCBM( p, dS, dsdr ) ; + KFParticleBaseSIMD::GetDStoParticleCBM(p, dS, dsdr); #endif } -inline void KFParticleSIMD::GetDStoParticleFast( const KFParticleBaseSIMD &p, float_v dS[2] )const +inline void KFParticleSIMD::GetDStoParticleFast(const KFParticleBaseSIMD& p, float_v dS[2]) const { /** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n @@ -1048,14 +1040,14 @@ inline void KFParticleSIMD::GetDStoParticleFast( const KFParticleBaseSIMD &p, fl ** \param[out] dS[2] - transport parameters dS for the current particle (dS[0]) and the second particle "p" (dS[1]) **/ #ifdef HomogeneousField - KFParticleBaseSIMD::GetDStoParticleBz( GetFieldAlice(), p, dS ) ; + KFParticleBaseSIMD::GetDStoParticleBz(GetFieldAlice(), p, dS); #endif #ifdef NonhomogeneousField - KFParticleBaseSIMD::GetDStoParticleCBM( p, dS ) ; + KFParticleBaseSIMD::GetDStoParticleCBM(p, dS); #endif } -inline void KFParticleSIMD::Transport( float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1, float_v* F, float_v* F1 ) const +inline void KFParticleSIMD::Transport(float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1, float_v* F, float_v* F1) const { /** Transports the parameters and their covariance matrix of the current particle ** on a length defined by the transport parameter dS = l/p, where l is the signed distance and p is @@ -1078,16 +1070,16 @@ inline void KFParticleSIMD::Transport( float_v dS, const float_v* dsdr, float_v ** \param[out] F[36] - optional parameter, transport jacobian, 6x6 matrix F = d(fP new)/d(fP old) ** \param[out] F1[36] - optional parameter, corelation 6x6 matrix betweeen the current particle and particle or vertex ** with the state vector r1, to which the current particle is being transported, F1 = d(fP new)/d(r1) - **/ + **/ #ifdef HomogeneousField - KFParticleBaseSIMD::TransportBz( GetFieldAlice(), dS, dsdr, P, C, dsdr1, F, F1 ); + KFParticleBaseSIMD::TransportBz(GetFieldAlice(), dS, dsdr, P, C, dsdr1, F, F1); #endif #ifdef NonhomogeneousField - KFParticleBaseSIMD::TransportCBM( dS, dsdr, P, C, dsdr1, F, F1 ); + KFParticleBaseSIMD::TransportCBM(dS, dsdr, P, C, dsdr1, F, F1); #endif } -inline void KFParticleSIMD::TransportFast( float_v dS, float_v P[] ) const +inline void KFParticleSIMD::TransportFast(float_v dS, float_v P[]) const { /** Transports the parametersof the current particle ** on a length defined by the transport parameter dS = l/p, where l is the signed distance and p is @@ -1098,13 +1090,13 @@ inline void KFParticleSIMD::TransportFast( float_v dS, float_v P[] ) const ** case the particle parameters will be modified. ** \param[in] dS - transport parameter which defines the distance to which particle should be transported ** \param[out] P[8] - array, where transported parameters should be stored - **/ + **/ #ifdef HomogeneousField - KFParticleBaseSIMD::TransportBz( GetFieldAlice(), dS, P ); + KFParticleBaseSIMD::TransportBz(GetFieldAlice(), dS, P); #endif #ifdef NonhomogeneousField - KFParticleBaseSIMD::TransportCBM( dS, P ); + KFParticleBaseSIMD::TransportCBM(dS, P); #endif } -#endif +#endif diff --git a/KFParticle/KFParticleTopoReconstructor.cxx b/KFParticle/KFParticleTopoReconstructor.cxx index ea33757..ae46976 100644 --- a/KFParticle/KFParticleTopoReconstructor.cxx +++ b/KFParticle/KFParticleTopoReconstructor.cxx @@ -19,7 +19,6 @@ * along with this program. If not, see . */ - #include "KFParticleTopoReconstructor.h" #ifdef KFPWITHTRACKER @@ -32,8 +31,8 @@ #include #include #include "string" -using std::string; using std::ofstream; +using std::string; using std::vector; #include "KFPInputData.h" @@ -41,9 +40,12 @@ using std::vector; KFParticleTopoReconstructor::~KFParticleTopoReconstructor() { /** The default destructor. Deallocates memory for all pointers if objects exist. **/ - if (fKFParticlePVReconstructor) delete fKFParticlePVReconstructor; - if (fKFParticleFinder) delete fKFParticleFinder; - if(fTracks) delete [] fTracks; + if (fKFParticlePVReconstructor) + delete fKFParticlePVReconstructor; + if (fKFParticleFinder) + delete fKFParticleFinder; + if (fTracks) + delete[] fTracks; } #ifdef HomogeneousField @@ -58,7 +60,7 @@ void KFParticleTopoReconstructor::SetField(double b) #ifdef KFPWITHTRACKER void KFParticleTopoReconstructor::Init(AliHLTTPCCAGBTracker* tracker, vector* pdg) { - if(!fTracks) + if (!fTracks) fTracks = new KFPTrackVector[NInputSets]; fTracks[0].Resize(0); @@ -69,67 +71,64 @@ void KFParticleTopoReconstructor::Init(AliHLTTPCCAGBTracker* tracker, vectorSlice(0).Param().Bz() ); - KFParticleSIMD::SetField( tracker->Slice(0).Param().Bz() ); + KFParticle::SetField(tracker->Slice(0).Param().Bz()); + KFParticleSIMD::SetField(tracker->Slice(0).Param().Bz()); - // create and fill array of tracks to init KFParticleTopoReconstructor + // create and fill array of tracks to init KFParticleTopoReconstructor const int nTracks = tracker->NTracks(); - fTracks[1].Resize( int(nTracks/float_vLen+1)*float_vLen ); - fTracks[5].Resize( int(nTracks/float_vLen+1)*float_vLen ); + fTracks[1].Resize(int(nTracks / float_vLen + 1) * float_vLen); + fTracks[5].Resize(int(nTracks / float_vLen + 1) * float_vLen); fParticles.clear(); int iOTr = 0; // index in out array - + float_v alpha(Vc::Zero); - int nElements=0; - - for ( int iTr = 0; iTr < nTracks; iTr++ ) { - // get track params in local CS - + int nElements = 0; + + for (int iTr = 0; iTr < nTracks; iTr++) { + // get track params in local CS + bool ok = true; - const int q = -(tracker->Tracks()[ iTr ].InnerParam().QPt()>=0 ? 1 : -1); - - for(int iParamSet=0; iParamSet<2; iParamSet++) - { + const int q = -(tracker->Tracks()[iTr].InnerParam().QPt() >= 0 ? 1 : -1); + + for (int iParamSet = 0; iParamSet < 2; iParamSet++) { AliHLTTPCCATrackParam trParam; int arrayIndex = -1; - if(iParamSet==0) - { + if (iParamSet == 0) { arrayIndex = 1; - trParam = tracker->Tracks()[ iTr ].InnerParam(); + trParam = tracker->Tracks()[iTr].InnerParam(); } - if(iParamSet==1) - { + if (iParamSet == 1) { arrayIndex = 5; - trParam = tracker->Tracks()[ iTr ].OuterParam(); + trParam = tracker->Tracks()[iTr].OuterParam(); } - + const float x0 = 0; - trParam.TransportToXWithMaterial( x0, tracker->Slice(0).Param().cBz( ) ); + trParam.TransportToXWithMaterial(x0, tracker->Slice(0).Param().cBz()); - // -- convert parameters + // -- convert parameters fTracks[arrayIndex].SetParameter(trParam.X(), 0, iOTr); // X fTracks[arrayIndex].SetParameter(trParam.Y(), 1, iOTr); // Y fTracks[arrayIndex].SetParameter(trParam.Z(), 2, iOTr); // Z - const float pt = CAMath::Abs( 1.f / trParam.QPt() ); -// const int q = -(trParam.QPt()>=0 ? 1 : -1); - // if ( pt < 1 ) continue; // dbg - ok = ok && !( trParam.NDF() < 10+5); //if ( trParam.NDF() < 10+5 ) continue; // at least 15 hits in track - ok = ok && !( trParam.Chi2() > 10*trParam.NDF() ); //if ( trParam.Chi2() > 10*trParam.NDF() ) continue; // dbg - // if ( iOTr >= 4 ) continue; // dbg - + const float pt = CAMath::Abs(1.f / trParam.QPt()); + // const int q = -(trParam.QPt()>=0 ? 1 : -1); + // if ( pt < 1 ) continue; // dbg + ok = ok && !(trParam.NDF() < 10 + 5); //if ( trParam.NDF() < 10+5 ) continue; // at least 15 hits in track + ok = ok && !(trParam.Chi2() > 10 * trParam.NDF()); //if ( trParam.Chi2() > 10*trParam.NDF() ) continue; // dbg + // if ( iOTr >= 4 ) continue; // dbg + const float cosL = trParam.DzDs(); fTracks[arrayIndex].SetParameter(pt * trParam.GetCosPhi(), 3, iOTr); // Px - fTracks[arrayIndex].SetParameter(pt * trParam.SinPhi() , 4, iOTr); // Py - fTracks[arrayIndex].SetParameter(pt * cosL , 5, iOTr); // Pz - - // -- convert cov matrix - // get jacobian + fTracks[arrayIndex].SetParameter(pt * trParam.SinPhi(), 4, iOTr); // Py + fTracks[arrayIndex].SetParameter(pt * cosL, 5, iOTr); // Pz + + // -- convert cov matrix + // get jacobian float J[6][6]; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) @@ -139,14 +138,14 @@ void KFParticleTopoReconstructor::Init(AliHLTTPCCAGBTracker* tracker, vector z J[3][3] = -pt * trParam.SinPhi() / trParam.GetCosPhi(); J[3][5] = -q * pt * pt * trParam.GetCosPhi(); // q/pt -> px - J[4][3] = pt; // sinPhi -> py - J[4][5] = -q* pt * pt * trParam.SinPhi(); // q/pt -> py - J[5][4] = pt; // dz/ds -> pz - J[5][5] = -q* pt * pt * cosL; // q/pt -> pz + J[4][3] = pt; // sinPhi -> py + J[4][5] = -q * pt * pt * trParam.SinPhi(); // q/pt -> py + J[5][4] = pt; // dz/ds -> pz + J[5][5] = -q * pt * pt * cosL; // q/pt -> pz float CovIn[6][6]; // triangular -> symmetric matrix { - CovIn[0][0] = .001f*.001f; // dx. From nowhere. TODO + CovIn[0][0] = .001f * .001f; // dx. From nowhere. TODO for (int i = 1; i < 6; i++) { CovIn[i][0] = 0; CovIn[0][i] = 0; @@ -159,8 +158,8 @@ void KFParticleTopoReconstructor::Init(AliHLTTPCCAGBTracker* tracker, vector 0 ); + ok &= (KFPCov[k - 1] > 0); } } - - if(ok) - { - int trackPDG = -1; - if(pdg) + + if (ok) { + int trackPDG = -1; + if (pdg) trackPDG = (*pdg)[iTr]; - - for(int iC=0; iC<21; iC++) - fTracks[arrayIndex].SetCovariance( KFPCov[iC], iC, iOTr); + + for (int iC = 0; iC < 21; iC++) + fTracks[arrayIndex].SetCovariance(KFPCov[iC], iC, iOTr); fTracks[arrayIndex].SetId(iTr, iOTr); fTracks[arrayIndex].SetPDG(trackPDG, iOTr); fTracks[arrayIndex].SetQ(q, iOTr); fTracks[arrayIndex].SetPVIndex(-1, iOTr); } } - if (!ok) continue; - + if (!ok) + continue; + iOTr++; - + // convert into Global CS. Can't be done erlier because in tracker X hasn't correspondent covMatrix elements. - alpha[nElements] = tracker->Tracks()[ iTr ].Alpha(); + alpha[nElements] = tracker->Tracks()[iTr].Alpha(); nElements++; - if(nElements == float_vLen) - { - fTracks[1].RotateXY( alpha, iOTr-nElements); - fTracks[5].RotateXY( alpha, iOTr-nElements); - nElements=0; + if (nElements == float_vLen) { + fTracks[1].RotateXY(alpha, iOTr - nElements); + fTracks[5].RotateXY(alpha, iOTr - nElements); + nElements = 0; } } - if(nElements>0) - { - fTracks[1].RotateXY( alpha, iOTr-nElements); - fTracks[5].RotateXY( alpha, iOTr-nElements); + if (nElements > 0) { + fTracks[1].RotateXY(alpha, iOTr - nElements); + fTracks[5].RotateXY(alpha, iOTr - nElements); } - + fTracks[0].Resize(iOTr); - fTracks[0].Set(fTracks[1],iOTr,0); + fTracks[0].Set(fTracks[1], iOTr, 0); fTracks[4].Resize(iOTr); - fTracks[4].Set(fTracks[5],iOTr,0); - - fKFParticlePVReconstructor->Init( &fTracks[0], iOTr ); + fTracks[4].Set(fTracks[5], iOTr, 0); + + fKFParticlePVReconstructor->Init(&fTracks[0], iOTr); #ifdef USE_TIMERS timer.Stop(); fStatTime[0] = timer.RealTime(); @@ -249,17 +245,17 @@ void KFParticleTopoReconstructor::Init(AliHLTTPCCAGBTracker* tracker, vector &particles, vector* pdg, vector* nPixelHits) +void KFParticleTopoReconstructor::Init(vector& particles, vector* pdg, vector* nPixelHits) { #ifdef USE_TIMERS timer.Start(); #endif // USE_TIMERS - - if(!fTracks) + + if (!fTracks) fTracks = new KFPTrackVector[NInputSets]; - + fParticles.clear(); - fPV.clear(); + fPV.clear(); int nTracks = particles.size(); fTracks[0].Resize(nTracks); @@ -270,49 +266,48 @@ void KFParticleTopoReconstructor::Init(vector &particles, vectorat(iTr); - - for(int iP=0; iP<6; iP++) + + for (int iP = 0; iP < 6; iP++) fTracks[0].SetParameter(particles[iTr].Parameters()[iP], iP, iTr); - for(int iC=0; iC<21; iC++) + for (int iC = 0; iC < 21; iC++) fTracks[0].SetCovariance(particles[iTr].CovarianceMatrix()[iC], iC, iTr); -// fTracks[0].SetId(iTr, iTr); + // fTracks[0].SetId(iTr, iTr); fTracks[0].SetId(particles[iTr].Id(), iTr); fTracks[0].SetPDG(trackPDG, iTr); fTracks[0].SetQ(particles[iTr].Q(), iTr); fTracks[0].SetPVIndex(-1, iTr); - fTracks[0].SetNPixelHits(npixelhits,iTr); + fTracks[0].SetNPixelHits(npixelhits, iTr); } - fKFParticlePVReconstructor->Init( &fTracks[0], nTracks ); - + fKFParticlePVReconstructor->Init(&fTracks[0], nTracks); + #ifdef USE_TIMERS timer.Stop(); fStatTime[0] = timer.RealTime(); #endif // USE_TIMERS } -void KFParticleTopoReconstructor::Init(KFPTrackVector &tracks, KFPTrackVector &tracksAtLastPoint) +void KFParticleTopoReconstructor::Init(KFPTrackVector& tracks, KFPTrackVector& tracksAtLastPoint) { #ifdef USE_TIMERS timer.Start(); #endif // USE_TIMERS - - if(!fTracks) + + if (!fTracks) fTracks = new KFPTrackVector[NInputSets]; - + fParticles.clear(); - fPV.clear(); - + fPV.clear(); + int nTracks = tracks.Size(); fTracks[0].Resize(nTracks); fTracks[0].Set(tracks, nTracks, 0); @@ -324,28 +319,28 @@ void KFParticleTopoReconstructor::Init(KFPTrackVector &tracks, KFPTrackVector &t fTracks[5].Resize(0); fTracks[6].Resize(0); fTracks[7].Resize(0); - fKFParticlePVReconstructor->Init( &fTracks[0], nTracks ); - + fKFParticlePVReconstructor->Init(&fTracks[0], nTracks); + #ifdef USE_TIMERS timer.Stop(); fStatTime[0] = timer.RealTime(); #endif // USE_TIMERS } -void KFParticleTopoReconstructor::Init(const KFPTrackVector *particles, const vector& pv) -{ +void KFParticleTopoReconstructor::Init(const KFPTrackVector* particles, const vector& pv) +{ #ifdef USE_TIMERS timer.Start(); #endif // USE_TIMERS fParticles.clear(); - fPV.clear(); + fPV.clear(); - fTracks = const_cast< KFPTrackVector* >(particles); + fTracks = const_cast(particles); fChiToPrimVtx[0].resize(fTracks[0].Size()); fChiToPrimVtx[1].resize(fTracks[1].Size()); fPV.resize(pv.size()); - for(unsigned int iPV=0; iPV(pv[iPV])); #ifdef USE_TIMERS @@ -363,58 +358,51 @@ void KFParticleTopoReconstructor::ReconstructPrimVertex(bool isHeavySystem) timer.Start(); #endif // USE_TIMERS fKFParticlePVReconstructor->ReconstructPrimVertex(); - - fPV.clear(); + + fPV.clear(); int nPrimVtx = NPrimaryVertices(); int nPV = 0; - if(isHeavySystem) - { - if(NPrimaryVertices() > 1) - { + if (isHeavySystem) { + if (NPrimaryVertices() > 1) { unsigned int nMax = GetPVTrackIndexArray(0).size(); - for(int i=1; i nMax) - { + for (int i = 1; i < NPrimaryVertices(); i++) + if (GetPVTrackIndexArray(i).size() > nMax) { nMax = GetPVTrackIndexArray(i).size(); nPV = i; } } - + nPrimVtx = 1; fPV.resize(nPrimVtx); fPV[0] = GetPrimVertex(nPV); - } - else - { + } else { fPV.resize(nPrimVtx); - for(int iPV=0; iPV& tracks = GetPVTrackIndexArray(iPV); - for(unsigned int iTr=0; iTr pvTracks = fKFParticlePVReconstructor->GetPVTrackIndexArray(nPV); KFVertex pv = fKFParticlePVReconstructor->GetPrimKFVertex(nPV); fKFParticlePVReconstructor->CleanPV(); fKFParticlePVReconstructor->AddPV(pv, pvTracks); } - + #ifdef USE_TIMERS timer.Stop(); fStatTime[1] = timer.RealTime(); @@ -440,100 +428,91 @@ void KFParticleTopoReconstructor::SortTracks() #ifdef USE_TIMERS timer.Start(); #endif // USE_TIMERS - + int offset[2] = {0, 4}; int nSets = 2; - - if(fTracks[4].Size() == 0) + + if (fTracks[4].Size() == 0) nSets = 1; - - for(int iSet=nSets-1; iSet>=0; iSet--) - { + + for (int iSet = nSets - 1; iSet >= 0; iSet--) { int Size = fTracks[0].Size(); - + vector sortedTracks(Size); kfvector_uint trackIndex[4]; - for(int iTV=0; iTV<4; iTV++) + for (int iTV = 0; iTV < 4; iTV++) trackIndex[iTV].resize(Size); - int nTracks[4] = {0,0,0,0}; - - for(int iTr=0; iTr newIndex(Size); - int iCurrentTrack=0; - for(int iTC=0; iTC<4; iTC++) - { - for(int iTrackIndex=0; iTrackIndexGetPVTrackIndexArray(iPV)[iTrack] = newIndex[GetPVTrackIndexArray(iPV)[iTrack]]; } } - + fChiToPrimVtx[0].resize(fTracks[0].Size(), -1); fChiToPrimVtx[1].resize(fTracks[1].Size(), -1); - + #ifdef USE_TIMERS timer.Stop(); fStatTime[2] = timer.RealTime(); @@ -548,66 +527,61 @@ void KFParticleTopoReconstructor::TransportPVTracksToPrimVertex() **/ float_v point[3]; KFParticleSIMD tmpPart; - - for(int iTV=2; iTV<4; iTV++) - { - unsigned int NTr = fTracks[iTV].Size(); - for(unsigned int iTr=0; iTr < NTr; iTr += float_vLen) - { + + for (int iTV = 2; iTV < 4; iTV++) { + unsigned int NTr = fTracks[iTV].Size(); + for (unsigned int iTr = 0; iTr < NTr; iTr += float_vLen) { const int_v& pdg = reinterpret_cast(fTracks[iTV].PDG()[iTr]); const int_v& pvIndex = reinterpret_cast(fTracks[iTV].PVIndex()[iTr]); - + tmpPart.Load(fTracks[iTV], iTr, pdg); - - for(unsigned int iV=0; iV < (unsigned int)float_vLen; iV++) - { - if(iV+iTr >= NTr) continue; - + + for (unsigned int iV = 0; iV < (unsigned int)float_vLen; iV++) { + if (iV + iTr >= NTr) + continue; + int iPV = pvIndex[iV]; point[0][iV] = fPV[iPV].X()[0]; point[1][iV] = fPV[iPV].Y()[0]; - point[2][iV] = fPV[iPV].Z()[0]; + point[2][iV] = fPV[iPV].Z()[0]; } - + tmpPart.TransportToPoint(point); - - for(int iP=0; iP<6; iP++) - fTracks[iTV].SetParameter( tmpPart.GetParameter(iP), iP, iTr ); - for(int iC=0; iC<21; iC++) - fTracks[iTV].SetCovariance( tmpPart.GetCovariance(iC), iC, iTr ); + + for (int iP = 0; iP < 6; iP++) + fTracks[iTV].SetParameter(tmpPart.GetParameter(iP), iP, iTr); + for (int iC = 0; iC < 21; iC++) + fTracks[iTV].SetCovariance(tmpPart.GetCovariance(iC), iC, iTr); } } } void KFParticleTopoReconstructor::GetChiToPrimVertex(KFParticleSIMD* pv, const int nPV) -{ +{ /** Calculates the chi2-deviation from the primary vertex. If several primary vertices ** are found the minimum value is stored. ** \param[in] pv - pointer to the array with primary vertices ** \param[in] nPV - number of the primary vertices in the array **/ KFParticleSIMD tmpPart; - - for(int iTV=0; iTV<2; iTV++) - { + + for (int iTV = 0; iTV < 2; iTV++) { unsigned int NTr = fTracks[iTV].Size(); - for(unsigned int iTr=0; iTr < NTr; iTr += float_vLen) - { + for (unsigned int iTr = 0; iTr < NTr; iTr += float_vLen) { uint_v trackIndex = iTr + uint_v::IndexesFromZero(); const int_v& pdg = reinterpret_cast(fTracks[iTV].PDG()[iTr]); - tmpPart.Create(fTracks[iTV],trackIndex, pdg); - + tmpPart.Create(fTracks[iTV], trackIndex, pdg); + float_v& chi2 = reinterpret_cast(fChiToPrimVtx[iTV][iTr]); - chi2(simd_cast(trackIndex(trackIndex < NTr)) = 10000.f; - for(int iPV=0; iPVchiVec) && simd_cast(trackIndex chiVec) && simd_cast(trackIndex < NTr)) = chiVec; } - } + } } } @@ -622,17 +596,16 @@ void KFParticleTopoReconstructor::GetChiToPrimVertex(KFParticleSIMD* pv, const i ** sort the array with particle candidates according to the smallest difference. Then only ** the best candidate is stored. **/ -struct ParticleInfo -{ - ParticleInfo():fParticleIndex(-1),fMassDistance(1.e9f) {}; +struct ParticleInfo { + ParticleInfo() : fParticleIndex(-1), fMassDistance(1.e9f){}; /** \brief Constructor with all parameters initialised by user. */ - ParticleInfo(int index, float massDistance):fParticleIndex(index),fMassDistance(massDistance) {}; - + ParticleInfo(int index, float massDistance) : fParticleIndex(index), fMassDistance(massDistance){}; + /** \brief Sorting function, returns true if the mass difference of "a" is smaller then of "b". The array is sorted according to the smallest difference.*/ static bool compare(const ParticleInfo& a, const ParticleInfo& b) { return (a.fMassDistance < b.fMassDistance); } - - int fParticleIndex; ///< Index in the array of the particle candidates. - float fMassDistance; ///< difference between the mass of the candidate and the table mass normalised to the width of the peak. + + int fParticleIndex; ///< Index in the array of the particle candidates. + float fMassDistance; ///< difference between the mass of the candidate and the table mass normalised to the width of the peak. }; bool UseParticleInCompetition(int PDG) @@ -640,23 +613,23 @@ bool UseParticleInCompetition(int PDG) /** Defines if a particle with a given PDG code should be used in the ** competition between reconstructed particle candidates. **/ - bool use = (PDG == 310) || //K0 - (PDG == 22) || //gamma - (PDG == 111) || //pi0 - (abs(PDG) == 3122) || //Lambda - (abs(PDG) == 3312) || //Xi - (abs(PDG) == 3334) || //Omega - (abs(PDG) == 3003) || //LambdaN - (abs(PDG) == 3103) || //LambdaNN - (abs(PDG) == 3004) || //H3L - (abs(PDG) == 3005) || //H4L - (abs(PDG) == 3006) || //He4L - (abs(PDG) == 3007) || //He5L - (abs(PDG) == 3203) || //LLn - (abs(PDG) == 3008) || //H4LL - (abs(PDG) == 3009) || //H4LL - (abs(PDG) == 3010) || //H5LL - (abs(PDG) == 3011); //He6LL + bool use = (PDG == 310) || //K0 + (PDG == 22) || //gamma + (PDG == 111) || //pi0 + (abs(PDG) == 3122) || //Lambda + (abs(PDG) == 3312) || //Xi + (abs(PDG) == 3334) || //Omega + (abs(PDG) == 3003) || //LambdaN + (abs(PDG) == 3103) || //LambdaNN + (abs(PDG) == 3004) || //H3L + (abs(PDG) == 3005) || //H4L + (abs(PDG) == 3006) || //He4L + (abs(PDG) == 3007) || //He5L + (abs(PDG) == 3203) || //LLn + (abs(PDG) == 3008) || //H4LL + (abs(PDG) == 3009) || //H4LL + (abs(PDG) == 3010) || //H5LL + (abs(PDG) == 3011); //He6LL return use; } @@ -670,129 +643,125 @@ void KFParticleTopoReconstructor::SelectParticleCandidates() ** 4) in the dielectron spectrum for low mass vector mesons only those ** candidates are left, which have both daughters identified as electrons. **/ - + std::vector particleInfo; std::vector isUsed(fParticles.size()); std::vector deleteCandidate(fParticles.size()); - std::vector bestMother(fParticles.size()); - - for(unsigned int iParticle=0; iParticle bestMother(fParticles.size()); + + for (unsigned int iParticle = 0; iParticle < fParticles.size(); iParticle++) { isUsed[iParticle] = false; - deleteCandidate[iParticle] = false; + deleteCandidate[iParticle] = false; bestMother[iParticle] = -1; } - for(unsigned int iParticle=0; iParticle daughterIds(fParticles[iParticle].NDaughters()); -// for(int iDaughter=0; iDaughter daughterIdsDPlus(fParticles[jParticle].NDaughters()); -// for(int iDaughter=0; iDaughterGetDPlusMass()) < 3*KFParticleDatabase::Instance()->GetDPlusMassSigma()) -// { -// deleteCandidate[iParticle] = true; -// break; -// } -// } -// } -// } -// } - + // for(unsigned int iParticle=0; iParticle daughterIds(fParticles[iParticle].NDaughters()); + // for(int iDaughter=0; iDaughter daughterIdsDPlus(fParticles[jParticle].NDaughters()); + // for(int iDaughter=0; iDaughterGetDPlusMass()) < 3*KFParticleDatabase::Instance()->GetDPlusMassSigma()) + // { + // deleteCandidate[iParticle] = true; + // break; + // } + // } + // } + // } + // } //clean K0 and Lambda - for(unsigned int iParticle=0; iParticleGetMotherMass(fParticles[iParticle].GetPDG(), massPDG, massPDGSigma); - - float dm1 = fabs(mass - massPDG)/massPDGSigma; -// if(dm1 > 3.f) continue; - - for(unsigned int jParticle=iParticle+1; jParticle 3.f) continue; + + for (unsigned int jParticle = iParticle + 1; jParticle < fParticles.size(); jParticle++) { + if (deleteCandidate[jParticle]) + continue; + if (!UseParticleInCompetition(fParticles[jParticle].GetPDG())) + continue; + fParticles[jParticle].GetMass(mass, massSigma); KFParticleDatabase::Instance()->GetMotherMass(fParticles[jParticle].GetPDG(), massPDG, massPDGSigma); - - float dm2 = fabs(mass - massPDG)/massPDGSigma; -// if(dm2 > 3.f) continue; - - if(! (fParticles[iParticle].DaughterIds()[0] == fParticles[jParticle].DaughterIds()[0] && - fParticles[iParticle].DaughterIds()[1] == fParticles[jParticle].DaughterIds()[1]) ) continue; - - if(dm1 < 3.f || dm2 < 3.f) - { -// if(dm1 < 3.f && dm2<3.f) -// { -// KFParticle part1 = fParticles[iParticle]; -// KFParticle part2 = fParticles[jParticle]; -// -// if(fParticles[iParticle].GetPDG() == 310) -// { -// deleteCandidate[iParticle] = true; -// break; -// } -// else -// { -// deleteCandidate[jParticle] = true; -// } -// } - - if(dm1 < dm2) - { + + float dm2 = fabs(mass - massPDG) / massPDGSigma; + // if(dm2 > 3.f) continue; + + if (!(fParticles[iParticle].DaughterIds()[0] == fParticles[jParticle].DaughterIds()[0] && + fParticles[iParticle].DaughterIds()[1] == fParticles[jParticle].DaughterIds()[1])) + continue; + + if (dm1 < 3.f || dm2 < 3.f) { + // if(dm1 < 3.f && dm2<3.f) + // { + // KFParticle part1 = fParticles[iParticle]; + // KFParticle part2 = fParticles[jParticle]; + // + // if(fParticles[iParticle].GetPDG() == 310) + // { + // deleteCandidate[iParticle] = true; + // break; + // } + // else + // { + // deleteCandidate[jParticle] = true; + // } + // } + + if (dm1 < dm2) { deleteCandidate[jParticle] = true; bestMother[fParticles[iParticle].DaughterIds()[0]] = iParticle; bestMother[fParticles[iParticle].DaughterIds()[1]] = iParticle; - } - else - { + } else { deleteCandidate[iParticle] = true; bestMother[fParticles[iParticle].DaughterIds()[0]] = jParticle; bestMother[fParticles[iParticle].DaughterIds()[1]] = jParticle; @@ -801,178 +770,171 @@ void KFParticleTopoReconstructor::SelectParticleCandidates() } } } - -// for(unsigned int iParticle=0; iParticleGetMotherMass(fParticles[iParticle].GetPDG(), massPDG, massPDGSigma); - float dm = fabs(mass - massPDG)/massPDGSigma; - - if(dm < 3.f) + float dm = fabs(mass - massPDG) / massPDGSigma; + + if (dm < 3.f) particleInfo.push_back(ParticleInfo(iParticle, dm)); } std::sort(particleInfo.begin(), particleInfo.end(), ParticleInfo::compare); - - for(unsigned int iPI=0; iPIGetMotherMass(fParticles[iParticle].GetPDG(), massPDG, massPDGSigma); - float dm = fabs(mass - massPDG)/massPDGSigma; - -// if( (bothDaughtersElectrons && dm > 3.f) || !bothDaughtersElectrons) - if( dm > 3.f ) - { + float dm = fabs(mass - massPDG) / massPDGSigma; + + // if( (bothDaughtersElectrons && dm > 3.f) || !bothDaughtersElectrons) + if (dm > 3.f) { bool isStore = true; - for(int iDaughter=0; iDaughterGetMotherMass(fParticles[iParticle].GetPDG(), massPDG, massPDGSigma); -// // -// // float dm = fabs(mass - massPDG)/massPDGSigma; -// -// KFParticle tmp = fParticles[iParticle]; -// // tmp.SetNonlinearMassConstraint(massPDG); -// -// particleInfo.push_back(ParticleInfo(iParticle, tmp.Chi2())); -// } -// } -// -// std::sort(particleInfo.begin(), particleInfo.end(), ParticleInfo::compare); -// -// for(unsigned int iPI=0; iPI -1) - { + // for(unsigned int iParticle=0; iParticleGetMotherMass(fParticles[iParticle].GetPDG(), massPDG, massPDGSigma); + // // + // // float dm = fabs(mass - massPDG)/massPDGSigma; + // + // KFParticle tmp = fParticles[iParticle]; + // // tmp.SetNonlinearMassConstraint(massPDG); + // + // particleInfo.push_back(ParticleInfo(iParticle, tmp.Chi2())); + // } + // } + // + // std::sort(particleInfo.begin(), particleInfo.end(), ParticleInfo::compare); + // + // for(unsigned int iPI=0; iPI -1) { deleteCandidate[iParticle] = true; break; } } - for(unsigned int iParticle=0; iParticle daughters; GetListOfDaughterTracks(particle, daughters); std::sort(daughters.begin(), daughters.end()); - bool sameDaughter=0; - for(unsigned int iDaughter=1; iDaughterFindParticles(fTracks, fChiToPrimVtx, fParticles, fPV, fPV.size()); -// #pragma omp critical -// std::cout << "NPart " << fParticles.size() << " " << fTracks[0].Size() << " "<< fTracks[1].Size() << " " << fTracks[2].Size() << " " << fTracks[3].Size()<< std::endl; - -// for(unsigned int iParticle=0; iParticle(buffer); int dataSize = NInputSets + 1 + 1; //sizes of the track vectors and pv vector, and field - for(int iSet=0; iSet(data[NInputSets+1]); + + float& field = reinterpret_cast(data[NInputSets + 1]); field = Bz; - - int offset = NInputSets+2; - - for(int iSet=0; iSet(data[offset + iPV]); tmpFloat = fPV[iPV].Parameter(iP)[0]; } offset += fPV.size(); } - - for(int iC=0; iC<6; iC++) - { - for(unsigned int iPV=0; iPV(data[offset + iPV]); tmpFloat = fPV[iPV].Covariance(iC)[0]; } offset += fPV.size(); } - + //send the input data to Xeon Phi - int msgSize = sizeof(int) * dataSize;//1000 * sizeof(int); - + int msgSize = sizeof(int) * dataSize; //1000 * sizeof(int); + const uint16_t portSenderId = 2000 + iHLT; int controlSignal = portSenderId; scif_send(endpoint, &msgSize, sizeof(int), SCIF_SEND_BLOCK); scif_recv(endpoint, &controlSignal, sizeof(controlSignal), 1); - if(controlSignal != portSenderId) { std::cout << controlSignal << " " << portSenderId << std::endl; return; } - + if (controlSignal != portSenderId) { + std::cout << controlSignal << " " << portSenderId << std::endl; + return; + } + int ret = scif_writeto(endpoint, offsetServer, msgSize, offsetSender, 0); - if ( ret == -1 ) std::cout << "Fail sending array to the server. Error: " << errno << std::endl; - + if (ret == -1) + std::cout << "Fail sending array to the server. Error: " << errno << std::endl; + scif_send(endpoint, &controlSignal, sizeof(int), SCIF_SEND_BLOCK); // synchronization } #endif @@ -1118,60 +1080,57 @@ void KFParticleTopoReconstructor::SaveInputParticles(const string prefix, bool o ** "event#_KFPTracks.data", where "#" is the number of the event. ** \param[in] prefix - path to the output folder ** \param[in] onlySecondary - flag shows if only secondary tracks should be stored - **/ + **/ static int nEvents = 0; string outFileName = "/event"; char Result[16]; // string which will contain the number - sprintf ( Result, "%d", nEvents ); + sprintf(Result, "%d", nEvents); outFileName += string(Result); outFileName += "_KFPTracks.data"; - ofstream out((prefix+outFileName).data()); - + ofstream out((prefix + outFileName).data()); + //save tracks. tracks are already propagated to the beam - + int nSets = NInputSets; - if(onlySecondary) + if (onlySecondary) nSets = 2; - + float B[3] = {0.f}, r[3] = {0.f}; KFParticle kfpTmp; kfpTmp.GetFieldValue(r, B); out << B[2] << std::endl; out << nSets << std::endl; - for(int iSet=0; iSetSetNThreads(fNThreads); } @@ -88,7 +92,7 @@ class KFParticleTopoReconstructor{ ** \param[in] pdg - pointer to the vector with PDG hypothesis for each track, if pointer is not provided ** "-1" is set as the pdg hypothesis for all tracks **/ - void Init(AliHLTTPCCAGBTracker* tracker, std::vector* pdg=0); // init array of particles + void Init(AliHLTTPCCAGBTracker* tracker, std::vector* pdg = 0); // init array of particles #endif /** Copies provided particles to the vector KFParticleTopoReconstructor::fTracks ** assuming a given PDG hypothesis for each particle. If pointer to pdg-vector is not provided @@ -100,8 +104,8 @@ class KFParticleTopoReconstructor{ ** \param[in] pdg - pointer to the vector with PDG hypothesis for each track, if pointer is not provided ** "-1" is set as the pdg hypothesis for all tracks ** \param[in] nPixelHits - pointer to the vector with number of precise measurement in each track - **/ - void Init(std::vector &particles, std::vector* pdg=0, std::vector* nPixelHits=0); + **/ + void Init(std::vector& particles, std::vector* pdg = 0, std::vector* nPixelHits = 0); /** Initialises the pointer KFParticleTopoReconstructor::fTracks with the external pointer "particles". ** Primary vertices are assumed to be found and are also provided externally. Only reconstruction ** of short-lived particles should be run if this initialisation method is used. @@ -111,66 +115,81 @@ class KFParticleTopoReconstructor{ ** \param[in] particles - pointer to the external vectors with input tracks ** \param[in] pv - vector with externally reconstructed primary vertex candidates **/ - void Init(const KFPTrackVector *particles, const std::vector& pv); + void Init(const KFPTrackVector* particles, const std::vector& pv); /** Initialises tracks at the first and last hit positions. ** The KFParticleTopoReconstructor::fKFParticlePVReconstructor is initialised with the copied ** tracks at the first hit position. ** \param[in] tracks - vector with the tracks at the first hit position ** \param[in] tracksAtLastPoint - vector with the tracks at the last hit position **/ - void Init(KFPTrackVector &tracks, KFPTrackVector &tracksAtLastPoint); + void Init(KFPTrackVector& tracks, KFPTrackVector& tracksAtLastPoint); /** \brief Sets input clusters of the electromagnetic calorimeter to KFParticleFinder. */ void SetEmcClusters(KFPEmcCluster* clusters) { fKFParticleFinder->SetEmcClusters(clusters); } void SetMixedEventAnalysis() { fKFParticleFinder->SetMixedEventAnalysis(); } ///< KFParticleFinder is forced to be run in the mixed event analysis mode. - + void DeInit() { fTracks = NULL; } ///< Sets a pointer to the input tracks KFParticleTopoReconstructor::fTracks to NULL. /** \brief Cleans all candidates for primary vertices and short-lived particles. */ - void Clear() { fParticles.clear(); fPV.clear(); fKFParticlePVReconstructor->CleanPV(); } - + void Clear() + { + fParticles.clear(); + fPV.clear(); + fKFParticlePVReconstructor->CleanPV(); + } + void ReconstructPrimVertex(bool isHeavySystem = 1); // find primary vertex - void SortTracks(); //sort tracks according to the pdg hypothesis and pv index - void ReconstructParticles(); //find short-lived particles - void SelectParticleCandidates(); //clean particle candidates: track can belong to only one particle + void SortTracks(); //sort tracks according to the pdg hypothesis and pv index + void ReconstructParticles(); //find short-lived particles + void SelectParticleCandidates(); //clean particle candidates: track can belong to only one particle #ifdef WITHSCIF - void SendDataToXeonPhi( int iHLT, scif_epd_t& endpoint, void* buffer, off_t& offsetServer, off_t& offsetSender, float Bz); + void SendDataToXeonPhi(int iHLT, scif_epd_t& endpoint, void* buffer, off_t& offsetServer, off_t& offsetSender, float Bz); #endif - int NPrimaryVertices() const { return fKFParticlePVReconstructor->NPrimaryVertices(); } ///< Returns number of the found primary vertex candidates. - KFParticle &GetPrimVertex(int iPV=0) const { return fKFParticlePVReconstructor->GetPrimVertex(iPV); } ///< Return primary vertex candidate with index "iPV". - KFVertex &GetPrimKFVertex(int iPV=0) const { return fKFParticlePVReconstructor->GetPrimKFVertex(iPV); } ///< Return primary vertex candidate with index "iPV". + int NPrimaryVertices() const + { + return fKFParticlePVReconstructor->NPrimaryVertices(); + } ///< Returns number of the found primary vertex candidates. + KFParticle& GetPrimVertex(int iPV = 0) const { return fKFParticlePVReconstructor->GetPrimVertex(iPV); } ///< Return primary vertex candidate with index "iPV". + KFVertex& GetPrimKFVertex(int iPV = 0) const { return fKFParticlePVReconstructor->GetPrimKFVertex(iPV); } ///< Return primary vertex candidate with index "iPV". /** Returns vector with track indices from a cluster with index "iPV". */ - std::vector& GetPVTrackIndexArray(int iPV=0) const { return fKFParticlePVReconstructor->GetPVTrackIndexArray(iPV); } - - std::vector const &GetParticles() const { return fParticles; } ///< Returns constant reference to the vector with short-lived particle candidates. + std::vector& GetPVTrackIndexArray(int iPV = 0) const { return fKFParticlePVReconstructor->GetPVTrackIndexArray(iPV); } + + std::vector const& GetParticles() const { return fParticles; } ///< Returns constant reference to the vector with short-lived particle candidates. /** \brief Logically kills the candidate for short-lived particle with index "iParticle" by setting its PDG hypothesis to "-1". */ - void RemoveParticle(const int iParticle) { if(iParticle>=0 && iParticle= 0 && iParticle < int(fParticles.size())) + fParticles[iParticle].SetPDG(-1); + } + const KFPTrackVector* GetTracks() const { return fTracks; } ///< Returns a pointer to the arrays with tracks KFParticleTopoReconstructor::fTracks. const kfvector_float* GetChiPrim() const { return fChiToPrimVtx; } ///CleanPV(); } - void AddPV(const KFVertex &pv, const std::vector &tracks) { + void AddPV(const KFVertex& pv, const std::vector& tracks) + { /** Adds externally found primary vertex to the list together with the cluster of ** tracks from this vertex. ** \param[in] pv - external primary vertex ** \param[in] tracks - vector with indices of tracks associated with the provided primary vertex. **/ - fKFParticlePVReconstructor->AddPV(pv,tracks); - KFParticle pvPart=pv; + fKFParticlePVReconstructor->AddPV(pv, tracks); + KFParticle pvPart = pv; fPV.push_back(pvPart); fKFParticleFinder->SetNPV(fPV.size()); } - void AddPV(const KFVertex &pv) { - /** Adds externally found primary vertex to the list. + void AddPV(const KFVertex& pv) + { + /** Adds externally found primary vertex to the list. ** \param[in] pv - external primary vertex **/ fKFParticlePVReconstructor->AddPV(pv); - KFParticle pvPart=pv; + KFParticle pvPart = pv; fPV.push_back(pvPart); fKFParticleFinder->SetNPV(fPV.size()); } @@ -178,10 +197,10 @@ class KFParticleTopoReconstructor{ { /** Assigns index of the corresponding primary vertex to each input track ** according to the clusters reconstructed by KFParticlePVReconstructor. */ - if(fTracks) - for(int iPV=0; iPVSetChi2PrimaryCut(chi); + fKFParticlePVReconstructor->SetChi2PrimaryCut(chi); fKFParticleFinder->SetChiPrimaryCut2D(chi); } - + void GetListOfDaughterTracks(const KFParticle& particle, std::vector& daughters); bool ParticleHasRepeatingDaughters(const KFParticle& particle); - const KFParticleTopoReconstructor &operator=(const KFParticleTopoReconstructor& a) + const KFParticleTopoReconstructor& operator=(const KFParticleTopoReconstructor& a) { /** Copy operator. All pointers are set to zero, other members are copied. Returns the current object after copying is finished. **/ fKFParticlePVReconstructor = 0; fKFParticleFinder = 0; fTracks = 0; - + fNThreads = a.fNThreads; - + return *this; } - + /** \brief A copy constructor. All pointers are set to zero, other members are copied. **/ - KFParticleTopoReconstructor(const KFParticleTopoReconstructor& a):fKFParticlePVReconstructor(0),fKFParticleFinder(0),fTracks(0), fParticles(), fPV(), fNThreads(a.fNThreads) + KFParticleTopoReconstructor(const KFParticleTopoReconstructor& a) : fKFParticlePVReconstructor(0), fKFParticleFinder(0), fTracks(0), fParticles(), fPV(), fNThreads(a.fNThreads) #ifdef USE_TIMERS - ,fTime(0.),timer() + , + fTime(0.), + timer() #endif { } - + /** Copy cuts from KF Particle Finder of another topology reconstructor object topo. */ void CopyCuts(const KFParticleTopoReconstructor* topo) { fKFParticleFinder->CopyCuts(topo->fKFParticleFinder); } - private: + private: void GetChiToPrimVertex(KFParticleSIMD* pv, const int nPV); void TransportPVTracksToPrimVertex(); - + KFParticlePVReconstructor* fKFParticlePVReconstructor; ///< Pointer to the KFParticlePVReconstructor. Allocated in the constructor. - KFParticleFinder* fKFParticleFinder; ///< Pointer to the KFParticleFinder object. Allocated in the constructor. + KFParticleFinder* fKFParticleFinder; ///< Pointer to the KFParticleFinder object. Allocated in the constructor. /** Pointer to the array with the input tracks. Memory is allocated by the Init() functions. ** For reconstruction of primary vertex candidates unsorted tracks are used. For reconstruction of short-lived particles ** Tracks should be sorted by the KFParticleTopoReconstructor::SortTracks() function. The tracks after sorting are divided @@ -261,26 +286,23 @@ class KFParticleTopoReconstructor{ ** 6) primary positive at the last hit position; \n ** 7) primary negative at the last hit position. **/ - KFPTrackVector *fTracks; - kfvector_float fChiToPrimVtx[2]; ///< Chi2-deviation of the secondary tracks. - std::vector fParticles; ///< Vector of the reconstructed candidates of short-lived particles. - std::vector > fPV; ///< Vector of the reconstructed primary vertices. - + KFPTrackVector* fTracks; + kfvector_float fChiToPrimVtx[2]; ///< Chi2-deviation of the secondary tracks. + std::vector fParticles; ///< Vector of the reconstructed candidates of short-lived particles. + std::vector> fPV; ///< Vector of the reconstructed primary vertices. + short int fNThreads; ///< Number of threads to be run in KFParticleFinder. Currently is not used. - + //speed measurements #ifdef USE_TIMERS - double fTime; ///< Total run time. + double fTime; ///< Total run time. static const int fNTimers = 4; ///< Number of timers to measure different part of the code. /** \brief Execution time of different parts of the code: initialisation, reconstruction of primary vertices, - ** sorting of input particles, reconstruction of short-lived particles. */ + ** sorting of input particles, reconstruction of short-lived particles. */ double fStatTime[fNTimers]; Stopwatch timer; ///< Timer. -#endif // USE_TIMERS - -}__attribute__((aligned(sizeof(float_v)))); // class KFParticleTopoReconstructor +#endif // USE_TIMERS +} __attribute__((aligned(sizeof(float_v)))); // class KFParticleTopoReconstructor - #endif // KFParticleTopoReconstructor_H - diff --git a/KFParticle/KFVertex.cxx b/KFParticle/KFVertex.cxx index 07b4d61..c92b1fc 100644 --- a/KFParticle/KFVertex.cxx +++ b/KFParticle/KFVertex.cxx @@ -19,28 +19,27 @@ * along with this program. If not, see . */ - #include "KFVertex.h" #ifndef KFParticleStandalone ClassImp(KFVertex); #endif -KFVertex::KFVertex( const KFPVertex &vertex ): fIsConstrained(0) +KFVertex::KFVertex(const KFPVertex& vertex) : fIsConstrained(0) { /** Constructor from KFPVertex. **/ - vertex.GetXYZ( fP ); - vertex.GetCovarianceMatrix( fC ); - fChi2 = vertex.GetChi2(); - fNDF = 2*vertex.GetNContributors() - 3; + vertex.GetXYZ(fP); + vertex.GetCovarianceMatrix(fC); + fChi2 = vertex.GetChi2(); + fNDF = 2 * vertex.GetNContributors() - 3; fQ = 0; fAtProductionVertex = 0; fSFromDecay = 0; } -void KFVertex::SetBeamConstraint( float x, float y, float z, - float errX, float errY, float errZ ) +void KFVertex::SetBeamConstraint(float x, float y, float z, + float errX, float errY, float errZ) { /** Sets a soft beam constraint on the vertex position. ** \param[in] x, y, z - coordinates of the constraint @@ -49,12 +48,12 @@ void KFVertex::SetBeamConstraint( float x, float y, float z, fP[0] = x; fP[1] = y; fP[2] = z; - fC[0] = errX*errX; + fC[0] = errX * errX; fC[1] = 0; - fC[2] = errY*errY; + fC[2] = errY * errY; fC[3] = 0; fC[4] = 0; - fC[5] = errZ*errZ; + fC[5] = errZ * errZ; fIsConstrained = 1; } @@ -64,9 +63,9 @@ void KFVertex::SetBeamConstraintOff() fIsConstrained = 0; } -void KFVertex::ConstructPrimaryVertex( const KFParticle *vDaughters[], - int nDaughters, Bool_t vtxFlag[], - float ChiCut ) +void KFVertex::ConstructPrimaryVertex(const KFParticle* vDaughters[], + int nDaughters, Bool_t vtxFlag[], + float ChiCut) { /** Reconstructs the primary vertex from a set of particles. Reconstruction is ** parformed in three steps:\n @@ -82,67 +81,73 @@ void KFVertex::ConstructPrimaryVertex( const KFParticle *vDaughters[], ** seed, by default the cut is set to 3.5 **/ - if( nDaughters<2 ) return; - float constrP[3]={fP[0], fP[1], fP[2]}; - float constrC[6]={fC[0], fC[1], fC[2], fC[3], fC[4], fC[5]}; + if (nDaughters < 2) + return; + float constrP[3] = {fP[0], fP[1], fP[2]}; + float constrC[6] = {fC[0], fC[1], fC[2], fC[3], fC[4], fC[5]}; - Construct( vDaughters, nDaughters, 0, -1 ); + Construct(vDaughters, nDaughters, 0, -1); -// SetVtxGuess( fVtxGuess[0], fVtxGuess[1], fVtxGuess[2] ); + // SetVtxGuess( fVtxGuess[0], fVtxGuess[1], fVtxGuess[2] ); - for( int i=0; i2 ) -// { -// float worstChi = 0.; -// Int_t worstDaughter = 0; -// for( Int_t it=0; it= ChiCut ){ - vtxFlag[it] = 0; + // while( nRest>2 ) + // { + // float worstChi = 0.; + // Int_t worstDaughter = 0; + // for( Int_t it=0; it= ChiCut) { + vtxFlag[it] = 0; nRest--; } } - if( nRest>=2 ) {// final refit -// SetVtxGuess( fP[0], fP[1], fP[2] ); - if( fIsConstrained ){ + if (nRest >= 2) { // final refit + // SetVtxGuess( fP[0], fP[1], fP[2] ); + if (fIsConstrained) { fP[0] = constrP[0]; fP[1] = constrP[1]; fP[2] = constrP[2]; - for( int i=0; i<6; i++ ) fC[i] = constrC[i]; + for (int i = 0; i < 6; i++) + fC[i] = constrC[i]; } - int nDaughtersNew=0; - const KFParticle **vDaughtersNew=new const KFParticle *[nDaughters]; - for( int i=0; i ChiCut*ChiCut*GetNDF() ) { - for( int i=0; i ChiCut * ChiCut * GetNDF()) { + for (int i = 0; i < nDaughters; i++) + vtxFlag[i] = 0; fNDF = -3; fChi2 = 0; } diff --git a/KFParticle/KFVertex.h b/KFParticle/KFVertex.h index 8002675..20de833 100644 --- a/KFParticle/KFVertex.h +++ b/KFParticle/KFVertex.h @@ -19,7 +19,6 @@ * along with this program. If not, see . */ - #ifndef KFVERTEX_H #define KFVERTEX_H @@ -39,60 +38,53 @@ class KFVertex : public KFParticle { public: + KFVertex() : KFParticle(), fIsConstrained(0) {} + KFVertex(const KFParticle& particle) : KFParticle(particle), fIsConstrained(0) {} ///< Vertex is constructed from the current position of a given particle. + KFVertex(const KFPVertex& vertex); + virtual ~KFVertex() {} - KFVertex():KFParticle(),fIsConstrained(0){ } - KFVertex( const KFParticle &particle ): KFParticle(particle), fIsConstrained(0) {} ///< Vertex is constructed from the current position of a given particle. - KFVertex( const KFPVertex &vertex ); - virtual ~KFVertex(){} - - Int_t GetNContributors() const { return fIsConstrained ?fNDF/2:(fNDF+3)/2; } ///< Returns number of particles used for construction of the vertex. - + Int_t GetNContributors() const { return fIsConstrained ? fNDF / 2 : (fNDF + 3) / 2; } ///< Returns number of particles used for construction of the vertex. - void operator +=( const KFParticle &Daughter ); ///< Adds particle to a vertex. - KFVertex operator -( const KFParticle &Daughter ) const; ///< Subtracts particle from a vertex, returns temporary object. Initial vertex stays untouched. - void operator -=( const KFParticle &Daughter ); ///< Subtracts particle from a current vertex. + void operator+=(const KFParticle& Daughter); ///< Adds particle to a vertex. + KFVertex operator-(const KFParticle& Daughter) const; ///< Subtracts particle from a vertex, returns temporary object. Initial vertex stays untouched. + void operator-=(const KFParticle& Daughter); ///< Subtracts particle from a current vertex. - void SetBeamConstraint( float X, float Y, float Z, - float ErrX, float ErrY, float ErrZ ); + void SetBeamConstraint(float X, float Y, float Z, + float ErrX, float ErrY, float ErrZ); void SetBeamConstraintOff(); - void ConstructPrimaryVertex( const KFParticle *vDaughters[], int nDaughters, - Bool_t vtxFlag[], float ChiCut=3.5 ); + void ConstructPrimaryVertex(const KFParticle* vDaughters[], int nDaughters, + Bool_t vtxFlag[], float ChiCut = 3.5); protected: - Bool_t fIsConstrained; ///< Flag showing if the the beam constraint is set - + #ifndef KFParticleStandalone - ClassDef( KFVertex, 2 ) + ClassDef(KFVertex, 2) #endif }; - //--------------------------------------------------------------------- // // Inline implementation of the KFVertex methods // //--------------------------------------------------------------------- - -inline void KFVertex::operator+=( const KFParticle &Daughter ) +inline void KFVertex::operator+=(const KFParticle& Daughter) { - KFParticle::operator+=( Daughter ); + KFParticle::operator+=(Daughter); } - -inline void KFVertex::operator-=( const KFParticle &Daughter ) +inline void KFVertex::operator-=(const KFParticle& Daughter) { - Daughter.SubtractFromVertex( *this ); + Daughter.SubtractFromVertex(*this); } - -inline KFVertex KFVertex::operator-( const KFParticle &Daughter ) const + +inline KFVertex KFVertex::operator-(const KFParticle& Daughter) const { KFVertex tmp = *this; - Daughter.SubtractFromVertex( tmp ); + Daughter.SubtractFromVertex(tmp); return tmp; } - -#endif +#endif diff --git a/KFParticlePerformance/KFMCCounter.h b/KFParticlePerformance/KFMCCounter.h index b72332a..7a5fb19 100644 --- a/KFParticlePerformance/KFMCCounter.h +++ b/KFParticlePerformance/KFMCCounter.h @@ -36,84 +36,95 @@ **/ template -struct KFMCCounter -{ +struct KFMCCounter { int NCounters; ///< Number of counters in the current object. - + std::vector counters; ///< Counters of different set of particles. - KFMCCounter():NCounters(0),counters(0) { } - KFMCCounter(int nCounters):NCounters(nCounters), counters(nCounters,T(0)) { } ///< Constructs the object with the set of counters "nCounters". + KFMCCounter() : NCounters(0), counters(0) {} + KFMCCounter(int nCounters) : NCounters(nCounters), counters(nCounters, T(0)) {} ///< Constructs the object with the set of counters "nCounters". + + void AddCounter() + { + NCounters++; + counters.push_back(T(0)); + } ///< Adds a counter to the existing list. + void AddCounters(int nCounters) + { + NCounters += nCounters; + counters.resize(NCounters, T(0)); + } ///< Adds several counters to the existing list. - void AddCounter(){ NCounters++; counters.push_back(T(0)); } ///< Adds a counter to the existing list. - void AddCounters(int nCounters){ NCounters += nCounters; counters.resize( NCounters, T(0)); } ///< Adds several counters to the existing list. - /** Operator adds all counters from object "a" to the current object. Returns the current object. */ - KFMCCounter& operator+=(KFMCCounter& a){ - if (NCounters != a.NCounters){ + KFMCCounter& operator+=(KFMCCounter& a) + { + if (NCounters != a.NCounters) { std::cout << " KFMCCounter: Error. Addition of counters of different sizes: " << NCounters << " " << a.NCounters << std::endl; - } - else{ - for (int iC = 0; iC < NCounters; iC++){ + } else { + for (int iC = 0; iC < NCounters; iC++) { counters[iC] += a.counters[iC]; } } return *this; }; /** Operator adds all counters from object "a" to the current object, result is stored to the temporary object. Returns the temporary object. */ - KFMCCounter operator+(KFMCCounter& a){ + KFMCCounter operator+(KFMCCounter& a) + { KFMCCounter res = *this; res += a; return res; }; /** Operator divides all counters from the current object to the counters from object "a", result is stored to the temporary object. Returns the temporary object. */ template - KFMCCounter operator/(KFMCCounter& a){ + KFMCCounter operator/(KFMCCounter& a) + { KFMCCounter b(NCounters); - if (NCounters != a.NCounters){ + if (NCounters != a.NCounters) { std::cout << " KFMCCounter: Error. Addition of counters of different sizes: " << NCounters << " " << a.NCounters << std::endl; - } - else{ - for (int iC = 0; iC < NCounters; iC++){ - b.counters[iC] = Div(counters[iC],a.counters[iC]); + } else { + for (int iC = 0; iC < NCounters; iC++) { + b.counters[iC] = Div(counters[iC], a.counters[iC]); } } return b; } /** Operator divides all counters from the current object to the value "a", result is stored to the temporary object. Returns the temporary object. */ template - KFMCCounter operator/(double a){ + KFMCCounter operator/(double a) + { KFMCCounter b(NCounters); - for (int iC = 0; iC < NCounters; iC++){ - b.counters[iC] = (T2)Div(counters[iC],a); + for (int iC = 0; iC < NCounters; iC++) { + b.counters[iC] = (T2)Div(counters[iC], a); } return b; } /** Operator to write the object "a" to the file "strm".*/ - friend std::fstream & operator<<(std::fstream &strm, const KFMCCounter &a ){ + friend std::fstream& operator<<(std::fstream& strm, const KFMCCounter& a) + { strm << a.NCounters << " " << a.counters.size() << " "; - for(unsigned int iV=0; iV &a ){ + friend std::ostream& operator<<(std::ostream& strm, const KFMCCounter& a) + { strm << a.NCounters << " " << a.counters.size() << " "; - for(unsigned int iV=0; iV>(std::fstream &strm, KFMCCounter &a ){ + friend std::fstream& operator>>(std::fstream& strm, KFMCCounter& a) + { int tmp; strm >> tmp; a.NCounters = tmp; strm >> tmp; - a.counters.resize(tmp,T(0)); - for(int iV=0; iV> tmp1; a.counters[iV] = tmp1; @@ -121,9 +132,9 @@ struct KFMCCounter return strm; } - private: - /** Divides value "a" on value "b" if b is not zero, otherwise returns "-1". */ - double Div(double a, double b){return (b > 0) ? a/b : -1.;} + private: + /** Divides value "a" on value "b" if b is not zero, otherwise returns "-1". */ + double Div(double a, double b) { return (b > 0) ? a / b : -1.; } }; #endif diff --git a/KFParticlePerformance/KFMCParticle.cxx b/KFParticlePerformance/KFMCParticle.cxx index eec5d1c..7619d67 100644 --- a/KFParticlePerformance/KFMCParticle.cxx +++ b/KFParticlePerformance/KFMCParticle.cxx @@ -25,10 +25,9 @@ ClassImp(KFMCParticle) #endif -KFMCParticle::KFMCParticle() :fDaughterIds(), fMCTrackID(-1), fMotherId(-1), fPDG(0), fInitialParticleId(-1) + KFMCParticle::KFMCParticle() : fDaughterIds(), fMCTrackID(-1), fMotherId(-1), fPDG(0), fInitialParticleId(-1) { - for(int i=0; i<3; i++) - { + for (int i = 0; i < 3; i++) { fIsReconstructable[i] = 0; fIsV0[i] = 0; } @@ -40,7 +39,7 @@ KFMCParticle::~KFMCParticle() { } -void KFMCParticle::AddDaughter( int i ) +void KFMCParticle::AddDaughter(int i) { fDaughterIds.push_back(i); } diff --git a/KFParticlePerformance/KFMCParticle.h b/KFParticlePerformance/KFMCParticle.h index de09607..f650e3c 100644 --- a/KFParticlePerformance/KFMCParticle.h +++ b/KFParticlePerformance/KFMCParticle.h @@ -45,39 +45,39 @@ ** decays, since GEANT engines do not store neutrinos. **/ -class KFMCParticle :public TObject +class KFMCParticle : public TObject { public: KFMCParticle(); ~KFMCParticle(); - void AddDaughter( int i ); ///< Adds an Id of the new particle to the list with Ids of daughter particles. - int NDaughters() const { return fDaughterIds.size(); } ///< Returns number of daughter particles. - const std::vector& GetDaughterIds() const { return fDaughterIds; } ///< Returns a reference to the vector with Id of daughter particle KFMCParticle::fDaughterIds. - void CleanDaughters() { fDaughterIds.resize(0); } ///< Remove Ids of all daughter particles from the current object. + void AddDaughter(int i); ///< Adds an Id of the new particle to the list with Ids of daughter particles. + int NDaughters() const { return fDaughterIds.size(); } ///< Returns number of daughter particles. + const std::vector& GetDaughterIds() const { return fDaughterIds; } ///< Returns a reference to the vector with Id of daughter particle KFMCParticle::fDaughterIds. + void CleanDaughters() { fDaughterIds.resize(0); } ///< Remove Ids of all daughter particles from the current object. + + void SetPDG(int pdg) { fPDG = pdg; } ///< Set the PDG code of the current particle KFMCParticle::fPDG. + void SetMCTrackID(int id) { fMCTrackID = id; } ///< Sets the Id of the corresponding Monte Carlo track KFMCParticle::fMCTrackID. + void SetMotherId(int id) { fMotherId = id; } ///< Sets the Id of the mother particle or primary vertex KFMCParticle::fMotherId. + + int GetMCTrackID() const { return fMCTrackID; } ///< Returns Id of the corresponding MC track KFMCParticle::fMCTrackID. + int GetMotherId() const { return fMotherId; } ///< Returns Id of the mother particle or primary vertex KFMCParticle::fMotherId. + int GetPDG() const { return fPDG; } ///< Returns PDG code of the current particle KFMCParticle::fPDG. + + bool IsReconstructable(int i) const { return fIsReconstructable[i]; } ///< Returns a flag showing if particle can be reconstructed with KFMCParticle::fIsReconstructable index "i". + void SetAsReconstructable(int i) { fIsReconstructable[i] = 1; } ///< Defines the particle as those which should be reconstructed for the efficiency set "i". + + bool IsReconstructableV0(int i) const { return fIsV0[i]; } ///< Returns a flag showing if particle is a reconstructable V0. + void SetAsReconstructableV0(int i) { fIsV0[i] = 1; } ///< Defines the particle as V0 which should be reconstructed for the efficiency set "i". + + void SetInitialParticleId(int i) { fInitialParticleId = i; } ///< Sets Id of the Monte Carlo particle, from which the current particle was copied. + int InitialParticleId() const { return fInitialParticleId; } ///< Returns the Id of the Monte Carlo particle, from which the current particle was copied. + private: //data + std::vector fDaughterIds; ///< A vector with Ids of the daughter Monte Carlo particles. + int fMCTrackID; ///< A unique Id of the corresponding Monte Carlo track. + int fMotherId; ///< A unique Id of the mother particle. If the current particle is primary the Id of the primary vertex with a negative sigh is stored. + int fPDG; ///< A PDG code of the current particle. - void SetPDG(int pdg) {fPDG = pdg;} ///< Set the PDG code of the current particle KFMCParticle::fPDG. - void SetMCTrackID(int id) {fMCTrackID = id;} ///< Sets the Id of the corresponding Monte Carlo track KFMCParticle::fMCTrackID. - void SetMotherId(int id) {fMotherId = id;} ///< Sets the Id of the mother particle or primary vertex KFMCParticle::fMotherId. - - int GetMCTrackID() const {return fMCTrackID;} ///< Returns Id of the corresponding MC track KFMCParticle::fMCTrackID. - int GetMotherId() const {return fMotherId;} ///< Returns Id of the mother particle or primary vertex KFMCParticle::fMotherId. - int GetPDG() const {return fPDG;} ///< Returns PDG code of the current particle KFMCParticle::fPDG. - - bool IsReconstructable(int i) const {return fIsReconstructable[i];} ///< Returns a flag showing if particle can be reconstructed with KFMCParticle::fIsReconstructable index "i". - void SetAsReconstructable(int i) { fIsReconstructable[i] = 1;} ///< Defines the particle as those which should be reconstructed for the efficiency set "i". - - bool IsReconstructableV0(int i) const {return fIsV0[i];} ///< Returns a flag showing if particle is a reconstructable V0. - void SetAsReconstructableV0(int i) { fIsV0[i] = 1;} ///< Defines the particle as V0 which should be reconstructed for the efficiency set "i". - - void SetInitialParticleId(int i) {fInitialParticleId = i;} ///< Sets Id of the Monte Carlo particle, from which the current particle was copied. - int InitialParticleId() const {return fInitialParticleId;} ///< Returns the Id of the Monte Carlo particle, from which the current particle was copied. - private: //data - std::vector fDaughterIds; ///< A vector with Ids of the daughter Monte Carlo particles. - int fMCTrackID; ///< A unique Id of the corresponding Monte Carlo track. - int fMotherId; ///< A unique Id of the mother particle. If the current particle is primary the Id of the primary vertex with a negative sigh is stored. - int fPDG; ///< A PDG code of the current particle. - /** Flags for calculation of the efficiency, define the denominator in each set of efficiency. ** Flags 0-2 are used for particles reconstructed by the conventional method, 3 and 4 are used ** for particles found by the missing mass method: \n @@ -97,16 +97,15 @@ class KFMCParticle :public TObject /** Flags to calculate efficiency of short-lived particles producing a secondary vertex with ** two or more daughters; similar to KFMCParticle::fIsReconstructable[0-2]. **/ - bool fIsV0[3]; + bool fIsV0[3]; /** For calculation of missing mass method efficiency a copy of the mother particle ** is created. fInitialParticleId is an Id of the initial mother particle. **/ int fInitialParticleId; #ifndef KFParticleStandalone - ClassDef( KFMCParticle, 1 ) + ClassDef(KFMCParticle, 1) #endif }; #endif - diff --git a/KFParticlePerformance/KFMCTrack.h b/KFParticlePerformance/KFMCTrack.h index 293fe68..fe3a1f0 100644 --- a/KFParticlePerformance/KFMCTrack.h +++ b/KFParticlePerformance/KFMCTrack.h @@ -41,50 +41,49 @@ class KFMCTrack { public: - KFMCTrack():fMotherId(-1),fPDG(0),fNMCPoints(0), fNMCPixelPoints(0), fIsReconstructed(0),fIsOutOfDetector(0) {}; + KFMCTrack() : fMotherId(-1), fPDG(0), fNMCPoints(0), fNMCPixelPoints(0), fIsReconstructed(0), fIsOutOfDetector(0){}; + + int MotherId() const { return fMotherId; } ///< Returns a uniqueue Id of the mother track or primary vertex KFMCTrack::fMotherId. + int PDG() const { return fPDG; } ///< Returns PDG code of the track KFMCTrack::fPDG. + float Par(int i) const { return fPar[i]; } ///< Returns value of the parameter KFMCTrack::fPar with index "i". + float X() const { return fPar[0]; } ///< Returns X coordinate of the track at the origin position. + float Y() const { return fPar[1]; } ///< Returns Y coordinate of the track at the origin position. + float Z() const { return fPar[2]; } ///< Returns Y coordinate of the track at the origin position. + float L() const { return sqrt(X() * X() + Y() * Y() + Z() * Z()); } ///< Returns distance from the origin of the track to a point {0,0,0}. + float Px() const { return fPar[3]; } ///< Returns Px momentum component of the track at the origin position. + float Py() const { return fPar[4]; } ///< Returns Py momentum component of the track at the origin position. + float Pz() const { return fPar[5]; } ///< Returns Pz momentum component of the track at the origin position. + float P() const { return sqrt(fPar[3] * fPar[3] + fPar[4] * fPar[4] + fPar[5] * fPar[5]); } ///< Returns momentum of the track. + float Pt() const { return sqrt(fPar[3] * fPar[3] + fPar[4] * fPar[4]); } ///< Returns transverse momentum of the track. + const float* Par() const { return fPar; } ///< Returns a pointer to the array with track parameters KFMCTrack::fPar. + int NMCPoints() const { return fNMCPoints; } ///< Returns number of MC points KFMCTrack::fNMCPoints. + int NMCPixelPoints() const { return fNMCPixelPoints; } ///< Returns number of MC points at the precise detectors KFMCTrack::fNMCPixelPoints. + bool IsReconstructed() const { return fIsReconstructed; } ///< Returns a flag showing if track was found by the reconstruction procedure. + bool IsOutOfDetector() const { return fIsOutOfDetector; } ///< Returns a flag showing if track was out of acceptance. + + void SetPar(int i, float v) { fPar[i] = v; } ///< Sets a value "v" to the parameter with index "i". + void SetX(float v) { fPar[0] = v; } ///< Sets X coordinate at the origin position of the track. + void SetY(float v) { fPar[1] = v; } ///< Sets Y coordinate at the origin position of the track. + void SetZ(float v) { fPar[2] = v; } ///< Sets Z coordinate at the origin position of the track. + void SetPx(float v) { fPar[3] = v; } ///< Sets Px momentum component at the origin position of the track. + void SetPy(float v) { fPar[4] = v; } ///< Sets Py momentum component at the origin position of the track. + void SetPz(float v) { fPar[5] = v; } ///< Sets Pz momentum component at the origin position of the track. + void SetQP(float v) { fPar[6] = v; } ///< Sets q/P at the origin position of the track. + void SetMotherId(int v) { fMotherId = v; } ///< Sets a unique id of the mother track if track is secondary or primary vertex with a negative sign if it is primary. + void SetPDG(int v) { fPDG = v; } ///< Sets PDG code of the current track. + void SetNMCPoints(int v) { fNMCPoints = v; } ///< Sets number of MC points produced at the detector planes. + void SetNMCPixelPoints(int v) { fNMCPixelPoints = v; } ///< Sets number of the MC points produced at the precise detectors. + void SetReconstructed() { fIsReconstructed = 1; } ///< Defines the track as reconstructed. + void SetNotReconstructed() { fIsReconstructed = 0; } ///< Defines the track as not reconstructed. + void SetOutOfDetector() { fIsOutOfDetector = 1; } ///< Defines the track out of acceptance. - int MotherId() const { return fMotherId; } ///< Returns a uniqueue Id of the mother track or primary vertex KFMCTrack::fMotherId. - int PDG() const { return fPDG;} ///< Returns PDG code of the track KFMCTrack::fPDG. - float Par( int i ) const { return fPar[i]; } ///< Returns value of the parameter KFMCTrack::fPar with index "i". - float X() const { return fPar[0]; } ///< Returns X coordinate of the track at the origin position. - float Y() const { return fPar[1]; } ///< Returns Y coordinate of the track at the origin position. - float Z() const { return fPar[2]; } ///< Returns Y coordinate of the track at the origin position. - float L() const { return sqrt(X()*X() + Y()*Y() + Z()*Z()); } ///< Returns distance from the origin of the track to a point {0,0,0}. - float Px() const { return fPar[3]; } ///< Returns Px momentum component of the track at the origin position. - float Py() const { return fPar[4]; } ///< Returns Py momentum component of the track at the origin position. - float Pz() const { return fPar[5]; } ///< Returns Pz momentum component of the track at the origin position. - float P() const { return sqrt(fPar[3]*fPar[3] + fPar[4]*fPar[4] + fPar[5]*fPar[5]); } ///< Returns momentum of the track. - float Pt() const { return sqrt(fPar[3]*fPar[3] + fPar[4]*fPar[4]); } ///< Returns transverse momentum of the track. - const float *Par() const { return fPar; } ///< Returns a pointer to the array with track parameters KFMCTrack::fPar. - int NMCPoints() const { return fNMCPoints; } ///< Returns number of MC points KFMCTrack::fNMCPoints. - int NMCPixelPoints() const { return fNMCPixelPoints; } ///< Returns number of MC points at the precise detectors KFMCTrack::fNMCPixelPoints. - bool IsReconstructed() const { return fIsReconstructed; } ///< Returns a flag showing if track was found by the reconstruction procedure. - bool IsOutOfDetector() const { return fIsOutOfDetector; } ///< Returns a flag showing if track was out of acceptance. - - void SetPar( int i, float v ) { fPar[i] = v; } ///< Sets a value "v" to the parameter with index "i". - void SetX( float v ) { fPar[0] = v; } ///< Sets X coordinate at the origin position of the track. - void SetY( float v ) { fPar[1] = v; } ///< Sets Y coordinate at the origin position of the track. - void SetZ( float v ) { fPar[2] = v; } ///< Sets Z coordinate at the origin position of the track. - void SetPx( float v ) { fPar[3] = v; } ///< Sets Px momentum component at the origin position of the track. - void SetPy( float v ) { fPar[4] = v; } ///< Sets Py momentum component at the origin position of the track. - void SetPz( float v ) { fPar[5] = v; } ///< Sets Pz momentum component at the origin position of the track. - void SetQP( float v ) { fPar[6] = v; } ///< Sets q/P at the origin position of the track. - void SetMotherId( int v ) { fMotherId = v; } ///< Sets a unique id of the mother track if track is secondary or primary vertex with a negative sign if it is primary. - void SetPDG( int v ) { fPDG = v; } ///< Sets PDG code of the current track. - void SetNMCPoints( int v ) { fNMCPoints = v; } ///< Sets number of MC points produced at the detector planes. - void SetNMCPixelPoints( int v ){ fNMCPixelPoints = v; } ///< Sets number of the MC points produced at the precise detectors. - void SetReconstructed() { fIsReconstructed = 1; } ///< Defines the track as reconstructed. - void SetNotReconstructed() { fIsReconstructed = 0; } ///< Defines the track as not reconstructed. - void SetOutOfDetector() { fIsOutOfDetector = 1; } ///< Defines the track out of acceptance. - protected: + int fMotherId; ///< Index of the mother track in tracks array. If track is produced at the primary vertex (PV) negative value with the PV Id is assigned. + int fPDG; ///< The PDG code of the current Monte Carlo track. + float fPar[7]; ///< Parameters of the track: { X, Y, Z, Px, Py, Pz, q/P }, where "q" is its charge. + int fNMCPoints; ///< Total number of Monte Carlo points produced by the simulation engine at the detector stations. + int fNMCPixelPoints; ///< Number of Monte Carlo points produced at the precise detectors (like MVD in CBM, HFT in STAR, ITS in ALICE, etc.). - int fMotherId; ///< Index of the mother track in tracks array. If track is produced at the primary vertex (PV) negative value with the PV Id is assigned. - int fPDG; ///< The PDG code of the current Monte Carlo track. - float fPar[7]; ///< Parameters of the track: { X, Y, Z, Px, Py, Pz, q/P }, where "q" is its charge. - int fNMCPoints; ///< Total number of Monte Carlo points produced by the simulation engine at the detector stations. - int fNMCPixelPoints; ///< Number of Monte Carlo points produced at the precise detectors (like MVD in CBM, HFT in STAR, ITS in ALICE, etc.). - bool fIsReconstructed; ///< A flag showing if track was found by the reconstruction procedure. Is required for correct efficiency calculation. bool fIsOutOfDetector; ///< A flag showing if track was out of acceptance. Is required for correct calculation of the acceptance. }; diff --git a/KFParticlePerformance/KFMCVertex.cxx b/KFParticlePerformance/KFMCVertex.cxx index b74d607..3077bb8 100644 --- a/KFParticlePerformance/KFMCVertex.cxx +++ b/KFParticlePerformance/KFMCVertex.cxx @@ -21,28 +21,30 @@ #include "KFMCVertex.h" -KFMCVertex::KFMCVertex():fDaughterTracks(0),fIsReconstructable(0),fIsMCReconstructable(0),fIsReconstructed(0),fNReconstructedDaughters(0),fIsTriggerPV(0) +KFMCVertex::KFMCVertex() : fDaughterTracks(0), fIsReconstructable(0), fIsMCReconstructable(0), fIsReconstructed(0), fNReconstructedDaughters(0), fIsTriggerPV(0) { - for( int i = 0; i < 3; i++) fPar[i] = 0; + for (int i = 0; i < 3; i++) + fPar[i] = 0; } -std::ostream& operator<<(std::ostream& out, const KFMCVertex &a) +std::ostream& operator<<(std::ostream& out, const KFMCVertex& a) { /** Operator to print coordinates of the MC vertex "a". ** \param[in] out - stream, where coordinates will be printed ** \param[in] a - vertex to be printed **/ - for (int i = 0; i < 3; i++) out << a.fPar[i] << std::endl; + for (int i = 0; i < 3; i++) + out << a.fPar[i] << std::endl; return out; } -std::istream& operator>>(std::istream& in, KFMCVertex &a) +std::istream& operator>>(std::istream& in, KFMCVertex& a) { /** Operator to read coordinates of the vertex from the input stream. ** \param[in] in - input stream ** \param[in] a - vertex, where the coordinates will be read in **/ - for (int i = 0; i < 3; i++) in >> a.fPar[i]; + for (int i = 0; i < 3; i++) + in >> a.fPar[i]; return in; } - diff --git a/KFParticlePerformance/KFMCVertex.h b/KFParticlePerformance/KFMCVertex.h index e17d920..0eeebc4 100644 --- a/KFParticlePerformance/KFMCVertex.h +++ b/KFParticlePerformance/KFMCVertex.h @@ -40,31 +40,30 @@ class KFMCVertex public: KFMCVertex(); - float Par( int i ) const { return fPar[i]; } ///< Returns parameter with index "i" from KFMCVertex::fPar - - float X() const { return fPar[0]; } ///< Returns X coordinate of the vertex. - float Y() const { return fPar[1]; } ///< Returns Y coordinate of the vertex. - float Z() const { return fPar[2]; } ///< Returns Z coordinate of the vertex. - - const float* GetPar() const { return fPar; } ///< Returns pointer to the parameters of the vertex KFMCVertex::fPar - - void SetPar( int i, float v ) { fPar[i] = v; } ///< Sets a value "v" to parameter "i". - - void SetX( float v ) { fPar[0] = v; } ///< Sets value "v" to the X coordinate. - void SetY( float v ) { fPar[1] = v; } ///< Sets value "v" to the Y coordinate. - void SetZ( float v ) { fPar[2] = v; } ///< Sets value "v" to the Z coordinate. - - int NDaughterTracks() const { return fDaughterTracks.size(); } ///< Returns number of Monte Carlo tracks produced at the current vertex. + float Par(int i) const { return fPar[i]; } ///< Returns parameter with index "i" from KFMCVertex::fPar + + float X() const { return fPar[0]; } ///< Returns X coordinate of the vertex. + float Y() const { return fPar[1]; } ///< Returns Y coordinate of the vertex. + float Z() const { return fPar[2]; } ///< Returns Z coordinate of the vertex. + + const float* GetPar() const { return fPar; } ///< Returns pointer to the parameters of the vertex KFMCVertex::fPar + + void SetPar(int i, float v) { fPar[i] = v; } ///< Sets a value "v" to parameter "i". + + void SetX(float v) { fPar[0] = v; } ///< Sets value "v" to the X coordinate. + void SetY(float v) { fPar[1] = v; } ///< Sets value "v" to the Y coordinate. + void SetZ(float v) { fPar[2] = v; } ///< Sets value "v" to the Z coordinate. + + int NDaughterTracks() const { return fDaughterTracks.size(); } ///< Returns number of Monte Carlo tracks produced at the current vertex. int NReconstructedDaughterTracks() const { return fNReconstructedDaughters; } ///< Returns number of reconstructed tracks from this vertex. - void AddDaughterTrack( int iTr ) { fDaughterTracks.push_back(iTr); } ///< Adds unique id of the Monte Carlo track produced at the current vertex. - int DaughterTrack( int iTr ) const - { + void AddDaughterTrack(int iTr) { fDaughterTracks.push_back(iTr); } ///< Adds unique id of the Monte Carlo track produced at the current vertex. + int DaughterTrack(int iTr) const + { /** Returns unique id of the Monte Carlo track from this vertex with index "iTr". ** \param[in] iTr - index of the track. **/ - if(iTr >= NDaughterTracks()) - { - std::cout << "ERROR!!!! MC PV contains only " << NDaughterTracks() << " tracks" << std::endl; + if (iTr >= NDaughterTracks()) { + std::cout << "ERROR!!!! MC PV contains only " << NDaughterTracks() << " tracks" << std::endl; return -1; } return fDaughterTracks[iTr]; @@ -72,27 +71,26 @@ class KFMCVertex bool IsMCReconstructable() const { return fIsMCReconstructable; } ///< Returns flag showing if the vertex can be found (definition is based on the MC tracks) bool IsReconstructable() const { return fIsReconstructable; } ///< Returns flag showing if the vertex can be found (definition is based on the reconstructed tracks) - bool IsReconstructed() const { return fIsReconstructed; } ///< Returns flag showing if the vertex was reconstructed - - void SetReconstructable() { fIsReconstructable = 1; } ///< Defines the current vertex as such that can be reconstructed (based on the reconstructed tracks) - void SetUnReconstructable() { fIsReconstructable = 0; } ///< Defines the current vertex as such that can not be reconstructed (based on the reconstructed tracks) - - void SetMCReconstructable() { fIsMCReconstructable = 1; } ///< Defines the current vertex as such that can be reconstructed (based on the MC tracks) - void SetMCUnReconstructable() { fIsMCReconstructable = 0; } ///< Defines the current vertex as such that can not be reconstructed (based on the MC tracks) - + bool IsReconstructed() const { return fIsReconstructed; } ///< Returns flag showing if the vertex was reconstructed + + void SetReconstructable() { fIsReconstructable = 1; } ///< Defines the current vertex as such that can be reconstructed (based on the reconstructed tracks) + void SetUnReconstructable() { fIsReconstructable = 0; } ///< Defines the current vertex as such that can not be reconstructed (based on the reconstructed tracks) + + void SetMCReconstructable() { fIsMCReconstructable = 1; } ///< Defines the current vertex as such that can be reconstructed (based on the MC tracks) + void SetMCUnReconstructable() { fIsMCReconstructable = 0; } ///< Defines the current vertex as such that can not be reconstructed (based on the MC tracks) + void SetReconstructed() { fIsReconstructed = 1; } ///< Defines the current vertex as such that was reconstructed void SetUnReconstructed() { fIsReconstructed = 0; } ///< Defines the current vertex as such that was not reconstructed void SetNReconstructedDaughters(int n) { fNReconstructedDaughters = n; } ///< Defines number of the reconstructed tracks produced at the current vertex. - + bool IsTriggerPV() const { return fIsTriggerPV; } ///< Returns flag showing if the vertex is considerred as tigger. void SetTriggerPV() { fIsTriggerPV = 1; } ///< Defines the current vertex as the trigger primary vertex. - - friend std::ostream& operator<<(std::ostream& out, const KFMCVertex &a); - friend std::istream& operator>>(std::istream& in, KFMCVertex &a); - protected: + friend std::ostream& operator<<(std::ostream& out, const KFMCVertex& a); + friend std::istream& operator>>(std::istream& in, KFMCVertex& a); + protected: float fPar[3]; ///< Cartesian coordinates of the vertex: { X, Y, Z }. std::vector fDaughterTracks; ///< Vector with unique ids of the Monte Carlo tracks produced at this vertex. bool fIsReconstructable; ///< Flag showing if the vertex considered as reconstructable based on the reconstructed tracks. diff --git a/KFParticlePerformance/KFPVEfficiencies.h b/KFParticlePerformance/KFPVEfficiencies.h index 4f09014..34b3a0c 100644 --- a/KFParticlePerformance/KFPVEfficiencies.h +++ b/KFParticlePerformance/KFPVEfficiencies.h @@ -44,26 +44,24 @@ ** another half form second group. **/ -class KFPVEfficiencies: public TNamed +class KFPVEfficiencies : public TNamed { public: - - KFPVEfficiencies(): - names(), - indices(), - ratio_reco(), - mc(), - reco(), - ratio_ghost(), - ratio_bg(), - ratio_clone(), - ghost(), - bg(), - clone() + KFPVEfficiencies() : names(), + indices(), + ratio_reco(), + mc(), + reco(), + ratio_ghost(), + ratio_bg(), + ratio_clone(), + ghost(), + bg(), + clone() { - AddCounter(Form("%s","PV"), Form("%-*s",12,"PV")); - AddCounter(Form("%s","PVtrigger"), Form("%-*s",12,"PV trigger")); - AddCounter(Form("%s","PVpileup"), Form("%-*s",12,"PV pileup ")); + AddCounter(Form("%s", "PV"), Form("%-*s", 12, "PV")); + AddCounter(Form("%s", "PVtrigger"), Form("%-*s", 12, "PV trigger")); + AddCounter(Form("%s", "PVpileup"), Form("%-*s", 12, "PV pileup ")); } virtual ~KFPVEfficiencies(){}; @@ -92,22 +90,26 @@ class KFPVEfficiencies: public TNamed }; /** \brief Operator to add efficiency table from object "a" to the current object. Returns the current object after addition. */ - KFPVEfficiencies& operator+=(KFPVEfficiencies& a){ - mc += a.mc; reco += a.reco; - ghost += a.ghost; bg += a.bg; clone += a.clone; + KFPVEfficiencies& operator+=(KFPVEfficiencies& a) + { + mc += a.mc; + reco += a.reco; + ghost += a.ghost; + bg += a.bg; + clone += a.clone; return *this; }; - + /** \brief Function to calculate efficiency after all counters are set. If the counters are modified the function should be called again. */ - void CalcEff(){ - ratio_reco = reco/mc; + void CalcEff() + { + ratio_reco = reco / mc; KFMCCounter allReco = reco + ghost + bg; - ratio_ghost = ghost/allReco; - ratio_bg = bg/allReco; - ratio_clone = clone/allReco; + ratio_ghost = ghost / allReco; + ratio_bg = bg / allReco; + ratio_clone = clone / allReco; }; - void Inc(bool isReco, int nClones, TString name) { @@ -119,10 +121,11 @@ class KFPVEfficiencies: public TNamed ** \param[in] name - "shortname" of the set of counters, which should be increased **/ const int index = indices[name]; - + mc.counters[index]++; - if (isReco) reco.counters[index]++; - if(nClones > 0) + if (isReco) + reco.counters[index]++; + if (nClones > 0) clone.counters[index] += nClones; }; @@ -135,45 +138,57 @@ class KFPVEfficiencies: public TNamed **/ const int index = indices[name]; - if (isGhost) ghost.counters[index]++; - if (isBg) bg.counters[index]++; + if (isGhost) + ghost.counters[index]++; + if (isBg) + bg.counters[index]++; }; /** \brief Prints the efficiency table on the screen. */ - void PrintEff(){ + void PrintEff() + { std::ios_base::fmtflags original_flags = std::cout.flags(); std::cout.setf(std::ios::fixed); std::cout.setf(std::ios::showpoint); std::cout.precision(3); std::cout << " : " - << " Eff " - <<" / "<< " Ghost " - <<" / "<< "BackGr " - <<" / "<< "Clone " - <<" / "<< "N Ghost" - <<" / "<< "N BackGr" - <<" / "<< "N Reco " - <<" / "<< "N Clone " - <<" | "<< " N MC " << std::endl; - + << " Eff " + << " / " + << " Ghost " + << " / " + << "BackGr " + << " / " + << "Clone " + << " / " + << "N Ghost" + << " / " + << "N BackGr" + << " / " + << "N Reco " + << " / " + << "N Clone " + << " | " + << " N MC " << std::endl; + int NCounters = mc.NCounters; - for (int iC = 0; iC < NCounters; iC++){ - std::cout << names[iC] - << " : " << std::setw(6) << ratio_reco.counters[iC] - << " / " << std::setw(6) << ratio_ghost.counters[iC] // particles w\o MCParticle - << " / " << std::setw(6) << ratio_bg.counters[iC] // particles with incorrect MCParticle - << " / " << std::setw(6) << ratio_clone.counters[iC] // particles with incorrect MCParticle - << " / " << std::setw(6) << ghost.counters[iC] - << " / " << std::setw(7) << bg.counters[iC] - << " / " << std::setw(6) << reco.counters[iC] - << " / " << std::setw(7) << clone.counters[iC] - << " | " << std::setw(6) << mc.counters[iC] << std::endl; + for (int iC = 0; iC < NCounters; iC++) { + std::cout << names[iC] + << " : " << std::setw(6) << ratio_reco.counters[iC] + << " / " << std::setw(6) << ratio_ghost.counters[iC] // particles w\o MCParticle + << " / " << std::setw(6) << ratio_bg.counters[iC] // particles with incorrect MCParticle + << " / " << std::setw(6) << ratio_clone.counters[iC] // particles with incorrect MCParticle + << " / " << std::setw(6) << ghost.counters[iC] + << " / " << std::setw(7) << bg.counters[iC] + << " / " << std::setw(6) << reco.counters[iC] + << " / " << std::setw(7) << clone.counters[iC] + << " | " << std::setw(6) << mc.counters[iC] << std::endl; } - std::cout.flags(original_flags); + std::cout.flags(original_flags); }; - + /** \brief Operator to write efficiencies to file. */ - friend std::fstream & operator<<(std::fstream &strm, KFPVEfficiencies &a) { + friend std::fstream& operator<<(std::fstream& strm, KFPVEfficiencies& a) + { strm << a.ratio_reco; strm << a.mc; @@ -188,7 +203,8 @@ class KFPVEfficiencies: public TNamed return strm; } /** \brief Operator to read efficiencies from file. */ - friend std::fstream & operator>>(std::fstream &strm, KFPVEfficiencies &a){ + friend std::fstream& operator>>(std::fstream& strm, KFPVEfficiencies& a) + { strm >> a.ratio_reco; strm >> a.mc; @@ -205,26 +221,26 @@ class KFPVEfficiencies: public TNamed /** \brief Adds efficiency from the file with the name defined by "fileName" to the current objects. */ void AddFromFile(TString fileName) { - std::fstream file(fileName.Data(),std::fstream::in); + std::fstream file(fileName.Data(), std::fstream::in); file >> *this; } private: - std::vector names; ///< Names of the counters. The same for all counters objects. - std::map indices; ///< Map between the counter index and its short name. + std::vector names; ///< Names of the counters. The same for all counters objects. + std::map indices; ///< Map between the counter index and its short name. - KFMCCounter ratio_reco; ///< Efficiency. + KFMCCounter ratio_reco; ///< Efficiency. - KFMCCounter mc; ///< Counters of the Monte Carlo vertices. - KFMCCounter reco; ///< Counters of the reconstructed vertices. + KFMCCounter mc; ///< Counters of the Monte Carlo vertices. + KFMCCounter reco; ///< Counters of the reconstructed vertices. KFMCCounter ratio_ghost; ///< Ratio of the ghost candidates to the total number of candidates. KFMCCounter ratio_bg; ///< Ratio of the physics background candidates to the total number of candidates. KFMCCounter ratio_clone; ///< Ratio of double reconstructed vertices to the total number of signal candidates. - KFMCCounter ghost; ///< Counters of the ghost candidates. - KFMCCounter bg; ///< Counters of the physics background candidates. - KFMCCounter clone; ///< Counters of the double reconstructed vertices. + KFMCCounter ghost; ///< Counters of the ghost candidates. + KFMCCounter bg; ///< Counters of the physics background candidates. + KFMCCounter clone; ///< Counters of the double reconstructed vertices. }; #endif diff --git a/KFParticlePerformance/KFPartEfficiencies.h b/KFParticlePerformance/KFPartEfficiencies.h index 1d41fad..f2b5aef 100644 --- a/KFParticlePerformance/KFPartEfficiencies.h +++ b/KFParticlePerformance/KFPartEfficiencies.h @@ -42,23 +42,22 @@ class KFEfficiencyParticleInfo { public: - KFEfficiencyParticleInfo():fName("null"),fTitle("null"),fPDG(0),fHistoMin(0.f),fHistoMax(0.f),fMass(0.f),fLifeTime(0.f),fCharge(0), fMassSigma(0.001) {}; + KFEfficiencyParticleInfo() : fName("null"), fTitle("null"), fPDG(0), fHistoMin(0.f), fHistoMax(0.f), fMass(0.f), fLifeTime(0.f), fCharge(0), fMassSigma(0.001){}; /** \brief Constructor with all parameters set in. There is no other way to define the parameters other then use this constructor.*/ - KFEfficiencyParticleInfo(std::string name, std::string title, int pdg, float histoMin, float histoMax, float mass, float lifeTime, int charge, float massSigma ): - fName(name), fTitle(title), fPDG(pdg), fHistoMin(histoMin), fHistoMax(histoMax), fMass(mass), fLifeTime(lifeTime), fCharge(charge), fMassSigma(massSigma) {}; - ~KFEfficiencyParticleInfo() {}; - + KFEfficiencyParticleInfo(std::string name, std::string title, int pdg, float histoMin, float histoMax, float mass, float lifeTime, int charge, float massSigma) : fName(name), fTitle(title), fPDG(pdg), fHistoMin(histoMin), fHistoMax(histoMax), fMass(mass), fLifeTime(lifeTime), fCharge(charge), fMassSigma(massSigma){}; + ~KFEfficiencyParticleInfo(){}; + //accessors - std::string Name() const { return fName; } ///< Returns name of the decay in the file with histograms. - std::string Title() const { return fTitle; } ///< Returns name of the decay in the output table with efficiency. - int PDG() const { return fPDG; } ///< Returns the assigned PDG code. - float HistoMin() const { return fHistoMin; } ///< Returns lower boundary in the mass histogram for the current decay. - float HistoMax() const { return fHistoMax; } ///< Returns upper boundary in the mass histogram for the current decay. - float Mass() const { return fMass; } ///< Returns table mass of the particle. - float LifeTime() const { return fLifeTime; } ///< Returns lifetime of the particle. - int Charge() const { return fCharge; } ///< Returns charge of the particle in units of the elementary charge. - float MassSigma() const { return fMassSigma; } ///< Returns expected width of the mass peak, used in the side bands method. - + std::string Name() const { return fName; } ///< Returns name of the decay in the file with histograms. + std::string Title() const { return fTitle; } ///< Returns name of the decay in the output table with efficiency. + int PDG() const { return fPDG; } ///< Returns the assigned PDG code. + float HistoMin() const { return fHistoMin; } ///< Returns lower boundary in the mass histogram for the current decay. + float HistoMax() const { return fHistoMax; } ///< Returns upper boundary in the mass histogram for the current decay. + float Mass() const { return fMass; } ///< Returns table mass of the particle. + float LifeTime() const { return fLifeTime; } ///< Returns lifetime of the particle. + int Charge() const { return fCharge; } ///< Returns charge of the particle in units of the elementary charge. + float MassSigma() const { return fMassSigma; } ///< Returns expected width of the mass peak, used in the side bands method. + private: std::string fName; ///< Name of the decay in the file with histograms. std::string fTitle; ///< Name of the decay in the output table with efficiency. @@ -90,982 +89,977 @@ class KFEfficiencyParticleInfo ** to parts due to the multiple scattering. **/ -class KFPartEfficiencies :public TObject +class KFPartEfficiencies : public TObject { public: - /** \brief The default constructor. Defines the list of decays to be analysed and their properties. Please, see the code for indexing scheme. */ - KFPartEfficiencies(): - partDaughterPdg(0), - names(), - indices(), - fPdgToIndex(), - ratio_reco1(), - ratio_reco2(), - ratio_reco3(), - mc1(), - mc2(), - mc3(), - reco(), - ratio_ghost(), - ratio_bg(), - ratio_clone(), - ghost(), - bg(), - clone() - { - KFEfficiencyParticleInfo particleInfo[nParticles] = - { - // name title PDG code min max mass lifetime Q + KFPartEfficiencies() : partDaughterPdg(0), + names(), + indices(), + fPdgToIndex(), + ratio_reco1(), + ratio_reco2(), + ratio_reco3(), + mc1(), + mc2(), + mc3(), + reco(), + ratio_ghost(), + ratio_bg(), + ratio_clone(), + ghost(), + bg(), + clone() + { + KFEfficiencyParticleInfo particleInfo[nParticles] = + { + // name title PDG code min max mass lifetime Q #ifdef CBM - KFEfficiencyParticleInfo("Ks", "KShort ", 310, 0.3f, 1.3f, 0.497614 , 8.954e-11, 0, 0.0045), //0 + KFEfficiencyParticleInfo("Ks", "KShort ", 310, 0.3f, 1.3f, 0.497614, 8.954e-11, 0, 0.0045), //0 #else - KFEfficiencyParticleInfo("Ks", "KShort ", 310, 0.3f, 1.3f, 0.497614 , 8.954e-11, 0, 0.0057), //0 + KFEfficiencyParticleInfo("Ks", "KShort ", 310, 0.3f, 1.3f, 0.497614, 8.954e-11, 0, 0.0057), //0 #endif - KFEfficiencyParticleInfo("Lambda", "Lambda ", 3122, 1.0f, 2.0f, 1.115683 , 2.632e-10, 0, 0.0020), //1 - KFEfficiencyParticleInfo("Lambdab", "Lambda b ", -3122, 1.0f, 2.0f, 1.115683 , 2.632e-10, 0, 0.0020), //2 - KFEfficiencyParticleInfo("Xi-", "Xi- ", 3312, 1.0f, 3.0f, 1.32171 , 1.639e-10, -1, 0.0022), //3 - KFEfficiencyParticleInfo("Xi+", "Xi+ ", -3312, 1.0f, 3.0f, 1.32171 , 1.639e-10, 1, 0.0022), //4 - KFEfficiencyParticleInfo("Xi0", "Xi0 ", 3322, 1.0f, 3.0f, 1.31486 , 2.9e-10, 0, 0.0030), //5 - KFEfficiencyParticleInfo("Xi0b", "Xi0 b ", -3322, 1.0f, 3.0f, 1.31486 , 2.9e-10, 0, 0.0030), //6 - KFEfficiencyParticleInfo("Omega-", "Omega- ", 3334, 1.0f, 3.0f, 1.67245 , 0.821e-10, -1, 0.0022), //7 - KFEfficiencyParticleInfo("Omega+", "Omega+ ", -3334, 1.0f, 3.0f, 1.67245 , 0.821e-10, 1, 0.0022), //8 - KFEfficiencyParticleInfo("Sigma^0", "Sigma0 ", 3212, 1.0f, 3.0f, 1.192642 , 7.4e-20, 0, 0.0030), //9 - KFEfficiencyParticleInfo("Sigma^0b", "Sigma0 b ", -3212, 1.0f, 3.0f, 1.192642 , 7.4e-20, 0, 0.0030), //10 - KFEfficiencyParticleInfo("Sigma^+", "Sigma+ ", 3222, 1.0f, 3.0f, 1.18937 , 0.8018e-10, 1, 0.0030), //11 - KFEfficiencyParticleInfo("Sigma^-b", "Sigma- b ", -3222, 1.0f, 3.0f, 1.18937 , 0.8018e-10,-1, 0.0030), //12 - KFEfficiencyParticleInfo("K*0", "K*0 ", 313, 0.6f, 2.6f, 0.8958 , 1.38e-23, 0, 0.0300), //13 - KFEfficiencyParticleInfo("K*0b", "K*0 b ", -313, 0.6f, 2.6f, 0.8958 , 1.38e-23, 0, 0.0300), //14 - KFEfficiencyParticleInfo("K*+", "K*+ ", 323, 0.6f, 2.6f, 0.89166 , 1.30e-23, 1, 0.0300), //15 - KFEfficiencyParticleInfo("K*-", "K*- ", -323, 0.6f, 2.6f, 0.89166 , 1.30e-23, -1, 0.0300), //16 - KFEfficiencyParticleInfo("K*0_K0,pi0", "K*0_K0pi0 ", 100313, 0.6f, 2.6f, 0.8958 , 1.38e-23, 0, 0.0030), //17 - KFEfficiencyParticleInfo("K*+_K+,pi0", "K*+_K+pi0 ", 100323, 0.6f, 2.6f, 0.89166 , 1.30e-23, 1, 0.0030), //18 - KFEfficiencyParticleInfo("K*-_K-,pi0", "K*-_K-pi0 ", -100323, 0.6f, 2.6f, 0.89166 , 1.30e-23, -1, 0.0030), //19 - KFEfficiencyParticleInfo("Sigma*+", "Sigma*+ ", 3224, 1.0f, 3.0f, 1.3828 , 1.83e-23, 1, 0.0100), //20 - KFEfficiencyParticleInfo("Sigma*-", "Sigma*- ", 3114, 1.0f, 3.0f, 1.3872 , 1.67e-23, -1, 0.0100), //21 - KFEfficiencyParticleInfo("Sigma*+b", "Sigma*+ b ", -3114, 1.0f, 3.0f, 1.3828 , 1.83e-23, -1, 0.0100), //22 - KFEfficiencyParticleInfo("Sigma*-b", "Sigma*- b ", -3224, 1.0f, 3.0f, 1.3872 , 1.67e-23, 1, 0.0100), //23 - KFEfficiencyParticleInfo("Sigma*0", "Sigma*0 ", 3214, 1.0f, 3.0f, 1.3837 , 1.83e-23, 0, 0.0030), //24 - KFEfficiencyParticleInfo("Sigma*0b", "Sigma*0 b ", -3214, 1.0f, 3.0f, 1.3837 , 1.83e-23, 0, 0.0030), //25 - KFEfficiencyParticleInfo("Lambda*", "Lambda* ", 3124, 1.4f, 3.4f, 1.5195 , 4.22e-23, 0, 0.0100), //26 - KFEfficiencyParticleInfo("Lambda*b", "Lambda* b ", -3124, 1.4f, 3.4f, 1.5195 , 4.22e-23, 0, 0.0100), //27 - KFEfficiencyParticleInfo("Xi*0", "Xi*0 ", 3324, 1.4f, 3.4f, 1.53180 , 7.23e-23, 0, 0.0100), //28 - KFEfficiencyParticleInfo("Xi*0b", "Xi*0 b ", -3324, 1.4f, 3.4f, 1.53180 , 7.23e-23, 0, 0.0100), //29 - KFEfficiencyParticleInfo("Xi*-_LK", "Xi*-_lk ", 1003314, 1.4f, 3.4f, 1.823 , 2.74e-23, -1, 0.0030), //30 - KFEfficiencyParticleInfo("Xi*+_LK", "Xi*+_lk ", -1003314, 1.4f, 3.4f, 1.823 , 2.74e-23, 1, 0.0030), //31 - KFEfficiencyParticleInfo("Xi*-_xi-,pi0", "Xi*-_XiPi ", 3314, 1.4f, 3.4f, 1.535 , 6.65e-23, -1, 0.0030), //32 - KFEfficiencyParticleInfo("Xi*+_xi+,pi0", "Xi*+_XiPi ", -3314, 1.4f, 3.4f, 1.535 , 6.65e-23, 1, 0.0030), //33 - KFEfficiencyParticleInfo("Omega*-", "Omega*- ", 1003334, 1.8f, 3.8f, 2.252 , 1.2e-23, -1, 0.0030), //34 - KFEfficiencyParticleInfo("Omega*+", "Omega*+ ", -1003334, 1.8f, 3.8f, 2.252 , 1.2e-23, 1, 0.0030), //35 - KFEfficiencyParticleInfo("H0_LL", "H0_LL ", 3000, 1.5f, 3.5f, 2.21 , 1.32e-10, 0, 0.0030), //36 - KFEfficiencyParticleInfo("phi_KK", "phi_KK ", 333, 0.8f, 2.8f, 1.019455 , 1.55e-22, 0, 0.0030), //37 - KFEfficiencyParticleInfo("rho_pipi", "rho_pipi ", 113, 0.0f, 2.0f, 0.77526 , 4.45e-24, 0, 0.0030), //38 - KFEfficiencyParticleInfo("rho_ee", "rho_ee ", 100113, 0.0f, 2.0f, 0.77526 , 4.45e-24, 0, 0.0030), //39 - KFEfficiencyParticleInfo("rho_mm", "rho_mm ", 200113, 0.0f, 2.0f, 0.77526 , 4.45e-24, 0, 0.0030), //40 - KFEfficiencyParticleInfo("gamma", "gamma ", 22, 0.0f, 3.0f, 0. , 1.e20, 0, 0.0030), //41 - KFEfficiencyParticleInfo("pi0", "pi0 ", 111, 0.0f, 3.0f, 0.1349766 , 8.52e-17, 0, 0.0030), //42 - KFEfficiencyParticleInfo("eta", "eta ", 221, 0.0f, 3.0f, 0.547862 , 5.0e-19, 0, 0.0030), //43 -//Delta and N resonances - KFEfficiencyParticleInfo("Delta0", "Delta0 ", 2114, 1.0f, 3.0f, 1.232 , 5.63e-24, 0, 0.0030), //44 - KFEfficiencyParticleInfo("Delta0 b", "Delta0 b ", -2114, 1.0f, 3.0f, 1.232 , 5.63e-24, 0, 0.0030), //45 - KFEfficiencyParticleInfo("Delta++", "Delta++ ", 2224, 1.0f, 3.0f, 1.232 , 5.63e-24, 2, 0.0030), //46 - KFEfficiencyParticleInfo("Delta-- b", "Delta-- b ", -2224, 1.0f, 3.0f, 1.232 , 5.63e-24, -2, 0.0030), //47 -//charmonium - KFEfficiencyParticleInfo("JPsi_ee", "JPsi_ee ", 443, 1.0f, 4.0f, 3.096916 , 7.1e-21, 0, 0.0030), //48 - KFEfficiencyParticleInfo("JPsi_mumu", "JPsi_mm ", 100443, 1.0f, 4.0f, 3.096916 , 7.1e-21, 0, 0.0030), //49 - KFEfficiencyParticleInfo("JPsi_pp", "JPsi_pp ", 200443, 1.0f, 4.0f, 3.096916 , 7.1e-21, 0, 0.0030), //50 - KFEfficiencyParticleInfo("JPsi_LL", "JPsi_LL ", 300443, 2.0f, 5.0f, 3.096916 , 7.1e-21, 0, 0.0030), //51 - KFEfficiencyParticleInfo("JPsi_XiXi", "JPsi_XiXi ", 400443, 2.0f, 5.0f, 3.096916 , 7.1e-21, 0, 0.0030), //52 - KFEfficiencyParticleInfo("Psi_OO", "Psi_OO ", 500443, 3.0f, 6.0f, 3.686109 , 2.1e-22, 0, 0.0030), //53 -//open charm - KFEfficiencyParticleInfo("D0", "D0 ", 421, 0.6f, 3.6f, 1.86486 , 4.1e-13, 0, 0.0154), //54 - KFEfficiencyParticleInfo("D0b", "D0b ", -421, 0.6f, 3.6f, 1.86486 , 4.1e-13, 0, 0.0154), //55 - KFEfficiencyParticleInfo("D0_4", "D0_4 ", 429, 0.6f, 3.6f, 1.86486 , 4.1e-13, 0, 0.0100), //56 - KFEfficiencyParticleInfo("D0b_4", "D0b_4 ", -429, 0.6f, 3.6f, 1.86486 , 4.1e-13, 0, 0.0100), //57 - KFEfficiencyParticleInfo("D0_pipi", "D0_pipi ", 420, 0.6f, 3.6f, 1.86486 , 4.1e-13, 0, 0.0154), //58 - KFEfficiencyParticleInfo("D0_2pi2pi", "D0_2pi2pi ", 470, 0.6f, 3.6f, 1.86486 , 4.1e-13, 0, 0.0154), //59 - KFEfficiencyParticleInfo("D0_K0pipi", "D0_K0pipi ", 425, 0.6f, 3.6f, 1.86486 , 4.1e-13, 0, 0.0150), //60 - KFEfficiencyParticleInfo("D0_KK", "D0_KK ", 426, 0.6f, 3.6f, 1.86486 , 4.1e-13, 0, 0.0130), //61 - KFEfficiencyParticleInfo("D0_KKK0", "D0_KKK0 ", 427, 0.6f, 3.6f, 1.86486 , 4.1e-13, 0, 0.0154), //62 - KFEfficiencyParticleInfo("D0_pi0", "D0_#pi0 ", 428, 1.0f, 3.0f, 1.86486 , 4.1e-13, 0, 0.0030), //63 - KFEfficiencyParticleInfo("D+", "D+ ", 411, 1.0f, 3.0f, 1.86962 , 1.04e-13, 1, 0.0114), //64 - KFEfficiencyParticleInfo("D-", "D- ", -411, 1.0f, 3.0f, 1.86962 , 1.04e-13, -1, 0.0114), //65 - KFEfficiencyParticleInfo("D+_K0pi+", "D+_K0pi+ ", 100411, 0.6f, 4.6f, 1.86962 , 1.04e-13, 1, 0.0030), //66 - KFEfficiencyParticleInfo("D-_K0pi-", "D-_K0pi- ", -100411, 0.6f, 4.6f, 1.86962 , 1.04e-13, -1, 0.0030), //67 - KFEfficiencyParticleInfo("D+_K03pi", "D+_K03pi ", 200411, 0.6f, 4.6f, 1.86962 , 1.04e-13, 1, 0.0030), //68 - KFEfficiencyParticleInfo("D-_K03pi", "D-_K03pi ", -200411, 0.6f, 4.6f, 1.86962 , 1.04e-13, -1, 0.0030), //69 - KFEfficiencyParticleInfo("D+_3pi", "D+_3pi ", 300411, 0.6f, 4.6f, 1.86962 , 1.04e-13, 1, 0.0030), //70 - KFEfficiencyParticleInfo("D-_3pi", "D-_3pi ", -300411, 0.6f, 4.6f, 1.86962 , 1.04e-13, -1, 0.0030), //71 - KFEfficiencyParticleInfo("Ds+", "Ds+ ", 431, 1.0f, 3.0f, 1.96850 , 5.0e-13, 1, 0.0110), //72 - KFEfficiencyParticleInfo("Ds-", "Ds- ", -431, 1.0f, 3.0f, 1.96850 , 5.0e-13, -1, 0.0110), //73 - KFEfficiencyParticleInfo("Ds+_K0K+", "Ds+_K0K+ ", 100431, 1.0f, 3.0f, 1.96850 , 5.0e-13, 1, 0.0030), //74 - KFEfficiencyParticleInfo("Ds-_K0K-", "Ds-_K0K- ", -100431, 1.0f, 3.0f, 1.96850 , 5.0e-13, -1, 0.0030), //75 - KFEfficiencyParticleInfo("Ds+_K0K0pi+", "Ds+_K0K0pi+ ", 200431, 1.0f, 3.0f, 1.96850 , 5.0e-13, 1, 0.0030), //76 - KFEfficiencyParticleInfo("Ds-_K0K0pi-", "Ds-_K0K0pi- ", -200431, 1.0f, 3.0f, 1.96850 , 5.0e-13, -1, 0.0030), //77 - KFEfficiencyParticleInfo("Ds+_K0K+pipi", "Ds+_K0K+pipi ", 300431, 1.0f, 3.0f, 1.96850 , 5.0e-13, 1, 0.0030), //78 - KFEfficiencyParticleInfo("Ds-_K0K-pipi", "Ds-_K0K-pipi ", -300431, 1.0f, 3.0f, 1.96850 , 5.0e-13, -1, 0.0030), //79 - KFEfficiencyParticleInfo("Ds+_K+pipi", "Ds+_K+pipi ", 400431, 1.0f, 3.0f, 1.96850 , 5.0e-13, 1, 0.0030), //80 - KFEfficiencyParticleInfo("Ds-_K-pipi", "Ds-_K-pipi ", -400431, 1.0f, 3.0f, 1.96850 , 5.0e-13, -1, 0.0030), //81 - KFEfficiencyParticleInfo("Lc", "Lambdac ", 4122, 1.8f, 3.8f, 2.28646 , 2.0e-13, 1, 0.0110), //82 - KFEfficiencyParticleInfo("Lcb", "Lambdac b ", -4122, 1.8f, 3.8f, 2.28646 , 2.0e-13, -1, 0.0110), //83 - KFEfficiencyParticleInfo("Lc_{pK0}", "Lc {pK0} ", 104122, 1.8f, 3.8f, 2.28646 , 2.0e-13, 1, 0.0030), //84 - KFEfficiencyParticleInfo("Lcb_{pK0}", "Lc b {pK0} ", -104122, 1.8f, 3.8f, 2.28646 , 2.0e-13, -1, 0.0030), //85 - KFEfficiencyParticleInfo("Lc_{pK02pi}", "Lc {pK02pi} ", 204122, 1.8f, 3.8f, 2.28646 , 2.0e-13, 1, 0.0030), //86 - KFEfficiencyParticleInfo("Lcb_{pK02pi}", "Lc b {pK02pi} ", -204122, 1.8f, 3.8f, 2.28646 , 2.0e-13, -1, 0.0030), //87 - KFEfficiencyParticleInfo("Lc_{Lpi}", "Lc {Lpi} ", 304122, 1.8f, 3.8f, 2.28646 , 2.0e-13, 1, 0.0030), //88 - KFEfficiencyParticleInfo("Lcb_{Lpi}", "Lc b {Lpi} ", -304122, 1.8f, 3.8f, 2.28646 , 2.0e-13, -1, 0.0030), //89 - KFEfficiencyParticleInfo("Lc_{L3pi}", "Lc {L3pi} ", 404122, 1.8f, 3.8f, 2.28646 , 2.0e-13, 1, 0.0030), //90 - KFEfficiencyParticleInfo("Lcb_{L3pi}", "Lc b {L3pi} ", -404122, 1.8f, 3.8f, 2.28646 , 2.0e-13, -1, 0.0030), //91 - KFEfficiencyParticleInfo("Lc_{p2pi}", "Lc {p2pi} ", 504122, 1.8f, 3.8f, 2.28646 , 2.0e-13, 1, 0.0030), //92 - KFEfficiencyParticleInfo("Lcb_{p2pi}", "Lc b {p2pi} ", -504122, 1.8f, 3.8f, 2.28646 , 2.0e-13, -1, 0.0030), //93 - KFEfficiencyParticleInfo("Xic0", "Xic0 ", 4132, 2.1f, 4.1f, 2.47087 , 1.0e-13, 0, 0.0030), //94 - KFEfficiencyParticleInfo("Xic0b", "Xic0b ", -4132, 2.1f, 4.1f, 2.47087 , 1.0e-13, 0, 0.0030), //95 - KFEfficiencyParticleInfo("D*0", "D*0 ", 10421, 1.8f, 3.8f, 2.00699 , 3.0e-22, 0, 0.0030), //96 - KFEfficiencyParticleInfo("D*0b", "D*0 b ", -10421, 1.8f, 3.8f, 2.00699 , 3.0e-22, 0, 0.0030), //97 - KFEfficiencyParticleInfo("D*+", "D*+ ", 10411, 1.8f, 3.8f, 2.01029 , 6.86e-21, 1, 0.0030), //98 - KFEfficiencyParticleInfo("D*-", "D*- ", -10411, 1.8f, 3.8f, 2.01029 , 6.86e-21, -1, 0.0030), //99 - KFEfficiencyParticleInfo("D*+_4", "D*+_4 ", 20411, 1.8f, 3.8f, 2.01029 , 6.86e-21, 1, 0.0030), //100 - KFEfficiencyParticleInfo("D*-_4", "D*-_4 ", -20411, 1.8f, 3.8f, 2.01029 , 6.86e-21, -1, 0.0030), //101 - KFEfficiencyParticleInfo("D0*_pi0", "D0*_#pi0 ", 10428, 1.8f, 3.8f, 2.00699 , 6.86e-21, 0, 0.0030), //102 -//B mesons - KFEfficiencyParticleInfo("B_Jpsi_ee", "B_Jpsi_ee ", 500, 1.0f, 4.0f, 3.096916 , 7.1e-21, 0, 0.0030), //103 - KFEfficiencyParticleInfo("B_Jpsi_mm", "B_Jpsi_mm ", 501, 1.0f, 4.0f, 3.096916 , 7.1e-21, 0, 0.0030), //104 - KFEfficiencyParticleInfo("B+_D0bPi+", "B+ {D0bPi+} ", 521, 3.0f, 7.0f, 5.27931 , 1.638e-12, 0, 0.0030), //105 - KFEfficiencyParticleInfo("B-_D0Pi-", "B- {D0Pi-} ", -521, 3.0f, 7.0f, 5.27931 , 1.638e-12, 0, 0.0030), //106 - KFEfficiencyParticleInfo("B+_D0bK+", "B+ {D0bK+} ", 529, 3.0f, 7.0f, 5.27931 , 1.638e-12, 0, 0.0030), //107 - KFEfficiencyParticleInfo("B-_D0K-", "B- {D0K+} ", -529, 3.0f, 7.0f, 5.27931 , 1.638e-12, 0, 0.0030), //108 - KFEfficiencyParticleInfo("B0_D-Pi+", "B0 {D-Pi+} ", 511, 3.0f, 7.0f, 5.27962 , 1.520e-12, 0, 0.0030), //109 - KFEfficiencyParticleInfo("B0b_D+Pi-", "B0b {D+Pi-} ", -511, 3.0f, 7.0f, 5.27962 , 1.520e-12, 0, 0.0030), //110 - KFEfficiencyParticleInfo("B0_D-K+", "B0 {D-K+} ", 519, 3.0f, 7.0f, 5.27962 , 1.520e-12, 0, 0.0030), //111 - KFEfficiencyParticleInfo("B0b_D+K-", "B0b {D+K-} ", -519, 3.0f, 7.0f, 5.27962 , 1.520e-12, 0, 0.0030), //112 - KFEfficiencyParticleInfo("H0_{Lppi}", "H0 ", 3001, 2.0f, 4.0f, 2.21 , 1.32e-10, 0, 0.0030), //113 -//hypernuclei - KFEfficiencyParticleInfo("LambdaN", "LambdaN ", 3003, 1.0f, 3.0f, 2.05395 , 1.00e-10, 0, 0.0030), //114 - KFEfficiencyParticleInfo("LambdaNb", "LambdaN b ", -3003, 1.0f, 3.0f, 2.05395 , 1.00e-10, 0, 0.0030), //115 - KFEfficiencyParticleInfo("LambdaNN", "LambdaNN ", 3103, 2.0f, 4.0f, 2.99352 , 1.00e-10, 0, 0.0030), //116 - KFEfficiencyParticleInfo("LambdaNNb", "LambdaNN b ", -3103, 2.0f, 4.0f, 2.99352 , 1.00e-10, 0, 0.0030), //117 - KFEfficiencyParticleInfo("H3L", "H3L ", 3004, 2.0f, 4.0f, 2.99339 , 1.85e-10, 1, 0.0030), //118 - KFEfficiencyParticleInfo("H3Lb", "H3L b ", -3004, 2.0f, 4.0f, 2.99339 , 1.85e-10, -1, 0.0030), //119 - KFEfficiencyParticleInfo("H4L", "H4L ", 3005, 3.0f, 5.0f, 3.92975 , 1.80e-10, 1, 0.0030), //120 - KFEfficiencyParticleInfo("H4Lb", "H4L b ", -3005, 3.0f, 5.0f, 3.92975 , 1.80e-10, -1, 0.0030), //121 - KFEfficiencyParticleInfo("He4L", "He4L ", 3006, 3.0f, 5.0f, 3.93070 , 1.50e-10, 2, 0.0030), //122 - KFEfficiencyParticleInfo("He4Lb", "He4L b ", -3006, 3.0f, 5.0f, 3.93070 , 1.50e-10, -2, 0.0030), //123 - KFEfficiencyParticleInfo("He5L", "He5L ", 3007, 4.0f, 6.0f, 4.86824 , 1.40e-10, 2, 0.0030), //124 - KFEfficiencyParticleInfo("He5Lb", "He5L b ", -3007, 4.0f, 6.0f, 4.86824 , 1.40e-10, -2, 0.0030), //125 - KFEfficiencyParticleInfo("LLn", "LLn ", 3203, 3.0f, 5.0f, 3.16964 , 1.00e-10, 0, 0.0030), //126 - KFEfficiencyParticleInfo("H4LL_{He4Lpi-}", "H4LL_{He4Lpi-}", 3008, 3.0f, 5.0f, 4.10791 , 1.0e-10, 1, 0.0030), //127 - KFEfficiencyParticleInfo("H4LL_{H3Lppi-}", "H4LL_{H3Lppi-}", 3009, 3.0f, 5.0f, 4.10791 , 1.0e-10, 1, 0.0030), //128 - KFEfficiencyParticleInfo("H5LL_{He5Lpi-}", "H5LL_{He5Lpi-}", 3010, 4.0f, 6.0f, 5.04748 , 1.0e-10, 1, 0.0030), //129 - KFEfficiencyParticleInfo("He6LL", "He6LL ", 3011, 5.0f, 7.0f, 5.98575 , 1.0e-10, 2, 0.0030), //130 -//missing mass method - KFEfficiencyParticleInfo("pi-_{mu,nu}", "pi-_{mnu} ", -7000211,-1.0f, 1.0f, 0.139570 , 2.6e-8, -1, 0.0030), //131 - KFEfficiencyParticleInfo("nu_{pi-}", "nu_{mupi-} b ", -7000014,-1.0f, 1.0f, 0. , 1.0e20, 0, 0.0030), //132 - KFEfficiencyParticleInfo("pi+_{mu,nu}", "pi+_{mnu} ", 7000211,-1.0f, 1.0f, 0.139570 , 2.6e-8, 1, 0.0030), //133 - KFEfficiencyParticleInfo("nu_{pi+}", "nu_{mupi+} ", 7000014,-1.0f, 1.0f, 0. , 1.0e20, 0, 0.0030), //134 - KFEfficiencyParticleInfo("K-_{mu,nu}", "K-_{mnu} ", -7000321,-1.0f, 1.0f, 0.493677 , 1.238e-8, -1, 0.0030), //135 - KFEfficiencyParticleInfo("nu_{K-}", "nu_{K-} b ", -8000014,-1.0f, 1.0f, 0. , 1.0e20, 0, 0.0030), //136 - KFEfficiencyParticleInfo("K+_{mu,nu}", "K+_{mnu} ", 7000321,-1.0f, 1.0f, 0.493677 , 1.238e-8, 1, 0.0030), //137 - KFEfficiencyParticleInfo("nu_{K+}", "nu_{K+} ", 8000014,-1.0f, 1.0f, 0. , 1.0e20, 0, 0.0030), //138 - KFEfficiencyParticleInfo("Sigma-_{pi-,n}", "Sigma-_{pi-n} ", 7003112, 0.0f, 3.0f, 1.192642 , 1.479e-10, -1, 0.0100), //139 - KFEfficiencyParticleInfo("n_{Sigma-}", "n_{Sigma-} ", 7002112, 0.0f, 1.5f, 0.9395654 , 880, 0, 0.0030), //140 - KFEfficiencyParticleInfo("Sigma+_{pi+n}b", "Sigma+{pi+n} b", -7003112, 0.0f, 3.0f, 1.192642 , 1.479e-10, -1, 0.0030), //141 - KFEfficiencyParticleInfo("n_{Sigma+} b", "n_{Sigma+b} b ", -7002112, 0.0f, 1.5f, 0.9395654 , 880, 0, 0.0030), //142 - KFEfficiencyParticleInfo("Sigma-_{pi-n}b", "Sigma+{pi-n} b", -7003222, 0.0f, 3.0f, 1.18937 , 0.8018e-10, 1, 0.0030), //143 - KFEfficiencyParticleInfo("n_{Sigma-} b", "n_{Sigma-_b} b", -8002112, 0.0f, 1.5f, 0.9395654 , 0.93956541, 0, 0.0030), //144 - KFEfficiencyParticleInfo("Sigma+_{pi+n}", "Sigma+_{pi+n} ", 7003222, 0.0f, 3.0f, 1.18937 , 0.8018e-10, 1, 0.0100), //145 - KFEfficiencyParticleInfo("n_{Sigma+}", "n_{Sigma+} ", 8002112, 0.0f, 1.5f, 0.9395654 , 880, 0, 0.0030), //146 - KFEfficiencyParticleInfo("Xi-_{pi-L}", "Xi-_{pi-L} ", 7003312, 0.0f, 3.0f, 1.32171 , 1.639e-10, -1, 0.0030), //147 - KFEfficiencyParticleInfo("Lambda_{Xi-}", "Lambda_{Xi-} ", 7003122, 0.0f, 2.0f, 1.115683 , 2.632e-10, 0, 0.0030), //148 - KFEfficiencyParticleInfo("Xi+_{pi+L_b}", "Xi+_{pi+L_b} ", -7003312, 0.0f, 3.0f, 1.32171 , 1.639e-10, 1, 0.0030), //149 - KFEfficiencyParticleInfo("Lambda_{Xi+} b", "Lambda_{Xi+} b", -7003122, 0.0f, 2.0f, 1.115683 , 2.632e-10, 0, 0.0030), //150 - KFEfficiencyParticleInfo("Omega-_{Xi-pi0}", "Omega-{pi-Xi0}", 7003334, 0.0f, 3.0f, 1.67245 , 0.821e-10, -1, 0.0030), //151 - KFEfficiencyParticleInfo("Xi0_{Omega-}", "Xi0_{Omega-} ", 7003322, 0.0f, 3.0f, 1.31486 , 2.9e-10, 0, 0.0030), //152 - KFEfficiencyParticleInfo("Omega+_{Xi+pi0}", "Omega+_{Xipi0}", -7003334, 0.0f, 3.0f, 1.67245 , 0.821e-10, 1, 0.0030), //153 - KFEfficiencyParticleInfo("Xi0_{Omega+} b", "Xi0_{Omega+} b", -7003322, 0.0f, 3.0f, 1.31486 , 2.9e-10, 0, 0.0030), //154 - KFEfficiencyParticleInfo("K-_{pi-pi0}", "K-_{pi-pi0} ", -9000321, 0.0f, 3.0f, 0.493677 , 1.24e-8, -1, 0.0030), //155 - KFEfficiencyParticleInfo("pi0_{K-}", "pi0_{K-} ", -9000111, 0.0f, 3.0f, 0.1349766 , 8.52e-17, 0, 0.0030), //156 - KFEfficiencyParticleInfo("K+_{pi+pi0}", "K+_{pi+pi0} ", 9000321, 0.0f, 3.0f, 0.493677 , 1.24e-8, 1, 0.0030), //157 - KFEfficiencyParticleInfo("pi0_{K+}", "pi0_{K+} ", 9000111, 0.0f, 3.0f, 0.1349766 , 8.52e-17, 0, 0.0030), //158 - KFEfficiencyParticleInfo("Omega-{K-L}", "Omega-_{K-L} ", 8003334, 0.0f, 3.0f, 1.67245 , 0.821e-10, -1, 0.0030), //159 - KFEfficiencyParticleInfo("Lambda_{Omega-}", "Lambda_{O-} ", 8003122, 0.0f, 3.0f, 1.115683 , 2.632e-10, 0, 0.0030), //160 - KFEfficiencyParticleInfo("Omega+_{K+L_b}", "Omega+_{K+Lb} ", -8003334, 0.0f, 3.0f, 1.67245 , 0.821e-10, 1, 0.0030), //161 - KFEfficiencyParticleInfo("Lamda_{Omega+} b", "Lambda_{O+} b ", -8003122, 0.0f, 3.0f, 1.115683 , 2.632e-10, 0, 0.0030), //162 - KFEfficiencyParticleInfo("Sigma-{p_b pi0} b","Sigma-{ppi0} b", -8003222, 0.0f, 3.0f, 1.18937 , 0.8018e-10, 1, 0.0030), //163 - KFEfficiencyParticleInfo("pi0_{Sigma-b}", "pi0_{Sigma-_b}", -8000111, 0.0f, 3.0f, 0.1349766 , 8.52e-17, 0, 0.0030), //164 - KFEfficiencyParticleInfo("Sigma+_{p pi0}", "Sigma+_{ppi0} ", 8003222, 0.0f, 3.0f, 1.18937 , 0.8018e-10, 1, 0.0250), //165 - KFEfficiencyParticleInfo("pi0_{Sigma+}", "pi0_{Sigma+} ", 8000111, 0.0f, 3.0f, 0.1349766 , 8.52e-17, 0, 0.0030), //166 -//tracks - KFEfficiencyParticleInfo("e-", "e- ", 11, 0.0f,0.01f, 5.485799e-4, 1.0e20, -1, 0.0030), //167 - KFEfficiencyParticleInfo("e+", "e+ ", -11, 0.0f,0.01f, 5.485799e-4, 1.0e20, 1, 0.0030), //168 - KFEfficiencyParticleInfo("mu-", "mu- ", 13, 0.0f, 1.0f, 0.105658 , 2.2e-6, -1, 0.0030), //169 - KFEfficiencyParticleInfo("mu+", "mu+ ", -13, 0.0f, 1.0f, 0.105658 , 2.2e-6, 1, 0.0030), //170 - KFEfficiencyParticleInfo("pi+", "pi+ ", 211, 0.0f, 1.0f, 0.139570 , 2.6e-8, 1, 0.0030), //171 - KFEfficiencyParticleInfo("pi-", "pi- ", -211, 0.0f, 1.0f, 0.139570 , 2.6e-8, -1, 0.0030), //172 - KFEfficiencyParticleInfo("K+", "K+ ", 321, 0.0f, 1.0f, 0.493677 , 1.238e-8, 1, 0.0030), //173 - KFEfficiencyParticleInfo("K-", "K- ", -321, 0.0f, 1.0f, 0.493677 , 1.238e-8, -1, 0.0030), //174 - KFEfficiencyParticleInfo("p+", "p+ ", 2212, 0.0f, 1.5f, 0.938272 , 1.0e20, 1, 0.0030), //175 - KFEfficiencyParticleInfo("p-", "p- ", -2212, 0.0f, 1.5f, 0.938272 , 1.0e20, -1, 0.0030), //176 - KFEfficiencyParticleInfo("d+", "d+ ", 1000010020, 0.0f, 2.5f, 1.876124 , 1.0e20, 1, 0.0030), //177 - KFEfficiencyParticleInfo("d-", "d- ",-1000010020, 0.0f, 2.5f, 1.876124 , 1.0e20, -1, 0.0030), //178 - KFEfficiencyParticleInfo("t+", "t+ ", 1000010030, 0.0f, 3.5f, 2.809432 , 1.0e20, 1, 0.0030), //179 - KFEfficiencyParticleInfo("t-", "t- ",-1000010030, 0.0f, 3.5f, 2.809432 , 1.0e20, -1, 0.0030), //180 - KFEfficiencyParticleInfo("He3+", "He3+ ", 1000020030, 0.0f, 3.5f, 2.809413 , 1.0e20, 2, 0.0030), //181 - KFEfficiencyParticleInfo("He3-", "He3- ",-1000020030, 0.0f, 3.5f, 2.809413 , 1.0e20, -2, 0.0030), //182 - KFEfficiencyParticleInfo("He4+", "He4+ ", 1000020040, 0.0f, 4.5f, 3.728400 , 1.0e20, 2, 0.0030), //183 - KFEfficiencyParticleInfo("He4-", "He4- ",-1000020040, 0.0f, 4.5f, 3.728400 , 1.0e20, -2, 0.0030), //184 -//background for subtraction - KFEfficiencyParticleInfo("pi+pi+", "pi+pi+ ", 9001, 0.0f, 2.0f, 0 , 1.0e20, 0, 0.0030), //185 - KFEfficiencyParticleInfo("pi+K+", "pi+K+ ", 9002, 0.6f, 5.6f, 0 , 1.0e20, 0, 0.0030), //186 - KFEfficiencyParticleInfo("K+K+", "K+K+ ", 9003, 0.8f, 3.8f, 0 , 1.0e20, 0, 0.0030), //187 - KFEfficiencyParticleInfo("K+p+", "K+p+ ", 9004, 1.4f, 5.4f, 0 , 1.0e20, 0, 0.0030), //188 - KFEfficiencyParticleInfo("pi-pi-", "pi-pi- ", -9001, 0.0f, 2.0f, 0 , 1.0e20, 0, 0.0030), //189 - KFEfficiencyParticleInfo("pi-K-", "pi-K- ", -9002, 0.6f, 5.6f, 0 , 1.0e20, 0, 0.0030), //190 - KFEfficiencyParticleInfo("K-K-", "K-K- ", -9003, 0.8f, 3.8f, 0 , 1.0e20, 0, 0.0030), //191 - KFEfficiencyParticleInfo("K-p-", "K-p- ", -9004, 1.4f, 5.4f, 0 , 1.0e20, 0, 0.0030), //192 -//V0 - KFEfficiencyParticleInfo("V0", "V0 ", 123456789, 0.3f, 1.3f, 0 , 0, 0, 0.0030) //193 - }; - + KFEfficiencyParticleInfo("Lambda", "Lambda ", 3122, 1.0f, 2.0f, 1.115683, 2.632e-10, 0, 0.0020), //1 + KFEfficiencyParticleInfo("Lambdab", "Lambda b ", -3122, 1.0f, 2.0f, 1.115683, 2.632e-10, 0, 0.0020), //2 + KFEfficiencyParticleInfo("Xi-", "Xi- ", 3312, 1.0f, 3.0f, 1.32171, 1.639e-10, -1, 0.0022), //3 + KFEfficiencyParticleInfo("Xi+", "Xi+ ", -3312, 1.0f, 3.0f, 1.32171, 1.639e-10, 1, 0.0022), //4 + KFEfficiencyParticleInfo("Xi0", "Xi0 ", 3322, 1.0f, 3.0f, 1.31486, 2.9e-10, 0, 0.0030), //5 + KFEfficiencyParticleInfo("Xi0b", "Xi0 b ", -3322, 1.0f, 3.0f, 1.31486, 2.9e-10, 0, 0.0030), //6 + KFEfficiencyParticleInfo("Omega-", "Omega- ", 3334, 1.0f, 3.0f, 1.67245, 0.821e-10, -1, 0.0022), //7 + KFEfficiencyParticleInfo("Omega+", "Omega+ ", -3334, 1.0f, 3.0f, 1.67245, 0.821e-10, 1, 0.0022), //8 + KFEfficiencyParticleInfo("Sigma^0", "Sigma0 ", 3212, 1.0f, 3.0f, 1.192642, 7.4e-20, 0, 0.0030), //9 + KFEfficiencyParticleInfo("Sigma^0b", "Sigma0 b ", -3212, 1.0f, 3.0f, 1.192642, 7.4e-20, 0, 0.0030), //10 + KFEfficiencyParticleInfo("Sigma^+", "Sigma+ ", 3222, 1.0f, 3.0f, 1.18937, 0.8018e-10, 1, 0.0030), //11 + KFEfficiencyParticleInfo("Sigma^-b", "Sigma- b ", -3222, 1.0f, 3.0f, 1.18937, 0.8018e-10, -1, 0.0030), //12 + KFEfficiencyParticleInfo("K*0", "K*0 ", 313, 0.6f, 2.6f, 0.8958, 1.38e-23, 0, 0.0300), //13 + KFEfficiencyParticleInfo("K*0b", "K*0 b ", -313, 0.6f, 2.6f, 0.8958, 1.38e-23, 0, 0.0300), //14 + KFEfficiencyParticleInfo("K*+", "K*+ ", 323, 0.6f, 2.6f, 0.89166, 1.30e-23, 1, 0.0300), //15 + KFEfficiencyParticleInfo("K*-", "K*- ", -323, 0.6f, 2.6f, 0.89166, 1.30e-23, -1, 0.0300), //16 + KFEfficiencyParticleInfo("K*0_K0,pi0", "K*0_K0pi0 ", 100313, 0.6f, 2.6f, 0.8958, 1.38e-23, 0, 0.0030), //17 + KFEfficiencyParticleInfo("K*+_K+,pi0", "K*+_K+pi0 ", 100323, 0.6f, 2.6f, 0.89166, 1.30e-23, 1, 0.0030), //18 + KFEfficiencyParticleInfo("K*-_K-,pi0", "K*-_K-pi0 ", -100323, 0.6f, 2.6f, 0.89166, 1.30e-23, -1, 0.0030), //19 + KFEfficiencyParticleInfo("Sigma*+", "Sigma*+ ", 3224, 1.0f, 3.0f, 1.3828, 1.83e-23, 1, 0.0100), //20 + KFEfficiencyParticleInfo("Sigma*-", "Sigma*- ", 3114, 1.0f, 3.0f, 1.3872, 1.67e-23, -1, 0.0100), //21 + KFEfficiencyParticleInfo("Sigma*+b", "Sigma*+ b ", -3114, 1.0f, 3.0f, 1.3828, 1.83e-23, -1, 0.0100), //22 + KFEfficiencyParticleInfo("Sigma*-b", "Sigma*- b ", -3224, 1.0f, 3.0f, 1.3872, 1.67e-23, 1, 0.0100), //23 + KFEfficiencyParticleInfo("Sigma*0", "Sigma*0 ", 3214, 1.0f, 3.0f, 1.3837, 1.83e-23, 0, 0.0030), //24 + KFEfficiencyParticleInfo("Sigma*0b", "Sigma*0 b ", -3214, 1.0f, 3.0f, 1.3837, 1.83e-23, 0, 0.0030), //25 + KFEfficiencyParticleInfo("Lambda*", "Lambda* ", 3124, 1.4f, 3.4f, 1.5195, 4.22e-23, 0, 0.0100), //26 + KFEfficiencyParticleInfo("Lambda*b", "Lambda* b ", -3124, 1.4f, 3.4f, 1.5195, 4.22e-23, 0, 0.0100), //27 + KFEfficiencyParticleInfo("Xi*0", "Xi*0 ", 3324, 1.4f, 3.4f, 1.53180, 7.23e-23, 0, 0.0100), //28 + KFEfficiencyParticleInfo("Xi*0b", "Xi*0 b ", -3324, 1.4f, 3.4f, 1.53180, 7.23e-23, 0, 0.0100), //29 + KFEfficiencyParticleInfo("Xi*-_LK", "Xi*-_lk ", 1003314, 1.4f, 3.4f, 1.823, 2.74e-23, -1, 0.0030), //30 + KFEfficiencyParticleInfo("Xi*+_LK", "Xi*+_lk ", -1003314, 1.4f, 3.4f, 1.823, 2.74e-23, 1, 0.0030), //31 + KFEfficiencyParticleInfo("Xi*-_xi-,pi0", "Xi*-_XiPi ", 3314, 1.4f, 3.4f, 1.535, 6.65e-23, -1, 0.0030), //32 + KFEfficiencyParticleInfo("Xi*+_xi+,pi0", "Xi*+_XiPi ", -3314, 1.4f, 3.4f, 1.535, 6.65e-23, 1, 0.0030), //33 + KFEfficiencyParticleInfo("Omega*-", "Omega*- ", 1003334, 1.8f, 3.8f, 2.252, 1.2e-23, -1, 0.0030), //34 + KFEfficiencyParticleInfo("Omega*+", "Omega*+ ", -1003334, 1.8f, 3.8f, 2.252, 1.2e-23, 1, 0.0030), //35 + KFEfficiencyParticleInfo("H0_LL", "H0_LL ", 3000, 1.5f, 3.5f, 2.21, 1.32e-10, 0, 0.0030), //36 + KFEfficiencyParticleInfo("phi_KK", "phi_KK ", 333, 0.8f, 2.8f, 1.019455, 1.55e-22, 0, 0.0030), //37 + KFEfficiencyParticleInfo("rho_pipi", "rho_pipi ", 113, 0.0f, 2.0f, 0.77526, 4.45e-24, 0, 0.0030), //38 + KFEfficiencyParticleInfo("rho_ee", "rho_ee ", 100113, 0.0f, 2.0f, 0.77526, 4.45e-24, 0, 0.0030), //39 + KFEfficiencyParticleInfo("rho_mm", "rho_mm ", 200113, 0.0f, 2.0f, 0.77526, 4.45e-24, 0, 0.0030), //40 + KFEfficiencyParticleInfo("gamma", "gamma ", 22, 0.0f, 3.0f, 0., 1.e20, 0, 0.0030), //41 + KFEfficiencyParticleInfo("pi0", "pi0 ", 111, 0.0f, 3.0f, 0.1349766, 8.52e-17, 0, 0.0030), //42 + KFEfficiencyParticleInfo("eta", "eta ", 221, 0.0f, 3.0f, 0.547862, 5.0e-19, 0, 0.0030), //43 + //Delta and N resonances + KFEfficiencyParticleInfo("Delta0", "Delta0 ", 2114, 1.0f, 3.0f, 1.232, 5.63e-24, 0, 0.0030), //44 + KFEfficiencyParticleInfo("Delta0 b", "Delta0 b ", -2114, 1.0f, 3.0f, 1.232, 5.63e-24, 0, 0.0030), //45 + KFEfficiencyParticleInfo("Delta++", "Delta++ ", 2224, 1.0f, 3.0f, 1.232, 5.63e-24, 2, 0.0030), //46 + KFEfficiencyParticleInfo("Delta-- b", "Delta-- b ", -2224, 1.0f, 3.0f, 1.232, 5.63e-24, -2, 0.0030), //47 + //charmonium + KFEfficiencyParticleInfo("JPsi_ee", "JPsi_ee ", 443, 1.0f, 4.0f, 3.096916, 7.1e-21, 0, 0.0030), //48 + KFEfficiencyParticleInfo("JPsi_mumu", "JPsi_mm ", 100443, 1.0f, 4.0f, 3.096916, 7.1e-21, 0, 0.0030), //49 + KFEfficiencyParticleInfo("JPsi_pp", "JPsi_pp ", 200443, 1.0f, 4.0f, 3.096916, 7.1e-21, 0, 0.0030), //50 + KFEfficiencyParticleInfo("JPsi_LL", "JPsi_LL ", 300443, 2.0f, 5.0f, 3.096916, 7.1e-21, 0, 0.0030), //51 + KFEfficiencyParticleInfo("JPsi_XiXi", "JPsi_XiXi ", 400443, 2.0f, 5.0f, 3.096916, 7.1e-21, 0, 0.0030), //52 + KFEfficiencyParticleInfo("Psi_OO", "Psi_OO ", 500443, 3.0f, 6.0f, 3.686109, 2.1e-22, 0, 0.0030), //53 + //open charm + KFEfficiencyParticleInfo("D0", "D0 ", 421, 0.6f, 3.6f, 1.86486, 4.1e-13, 0, 0.0154), //54 + KFEfficiencyParticleInfo("D0b", "D0b ", -421, 0.6f, 3.6f, 1.86486, 4.1e-13, 0, 0.0154), //55 + KFEfficiencyParticleInfo("D0_4", "D0_4 ", 429, 0.6f, 3.6f, 1.86486, 4.1e-13, 0, 0.0100), //56 + KFEfficiencyParticleInfo("D0b_4", "D0b_4 ", -429, 0.6f, 3.6f, 1.86486, 4.1e-13, 0, 0.0100), //57 + KFEfficiencyParticleInfo("D0_pipi", "D0_pipi ", 420, 0.6f, 3.6f, 1.86486, 4.1e-13, 0, 0.0154), //58 + KFEfficiencyParticleInfo("D0_2pi2pi", "D0_2pi2pi ", 470, 0.6f, 3.6f, 1.86486, 4.1e-13, 0, 0.0154), //59 + KFEfficiencyParticleInfo("D0_K0pipi", "D0_K0pipi ", 425, 0.6f, 3.6f, 1.86486, 4.1e-13, 0, 0.0150), //60 + KFEfficiencyParticleInfo("D0_KK", "D0_KK ", 426, 0.6f, 3.6f, 1.86486, 4.1e-13, 0, 0.0130), //61 + KFEfficiencyParticleInfo("D0_KKK0", "D0_KKK0 ", 427, 0.6f, 3.6f, 1.86486, 4.1e-13, 0, 0.0154), //62 + KFEfficiencyParticleInfo("D0_pi0", "D0_#pi0 ", 428, 1.0f, 3.0f, 1.86486, 4.1e-13, 0, 0.0030), //63 + KFEfficiencyParticleInfo("D+", "D+ ", 411, 1.0f, 3.0f, 1.86962, 1.04e-13, 1, 0.0114), //64 + KFEfficiencyParticleInfo("D-", "D- ", -411, 1.0f, 3.0f, 1.86962, 1.04e-13, -1, 0.0114), //65 + KFEfficiencyParticleInfo("D+_K0pi+", "D+_K0pi+ ", 100411, 0.6f, 4.6f, 1.86962, 1.04e-13, 1, 0.0030), //66 + KFEfficiencyParticleInfo("D-_K0pi-", "D-_K0pi- ", -100411, 0.6f, 4.6f, 1.86962, 1.04e-13, -1, 0.0030), //67 + KFEfficiencyParticleInfo("D+_K03pi", "D+_K03pi ", 200411, 0.6f, 4.6f, 1.86962, 1.04e-13, 1, 0.0030), //68 + KFEfficiencyParticleInfo("D-_K03pi", "D-_K03pi ", -200411, 0.6f, 4.6f, 1.86962, 1.04e-13, -1, 0.0030), //69 + KFEfficiencyParticleInfo("D+_3pi", "D+_3pi ", 300411, 0.6f, 4.6f, 1.86962, 1.04e-13, 1, 0.0030), //70 + KFEfficiencyParticleInfo("D-_3pi", "D-_3pi ", -300411, 0.6f, 4.6f, 1.86962, 1.04e-13, -1, 0.0030), //71 + KFEfficiencyParticleInfo("Ds+", "Ds+ ", 431, 1.0f, 3.0f, 1.96850, 5.0e-13, 1, 0.0110), //72 + KFEfficiencyParticleInfo("Ds-", "Ds- ", -431, 1.0f, 3.0f, 1.96850, 5.0e-13, -1, 0.0110), //73 + KFEfficiencyParticleInfo("Ds+_K0K+", "Ds+_K0K+ ", 100431, 1.0f, 3.0f, 1.96850, 5.0e-13, 1, 0.0030), //74 + KFEfficiencyParticleInfo("Ds-_K0K-", "Ds-_K0K- ", -100431, 1.0f, 3.0f, 1.96850, 5.0e-13, -1, 0.0030), //75 + KFEfficiencyParticleInfo("Ds+_K0K0pi+", "Ds+_K0K0pi+ ", 200431, 1.0f, 3.0f, 1.96850, 5.0e-13, 1, 0.0030), //76 + KFEfficiencyParticleInfo("Ds-_K0K0pi-", "Ds-_K0K0pi- ", -200431, 1.0f, 3.0f, 1.96850, 5.0e-13, -1, 0.0030), //77 + KFEfficiencyParticleInfo("Ds+_K0K+pipi", "Ds+_K0K+pipi ", 300431, 1.0f, 3.0f, 1.96850, 5.0e-13, 1, 0.0030), //78 + KFEfficiencyParticleInfo("Ds-_K0K-pipi", "Ds-_K0K-pipi ", -300431, 1.0f, 3.0f, 1.96850, 5.0e-13, -1, 0.0030), //79 + KFEfficiencyParticleInfo("Ds+_K+pipi", "Ds+_K+pipi ", 400431, 1.0f, 3.0f, 1.96850, 5.0e-13, 1, 0.0030), //80 + KFEfficiencyParticleInfo("Ds-_K-pipi", "Ds-_K-pipi ", -400431, 1.0f, 3.0f, 1.96850, 5.0e-13, -1, 0.0030), //81 + KFEfficiencyParticleInfo("Lc", "Lambdac ", 4122, 1.8f, 3.8f, 2.28646, 2.0e-13, 1, 0.0110), //82 + KFEfficiencyParticleInfo("Lcb", "Lambdac b ", -4122, 1.8f, 3.8f, 2.28646, 2.0e-13, -1, 0.0110), //83 + KFEfficiencyParticleInfo("Lc_{pK0}", "Lc {pK0} ", 104122, 1.8f, 3.8f, 2.28646, 2.0e-13, 1, 0.0030), //84 + KFEfficiencyParticleInfo("Lcb_{pK0}", "Lc b {pK0} ", -104122, 1.8f, 3.8f, 2.28646, 2.0e-13, -1, 0.0030), //85 + KFEfficiencyParticleInfo("Lc_{pK02pi}", "Lc {pK02pi} ", 204122, 1.8f, 3.8f, 2.28646, 2.0e-13, 1, 0.0030), //86 + KFEfficiencyParticleInfo("Lcb_{pK02pi}", "Lc b {pK02pi} ", -204122, 1.8f, 3.8f, 2.28646, 2.0e-13, -1, 0.0030), //87 + KFEfficiencyParticleInfo("Lc_{Lpi}", "Lc {Lpi} ", 304122, 1.8f, 3.8f, 2.28646, 2.0e-13, 1, 0.0030), //88 + KFEfficiencyParticleInfo("Lcb_{Lpi}", "Lc b {Lpi} ", -304122, 1.8f, 3.8f, 2.28646, 2.0e-13, -1, 0.0030), //89 + KFEfficiencyParticleInfo("Lc_{L3pi}", "Lc {L3pi} ", 404122, 1.8f, 3.8f, 2.28646, 2.0e-13, 1, 0.0030), //90 + KFEfficiencyParticleInfo("Lcb_{L3pi}", "Lc b {L3pi} ", -404122, 1.8f, 3.8f, 2.28646, 2.0e-13, -1, 0.0030), //91 + KFEfficiencyParticleInfo("Lc_{p2pi}", "Lc {p2pi} ", 504122, 1.8f, 3.8f, 2.28646, 2.0e-13, 1, 0.0030), //92 + KFEfficiencyParticleInfo("Lcb_{p2pi}", "Lc b {p2pi} ", -504122, 1.8f, 3.8f, 2.28646, 2.0e-13, -1, 0.0030), //93 + KFEfficiencyParticleInfo("Xic0", "Xic0 ", 4132, 2.1f, 4.1f, 2.47087, 1.0e-13, 0, 0.0030), //94 + KFEfficiencyParticleInfo("Xic0b", "Xic0b ", -4132, 2.1f, 4.1f, 2.47087, 1.0e-13, 0, 0.0030), //95 + KFEfficiencyParticleInfo("D*0", "D*0 ", 10421, 1.8f, 3.8f, 2.00699, 3.0e-22, 0, 0.0030), //96 + KFEfficiencyParticleInfo("D*0b", "D*0 b ", -10421, 1.8f, 3.8f, 2.00699, 3.0e-22, 0, 0.0030), //97 + KFEfficiencyParticleInfo("D*+", "D*+ ", 10411, 1.8f, 3.8f, 2.01029, 6.86e-21, 1, 0.0030), //98 + KFEfficiencyParticleInfo("D*-", "D*- ", -10411, 1.8f, 3.8f, 2.01029, 6.86e-21, -1, 0.0030), //99 + KFEfficiencyParticleInfo("D*+_4", "D*+_4 ", 20411, 1.8f, 3.8f, 2.01029, 6.86e-21, 1, 0.0030), //100 + KFEfficiencyParticleInfo("D*-_4", "D*-_4 ", -20411, 1.8f, 3.8f, 2.01029, 6.86e-21, -1, 0.0030), //101 + KFEfficiencyParticleInfo("D0*_pi0", "D0*_#pi0 ", 10428, 1.8f, 3.8f, 2.00699, 6.86e-21, 0, 0.0030), //102 + //B mesons + KFEfficiencyParticleInfo("B_Jpsi_ee", "B_Jpsi_ee ", 500, 1.0f, 4.0f, 3.096916, 7.1e-21, 0, 0.0030), //103 + KFEfficiencyParticleInfo("B_Jpsi_mm", "B_Jpsi_mm ", 501, 1.0f, 4.0f, 3.096916, 7.1e-21, 0, 0.0030), //104 + KFEfficiencyParticleInfo("B+_D0bPi+", "B+ {D0bPi+} ", 521, 3.0f, 7.0f, 5.27931, 1.638e-12, 0, 0.0030), //105 + KFEfficiencyParticleInfo("B-_D0Pi-", "B- {D0Pi-} ", -521, 3.0f, 7.0f, 5.27931, 1.638e-12, 0, 0.0030), //106 + KFEfficiencyParticleInfo("B+_D0bK+", "B+ {D0bK+} ", 529, 3.0f, 7.0f, 5.27931, 1.638e-12, 0, 0.0030), //107 + KFEfficiencyParticleInfo("B-_D0K-", "B- {D0K+} ", -529, 3.0f, 7.0f, 5.27931, 1.638e-12, 0, 0.0030), //108 + KFEfficiencyParticleInfo("B0_D-Pi+", "B0 {D-Pi+} ", 511, 3.0f, 7.0f, 5.27962, 1.520e-12, 0, 0.0030), //109 + KFEfficiencyParticleInfo("B0b_D+Pi-", "B0b {D+Pi-} ", -511, 3.0f, 7.0f, 5.27962, 1.520e-12, 0, 0.0030), //110 + KFEfficiencyParticleInfo("B0_D-K+", "B0 {D-K+} ", 519, 3.0f, 7.0f, 5.27962, 1.520e-12, 0, 0.0030), //111 + KFEfficiencyParticleInfo("B0b_D+K-", "B0b {D+K-} ", -519, 3.0f, 7.0f, 5.27962, 1.520e-12, 0, 0.0030), //112 + KFEfficiencyParticleInfo("H0_{Lppi}", "H0 ", 3001, 2.0f, 4.0f, 2.21, 1.32e-10, 0, 0.0030), //113 + //hypernuclei + KFEfficiencyParticleInfo("LambdaN", "LambdaN ", 3003, 1.0f, 3.0f, 2.05395, 1.00e-10, 0, 0.0030), //114 + KFEfficiencyParticleInfo("LambdaNb", "LambdaN b ", -3003, 1.0f, 3.0f, 2.05395, 1.00e-10, 0, 0.0030), //115 + KFEfficiencyParticleInfo("LambdaNN", "LambdaNN ", 3103, 2.0f, 4.0f, 2.99352, 1.00e-10, 0, 0.0030), //116 + KFEfficiencyParticleInfo("LambdaNNb", "LambdaNN b ", -3103, 2.0f, 4.0f, 2.99352, 1.00e-10, 0, 0.0030), //117 + KFEfficiencyParticleInfo("H3L", "H3L ", 3004, 2.0f, 4.0f, 2.99339, 1.85e-10, 1, 0.0030), //118 + KFEfficiencyParticleInfo("H3Lb", "H3L b ", -3004, 2.0f, 4.0f, 2.99339, 1.85e-10, -1, 0.0030), //119 + KFEfficiencyParticleInfo("H4L", "H4L ", 3005, 3.0f, 5.0f, 3.92975, 1.80e-10, 1, 0.0030), //120 + KFEfficiencyParticleInfo("H4Lb", "H4L b ", -3005, 3.0f, 5.0f, 3.92975, 1.80e-10, -1, 0.0030), //121 + KFEfficiencyParticleInfo("He4L", "He4L ", 3006, 3.0f, 5.0f, 3.93070, 1.50e-10, 2, 0.0030), //122 + KFEfficiencyParticleInfo("He4Lb", "He4L b ", -3006, 3.0f, 5.0f, 3.93070, 1.50e-10, -2, 0.0030), //123 + KFEfficiencyParticleInfo("He5L", "He5L ", 3007, 4.0f, 6.0f, 4.86824, 1.40e-10, 2, 0.0030), //124 + KFEfficiencyParticleInfo("He5Lb", "He5L b ", -3007, 4.0f, 6.0f, 4.86824, 1.40e-10, -2, 0.0030), //125 + KFEfficiencyParticleInfo("LLn", "LLn ", 3203, 3.0f, 5.0f, 3.16964, 1.00e-10, 0, 0.0030), //126 + KFEfficiencyParticleInfo("H4LL_{He4Lpi-}", "H4LL_{He4Lpi-}", 3008, 3.0f, 5.0f, 4.10791, 1.0e-10, 1, 0.0030), //127 + KFEfficiencyParticleInfo("H4LL_{H3Lppi-}", "H4LL_{H3Lppi-}", 3009, 3.0f, 5.0f, 4.10791, 1.0e-10, 1, 0.0030), //128 + KFEfficiencyParticleInfo("H5LL_{He5Lpi-}", "H5LL_{He5Lpi-}", 3010, 4.0f, 6.0f, 5.04748, 1.0e-10, 1, 0.0030), //129 + KFEfficiencyParticleInfo("He6LL", "He6LL ", 3011, 5.0f, 7.0f, 5.98575, 1.0e-10, 2, 0.0030), //130 + //missing mass method + KFEfficiencyParticleInfo("pi-_{mu,nu}", "pi-_{mnu} ", -7000211, -1.0f, 1.0f, 0.139570, 2.6e-8, -1, 0.0030), //131 + KFEfficiencyParticleInfo("nu_{pi-}", "nu_{mupi-} b ", -7000014, -1.0f, 1.0f, 0., 1.0e20, 0, 0.0030), //132 + KFEfficiencyParticleInfo("pi+_{mu,nu}", "pi+_{mnu} ", 7000211, -1.0f, 1.0f, 0.139570, 2.6e-8, 1, 0.0030), //133 + KFEfficiencyParticleInfo("nu_{pi+}", "nu_{mupi+} ", 7000014, -1.0f, 1.0f, 0., 1.0e20, 0, 0.0030), //134 + KFEfficiencyParticleInfo("K-_{mu,nu}", "K-_{mnu} ", -7000321, -1.0f, 1.0f, 0.493677, 1.238e-8, -1, 0.0030), //135 + KFEfficiencyParticleInfo("nu_{K-}", "nu_{K-} b ", -8000014, -1.0f, 1.0f, 0., 1.0e20, 0, 0.0030), //136 + KFEfficiencyParticleInfo("K+_{mu,nu}", "K+_{mnu} ", 7000321, -1.0f, 1.0f, 0.493677, 1.238e-8, 1, 0.0030), //137 + KFEfficiencyParticleInfo("nu_{K+}", "nu_{K+} ", 8000014, -1.0f, 1.0f, 0., 1.0e20, 0, 0.0030), //138 + KFEfficiencyParticleInfo("Sigma-_{pi-,n}", "Sigma-_{pi-n} ", 7003112, 0.0f, 3.0f, 1.192642, 1.479e-10, -1, 0.0100), //139 + KFEfficiencyParticleInfo("n_{Sigma-}", "n_{Sigma-} ", 7002112, 0.0f, 1.5f, 0.9395654, 880, 0, 0.0030), //140 + KFEfficiencyParticleInfo("Sigma+_{pi+n}b", "Sigma+{pi+n} b", -7003112, 0.0f, 3.0f, 1.192642, 1.479e-10, -1, 0.0030), //141 + KFEfficiencyParticleInfo("n_{Sigma+} b", "n_{Sigma+b} b ", -7002112, 0.0f, 1.5f, 0.9395654, 880, 0, 0.0030), //142 + KFEfficiencyParticleInfo("Sigma-_{pi-n}b", "Sigma+{pi-n} b", -7003222, 0.0f, 3.0f, 1.18937, 0.8018e-10, 1, 0.0030), //143 + KFEfficiencyParticleInfo("n_{Sigma-} b", "n_{Sigma-_b} b", -8002112, 0.0f, 1.5f, 0.9395654, 0.93956541, 0, 0.0030), //144 + KFEfficiencyParticleInfo("Sigma+_{pi+n}", "Sigma+_{pi+n} ", 7003222, 0.0f, 3.0f, 1.18937, 0.8018e-10, 1, 0.0100), //145 + KFEfficiencyParticleInfo("n_{Sigma+}", "n_{Sigma+} ", 8002112, 0.0f, 1.5f, 0.9395654, 880, 0, 0.0030), //146 + KFEfficiencyParticleInfo("Xi-_{pi-L}", "Xi-_{pi-L} ", 7003312, 0.0f, 3.0f, 1.32171, 1.639e-10, -1, 0.0030), //147 + KFEfficiencyParticleInfo("Lambda_{Xi-}", "Lambda_{Xi-} ", 7003122, 0.0f, 2.0f, 1.115683, 2.632e-10, 0, 0.0030), //148 + KFEfficiencyParticleInfo("Xi+_{pi+L_b}", "Xi+_{pi+L_b} ", -7003312, 0.0f, 3.0f, 1.32171, 1.639e-10, 1, 0.0030), //149 + KFEfficiencyParticleInfo("Lambda_{Xi+} b", "Lambda_{Xi+} b", -7003122, 0.0f, 2.0f, 1.115683, 2.632e-10, 0, 0.0030), //150 + KFEfficiencyParticleInfo("Omega-_{Xi-pi0}", "Omega-{pi-Xi0}", 7003334, 0.0f, 3.0f, 1.67245, 0.821e-10, -1, 0.0030), //151 + KFEfficiencyParticleInfo("Xi0_{Omega-}", "Xi0_{Omega-} ", 7003322, 0.0f, 3.0f, 1.31486, 2.9e-10, 0, 0.0030), //152 + KFEfficiencyParticleInfo("Omega+_{Xi+pi0}", "Omega+_{Xipi0}", -7003334, 0.0f, 3.0f, 1.67245, 0.821e-10, 1, 0.0030), //153 + KFEfficiencyParticleInfo("Xi0_{Omega+} b", "Xi0_{Omega+} b", -7003322, 0.0f, 3.0f, 1.31486, 2.9e-10, 0, 0.0030), //154 + KFEfficiencyParticleInfo("K-_{pi-pi0}", "K-_{pi-pi0} ", -9000321, 0.0f, 3.0f, 0.493677, 1.24e-8, -1, 0.0030), //155 + KFEfficiencyParticleInfo("pi0_{K-}", "pi0_{K-} ", -9000111, 0.0f, 3.0f, 0.1349766, 8.52e-17, 0, 0.0030), //156 + KFEfficiencyParticleInfo("K+_{pi+pi0}", "K+_{pi+pi0} ", 9000321, 0.0f, 3.0f, 0.493677, 1.24e-8, 1, 0.0030), //157 + KFEfficiencyParticleInfo("pi0_{K+}", "pi0_{K+} ", 9000111, 0.0f, 3.0f, 0.1349766, 8.52e-17, 0, 0.0030), //158 + KFEfficiencyParticleInfo("Omega-{K-L}", "Omega-_{K-L} ", 8003334, 0.0f, 3.0f, 1.67245, 0.821e-10, -1, 0.0030), //159 + KFEfficiencyParticleInfo("Lambda_{Omega-}", "Lambda_{O-} ", 8003122, 0.0f, 3.0f, 1.115683, 2.632e-10, 0, 0.0030), //160 + KFEfficiencyParticleInfo("Omega+_{K+L_b}", "Omega+_{K+Lb} ", -8003334, 0.0f, 3.0f, 1.67245, 0.821e-10, 1, 0.0030), //161 + KFEfficiencyParticleInfo("Lamda_{Omega+} b", "Lambda_{O+} b ", -8003122, 0.0f, 3.0f, 1.115683, 2.632e-10, 0, 0.0030), //162 + KFEfficiencyParticleInfo("Sigma-{p_b pi0} b", "Sigma-{ppi0} b", -8003222, 0.0f, 3.0f, 1.18937, 0.8018e-10, 1, 0.0030), //163 + KFEfficiencyParticleInfo("pi0_{Sigma-b}", "pi0_{Sigma-_b}", -8000111, 0.0f, 3.0f, 0.1349766, 8.52e-17, 0, 0.0030), //164 + KFEfficiencyParticleInfo("Sigma+_{p pi0}", "Sigma+_{ppi0} ", 8003222, 0.0f, 3.0f, 1.18937, 0.8018e-10, 1, 0.0250), //165 + KFEfficiencyParticleInfo("pi0_{Sigma+}", "pi0_{Sigma+} ", 8000111, 0.0f, 3.0f, 0.1349766, 8.52e-17, 0, 0.0030), //166 + //tracks + KFEfficiencyParticleInfo("e-", "e- ", 11, 0.0f, 0.01f, 5.485799e-4, 1.0e20, -1, 0.0030), //167 + KFEfficiencyParticleInfo("e+", "e+ ", -11, 0.0f, 0.01f, 5.485799e-4, 1.0e20, 1, 0.0030), //168 + KFEfficiencyParticleInfo("mu-", "mu- ", 13, 0.0f, 1.0f, 0.105658, 2.2e-6, -1, 0.0030), //169 + KFEfficiencyParticleInfo("mu+", "mu+ ", -13, 0.0f, 1.0f, 0.105658, 2.2e-6, 1, 0.0030), //170 + KFEfficiencyParticleInfo("pi+", "pi+ ", 211, 0.0f, 1.0f, 0.139570, 2.6e-8, 1, 0.0030), //171 + KFEfficiencyParticleInfo("pi-", "pi- ", -211, 0.0f, 1.0f, 0.139570, 2.6e-8, -1, 0.0030), //172 + KFEfficiencyParticleInfo("K+", "K+ ", 321, 0.0f, 1.0f, 0.493677, 1.238e-8, 1, 0.0030), //173 + KFEfficiencyParticleInfo("K-", "K- ", -321, 0.0f, 1.0f, 0.493677, 1.238e-8, -1, 0.0030), //174 + KFEfficiencyParticleInfo("p+", "p+ ", 2212, 0.0f, 1.5f, 0.938272, 1.0e20, 1, 0.0030), //175 + KFEfficiencyParticleInfo("p-", "p- ", -2212, 0.0f, 1.5f, 0.938272, 1.0e20, -1, 0.0030), //176 + KFEfficiencyParticleInfo("d+", "d+ ", 1000010020, 0.0f, 2.5f, 1.876124, 1.0e20, 1, 0.0030), //177 + KFEfficiencyParticleInfo("d-", "d- ", -1000010020, 0.0f, 2.5f, 1.876124, 1.0e20, -1, 0.0030), //178 + KFEfficiencyParticleInfo("t+", "t+ ", 1000010030, 0.0f, 3.5f, 2.809432, 1.0e20, 1, 0.0030), //179 + KFEfficiencyParticleInfo("t-", "t- ", -1000010030, 0.0f, 3.5f, 2.809432, 1.0e20, -1, 0.0030), //180 + KFEfficiencyParticleInfo("He3+", "He3+ ", 1000020030, 0.0f, 3.5f, 2.809413, 1.0e20, 2, 0.0030), //181 + KFEfficiencyParticleInfo("He3-", "He3- ", -1000020030, 0.0f, 3.5f, 2.809413, 1.0e20, -2, 0.0030), //182 + KFEfficiencyParticleInfo("He4+", "He4+ ", 1000020040, 0.0f, 4.5f, 3.728400, 1.0e20, 2, 0.0030), //183 + KFEfficiencyParticleInfo("He4-", "He4- ", -1000020040, 0.0f, 4.5f, 3.728400, 1.0e20, -2, 0.0030), //184 + //background for subtraction + KFEfficiencyParticleInfo("pi+pi+", "pi+pi+ ", 9001, 0.0f, 2.0f, 0, 1.0e20, 0, 0.0030), //185 + KFEfficiencyParticleInfo("pi+K+", "pi+K+ ", 9002, 0.6f, 5.6f, 0, 1.0e20, 0, 0.0030), //186 + KFEfficiencyParticleInfo("K+K+", "K+K+ ", 9003, 0.8f, 3.8f, 0, 1.0e20, 0, 0.0030), //187 + KFEfficiencyParticleInfo("K+p+", "K+p+ ", 9004, 1.4f, 5.4f, 0, 1.0e20, 0, 0.0030), //188 + KFEfficiencyParticleInfo("pi-pi-", "pi-pi- ", -9001, 0.0f, 2.0f, 0, 1.0e20, 0, 0.0030), //189 + KFEfficiencyParticleInfo("pi-K-", "pi-K- ", -9002, 0.6f, 5.6f, 0, 1.0e20, 0, 0.0030), //190 + KFEfficiencyParticleInfo("K-K-", "K-K- ", -9003, 0.8f, 3.8f, 0, 1.0e20, 0, 0.0030), //191 + KFEfficiencyParticleInfo("K-p-", "K-p- ", -9004, 1.4f, 5.4f, 0, 1.0e20, 0, 0.0030), //192 + //V0 + KFEfficiencyParticleInfo("V0", "V0 ", 123456789, 0.3f, 1.3f, 0, 0, 0, 0.0030) //193 + }; + int mPartMaxMult[nParticles]; - for(int i=0; i pi+ pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(211); //K0s -> pi+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 2212); //Lambda -> p pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(2212); //Lambda -> p pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - + partDaughterPdg[curPart].push_back(-2212); //Lambda_bar -> p- pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //Xi- -> Lambda pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(3122); //Xi- -> Lambda pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - + partDaughterPdg[curPart].push_back(-3122); //Xi+ -> Lambda_bar pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //Xi0 -> Lambda Pi0 - partDaughterPdg[curPart].push_back( 111); + + partDaughterPdg[curPart].push_back(3122); //Xi0 -> Lambda Pi0 + partDaughterPdg[curPart].push_back(111); curPart++; - + partDaughterPdg[curPart].push_back(-3122); //Xi0_bar -> Lambda_bar Pi0 - partDaughterPdg[curPart].push_back( 111); + partDaughterPdg[curPart].push_back(111); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //Omega- -> Lambda K- - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(3122); //Omega- -> Lambda K- + partDaughterPdg[curPart].push_back(-321); curPart++; - + partDaughterPdg[curPart].push_back(-3122); //Omega+ -> Lambda_bar K+ - partDaughterPdg[curPart].push_back( 321); + partDaughterPdg[curPart].push_back(321); curPart++; - - partDaughterPdg[curPart].push_back( 22); //Sigma0 -> Lambda Gamma - partDaughterPdg[curPart].push_back( 3122); + + partDaughterPdg[curPart].push_back(22); //Sigma0 -> Lambda Gamma + partDaughterPdg[curPart].push_back(3122); curPart++; - - partDaughterPdg[curPart].push_back( 22); //Sigma0_bar -> Lambda_bar Gamma + + partDaughterPdg[curPart].push_back(22); //Sigma0_bar -> Lambda_bar Gamma partDaughterPdg[curPart].push_back(-3122); curPart++; - - partDaughterPdg[curPart].push_back( 111); //Sigma+ -> p Pi0 - partDaughterPdg[curPart].push_back( 2212); + + partDaughterPdg[curPart].push_back(111); //Sigma+ -> p Pi0 + partDaughterPdg[curPart].push_back(2212); curPart++; - - partDaughterPdg[curPart].push_back( 111); //Sigma+_bar -> p- Pi0 + + partDaughterPdg[curPart].push_back(111); //Sigma+_bar -> p- Pi0 partDaughterPdg[curPart].push_back(-2212); curPart++; - - partDaughterPdg[curPart].push_back( 321); //K*0 -> K+ pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(321); //K*0 -> K+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( -321); //K*0_bar -> K- pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(-321); //K*0_bar -> K- pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 310); //K*+ -> K0s pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(310); //K*+ -> K0s pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 310); //K*- -> K0s pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(310); //K*- -> K0s pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 310); //K*0 -> K0 pi0 - partDaughterPdg[curPart].push_back( 111); + + partDaughterPdg[curPart].push_back(310); //K*0 -> K0 pi0 + partDaughterPdg[curPart].push_back(111); curPart++; - - partDaughterPdg[curPart].push_back( 111); //K*+ -> K+ pi0 - partDaughterPdg[curPart].push_back( 321); + + partDaughterPdg[curPart].push_back(111); //K*+ -> K+ pi0 + partDaughterPdg[curPart].push_back(321); curPart++; - - partDaughterPdg[curPart].push_back( 111); //K*- -> K- pi0 - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(111); //K*- -> K- pi0 + partDaughterPdg[curPart].push_back(-321); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //Sigma+ -> Lambda pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(3122); //Sigma+ -> Lambda pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //Sigma- -> Lambda pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(3122); //Sigma- -> Lambda pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - + partDaughterPdg[curPart].push_back(-3122); //Sigma+_bar -> Lambda_bar pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - + partDaughterPdg[curPart].push_back(-3122); //Sigma-_bar -> Lambda_bar pi- - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //Sigma*0 -> Lambda pi0 - partDaughterPdg[curPart].push_back( 111); + + partDaughterPdg[curPart].push_back(3122); //Sigma*0 -> Lambda pi0 + partDaughterPdg[curPart].push_back(111); curPart++; - + partDaughterPdg[curPart].push_back(-3122); //Sigma*0_bar -> Lambda_bar pi0 - partDaughterPdg[curPart].push_back( 111); + partDaughterPdg[curPart].push_back(111); curPart++; - - partDaughterPdg[curPart].push_back( 2212); //Lambda* -> p K- - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(2212); //Lambda* -> p K- + partDaughterPdg[curPart].push_back(-321); curPart++; - + partDaughterPdg[curPart].push_back(-2212); //Lambda*_bar -> p- K+ - partDaughterPdg[curPart].push_back( 321); + partDaughterPdg[curPart].push_back(321); curPart++; - - partDaughterPdg[curPart].push_back( 3312); //Xi*0 -> Xi- pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(3312); //Xi*0 -> Xi- pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - + partDaughterPdg[curPart].push_back(-3312); //Xi*0_bar -> Xi+ pi- - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //Xi*- -> Lambda K- - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(3122); //Xi*- -> Lambda K- + partDaughterPdg[curPart].push_back(-321); curPart++; - + partDaughterPdg[curPart].push_back(-3122); //Xi*+ -> Lambda_bar K+ - partDaughterPdg[curPart].push_back( 321); + partDaughterPdg[curPart].push_back(321); curPart++; - - partDaughterPdg[curPart].push_back( 3312); //Xi*- -> Xi- pi0 - partDaughterPdg[curPart].push_back( 111); + + partDaughterPdg[curPart].push_back(3312); //Xi*- -> Xi- pi0 + partDaughterPdg[curPart].push_back(111); curPart++; - + partDaughterPdg[curPart].push_back(-3312); //Xi*+ -> Xi+ pi0 - partDaughterPdg[curPart].push_back( 111); + partDaughterPdg[curPart].push_back(111); curPart++; - - partDaughterPdg[curPart].push_back( 3312); //Omega*- -> Xi- pi+ K- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(3312); //Omega*- -> Xi- pi+ K- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-321); curPart++; - + partDaughterPdg[curPart].push_back(-3312); //Omega*- -> Xi+ pi- K+ - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( 321); + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(321); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //H-dibar -> Lambda Lambda - partDaughterPdg[curPart].push_back( 3122); + + partDaughterPdg[curPart].push_back(3122); //H-dibar -> Lambda Lambda + partDaughterPdg[curPart].push_back(3122); curPart++; - - partDaughterPdg[curPart].push_back( 321); //phi -> K+ K- - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(321); //phi -> K+ K- + partDaughterPdg[curPart].push_back(-321); curPart++; - - partDaughterPdg[curPart].push_back( 211); //rho, omega, phi -> pi+ pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(211); //rho, omega, phi -> pi+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 11); //rho, omega, phi -> e+ e- - partDaughterPdg[curPart].push_back( -11); + + partDaughterPdg[curPart].push_back(11); //rho, omega, phi -> e+ e- + partDaughterPdg[curPart].push_back(-11); curPart++; - - partDaughterPdg[curPart].push_back( 13); //rho, omega, phi -> mu+ mu- - partDaughterPdg[curPart].push_back( -13); + + partDaughterPdg[curPart].push_back(13); //rho, omega, phi -> mu+ mu- + partDaughterPdg[curPart].push_back(-13); curPart++; - - partDaughterPdg[curPart].push_back( 11); //gamma -> e+ e- - partDaughterPdg[curPart].push_back( -11); + + partDaughterPdg[curPart].push_back(11); //gamma -> e+ e- + partDaughterPdg[curPart].push_back(-11); curPart++; - - partDaughterPdg[curPart].push_back( 22); //pi0 -> gamma gamma - partDaughterPdg[curPart].push_back( 22); + + partDaughterPdg[curPart].push_back(22); //pi0 -> gamma gamma + partDaughterPdg[curPart].push_back(22); curPart++; - - partDaughterPdg[curPart].push_back( 111); //eta -> pi0 pi0 - partDaughterPdg[curPart].push_back( 111); - partDaughterPdg[curPart].push_back( 111); + + partDaughterPdg[curPart].push_back(111); //eta -> pi0 pi0 + partDaughterPdg[curPart].push_back(111); + partDaughterPdg[curPart].push_back(111); curPart++; - - partDaughterPdg[curPart].push_back( 2212); //Delta0 -> p pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(2212); //Delta0 -> p pi- + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-2212); //Delta0_bar -> p- pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - partDaughterPdg[curPart].push_back( 2212); //Delta++ -> p pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(2212); //Delta++ -> p pi+ + partDaughterPdg[curPart].push_back(211); curPart++; partDaughterPdg[curPart].push_back(-2212); //Delta--_bar -> p- pi- - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(-211); + curPart++; + + partDaughterPdg[curPart].push_back(11); //JPsi -> e+ e- + partDaughterPdg[curPart].push_back(-11); + curPart++; + + partDaughterPdg[curPart].push_back(13); //JPsi -> mu+ mu- + partDaughterPdg[curPart].push_back(-13); + curPart++; + + partDaughterPdg[curPart].push_back(2212); //JPsi -> p p- + partDaughterPdg[curPart].push_back(-2212); + curPart++; + + partDaughterPdg[curPart].push_back(3122); //JPsi -> Lambda Lambda_bar + partDaughterPdg[curPart].push_back(-3122); + curPart++; + + partDaughterPdg[curPart].push_back(3312); //JPsi -> Xi- Xi+ + partDaughterPdg[curPart].push_back(-3312); + curPart++; + + partDaughterPdg[curPart].push_back(3334); //Psi -> Omega- Omega+ + partDaughterPdg[curPart].push_back(-3334); + curPart++; + + partDaughterPdg[curPart].push_back(211); //D0 -> pi+ K- + partDaughterPdg[curPart].push_back(-321); curPart++; - - partDaughterPdg[curPart].push_back( 11); //JPsi -> e+ e- - partDaughterPdg[curPart].push_back( -11); + + partDaughterPdg[curPart].push_back(-211); //D0_bar -> K+ pi- + partDaughterPdg[curPart].push_back(321); + curPart++; + + partDaughterPdg[curPart].push_back(211); //D0 -> pi+ pi+ pi- K- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(-321); curPart++; - - partDaughterPdg[curPart].push_back( 13); //JPsi -> mu+ mu- - partDaughterPdg[curPart].push_back( -13); + + partDaughterPdg[curPart].push_back(-211); //D0_bar -> pi- pi- pi+ K+ + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(321); curPart++; - partDaughterPdg[curPart].push_back( 2212); //JPsi -> p p- - partDaughterPdg[curPart].push_back( -2212); + partDaughterPdg[curPart].push_back(211); //D0 -> pi+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - partDaughterPdg[curPart].push_back( 3122); //JPsi -> Lambda Lambda_bar - partDaughterPdg[curPart].push_back( -3122); + partDaughterPdg[curPart].push_back(211); //D0 -> 2pi+ 2pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(-211); curPart++; - partDaughterPdg[curPart].push_back( 3312); //JPsi -> Xi- Xi+ - partDaughterPdg[curPart].push_back( -3312); + partDaughterPdg[curPart].push_back(310); //D0_bar -> K0 pi+ pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; - partDaughterPdg[curPart].push_back( 3334); //Psi -> Omega- Omega+ - partDaughterPdg[curPart].push_back( -3334); + partDaughterPdg[curPart].push_back(321); //D0_bar -> K+ K- + partDaughterPdg[curPart].push_back(-321); curPart++; - - partDaughterPdg[curPart].push_back( 211); //D0 -> pi+ K- - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(321); //D0_bar -> K+ K- K0 + partDaughterPdg[curPart].push_back(-321); + partDaughterPdg[curPart].push_back(310); curPart++; - - partDaughterPdg[curPart].push_back( -211); //D0_bar -> K+ pi- - partDaughterPdg[curPart].push_back( 321); + + partDaughterPdg[curPart].push_back(310); //D0_bar -> K0 pi+ pi- pi0 + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(111); curPart++; - - partDaughterPdg[curPart].push_back( 211); //D0 -> pi+ pi+ pi- K- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(-321); //D+ -> K- pi+ pi+ + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(211); + curPart++; + + partDaughterPdg[curPart].push_back(321); //D- -> K+ pi- pi- + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(-211); + curPart++; + + partDaughterPdg[curPart].push_back(310); //D+ -> K0 pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( -211); //D0_bar -> pi- pi- pi+ K+ - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( 321); + + partDaughterPdg[curPart].push_back(310); //D- -> K0 pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - partDaughterPdg[curPart].push_back( 211); //D0 -> pi+ pi- - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(310); //D+ -> K0 pi+ pi+ pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; - partDaughterPdg[curPart].push_back( 211); //D0 -> 2pi+ 2pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(310); //D- -> K0 pi+ pi- pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 310); //D0_bar -> K0 pi+ pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(211); //D+ -> pi+ pi+ pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 321); //D0_bar -> K+ K- - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(211); //D- -> pi+ pi- pi- + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(-211); curPart++; - partDaughterPdg[curPart].push_back( 321); //D0_bar -> K+ K- K0 - partDaughterPdg[curPart].push_back( -321); - partDaughterPdg[curPart].push_back( 310); + partDaughterPdg[curPart].push_back(-321); //Ds+ -> K- K+ pi+ + partDaughterPdg[curPart].push_back(321); + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 310); //D0_bar -> K0 pi+ pi- pi0 - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( 111); + + partDaughterPdg[curPart].push_back(321); //Ds- -> K+ K- pi- + partDaughterPdg[curPart].push_back(-321); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( -321); //D+ -> K- pi+ pi+ - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(310); //Ds+ -> K0 K+ + partDaughterPdg[curPart].push_back(321); curPart++; - - partDaughterPdg[curPart].push_back( 321); //D- -> K+ pi- pi- - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(310); //Ds- -> K0 K- + partDaughterPdg[curPart].push_back(-321); curPart++; - - partDaughterPdg[curPart].push_back( 310); //D+ -> K0 pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(310); //Ds+ -> K0 K0 pi+ + partDaughterPdg[curPart].push_back(310); + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 310); //D- -> K0 pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(310); //Ds- -> K0 K0 pi- + partDaughterPdg[curPart].push_back(310); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 310); //D+ -> K0 pi+ pi+ pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(310); //Ds+ -> K0 K+ pi+ pi- + partDaughterPdg[curPart].push_back(321); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 310); //D- -> K0 pi+ pi- pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(310); //Ds- -> K0 K- pi+ pi- + partDaughterPdg[curPart].push_back(-321); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 211); //D+ -> pi+ pi+ pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(321); //Ds+ -> K+ pi+ pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 211); //D- -> pi+ pi- pi- - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(-321); //Ds- -> K- pi+ pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( -321); //Ds+ -> K- K+ pi+ - partDaughterPdg[curPart].push_back( 321); - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(211); //Lambdac -> pi+ K- p + partDaughterPdg[curPart].push_back(-321); + partDaughterPdg[curPart].push_back(2212); curPart++; - - partDaughterPdg[curPart].push_back( 321); //Ds- -> K+ K- pi- - partDaughterPdg[curPart].push_back( -321); - partDaughterPdg[curPart].push_back( -211); - curPart++; - - partDaughterPdg[curPart].push_back( 310); //Ds+ -> K0 K+ - partDaughterPdg[curPart].push_back( 321); - curPart++; - - partDaughterPdg[curPart].push_back( 310); //Ds- -> K0 K- - partDaughterPdg[curPart].push_back( -321); - curPart++; - - partDaughterPdg[curPart].push_back( 310); //Ds+ -> K0 K0 pi+ - partDaughterPdg[curPart].push_back( 310); - partDaughterPdg[curPart].push_back( 211); - curPart++; - - partDaughterPdg[curPart].push_back( 310); //Ds- -> K0 K0 pi- - partDaughterPdg[curPart].push_back( 310); - partDaughterPdg[curPart].push_back( -211); - curPart++; - - partDaughterPdg[curPart].push_back( 310); //Ds+ -> K0 K+ pi+ pi- - partDaughterPdg[curPart].push_back( 321); - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - curPart++; - - partDaughterPdg[curPart].push_back( 310); //Ds- -> K0 K- pi+ pi- - partDaughterPdg[curPart].push_back( -321); - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - curPart++; - - partDaughterPdg[curPart].push_back( 321); //Ds+ -> K+ pi+ pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - curPart++; - - partDaughterPdg[curPart].push_back( -321); //Ds- -> K- pi+ pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - curPart++; - - - partDaughterPdg[curPart].push_back( 211); //Lambdac -> pi+ K- p - partDaughterPdg[curPart].push_back( -321); - partDaughterPdg[curPart].push_back( 2212); - curPart++; - - partDaughterPdg[curPart].push_back( -211); //Lambdac_bar -> pi- K+ p- - partDaughterPdg[curPart].push_back( 321); + + partDaughterPdg[curPart].push_back(-211); //Lambdac_bar -> pi- K+ p- + partDaughterPdg[curPart].push_back(321); partDaughterPdg[curPart].push_back(-2212); curPart++; - - partDaughterPdg[curPart].push_back( 2212); //Lambdac -> p K0s - partDaughterPdg[curPart].push_back( 310); + + partDaughterPdg[curPart].push_back(2212); //Lambdac -> p K0s + partDaughterPdg[curPart].push_back(310); curPart++; partDaughterPdg[curPart].push_back(-2212); //Lambdac_bar -> p_bar K0s - partDaughterPdg[curPart].push_back( 310); + partDaughterPdg[curPart].push_back(310); curPart++; - - partDaughterPdg[curPart].push_back( 2212); //Lambdac -> p K0s pi+ pi- - partDaughterPdg[curPart].push_back( 310); - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(2212); //Lambdac -> p K0s pi+ pi- + partDaughterPdg[curPart].push_back(310); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-2212); //Lambdac_bar -> p_bar K0s pi+ pi- - partDaughterPdg[curPart].push_back( 310); - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(310); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //Lambdac -> Lambda pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(3122); //Lambdac -> Lambda pi+ + partDaughterPdg[curPart].push_back(211); curPart++; partDaughterPdg[curPart].push_back(-3122); //Lambdac_bar -> Lambda_bar pi- - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 3122); //Lambdac -> Lambda 2pi+ pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(3122); //Lambdac -> Lambda 2pi+ pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-3122); //Lambdac_bar -> Lambda_bar 2pi- pi+ - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - curPart++; - - partDaughterPdg[curPart].push_back( 3312); //Xic0 -> Xi- 2pi+ pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - curPart++; - + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); + curPart++; + + partDaughterPdg[curPart].push_back(3312); //Xic0 -> Xi- 2pi+ pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); + curPart++; + partDaughterPdg[curPart].push_back(-3312); //Xic0_bar -> Xi+ 2pi- pi+ - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 2212); //Lambdac -> p pi+ pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(2212); //Lambdac -> p pi+ pi- + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-2212); //Lambdac_bar -> p_bar pi+ pi- - partDaughterPdg[curPart].push_back( 211); - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(211); + partDaughterPdg[curPart].push_back(-211); curPart++; - - - partDaughterPdg[curPart].push_back( 411); //D*0 -> D+ pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(411); //D*0 -> D+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( -411); //D*0_bar -> D- pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(-411); //D*0_bar -> D- pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 421); //D*+ -> D0 pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(421); //D*+ -> D0 pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( -421); //D*- -> D0_bar pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(-421); //D*- -> D0_bar pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 429); //D*+ -> D04 pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(429); //D*+ -> D04 pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( -429); //D*- -> D04_bar pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(-429); //D*- -> D04_bar pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - partDaughterPdg[curPart].push_back( 428); //D*0 -> D04 pi0 - partDaughterPdg[curPart].push_back( 111); + partDaughterPdg[curPart].push_back(428); //D*0 -> D04 pi0 + partDaughterPdg[curPart].push_back(111); curPart++; - - partDaughterPdg[curPart].push_back( 11); //B -> e+ e- - partDaughterPdg[curPart].push_back( -11); + + partDaughterPdg[curPart].push_back(11); //B -> e+ e- + partDaughterPdg[curPart].push_back(-11); curPart++; - - partDaughterPdg[curPart].push_back( 13); //B -> mu+ mu- - partDaughterPdg[curPart].push_back( -13); + + partDaughterPdg[curPart].push_back(13); //B -> mu+ mu- + partDaughterPdg[curPart].push_back(-13); curPart++; - - partDaughterPdg[curPart].push_back( -421); //B+ -> D0_bar pi+ - partDaughterPdg[curPart].push_back( 211); + + partDaughterPdg[curPart].push_back(-421); //B+ -> D0_bar pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 421); //B- -> D0 pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(421); //B- -> D0 pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( -421); //B+ -> D0_bar K+ - partDaughterPdg[curPart].push_back( 321); + + partDaughterPdg[curPart].push_back(-421); //B+ -> D0_bar K+ + partDaughterPdg[curPart].push_back(321); curPart++; - - partDaughterPdg[curPart].push_back( 421); //B- -> D0 K- - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(421); //B- -> D0 K- + partDaughterPdg[curPart].push_back(-321); curPart++; - partDaughterPdg[curPart].push_back( -411); //B0 -> D- pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(-411); //B0 -> D- pi+ + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 411); //B0_bar -> D+ pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(411); //B0_bar -> D+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( -411); //B0 -> D0_bar K+ - partDaughterPdg[curPart].push_back( 321); + + partDaughterPdg[curPart].push_back(-411); //B0 -> D0_bar K+ + partDaughterPdg[curPart].push_back(321); curPart++; - - partDaughterPdg[curPart].push_back( 411); //B0_bar -> D0 K- - partDaughterPdg[curPart].push_back( -321); + + partDaughterPdg[curPart].push_back(411); //B0_bar -> D0 K- + partDaughterPdg[curPart].push_back(-321); curPart++; - partDaughterPdg[curPart].push_back( 3122); //H0-> Lambda pi- p - partDaughterPdg[curPart].push_back( -211); - partDaughterPdg[curPart].push_back( 2212); + partDaughterPdg[curPart].push_back(3122); //H0-> Lambda pi- p + partDaughterPdg[curPart].push_back(-211); + partDaughterPdg[curPart].push_back(2212); curPart++; - - partDaughterPdg[curPart].push_back( 1000010020); //LambdaN -> d+ pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(1000010020); //LambdaN -> d+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-1000010020); //LambdaN_bar-> d- pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - partDaughterPdg[curPart].push_back( 1000010030); //LambdaNN -> t+ pi- - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(1000010030); //LambdaNN -> t+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-1000010030); //LambdaNN_bar -> t- pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 1000020030); //H3Lambda -> He3+ pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(1000020030); //H3Lambda -> He3+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-1000020030); //H3Lambda_bar -> He3- pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - partDaughterPdg[curPart].push_back( 1000020040); //H4Lambda -> He4+ pi- - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(1000020040); //H4Lambda -> He4+ pi- + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-1000020040); //H4Lambda_bar -> He4- pi+ - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 1000020030); //He4Lambda -> He3+ p+ pi- - partDaughterPdg[curPart].push_back( 2212); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(1000020030); //He4Lambda -> He3+ p+ pi- + partDaughterPdg[curPart].push_back(2212); + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-1000020030); //He4Lambda_bar -> He3- p- pi+ partDaughterPdg[curPart].push_back(-2212); - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 1000020040); //He5Lambda -> He4+ p+ pi- - partDaughterPdg[curPart].push_back( 2212); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(1000020040); //He5Lambda -> He4+ p+ pi- + partDaughterPdg[curPart].push_back(2212); + partDaughterPdg[curPart].push_back(-211); curPart++; partDaughterPdg[curPart].push_back(-1000020040); //He5Lambda_bar -> He4- p- pi+ partDaughterPdg[curPart].push_back(-2212); - partDaughterPdg[curPart].push_back( 211); + partDaughterPdg[curPart].push_back(211); curPart++; - - partDaughterPdg[curPart].push_back( 3004); //LLn -> H3Lambda pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(3004); //LLn -> H3Lambda pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 3006); //H4LL -> He4Lambda pi- - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(3006); //H4LL -> He4Lambda pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - partDaughterPdg[curPart].push_back( 3004); //H4LL -> H3Lambda p pi- - partDaughterPdg[curPart].push_back( 2212); - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(3004); //H4LL -> H3Lambda p pi- + partDaughterPdg[curPart].push_back(2212); + partDaughterPdg[curPart].push_back(-211); curPart++; - partDaughterPdg[curPart].push_back( 3007); //H5LL -> He5Lambda pi- - partDaughterPdg[curPart].push_back( -211); + partDaughterPdg[curPart].push_back(3007); //H5LL -> He5Lambda pi- + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 3007); //He6LL -> He5Lambda p pi- - partDaughterPdg[curPart].push_back( 2212); - partDaughterPdg[curPart].push_back( -211); + + partDaughterPdg[curPart].push_back(3007); //He6LL -> He5Lambda p pi- + partDaughterPdg[curPart].push_back(2212); + partDaughterPdg[curPart].push_back(-211); curPart++; - - partDaughterPdg[curPart].push_back( 13); // pi- -> mu- + nu_mu_bar + + partDaughterPdg[curPart].push_back(13); // pi- -> mu- + nu_mu_bar partDaughterPdg[curPart].push_back(-7000014); // curPart++; - - partDaughterPdg[curPart].push_back( -211); // nu_mu_bar <- pi- - mu- - partDaughterPdg[curPart].push_back( 13); // + + partDaughterPdg[curPart].push_back(-211); // nu_mu_bar <- pi- - mu- + partDaughterPdg[curPart].push_back(13); // curPart++; - - partDaughterPdg[curPart].push_back( -13); // pi+ -> mu+ + nu_mu - partDaughterPdg[curPart].push_back( 7000014); // + + partDaughterPdg[curPart].push_back(-13); // pi+ -> mu+ + nu_mu + partDaughterPdg[curPart].push_back(7000014); // curPart++; - - partDaughterPdg[curPart].push_back( 211); // nu_mu <- pi+ - mu+ - partDaughterPdg[curPart].push_back( -13); // + + partDaughterPdg[curPart].push_back(211); // nu_mu <- pi+ - mu+ + partDaughterPdg[curPart].push_back(-13); // curPart++; - - partDaughterPdg[curPart].push_back( 13); // K- -> mu- + nu_mu_bar + + partDaughterPdg[curPart].push_back(13); // K- -> mu- + nu_mu_bar partDaughterPdg[curPart].push_back(-8000014); // curPart++; - - partDaughterPdg[curPart].push_back( -321); // nu_mu_bar <- K- - mu- - partDaughterPdg[curPart].push_back( 13); // + + partDaughterPdg[curPart].push_back(-321); // nu_mu_bar <- K- - mu- + partDaughterPdg[curPart].push_back(13); // curPart++; - - partDaughterPdg[curPart].push_back( -13); // K+ -> mu+ + nu_mu - partDaughterPdg[curPart].push_back( 8000014); // + + partDaughterPdg[curPart].push_back(-13); // K+ -> mu+ + nu_mu + partDaughterPdg[curPart].push_back(8000014); // curPart++; - - partDaughterPdg[curPart].push_back( 321); // nu_mu <- K+ - mu+ - partDaughterPdg[curPart].push_back( -13); // + + partDaughterPdg[curPart].push_back(321); // nu_mu <- K+ - mu+ + partDaughterPdg[curPart].push_back(-13); // curPart++; - - partDaughterPdg[curPart].push_back( -211); // Sigma- -> pi- + n - partDaughterPdg[curPart].push_back( 7002112); // + + partDaughterPdg[curPart].push_back(-211); // Sigma- -> pi- + n + partDaughterPdg[curPart].push_back(7002112); // curPart++; - - partDaughterPdg[curPart].push_back( 3112); // n <- Sigma- - pi- - partDaughterPdg[curPart].push_back( -211); // + + partDaughterPdg[curPart].push_back(3112); // n <- Sigma- - pi- + partDaughterPdg[curPart].push_back(-211); // curPart++; - - partDaughterPdg[curPart].push_back( 211); // Sigma-b -> pi+ + nb - partDaughterPdg[curPart].push_back( -7002112); // + + partDaughterPdg[curPart].push_back(211); // Sigma-b -> pi+ + nb + partDaughterPdg[curPart].push_back(-7002112); // curPart++; - - partDaughterPdg[curPart].push_back( -3112); // nb <- Sigma-b - pi+ - partDaughterPdg[curPart].push_back( 211); // + + partDaughterPdg[curPart].push_back(-3112); // nb <- Sigma-b - pi+ + partDaughterPdg[curPart].push_back(211); // curPart++; - - partDaughterPdg[curPart].push_back( -211); // Sigma+b -> pi- + nb - partDaughterPdg[curPart].push_back( -8002112); // + + partDaughterPdg[curPart].push_back(-211); // Sigma+b -> pi- + nb + partDaughterPdg[curPart].push_back(-8002112); // curPart++; - - partDaughterPdg[curPart].push_back( -3222); // nb <- Sigma+b - pi- - partDaughterPdg[curPart].push_back( -211); // + + partDaughterPdg[curPart].push_back(-3222); // nb <- Sigma+b - pi- + partDaughterPdg[curPart].push_back(-211); // curPart++; - - partDaughterPdg[curPart].push_back( 211); // Sigma+ -> pi+ + n - partDaughterPdg[curPart].push_back( 8002112); // + + partDaughterPdg[curPart].push_back(211); // Sigma+ -> pi+ + n + partDaughterPdg[curPart].push_back(8002112); // curPart++; - - partDaughterPdg[curPart].push_back( 3222); // n <- Sigma+ - pi+ - partDaughterPdg[curPart].push_back( 211); // + + partDaughterPdg[curPart].push_back(3222); // n <- Sigma+ - pi+ + partDaughterPdg[curPart].push_back(211); // curPart++; - - partDaughterPdg[curPart].push_back( -211); // Xi- -> pi- + lam - partDaughterPdg[curPart].push_back( 7003122); // + + partDaughterPdg[curPart].push_back(-211); // Xi- -> pi- + lam + partDaughterPdg[curPart].push_back(7003122); // curPart++; - - partDaughterPdg[curPart].push_back( 3312); // lam <- Xi- - pi- - partDaughterPdg[curPart].push_back( -211); // + + partDaughterPdg[curPart].push_back(3312); // lam <- Xi- - pi- + partDaughterPdg[curPart].push_back(-211); // curPart++; - - partDaughterPdg[curPart].push_back( 211); // Xi-b -> pi+ + lam_b - partDaughterPdg[curPart].push_back( -7003122); // + + partDaughterPdg[curPart].push_back(211); // Xi-b -> pi+ + lam_b + partDaughterPdg[curPart].push_back(-7003122); // curPart++; - - partDaughterPdg[curPart].push_back( -3312); // lam_b <- Xi-b - pi+ - partDaughterPdg[curPart].push_back( 211); // + + partDaughterPdg[curPart].push_back(-3312); // lam_b <- Xi-b - pi+ + partDaughterPdg[curPart].push_back(211); // curPart++; - - partDaughterPdg[curPart].push_back( -211); // Om- -> pi- + Xi0 - partDaughterPdg[curPart].push_back( 7003322); // + + partDaughterPdg[curPart].push_back(-211); // Om- -> pi- + Xi0 + partDaughterPdg[curPart].push_back(7003322); // curPart++; - - partDaughterPdg[curPart].push_back( 3334); // Xi0 <- Om- - pi- - partDaughterPdg[curPart].push_back( -211); // + + partDaughterPdg[curPart].push_back(3334); // Xi0 <- Om- - pi- + partDaughterPdg[curPart].push_back(-211); // curPart++; - - partDaughterPdg[curPart].push_back( 211); // Om-b -> pi+ + Xi0_b - partDaughterPdg[curPart].push_back( -7003322); // + + partDaughterPdg[curPart].push_back(211); // Om-b -> pi+ + Xi0_b + partDaughterPdg[curPart].push_back(-7003322); // curPart++; - - partDaughterPdg[curPart].push_back( -3334); // Xi0_b <- Om-b - pi+ - partDaughterPdg[curPart].push_back( 211); // + + partDaughterPdg[curPart].push_back(-3334); // Xi0_b <- Om-b - pi+ + partDaughterPdg[curPart].push_back(211); // curPart++; - - partDaughterPdg[curPart].push_back( -211); // K- -> pi- + Pi0_b - partDaughterPdg[curPart].push_back( -9000111); // + + partDaughterPdg[curPart].push_back(-211); // K- -> pi- + Pi0_b + partDaughterPdg[curPart].push_back(-9000111); // curPart++; - - partDaughterPdg[curPart].push_back( -321); // Pi0_b <- K- - pi- - partDaughterPdg[curPart].push_back( -211); // + + partDaughterPdg[curPart].push_back(-321); // Pi0_b <- K- - pi- + partDaughterPdg[curPart].push_back(-211); // curPart++; - - partDaughterPdg[curPart].push_back( 211); // K+ -> pi+ + Pi0 - partDaughterPdg[curPart].push_back( 9000111); // + + partDaughterPdg[curPart].push_back(211); // K+ -> pi+ + Pi0 + partDaughterPdg[curPart].push_back(9000111); // curPart++; - - partDaughterPdg[curPart].push_back( 321); // Pi0 <- K+ - pi+ - partDaughterPdg[curPart].push_back( 211); // + + partDaughterPdg[curPart].push_back(321); // Pi0 <- K+ - pi+ + partDaughterPdg[curPart].push_back(211); // curPart++; - - partDaughterPdg[curPart].push_back( -321); // Om- -> K- + Lam - partDaughterPdg[curPart].push_back( 8003122); // + + partDaughterPdg[curPart].push_back(-321); // Om- -> K- + Lam + partDaughterPdg[curPart].push_back(8003122); // curPart++; - - partDaughterPdg[curPart].push_back( 3334); // Lam <- Om- - K- - partDaughterPdg[curPart].push_back( -321); // + + partDaughterPdg[curPart].push_back(3334); // Lam <- Om- - K- + partDaughterPdg[curPart].push_back(-321); // curPart++; - - partDaughterPdg[curPart].push_back( 321); // Om+ -> K+ + Lam_b - partDaughterPdg[curPart].push_back( -8003122); // + + partDaughterPdg[curPart].push_back(321); // Om+ -> K+ + Lam_b + partDaughterPdg[curPart].push_back(-8003122); // curPart++; - - partDaughterPdg[curPart].push_back( -3334); // Lam_b <- Om+ - K+ - partDaughterPdg[curPart].push_back( 321); // + + partDaughterPdg[curPart].push_back(-3334); // Lam_b <- Om+ - K+ + partDaughterPdg[curPart].push_back(321); // curPart++; - - partDaughterPdg[curPart].push_back( -2212); // Si+b -> p_b + Pi0 - partDaughterPdg[curPart].push_back( -8000111); // + + partDaughterPdg[curPart].push_back(-2212); // Si+b -> p_b + Pi0 + partDaughterPdg[curPart].push_back(-8000111); // curPart++; - - partDaughterPdg[curPart].push_back( -3222); // Pi0 <- Si+b - p_b - partDaughterPdg[curPart].push_back( -2212); // + + partDaughterPdg[curPart].push_back(-3222); // Pi0 <- Si+b - p_b + partDaughterPdg[curPart].push_back(-2212); // curPart++; - - partDaughterPdg[curPart].push_back( 2212); // Si+ -> p + Pi0 - partDaughterPdg[curPart].push_back( 8000111); // + + partDaughterPdg[curPart].push_back(2212); // Si+ -> p + Pi0 + partDaughterPdg[curPart].push_back(8000111); // curPart++; - - partDaughterPdg[curPart].push_back( 3222); // Pi0 <- Si+ - p - partDaughterPdg[curPart].push_back( 2212); // + + partDaughterPdg[curPart].push_back(3222); // Pi0 <- Si+ - p + partDaughterPdg[curPart].push_back(2212); // curPart++; - - for(int iP=0; iP::iterator it; - it=fPdgToIndex.find(pdg); - if(it != fPdgToIndex.end()) return it->second; - else return -1; + it = fPdgToIndex.find(pdg); + if (it != fPdgToIndex.end()) + return it->second; + else + return -1; } /** \brief Returns the map between PDG codes and index of the decay in the scheme of the KF Particle Finder. */ - std::map GetPdgToIndexMap() const { return fPdgToIndex; } - + std::map GetPdgToIndexMap() const { return fPdgToIndex; } + virtual void AddCounter(std::string shortname, std::string name) { /** Adds a counter with the name defined by "name" to all counter @@ -1121,7 +1116,7 @@ class KFPartEfficiencies :public TObject mc1.AddCounter(); mc2.AddCounter(); mc3.AddCounter(); - + reco.AddCounter(); ratio_ghost.AddCounter(); @@ -1133,24 +1128,31 @@ class KFPartEfficiencies :public TObject }; /** \brief Operator to add efficiency table from object "a" to the current object. Returns the current object after addition. */ - KFPartEfficiencies& operator+=(KFPartEfficiencies& a){ - mc1 += a.mc1; mc2 += a.mc2; mc3 += a.mc3; reco += a.reco; - ghost += a.ghost; bg += a.bg; clone += a.clone; + KFPartEfficiencies& operator+=(KFPartEfficiencies& a) + { + mc1 += a.mc1; + mc2 += a.mc2; + mc3 += a.mc3; + reco += a.reco; + ghost += a.ghost; + bg += a.bg; + clone += a.clone; return *this; }; - + /** \brief Function to calculate efficiency after all counters are set. If the counters are modified the function should be called again. */ - void CalcEff(){ - ratio_reco1 = reco/mc1; - ratio_reco2 = reco/mc2; - ratio_reco3 = reco/mc3; + void CalcEff() + { + ratio_reco1 = reco / mc1; + ratio_reco2 = reco / mc2; + ratio_reco3 = reco / mc3; KFMCCounter allReco = reco + ghost + bg; - ratio_ghost = ghost/allReco; - ratio_bg = bg/allReco; - ratio_clone = clone/allReco; + ratio_ghost = ghost / allReco; + ratio_bg = bg / allReco; + ratio_clone = clone / allReco; }; - + void Inc(bool isReco, int nClones, bool isMC1, bool isMC2, bool isMC3, std::string name) { /** Increases counters by one, if the corresponding boolean variable is "true". @@ -1163,13 +1165,17 @@ class KFPartEfficiencies :public TObject ** \param[in] name - "shortname" of the set of counters, which should be increased **/ const int index = indices[name]; - - if(isMC1) mc1.counters[index]++; - if(isMC2) mc2.counters[index]++; - if(isMC3) mc3.counters[index]++; - - if(isReco) reco.counters[index]++; - if(nClones > 0) + + if (isMC1) + mc1.counters[index]++; + if (isMC2) + mc2.counters[index]++; + if (isMC3) + mc3.counters[index]++; + + if (isReco) + reco.counters[index]++; + if (nClones > 0) clone.counters[index] += nClones; }; @@ -1182,58 +1188,72 @@ class KFPartEfficiencies :public TObject **/ const int index = indices[name]; - if (isGhost) ghost. counters[index]++; - if (isBg) bg.counters[index]++; + if (isGhost) + ghost.counters[index]++; + if (isBg) + bg.counters[index]++; }; /** \brief Prints the efficiency table on the screen. */ - void PrintEff(){ + void PrintEff() + { std::ios_base::fmtflags original_flags = std::cout.flags(); std::cout.setf(std::ios::fixed); std::cout.setf(std::ios::showpoint); std::cout.precision(3); std::cout << "Particle : " - << " Eff 4pi " - <<" / "<< " Eff accept" - <<" / "<< " Eff KFPF " - <<" / "<< " Ghost " - <<" / "<< " BackGr " - <<" / "<< " N Ghost " - <<" / "<< " N BackGr " - <<" / "<< " N Reco " - <<" / "<< " N Clone " - <<" | "<< " N MC 4pi " - <<" | "<< "N MC accept" - <<" | "<< " N MC KFPF " << std::endl; - + << " Eff 4pi " + << " / " + << " Eff accept" + << " / " + << " Eff KFPF " + << " / " + << " Ghost " + << " / " + << " BackGr " + << " / " + << " N Ghost " + << " / " + << " N BackGr " + << " / " + << " N Reco " + << " / " + << " N Clone " + << " | " + << " N MC 4pi " + << " | " + << "N MC accept" + << " | " + << " N MC KFPF " << std::endl; + int NCounters = mc1.NCounters; - for (int iC = 0; iC < NCounters; iC++){ - std::cout << names[iC] - << " : " << std::setw(10) << ratio_reco1.counters[iC] - << " / " << std::setw(10) << ratio_reco2.counters[iC] - << " / " << std::setw(10) << ratio_reco3.counters[iC] - << " / " << std::setw(10) << ratio_ghost.counters[iC] // particles w\o MCParticle - << " / " << std::setw(10) << ratio_bg.counters[iC] // particles with incorrect MCParticle - << " / " << std::setw(10) << ghost.counters[iC] - << " / " << std::setw(10) << bg.counters[iC] - << " / " << std::setw(10) << reco.counters[iC] - << " / " << std::setw(10) << clone.counters[iC] - << " | " << std::setw(10) << mc1.counters[iC] - << " | " << std::setw(10) << mc2.counters[iC] - << " | " << std::setw(10) << mc3.counters[iC] << std::endl; + for (int iC = 0; iC < NCounters; iC++) { + std::cout << names[iC] + << " : " << std::setw(10) << ratio_reco1.counters[iC] + << " / " << std::setw(10) << ratio_reco2.counters[iC] + << " / " << std::setw(10) << ratio_reco3.counters[iC] + << " / " << std::setw(10) << ratio_ghost.counters[iC] // particles w\o MCParticle + << " / " << std::setw(10) << ratio_bg.counters[iC] // particles with incorrect MCParticle + << " / " << std::setw(10) << ghost.counters[iC] + << " / " << std::setw(10) << bg.counters[iC] + << " / " << std::setw(10) << reco.counters[iC] + << " / " << std::setw(10) << clone.counters[iC] + << " | " << std::setw(10) << mc1.counters[iC] + << " | " << std::setw(10) << mc2.counters[iC] + << " | " << std::setw(10) << mc3.counters[iC] << std::endl; } - std::cout.flags(original_flags); + std::cout.flags(original_flags); }; - - float GetTotal4piEfficiency(int iDecay) { return ratio_reco1.counters[3*iDecay]; } ///< Returns efficiency in 4pi for decay "iDecay". - float GetTotalKFPEfficiency(int iDecay) { return ratio_reco3.counters[3*iDecay]; } ///< Returns efficiency of KF Particle Finder method (cuts) for decay "iDecay". - float GetPrimary4piEfficiency(int iDecay) { return ratio_reco1.counters[3*iDecay+1]; } ///< Returns efficiency in 4pi for decay "iDecay" for primary particles. - float GetPrimaryKFPEfficiency(int iDecay) { return ratio_reco3.counters[3*iDecay+1]; } ///< Returns efficiency of KF Particle Finder method (cuts) for decay "iDecay" for primary particles. - float GetSecondary4piEfficiency(int iDecay) { return ratio_reco1.counters[3*iDecay+2]; } ///< Returns efficiency in 4pi for decay "iDecay" for secondary particles. - float GetSecondaryKFPEfficiency(int iDecay) { return ratio_reco3.counters[3*iDecay+2]; } ///< Returns efficiency of KF Particle Finder method (cuts) for decay "iDecay" for secondary particles. - + + float GetTotal4piEfficiency(int iDecay) { return ratio_reco1.counters[3 * iDecay]; } ///< Returns efficiency in 4pi for decay "iDecay". + float GetTotalKFPEfficiency(int iDecay) { return ratio_reco3.counters[3 * iDecay]; } ///< Returns efficiency of KF Particle Finder method (cuts) for decay "iDecay". + float GetPrimary4piEfficiency(int iDecay) { return ratio_reco1.counters[3 * iDecay + 1]; } ///< Returns efficiency in 4pi for decay "iDecay" for primary particles. + float GetPrimaryKFPEfficiency(int iDecay) { return ratio_reco3.counters[3 * iDecay + 1]; } ///< Returns efficiency of KF Particle Finder method (cuts) for decay "iDecay" for primary particles. + float GetSecondary4piEfficiency(int iDecay) { return ratio_reco1.counters[3 * iDecay + 2]; } ///< Returns efficiency in 4pi for decay "iDecay" for secondary particles. + float GetSecondaryKFPEfficiency(int iDecay) { return ratio_reco3.counters[3 * iDecay + 2]; } ///< Returns efficiency of KF Particle Finder method (cuts) for decay "iDecay" for secondary particles. + /** \brief Operator to write efficiencies to file. */ - friend std::fstream & operator<<(std::fstream &strm, KFPartEfficiencies &a) + friend std::fstream& operator<<(std::fstream& strm, KFPartEfficiencies& a) { strm << a.ratio_reco1; strm << a.ratio_reco2; @@ -1252,7 +1272,7 @@ class KFPartEfficiencies :public TObject return strm; } /** \brief Operator to read efficiencies from file. */ - friend std::fstream & operator>>(std::fstream &strm, KFPartEfficiencies &a) + friend std::fstream& operator>>(std::fstream& strm, KFPartEfficiencies& a) { strm >> a.ratio_reco1; strm >> a.ratio_reco2; @@ -1273,17 +1293,17 @@ class KFPartEfficiencies :public TObject /** \brief Adds efficiency from the file with the name defined by "fileName" to the current objects. */ void AddFromFile(std::string fileName) { - std::fstream file(fileName.data(),std::fstream::in); + std::fstream file(fileName.data(), std::fstream::in); file >> *this; } - + int GetNDaughters(int iParticle) const { return partDaughterPdg[iParticle].size(); } ///< Returns number of daughter particles for the decay with index "iParticle". /** \brief Returns the PDG code of the daughter "iDaughter" from the decay with index "iParticle". */ int GetDaughterPDG(int iParticle, int iDaughter) const { return partDaughterPdg[iParticle][iDaughter]; } - - float GetMass(int iParticle) const { return partMass[iParticle]; } ///< Returns the table mass of the decay with index "iParticle". + + float GetMass(int iParticle) const { return partMass[iParticle]; } ///< Returns the table mass of the decay with index "iParticle". float GetMassSigma(int iParticle) const { return partMassSigma[iParticle]; } ///< Returns expected width of the mass peak of the decay with index "iParticle". - + static const int nParticles = 194; ///< Number of particles. static const int fFirstHypernucleusIndex = 114; ///< Index of the first hypernuclei in the list. static const int fLastHypernucleusIndex = 130; ///< Index of the last hypernuclei in the list. @@ -1291,46 +1311,45 @@ class KFPartEfficiencies :public TObject static const int fLastMissingMassParticleIndex = 166; ///< Index of the last decay reconstructed by the missing mass method. static const int fFirstStableParticleIndex = 167; ///< Index of the first stable particle in the list. static const int fLastStableParticleIndex = 184; ///< Index of the last stable particle in the list. - - int partPDG[nParticles]; ///< Array of PDG codes assigned to the decays. - std::string partName[nParticles]; ///< Array of names of the decay in the file with histograms. - std::string partTitle[nParticles]; ///< Array of names of the decay in the output table with efficiency. - std::vector > partDaughterPdg; ///< Array with vectors of daughter particles for each decay. - float partMHistoMin[nParticles]; ///< Array with lower boundary in the mass histograms for each decay. - float partMHistoMax[nParticles]; ///< Array with upper boundary in the mass histograms for each decay. - int partMaxMult[nParticles]; ///< Array with upper boundary in the multiplicity histograms of each decay. - float partMass[nParticles]; ///< Array with table masses of each decay. - float partLifeTime[nParticles]; ///< Array with lifetimes in seconds of each decay. - int partCharge[nParticles]; ///< Array with charge of each particle specie in units of the elementary charge. - float partMassSigma[nParticles]; ///< Array with expected width of mass peaks used for the side band method. - - + + int partPDG[nParticles]; ///< Array of PDG codes assigned to the decays. + std::string partName[nParticles]; ///< Array of names of the decay in the file with histograms. + std::string partTitle[nParticles]; ///< Array of names of the decay in the output table with efficiency. + std::vector> partDaughterPdg; ///< Array with vectors of daughter particles for each decay. + float partMHistoMin[nParticles]; ///< Array with lower boundary in the mass histograms for each decay. + float partMHistoMax[nParticles]; ///< Array with upper boundary in the mass histograms for each decay. + int partMaxMult[nParticles]; ///< Array with upper boundary in the multiplicity histograms of each decay. + float partMass[nParticles]; ///< Array with table masses of each decay. + float partLifeTime[nParticles]; ///< Array with lifetimes in seconds of each decay. + int partCharge[nParticles]; ///< Array with charge of each particle specie in units of the elementary charge. + float partMassSigma[nParticles]; ///< Array with expected width of mass peaks used for the side band method. + private: std::vector names; ///< Names of the counters. The same for all counters objects. std::map indices; ///< Map between the counter index and its short name. - std::map fPdgToIndex; ///< The map between PDG code assigned to the decay and index in the decay list. + std::map fPdgToIndex; ///< The map between PDG code assigned to the decay and index in the decay list. + + KFMCCounter ratio_reco1; ///< Efficiency in 4 pi for all decays. + KFMCCounter ratio_reco2; ///< Efficiency normalised on the particles with all daughters reconstructable for all decays. + KFMCCounter ratio_reco3; ///< Efficiency normalised on the particles with all daughters reconstructed for all decays. - KFMCCounter ratio_reco1; ///< Efficiency in 4 pi for all decays. - KFMCCounter ratio_reco2; ///< Efficiency normalised on the particles with all daughters reconstructable for all decays. - KFMCCounter ratio_reco3; ///< Efficiency normalised on the particles with all daughters reconstructed for all decays. + KFMCCounter mc1; ///< Counters of the Monte Carlo particles of all species. + KFMCCounter mc2; ///< Counters of the Monte Carlo particles with all daughters reconstructable for all species. + KFMCCounter mc3; ///< Counters of the Monte Carlo particles with all daughters found for all species. - KFMCCounter mc1; ///< Counters of the Monte Carlo particles of all species. - KFMCCounter mc2; ///< Counters of the Monte Carlo particles with all daughters reconstructable for all species. - KFMCCounter mc3; ///< Counters of the Monte Carlo particles with all daughters found for all species. + KFMCCounter reco; ///< Counters of the reconstructed particles for all species. - KFMCCounter reco; ///< Counters of the reconstructed particles for all species. + KFMCCounter ratio_ghost; ///< Ratio of the ghost candidates to the total number of candidates for all species. + KFMCCounter ratio_bg; ///< Ratio of the physics background candidates to the total number of candidates for all species. + KFMCCounter ratio_clone; ///< Ratio of double reconstructed particles to the total number of signal candidates for all species. - KFMCCounter ratio_ghost; ///< Ratio of the ghost candidates to the total number of candidates for all species. - KFMCCounter ratio_bg; ///< Ratio of the physics background candidates to the total number of candidates for all species. - KFMCCounter ratio_clone; ///< Ratio of double reconstructed particles to the total number of signal candidates for all species. + KFMCCounter ghost; ///< Counters of the ghost candidates for all species. + KFMCCounter bg; ///< Counters of the physics background candidates for all species. + KFMCCounter clone; ///< Counters of the double reconstructed particles for all species. - KFMCCounter ghost; ///< Counters of the ghost candidates for all species. - KFMCCounter bg; ///< Counters of the physics background candidates for all species. - KFMCCounter clone; ///< Counters of the double reconstructed particles for all species. - #ifndef KFParticleStandalone - ClassDef( KFPartEfficiencies, 1 ) + ClassDef(KFPartEfficiencies, 1) #endif }; diff --git a/KFParticlePerformance/KFPartMatch.h b/KFParticlePerformance/KFPartMatch.h index 5546612..d3b2abc 100644 --- a/KFParticlePerformance/KFPartMatch.h +++ b/KFParticlePerformance/KFPartMatch.h @@ -24,7 +24,6 @@ #include - /** @class KFPartMatch ** @brief A structure to store matching information between simulated Monte Carlo and reconstructed particles. ** @author M.Zyzak, I.Kisel @@ -38,19 +37,26 @@ struct KFPartMatch // used for Reco to MC match as well as for MC to Reco { - KFPartMatch():ids(),idsMI() {} - + KFPartMatch() : ids(), idsMI() {} + bool IsMatched() const { return ids.size() != 0 || idsMI.size() != 0; } ///< Returns true if at least one link exists independently of the PDG hypothesis. bool IsMatchedWithPdg() const { return ids.size() != 0; } ///< Returns true is at least one link with the correct PDG exists. - int GetBestMatch() const { - if (ids.size() != 0) return ids[0]; - else if (idsMI.size() != 0) return idsMI[0]; - else return -1; + int GetBestMatch() const + { + if (ids.size() != 0) + return ids[0]; + else if (idsMI.size() != 0) + return idsMI[0]; + else + return -1; } ///< Returns first link with correct PDG if exists, otherwise first link with incorrect PDG. If no link exists returns "-1". - int GetBestMatchWithPdg() const { - if (ids.size() != 0) return ids[0]; - else return -1; - } ///< Returns first link with correct PDG if exists, otherwise returns "-1". + int GetBestMatchWithPdg() const + { + if (ids.size() != 0) + return ids[0]; + else + return -1; + } ///< Returns first link with correct PDG if exists, otherwise returns "-1". std::vector ids; ///< Vector of links, PDG hypothesis of the reconstructed particle is required to be the same as the PDG code of the Monte Carlo particle. std::vector idsMI; ///< Vector of links, PDG hypothesis of the reconstructed particle differs from the Monte Carlo particle. }; diff --git a/KFParticlePerformance/KFParticlePerformanceBase.cxx b/KFParticlePerformance/KFParticlePerformanceBase.cxx index 6ee3e98..1c7b270 100644 --- a/KFParticlePerformance/KFParticlePerformanceBase.cxx +++ b/KFParticlePerformance/KFParticlePerformanceBase.cxx @@ -30,110 +30,98 @@ #include "TProfile.h" #include "TProfile2D.h" - -KFParticlePerformanceBase::KFParticlePerformanceBase(): - fParteff(), fPVeff(), fPVeffMCReconstructable(), outfileName(), histodir(0), fNEvents(0), fStoreMCHistograms(1), - fStorePrimSecHistograms(1), fStoreZRHistograms(1),fHistoDir(0) +KFParticlePerformanceBase::KFParticlePerformanceBase() : fParteff(), fPVeff(), fPVeffMCReconstructable(), outfileName(), histodir(0), fNEvents(0), fStoreMCHistograms(1), fStorePrimSecHistograms(1), fStoreZRHistograms(1), fHistoDir(0) { /** The default constructor. Initialises all pointers to nullptr. **/ - for(int iParticle=0; iParticle decays) +void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* outFile, std::map decays) { /** Creates all histograms. If "outFile" is provided - creates a new ROOT directory and stores all ** histograms there. Otherwise histograms are stored in TDirectory::CurrentDirectory(). @@ -142,12 +130,12 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o ** \param[in] decays - a list of decays, for which histograms are created, if empty - histograms are ** created for all decay channels from the KF Particle Finder reconstruction scheme **/ - TDirectory *curdir = gDirectory; + TDirectory* curdir = gDirectory; if (outFile) { outFile->cd(); fHistoDir = outFile; if (histoDir != "") { - fHistoDir = outFile->mkdir( TString(histoDir) ); + fHistoDir = outFile->mkdir(TString(histoDir)); fHistoDir->cd(); } } else { @@ -159,34 +147,33 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o histodir = gDirectory; gDirectory->mkdir("Particles"); gDirectory->cd("Particles"); - for(int iPart=0; iPart fParteff.fLastStableParticleIndex)) - if(decays.find(fParteff.partPDG[iPart]) == decays.end()) continue; - + for (int iPart = 0; iPart < fParteff.nParticles; ++iPart) { + if (!(decays.empty()) && (iPart < fParteff.fFirstStableParticleIndex || iPart > fParteff.fLastStableParticleIndex)) + if (decays.find(fParteff.partPDG[iPart]) == decays.end()) + continue; + gDirectory->mkdir(fParteff.partName[iPart].data()); gDirectory->cd(fParteff.partName[iPart].data()); { - if(fStoreMCHistograms) - { + if (fStoreMCHistograms) { TString res = "res"; TString pull = "pull"; gDirectory->mkdir("DaughtersQA"); gDirectory->cd("DaughtersQA"); { - TString parName[nFitQA/2] = {"X","Y","Z","Px","Py","Pz","E","M"}; + TString parName[nFitQA / 2] = {"X", "Y", "Z", "Px", "Py", "Pz", "E", "M"}; int nBins = 100; - float xMax[nFitQA/2] = {0.15,0.15,0.03,0.01,0.01,0.06,0.06,0.01}; - // float xMax[nFitQA/2] = {2.,2.,5.,0.3,0.3,0.3,0.03,0.03}; - - for( int iH=0; iHcd(".."); //particle directory @@ -194,25 +181,25 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o gDirectory->mkdir("DSToParticleQA"); gDirectory->cd("DSToParticleQA"); { - TString parName[3] = {"X","Y","Z"}; + TString parName[3] = {"X", "Y", "Z"}; int nBins = 100; float xMax[3] = {0.5, 0.5, 2.}; - for( int iH=0; iH<3; iH++ ){ - hDSToParticleQA[iPart][iH] = new TH1F((res+parName[iH]).Data(), - (GetDirectoryPath()+res+parName[iH]).Data(), - nBins, -xMax[iH],xMax[iH]); - hDSToParticleQA[iPart][iH+3] = new TH1F((pull+parName[iH]).Data(), - (GetDirectoryPath()+pull+parName[iH]).Data(), - nBins, -6,6); + for (int iH = 0; iH < 3; iH++) { + hDSToParticleQA[iPart][iH] = new TH1F((res + parName[iH]).Data(), + (GetDirectoryPath() + res + parName[iH]).Data(), + nBins, -xMax[iH], xMax[iH]); + hDSToParticleQA[iPart][iH + 3] = new TH1F((pull + parName[iH]).Data(), + (GetDirectoryPath() + pull + parName[iH]).Data(), + nBins, -6, 6); } - - hDSToParticleQA[iPart][6] = new TH1F("r", (GetDirectoryPath()+TString("r")).Data(), 1000, 0.0, 20.0); + + hDSToParticleQA[iPart][6] = new TH1F("r", (GetDirectoryPath() + TString("r")).Data(), 1000, 0.0, 20.0); } gDirectory->cd(".."); //particle directory - + CreateFitHistograms(hFitQA[iPart], iPart); - CreateEfficiencyHistograms(hPartEfficiency[iPart],hPartEfficiency2D[iPart]); + CreateEfficiencyHistograms(hPartEfficiency[iPart], hPartEfficiency2D[iPart]); } gDirectory->mkdir("Parameters"); gDirectory->cd("Parameters"); @@ -220,8 +207,7 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o const bool drawZR = IsCollectZRHistogram(iPart); CreateParameterHistograms(hPartParam[0], hPartParam2D[0], hPartParam3D[0], iPart, drawZR); - if(IsCollect3DHistogram(iPart)) - { + if (IsCollect3DHistogram(iPart)) { gDirectory->mkdir("SignalReco"); gDirectory->cd("SignalReco"); { @@ -235,9 +221,8 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o } gDirectory->cd(".."); // Parameters } - - if(fStoreMCHistograms) - { + + if (fStoreMCHistograms) { gDirectory->mkdir("Signal"); gDirectory->cd("Signal"); { @@ -262,22 +247,20 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o CreateParameterHistograms(hPartParam[6], hPartParam2D[6], 0, iPart, drawZR); } gDirectory->cd(".."); // Parameters - - + bool plotPrimaryHistograms = abs(fParteff.partPDG[iPart]) == 310 || abs(fParteff.partPDG[iPart]) == 3122 || abs(fParteff.partPDG[iPart]) == 22 || abs(fParteff.partPDG[iPart]) == 111 || abs(fParteff.partPDG[iPart]) == 3312 || - abs(fParteff.partPDG[iPart]) == 3334; - + abs(fParteff.partPDG[iPart]) == 3334; + bool plotSecondaryHistograms = abs(fParteff.partPDG[iPart]) == 310 || abs(fParteff.partPDG[iPart]) == 3122 || abs(fParteff.partPDG[iPart]) == 22 || abs(fParteff.partPDG[iPart]) == 111; - - if(fStorePrimSecHistograms && plotPrimaryHistograms) - { + + if (fStorePrimSecHistograms && plotPrimaryHistograms) { gDirectory->mkdir("Primary"); gDirectory->cd("Primary"); { @@ -288,9 +271,8 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o } gDirectory->cd(".."); // particle directory / Parameters } - - if(fStorePrimSecHistograms && plotSecondaryHistograms) - { + + if (fStorePrimSecHistograms && plotSecondaryHistograms) { gDirectory->mkdir("Secondary"); gDirectory->cd("Secondary"); { @@ -313,66 +295,63 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o TString name; TString title; Int_t n; - Double_t l,r; - } Table[nHistosPV]= - { - {"PVResX", "x_{rec}-x_{mc}, cm", 100, -0.1f, 0.1f}, - {"PVResY", "y_{rec}-y_{mc}, cm", 100, -0.1f, 0.1f}, - {"PVResZ", "z_{rec}-z_{mc}, cm", 100, -1.f, 1.f}, - {"PVPullX", "Pull X", 100, -6.f, 6.f}, - {"PVPullY", "Pull Y", 100, -6.f, 6.f}, - {"PVPullZ", "Pull Z", 100, -6.f, 6.f}, - {"Lost", "Lost tracks", 102, -0.01f, 1.01f} - }; - - TString parName[nHistosPVParam] = {"x","y","z","r","Ntracks","Chi2","NDF","Chi2NDF","prob", "PVpurity", + Double_t l, r; + } Table[nHistosPV] = + { + {"PVResX", "x_{rec}-x_{mc}, cm", 100, -0.1f, 0.1f}, + {"PVResY", "y_{rec}-y_{mc}, cm", 100, -0.1f, 0.1f}, + {"PVResZ", "z_{rec}-z_{mc}, cm", 100, -1.f, 1.f}, + {"PVPullX", "Pull X", 100, -6.f, 6.f}, + {"PVPullY", "Pull Y", 100, -6.f, 6.f}, + {"PVPullZ", "Pull Z", 100, -6.f, 6.f}, + {"Lost", "Lost tracks", 102, -0.01f, 1.01f}}; + + TString parName[nHistosPVParam] = {"x", "y", "z", "r", "Ntracks", "Chi2", "NDF", "Chi2NDF", "prob", "PVpurity", "ghostTr", "triggerTr", "pileupTr", "bgTr", "dzSamePV"}; - TString parAxisName[nHistosPVParam] = {"x [cm]","y [cm]","z [cm]","r [cm]","N tracks","Chi2","NDF","Chi2NDF","prob","purity", + TString parAxisName[nHistosPVParam] = {"x [cm]", "y [cm]", "z [cm]", "r [cm]", "N tracks", "Chi2", "NDF", "Chi2NDF", "prob", "purity", "ghost tracks [%]", "trigger tracks [%]", "pileup tracks [%]", "bg tracks [%]", "dz [cm]"}; - int nBins[nHistosPVParam] = {1000,1000,1000,1000,1001,10000,1001,10000,100,102,102,102,102,102,1000}; - float xMin[nHistosPVParam] = {-1., -1., -10., 0, -0.5, 0., -0.5, 0., 0., -0.01, -0.01, -0.01, -0.01, -0.01, 0.}; - float xMax[nHistosPVParam] = { 1., 1., 10., 10, 1000.5, 1000., 1000.5, 1000., 1., 1.01, 1.01, 1.01, 1.01, 1.01, 100.}; - + int nBins[nHistosPVParam] = {1000, 1000, 1000, 1000, 1001, 10000, 1001, 10000, 100, 102, 102, 102, 102, 102, 1000}; + float xMin[nHistosPVParam] = {-1., -1., -10., 0, -0.5, 0., -0.5, 0., 0., -0.01, -0.01, -0.01, -0.01, -0.01, 0.}; + float xMax[nHistosPVParam] = {1., 1., 10., 10, 1000.5, 1000., 1000.5, 1000., 1., 1.01, 1.01, 1.01, 1.01, 1.01, 100.}; + TString parName2D[nHistosPVParam2D] = {"xy"}; TString parXAxisName2D[nHistosPVParam2D] = {"x [cm]"}; TString parYAxisName2D[nHistosPVParam2D] = {"y [cm]"}; int nBinsX2D[nHistosPVParam2D] = {1000}; float xMin2D[nHistosPVParam2D] = {-1.}; - float xMax2D[nHistosPVParam2D] = { 1.}; + float xMax2D[nHistosPVParam2D] = {1.}; int nBinsY2D[nHistosPVParam2D] = {1000}; float yMin2D[nHistosPVParam2D] = {-1.}; - float yMax2D[nHistosPVParam2D] = { 1.}; - - for(int iH=0; iHGetXaxis()->SetTitle(parAxisName[iH].Data()); } - for(int iH=0; iHGetXaxis()->SetTitle(parXAxisName2D[iH].Data()); hPVParam2D[iH]->GetYaxis()->SetTitle(parYAxisName2D[iH].Data()); hPVParam2D[iH]->GetYaxis()->SetTitleOffset(1.0); } - + gDirectory->mkdir("Efficiency"); gDirectory->cd("Efficiency"); { - TString effName[nPVefficiency] = {"effVsNMCPVTracks","effVsNMCPV","effVsNMCTracks","effVsNPVTracks","effVsNPV","effVsNTracks"}; - int nBinsEff[nPVefficiency] = { 100 , 100 , 100 , 100 , 100 , 1000 }; - float xMinEff[nPVefficiency] = { 0., 0., 0., 0., 0., 0.}; - float xMaxEff[nPVefficiency] = { 100., 100., 1000., 100., 100., 1000.}; + TString effName[nPVefficiency] = {"effVsNMCPVTracks", "effVsNMCPV", "effVsNMCTracks", "effVsNPVTracks", "effVsNPV", "effVsNTracks"}; + int nBinsEff[nPVefficiency] = {100, 100, 100, 100, 100, 1000}; + float xMinEff[nPVefficiency] = {0., 0., 0., 0., 0., 0.}; + float xMaxEff[nPVefficiency] = {100., 100., 1000., 100., 100., 1000.}; gDirectory->mkdir("Signal"); gDirectory->cd("Signal"); { - for( int iH=0; iHcd(".."); //L1 @@ -380,52 +359,52 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o gDirectory->mkdir("Pileup"); gDirectory->cd("Pileup"); { - for( int iH=0; iHcd(".."); //L1 - + gDirectory->mkdir("Signal_MCReconstructable"); gDirectory->cd("Signal_MCReconstructable"); { - for( int iH=0; iHcd(".."); //L1 - + gDirectory->mkdir("Pileup_MCReconstructable"); gDirectory->cd("Pileup_MCReconstructable"); { - for( int iH=0; iHcd(".."); //L1 - } + } gDirectory->cd(".."); //L1 - + gDirectory->mkdir("PVTracksQA"); gDirectory->cd("PVTracksQA"); { TString resTrPV = "resTrPV"; TString pullTrPV = "pullTrPV"; - TString parNameTrPV[nFitPVTracksQA/2] = {"X","Y","Z","Px","Py","Pz"}; + TString parNameTrPV[nFitPVTracksQA / 2] = {"X", "Y", "Z", "Px", "Py", "Pz"}; int nBinsTrPV = 100; - float xMaxTrPV[nFitPVTracksQA/2] = {0.5,0.5,0.5,0.05,0.05,0.05}; - - for( int iH=0; iHcd(".."); //L1 - + gDirectory->mkdir("Signal"); gDirectory->cd("Signal"); { @@ -435,8 +414,8 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o gDirectory->mkdir("FitQAvcNMCPVTracks"); gDirectory->cd("FitQAvcNMCPVTracks"); { - for(int iHPV=0; iHPVmkdir("FitQAvcNPVTracks"); gDirectory->cd("FitQAvcNPVTracks"); { - for(int iHPV=0; iHPVcd(".."); //FitQA - - for(int iHPV=0; iHPVcd(".."); //Signal - for(int iH=0; iHGetXaxis()->SetTitle(parAxisName[iH].Data()); } - } + } gDirectory->cd(".."); //L1 gDirectory->mkdir("Pileup"); @@ -479,8 +457,8 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o gDirectory->mkdir("FitQAvcNMCPVTracks"); gDirectory->cd("FitQAvcNMCPVTracks"); { - for(int iHPV=0; iHPVmkdir("FitQAvcNPVTracks"); gDirectory->cd("FitQAvcNPVTracks"); { - for(int iHPV=0; iHPVcd(".."); //FitQA - - for(int iHPV=0; iHPVcd(".."); //Signal - - for(int iH=0; iHGetXaxis()->SetTitle(parAxisName[iH].Data()); } - } + } gDirectory->cd(".."); //L1 - + gDirectory->mkdir("Background"); gDirectory->cd("Background"); { - for(int iH=0; iHGetXaxis()->SetTitle(parAxisName[iH].Data()); } - } + } gDirectory->cd(".."); //L1 - + gDirectory->mkdir("Ghost"); gDirectory->cd("Ghost"); { - for(int iH=0; iHGetXaxis()->SetTitle(parAxisName[iH].Data()); } } @@ -543,26 +518,24 @@ void KFParticlePerformanceBase::CreateHistos(std::string histoDir, TDirectory* o gDirectory->cd("TrackParameters"); { TString chi2Name = "Chi2Prim"; - for(int iPart=0; iPart < KFPartEfficiencies::nParticles; iPart++) - { + for (int iPart = 0; iPart < KFPartEfficiencies::nParticles; iPart++) { TString chi2NamePart = "Chi2Prim"; chi2NamePart += "_"; chi2NamePart += fParteff.partName[iPart].data(); - hTrackParameters[iPart] = new TH1F(chi2NamePart.Data(), (GetDirectoryPath()+chi2NamePart).Data(), 1000, 0, 100); - + hTrackParameters[iPart] = new TH1F(chi2NamePart.Data(), (GetDirectoryPath() + chi2NamePart).Data(), 1000, 0, 100); } - hTrackParameters[KFPartEfficiencies::nParticles ] = new TH1F("Chi2Prim_total", (GetDirectoryPath()+TString("Chi2Prim_total")), 1000, 0, 100); - hTrackParameters[KFPartEfficiencies::nParticles+1] = new TH1F("Chi2Prim_prim", (GetDirectoryPath()+TString("Chi2Prim_prim")), 1000, 0, 100); - hTrackParameters[KFPartEfficiencies::nParticles+2] = new TH1F("Chi2Prim_sec", (GetDirectoryPath()+TString("Chi2Prim_sec")), 1000, 0, 100); - hTrackParameters[KFPartEfficiencies::nParticles+3] = new TH1F("Chi2Prim_ghost", (GetDirectoryPath()+TString("Chi2Prim_ghost")), 1000, 0, 100); - - hTrackParameters[KFPartEfficiencies::nParticles+4] = new TH1F("ProbPrim_total", (GetDirectoryPath()+TString("ProbPrim_total")), 10000, 0, 1); - hTrackParameters[KFPartEfficiencies::nParticles+5] = new TH1F("ProbPrim_prim", (GetDirectoryPath()+TString("ProbPrim_prim")), 10000, 0, 1); - hTrackParameters[KFPartEfficiencies::nParticles+6] = new TH1F("ProbPrim_sec", (GetDirectoryPath()+TString("ProbPrim_sec")), 10000, 0, 1); - hTrackParameters[KFPartEfficiencies::nParticles+7] = new TH1F("ProbPrim_ghost", (GetDirectoryPath()+TString("ProbPrim_ghost")), 10000, 0, 1); + hTrackParameters[KFPartEfficiencies::nParticles] = new TH1F("Chi2Prim_total", (GetDirectoryPath() + TString("Chi2Prim_total")), 1000, 0, 100); + hTrackParameters[KFPartEfficiencies::nParticles + 1] = new TH1F("Chi2Prim_prim", (GetDirectoryPath() + TString("Chi2Prim_prim")), 1000, 0, 100); + hTrackParameters[KFPartEfficiencies::nParticles + 2] = new TH1F("Chi2Prim_sec", (GetDirectoryPath() + TString("Chi2Prim_sec")), 1000, 0, 100); + hTrackParameters[KFPartEfficiencies::nParticles + 3] = new TH1F("Chi2Prim_ghost", (GetDirectoryPath() + TString("Chi2Prim_ghost")), 1000, 0, 100); + + hTrackParameters[KFPartEfficiencies::nParticles + 4] = new TH1F("ProbPrim_total", (GetDirectoryPath() + TString("ProbPrim_total")), 10000, 0, 1); + hTrackParameters[KFPartEfficiencies::nParticles + 5] = new TH1F("ProbPrim_prim", (GetDirectoryPath() + TString("ProbPrim_prim")), 10000, 0, 1); + hTrackParameters[KFPartEfficiencies::nParticles + 6] = new TH1F("ProbPrim_sec", (GetDirectoryPath() + TString("ProbPrim_sec")), 10000, 0, 1); + hTrackParameters[KFPartEfficiencies::nParticles + 7] = new TH1F("ProbPrim_ghost", (GetDirectoryPath() + TString("ProbPrim_ghost")), 10000, 0, 1); } gDirectory->cd(".."); //particle directory - curdir->cd(); + curdir->cd(); } } @@ -574,9 +547,9 @@ void KFParticlePerformanceBase::CreateFitHistograms(TH1F* histo[nFitQA], int iPa **/ TString res = "res"; TString pull = "pull"; - - TString AxisNameResidual[nFitQA/2]; - TString AxisNamePull[nFitQA/2]; + + TString AxisNameResidual[nFitQA / 2]; + TString AxisNamePull[nFitQA / 2]; AxisNameResidual[0] = "Residual (x^{reco} - x^{mc}) [cm]"; AxisNameResidual[1] = "Residual (y^{reco} - y^{mc}) [cm]"; @@ -585,7 +558,7 @@ void KFParticlePerformanceBase::CreateFitHistograms(TH1F* histo[nFitQA], int iPa AxisNameResidual[4] = "Residual (P_{y}^{reco} - P_{y}^{mc}) [GeV/c]"; AxisNameResidual[5] = "Residual (P_{z}^{reco} - P_{z}^{mc}) [GeV/c]"; AxisNameResidual[6] = "Residual (E^{reco} - E^{mc}) [GeV/c^{2}]"; - AxisNameResidual[7] = "Residual (M^{reco} - M^{mc}) [GeV/c^{2}]"; + AxisNameResidual[7] = "Residual (M^{reco} - M^{mc}) [GeV/c^{2}]"; AxisNamePull[0] = "Pull x"; AxisNamePull[1] = "Pull y"; @@ -595,51 +568,48 @@ void KFParticlePerformanceBase::CreateFitHistograms(TH1F* histo[nFitQA], int iPa AxisNamePull[5] = "Pull P_{z}"; AxisNamePull[6] = "Pull E"; AxisNamePull[7] = "Pull M"; - + gDirectory->mkdir("FitQA"); gDirectory->cd("FitQA"); { - TString parName[nFitQA/2] = {"X","Y","Z","Px","Py","Pz","E","M"}; + TString parName[nFitQA / 2] = {"X", "Y", "Z", "Px", "Py", "Pz", "E", "M"}; int nBins = 50; - float xMax[nFitQA/2] = {0.15,0.15,1.2,0.02,0.02,0.15,0.15,0.006}; - float mult[nFitQA/2]={1.f,1.f,1.f,1.f,1.f,1.f,1.f,1.f}; - if(iPart>63 && iPart<75) - for(int iMult=3; iMult 63 && iPart < 75) + for (int iMult = 3; iMult < nFitQA / 2; iMult++) mult[iMult] = 3; - if(iPart>45 && iPart<64) - { + if (iPart > 45 && iPart < 64) { #ifdef CBM - for(int iMult=0; iMult<3; iMult++) + for (int iMult = 0; iMult < 3; iMult++) mult[iMult] = 0.03; - for(int iMult=3; iMultGetXaxis()->SetTitle(AxisNameResidual[iH].Data()); - histo[iH+8] = new TH1F((pull+parName[iH]).Data(), - (GetDirectoryPath()+pull+parName[iH]).Data(), - nBins, -6,6); - histo[iH+8]->GetXaxis()->SetTitle(AxisNamePull[iH+8].Data()); + histo[iH + 8] = new TH1F((pull + parName[iH]).Data(), + (GetDirectoryPath() + pull + parName[iH]).Data(), + nBins, -6, 6); + histo[iH + 8]->GetXaxis()->SetTitle(AxisNamePull[iH + 8].Data()); } } gDirectory->cd(".."); @@ -653,60 +623,58 @@ void KFParticlePerformanceBase::CreateEfficiencyHistograms(TProfile* histo[3][nP **/ gDirectory->mkdir("Efficiency"); gDirectory->cd("Efficiency"); - {//vs p, pt, y, z, c*tau, decay length, l, r - TString partNameEff[nPartEfficiency] = {"EffVsP","EffVsPt","EffVsY","EffVsZ","EffVsCT","EffVsDL","EffVsL","EffVsR","EffVsMt" }; - TString partAxisNameEff[nPartEfficiency] = {"p [GeV/c]","p_{t} [GeV/c]", - "y", "z [cm]", "Life time c#tau [cm]", "Decay length [cm]", + { //vs p, pt, y, z, c*tau, decay length, l, r + TString partNameEff[nPartEfficiency] = {"EffVsP", "EffVsPt", "EffVsY", "EffVsZ", "EffVsCT", "EffVsDL", "EffVsL", "EffVsR", "EffVsMt"}; + TString partAxisNameEff[nPartEfficiency] = {"p [GeV/c]", "p_{t} [GeV/c]", + "y", "z [cm]", "Life time c#tau [cm]", "Decay length [cm]", "L [cm]", "Rxy [cm]", "m_{t} [GeV/c^{2}]"}; #ifdef CBM - int nBinsEff[nPartEfficiency] = { 100 , 100 , 100 , 360 , 100 , 100 , 200 , 200 , 100 }; - float xMinEff[nPartEfficiency] = { 0., 0., 0., -10., 0., 0., 0., 0. , 0.}; - float xMaxEff[nPartEfficiency] = { 20., 5., 6., 80., 100., 100., 100., 50. , 4.}; + int nBinsEff[nPartEfficiency] = {100, 100, 100, 360, 100, 100, 200, 200, 100}; + float xMinEff[nPartEfficiency] = {0., 0., 0., -10., 0., 0., 0., 0., 0.}; + float xMaxEff[nPartEfficiency] = {20., 5., 6., 80., 100., 100., 100., 50., 4.}; #else - int nBinsEff[nPartEfficiency] = { 100 , 100 , 30 , 100 , 100 , 100 , 100 , 100 , 100 }; - float xMinEff[nPartEfficiency] = { 0., 0., -1.5, -10., 0., 0., 0., 0., 0. }; - float xMaxEff[nPartEfficiency] = { 10., 10., 1.5, 10., 30., 5., 1., 1., 10. }; + int nBinsEff[nPartEfficiency] = {100, 100, 30, 100, 100, 100, 100, 100, 100}; + float xMinEff[nPartEfficiency] = {0., 0., -1.5, -10., 0., 0., 0., 0., 0.}; + float xMaxEff[nPartEfficiency] = {10., 10., 1.5, 10., 30., 5., 1., 1., 10.}; #endif TString effTypeName[3] = {"All particles", "Reconstructable daughters", "Reconstructed daughters"}; - - for(int iEff=0; iEff<3; iEff++) - { + + for (int iEff = 0; iEff < 3; iEff++) { gDirectory->mkdir(effTypeName[iEff].Data()); gDirectory->cd(effTypeName[iEff].Data()); { - for(int iH=0; iHGetYaxis()->SetTitle("Efficiency"); - histo[iEff][iH]->GetYaxis()->SetTitleOffset(1.0); + for (int iH = 0; iH < nPartEfficiency; iH++) { + histo[iEff][iH] = new TProfile(partNameEff[iH].Data(), (GetDirectoryPath() + partAxisNameEff[iH]).Data(), nBinsEff[iH], xMinEff[iH], xMaxEff[iH]); + histo[iEff][iH]->GetYaxis()->SetTitle("Efficiency"); + histo[iEff][iH]->GetYaxis()->SetTitleOffset(1.0); histo[iEff][iH]->GetXaxis()->SetTitle(partAxisNameEff[iH].Data()); } - - histo2[iEff][0] = new TProfile2D( "EffVsPtVsY", (GetDirectoryPath()+partAxisNameEff[2]+partAxisNameEff[1]).Data(), - nBinsEff[2], xMinEff[2], xMaxEff[2], nBinsEff[1], xMinEff[1], xMaxEff[1]); + + histo2[iEff][0] = new TProfile2D("EffVsPtVsY", (GetDirectoryPath() + partAxisNameEff[2] + partAxisNameEff[1]).Data(), + nBinsEff[2], xMinEff[2], xMaxEff[2], nBinsEff[1], xMinEff[1], xMaxEff[1]); histo2[iEff][0]->GetZaxis()->SetTitle("Efficiency"); histo2[iEff][0]->GetXaxis()->SetTitle(partAxisNameEff[2].Data()); histo2[iEff][0]->GetYaxis()->SetTitle(partAxisNameEff[1].Data()); histo2[iEff][0]->GetYaxis()->SetTitleOffset(1.0); - - histo2[iEff][1] = new TProfile2D( "EffVsMtVsY", (GetDirectoryPath()+partAxisNameEff[2]+partAxisNameEff[8]).Data(), - nBinsEff[2], xMinEff[2], xMaxEff[2], nBinsEff[8], xMinEff[8], xMaxEff[8]); + + histo2[iEff][1] = new TProfile2D("EffVsMtVsY", (GetDirectoryPath() + partAxisNameEff[2] + partAxisNameEff[8]).Data(), + nBinsEff[2], xMinEff[2], xMaxEff[2], nBinsEff[8], xMinEff[8], xMaxEff[8]); histo2[iEff][1]->GetZaxis()->SetTitle("Efficiency"); histo2[iEff][1]->GetXaxis()->SetTitle(partAxisNameEff[2].Data()); histo2[iEff][1]->GetYaxis()->SetTitle(partAxisNameEff[8].Data()); histo2[iEff][1]->GetYaxis()->SetTitleOffset(1.0); } - gDirectory->cd("..");// particle directory / Efficiency + gDirectory->cd(".."); // particle directory / Efficiency } } - gDirectory->cd("..");// particle directory + gDirectory->cd(".."); // particle directory } void KFParticlePerformanceBase::CreateParameterHistograms(TH1F* histoParameters[KFPartEfficiencies::nParticles][nHistoPartParam], - TH2F *histoParameters2D[KFPartEfficiencies::nParticles][nHistoPartParam2D], - TH3F *histoParameters3D[KFPartEfficiencies::nParticles][nHistoPartParam3D], + TH2F* histoParameters2D[KFPartEfficiencies::nParticles][nHistoPartParam2D], + TH3F* histoParameters3D[KFPartEfficiencies::nParticles][nHistoPartParam3D], int iPart, bool drawZR) { /** Creates histograms with parameter distributions for decay with "iPart" number. @@ -716,237 +684,231 @@ void KFParticlePerformanceBase::CreateParameterHistograms(TH1F* histoParameters[ ** \param[in] iPart - number of the decay in the KF Particle Finder reconstruction scheme ** \param[in] drawZR - flag showing if Z-R histogram should be created **/ - TString parName[nHistoPartParam] = {"M","p","p_{t}","y","DecayL","c#tau","chi2ndf","prob","#theta","phi","X","Y","Z","R", "L", "l/dl","m_{t}","Multiplicity"}; + TString parName[nHistoPartParam] = {"M", "p", "p_{t}", "y", "DecayL", "c#tau", "chi2ndf", "prob", "#theta", "phi", "X", "Y", "Z", "R", "L", "l/dl", "m_{t}", "Multiplicity"}; TString parTitle[nHistoPartParam]; TString parName2D[nHistoPartParam2D] = {"y-p_{t}", "Z-R", "Armenteros", "y-m_{t}"}; TString parTitle2D[nHistoPartParam2D]; TString parName3D[nHistoPartParam3D] = {"y-p_{t}-M", "y-m_{t}-M", "centrality-pt-M", "centrality-y-M", "centrality-mt-M", "ct-pt-M"}; TString parTitle3D[nHistoPartParam3D]; - for(int iParam=0; iParamGetXaxis()->SetTitle(parAxisName[iH].Data()); } - histoParameters2D[iPart][0] = new TH2F(parName2D[0].Data(),parTitle2D[0].Data(), - nBins[3],xMin[3],xMax[3], - nBins[2],xMin[2],xMax[2]); + histoParameters2D[iPart][0] = new TH2F(parName2D[0].Data(), parTitle2D[0].Data(), + nBins[3], xMin[3], xMax[3], + nBins[2], xMin[2], xMax[2]); histoParameters2D[iPart][0]->GetXaxis()->SetTitle("y"); histoParameters2D[iPart][0]->GetYaxis()->SetTitle("p_{t} [GeV/c]"); histoParameters2D[iPart][0]->GetYaxis()->SetTitleOffset(1.0); - if(drawZR) - { - histoParameters2D[iPart][1] = new TH2F(parName2D[1].Data(),parTitle2D[1].Data(), - nBins[12],xMin[12],xMax[12], - nBins[13],xMin[13],xMax[13]); + if (drawZR) { + histoParameters2D[iPart][1] = new TH2F(parName2D[1].Data(), parTitle2D[1].Data(), + nBins[12], xMin[12], xMax[12], + nBins[13], xMin[13], xMax[13]); histoParameters2D[iPart][1]->GetXaxis()->SetTitle("Z [cm]"); histoParameters2D[iPart][1]->GetYaxis()->SetTitle("R [cm]"); histoParameters2D[iPart][1]->GetYaxis()->SetTitleOffset(1.0); - } - else + } else histoParameters2D[iPart][1] = NULL; - + //create armenteros plot - if(IsCollectArmenteros(iPart)) - { - histoParameters2D[iPart][2] = new TH2F(parName2D[2].Data(),parTitle2D[2].Data(), + if (IsCollectArmenteros(iPart)) { + histoParameters2D[iPart][2] = new TH2F(parName2D[2].Data(), parTitle2D[2].Data(), 50, -1.f, 1.f, - 150, 0.f, 1.f); + 150, 0.f, 1.f); histoParameters2D[iPart][2]->GetXaxis()->SetTitle("#alpha (p_{L}^{+}-p_{L}^{-})/(p_{L}^{+}+p_{L}^{-})"); histoParameters2D[iPart][2]->GetYaxis()->SetTitle("q_{t} [GeV/c]"); histoParameters2D[iPart][2]->GetYaxis()->SetTitleOffset(1.0); - } - else + } else histoParameters2D[iPart][2] = NULL; //create y-mt plot - histoParameters2D[iPart][3] = new TH2F(parName2D[3].Data(),parTitle2D[3].Data(), - nBins[3],xMin[3], xMax[3], //y - nBins[16],xMin[16],xMax[16]); //Mt + histoParameters2D[iPart][3] = new TH2F(parName2D[3].Data(), parTitle2D[3].Data(), + nBins[3], xMin[3], xMax[3], //y + nBins[16], xMin[16], xMax[16]); //Mt histoParameters2D[iPart][3]->GetXaxis()->SetTitle("y"); histoParameters2D[iPart][3]->GetYaxis()->SetTitle("m_{t} [GeV/c]"); histoParameters2D[iPart][3]->GetYaxis()->SetTitleOffset(1.0); - - - if( histoParameters3D && IsCollect3DHistogram(iPart) ) - { - histoParameters3D[iPart][0] = new TH3F(parName3D[0].Data(),parTitle3D[0].Data(), - nBins[3],xMin[3],xMax[3], - nBins[2],xMin[2],xMax[2], - nBins[0],xMin[0],xMax[0]); + + if (histoParameters3D && IsCollect3DHistogram(iPart)) { + histoParameters3D[iPart][0] = new TH3F(parName3D[0].Data(), parTitle3D[0].Data(), + nBins[3], xMin[3], xMax[3], + nBins[2], xMin[2], xMax[2], + nBins[0], xMin[0], xMax[0]); histoParameters3D[iPart][0]->GetXaxis()->SetTitle("y"); histoParameters3D[iPart][0]->GetYaxis()->SetTitle("p_{t} [GeV/c]"); histoParameters3D[iPart][0]->GetYaxis()->SetTitleOffset(1.0); histoParameters3D[iPart][0]->GetZaxis()->SetTitle("M"); - - histoParameters3D[iPart][1] = new TH3F(parName3D[1].Data(),parTitle3D[1].Data(), - nBins[3],xMin[3],xMax[3], - nBins[16],xMin[16],xMax[16], - nBins[0],xMin[0],xMax[0]); + + histoParameters3D[iPart][1] = new TH3F(parName3D[1].Data(), parTitle3D[1].Data(), + nBins[3], xMin[3], xMax[3], + nBins[16], xMin[16], xMax[16], + nBins[0], xMin[0], xMax[0]); histoParameters3D[iPart][1]->GetXaxis()->SetTitle("y"); histoParameters3D[iPart][1]->GetYaxis()->SetTitle("m_{t} [GeV/c]"); histoParameters3D[iPart][1]->GetYaxis()->SetTitleOffset(1.0); histoParameters3D[iPart][1]->GetZaxis()->SetTitle("M"); - - int centralityHisto[3] = {2,3,16}; - for(int iCH = 0; iCH<3; iCH++) - { - histoParameters3D[iPart][2+iCH] = new TH3F(parName3D[2+iCH].Data(),parTitle3D[2+iCH].Data(), - 10,0.,10., - nBins[centralityHisto[iCH]],xMin[centralityHisto[iCH]],xMax[centralityHisto[iCH]], - nBins[0],xMin[0],xMax[0]); - histoParameters3D[iPart][2+iCH]->GetXaxis()->SetTitle("centrality bin"); - histoParameters3D[iPart][2+iCH]->GetYaxis()->SetTitle(parAxisName[centralityHisto[iCH]]); - histoParameters3D[iPart][2+iCH]->GetYaxis()->SetTitleOffset(1.0); - histoParameters3D[iPart][2+iCH]->GetZaxis()->SetTitle("M"); + + int centralityHisto[3] = {2, 3, 16}; + for (int iCH = 0; iCH < 3; iCH++) { + histoParameters3D[iPart][2 + iCH] = new TH3F(parName3D[2 + iCH].Data(), parTitle3D[2 + iCH].Data(), + 10, 0., 10., + nBins[centralityHisto[iCH]], xMin[centralityHisto[iCH]], xMax[centralityHisto[iCH]], + nBins[0], xMin[0], xMax[0]); + histoParameters3D[iPart][2 + iCH]->GetXaxis()->SetTitle("centrality bin"); + histoParameters3D[iPart][2 + iCH]->GetYaxis()->SetTitle(parAxisName[centralityHisto[iCH]]); + histoParameters3D[iPart][2 + iCH]->GetYaxis()->SetTitleOffset(1.0); + histoParameters3D[iPart][2 + iCH]->GetZaxis()->SetTitle("M"); } - - histoParameters3D[iPart][5] = new TH3F(parName3D[5].Data(),parTitle3D[5].Data(), - nBins[5],xMin[5],xMax[5], - nBins[2],xMin[2],xMax[2], - nBins[0],xMin[0],xMax[0]); + + histoParameters3D[iPart][5] = new TH3F(parName3D[5].Data(), parTitle3D[5].Data(), + nBins[5], xMin[5], xMax[5], + nBins[2], xMin[2], xMax[2], + nBins[0], xMin[0], xMax[0]); histoParameters3D[iPart][5]->GetXaxis()->SetTitle("c#tau [cm]"); histoParameters3D[iPart][5]->GetYaxis()->SetTitle("p_{t} [GeV/c]"); histoParameters3D[iPart][5]->GetYaxis()->SetTitleOffset(1.0); histoParameters3D[iPart][5]->GetZaxis()->SetTitle("M"); - } - else if(histoParameters3D) - { + } else if (histoParameters3D) { histoParameters3D[iPart][0] = NULL; histoParameters3D[iPart][1] = NULL; - for(int iCH = 0; iCH<3; iCH++) - histoParameters3D[iPart][2+iCH] = NULL; + for (int iCH = 0; iCH < 3; iCH++) + histoParameters3D[iPart][2 + iCH] = NULL; histoParameters3D[iPart][5] = NULL; } } @@ -958,7 +920,8 @@ bool KFParticlePerformanceBase::IsCollectZRHistogram(int iParticle) const abs(fParteff.partPDG[iParticle]) == 3122 || abs(fParteff.partPDG[iParticle]) == 3312 || abs(fParteff.partPDG[iParticle]) == 3334 || - abs(fParteff.partPDG[iParticle]) == 22) && fStoreMCHistograms && fStoreZRHistograms; + abs(fParteff.partPDG[iParticle]) == 22) && + fStoreMCHistograms && fStoreZRHistograms; } bool KFParticlePerformanceBase::IsCollect3DHistogram(int iParticle) const @@ -1018,11 +981,11 @@ bool KFParticlePerformanceBase::IsCollectArmenteros(int iParticle) const abs(fParteff.partPDG[iParticle]) == 420 || abs(fParteff.partPDG[iParticle]) == 426 || abs(fParteff.partPDG[iParticle]) == 521 || - abs(fParteff.partPDG[iParticle]) == 511; + abs(fParteff.partPDG[iParticle]) == 511; #endif } -void KFParticlePerformanceBase::CreateParameterSubfolder(TString folderName, +void KFParticlePerformanceBase::CreateParameterSubfolder(TString folderName, TH1F* histoParameters[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam], TH2F* histoParameters2D[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D], TH1F* histoFit[KFPartEfficiencies::nParticles][nFitQA], int iPart, bool withWrongPVHypothesis) @@ -1037,8 +1000,7 @@ void KFParticlePerformanceBase::CreateParameterSubfolder(TString folderName, CreateParameterHistograms(histoParameters[1], histoParameters2D[1], 0, iPart); } gDirectory->cd(".."); - if(withWrongPVHypothesis) - { + if (withWrongPVHypothesis) { gDirectory->mkdir("WrongPVHypothesis"); gDirectory->cd("WrongPVHypothesis"); { @@ -1058,9 +1020,9 @@ void KFParticlePerformanceBase::CreateParameterSubfolder(TString folderName, CreateParameterHistograms(histoParameters[3], histoParameters2D[3], 0, iPart); } gDirectory->cd(".."); - + CreateParameterHistograms(histoParameters[0], histoParameters2D[0], 0, iPart); - if(histoFit!=0) + if (histoFit != 0) CreateFitHistograms(histoFit[iPart], iPart); } gDirectory->cd(".."); @@ -1071,12 +1033,11 @@ TString KFParticlePerformanceBase::GetDirectoryPath() /** Returns the path to the current folder. It is used as an addition to the histogram name. */ TString path = gDirectory->GetPath(); int fileNamePosition = path.Index("Finder/"); - path.Remove(0, fileNamePosition+7); + path.Remove(0, fileNamePosition + 7); path.ReplaceAll("Particles/", ""); path.ReplaceAll("/Parameters", ""); - path+=" "; + path += " "; return path; } #endif //DO_TPCCATRACKER_EFF_PERFORMANCE - diff --git a/KFParticlePerformance/KFParticlePerformanceBase.h b/KFParticlePerformance/KFParticlePerformanceBase.h index be4c9f0..7ce58a0 100644 --- a/KFParticlePerformance/KFParticlePerformanceBase.h +++ b/KFParticlePerformance/KFParticlePerformanceBase.h @@ -67,137 +67,136 @@ class TProfile2D; class KFParticlePerformanceBase #ifdef KFPWITHTRACKER -: public AliHLTTPCPerformanceBase + : public AliHLTTPCPerformanceBase #endif { public: - KFParticlePerformanceBase(); virtual ~KFParticlePerformanceBase(){}; - - /// Histograms - virtual void CreateHistos(std::string histoDir = "", TDirectory* outFile = 0, std::map decays = std::map()); + + /// Histograms + virtual void CreateHistos(std::string histoDir = "", TDirectory* outFile = 0, std::map decays = std::map()); TDirectory* GetHistosDirectory() { return fHistoDir; } ///< Returns pointer to the ROOT directory with created histograms. /** Switch off collection of histograms requiring Monte Carlo information. Not to allocate memory should be called ** before KFParticlePerformanceBase::CreateHistos(). **/ - void DoNotStoreMCHistograms() { fStoreMCHistograms = 0; } + void DoNotStoreMCHistograms() { fStoreMCHistograms = 0; } /** Switch off collection of histograms for primary and secondary candidates. Not to allocate memory should be called ** before KFParticlePerformanceBase::CreateHistos(). **/ void DoNotStorePrimSecHistograms() { fStorePrimSecHistograms = 0; } /** Switch off collection of Z-R histograms. Not to allocate memory should be called ** before KFParticlePerformanceBase::CreateHistos(). **/ - void DoNotStoreZRHistograms() { fStoreZRHistograms = 0; } - + void DoNotStoreZRHistograms() { fStoreZRHistograms = 0; } + /** Returns residual histogram with "iParameter" parameter for decay with "iDecay" number. */ - const TH1F* GetDecayResidual(const int iDecay, const int iParameter) const { return hFitQA[iDecay][iParameter]; } + const TH1F* GetDecayResidual(const int iDecay, const int iParameter) const { return hFitQA[iDecay][iParameter]; } /** Returns pull histogram with "iParameter" parameter for decay with "iDecay" number. */ - const TH1F* GetDecayPull(const int iDecay, const int iParameter) const { return hFitQA[iDecay][iParameter+nFitQA/2]; } - -// efficiencies - KFPartEfficiencies fParteff; ///< Object with reconstruction efficiency of short-lived particles. - KFPVEfficiencies fPVeff; ///< Object with reconstruction efficiency of primary vertices defined by the reconstructed tracks. + const TH1F* GetDecayPull(const int iDecay, const int iParameter) const { return hFitQA[iDecay][iParameter + nFitQA / 2]; } + + // efficiencies + KFPartEfficiencies fParteff; ///< Object with reconstruction efficiency of short-lived particles. + KFPVEfficiencies fPVeff; ///< Object with reconstruction efficiency of primary vertices defined by the reconstructed tracks. KFPVEfficiencies fPVeffMCReconstructable; ///< Object with reconstruction efficiency of primary vertices defined by the Monte Carlo tracks. - + protected: - TString outfileName; ///< Name of the output file, where histograms will be stored. + TString outfileName; ///< Name of the output file, where histograms will be stored. TDirectory* histodir; ///< Pointer to the ROOT directory, where histograms are created. - int fNEvents; ///< Number of processed events. - bool fStoreMCHistograms; ///< Flag showing if histograms requiring Monte Carlo information should be created and collected. "True" by default. + int fNEvents; ///< Number of processed events. + bool fStoreMCHistograms; ///< Flag showing if histograms requiring Monte Carlo information should be created and collected. "True" by default. bool fStorePrimSecHistograms; ///< Flag showing if histograms for primary and secondary candidates should be created and collected. "True" by default. - bool fStoreZRHistograms; ///< Flag showing if Z-R histograms should be created and collected. "True" by default. - -//histos - static const int nFitQA = 16; ///< Number of fit QA histograms: residuals and pulls in X, Y, Z, Px, Py, Pz, E, M. - TH1F *hFitDaughtersQA[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of daughter particles at production point. - TH1F *hFitQA[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the reconstructed particle: X, Y, Z at decay point, P, E, M - at production point - TH1F *hFitQANoConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with no constraints set. - TH1F *hFitQAMassConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with the mass constraint. - TH1F *hFitQATopoConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with the production point constraint. - TH1F *hFitQATopoMassConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with the mass and production point constraints. - - static const int nDSToParticleQA = 7; ///< Number of histograms to evaluate GetDStoParticle function: residuals and pulls in X, Y, Z; distance between DCA points. - TH1F *hDSToParticleQA[KFPartEfficiencies::nParticles][nDSToParticleQA]; ///< Histograms to evaluate KFParticleSIMD::GetDStoParticle() function - + bool fStoreZRHistograms; ///< Flag showing if Z-R histograms should be created and collected. "True" by default. + + //histos + static const int nFitQA = 16; ///< Number of fit QA histograms: residuals and pulls in X, Y, Z, Px, Py, Pz, E, M. + TH1F* hFitDaughtersQA[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of daughter particles at production point. + TH1F* hFitQA[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the reconstructed particle: X, Y, Z at decay point, P, E, M - at production point + TH1F* hFitQANoConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with no constraints set. + TH1F* hFitQAMassConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with the mass constraint. + TH1F* hFitQATopoConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with the production point constraint. + TH1F* hFitQATopoMassConstraint[KFPartEfficiencies::nParticles][nFitQA]; ///< Residuals and pulls of the particle with the mass and production point constraints. + + static const int nDSToParticleQA = 7; ///< Number of histograms to evaluate GetDStoParticle function: residuals and pulls in X, Y, Z; distance between DCA points. + TH1F* hDSToParticleQA[KFPartEfficiencies::nParticles][nDSToParticleQA]; ///< Histograms to evaluate KFParticleSIMD::GetDStoParticle() function + /** \brief Number of histograms with parameter distributions: mass, p, pt, rapidity, decay length, c*tau, ** chi/ndf, prob, theta, phi, X, Y, Z, R, L, L/dL, Mt, multiplicity. **/ static const int nHistoPartParam = 18; /** Number of sets of histograms with parameter distributions: 0 - all candidates, 1 - reconstructed signal, 2 - physics background from other decays, 3 - combinatorial ** background (ghost), 4 - reconstructed signal for side bands method, 5- reconstructed background for side bands method, 6 - MC signal. **/ static const int nParametersSet = 7; - TH1F *hPartParam[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of all candidates. - TH1F *hPartParamPrimary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates. - TH1F *hPartParamPrimaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates with mass constraint. - TH1F *hPartParamPrimaryTopo[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates with vertex constraint. - TH1F *hPartParamPrimaryTopoMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates with mass and vertex constraint. - TH1F *hPartParamSecondary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of secondary candidates. - TH1F *hPartParamSecondaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of secondary candidates with mass constraint. - - static const int nHistoPartParam2D = 4; ///< Number of 2D histograms: 0 - y-pt, 1 - z-r, 2 - armenteros, 3- y-mt. - TH2F *hPartParam2D[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D histograms for all candidates. - TH2F *hPartParam2DPrimary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for primary candidates. - TH2F *hPartParam2DPrimaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for primary candidates with mass constraint. - TH2F *hPartParam2DPrimaryTopo[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for primary candidates with vertex constraint. - TH2F *hPartParam2DPrimaryTopoMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D with mass and vertex constraints. - TH2F *hPartParam2DSecondary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for secondary candidates. - TH2F *hPartParam2DSecondaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for secondary candidates with mass constraint. - - static const int nHistoPartParam3D = 6; ///< Number of 3D histograms: y-pt-M, y-mt-M, b-pt-M, b-y-M, b-mt-M, ct-pt-M - TH3F *hPartParam3D[1][KFPartEfficiencies::nParticles][nHistoPartParam3D]; ///< 3D histograms. - - static const int nPartEfficiency = 9; ///< Number of efficiency plots for each decay: vs p, pt, y, z, c*tau, decay length, l, r, Mt. - TProfile* hPartEfficiency[KFPartEfficiencies::nParticles][3][nPartEfficiency]; ///< Efficiency plots. - static const int nPartEfficiency2D = 2; ///< Number of 2D efficiency plots for each decay: y-pt, y-mt. + TH1F* hPartParam[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of all candidates. + TH1F* hPartParamPrimary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates. + TH1F* hPartParamPrimaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates with mass constraint. + TH1F* hPartParamPrimaryTopo[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates with vertex constraint. + TH1F* hPartParamPrimaryTopoMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of primary candidates with mass and vertex constraint. + TH1F* hPartParamSecondary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of secondary candidates. + TH1F* hPartParamSecondaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam]; ///< Parameters of secondary candidates with mass constraint. + + static const int nHistoPartParam2D = 4; ///< Number of 2D histograms: 0 - y-pt, 1 - z-r, 2 - armenteros, 3- y-mt. + TH2F* hPartParam2D[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D histograms for all candidates. + TH2F* hPartParam2DPrimary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for primary candidates. + TH2F* hPartParam2DPrimaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for primary candidates with mass constraint. + TH2F* hPartParam2DPrimaryTopo[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for primary candidates with vertex constraint. + TH2F* hPartParam2DPrimaryTopoMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D with mass and vertex constraints. + TH2F* hPartParam2DSecondary[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for secondary candidates. + TH2F* hPartParam2DSecondaryMass[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D]; ///< 2D for secondary candidates with mass constraint. + + static const int nHistoPartParam3D = 6; ///< Number of 3D histograms: y-pt-M, y-mt-M, b-pt-M, b-y-M, b-mt-M, ct-pt-M + TH3F* hPartParam3D[1][KFPartEfficiencies::nParticles][nHistoPartParam3D]; ///< 3D histograms. + + static const int nPartEfficiency = 9; ///< Number of efficiency plots for each decay: vs p, pt, y, z, c*tau, decay length, l, r, Mt. + TProfile* hPartEfficiency[KFPartEfficiencies::nParticles][3][nPartEfficiency]; ///< Efficiency plots. + static const int nPartEfficiency2D = 2; ///< Number of 2D efficiency plots for each decay: y-pt, y-mt. TProfile2D* hPartEfficiency2D[KFPartEfficiencies::nParticles][3][nPartEfficiency2D]; ///< 2D efficiency plots. - - static const int nHistosPV = 7; ///< Number of QA histograms for primary vertices: residuals, pulls, number of lost tracks. - TH1F *hPVFitQa[2][nHistosPV]; ///< Fit QA of primary vertices, 1D histograms. - TH2F *hPVFitQa2D[2][2][nHistosPV-1]; ///< Fit QA of primary vertices, 2D histograms. + + static const int nHistosPV = 7; ///< Number of QA histograms for primary vertices: residuals, pulls, number of lost tracks. + TH1F* hPVFitQa[2][nHistosPV]; ///< Fit QA of primary vertices, 1D histograms. + TH2F* hPVFitQa2D[2][2][nHistosPV - 1]; ///< Fit QA of primary vertices, 2D histograms. /** Number of histograms with parameter distributions: x, y, z, r, Ntracks, Chi2, NDF, Chi2/NDF, prob, purity, part of ghost tracks, ** part of tracks from the current vertex, number of tracks from merged vertices, number of background tracks from decays, distance in Z between clones. **/ - static const int nHistosPVParam = 15; ///< - TH1F *hPVParam[nHistosPVParam]; ///< Histograms for all vertex candidates. - TH1F *hPVParamGhost[nHistosPVParam]; ///< Histograms for ghost (combinatorial background) vertex candidates. - TH1F *hPVParamSignal[nHistosPVParam]; ///< Histograms for signal vertex candidates. - TH1F *hPVParamPileup[nHistosPVParam]; ///< Histograms for pileup vertex candidates. - TH1F *hPVParamBG[nHistosPVParam]; ///< Histograms for physics background (decays, secondary vertices) vertex candidates. + static const int nHistosPVParam = 15; ///< + TH1F* hPVParam[nHistosPVParam]; ///< Histograms for all vertex candidates. + TH1F* hPVParamGhost[nHistosPVParam]; ///< Histograms for ghost (combinatorial background) vertex candidates. + TH1F* hPVParamSignal[nHistosPVParam]; ///< Histograms for signal vertex candidates. + TH1F* hPVParamPileup[nHistosPVParam]; ///< Histograms for pileup vertex candidates. + TH1F* hPVParamBG[nHistosPVParam]; ///< Histograms for physics background (decays, secondary vertices) vertex candidates. static const int nHistosPVParam2D = 1; ///< Number of 2D histograms for primary vertex. - TH2F *hPVParam2D[nHistosPVParam2D]; ///< x-y histogram. - + TH2F* hPVParam2D[nHistosPVParam2D]; ///< x-y histogram. + static const int nFitPVTracksQA = 12; ///< Number of fit QA histograms for primary tracks: residuals and pulls in X, Y, Z, Px, Py, Pz. - TH1F *hFitPVTracksQA[nFitPVTracksQA]; ///< Residuals and pulls of primary tracks at the primary vertex position. - + TH1F* hFitPVTracksQA[nFitPVTracksQA]; ///< Residuals and pulls of primary tracks at the primary vertex position. + static const int nHistosTP = KFPartEfficiencies::nParticles + 8; ///< Number of histograms with chi2 primary distributions for daughter tracks. /** Histograms with chi2 primary distributions for daughter tracks of each decays plus 4 distributions of chi2 and 4 prob for primary, secondary, ** ghost and all particles. **/ - TH1F *hTrackParameters[nHistosTP]; - - static const int nPVefficiency = 6; ///< Number of Efficiency plots for primary vertices for each category. + TH1F* hTrackParameters[nHistosTP]; + + static const int nPVefficiency = 6; ///< Number of Efficiency plots for primary vertices for each category. TProfile* hPVefficiency[4][nPVefficiency]; ///< Efficiency plots for primary vertices. - - TDirectory *fHistoDir; ///< ROOT directory with histograms. + + TDirectory* fHistoDir; ///< ROOT directory with histograms. bool IsCollectZRHistogram(int iParticle) const; bool IsCollect3DHistogram(int iParticle) const; bool IsCollectArmenteros(int iParticle) const; - + private: - const KFParticlePerformanceBase& operator = (const KFParticlePerformanceBase&); ///< Copying of objects of this class is forbidden. - KFParticlePerformanceBase(const KFParticlePerformanceBase&); ///< Copying of objects of this class is forbidden. - + const KFParticlePerformanceBase& operator=(const KFParticlePerformanceBase&); ///< Copying of objects of this class is forbidden. + KFParticlePerformanceBase(const KFParticlePerformanceBase&); ///< Copying of objects of this class is forbidden. + void CreateFitHistograms(TH1F* histo[nFitQA], int iPart); void CreateEfficiencyHistograms(TProfile* histo[3][nPartEfficiency], TProfile2D* histo2[3][nPartEfficiency2D]); void CreateParameterHistograms(TH1F* histoParameters[KFPartEfficiencies::nParticles][nHistoPartParam], - TH2F *histoParameters2D[KFPartEfficiencies::nParticles][nHistoPartParam2D], - TH3F *histoParameters3D[KFPartEfficiencies::nParticles][nHistoPartParam3D], + TH2F* histoParameters2D[KFPartEfficiencies::nParticles][nHistoPartParam2D], + TH3F* histoParameters3D[KFPartEfficiencies::nParticles][nHistoPartParam3D], int iPart, bool drawZR = 0); - void CreateParameterSubfolder(TString folderName, + void CreateParameterSubfolder(TString folderName, TH1F* histoParameters[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam], TH2F* histoParameters2D[nParametersSet][KFPartEfficiencies::nParticles][nHistoPartParam2D], TH1F* histoFit[KFPartEfficiencies::nParticles][nFitQA], int iPart, bool withWrongPVHypothesis = 0); - + TString GetDirectoryPath(); }; diff --git a/KFParticlePerformance/KFTopoPerformance.cxx b/KFParticlePerformance/KFTopoPerformance.cxx index 9d7653d..68b4837 100644 --- a/KFParticlePerformance/KFTopoPerformance.cxx +++ b/KFParticlePerformance/KFTopoPerformance.cxx @@ -49,9 +49,7 @@ using std::sort; using std::vector; -KFTopoPerformance::KFTopoPerformance():KFParticlePerformanceBase(),fTopoReconstructor(0),fPrimVertices(0), fMCTrackToMCPVMatch(0), - fPVPurity(0), fNCorrectPVTracks(0), fTrackMatch(0), vMCTracks(0), vMCParticles(0), fNeutralIndex(0), MCtoRParticleId(0), RtoMCParticleId(0), - MCtoRPVId(0), RtoMCPVId(0), fPrintEffFrequency(1), fCentralityBin(-1), fCentralityWeight(0.f) +KFTopoPerformance::KFTopoPerformance() : KFParticlePerformanceBase(), fTopoReconstructor(0), fPrimVertices(0), fMCTrackToMCPVMatch(0), fPVPurity(0), fNCorrectPVTracks(0), fTrackMatch(0), vMCTracks(0), vMCParticles(0), fNeutralIndex(0), MCtoRParticleId(0), RtoMCParticleId(0), MCtoRPVId(0), RtoMCPVId(0), fPrintEffFrequency(1), fCentralityBin(-1), fCentralityWeight(0.f) { } @@ -61,29 +59,28 @@ KFTopoPerformance::~KFTopoPerformance() #ifdef KFPWITHTRACKER void KFTopoPerformance::SetNewEvent( - const AliHLTTPCCAGBTracker * const tracker, - AliHLTResizableArray *hitLabels, - AliHLTResizableArray *mcTracks, - AliHLTResizableArray *localMCPoints) -{ + const AliHLTTPCCAGBTracker* const tracker, + AliHLTResizableArray* hitLabels, + AliHLTResizableArray* mcTracks, + AliHLTResizableArray* localMCPoints) +{ vMCTracks.resize(mcTracks->Size()); - for(int iTr=0; iTr pvIndex; - for(unsigned int iTr=0; iTr= nMCParticles) - { + if (motherId < 0) + continue; + if (motherId >= nMCParticles) { std::cout << "ERROR!!!!! KF Particle Performance: MC track mother Id is out of range." << std::endl; exit(1); } - KFMCParticle &motherPart = vMCParticles[motherId]; + KFMCParticle& motherPart = vMCParticles[motherId]; motherPart.AddDaughter(iP); } - + fNeutralIndex.clear(); fNeutralIndex.resize(nMCParticles, -1); - - for(unsigned int iMC=0; iMC < vMCParticles.size(); iMC++) - { - KFMCParticle &part = vMCParticles[iMC]; - part.SetMCTrackID( iMC ); + + for (unsigned int iMC = 0; iMC < vMCParticles.size(); iMC++) { + KFMCParticle& part = vMCParticles[iMC]; + part.SetMCTrackID(iMC); } - + const int NmmPDG = 7; vector mmMotherPDG(NmmPDG); //PDG for particles found by the missing mass method vector mmChargedDaughterPDG(NmmPDG); vector mmNeutralDaughterPDG(NmmPDG); vector newMotherPDG(NmmPDG); vector newNeutralPDG(NmmPDG); - - mmMotherPDG[ 0] = 3112; mmChargedDaughterPDG[ 0] = 211; mmNeutralDaughterPDG[ 0] = 2112; - mmMotherPDG[ 1] = 3222; mmChargedDaughterPDG[ 1] = 211; mmNeutralDaughterPDG[ 1] = 2112; - mmMotherPDG[ 2] = 3312; mmChargedDaughterPDG[ 2] = 211; mmNeutralDaughterPDG[ 2] = 3122; - mmMotherPDG[ 3] = 3334; mmChargedDaughterPDG[ 3] = 211; mmNeutralDaughterPDG[ 3] = 3322; - mmMotherPDG[ 4] = 321; mmChargedDaughterPDG[ 4] = 211; mmNeutralDaughterPDG[ 4] = 111; - mmMotherPDG[ 5] = 3334; mmChargedDaughterPDG[ 5] = 321; mmNeutralDaughterPDG[ 5] = 3122; - mmMotherPDG[ 6] = 3222; mmChargedDaughterPDG[ 6] = 2212; mmNeutralDaughterPDG[ 6] = 111; - - newMotherPDG[ 0] = 7003112; newNeutralPDG[ 0] = 7002112; - newMotherPDG[ 1] = 7003222; newNeutralPDG[ 1] = 8002112; - newMotherPDG[ 2] = 7003312; newNeutralPDG[ 2] = 7003122; - newMotherPDG[ 3] = 7003334; newNeutralPDG[ 3] = 7003322; - newMotherPDG[ 4] = 9000321; newNeutralPDG[ 4] = 9000111; - newMotherPDG[ 5] = 8003334; newNeutralPDG[ 5] = 8003122; - newMotherPDG[ 6] = 8003222; newNeutralPDG[ 6] = 8000111; - + + mmMotherPDG[0] = 3112; + mmChargedDaughterPDG[0] = 211; + mmNeutralDaughterPDG[0] = 2112; + mmMotherPDG[1] = 3222; + mmChargedDaughterPDG[1] = 211; + mmNeutralDaughterPDG[1] = 2112; + mmMotherPDG[2] = 3312; + mmChargedDaughterPDG[2] = 211; + mmNeutralDaughterPDG[2] = 3122; + mmMotherPDG[3] = 3334; + mmChargedDaughterPDG[3] = 211; + mmNeutralDaughterPDG[3] = 3322; + mmMotherPDG[4] = 321; + mmChargedDaughterPDG[4] = 211; + mmNeutralDaughterPDG[4] = 111; + mmMotherPDG[5] = 3334; + mmChargedDaughterPDG[5] = 321; + mmNeutralDaughterPDG[5] = 3122; + mmMotherPDG[6] = 3222; + mmChargedDaughterPDG[6] = 2212; + mmNeutralDaughterPDG[6] = 111; + + newMotherPDG[0] = 7003112; + newNeutralPDG[0] = 7002112; + newMotherPDG[1] = 7003222; + newNeutralPDG[1] = 8002112; + newMotherPDG[2] = 7003312; + newNeutralPDG[2] = 7003122; + newMotherPDG[3] = 7003334; + newNeutralPDG[3] = 7003322; + newMotherPDG[4] = 9000321; + newNeutralPDG[4] = 9000111; + newMotherPDG[5] = 8003334; + newNeutralPDG[5] = 8003122; + newMotherPDG[6] = 8003222; + newNeutralPDG[6] = 8000111; + //add neutrinos, if they are not saved - for(int iMC=0; iMC -1) - { + if (muonIndex > -1) { int newPDG = 0; - if(vMCParticles[iMC].GetPDG() >0) + if (vMCParticles[iMC].GetPDG() > 0) newPDG = vMCParticles[iMC].GetPDG() + 7000000; else newPDG = vMCParticles[iMC].GetPDG() - 7000000; @@ -225,13 +234,16 @@ void KFTopoPerformance::GetMCParticles() const KFMCTrack& daughterTrack = vMCTracks[daughterPart.GetMCTrackID()]; int neutrinoPDG = 7000014; - if(vMCParticles[iMC].GetPDG() == -211) neutrinoPDG = -7000014; - if(vMCParticles[iMC].GetPDG() == 321) neutrinoPDG = 8000014; - if(vMCParticles[iMC].GetPDG() == -321) neutrinoPDG = -8000014; - - int neutrinoIndex = vMCTracks.size()+1; + if (vMCParticles[iMC].GetPDG() == -211) + neutrinoPDG = -7000014; + if (vMCParticles[iMC].GetPDG() == 321) + neutrinoPDG = 8000014; + if (vMCParticles[iMC].GetPDG() == -321) + neutrinoPDG = -8000014; + + int neutrinoIndex = vMCTracks.size() + 1; vMCParticles[iMC].AddDaughter(neutrinoIndex); - + fNeutralIndex[iMC] = neutrinoIndex; KFMCParticle neutrinoPart; @@ -253,7 +265,7 @@ void KFTopoPerformance::GetMCParticles() vMCTracks.push_back(motherTrack); vMCParticles.push_back(motherPart); fNeutralIndex.push_back(-1); - + neutrinoPart.SetMCTrackID(neutrinoIndex); neutrinoPart.SetMotherId(newMotherIndex); neutrinoPart.SetPDG(neutrinoPDG); @@ -262,54 +274,48 @@ void KFTopoPerformance::GetMCParticles() vMCTracks.push_back(neutrinoTrack); vMCParticles.push_back(neutrinoPart); fNeutralIndex.push_back(-1); - + vMCParticles[iMC].SetAsReconstructable(4); vMCParticles[muonIndex].SetAsReconstructable(4); } } // add sigmas, omegas, xis ... - if( vMCParticles[iMC].NDaughters() >= 2 && - (abs(vMCParticles[iMC].GetPDG()) == 3112 || - abs(vMCParticles[iMC].GetPDG()) == 3222 || - abs(vMCParticles[iMC].GetPDG()) == 3312 || - abs(vMCParticles[iMC].GetPDG()) == 3334 || - abs(vMCParticles[iMC].GetPDG()) == 321) ) - { + if (vMCParticles[iMC].NDaughters() >= 2 && + (abs(vMCParticles[iMC].GetPDG()) == 3112 || + abs(vMCParticles[iMC].GetPDG()) == 3222 || + abs(vMCParticles[iMC].GetPDG()) == 3312 || + abs(vMCParticles[iMC].GetPDG()) == 3334 || + abs(vMCParticles[iMC].GetPDG()) == 321)) { int neutralDaughterId = -1, chargedDaughterId = -1; int newPDG = 0; int neutralPDG = 0; - for(int iPDG=0; iPDG xDaughter; vector yDaughter; vector zDaughter; - vector< vector > nDaughtersAtPoint; - - for(int iMCDaughter=0; iMCDaughter> nDaughtersAtPoint; + + for (int iMCDaughter = 0; iMCDaughter < vMCParticles[iMC].NDaughters(); iMCDaughter++) { bool isNewDecayPoint = 1; - - for(unsigned int iPoint=0; iPoint newDaughters; - for(unsigned int iD=0; iD isDaughterFound(nDaughters); vector isDaughterUsed(nDaughters); - for(int iDMC=0; iDMC= 15) - part.SetAsReconstructable(1); -// if(mc.IsReconstructable()) -// part.SetAsReconstructable2(); + if (mcTrack.NMCPoints() >= 15) + part.SetAsReconstructable(1); + // if(mc.IsReconstructable()) + // part.SetAsReconstructable2(); - if(mcTrack.IsReconstructed()) + if (mcTrack.IsReconstructed()) part.SetAsReconstructable(2); } - // mother particles - else - { + // mother particles + else { //Check if the particle is V0 - - if(part.NDaughters() >= 2) - { - bool isPositiveDaughter[5] = {0,0,0,0,0}; - bool isNegativeDaughter[5] = {0,0,0,0,0}; - - int nRecoDaughters[5] = {0,0,0,0,0}; - - for(int iD=0; iD < part.NDaughters(); iD++) - { - KFMCParticle &daughter = vMCParticles[part.GetDaughterIds()[iD]]; + + if (part.NDaughters() >= 2) { + bool isPositiveDaughter[5] = {0, 0, 0, 0, 0}; + bool isNegativeDaughter[5] = {0, 0, 0, 0, 0}; + + int nRecoDaughters[5] = {0, 0, 0, 0, 0}; + + for (int iD = 0; iD < part.NDaughters(); iD++) { + KFMCParticle& daughter = vMCParticles[part.GetDaughterIds()[iD]]; CheckMCParticleIsReconstructable(daughter); - + TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(daughter.GetPDG()); - Double_t charge = (particlePDG) ? particlePDG->Charge()/3 : 0; - - for(int iEff=0; iEff<5; iEff++) - { - if(charge > 0) + Double_t charge = (particlePDG) ? particlePDG->Charge() / 3 : 0; + + for (int iEff = 0; iEff < 5; iEff++) { + if (charge > 0) isPositiveDaughter[iEff] |= daughter.IsReconstructable(iEff); else isNegativeDaughter[iEff] |= daughter.IsReconstructable(iEff); - - if(daughter.IsReconstructable(iEff)) + + if (daughter.IsReconstructable(iEff)) nRecoDaughters[iEff]++; } } - -// for(int iEff=0; iEff<3; iEff++) -// if(isPositiveDaughter[iEff] && isNegativeDaughter[iEff]) -// part.SetAsReconstructableV0(iEff); - for(int iEff=0; iEff<3; iEff++) - if(nRecoDaughters[iEff] > 1) + + // for(int iEff=0; iEff<3; iEff++) + // if(isPositiveDaughter[iEff] && isNegativeDaughter[iEff]) + // part.SetAsReconstructableV0(iEff); + for (int iEff = 0; iEff < 3; iEff++) + if (nRecoDaughters[iEff] > 1) part.SetAsReconstructableV0(iEff); } - - for(int iPart=0; iPart pdg(nDaughters); - for(unsigned int iD=0; iD isDaughterFound(nDaughters); - for(unsigned int iDMC=0; iDMC& dIds = part.GetDaughterIds(); const unsigned int nD = dIds.size(); - if(nD == 0) return; //TODO optimize for all species - + if (nD == 0) + return; //TODO optimize for all species + bool reco1 = 1; bool reco2 = 1; bool reco3 = 1; bool reco4 = 1; bool reco5 = 1; - - for ( unsigned int iD = 0; iD < nD && (reco1 || reco2 || reco3 || reco4 || reco5); iD++ ) { - KFMCParticle &dp = vMCParticles[dIds[iD]]; + + for (unsigned int iD = 0; iD < nD && (reco1 || reco2 || reco3 || reco4 || reco5); iD++) { + KFMCParticle& dp = vMCParticles[dIds[iD]]; CheckMCParticleIsReconstructable(dp); reco1 &= dp.IsReconstructable(0); reco2 &= dp.IsReconstructable(1); @@ -614,44 +601,53 @@ void KFTopoPerformance::CheckMCParticleIsReconstructable(KFMCParticle &part) reco4 &= dp.IsReconstructable(3); reco5 &= dp.IsReconstructable(4); } - - if (reco1) part.SetAsReconstructable(0); - if (reco2) part.SetAsReconstructable(1); - if (reco3) part.SetAsReconstructable(2); + + if (reco1) + part.SetAsReconstructable(0); + if (reco2) + part.SetAsReconstructable(1); + if (reco3) + part.SetAsReconstructable(2); int iParticle = fParteff.GetParticleIndex(part.GetPDG()); - if (reco4 && iParticle>=KFPartEfficiencies::fFirstMissingMassParticleIndex && - iParticle<=KFPartEfficiencies::fLastMissingMassParticleIndex ) part.SetAsReconstructable(3); - if (reco5 && iParticle>=KFPartEfficiencies::fFirstMissingMassParticleIndex && - iParticle<=KFPartEfficiencies::fLastMissingMassParticleIndex ) part.SetAsReconstructable(4); + if (reco4 && iParticle >= KFPartEfficiencies::fFirstMissingMassParticleIndex && + iParticle <= KFPartEfficiencies::fLastMissingMassParticleIndex) + part.SetAsReconstructable(3); + if (reco5 && iParticle >= KFPartEfficiencies::fFirstMissingMassParticleIndex && + iParticle <= KFPartEfficiencies::fLastMissingMassParticleIndex) + part.SetAsReconstructable(4); } } - void KFTopoPerformance::FindReconstructableMCVertices() { /** Checks which Monte Carlo primary vertices can be reconstructed. */ const unsigned int nMCVertices = fPrimVertices.size(); - for ( unsigned int iV = 0; iV < nMCVertices; iV++ ) { - KFMCVertex &vert = fPrimVertices[iV]; - + for (unsigned int iV = 0; iV < nMCVertices; iV++) { + KFMCVertex& vert = fPrimVertices[iV]; + int nReconstructableDaughters = 0; int nMCReconstructableDaughters = 0; - for(int iP=0; iP= 2) vert.SetReconstructable(); - else vert.SetUnReconstructable(); - - if(nMCReconstructableDaughters >= 2) vert.SetMCReconstructable(); - else vert.SetMCUnReconstructable(); + + if (nReconstructableDaughters >= 2) + vert.SetReconstructable(); + else + vert.SetUnReconstructable(); + + if (nMCReconstructableDaughters >= 2) + vert.SetMCReconstructable(); + else + vert.SetMCUnReconstructable(); } } @@ -661,140 +657,139 @@ void KFTopoPerformance::MatchParticles() MCtoRParticleId.clear(); RtoMCParticleId.clear(); MCtoRParticleId.resize(vMCParticles.size()); - RtoMCParticleId.resize(fTopoReconstructor->GetParticles().size() ); + RtoMCParticleId.resize(fTopoReconstructor->GetParticles().size()); // match tracks ( particles which are direct copies of tracks ) - for( unsigned int iRP = 0; iRP < fTopoReconstructor->GetParticles().size(); iRP++ ) - { - const KFParticle &rPart = fTopoReconstructor->GetParticles()[iRP]; + for (unsigned int iRP = 0; iRP < fTopoReconstructor->GetParticles().size(); iRP++) { + const KFParticle& rPart = fTopoReconstructor->GetParticles()[iRP]; - if (rPart.NDaughters() != 1) continue; + if (rPart.NDaughters() != 1) + continue; const int rTrackId = rPart.DaughterIds()[0]; const int mcTrackId = fTrackMatch[rTrackId]; - if(mcTrackId < 0) continue; + if (mcTrackId < 0) + continue; - KFMCParticle &mPart = vMCParticles[mcTrackId]; - if( mPart.GetPDG() == rPart.GetPDG() ) - { + KFMCParticle& mPart = vMCParticles[mcTrackId]; + if (mPart.GetPDG() == rPart.GetPDG()) { MCtoRParticleId[mcTrackId].ids.push_back(iRP); RtoMCParticleId[iRP].ids.push_back(mcTrackId); - } - else { + } else { MCtoRParticleId[mcTrackId].idsMI.push_back(iRP); RtoMCParticleId[iRP].idsMI.push_back(mcTrackId); } } // match created mother particles - for( unsigned int iRP = 0; iRP < fTopoReconstructor->GetParticles().size(); iRP++ ) { - const KFParticle &rPart = fTopoReconstructor->GetParticles()[iRP]; + for (unsigned int iRP = 0; iRP < fTopoReconstructor->GetParticles().size(); iRP++) { + const KFParticle& rPart = fTopoReconstructor->GetParticles()[iRP]; const unsigned int NRDaughters = rPart.NDaughters(); - - if (NRDaughters < 2) continue; - bool isMissingMass = ((abs(rPart.GetPDG()) == 7000211)||(abs(rPart.GetPDG()) == 7000321)||(abs(rPart.GetPDG()) == 7003112) || (abs(rPart.GetPDG()) == 7003222)|| (abs(rPart.GetPDG()) == 7003312)|| (abs(rPart.GetPDG()) == 7003334)|| (abs(rPart.GetPDG()) == 9000321)|| (abs(rPart.GetPDG()) == 8003334)||(abs(rPart.GetPDG()) == 8003222)); - + if (NRDaughters < 2) + continue; + + bool isMissingMass = ((abs(rPart.GetPDG()) == 7000211) || (abs(rPart.GetPDG()) == 7000321) || (abs(rPart.GetPDG()) == 7003112) || (abs(rPart.GetPDG()) == 7003222) || (abs(rPart.GetPDG()) == 7003312) || (abs(rPart.GetPDG()) == 7003334) || (abs(rPart.GetPDG()) == 9000321) || (abs(rPart.GetPDG()) == 8003334) || (abs(rPart.GetPDG()) == 8003222)); + //missing mass method - if ( (abs(rPart.GetPDG()) == 7000014 ) || (abs(rPart.GetPDG()) == 8000014 ) || (abs(rPart.GetPDG()) == 7002112 ) || - (abs(rPart.GetPDG()) == 8002112 ) || (abs(rPart.GetPDG()) == 7003122 ) || (abs(rPart.GetPDG()) == 7003322 ) || - (abs(rPart.GetPDG()) == 9000111 ) || (abs(rPart.GetPDG()) == 8003122 ) || (abs(rPart.GetPDG()) == 8000111 ) ) - { + if ((abs(rPart.GetPDG()) == 7000014) || (abs(rPart.GetPDG()) == 8000014) || (abs(rPart.GetPDG()) == 7002112) || + (abs(rPart.GetPDG()) == 8002112) || (abs(rPart.GetPDG()) == 7003122) || (abs(rPart.GetPDG()) == 7003322) || + (abs(rPart.GetPDG()) == 9000111) || (abs(rPart.GetPDG()) == 8003122) || (abs(rPart.GetPDG()) == 8000111)) { //During the reconstruction 1st daughter - mother particle, 2nd daughter - charged daughter int mcNeutralDaughterId = -1; const int recoMotherId = rPart.DaughterIds()[0]; - if ( !RtoMCParticleId[recoMotherId].IsMatched() ) continue; + if (!RtoMCParticleId[recoMotherId].IsMatched()) + continue; const int mcMotherId = RtoMCParticleId[recoMotherId].GetBestMatch(); - + const int recoChargedDaughterId = rPart.DaughterIds()[1]; - if ( !RtoMCParticleId[recoChargedDaughterId].IsMatched() ) continue; + if (!RtoMCParticleId[recoChargedDaughterId].IsMatched()) + continue; const int mcChargedDaughterId = RtoMCParticleId[recoChargedDaughterId].GetBestMatch(); const KFMCParticle& chargedDaughter = vMCParticles[mcChargedDaughterId]; - if(chargedDaughter.GetMotherId() != mcMotherId) continue; + if (chargedDaughter.GetMotherId() != mcMotherId) + continue; const KFMCParticle& mother = vMCParticles[mcMotherId]; - if(fNeutralIndex[mcMotherId] > -1) + if (fNeutralIndex[mcMotherId] > -1) mcNeutralDaughterId = fNeutralIndex[mcMotherId]; - if(mcNeutralDaughterId > -1) - { - KFMCParticle &neutralDaughter = vMCParticles[mcNeutralDaughterId]; - + if (mcNeutralDaughterId > -1) { + KFMCParticle& neutralDaughter = vMCParticles[mcNeutralDaughterId]; + int iParticle = fParteff.GetParticleIndex(rPart.GetPDG()); - - bool allCorrectDaughters = mother.GetPDG() == fParteff.partDaughterPdg[iParticle][0] && + + bool allCorrectDaughters = mother.GetPDG() == fParteff.partDaughterPdg[iParticle][0] && chargedDaughter.GetPDG() == fParteff.partDaughterPdg[iParticle][1]; - if( neutralDaughter.GetPDG() == rPart.GetPDG() && + if (neutralDaughter.GetPDG() == rPart.GetPDG() && neutralDaughter.NDaughters() == rPart.NDaughters() && allCorrectDaughters) { MCtoRParticleId[mcNeutralDaughterId].ids.push_back(iRP); RtoMCParticleId[iRP].ids.push_back(mcNeutralDaughterId); - } - else { + } else { MCtoRParticleId[mcNeutralDaughterId].idsMI.push_back(iRP); RtoMCParticleId[iRP].idsMI.push_back(mcNeutralDaughterId); } } } - - - + //normal decays - else - { + else { unsigned int iD = 0; vector mcDaughterIds; int mmId = -2; // MC id for rPart { const int rdId = rPart.DaughterIds()[iD]; - if ( !RtoMCParticleId[rdId].IsMatched() ) continue; + if (!RtoMCParticleId[rdId].IsMatched()) + continue; const int mdId = RtoMCParticleId[rdId].GetBestMatch(); mcDaughterIds.push_back(mdId); mmId = vMCParticles[mdId].GetMotherId(); } - + iD++; - for ( ; iD < NRDaughters; iD++ ) { + for (; iD < NRDaughters; iD++) { const int rdId = rPart.DaughterIds()[iD]; - if ( !RtoMCParticleId[rdId].IsMatched() ) break; + if (!RtoMCParticleId[rdId].IsMatched()) + break; const int mdId = RtoMCParticleId[rdId].GetBestMatch(); mcDaughterIds.push_back(mdId); - if(isMissingMass) - { - const KFMCParticle &neutralDaughter = vMCParticles[mdId]; - if(mmId != vMCParticles[neutralDaughter.GetMotherId()].InitialParticleId()) break; + if (isMissingMass) { + const KFMCParticle& neutralDaughter = vMCParticles[mdId]; + if (mmId != vMCParticles[neutralDaughter.GetMotherId()].InitialParticleId()) + break; mmId = neutralDaughter.GetMotherId(); } - - if( !(isMissingMass) && (vMCParticles[mdId].GetMotherId() != mmId) ) break; + + if (!(isMissingMass) && (vMCParticles[mdId].GetMotherId() != mmId)) + break; } - + int nClones = 0; sort(mcDaughterIds.begin(), mcDaughterIds.end()); - for(unsigned int ie=1; ie 0) continue; - - if ( iD == NRDaughters && mmId > -1 ) { // match is found and it is not primary vertex - KFMCParticle &mmPart = vMCParticles[mmId]; - - if( mmPart.GetPDG() == rPart.GetPDG() && - mmPart.NDaughters() == rPart.NDaughters() ) { + if (nClones > 0) + continue; + + if (iD == NRDaughters && mmId > -1) { // match is found and it is not primary vertex + KFMCParticle& mmPart = vMCParticles[mmId]; + + if (mmPart.GetPDG() == rPart.GetPDG() && + mmPart.NDaughters() == rPart.NDaughters()) { MCtoRParticleId[mmId].ids.push_back(iRP); - RtoMCParticleId[iRP].ids.push_back(mmId); - } - else { + RtoMCParticleId[iRP].ids.push_back(mmId); + } else { MCtoRParticleId[mmId].idsMI.push_back(iRP); RtoMCParticleId[iRP].idsMI.push_back(mmId); } @@ -809,100 +804,89 @@ void KFTopoPerformance::MatchPV() MCtoRPVId.clear(); RtoMCPVId.clear(); MCtoRPVId.resize(fPrimVertices.size()); - RtoMCPVId.resize(fTopoReconstructor->NPrimaryVertices() ); + RtoMCPVId.resize(fTopoReconstructor->NPrimaryVertices()); fPVPurity.clear(); fPVPurity.resize(fTopoReconstructor->NPrimaryVertices(), 0.); fNCorrectPVTracks.clear(); fNCorrectPVTracks.resize(fTopoReconstructor->NPrimaryVertices(), 0); - for(int iE = 0; iE<4; iE++) - { + for (int iE = 0; iE < 4; iE++) { fPVTracksRate[iE].clear(); - fPVTracksRate[iE].resize(fTopoReconstructor->NPrimaryVertices(),0); + fPVTracksRate[iE].resize(fTopoReconstructor->NPrimaryVertices(), 0); } - - for( unsigned int iMCPV=0; iMCPVNPrimaryVertices(); iPV++ ) { + for (int iPV = 0; iPV < fTopoReconstructor->NPrimaryVertices(); iPV++) { + + vector& tracks = fTopoReconstructor->GetPVTrackIndexArray(iPV); + + int nPVTracks = tracks.size() > 0 ? tracks.size() : -1; //tracks.size(); - vector &tracks = fTopoReconstructor->GetPVTrackIndexArray(iPV); - - int nPVTracks = tracks.size()>0 ? tracks.size() : -1;//tracks.size(); - vector nTracksFromMCPV(fPrimVertices.size() + vMCParticles.size(), 0); - vector< vector > mcIDs(fPrimVertices.size() + vMCParticles.size()); + vector> mcIDs(fPrimVertices.size() + vMCParticles.size()); int nGhostTracks = 0; int nTriggerTracks = 0; int nPileupTracks = 0; int nBGTracks = 0; - - for(int iRP=0; iRP < nPVTracks; iRP++) - { + + for (int iRP = 0; iRP < nPVTracks; iRP++) { const int rTrackId = tracks[iRP]; - if ( !RtoMCParticleId[rTrackId].IsMatched() ) - { + if (!RtoMCParticleId[rTrackId].IsMatched()) { nGhostTracks++; continue; } - + int iMCPart = RtoMCParticleId[rTrackId].GetBestMatch(); - KFMCParticle &mcPart = vMCParticles[iMCPart]; + KFMCParticle& mcPart = vMCParticles[iMCPart]; int iMCTrack = mcPart.GetMCTrackID(); - KFMCTrack &mcTrack = vMCTracks[iMCTrack]; - + KFMCTrack& mcTrack = vMCTracks[iMCTrack]; + int motherId = mcTrack.MotherId(); - if(motherId < 0) //real PV + if (motherId < 0) //real PV { - if(motherId == -1) + if (motherId == -1) nTriggerTracks++; - if(motherId < -1) + if (motherId < -1) nPileupTracks++; - + int iMCPV = fMCTrackToMCPVMatch[iMCTrack]; - if(iMCPV < 0) - { + if (iMCPV < 0) { std::cout << "Error!!! iMCPV < 0" << std::endl; continue; } - + nTracksFromMCPV[iMCPV]++; mcIDs[iMCPV].push_back(iMCTrack); - } - else // pchysics background - { - if(motherId >-1) - { + } else // pchysics background + { + if (motherId > -1) { nBGTracks++; int iMCPV = motherId + fPrimVertices.size(); - + nTracksFromMCPV[iMCPV]++; mcIDs[iMCPV].push_back(iMCTrack); } } } - - - for(unsigned int iMCPV=0; iMCPV nTracksBestMCPV ) - { + for (unsigned int iMCPV = 0; iMCPV < nTracksFromMCPV.size(); iMCPV++) { + if (nTracksFromMCPV[iMCPV] > nTracksBestMCPV) { nTracksBestMCPV = nTracksFromMCPV[iMCPV]; iBestMCPV = iMCPV; } } - if( (iBestMCPV > -1) && (iBestMCPV -1) && (iBestMCPV < int(fPrimVertices.size()))) { fNCorrectPVTracks[iPV] = nTracksFromMCPV[iBestMCPV]; - } - else + } else fNCorrectPVTracks[iPV] = 0; - - double purity = double(nTracksBestMCPV)/double(nPVTracks); + + double purity = double(nTracksBestMCPV) / double(nPVTracks); fPVPurity[iPV] = purity; -// if(purity < 0.7) continue; + // if(purity < 0.7) continue; - if(iBestMCPV < 0) continue; - - if(iBestMCPV < int(fPrimVertices.size())) - { + if (iBestMCPV < 0) + continue; + + if (iBestMCPV < int(fPrimVertices.size())) { fPrimVertices[iBestMCPV].SetReconstructed(); - + MCtoRPVId[iBestMCPV].ids.push_back(iPV); RtoMCPVId[iPV].ids.push_back(iBestMCPV); - } - else - { + } else { RtoMCPVId[iPV].idsMI.push_back(iBestMCPV); } } @@ -958,16 +936,14 @@ void KFTopoPerformance::MatchTracks() { /** Runs reading of Monte Carlo particles and vertices, their matching, calculation of efficiency. */ #ifdef KFPWITHTRACKER - for(int iTr=0; iTrGetMCData())[iTr].IsReconstructed() ) + for (int iTr = 0; iTr < vMCTracks.size(); iTr++) { + if ((AliHLTTPCCAPerformance::Instance().GetSubPerformance("Global Performance")->GetMCData())[iTr].IsReconstructed()) vMCTracks[iTr].SetReconstructed(); - } + } fTrackMatch.resize(AliHLTTPCCAPerformance::Instance().GetSubPerformance("Global Performance")->GetRecoData().size()); - for(int iTr=0; iTrGetRecoData())[iTr]; - if( matchInfo.IsGhost(PParameters::MinTrackPurity) || matchInfo.GetMCTrackId()<0 ) + if (matchInfo.IsGhost(PParameters::MinTrackPurity) || matchInfo.GetMCTrackId() < 0) fTrackMatch[iTr] = -1; else fTrackMatch[iTr] = matchInfo.GetMCTrackId(); @@ -978,7 +954,7 @@ void KFTopoPerformance::MatchTracks() FindReconstructableMCParticles(); MatchParticles(); CalculateEfficiency(); - + FindReconstructableMCVertices(); MatchPV(); CalculatePVEfficiency(); @@ -990,142 +966,139 @@ void KFTopoPerformance::CalculateEfficiency() KFPartEfficiencies partEff; // efficiencies for current event const int NRP = fTopoReconstructor->GetParticles().size(); - for ( int iP = 0; iP < NRP; ++iP ) { -// const CbmKFParticle &part = fPF->GetParticles()[iP]; - const KFParticle &part = fTopoReconstructor->GetParticles()[iP]; + for (int iP = 0; iP < NRP; ++iP) { + // const CbmKFParticle &part = fPF->GetParticles()[iP]; + const KFParticle& part = fTopoReconstructor->GetParticles()[iP]; const int pdg = part.GetPDG(); const bool isBG = RtoMCParticleId[iP].idsMI.size() != 0; const bool isGhost = !RtoMCParticleId[iP].IsMatched(); - for(int iPart=0; iPart isReco; vector nClones; vector iParticle; iParticle.push_back(fParteff.GetParticleIndex(pdg)); - vector< vector > isReconstructable; + vector> isReconstructable; vector isRecPart; - const std::map& decays = fTopoReconstructor->GetKFParticleFinder()->GetReconstructionList(); - if(!(decays.empty()) && (iParticle[0] < fParteff.fFirstStableParticleIndex || iParticle[0] > fParteff.fLastStableParticleIndex)) - if(decays.find(pdg) == decays.end()) continue; - - if( fParteff.GetParticleIndex(pdg)>=KFPartEfficiencies::fFirstMissingMassParticleIndex && - fParteff.GetParticleIndex(pdg)<=KFPartEfficiencies::fLastMissingMassParticleIndex ) - { + const std::map& decays = fTopoReconstructor->GetKFParticleFinder()->GetReconstructionList(); + if (!(decays.empty()) && (iParticle[0] < fParteff.fFirstStableParticleIndex || iParticle[0] > fParteff.fLastStableParticleIndex)) + if (decays.find(pdg) == decays.end()) + continue; + + if (fParteff.GetParticleIndex(pdg) >= KFPartEfficiencies::fFirstMissingMassParticleIndex && + fParteff.GetParticleIndex(pdg) <= KFPartEfficiencies::fLastMissingMassParticleIndex) { isRecPart.push_back(part.IsReconstructable(4)); isRecPart.push_back(part.IsReconstructable(1)); isRecPart.push_back(part.IsReconstructable(3)); - } - else - for(int iEff = 0; iEff < 3; iEff++) + } else + for (int iEff = 0; iEff < 3; iEff++) isRecPart.push_back(part.IsReconstructable(iEff)); - + isReconstructable.push_back(isRecPart); - isReco.push_back( MCtoRParticleId[iP].ids.size() != 0 ); - nClones.push_back( MCtoRParticleId[iP].ids.size() - 1 ); - - if(decays.empty() && (part.IsReconstructableV0(0) || part.IsReconstructableV0(1) || part.IsReconstructableV0(2)) ) - { + isReco.push_back(MCtoRParticleId[iP].ids.size() != 0); + nClones.push_back(MCtoRParticleId[iP].ids.size() - 1); + + if (decays.empty() && (part.IsReconstructableV0(0) || part.IsReconstructableV0(1) || part.IsReconstructableV0(2))) { iParticle.push_back(fParteff.nParticles - 1); vector isRecV0; - for(int iEff = 0; iEff < 3; iEff++) + for (int iEff = 0; iEff < 3; iEff++) isRecV0.push_back(part.IsReconstructableV0(iEff)); isReconstructable.push_back(isRecV0); - isReco.push_back( (MCtoRParticleId[iP].ids.size() != 0) || (MCtoRParticleId[iP].idsMI.size() != 0) ); - + isReco.push_back((MCtoRParticleId[iP].ids.size() != 0) || (MCtoRParticleId[iP].idsMI.size() != 0)); + int nClonesV0 = MCtoRParticleId[iP].ids.size() + MCtoRParticleId[iP].idsMI.size() - 1; - nClones.push_back( nClonesV0 ); + nClones.push_back(nClonesV0); } { - for(unsigned int iPType=0; iPType 0) - { + + if (part.NDaughters() > 0) { int mcDaughterId = part.GetDaughterIds()[0]; - KFMCTrack &mcDaughter = vMCTracks[mcDaughterId]; - R = sqrt(mcDaughter.X()*mcDaughter.X() + mcDaughter.Y()*mcDaughter.Y()); - L = sqrt(mcDaughter.X()*mcDaughter.X() + mcDaughter.Y()*mcDaughter.Y()); + KFMCTrack& mcDaughter = vMCTracks[mcDaughterId]; + R = sqrt(mcDaughter.X() * mcDaughter.X() + mcDaughter.Y() * mcDaughter.Y()); + L = sqrt(mcDaughter.X() * mcDaughter.X() + mcDaughter.Y() * mcDaughter.Y()); Z = mcDaughter.Z(); - - if(mcTrack.MotherId() < 0) - { + + if (mcTrack.MotherId() < 0) { KFParticle motherKFParticle; - float decayPoint[3] = { mcDaughter.X(), mcDaughter.Y(), mcDaughter.Z() }; - for(int iP=0; iP<6; iP++) + float decayPoint[3] = {mcDaughter.X(), mcDaughter.Y(), mcDaughter.Z()}; + for (int iP = 0; iP < 6; iP++) motherKFParticle.Parameter(iP) = mcTrack.Par()[iP]; - + float dsdr[6]; double s = motherKFParticle.GetDStoPoint(decayPoint, dsdr); - int jParticlePDG = fParteff.GetParticleIndex(mcTrack.PDG()); - Double_t massMC = (jParticlePDG>=0) ? fParteff.partMass[jParticlePDG] :0.13957; - - cT = s*massMC; - decayLength = s*mcTrack.P(); + int jParticlePDG = fParteff.GetParticleIndex(mcTrack.PDG()); + Double_t massMC = (jParticlePDG >= 0) ? fParteff.partMass[jParticlePDG] : 0.13957; + + cT = s * massMC; + decayLength = s * mcTrack.P(); } } - if(fStoreMCHistograms) - { - hPartEfficiency[iPart][iEff][0]->Fill( mcTrack.P(), isReco[iPType] ); - hPartEfficiency[iPart][iEff][1]->Fill( mcTrack.Pt(), isReco[iPType] ); - hPartEfficiency[iPart][iEff][2]->Fill( Y, isReco[iPType] ); - hPartEfficiency[iPart][iEff][3]->Fill( Z, isReco[iPType] ); - if(cT > -1.e10) hPartEfficiency[iPart][iEff][4]->Fill( cT, isReco[iPType] ); - if(decayLength > -1.e10) hPartEfficiency[iPart][iEff][5]->Fill( decayLength, isReco[iPType] ); - hPartEfficiency[iPart][iEff][3]->Fill( Z, isReco[iPType] ); - hPartEfficiency[iPart][iEff][6]->Fill( L, isReco[iPType] ); - hPartEfficiency[iPart][iEff][7]->Fill( R, isReco[iPType] ); - hPartEfficiency[iPart][iEff][8]->Fill( Mt_mc, isReco[iPType] ); - - hPartEfficiency2D[iPart][iEff][0]->Fill( Y, mcTrack.Pt(), isReco[iPType] ); - hPartEfficiency2D[iPart][iEff][1]->Fill( Y, Mt_mc, isReco[iPType] ); + if (fStoreMCHistograms) { + hPartEfficiency[iPart][iEff][0]->Fill(mcTrack.P(), isReco[iPType]); + hPartEfficiency[iPart][iEff][1]->Fill(mcTrack.Pt(), isReco[iPType]); + hPartEfficiency[iPart][iEff][2]->Fill(Y, isReco[iPType]); + hPartEfficiency[iPart][iEff][3]->Fill(Z, isReco[iPType]); + if (cT > -1.e10) + hPartEfficiency[iPart][iEff][4]->Fill(cT, isReco[iPType]); + if (decayLength > -1.e10) + hPartEfficiency[iPart][iEff][5]->Fill(decayLength, isReco[iPType]); + hPartEfficiency[iPart][iEff][3]->Fill(Z, isReco[iPType]); + hPartEfficiency[iPart][iEff][6]->Fill(L, isReco[iPType]); + hPartEfficiency[iPart][iEff][7]->Fill(R, isReco[iPType]); + hPartEfficiency[iPart][iEff][8]->Fill(Mt_mc, isReco[iPType]); + + hPartEfficiency2D[iPart][iEff][0]->Fill(Y, mcTrack.Pt(), isReco[iPType]); + hPartEfficiency2D[iPart][iEff][1]->Fill(Y, Mt_mc, isReco[iPType]); } } } @@ -1139,12 +1112,12 @@ void KFTopoPerformance::CalculateEfficiency() partEff.CalcEff(); fParteff.CalcEff(); - if(fNEvents%fPrintEffFrequency == 0) - { + if (fNEvents % fPrintEffFrequency == 0) { std::cout << " ---- KF Particle finder --- " << std::endl; - std::cout << "ACCUMULATED STAT : " << fNEvents << " EVENTS " << std::endl << std::endl; + std::cout << "ACCUMULATED STAT : " << fNEvents << " EVENTS " << std::endl + << std::endl; fParteff.PrintEff(); - std::cout<GetParticles().size(); iRP++ ) { -// CbmKFParticle &rPart = fTopoReconstructor->GetParticles()[iRP]; - const KFParticle &rPart = fTopoReconstructor->GetParticles()[iRP]; + for (unsigned int iRP = 0; iRP < fTopoReconstructor->GetParticles().size(); iRP++) { + // CbmKFParticle &rPart = fTopoReconstructor->GetParticles()[iRP]; + const KFParticle& rPart = fTopoReconstructor->GetParticles()[iRP]; + + if (rPart.NDaughters() != 1) + continue; - if (rPart.NDaughters() != 1) continue; - nTracks++; } - + const int NRecoPV = fTopoReconstructor->NPrimaryVertices(); - for ( int iP = 0; iP < NRecoPV; ++iP ) { - + for (int iP = 0; iP < NRecoPV; ++iP) { + const bool isBG = RtoMCPVId[iP].idsMI.size() != 0; const bool isGhost = !RtoMCPVId[iP].IsMatched(); @@ -1175,86 +1149,76 @@ void KFTopoPerformance::CalculatePVEfficiency() } const int NMCPV = fPrimVertices.size(); - for ( int iV = 0; iV < NMCPV; ++iV ) { - const KFMCVertex &pvMC = fPrimVertices[iV]; - if ( pvMC.IsReconstructable() ) - { + for (int iV = 0; iV < NMCPV; ++iV) { + const KFMCVertex& pvMC = fPrimVertices[iV]; + if (pvMC.IsReconstructable()) { const bool isReco = pvMC.IsReconstructed(); const int nClones = MCtoRPVId[iV].ids.size() - 1; - pvEff.Inc(isReco, nClones, "PV"); - if ( pvMC.IsTriggerPV() ) - { + if (pvMC.IsTriggerPV()) { pvEff.Inc(isReco, nClones, "PVtrigger"); - hPVefficiency[0][0]->Fill( pvMC.NDaughterTracks(), isReco ); - hPVefficiency[0][1]->Fill( NMCPV, isReco ); - hPVefficiency[0][2]->Fill( vMCTracks.size(), isReco ); - hPVefficiency[0][3]->Fill( pvMC.NReconstructedDaughterTracks(), isReco ); - hPVefficiency[0][4]->Fill( NRecoPV, isReco ); - hPVefficiency[0][5]->Fill( nTracks, isReco ); - } - else - { + hPVefficiency[0][0]->Fill(pvMC.NDaughterTracks(), isReco); + hPVefficiency[0][1]->Fill(NMCPV, isReco); + hPVefficiency[0][2]->Fill(vMCTracks.size(), isReco); + hPVefficiency[0][3]->Fill(pvMC.NReconstructedDaughterTracks(), isReco); + hPVefficiency[0][4]->Fill(NRecoPV, isReco); + hPVefficiency[0][5]->Fill(nTracks, isReco); + } else { pvEff.Inc(isReco, nClones, "PVpileup"); - hPVefficiency[1][0]->Fill( pvMC.NDaughterTracks(), isReco ); - hPVefficiency[1][1]->Fill( NMCPV, isReco ); - hPVefficiency[1][2]->Fill( vMCTracks.size(), isReco ); - hPVefficiency[1][3]->Fill( pvMC.NReconstructedDaughterTracks(), isReco ); - hPVefficiency[1][4]->Fill( NRecoPV, isReco ); - hPVefficiency[1][5]->Fill( nTracks, isReco ); + hPVefficiency[1][0]->Fill(pvMC.NDaughterTracks(), isReco); + hPVefficiency[1][1]->Fill(NMCPV, isReco); + hPVefficiency[1][2]->Fill(vMCTracks.size(), isReco); + hPVefficiency[1][3]->Fill(pvMC.NReconstructedDaughterTracks(), isReco); + hPVefficiency[1][4]->Fill(NRecoPV, isReco); + hPVefficiency[1][5]->Fill(nTracks, isReco); } } - if ( pvMC.IsMCReconstructable() ) - { + if (pvMC.IsMCReconstructable()) { const bool isReco = pvMC.IsReconstructed(); const int nClones = MCtoRPVId[iV].ids.size() - 1; - pvEffMCReconstructable.Inc(isReco, nClones, "PV"); - if ( pvMC.IsTriggerPV() ) - { + if (pvMC.IsTriggerPV()) { pvEffMCReconstructable.Inc(isReco, nClones, "PVtrigger"); - hPVefficiency[2][0]->Fill( pvMC.NDaughterTracks(), isReco ); - hPVefficiency[2][1]->Fill( NMCPV, isReco ); - hPVefficiency[2][2]->Fill( vMCTracks.size(), isReco ); - hPVefficiency[2][3]->Fill( pvMC.NReconstructedDaughterTracks(), isReco ); - hPVefficiency[2][4]->Fill( NRecoPV, isReco ); - hPVefficiency[2][5]->Fill( nTracks, isReco ); - } - else - { + hPVefficiency[2][0]->Fill(pvMC.NDaughterTracks(), isReco); + hPVefficiency[2][1]->Fill(NMCPV, isReco); + hPVefficiency[2][2]->Fill(vMCTracks.size(), isReco); + hPVefficiency[2][3]->Fill(pvMC.NReconstructedDaughterTracks(), isReco); + hPVefficiency[2][4]->Fill(NRecoPV, isReco); + hPVefficiency[2][5]->Fill(nTracks, isReco); + } else { pvEffMCReconstructable.Inc(isReco, nClones, "PVpileup"); - hPVefficiency[3][0]->Fill( pvMC.NDaughterTracks(), isReco ); - hPVefficiency[3][1]->Fill( NMCPV, isReco ); - hPVefficiency[3][2]->Fill( vMCTracks.size(), isReco ); - hPVefficiency[3][3]->Fill( pvMC.NReconstructedDaughterTracks(), isReco ); - hPVefficiency[3][4]->Fill( NRecoPV, isReco ); - hPVefficiency[3][5]->Fill( nTracks, isReco ); + hPVefficiency[3][0]->Fill(pvMC.NDaughterTracks(), isReco); + hPVefficiency[3][1]->Fill(NMCPV, isReco); + hPVefficiency[3][2]->Fill(vMCTracks.size(), isReco); + hPVefficiency[3][3]->Fill(pvMC.NReconstructedDaughterTracks(), isReco); + hPVefficiency[3][4]->Fill(NRecoPV, isReco); + hPVefficiency[3][5]->Fill(nTracks, isReco); } } } fPVeff += pvEff; - + pvEff.CalcEff(); fPVeff.CalcEff(); - + fPVeffMCReconstructable += pvEffMCReconstructable; pvEffMCReconstructable.CalcEff(); fPVeffMCReconstructable.CalcEff(); - if(fNEvents%fPrintEffFrequency == 0) - { + if (fNEvents % fPrintEffFrequency == 0) { std::cout << " ---- KF PV finder --- " << std::endl; - std::cout << "ACCUMULATED STAT : " << fNEvents << " EVENTS " << std::endl << std::endl; + std::cout << "ACCUMULATED STAT : " << fNEvents << " EVENTS " << std::endl + << std::endl; std::cout << "PV with at least 2 reconstructed tracks is reconstructable:" << std::endl; fPVeff.PrintEff(); std::cout << std::endl; std::cout << "PV with at least 2 MC tracks with 15 MC points is reconstructable:" << std::endl; fPVeffMCReconstructable.PrintEff(); - std::cout<* multiplicities) { /** Fills provided histograms with the parameters of the given particle. */ - - const std::map& decays = fTopoReconstructor->GetKFParticleFinder()->GetReconstructionList(); - if(!(decays.empty()) && (iParticle < fParteff.fFirstStableParticleIndex || iParticle > fParteff.fLastStableParticleIndex)) - if(decays.find(TempPart.GetPDG()) == decays.end()) return; - + + const std::map& decays = fTopoReconstructor->GetKFParticleFinder()->GetReconstructionList(); + if (!(decays.empty()) && (iParticle < fParteff.fFirstStableParticleIndex || iParticle > fParteff.fLastStableParticleIndex)) + if (decays.find(TempPart.GetPDG()) == decays.end()) + return; + float M, M_t, ErrM; float dL, ErrdL; // decay length float cT, ErrcT; // c*tau @@ -1284,329 +1249,322 @@ void KFTopoPerformance::FillParticleParameters(KFParticle& TempPart, float Rapidity; float Theta; float Phi; - float X,Y,Z,R; + float X, Y, Z, R; float QtAlpha[2]; - - TempPart.GetMass(M,ErrM); - TempPart.GetMomentum(P,ErrP); + + TempPart.GetMass(M, ErrM); + TempPart.GetMomentum(P, ErrP); Pt = TempPart.GetPt(); Rapidity = TempPart.GetRapidity(); - + KFParticle TempPartTopo = TempPart; TempPartTopo.SetProductionVertex(fTopoReconstructor->GetPrimVertex(0)); - TempPartTopo.GetDecayLength(dL,ErrdL); - TempPartTopo.GetLifeTime(cT,ErrcT); - + TempPartTopo.GetDecayLength(dL, ErrdL); + TempPartTopo.GetLifeTime(cT, ErrcT); + float chi2 = TempPart.GetChi2(); Int_t ndf = TempPart.GetNDF(); - float prob = TMath::Prob(chi2, ndf);//(TDHelper::Chi2IProbability( ndf, chi2 )); + float prob = TMath::Prob(chi2, ndf); //(TDHelper::Chi2IProbability( ndf, chi2 )); Theta = TempPart.GetTheta(); Phi = TempPart.GetPhi(); X = TempPart.GetX(); Y = TempPart.GetY(); Z = TempPart.GetZ(); #ifdef CBM - if(Z>=1. && iParticle>=54 && iParticle<=64) return; + if (Z >= 1. && iParticle >= 54 && iParticle <= 64) + return; #endif - R = sqrt(X*X+Y*Y); - M_t = sqrt(Pt*Pt+fParteff.GetMass(iParticle)*fParteff.GetMass(iParticle))-fParteff.GetMass(iParticle); - + R = sqrt(X * X + Y * Y); + M_t = sqrt(Pt * Pt + fParteff.GetMass(iParticle) * fParteff.GetMass(iParticle)) - fParteff.GetMass(iParticle); + KFParticleSIMD tempSIMDPart(TempPart); - float_v l,dl; + float_v l, dl; KFParticleSIMD pv(fTopoReconstructor->GetPrimVertex(iPV)); tempSIMDPart.GetDistanceToVertexLine(pv, l, dl); #ifdef __ROOT__ - if( (l[0] > 0.2f || Pt < 0.f) && (abs( TempPart.GetPDG() ) == 4122 || - abs( TempPart.GetPDG() ) == 104122 || - abs( TempPart.GetPDG() ) == 204122 || - abs( TempPart.GetPDG() ) == 304122 || - abs( TempPart.GetPDG() ) == 404122 || - abs( TempPart.GetPDG() ) == 504122 ) ) return; - if( (l[0] > 0.2f || Pt < 0.f) && (abs( TempPart.GetPDG() ) == 421 || - abs( TempPart.GetPDG() ) == 420 || - abs( TempPart.GetPDG() ) == 425 || - abs( TempPart.GetPDG() ) == 426 || - abs( TempPart.GetPDG() ) == 427 || - abs( TempPart.GetPDG() ) == 429) ) return; - if( (l[0] > 0.4f || Pt < 0.f) && (abs( TempPart.GetPDG() ) == 411 || - abs( TempPart.GetPDG() ) == 100411 || - abs( TempPart.GetPDG() ) == 200411 || - abs( TempPart.GetPDG() ) == 300411) ) return; - if( (l[0] > 0.2f || Pt < 0.f) && (abs( TempPart.GetPDG() ) == 431 || - abs( TempPart.GetPDG() ) == 100431 || - abs( TempPart.GetPDG() ) == 200431 || - abs( TempPart.GetPDG() ) == 300431 || - abs( TempPart.GetPDG() ) == 400431) ) return; - -// if(Pt < 2. && (abs( TempPart.GetPDG() ) == 443 || -// abs( TempPart.GetPDG() ) == 100443 || -// abs( TempPart.GetPDG() ) == 200443 || -// abs( TempPart.GetPDG() ) == 300443 || -// abs( TempPart.GetPDG() ) == 400443 || -// abs( TempPart.GetPDG() ) == 500443) ) return; - - if(Pt < 0.5f && (abs( TempPart.GetPDG() ) == 3000 || - abs( TempPart.GetPDG() ) == 3001) ) return; + if ((l[0] > 0.2f || Pt < 0.f) && (abs(TempPart.GetPDG()) == 4122 || + abs(TempPart.GetPDG()) == 104122 || + abs(TempPart.GetPDG()) == 204122 || + abs(TempPart.GetPDG()) == 304122 || + abs(TempPart.GetPDG()) == 404122 || + abs(TempPart.GetPDG()) == 504122)) + return; + if ((l[0] > 0.2f || Pt < 0.f) && (abs(TempPart.GetPDG()) == 421 || + abs(TempPart.GetPDG()) == 420 || + abs(TempPart.GetPDG()) == 425 || + abs(TempPart.GetPDG()) == 426 || + abs(TempPart.GetPDG()) == 427 || + abs(TempPart.GetPDG()) == 429)) + return; + if ((l[0] > 0.4f || Pt < 0.f) && (abs(TempPart.GetPDG()) == 411 || + abs(TempPart.GetPDG()) == 100411 || + abs(TempPart.GetPDG()) == 200411 || + abs(TempPart.GetPDG()) == 300411)) + return; + if ((l[0] > 0.2f || Pt < 0.f) && (abs(TempPart.GetPDG()) == 431 || + abs(TempPart.GetPDG()) == 100431 || + abs(TempPart.GetPDG()) == 200431 || + abs(TempPart.GetPDG()) == 300431 || + abs(TempPart.GetPDG()) == 400431)) + return; + + // if(Pt < 2. && (abs( TempPart.GetPDG() ) == 443 || + // abs( TempPart.GetPDG() ) == 100443 || + // abs( TempPart.GetPDG() ) == 200443 || + // abs( TempPart.GetPDG() ) == 300443 || + // abs( TempPart.GetPDG() ) == 400443 || + // abs( TempPart.GetPDG() ) == 500443) ) return; + + if (Pt < 0.5f && (abs(TempPart.GetPDG()) == 3000 || + abs(TempPart.GetPDG()) == 3001)) + return; #endif - float parameters[17] = {M, P, Pt, Rapidity, dL, cT, chi2/ndf, prob, Theta, Phi, X, Y, Z, R, l[0], l[0]/dl[0], M_t }; + float parameters[17] = {M, P, Pt, Rapidity, dL, cT, chi2 / ndf, prob, Theta, Phi, X, Y, Z, R, l[0], l[0] / dl[0], M_t}; //for all particle-candidates - for(int iParam=0; iParam<17; iParam++) + for (int iParam = 0; iParam < 17; iParam++) histoParameters[0][iParticle][iParam]->Fill(parameters[iParam]); - if(multiplicities) + if (multiplicities) multiplicities[0][iParticle]++; - histoParameters2D[0][iParticle][0]->Fill(Rapidity,Pt,1); - histoParameters2D[0][iParticle][3]->Fill(Rapidity,M_t,1); - + histoParameters2D[0][iParticle][0]->Fill(Rapidity, Pt, 1); + histoParameters2D[0][iParticle][3]->Fill(Rapidity, M_t, 1); + const bool drawZR = IsCollectZRHistogram(iParticle); - if(histoParameters2D[0][iParticle][1] && drawZR) - { - histoParameters2D[0][iParticle][1]->Fill(Z,R,1); + if (histoParameters2D[0][iParticle][1] && drawZR) { + histoParameters2D[0][iParticle][1]->Fill(Z, R, 1); } - if(TempPart.NDaughters() == 2 && IsCollectArmenteros(iParticle)) - { + if (TempPart.NDaughters() == 2 && IsCollectArmenteros(iParticle)) { int index1 = TempPart.DaughterIds()[0]; int index2 = TempPart.DaughterIds()[1]; - if(index1 >= int(fTopoReconstructor->GetParticles().size()) || - index2 >= int(fTopoReconstructor->GetParticles().size()) || - index1 < 0 || index2 < 0 ) + if (index1 >= int(fTopoReconstructor->GetParticles().size()) || + index2 >= int(fTopoReconstructor->GetParticles().size()) || + index1 < 0 || index2 < 0) return; - + KFParticle posDaughter, negDaughter; - if(int(fTopoReconstructor->GetParticles()[index1].Q()) > 0) - { + if (int(fTopoReconstructor->GetParticles()[index1].Q()) > 0) { posDaughter = fTopoReconstructor->GetParticles()[index1]; negDaughter = fTopoReconstructor->GetParticles()[index2]; - } - else - { + } else { negDaughter = fTopoReconstructor->GetParticles()[index1]; posDaughter = fTopoReconstructor->GetParticles()[index2]; } float vertex[3] = {TempPart.GetX(), TempPart.GetY(), TempPart.GetZ()}; posDaughter.TransportToPoint(vertex); negDaughter.TransportToPoint(vertex); - KFParticle::GetArmenterosPodolanski(posDaughter, negDaughter, QtAlpha ); - - histoParameters2D[0][iParticle][2]->Fill(QtAlpha[1],QtAlpha[0],1); + KFParticle::GetArmenterosPodolanski(posDaughter, negDaughter, QtAlpha); + + histoParameters2D[0][iParticle][2]->Fill(QtAlpha[1], QtAlpha[0], 1); } - + //Fill 3D histograms for multi differential analysis - if( histoParameters3D && IsCollect3DHistogram(iParticle)) - { - histoParameters3D[0][iParticle][0]->Fill(Rapidity,Pt,M,1); - histoParameters3D[0][iParticle][1]->Fill(Rapidity,M_t,M,1); - if(fCentralityBin>=0) - { + if (histoParameters3D && IsCollect3DHistogram(iParticle)) { + histoParameters3D[0][iParticle][0]->Fill(Rapidity, Pt, M, 1); + histoParameters3D[0][iParticle][1]->Fill(Rapidity, M_t, M, 1); + if (fCentralityBin >= 0) { histoParameters3D[0][iParticle][2]->Fill(fCentralityBin, Pt, M, fCentralityWeight); histoParameters3D[0][iParticle][3]->Fill(fCentralityBin, Rapidity, M, fCentralityWeight); histoParameters3D[0][iParticle][4]->Fill(fCentralityBin, M_t, M, fCentralityWeight); } histoParameters3D[0][iParticle][5]->Fill(cT, Pt, M, 1); } - + //Fill histograms for the side bands analysis - if(histoDSToParticleQA && IsCollect3DHistogram(iParticle)) - { - if(fabs(fParteff.GetMass(iParticle)-M) < 3.f*fParteff.GetMassSigma(iParticle))//SignalReco + if (histoDSToParticleQA && IsCollect3DHistogram(iParticle)) { + if (fabs(fParteff.GetMass(iParticle) - M) < 3.f * fParteff.GetMassSigma(iParticle)) //SignalReco { - for(int iParam=0; iParam<17; iParam++) + for (int iParam = 0; iParam < 17; iParam++) histoParameters[4][iParticle][iParam]->Fill(parameters[iParam]); - - if(multiplicities) + + if (multiplicities) multiplicities[4][iParticle]++; - histoParameters2D[4][iParticle][0]->Fill(Rapidity,Pt,1); - histoParameters2D[4][iParticle][3]->Fill(Rapidity,M_t,1); - - if(drawZR) - { - if(histoParameters2D[4][iParticle][1]) - histoParameters2D[4][iParticle][1]->Fill(Z,R,1); - if(histoParameters2D[4][iParticle][2]) - histoParameters2D[4][iParticle][2]->Fill(QtAlpha[1],QtAlpha[0],1); + histoParameters2D[4][iParticle][0]->Fill(Rapidity, Pt, 1); + histoParameters2D[4][iParticle][3]->Fill(Rapidity, M_t, 1); + + if (drawZR) { + if (histoParameters2D[4][iParticle][1]) + histoParameters2D[4][iParticle][1]->Fill(Z, R, 1); + if (histoParameters2D[4][iParticle][2]) + histoParameters2D[4][iParticle][2]->Fill(QtAlpha[1], QtAlpha[0], 1); } } - - if( fabs(fParteff.GetMass(iParticle)-M) > 3.f*fParteff.GetMassSigma(iParticle) && - fabs(fParteff.GetMass(iParticle)-M) <= 6.f*fParteff.GetMassSigma(iParticle) )//BGReco + + if (fabs(fParteff.GetMass(iParticle) - M) > 3.f * fParteff.GetMassSigma(iParticle) && + fabs(fParteff.GetMass(iParticle) - M) <= 6.f * fParteff.GetMassSigma(iParticle)) //BGReco { - for(int iParam=0; iParam<17; iParam++) + for (int iParam = 0; iParam < 17; iParam++) histoParameters[5][iParticle][iParam]->Fill(parameters[iParam]); - - if(multiplicities) + + if (multiplicities) multiplicities[5][iParticle]++; - histoParameters2D[5][iParticle][0]->Fill(Rapidity,Pt,1); - histoParameters2D[5][iParticle][3]->Fill(Rapidity,M_t,1); - - if(drawZR) - { - if(histoParameters2D[5][iParticle][1]) - histoParameters2D[5][iParticle][1]->Fill(Z,R,1); - if(histoParameters2D[5][iParticle][2]) - histoParameters2D[5][iParticle][2]->Fill(QtAlpha[1],QtAlpha[0],1); + histoParameters2D[5][iParticle][0]->Fill(Rapidity, Pt, 1); + histoParameters2D[5][iParticle][3]->Fill(Rapidity, M_t, 1); + + if (drawZR) { + if (histoParameters2D[5][iParticle][1]) + histoParameters2D[5][iParticle][1]->Fill(Z, R, 1); + if (histoParameters2D[5][iParticle][2]) + histoParameters2D[5][iParticle][2]->Fill(QtAlpha[1], QtAlpha[0], 1); } } } - - if(!fStoreMCHistograms) return; + + if (!fStoreMCHistograms) + return; int iSet = 1; - if(!RtoMCParticleId[iP].IsMatchedWithPdg()) //background + if (!RtoMCParticleId[iP].IsMatchedWithPdg()) //background { - if(!RtoMCParticleId[iP].IsMatched()) iSet = 3; // for ghost particles - combinatorial background - else iSet = 2; // for physical background + if (!RtoMCParticleId[iP].IsMatched()) + iSet = 3; // for ghost particles - combinatorial background + else + iSet = 2; // for physical background } - + //Check if PV association is correct - if(!histoDSToParticleQA && iSet == 1) - { + if (!histoDSToParticleQA && iSet == 1) { int iMCPart = RtoMCParticleId[iP].GetBestMatchWithPdg(); - KFMCParticle &mcPart = vMCParticles[iMCPart]; + KFMCParticle& mcPart = vMCParticles[iMCPart]; int iMCTrack = mcPart.GetMCTrackID(); - KFMCTrack &mcTrack = vMCTracks[iMCTrack]; + KFMCTrack& mcTrack = vMCTracks[iMCTrack]; int motherId = mcTrack.MotherId(); bool isSecondaryParticle = motherId >= 0; - - if(iPV >=0) - { - if(isSecondaryParticle) + + if (iPV >= 0) { + if (isSecondaryParticle) iSet = 4; - else - { + else { int iMCPV = -1; - if(RtoMCPVId[iPV].IsMatchedWithPdg()) + if (RtoMCPVId[iPV].IsMatchedWithPdg()) iMCPV = RtoMCPVId[iPV].GetBestMatch(); - + int iMCPVFromParticle = fMCTrackToMCPVMatch[iMCTrack]; - if(iMCPV != iMCPVFromParticle) + if (iMCPV != iMCPVFromParticle) iSet = 4; } - } - else - { - if(!isSecondaryParticle) + } else { + if (!isSecondaryParticle) iSet = 4; } } - + //for signal particles - for(int iParam=0; iParam<17; iParam++) + for (int iParam = 0; iParam < 17; iParam++) histoParameters[iSet][iParticle][iParam]->Fill(parameters[iParam]); - - if(multiplicities) + + if (multiplicities) multiplicities[iSet][iParticle]++; - - histoParameters2D[iSet][iParticle][0]->Fill(Rapidity,Pt,1); - if(drawZR) - { - if(histoParameters2D[iSet][iParticle][1]) - histoParameters2D[iSet][iParticle][1]->Fill(Z,R,1); - if(histoParameters2D[iSet][iParticle][2]) - histoParameters2D[iSet][iParticle][2]->Fill(QtAlpha[1],QtAlpha[0],1); + + histoParameters2D[iSet][iParticle][0]->Fill(Rapidity, Pt, 1); + if (drawZR) { + if (histoParameters2D[iSet][iParticle][1]) + histoParameters2D[iSet][iParticle][1]->Fill(Z, R, 1); + if (histoParameters2D[iSet][iParticle][2]) + histoParameters2D[iSet][iParticle][2]->Fill(QtAlpha[1], QtAlpha[0], 1); } - histoParameters2D[iSet][iParticle][3]->Fill(Rapidity,M_t,1); - - if(iSet != 1) return; - + histoParameters2D[iSet][iParticle][3]->Fill(Rapidity, M_t, 1); + + if (iSet != 1) + return; + int iMCPart = RtoMCParticleId[iP].GetBestMatchWithPdg(); - KFMCParticle &mcPart = vMCParticles[iMCPart]; + KFMCParticle& mcPart = vMCParticles[iMCPart]; // Fit quality of the mother particle - if(histoFit) - { + if (histoFit) { int iMCTrack = mcPart.GetMCTrackID(); - KFMCTrack &mcTrack = vMCTracks[iMCTrack]; + KFMCTrack& mcTrack = vMCTracks[iMCTrack]; int mcDaughterId = -1; - if(iParticle >= fParteff.fFirstStableParticleIndex && iParticle <= fParteff.fLastStableParticleIndex) + if (iParticle >= fParteff.fFirstStableParticleIndex && iParticle <= fParteff.fLastStableParticleIndex) mcDaughterId = iMCTrack; - else if(mcTrack.PDG() == 22 && TempPart.NDaughters() == 1) + else if (mcTrack.PDG() == 22 && TempPart.NDaughters() == 1) mcDaughterId = iMCTrack; - else if(iParticle >= fParteff.fFirstMissingMassParticleIndex && iParticle <= fParteff.fLastMissingMassParticleIndex) + else if (iParticle >= fParteff.fFirstMissingMassParticleIndex && iParticle <= fParteff.fLastMissingMassParticleIndex) mcDaughterId = mcPart.GetDaughterIds()[1]; //the charged daughter else mcDaughterId = mcPart.GetDaughterIds()[0]; - - KFMCTrack &mcDaughter = vMCTracks[mcDaughterId]; - - float mcX = mcTrack.X(); - float mcY = mcTrack.Y(); - float mcZ = mcTrack.Z(); - if(histoDSToParticleQA || hPartParamPrimary == histoParameters) - { - mcX = mcDaughter.X(); - mcY = mcDaughter.Y(); - mcZ = mcDaughter.Z(); + + KFMCTrack& mcDaughter = vMCTracks[mcDaughterId]; + + float mcX = mcTrack.X(); + float mcY = mcTrack.Y(); + float mcZ = mcTrack.Z(); + if (histoDSToParticleQA || hPartParamPrimary == histoParameters) { + mcX = mcDaughter.X(); + mcY = mcDaughter.Y(); + mcZ = mcDaughter.Z(); } const float mcPx = mcTrack.Par(3); const float mcPy = mcTrack.Par(4); const float mcPz = mcTrack.Par(5); - float decayVtx[3] = { mcTrack.X(), mcTrack.Y(), mcTrack.Z() }; - float recParam[8] = { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; - float errParam[8] = { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; + float decayVtx[3] = {mcTrack.X(), mcTrack.Y(), mcTrack.Z()}; + float recParam[8] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; + float errParam[8] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; - for(int iPar=0; iPar<3; iPar++) - { + for (int iPar = 0; iPar < 3; iPar++) { recParam[iPar] = TempPart.GetParameter(iPar); - Double_t error = TempPart.GetCovariance(iPar,iPar); - if(error < 0.) { error = 1.e20;} + Double_t error = TempPart.GetCovariance(iPar, iPar); + if (error < 0.) { + error = 1.e20; + } errParam[iPar] = TMath::Sqrt(error); } TempPart.TransportToPoint(decayVtx); - for(int iPar=3; iPar<7; iPar++) - { + for (int iPar = 3; iPar < 7; iPar++) { recParam[iPar] = TempPart.GetParameter(iPar); - Double_t error = TempPart.GetCovariance(iPar,iPar); - if(error < 0.) { error = 1.e20;} + Double_t error = TempPart.GetCovariance(iPar, iPar); + if (error < 0.) { + error = 1.e20; + } errParam[iPar] = TMath::Sqrt(error); } - int jParticlePDG = fParteff.GetParticleIndex(mcTrack.PDG()); - Double_t massMC = (jParticlePDG>=0) ? fParteff.partMass[jParticlePDG] :0.13957; - - Double_t Emc = sqrt(mcTrack.P()*mcTrack.P() + massMC*massMC); - Double_t res[8] = {0}, - pull[8] = {0}, - mcParam[8] = { mcX, mcY, mcZ, - mcPx, mcPy, mcPz, Emc, massMC }; - for(int iPar=0; iPar < 7; iPar++ ) - { - res[iPar] = recParam[iPar] - mcParam[iPar]; - if(fabs(errParam[iPar]) > 1.e-20) pull[iPar] = res[iPar]/errParam[iPar]; + int jParticlePDG = fParteff.GetParticleIndex(mcTrack.PDG()); + Double_t massMC = (jParticlePDG >= 0) ? fParteff.partMass[jParticlePDG] : 0.13957; + + Double_t Emc = sqrt(mcTrack.P() * mcTrack.P() + massMC * massMC); + Double_t res[8] = {0}, + pull[8] = {0}, + mcParam[8] = {mcX, mcY, mcZ, + mcPx, mcPy, mcPz, Emc, massMC}; + for (int iPar = 0; iPar < 7; iPar++) { + res[iPar] = recParam[iPar] - mcParam[iPar]; + if (fabs(errParam[iPar]) > 1.e-20) + pull[iPar] = res[iPar] / errParam[iPar]; } res[7] = M - mcParam[7]; - if(fabs(ErrM) > 1.e-20) pull[7] = res[7]/ErrM; + if (fabs(ErrM) > 1.e-20) + pull[7] = res[7] / ErrM; - for(int iPar=0; iPar < 8; iPar++ ) - { + for (int iPar = 0; iPar < 8; iPar++) { histoFit[iParticle][iPar]->Fill(res[iPar]); - histoFit[iParticle][iPar+8]->Fill(pull[iPar]); + histoFit[iParticle][iPar + 8]->Fill(pull[iPar]); } } // Fit quality of daughters int daughterIndex[2] = {-1, -1}; - - if(histoFitDaughtersQA) - { - for(int iD=0; iDGetParticles()[recDaughterId]; - Daughter.GetMass(M,ErrM); + Daughter.GetMass(M, ErrM); - const float mcX = mcTrack.X(); - const float mcY = mcTrack.Y(); - const float mcZ = mcTrack.Z(); + const float mcX = mcTrack.X(); + const float mcY = mcTrack.Y(); + const float mcZ = mcTrack.Z(); const float mcPx = mcTrack.Px(); const float mcPy = mcTrack.Py(); const float mcPz = mcTrack.Pz(); @@ -1615,106 +1573,104 @@ void KFTopoPerformance::FillParticleParameters(KFParticle& TempPart, KFParticleSIMD DaughterSIMD(Daughter); DaughterSIMD.TransportToPoint(decayVtx); - - int jParticlePDG = fParteff.GetParticleIndex(mcTrack.PDG()); - Double_t massMC = (jParticlePDG>=0) ? fParteff.partMass[jParticlePDG] :0.13957; - Double_t Emc = sqrt(mcTrack.P()*mcTrack.P() + massMC*massMC); - - Double_t res[8] = {0}, - pull[8] = {0}, - mcParam[8] = { mcX, mcY, mcZ, - mcPx, mcPy, mcPz, Emc, massMC }; - for(int iPar=0; iPar < 7; iPar++ ) - { - Double_t error = DaughterSIMD.GetCovariance(iPar,iPar)[0]; - if(error < 0.) { error = 1.e20;} + + int jParticlePDG = fParteff.GetParticleIndex(mcTrack.PDG()); + Double_t massMC = (jParticlePDG >= 0) ? fParteff.partMass[jParticlePDG] : 0.13957; + Double_t Emc = sqrt(mcTrack.P() * mcTrack.P() + massMC * massMC); + + Double_t res[8] = {0}, + pull[8] = {0}, + mcParam[8] = {mcX, mcY, mcZ, + mcPx, mcPy, mcPz, Emc, massMC}; + for (int iPar = 0; iPar < 7; iPar++) { + Double_t error = DaughterSIMD.GetCovariance(iPar, iPar)[0]; + if (error < 0.) { + error = 1.e20; + } error = TMath::Sqrt(error); Double_t recoPar = DaughterSIMD.GetParameter(iPar)[0]; - res[iPar] = recoPar - mcParam[iPar]; - if(fabs(error) > 1.e-20) pull[iPar] = res[iPar]/error; + res[iPar] = recoPar - mcParam[iPar]; + if (fabs(error) > 1.e-20) + pull[iPar] = res[iPar] / error; } res[7] = M - mcParam[7]; - if(fabs(ErrM) > 1.e-20) pull[7] = res[7]/ErrM; + if (fabs(ErrM) > 1.e-20) + pull[7] = res[7] / ErrM; - for(int iPar=0; iPar < 8; iPar++ ) - { + for (int iPar = 0; iPar < 8; iPar++) { histoFitDaughtersQA[iParticle][iPar]->Fill(res[iPar]); - histoFitDaughtersQA[iParticle][iPar+8]->Fill(pull[iPar]); + histoFitDaughtersQA[iParticle][iPar + 8]->Fill(pull[iPar]); } - + //fill Histos for GetDStoParticle - if(iD == 0) + if (iD == 0) daughterIndex[0] = recDaughterId; - if(iD == 1 && daughterIndex[0] > -1 && histoDSToParticleQA) - { + if (iD == 1 && daughterIndex[0] > -1 && histoDSToParticleQA) { daughterIndex[1] = recDaughterId; KFParticle d1 = fTopoReconstructor->GetParticles()[daughterIndex[0]]; KFParticle d2 = fTopoReconstructor->GetParticles()[daughterIndex[1]]; - + KFParticleSIMD daughters[2] = {d2, d1}; - + float_v dS[2] = {0.f, 0.f}; float_v dsdr[4][6]; - for(int i1=0; i1<4; i1++) - for(int i2=0; i2<6; i2++) + for (int i1 = 0; i1 < 4; i1++) + for (int i2 = 0; i2 < 6; i2++) dsdr[i1][i2] = 0.f; - + daughters[0].GetDStoParticle(daughters[1], dS, dsdr); float_v pD[2][8], cD[2][36], corrPD[2][36], corrCD[2][36]; - - for(int iDR=0; iDR<2; iDR++) - { - for(int iPD = 0; iPD<8; iPD++) - { + + for (int iDR = 0; iDR < 2; iDR++) { + for (int iPD = 0; iPD < 8; iPD++) { pD[iDR][iPD] = 0; corrPD[iDR][iPD] = 0; } - for(int iCD=0; iCD<36; iCD++) - { + for (int iCD = 0; iCD < 36; iCD++) { cD[iDR][iCD] = 0; corrCD[iDR][iCD] = 0; } } - + float_v F[4][36]; { - for(int i1=0; i1<4; i1++) - for(int i2=0; i2<36; i2++) - F[i1][i2] = 0; + for (int i1 = 0; i1 < 4; i1++) + for (int i2 = 0; i2 < 36; i2++) + F[i1][i2] = 0; } daughters[0].Transport(dS[0], dsdr[0], pD[0], cD[0], dsdr[1], F[0], F[1]); daughters[1].Transport(dS[1], dsdr[3], pD[1], cD[1], dsdr[2], F[3], F[2]); - - daughters[0].MultQSQt( F[1], daughters[1].CovarianceMatrix(), corrCD[0], 6); - daughters[0].MultQSQt( F[2], daughters[0].CovarianceMatrix(), corrCD[1], 6); - for(int iDR=0; iDR<2; iDR++) - for(int iC=0; iC<6; iC++) + + daughters[0].MultQSQt(F[1], daughters[1].CovarianceMatrix(), corrCD[0], 6); + daughters[0].MultQSQt(F[2], daughters[0].CovarianceMatrix(), corrCD[1], 6); + for (int iDR = 0; iDR < 2; iDR++) + for (int iC = 0; iC < 6; iC++) cD[iDR][iC] += corrCD[iDR][iC]; - for(int iDR=0; iDR<2; iDR++) - { + for (int iDR = 0; iDR < 2; iDR++) { cD[iDR][1] = cD[iDR][2]; cD[iDR][2] = cD[iDR][5]; - for(int iPar=0; iPar<3; iPar++) - { + for (int iPar = 0; iPar < 3; iPar++) { res[iPar] = pD[iDR][iPar][0] - decayVtx[iPar][0]; - + Double_t error = cD[iDR][iPar][0]; - if(error < 0.) { error = 1.e20;} + if (error < 0.) { + error = 1.e20; + } error = sqrt(error); - + pull[iPar] = res[iPar] / error; - + histoDSToParticleQA[iParticle][iPar]->Fill(res[iPar]); - histoDSToParticleQA[iParticle][iPar+3]->Fill(pull[iPar]); + histoDSToParticleQA[iParticle][iPar + 3]->Fill(pull[iPar]); } } - + Double_t dXds = pD[0][0][0] - pD[1][0][0]; Double_t dYds = pD[0][1][0] - pD[1][1][0]; Double_t dZds = pD[0][2][0] - pD[1][2][0]; - - Double_t dRds = sqrt(dXds*dXds + dYds*dYds + dZds*dZds); + + Double_t dRds = sqrt(dXds * dXds + dYds * dYds + dZds * dZds); histoDSToParticleQA[iParticle][6]->Fill(dRds); } } @@ -1725,313 +1681,292 @@ void KFTopoPerformance::FillHistos() { /** Fills histograms with parameter distributions and fit quality for all particle and primary vertex candidates. */ vector multiplicities[6]; - for(int iV=0; iV<6; iV++) + for (int iV = 0; iV < 6; iV++) multiplicities[iV].resize(KFPartEfficiencies::nParticles, 0); - + //fill histograms for found short-lived particles - for(unsigned int iP=0; iPGetParticles().size(); iP++) - { + for (unsigned int iP = 0; iP < fTopoReconstructor->GetParticles().size(); iP++) { int iParticle = fParteff.GetParticleIndex(fTopoReconstructor->GetParticles()[iP].GetPDG()); - if(iParticle < 0) continue; + if (iParticle < 0) + continue; KFParticle TempPart = fTopoReconstructor->GetParticles()[iP]; - - FillParticleParameters(TempPart,iParticle, iP, 0, hPartParam, hPartParam2D, hPartParam3D, + + FillParticleParameters(TempPart, iParticle, iP, 0, hPartParam, hPartParam2D, hPartParam3D, hFitQA, hFitDaughtersQA, hDSToParticleQA, multiplicities); } - - if(fStoreMCHistograms) - { - for(int iSet=0; iSet& SecondaryCandidates = fTopoReconstructor->GetKFParticleFinder()->GetSecondaryCandidates()[iSet]; - for(unsigned int iP=0; iPGetParticles()[id]; FillParticleParameters(TempPart, iParticle, id, 0, hPartParamSecondary, hPartParam2DSecondary, 0); } } - - for(int iSet=0; iSetNPrimaryVertices(); iPV++) - { + + for (int iSet = 0; iSet < KFParticleFinder::GetNPrimarySets(); iSet++) { + for (int iPV = 0; iPV < fTopoReconstructor->NPrimaryVertices(); iPV++) { const std::vector& PrimaryCandidates = fTopoReconstructor->GetKFParticleFinder()->GetPrimaryCandidates()[iSet][iPV]; - for(unsigned int iP=0; iPGetParticles()[id]; - FillParticleParameters(TempPart,iParticle, id, iPV, hPartParamPrimary, hPartParam2DPrimary, 0, hFitQANoConstraint); + FillParticleParameters(TempPart, iParticle, id, iPV, hPartParamPrimary, hPartParam2DPrimary, 0, hFitQANoConstraint); } - + const std::vector& PrimaryCandidatesTopo = fTopoReconstructor->GetKFParticleFinder()->GetPrimaryTopoCandidates()[iSet][iPV]; - for(unsigned int iP=0; iP& PrimaryCandidatesTopoMass = fTopoReconstructor->GetKFParticleFinder()->GetPrimaryTopoMassCandidates()[iSet][iPV]; - for(unsigned int iP=0; iPGetParticles().size(); iP++) - { + for (unsigned int iP = 0; iP < fTopoReconstructor->GetParticles().size(); iP++) { KFParticle TempPart = fTopoReconstructor->GetParticles()[iP]; KFParticle vtx = fTopoReconstructor->GetPrimVertex(0); - - if(RtoMCParticleId[iP].IsMatched()) - { + + if (RtoMCParticleId[iP].IsMatched()) { int iMCPV = vMCParticles[RtoMCParticleId[iP].GetBestMatch()].GetMotherId(); - if(iMCPV<0.) - { + if (iMCPV < 0.) { iMCPV = -iMCPV - 1; - if(MCtoRPVId[iMCPV].IsMatched()) - { + if (MCtoRPVId[iMCPV].IsMatched()) { vtx = fTopoReconstructor->GetPrimVertex(MCtoRPVId[iMCPV].GetBestMatch()); - } + } } } -// else -// KFParticle & vtx = fTopoReconstructor->GetPrimVertex(0); - - + // else + // KFParticle & vtx = fTopoReconstructor->GetPrimVertex(0); + float chi2 = TempPart.GetDeviationFromVertex(vtx); int ndf = 2; - + hTrackParameters[KFPartEfficiencies::nParticles]->Fill(chi2); - hTrackParameters[KFPartEfficiencies::nParticles+4]->Fill(TMath::Prob(chi2, ndf)); - - if(!RtoMCParticleId[iP].IsMatched()) - { - hTrackParameters[KFPartEfficiencies::nParticles+3]->Fill(chi2); - hTrackParameters[KFPartEfficiencies::nParticles+7]->Fill(TMath::Prob(chi2, ndf)); + hTrackParameters[KFPartEfficiencies::nParticles + 4]->Fill(TMath::Prob(chi2, ndf)); + + if (!RtoMCParticleId[iP].IsMatched()) { + hTrackParameters[KFPartEfficiencies::nParticles + 3]->Fill(chi2); + hTrackParameters[KFPartEfficiencies::nParticles + 7]->Fill(TMath::Prob(chi2, ndf)); continue; } - + int iMCPart = RtoMCParticleId[iP].GetBestMatch(); - KFMCParticle &mcPart = vMCParticles[iMCPart]; - if(mcPart.GetMotherId() < 0) - { - hTrackParameters[KFPartEfficiencies::nParticles+1]->Fill(chi2 ); - hTrackParameters[KFPartEfficiencies::nParticles+5]->Fill(TMath::Prob(chi2, ndf)); + KFMCParticle& mcPart = vMCParticles[iMCPart]; + if (mcPart.GetMotherId() < 0) { + hTrackParameters[KFPartEfficiencies::nParticles + 1]->Fill(chi2); + hTrackParameters[KFPartEfficiencies::nParticles + 5]->Fill(TMath::Prob(chi2, ndf)); + } else { + hTrackParameters[KFPartEfficiencies::nParticles + 2]->Fill(chi2); + hTrackParameters[KFPartEfficiencies::nParticles + 6]->Fill(TMath::Prob(chi2, ndf)); } - else - { - hTrackParameters[KFPartEfficiencies::nParticles+2]->Fill(chi2 ); - hTrackParameters[KFPartEfficiencies::nParticles+6]->Fill(TMath::Prob(chi2, ndf)); - } int iParticle = fParteff.GetParticleIndex(fTopoReconstructor->GetParticles()[iP].GetPDG()); - if(iParticle > -1 && iParticleFill(chi2 ); - + if (iParticle > -1 && iParticle < KFPartEfficiencies::nParticles) + hTrackParameters[iParticle]->Fill(chi2); } - - + //fill histograms of the primary vertex quality - for(int iPV = 0; iPVNPrimaryVertices(); iPV++) - { - KFParticle & vtx = fTopoReconstructor->GetPrimVertex(iPV); - vector &tracks = fTopoReconstructor->GetPVTrackIndexArray(iPV); + for (int iPV = 0; iPV < fTopoReconstructor->NPrimaryVertices(); iPV++) { + KFParticle& vtx = fTopoReconstructor->GetPrimVertex(iPV); + vector& tracks = fTopoReconstructor->GetPVTrackIndexArray(iPV); - Double_t probPV = TMath::Prob(vtx.Chi2(), vtx.NDF());//(TDHelper::Chi2IProbability( ndf, chi2 )); + Double_t probPV = TMath::Prob(vtx.Chi2(), vtx.NDF()); //(TDHelper::Chi2IProbability( ndf, chi2 )); vector dzPV; - if(RtoMCPVId[iPV].IsMatched()) - { + if (RtoMCPVId[iPV].IsMatched()) { int iCurrMCPV = RtoMCPVId[iPV].GetBestMatch(); - for(int iPV2 = iPV+1; iPV2 < fTopoReconstructor->NPrimaryVertices(); iPV2++) - { - if(!RtoMCPVId[iPV2].IsMatched()) continue; + for (int iPV2 = iPV + 1; iPV2 < fTopoReconstructor->NPrimaryVertices(); iPV2++) { + if (!RtoMCPVId[iPV2].IsMatched()) + continue; int iCurrMCPV2 = RtoMCPVId[iPV2].GetBestMatch(); - if(iCurrMCPV != iCurrMCPV2) continue; - KFParticle & vtx2 = fTopoReconstructor->GetPrimVertex(iPV2); - - dzPV.push_back(fabs(vtx.Z() - vtx2.Z())); + if (iCurrMCPV != iCurrMCPV2) + continue; + KFParticle& vtx2 = fTopoReconstructor->GetPrimVertex(iPV2); + + dzPV.push_back(fabs(vtx.Z() - vtx2.Z())); } } - - hPVParam[ 0]->Fill(vtx.X()); - hPVParam[ 1]->Fill(vtx.Y()); - hPVParam[ 2]->Fill(vtx.Z()); - hPVParam[ 3]->Fill(sqrt(vtx.X()*vtx.X() + vtx.Y()*vtx.Y())); - hPVParam[ 4]->Fill(tracks.size()); - hPVParam[ 5]->Fill(vtx.Chi2()); - hPVParam[ 6]->Fill(vtx.NDF()); - hPVParam[ 7]->Fill(vtx.Chi2()/vtx.NDF()); - hPVParam[ 8]->Fill(probPV); - hPVParam[ 9]->Fill(fPVPurity[iPV]); + + hPVParam[0]->Fill(vtx.X()); + hPVParam[1]->Fill(vtx.Y()); + hPVParam[2]->Fill(vtx.Z()); + hPVParam[3]->Fill(sqrt(vtx.X() * vtx.X() + vtx.Y() * vtx.Y())); + hPVParam[4]->Fill(tracks.size()); + hPVParam[5]->Fill(vtx.Chi2()); + hPVParam[6]->Fill(vtx.NDF()); + hPVParam[7]->Fill(vtx.Chi2() / vtx.NDF()); + hPVParam[8]->Fill(probPV); + hPVParam[9]->Fill(fPVPurity[iPV]); hPVParam[10]->Fill(fPVTracksRate[0][iPV]); hPVParam[11]->Fill(fPVTracksRate[1][iPV]); hPVParam[12]->Fill(fPVTracksRate[2][iPV]); hPVParam[13]->Fill(fPVTracksRate[3][iPV]); - for(unsigned int iZ=0; iZFill(dzPV[iZ]); - hPVParam2D[0]->Fill(vtx.X(),vtx.Y()); - - - if(!RtoMCPVId[iPV].IsMatchedWithPdg()) - { - if(!RtoMCPVId[iPV].IsMatched()) - { - hPVParamGhost[ 0]->Fill(vtx.X()); - hPVParamGhost[ 1]->Fill(vtx.Y()); - hPVParamGhost[ 2]->Fill(vtx.Z()); - hPVParamGhost[ 3]->Fill(sqrt(vtx.X()*vtx.X() + vtx.Y()*vtx.Y())); - hPVParamGhost[ 4]->Fill(tracks.size()); - hPVParamGhost[ 5]->Fill(vtx.Chi2()); - hPVParamGhost[ 6]->Fill(vtx.NDF()); - hPVParamGhost[ 7]->Fill(vtx.Chi2()/vtx.NDF()); - hPVParamGhost[ 8]->Fill(probPV); - hPVParamGhost[ 9]->Fill(fPVPurity[iPV]); + hPVParam2D[0]->Fill(vtx.X(), vtx.Y()); + + if (!RtoMCPVId[iPV].IsMatchedWithPdg()) { + if (!RtoMCPVId[iPV].IsMatched()) { + hPVParamGhost[0]->Fill(vtx.X()); + hPVParamGhost[1]->Fill(vtx.Y()); + hPVParamGhost[2]->Fill(vtx.Z()); + hPVParamGhost[3]->Fill(sqrt(vtx.X() * vtx.X() + vtx.Y() * vtx.Y())); + hPVParamGhost[4]->Fill(tracks.size()); + hPVParamGhost[5]->Fill(vtx.Chi2()); + hPVParamGhost[6]->Fill(vtx.NDF()); + hPVParamGhost[7]->Fill(vtx.Chi2() / vtx.NDF()); + hPVParamGhost[8]->Fill(probPV); + hPVParamGhost[9]->Fill(fPVPurity[iPV]); hPVParamGhost[10]->Fill(fPVTracksRate[0][iPV]); hPVParamGhost[11]->Fill(fPVTracksRate[1][iPV]); hPVParamGhost[12]->Fill(fPVTracksRate[2][iPV]); hPVParamGhost[13]->Fill(fPVTracksRate[3][iPV]); - for(unsigned int iZ=0; iZFill(dzPV[iZ]); - } - else - { - hPVParamBG[ 0]->Fill(vtx.X()); - hPVParamBG[ 1]->Fill(vtx.Y()); - hPVParamBG[ 2]->Fill(vtx.Z()); - hPVParamBG[ 3]->Fill(sqrt(vtx.X()*vtx.X() + vtx.Y()*vtx.Y())); - hPVParamBG[ 4]->Fill(tracks.size()); - hPVParamBG[ 5]->Fill(vtx.Chi2()); - hPVParamBG[ 6]->Fill(vtx.NDF()); - hPVParamBG[ 7]->Fill(vtx.Chi2()/vtx.NDF()); - hPVParamBG[ 8]->Fill(probPV); - hPVParamBG[ 9]->Fill(fPVPurity[iPV]); + } else { + hPVParamBG[0]->Fill(vtx.X()); + hPVParamBG[1]->Fill(vtx.Y()); + hPVParamBG[2]->Fill(vtx.Z()); + hPVParamBG[3]->Fill(sqrt(vtx.X() * vtx.X() + vtx.Y() * vtx.Y())); + hPVParamBG[4]->Fill(tracks.size()); + hPVParamBG[5]->Fill(vtx.Chi2()); + hPVParamBG[6]->Fill(vtx.NDF()); + hPVParamBG[7]->Fill(vtx.Chi2() / vtx.NDF()); + hPVParamBG[8]->Fill(probPV); + hPVParamBG[9]->Fill(fPVPurity[iPV]); hPVParamBG[10]->Fill(fPVTracksRate[0][iPV]); hPVParamBG[11]->Fill(fPVTracksRate[1][iPV]); hPVParamBG[12]->Fill(fPVTracksRate[2][iPV]); hPVParamBG[13]->Fill(fPVTracksRate[3][iPV]); - for(unsigned int iZ=0; iZFill(dzPV[iZ]); } continue; } - + int iMCPV = RtoMCPVId[iPV].GetBestMatch(); - KFMCVertex &mcPV = fPrimVertices[iMCPV]; // primary vertex positions (currently only one vertex is implemented) - + KFMCVertex& mcPV = fPrimVertices[iMCPV]; // primary vertex positions (currently only one vertex is implemented) + int iPVType = 0; - if(mcPV.IsTriggerPV()) - { - hPVParamSignal[ 0]->Fill(vtx.X()); - hPVParamSignal[ 1]->Fill(vtx.Y()); - hPVParamSignal[ 2]->Fill(vtx.Z()); - hPVParamSignal[ 3]->Fill(sqrt(vtx.X()*vtx.X() + vtx.Y()*vtx.Y())); - hPVParamSignal[ 4]->Fill(tracks.size()); - hPVParamSignal[ 5]->Fill(vtx.Chi2()); - hPVParamSignal[ 6]->Fill(vtx.NDF()); - hPVParamSignal[ 7]->Fill(vtx.Chi2()/vtx.NDF()); - hPVParamSignal[ 8]->Fill(probPV); - hPVParamSignal[ 9]->Fill(fPVPurity[iPV]); + if (mcPV.IsTriggerPV()) { + hPVParamSignal[0]->Fill(vtx.X()); + hPVParamSignal[1]->Fill(vtx.Y()); + hPVParamSignal[2]->Fill(vtx.Z()); + hPVParamSignal[3]->Fill(sqrt(vtx.X() * vtx.X() + vtx.Y() * vtx.Y())); + hPVParamSignal[4]->Fill(tracks.size()); + hPVParamSignal[5]->Fill(vtx.Chi2()); + hPVParamSignal[6]->Fill(vtx.NDF()); + hPVParamSignal[7]->Fill(vtx.Chi2() / vtx.NDF()); + hPVParamSignal[8]->Fill(probPV); + hPVParamSignal[9]->Fill(fPVPurity[iPV]); hPVParamSignal[10]->Fill(fPVTracksRate[0][iPV]); hPVParamSignal[11]->Fill(fPVTracksRate[1][iPV]); hPVParamSignal[12]->Fill(fPVTracksRate[2][iPV]); hPVParamSignal[13]->Fill(fPVTracksRate[3][iPV]); - for(unsigned int iZ=0; iZFill(dzPV[iZ]); - } - else - { - hPVParamPileup[ 0]->Fill(vtx.X()); - hPVParamPileup[ 1]->Fill(vtx.Y()); - hPVParamPileup[ 2]->Fill(vtx.Z()); - hPVParamPileup[ 3]->Fill(sqrt(vtx.X()*vtx.X() + vtx.Y()*vtx.Y())); - hPVParamPileup[ 4]->Fill(tracks.size()); - hPVParamPileup[ 5]->Fill(vtx.Chi2()); - hPVParamPileup[ 6]->Fill(vtx.NDF()); - hPVParamPileup[ 7]->Fill(vtx.Chi2()/vtx.NDF()); - hPVParamPileup[ 8]->Fill(probPV); - hPVParamPileup[ 9]->Fill(fPVPurity[iPV]); + } else { + hPVParamPileup[0]->Fill(vtx.X()); + hPVParamPileup[1]->Fill(vtx.Y()); + hPVParamPileup[2]->Fill(vtx.Z()); + hPVParamPileup[3]->Fill(sqrt(vtx.X() * vtx.X() + vtx.Y() * vtx.Y())); + hPVParamPileup[4]->Fill(tracks.size()); + hPVParamPileup[5]->Fill(vtx.Chi2()); + hPVParamPileup[6]->Fill(vtx.NDF()); + hPVParamPileup[7]->Fill(vtx.Chi2() / vtx.NDF()); + hPVParamPileup[8]->Fill(probPV); + hPVParamPileup[9]->Fill(fPVPurity[iPV]); hPVParamPileup[10]->Fill(fPVTracksRate[0][iPV]); hPVParamPileup[11]->Fill(fPVTracksRate[1][iPV]); hPVParamPileup[12]->Fill(fPVTracksRate[2][iPV]); hPVParamPileup[13]->Fill(fPVTracksRate[3][iPV]); - for(unsigned int iZ=0; iZFill(dzPV[iZ]); iPVType = 1; } - //Find MC parameters of the primary vertex - float mcPVx[3]={mcPV.X(), mcPV.Y(), mcPV.Z()}; + //Find MC parameters of the primary vertex + float mcPVx[3] = {mcPV.X(), mcPV.Y(), mcPV.Z()}; float errPV[3] = {vtx.CovarianceMatrix()[0], vtx.CovarianceMatrix()[2], vtx.CovarianceMatrix()[5]}; - for(int iErr=0; iErr<3; iErr++) - if(fabs(errPV[iErr]) < 1.e-8f) errPV[iErr] = 1.e8; - - float dRPVr[3] = {vtx.X()-mcPVx[0], - vtx.Y()-mcPVx[1], - vtx.Z()-mcPVx[2]}; - float dRPVp[3] = {static_cast(dRPVr[0]/sqrt(errPV[0])), - static_cast(dRPVr[1]/sqrt(errPV[1])), - static_cast(dRPVr[2]/sqrt(errPV[2]))}; - - for(unsigned int iHPV=0; iHPV<3; ++iHPV) + for (int iErr = 0; iErr < 3; iErr++) + if (fabs(errPV[iErr]) < 1.e-8f) + errPV[iErr] = 1.e8; + + float dRPVr[3] = {vtx.X() - mcPVx[0], + vtx.Y() - mcPVx[1], + vtx.Z() - mcPVx[2]}; + float dRPVp[3] = {static_cast(dRPVr[0] / sqrt(errPV[0])), + static_cast(dRPVr[1] / sqrt(errPV[1])), + static_cast(dRPVr[2] / sqrt(errPV[2]))}; + + for (unsigned int iHPV = 0; iHPV < 3; ++iHPV) hPVFitQa[iPVType][iHPV]->Fill(dRPVr[iHPV]); - for(unsigned int iHPV=3; iHPV<6; ++iHPV) - hPVFitQa[iPVType][iHPV]->Fill(dRPVp[iHPV-3]); - - for(unsigned int iHPV=0; iHPV<3; ++iHPV) - hPVFitQa2D[iPVType][1][iHPV]->Fill(fNCorrectPVTracks[iPV],dRPVr[iHPV]); - for(unsigned int iHPV=3; iHPV<6; ++iHPV) - hPVFitQa2D[iPVType][1][iHPV]->Fill(fNCorrectPVTracks[iPV],dRPVp[iHPV-3]); - - for(unsigned int iHPV=0; iHPV<3; ++iHPV) - hPVFitQa2D[iPVType][0][iHPV]->Fill(mcPV.NReconstructedDaughterTracks(),dRPVr[iHPV]); - for(unsigned int iHPV=3; iHPV<6; ++iHPV) - hPVFitQa2D[iPVType][0][iHPV]->Fill(mcPV.NReconstructedDaughterTracks(),dRPVp[iHPV-3]); - - hPVFitQa[iPVType][6]->Fill( double(mcPV.NReconstructedDaughterTracks() - fNCorrectPVTracks[iPV])/double(mcPV.NReconstructedDaughterTracks()) ); + for (unsigned int iHPV = 3; iHPV < 6; ++iHPV) + hPVFitQa[iPVType][iHPV]->Fill(dRPVp[iHPV - 3]); + + for (unsigned int iHPV = 0; iHPV < 3; ++iHPV) + hPVFitQa2D[iPVType][1][iHPV]->Fill(fNCorrectPVTracks[iPV], dRPVr[iHPV]); + for (unsigned int iHPV = 3; iHPV < 6; ++iHPV) + hPVFitQa2D[iPVType][1][iHPV]->Fill(fNCorrectPVTracks[iPV], dRPVp[iHPV - 3]); + + for (unsigned int iHPV = 0; iHPV < 3; ++iHPV) + hPVFitQa2D[iPVType][0][iHPV]->Fill(mcPV.NReconstructedDaughterTracks(), dRPVr[iHPV]); + for (unsigned int iHPV = 3; iHPV < 6; ++iHPV) + hPVFitQa2D[iPVType][0][iHPV]->Fill(mcPV.NReconstructedDaughterTracks(), dRPVp[iHPV - 3]); + + hPVFitQa[iPVType][6]->Fill(double(mcPV.NReconstructedDaughterTracks() - fNCorrectPVTracks[iPV]) / double(mcPV.NReconstructedDaughterTracks())); } - + //fill histograms with quality of input tracks from PV - for(unsigned int iP=0; iPGetParticles().size(); iP++) - { + for (unsigned int iP = 0; iP < fTopoReconstructor->GetParticles().size(); iP++) { KFParticle TempPart = fTopoReconstructor->GetParticles()[iP]; int nDaughters = TempPart.NDaughters(); - if(nDaughters > 1) continue; //use only tracks, not short lived particles - - if(!RtoMCParticleId[iP].IsMatchedWithPdg()) continue; //ghost - + if (nDaughters > 1) + continue; //use only tracks, not short lived particles + + if (!RtoMCParticleId[iP].IsMatchedWithPdg()) + continue; //ghost + int iMCPart = RtoMCParticleId[iP].GetBestMatchWithPdg(); - KFMCParticle &mcPart = vMCParticles[iMCPart]; + KFMCParticle& mcPart = vMCParticles[iMCPart]; int iMCTrack = mcPart.GetMCTrackID(); - KFMCTrack &mcTrack = vMCTracks[iMCTrack]; - - if( mcTrack.MotherId() > -1 ) continue; // select only PV tracks - - const float mcX = mcTrack.X(); - const float mcY = mcTrack.Y(); - const float mcZ = mcTrack.Z(); + KFMCTrack& mcTrack = vMCTracks[iMCTrack]; + + if (mcTrack.MotherId() > -1) + continue; // select only PV tracks + + const float mcX = mcTrack.X(); + const float mcY = mcTrack.Y(); + const float mcZ = mcTrack.Z(); const float mcPx = mcTrack.Px(); const float mcPy = mcTrack.Py(); const float mcPz = mcTrack.Pz(); @@ -2039,99 +1974,95 @@ void KFTopoPerformance::FillHistos() float decayVtx[3] = {mcX, mcY, mcZ}; TempPart.TransportToPoint(decayVtx); - - Double_t res[6] = {0}, - pull[6] = {0}, - mcParam[6] = { mcX, mcY, mcZ, - mcPx, mcPy, mcPz }; - for(int iPar=0; iPar < 6; iPar++ ) - { - Double_t error = TempPart.GetCovariance(iPar,iPar); - if(error < 0.) { error = 1.e20;} + Double_t res[6] = {0}, + pull[6] = {0}, + mcParam[6] = {mcX, mcY, mcZ, + mcPx, mcPy, mcPz}; + for (int iPar = 0; iPar < 6; iPar++) { + Double_t error = TempPart.GetCovariance(iPar, iPar); + if (error < 0.) { + error = 1.e20; + } error = TMath::Sqrt(error); - res[iPar] = TempPart.GetParameter(iPar) - mcParam[iPar]; - if(fabs(error) > 1.e-20) pull[iPar] = res[iPar]/error; - + res[iPar] = TempPart.GetParameter(iPar) - mcParam[iPar]; + if (fabs(error) > 1.e-20) + pull[iPar] = res[iPar] / error; + hFitPVTracksQA[iPar]->Fill(res[iPar]); - hFitPVTracksQA[iPar+6]->Fill(pull[iPar]); + hFitPVTracksQA[iPar + 6]->Fill(pull[iPar]); } } - - if(fStoreMCHistograms) - { - for(int iV=0; iV<6; iV++) - for(int iP=0; iP < KFPartEfficiencies::nParticles; iP++) - if(hPartParam[iV][iP][17]) + + if (fStoreMCHistograms) { + for (int iV = 0; iV < 6; iV++) + for (int iP = 0; iP < KFPartEfficiencies::nParticles; iP++) + if (hPartParam[iV][iP][17]) hPartParam[iV][iP][17]->Fill(multiplicities[iV][iP]); FillMCHistos(); - } - else - for(int iP=0; iP < KFPartEfficiencies::nParticles; iP++) - if(hPartParam[0][iP][17]) - hPartParam[0][iP][17]->Fill(multiplicities[0][iP]); + } else + for (int iP = 0; iP < KFPartEfficiencies::nParticles; iP++) + if (hPartParam[0][iP][17]) + hPartParam[0][iP][17]->Fill(multiplicities[0][iP]); } // void KFTopoPerformance::FillHistos() void KFTopoPerformance::FillMCHistos() { /** Fills histograms of Monte Carlo particles. */ - for(unsigned int iMCTrack=0; iMCTrack=0) continue; - KFMCParticle &part = vMCParticles[iMCTrack]; - + if (iPDG < 0) + continue; + + if (vMCTracks[iMCTrack].MotherId() >= 0) + continue; + KFMCParticle& part = vMCParticles[iMCTrack]; + float M = fParteff.partMass[iPDG]; float P = vMCTracks[iMCTrack].P(); float Pt = vMCTracks[iMCTrack].Pt(); - float E = sqrt(M*M+P*P); - float Rapidity = 0.5*log((E+vMCTracks[iMCTrack].Pz())/(E-vMCTracks[iMCTrack].Pz())); - float M_t = sqrt(Pt*Pt+M*M)-M; - + float E = sqrt(M * M + P * P); + float Rapidity = 0.5 * log((E + vMCTracks[iMCTrack].Pz()) / (E - vMCTracks[iMCTrack].Pz())); + float M_t = sqrt(Pt * Pt + M * M) - M; + float X; float Y; float Z; float R; - - if (part.NDaughters()>0) - { + + if (part.NDaughters() > 0) { X = vMCTracks[part.GetDaughterIds()[0]].X(); Y = vMCTracks[part.GetDaughterIds()[0]].Y(); Z = vMCTracks[part.GetDaughterIds()[0]].Z(); - } - else - { + } else { X = vMCTracks[iMCTrack].X(); Y = vMCTracks[iMCTrack].Y(); Z = vMCTracks[iMCTrack].Z(); } - R = sqrt(X*X+Y*Y); - - + R = sqrt(X * X + Y * Y); + float parameters[17] = {M, P, Pt, Rapidity, 0, 0, 0, 0, 0, 0, X, Y, Z, R, 0, 0, M_t}; //for all particle-candidates - for(int iParam=0; iParam<17; iParam++) - if(hPartParam[6][iPDG][iParam]) hPartParam[6][iPDG][iParam]->Fill(parameters[iParam]); - - if(hPartParam2D[6][iPDG][0]) hPartParam2D[6][iPDG][0]->Fill(Rapidity,Pt,1); - if(hPartParam2D[6][iPDG][3]) hPartParam2D[6][iPDG][3]->Fill(Rapidity,M_t,1); - - if(IsCollectZRHistogram(iPDG)) - if(hPartParam2D[6][iPDG][1]) hPartParam2D[6][iPDG][1]->Fill(Z,R,1); - - if( part.IsReconstructable(2) && IsCollectArmenteros(iPDG)) - { + for (int iParam = 0; iParam < 17; iParam++) + if (hPartParam[6][iPDG][iParam]) + hPartParam[6][iPDG][iParam]->Fill(parameters[iParam]); + + if (hPartParam2D[6][iPDG][0]) + hPartParam2D[6][iPDG][0]->Fill(Rapidity, Pt, 1); + if (hPartParam2D[6][iPDG][3]) + hPartParam2D[6][iPDG][3]->Fill(Rapidity, M_t, 1); + + if (IsCollectZRHistogram(iPDG)) + if (hPartParam2D[6][iPDG][1]) + hPartParam2D[6][iPDG][1]->Fill(Z, R, 1); + + if (part.IsReconstructable(2) && IsCollectArmenteros(iPDG)) { int index1 = part.GetDaughterIds()[0]; int index2 = part.GetDaughterIds()[1]; KFMCTrack positive, negative; - if(vMCTracks[index1].Par(6) > 0) - { + if (vMCTracks[index1].Par(6) > 0) { positive = vMCTracks[index1]; negative = vMCTracks[index2]; - } - else - { + } else { negative = vMCTracks[index1]; positive = vMCTracks[index2]; } @@ -2140,17 +2071,18 @@ void KFTopoPerformance::FillMCHistos() float spx = positive.Px() + negative.Px(); float spy = positive.Py() + negative.Py(); float spz = positive.Pz() + negative.Pz(); - float sp = sqrt(spx*spx + spy*spy + spz*spz); + float sp = sqrt(spx * spx + spy * spy + spz * spz); float pn, pln, plp; - pn = sqrt(negative.Px()*negative.Px() + negative.Py()*negative.Py() + negative.Pz()*negative.Pz()); - pln = (negative.Px()*spx+negative.Py()*spy+negative.Pz()*spz)/sp; - plp = (positive.Px()*spx+positive.Py()*spy+positive.Pz()*spz)/sp; - float ptm = (1.-((pln/pn)*(pln/pn))); - qt= (ptm>=0.)? pn*sqrt(ptm) :0; - alpha = (plp-pln)/(plp+pln); - - if(hPartParam2D[6][iPDG][2]) hPartParam2D[6][iPDG][2]->Fill(alpha,qt,1); - } + pn = sqrt(negative.Px() * negative.Px() + negative.Py() * negative.Py() + negative.Pz() * negative.Pz()); + pln = (negative.Px() * spx + negative.Py() * spy + negative.Pz() * spz) / sp; + plp = (positive.Px() * spx + positive.Py() * spy + positive.Pz() * spz) / sp; + float ptm = (1. - ((pln / pn) * (pln / pn))); + qt = (ptm >= 0.) ? pn * sqrt(ptm) : 0; + alpha = (plp - pln) / (plp + pln); + + if (hPartParam2D[6][iPDG][2]) + hPartParam2D[6][iPDG][2]->Fill(alpha, qt, 1); + } } } @@ -2159,29 +2091,26 @@ void KFTopoPerformance::AddV0Histos() /** Copies histograms of K0s candidates to V0 folder. */ int iV0 = fParteff.nParticles - 1; int iK0 = fParteff.GetParticleIndex(310); - - for(int iH=0; iHAdd(hFitDaughtersQA[iK0][iH]); hFitQA[iV0][iH]->Add(hFitQA[iK0][iH]); } - for(int iV=0; iV<4; iV++) - for(int iH=0; iHAdd(hPartParam[iV][iK0][iH]); } void KFTopoPerformance::FillHistos(const KFPHistogram* histograms) { /** Fill histograms with the histograms from the provided KFPHistogram object. */ - for(int iParticle=0; iParticleGetHistogramSet(0).GetNHisto1D(); - for(int iHistogram=0; iHistogramGetHistogram(iParticle,iHistogram); - for(int iBin=0; iBinSetBinContent( iBin, histogram.GetHistogram()[iBin] ); + for (int iHistogram = 0; iHistogram < nHistograms; iHistogram++) { + const KFPHistogram1D& histogram = histograms->GetHistogram(iParticle, iHistogram); + for (int iBin = 0; iBin < histogram.Size(); iBin++) + hPartParam[0][iParticle][iHistogram]->SetBinContent(iBin, histogram.GetHistogram()[iBin]); } } } diff --git a/KFParticlePerformance/KFTopoPerformance.h b/KFParticlePerformance/KFTopoPerformance.h index 731faf6..ec1edd4 100644 --- a/KFParticlePerformance/KFTopoPerformance.h +++ b/KFParticlePerformance/KFTopoPerformance.h @@ -24,7 +24,6 @@ #ifndef KFTOPOPERFORMANCE_H #define KFTOPOPERFORMANCE_H - #include "KFParticlePerformanceBase.h" #include "KFMCVertex.h" @@ -55,70 +54,68 @@ class KFPHistogram; ** another primary vertex; efficiency. **/ -class KFTopoPerformance: public KFParticlePerformanceBase +class KFTopoPerformance : public KFParticlePerformanceBase { public: - KFTopoPerformance(); virtual ~KFTopoPerformance(); #ifdef KFPWITHTRACKER virtual void SetNewEvent( - const AliHLTTPCCAGBTracker * const Tracker, - AliHLTResizableArray *hitLabels, - AliHLTResizableArray *mcTracks, - AliHLTResizableArray *localMCPoints); -#endif - void SetTopoReconstructor( const KFParticleTopoReconstructor * const TopoReconstructor ); - const KFParticleTopoReconstructor * GetTopoReconstructor() const { return fTopoReconstructor; } ///< Returns pointer to the KFParticleTopoReconstructor object. - - // Check if MC track is reconstructable. Calculate set of MC track. Etc. + const AliHLTTPCCAGBTracker* const Tracker, + AliHLTResizableArray* hitLabels, + AliHLTResizableArray* mcTracks, + AliHLTResizableArray* localMCPoints); +#endif + void SetTopoReconstructor(const KFParticleTopoReconstructor* const TopoReconstructor); + const KFParticleTopoReconstructor* GetTopoReconstructor() const { return fTopoReconstructor; } ///< Returns pointer to the KFParticleTopoReconstructor object. + + // Check if MC track is reconstructable. Calculate set of MC track. Etc. virtual void CheckMCTracks(); // fill mcData. // Find reco-MCTracks correspondence - virtual void MatchTracks(); // fill recoData. + virtual void MatchTracks(); // fill recoData. // Calculate efficiencies - + /// Histograms void FillHistos(); void FillHistos(const KFPHistogram* histograms); void FillMCHistos(); void AddV0Histos(); - - void SetTrackMatch(const std::vector& trackMatch) { fTrackMatch = trackMatch;} ///< Fill matching between Monte Carlo and reconstructed tracks. - void SetMCTracks(const std::vector& mcTracks) { vMCTracks = mcTracks; } ///< Fill Monte Carlo tracks. - + + void SetTrackMatch(const std::vector& trackMatch) { fTrackMatch = trackMatch; } ///< Fill matching between Monte Carlo and reconstructed tracks. + void SetMCTracks(const std::vector& mcTracks) { vMCTracks = mcTracks; } ///< Fill Monte Carlo tracks. + const KFPartEfficiencies GetEfficiency() const { return fParteff; } ///< Returns KFPartEfficiencies object with calculated efficiency. - void SetPrintEffFrequency(int n) { fPrintEffFrequency = n;} ///< Sets frequency in events for efficiency table to be printed on the screen. + void SetPrintEffFrequency(int n) { fPrintEffFrequency = n; } ///< Sets frequency in events for efficiency table to be printed on the screen. - const std::vector GetPrimVertices() { return fPrimVertices; } ///< Returns Monte Carlo primary vertices in the current event. - const std::vector& MCParticles() { return vMCParticles; } ///< Returns Monte Carlo particles in the current event. + const std::vector GetPrimVertices() { return fPrimVertices; } ///< Returns Monte Carlo primary vertices in the current event. + const std::vector& MCParticles() { return vMCParticles; } ///< Returns Monte Carlo particles in the current event. const std::vector& ParticlesMatch() { return RtoMCParticleId; } ///< Returns matching between reconstructed and Monte Carlo particles. - const std::vector& GetMCtoRPVId() { return MCtoRPVId; } ///< Returns matching between Monte Carlo and reconstructed primary vertices. - const std::vector& GetRtoMCPVId() { return RtoMCPVId; } ///< Returns matching between reconstructed and Monte Carlo primary vertices. + const std::vector& GetMCtoRPVId() { return MCtoRPVId; } ///< Returns matching between Monte Carlo and reconstructed primary vertices. + const std::vector& GetRtoMCPVId() { return RtoMCPVId; } ///< Returns matching between reconstructed and Monte Carlo primary vertices. const KFMCTrack& GetMCTrack(const int iRecoTrack) - { + { /** Returns Monte Carlo track matched with the reconstructed track with index "iRecoTrack". */ int iMCTrack = 0; - if(RtoMCParticleId[iRecoTrack].IsMatched()) + if (RtoMCParticleId[iRecoTrack].IsMatched()) iMCTrack = RtoMCParticleId[iRecoTrack].GetBestMatch(); - return vMCTracks[iMCTrack]; + return vMCTracks[iMCTrack]; } - - void SetCentralityBin(const int iBin) { fCentralityBin = iBin; } ///< Sets centrality bin of the current event. + + void SetCentralityBin(const int iBin) { fCentralityBin = iBin; } ///< Sets centrality bin of the current event. void SetCentralityWeight(const float weight) { fCentralityWeight = weight; } ///< Sets weight of the centrality bin of the current event. - + private: + const KFTopoPerformance& operator=(const KFTopoPerformance&); ///< Copying of objects of this class is forbidden. + KFTopoPerformance(const KFTopoPerformance&); ///< Copying of objects of this class is forbidden. - const KFTopoPerformance& operator = (const KFTopoPerformance&); ///< Copying of objects of this class is forbidden. - KFTopoPerformance(const KFTopoPerformance&); ///< Copying of objects of this class is forbidden. - void GetMCParticles(); void MatchParticles(); void MatchPV(); void CalculateEfficiency(); void CalculatePVEfficiency(); void FindReconstructableMCParticles(); - void CheckMCParticleIsReconstructable(KFMCParticle &part); + void CheckMCParticleIsReconstructable(KFMCParticle& part); void FindReconstructableMCVertices(); void FillParticleParameters(KFParticle& TempPart, int iParticle, @@ -131,20 +128,20 @@ class KFTopoPerformance: public KFParticlePerformanceBase TH1F* histoFitDaughtersQA[KFPartEfficiencies::nParticles][nFitQA] = 0, TH1F* histoDSToParticleQA[KFPartEfficiencies::nParticles][nDSToParticleQA] = 0, std::vector* multiplicities = 0); - - const KFParticleTopoReconstructor *fTopoReconstructor; ///< Pointer to the KFParticleTopoReconstructor object with particles and vertices to be analysed. + + const KFParticleTopoReconstructor* fTopoReconstructor; ///< Pointer to the KFParticleTopoReconstructor object with particles and vertices to be analysed. std::vector fPrimVertices; ///< Monte Carlo primary vertices. - std::vector fMCTrackToMCPVMatch; ///< Matching of Monte Carlo tracks and corresponding primary vertex - std::vector fPVPurity; ///< Purity of the primary vertices. - std::vector fPVTracksRate[4]; ///< Ratio in the primary vertices of: 0 - ghost tracks, 1 - from trigger PV, 2 - from pileup, 3 - from physics background. - std::vector fNCorrectPVTracks; ///< Number of correctly attached tracks in the corresponding reconstructed primary vertex. - - std::vector fTrackMatch; ///< Matching between reconstructed tracks and - std::vector vMCTracks; ///< Monte Carlo tracks (parameters of the particle trajectories at the production point). - std::vector vMCParticles; ///< Monte Carlo particles. - std::vector fNeutralIndex; ///< Index of the created neutral daughters for missing mass method in vMCTracks for the Monte Carlo track with given index. - + std::vector fMCTrackToMCPVMatch; ///< Matching of Monte Carlo tracks and corresponding primary vertex + std::vector fPVPurity; ///< Purity of the primary vertices. + std::vector fPVTracksRate[4]; ///< Ratio in the primary vertices of: 0 - ghost tracks, 1 - from trigger PV, 2 - from pileup, 3 - from physics background. + std::vector fNCorrectPVTracks; ///< Number of correctly attached tracks in the corresponding reconstructed primary vertex. + + std::vector fTrackMatch; ///< Matching between reconstructed tracks and + std::vector vMCTracks; ///< Monte Carlo tracks (parameters of the particle trajectories at the production point). + std::vector vMCParticles; ///< Monte Carlo particles. + std::vector fNeutralIndex; ///< Index of the created neutral daughters for missing mass method in vMCTracks for the Monte Carlo track with given index. + /** Matching between Monte Carlo and reconstructed particles. MCtoRParticleId[i] provides index of the reconstructed particle in the ** fTopoReconstructor->GetParticles() array for the Monte Carlo particle (or track) with index "i". **/ std::vector MCtoRParticleId; @@ -158,10 +155,10 @@ class KFTopoPerformance: public KFParticlePerformanceBase /** Matching between reconstructed and Monte Carlo primary vertices. RtoMCPVId[i] provides index of the Monte Carlo vertex in the ** fPrimVertices array for the reconstructed vertex with index "i" from fTopoReconstructor->GetPrimVertex(). **/ std::vector RtoMCPVId; - - int fPrintEffFrequency; ///< Frequency in events with which efficiency table is printed on the screen. - - int fCentralityBin; ///< Centrality bin for the current event. + + int fPrintEffFrequency; ///< Frequency in events with which efficiency table is printed on the screen. + + int fCentralityBin; ///< Centrality bin for the current event. float fCentralityWeight; ///< Centrality weight for the current event. }; diff --git a/KFParticleTest/KFParticleTest.cxx b/KFParticleTest/KFParticleTest.cxx index 577b497..25bc9d8 100644 --- a/KFParticleTest/KFParticleTest.cxx +++ b/KFParticleTest/KFParticleTest.cxx @@ -33,32 +33,46 @@ ClassImp(KFParticleTest) #endif -std::ostream& operator<<(std::ostream& os, const KFParticleBase& particle) { - static const char *vn[14] = {"x","y","z","px","py","pz","E","S","M","t","p","Q","Chi2","NDF"}; + std::ostream& + operator<<(std::ostream& os, const KFParticleBase& particle) +{ + static const char* vn[14] = {"x", "y", "z", "px", "py", "pz", "E", "S", "M", "t", "p", "Q", "Chi2", "NDF"}; for (Int_t i = 0; i < 8; i++) { - if (i == 6) continue; // E - if (i == 7 && particle.GetParameter(i) <= 0.0) continue; // S - if (particle.GetParameter(i) == 0. && particle.GetCovariance(i,i) == 0) continue; - if (particle.GetCovariance(i,i) > 0) - os << " " << vn[i]<<": "<< std::setw(8) << particle.GetParameter(i)<< " +/- " << std::setw(6) << sqrt(particle.GetCovariance(i,i)); - else + if (i == 6) + continue; // E + if (i == 7 && particle.GetParameter(i) <= 0.0) + continue; // S + if (particle.GetParameter(i) == 0. && particle.GetCovariance(i, i) == 0) + continue; + if (particle.GetCovariance(i, i) > 0) + os << " " << vn[i] << ": " << std::setw(8) << particle.GetParameter(i) << " +/- " << std::setw(6) << sqrt(particle.GetCovariance(i, i)); + else os << " " << vn[i] << ": " << std::setw(8) << particle.GetParameter(i); } float Mtp[3], MtpErr[3]; - particle.GetMass(Mtp[0], MtpErr[0]); if (MtpErr[0] < 1e-7 || MtpErr[0] > 1e10) MtpErr[0] = -13; - particle.GetLifeTime(Mtp[1], MtpErr[1]); if (MtpErr[1] <= 0 || MtpErr[1] > 1e10) MtpErr[1] = -13; - particle.GetMomentum(Mtp[2], MtpErr[2]); if (MtpErr[2] <= 0 || MtpErr[2] > 1e10) MtpErr[2] = -13; + particle.GetMass(Mtp[0], MtpErr[0]); + if (MtpErr[0] < 1e-7 || MtpErr[0] > 1e10) + MtpErr[0] = -13; + particle.GetLifeTime(Mtp[1], MtpErr[1]); + if (MtpErr[1] <= 0 || MtpErr[1] > 1e10) + MtpErr[1] = -13; + particle.GetMomentum(Mtp[2], MtpErr[2]); + if (MtpErr[2] <= 0 || MtpErr[2] > 1e10) + MtpErr[2] = -13; for (Int_t i = 8; i < 11; i++) { - if (i == 9 && Mtp[i-8] <= 0.0) continue; // t - if (MtpErr[i-8] > 0 && MtpErr[i-8] < 1e10) os << " " << vn[i] << ": " << std::setw(8) << Mtp[i-8] << " +/-" << std::setw(7) << MtpErr[i-8]; - else os << " " << vn[i] << ": " << std::setw(8) << Mtp[i-8]; + if (i == 9 && Mtp[i - 8] <= 0.0) + continue; // t + if (MtpErr[i - 8] > 0 && MtpErr[i - 8] < 1e10) + os << " " << vn[i] << ": " << std::setw(8) << Mtp[i - 8] << " +/-" << std::setw(7) << MtpErr[i - 8]; + else + os << " " << vn[i] << ": " << std::setw(8) << Mtp[i - 8]; } - os << " pdg:" << std::setw(5) << particle.GetPDG() << " Q: "<< std::setw(2) << int(particle.GetQ()) << " chi2/NDF: " << std::setw(8) << particle.GetChi2() << "/" << std::setw(2) << particle.GetNDF(); + os << " pdg:" << std::setw(5) << particle.GetPDG() << " Q: " << std::setw(2) << int(particle.GetQ()) << " chi2/NDF: " << std::setw(8) << particle.GetChi2() << "/" << std::setw(2) << particle.GetNDF(); return os; } -KFParticleTest::KFParticleTest():fMotherSingle(0),fMotherSIMD(0) +KFParticleTest::KFParticleTest() : fMotherSingle(0), fMotherSIMD(0) { fMotherSingle = new KFParticle(); fMotherSIMD = new KFParticleSIMD(); @@ -66,11 +80,13 @@ KFParticleTest::KFParticleTest():fMotherSingle(0),fMotherSIMD(0) KFParticleTest::~KFParticleTest() { - if(fMotherSingle) delete fMotherSingle; - if(fMotherSIMD) delete fMotherSIMD; + if (fMotherSingle) + delete fMotherSingle; + if (fMotherSIMD) + delete fMotherSIMD; } -void KFParticleTest::RunTest() +void KFParticleTest::RunTest() { RunTestSingle(); RunTestSIMD(); @@ -81,133 +97,158 @@ void KFParticleTest::RunTestSingle() std::cout.setf(std::ios::fixed); std::cout.setf(std::ios::showpoint); std::cout.precision(3); - - std::cout << "Try different constructors" << std::endl<< std::endl; - std::cout << "1. Construction from Vertex" << std::endl<< std::endl; + + std::cout << "Try different constructors" << std::endl + << std::endl; + std::cout << "1. Construction from Vertex" << std::endl + << std::endl; KFPVertex vert; vert.SetXYZ(0.0, 0.0, 10.0); - vert.SetCovarianceMatrix( 0.01, - 0.00, 0.01, - 0.00, 0.00, 0.01 ); + vert.SetCovarianceMatrix(0.01, + 0.00, 0.01, + 0.00, 0.00, 0.01); vert.SetNContributors(2); vert.SetChi2(1.01); - + KFParticle p1(vert); - std::cout << "Vertex Particle p1" << std::endl << " " << p1 << std::endl; + std::cout << "Vertex Particle p1" << std::endl + << " " << p1 << std::endl; /// ***************************************************************************************** - -#ifdef HomogeneousField + +#ifdef HomogeneousField KFParticle::SetField(4.9797992706298828); #endif - float point[3]={0.f}; + float point[3] = {0.f}; float b[3] = {0.f}; - p1.GetFieldValue(point,b); - std::cout << "Set Field " << std::setw(6) << b[2] << std::endl; - - std::cout << std::endl << "2. Construction from Track" << std::endl<< std::endl; - + p1.GetFieldValue(point, b); + std::cout << "Set Field " << std::setw(6) << b[2] << std::endl; + + std::cout << std::endl + << "2. Construction from Track" << std::endl + << std::endl; + KFPTrack track; - track.SetParameters(-0.061996019110347252, -1.3579236865955473, 27.147283554077148, - 0.62539337626870062, -0.028552340672283318, -0.18467358509984011); - float C[21]= {3.3055800809774214e-05, - 0.00098316976438185002, 0.04740889543423539, - -8.5596097466772512e-05, -0.0037516094381694971, 0.032156504690647125, - -2.2812597903705375e-05, -0.0012121012247057524, 3.0646383360925928e-05, 6.1388628418184652e-05, - -4.4071909055788304e-06,-0.00048870318030618627, 3.8062554692505919e-05, 1.2177141510445709e-05, 7.6900178535210476e-06, - 6.6224441962932268e-06, 0.00034363110217286891, -0.00031520420397528146,-1.6277704753223909e-05,-3.4322154557097545e-06, 1.027411488502718e-05}; + track.SetParameters(-0.061996019110347252, -1.3579236865955473, 27.147283554077148, + 0.62539337626870062, -0.028552340672283318, -0.18467358509984011); + float C[21] = {3.3055800809774214e-05, + 0.00098316976438185002, 0.04740889543423539, + -8.5596097466772512e-05, -0.0037516094381694971, 0.032156504690647125, + -2.2812597903705375e-05, -0.0012121012247057524, 3.0646383360925928e-05, 6.1388628418184652e-05, + -4.4071909055788304e-06, -0.00048870318030618627, 3.8062554692505919e-05, 1.2177141510445709e-05, 7.6900178535210476e-06, + 6.6224441962932268e-06, 0.00034363110217286891, -0.00031520420397528146, -1.6277704753223909e-05, -3.4322154557097545e-06, 1.027411488502718e-05}; track.SetCovarianceMatrix(C); track.SetNDF(1); track.SetChi2(1.5); track.SetCharge(-1); - + KFParticle p2(track, -211); - - std::cout << "Track Particle p2" << std::endl <<" "<< p2 << std::endl; - + + std::cout << "Track Particle p2" << std::endl + << " " << p2 << std::endl; + /// ***************************************************************************************** - - std::cout << std::endl << "3. Now we will create one more particle from track and call the construction from these 2 particles" << std::endl<< std::endl; - + + std::cout << std::endl + << "3. Now we will create one more particle from track and call the construction from these 2 particles" << std::endl + << std::endl; + KFPTrack track2; - track2.SetParameters(-0.20371287092090862, 3.0678058943547839, -19.93988037109375, - 0.37533048135363339, 0.024923235867488316, 0.19031024520542122); - float C2[21]= - { 0.00022312908970259721, - -0.00064291160449645151, 0.089331037457232143, - 0.00047880877483649206, -0.045478494677353445, 0.11199165135622025, - 4.6362085390124077e-07, 0.00070978326424729935, -0.00014164977426380486, 1.7553871209443515e-05, - -2.2044831998838091e-05,-0.00059994741249631909, 0.00030148707952079015,-4.6574515272730461e-06, 7.2618497455845866e-06, - -1.2427988441207971e-06, 0.00030830063771211896, -0.00061853865528922161, 5.4390968700069889e-06,-1.9914477627292868e-06, 8.9837108094398403e-06}; + track2.SetParameters(-0.20371287092090862, 3.0678058943547839, -19.93988037109375, + 0.37533048135363339, 0.024923235867488316, 0.19031024520542122); + float C2[21] = + {0.00022312908970259721, + -0.00064291160449645151, 0.089331037457232143, + 0.00047880877483649206, -0.045478494677353445, 0.11199165135622025, + 4.6362085390124077e-07, 0.00070978326424729935, -0.00014164977426380486, 1.7553871209443515e-05, + -2.2044831998838091e-05, -0.00059994741249631909, 0.00030148707952079015, -4.6574515272730461e-06, 7.2618497455845866e-06, + -1.2427988441207971e-06, 0.00030830063771211896, -0.00061853865528922161, 5.4390968700069889e-06, -1.9914477627292868e-06, 8.9837108094398403e-06}; track2.SetCovarianceMatrix(C2); track2.SetNDF(2); track2.SetChi2(2.5); track2.SetCharge(+1); KFParticle p3(track2, 211); // PDG = 11 - std::cout << "Track Particle p3 " << std::endl <<" "<< p3 << std::endl; - + std::cout << "Track Particle p3 " << std::endl + << " " << p3 << std::endl; + KFParticle p4(p2, p3); - std::cout << "Particle p4(p2,p3)" << std::endl << " " << p4 << std::endl; + std::cout << "Particle p4(p2,p3)" << std::endl + << " " << p4 << std::endl; /// ***************************************************************************************** - std::cout << std::endl << "4. Construction with constrained Mass or (and) vertex position values" << std::endl<< std::endl; + std::cout << std::endl + << "4. Construction with constrained Mass or (and) vertex position values" << std::endl + << std::endl; -/// This is the example of the KFParticleBase::Construct function usage. -/// parameter 1 - array of the daughter particles -/// parameter 2 - number of the daughter particles -/// parameter 3 - vertex (it should be the object of the KFParticle class) -/// parameter 4 - the value we force the particle mass to be equial to. + /// This is the example of the KFParticleBase::Construct function usage. + /// parameter 1 - array of the daughter particles + /// parameter 2 - number of the daughter particles + /// parameter 3 - vertex (it should be the object of the KFParticle class) + /// parameter 4 - the value we force the particle mass to be equial to. const KFParticle pVertex = p1; int NDaughters = 2; - const KFParticle *vDaughters[2] = {&p2, &p3}; - + const KFParticle* vDaughters[2] = {&p2, &p3}; + Double_t Mass = 0.497614; - - std::cout << "4.1 Construction with constrained Mass, without vertex hypothesis " << std::endl<< std::endl; -/// we assume Mass to be the mass of the constructed particle + + std::cout << "4.1 Construction with constrained Mass, without vertex hypothesis " << std::endl + << std::endl; + /// we assume Mass to be the mass of the constructed particle KFParticle K0; - K0.Construct(vDaughters,NDaughters,0,Mass); + K0.Construct(vDaughters, NDaughters, 0, Mass); std::cout << "Dauthers" << std::endl - << " " << *vDaughters[0] << std::endl - << " " << *vDaughters[1] << std::endl - << "Mass " << Mass << std::endl; - std::cout << "Particle K0" << std::endl << K0 << std::endl; + << " " << *vDaughters[0] << std::endl + << " " << *vDaughters[1] << std::endl + << "Mass " << Mass << std::endl; + std::cout << "Particle K0" << std::endl + << K0 << std::endl; K0.SetProductionVertex(pVertex); std::cout << " Add parent Vertex" << std::endl; std::cout << " K0 with vertex " << K0 << std::endl; - std::cout << std::endl << "4.2 Construction without constrained Mass, with vertex hypothesis " << std::endl<< std::endl; -/// we assume p1 to be the vertex of the constructed particle + std::cout << std::endl + << "4.2 Construction without constrained Mass, with vertex hypothesis " << std::endl + << std::endl; + /// we assume p1 to be the vertex of the constructed particle KFParticle K0_1; - K0_1.Construct(vDaughters,NDaughters,&pVertex,-1); + K0_1.Construct(vDaughters, NDaughters, &pVertex, -1); std::cout << "Dauthers" << std::endl - << " " << *vDaughters[0] << std::endl - << " " << *vDaughters[1] << std::endl - << "PV " << std::endl << " " << pVertex << std::endl; - std::cout << "K0_1" << std::endl <<" " << K0_1 << std::endl; - std::cout << std::endl << "4.3 Construction with constrained Mass, with vertex hypothesis " << std::endl<< std::endl; -///we assume p1 to be the vertex of the constructed particle, Mass to be the mass of the constructed particle + << " " << *vDaughters[0] << std::endl + << " " << *vDaughters[1] << std::endl + << "PV " << std::endl + << " " << pVertex << std::endl; + std::cout << "K0_1" << std::endl + << " " << K0_1 << std::endl; + std::cout << std::endl + << "4.3 Construction with constrained Mass, with vertex hypothesis " << std::endl + << std::endl; + ///we assume p1 to be the vertex of the constructed particle, Mass to be the mass of the constructed particle KFParticle K0_2; - K0_2.Construct(vDaughters,NDaughters,&pVertex,Mass); + K0_2.Construct(vDaughters, NDaughters, &pVertex, Mass); std::cout << "Dauthers" << std::endl - << " " << *vDaughters[0] << std::endl - << " " << *vDaughters[1] << std::endl - << "PV " << std::endl << " " << pVertex << std::endl - << "Mass " << Mass << std::endl; - std::cout << "K0_2" << std::endl << " " << K0_2 << std::endl; - - std::cout << std::endl << "4.4 Construction K0_3(p2,p3) without constrained Mass, without vertex hypothesis " << std::endl<< std::endl; -///we assume p1 to be the vertex of the constructed particle, Mass to be the mass of the constructed particle + << " " << *vDaughters[0] << std::endl + << " " << *vDaughters[1] << std::endl + << "PV " << std::endl + << " " << pVertex << std::endl + << "Mass " << Mass << std::endl; + std::cout << "K0_2" << std::endl + << " " << K0_2 << std::endl; + + std::cout << std::endl + << "4.4 Construction K0_3(p2,p3) without constrained Mass, without vertex hypothesis " << std::endl + << std::endl; + ///we assume p1 to be the vertex of the constructed particle, Mass to be the mass of the constructed particle KFParticle K0_3; - K0_3.Construct(vDaughters,NDaughters,0,-1); + K0_3.Construct(vDaughters, NDaughters, 0, -1); std::cout << "Dauthers" << std::endl - << " " << *vDaughters[0] << std::endl - << " " << *vDaughters[1] << std::endl; - std::cout << "K0_3" << std::endl << " " << K0_3 << std::endl; + << " " << *vDaughters[0] << std::endl + << " " << *vDaughters[1] << std::endl; + std::cout << "K0_3" << std::endl + << " " << K0_3 << std::endl; } void KFParticleTest::RunTestSIMD() diff --git a/KFParticleTest/KFParticleTest.h b/KFParticleTest/KFParticleTest.h index bca7f52..f42349e 100644 --- a/KFParticleTest/KFParticleTest.h +++ b/KFParticleTest/KFParticleTest.h @@ -28,26 +28,23 @@ class KFParticleSIMD; class KFParticleTest { public: - KFParticleTest(); ~KFParticleTest(); - + void PrintTutorial(); void RunTest(); - + private: - void RunTestSingle(); void RunTestSIMD(); void CompareSingleAndSIMDResults(); - + KFParticle* fMotherSingle; KFParticleSIMD* fMotherSIMD; - + #ifndef KFParticleStandalone - ClassDef( KFParticleTest, 1 ) + ClassDef(KFParticleTest, 1) #endif }; #endif //KFParticleTest_H - From c7dd26a4cf2fa8ffb5c2b6356e94c8dd8d779d9b Mon Sep 17 00:00:00 2001 From: sgorbuno Date: Thu, 25 Feb 2021 19:49:05 +0000 Subject: [PATCH 3/3] code format - braces for some of the one-line loops and ifs --- KFParticle/KFPInputData.h | 43 +- KFParticle/KFPTrackVector.cxx | 79 +-- KFParticle/KFPTrackVector.h | 24 +- KFParticle/KFParticle.cxx | 47 +- KFParticle/KFParticle.h | 121 ++--- KFParticle/KFParticleBase.cxx | 539 +++++++++++++-------- KFParticle/KFParticleBaseSIMD.cxx | 401 +++++++++------ KFParticle/KFParticleSIMD.cxx | 184 ++++--- KFParticle/KFParticleTopoReconstructor.cxx | 230 +++++---- 9 files changed, 1024 insertions(+), 644 deletions(-) diff --git a/KFParticle/KFPInputData.h b/KFParticle/KFPInputData.h index 539b87d..8f674f8 100644 --- a/KFParticle/KFPInputData.h +++ b/KFParticle/KFPInputData.h @@ -91,8 +91,9 @@ class KFPInputData ** \param[in] prefix - string with the name of the input file **/ std::ifstream ifile(prefix.data()); - if (!ifile.is_open()) + if (!ifile.is_open()) { return 0; + } int nSets; ifile >> fBz; ifile >> nSets; @@ -154,11 +155,12 @@ class KFPInputData ifile >> nPV; fPV.resize(nPV); for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { - for (int iP = 0; iP < 3; iP++) + for (int iP = 0; iP < 3; iP++) { ifile >> fPV[iPV].Parameter(iP); - - for (int iC = 0; iC < 6; iC++) + } + for (int iC = 0; iC < 6; iC++) { ifile >> fPV[iPV].Covariance(iC); + } } ifile.close(); @@ -172,12 +174,14 @@ class KFPInputData ** \param[out] dataSize - size of the stored memory in "int" (or bloks of 4 bytes, or 32 bits) **/ dataSize = NInputSets + 1 + 1; //sizes of the track vectors and pv vector, and field - for (int iSet = 0; iSet < NInputSets; iSet++) + for (int iSet = 0; iSet < NInputSets; iSet++) { dataSize += fTracks[iSet].DataSize(); + } dataSize += fPV.size() * 9; - for (int iSet = 0; iSet < NInputSets; iSet++) + for (int iSet = 0; iSet < NInputSets; iSet++) { data[iSet] = fTracks[iSet].Size(); + } data[NInputSets] = fPV.size(); float& field = reinterpret_cast(data[NInputSets + 1]); @@ -185,8 +189,9 @@ class KFPInputData int offset = NInputSets + 2; - for (int iSet = 0; iSet < NInputSets; iSet++) + for (int iSet = 0; iSet < NInputSets; iSet++) { fTracks[iSet].SetDataToVector(data, offset); + } for (int iP = 0; iP < 3; iP++) { for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { @@ -241,28 +246,33 @@ class KFPInputData void Print() { /**Prints all fields of the current object.*/ - for (int iSet = 0; iSet < NInputSets; iSet++) + for (int iSet = 0; iSet < NInputSets; iSet++) { fTracks[iSet].Print(); + } std::cout << "N PV: " << fPV.size() << std::endl; std::cout << "X: "; - for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) + for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { std::cout << fPV[iPV].X() << " "; + } std::cout << std::endl; std::cout << "Y: "; - for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) + for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { std::cout << fPV[iPV].Y() << " "; + } std::cout << std::endl; std::cout << "Z: "; - for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) + for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { std::cout << fPV[iPV].Z() << " "; + } std::cout << std::endl; std::cout << "Cov matrix: " << std::endl; for (int iC = 0; iC < 6; iC++) { std::cout << " iC " << iC << ": "; - for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) + for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { std::cout << fPV[iPV].Covariance(iC) << " "; + } std::cout << std::endl; } @@ -276,8 +286,9 @@ class KFPInputData const KFPInputData& operator=(const KFPInputData& data) { /** Copies input data from object "data" to the current object. Returns the current object. \param[in] data - input data*/ - for (int i = 0; i < NInputSets; i++) + for (int i = 0; i < NInputSets; i++) { fTracks[i] = data.fTracks[i]; + } fPV = data.fPV; fBz = data.fBz; @@ -286,8 +297,9 @@ class KFPInputData KFPInputData(const KFPInputData& data) : fPV(0), fBz(0.f) { /** Copies input data from object "data" to the current object. \param[in] data - input data */ - for (int i = 0; i < NInputSets; i++) + for (int i = 0; i < NInputSets; i++) { fTracks[i] = data.fTracks[i]; + } fPV = data.fPV; fBz = data.fBz; } @@ -323,8 +335,9 @@ struct KFPInputDataArray { KFPInputDataArray() : fInput(0){}; virtual ~KFPInputDataArray() { - if (fInput) + if (fInput) { delete[] fInput; + } } KFPInputData* fInput; ///< Pointer to the array of the input data objects. diff --git a/KFParticle/KFPTrackVector.cxx b/KFParticle/KFPTrackVector.cxx index 183e40c..e5aa67d 100644 --- a/KFParticle/KFPTrackVector.cxx +++ b/KFParticle/KFPTrackVector.cxx @@ -39,14 +39,16 @@ void KFPTrackVector::SetParameter(const float_v& value, int iP, int iTr) // (reinterpret_cast(fP[iP][iTr])).gather(reinterpret_cast(&value), index, float_m(index<(Size() - iTr))); // } - if ((iTr + float_vLen) < Size()) + if (iTr + float_vLen < Size()) { reinterpret_cast(fP[iP][iTr]) = value; - else + } else { for (int i = 0; i < float_v::Size; i++) { - if (iTr + i >= Size()) + if (iTr + i >= Size()) { continue; + } fP[iP][iTr + i] = value[i]; } + } } void KFPTrackVector::SetCovariance(const float_v& value, int iC, int iTr) { @@ -65,14 +67,16 @@ void KFPTrackVector::SetCovariance(const float_v& value, int iC, int iTr) // (reinterpret_cast(fC[iC][iTr])).gather(reinterpret_cast(&value), index, float_m(index<(Size() - iTr))); // } - if ((iTr + float_vLen) < Size()) + if (iTr + float_vLen < Size()) { reinterpret_cast(fC[iC][iTr]) = value; - else + } else { for (int i = 0; i < float_v::Size; i++) { - if (iTr + i >= Size()) + if (iTr + i >= Size()) { continue; + } fC[iC][iTr + i] = value[i]; } + } } void KFPTrackVector::Resize(const int n) @@ -80,13 +84,16 @@ void KFPTrackVector::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 < 6; i++) + for (int i = 0; i < 6; i++) { fP[i].resize(n); - for (int i = 0; i < 21; i++) + } + for (int i = 0; i < 21; i++) { fC[i].resize(n); + } #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { fField[i].resize(n); + } #endif // fChi2.resize(n); // fNDF.resize(n); @@ -106,13 +113,16 @@ void KFPTrackVector::Set(KFPTrackVector& v, int vSize, int offset) ** \param[in] offset - offset position in the current object, starting from which input tracks will be stored **/ for (int iV = 0; iV < vSize; iV++) { - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { fP[i][offset + iV] = v.fP[i][iV]; - for (int i = 0; i < 21; i++) + } + for (int i = 0; i < 21; i++) { fC[i][offset + iV] = v.fC[i][iV]; + } #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { fField[i][offset + iV] = v.fField[i][iV]; + } #endif // fChi2[offset+iV] = v.fChi2[iV]; // fNDF[offset+iV] = v.fNDF[iV]; @@ -131,8 +141,9 @@ void KFPTrackVector::SetTracks(const KFPTrackVector& track, const kfvector_uint& ** \param[in] trackIndex - indices of tracks in a vector "track", which should be stored to the current object ** \param[in] nIndexes - number of tracks to be copied, defines the new size of the current object **/ - if (nIndexes == 0) + if (nIndexes == 0) { return; + } Resize(nIndexes); @@ -235,16 +246,18 @@ void KFPTrackVector::GetTrack(KFPTrack& track, const int n) ** \param[in] n - index of the track to be copied **/ track.SetParameters(fP[0][n], fP[1][n], fP[2][n], fP[3][n], fP[4][n], fP[5][n]); - for (int i = 0; i < 21; i++) + for (int i = 0; i < 21; i++) { track.SetCovariance(i, fC[i][n]); + } // track.SetChi2(fChi2[n]); // track.SetNDF(fNDF[n]); track.SetId(fId[n]); track.SetCharge(fQ[n]); #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { track.SetFieldCoeff(fField[i][n], i); + } #endif } @@ -286,8 +299,9 @@ void KFPTrackVector::RotateXY(float_v alpha, int firstElement) py = pxInit * cA - pyInit * sA; float_v cov[21]; - for (int iC = 0; iC < 21; iC++) + for (int iC = 0; iC < 21; iC++) { cov[iC] = reinterpret_cast(fC[iC][firstElement]); + } reinterpret_cast(fC[0][firstElement]) = cA * cA * cov[2] + 2 * cA * cov[1] * sA + cov[0] * sA * sA; @@ -322,12 +336,14 @@ void KFPTrackVector::PrintTrack(int n) /** Prints parameters of the track with index "n". ** \param[in] n - index of track to be printed **/ - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { std::cout << fP[i][n] << " "; + } std::cout << std::endl; - for (int i = 0; i < 21; i++) + for (int i = 0; i < 21; i++) { std::cout << fC[i][n] << " "; + } std::cout << std::endl; std::cout << fId[n] << " " << fPDG[n] << " " << fQ[n] << " " << fPVIndex[n] << " " << fNPixelHits[n] << std::endl; @@ -338,56 +354,65 @@ void KFPTrackVector::Print() /** Prints all field of the current object. **/ std::cout << "NTracks " << Size() << std::endl; - if (Size() == 0) + if (Size() == 0) { return; + } std::cout << "Parameters: " << std::endl; for (int iP = 0; iP < 6; iP++) { std::cout << " iP " << iP << ": "; - for (int iTr = 0; iTr < Size(); 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 < 21; iC++) { std::cout << " iC " << iC << ": "; - for (int iTr = 0; iTr < Size(); 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++) + for (int iTr = 0; iTr < Size(); iTr++) { std::cout << Id()[iTr] << " "; + } std::cout << std::endl; std::cout << "Pdg: " << std::endl; - for (int iTr = 0; iTr < Size(); iTr++) + for (int iTr = 0; iTr < Size(); iTr++) { std::cout << PDG()[iTr] << " "; + } std::cout << std::endl; std::cout << "Q: " << std::endl; - for (int iTr = 0; iTr < Size(); iTr++) + for (int iTr = 0; iTr < Size(); iTr++) { std::cout << Q()[iTr] << " "; + } std::cout << std::endl; std::cout << "PV index: " << std::endl; - for (int iTr = 0; iTr < Size(); iTr++) + for (int iTr = 0; iTr < Size(); iTr++) { std::cout << PVIndex()[iTr] << " "; + } std::cout << std::endl; std::cout << "fNPixelHits: " << std::endl; - for (int iTr = 0; iTr < Size(); iTr++) + for (int iTr = 0; iTr < Size(); iTr++) { std::cout << NPixelHits()[iTr] << " "; + } std::cout << std::endl; #ifdef NonhomogeneousField std::cout << "Field: " << std::endl; for (int iF = 0; iF < 6; iF++) { std::cout << " iF " << iF << ": "; - for (int iTr = 0; iTr < Size(); iTr++) + for (int iTr = 0; iTr < Size(); iTr++) { std::cout << FieldCoefficient(iF)[iTr] << " "; + } std::cout << std::endl; } #endif diff --git a/KFParticle/KFPTrackVector.h b/KFParticle/KFPTrackVector.h index 6b2c4cc..e8ad5f8 100644 --- a/KFParticle/KFPTrackVector.h +++ b/KFParticle/KFPTrackVector.h @@ -246,43 +246,51 @@ class KFPTrackVector for (int i = 0; i < 6; i++) { fP[i].resize(localSize); - for (int n = 0; n < localSize; n++) + for (int n = 0; n < localSize; n++) { fP[i][n] = track.fP[i][n]; + } } for (int i = 0; i < 21; i++) { fC[i].resize(localSize); - for (int n = 0; n < localSize; n++) + for (int n = 0; n < localSize; n++) { fC[i][n] = track.fC[i][n]; + } } #ifdef NonhomogeneousField for (int i = 0; i < 10; i++) { fField[i].resize(localSize); - for (int n = 0; n < localSize; n++) + for (int n = 0; n < localSize; n++) { fField[i][n] = track.fField[i][n]; + } } #endif fId.resize(localSize); - for (int n = 0; n < localSize; n++) + for (int n = 0; n < localSize; n++) { fId[n] = track.fId[n]; + } fPDG.resize(localSize); - for (int n = 0; n < localSize; n++) + for (int n = 0; n < localSize; n++) { fPDG[n] = track.fPDG[n]; + } fQ.resize(localSize); - for (int n = 0; n < localSize; n++) + for (int n = 0; n < localSize; n++) { fQ[n] = track.fQ[n]; + } fPVIndex.resize(localSize); - for (int n = 0; n < localSize; n++) + for (int n = 0; n < localSize; n++) { fPVIndex[n] = track.fPVIndex[n]; + } fNPixelHits.resize(localSize); - for (int n = 0; n < localSize; n++) + for (int n = 0; n < localSize; n++) { fNPixelHits[n] = track.fNPixelHits[n]; + } fNE = track.fNE; fNMu = track.fNMu; diff --git a/KFParticle/KFParticle.cxx b/KFParticle/KFParticle.cxx index f7569ac..1c04fff 100644 --- a/KFParticle/KFParticle.cxx +++ b/KFParticle/KFParticle.cxx @@ -63,8 +63,9 @@ void KFParticle::Create(const float Param[], const float Cov[], Int_t Charge, fl ** \param[in] mass - the mass hypothesis **/ float C[21]; - for (int i = 0; i < 21; i++) + for (int i = 0; i < 21; i++) { C[i] = Cov[i]; + } KFParticleBase::Initialize(Param, C, Charge, mass); } @@ -86,11 +87,13 @@ void KFParticle::Create(const Double_t Param[], const Double_t Cov[], Int_t Char ** \param[in] mass - the mass hypothesis **/ float P[6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { P[i] = Param[i]; + } float C[21]; - for (int i = 0; i < 21; i++) + for (int i = 0; i < 21; i++) { C[i] = Cov[i]; + } KFParticleBase::Initialize(P, C, Charge, mass); } @@ -114,8 +117,9 @@ KFParticle::KFParticle(const KFPTrack& track, const int PID) : KFParticleBase() fNDF = track.GetNDF(); SetPDG(PID); #ifdef NonhomogeneousField - for (int iF = 0; iF < 10; iF++) + for (int iF = 0; iF < 10; iF++) { SetFieldCoeff(track.GetFieldCoeff()[iF], iF); + } #endif } @@ -309,10 +313,11 @@ float KFParticle::GetDeviationFromVertexXY(const float vtx[], const float Cv[]) float val, err; Bool_t problem = GetDistanceFromVertexXY(vtx, Cv, val, err); - if (problem || err < 1.e-20) + if (problem || err < 1.e-20) { return 1.e4; - else + } else { return val / err; + } } float KFParticle::GetDeviationFromVertexXY(const KFParticle& Vtx) const @@ -358,12 +363,14 @@ void KFParticle::GetParametersAtPoint(const float* point, const float* pointCov, Transport(dS, dsdr, m, mV, dsdp, F, F1); float V1Tmp[36]; - for (int i = 0; i < 36; i++) + for (int i = 0; i < 36; i++) { V1Tmp[i] = 0.f; + } KFParticle::MultQSQt(F1, pointCov, V1Tmp, 6); - for (int iC = 0; iC < 21; iC++) + for (int iC = 0; iC < 21; iC++) { mV[iC] += V1Tmp[iC]; + } } float KFParticle::GetAngle(const KFParticle& p) const @@ -382,12 +389,14 @@ float KFParticle::GetAngle(const KFParticle& p) const float n1 = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4] + mP1[5] * mP1[5]); n *= n1; float a = 0; - if (n > 1.e-8) + if (n > 1.e-8) { a = (mP[3] * mP1[3] + mP[4] * mP1[4] + mP[5] * mP1[5]) / n; - if (fabs(a) < 1.) + } + if (fabs(a) < 1.) { a = acos(a); - else + } else { a = (a >= 0) ? 0 : 3.14; + } return a; } @@ -407,12 +416,14 @@ float KFParticle::GetAngleXY(const KFParticle& p) const float n1 = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4]); n *= n1; float a = 0; - if (n > 1.e-8) + if (n > 1.e-8) { a = (mP[3] * mP1[3] + mP[4] * mP1[4]) / n; - if (fabs(a) < 1.) + } + if (fabs(a) < 1.) { a = acos(a); - else + } else { a = (a >= 0) ? 0 : 3.14; + } return a; } @@ -434,12 +445,14 @@ float KFParticle::GetAngleRZ(const KFParticle& p) const float n1 = sqrt(n1r * n1r + mP1[5] * mP1[5]); n *= n1; float a = 0; - if (n > 1.e-8) + if (n > 1.e-8) { a = (nr * n1r + mP[5] * mP1[5]) / n; - if (fabs(a) < 1.) + } + if (fabs(a) < 1.) { a = acos(a); - else + } else { a = (a >= 0) ? 0 : 3.14; + } return a; } diff --git a/KFParticle/KFParticle.h b/KFParticle/KFParticle.h index 74f8b01..48ad42c 100644 --- a/KFParticle/KFParticle.h +++ b/KFParticle/KFParticle.h @@ -460,91 +460,61 @@ inline float KFParticle::GetCovariance(int i, int j) const inline float KFParticle::GetP() const { float par, err; - if (KFParticleBase::GetMomentum(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetMomentum(par, err)) ? 0.f : par; } inline float KFParticle::GetPt() const { float par, err; - if (KFParticleBase::GetPt(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetPt(par, err)) ? 0.f : par; } inline float KFParticle::GetEta() const { float par, err; - if (KFParticleBase::GetEta(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetEta(par, err)) ? 0.f : par; } inline float KFParticle::GetPhi() const { float par, err; - if (KFParticleBase::GetPhi(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetPhi(par, err)) ? 0.f : par; } inline float KFParticle::GetMomentum() const { float par, err; - if (KFParticleBase::GetMomentum(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetMomentum(par, err)) ? 0.f : par; } inline float KFParticle::GetMass() const { float par, err; - if (KFParticleBase::GetMass(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetMass(par, err)) ? 0.f : par; } inline float KFParticle::GetDecayLength() const { float par, err; - if (KFParticleBase::GetDecayLength(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetDecayLength(par, err)) ? 0.f : par; } inline float KFParticle::GetDecayLengthXY() const { float par, err; - if (KFParticleBase::GetDecayLengthXY(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetDecayLengthXY(par, err)) ?: 0.f : par; } inline float KFParticle::GetLifeTime() const { float par, err; - if (KFParticleBase::GetLifeTime(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetLifeTime(par, err)) ? 0.f : par; } inline float KFParticle::GetR() const { float par, err; - if (KFParticleBase::GetR(par, err)) - return 0; - else - return par; + return (KFParticleBase::GetR(par, err)) ? 0.f : par; } inline float KFParticle::GetErrX() const @@ -590,91 +560,61 @@ inline float KFParticle::GetErrS() const inline float KFParticle::GetErrP() const { float par, err; - if (KFParticleBase::GetMomentum(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetMomentum(par, err)) ? 1.e10 : err; } inline float KFParticle::GetErrPt() const { float par, err; - if (KFParticleBase::GetPt(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetPt(par, err)) ? 1.e10 : err; } inline float KFParticle::GetErrEta() const { float par, err; - if (KFParticleBase::GetEta(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetEta(par, err)) ? 1.e10 : err; } inline float KFParticle::GetErrPhi() const { float par, err; - if (KFParticleBase::GetPhi(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetPhi(par, err)) ? 1.e10 : err; } inline float KFParticle::GetErrMomentum() const { float par, err; - if (KFParticleBase::GetMomentum(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetMomentum(par, err)) ? 1.e10 : err; } inline float KFParticle::GetErrMass() const { float par, err; - if (KFParticleBase::GetMass(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetMass(par, err)) ? 1.e10 : err; } inline float KFParticle::GetErrDecayLength() const { float par, err; - if (KFParticleBase::GetDecayLength(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetDecayLength(par, err)) ? 1.e10 : err; } inline float KFParticle::GetErrDecayLengthXY() const { float par, err; - if (KFParticleBase::GetDecayLengthXY(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetDecayLengthXY(par, err)) ? 1.e10 : err; } inline float KFParticle::GetErrLifeTime() const { float par, err; - if (KFParticleBase::GetLifeTime(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetLifeTime(par, err)) ? 1.e10 : err; } inline float KFParticle::GetErrR() const { float par, err; - if (KFParticleBase::GetR(par, err)) - return 1.e10; - else - return err; + return (KFParticleBase::GetR(par, err)) ? 1.e10 : err; } inline int KFParticle::GetP(float& P, float& SigmaP) const @@ -854,19 +794,20 @@ inline float* KFParticle::CovarianceMatrix() inline void KFParticle::operator+=(const KFParticle& Daughter) { - /** Operator to add daughter to the current particle. Calls AddDaughter() function. +/** Operator to add daughter to the current particle. Calls AddDaughter() function. ** \param[in] Daughter - the daughter particle **/ #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { SetFieldCoeff(Daughter.GetFieldCoeff()[i], i); + } #endif KFParticleBase::operator+=(Daughter); } inline void KFParticle::AddDaughter(const KFParticle& Daughter) { - /** Adds daughter to the current particle. Depending on the selected construction method uses: \n +/** Adds daughter to the current particle. Depending on the selected construction method uses: \n ** 1) Either simplifyed fast mathematics which consideres momentum and energy as ** independent variables and thus ignores constraint on the fixed mass (fConstructMethod = 0). ** In this case the mass of the daughter particle can be corrupted when the constructed vertex @@ -879,8 +820,9 @@ inline void KFParticle::AddDaughter(const KFParticle& Daughter) ** \param[in] Daughter - the daughter particle **/ #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { SetFieldCoeff(Daughter.GetFieldCoeff()[i], i); + } #endif KFParticleBase::AddDaughter(Daughter); } @@ -888,7 +830,7 @@ inline void KFParticle::AddDaughter(const KFParticle& Daughter) inline void KFParticle::Construct(const KFParticle* vDaughters[], int nDaughters, const KFParticle* ProdVtx, float Mass) { - /** Constructs a short-lived particle from a set of daughter particles:\n +/** Constructs a short-lived particle from a set of daughter particles:\n ** 1) all parameters of the "this" objects are initialised;\n ** 2) daughters are added one after another;\n ** 3) if Parent pointer is not null, the production vertex is set to it;\n @@ -899,8 +841,9 @@ inline void KFParticle::Construct(const KFParticle* vDaughters[], int nDaughters ** \param[in] Mass - optional mass hypothesis **/ #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { SetFieldCoeff(vDaughters[0]->GetFieldCoeff()[i], i); + } #endif KFParticleBase::Construct((const KFParticleBase**)vDaughters, nDaughters, (const KFParticleBase*)ProdVtx, Mass); @@ -937,7 +880,7 @@ inline void KFParticle::TransportToParticle(const KFParticle& p) inline float KFParticle::GetDStoPoint(const float xyz[], float* dsdr) const { - /** Returns dS = l/p parameter, where \n +/** Returns dS = l/p parameter, where \n ** 1) l - signed distance to the DCA point with the input xyz point;\n ** 2) p - momentum of the particle; \n ** Also calculates partial derivatives dsdr of the parameter dS over the state vector of the current particle. @@ -998,7 +941,7 @@ inline void KFParticle::GetFieldValue(const float xyz[], float B[]) const inline void KFParticle::GetDStoParticle(const KFParticleBase& p, float dS[2], float dsdr[4][6]) const { - /** Calculates dS = l/p parameters for two particles, where \n +/** Calculates dS = l/p parameters for two particles, where \n ** 1) l - signed distance to the DCA point with the other particle;\n ** 2) p - momentum of the particle \n ** dS[0] is the transport parameter for the current particle, dS[1] - for the particle "p". @@ -1024,7 +967,7 @@ inline void KFParticle::GetDStoParticle(const KFParticleBase& p, float dS[2], fl inline void KFParticle::Transport(float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1) const { - /** Transports the parameters and their covariance matrix of the current particle +/** Transports the parameters and their covariance matrix of the current particle ** on a length defined by the transport parameter dS = l/p, where l is the signed distance and p is ** the momentum of the current particle. If "HomogeneousField" is defined KFParticleBase::TransportBz() ** is called, if "NonhomogeneousField" - KFParticleBase::TransportCBM(). diff --git a/KFParticle/KFParticleBase.cxx b/KFParticle/KFParticleBase.cxx index 8059c55..8d9e53d 100644 --- a/KFParticle/KFParticleBase.cxx +++ b/KFParticle/KFParticleBase.cxx @@ -69,47 +69,59 @@ std::ostream& operator<<(std::ostream& os, const KFParticleBase& particle) static const Char_t* vn[14] = {"x", "y", "z", "px", "py", "pz", "E", "S", "M", "t", "p", "Q", "Chi2", "NDF"}; os << Form("p(%4i,%4i,%4i)", particle.Id(), particle.GetParentID(), particle.IdParentMcVx()); for (Int_t i = 0; i < 8; i++) { - if (i == 6) - continue; // E - if (i == 7 && particle.GetParameter(i) <= 0.0) - continue; // S - if (particle.GetParameter(i) == 0. && particle.GetCovariance(i, i) == 0) + if (i == 6) { // E continue; - if (particle.GetCovariance(i, i) > 0) + } + if (i == 7 && particle.GetParameter(i) <= 0.0) { // S + continue; + } + if (particle.GetParameter(i) == 0. && particle.GetCovariance(i, i) == 0) { + continue; + } + if (particle.GetCovariance(i, i) > 0) { os << Form(" %s:%8.3f+/-%6.3f", vn[i], particle.GetParameter(i), TMath::Sqrt(particle.GetCovariance(i, i))); - else + } else { os << Form(" %s:%8.3f", vn[i], particle.GetParameter(i)); + } } float Mtp[3] = {0.f, 0.f, 0.f}, MtpErr[3] = {0.f, 0.f, 0.f}; particle.GetMass(Mtp[0], MtpErr[0]); - if (MtpErr[0] < 1e-7 || MtpErr[0] > 1e10) + if (MtpErr[0] < 1e-7 || MtpErr[0] > 1e10) { MtpErr[0] = -13; + } particle.GetLifeTime(Mtp[1], MtpErr[1]); - if (MtpErr[1] <= 0 || MtpErr[1] > 1e10) + if (MtpErr[1] <= 0 || MtpErr[1] > 1e10) { MtpErr[1] = -13; + } particle.GetMomentum(Mtp[2], MtpErr[2]); - if (MtpErr[2] <= 0 || MtpErr[2] > 1e10) + if (MtpErr[2] <= 0 || MtpErr[2] > 1e10) { MtpErr[2] = -13; + } for (Int_t i = 8; i < 11; i++) { - if (i == 9 && Mtp[i - 8] <= 0.0) + if (i == 9 && Mtp[i - 8] <= 0.0) { continue; // t - if (MtpErr[i - 8] > 0 && MtpErr[i - 8] < 9e2) + } + if (MtpErr[i - 8] > 0 && MtpErr[i - 8] < 9e2) { os << Form(" %s:%8.3f+/-%7.3f", vn[i], Mtp[i - 8], MtpErr[i - 8]); - else + } else { os << Form(" %s:%8.3f", vn[i], Mtp[i - 8]); + } } os << Form(" pdg:%5i Q:%2i chi2/NDF :%8.2f/%2i", particle.GetPDG(), particle.GetQ(), particle.GetChi2(), particle.GetNDF()); - if (particle.IdTruth()) + if (particle.IdTruth()) { os << Form(" IdT:%4i/%3i", particle.IdTruth(), particle.QaTruth()); + } int nd = particle.NDaughters(); if (nd > 1) { os << " ND: " << nd << ":"; - if (nd > 3) + if (nd > 3) { nd = 3; + } for (int d = 0; d < nd; d++) { os << particle.DaughterIds()[d]; - if (d < nd - 1) + if (d < nd - 1) { os << ","; + } } } return os; @@ -148,10 +160,12 @@ void KFParticleBase::Initialize(const float Param[], const float Cov[], Int_t Ch ** \param[in] mass - the mass hypothesis **/ - for (Int_t i = 0; i < 6; i++) + for (Int_t i = 0; i < 6; i++) { fP[i] = Param[i]; - for (Int_t i = 0; i < 21; i++) + } + for (Int_t i = 0; i < 21; i++) { fC[i] = Cov[i]; + } float energy = sqrt(Mass * Mass + fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]); fP[6] = energy; @@ -175,8 +189,9 @@ void KFParticleBase::Initialize(const float Param[], const float Cov[], Int_t Ch fC[25] = h0 * fC[13] + h1 * fC[14] + h2 * fC[19]; fC[26] = h0 * fC[18] + h1 * fC[19] + h2 * fC[20]; fC[27] = (h0 * h0 * fC[9] + h1 * h1 * fC[14] + h2 * h2 * fC[20] + 2 * (h0 * h1 * fC[13] + h0 * h2 * fC[18] + h1 * h2 * fC[19])); - for (Int_t i = 28; i < 36; i++) + for (Int_t i = 28; i < 36; i++) { fC[i] = 0; + } fC[35] = 1.; SumDaughterMass = Mass; @@ -193,10 +208,12 @@ void KFParticleBase::Initialize() ** 5) NDF = -3, since 3 parameters should be fitted: X, Y, Z. **/ - for (Int_t i = 0; i < 8; i++) + for (Int_t i = 0; i < 8; i++) { fP[i] = 0; - for (Int_t i = 0; i < 36; ++i) + } + for (Int_t i = 0; i < 36; ++i) { fC[i] = 0.; + } fC[0] = fC[2] = fC[5] = 100.; fC[35] = 1.; fNDF = -3; @@ -228,7 +245,7 @@ Int_t KFParticleBase::GetMomentum(float& p, float& error) const error = sqrt(error) / p; return 0; } - error = 1.e8; + error = 1.e8f; return 1; } @@ -250,7 +267,7 @@ Int_t KFParticleBase::GetPt(float& pt, float& error) const error = sqrt(error) / pt; return 0; } - error = 1.e10; + error = 1.e10f; return 1; } @@ -272,8 +289,9 @@ Int_t KFParticleBase::GetEta(float& eta, float& error) const eta = 1.e10; if (b > 1.e-8) { float c = a / b; - if (c > 1.e-8) + if (c > 1.e-8) { eta = 0.5 * log(c); + } } float h3 = -px * pz; float h4 = -py * pz; @@ -476,15 +494,17 @@ bool KFParticleBase::GetMeasurement(const KFParticleBase& daughter, float m[], f } GetDStoParticle(daughter, ds, dsdr); - if (fabs(ds[0] * fP[5]) > 1000.f || fabs(ds[1] * daughter.fP[5]) > 1000.f) + if (fabs(ds[0] * fP[5]) > 1000.f || fabs(ds[1] * daughter.fP[5]) > 1000.f) { return 0; + } float V0Tmp[36] = {0.}; float V1Tmp[36] = {0.}; float C[36]; - for (int iC = 0; iC < 36; iC++) + for (int iC = 0; iC < 36; iC++) { C[iC] = fC[iC]; + } Transport(ds[0], dsdr[0], fP, fC, dsdr[1], F1, F2); daughter.Transport(ds[1], dsdr[3], m, V, dsdr[2], F4, F3); @@ -498,36 +518,40 @@ bool KFParticleBase::GetMeasurement(const KFParticleBase& daughter, float m[], f } float C1F1T[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { C1F1T[i][j] = 0; for (int k = 0; k < 6; k++) { C1F1T[i][j] += C[IJ(i, k)] * F1[j * 6 + k]; } } + } float F3C1F1T[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { F3C1F1T[i][j] = 0; for (int k = 0; k < 6; k++) { F3C1F1T[i][j] += F3[i * 6 + k] * C1F1T[k][j]; } } + } float C2F2T[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { C2F2T[i][j] = 0; for (int k = 0; k < 6; k++) { C2F2T[i][j] += daughter.fC[IJ(i, k)] * F2[j * 6 + k]; } } - for (int i = 0; i < 3; i++) + } + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { D[i][j] = F3C1F1T[i][j]; for (int k = 0; k < 6; k++) { D[i][j] += F4[i * 6 + k] * C2F2T[k][j]; } } + } } else { float dsdr[6]; float dS = daughter.GetDStoPoint(fP, dsdr); @@ -548,31 +572,31 @@ bool KFParticleBase::GetMeasurement(const KFParticleBase& daughter, float m[], f // V[iC] += V1Tmp[iC]; float VFT[3][6]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 6; j++) { VFT[i][j] = 0; for (int k = 0; k < 3; k++) { VFT[i][j] += fC[IJ(i, k)] * F1[j * 6 + k]; } } - + } float FVFT[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { FVFT[i][j] = 0; for (int k = 0; k < 3; k++) { FVFT[i][j] += F1[i * 6 + k] * VFT[k][j]; } } - - for (int i = 0; i < 3; i++) + } + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { D[i][j] = 0; for (int k = 0; k < 3; k++) { D[i][j] += fC[IJ(j, k)] * F1[i * 6 + k]; } } - + } V[0] += FVFT[0][0]; V[1] += FVFT[1][0]; V[2] += FVFT[1][1]; @@ -618,20 +642,23 @@ void KFParticleBase::AddDaughter(const KFParticleBase& Daughter) if (fNDF < -1) { // first daughter -> just copy fNDF = -1; fQ = Daughter.GetQ(); - for (Int_t i = 0; i < 7; i++) + for (Int_t i = 0; i < 7; i++) { fP[i] = Daughter.fP[i]; - for (Int_t i = 0; i < 28; i++) + } + for (Int_t i = 0; i < 28; i++) { fC[i] = Daughter.fC[i]; + } fSFromDecay = 0; fMassHypo = Daughter.fMassHypo; SumDaughterMass = Daughter.SumDaughterMass; return; } - if (static_cast(fConstructMethod) == 0) + if (static_cast(fConstructMethod) == 0) { AddDaughterWithEnergyFit(Daughter); - else if (static_cast(fConstructMethod) == 2) + } else if (static_cast(fConstructMethod) == 2) { AddDaughterWithEnergyFitMC(Daughter); + } SumDaughterMass += Daughter.SumDaughterMass; fMassHypo = -1; @@ -654,8 +681,9 @@ void KFParticleBase::AddDaughterWithEnergyFit(const KFParticleBase& Daughter) float m[8], mV[36]; float D[3][3]; - if (!GetMeasurement(Daughter, m, mV, D)) + if (!GetMeasurement(Daughter, m, mV, D)) { return; + } float mS[6] = {fC[0] + mV[0], fC[1] + mV[1], fC[2] + mV[2], @@ -668,17 +696,20 @@ void KFParticleBase::AddDaughterWithEnergyFit(const KFParticleBase& Daughter) float zeta[3] = {m[0] - fP[0], m[1] - fP[1], m[2] - fP[2]}; float dChi2 = (mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]; - if (dChi2 > 1e9) + if (dChi2 > 1e9) { return; + } // if(fNDF > 100 && dChi2 > 9) return; float K[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { K[i][j] = 0; - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; + } } + } //* CHt = CH' - D' float mCHt0[7], mCHt1[7], mCHt2[7]; @@ -735,8 +766,9 @@ void KFParticleBase::AddDaughterWithEnergyFit(const KFParticleBase& Daughter) //* New estimation of the vertex position r += K*zeta - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + } //* New covariance matrix C -= K*(mCH')' @@ -748,28 +780,31 @@ void KFParticleBase::AddDaughterWithEnergyFit(const KFParticleBase& Daughter) float K2[3][3]; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { K2[i][j] = -K[j][i]; + } K2[i][i] += 1; } float A[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { A[i][j] = 0; for (int k = 0; k < 3; k++) { A[i][j] += D[i][k] * K2[k][j]; } } + } double M[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { M[i][j] = 0; for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } + } fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; @@ -797,8 +832,9 @@ void KFParticleBase::SubtractDaughter(const KFParticleBase& Daughter) float m[8], mV[36]; float D[3][3]; - if (!GetMeasurement(Daughter, m, mV, D)) + if (!GetMeasurement(Daughter, m, mV, D)) { return; + } float mS[6] = {fC[0] + mV[0], fC[1] + mV[1], fC[2] + mV[2], @@ -813,12 +849,14 @@ void KFParticleBase::SubtractDaughter(const KFParticleBase& Daughter) float dChi2 = (mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]; float K[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { K[i][j] = 0; - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; + } } + } //* CHt = CH' - D' float mCHt0[7], mCHt1[7], mCHt2[7]; @@ -875,8 +913,9 @@ void KFParticleBase::SubtractDaughter(const KFParticleBase& Daughter) //* New estimation of the vertex position r += K*zeta - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + } //* New covariance matrix C -= K*(mCH')' @@ -888,28 +927,31 @@ void KFParticleBase::SubtractDaughter(const KFParticleBase& Daughter) float K2[3][3]; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { K2[i][j] = -K[j][i]; + } K2[i][i] += 1; } float A[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { A[i][j] = 0; for (int k = 0; k < 3; k++) { A[i][j] += D[i][k] * K2[k][j]; } } + } double M[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { M[i][j] = 0; for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } + } fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; @@ -952,12 +994,14 @@ void KFParticleBase::AddDaughterWithEnergyFitMC(const KFParticleBase& Daughter) float zeta[3] = {m[0] - fP[0], m[1] - fP[1], m[2] - fP[2]}; float K[3][6]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { K[i][j] = 0; - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; + } } + } //* CHt = CH' @@ -1033,11 +1077,13 @@ void KFParticleBase::AddDaughterWithEnergyFitMC(const KFParticleBase& Daughter) km2[i] = mVHt0[i] * mS[3] + mVHt1[i] * mS[4] + mVHt2[i] * mS[5]; } - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + } - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { m[i] = m[i] - km0[i] * zeta[0] - km1[i] * zeta[1] - km2[i] * zeta[2]; + } for (Int_t i = 0, k = 0; i < 7; ++i) { for (Int_t j = 0; j <= i; ++j, ++k) { @@ -1069,20 +1115,24 @@ void KFParticleBase::AddDaughterWithEnergyFitMC(const KFParticleBase& Daughter) float mMassParticle = fP[6] * fP[6] - (fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]); float mMassDaughter = m[6] * m[6] - (m[3] * m[3] + m[4] * m[4] + m[5] * m[5]); - if (mMassParticle > 0) + if (mMassParticle > 0) { mMassParticle = sqrt(mMassParticle); - if (mMassDaughter > 0) + } + if (mMassDaughter > 0) { mMassDaughter = sqrt(mMassDaughter); + } - if (fMassHypo > -0.5) + if (fMassHypo > -0.5) { SetMassConstraint(fP, fC, mJ1, fMassHypo); - else if ((mMassParticle < SumDaughterMass) || (fP[6] < 0)) + } else if ((mMassParticle < SumDaughterMass) || (fP[6] < 0)) { SetMassConstraint(fP, fC, mJ1, SumDaughterMass); + } - if (Daughter.fMassHypo > -0.5) + if (Daughter.fMassHypo > -0.5) { SetMassConstraint(m, mV, mJ2, Daughter.fMassHypo); - else if ((mMassDaughter < Daughter.SumDaughterMass) || (m[6] < 0)) + } else if ((mMassDaughter < Daughter.SumDaughterMass) || (m[6] < 0)) { SetMassConstraint(m, mV, mJ2, Daughter.SumDaughterMass); + } float mDJ[7][7]; @@ -1148,28 +1198,31 @@ void KFParticleBase::AddDaughterWithEnergyFitMC(const KFParticleBase& Daughter) float K2[3][3]; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { K2[i][j] = -K[j][i]; + } K2[i][i] += 1; } float A[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { A[i][j] = 0; for (int k = 0; k < 3; k++) { A[i][j] += D[i][k] * K2[k][j]; } } + } double M[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { M[i][j] = 0; for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } + } fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; @@ -1203,10 +1256,11 @@ void KFParticleBase::SetProductionVertex(const KFParticleBase& Vtx) float decayPointCov[6] = {fC[0], fC[1], fC[2], fC[3], fC[4], fC[5]}; float D[6][6]; - for (int iD1 = 0; iD1 < 6; iD1++) - for (int iD2 = 0; iD2 < 6; iD2++) + for (int iD1 = 0; iD1 < 6; iD1++) { + for (int iD2 = 0; iD2 < 6; iD2++) { D[iD1][iD2] = 0.f; - + } + } Bool_t noS = (fC[35] <= 0); // no decay length allowed if (noS) { @@ -1229,16 +1283,18 @@ void KFParticleBase::SetProductionVertex(const KFParticleBase& Vtx) float CTmp[36] = {0.}; MultQSQt(F1, mV, CTmp, 6); - for (int iC = 0; iC < 6; iC++) + for (int iC = 0; iC < 6; iC++) { fC[iC] += CTmp[iC]; + } - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { D[i][j] = 0; for (int k = 0; k < 3; k++) { D[i][j] += mV[IJ(j, k)] * F1[i * 6 + k]; } } + } } float mS[6] = {fC[0] + mV[0], @@ -1249,12 +1305,14 @@ void KFParticleBase::SetProductionVertex(const KFParticleBase& Vtx) float res[3] = {m[0] - X(), m[1] - Y(), m[2] - Z()}; float K[3][6]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { K[i][j] = 0; - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; + } } + } float mCHt0[7], mCHt1[7], mCHt2[7]; mCHt0[0] = fC[0]; @@ -1286,8 +1344,9 @@ void KFParticleBase::SetProductionVertex(const KFParticleBase& Vtx) k2[i] = mCHt0[i] * mS[3] + mCHt1[i] * mS[4] + mCHt2[i] * mS[5]; } - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { fP[i] = fP[i] + k0[i] * res[0] + k1[i] * res[1] + k2[i] * res[2]; + } for (Int_t i = 0, k = 0; i < 7; ++i) { for (Int_t j = 0; j <= i; ++j, ++k) { @@ -1297,28 +1356,31 @@ void KFParticleBase::SetProductionVertex(const KFParticleBase& Vtx) float K2[3][3]; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { K2[i][j] = -K[j][i]; + } K2[i][i] += 1; } float A[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { A[i][j] = 0; for (int k = 0; k < 3; k++) { A[i][j] += D[k][i] * K2[k][j]; } } + } double M[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { M[i][j] = 0; for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } + } fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; @@ -1352,14 +1414,16 @@ void KFParticleBase::SetProductionVertex(const KFParticleBase& Vtx) for (int iDsDr = 0; iDsDr < 6; iDsDr++) { float dsdrC = 0, dsdpV = 0; - for (int k = 0; k < 6; k++) + for (int k = 0; k < 6; k++) { dsdrC += dsdr[k] * fC[IJ(k, iDsDr)]; // (-dsdr[k])*fC[k,j] + } fC[iDsDr + 28] = dsdrC; fC[35] += dsdrC * dsdr[iDsDr]; if (iDsDr < 3) { - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { dsdpV -= dsdr[k] * decayPointCov[IJ(k, iDsDr)]; // + } fC[35] -= dsdpV * dsdr[iDsDr]; } } @@ -1391,11 +1455,13 @@ void KFParticleBase::SetMassConstraint(float* mP, float* mC, float mJ[7][7], flo lambda = -c / b; float d = 4. * energy2 * p2 - mass2 * (energy2 - p2 - 2. * mass2); - if (d >= 0 && fabs(a) > 1.e-10) + if (d >= 0 && fabs(a) > 1.e-10) { lambda = (energy2 + p2 - sqrt(d)) / a; + } - if (mP[6] < 0) //If energy < 0 we need a lambda < 0 + if (mP[6] < 0) { //If energy < 0 we need a lambda < 0 lambda = -1000000.; //Empirical, a better solution should be found + } Int_t iIter = 0; for (iIter = 0; iIter < 100; iIter++) { @@ -1406,11 +1472,13 @@ void KFParticleBase::SetMassConstraint(float* mP, float* mC, float mJ[7][7], flo float f = -mass2 * lambda4 + a * lambda2 + b * lambda + c; float df = -4. * mass2 * lambda2 * lambda + 2. * a * lambda + b; - if (fabs(df) < 1.e-10) + if (fabs(df) < 1.e-10) { break; + } lambda -= f / df; - if (fabs(lambda0 - lambda) < 1.e-8) + if (fabs(lambda0 - lambda) < 1.e-8) { break; + } } const float lpi = 1. / (1. + lambda); @@ -1428,25 +1496,31 @@ void KFParticleBase::SetMassConstraint(float* mP, float* mC, float mJ[7][7], flo dfx[3] = 2. * (1. - lambda) * (1. - lambda) * mP[6]; float dlx[4] = {1, 1, 1, 1}; if (fabs(dfl) > 1.e-10) { - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { dlx[i] = -dfx[i] / dfl; + } } float dxx[4] = {mP[3] * lm2i, mP[4] * lm2i, mP[5] * lm2i, -mP[6] * lp2i}; - for (Int_t i = 0; i < 7; i++) - for (Int_t j = 0; j < 7; j++) + for (Int_t i = 0; i < 7; i++) { + for (Int_t j = 0; j < 7; j++) { mJ[i][j] = 0; + } + } mJ[0][0] = 1.; mJ[1][1] = 1.; mJ[2][2] = 1.; - for (Int_t i = 3; i < 7; i++) - for (Int_t j = 3; j < 7; j++) + for (Int_t i = 3; i < 7; i++) { + for (Int_t j = 3; j < 7; j++) { mJ[i][j] = dlx[j - 3] * dxx[i - 3]; + } + } - for (Int_t i = 3; i < 6; i++) + for (Int_t i = 3; i < 6; i++) { mJ[i][i] += lmi; + } mJ[6][6] += lpi; float mCJ[7][7]; @@ -1487,8 +1561,8 @@ void KFParticleBase::SetNonlinearMassConstraint(float mass) const float& energy = fP[6]; const float residual = (energy * energy - px * px - py * py - pz * pz) - mass * mass; - const float dm2 = float(4.f) * (px * px * fC[9] + py * py * fC[14] + pz * pz * fC[20] + energy * energy * fC[27] + - float(2.f) * (px * py * fC[13] + pz * (px * fC[18] + py * fC[19]) - energy * (px * fC[24] + py * fC[25] + pz * fC[26]))); + const float dm2 = 4.f * (px * px * fC[9] + py * py * fC[14] + pz * pz * fC[20] + energy * energy * fC[27] + + 2.f * (px * py * fC[13] + pz * (px * fC[18] + py * fC[19]) - energy * (px * fC[24] + py * fC[25] + pz * fC[26]))); const float dChi2 = residual * residual / dm2; fChi2 += dChi2; fNDF += 1; @@ -1530,23 +1604,26 @@ void KFParticleBase::SetMassConstraint(float Mass, float SigmaMass) float mCHt[8], s2_est = 0; for (Int_t i = 0; i < 8; ++i) { mCHt[i] = 0.0; - for (Int_t j = 0; j < 8; ++j) + for (Int_t j = 0; j < 8; ++j) { mCHt[i] += Cij(i, j) * mH[j]; + } s2_est += mH[i] * mCHt[i]; } - if (s2_est < 1.e-20) - return; // calculated mass error is already 0, - // the particle can not be constrained on mass - + if (s2_est < 1.e-20) { + // calculated mass error is already 0, + // the particle can not be constrained on mass + return; + } float w2 = 1. / (s2 + s2_est); fChi2 += zeta * zeta * w2; fNDF += 1; for (Int_t i = 0, ii = 0; i < 8; ++i) { float ki = mCHt[i] * w2; fP[i] += ki * zeta; - for (Int_t j = 0; j <= i; ++j) + for (Int_t j = 0; j <= i; ++j) { fC[ii++] -= ki * mCHt[j]; + } } } @@ -1563,9 +1640,9 @@ void KFParticleBase::SetNoDecayLength() h[7] = 1; float zeta = 0 - fP[7]; - for (Int_t i = 0; i < 8; ++i) + for (Int_t i = 0; i < 8; ++i) { zeta -= h[i] * (fP[i] - fP[i]); - + } float s = fC[35]; if (s > 1.e-20) { s = 1. / s; @@ -1574,8 +1651,9 @@ void KFParticleBase::SetNoDecayLength() for (Int_t i = 0, ii = 0; i < 7; ++i) { float ki = fC[28 + i] * s; fP[i] += ki * zeta; - for (Int_t j = 0; j <= i; ++j) + for (Int_t j = 0; j <= i; ++j) { fC[ii++] -= ki * fC[28 + j]; + } } } fP[7] = 0; @@ -1602,8 +1680,10 @@ void KFParticleBase::Construct(const KFParticleBase* vDaughters[], Int_t nDaught fSFromDecay = 0; SumDaughterMass = 0; - for (Int_t i = 0; i < 36; ++i) + for (Int_t i = 0; i < 36; ++i) { fC[i] = 0.; + } + fC[35] = 1.; fNDF = -3; @@ -1615,18 +1695,21 @@ void KFParticleBase::Construct(const KFParticleBase* vDaughters[], Int_t nDaught } } - if (Mass >= 0) + if (Mass >= 0) { SetMassConstraint(Mass); - if (Parent) + } + if (Parent) { SetProductionVertex(*Parent); + } } void KFParticleBase::TransportToDecayVertex() { /** Transports the particle to its decay vertex */ float dsdr[6] = {0.f}; - if (fSFromDecay != 0) + if (fSFromDecay != 0) { TransportToDS(-fSFromDecay, dsdr); + } fAtProductionVertex = 0; } @@ -1634,8 +1717,9 @@ void KFParticleBase::TransportToProductionVertex() { /** Transports the particle to its production vertex */ float dsdr[6] = {0.f}; - if (fSFromDecay != -fP[7]) + if (fSFromDecay != -fP[7]) { TransportToDS(-fSFromDecay - fP[7], dsdr); + } fAtProductionVertex = 1; } @@ -1664,8 +1748,9 @@ float KFParticleBase::GetDStoPointLine(const float xyz[3], float dsdr[6]) const **/ float p2 = fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]; - if (p2 < 1.e-4) - p2 = 1; + if (p2 < 1.e-4f) { + p2 = 1.f; + } const float& a = fP[3] * (xyz[0] - fP[0]) + fP[4] * (xyz[1] - fP[1]) + fP[5] * (xyz[2] - fP[2]); dsdr[0] = -fP[3] / p2; @@ -1692,8 +1777,9 @@ float KFParticleBase::GetDStoPointBz(float B, const float xyz[3], float dsdr[6], ** to other coordinate system (see GetDStoPointBy() function), otherwise fP are used **/ - if (!param) + if (!param) { param = fP; + } const float& x = param[0]; const float& y = param[1]; @@ -1737,8 +1823,10 @@ float KFParticleBase::GetDStoPointBz(float B, const float xyz[3], float dsdr[6], float s = sin(bs), c = cos(bs); - if (fabs(bq) < LocalSmall) + if (fabs(bq) < LocalSmall) { bq = LocalSmall; + } + float bbq = bq * (dx * py - dy * px) - pt2; float den = (abq * abq + bbq * bbq); @@ -1753,9 +1841,9 @@ float KFParticleBase::GetDStoPointBz(float B, const float xyz[3], float dsdr[6], float sz(0.f); float cCoeff = (bbq * c - abq * s) - pz * pz; - if (fabs(cCoeff) > LocalSmall) + if (fabs(cCoeff) > LocalSmall) { sz = (dS * pz - dz) * pz / cCoeff; - + } float dcdr[6] = {0.f}; dcdr[0] = -bq * py * c - bbq * s * bq * dsdr[0] + px * bq * s - abq * c * bq * dsdr[0]; dcdr[1] = bq * px * c - bbq * s * bq * dsdr[1] + py * bq * s - abq * c * bq * dsdr[1]; @@ -1763,8 +1851,9 @@ float KFParticleBase::GetDStoPointBz(float B, const float xyz[3], float dsdr[6], dcdr[4] = (bq * dx - 2 * py) * c - bbq * s * bq * dsdr[4] - dy * bq * s - abq * c * bq * dsdr[4]; dcdr[5] = -2 * pz; - for (int iP = 0; iP < 6; iP++) + for (int iP = 0; iP < 6; iP++) { dsdr[iP] += pz * pz / cCoeff * dsdr[iP] - sz / cCoeff * dcdr[iP]; + } dsdr[2] += pz / cCoeff; dsdr[5] += (2.f * pz * dS - dz) / cCoeff; @@ -1774,7 +1863,7 @@ float KFParticleBase::GetDStoPointBz(float B, const float xyz[3], float dsdr[6], s = sin(bs), c = cos(bs); float sB, cB; - const float kOvSqr6 = 1.f / sqrt(float(6.f)); + const float kOvSqr6 = 1.f / sqrt(6.f); if (LocalSmall < fabs(bs)) { sB = s / bq; @@ -1940,7 +2029,7 @@ void KFParticleBase::GetDStoParticleBz(float Bz, const KFParticleBase& p, float } //* Get dS to another particle for Bz field - const float kOvSqr6 = 1.f / sqrt(float(6.f)); + const float kOvSqr6 = 1.f / sqrt(6.f); const float kCLight = 0.000299792458f; //in XY plane @@ -1998,12 +2087,14 @@ void KFParticleBase::GetDStoParticleBz(float Bz, const KFParticleBase& p, float const float& c2 = bq2 * kd + pt22 * bq1; float d1 = pt12 * pt22 - kd * kd; - if (d1 < 0.f) - d1 = float(0.f); + if (d1 < 0.f) { + d1 = 0.f; + } d1 = sqrt(d1); float d2 = pt12 * pt22 - kd * kd; - if (d2 < 0.f) - d2 = float(0.f); + if (d2 < 0.f) { + d2 = 0.f; + } d2 = sqrt(d2); // find two points of closest approach in XY plane @@ -2034,7 +2125,7 @@ void KFParticleBase::GetDStoParticleBz(float Bz, const KFParticleBase& p, float float dd1dr1[6] = {0, 0, 0, 0, 0, 0}; float dd1dr2[6] = {0, 0, 0, 0, 0, 0}; - if (d1 > 0) { + if (d1 > 0.f) { for (int i = 0; i < 6; i++) { dd1dr1[i] = -kd / d1 * dkddr1[i]; dd1dr2[i] = -kd / d1 * dkddr2[i]; @@ -2360,9 +2451,9 @@ void KFParticleBase::GetDStoParticleBz(float Bz, const KFParticleBase& p, float const float& ldrp2 = ppx2 * dx + ppy2 * dy + ppz2 * dz; float detp = lp1p2 * lp1p2 - p12 * p22; - if (fabs(detp) < 1.e-4) - detp = 1; //TODO correct!!! - + if (fabs(detp) < 1.e-4f) { + detp = 1.f; //TODO correct!!! + } //dsdr calculation const float a1 = ldrp2 * lp1p2 - ldrp1 * p22; const float a2 = ldrp2 * p12 - ldrp1 * lp1p2; @@ -2392,9 +2483,11 @@ void KFParticleBase::GetDStoParticleBz(float Bz, const KFParticleBase& p, float dsldr[3][iP] = dsl2ds0 * dsdr[1][iP] + dsl2ds1 * dsdr[3][iP]; } - for (int iDS = 0; iDS < 4; iDS++) - for (int iP = 0; iP < 6; iP++) + for (int iDS = 0; iDS < 4; iDS++) { + for (int iP = 0; iP < 6; iP++) { dsdr[iDS][iP] += dsldr[iDS][iP]; + } + } const float lp1p2_dr0[6] = {0, 0, 0, ccc * ppx2 - ppy2 * sss, ccc * ppy2 + ppx2 * sss, pz2}; const float lp1p2_dr1[6] = {0, 0, 0, ccc1 * ppx1 - ppy1 * sss1, ccc1 * ppy1 + ppx1 * sss1, pz1}; @@ -2451,9 +2544,11 @@ void KFParticleBase::GetDStoParticleBy(float B, const KFParticleBase& p, float d const float param2[6] = {p.fP[0], -p.fP[2], p.fP[1], p.fP[3], -p.fP[5], p.fP[4]}; float dsdrBz[4][6]; - for (int i1 = 0; i1 < 4; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 4; i1++) { + for (int i2 = 0; i2 < 6; i2++) { dsdrBz[i1][i2] = 0; + } + } GetDStoParticleBz(B, p, dS, dsdrBz, param1, param2); @@ -2494,9 +2589,9 @@ void KFParticleBase::GetDStoParticleLine(const KFParticleBase& p, float dS[2], f float drp2 = p.fP[3] * (p.fP[0] - fP[0]) + p.fP[4] * (p.fP[1] - fP[1]) + p.fP[5] * (p.fP[2] - fP[2]); float detp = p1p2 * p1p2 - p12 * p22; - if (fabs(detp) < 1.e-4) - detp = 1; //TODO correct!!! - + if (fabs(detp) < 1.e-4f) { + detp = 1.f; //TODO correct!!! + } dS[0] = (drp2 * p1p2 - drp1 * p22) / detp; dS[1] = (drp2 * p12 - drp1 * p1p2) / detp; @@ -2577,10 +2672,11 @@ void KFParticleBase::GetDStoParticleCBM(const KFParticleBase& p, float dS[2], fl const bool& isStraight1 = fabs(bq1) < 1.e-8f; const bool& isStraight2 = fabs(bq2) < 1.e-8f; - if (isStraight1 && isStraight2) + if (isStraight1 && isStraight2) { GetDStoParticleLine(p, dS, dsdr); - else + } else { GetDStoParticleBy(fld[1], p, dS, dsdr); + } } void KFParticleBase::TransportCBM(float dS, const float* dsdr, float P[], float C[], float* dsdr1, float* F, float* F1) const @@ -2611,8 +2707,9 @@ void KFParticleBase::TransportCBM(float dS, const float* dsdr, float P[], float return; } - if (fabs(dS * fP[5]) > 1000.f) + if (fabs(dS * fP[5]) > 1000.f) { dS = 0; + } const float kCLight = 0.000299792458; @@ -2620,10 +2717,9 @@ void KFParticleBase::TransportCBM(float dS, const float* dsdr, float P[], float // construct coefficients - float - px = fP[3], - py = fP[4], - pz = fP[5]; + float px = fP[3], + py = fP[4], + pz = fP[5]; float sx = 0, sy = 0, sz = 0, syy = 0, syz = 0, syyy = 0, ssx = 0, ssy = 0, ssz = 0, ssyy = 0, ssyz = 0, ssyyy = 0; @@ -2675,11 +2771,12 @@ void KFParticleBase::TransportCBM(float dS, const float* dsdr, float P[], float float c2[3][3] = {{5, -4, -1}, {44, 80, -4}, {11, 44, 5}}; // /=360. float cc2[3][3] = {{38, 8, -4}, {148, 208, -20}, {3, 36, 3}}; // /=2520. - for (Int_t n = 0; n < 3; n++) + for (Int_t n = 0; n < 3; n++) { for (Int_t m = 0; m < 3; m++) { syz += c2[n][m] * fld[n][1] * fld[m][2]; ssyz += cc2[n][m] * fld[n][1] * fld[m][2]; } + } syz *= c * c * dS * dS / 360.; ssyz *= c * c * dS * dS * dS / 2520.; @@ -2703,9 +2800,11 @@ void KFParticleBase::TransportCBM(float dS, const float* dsdr, float P[], float } float mJ[8][8]; - for (Int_t i = 0; i < 8; i++) - for (Int_t j = 0; j < 8; j++) + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mJ[i][j] = 0; + } + } mJ[0][0] = 1; mJ[0][1] = 0; @@ -2756,9 +2855,11 @@ void KFParticleBase::TransportCBM(float dS, const float* dsdr, float P[], float P[7] = fP[7]; float mJds[6][6]; - for (Int_t i = 0; i < 6; i++) - for (Int_t j = 0; j < 6; j++) + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { mJds[i][j] = 0; + } + } if (fabs(dS) > 0) { mJds[0][3] = 1 - 3 * ssyy / dS; @@ -2782,20 +2883,26 @@ void KFParticleBase::TransportCBM(float dS, const float* dsdr, float P[], float mJds[5][5] = -2.f * syy / dS; } - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + } + } MultQSQt(mJ[0], fC, C, 8); if (F) { - for (int i = 0; i < 6; i++) - for (int j = 0; j < 6; j++) + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 6; j++) { F[i * 6 + j] = mJ[i][j]; + } + } - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; + } + } } } @@ -2851,12 +2958,15 @@ void KFParticleBase::TransportBz(float Bz, float dS, const float* dsdr, float P[ P[7] = fP[7]; float mJ[8][8]; - for (Int_t i = 0; i < 8; i++) - for (Int_t j = 0; j < 8; j++) + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mJ[i][j] = 0; + } + } - for (int i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { mJ[i][i] = 1; + } mJ[0][3] = sB; mJ[0][4] = cB; mJ[1][3] = -cB; @@ -2868,9 +2978,11 @@ void KFParticleBase::TransportBz(float Bz, float dS, const float* dsdr, float P[ mJ[4][4] = c; float mJds[6][6]; - for (Int_t i = 0; i < 6; i++) - for (Int_t j = 0; j < 6; j++) + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { mJds[i][j] = 0; + } + } mJds[0][3] = c; mJds[0][4] = s; mJds[1][3] = -s; @@ -2881,20 +2993,25 @@ void KFParticleBase::TransportBz(float Bz, float dS, const float* dsdr, float P[ mJds[4][3] = -Bz * c; mJds[4][4] = -Bz * s; - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; - + } + } MultQSQt(mJ[0], fC, C, 8); if (F) { - for (int i = 0; i < 6; i++) - for (int j = 0; j < 6; j++) + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 6; j++) { F[i * 6 + j] = mJ[i][j]; + } + } - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; + } + } } } @@ -2972,22 +3089,23 @@ float KFParticleBase::GetDeviationFromVertex(const float v[], const float Cv[]) if (Cv) { float VFT[3][6]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 6; j++) { VFT[i][j] = 0; for (int k = 0; k < 3; k++) { VFT[i][j] += Cv[IJ(i, k)] * F1[j * 6 + k]; } } - + } float FVFT[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { FVFT[i][j] = 0; for (int k = 0; k < 3; k++) { FVFT[i][j] += F1[i * 6 + k] * VFT[k][j]; } } + } mC[0] += FVFT[0][0] + Cv[0]; mC[1] += FVFT[1][0] + Cv[1]; mC[2] += FVFT[1][1] + Cv[2]; @@ -3032,8 +3150,9 @@ float KFParticleBase::GetDeviationFromParticle(const KFParticleBase& p) const MultQSQt(F2, p.fC, V0Tmp, 6); MultQSQt(F3, fC, V1Tmp, 6); - for (int iC = 0; iC < 6; iC++) + for (int iC = 0; iC < 6; iC++) { mC1[iC] += V0Tmp[iC] + mC2[iC] + V1Tmp[iC]; + } float d[3] = {mP2[0] - mP1[0], mP2[1] - mP1[1], mP2[2] - mP1[2]}; @@ -3089,14 +3208,15 @@ void KFParticleBase::SubtractFromVertex(KFParticleBase& Vtx) const float dChi2 = ((mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]); - for (Int_t i = 0; i < 3; ++i) + for (Int_t i = 0; i < 3; ++i) { Vtx.fP[i] -= k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; - + } //* New covariance matrix C -= K*(mCH')' for (Int_t i = 0, k = 0; i < 3; ++i) { - for (Int_t j = 0; j <= i; ++j, ++k) + for (Int_t j = 0; j <= i; ++j, ++k) { Vtx.fC[k] += k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]; + } } //* Calculate Chi^2 @@ -3183,10 +3303,12 @@ void KFParticleBase::SubtractFromParticle(KFParticleBase& Vtx) const //* New estimation of the vertex position r += K*zeta - for (Int_t i = 0; i < 3; ++i) + for (Int_t i = 0; i < 3; ++i) { Vtx.fP[i] = m[i] - (k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]); - for (Int_t i = 3; i < 7; ++i) + } + for (Int_t i = 3; i < 7; ++i) { Vtx.fP[i] = Vtx.fP[i] - (k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]); + } //* New covariance matrix C -= K*(mCH')' @@ -3235,9 +3357,11 @@ void KFParticleBase::TransportLine(float dS, const float* dsdr, float P[], float **/ float mJ[8][8]; - for (Int_t i = 0; i < 8; i++) - for (Int_t j = 0; j < 8; j++) + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mJ[i][j] = 0; + } + } mJ[0][0] = 1; mJ[0][1] = 0; @@ -3290,27 +3414,34 @@ void KFParticleBase::TransportLine(float dS, const float* dsdr, float P[], float P[7] = fP[7]; float mJds[6][6]; - for (Int_t i = 0; i < 6; i++) - for (Int_t j = 0; j < 6; j++) + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { mJds[i][j] = 0; + } + } mJds[0][3] = 1; mJds[1][4] = 1; mJds[2][5] = 1; - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; - MultQSQt(mJ[0], fC, C, 8); + MultQSQt(mJ[0], fC, C, 8); + } + } if (F) { - for (int i = 0; i < 6; i++) - for (int j = 0; j < 6; j++) + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 6; j++) { F[i * 6 + j] = mJ[i][j]; - - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + } + } + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; + } + } } } @@ -3338,8 +3469,9 @@ void KFParticleBase::GetArmenterosPodolanski(KFParticleBase& positive, KFParticl float spy = positive.GetPy() + negative.GetPy(); float spz = positive.GetPz() + negative.GetPz(); float sp = sqrt(spx * spx + spy * spy + spz * spz); - if (sp == 0.0) + if (sp == 0.f) { return; + } float pn, pln, plp; pn = sqrt(negative.GetPx() * negative.GetPx() + negative.GetPy() * negative.GetPy() + negative.GetPz() * negative.GetPz()); @@ -3347,8 +3479,9 @@ void KFParticleBase::GetArmenterosPodolanski(KFParticleBase& positive, KFParticl pln = (negative.GetPx() * spx + negative.GetPy() * spy + negative.GetPz() * spz) / sp; plp = (positive.GetPx() * spx + positive.GetPy() * spy + positive.GetPz() * spz) / sp; - if (pn == 0.0) + if (pn == 0.f) { return; + } float ptm = (1. - ((pln / pn) * (pln / pn))); qt = (ptm >= 0.) ? pn * sqrt(ptm) : 0; alpha = (plp - pln) / (plp + pln); @@ -3376,11 +3509,11 @@ void KFParticleBase::RotateXY(float angle, float Vtx[3]) float mA[8][8]; for (Int_t i = 0; i < 8; i++) { for (Int_t j = 0; j < 8; j++) { - mA[i][j] = 0; + mA[i][j] = 0.f; } } for (int i = 0; i < 8; i++) { - mA[i][i] = 1; + mA[i][i] = 1.f; } mA[0][0] = c; mA[0][1] = s; @@ -3395,7 +3528,7 @@ void KFParticleBase::RotateXY(float angle, float Vtx[3]) float mAp[8]; for (Int_t i = 0; i < 8; i++) { - mAp[i] = 0; + mAp[i] = 0.f; for (Int_t k = 0; k < 8; k++) { mAp[i] += mA[i][k] * fP[k]; } @@ -3438,26 +3571,30 @@ void KFParticleBase::InvertCholetsky3(float a[6]) float d[3], uud, u[3][3]; for (int i = 0; i < 3; i++) { d[i] = 0; - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { u[i][j] = 0; + } } for (int i = 0; i < 3; i++) { uud = 0; - for (int j = 0; j < i; j++) + for (int j = 0; j < i; j++) { uud += u[j][i] * u[j][i] * d[j]; + } uud = a[i * (i + 3) / 2] - uud; - if (fabs(uud) < 1.e-12f) + if (fabs(uud) < 1.e-12f) { uud = 1.e-12f; + } d[i] = uud / fabs(uud); u[i][i] = sqrt(fabs(uud)); for (int j = i + 1; j < 3; j++) { uud = 0; - for (int k = 0; k < i; k++) + for (int k = 0; k < i; k++) { uud += u[k][i] * u[k][j] * d[k]; + } uud = a[j * (j + 1) / 2 + i] - uud; u[i][j] = d[i] / u[i][i] * uud; } @@ -3476,10 +3613,12 @@ void KFParticleBase::InvertCholetsky3(float a[6]) u[i][i + 2] = u[i][i + 1] * u1[i + 1] * u[i + 1][i + 2] - u[i][i + 2] * u[i][i] * u[i + 2][i + 2]; } - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { a[i + 3] = u[i][2] * u[2][2] * d[2]; - for (int i = 0; i < 2; i++) + } + for (int i = 0; i < 2; i++) { a[i + 1] = u[i][1] * u[1][1] * d[1] + u[i][2] * u[1][2] * d[2]; + } a[0] = u[0][0] * u[0][0] * d[0] + u[0][1] * u[0][1] * d[1] + u[0][2] * u[0][2] * d[2]; } @@ -3497,8 +3636,9 @@ void KFParticleBase::MultQSQt(const float Q[], const float S[], float SOut[], co for (Int_t i = 0, ij = 0; i < kN; i++) { for (Int_t j = 0; j < kN; j++, ++ij) { mA[ij] = 0; - for (Int_t k = 0; k < kN; ++k) + for (Int_t k = 0; k < kN; ++k) { mA[ij] += S[(k <= i) ? i * (i + 1) / 2 + k : k * (k + 1) / 2 + i] * Q[j * kN + k]; + } } } @@ -3506,14 +3646,13 @@ void KFParticleBase::MultQSQt(const float Q[], const float S[], float SOut[], co for (Int_t j = 0; j <= i; j++) { Int_t ij = (j <= i) ? i * (i + 1) / 2 + j : j * (j + 1) / 2 + i; SOut[ij] = 0; - for (Int_t k = 0; k < kN; k++) + for (Int_t k = 0; k < kN; k++) { SOut[ij] += Q[i * kN + k] * mA[k * kN + j]; + } } } - if (mA) + if (mA) { delete[] mA; -} - -// 72-charachters line to define the printer border -//3456789012345678901234567890123456789012345678901234567890123456789012 + } +} \ No newline at end of file diff --git a/KFParticle/KFParticleBaseSIMD.cxx b/KFParticle/KFParticleBaseSIMD.cxx index 8b57c72..fa9a4ee 100644 --- a/KFParticle/KFParticleBaseSIMD.cxx +++ b/KFParticle/KFParticleBaseSIMD.cxx @@ -53,10 +53,12 @@ void KFParticleBaseSIMD::Initialize(const float_v Param[], const float_v Cov[], ** \param[in] mass - the mass hypothesis **/ - for (Int_t i = 0; i < 6; i++) + for (Int_t i = 0; i < 6; i++) { fP[i] = Param[i]; - for (Int_t i = 0; i < 21; i++) + } + for (Int_t i = 0; i < 21; i++) { fC[i] = Cov[i]; + } float_v energy = sqrt(Mass * Mass + fP[3] * fP[3] + fP[4] * fP[4] + fP[5] * fP[5]); fP[6] = energy; @@ -80,8 +82,9 @@ void KFParticleBaseSIMD::Initialize(const float_v Param[], const float_v Cov[], fC[25] = h0 * fC[13] + h1 * fC[14] + h2 * fC[19]; fC[26] = h0 * fC[18] + h1 * fC[19] + h2 * fC[20]; fC[27] = (h0 * h0 * fC[9] + h1 * h1 * fC[14] + h2 * h2 * fC[20] + 2 * (h0 * h1 * fC[13] + h0 * h2 * fC[18] + h1 * h2 * fC[19])); - for (Int_t i = 28; i < 36; i++) + for (Int_t i = 28; i < 36; i++) { fC[i] = 0.f; + } fC[35] = 1.f; SumDaughterMass = Mass; @@ -98,10 +101,12 @@ void KFParticleBaseSIMD::Initialize() ** 5) NDF = -3, since 3 parameters should be fitted: X, Y, Z. **/ - for (Int_t i = 0; i < 8; i++) + for (Int_t i = 0; i < 8; i++) { fP[i] = 0.f; - for (Int_t i = 0; i < 36; ++i) + } + for (Int_t i = 0; i < 36; ++i) { fC[i] = 0.f; + } fC[0] = fC[2] = fC[5] = 100.f; fC[35] = 1.f; fNDF = -3; @@ -384,8 +389,9 @@ void KFParticleBaseSIMD::GetMeasurement(const KFParticleBaseSIMD& daughter, floa float_v V1Tmp[36]; float_v C[36]; - for (int iC = 0; iC < 36; iC++) + for (int iC = 0; iC < 36; iC++) { C[iC] = fC[iC]; + } Transport(ds[0], dsdr[0], fP, fC, dsdr[1], F1, F2); daughter.Transport(ds[1], dsdr[3], m, V, dsdr[2], F4, F3); @@ -399,36 +405,40 @@ void KFParticleBaseSIMD::GetMeasurement(const KFParticleBaseSIMD& daughter, floa } float_v C1F1T[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { C1F1T[i][j] = 0; for (int k = 0; k < 6; k++) { C1F1T[i][j] += C[IJ(i, k)] * F1[j * 6 + k]; } } + } float_v F3C1F1T[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { F3C1F1T[i][j] = 0; for (int k = 0; k < 6; k++) { F3C1F1T[i][j] += F3[i * 6 + k] * C1F1T[k][j]; } } + } float_v C2F2T[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { C2F2T[i][j] = 0; for (int k = 0; k < 6; k++) { C2F2T[i][j] += daughter.fC[IJ(i, k)] * F2[j * 6 + k]; } } - for (int i = 0; i < 3; i++) + } + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { D[i][j] = F3C1F1T[i][j]; for (int k = 0; k < 6; k++) { D[i][j] += F4[i * 6 + k] * C2F2T[k][j]; } } + } } else { float_v dsdr[6]; float_v dS = daughter.GetDStoPoint(fP, dsdr); @@ -449,30 +459,31 @@ void KFParticleBaseSIMD::GetMeasurement(const KFParticleBaseSIMD& daughter, floa // V[iC] += V1Tmp[iC]; float_v VFT[3][6]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 6; j++) { VFT[i][j] = 0; for (int k = 0; k < 3; k++) { VFT[i][j] += fC[IJ(i, k)] * F1[j * 6 + k]; } } - + } float_v FVFT[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { FVFT[i][j] = 0; for (int k = 0; k < 3; k++) { FVFT[i][j] += F1[i * 6 + k] * VFT[k][j]; } } - - for (int i = 0; i < 3; i++) + } + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { D[i][j] = 0; for (int k = 0; k < 3; k++) { D[i][j] += fC[IJ(j, k)] * F1[i * 6 + k]; } } + } V[0] += FVFT[0][0]; V[1] += FVFT[1][0]; @@ -503,21 +514,23 @@ void KFParticleBaseSIMD::AddDaughter(const KFParticleBaseSIMD& Daughter) if (int(fNDF[0]) < -1) { // first daughter -> just copy fNDF = -1; fQ = Daughter.GetQ(); - for (Int_t i = 0; i < 7; i++) + for (Int_t i = 0; i < 7; i++) { fP[i] = Daughter.fP[i]; - for (Int_t i = 0; i < 28; i++) + } + for (Int_t i = 0; i < 28; i++) { fC[i] = Daughter.fC[i]; + } fSFromDecay = 0; fMassHypo = Daughter.fMassHypo; SumDaughterMass = Daughter.SumDaughterMass; return; } - if (fConstructMethod == 0) + if (fConstructMethod == 0) { AddDaughterWithEnergyFit(Daughter); - else if (fConstructMethod == 2) + } else if (fConstructMethod == 2) { AddDaughterWithEnergyFitMC(Daughter); - + } SumDaughterMass += Daughter.SumDaughterMass; fMassHypo = -1.f; } @@ -550,13 +563,14 @@ void KFParticleBaseSIMD::AddDaughterWithEnergyFit(const KFParticleBaseSIMD& Daug float_v zeta[3] = {m[0] - fP[0], m[1] - fP[1], m[2] - fP[2]}; float_v K[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { K[i][j] = 0; - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; + } } - + } //* CHt = CH' - D' float_v mCHt0[7], mCHt1[7], mCHt2[7]; @@ -612,9 +626,9 @@ void KFParticleBaseSIMD::AddDaughterWithEnergyFit(const KFParticleBaseSIMD& Daug //* New estimation of the vertex position r += K*zeta - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; - + } //* New covariance matrix C -= K*(mCH')' for (Int_t i = 0, k = 0; i < 7; ++i) { @@ -625,28 +639,31 @@ void KFParticleBaseSIMD::AddDaughterWithEnergyFit(const KFParticleBaseSIMD& Daug float_v K2[3][3]; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { K2[i][j] = -K[j][i]; + } K2[i][i] += 1; } float_v A[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { A[i][j] = 0; for (int k = 0; k < 3; k++) { A[i][j] += D[i][k] * K2[k][j]; } } + } float_v M[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { M[i][j] = 0; for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } + } fC[0] += 2.f * M[0][0]; fC[1] += M[0][1] + M[1][0]; @@ -690,12 +707,14 @@ void KFParticleBaseSIMD::AddDaughterWithEnergyFitMC(const KFParticleBaseSIMD& Da float_v zeta[3] = {m[0] - fP[0], m[1] - fP[1], m[2] - fP[2]}; float_v K[3][6]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { K[i][j] = 0; - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; + } } + } //* CHt = CH' @@ -771,11 +790,13 @@ void KFParticleBaseSIMD::AddDaughterWithEnergyFitMC(const KFParticleBaseSIMD& Da km2[i] = mVHt0[i] * mS[3] + mVHt1[i] * mS[4] + mVHt2[i] * mS[5]; } - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + } - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { m[i] = m[i] - km0[i] * zeta[0] - km1[i] * zeta[1] - km2[i] * zeta[2]; + } for (Int_t i = 0, k = 0; i < 7; ++i) { for (Int_t j = 0; j <= i; ++j, ++k) { @@ -886,28 +907,31 @@ void KFParticleBaseSIMD::AddDaughterWithEnergyFitMC(const KFParticleBaseSIMD& Da float_v K2[3][3]; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { K2[i][j] = -K[j][i]; + } K2[i][i] += 1; } float_v A[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { A[i][j] = 0.f; for (int k = 0; k < 3; k++) { A[i][j] += D[i][k] * K2[k][j]; } } + } float_v M[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { M[i][j] = 0.f; for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } + } fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; @@ -948,12 +972,14 @@ void KFParticleBaseSIMD::SubtractDaughter(const KFParticleBaseSIMD& Daughter) float_v zeta[3] = {m[0] - fP[0], m[1] - fP[1], m[2] - fP[2]}; float_v K[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { K[i][j] = 0; - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; + } } + } //* CHt = CH' - D' float_v mCHt0[7], mCHt1[7], mCHt2[7]; @@ -1010,8 +1036,9 @@ void KFParticleBaseSIMD::SubtractDaughter(const KFParticleBaseSIMD& Daughter) //* New estimation of the vertex position r += K*zeta - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { fP[i] = fP[i] + k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + } //* New covariance matrix C -= K*(mCH')' @@ -1023,28 +1050,31 @@ void KFParticleBaseSIMD::SubtractDaughter(const KFParticleBaseSIMD& Daughter) float_v K2[3][3]; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { K2[i][j] = -K[j][i]; - K2[i][i] += 1; + K2[i][i] += 1; + } } float_v A[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { A[i][j] = 0; for (int k = 0; k < 3; k++) { A[i][j] += D[i][k] * K2[k][j]; } } + } float_v M[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { M[i][j] = 0; for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } + } fC[0] += 2.f * M[0][0]; fC[1] += M[0][1] + M[1][0]; @@ -1077,9 +1107,11 @@ void KFParticleBaseSIMD::SetProductionVertex(const KFParticleBaseSIMD& Vtx) float_v decayPointCov[6] = {fC[0], fC[1], fC[2], fC[3], fC[4], fC[5]}; float_v D[6][6]; - for (int iD1 = 0; iD1 < 6; iD1++) - for (int iD2 = 0; iD2 < 6; iD2++) + for (int iD1 = 0; iD1 < 6; iD1++) { + for (int iD2 = 0; iD2 < 6; iD2++) { D[iD1][iD2] = 0.f; + } + } Bool_t noS = (fC[35][0] <= 0.f); // no decay length allowed @@ -1103,16 +1135,18 @@ void KFParticleBaseSIMD::SetProductionVertex(const KFParticleBaseSIMD& Vtx) float_v CTmp[36]; MultQSQt(F1, mV, CTmp, 6); - for (int iC = 0; iC < 21; iC++) + for (int iC = 0; iC < 21; iC++) { fC[iC] += CTmp[iC]; + } - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { D[i][j] = 0; for (int k = 0; k < 3; k++) { D[i][j] += mV[IJ(j, k)] * F1[i * 6 + k]; } } + } } float_v mS[6] = {fC[0] + mV[0], @@ -1123,12 +1157,14 @@ void KFParticleBaseSIMD::SetProductionVertex(const KFParticleBaseSIMD& Vtx) float_v res[3] = {m[0] - X(), m[1] - Y(), m[2] - Z()}; float_v K[3][6]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { K[i][j] = 0; - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { K[i][j] += fC[IJ(i, k)] * mS[IJ(k, j)]; + } } + } float_v mCHt0[7], mCHt1[7], mCHt2[7]; mCHt0[0] = fC[0]; @@ -1160,8 +1196,9 @@ void KFParticleBaseSIMD::SetProductionVertex(const KFParticleBaseSIMD& Vtx) k2[i] = mCHt0[i] * mS[3] + mCHt1[i] * mS[4] + mCHt2[i] * mS[5]; } - for (Int_t i = 0; i < 7; ++i) + for (Int_t i = 0; i < 7; ++i) { fP[i] = fP[i] + k0[i] * res[0] + k1[i] * res[1] + k2[i] * res[2]; + } for (Int_t i = 0, k = 0; i < 7; ++i) { for (Int_t j = 0; j <= i; ++j, ++k) { @@ -1171,28 +1208,31 @@ void KFParticleBaseSIMD::SetProductionVertex(const KFParticleBaseSIMD& Vtx) float_v K2[3][3]; for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { K2[i][j] = -K[j][i]; + } K2[i][i] += 1; } float_v A[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { A[i][j] = 0; for (int k = 0; k < 3; k++) { A[i][j] += D[k][i] * K2[k][j]; } } + } float_v M[3][3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { M[i][j] = 0; for (int k = 0; k < 3; k++) { M[i][j] += K[i][k] * A[k][j]; } } + } fC[0] += 2 * M[0][0]; fC[1] += M[0][1] + M[1][0]; @@ -1226,14 +1266,15 @@ void KFParticleBaseSIMD::SetProductionVertex(const KFParticleBaseSIMD& Vtx) for (int iDsDr = 0; iDsDr < 6; iDsDr++) { float_v dsdrC = 0.f, dsdpV = 0.f; - for (int k = 0; k < 6; k++) + for (int k = 0; k < 6; k++) { dsdrC += dsdr[k] * fC[IJ(k, iDsDr)]; // (-dsdr[k])*fC[k,j] - + } fC[iDsDr + 28] = dsdrC; fC[35] += dsdrC * dsdr[iDsDr]; if (iDsDr < 3) { - for (int k = 0; k < 3; k++) + for (int k = 0; k < 3; k++) { dsdpV -= dsdr[k] * decayPointCov[IJ(k, iDsDr)]; // + } fC[35] -= dsdpV * dsdr[iDsDr]; } } @@ -1296,24 +1337,31 @@ void KFParticleBaseSIMD::SetMassConstraint(float_v* mP, float_v* mC, float_v mJ[ dfx[3] = 2.f * (1.f - lambda) * (1.f - lambda) * mP[6]; float_v dlx[4] = {1.f, 1.f, 1.f, 1.f}; - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { dlx[i](abs(dfl) > float_v(1.e-10f)) = -dfx[i] / dfl; + } float_v dxx[4] = {mP[3] * lm2i, mP[4] * lm2i, mP[5] * lm2i, -mP[6] * lp2i}; - for (Int_t i = 0; i < 7; i++) - for (Int_t j = 0; j < 7; j++) + for (Int_t i = 0; i < 7; i++) { + for (Int_t j = 0; j < 7; j++) { mJ[i][j] = 0; + } + } mJ[0][0] = 1.; mJ[1][1] = 1.; mJ[2][2] = 1.; - for (Int_t i = 3; i < 7; i++) - for (Int_t j = 3; j < 7; j++) + for (Int_t i = 3; i < 7; i++) { + for (Int_t j = 3; j < 7; j++) { mJ[i][j] = dlx[j - 3] * dxx[i - 3]; + } + } - for (Int_t i = 3; i < 6; i++) + for (Int_t i = 3; i < 6; i++) { mJ[i][i] += lmi; + } + mJ[6][6] += lpi; float_v mCJ[7][7]; @@ -1397,8 +1445,9 @@ void KFParticleBaseSIMD::SetMassConstraint(float_v Mass, float_v SigmaMass) float_v mCHt[8], s2_est = 0.f; for (Int_t i = 0; i < 8; ++i) { mCHt[i] = 0.0f; - for (Int_t j = 0; j < 8; ++j) + for (Int_t j = 0; j < 8; ++j) { mCHt[i] += Cij(i, j) * mH[j]; + } s2_est += mH[i] * mCHt[i]; } @@ -1412,8 +1461,9 @@ void KFParticleBaseSIMD::SetMassConstraint(float_v Mass, float_v SigmaMass) for (Int_t i = 0, ii = 0; i < 8; ++i) { float_v ki = mCHt[i] * w2; fP[i] += ki * zeta; - for (Int_t j = 0; j <= i; ++j) + for (Int_t j = 0; j <= i; ++j) { fC[ii++] -= ki * mCHt[j]; + } } } @@ -1430,8 +1480,9 @@ void KFParticleBaseSIMD::SetNoDecayLength() h[7] = 1.f; float_v zeta = 0.f - fP[7]; - for (Int_t i = 0; i < 8; ++i) + for (Int_t i = 0; i < 8; ++i) { zeta -= h[i] * (fP[i] - fP[i]); + } float_v s = fC[35]; // if( s>1.e-20 ) //TODO add protection @@ -1442,8 +1493,9 @@ void KFParticleBaseSIMD::SetNoDecayLength() for (Int_t i = 0, ii = 0; i < 7; ++i) { float_v ki = fC[28 + i] * s; fP[i] += ki * zeta; - for (Int_t j = 0; j <= i; ++j) + for (Int_t j = 0; j <= i; ++j) { fC[ii++] -= ki * fC[28 + j]; + } } } fP[7] = 0.f; @@ -1474,8 +1526,9 @@ void KFParticleBaseSIMD::Construct(const KFParticleBaseSIMD* vDaughters[], Int_t fSFromDecay = float_v(Vc::Zero); SumDaughterMass = float_v(Vc::Zero); - for (Int_t i = 0; i < 36; ++i) + for (Int_t i = 0; i < 36; ++i) { fC[i] = 0.; + } fC[35] = 1.; fNDF = -3; @@ -1487,10 +1540,12 @@ void KFParticleBaseSIMD::Construct(const KFParticleBaseSIMD* vDaughters[], Int_t } } - if (Mass >= 0) + if (Mass >= 0) { SetMassConstraint(Mass); - if (Parent) + } + if (Parent) { SetProductionVertex(*Parent); + } } void KFParticleBaseSIMD::TransportToDecayVertex() @@ -1619,8 +1674,9 @@ float_v KFParticleBaseSIMD::GetDStoPointBz(float_v B, const float_v xyz[3], floa ** to other coordinate system (see GetDStoPointBy() function), otherwise fP are used **/ - if (!param) + if (!param) { param = fP; + } //* Get dS to a certain space point for Bz field const float_v& x = param[0]; @@ -1655,8 +1711,9 @@ float_v KFParticleBaseSIMD::GetDStoPointBz(float_v B, const float_v xyz[3], floa dsdr[4](mask && float_m(p2 > 1.e-4f)) = (dy * p2 - 2.f * py * (a + dz * pz)) / (p2 * p2); dsdr[5](mask && float_m(p2 > 1.e-4f)) = (dz * p2 - 2.f * pz * (a + dz * pz)) / (p2 * p2); - if (mask.isFull()) + if (mask.isFull()) { return dS; + } } dS(!mask) = KFPMath::ATan2(abq, pt2 + bq * (dy * px - dx * py)) / bq; @@ -1686,8 +1743,9 @@ float_v KFParticleBaseSIMD::GetDStoPointBz(float_v B, const float_v xyz[3], floa dcdr[4] = (bq * dx - 2 * py) * c - bbq * s * bq * dsdr[4] - dy * bq * s - abq * c * bq * dsdr[4]; dcdr[5] = -2 * pz; - for (int iP = 0; iP < 6; iP++) + for (int iP = 0; iP < 6; iP++) { dsdr[iP](!mask) += pz * pz / cCoeff * dsdr[iP] - sz / cCoeff * dcdr[iP]; + } dsdr[2](!mask) += pz / cCoeff; dsdr[5](!mask) += (2.f * pz * dS - dz) / cCoeff; @@ -2072,12 +2130,14 @@ void KFParticleBaseSIMD::GetDStoParticleBz(float_v B, const KFParticleBaseSIMD& float_v pointCov[2][36]; float_v dsdrM1[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; - for (int iP = 0; iP < 6; iP++) + for (int iP = 0; iP < 6; iP++) { dsdrM1[iP] = (dS1dR1[0][iP] + dS1dR1[1][iP]) / 2.f; + } Transport((dS1[0] + dS1[1]) / 2.f, dsdrM1, pointParam[0], pointCov[0]); float_v dsdrM2[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; - for (int iP = 0; iP < 6; iP++) + for (int iP = 0; iP < 6; iP++) { dsdrM2[iP] = (dS2dR2[0][iP] + dS2dR2[1][iP]) / 2.f; + } p.Transport((dS2[0] + dS2[1]) / 2.f, dsdrM2, pointParam[1], pointCov[1]); const float_v drPoint[3] = {pointParam[0][0] - pointParam[1][0], pointParam[0][1] - pointParam[1][1], pointParam[0][2] - pointParam[1][2]}; @@ -2413,9 +2473,11 @@ void KFParticleBaseSIMD::GetDStoParticleBz(float_v B, const KFParticleBaseSIMD& dsldr[3][iP] = dsl2ds0 * dsdr[1][iP] + dsl2ds1 * dsdr[3][iP]; } - for (int iDS = 0; iDS < 4; iDS++) - for (int iP = 0; iP < 6; iP++) + for (int iDS = 0; iDS < 4; iDS++) { + for (int iP = 0; iP < 6; iP++) { dsdr[iDS][iP] += dsldr[iDS][iP]; + } + } const float_v lp1p2_dr0[6] = {0.f, 0.f, 0.f, ccc * ppx2 - ppy2 * sss, ccc * ppy2 + ppx2 * sss, pz2}; const float_v lp1p2_dr1[6] = {0.f, 0.f, 0.f, ccc1 * ppx1 - ppy1 * sss1, ccc1 * ppy1 + ppx1 * sss1, pz1}; @@ -2719,9 +2781,11 @@ void KFParticleBaseSIMD::GetDStoParticleBy(float_v B, const KFParticleBaseSIMD& const float_v param2[6] = {p.fP[0], -p.fP[2], p.fP[1], p.fP[3], -p.fP[5], p.fP[4]}; float_v dsdrBz[4][6]; - for (int i1 = 0; i1 < 4; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 4; i1++) { + for (int i2 = 0; i2 < 6; i2++) { dsdrBz[i1][i2] = 0.f; + } + } GetDStoParticleBz(B, p, dS, dsdrBz, param1, param2); @@ -2808,9 +2872,11 @@ void KFParticleBaseSIMD::GetDStoParticleB(float_v B[3], const KFParticleBaseSIMD cosP * sinA * p.fP[3] + sinP * p.fP[4] + cosA * cosP * p.fP[5]}; float_v dsdrBz[4][6]; - for (int i1 = 0; i1 < 4; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 4; i1++) { + for (int i2 = 0; i2 < 6; i2++) { dsdrBz[i1][i2] = 0.f; + } + } GetDStoParticleBz(Br, p, dS, dsdrBz, param1, param2); @@ -3004,10 +3070,11 @@ void KFParticleBaseSIMD::GetDStoParticleCBM(const KFParticleBaseSIMD& p, float_v const float_m& isStraight1 = abs(bq1) < float_v(1.e-8f); const float_m& isStraight2 = abs(bq2) < float_v(1.e-8f); - if (isStraight1.isFull() && isStraight2.isFull()) + if (isStraight1.isFull() && isStraight2.isFull()) { GetDStoParticleLine(p, dS, dsdr); - else + } else { GetDStoParticleBy(fld[1], p, dS, dsdr); + } } void KFParticleBaseSIMD::GetDStoParticleCBM(const KFParticleBaseSIMD& p, float_v dS[2]) const @@ -3033,10 +3100,11 @@ void KFParticleBaseSIMD::GetDStoParticleCBM(const KFParticleBaseSIMD& p, float_v const float_m& isStraight1 = abs(bq1) < float_v(1.e-8f); const float_m& isStraight2 = abs(bq2) < float_v(1.e-8f); - if (isStraight1.isFull() && isStraight2.isFull()) + if (isStraight1.isFull() && isStraight2.isFull()) { GetDStoParticleLine(p, dS); - else + } else { GetDStoParticleBy(fld[1], p, dS); + } } void KFParticleBaseSIMD::TransportCBM(float_v dS, const float_v* dsdr, float_v P[], float_v C[], float_v* dsdr1, float_v* F, float_v* F1) const @@ -3118,9 +3186,11 @@ void KFParticleBaseSIMD::TransportCBM(float_v dS, const float_v* dsdr, float_v P GetFieldValue(p1, fld[1]); GetFieldValue(p2, fld[2]); - for (int iF1 = 0; iF1 < 3; iF1++) - for (int iF2 = 0; iF2 < 3; iF2++) + for (int iF1 = 0; iF1 < 3; iF1++) { + for (int iF2 = 0; iF2 < 3; iF2++) { fld[iF1][iF2](abs(fld[iF1][iF2]) > float_v(100.f)) = 0.f; + } + } sx = c * (fld[0][0] + 4 * fld[1][0] + fld[2][0]) * dS / 6.f; sy = c * (fld[0][1] + 4 * fld[1][1] + fld[2][1]) * dS / 6.f; @@ -3132,11 +3202,12 @@ void KFParticleBaseSIMD::TransportCBM(float_v dS, const float_v* dsdr, float_v P float_v c2[3][3] = {{5.f, -4.f, -1.f}, {44.f, 80.f, -4.f}, {11.f, 44.f, 5.f}}; // /=360. float_v cc2[3][3] = {{38.f, 8.f, -4.f}, {148.f, 208.f, -20.f}, {3.f, 36.f, 3.f}}; // /=2520. - for (Int_t n = 0; n < 3; n++) + for (Int_t n = 0; n < 3; n++) { for (Int_t m = 0; m < 3; m++) { syz += c2[n][m] * fld[n][1] * fld[m][2]; ssyz += cc2[n][m] * fld[n][1] * fld[m][2]; } + } syz *= c * c * dS * dS / 360.f; ssyz *= c * c * dS * dS * dS / 2520.f; @@ -3187,9 +3258,11 @@ void KFParticleBaseSIMD::TransportCBM(float_v dS, const float_v* dsdr, float_v P // multQSQt1( mJ, C); float_v mJ[8][8]; - for (Int_t i = 0; i < 8; i++) - for (Int_t j = 0; j < 8; j++) + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mJ[i][j] = 0; + } + } mJ[0][0] = 1; mJ[0][1] = 0; @@ -3240,9 +3313,11 @@ void KFParticleBaseSIMD::TransportCBM(float_v dS, const float_v* dsdr, float_v P P[7] = fP[7]; float_v mJds[6][6]; - for (Int_t i = 0; i < 6; i++) - for (Int_t j = 0; j < 6; j++) + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { mJds[i][j] = 0; + } + } mJds[0][3] = 1.f; mJds[1][4] = 1.f; @@ -3268,20 +3343,26 @@ void KFParticleBaseSIMD::TransportCBM(float_v dS, const float_v* dsdr, float_v P mJds[5][4](abs(dS) > 0.f) = -sx / dS; mJds[5][5](abs(dS) > 0.f) = -2.f * syy / dS; - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + } + } MultQSQt(mJ[0], fC, C, 8); if (F) { - for (int i = 0; i < 6; i++) - for (int j = 0; j < 6; j++) + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 6; j++) { F[i * 6 + j] = mJ[i][j]; + } + } - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; + } + } } } @@ -3351,9 +3432,11 @@ void KFParticleBaseSIMD::TransportCBM(float_v dS, float_v P[]) const GetFieldValue(p1, fld[1]); GetFieldValue(p2, fld[2]); - for (int iF1 = 0; iF1 < 3; iF1++) - for (int iF2 = 0; iF2 < 3; iF2++) + for (int iF1 = 0; iF1 < 3; iF1++) { + for (int iF2 = 0; iF2 < 3; iF2++) { fld[iF1][iF2](abs(fld[iF1][iF2]) > float_v(100.f)) = 0.f; + } + } sx = c * (fld[0][0] + 4 * fld[1][0] + fld[2][0]) * dS / 6.f; sy = c * (fld[0][1] + 4 * fld[1][1] + fld[2][1]) * dS / 6.f; @@ -3365,11 +3448,12 @@ void KFParticleBaseSIMD::TransportCBM(float_v dS, float_v P[]) const float_v c2[3][3] = {{5.f, -4.f, -1.f}, {44.f, 80.f, -4.f}, {11.f, 44.f, 5.f}}; // /=360. float_v cc2[3][3] = {{38.f, 8.f, -4.f}, {148.f, 208.f, -20.f}, {3.f, 36.f, 3.f}}; // /=2520. - for (Int_t n = 0; n < 3; n++) + for (Int_t n = 0; n < 3; n++) { for (Int_t m = 0; m < 3; m++) { syz += c2[n][m] * fld[n][1] * fld[m][2]; ssyz += cc2[n][m] * fld[n][1] * fld[m][2]; } + } syz *= c * c * dS * dS / 360.f; ssyz *= c * c * dS * dS * dS / 2520.f; @@ -3393,9 +3477,11 @@ void KFParticleBaseSIMD::TransportCBM(float_v dS, float_v P[]) const } float_v mJ[8][8]; - for (Int_t i = 0; i < 8; i++) - for (Int_t j = 0; j < 8; j++) + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mJ[i][j] = 0; + } + } mJ[0][0] = 1; mJ[0][1] = 0; @@ -3500,12 +3586,16 @@ void KFParticleBaseSIMD::TransportBz(float_v Bz, float_v dS, const float_v* dsdr P[7] = fP[7]; float_v mJ[8][8]; - for (Int_t i = 0; i < 8; i++) - for (Int_t j = 0; j < 8; j++) + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mJ[i][j] = 0; + } + } - for (int i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { mJ[i][i] = 1; + } + mJ[0][3] = sB; mJ[0][4] = cB; mJ[1][3] = -cB; @@ -3517,9 +3607,12 @@ void KFParticleBaseSIMD::TransportBz(float_v Bz, float_v dS, const float_v* dsdr mJ[4][4] = c; float_v mJds[6][6]; - for (Int_t i = 0; i < 6; i++) - for (Int_t j = 0; j < 6; j++) + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { mJds[i][j] = 0; + } + } + mJds[0][3] = c; mJds[0][4] = s; mJds[1][3] = -s; @@ -3530,20 +3623,25 @@ void KFParticleBaseSIMD::TransportBz(float_v Bz, float_v dS, const float_v* dsdr mJds[4][3] = -Bz * c; mJds[4][4] = -Bz * s; - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + } + } MultQSQt(mJ[0], fC, C, 8); if (F) { - for (int i = 0; i < 6; i++) - for (int j = 0; j < 6; j++) + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 6; j++) { F[i * 6 + j] = mJ[i][j]; - - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + } + } + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; + } + } } } @@ -3659,22 +3757,24 @@ float_v KFParticleBaseSIMD::GetDeviationFromVertex(const float_v v[], const floa if (Cv) { float_v VFT[3][6]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 6; j++) { VFT[i][j] = 0; for (int k = 0; k < 3; k++) { VFT[i][j] += Cv[IJ(i, k)] * F1[j * 6 + k]; } } + } float_v FVFT[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { FVFT[i][j] = 0; for (int k = 0; k < 3; k++) { FVFT[i][j] += F1[i * 6 + k] * VFT[k][j]; } } + } mC[0] += FVFT[0][0] + Cv[0]; mC[1] += FVFT[1][0] + Cv[1]; mC[2] += FVFT[1][1] + Cv[2]; @@ -3719,8 +3819,9 @@ float_v KFParticleBaseSIMD::GetDeviationFromParticle(const KFParticleBaseSIMD& p MultQSQt(F2, p.fC, V0Tmp, 6); MultQSQt(F3, fC, V1Tmp, 6); - for (int iC = 0; iC < 6; iC++) + for (int iC = 0; iC < 6; iC++) { mC1[iC] += V0Tmp[iC] + mC2[iC] + V1Tmp[iC]; + } float_v d[3] = {mP2[0] - mP1[0], mP2[1] - mP1[1], mP2[2] - mP1[2]}; @@ -3776,14 +3877,16 @@ void KFParticleBaseSIMD::SubtractFromVertex(KFParticleBaseSIMD& Vtx) const float_v dChi2 = ((mS[0] * zeta[0] + mS[1] * zeta[1] + mS[3] * zeta[2]) * zeta[0] + (mS[1] * zeta[0] + mS[2] * zeta[1] + mS[4] * zeta[2]) * zeta[1] + (mS[3] * zeta[0] + mS[4] * zeta[1] + mS[5] * zeta[2]) * zeta[2]); - for (Int_t i = 0; i < 3; ++i) + for (Int_t i = 0; i < 3; ++i) { Vtx.fP[i] -= k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]; + } //* New covariance matrix C -= K*(mCH')' for (Int_t i = 0, k = 0; i < 3; ++i) { - for (Int_t j = 0; j <= i; ++j, ++k) + for (Int_t j = 0; j <= i; ++j, ++k) { Vtx.fC[k] += k0[i] * mCHt0[j] + k1[i] * mCHt1[j] + k2[i] * mCHt2[j]; + } } //* Calculate Chi^2 @@ -3870,10 +3973,12 @@ void KFParticleBaseSIMD::SubtractFromParticle(KFParticleBaseSIMD& Vtx) const //* New estimation of the vertex position r += K*zeta - for (Int_t i = 0; i < 3; ++i) + for (Int_t i = 0; i < 3; ++i) { Vtx.fP[i] = m[i] - (k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]); - for (Int_t i = 3; i < 7; ++i) + } + for (Int_t i = 3; i < 7; ++i) { Vtx.fP[i] = Vtx.fP[i] - (k0[i] * zeta[0] + k1[i] * zeta[1] + k2[i] * zeta[2]); + } //* New covariance matrix C -= K*(mCH')' @@ -3922,9 +4027,11 @@ void KFParticleBaseSIMD::TransportLine(float_v dS, const float_v* dsdr, float_v **/ float_v mJ[8][8]; - for (Int_t i = 0; i < 8; i++) - for (Int_t j = 0; j < 8; j++) + for (Int_t i = 0; i < 8; i++) { + for (Int_t j = 0; j < 8; j++) { mJ[i][j] = 0; + } + } mJ[0][0] = 1; mJ[0][1] = 0; @@ -3977,27 +4084,36 @@ void KFParticleBaseSIMD::TransportLine(float_v dS, const float_v* dsdr, float_v P[7] = fP[7]; float_v mJds[6][6]; - for (Int_t i = 0; i < 6; i++) - for (Int_t j = 0; j < 6; j++) + for (Int_t i = 0; i < 6; i++) { + for (Int_t j = 0; j < 6; j++) { mJds[i][j] = 0; + } + } mJds[0][3] = 1; mJds[1][4] = 1; mJds[2][5] = 1; - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { mJ[i1][i2] += mJds[i1][3] * px * dsdr[i2] + mJds[i1][4] * py * dsdr[i2] + mJds[i1][5] * pz * dsdr[i2]; + } + } + MultQSQt(mJ[0], fC, C, 8); if (F) { - for (int i = 0; i < 6; i++) - for (int j = 0; j < 6; j++) + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 6; j++) { F[i * 6 + j] = mJ[i][j]; + } + } - for (int i1 = 0; i1 < 6; i1++) - for (int i2 = 0; i2 < 6; i2++) + for (int i1 = 0; i1 < 6; i1++) { + for (int i2 = 0; i2 < 6; i2++) { F1[i1 * 6 + i2] = mJds[i1][3] * px * dsdr1[i2] + mJds[i1][4] * py * dsdr1[i2] + mJds[i1][5] * pz * dsdr1[i2]; + } + } } } @@ -4144,14 +4260,16 @@ void KFParticleBaseSIMD::InvertCholetsky3(float_v a[6]) float_v d[3], uud, u[3][3]; for (int i = 0; i < 3; i++) { d[i] = 0.f; - for (int j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { u[i][j] = 0.f; + } } for (int i = 0; i < 3; i++) { uud = 0.f; - for (int j = 0; j < i; j++) + for (int j = 0; j < i; j++) { uud += u[j][i] * u[j][i] * d[j]; + } uud = a[i * (i + 3) / 2] - uud; uud(abs(uud) < 1.e-8f) = 1.e-8f; @@ -4160,8 +4278,9 @@ void KFParticleBaseSIMD::InvertCholetsky3(float_v a[6]) for (int j = i + 1; j < 3; j++) { uud = 0.f; - for (int k = 0; k < i; k++) + for (int k = 0; k < i; k++) { uud += u[k][i] * u[k][j] * d[k]; + } uud = a[j * (j + 1) / 2 + i] - uud; u[i][j] = d[i] / u[i][i] * uud; } @@ -4179,11 +4298,12 @@ void KFParticleBaseSIMD::InvertCholetsky3(float_v a[6]) for (int i = 0; i < 1; i++) { u[i][i + 2] = u[i][i + 1] * u1[i + 1] * u[i + 1][i + 2] - u[i][i + 2] * u[i][i] * u[i + 2][i + 2]; } - - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { a[i + 3] = u[i][2] * u[2][2] * d[2]; - for (int i = 0; i < 2; i++) + } + for (int i = 0; i < 2; i++) { a[i + 1] = u[i][1] * u[1][1] * d[1] + u[i][2] * u[1][2] * d[2]; + } a[0] = u[0][0] * u[0][0] * d[0] + u[0][1] * u[0][1] * d[1] + u[0][2] * u[0][2] * d[2]; } @@ -4201,8 +4321,9 @@ void KFParticleBaseSIMD::MultQSQt(const float_v Q[], const float_v S[], float_v for (Int_t i = 0, ij = 0; i < kN; i++) { for (Int_t j = 0; j < kN; j++, ++ij) { mA[ij] = 0; - for (Int_t k = 0; k < kN; ++k) + for (Int_t k = 0; k < kN; ++k) { mA[ij] += S[(k <= i) ? i * (i + 1) / 2 + k : k * (k + 1) / 2 + i] * Q[j * kN + k]; + } } } @@ -4210,13 +4331,15 @@ void KFParticleBaseSIMD::MultQSQt(const float_v Q[], const float_v S[], float_v for (Int_t j = 0; j <= i; j++) { Int_t ij = (j <= i) ? i * (i + 1) / 2 + j : j * (j + 1) / 2 + i; SOut[ij] = 0; - for (Int_t k = 0; k < kN; k++) + for (Int_t k = 0; k < kN; k++) { SOut[ij] += Q[i * kN + k] * mA[k * kN + j]; + } } } - if (mA) + if (mA) { delete[] mA; + } } // 72-charachters line to define the printer border diff --git a/KFParticle/KFParticleSIMD.cxx b/KFParticle/KFParticleSIMD.cxx index 41f3422..fffab26 100644 --- a/KFParticle/KFParticleSIMD.cxx +++ b/KFParticle/KFParticleSIMD.cxx @@ -63,8 +63,9 @@ void KFParticleSIMD::Create(const float_v Param[], const float_v Cov[], int_v Ch **/ float_v C[21]; - for (int i = 0; i < 21; i++) + for (int i = 0; i < 21; i++) { C[i] = Cov[i]; + } KFParticleBaseSIMD::Initialize(Param, C, Charge, mass); } @@ -85,15 +86,18 @@ KFParticleSIMD::KFParticleSIMD(const KFPTrack* track, Int_t PID) : KFParticleBas for (Int_t iPart = 0; iPart < float_vLen; iPart++) { track[iPart].XvYvZv(r); - for (Int_t i = 0; i < 3; i++) + for (Int_t i = 0; i < 3; i++) { fP[i][iPart] = r[i]; + } track[iPart].PxPyPz(r); - for (Int_t i = 0; i < 3; i++) + for (Int_t i = 0; i < 3; i++) { fP[i + 3][iPart] = r[i]; + } fQ[iPart] = track[iPart].Charge(); track[iPart].GetCovarianceXYZPxPyPz(C); - for (Int_t i = 0; i < 21; i++) + for (Int_t i = 0; i < 21; i++) { fC[i][iPart] = C[i]; + } } float_v mass = KFParticleDatabase::Instance()->GetMass(PID); @@ -120,15 +124,18 @@ KFParticleSIMD::KFParticleSIMD(KFPTrack& Track, const Int_t* pdg) : KFParticleBa Double_t C[21]; Track.XvYvZv(r); - for (Int_t i = 0; i < 3; i++) + for (Int_t i = 0; i < 3; i++) { fP[i] = r[i]; + } Track.PxPyPz(r); - for (Int_t i = 0; i < 3; i++) + for (Int_t i = 0; i < 3; i++) { fP[i + 3] = r[i]; + } fQ = Track.Charge(); Track.GetCovarianceXYZPxPyPz(C); - for (Int_t i = 0; i < 21; i++) + for (Int_t i = 0; i < 21; i++) { fC[i] = C[i]; + } float_v mass = KFParticleDatabase::Instance()->GetMass(*pdg); Create(fP, fC, fQ, mass); @@ -150,13 +157,16 @@ KFParticleSIMD::KFParticleSIMD(KFPTrackVector& track, int n, const Int_t* pdg) : ** \param[in] pdg - pointer to the pdg hypothesis **/ - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { fP[i] = track.Parameter(i)[n]; - for (int i = 0; i < 21; i++) + } + for (int i = 0; i < 21; i++) { fC[i] = track.Covariance(i)[n]; + } #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { fField.fField[i] = track.FieldCoefficient(i)[n]; + } #endif fQ = track.Q()[n]; @@ -192,15 +202,18 @@ void KFParticleSIMD::Create(KFPTrack* Track[], int NTracks, const Int_t* pdg) for (Int_t iPart = 0; iPart < float_vLen; iPart++) { Int_t iEntry = (iPart < NTracks) ? iPart : 0; Track[iEntry]->XvYvZv(r); - for (Int_t i = 0; i < 3; i++) + for (Int_t i = 0; i < 3; i++) { fP[i][iEntry] = r[i]; + } Track[iEntry]->PxPyPz(r); - for (Int_t i = 0; i < 3; i++) + for (Int_t i = 0; i < 3; i++) { fP[i + 3][iEntry] = r[i]; + } fQ[iEntry] = Track[iEntry]->Charge(); Track[iEntry]->GetCovarianceXYZPxPyPz(C); - for (Int_t i = 0; i < 21; i++) + for (Int_t i = 0; i < 21; i++) { fC[i][iEntry] = C[i]; + } } float_v mass = KFParticleDatabase::Instance()->GetMass(*pdg); @@ -238,13 +251,16 @@ void KFParticleSIMD::Create(KFPTrackVector& track, uint_v& index, const int_v& p ** \param[in] pdg - a SIMD vector with an individual pdg hypothesis for each element **/ - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { fP[i].gather(&(track.Parameter(i)[0]), index); - for (int i = 0; i < 21; i++) + } + for (int i = 0; i < 21; i++) { fC[i].gather(&(track.Covariance(i)[0]), index); + } #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { fField.fField[i].gather(&(track.FieldCoefficient(i)[0]), index); + } #endif // fPDG.gather(&(track.PDG()[0]), index); @@ -263,13 +279,16 @@ void KFParticleSIMD::Load(KFPTrackVector& track, int index, const int_v& pdg) ** \param[in] pdg - a SIMD vector with an individual pdg hypothesis for each element **/ - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { fP[i] = reinterpret_cast(track.Parameter(i)[index]); - for (int i = 0; i < 21; i++) + } + for (int i = 0; i < 21; i++) { fC[i] = reinterpret_cast(track.Covariance(i)[index]); + } #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { fField.fField[i] = reinterpret_cast(track.FieldCoefficient(i)[index]); + } #endif // fPDG.gather(&(track.PDG()[0]), index); @@ -283,13 +302,16 @@ void KFParticleSIMD::Rotate() { /** Rotates the entries of each SIMD vector of the data members. */ - for (int i = 0; i < 7; i++) + for (int i = 0; i < 7; i++) { fP[i] = fP[i].rotated(1); - for (int i = 0; i < 27; i++) + } + for (int i = 0; i < 27; i++) { fC[i] = fC[i].rotated(1); + } #ifdef NonhomogeneousField - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { fField.fField[i] = fField.fField[i].rotated(1); + } #endif fQ = fQ.rotated(1); fId = fId.rotated(1); @@ -320,8 +342,9 @@ void KFParticleSIMD::Create(KFPEmcCluster& track, uint_v& index, const KFParticl ** \param[in] vertexGuess - vertex guess for estimation of the momentum of created gamma particles **/ - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { fP[i].gather(&(track.Parameter(i)[0]), index); + } fP[6].gather(&(track.Parameter(3)[0]), index); const float_v& dx = fP[0] - vertexGuess.fP[0]; @@ -339,13 +362,15 @@ void KFParticleSIMD::Create(KFPEmcCluster& track, uint_v& index, const KFParticl fP[5] = dz / dl * fP[6]; float_v V[10]; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { V[i].gather(&(track.Covariance(i)[0]), index); - + } float_v J[7][4]; - for (int i = 0; i < 7; i++) - for (int j = 0; j < 4; j++) + for (int i = 0; i < 7; i++) { + for (int j = 0; j < 4; j++) { J[i][j] = 0.f; + } + } J[0][0] = 1.f; J[1][1] = 1.f; J[2][2] = 1.f; @@ -367,18 +392,23 @@ void KFParticleSIMD::Create(KFPEmcCluster& track, uint_v& index, const KFParticl for (Int_t i = 0; i < 4; i++) { for (Int_t j = 0; j < 7; j++) { VJT[i][j] = 0.f; - for (Int_t k = 0; k < 4; k++) + for (Int_t k = 0; k < 4; k++) { VJT[i][j] += V[IJ(i, k)] * J[j][k]; + } } } //Calculate the covariance matrix of the particle fC - for (Int_t i = 0; i < 36; i++) + for (Int_t i = 0; i < 36; i++) { fC[i] = 0.f; + } - for (Int_t i = 0; i < 7; ++i) - for (Int_t j = 0; j <= i; ++j) - for (Int_t l = 0; l < 4; l++) + for (Int_t i = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j) { + for (Int_t l = 0; l < 4; l++) { fC[IJ(i, j)] += J[i][l] * VJT[l][j]; + } + } + } fC[35] = 1.f; fQ = int_v(Vc::Zero); @@ -414,8 +444,9 @@ void KFParticleSIMD::Load(KFPEmcCluster& track, int index, const KFParticleSIMD& ** \param[in] vertexGuess - vertex guess for estimation of the momentum of created gamma particles **/ - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { fP[i] = reinterpret_cast(track.Parameter(i)[index]); + } fP[6] = reinterpret_cast(track.Parameter(3)[index]); const float_v& dx = fP[0] - vertexGuess.fP[0]; const float_v& dy = fP[1] - vertexGuess.fP[1]; @@ -432,13 +463,15 @@ void KFParticleSIMD::Load(KFPEmcCluster& track, int index, const KFParticleSIMD& fP[5] = dz / dl * fP[6]; float_v V[10]; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { V[i] = reinterpret_cast(track.Covariance(i)[index]); - + } float_v J[7][4]; - for (int i = 0; i < 7; i++) - for (int j = 0; j < 4; j++) + for (int i = 0; i < 7; i++) { + for (int j = 0; j < 4; j++) { J[i][j] = 0.f; + } + } J[0][0] = 1.f; J[1][1] = 1.f; J[2][2] = 1.f; @@ -460,18 +493,23 @@ void KFParticleSIMD::Load(KFPEmcCluster& track, int index, const KFParticleSIMD& for (Int_t i = 0; i < 4; i++) { for (Int_t j = 0; j < 7; j++) { VJT[i][j] = 0.f; - for (Int_t k = 0; k < 4; k++) + for (Int_t k = 0; k < 4; k++) { VJT[i][j] += V[IJ(i, k)] * J[j][k]; + } } } //Calculate the covariance matrix of the particle fC - for (Int_t i = 0; i < 36; i++) + for (Int_t i = 0; i < 36; i++) { fC[i] = 0.f; + } - for (Int_t i = 0; i < 7; ++i) - for (Int_t j = 0; j <= i; ++j) - for (Int_t l = 0; l < 4; l++) + for (Int_t i = 0; i < 7; ++i) { + for (Int_t j = 0; j <= i; ++j) { + for (Int_t l = 0; l < 4; l++) { fC[IJ(i, j)] += J[i][l] * VJT[l][j]; + } + } + } fC[35] = 1.f; fQ = int_v(Vc::Zero); @@ -496,11 +534,13 @@ KFParticleSIMD::KFParticleSIMD(const KFPVertex& vertex) : KFParticleBaseSIMD() Double_t C[21]; vertex.GetXYZ(r); - for (Int_t i = 0; i < 3; i++) + for (Int_t i = 0; i < 3; i++) { fP[i] = r[i]; + } vertex.GetCovarianceMatrix(C); - for (Int_t i = 0; i < 21; i++) + for (Int_t i = 0; i < 21; i++) { fC[i] = C[i]; + } fChi2 = vertex.GetChi2(); fNDF = 2 * vertex.GetNContributors() - 3; fQ = int_v(Vc::Zero); @@ -516,10 +556,12 @@ void KFParticleSIMD::SetOneEntry(int iEntry, KFParticleSIMD& part, int iEntryPar ** \param[in] iEntryPart - index of the element of particle part, which should be copied to the current particle **/ - for (int i = 0; i < 7; ++i) + for (int i = 0; i < 7; ++i) { fP[i][iEntry] = part.Parameters()[i][iEntryPart]; - for (int i = 0; i < 36; ++i) + } + for (int i = 0; i < 36; ++i) { fC[i][iEntry] = part.CovarianceMatrix()[i][iEntryPart]; + } fQ[iEntry] = part.Q()[iEntryPart]; fNDF[iEntry] = part.NDF()[iEntryPart]; @@ -533,11 +575,13 @@ void KFParticleSIMD::SetOneEntry(int iEntry, KFParticleSIMD& part, int iEntryPar fPDG[iEntry] = part.GetPDG()[iEntryPart]; - if (iEntry == 0) + if (iEntry == 0) { fDaughterIds.resize(part.NDaughters(), int_v(-1)); + } - for (int iD = 0; iD < part.NDaughters(); iD++) + for (int iD = 0; iD < part.NDaughters(); iD++) { fDaughterIds[iD][iEntry] = part.fDaughterIds[iD][iEntryPart]; + } #ifdef NonhomogeneousField fField.SetOneEntry(iEntry, part.fField, iEntryPart); //CHECKME @@ -575,16 +619,17 @@ KFParticleSIMD::KFParticleSIMD(KFParticle* parts[], const int nPart) : KFParticl KFParticle& part = *(parts[iEntry]); fId[iEntry] = part.Id(); - for (int iD = 0; iD < part.NDaughters(); iD++) + for (int iD = 0; iD < part.NDaughters(); iD++) { fDaughterIds[iD][iEntry] = part.DaughterIds()[iD]; - + } fPDG[iEntry] = part.GetPDG(); - for (int i = 0; i < 8; ++i) + for (int i = 0; i < 8; ++i) { fP[i][iEntry] = part.Parameters()[i]; - for (int i = 0; i < 36; ++i) + } + for (int i = 0; i < 36; ++i) { fC[i][iEntry] = part.CovarianceMatrix()[i]; - + } fNDF[iEntry] = part.GetNDF(); fChi2[iEntry] = part.GetChi2(); fQ[iEntry] = part.GetQ(); @@ -617,11 +662,12 @@ KFParticleSIMD::KFParticleSIMD(KFParticle& part) : KFParticleBaseSIMD() fDaughterIds.push_back(part.DaughterIds()[i]); } - for (int i = 0; i < 8; ++i) + for (int i = 0; i < 8; ++i) { fP[i] = part.Parameters()[i]; - for (int i = 0; i < 36; ++i) + } + for (int i = 0; i < 36; ++i) { fC[i] = part.CovarianceMatrix()[i]; - + } #ifdef NonhomogeneousField fField = KFParticleFieldRegion(part.GetFieldCoeff()); #endif @@ -793,8 +839,9 @@ float_v KFParticleSIMD::GetDeviationFromParticleXY(const KFParticleSIMD& p) cons MultQSQt(F2, p.fC, V0Tmp, 6); MultQSQt(F3, fC, V1Tmp, 6); - for (int iC = 0; iC < 3; iC++) + for (int iC = 0; iC < 3; iC++) { mC1[iC] += V0Tmp[iC] + mC2[iC] + V1Tmp[iC]; + } float_v d[3] = {mP2[0] - mP1[0], mP2[1] - mP1[1], mP2[2] - mP1[2]}; @@ -822,22 +869,25 @@ float_v KFParticleSIMD::GetDeviationFromVertexXY(const float_v vtx[], const floa if (Cv) { float_v VFT[3][6]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { for (int j = 0; j < 6; j++) { VFT[i][j] = 0; for (int k = 0; k < 3; k++) { VFT[i][j] += Cv[IJ(i, k)] * F1[j * 6 + k]; } } + } float_v FVFT[6][6]; - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { FVFT[i][j] = 0; for (int k = 0; k < 3; k++) { FVFT[i][j] += F1[i * 6 + k] * VFT[k][j]; } } + } + mC[0] += FVFT[0][0] + Cv[0]; mC[1] += FVFT[1][0] + Cv[1]; mC[2] += FVFT[1][1] + Cv[2]; @@ -1028,23 +1078,26 @@ void KFParticleSIMD::GetKFParticle(KFParticle& Part, int iPart) Part.SetId(static_cast(Id()[iPart])); Part.CleanDaughtersId(); - for (unsigned int i = 0; i < DaughterIds().size(); i++) + for (unsigned int i = 0; i < DaughterIds().size(); i++) { Part.AddDaughterId(static_cast(DaughterIds()[i][iPart])); + } Part.SetPDG(static_cast(GetPDG()[iPart])); - for (int iP = 0; iP < 8; iP++) + for (int iP = 0; iP < 8; iP++) { Part.Parameters()[iP] = Parameters()[iP][iPart]; - for (int iC = 0; iC < 36; iC++) + } + for (int iC = 0; iC < 36; iC++) { Part.CovarianceMatrix()[iC] = CovarianceMatrix()[iC][iPart]; - + } Part.NDF() = static_cast(GetNDF()[iPart]); Part.Chi2() = GetChi2()[iPart]; Part.Q() = GetQ()[iPart]; Part.SetAtProductionVertex(fAtProductionVertex); #ifdef NonhomogeneousField - for (int iF = 0; iF < 10; iF++) + for (int iF = 0; iF < 10; iF++) { Part.SetFieldCoeff(fField.fField[iF][iPart], iF); + } #endif } @@ -1055,6 +1108,7 @@ void KFParticleSIMD::GetKFParticle(KFParticle* Part, int nPart) ** \param[in] nPart - number of elements to be copied to the array of scalar objects **/ - for (int i = 0; i < nPart; i++) + for (int i = 0; i < nPart; i++) { GetKFParticle(Part[i], i); + } } diff --git a/KFParticle/KFParticleTopoReconstructor.cxx b/KFParticle/KFParticleTopoReconstructor.cxx index ae46976..68d541a 100644 --- a/KFParticle/KFParticleTopoReconstructor.cxx +++ b/KFParticle/KFParticleTopoReconstructor.cxx @@ -40,12 +40,15 @@ using std::vector; KFParticleTopoReconstructor::~KFParticleTopoReconstructor() { /** The default destructor. Deallocates memory for all pointers if objects exist. **/ - if (fKFParticlePVReconstructor) + if (fKFParticlePVReconstructor) { delete fKFParticlePVReconstructor; - if (fKFParticleFinder) + } + if (fKFParticleFinder) { delete fKFParticleFinder; - if (fTracks) + } + if (fTracks) { delete[] fTracks; + } } #ifdef HomogeneousField @@ -60,9 +63,9 @@ void KFParticleTopoReconstructor::SetField(double b) #ifdef KFPWITHTRACKER void KFParticleTopoReconstructor::Init(AliHLTTPCCAGBTracker* tracker, vector* pdg) { - if (!fTracks) + if (!fTracks) { fTracks = new KFPTrackVector[NInputSets]; - + } fTracks[0].Resize(0); fTracks[1].Resize(0); fTracks[2].Resize(0); @@ -130,9 +133,11 @@ void KFParticleTopoReconstructor::Init(AliHLTTPCCAGBTracker* tracker, vector x J[1][1] = 1; // y -> y J[2][2] = 1; // z -> z @@ -160,22 +165,24 @@ void KFParticleTopoReconstructor::Init(AliHLTTPCCAGBTracker* tracker, vector triangular { @@ -201,19 +208,21 @@ void KFParticleTopoReconstructor::Init(AliHLTTPCCAGBTracker* tracker, vector& particles, vector& particles, vectorat(iTr); - - for (int iP = 0; iP < 6; iP++) + } + for (int iP = 0; iP < 6; iP++) { fTracks[0].SetParameter(particles[iTr].Parameters()[iP], iP, iTr); - for (int iC = 0; iC < 21; iC++) + } + for (int iC = 0; iC < 21; iC++) { fTracks[0].SetCovariance(particles[iTr].CovarianceMatrix()[iC], iC, iTr); + } // fTracks[0].SetId(iTr, iTr); fTracks[0].SetId(particles[iTr].Id(), iTr); fTracks[0].SetPDG(trackPDG, iTr); @@ -302,8 +314,9 @@ void KFParticleTopoReconstructor::Init(KFPTrackVector& tracks, KFPTrackVector& t timer.Start(); #endif // USE_TIMERS - if (!fTracks) + if (!fTracks) { fTracks = new KFPTrackVector[NInputSets]; + } fParticles.clear(); fPV.clear(); @@ -340,8 +353,9 @@ void KFParticleTopoReconstructor::Init(const KFPTrackVector* particles, const ve fChiToPrimVtx[1].resize(fTracks[1].Size()); fPV.resize(pv.size()); - for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) + for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { fPV[iPV] = KFParticleSIMD(const_cast(pv[iPV])); + } #ifdef USE_TIMERS timer.Stop(); @@ -351,7 +365,7 @@ void KFParticleTopoReconstructor::Init(const KFPTrackVector* particles, const ve void KFParticleTopoReconstructor::ReconstructPrimVertex(bool isHeavySystem) { - /** Runs reconstruction of primary vertices. If "isHeavySystem" is defined - only the +/** Runs reconstruction of primary vertices. If "isHeavySystem" is defined - only the ** best vertex with the maximum number of tracks-contributors is stored. **/ #ifdef USE_TIMERS @@ -366,11 +380,12 @@ void KFParticleTopoReconstructor::ReconstructPrimVertex(bool isHeavySystem) if (isHeavySystem) { if (NPrimaryVertices() > 1) { unsigned int nMax = GetPVTrackIndexArray(0).size(); - for (int i = 1; i < NPrimaryVertices(); i++) + for (int i = 1; i < NPrimaryVertices(); i++) { if (GetPVTrackIndexArray(i).size() > nMax) { nMax = GetPVTrackIndexArray(i).size(); nPV = i; } + } } nPrimVtx = 1; @@ -378,22 +393,25 @@ void KFParticleTopoReconstructor::ReconstructPrimVertex(bool isHeavySystem) fPV[0] = GetPrimVertex(nPV); } else { fPV.resize(nPrimVtx); - for (int iPV = 0; iPV < nPrimVtx; iPV++) + for (int iPV = 0; iPV < nPrimVtx; iPV++) { fPV[iPV] = GetPrimVertex(iPV); + } } for (int iPV = 0; iPV < NPrimaryVertices(); iPV++) { int pvI = iPV; if (isHeavySystem) { - if (iPV != nPV) + if (iPV != nPV) { continue; + } pvI = 0; //save only one PV } vector& tracks = GetPVTrackIndexArray(iPV); - for (unsigned int iTr = 0; iTr < tracks.size(); iTr++) + for (unsigned int iTr = 0; iTr < tracks.size(); iTr++) { fTracks[0].SetPVIndex(pvI, tracks[iTr]); + } } if (isHeavySystem) { @@ -411,7 +429,7 @@ void KFParticleTopoReconstructor::ReconstructPrimVertex(bool isHeavySystem) void KFParticleTopoReconstructor::SortTracks() { - /** Sorts input tracks according to they charge, relation to the primary +/** Sorts input tracks according to they charge, relation to the primary ** vertex candidates, PDG hypothesis. The tracks after sorting are divided ** into several groups: \n ** 0) secondary positive at the first hit position; \n @@ -432,16 +450,18 @@ void KFParticleTopoReconstructor::SortTracks() int offset[2] = {0, 4}; int nSets = 2; - if (fTracks[4].Size() == 0) + if (fTracks[4].Size() == 0) { nSets = 1; + } for (int iSet = nSets - 1; iSet >= 0; iSet--) { int Size = fTracks[0].Size(); vector sortedTracks(Size); kfvector_uint trackIndex[4]; - for (int iTV = 0; iTV < 4; iTV++) + for (int iTV = 0; iTV < 4; iTV++) { trackIndex[iTV].resize(Size); + } int nTracks[4] = {0, 0, 0, 0}; for (int iTr = 0; iTr < Size; iTr++) { @@ -458,7 +478,6 @@ void KFParticleTopoReconstructor::SortTracks() int q = fTracks[0].Q()[iTrSorted]; //take the charge at the first point to avoid ambiguities in array size if (fTracks[0].PVIndex()[iTrSorted] < 0) //secondary track { - if (q < 0) //secondary negative track { trackIndex[1][nTracks[1]] = iTrSorted; @@ -482,16 +501,18 @@ void KFParticleTopoReconstructor::SortTracks() } } - for (int iTV = 1; iTV < 4; iTV++) + for (int iTV = 1; iTV < 4; iTV++) { fTracks[iTV + offset[iSet]].SetTracks(fTracks[offset[iSet]], trackIndex[iTV], nTracks[iTV]); + } KFPTrackVector positive; positive.SetTracks(fTracks[offset[iSet]], trackIndex[0], nTracks[0]); fTracks[offset[iSet]].Resize(nTracks[0]); fTracks[offset[iSet]].Set(positive, nTracks[0], 0); - for (int iTV = 0; iTV < 4; iTV++) + for (int iTV = 0; iTV < 4; iTV++) { fTracks[iTV + offset[iSet]].RecalculateLastIndex(); + } //correct index of tracks in primary clusters with respect to the sorted array if (iSet == 0) { @@ -504,9 +525,11 @@ void KFParticleTopoReconstructor::SortTracks() } } - for (int iPV = 0; iPV < NPrimaryVertices(); iPV++) - for (unsigned int iTrack = 0; iTrack < GetPVTrackIndexArray(iPV).size(); iTrack++) + for (int iPV = 0; iPV < NPrimaryVertices(); iPV++) { + for (unsigned int iTrack = 0; iTrack < GetPVTrackIndexArray(iPV).size(); iTrack++) { fKFParticlePVReconstructor->GetPVTrackIndexArray(iPV)[iTrack] = newIndex[GetPVTrackIndexArray(iPV)[iTrack]]; + } + } } } @@ -537,8 +560,9 @@ void KFParticleTopoReconstructor::TransportPVTracksToPrimVertex() tmpPart.Load(fTracks[iTV], iTr, pdg); for (unsigned int iV = 0; iV < (unsigned int)float_vLen; iV++) { - if (iV + iTr >= NTr) + if (iV + iTr >= NTr) { continue; + } int iPV = pvIndex[iV]; point[0][iV] = fPV[iPV].X()[0]; @@ -548,10 +572,12 @@ void KFParticleTopoReconstructor::TransportPVTracksToPrimVertex() tmpPart.TransportToPoint(point); - for (int iP = 0; iP < 6; iP++) + for (int iP = 0; iP < 6; iP++) { fTracks[iTV].SetParameter(tmpPart.GetParameter(iP), iP, iTr); - for (int iC = 0; iC < 21; iC++) + } + for (int iC = 0; iC < 21; iC++) { fTracks[iTV].SetCovariance(tmpPart.GetCovariance(iC), iC, iTr); + } } } } @@ -656,18 +682,21 @@ void KFParticleTopoReconstructor::SelectParticleCandidates() } for (unsigned int iParticle = 0; iParticle < fParticles.size(); iParticle++) { - if (!UseParticleInCompetition(fParticles[iParticle].GetPDG())) + if (!UseParticleInCompetition(fParticles[iParticle].GetPDG())) { continue; + } bool isSecondary = 1; for (int iPV = 0; iPV < NPrimaryVertices(); iPV++) { KFParticle tmp = fParticles[iParticle]; tmp.SetProductionVertex(GetPrimVertex(iPV)); - if (tmp.Chi2() / tmp.NDF() < 5) + if (tmp.Chi2() / tmp.NDF() < 5) { isSecondary = 0; + } } - if (isSecondary) + if (isSecondary) { deleteCandidate[iParticle] = true; + } } // for(unsigned int iParticle=0; iParticle 3.f) continue; for (unsigned int jParticle = iParticle + 1; jParticle < fParticles.size(); jParticle++) { - if (deleteCandidate[jParticle]) + if (deleteCandidate[jParticle]) { continue; - if (!UseParticleInCompetition(fParticles[jParticle].GetPDG())) + } + if (!UseParticleInCompetition(fParticles[jParticle].GetPDG())) { continue; + } fParticles[jParticle].GetMass(mass, massSigma); KFParticleDatabase::Instance()->GetMotherMass(fParticles[jParticle].GetPDG(), massPDG, massPDGSigma); @@ -737,8 +770,9 @@ void KFParticleTopoReconstructor::SelectParticleCandidates() // if(dm2 > 3.f) continue; if (!(fParticles[iParticle].DaughterIds()[0] == fParticles[jParticle].DaughterIds()[0] && - fParticles[iParticle].DaughterIds()[1] == fParticles[jParticle].DaughterIds()[1])) + fParticles[iParticle].DaughterIds()[1] == fParticles[jParticle].DaughterIds()[1])) { continue; + } if (dm1 < 3.f || dm2 < 3.f) { // if(dm1 < 3.f && dm2<3.f) @@ -790,10 +824,12 @@ void KFParticleTopoReconstructor::SelectParticleCandidates() //clean dielectron spectrum //at first - both electrons are identified for (unsigned int iParticle = 0; iParticle < fParticles.size(); iParticle++) { - if (deleteCandidate[iParticle]) + if (deleteCandidate[iParticle]) { continue; - if (!(abs(fParticles[iParticle].GetPDG()) == 22)) + } + if (!(abs(fParticles[iParticle].GetPDG()) == 22)) { continue; + } // bool bothDaughtersElectrons = 1; // for(int iDaughter=0; iDaughterGetMotherMass(fParticles[iParticle].GetPDG(), massPDG, massPDGSigma); float dm = fabs(mass - massPDG) / massPDGSigma; - if (dm < 3.f) + if (dm < 3.f) { particleInfo.push_back(ParticleInfo(iParticle, dm)); + } } std::sort(particleInfo.begin(), particleInfo.end(), ParticleInfo::compare); for (unsigned int iPI = 0; iPI < particleInfo.size(); iPI++) { const int index = particleInfo[iPI].fParticleIndex; - if (deleteCandidate[index]) + if (deleteCandidate[index]) { continue; - + } bool isStore = true; - for (int iDaughter = 0; iDaughter < fParticles[index].NDaughters(); iDaughter++) + for (int iDaughter = 0; iDaughter < fParticles[index].NDaughters(); iDaughter++) { isStore &= !(isUsed[fParticles[index].DaughterIds()[iDaughter]]); - + } if (isStore) { - for (int iDaughter = 0; iDaughter < fParticles[index].NDaughters(); iDaughter++) + for (int iDaughter = 0; iDaughter < fParticles[index].NDaughters(); iDaughter++) { isUsed[fParticles[index].DaughterIds()[iDaughter]] = true; - } else + } + } else { deleteCandidate[index] = true; + } } for (unsigned int iParticle = 0; iParticle < fParticles.size(); iParticle++) { - if (deleteCandidate[iParticle]) + if (deleteCandidate[iParticle]) { continue; - if (!(abs(fParticles[iParticle].GetPDG()) == 22)) + } + if (!(abs(fParticles[iParticle].GetPDG()) == 22)) { continue; + } bool bothDaughtersElectrons = 1; for (int iDaughter = 0; iDaughter < fParticles[iParticle].NDaughters(); iDaughter++) { @@ -852,8 +893,9 @@ void KFParticleTopoReconstructor::SelectParticleCandidates() // if( (bothDaughtersElectrons && dm > 3.f) || !bothDaughtersElectrons) if (dm > 3.f) { bool isStore = true; - for (int iDaughter = 0; iDaughter < fParticles[iParticle].NDaughters(); iDaughter++) + for (int iDaughter = 0; iDaughter < fParticles[iParticle].NDaughters(); iDaughter++) { isStore &= !(isUsed[fParticles[iParticle].DaughterIds()[iDaughter]]); + } if (!isStore) { deleteCandidate[iParticle] = true; } @@ -862,8 +904,9 @@ void KFParticleTopoReconstructor::SelectParticleCandidates() // clean LMVM spectrum for (unsigned int iParticle = 0; iParticle < fParticles.size(); iParticle++) { - if (!(abs(fParticles[iParticle].GetPDG()) == 100113 || abs(fParticles[iParticle].GetPDG()) == 443)) + if (!(abs(fParticles[iParticle].GetPDG()) == 100113 || abs(fParticles[iParticle].GetPDG()) == 443)) { continue; + } bool bothDaughtersElectrons = 1; for (int iDaughter = 0; iDaughter < fParticles[iParticle].NDaughters(); iDaughter++) { @@ -876,8 +919,9 @@ void KFParticleTopoReconstructor::SelectParticleCandidates() } bool isStore = true; - for (int iDaughter = 0; iDaughter < fParticles[iParticle].NDaughters(); iDaughter++) + for (int iDaughter = 0; iDaughter < fParticles[iParticle].NDaughters(); iDaughter++) { isStore &= !(isUsed[fParticles[iParticle].DaughterIds()[iDaughter]]); + } if (!isStore) { deleteCandidate[iParticle] = true; } @@ -923,19 +967,23 @@ void KFParticleTopoReconstructor::SelectParticleCandidates() // } for (int iParticle = 0; iParticle < int(fParticles.size()); iParticle++) { - if (deleteCandidate[iParticle]) + if (deleteCandidate[iParticle]) { continue; + } - for (int iDaughter = 0; iDaughter < fParticles[iParticle].NDaughters(); iDaughter++) + for (int iDaughter = 0; iDaughter < fParticles[iParticle].NDaughters(); iDaughter++) { if (bestMother[fParticles[iParticle].DaughterIds()[iDaughter]] != iParticle && bestMother[fParticles[iParticle].DaughterIds()[iDaughter]] > -1) { deleteCandidate[iParticle] = true; break; } + } } - for (unsigned int iParticle = 0; iParticle < fParticles.size(); iParticle++) - if (deleteCandidate[iParticle]) + for (unsigned int iParticle = 0; iParticle < fParticles.size(); iParticle++) { + if (deleteCandidate[iParticle]) { fParticles[iParticle].SetPDG(-1); + } + } } bool KFParticleTopoReconstructor::ParticleHasRepeatingDaughters(const KFParticle& particle) @@ -944,8 +992,9 @@ bool KFParticleTopoReconstructor::ParticleHasRepeatingDaughters(const KFParticle ** with the same index including tracks from the daughter particles in the decay ** chains. Such candidates should be rejected. **/ - if (particle.NDaughters() < 2) + if (particle.NDaughters() < 2) { return 0; + } vector daughters; GetListOfDaughterTracks(particle, daughters); @@ -967,16 +1016,18 @@ void KFParticleTopoReconstructor::GetListOfDaughterTracks(const KFParticle& part ** \param[in] particle - the particle to be processed ** \param[out] daughters - a vector with indices of all daughter tracks **/ - if (particle.NDaughters() == 1) + if (particle.NDaughters() == 1) { daughters.push_back(particle.DaughterIds()[0]); - else - for (int iDaughter = 0; iDaughter < particle.NDaughters(); iDaughter++) + } else { + for (int iDaughter = 0; iDaughter < particle.NDaughters(); iDaughter++) { GetListOfDaughterTracks(fParticles[particle.DaughterIds()[iDaughter]], daughters); + } + } } void KFParticleTopoReconstructor::ReconstructParticles() { - /** Runs reconstruction of the short-lived particles by KFParticleFinder. +/** Runs reconstruction of the short-lived particles by KFParticleFinder. ** At first, primary tracks are transported to the DCA point with the ** corresponding primary vertices for better precision, ** chi2-deviation of the secondary tracks to the primary vertex is @@ -989,8 +1040,9 @@ void KFParticleTopoReconstructor::ReconstructParticles() fParticles.clear(); - if (fPV.size() < 1) + if (fPV.size() < 1) { return; + } TransportPVTracksToPrimVertex(); //calculate chi to primary vertex, chi = sqrt(dr C-1 dr) @@ -1018,12 +1070,14 @@ void KFParticleTopoReconstructor::SendDataToXeonPhi(int iHLT, scif_epd_t& endpoi //pack the input data int* data = reinterpret_cast(buffer); int dataSize = NInputSets + 1 + 1; //sizes of the track vectors and pv vector, and field - for (int iSet = 0; iSet < NInputSets; iSet++) + for (int iSet = 0; iSet < NInputSets; iSet++) { dataSize += fTracks[iSet].DataSize(); + } dataSize += fPV.size() * 9; - for (int iSet = 0; iSet < NInputSets; iSet++) + for (int iSet = 0; iSet < NInputSets; iSet++) { data[iSet] = fTracks[iSet].Size(); + } data[NInputSets] = fPV.size(); float& field = reinterpret_cast(data[NInputSets + 1]); @@ -1031,8 +1085,9 @@ void KFParticleTopoReconstructor::SendDataToXeonPhi(int iHLT, scif_epd_t& endpoi int offset = NInputSets + 2; - for (int iSet = 0; iSet < NInputSets; iSet++) + for (int iSet = 0; iSet < NInputSets; iSet++) { fTracks[iSet].SetDataToVector(data, offset); + } for (int iP = 0; iP < 3; iP++) { for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { @@ -1064,9 +1119,9 @@ void KFParticleTopoReconstructor::SendDataToXeonPhi(int iHLT, scif_epd_t& endpoi } int ret = scif_writeto(endpoint, offsetServer, msgSize, offsetSender, 0); - if (ret == -1) + if (ret == -1) { std::cout << "Fail sending array to the server. Error: " << errno << std::endl; - + } scif_send(endpoint, &controlSignal, sizeof(int), SCIF_SEND_BLOCK); // synchronization } #endif @@ -1093,9 +1148,9 @@ void KFParticleTopoReconstructor::SaveInputParticles(const string prefix, bool o //save tracks. tracks are already propagated to the beam int nSets = NInputSets; - if (onlySecondary) + if (onlySecondary) { nSets = 2; - + } float B[3] = {0.f}, r[3] = {0.f}; KFParticle kfpTmp; kfpTmp.GetFieldValue(r, B); @@ -1104,31 +1159,37 @@ void KFParticleTopoReconstructor::SaveInputParticles(const string prefix, bool o for (int iSet = 0; iSet < nSets; iSet++) { out << fTracks[iSet].Size() << std::endl; for (int iP = 0; iP < 6; iP++) { - for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) + for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) { out << fTracks[iSet].Parameter(iP)[iTr] << " "; + } out << std::endl; } for (int iC = 0; iC < 21; iC++) { - for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) + for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) { out << fTracks[iSet].Covariance(iC)[iTr] << " "; + } out << std::endl; } - for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) + for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) { out << fTracks[iSet].Id()[iTr] << " "; + } out << std::endl; - for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) + for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) { out << fTracks[iSet].PDG()[iTr] << " "; + } out << std::endl; - for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) + for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) { out << fTracks[iSet].Q()[iTr] << " "; + } out << std::endl; - for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) + for (int iTr = 0; iTr < fTracks[iSet].Size(); iTr++) { out << fTracks[iSet].PVIndex()[iTr] << " "; + } out << std::endl; out << fTracks[iSet].LastElectron() << " " @@ -1143,8 +1204,9 @@ void KFParticleTopoReconstructor::SaveInputParticles(const string prefix, bool o for (unsigned int iPV = 0; iPV < fPV.size(); iPV++) { out << fPV[iPV].X()[0] << " " << fPV[iPV].Y()[0] << " " << fPV[iPV].Z()[0] << " " << std::endl; - for (int iC = 0; iC < 6; iC++) + for (int iC = 0; iC < 6; iC++) { out << fPV[iPV].GetCovariance(iC)[0] << " "; + } out << std::endl; } out.close();