From ef1e19b8a7d6f218b16f51349fa0bf0f6aae46d0 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Thu, 10 Mar 2016 09:30:53 +0100 Subject: [PATCH 01/28] Cherry pick: Minor changes to build system to allow building as a submodule of something else --- CMakeLists.txt | 2 +- Kommon/cmake/KasperDefaults.cmake | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c1dbba0b7..f258a5269 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required( VERSION 2.8.6 ) -project( Kassiopeia ) +project( Kasper ) set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/Kommon/cmake ) include( KasperDefaults ) diff --git a/Kommon/cmake/KasperDefaults.cmake b/Kommon/cmake/KasperDefaults.cmake index 2963cf5f6..daf9a3676 100644 --- a/Kommon/cmake/KasperDefaults.cmake +++ b/Kommon/cmake/KasperDefaults.cmake @@ -9,8 +9,9 @@ endmacro(set_path) include(CMakeDependentOption) include(MacroParseArguments) -if( ${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} ) - +if( ${Kasper_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} ) + +>>>>>>> 2f382a5... Minor changes to build system to allow building as a submodule of something else set(STANDALONE true) # use this section to modifiy initial values of builtin CMAKE variables @@ -175,9 +176,15 @@ macro(kasper_find_module NAME) else() set( VERSION "0" ) endif() +<<<<<<< HEAD find_package( ${NAME} ${VERSION} REQUIRED NO_MODULE ) #message("${NAME}_INCLUDE_DIRS: ${${NAME}_INCLUDE_DIRS}") +======= + + find_package( ${NAME} ${VERSION} REQUIRED NO_MODULE HINTS ${Kasper_BINARY_DIR}/${NAME} ) + #include_directories( ${${NAME}_INCLUDE_DIRS} ) +>>>>>>> 2f382a5... Minor changes to build system to allow building as a submodule of something else kasper_internal_include_directories( ${${NAME}_INCLUDE_DIRS} ) #kasper_external_include_directories( ${${NAME}_INCLUDE_DIRS} ) #set( ${NAME}_INCLUDE_DIRS "${${NAME}_INCLUDE_DIRS}" PARENT_SCOPE ) From fea57ea880e41a7451d51332a883f37c1d69939f Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Fri, 11 Mar 2016 09:20:36 +0100 Subject: [PATCH 02/28] CMake policy fixes --- CMakeLists.txt | 3 +++ KEMField/CMakeLists.txt | 7 +++---- KGeoBag/CMakeLists.txt | 3 +++ Kassiopeia/CMakeLists.txt | 7 +++---- Kommon/CMakeLists.txt | 3 +++ Kommon/cmake/KasperDefaults.cmake | 9 ++++++--- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f258a5269..51ed44cf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required( VERSION 2.8.6 ) +if(POLICY CMP0048) + cmake_policy(SET CMP0048 OLD) +endif() project( Kasper ) diff --git a/KEMField/CMakeLists.txt b/KEMField/CMakeLists.txt index f8514127d..43f401637 100644 --- a/KEMField/CMakeLists.txt +++ b/KEMField/CMakeLists.txt @@ -1,12 +1,11 @@ cmake_minimum_required( VERSION 2.8.6 ) +if(POLICY CMP0048) + cmake_policy(SET CMP0048 OLD) +endif() project(KEMField) include(KasperDefaults) -if(POLICY CMP0053) - cmake_policy(SET CMP0053 OLD) -endif() - # Module version set(MODULE_VERSION_MAJOR 2) set(MODULE_VERSION_MINOR 1) diff --git a/KGeoBag/CMakeLists.txt b/KGeoBag/CMakeLists.txt index a7cf314bf..3e1081328 100644 --- a/KGeoBag/CMakeLists.txt +++ b/KGeoBag/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required( VERSION 2.8.6 ) +if(POLICY CMP0048) + cmake_policy(SET CMP0048 OLD) +endif() project( KGeoBag ) include( KasperDefaults ) diff --git a/Kassiopeia/CMakeLists.txt b/Kassiopeia/CMakeLists.txt index badea32ca..337369d87 100644 --- a/Kassiopeia/CMakeLists.txt +++ b/Kassiopeia/CMakeLists.txt @@ -5,14 +5,13 @@ # thank you! -dan. cmake_minimum_required( VERSION 2.8.6 ) +if(POLICY CMP0048) + cmake_policy(SET CMP0048 OLD) +endif() project( Kassiopeia ) include( KasperDefaults ) -if(POLICY CMP0053) - cmake_policy(SET CMP0053 OLD) -endif() - # module version set( MODULE_VERSION_MAJOR 3 ) set( MODULE_VERSION_MINOR 1 ) diff --git a/Kommon/CMakeLists.txt b/Kommon/CMakeLists.txt index 9f4ff1115..ccf118500 100644 --- a/Kommon/CMakeLists.txt +++ b/Kommon/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required( VERSION 2.8.6 ) +if(POLICY CMP0048) + cmake_policy(SET CMP0048 OLD) +endif() project( Kommon ) set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${PROJECT_SOURCE_DIR}/GoogleTest/cmake ) diff --git a/Kommon/cmake/KasperDefaults.cmake b/Kommon/cmake/KasperDefaults.cmake index daf9a3676..11f051732 100644 --- a/Kommon/cmake/KasperDefaults.cmake +++ b/Kommon/cmake/KasperDefaults.cmake @@ -9,9 +9,12 @@ endmacro(set_path) include(CMakeDependentOption) include(MacroParseArguments) -if( ${Kasper_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} ) - ->>>>>>> 2f382a5... Minor changes to build system to allow building as a submodule of something else +cmake_policy( SET CMP0011 NEW ) +if( POLICY 0053 ) + cmake_policy( SET CMP0053 OLD ) +endif( POLICY 0053 ) + +if( "${Kasper_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}" ) set(STANDALONE true) # use this section to modifiy initial values of builtin CMAKE variables From 30dcbb1700500f233ca99ece6a10e1d69cbdbe64 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Fri, 11 Mar 2016 15:50:32 +0100 Subject: [PATCH 03/28] A few more cmake changes --- KEMField/CMakeLists.txt | 3 +++ Kassiopeia/CMakeLists.txt | 3 +++ Kommon/cmake/KasperDefaults.cmake | 11 +---------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/KEMField/CMakeLists.txt b/KEMField/CMakeLists.txt index 43f401637..e182569c5 100644 --- a/KEMField/CMakeLists.txt +++ b/KEMField/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required( VERSION 2.8.6 ) if(POLICY CMP0048) cmake_policy(SET CMP0048 OLD) endif() +if( POLICY CMP0053 ) + cmake_policy( SET CMP0053 OLD ) +endif( POLICY CMP0053 ) project(KEMField) include(KasperDefaults) diff --git a/Kassiopeia/CMakeLists.txt b/Kassiopeia/CMakeLists.txt index 337369d87..4195359ae 100644 --- a/Kassiopeia/CMakeLists.txt +++ b/Kassiopeia/CMakeLists.txt @@ -8,6 +8,9 @@ cmake_minimum_required( VERSION 2.8.6 ) if(POLICY CMP0048) cmake_policy(SET CMP0048 OLD) endif() +if( POLICY CMP0053 ) + cmake_policy( SET CMP0053 OLD ) +endif( POLICY CMP0053 ) project( Kassiopeia ) include( KasperDefaults ) diff --git a/Kommon/cmake/KasperDefaults.cmake b/Kommon/cmake/KasperDefaults.cmake index 11f051732..b3c352457 100644 --- a/Kommon/cmake/KasperDefaults.cmake +++ b/Kommon/cmake/KasperDefaults.cmake @@ -10,9 +10,6 @@ include(CMakeDependentOption) include(MacroParseArguments) cmake_policy( SET CMP0011 NEW ) -if( POLICY 0053 ) - cmake_policy( SET CMP0053 OLD ) -endif( POLICY 0053 ) if( "${Kasper_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}" ) set(STANDALONE true) @@ -179,15 +176,9 @@ macro(kasper_find_module NAME) else() set( VERSION "0" ) endif() -<<<<<<< HEAD - find_package( ${NAME} ${VERSION} REQUIRED NO_MODULE ) - #message("${NAME}_INCLUDE_DIRS: ${${NAME}_INCLUDE_DIRS}") -======= - find_package( ${NAME} ${VERSION} REQUIRED NO_MODULE HINTS ${Kasper_BINARY_DIR}/${NAME} ) - #include_directories( ${${NAME}_INCLUDE_DIRS} ) ->>>>>>> 2f382a5... Minor changes to build system to allow building as a submodule of something else + #message("${NAME}_INCLUDE_DIRS: ${${NAME}_INCLUDE_DIRS}") kasper_internal_include_directories( ${${NAME}_INCLUDE_DIRS} ) #kasper_external_include_directories( ${${NAME}_INCLUDE_DIRS} ) #set( ${NAME}_INCLUDE_DIRS "${${NAME}_INCLUDE_DIRS}" PARENT_SCOPE ) From 7b9d0a1dca1b6131d0159dc5e7b6889689eed5d6 Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Mon, 14 Mar 2016 12:02:51 -0400 Subject: [PATCH 04/28] Allow the KVariableProcessor variable map to be set after construction --- Kommon/Core/Initialization/KVariableProcessor.cc | 7 +++++++ Kommon/Core/Initialization/KVariableProcessor.hh | 2 ++ 2 files changed, 9 insertions(+) diff --git a/Kommon/Core/Initialization/KVariableProcessor.cc b/Kommon/Core/Initialization/KVariableProcessor.cc index 9620a42e1..ef811e329 100644 --- a/Kommon/Core/Initialization/KVariableProcessor.cc +++ b/Kommon/Core/Initialization/KVariableProcessor.cc @@ -42,6 +42,13 @@ namespace katrin delete fLocalMap; } + void KVariableProcessor::SetExternalMap( const VariableMap& anExternalMap ) + { + delete fExternalMap; + fExternalMap = new VariableMap( anExternalMap ); + return; + } + void KVariableProcessor::ProcessToken( KBeginFileToken* aToken ) { if( fElementState == eElementInactive ) diff --git a/Kommon/Core/Initialization/KVariableProcessor.hh b/Kommon/Core/Initialization/KVariableProcessor.hh index 566b622c8..4855a99a7 100644 --- a/Kommon/Core/Initialization/KVariableProcessor.hh +++ b/Kommon/Core/Initialization/KVariableProcessor.hh @@ -26,6 +26,8 @@ namespace katrin KVariableProcessor( const VariableMap& anExternalMap ); virtual ~KVariableProcessor(); + void SetExternalMap( const VariableMap& anExternalMap ); + virtual void ProcessToken( KBeginFileToken* aToken ); virtual void ProcessToken( KBeginElementToken* aToken ); virtual void ProcessToken( KBeginAttributeToken* aToken ); From 4db786c5e1b62c2ade462993311d3ec79227340f Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Mon, 14 Mar 2016 12:03:21 -0400 Subject: [PATCH 05/28] Added KSEventModifier, and KSRootEventModifier, and implement use by KSRoot --- Kassiopeia/Operators/CMakeLists.txt | 2 + .../Operators/Include/KSEventModifier.h | 29 ++++ .../Operators/Source/KSEventModifier.cxx | 11 ++ Kassiopeia/Simulation/CMakeLists.txt | 2 + Kassiopeia/Simulation/Include/KSRoot.h | 2 + .../Simulation/Include/KSRootEventModifier.h | 63 +++++++ Kassiopeia/Simulation/Source/KSRoot.cxx | 19 +++ .../Simulation/Source/KSRootEventModifier.cxx | 158 ++++++++++++++++++ 8 files changed, 286 insertions(+) create mode 100644 Kassiopeia/Operators/Include/KSEventModifier.h create mode 100644 Kassiopeia/Operators/Source/KSEventModifier.cxx create mode 100644 Kassiopeia/Simulation/Include/KSRootEventModifier.h create mode 100644 Kassiopeia/Simulation/Source/KSRootEventModifier.cxx diff --git a/Kassiopeia/Operators/CMakeLists.txt b/Kassiopeia/Operators/CMakeLists.txt index 558ace7ed..c0df34fde 100644 --- a/Kassiopeia/Operators/CMakeLists.txt +++ b/Kassiopeia/Operators/CMakeLists.txt @@ -1,5 +1,6 @@ # header files set( OPERATORS_HEADER_BASENAMES + KSEventModifier.h KSOperatorsMessage.h KSParticle.h KSParticleFactory.h @@ -26,6 +27,7 @@ endforeach( BASENAME ) # source files set( OPERATORS_SOURCE_BASENAMES + KSEventModifier.cxx KSOperatorsMessage.cxx KSParticle.cxx KSParticleFactory.cxx diff --git a/Kassiopeia/Operators/Include/KSEventModifier.h b/Kassiopeia/Operators/Include/KSEventModifier.h new file mode 100644 index 000000000..a8f07a712 --- /dev/null +++ b/Kassiopeia/Operators/Include/KSEventModifier.h @@ -0,0 +1,29 @@ +#ifndef Kassiopeia_KSEventModifier_h_ +#define Kassiopeia_KSEventModifier_h_ + +#include "KSComponentTemplate.h" + +namespace Kassiopeia +{ + + class KSEvent; + + class KSEventModifier: + public KSComponentTemplate< KSEventModifier > + { + public: + KSEventModifier(); + virtual ~KSEventModifier(); + + public: + + //returns true if any of the state variables of anInitialParticle are changed + virtual bool ExecutePreEventModification() = 0; + + //returns true if any of the state variables of aFinalParticle are changed + virtual bool ExecutePostEventModifcation() = 0; + }; + +} + +#endif diff --git a/Kassiopeia/Operators/Source/KSEventModifier.cxx b/Kassiopeia/Operators/Source/KSEventModifier.cxx new file mode 100644 index 000000000..e4b545f7e --- /dev/null +++ b/Kassiopeia/Operators/Source/KSEventModifier.cxx @@ -0,0 +1,11 @@ +#include "KSEventModifier.h" + +namespace Kassiopeia +{ + KSEventModifier::KSEventModifier() + { + } + KSEventModifier::~KSEventModifier() + { + } +} diff --git a/Kassiopeia/Simulation/CMakeLists.txt b/Kassiopeia/Simulation/CMakeLists.txt index e1d5856fc..fd0208dfa 100644 --- a/Kassiopeia/Simulation/CMakeLists.txt +++ b/Kassiopeia/Simulation/CMakeLists.txt @@ -11,6 +11,7 @@ set( SIMULATION_HEADER_BASENAMES KSTrack.h KSStep.h KSRootElectricField.h + KSRootEventModifier.h KSRootMagneticField.h KSRootStepModifier.h KSRootSpace.h @@ -44,6 +45,7 @@ set( SIMULATION_SOURCE_BASENAMES KSTrack.cxx KSStep.cxx KSRootElectricField.cxx + KSRootEventModifier.cxx KSRootMagneticField.cxx KSRootStepModifier.cxx KSRootSpace.cxx diff --git a/Kassiopeia/Simulation/Include/KSRoot.h b/Kassiopeia/Simulation/Include/KSRoot.h index 6884f80d4..a3c44d7cb 100644 --- a/Kassiopeia/Simulation/Include/KSRoot.h +++ b/Kassiopeia/Simulation/Include/KSRoot.h @@ -23,6 +23,7 @@ namespace Kassiopeia class KSRootTerminator; class KSRootWriter; class KSRootStepModifier; + class KSRootEventModifier; class KSSimulation; class KSRun; @@ -78,6 +79,7 @@ namespace Kassiopeia KSRootTerminator* fRootTerminator; KSRootWriter* fRootWriter; KSRootStepModifier* fRootStepModifier; + KSRootEventModifier* fRootEventModifier; unsigned int fRunIndex; unsigned int fEventIndex; diff --git a/Kassiopeia/Simulation/Include/KSRootEventModifier.h b/Kassiopeia/Simulation/Include/KSRootEventModifier.h new file mode 100644 index 000000000..ff9144bd9 --- /dev/null +++ b/Kassiopeia/Simulation/Include/KSRootEventModifier.h @@ -0,0 +1,63 @@ +#ifndef Kassiopeia_KSRootEventModifier_h_ +#define Kassiopeia_KSRootEventModifier_h_ + +#include "KSEventModifier.h" +#include "KSEvent.h" +#include "KSList.h" +#include "KSParticle.h" + +namespace Kassiopeia +{ + + class KSTrack; + + class KSRootEventModifier : + public KSComponentTemplate< KSRootEventModifier, KSEventModifier > + { + public: + KSRootEventModifier(); + KSRootEventModifier( const KSRootEventModifier& aCopy ); + KSRootEventModifier* Clone() const; + virtual ~KSRootEventModifier(); + + //********** + // modifier + //********** + + public: + //bool ExecutePreEventModification( KSParticle& anInitialParticle, KSParticleQueue& aQueue ); + //bool ExecutePostEventModifcation( KSParticle& anInitialParticle, KSParticle& aFinalParticle, KSParticleQueue& aQueue ); + + //*********** + //composition + //*********** + + public: + void AddModifier( KSEventModifier* aModifier ); + void RemoveModifier( KSEventModifier* aModifier ); + + private: + KSList< KSEventModifier > fModifiers; + KSEventModifier* fModifier; + + //****** + //action + //****** + + public: + void SetEvent( KSEvent* aEvent ); + + bool ExecutePreEventModification(); + bool ExecutePostEventModifcation(); + + virtual void PushUpdateComponent(); + virtual void PushDeupdateComponent(); + + private: + KSEvent* fEvent; + }; + + +} + +#endif diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index 4138cfc09..7a2077c8e 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -19,6 +19,7 @@ #include "KSRootTerminator.h" #include "KSRootWriter.h" #include "KSRootStepModifier.h" +#include "KSRootEventModifier.h" #include "KSParticle.h" #include "KSParticleFactory.h" @@ -65,6 +66,7 @@ namespace Kassiopeia fRootTerminator( new KSRootTerminator() ), fRootWriter( new KSRootWriter() ), fRootStepModifier( new KSRootStepModifier() ), + fRootEventModifier( new KSRootEventModifier() ), fRunIndex( 0 ), fEventIndex( 0 ), fTrackIndex( 0 ), @@ -133,6 +135,10 @@ namespace Kassiopeia fRootStepModifier->SetName( "root_stepmodifier" ); fRootStepModifier->SetStep( fStep ); fToolbox->AddObject( fRootStepModifier ); + + fRootEventModifier->SetName( "root_eventmodifier" ); + fRootEventModifier->SetEvent( fEvent ); + fToolbox->AddObject( fRootEventModifier ); } KSRoot::KSRoot( const KSRoot& /*aCopy*/) : KSComponent(), @@ -154,6 +160,7 @@ namespace Kassiopeia fRootTerminator( new KSRootTerminator() ), fRootWriter( new KSRootWriter() ), fRootStepModifier( new KSRootStepModifier() ), + fRootEventModifier( new KSRootEventModifier() ), fRunIndex( 0 ), fEventIndex( 0 ), fTrackIndex( 0 ), @@ -221,6 +228,9 @@ namespace Kassiopeia fRootStepModifier->SetName( "root_stepmodifier" ); fToolbox->AddObject( fRootStepModifier ); + + fRootEventModifier->SetName( "root_eventmodifier" ); + fToolbox->AddObject( fRootEventModifier ); } KSRoot* KSRoot::Clone() const { @@ -266,6 +276,9 @@ namespace Kassiopeia fToolbox->RemoveObject( fRootStepModifier ); delete fRootStepModifier; + fToolbox->RemoveObject( fRootEventModifier ); + delete fRootEventModifier; + fToolbox->RemoveObject( fRun ); delete fRun; @@ -419,6 +432,9 @@ namespace Kassiopeia // generate primaries fRootGenerator->ExecuteGeneration(); + // execute post-step modification + fRootEventModifier->ExecutePreEventModification(); + // send report eventmsg( eNormal ) << "processing event " << fEvent->GetEventId() << " <" << fEvent->GetGeneratorName() << ">..." << eom; @@ -471,6 +487,9 @@ namespace Kassiopeia fEvent->DiscreteSecondaries() += fTrack->DiscreteSecondaries(); } + // execute post-step modification + fRootEventModifier->ExecutePostEventModifcation(); + // write event fEvent->PushUpdate(); diff --git a/Kassiopeia/Simulation/Source/KSRootEventModifier.cxx b/Kassiopeia/Simulation/Source/KSRootEventModifier.cxx new file mode 100644 index 000000000..8e696b2b9 --- /dev/null +++ b/Kassiopeia/Simulation/Source/KSRootEventModifier.cxx @@ -0,0 +1,158 @@ +#include "KSRootEventModifier.h" +#include "KSModifiersMessage.h" + +namespace Kassiopeia +{ + KSRootEventModifier::KSRootEventModifier() : + fModifiers(128), + fModifier( NULL ), + fEvent( NULL ) + { + } + + KSRootEventModifier::KSRootEventModifier(const KSRootEventModifier &aCopy) : KSComponent(), + fModifiers( aCopy.fModifiers ), + fModifier( aCopy.fModifier), + fEvent( aCopy.fEvent ) + { + } + + KSRootEventModifier* KSRootEventModifier::Clone() const + { + return new KSRootEventModifier( *this ); + } + + KSRootEventModifier::~KSRootEventModifier() + { + } + + void KSRootEventModifier::AddModifier(KSEventModifier *aModifier) + { + fModifiers.AddElement( aModifier ); + return; + } + void KSRootEventModifier::RemoveModifier(KSEventModifier *aModifier) + { + fModifiers.RemoveElement( aModifier ); + return; + } + void KSRootEventModifier::SetEvent( KSEvent* aEvent ) + { + fEvent = aEvent; + return; + } + + void KSRootEventModifier::PushUpdateComponent() + { + for( int tIndex = 0; tIndex < fModifiers.End(); tIndex++ ) + { + fModifiers.ElementAt( tIndex )->PushUpdate(); + } + } + + void KSRootEventModifier::PushDeupdateComponent() + { + for( int tIndex = 0; tIndex < fModifiers.End(); tIndex++ ) + { + fModifiers.ElementAt( tIndex )->PushDeupdate(); + } + } + + bool KSRootEventModifier::ExecutePreEventModification() + { + if( fModifiers.End() == 0 ) + { + modmsg_debug( "modifier calculation:" << eom ) + modmsg_debug( " no modifier active" << eom ) + //modmsg_debug( " modifier name: <" << fEvent->GetModifierName() << ">" << eom ) + //modmsg_debug( " modifier flag: <" << fEvent->GetModificationFlag() << ">" << eom ) +/* + modmsg_debug( "modifier calculation terminator particle state: " << eom ) + modmsg_debug( " modifier particle space: <" << (fModifierParticle->GetCurrentSpace() ? fModifierParticle->GetCurrentSpace()->GetName() : "" ) << ">" << eom ) + modmsg_debug( " modifier particle surface: <" << (fModifierParticle->GetCurrentSurface() ? fModifierParticle->GetCurrentSurface()->GetName() : "" ) << ">" << eom ) + modmsg_debug( " modifier particle time: <" << fModifierParticle->GetTime() << ">" << eom ) + modmsg_debug( " modifier particle length: <" << fModifierParticle->GetLength() << ">" << eom ) + modmsg_debug( " modifier particle position: <" << fModifierParticle->GetPosition().X() << ", " << fModifierParticle->GetPosition().Y() << ", " << fModifierParticle->GetPosition().Z() << ">" << eom ) + modmsg_debug( " modifier particle momentum: <" << fModifierParticle->GetMomentum().X() << ", " << fModifierParticle->GetMomentum().Y() << ", " << fModifierParticle->GetMomentum().Z() << ">" << eom ) + modmsg_debug( " modifier particle kinetic energy: <" << fModifierParticle->GetKineticEnergy_eV() << ">" << eom ) + modmsg_debug( " modifier particle electric field: <" << fModifierParticle->GetElectricField().X() << "," << fModifierParticle->GetElectricField().Y() << "," << fModifierParticle->GetElectricField().Z() << ">" << eom ) + modmsg_debug( " modifier particle magnetic field: <" << fModifierParticle->GetMagneticField().X() << "," << fModifierParticle->GetMagneticField().Y() << "," << fModifierParticle->GetMagneticField().Z() << ">" << eom ) + modmsg_debug( " modifier particle angle to magnetic field: <" << fModifierParticle->GetPolarAngleToB() << ">" << eom ) +*/ + return false; + } + + bool hasChangedState = false; + for( int tIndex = 0; tIndex < fModifiers.End(); tIndex++ ) + { + bool changed = fModifiers.ElementAt( tIndex )->ExecutePreEventModification(); + if(changed){hasChangedState = true;}; + } + +// if( fEvent->ModificationFlag() == true ) +// { +// modmsg_debug( "modifier calculation:" << eom ) +// modmsg_debug( " modification may occur" << eom ) +// } +// else +// { +// modmsg_debug( "modifier calculation:" << eom ) +// modmsg_debug( " modification will not occur" << eom ) +// } +/* + modmsg_debug( "modifier calculation modifier particle state: " << eom ) + modmsg_debug( " modifier particle space: <" << (fModifierParticle->GetCurrentSpace() ? fModifierParticle->GetCurrentSpace()->GetName() : "" ) << ">" << eom ) + modmsg_debug( " modifier particle surface: <" << (fModifierParticle->GetCurrentSurface() ? fModifierParticle->GetCurrentSurface()->GetName() : "" ) << ">" << eom ) + modmsg_debug( " modifier particle time: <" << fModifierParticle->GetTime() << ">" << eom ) + modmsg_debug( " modifier particle length: <" << fModifierParticle->GetLength() << ">" << eom ) + modmsg_debug( " modifier particle position: <" << fModifierParticle->GetPosition().X() << ", " << fModifierParticle->GetPosition().Y() << ", " << fModifierParticle->GetPosition().Z() << ">" << eom ) + modmsg_debug( " modifier particle momentum: <" << fModifierParticle->GetMomentum().X() << ", " << fModifierParticle->GetMomentum().Y() << ", " << fModifierParticle->GetMomentum().Z() << ">" << eom ) + modmsg_debug( " modifier particle kinetic energy: <" << fModifierParticle->GetKineticEnergy_eV() << ">" << eom ) + modmsg_debug( " modifier particle electric field: <" << fModifierParticle->GetElectricField().X() << "," << fModifierParticle->GetElectricField().Y() << "," << fModifierParticle->GetElectricField().Z() << ">" << eom ) + modmsg_debug( " modifier particle magnetic field: <" << fModifierParticle->GetMagneticField().X() << "," << fModifierParticle->GetMagneticField().Y() << "," << fModifierParticle->GetMagneticField().Z() << ">" << eom ) + modmsg_debug( " modifier particle angle to magnetic field: <" << fModifierParticle->GetPolarAngleToB() << ">" << eom ) +*/ + return hasChangedState; + } + + bool KSRootEventModifier::ExecutePostEventModifcation() + { + bool hasChangedState = false; + for( int tIndex = 0; tIndex < fModifiers.End(); tIndex++ ) + { + bool changed = fModifiers.ElementAt( tIndex )->ExecutePostEventModifcation(); + if(changed){hasChangedState = true;}; + } +/* + modmsg_debug( "terminator execution:" << eom ) + modmsg_debug( " terminator name: <" << fEvent->TerminatorName() << ">" << eom ) + modmsg_debug( " step continuous time: <" << fEvent->ContinuousTime() << ">" << eom ) + modmsg_debug( " step continuous length: <" << fEvent->ContinuousLength() << ">" << eom ) + modmsg_debug( " step continuous energy change: <" << fEvent->ContinuousEnergyChange() << ">" << eom ) + modmsg_debug( " step continuous momentum change: <" << fEvent->ContinuousMomentumChange() << ">" << eom ) + modmsg_debug( " step discrete secondaries: <" << fEvent->DiscreteSecondaries() << ">" << eom ) + modmsg_debug( " step discrete energy change: <" << fEvent->DiscreteEnergyChange() << ">" << eom ) + modmsg_debug( " step discrete momentum change: <" << fEvent->DiscreteMomentumChange() << ">" << eom ) + + modmsg_debug( "terminator final particle state: " << eom ) + modmsg_debug( " final particle space: <" << (fModifierParticle->GetCurrentSpace() ? fModifierParticle->GetCurrentSpace()->GetName() : "" ) << ">" << eom ) + modmsg_debug( " final particle surface: <" << (fModifierParticle->GetCurrentSurface() ? fModifierParticle->GetCurrentSurface()->GetName() : "" ) << ">" << eom ) + modmsg_debug( " final particle time: <" << fModifierParticle->GetTime() << ">" << eom ) + modmsg_debug( " final particle length: <" << fModifierParticle->GetLength() << ">" << eom ) + modmsg_debug( " final particle position: <" << fModifierParticle->GetPosition().X() << ", " << fModifierParticle->GetPosition().Y() << ", " << fModifierParticle->GetPosition().Z() << ">" << eom ) + modmsg_debug( " final particle momentum: <" << fModifierParticle->GetMomentum().X() << ", " << fModifierParticle->GetMomentum().Y() << ", " << fModifierParticle->GetMomentum().Z() << ">" << eom ) + modmsg_debug( " final particle kinetic energy: <" << fModifierParticle->GetKineticEnergy_eV() << ">" << eom ) + modmsg_debug( " final particle electric field: <" << fModifierParticle->GetElectricField().X() << "," << fModifierParticle->GetElectricField().Y() << "," << fModifierParticle->GetElectricField().Z() << ">" << eom ) + modmsg_debug( " final particle magnetic field: <" << fModifierParticle->GetMagneticField().X() << "," << fModifierParticle->GetMagneticField().Y() << "," << fModifierParticle->GetMagneticField().Z() << ">" << eom ) + modmsg_debug( " final particle angle to magnetic field: <" << fModifierParticle->GetPolarAngleToB() << ">" << eom ) +*/ + return hasChangedState; + } + + STATICINT sKSRootModifierDict = + KSDictionary< KSRootEventModifier >::AddCommand( &KSRootEventModifier::AddModifier, + &KSRootEventModifier::RemoveModifier, + "add_event_modifier", + "remove_event_modifier" ); + +} From b0b4fd62b7ed6ccd04d500928f66b922f8ce11ad Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Mon, 28 Mar 2016 12:02:50 -0400 Subject: [PATCH 06/28] Added KSRootEventModifierBuilder --- Kassiopeia/Bindings/CMakeLists.txt | 2 ++ .../Include/KSRootEventModifierBuilder.h | 30 +++++++++++++++++++ .../Source/KSRootEventModifierBuilder.cxx | 18 +++++++++++ 3 files changed, 50 insertions(+) create mode 100644 Kassiopeia/Bindings/Simulation/Include/KSRootEventModifierBuilder.h create mode 100644 Kassiopeia/Bindings/Simulation/Source/KSRootEventModifierBuilder.cxx diff --git a/Kassiopeia/Bindings/CMakeLists.txt b/Kassiopeia/Bindings/CMakeLists.txt index 356b1d003..caf664098 100644 --- a/Kassiopeia/Bindings/CMakeLists.txt +++ b/Kassiopeia/Bindings/CMakeLists.txt @@ -153,6 +153,7 @@ set( BINDINGS_HEADER_FILES # simulation Simulation/Include/KSRootMagneticFieldBuilder.h Simulation/Include/KSRootElectricFieldBuilder.h + Simulation/Include/KSRootEventModifierBuilder.h Simulation/Include/KSRootGeneratorBuilder.h Simulation/Include/KSRootTrajectoryBuilder.h Simulation/Include/KSRootSpaceInteractionBuilder.h @@ -347,6 +348,7 @@ set( BINDINGS_SOURCE_FILES # simulation Simulation/Source/KSRootMagneticFieldBuilder.cxx Simulation/Source/KSRootElectricFieldBuilder.cxx + Simulation/Source/KSRootEventModifierBuilder.cxx Simulation/Source/KSRootGeneratorBuilder.cxx Simulation/Source/KSRootTrajectoryBuilder.cxx Simulation/Source/KSRootSpaceInteractionBuilder.cxx diff --git a/Kassiopeia/Bindings/Simulation/Include/KSRootEventModifierBuilder.h b/Kassiopeia/Bindings/Simulation/Include/KSRootEventModifierBuilder.h new file mode 100644 index 000000000..1ff0f7675 --- /dev/null +++ b/Kassiopeia/Bindings/Simulation/Include/KSRootEventModifierBuilder.h @@ -0,0 +1,30 @@ +#ifndef Kassiopeia_KSRootEventModifierBuilder_h_ +#define Kassiopeia_KSRootEventModifierBuilder_h_ + +#include "KComplexElement.hh" +#include "KSRootEventModifier.h" +#include "KSToolbox.h" + +using namespace Kassiopeia; +namespace katrin +{ + typedef KComplexElement< KSRootEventModifier > KSRootEventModifierBuilder; + + template< > + inline bool KSRootEventModifierBuilder::AddAttribute(KContainer *aContainer) + { + if( aContainer->GetName() == "name" ) + { + aContainer->CopyTo( fObject, &KNamed::SetName ); + return true; + } + if( aContainer->GetName() == "add_modifier" ) + { + fObject->AddModifier( KSToolbox::GetInstance()->GetObjectAs< KSEventModifier >( aContainer->AsReference< string >() ) ); + return true; + } + return false; + } +} + +#endif //Kassiopeia_KSRootEventModifierBuilder_h_ diff --git a/Kassiopeia/Bindings/Simulation/Source/KSRootEventModifierBuilder.cxx b/Kassiopeia/Bindings/Simulation/Source/KSRootEventModifierBuilder.cxx new file mode 100644 index 000000000..515c9e139 --- /dev/null +++ b/Kassiopeia/Bindings/Simulation/Source/KSRootEventModifierBuilder.cxx @@ -0,0 +1,18 @@ +#include "KSRootEventModifierBuilder.h" +#include "KSRootBuilder.h" + +using namespace Kassiopeia; +namespace katrin +{ + template< > + KSRootEventModifierBuilder::~KComplexElement() + { + } + + STATICINT sKSRootEventModifier = + KSRootBuilder::ComplexElement< KSRootEventModifier >( "ks_root_eventmodifier" ); + + STATICINT sKSRootEventModifierStructure = + KSRootEventModifierBuilder::Attribute< string >( "name" ) + + KSRootEventModifierBuilder::Attribute< string >( "add_modifier" ); +} From aa86f4c4381f65b49c3b8140ef4548d9f5011292 Mon Sep 17 00:00:00 2001 From: pslocum Date: Tue, 5 Apr 2016 11:29:12 -0400 Subject: [PATCH 07/28] Added temporary pthreads to KSRoot.cxx for purpose of generating signal and checking mixing in Locust MC. --- Kassiopeia/Simulation/Include/KSRoot.h | 1 + Kassiopeia/Simulation/Include/KSStep.h | 1 + Kassiopeia/Simulation/Source/KSRoot.cxx | 71 ++++++++++++++++++- .../Simulation/Source/KSRootEventModifier.cxx | 6 +- 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/Kassiopeia/Simulation/Include/KSRoot.h b/Kassiopeia/Simulation/Include/KSRoot.h index a3c44d7cb..147906bc6 100644 --- a/Kassiopeia/Simulation/Include/KSRoot.h +++ b/Kassiopeia/Simulation/Include/KSRoot.h @@ -85,6 +85,7 @@ namespace Kassiopeia unsigned int fEventIndex; unsigned int fTrackIndex; unsigned int fStepIndex; + unsigned int fPersistentStepIndex; static bool fStopRunSignal; static bool fStopEventSignal; diff --git a/Kassiopeia/Simulation/Include/KSStep.h b/Kassiopeia/Simulation/Include/KSStep.h index 99c877f3c..3007b7b9c 100644 --- a/Kassiopeia/Simulation/Include/KSStep.h +++ b/Kassiopeia/Simulation/Include/KSStep.h @@ -51,6 +51,7 @@ namespace Kassiopeia public: K_REFS( string, TerminatorName ) K_REFS( bool, TerminatorFlag ) + K_REFS( bool, PauseFlag ); // pls addition. //********** //trajectory diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index 7a2077c8e..a4b0d1e06 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -1,3 +1,5 @@ +#include "LMCGlobals.hh" + #include "KSRoot.h" #include "KSRunMessage.h" #include "KSEventMessage.h" @@ -70,7 +72,8 @@ namespace Kassiopeia fRunIndex( 0 ), fEventIndex( 0 ), fTrackIndex( 0 ), - fStepIndex( 0 ) + fStepIndex( 0 ), + fPersistentStepIndex( 0 ) // pls addition { KSParticleFactory::GetInstance()->SetMagneticField( fRootMagneticField ); KSParticleFactory::GetInstance()->SetElectricField( fRootElectricField ); @@ -368,6 +371,8 @@ namespace Kassiopeia while( true ) { + + printf("fSimulation->GetEvents() is %d\n", fSimulation->GetEvents()); // pls addition // break if done if( fRun->GetTotalEvents() == fSimulation->GetEvents() ) { @@ -384,6 +389,7 @@ namespace Kassiopeia fEvent->ParentRunId() = fRun->GetRunId(); // execute event + fStep->PauseFlag() = true; // pls addition. ExecuteEvent(); // update run @@ -464,8 +470,60 @@ namespace Kassiopeia delete tParticle; fEvent->ParticleQueue().pop_front(); - // execute a track + // pls code starts here: + fPersistentStepIndex = fStepIndex; // This index updates before each track starts. It is similar to + // fRun->TotalSteps() except that it updates BEFORE THE TRACK STARTS. + printf("fEvent->TotalSteps() is %d and fStepIndex is %d and fStep->FinalParticle().IsActive() is %d and fPersistenStepIndex is %d and fEvent->TotalTracks() is %d\n", + fEvent->TotalSteps(), fStepIndex, fStep->FinalParticle().IsActive(), fPersistentStepIndex, fEvent->TotalTracks()); + while( (fStep->PauseFlag() == true) && ((fStep->FinalParticle().IsActive() == true) || (fPersistentStepIndex == fStepIndex))) // pls addition. + // middle of track new track starting + { + + // execute a track ExecuteTrack(); + // if (fStep->GetStepId() % 1000 == 0) + t += fStep->ContinuousTime(); + if (t - t_old > 5.e-9) + { + pthread_mutex_lock (&mymutex); // lock access to mutex before writing to globals. + Z = fStep->InitialParticle().GetPosition().Z(); + R = fStep->InitialParticle().GetPosition().Perp(); + K = fStep->InitialParticle().GetKineticEnergy_eV(); + zvelocity = fStep->InitialParticle().GetVelocity().GetZ(); + GammaZ = 1.0/pow(1.0-pow(zvelocity/2.99792e8,2.),0.5); + + vlong = fStep->InitialParticle().GetLongVelocity(); + dt = fStep->ContinuousTime(); + fcyc = 1./8./dt; + de = fStep->ContinuousEnergyChange(); + LarmorPower = -de/dt*1.602677e-19; + // printf("z position is %g and dt is %g\n", Z, dt); + + printf("Kassiopeia is about to send out a tick\n"); + pthread_cond_signal(&tick); // broadcast a tick to Locust. + t_old = t; + printf("Kassiopeia says: tick has happened; continuous time is %g and longvelocity is %f\n", t, zvelocity); + printf("Kassiopeia says: fcyc is %g\n", fcyc); + printf(" initial particle momentum: %g\n", fStep->InitialParticle().GetMomentum().Z()); + printf("Mass is %g\n", fStep->InitialParticle().GetMass()); + printf("k.e. = %g eV\n", fStep->InitialParticle().GetKineticEnergy_eV()); + printf("Lorentz factor is %f\n", fStep->InitialParticle().GetLorentzFactor()); + printf("1/(sqrt(1-v^2/c^2) is %f\n", 1.0/pow(1.0-pow(fStep->InitialParticle().GetSpeed()/2.99792e8,2.),0.5)); + printf("FinalParticle().IsActive() is %d\n", fStep->FinalParticle().IsActive()); +// getchar(); + pthread_mutex_unlock (&mymutex); // unlock access after writing. + + } + + } // while pause flag is true. aka while Locust is hacking in. + + if (fStep->PauseFlag() == false) + ExecuteTrack(); // just execute a track without dealing with globals or threads. + +// end pls additions. + + + // move particles in track queue to event queue while( fTrack->ParticleQueue().empty() == false ) @@ -506,6 +564,10 @@ namespace Kassiopeia void KSRoot::ExecuteTrack() { + // "if" brackets - pls addition. If the track loop finished a.k.a. fPersistentStepIndex got updated. + if (fStep->PauseFlag() == false || (fPersistentStepIndex == fStepIndex)) + { + // reset track fTrack->TrackId() = fTrackIndex; fTrack->TotalSteps() = 0; @@ -532,6 +594,8 @@ namespace Kassiopeia //clear any internal trajectory state fRootTrajectory->Reset(); + } // end pls addition. + while( fStep->FinalParticle().IsActive() == true ) { //signal handler break @@ -574,6 +638,9 @@ namespace Kassiopeia fTrack->DiscreteEnergyChange() += fStep->DiscreteEnergyChange(); fTrack->DiscreteMomentumChange() += fStep->DiscreteMomentumChange(); fTrack->DiscreteSecondaries() += fStep->DiscreteSecondaries(); + if (fStep->PauseFlag() == true && fStep->FinalParticle().IsActive() == true) + return; // pls addition: get out of this track for now. + } } diff --git a/Kassiopeia/Simulation/Source/KSRootEventModifier.cxx b/Kassiopeia/Simulation/Source/KSRootEventModifier.cxx index 8e696b2b9..feb37ddf5 100644 --- a/Kassiopeia/Simulation/Source/KSRootEventModifier.cxx +++ b/Kassiopeia/Simulation/Source/KSRootEventModifier.cxx @@ -60,6 +60,7 @@ namespace Kassiopeia bool KSRootEventModifier::ExecutePreEventModification() { + if( fModifiers.End() == 0 ) { modmsg_debug( "modifier calculation:" << eom ) @@ -117,6 +118,7 @@ namespace Kassiopeia bool KSRootEventModifier::ExecutePostEventModifcation() { + bool hasChangedState = false; for( int tIndex = 0; tIndex < fModifiers.End(); tIndex++ ) { @@ -152,7 +154,7 @@ namespace Kassiopeia STATICINT sKSRootModifierDict = KSDictionary< KSRootEventModifier >::AddCommand( &KSRootEventModifier::AddModifier, &KSRootEventModifier::RemoveModifier, - "add_event_modifier", - "remove_event_modifier" ); + "add_modifier", + "remove_modifier" ); } From a078fe621aea47a871aa03fd864a3286a164b46f Mon Sep 17 00:00:00 2001 From: pslocum Date: Mon, 25 Apr 2016 12:02:08 -0400 Subject: [PATCH 08/28] Added pre and post event conditions for triggering events in Kassiopeia from Locust. The conditions are presently global and are defined in small functions that can be dropped into the appropriate static event modifier class. Modified classes are LMCKassSignalGenerator and KSRoot. --- Kassiopeia/Simulation/Source/KSRoot.cxx | 66 +++++++++++++++++++++---- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index a4b0d1e06..f0d568757 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -347,6 +347,34 @@ namespace Kassiopeia return; } + + + void WakeAfterEvent(unsigned TotalEvents, unsigned EventsSoFar) + { + fEventInProgress = false; + if( TotalEvents == EventsSoFar-1 ) fRunInProgress = false; + fDigitizerCondition.notify_one(); + return; + } + + + + bool ReceivedEventStartSTLCondition() + { + if( fWaitBeforeEvent ) + { + printf("waiting for event trigger ...\n"); + fKassEventReady = true; + std::unique_lock< std::mutex >tLock( fMutex ); + fPreEventCondition.wait( tLock ); + fKassEventReady = false; + return true; + } + return false; + } + + + void KSRoot::ExecuteRun() { // set random seed @@ -372,8 +400,7 @@ namespace Kassiopeia while( true ) { - printf("fSimulation->GetEvents() is %d\n", fSimulation->GetEvents()); // pls addition - // break if done + // break if done if( fRun->GetTotalEvents() == fSimulation->GetEvents() ) { break; @@ -389,9 +416,16 @@ namespace Kassiopeia fEvent->ParentRunId() = fRun->GetRunId(); // execute event - fStep->PauseFlag() = true; // pls addition. + fStep->PauseFlag() = true; // pls addition. this will be replaced by step modifier class. + while (!ReceivedEventStartSTLCondition()) {} // pls: wait for event start. + printf("got the signal\n"); + + // end pls addition + ExecuteEvent(); + WakeAfterEvent(fRun->GetTotalEvents(), fSimulation->GetEvents()); // pls + // update run fRun->TotalEvents() += 1; fRun->TotalTracks() += fEvent->TotalTracks(); @@ -415,7 +449,6 @@ namespace Kassiopeia // send report runmsg( eNormal ) << "...run " << fRun->GetRunId() << " complete" << eom; - fStopRunSignal = false; return; } @@ -470,7 +503,11 @@ namespace Kassiopeia delete tParticle; fEvent->ParticleQueue().pop_front(); + + // pls code starts here: + + fPersistentStepIndex = fStepIndex; // This index updates before each track starts. It is similar to // fRun->TotalSteps() except that it updates BEFORE THE TRACK STARTS. printf("fEvent->TotalSteps() is %d and fStepIndex is %d and fStep->FinalParticle().IsActive() is %d and fPersistenStepIndex is %d and fEvent->TotalTracks() is %d\n", @@ -481,11 +518,12 @@ namespace Kassiopeia // execute a track ExecuteTrack(); - // if (fStep->GetStepId() % 1000 == 0) t += fStep->ContinuousTime(); if (t - t_old > 5.e-9) { - pthread_mutex_lock (&mymutex); // lock access to mutex before writing to globals. + // pthread_mutex_lock (&mymutex); // lock access to mutex before writing to globals. + std::unique_lock< std::mutex >tLock( fMutexDigitizer, std::defer_lock ); // lock access to mutex before writing to globals. + tLock.lock(); Z = fStep->InitialParticle().GetPosition().Z(); R = fStep->InitialParticle().GetPosition().Perp(); K = fStep->InitialParticle().GetKineticEnergy_eV(); @@ -497,10 +535,15 @@ namespace Kassiopeia fcyc = 1./8./dt; de = fStep->ContinuousEnergyChange(); LarmorPower = -de/dt*1.602677e-19; + tLock.unlock(); + // printf("z position is %g and dt is %g\n", Z, dt); printf("Kassiopeia is about to send out a tick\n"); - pthread_cond_signal(&tick); // broadcast a tick to Locust. + fDigitizerCondition.notify_one(); // notify Locust after writing. + +// getchar(); + t_old = t; printf("Kassiopeia says: tick has happened; continuous time is %g and longvelocity is %f\n", t, zvelocity); printf("Kassiopeia says: fcyc is %g\n", fcyc); @@ -510,16 +553,19 @@ namespace Kassiopeia printf("Lorentz factor is %f\n", fStep->InitialParticle().GetLorentzFactor()); printf("1/(sqrt(1-v^2/c^2) is %f\n", 1.0/pow(1.0-pow(fStep->InitialParticle().GetSpeed()/2.99792e8,2.),0.5)); printf("FinalParticle().IsActive() is %d\n", fStep->FinalParticle().IsActive()); -// getchar(); - pthread_mutex_unlock (&mymutex); // unlock access after writing. - } } // while pause flag is true. aka while Locust is hacking in. + + + if (fStep->PauseFlag() == false) ExecuteTrack(); // just execute a track without dealing with globals or threads. + + + // end pls additions. From 99dbab5b0f5cd9aa216f1b944d80b361aa58ee00 Mon Sep 17 00:00:00 2001 From: pslocum Date: Wed, 11 May 2016 17:05:06 -0400 Subject: [PATCH 09/28] Moved post-KSStep code for Locust_mc out of KSRoot.cxx and into CyclotronRadiationExtractor::ExecutePostStepModification(). --- Kassiopeia/Simulation/Include/KSRoot.h | 1 - Kassiopeia/Simulation/Source/KSRoot.cxx | 86 ++----------------------- 2 files changed, 6 insertions(+), 81 deletions(-) diff --git a/Kassiopeia/Simulation/Include/KSRoot.h b/Kassiopeia/Simulation/Include/KSRoot.h index 147906bc6..a3c44d7cb 100644 --- a/Kassiopeia/Simulation/Include/KSRoot.h +++ b/Kassiopeia/Simulation/Include/KSRoot.h @@ -85,7 +85,6 @@ namespace Kassiopeia unsigned int fEventIndex; unsigned int fTrackIndex; unsigned int fStepIndex; - unsigned int fPersistentStepIndex; static bool fStopRunSignal; static bool fStopEventSignal; diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index f0d568757..c688bca6b 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -1,4 +1,5 @@ -#include "LMCGlobals.hh" +#include "LMCGlobalsDeclaration.hh" // pls addition +#include "LMCGlobalsDefinition.hh" // pls addition #include "KSRoot.h" #include "KSRunMessage.h" @@ -40,6 +41,7 @@ using std::numeric_limits; #include + namespace Kassiopeia { bool KSRoot::fStopRunSignal = false; @@ -72,8 +74,7 @@ namespace Kassiopeia fRunIndex( 0 ), fEventIndex( 0 ), fTrackIndex( 0 ), - fStepIndex( 0 ), - fPersistentStepIndex( 0 ) // pls addition + fStepIndex( 0 ) { KSParticleFactory::GetInstance()->SetMagneticField( fRootMagneticField ); KSParticleFactory::GetInstance()->SetElectricField( fRootElectricField ); @@ -416,11 +417,9 @@ namespace Kassiopeia fEvent->ParentRunId() = fRun->GetRunId(); // execute event - fStep->PauseFlag() = true; // pls addition. this will be replaced by step modifier class. while (!ReceivedEventStartSTLCondition()) {} // pls: wait for event start. - printf("got the signal\n"); - - // end pls addition + printf("testvar is %f\n", testvar); // pls + printf("got the signal\n"); getchar(); // pls ExecuteEvent(); @@ -503,73 +502,7 @@ namespace Kassiopeia delete tParticle; fEvent->ParticleQueue().pop_front(); - - - // pls code starts here: - - - fPersistentStepIndex = fStepIndex; // This index updates before each track starts. It is similar to - // fRun->TotalSteps() except that it updates BEFORE THE TRACK STARTS. - printf("fEvent->TotalSteps() is %d and fStepIndex is %d and fStep->FinalParticle().IsActive() is %d and fPersistenStepIndex is %d and fEvent->TotalTracks() is %d\n", - fEvent->TotalSteps(), fStepIndex, fStep->FinalParticle().IsActive(), fPersistentStepIndex, fEvent->TotalTracks()); - while( (fStep->PauseFlag() == true) && ((fStep->FinalParticle().IsActive() == true) || (fPersistentStepIndex == fStepIndex))) // pls addition. - // middle of track new track starting - { - - // execute a track ExecuteTrack(); - t += fStep->ContinuousTime(); - if (t - t_old > 5.e-9) - { - // pthread_mutex_lock (&mymutex); // lock access to mutex before writing to globals. - std::unique_lock< std::mutex >tLock( fMutexDigitizer, std::defer_lock ); // lock access to mutex before writing to globals. - tLock.lock(); - Z = fStep->InitialParticle().GetPosition().Z(); - R = fStep->InitialParticle().GetPosition().Perp(); - K = fStep->InitialParticle().GetKineticEnergy_eV(); - zvelocity = fStep->InitialParticle().GetVelocity().GetZ(); - GammaZ = 1.0/pow(1.0-pow(zvelocity/2.99792e8,2.),0.5); - - vlong = fStep->InitialParticle().GetLongVelocity(); - dt = fStep->ContinuousTime(); - fcyc = 1./8./dt; - de = fStep->ContinuousEnergyChange(); - LarmorPower = -de/dt*1.602677e-19; - tLock.unlock(); - - // printf("z position is %g and dt is %g\n", Z, dt); - - printf("Kassiopeia is about to send out a tick\n"); - fDigitizerCondition.notify_one(); // notify Locust after writing. - -// getchar(); - - t_old = t; - printf("Kassiopeia says: tick has happened; continuous time is %g and longvelocity is %f\n", t, zvelocity); - printf("Kassiopeia says: fcyc is %g\n", fcyc); - printf(" initial particle momentum: %g\n", fStep->InitialParticle().GetMomentum().Z()); - printf("Mass is %g\n", fStep->InitialParticle().GetMass()); - printf("k.e. = %g eV\n", fStep->InitialParticle().GetKineticEnergy_eV()); - printf("Lorentz factor is %f\n", fStep->InitialParticle().GetLorentzFactor()); - printf("1/(sqrt(1-v^2/c^2) is %f\n", 1.0/pow(1.0-pow(fStep->InitialParticle().GetSpeed()/2.99792e8,2.),0.5)); - printf("FinalParticle().IsActive() is %d\n", fStep->FinalParticle().IsActive()); - } - - } // while pause flag is true. aka while Locust is hacking in. - - - - - if (fStep->PauseFlag() == false) - ExecuteTrack(); // just execute a track without dealing with globals or threads. - - - - -// end pls additions. - - - // move particles in track queue to event queue while( fTrack->ParticleQueue().empty() == false ) @@ -610,9 +543,6 @@ namespace Kassiopeia void KSRoot::ExecuteTrack() { - // "if" brackets - pls addition. If the track loop finished a.k.a. fPersistentStepIndex got updated. - if (fStep->PauseFlag() == false || (fPersistentStepIndex == fStepIndex)) - { // reset track fTrack->TrackId() = fTrackIndex; @@ -640,8 +570,6 @@ namespace Kassiopeia //clear any internal trajectory state fRootTrajectory->Reset(); - } // end pls addition. - while( fStep->FinalParticle().IsActive() == true ) { //signal handler break @@ -684,8 +612,6 @@ namespace Kassiopeia fTrack->DiscreteEnergyChange() += fStep->DiscreteEnergyChange(); fTrack->DiscreteMomentumChange() += fStep->DiscreteMomentumChange(); fTrack->DiscreteSecondaries() += fStep->DiscreteSecondaries(); - if (fStep->PauseFlag() == true && fStep->FinalParticle().IsActive() == true) - return; // pls addition: get out of this track for now. } } From 1b0ff2329b9f5a44db01d31b6abf4fb5e9b10c35 Mon Sep 17 00:00:00 2001 From: pslocum Date: Thu, 12 May 2016 10:44:03 -0400 Subject: [PATCH 10/28] Reset digitizer t_old in KSRoot::ReceivedEventStartCondition at the start of each Kass event. --- Kassiopeia/Simulation/Source/KSRoot.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index c688bca6b..6bada8b79 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -368,6 +368,7 @@ namespace Kassiopeia fKassEventReady = true; std::unique_lock< std::mutex >tLock( fMutex ); fPreEventCondition.wait( tLock ); + t_old = 0.; // reset time on digitizer. fKassEventReady = false; return true; } From 22ca12f8f629118ee7a7a07a9b474aeba6b17be3 Mon Sep 17 00:00:00 2001 From: pslocum Date: Thu, 19 May 2016 13:36:28 -0400 Subject: [PATCH 11/28] Tuned thread signals for faster Locust-Kassiopeia. --- Kassiopeia/Simulation/Source/KSRoot.cxx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index 6bada8b79..558c2af1d 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -354,25 +354,27 @@ namespace Kassiopeia { fEventInProgress = false; if( TotalEvents == EventsSoFar-1 ) fRunInProgress = false; - fDigitizerCondition.notify_one(); + fDigitizerCondition.notify_one(); // unlock + fKassReadyCondition.notify_one(); // unlock return; } - bool ReceivedEventStartSTLCondition() + bool ReceivedEventStartCondition() { if( fWaitBeforeEvent ) { printf("waiting for event trigger ...\n"); fKassEventReady = true; + fKassReadyCondition.notify_one(); std::unique_lock< std::mutex >tLock( fMutex ); fPreEventCondition.wait( tLock ); - t_old = 0.; // reset time on digitizer. fKassEventReady = false; + t_old = 0.; // reset time on digitizer. return true; } - return false; + return true; // check this. should return true if no wait. } @@ -418,9 +420,11 @@ namespace Kassiopeia fEvent->ParentRunId() = fRun->GetRunId(); // execute event - while (!ReceivedEventStartSTLCondition()) {} // pls: wait for event start. - printf("testvar is %f\n", testvar); // pls - printf("got the signal\n"); getchar(); // pls + if (ReceivedEventStartCondition()) + { +// printf("testvar is %f\n", testvar); // pls + printf("got the event trigger\n"); //getchar(); // pls + } ExecuteEvent(); From 606e9902fd9a66ed269d6499d28534da1f403cad Mon Sep 17 00:00:00 2001 From: pslocum Date: Mon, 20 Jun 2016 10:10:18 -0400 Subject: [PATCH 12/28] Tweaked timing of thread signals to interface with Locust. --- Kassiopeia/Simulation/Source/KSRoot.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index 558c2af1d..cfad3f91b 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -365,8 +365,8 @@ namespace Kassiopeia { if( fWaitBeforeEvent ) { - printf("waiting for event trigger ...\n"); fKassEventReady = true; + printf("waiting for event trigger ...\n"); fKassReadyCondition.notify_one(); std::unique_lock< std::mutex >tLock( fMutex ); fPreEventCondition.wait( tLock ); From dcf495664632c2a58dacde8b65715d1b25f96630 Mon Sep 17 00:00:00 2001 From: "Penelope L. Slocum of group heeger" Date: Tue, 19 Jul 2016 10:32:01 -0400 Subject: [PATCH 13/28] Commented out step_msg updates in KSRoot.cxx. Moved print statement on thread status out of ReceivedEventStartCondition. --- Kassiopeia/Simulation/Source/KSRoot.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index cfad3f91b..aa306b75c 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -366,7 +366,6 @@ namespace Kassiopeia if( fWaitBeforeEvent ) { fKassEventReady = true; - printf("waiting for event trigger ...\n"); fKassReadyCondition.notify_one(); std::unique_lock< std::mutex >tLock( fMutex ); fPreEventCondition.wait( tLock ); @@ -420,10 +419,11 @@ namespace Kassiopeia fEvent->ParentRunId() = fRun->GetRunId(); // execute event + printf("Kass is waiting for event trigger.\n"); if (ReceivedEventStartCondition()) { // printf("testvar is %f\n", testvar); // pls - printf("got the event trigger\n"); //getchar(); // pls + printf("Kass got the event trigger\n"); //getchar(); // pls } ExecuteEvent(); @@ -685,15 +685,17 @@ namespace Kassiopeia fStep->SurfaceNavigationFlag() = false; // send report + /* if( fStep->GetStepId() % fSimulation->GetStepReportIteration() == 0 ) { - stepmsg( eNormal ) << "processing step " << fStep->GetStepId() << "... ("; - stepmsg << "z = " << fStep->InitialParticle().GetPosition().Z() << ", "; + stepmsg( eNormal ) << "processing step " << fStep->GetStepId() << "... ("; + stepmsg << "z = " << fStep->InitialParticle().GetPosition().Z() << ", "; stepmsg << "r = " << fStep->InitialParticle().GetPosition().Perp() << ", "; stepmsg << "k = " << fStep->InitialParticle().GetKineticEnergy_eV() << ", "; stepmsg << "e = " << fStep->InitialParticle().GetKineticEnergy_eV() + (fStep->InitialParticle().GetCharge() / KConst::Q()) * fStep->InitialParticle().GetElectricPotential(); stepmsg << ")" << reom; } + */ // debug spritz stepmsg_debug( "processing step " << fStep->GetStepId() << eom ) From 821caba10573c27f7b8ba6e45febe014cb3bfe2f Mon Sep 17 00:00:00 2001 From: "Penelope L. Slocum of group heeger" Date: Fri, 7 Oct 2016 10:24:07 -0400 Subject: [PATCH 14/28] Adjusted thread signals to accomodate isotropic Kr spectrum with low trapping rate. --- Kassiopeia/Simulation/Source/KSRoot.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index aa306b75c..4882d88b9 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -356,16 +356,19 @@ namespace Kassiopeia if( TotalEvents == EventsSoFar-1 ) fRunInProgress = false; fDigitizerCondition.notify_one(); // unlock fKassReadyCondition.notify_one(); // unlock + printf("Kass is waking after event\n"); return; } bool ReceivedEventStartCondition() - { - if( fWaitBeforeEvent ) - { - fKassEventReady = true; + { + fKassEventReady = true; + fDigitizerCondition.notify_one(); // unlock if still locked. + if( fWaitBeforeEvent ) + { + fKassReadyCondition.notify_one(); std::unique_lock< std::mutex >tLock( fMutex ); fPreEventCondition.wait( tLock ); From 0b2718111c8fa01c102f9d061edda9918492eced Mon Sep 17 00:00:00 2001 From: "Penelope L. Slocum of group heeger" Date: Sat, 8 Oct 2016 13:34:08 -0400 Subject: [PATCH 15/28] Removed unnecessary fKassReadycondition.notify_one() from KSRoot::WakeAfterEVent --- Kassiopeia/Simulation/Source/KSRoot.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index 4882d88b9..2f71eda74 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -355,7 +355,7 @@ namespace Kassiopeia fEventInProgress = false; if( TotalEvents == EventsSoFar-1 ) fRunInProgress = false; fDigitizerCondition.notify_one(); // unlock - fKassReadyCondition.notify_one(); // unlock + // fKassReadyCondition.notify_one(); // unlock printf("Kass is waking after event\n"); return; } From 7e0a0ca641bd4a64eb61be61a6de665d22896f73 Mon Sep 17 00:00:00 2001 From: "Penelope L. Slocum of group heeger" Date: Thu, 13 Oct 2016 10:49:17 -0400 Subject: [PATCH 16/28] Tuned final thread stop signal in KSRoot.cxx --- Kassiopeia/Simulation/Source/KSRoot.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index 2f71eda74..e59b67907 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -353,9 +353,12 @@ namespace Kassiopeia void WakeAfterEvent(unsigned TotalEvents, unsigned EventsSoFar) { fEventInProgress = false; - if( TotalEvents == EventsSoFar-1 ) fRunInProgress = false; + if( TotalEvents == EventsSoFar-1 ) + { + fRunInProgress = false; + fKassReadyCondition.notify_one(); + } fDigitizerCondition.notify_one(); // unlock - // fKassReadyCondition.notify_one(); // unlock printf("Kass is waking after event\n"); return; } From 9e0c131f2b2535b75e79157db29747383255f805 Mon Sep 17 00:00:00 2001 From: pslocum Date: Mon, 26 Dec 2016 20:28:00 -0500 Subject: [PATCH 17/28] Removed initialization and finalization of derivative calculations in KSTrajInterpolatorHermite.cxx pending more testing. --- .../Include/KSTrajInterpolatorHermite.h | 8 ++++++ .../Source/KSTrajInterpolatorHermite.cxx | 28 +++++++++++++++++-- .../Source/KSTrajTrajectoryAdiabatic.cxx | 3 ++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Kassiopeia/Trajectories/Include/KSTrajInterpolatorHermite.h b/Kassiopeia/Trajectories/Include/KSTrajInterpolatorHermite.h index 25b759b9b..1c3e2f721 100644 --- a/Kassiopeia/Trajectories/Include/KSTrajInterpolatorHermite.h +++ b/Kassiopeia/Trajectories/Include/KSTrajInterpolatorHermite.h @@ -26,6 +26,14 @@ namespace Kassiopeia virtual ~KSTrajInterpolatorHermite(); public: + void GetInterpolate(double aTime, + const KSTrajAdiabaticIntegrator& anIntegrator, + const KSTrajAdiabaticDifferentiator& aDifferentiator, + const KSTrajAdiabaticParticle& anInitialParticle, + const KSTrajAdiabaticParticle& aFinalParticle, + const double& aTimeStep, + KSTrajAdiabaticParticle& anIntermediateParticle ) const; + virtual void Interpolate(double aTime, const KSTrajExactIntegrator& anIntegrator, const KSTrajExactDifferentiator& aDifferentiator, const KSTrajExactParticle& anInitialParticle, const KSTrajExactParticle& aFinalParticle, const double& aTimeStep, KSTrajExactParticle& anIntermediateParticle ) const; diff --git a/Kassiopeia/Trajectories/Source/KSTrajInterpolatorHermite.cxx b/Kassiopeia/Trajectories/Source/KSTrajInterpolatorHermite.cxx index b8f7c761c..86ea51873 100644 --- a/Kassiopeia/Trajectories/Source/KSTrajInterpolatorHermite.cxx +++ b/Kassiopeia/Trajectories/Source/KSTrajInterpolatorHermite.cxx @@ -88,6 +88,23 @@ namespace Kassiopeia } } + void KSTrajInterpolatorHermite::GetInterpolate(double aTime, + const KSTrajAdiabaticIntegrator& anIntegrator, + const KSTrajAdiabaticDifferentiator& aDifferentiator, + const KSTrajAdiabaticParticle& anInitialParticle, + const KSTrajAdiabaticParticle& aFinalParticle, + const double& aTimeStep, + KSTrajAdiabaticParticle& anIntermediateParticle ) const + { +// This is a routine to call the interpolater from a step modifier for Project 8. + + + KSTrajInterpolatorHermite::Interpolate(aTime, anIntegrator, aDifferentiator, anInitialParticle, aFinalParticle, aTimeStep, anIntermediateParticle); + + } + + + void KSTrajInterpolatorHermite::Interpolate(double aTime, const KSTrajAdiabaticIntegrator& anIntegrator, const KSTrajAdiabaticDifferentiator& aDifferentiator, @@ -132,9 +149,14 @@ namespace Kassiopeia CubicHermite(tFraction, h30, h31, h32, h33); //retrieve the first derivative evaluation from the integrator + KSTrajAdiabaticDerivative initialDerivative; initialDerivative = 0.0; - bool isValid = anIntegrator.GetInitialDerivative(initialDerivative); +// bool isValid = anIntegrator.GetInitialDerivative(initialDerivative); + + bool isValid = true; // Project 8 edit + + if(!isValid) { aDifferentiator.Differentiate(anInitialParticle.GetTime(), anInitialParticle, initialDerivative); @@ -143,7 +165,8 @@ namespace Kassiopeia //retrieve the final derivative evaluation from the integrator KSTrajAdiabaticDerivative finalDerivative; finalDerivative = 0.0; - isValid = anIntegrator.GetFinalDerivative(finalDerivative); +// isValid = anIntegrator.GetFinalDerivative(finalDerivative); + isValid = true; // Project 8 edit if(!isValid) { aDifferentiator.Differentiate(aFinalParticle.GetTime(), aFinalParticle, finalDerivative); @@ -154,6 +177,7 @@ namespace Kassiopeia anIntermediateParticle[0] = tInterpolatedTime; //explicitly set the time variable } + //interpolate alpha and beta linearly //(leaving this unchanged from fast interpolator, may need to improve this) KThreeVector tInitialAlpha = anInitialParticle.GetAlpha().Unit(); diff --git a/Kassiopeia/Trajectories/Source/KSTrajTrajectoryAdiabatic.cxx b/Kassiopeia/Trajectories/Source/KSTrajTrajectoryAdiabatic.cxx index 896f51f26..d8f660456 100644 --- a/Kassiopeia/Trajectories/Source/KSTrajTrajectoryAdiabatic.cxx +++ b/Kassiopeia/Trajectories/Source/KSTrajTrajectoryAdiabatic.cxx @@ -52,6 +52,8 @@ namespace Kassiopeia { } + + void KSTrajTrajectoryAdiabatic::SetIntegrator( KSTrajAdiabaticIntegrator* anIntegrator ) { if( fIntegrator == NULL ) @@ -62,6 +64,7 @@ namespace Kassiopeia trajmsg( eError ) << "cannot set integrator in <" << this->GetName() << "> with <" << anIntegrator << ">" << eom; return; } + void KSTrajTrajectoryAdiabatic::ClearIntegrator( KSTrajAdiabaticIntegrator* anIntegrator ) { if( fIntegrator == anIntegrator ) From c08dbdbb5191327ed05987fa2bc6341fd598207b Mon Sep 17 00:00:00 2001 From: "Penelope L. Slocum of group heeger" Date: Thu, 5 Jan 2017 12:54:58 -0500 Subject: [PATCH 18/28] Routine update --- .../Include/KSTrajInterpolatorHermite.h | 8 ------ .../Source/KSTrajInterpolatorHermite.cxx | 28 ++----------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/Kassiopeia/Trajectories/Include/KSTrajInterpolatorHermite.h b/Kassiopeia/Trajectories/Include/KSTrajInterpolatorHermite.h index 1c3e2f721..25b759b9b 100644 --- a/Kassiopeia/Trajectories/Include/KSTrajInterpolatorHermite.h +++ b/Kassiopeia/Trajectories/Include/KSTrajInterpolatorHermite.h @@ -26,14 +26,6 @@ namespace Kassiopeia virtual ~KSTrajInterpolatorHermite(); public: - void GetInterpolate(double aTime, - const KSTrajAdiabaticIntegrator& anIntegrator, - const KSTrajAdiabaticDifferentiator& aDifferentiator, - const KSTrajAdiabaticParticle& anInitialParticle, - const KSTrajAdiabaticParticle& aFinalParticle, - const double& aTimeStep, - KSTrajAdiabaticParticle& anIntermediateParticle ) const; - virtual void Interpolate(double aTime, const KSTrajExactIntegrator& anIntegrator, const KSTrajExactDifferentiator& aDifferentiator, const KSTrajExactParticle& anInitialParticle, const KSTrajExactParticle& aFinalParticle, const double& aTimeStep, KSTrajExactParticle& anIntermediateParticle ) const; diff --git a/Kassiopeia/Trajectories/Source/KSTrajInterpolatorHermite.cxx b/Kassiopeia/Trajectories/Source/KSTrajInterpolatorHermite.cxx index 86ea51873..b8f7c761c 100644 --- a/Kassiopeia/Trajectories/Source/KSTrajInterpolatorHermite.cxx +++ b/Kassiopeia/Trajectories/Source/KSTrajInterpolatorHermite.cxx @@ -88,23 +88,6 @@ namespace Kassiopeia } } - void KSTrajInterpolatorHermite::GetInterpolate(double aTime, - const KSTrajAdiabaticIntegrator& anIntegrator, - const KSTrajAdiabaticDifferentiator& aDifferentiator, - const KSTrajAdiabaticParticle& anInitialParticle, - const KSTrajAdiabaticParticle& aFinalParticle, - const double& aTimeStep, - KSTrajAdiabaticParticle& anIntermediateParticle ) const - { -// This is a routine to call the interpolater from a step modifier for Project 8. - - - KSTrajInterpolatorHermite::Interpolate(aTime, anIntegrator, aDifferentiator, anInitialParticle, aFinalParticle, aTimeStep, anIntermediateParticle); - - } - - - void KSTrajInterpolatorHermite::Interpolate(double aTime, const KSTrajAdiabaticIntegrator& anIntegrator, const KSTrajAdiabaticDifferentiator& aDifferentiator, @@ -149,14 +132,9 @@ namespace Kassiopeia CubicHermite(tFraction, h30, h31, h32, h33); //retrieve the first derivative evaluation from the integrator - KSTrajAdiabaticDerivative initialDerivative; initialDerivative = 0.0; -// bool isValid = anIntegrator.GetInitialDerivative(initialDerivative); - - bool isValid = true; // Project 8 edit - - + bool isValid = anIntegrator.GetInitialDerivative(initialDerivative); if(!isValid) { aDifferentiator.Differentiate(anInitialParticle.GetTime(), anInitialParticle, initialDerivative); @@ -165,8 +143,7 @@ namespace Kassiopeia //retrieve the final derivative evaluation from the integrator KSTrajAdiabaticDerivative finalDerivative; finalDerivative = 0.0; -// isValid = anIntegrator.GetFinalDerivative(finalDerivative); - isValid = true; // Project 8 edit + isValid = anIntegrator.GetFinalDerivative(finalDerivative); if(!isValid) { aDifferentiator.Differentiate(aFinalParticle.GetTime(), aFinalParticle, finalDerivative); @@ -177,7 +154,6 @@ namespace Kassiopeia anIntermediateParticle[0] = tInterpolatedTime; //explicitly set the time variable } - //interpolate alpha and beta linearly //(leaving this unchanged from fast interpolator, may need to improve this) KThreeVector tInitialAlpha = anInitialParticle.GetAlpha().Unit(); From 3bc272555f5fd6c1159e33d2b1a1ecfa9836a3c7 Mon Sep 17 00:00:00 2001 From: pslocum Date: Fri, 16 Jun 2017 11:27:43 -0400 Subject: [PATCH 19/28] Revert "Feature/eventmod" --- CMakeLists.txt | 3 - KEMField/CMakeLists.txt | 10 ++- KGeoBag/CMakeLists.txt | 3 - Kassiopeia/Bindings/CMakeLists.txt | 2 - Kassiopeia/CMakeLists.txt | 10 ++- Kassiopeia/Operators/CMakeLists.txt | 2 - .../Operators/Include/KSEventModifier.h | 5 +- Kassiopeia/Simulation/CMakeLists.txt | 2 - .../Simulation/Include/KSRootEventModifier.h | 3 +- Kassiopeia/Simulation/Include/KSStep.h | 1 - Kassiopeia/Simulation/Source/KSRoot.cxx | 64 ++----------------- .../Source/KSTrajTrajectoryAdiabatic.cxx | 3 - Kommon/CMakeLists.txt | 3 - .../Core/Initialization/KVariableProcessor.cc | 7 -- .../Core/Initialization/KVariableProcessor.hh | 2 - Kommon/cmake/KasperDefaults.cmake | 5 +- 16 files changed, 19 insertions(+), 106 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbc8253d7..75de7dea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,4 @@ cmake_minimum_required( VERSION 2.8.6 ) -if(POLICY CMP0048) - cmake_policy(SET CMP0048 OLD) -endif() project( Kasper ) diff --git a/KEMField/CMakeLists.txt b/KEMField/CMakeLists.txt index dc6c4118b..1500be51f 100644 --- a/KEMField/CMakeLists.txt +++ b/KEMField/CMakeLists.txt @@ -1,14 +1,12 @@ cmake_minimum_required( VERSION 2.8.6 ) -if(POLICY CMP0048) - cmake_policy(SET CMP0048 OLD) -endif() -if( POLICY CMP0053 ) - cmake_policy( SET CMP0053 OLD ) -endif( POLICY CMP0053 ) project(KEMField) include(KasperDefaults) +if(POLICY CMP0053) + cmake_policy(SET CMP0053 OLD) +endif() + # Module version set(MODULE_VERSION_MAJOR 2) set(MODULE_VERSION_MINOR 1) diff --git a/KGeoBag/CMakeLists.txt b/KGeoBag/CMakeLists.txt index da66a1e54..2db34a04e 100644 --- a/KGeoBag/CMakeLists.txt +++ b/KGeoBag/CMakeLists.txt @@ -1,7 +1,4 @@ cmake_minimum_required( VERSION 2.8.6 ) -if(POLICY CMP0048) - cmake_policy(SET CMP0048 OLD) -endif() project( KGeoBag ) include( KasperDefaults ) diff --git a/Kassiopeia/Bindings/CMakeLists.txt b/Kassiopeia/Bindings/CMakeLists.txt index 43e640309..80137b7bf 100644 --- a/Kassiopeia/Bindings/CMakeLists.txt +++ b/Kassiopeia/Bindings/CMakeLists.txt @@ -162,7 +162,6 @@ set( BINDINGS_HEADER_FILES # simulation Simulation/Include/KSRootMagneticFieldBuilder.h Simulation/Include/KSRootElectricFieldBuilder.h - Simulation/Include/KSRootEventModifierBuilder.h Simulation/Include/KSRootGeneratorBuilder.h Simulation/Include/KSRootTrajectoryBuilder.h Simulation/Include/KSRootSpaceInteractionBuilder.h @@ -372,7 +371,6 @@ set( BINDINGS_SOURCE_FILES # simulation Simulation/Source/KSRootMagneticFieldBuilder.cxx Simulation/Source/KSRootElectricFieldBuilder.cxx - Simulation/Source/KSRootEventModifierBuilder.cxx Simulation/Source/KSRootGeneratorBuilder.cxx Simulation/Source/KSRootTrajectoryBuilder.cxx Simulation/Source/KSRootSpaceInteractionBuilder.cxx diff --git a/Kassiopeia/CMakeLists.txt b/Kassiopeia/CMakeLists.txt index 27109955e..78aebbda2 100644 --- a/Kassiopeia/CMakeLists.txt +++ b/Kassiopeia/CMakeLists.txt @@ -5,16 +5,14 @@ # thank you! -dan. cmake_minimum_required( VERSION 2.8.6 ) -if(POLICY CMP0048) - cmake_policy(SET CMP0048 OLD) -endif() -if( POLICY CMP0053 ) - cmake_policy( SET CMP0053 OLD ) -endif( POLICY CMP0053 ) project( Kassiopeia ) include( KasperDefaults ) +if(POLICY CMP0053) + cmake_policy(SET CMP0053 OLD) +endif() + # module version set( MODULE_VERSION_MAJOR 3 ) set( MODULE_VERSION_MINOR 3 ) diff --git a/Kassiopeia/Operators/CMakeLists.txt b/Kassiopeia/Operators/CMakeLists.txt index aa2f47237..fd8a29f99 100644 --- a/Kassiopeia/Operators/CMakeLists.txt +++ b/Kassiopeia/Operators/CMakeLists.txt @@ -1,6 +1,5 @@ # header files set( OPERATORS_HEADER_BASENAMES - KSEventModifier.h KSOperatorsMessage.h KSParticle.h KSParticleFactory.h @@ -31,7 +30,6 @@ endforeach( BASENAME ) # source files set( OPERATORS_SOURCE_BASENAMES - KSEventModifier.cxx KSOperatorsMessage.cxx KSParticle.cxx KSParticleFactory.cxx diff --git a/Kassiopeia/Operators/Include/KSEventModifier.h b/Kassiopeia/Operators/Include/KSEventModifier.h index d801e9ed7..c5df8bf7a 100644 --- a/Kassiopeia/Operators/Include/KSEventModifier.h +++ b/Kassiopeia/Operators/Include/KSEventModifier.h @@ -5,7 +5,6 @@ namespace Kassiopeia { - class KSEvent; class KSEventModifier: @@ -17,14 +16,12 @@ namespace Kassiopeia public: - //returns true if any of the state variables of anEvent are changed virtual bool ExecutePreEventModification( KSEvent& anEvent ) = 0; //returns true if any of the state variables of anEvent are changed virtual bool ExecutePostEventModification( KSEvent& anEvent ) = 0; - - }; + }; } diff --git a/Kassiopeia/Simulation/CMakeLists.txt b/Kassiopeia/Simulation/CMakeLists.txt index 524d237e1..e15dbf3c4 100644 --- a/Kassiopeia/Simulation/CMakeLists.txt +++ b/Kassiopeia/Simulation/CMakeLists.txt @@ -11,7 +11,6 @@ set( SIMULATION_HEADER_BASENAMES KSTrack.h KSStep.h KSRootElectricField.h - KSRootEventModifier.h KSRootMagneticField.h KSRootStepModifier.h KSRootTrackModifier.h @@ -48,7 +47,6 @@ set( SIMULATION_SOURCE_BASENAMES KSTrack.cxx KSStep.cxx KSRootElectricField.cxx - KSRootEventModifier.cxx KSRootMagneticField.cxx KSRootStepModifier.cxx KSRootTrackModifier.cxx diff --git a/Kassiopeia/Simulation/Include/KSRootEventModifier.h b/Kassiopeia/Simulation/Include/KSRootEventModifier.h index df8b33488..83c879969 100644 --- a/Kassiopeia/Simulation/Include/KSRootEventModifier.h +++ b/Kassiopeia/Simulation/Include/KSRootEventModifier.h @@ -25,7 +25,6 @@ namespace Kassiopeia //********** public: - bool ExecutePreEventModification( KSEvent& anEvent ); bool ExecutePostEventModification( KSEvent& anEvent ); @@ -46,7 +45,6 @@ namespace Kassiopeia //****** public: - void SetEvent( KSEvent* anEvent ); bool ExecutePreEventModification(); @@ -56,6 +54,7 @@ namespace Kassiopeia virtual void PushDeupdateComponent(); private: + KSEvent* fEvent; }; diff --git a/Kassiopeia/Simulation/Include/KSStep.h b/Kassiopeia/Simulation/Include/KSStep.h index 518f3c49d..f075cc999 100644 --- a/Kassiopeia/Simulation/Include/KSStep.h +++ b/Kassiopeia/Simulation/Include/KSStep.h @@ -51,7 +51,6 @@ namespace Kassiopeia public: K_REFS( std::string, TerminatorName ) K_REFS( bool, TerminatorFlag ) - K_REFS( bool, PauseFlag ); // pls addition. //********** //trajectory diff --git a/Kassiopeia/Simulation/Source/KSRoot.cxx b/Kassiopeia/Simulation/Source/KSRoot.cxx index 72acf6ca0..6200916f8 100644 --- a/Kassiopeia/Simulation/Source/KSRoot.cxx +++ b/Kassiopeia/Simulation/Source/KSRoot.cxx @@ -1,6 +1,3 @@ -#include "LMCGlobalsDeclaration.hh" // pls addition -#include "LMCGlobalsDefinition.hh" // pls addition - #include "KSRoot.h" #include "KSRunMessage.h" #include "KSEventMessage.h" @@ -265,6 +262,9 @@ namespace Kassiopeia } KSRoot::~KSRoot() { + /* + * KToolbox takes care of destruction + */ } void KSRoot::Execute( KSSimulation* aSimulation ) @@ -379,42 +379,6 @@ namespace Kassiopeia return; } - - - void WakeAfterEvent(unsigned TotalEvents, unsigned EventsSoFar) - { - fEventInProgress = false; - if( TotalEvents == EventsSoFar-1 ) - { - fRunInProgress = false; - fKassReadyCondition.notify_one(); - } - fDigitizerCondition.notify_one(); // unlock - printf("Kass is waking after event\n"); - return; - } - - - - bool ReceivedEventStartCondition() - { - fKassEventReady = true; - fDigitizerCondition.notify_one(); // unlock if still locked. - if( fWaitBeforeEvent ) - { - - fKassReadyCondition.notify_one(); - std::unique_lock< std::mutex >tLock( fMutex ); - fPreEventCondition.wait( tLock ); - fKassEventReady = false; - t_old = 0.; // reset time on digitizer. - return true; - } - return true; // check this. should return true if no wait. - } - - - void KSRoot::ExecuteRun() { // set random seed @@ -459,17 +423,8 @@ namespace Kassiopeia fEvent->ParentRunId() = fRun->GetRunId(); // execute event - printf("Kass is waiting for event trigger.\n"); - if (ReceivedEventStartCondition()) - { -// printf("testvar is %f\n", testvar); // pls - printf("Kass got the event trigger\n"); //getchar(); // pls - } - ExecuteEvent(); - WakeAfterEvent(fRun->GetTotalEvents(), fSimulation->GetEvents()); // pls - // update run fRun->TotalEvents() += 1; fRun->TotalTracks() += fEvent->TotalTracks(); @@ -496,6 +451,7 @@ namespace Kassiopeia // send report runmsg( eNormal ) << "...run " << fRun->GetRunId() << " complete" << eom; + fStopRunSignal = false; return; } @@ -523,9 +479,6 @@ namespace Kassiopeia // generate primaries fRootGenerator->ExecuteGeneration(); - // execute post-step modification - fRootEventModifier->ExecutePreEventModification(); - // send report eventmsg( eNormal ) << "processing event " << fEvent->GetEventId() << " <" << fEvent->GetGeneratorName() << ">..." << eom; @@ -555,6 +508,7 @@ namespace Kassiopeia delete tParticle; fEvent->ParticleQueue().pop_front(); + // execute a track ExecuteTrack(); // move particles in track queue to event queue @@ -597,7 +551,6 @@ namespace Kassiopeia void KSRoot::ExecuteTrack() { - // reset track fTrack->TrackId() = fTrackIndex; fTrack->TotalSteps() = 0; @@ -668,7 +621,6 @@ namespace Kassiopeia fTrack->DiscreteEnergyChange() += fStep->DiscreteEnergyChange(); fTrack->DiscreteMomentumChange() += fStep->DiscreteMomentumChange(); fTrack->DiscreteSecondaries() += fStep->DiscreteSecondaries(); - } } @@ -741,17 +693,15 @@ namespace Kassiopeia fStep->SurfaceNavigationFlag() = false; // send report - /* if( fStep->GetStepId() % fSimulation->GetStepReportIteration() == 0 ) { - stepmsg( eNormal ) << "processing step " << fStep->GetStepId() << "... ("; - stepmsg << "z = " << fStep->InitialParticle().GetPosition().Z() << ", "; + stepmsg( eNormal ) << "processing step " << fStep->GetStepId() << "... ("; + stepmsg << "z = " << fStep->InitialParticle().GetPosition().Z() << ", "; stepmsg << "r = " << fStep->InitialParticle().GetPosition().Perp() << ", "; stepmsg << "k = " << fStep->InitialParticle().GetKineticEnergy_eV() << ", "; stepmsg << "e = " << fStep->InitialParticle().GetKineticEnergy_eV() + (fStep->InitialParticle().GetCharge() / KConst::Q()) * fStep->InitialParticle().GetElectricPotential(); stepmsg << ")" << reom; } - */ // debug spritz stepmsg_debug( "processing step " << fStep->GetStepId() << eom ) diff --git a/Kassiopeia/Trajectories/Source/KSTrajTrajectoryAdiabatic.cxx b/Kassiopeia/Trajectories/Source/KSTrajTrajectoryAdiabatic.cxx index d8f660456..896f51f26 100644 --- a/Kassiopeia/Trajectories/Source/KSTrajTrajectoryAdiabatic.cxx +++ b/Kassiopeia/Trajectories/Source/KSTrajTrajectoryAdiabatic.cxx @@ -52,8 +52,6 @@ namespace Kassiopeia { } - - void KSTrajTrajectoryAdiabatic::SetIntegrator( KSTrajAdiabaticIntegrator* anIntegrator ) { if( fIntegrator == NULL ) @@ -64,7 +62,6 @@ namespace Kassiopeia trajmsg( eError ) << "cannot set integrator in <" << this->GetName() << "> with <" << anIntegrator << ">" << eom; return; } - void KSTrajTrajectoryAdiabatic::ClearIntegrator( KSTrajAdiabaticIntegrator* anIntegrator ) { if( fIntegrator == anIntegrator ) diff --git a/Kommon/CMakeLists.txt b/Kommon/CMakeLists.txt index 05d195f09..cbe4b819f 100644 --- a/Kommon/CMakeLists.txt +++ b/Kommon/CMakeLists.txt @@ -1,7 +1,4 @@ cmake_minimum_required( VERSION 2.8.6 ) -if(POLICY CMP0048) - cmake_policy(SET CMP0048 OLD) -endif() project( Kommon ) set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${PROJECT_SOURCE_DIR}/GoogleTest/cmake ) diff --git a/Kommon/Core/Initialization/KVariableProcessor.cc b/Kommon/Core/Initialization/KVariableProcessor.cc index a025f8947..752f6bcd2 100644 --- a/Kommon/Core/Initialization/KVariableProcessor.cc +++ b/Kommon/Core/Initialization/KVariableProcessor.cc @@ -41,13 +41,6 @@ namespace katrin delete fLocalMap; } - void KVariableProcessor::SetExternalMap( const VariableMap& anExternalMap ) - { - delete fExternalMap; - fExternalMap = new VariableMap( anExternalMap ); - return; - } - void KVariableProcessor::ProcessToken( KBeginFileToken* aToken ) { if( fElementState == eElementInactive ) diff --git a/Kommon/Core/Initialization/KVariableProcessor.hh b/Kommon/Core/Initialization/KVariableProcessor.hh index b0e4563cb..abc4f1a16 100644 --- a/Kommon/Core/Initialization/KVariableProcessor.hh +++ b/Kommon/Core/Initialization/KVariableProcessor.hh @@ -23,8 +23,6 @@ namespace katrin KVariableProcessor( const VariableMap& anExternalMap ); virtual ~KVariableProcessor(); - void SetExternalMap( const VariableMap& anExternalMap ); - virtual void ProcessToken( KBeginFileToken* aToken ); virtual void ProcessToken( KBeginElementToken* aToken ); virtual void ProcessToken( KBeginAttributeToken* aToken ); diff --git a/Kommon/cmake/KasperDefaults.cmake b/Kommon/cmake/KasperDefaults.cmake index d63010a21..9e66af173 100644 --- a/Kommon/cmake/KasperDefaults.cmake +++ b/Kommon/cmake/KasperDefaults.cmake @@ -9,9 +9,8 @@ endmacro(set_path) include(CMakeDependentOption) include(MacroParseArguments) -cmake_policy( SET CMP0011 NEW ) +if( ${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} ) -if( "${Kasper_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}" ) set(STANDALONE true) # use this section to modifiy initial values of builtin CMAKE variables @@ -177,7 +176,7 @@ macro(kasper_find_module NAME) set( VERSION "0" ) endif() - find_package( ${NAME} ${VERSION} REQUIRED NO_MODULE HINTS ${Kasper_BINARY_DIR}/${NAME} ) + find_package( ${NAME} ${VERSION} REQUIRED NO_MODULE ) #message("${NAME}_INCLUDE_DIRS: ${${NAME}_INCLUDE_DIRS}") kasper_internal_include_directories( ${${NAME}_INCLUDE_DIRS} ) #kasper_external_include_directories( ${${NAME}_INCLUDE_DIRS} ) From 94544df1f157a9b488b9844a565cd7a35e81926a Mon Sep 17 00:00:00 2001 From: Noah Oblath Date: Fri, 1 May 2020 00:48:23 +0000 Subject: [PATCH 20/28] Check for Boost library as variable or imported target --- Kassiopeia/Applications/Other/CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Kassiopeia/Applications/Other/CMakeLists.txt b/Kassiopeia/Applications/Other/CMakeLists.txt index ef4a73884..f7bf980c9 100644 --- a/Kassiopeia/Applications/Other/CMakeLists.txt +++ b/Kassiopeia/Applications/Other/CMakeLists.txt @@ -33,9 +33,16 @@ set( APPLICATIONS_OTHER_LIBRARIES ) if( KASPER_USE_BOOST ) - list( APPEND APPLICATIONS_OTHER_LIBRARIES - ${Boost_LIBRARIES} - ) + if( Boost_LIBRARIES ) + list( APPEND APPLICATIONS_OTHER_LIBRARIES + ${Boost_LIBRARIES} + ) + endif() + if( TARGET Boost::program_options ) + list( APPEND APPLICATIONS_OTHER_LIBRARIES + Boost::program_options + ) + endif() endif() set( APPLICATIONS_OTHER_PATH From 035449724c1921b8b8988f6bba1ed9bc97ac5b64 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Tue, 13 Apr 2021 17:21:41 -0400 Subject: [PATCH 21/28] Commented out find_package() lines for Boost and Root in CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 876f8d573..68caf4196 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,10 +12,10 @@ project( Kasper ) # Silently try to find major dependencies. This list is not be complete! # (Somehow, CMake behaves better if this is done in the root scope before adding modules...) -find_package(Boost QUIET) +#find_package(Boost QUIET) find_package(HDF5 COMPONENTS CXX QUIET) find_package(MPI QUIET) -find_package(ROOT QUIET) +#find_package(ROOT QUIET) find_package(VTK QUIET) set( BUILD_SHARED_LIBS ON ) From ab1129752cc5cfb6db4915f990158577af69ee93 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Tue, 31 Aug 2021 13:46:26 -0400 Subject: [PATCH 22/28] Update CMakeLists.txt to v3.8.0 for purpose of merge test. --- CMakeLists.txt | 145 +++++++++++++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68caf4196..01a486f27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,21 @@ -set( CMAKE_MINIMUM_VERSION "3.13.0" ) +set( CMAKE_MINIMUM_VERSION "3.14.0" ) cmake_minimum_required( VERSION ${CMAKE_MINIMUM_VERSION} ) # project version set(KASPER_VERSION_MAJOR 3) -set(KASPER_VERSION_MINOR 7) -set(KASPER_VERSION_PATCH 7) +set(KASPER_VERSION_MINOR 8) +set(KASPER_VERSION_PATCH 0) set(KASPER_VERSION "${KASPER_VERSION_MAJOR}.${KASPER_VERSION_MINOR}.${KASPER_VERSION_PATCH}") -#project( Kasper VERSION ${KASPER_VERSION} ) -project( Kasper ) - -# Silently try to find major dependencies. This list is not be complete! -# (Somehow, CMake behaves better if this is done in the root scope before adding modules...) -#find_package(Boost QUIET) -find_package(HDF5 COMPONENTS CXX QUIET) -find_package(MPI QUIET) -#find_package(ROOT QUIET) -find_package(VTK QUIET) +#project( Kasper ) +project( Kasper VERSION ${KASPER_VERSION} + DESCRIPTION "The KATRIN Analysis and Simulations Package" + LANGUAGES CXX ) set( BUILD_SHARED_LIBS ON ) +set( Boost_USE_STATIC_LIBS OFF ) +set( Boost_USE_MULTITHREADED ON ) +set( Boost_USE_STATIC_RUNTIME OFF ) set( CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ standard whose features are requested to build this target" ) set( CMAKE_CXX_STANDARD_REQUIRED ON ) @@ -28,18 +25,18 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) # Additional compiler version checks, see https://en.cppreference.com/w/cpp/compiler_support if( CMAKE_SYSTEM_NAME STREQUAL "Linux" ) if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) - if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0" ) - message(WARNING "Your compiler is unsupported! You need at least GCC 5.0 to build Kasper.") + if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1" ) + message(FATAL_ERROR "Your compiler is unsupported! You need at least GCC 6.1 to build Kasper.") endif() elseif( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.4" ) - message(WARNING "Your compiler is unsupported! You need at least Clang 3.4 to build Kasper.") + message(FATAL_ERROR "Your compiler is unsupported! You need at least Clang 3.4 to build Kasper.") endif() endif() elseif( CMAKE_SYSTEM_NAME STREQUAL "Darwin" ) if( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0" ) - message(WARNING "Your compiler is unsupported! You need at least Clang 10.0 to build Kasper.") + message(FATAL_ERROR "Your compiler is unsupported! You need at least Clang 10.0 to build Kasper.") endif() endif() else() @@ -63,17 +60,12 @@ set( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE ) # which point to directories outside the build tree to the install RPATH set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) if( APPLE ) - set(CMAKE_INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR};@loader_path") + #set( CMAKE_INSTALL_RPATH "@executable_path/../${CMAKE_INSTALL_LIBDIR};@loader_path" ) + set( CMAKE_MACOSX_RPATH TRUE ) elseif( UNIX ) - set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") + set( CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" ) endif( APPLE ) -# the RPATH to be used when installing, but only if it's not a system directory -#LIST( FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${LIB_INSTALL_DIR}" isSystemDir ) -#IF( "${isSystemDir}" STREQUAL "-1" ) -# set( CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}" ) -#ENDIF() - # Flags for all modules, every module should have a flag. @@ -102,39 +94,34 @@ endif() # We like the compiler to be more pedantic than usual :-P add_compile_options( -Wall -Wextra -Werror ) +# Only link in libraries that we actually need (but not for executables since it makes things slow) +set(_target_type "$") +add_link_options( $,LINKER:--as-needed,LINKER:--no-as-needed> ) + # Enable some advanced options depending on build type if (CMAKE_BUILD_TYPE MATCHES Rel) option( COMPILER_TUNE_OPTIONS "Enable additional tuning options [compiles for local CPU, use with care!]" OFF ) + mark_as_advanced(COMPILER_TUNE_OPTIONS) if( COMPILER_TUNE_OPTIONS ) # These are advanced options for GCC which might improve performance ... or break everything - use with care! add_compile_options( -march=native -mfpmath=sse -funroll-loops ) endif( COMPILER_TUNE_OPTIONS ) endif() -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR CMAKE_COMPILER_IS_GNUCXX ) - if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.0" ) - # Use -faligned-new flag to trick gcc into using aligned allocators CL types. - # This is only used by KEMField, but required here because of include files. - add_compile_options($<$:-faligned-new>) - endif() - - # Enable some advanced options - option( GCC_FORCE_LINKING "Fix linker errors with some GCC versions by adding the --no-as-needed flag" ON ) - if( GCC_FORCE_LINKING ) - add_link_options( -Wl,--no-as-needed ) - endif( GCC_FORCE_LINKING ) - +if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_COMPILER_IS_GNUCXX ) option( GCC_REDUCE_MEMORY "Significantly reduce GCC memory usage by setting ftrack-macro-expansion=1 (default: 2)" ON ) + mark_as_advanced(GCC_REDUCE_MEMORY) if( GCC_REDUCE_MEMORY ) add_compile_options( -ftrack-macro-expansion=1 ) endif( GCC_REDUCE_MEMORY ) option( GCC_ENABLE_PIPES "Use pipes to speed up compiling with GCC by adding the -pipe flag" ON ) + mark_as_advanced(GCC_ENABLE_PIPES) if( GCC_ENABLE_PIPES ) add_compile_options( -pipe ) endif( GCC_ENABLE_PIPES ) -else( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) +else( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) # Suppress warnings about unknown warning options. See https://bugs.llvm.org/show_bug.cgi?id=24979 add_compile_options( -Wno-unknown-warning-option ) @@ -142,6 +129,7 @@ endif() # Enable some advanced options (compiler-independent) option( ENABLE_PROFILING "Enable profiling (gperftools-based, adds '-lprofile' flag to linker calls)" OFF ) +mark_as_advanced(ENABLE_PROFILING) if( ENABLE_PROFILING ) find_library( PROFILER_LIBRARY profiler ) if ( PROFILER_LIBRARY ) @@ -149,17 +137,29 @@ if( ENABLE_PROFILING ) endif( PROFILER_LIBRARY ) endif( ENABLE_PROFILING ) +# Check for memory errors using clang's AddressSanitizer. See https://github.com/google/sanitizers/wiki/AddressSanitizer +option( ENABLE_SANITIZE_ADDRESSES "Enable memory error detection (asan-based, adds '-fsanitize=address' flag)" OFF ) +mark_as_advanced(ENABLE_SANITIZE_ADDRESSES) +if( ENABLE_SANITIZE_ADDRESSES ) + add_compile_options( -O1 -g -fno-omit-frame-pointer -fsanitize=address -fno-optimize-sibling-calls ) + add_link_options( -g -fno-omit-frame-pointer -fsanitize=address ) + if( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) + # See https://github.com/google/sanitizers/issues/1017 + add_compile_options( -mllvm -asan-use-private-alias=1 ) + endif() +endif( ENABLE_SANITIZE_ADDRESSES ) + # Force coloured compiler output (useful for Ninja builds) -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) +if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) option( FORCE_COLOURED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." OFF ) - if( NOT DEFINED FORCE_COLOURED_OUTPUT AND "${CMAKE_GENERATOR}" MATCHES "Ninja" ) + if( NOT DEFINED FORCE_COLOURED_OUTPUT AND CMAKE_GENERATOR MATCHES "Ninja" ) message(STATUS "Building with Ninja - enabling coloured compiler output.") set( FORCE_COLOURED_OUTPUT ON CACHE BOOL "" FORCE ) endif() if( FORCE_COLOURED_OUTPUT ) - if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) + if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) add_compile_options( -fdiagnostics-color=always ) - elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + elseif( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) add_compile_options( -fcolor-diagnostics ) endif() endif( FORCE_COLOURED_OUTPUT ) @@ -169,19 +169,48 @@ mark_as_advanced( CLEAR CMAKE_VERBOSE_MAKEFILE ) # Global dependency options -option( KASPER_USE_BOOST "Build Boost dependent modules" ON ) -option( KASPER_USE_ROOT "Build ROOT dependent modules" ON ) -option( KASPER_USE_GSL "Build GSL dependent modules" OFF ) -option( KASPER_USE_VTK "Build VTK dependent modules" OFF ) +#find_package(Boost QUIET) +#option( KASPER_USE_BOOST "Build Boost dependent modules" ${Boost_FOUND} ) +set(KASPER_USE_BOOST ON) -# Advanced options mainly for testing -option( KASPER_EXPERIMENTAL "Enable some experimental features" OFF ) -if( KASPER_EXPERIMENTAL ) - option( KASPER_USE_TBB "Build TBB dependent modules" OFF ) - if( KASPER_USE_TBB ) - message( "WARNING: Enabling TBB can produce inconsistent or wrong results in KaFit. It is strongly recommended to leave this option disabled until further investigation." ) - endif() -endif( KASPER_EXPERIMENTAL ) +find_package(ROOT QUIET) +if(ROOT_FOUND AND NOT DEFINED KASPER_USE_ROOT) + message("ROOT was found and enabled automatically. Set KASPER_USE_ROOT=OFF to change this.") +endif() +option( KASPER_USE_ROOT "Build ROOT dependent modules" ${ROOT_FOUND} ) + +find_package(GSL QUIET) +if(GSL_FOUND AND NOT DEFINED KASPER_USE_GSL) + message("GSL was found and enabled automatically. Set KASPER_USE_GSL=OFF to change this.") +endif() +option( KASPER_USE_GSL "Build GSL dependent modules" ${GSL_FOUND} ) + +find_package(VTK QUIET) +if(VTK_FOUND AND NOT DEFINED KASPER_USE_VTK) + message("VTK was found and enabled automatically. Set KASPER_USE_VTK=OFF to change this.") +endif() +option( KASPER_USE_VTK "Build VTK dependent modules" ${VTK_FOUND} ) + +option( KASPER_USE_XGBOOST"Build XGBOOST dependent modules" OFF ) + +# Make sure that version requirements are fulfilled +if( KASPER_USE_BOOST ) + set(BOOST_MINIMUM_VERSION "1.65") + find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED) +endif( KASPER_USE_BOOST ) + +if( KASPER_USE_ROOT ) + set(ROOT_MINIMUM_VERSION "6.16") + find_package(ROOT ${ROOT_MINIMUM_VERSION} CONFIG REQUIRED) +endif( KASPER_USE_ROOT ) + +if( KASPER_USE_GSL ) + find_package( GSL REQUIRED ) +endif( KASPER_USE_GSL ) + +if( KASPER_USE_VTK ) + find_package(VTK REQUIRED) +endif( KASPER_USE_VTK ) # Make sure all dependencies are being built # Every module must be listed before its dependencies and activate ONLY its @@ -210,7 +239,6 @@ if( BUILD_KGEOBAG ) message("KGeoBag requires GSL to be enabled in Kasper (activated automatically)" ) endif() set( KASPER_USE_GSL ON CACHE BOOL "(Required)" FORCE ) - set( KASPER_USE_BOOST ON CACHE BOOL "(Required)" FORCE ) endif( BUILD_KGEOBAG ) # Build modules @@ -221,14 +249,17 @@ if( BUILD_KOMMON ) endif() if( BUILD_KGEOBAG ) + # needs Kommon add_subdirectory( KGeoBag ) endif() if( BUILD_KEMFIELD ) + # needs Kommon, KGeoBag add_subdirectory( KEMField ) endif() if( BUILD_KASSIOPEIA ) + # needs Kommon, KGeoBag, KEMField add_subdirectory( Kassiopeia ) endif() @@ -271,8 +302,6 @@ message("\n Build was configured. Run `${CMAKE_MAKE_PROGRAM_NAME}` to start th # Install common project files -install( EXPORT KasperTargets DESTINATION ${CMAKE_INSTALL_DIR}/${PROJECT_NAME} ) - configure_file( KasperVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/KasperVersion.h @ONLY ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/KasperVersion.h DESTINATION ${INCLUDE_INSTALL_DIR} ) From 1829313e772d407c5ab03cb856e7c14bbaea96cc Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Mon, 13 Sep 2021 20:41:24 -0400 Subject: [PATCH 23/28] Comment out find_package ROOT. Now it builds on Ubuntu laptop. --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01a486f27..848448fc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,7 +173,7 @@ mark_as_advanced( CLEAR CMAKE_VERBOSE_MAKEFILE ) #option( KASPER_USE_BOOST "Build Boost dependent modules" ${Boost_FOUND} ) set(KASPER_USE_BOOST ON) -find_package(ROOT QUIET) +#find_package(ROOT QUIET) if(ROOT_FOUND AND NOT DEFINED KASPER_USE_ROOT) message("ROOT was found and enabled automatically. Set KASPER_USE_ROOT=OFF to change this.") endif() @@ -199,10 +199,10 @@ if( KASPER_USE_BOOST ) find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED) endif( KASPER_USE_BOOST ) -if( KASPER_USE_ROOT ) - set(ROOT_MINIMUM_VERSION "6.16") - find_package(ROOT ${ROOT_MINIMUM_VERSION} CONFIG REQUIRED) -endif( KASPER_USE_ROOT ) +#if( KASPER_USE_ROOT ) +# set(ROOT_MINIMUM_VERSION "6.16") +# find_package(ROOT ${ROOT_MINIMUM_VERSION} CONFIG REQUIRED) +#endif( KASPER_USE_ROOT ) if( KASPER_USE_GSL ) find_package( GSL REQUIRED ) From 8f70bde03d69ba9c9675b15e7d951845f46fca9a Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Fri, 17 Sep 2021 12:52:59 -0400 Subject: [PATCH 24/28] Reinstate find_package(ROOT). Standalone Kass configures on Ubuntu laptop after upgrading Root version to > 6.16 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 848448fc2..507d41a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,7 +173,7 @@ mark_as_advanced( CLEAR CMAKE_VERBOSE_MAKEFILE ) #option( KASPER_USE_BOOST "Build Boost dependent modules" ${Boost_FOUND} ) set(KASPER_USE_BOOST ON) -#find_package(ROOT QUIET) +find_package(ROOT QUIET) if(ROOT_FOUND AND NOT DEFINED KASPER_USE_ROOT) message("ROOT was found and enabled automatically. Set KASPER_USE_ROOT=OFF to change this.") endif() From e1ce6042da870716efe366334a2f09c027b760bf Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Sun, 19 Sep 2021 20:44:25 -0400 Subject: [PATCH 25/28] Uncomment more lines for finding ROOT > v6.16 . --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 507d41a9d..01a486f27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,10 +199,10 @@ if( KASPER_USE_BOOST ) find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED) endif( KASPER_USE_BOOST ) -#if( KASPER_USE_ROOT ) -# set(ROOT_MINIMUM_VERSION "6.16") -# find_package(ROOT ${ROOT_MINIMUM_VERSION} CONFIG REQUIRED) -#endif( KASPER_USE_ROOT ) +if( KASPER_USE_ROOT ) + set(ROOT_MINIMUM_VERSION "6.16") + find_package(ROOT ${ROOT_MINIMUM_VERSION} CONFIG REQUIRED) +endif( KASPER_USE_ROOT ) if( KASPER_USE_GSL ) find_package( GSL REQUIRED ) From 4b81b7c383b07d4bccf7cd3b4ddf78e1b5e6aeda Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Fri, 1 Oct 2021 07:55:36 -0400 Subject: [PATCH 26/28] Comment out Applications/Validation subdirectory to allow build with kasper_use_vtk=false. --- Kassiopeia/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kassiopeia/CMakeLists.txt b/Kassiopeia/CMakeLists.txt index bee5a5249..022a461df 100644 --- a/Kassiopeia/CMakeLists.txt +++ b/Kassiopeia/CMakeLists.txt @@ -72,7 +72,7 @@ add_subdirectory( Bindings ) add_subdirectory( Python ) add_subdirectory( Applications/Simulation ) add_subdirectory( Applications/FieldCalculation ) -add_subdirectory( Applications/Validation ) +#add_subdirectory( Applications/Validation ) add_subdirectory( Applications/Examples ) add_subdirectory( Applications/Other ) add_subdirectory( Applications/Visualization ) From d83902ad245b128a04da03e88d2560719a8962b4 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Sun, 17 Oct 2021 20:36:25 -0400 Subject: [PATCH 27/28] Uncomment add_submodule(Applications/Validation) which relies on vtk. With vtk v9.1 the build works. --- Kassiopeia/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kassiopeia/CMakeLists.txt b/Kassiopeia/CMakeLists.txt index 022a461df..bee5a5249 100644 --- a/Kassiopeia/CMakeLists.txt +++ b/Kassiopeia/CMakeLists.txt @@ -72,7 +72,7 @@ add_subdirectory( Bindings ) add_subdirectory( Python ) add_subdirectory( Applications/Simulation ) add_subdirectory( Applications/FieldCalculation ) -#add_subdirectory( Applications/Validation ) +add_subdirectory( Applications/Validation ) add_subdirectory( Applications/Examples ) add_subdirectory( Applications/Other ) add_subdirectory( Applications/Visualization ) From 261f3a464766bd9ff88b00251b5604dd55f3978b Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Mon, 30 Sep 2024 20:51:55 -0400 Subject: [PATCH 28/28] Remove accumulation of field during iteration through vector components. --- .../include/KElectromagnetIntegratingFieldSolver.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/KEMField/Source/ExternalFields/Electromagnets/include/KElectromagnetIntegratingFieldSolver.hh b/KEMField/Source/ExternalFields/Electromagnets/include/KElectromagnetIntegratingFieldSolver.hh index d87faeb96..f5b5b1c5f 100644 --- a/KEMField/Source/ExternalFields/Electromagnets/include/KElectromagnetIntegratingFieldSolver.hh +++ b/KEMField/Source/ExternalFields/Electromagnets/include/KElectromagnetIntegratingFieldSolver.hh @@ -49,7 +49,7 @@ template class KIntegratingFieldSolver::const_iterator it; for (it = fContainer.Vector().begin(); it != fContainer.Vector().end(); ++it) - fVectorPotential += fIntegrator.VectorPotential(*(*it), fP); + fVectorPotential = fIntegrator.VectorPotential(*(*it), fP); } private: @@ -80,7 +80,7 @@ template class KIntegratingFieldSolver::const_iterator it; for (it = fContainer.Vector().begin(); it != fContainer.Vector().end(); ++it) - fMagneticField += fIntegrator.MagneticField(*(*it), fP); + fMagneticField = fIntegrator.MagneticField(*(*it), fP); } private: