Skip to content

Commit

Permalink
Add track momentum test, remove cc from CMakeLists
Browse files Browse the repository at this point in the history
  • Loading branch information
dudarboh committed Oct 17, 2022
1 parent 0ed4d96 commit 4cb3d67
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ SET( LCIO_UTIL_SRCS
./src/UTIL/PIDHandler.cc
./src/UTIL/ILDConf.cc
./src/UTIL/ProcessFlag.cc
./src/UTIL/TrackTools.cc
./src/UTIL/LCCollectionTools.cc
./src/UTIL/ReconstructedParticleTools.cc
)
Expand Down
49 changes: 48 additions & 1 deletion src/cpp/src/TESTS/test_tracks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "UTIL/Operators.h"
#include "UTIL/LCIterator.h"
#include "UTIL/TrackTools.h"

#include <sstream>
#include <assert.h>
Expand Down Expand Up @@ -218,6 +219,13 @@ int main(int /*argc*/, char** /*argv*/ ){
ss << " ref[" << k << "] " ;
MYTEST( ref[k] , float(k+1) , ss.str() ) ;
}

//Test of the getTrackMomentum
double trkPx = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*std::cos((i+j) * .3);
double trkPy = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*std::sin((i+j) * .3);
double trkPz = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*(i+j) * .2;
std::array<double, 3> trkRecoP = UTIL::getTrackMomentum(trk, 3.5);
MYTEST( std::sqrt(trkRecoP[0]*trkRecoP[0] + trkRecoP[1]*trkRecoP[1] + trkRecoP[2]*trkRecoP[2]), std::sqrt(trkPx*trkPx + trkPy*trkPy + trkPz*trkPz), "getTrackMomentum");

++j ;
}
Expand Down Expand Up @@ -259,6 +267,13 @@ int main(int /*argc*/, char** /*argv*/ ){
MYTEST( ref[k] , float(k+1) , ss.str() ) ;
}

//Test of the getTrackMomentum
double trkPx = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*std::cos((i+j) * .3);
double trkPy = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*std::sin((i+j) * .3);
double trkPz = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*(i+j) * .2;
std::array<double, 3> trkRecoP = UTIL::getTrackMomentum(trk, 3.5);
MYTEST( std::sqrt(trkRecoP[0]*trkRecoP[0] + trkRecoP[1]*trkRecoP[1] + trkRecoP[2]*trkRecoP[2]), std::sqrt(trkPx*trkPx + trkPy*trkPy + trkPz*trkPz), "getTrackMomentum");

++j ;
}

Expand Down Expand Up @@ -307,6 +322,13 @@ int main(int /*argc*/, char** /*argv*/ ){
ss << " ref[" << k << "] " ;
MYTEST( ref[k] , float(k+1) , ss.str() ) ;
}

//Test of the getTrackMomentum
double trkPx = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*std::cos((i+j) * .3);
double trkPy = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*std::sin((i+j) * .3);
double trkPz = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*(i+j) * .2;
std::array<double, 3> trkRecoP = UTIL::getTrackMomentum(trk, 3.5);
MYTEST( std::sqrt(trkRecoP[0]*trkRecoP[0] + trkRecoP[1]*trkRecoP[1] + trkRecoP[2]*trkRecoP[2]), std::sqrt(trkPx*trkPx + trkPy*trkPy + trkPz*trkPz), "getTrackMomentum");

// more than one trackstate
const TrackStateVec& trackstates = trk->getTrackStates() ;
Expand Down Expand Up @@ -337,6 +359,14 @@ int main(int /*argc*/, char** /*argv*/ ){
ss << " ref[" << l << "] " ;
MYTEST( refL[l] , float(k*(l+1)) , ss.str() ) ;
}

//Test of the getTrackMomentum
double tsPx = (1e-6 * 299.792458 * 3.5) / std::abs((i+j+k) * .1)*std::cos((i+j+k) * .3);
double tsPy = (1e-6 * 299.792458 * 3.5) / std::abs((i+j+k) * .1)*std::sin((i+j+k) * .3);
double tsPz = (1e-6 * 299.792458 * 3.5) / std::abs((i+j+k) * .1)*(i+j) * .2;
std::array<double, 3> tsRecoP = UTIL::getTrackMomentum(trackstates[k], 3.5);
MYTEST( std::sqrt(tsRecoP[0]*tsRecoP[0] + tsRecoP[1]*tsRecoP[1] + tsRecoP[2]*tsRecoP[2]), std::sqrt(tsPx*tsPx + tsPy*tsPy + tsPz*tsPz), "getTrackMomentum");

}


Expand Down Expand Up @@ -371,6 +401,16 @@ int main(int /*argc*/, char** /*argv*/ ){
MYTEST( ref[k] , float(k+1) , ss.str() ) ;
}



//Test of the getTrackMomentum
double trkcPx = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*std::cos((i+j) * .3);
double trkcPy = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*std::sin((i+j) * .3);
double trkcPz = (1e-6 * 299.792458 * 3.5) / std::abs((i+j) * .1)*(i+j) * .2;
std::array<double, 3> trkcRecoP = UTIL::getTrackMomentum(trkc, 3.5);
MYTEST( std::sqrt(trkcRecoP[0]*trkcRecoP[0] + trkcRecoP[1]*trkcRecoP[1] + trkcRecoP[2]*trkcRecoP[2]), std::sqrt(trkcPx*trkcPx + trkcPy*trkcPy + trkcPz*trkcPz), "getTrackMomentum");


// more than one trackstate
const TrackStateVec& trackstatesc = trkc->getTrackStates() ;

Expand All @@ -397,6 +437,14 @@ int main(int /*argc*/, char** /*argv*/ ){
ss << " ref[" << l << "] " ;
MYTEST( refL[l] , float(k*(l+1)) , ss.str() ) ;
}

//Test of the getTrackMomentum
double tscPx = (1e-6 * 299.792458 * 3.5) / std::abs((i+j+k) * .1)*std::cos((i+j+k) * .3);
double tscPy = (1e-6 * 299.792458 * 3.5) / std::abs((i+j+k) * .1)*std::sin((i+j+k) * .3);
double tscPz = (1e-6 * 299.792458 * 3.5) / std::abs((i+j+k) * .1)*(i+j) * .2;
std::array<double, 3> tscRecoP = UTIL::getTrackMomentum(trackstatesc[k], 3.5);
MYTEST( std::sqrt(tscRecoP[0]*tscRecoP[0] + tscRecoP[1]*tscRecoP[1] + tscRecoP[2]*tscRecoP[2]), std::sqrt(tscPx*tscPx + tscPy*tscPy + tscPz*tscPz), "getTrackMomentum");

}

// ---------- end test copies -------------------------------
Expand Down Expand Up @@ -443,4 +491,3 @@ int main(int /*argc*/, char** /*argv*/ ){
}

//=============================================================================

0 comments on commit 4cb3d67

Please sign in to comment.