Skip to content
Snippets Groups Projects
Commit b97b5484 authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

* fixing seg fault with analysis of analysis FDC

parent 1eabb90b
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,11 @@ ...@@ -18,7 +18,11 @@
*****************************************************************************/ *****************************************************************************/
#include"NPDCReconstructionMT.h" #include"NPDCReconstructionMT.h"
// ROOT
#include "Math/Factory.h" #include "Math/Factory.h"
#include "Math/Minimizer.h"
#include "Math/Functor.h"
#include "TError.h" #include "TError.h"
#include "TGraph.h" #include "TGraph.h"
#include "TVector3.h" #include "TVector3.h"
...@@ -29,6 +33,9 @@ using namespace NPL; ...@@ -29,6 +33,9 @@ using namespace NPL;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
DCReconstructionMT::DCReconstructionMT(unsigned int number_thread){ DCReconstructionMT::DCReconstructionMT(unsigned int number_thread){
m_nbr_thread= number_thread; m_nbr_thread= number_thread;
// force loading of the minimizer plugin ahead
ROOT::Math::Minimizer* mini=ROOT::Math::Factory::CreateMinimizer("Minuit2", "Migrad");
delete mini;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
DCReconstructionMT::~DCReconstructionMT(){ DCReconstructionMT::~DCReconstructionMT(){
...@@ -190,10 +197,8 @@ void NPL::DCReconstructionMT::InitThreadPool(){ ...@@ -190,10 +197,8 @@ void NPL::DCReconstructionMT::InitThreadPool(){
m_Ready.clear(); m_Ready.clear();
m_Ready.resize(m_nbr_thread,false); m_Ready.resize(m_nbr_thread,false);
for (unsigned int i=0; i < m_nbr_thread; i++) { for (unsigned int i=0; i < m_nbr_thread; i++) {
//Create the minimiser (deleted by the thread)
ROOT::Math::Minimizer* mini=ROOT::Math::Factory::CreateMinimizer("Minuit2", "Migrad");
// Register minimiser for futur deletion // Register minimiser for futur deletion
m_ThreadPool.push_back( std::thread(&NPL::DCReconstructionMT::StartThread,this,mini,i) ); m_ThreadPool.push_back( std::thread(&NPL::DCReconstructionMT::StartThread,this,i) );
} }
m_stop = false; m_stop = false;
for(auto& th: m_ThreadPool){ for(auto& th: m_ThreadPool){
...@@ -201,17 +206,21 @@ void NPL::DCReconstructionMT::InitThreadPool(){ ...@@ -201,17 +206,21 @@ void NPL::DCReconstructionMT::InitThreadPool(){
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void DCReconstructionMT::StartThread(ROOT::Math::Minimizer* mini,unsigned int id){ void DCReconstructionMT::StartThread(unsigned int id){
// Let the main thread start // usefull variable
std::this_thread::sleep_for(std::chrono::milliseconds(100)); double ai,bi;
unsigned int uid;
const double* xs;
// create the functor // create the functor
// each threads needs its own or the minisation is not thread safe // each threads needs its own or the minisation is not thread safe
ROOT::Math::Functor* func= new ROOT::Math::Functor(this,&NPL::DCReconstructionMT::SumD,3); ROOT::Math::Functor* func= new ROOT::Math::Functor(this,&NPL::DCReconstructionMT::SumD,3);
//Create the minimiser (deleted by the thread)
ROOT::Math::Minimizer* mini=ROOT::Math::Factory::CreateMinimizer("Minuit2", "Migrad");
mini->SetFunction(*func); mini->SetFunction(*func);
mini->SetPrintLevel(0); mini->SetPrintLevel(0);
double ai,bi;
unsigned int uid; // Let the main thread start
const double* xs; std::this_thread::sleep_for(std::chrono::milliseconds(100));
while(true){ while(true){
// Do the job if possible // Do the job if possible
if(m_Ready[id]){ if(m_Ready[id]){
......
...@@ -40,10 +40,6 @@ ...@@ -40,10 +40,6 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include <thread> #include <thread>
// ROOT
#include "Math/Minimizer.h"
#include "Math/Functor.h"
class TVector3; class TVector3;
class TGraph; class TGraph;
namespace NPL{ namespace NPL{
...@@ -97,7 +93,6 @@ namespace NPL{ ...@@ -97,7 +93,6 @@ namespace NPL{
long double av,bv,au,bu; long double av,bv,au,bu;
double xM,yM; double xM,yM;
private: // Thread Pool defined if C++11 is available private: // Thread Pool defined if C++11 is available
unsigned int m_nbr_thread; unsigned int m_nbr_thread;
std::vector<std::thread> m_ThreadPool; std::vector<std::thread> m_ThreadPool;
...@@ -107,7 +102,7 @@ namespace NPL{ ...@@ -107,7 +102,7 @@ namespace NPL{
public: // Init the Thread Pool public: // Init the Thread Pool
void InitThreadPool(); void InitThreadPool();
void StartThread(ROOT::Math::Minimizer*,unsigned int); void StartThread(unsigned int);
void StopThread(); void StopThread();
bool IsDone(); bool IsDone();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment