diff --git a/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx b/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx index beb21bab9b7cc83c6824b95ad82bea53aa3cfb9f..716841301a1a525cb60141ec17b0115efe84da49 100644 --- a/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx +++ b/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx @@ -90,21 +90,23 @@ void TSamuraiFDC2Physics::BuildPhysicalEvent(){ static unsigned int uid=0; VX0.clear();VX100.clear(),D.clear(); for(auto it = X.begin();it!=X.end();++it){ -#if __cplusplus > 199711L && NPMULTITHREADING +#if __cplusplus > 199711L && NPMULTITHREADING m_reconstruction.AddPlan(uid++,X[it->first],Z[it->first],R[it->first]); #else D[it->first]=m_reconstruction.BuildTrack2D(X[it->first],Z[it->first],R[it->first],X0,X100,a,b); #endif } -#if __cplusplus > 199711L && NPMULTITHREADING +#if __cplusplus > 199711L && NPMULTITHREADING + // do all plan at once in parallele, return when all plan are done m_reconstruction.BuildTrack2D(); uid=0; #endif for(auto it = X.begin();it!=X.end();++it){ -#if __cplusplus > 199711L && NPMULTITHREADING +#if __cplusplus > 199711L && NPMULTITHREADING + D[it->first]=m_reconstruction.GetResults(uid++,X0,X100,a,b); #endif @@ -344,7 +346,8 @@ void TSamuraiFDC2Physics::ReadConfiguration(NPL::InputParser parser){ } -#if __cplusplus > 199711L && NPMULTITHREADING +#if __cplusplus > 199711L && NPMULTITHREADING + if(blocks.size()){ // one thread for each plan X,U,V = 3 // ! more than this will not help ! diff --git a/NPLib/TrackReconstruction/NPDCReconstructionMT.cxx b/NPLib/TrackReconstruction/NPDCReconstructionMT.cxx index f35bc9ae356f2db30bfce87ac049bb972df5cee3..f76a8b5a0c8b7dfeea007e0d41c404831cdaeddc 100644 --- a/NPLib/TrackReconstruction/NPDCReconstructionMT.cxx +++ b/NPLib/TrackReconstruction/NPDCReconstructionMT.cxx @@ -21,13 +21,13 @@ #include "Math/Factory.h" #include "TError.h" #include "TGraph.h" +#include "TVector3.h" + using namespace std; using namespace NPL; //////////////////////////////////////////////////////////////////////////////// DCReconstructionMT::DCReconstructionMT(unsigned int number_thread){ - // this avoid error printout - gErrorIgnoreLevel = kError; m_nbr_thread= number_thread; } //////////////////////////////////////////////////////////////////////////////// @@ -181,6 +181,10 @@ TGraph* DCReconstructionMT::Scan(double a, double b, int tovary, double minV, do } //////////////////////////////////////////////////////////////////////////////// void NPL::DCReconstructionMT::InitThreadPool(){ + + // this avoid error printout during fitting + gErrorIgnoreLevel = kError; + StopThread(); m_ThreadPool.clear(); m_Ready.clear(); diff --git a/NPLib/TrackReconstruction/NPDCReconstructionMT.h b/NPLib/TrackReconstruction/NPDCReconstructionMT.h index ff878fe89963c64b5f99aa5d069d28e8dc5a62ea..cf2587dd91e0467d81ccd8788fbd4896129636eb 100644 --- a/NPLib/TrackReconstruction/NPDCReconstructionMT.h +++ b/NPLib/TrackReconstruction/NPDCReconstructionMT.h @@ -36,27 +36,31 @@ * - Resolving plane for two Z plane will provide a point and a direction * *****************************************************************************/ -#include <vector> +// stl #include <map> -#include "TVector3.h" +#include <vector> +#include <thread> +// ROOT #include "Math/Minimizer.h" #include "Math/Functor.h" -#include <thread> - +class TVector3; class TGraph; namespace NPL{ class DCReconstructionMT{ public: - DCReconstructionMT(unsigned int number_thread=1); + DCReconstructionMT(){DCReconstructionMT(1);}; + DCReconstructionMT(unsigned int number_thread); ~DCReconstructionMT(); public: // Set number of thread - // require to stop and reinit the thread + // require to stop and reinit the thread for this to be taken into account void SetNumberOfThread(unsigned int number_thread){m_nbr_thread=number_thread;}; + // Add a plan to the job list void AddPlan(unsigned int ID,const std::vector<double>& X, const std::vector<double>& Z, const std::vector<double>& R); + // Get results back for the plan with corresponding ID double GetResults(unsigned int ID,double& X0,double& X100,double& a, double& b); // Build a track in 2D based on drift circle of Radius R and position X,Z // return X0(X100) the X position at Z=0 (Z=100) @@ -89,6 +93,11 @@ namespace NPL{ std::map<unsigned int,double> m_a; std::map<unsigned int,double> m_b; + // used by resolve plane + long double av,bv,au,bu; + double xM,yM; + + private: // Thread Pool defined if C++11 is available unsigned int m_nbr_thread; std::vector<std::thread> m_ThreadPool; @@ -102,11 +111,6 @@ namespace NPL{ void StopThread(); bool IsDone(); - // used by SumD - // used by resolve plane - long double av,bv,au,bu; - double xM,yM; - }; } #endif//c++11