Skip to content

Commit

Permalink
Merge pull request #313 from project8/feature/eventRecording
Browse files Browse the repository at this point in the history
Feature/event recording
  • Loading branch information
pslocum authored Apr 25, 2024
2 parents 4e9842f + ba510c9 commit 6640344
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 9 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.1)
project( locust_mc VERSION 2.8.2)


list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/Scarab/cmake )
Expand Down
8 changes: 6 additions & 2 deletions Source/Generators/LMCCavitySignalGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ namespace locust
}
if ( aParam.has( "random-track-seed" ) )
{
SetSeed( aParam["random-track-seed"]().as_int() );
// Offset event-spacing seed from track-length seed.
int tSeed = aParam["random-track-seed"]().as_int() + 1;
SetSeed( tSeed );
}
else
{
Expand Down Expand Up @@ -302,11 +304,13 @@ namespace locust

bool CavitySignalGenerator::RecordRunParameters( Signal* aSignal )
{
#ifdef ROOT_FOUND
fInterface->aRunParameter = new RunParameters();
fInterface->aRunParameter->fSamplingRateMHz = fAcquisitionRate;
fInterface->aRunParameter->fDecimationFactor = aSignal->DecimationFactor();
fInterface->aRunParameter->fLOfrequency = fLO_Frequency;

fInterface->aRunParameter->fRandomSeed = fTrackDelaySeed;
#endif
return true;
}

Expand Down
6 changes: 5 additions & 1 deletion Source/IO/LMCEvent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace locust

void Event::AddTrack(const Track aTrack)
{
fOutputStartFrequencies.push_back( aTrack.OutputStartFrequency );
fStartFrequencies.push_back( aTrack.StartFrequency );
fEndFrequencies.push_back( aTrack.EndFrequency );
fAvgFrequencies.push_back( aTrack.AvgFrequency );
Expand All @@ -34,7 +35,10 @@ namespace locust
fRadii.push_back( aTrack.Radius );
fRadialPhases.push_back( aTrack.RadialPhase );

//update size
// Update size. And, record fLOFrequency for compatibility with previous work. The LO frequency is
// now also recorded in the RunParameters Tree.
fNTracks = fStartFrequencies.size();
fLOFrequency = aTrack.LOFrequency;
fRandomSeed = aTrack.RandomSeed;
}
}
1 change: 1 addition & 0 deletions Source/IO/LMCEvent.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace locust
double fLOFrequency;
int fRandomSeed;

std::vector<double> fOutputStartFrequencies;
std::vector<double> fStartFrequencies;
std::vector<double> fEndFrequencies;
std::vector<double> fAvgFrequencies;
Expand Down
1 change: 1 addition & 0 deletions Source/IO/LMCRootTreeWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace locust
TTree *aTree = new TTree(treename,"Locust Tree");
aTree->Branch("EventID", &anEvent->fEventID, "EventID/I");
aTree->Branch("ntracks", &anEvent->fNTracks, "ntracks/I");
aTree->Branch("OutputStartFrequencies", "std::vector<double>", &anEvent->fOutputStartFrequencies);
aTree->Branch("StartFrequencies", "std::vector<double>", &anEvent->fStartFrequencies);
aTree->Branch("EndFrequencies", "std::vector<double>", &anEvent->fEndFrequencies);
aTree->Branch("AvgFrequencies", "std::vector<double>", &anEvent->fAvgFrequencies);
Expand Down
1 change: 1 addition & 0 deletions Source/IO/LMCRunParameters.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace locust
double fLOfrequency;
double fSamplingRateMHz;
double fDecimationFactor;
int fRandomSeed;

ClassDef(RunParameters,1) // Root syntax.

Expand Down
2 changes: 2 additions & 0 deletions Source/IO/LMCTrack.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ namespace locust
Track();
virtual ~Track();
int EventID = -99;
int RandomSeed = -99.;
double StartTime = -99.;
double EndTime = -99.;
double TrackLength = -99.;
double OutputStartFrequency = -99.;
double StartFrequency = -99.;
double EndFrequency = -99.;
double AvgFrequency = -99.;
Expand Down
9 changes: 9 additions & 0 deletions Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,21 @@ namespace locust
if (fPitchAngle == -99.) // first crossing of center
{
fPitchAngle = aFinalParticle.GetPolarAngleToB();
#ifdef ROOT_FOUND
fInterface->aTrack.PitchAngle = aFinalParticle.GetPolarAngleToB();
fInterface->aTrack.StartFrequency = aFinalParticle.GetCyclotronFrequency();
double tLOfrequency = fInterface->aRunParameter->fLOfrequency; // Hz
double tSamplingRate = fInterface->aRunParameter->fSamplingRateMHz; // MHz
fInterface->aTrack.LOFrequency = tLOfrequency;
fInterface->aTrack.RandomSeed = fInterface->aRunParameter->fRandomSeed;
fInterface->aTrack.OutputStartFrequency = fInterface->aTrack.StartFrequency - tLOfrequency + tSamplingRate * 1.e6 / 2.;
#endif
}
else
{
#ifdef ROOT_FOUND
fInterface->aTrack.EndFrequency = aFinalParticle.GetCyclotronFrequency();
#endif
}
}
aNewParticle.SetPitchAngle(fPitchAngle);
Expand Down
2 changes: 1 addition & 1 deletion Source/Kassiopeia/LMCEventHold.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace locust
aRootTreeWriter->SetFilename(sFileName);
if (fAccumulateTruthInfo)
{
// This option should be used when running pileup. We will need to
// TO-DO: This option should be used when running pileup. We will need to
// figure out how to explicitly increment the event ID, given that the
// same (identical) simulation is being run multiple times in this case.
aRootTreeWriter->OpenFile("UPDATE");
Expand Down
9 changes: 5 additions & 4 deletions Source/Kassiopeia/LMCRunPause.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ namespace locust
RunPause::RunPause() :
fToolbox(KToolbox::GetInstance()),
KSComponent(),
fMinTrackLengthFraction(0.1),
fInterface( KLInterfaceBootstrapper::get_instance()->GetInterface() )
{
}

RunPause::RunPause( const RunPause& aCopy ) :
fToolbox(KToolbox::GetInstance()),
KSComponent(),
fMinTrackLengthFraction(0.1),
fInterface( aCopy.fInterface )
{
}
Expand Down Expand Up @@ -272,13 +274,12 @@ namespace locust
{

double tMaxTrackLength = 0.;
double tMinTrackLengthFraction = 0.1;
fLocustMaxTimeTerminator = new Kassiopeia::KSTermMaxTime();

if ( aParam.has( "min-track-length-fraction" ) )
{
tMinTrackLengthFraction = aParam["min-track-length-fraction"]().as_double();
LPROG(lmclog,"Setting minimum track length fraction to " << tMinTrackLengthFraction);
fMinTrackLengthFraction = aParam["min-track-length-fraction"]().as_double();
LPROG(lmclog,"Setting minimum track length fraction to " << fMinTrackLengthFraction);
}

if ( aParam.has( "track-length" ) )
Expand All @@ -300,7 +301,7 @@ namespace locust
default_setting.add("name","uniform");
fTrackLengthDistribution = fDistributionInterface.get_dist(default_setting);
fDistributionInterface.SetSeed( GetSeed(aParam) );
double tMinTrackLength = tMaxTrackLength * tMinTrackLengthFraction;
double tMinTrackLength = tMaxTrackLength * fMinTrackLengthFraction;
double tRandomTime = tMinTrackLength + (tMaxTrackLength - tMinTrackLength) * fTrackLengthDistribution->Generate();
fLocustMaxTimeTerminator->SetTime( tRandomTime );
LPROG(lmclog,"Randomizing the track length to " << tRandomTime);
Expand Down
1 change: 1 addition & 0 deletions Source/Kassiopeia/LMCRunPause.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace locust

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



Expand Down

0 comments on commit 6640344

Please sign in to comment.