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

Update event properties output #310

Merged
merged 6 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.7.2)
project( locust_mc VERSION 2.8.0)


list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/Scarab/cmake )
Expand Down
1 change: 1 addition & 0 deletions Source/IO/LMCEvent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace locust
{
fStartFrequencies.push_back( aTrack.StartFrequency );
fEndFrequencies.push_back( aTrack.EndFrequency );
fAvgFrequencies.push_back( aTrack.AvgFrequency );
fTrackPowers.push_back( aTrack.TrackPower );
fStartTimes.push_back( aTrack.StartTime );
fTrackLengths.push_back( aTrack.TrackLength );
Expand Down
1 change: 1 addition & 0 deletions Source/IO/LMCEvent.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace locust

std::vector<double> fStartFrequencies;
std::vector<double> fEndFrequencies;
std::vector<double> fAvgFrequencies;
std::vector<double> fTrackPowers;
std::vector<double> fStartTimes;
std::vector<double> fEndTimes;
Expand Down
1 change: 1 addition & 0 deletions Source/IO/LMCRootTreeWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace locust
aTree->Branch("ntracks", &anEvent->fNTracks, "ntracks/I");
aTree->Branch("StartFrequencies", "std::vector<double>", &anEvent->fStartFrequencies);
aTree->Branch("EndFrequencies", "std::vector<double>", &anEvent->fEndFrequencies);
aTree->Branch("AvgFrequencies", "std::vector<double>", &anEvent->fAvgFrequencies);
aTree->Branch("StartTimes", "std::vector<double>", &anEvent->fStartTimes);
aTree->Branch("EndTimes", "std::vector<double>", &anEvent->fEndTimes);
aTree->Branch("TrackLengths", "std::vector<double>", &anEvent->fTrackLengths);
Expand Down
1 change: 1 addition & 0 deletions Source/IO/LMCTrack.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace locust
double TrackLength = -99.;
double StartFrequency = -99.;
double EndFrequency = -99.;
double AvgFrequency = -99.;
double LOFrequency = -99.;
double TrackPower = -99.;
double Slope = -99.;
Expand Down
5 changes: 5 additions & 0 deletions Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace locust
#ifdef ROOT_FOUND
if (bStart)
{
fStartingIndex = index;
fInterface->aTrack.StartTime = tTime;
fInterface->aTrack.StartFrequency = aFinalParticle.GetCyclotronFrequency();
double tX = aFinalParticle.GetPosition().X();
Expand All @@ -72,6 +73,10 @@ namespace locust
{
fInterface->aTrack.EndTime = tTime;
fInterface->aTrack.EndFrequency = aFinalParticle.GetCyclotronFrequency();
unsigned nElapsedSamples = index - fStartingIndex;
fInterface->aTrack.AvgFrequency = ( fInterface->aTrack.AvgFrequency * nElapsedSamples + aFinalParticle.GetCyclotronFrequency() ) / ( nElapsedSamples + 1);
fInterface->aTrack.TrackLength = tTime - fInterface->aTrack.StartTime;
fInterface->aTrack.Slope = (fInterface->aTrack.EndFrequency - fInterface->aTrack.StartFrequency) / (fInterface->aTrack.TrackLength);
}
#endif

Expand Down
1 change: 1 addition & 0 deletions Source/Kassiopeia/LMCCyclotronRadiationExtractor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace locust
FieldCalculator* fFieldCalculator;
kl_interface_ptr_t fInterface;
unsigned fSampleIndex;
unsigned fStartingIndex;
};


Expand Down
18 changes: 17 additions & 1 deletion Source/Kassiopeia/LMCEventHold.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ namespace locust

EventHold::EventHold() :
fTruthOutputFilename("LocustEventProperties.root"),
fAccumulateTruthInfo( false ),
fInterface( KLInterfaceBootstrapper::get_instance()->GetInterface() )
{
}

EventHold::EventHold( const EventHold& aOrig ) : KSComponent(),
fTruthOutputFilename("LocustEventProperties.root"),
fAccumulateTruthInfo( false ),
fInterface( aOrig.fInterface )
{
}
Expand Down Expand Up @@ -66,6 +68,10 @@ namespace locust
{
fTruthOutputFilename = aParam["truth-output-filename"]().as_string();
}
if ( aParam.has( "accumulate-truth-info" ) )
{
fAccumulateTruthInfo = aParam["accumulate-truth-info"]().as_bool();
}


return true;
Expand Down Expand Up @@ -94,7 +100,17 @@ namespace locust
#ifdef ROOT_FOUND
FileWriter* aRootTreeWriter = RootTreeWriter::get_instance();
aRootTreeWriter->SetFilename(sFileName);
aRootTreeWriter->OpenFile("RECREATE");
if (fAccumulateTruthInfo)
{
// 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");
}
else
{
aRootTreeWriter->OpenFile("RECREATE");
}
fInterface->anEvent->AddTrack( fInterface->aTrack );
aRootTreeWriter->WriteEvent( fInterface->anEvent );
aRootTreeWriter->WriteRunParameters(fInterface->aRunParameter);
Expand Down
1 change: 1 addition & 0 deletions Source/Kassiopeia/LMCEventHold.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace locust
bool ConfigureByInterface();
bool Configure( const scarab::param_node& aParam );
std::string fTruthOutputFilename;
bool fAccumulateTruthInfo;


public:
Expand Down
Loading