From 1eabb90b25451326814f82fb69b99a12f076fa6a Mon Sep 17 00:00:00 2001 From: Adrien Matta <matta@lpccaen.in2p3.fr> Date: Fri, 11 Dec 2020 10:20:06 +0100 Subject: [PATCH] * Fixing seg fault when creating an FDC2/0 object within cling --- .../Detectors/Samurai/TSamuraiFDC2Physics.cxx | 11 +++++--- .../NPDCReconstructionMT.cxx | 8 ++++-- .../NPDCReconstructionMT.h | 26 +++++++++++-------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx b/NPLib/Detectors/Samurai/TSamuraiFDC2Physics.cxx index beb21bab9..716841301 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 f35bc9ae3..f76a8b5a0 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 ff878fe89..cf2587dd9 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 -- GitLab