Skip to content

Commit

Permalink
Merge pull request #5 from project8/feature/eventmod
Browse files Browse the repository at this point in the history
Feature/eventmod
  • Loading branch information
pslocum authored Jun 16, 2017
2 parents 38533ef + c08c2f3 commit ae0e94e
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
cmake_minimum_required( VERSION 2.8.6 )
if(POLICY CMP0048)
cmake_policy(SET CMP0048 OLD)
endif()

project( Kasper )

Expand Down
10 changes: 6 additions & 4 deletions KEMField/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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)
Expand Down
3 changes: 3 additions & 0 deletions KGeoBag/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
cmake_minimum_required( VERSION 2.8.6 )
if(POLICY CMP0048)
cmake_policy(SET CMP0048 OLD)
endif()

project( KGeoBag )
include( KasperDefaults )
Expand Down
2 changes: 2 additions & 0 deletions Kassiopeia/Bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,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
Expand Down Expand Up @@ -371,6 +372,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
Expand Down
10 changes: 6 additions & 4 deletions Kassiopeia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
# 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 )
Expand Down
2 changes: 2 additions & 0 deletions Kassiopeia/Operators/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# header files
set( OPERATORS_HEADER_BASENAMES
KSEventModifier.h
KSOperatorsMessage.h
KSParticle.h
KSParticleFactory.h
Expand Down Expand Up @@ -30,6 +31,7 @@ endforeach( BASENAME )

# source files
set( OPERATORS_SOURCE_BASENAMES
KSEventModifier.cxx
KSOperatorsMessage.cxx
KSParticle.cxx
KSParticleFactory.cxx
Expand Down
5 changes: 4 additions & 1 deletion Kassiopeia/Operators/Include/KSEventModifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Kassiopeia
{

class KSEvent;

class KSEventModifier:
Expand All @@ -16,12 +17,14 @@ 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;
};

};

}

Expand Down
2 changes: 2 additions & 0 deletions Kassiopeia/Simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set( SIMULATION_HEADER_BASENAMES
KSTrack.h
KSStep.h
KSRootElectricField.h
KSRootEventModifier.h
KSRootMagneticField.h
KSRootStepModifier.h
KSRootTrackModifier.h
Expand Down Expand Up @@ -47,6 +48,7 @@ set( SIMULATION_SOURCE_BASENAMES
KSTrack.cxx
KSStep.cxx
KSRootElectricField.cxx
KSRootEventModifier.cxx
KSRootMagneticField.cxx
KSRootStepModifier.cxx
KSRootTrackModifier.cxx
Expand Down
3 changes: 2 additions & 1 deletion Kassiopeia/Simulation/Include/KSRootEventModifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Kassiopeia
//**********

public:

bool ExecutePreEventModification( KSEvent& anEvent );
bool ExecutePostEventModification( KSEvent& anEvent );

Expand All @@ -45,6 +46,7 @@ namespace Kassiopeia
//******

public:

void SetEvent( KSEvent* anEvent );

bool ExecutePreEventModification();
Expand All @@ -54,7 +56,6 @@ namespace Kassiopeia
virtual void PushDeupdateComponent();

private:

KSEvent* fEvent;
};

Expand Down
1 change: 1 addition & 0 deletions Kassiopeia/Simulation/Include/KSStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace Kassiopeia
public:
K_REFS( std::string, TerminatorName )
K_REFS( bool, TerminatorFlag )
K_REFS( bool, PauseFlag ); // pls addition.

//**********
//trajectory
Expand Down
64 changes: 57 additions & 7 deletions Kassiopeia/Simulation/Source/KSRoot.cxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include "LMCGlobalsDeclaration.hh" // pls addition
#include "LMCGlobalsDefinition.hh" // pls addition

#include "KSRoot.h"
#include "KSRunMessage.h"
#include "KSEventMessage.h"
Expand Down Expand Up @@ -262,9 +265,6 @@ namespace Kassiopeia
}
KSRoot::~KSRoot()
{
/*
* KToolbox takes care of destruction
*/
}

void KSRoot::Execute( KSSimulation* aSimulation )
Expand Down Expand Up @@ -379,6 +379,42 @@ 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
Expand Down Expand Up @@ -423,8 +459,17 @@ 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();
Expand All @@ -451,7 +496,6 @@ namespace Kassiopeia

// send report
runmsg( eNormal ) << "...run " << fRun->GetRunId() << " complete" << eom;

fStopRunSignal = false;
return;
}
Expand Down Expand Up @@ -479,6 +523,9 @@ namespace Kassiopeia
// generate primaries
fRootGenerator->ExecuteGeneration();

// execute post-step modification
fRootEventModifier->ExecutePreEventModification();

// send report
eventmsg( eNormal ) << "processing event " << fEvent->GetEventId() << " <" << fEvent->GetGeneratorName() << ">..." << eom;

Expand Down Expand Up @@ -508,7 +555,6 @@ namespace Kassiopeia
delete tParticle;
fEvent->ParticleQueue().pop_front();

// execute a track
ExecuteTrack();

// move particles in track queue to event queue
Expand Down Expand Up @@ -551,6 +597,7 @@ namespace Kassiopeia

void KSRoot::ExecuteTrack()
{

// reset track
fTrack->TrackId() = fTrackIndex;
fTrack->TotalSteps() = 0;
Expand Down Expand Up @@ -621,6 +668,7 @@ namespace Kassiopeia
fTrack->DiscreteEnergyChange() += fStep->DiscreteEnergyChange();
fTrack->DiscreteMomentumChange() += fStep->DiscreteMomentumChange();
fTrack->DiscreteSecondaries() += fStep->DiscreteSecondaries();

}
}

Expand Down Expand Up @@ -693,15 +741,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 )
Expand Down
3 changes: 3 additions & 0 deletions Kassiopeia/Trajectories/Source/KSTrajTrajectoryAdiabatic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ namespace Kassiopeia
{
}



void KSTrajTrajectoryAdiabatic::SetIntegrator( KSTrajAdiabaticIntegrator* anIntegrator )
{
if( fIntegrator == NULL )
Expand All @@ -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 )
Expand Down
3 changes: 3 additions & 0 deletions Kommon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 )
Expand Down
7 changes: 7 additions & 0 deletions Kommon/Core/Initialization/KVariableProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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 )
Expand Down
2 changes: 2 additions & 0 deletions Kommon/Core/Initialization/KVariableProcessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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 );
Expand Down
5 changes: 3 additions & 2 deletions Kommon/cmake/KasperDefaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ endmacro(set_path)
include(CMakeDependentOption)
include(MacroParseArguments)

if( ${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} )
cmake_policy( SET CMP0011 NEW )

if( "${Kasper_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}" )
set(STANDALONE true)

# use this section to modifiy initial values of builtin CMAKE variables
Expand Down Expand Up @@ -176,7 +177,7 @@ macro(kasper_find_module NAME)
set( VERSION "0" )
endif()

find_package( ${NAME} ${VERSION} REQUIRED NO_MODULE )
find_package( ${NAME} ${VERSION} REQUIRED NO_MODULE HINTS ${Kasper_BINARY_DIR}/${NAME} )
#message("${NAME}_INCLUDE_DIRS: ${${NAME}_INCLUDE_DIRS}")
kasper_internal_include_directories( ${${NAME}_INCLUDE_DIRS} )
#kasper_external_include_directories( ${${NAME}_INCLUDE_DIRS} )
Expand Down

0 comments on commit ae0e94e

Please sign in to comment.