From db235b5833216ad5d48f67d0526a150e0ab0623e Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Fri, 29 Mar 2024 15:33:30 -0400 Subject: [PATCH 1/6] Accumulate events by updating existing truth file in pileup runs. --- Source/Kassiopeia/LMCEventHold.cc | 18 +++++++++++++++++- Source/Kassiopeia/LMCEventHold.hh | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/Kassiopeia/LMCEventHold.cc b/Source/Kassiopeia/LMCEventHold.cc index d98cc7d7..4beab0c2 100644 --- a/Source/Kassiopeia/LMCEventHold.cc +++ b/Source/Kassiopeia/LMCEventHold.cc @@ -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 ) { } @@ -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; @@ -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); diff --git a/Source/Kassiopeia/LMCEventHold.hh b/Source/Kassiopeia/LMCEventHold.hh index 3f02d4ff..88042d3f 100644 --- a/Source/Kassiopeia/LMCEventHold.hh +++ b/Source/Kassiopeia/LMCEventHold.hh @@ -35,6 +35,7 @@ namespace locust bool ConfigureByInterface(); bool Configure( const scarab::param_node& aParam ); std::string fTruthOutputFilename; + bool fAccumulateTruthInfo; public: From fee339a060f920114463f872c7014937e67f5411 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Sat, 30 Mar 2024 12:50:17 -0400 Subject: [PATCH 2/6] Add average cyclotron frequency to event properties output record. --- Source/IO/LMCEvent.cc | 1 + Source/IO/LMCEvent.hh | 1 + Source/IO/LMCRootTreeWriter.cc | 1 + Source/IO/LMCTrack.hh | 1 + Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc | 3 +++ Source/Kassiopeia/LMCCyclotronRadiationExtractor.hh | 1 + 6 files changed, 8 insertions(+) diff --git a/Source/IO/LMCEvent.cc b/Source/IO/LMCEvent.cc index 337926c3..dd4be47b 100644 --- a/Source/IO/LMCEvent.cc +++ b/Source/IO/LMCEvent.cc @@ -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 ); diff --git a/Source/IO/LMCEvent.hh b/Source/IO/LMCEvent.hh index 0cb9ffbb..afe16c27 100644 --- a/Source/IO/LMCEvent.hh +++ b/Source/IO/LMCEvent.hh @@ -35,6 +35,7 @@ namespace locust std::vector fStartFrequencies; std::vector fEndFrequencies; + std::vector fAvgFrequencies; std::vector fTrackPowers; std::vector fStartTimes; std::vector fEndTimes; diff --git a/Source/IO/LMCRootTreeWriter.cc b/Source/IO/LMCRootTreeWriter.cc index ca06ed52..5ad80b91 100644 --- a/Source/IO/LMCRootTreeWriter.cc +++ b/Source/IO/LMCRootTreeWriter.cc @@ -58,6 +58,7 @@ namespace locust aTree->Branch("ntracks", &anEvent->fNTracks, "ntracks/I"); aTree->Branch("StartFrequencies", "std::vector", &anEvent->fStartFrequencies); aTree->Branch("EndFrequencies", "std::vector", &anEvent->fEndFrequencies); + aTree->Branch("AvgFrequencies", "std::vector", &anEvent->fAvgFrequencies); aTree->Branch("StartTimes", "std::vector", &anEvent->fStartTimes); aTree->Branch("EndTimes", "std::vector", &anEvent->fEndTimes); aTree->Branch("TrackLengths", "std::vector", &anEvent->fTrackLengths); diff --git a/Source/IO/LMCTrack.hh b/Source/IO/LMCTrack.hh index 85d3bf2e..da4a450f 100644 --- a/Source/IO/LMCTrack.hh +++ b/Source/IO/LMCTrack.hh @@ -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.; diff --git a/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc b/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc index a2fb853a..ca30c450 100644 --- a/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc +++ b/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc @@ -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(); @@ -72,6 +73,8 @@ 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); } #endif diff --git a/Source/Kassiopeia/LMCCyclotronRadiationExtractor.hh b/Source/Kassiopeia/LMCCyclotronRadiationExtractor.hh index fad5a630..4fbf91c0 100644 --- a/Source/Kassiopeia/LMCCyclotronRadiationExtractor.hh +++ b/Source/Kassiopeia/LMCCyclotronRadiationExtractor.hh @@ -60,6 +60,7 @@ namespace locust FieldCalculator* fFieldCalculator; kl_interface_ptr_t fInterface; unsigned fSampleIndex; + unsigned fStartingIndex; }; From 8eadd0457b578996c118e993fcee6c258504a237 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Mon, 1 Apr 2024 10:11:14 -0400 Subject: [PATCH 3/6] Build on push to feature branch. --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 592aedda..12cfd442 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,7 +3,7 @@ name: Build and Test Locust on: pull_request: push: - branches: [master, develop] + branches: [master, develop, feature/truthWriting] tags: ['*'] workflow_dispatch: From 73300b49fc8b661a8e3bd3feb8384b70041e3570 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Mon, 1 Apr 2024 16:21:30 -0400 Subject: [PATCH 4/6] Add track length and slope to event properties output file. --- Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc b/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc index ca30c450..4b27c1bf 100644 --- a/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc +++ b/Source/Kassiopeia/LMCCyclotronRadiationExtractor.cc @@ -75,6 +75,8 @@ namespace locust 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 From 491e257de9e5fff031bf48fa99f8c1be213782dc Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Mon, 1 Apr 2024 16:22:02 -0400 Subject: [PATCH 5/6] Remove build on push to feature branch. --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 12cfd442..592aedda 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,7 +3,7 @@ name: Build and Test Locust on: pull_request: push: - branches: [master, develop, feature/truthWriting] + branches: [master, develop] tags: ['*'] workflow_dispatch: From ffb0ed47438f61fefe3da3aae47f737cb081a12f Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Mon, 1 Apr 2024 16:22:33 -0400 Subject: [PATCH 6/6] Bump version to v2.8.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d31d932..a78db879 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.7.2) +project( locust_mc VERSION 2.8.0) list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/Scarab/cmake )