Skip to content

Commit

Permalink
Merge pull request #312 from project8/feature/useFTGdistributions
Browse files Browse the repository at this point in the history
Update random distributions
  • Loading branch information
pslocum authored Apr 20, 2024
2 parents 6488392 + b14b3a6 commit 4e9842f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
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.8.0)
project( locust_mc VERSION 2.8.1)


list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/Scarab/cmake )
Expand Down
7 changes: 5 additions & 2 deletions Source/Generators/LMCCavitySignalGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,11 @@ namespace locust

bool CavitySignalGenerator::RandomizeStartDelay()
{
srand ( fTrackDelaySeed );
int tNPreEventSamples = fNPreEventSamples/10 * ( rand() % 10 );
scarab::param_node default_setting;
default_setting.add("name","uniform");
fStartDelayDistribution = fDistributionInterface.get_dist(default_setting);
fDistributionInterface.SetSeed( fTrackDelaySeed );
int tNPreEventSamples = fNPreEventSamples * fStartDelayDistribution->Generate();
LPROG(lmclog,"Randomizing the start delay to " << tNPreEventSamples << " fast samples.");
fNPreEventSamples = tNPreEventSamples;

Expand Down
4 changes: 4 additions & 0 deletions Source/Generators/LMCCavitySignalGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "LMCTFFileHandler.hh"
#include "LMCCavityUtility.hh"
#include "LMCAliasingUtility.hh"
#include "LMCDistributionInterface.hh"
#include <vector>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -134,6 +135,9 @@ namespace locust

const scarab::param_node* fParam;

std::shared_ptr< BaseDistribution> fStartDelayDistribution;
DistributionInterface fDistributionInterface;


};

Expand Down
7 changes: 5 additions & 2 deletions Source/Kassiopeia/LMCRunPause.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,12 @@ namespace locust
{
if ( aParam["random-track-length"]().as_bool() == true)
{
srand ( GetSeed( aParam ));
scarab::param_node default_setting;
default_setting.add("name","uniform");
fTrackLengthDistribution = fDistributionInterface.get_dist(default_setting);
fDistributionInterface.SetSeed( GetSeed(aParam) );
double tMinTrackLength = tMaxTrackLength * tMinTrackLengthFraction;
double tRandomTime = tMinTrackLength + (tMaxTrackLength - tMinTrackLength) * (rand() % 10) / 9.;
double tRandomTime = tMinTrackLength + (tMaxTrackLength - tMinTrackLength) * fTrackLengthDistribution->Generate();
fLocustMaxTimeTerminator->SetTime( tRandomTime );
LPROG(lmclog,"Randomizing the track length to " << tRandomTime);
}
Expand Down
6 changes: 6 additions & 0 deletions Source/Kassiopeia/LMCRunPause.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "KSGenTimeComposite.h"
#include "LMCKassLocustInterface.hh"
#include "KRandom.h"
#include "LMCDistributionInterface.hh"
#include <stdlib.h>
#include <time.h>

Expand Down Expand Up @@ -79,6 +80,11 @@ namespace locust
Kassiopeia::KSGeoSpace* fKSSpace;
Kassiopeia::KSGenGeneratorComposite* fGenerator;

std::shared_ptr< BaseDistribution> fTrackLengthDistribution;
DistributionInterface fDistributionInterface;





};
Expand Down

0 comments on commit 4e9842f

Please sign in to comment.