diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f16e6d2..98171a42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required( VERSION 3.1 ) # Define the project cmake_policy( SET CMP0048 NEW ) # version in project() -project( locust_mc VERSION 2.6.1) +project( locust_mc VERSION 2.6.2) list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/Scarab/cmake ) diff --git a/Source/Core/LMCGenerator.cc b/Source/Core/LMCGenerator.cc index 0e02d9b9..0bbba2d2 100644 --- a/Source/Core/LMCGenerator.cc +++ b/Source/Core/LMCGenerator.cc @@ -83,6 +83,11 @@ namespace locust fNChannels = nchannels; } + void Generator::ConfigureRecordLength( unsigned recordLength ) const + { + fRecordLength = recordLength; + } + void Generator::ConfigureAcquisitionRate( double ar ) const { fAcquisitionRate = ar; diff --git a/Source/Core/LMCGenerator.hh b/Source/Core/LMCGenerator.hh index e508dc3d..6b2f6ba6 100644 --- a/Source/Core/LMCGenerator.hh +++ b/Source/Core/LMCGenerator.hh @@ -27,6 +27,7 @@ namespace locust virtual bool Configure( const scarab::param_node& aNode ) = 0; void ConfigureNChannels( unsigned nchannels ) const; + void ConfigureRecordLength( unsigned recordLength ) const; void ConfigureAcquisitionRate( double ar ) const; virtual void Accept( GeneratorVisitor* aVisitor ) const = 0; @@ -52,6 +53,7 @@ namespace locust virtual bool DoGenerate( Signal* aSignal ) = 0; mutable unsigned fNChannels; mutable double fAcquisitionRate; + mutable unsigned fRecordLength; std::string fName; diff --git a/Source/Core/LMCRunLengthCalculator.cc b/Source/Core/LMCRunLengthCalculator.cc index 2b81dcba..357ed620 100644 --- a/Source/Core/LMCRunLengthCalculator.cc +++ b/Source/Core/LMCRunLengthCalculator.cc @@ -74,6 +74,7 @@ namespace locust while( nextGenerator != NULL ) { nextGenerator->ConfigureNChannels(frlcChannels); + nextGenerator->ConfigureRecordLength(fRecordSize); nextGenerator->ConfigureAcquisitionRate(frlcAcquisitionRate); nextGenerator->Accept( this ); nextGenerator = nextGenerator->GetNextGenerator(); diff --git a/Source/Generators/LMCCavitySignalGenerator.cc b/Source/Generators/LMCCavitySignalGenerator.cc index 9492149a..016c624c 100644 --- a/Source/Generators/LMCCavitySignalGenerator.cc +++ b/Source/Generators/LMCCavitySignalGenerator.cc @@ -50,7 +50,7 @@ namespace locust } - bool CavitySignalGenerator::ConfigureInterface() + bool CavitySignalGenerator::ConfigureInterface( Signal* aSignal ) { if ( fInterface == nullptr ) fInterface.reset( new KassLocustInterface() ); @@ -212,6 +212,7 @@ namespace locust { fInterface->fTriggerConfirm = tParam["trigger-confirm"]().as_int(); } + fInterface->fFastRecordLength = fRecordLength * aSignal->DecimationFactor(); // Configure Locust-Kass interface classes and parameters: fFieldCalculator = new FieldCalculator(); @@ -562,7 +563,8 @@ namespace locust bool CavitySignalGenerator::DoGenerateTime( Signal* aSignal ) { - ConfigureInterface(); + ConfigureInterface( aSignal ); + if (fRandomPreEventSamples) RandomizeStartDelay(); fPowerCombiner->SizeNChannels(fNChannels); diff --git a/Source/Generators/LMCCavitySignalGenerator.hh b/Source/Generators/LMCCavitySignalGenerator.hh index 3b9d620e..b0470852 100644 --- a/Source/Generators/LMCCavitySignalGenerator.hh +++ b/Source/Generators/LMCCavitySignalGenerator.hh @@ -72,7 +72,7 @@ namespace locust virtual ~CavitySignalGenerator(); bool Configure( const scarab::param_node& aNode ); - bool ConfigureInterface(); + bool ConfigureInterface(Signal* aSignal); bool CrossCheckCavityConfig(); bool CrossCheckAliasing(Signal* aSignal, double dopplerFrequency ); diff --git a/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc b/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc index 0244f65d..89683e2c 100644 --- a/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc +++ b/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc @@ -1,5 +1,7 @@ #include "LMCCyclotronRadiationExtractor.hh" #include "KSModifiersMessage.h" +#include +#include namespace locust @@ -53,6 +55,7 @@ namespace locust } + locust::Particle CyclotronRadiationExtractor::ExtractKassiopeiaParticle( Kassiopeia::KSParticle &anInitialParticle, Kassiopeia::KSParticle &aFinalParticle) { LMCThreeVector tPosition(aFinalParticle.GetPosition().Components()); @@ -188,12 +191,40 @@ namespace locust fInterface->fDigitizerCondition.notify_one(); // notify Locust after writing. int tTriggerConfirm = 0; - while ((fSampleIndex == fInterface->fSampleIndex) && (tTriggerConfirm < fInterface->fTriggerConfirm)) + + while ( !(fSampleIndex < fInterface->fSampleIndex) && (tTriggerConfirm < fInterface->fTriggerConfirm) ) { - // If the Locust sample index has not advanced yet, keep checking it. - tTriggerConfirm += 1; + // If the Locust sample index has not advanced yet, keep checking it. + tTriggerConfirm += 1; + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + if ( tTriggerConfirm % 1000 == 0 ) + { + LPROG(lmclog,"Checking the digitizer synchronization, tTriggerConfirm index = " << tTriggerConfirm ); + } + + if ( ( tTriggerConfirm > fInterface->fTriggerConfirm - 3) && ( fSampleIndex < fInterface->fFastRecordLength ) ) + { + LPROG(lmclog,"Checking the digitizer synchronization, tTriggerConfirm index = " << tTriggerConfirm); + LPROG(lmclog,"Checking the digitizer synchronization, at fast sample = " << fSampleIndex); + LPROG(lmclog,"Checking the digitizer synchronization, at Locust fast sample = " << fInterface->fSampleIndex); + LPROG(lmclog,"Fast record length = " << fInterface->fFastRecordLength); + std::this_thread::sleep_for(std::chrono::milliseconds(10000)); + if ( !(fSampleIndex < fInterface->fSampleIndex) ) + { + LPROG(lmclog,"Checking the digitizer synchronization again. "); + std::this_thread::sleep_for(std::chrono::milliseconds(10000)); + if ( !(fSampleIndex < fInterface->fSampleIndex) ) + { + LERROR(lmclog,"Locust digitizer sample index has not advanced properly. " + "Please either resubmit the job, or check HPC status."); + LERROR(lmclog, "tTriggerConfirm, fSampleIndex are " << tTriggerConfirm << " and " << fSampleIndex); + exit(-1); // TO-DO: throw this exception to be caught properly by scarab, as in LocustSim.cc . + } + } + } } + } } // DoneWithSignalGeneration diff --git a/Source/Kassiopeia/LMCKassLocustInterface.cc b/Source/Kassiopeia/LMCKassLocustInterface.cc index 52366610..a31f5d7a 100644 --- a/Source/Kassiopeia/LMCKassLocustInterface.cc +++ b/Source/Kassiopeia/LMCKassLocustInterface.cc @@ -38,7 +38,8 @@ namespace locust fBackReaction( true ), fbWaveguide( false ), fSampleIndex( 0 ), - fTriggerConfirm( 100000 ) + fTriggerConfirm( 100000 ), + fFastRecordLength( 0 ) {} KLInterfaceBootstrapper::KLInterfaceBootstrapper() : diff --git a/Source/Kassiopeia/LMCKassLocustInterface.hh b/Source/Kassiopeia/LMCKassLocustInterface.hh index b80ad3e8..73fc6c9d 100644 --- a/Source/Kassiopeia/LMCKassLocustInterface.hh +++ b/Source/Kassiopeia/LMCKassLocustInterface.hh @@ -67,6 +67,7 @@ namespace locust bool fbWaveguide; unsigned fSampleIndex; int fTriggerConfirm; + int fFastRecordLength; };