diff --git a/apps/AmpGen.cpp b/apps/AmpGen.cpp index 7c9aa11520..293d49a2b0 100644 --- a/apps/AmpGen.cpp +++ b/apps/AmpGen.cpp @@ -79,6 +79,7 @@ template void generateSource(T& pdf, const std::string& sourceFile, Mi double norm = 1; if( normalise ){ + INFO("Normalising PDF"); TRandom3 rnd(seed); unsigned d_i = pdf.eventType().dim().first; Generator phsp(pdf.eventType()); diff --git a/python/ampgen.py b/python/ampgen.py index 214fb43ae7..1f69749adb 100644 --- a/python/ampgen.py +++ b/python/ampgen.py @@ -91,7 +91,7 @@ def make_ampgen_model( options_file, src = "" ) : if src == "" : src=mkstemp( suffix='.cpp')[1] lib=src.replace(".cpp",".so") if not os.path.isfile(lib) : - cmd = ["AmpGen", options_file, f"--Output {src}", "--Normalise=0", "--CompilerWrapper::Verbose=1"] + cmd = ["AmpGen", options_file, f"--Output {src}", "--Normalise=0", "--CompilerWrapper::Verbose=1", "--AutoCompile=0"] print( f"Running command {cmd}") subprocess.run(cmd, check=True, text=True) return AmpGenModel(os.path.abspath(lib)) diff --git a/src/CoherentSum.cpp b/src/CoherentSum.cpp index 604a1a9237..a81703c3cb 100644 --- a/src/CoherentSum.cpp +++ b/src/CoherentSum.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "AmpGen/CompiledExpression.h" #include "AmpGen/ErrorPropagator.h" @@ -45,6 +46,7 @@ CoherentSum::CoherentSum( const EventType& type, const MinuitParameterSet& mps, , m_prefix (prefix) , m_mps(&mps) { + bool autocompile = NamedParameter("AutoCompile", true); auto rules = AmplitudeRules::create(mps); auto amplitudes = rules->getMatchingRules( m_eventType, prefix); if( amplitudes.size() == 0 ){ @@ -56,19 +58,14 @@ CoherentSum::CoherentSum( const EventType& type, const MinuitParameterSet& mps, size_t nThreads = NamedParameter ("nCores" , std::thread::hardware_concurrency(), "Number of threads to use" ); ThreadPool tp(nThreads); auto head_rules = rules->rulesForDecay(m_eventType.mother(), m_prefix); - /* - for( const auto& rule : head_rules ) - { - auto indices = findIndices(m_matrixElements, rule.particle().decayDescriptor() ); - INFO( rule.particle() << " [" << vectorToString(indices, " ") << "]" ); - } - */ for(size_t i = 0; i < m_matrixElements.size(); ++i){ - tp.enqueue( [i, this, &mps, &litudes]() mutable { + auto task = [i, this, &mps, &litudes, autocompile]() mutable { this->m_matrixElements[i] = MatrixElement(amplitudes[i].first, amplitudes[i].second, mps, this->m_eventType.getEventFormat(), this->m_dbThis); - CompilerWrapper().compile( this->m_matrixElements[i], this->m_objCache); - } ); + if(autocompile) CompilerWrapper().compile( this->m_matrixElements[i], this->m_objCache); + }; + if( autocompile ) tp.enqueue( task ); + else task(); } } @@ -77,10 +74,11 @@ void CoherentSum::prepare() transferParameters(); ProfileClock clockEval; for (auto& t : m_matrixElements ) { - if( not t.isReady() ) + if( not t.isReady() ){ + raise(SIGSEGV); FATAL( t.decayDescriptor() << " not ready, fix me"); + } t.prepare(); - if ( m_prepareCalls != 0 && !t.hasExternalsChanged() ) continue; if ( m_events != nullptr ) m_cache.update(t); m_integrator.updateCache(t);