Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2-way trigger. #307

Merged
merged 15 commits into from
Feb 9, 2024
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/LMCGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ namespace locust
fNChannels = nchannels;
}

void Generator::ConfigureRecordLength( unsigned recordLength ) const
{
fRecordLength = recordLength;
}

void Generator::ConfigureAcquisitionRate( double ar ) const
{
fAcquisitionRate = ar;
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/LMCGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -52,6 +53,7 @@ namespace locust
virtual bool DoGenerate( Signal* aSignal ) = 0;
mutable unsigned fNChannels;
mutable double fAcquisitionRate;
mutable unsigned fRecordLength;


std::string fName;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/LMCRunLengthCalculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ namespace locust
while( nextGenerator != NULL )
{
nextGenerator->ConfigureNChannels(frlcChannels);
nextGenerator->ConfigureRecordLength(fRecordSize);
nextGenerator->ConfigureAcquisitionRate(frlcAcquisitionRate);
nextGenerator->Accept( this );
nextGenerator = nextGenerator->GetNextGenerator();
Expand Down
6 changes: 4 additions & 2 deletions Source/Generators/LMCCavitySignalGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace locust
}


bool CavitySignalGenerator::ConfigureInterface()
bool CavitySignalGenerator::ConfigureInterface( Signal* aSignal )
{

if ( fInterface == nullptr ) fInterface.reset( new KassLocustInterface() );
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -562,7 +563,8 @@ namespace locust

bool CavitySignalGenerator::DoGenerateTime( Signal* aSignal )
{
ConfigureInterface();
ConfigureInterface( aSignal );

if (fRandomPreEventSamples) RandomizeStartDelay();

fPowerCombiner->SizeNChannels(fNChannels);
Expand Down
2 changes: 1 addition & 1 deletion Source/Generators/LMCCavitySignalGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
37 changes: 34 additions & 3 deletions Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "LMCCyclotronRadiationExtractor.hh"
#include "KSModifiersMessage.h"
#include <chrono>
#include <thread>


namespace locust
Expand Down Expand Up @@ -53,6 +55,7 @@ namespace locust
}



locust::Particle CyclotronRadiationExtractor::ExtractKassiopeiaParticle( Kassiopeia::KSParticle &anInitialParticle, Kassiopeia::KSParticle &aFinalParticle)
{
LMCThreeVector tPosition(aFinalParticle.GetPosition().Components());
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion Source/Kassiopeia/LMCKassLocustInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ namespace locust
fBackReaction( true ),
fbWaveguide( false ),
fSampleIndex( 0 ),
fTriggerConfirm( 100000 )
fTriggerConfirm( 100000 ),
fFastRecordLength( 0 )
{}

KLInterfaceBootstrapper::KLInterfaceBootstrapper() :
Expand Down
1 change: 1 addition & 0 deletions Source/Kassiopeia/LMCKassLocustInterface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace locust
bool fbWaveguide;
unsigned fSampleIndex;
int fTriggerConfirm;
int fFastRecordLength;


};
Expand Down
Loading