From f72651f346bd90a9f62b5af0702370fb681c1dbf Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Tue, 21 Jun 2022 06:42:36 -0400 Subject: [PATCH 01/14] Update README.md Remove "tracks" argument to Get() method which was always superfluous. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e43d4803f..3dd300a8a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ check it out and give feedback to help us improve it. Just to whet your appetite a little, the code snippet below is the most common signature of JANA. A large fraction of end users won't really need to know much more than this. ``` -auto tracks = jevent->Get(tracks); +auto tracks = jevent->Get(); for(auto t : tracks){ // ... do something with a track @@ -29,4 +29,4 @@ cmake --build build -j 10 --target install install/bin/jana -Pplugins=JTest ``` -For detailed instructions, see the [howto guide](https://jeffersonlab.github.io/JANA2/Installation.html). \ No newline at end of file +For detailed instructions, see the [howto guide](https://jeffersonlab.github.io/JANA2/Installation.html). From b47c2e7ed5a0987fb0729b43735bdeec2d300682 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Tue, 21 Jun 2022 06:44:26 -0400 Subject: [PATCH 02/14] Update index.md Remove "tracks" argument from Get() call. --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index ea7546eba..b9bcdb193 100644 --- a/docs/index.md +++ b/docs/index.md @@ -29,7 +29,7 @@ for actual use yet, but you are free to browse around to see how progress is goi [hosted on GitHub](https://github.com/JeffersonLab/JANA2) ``` -auto tracks = jevent->Get(tracks); +auto tracks = jevent->Get(); for(auto t : tracks){ // ... do something with a track From c63a4e2258fe32ee05f0aa77a1f4d56ff4ae7ae2 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Tue, 21 Jun 2022 06:48:24 -0400 Subject: [PATCH 03/14] Update index.md Remove wording about JANA2 being written and not quite ready for large scale use. --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index b9bcdb193..51b11ecc9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -24,8 +24,8 @@ options that allow for more complicated reconstruction as your project grows. Th run on a laptop for local code development, but to also be highly efficent when deploying to large computing sites like [NERSC](http://www.nersc.gov/){:target="_blank"}. -JANA is currently undergoing a complete rewrite. The new version will be JANA 2. The code is not quite ready -for actual use yet, but you are free to browse around to see how progress is going. The project is +JANA has undergone a large rewrite with the newer version dubbed JANA2. The code is now available for use +and you are free to browse around. The project is [hosted on GitHub](https://github.com/JeffersonLab/JANA2) ``` From 50cba54172cb99a163eacb6957750fc110744471 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Tue, 21 Jun 2022 08:43:13 -0400 Subject: [PATCH 04/14] Updated installation instructions to use specific version and reorganize a bit. --- docs/Installation.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/Installation.md b/docs/Installation.md index 45b679649..2615f921a 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -16,11 +16,10 @@ title: JANA: Multi-threaded HENP Event Reconstruction ### Building JANA First, set your `$JANA_HOME` environment variable. This is where the executables, libraries, headers, and plugins -get installed. You will need to tell CMake to install to `$JANA_HOME` manually -- this is on purpose to avoid accidentally -clobbering an existing JANA installation. Luckily, all you have to do is pass `-DCMAKE_INSTALL_PREFIX=$JANA_HOME` -to CMake. Be aware that if you change $JANA_HOME, you'll need to rerun cmake, and sometimes you'll also need to invalidate your CMake cache. -Also be aware that although CMake usually defaults `CMAKE_INSTALL_PREFIX` to `/usr/local`, we have disabled this because -we rarely want this in practice, and we don't want the build system picking up outdated headers and libraries we installed to `/usr/local` by accident. +get installed. (It is also where we will clone the source). CMake will install to `$JANA_HOME` if it is set (it +will install to `${CMAKE_BINARY_DIR}/install` if not). Be aware that although CMake usually defaults +`CMAKE_INSTALL_PREFIX` to `/usr/local`, we have disabled this because we rarely want this in practice, and we +don't want the build system picking up outdated headers and libraries we installed to `/usr/local` by accident. If you want to set `JANA_HOME=/usr/local`, you are free to do so, but you must do so deliberately. Next, set your build directory. This is where CMake's caches, logs, intermediate build artifacts, etc go. The convention @@ -30,16 +29,18 @@ a `cmake-build-debug` directory which works just fine. Finally, you can cd into your build directory and build and install everything the usual CMake way. ~~~ bash -git clone https://github.com/JeffersonLab/JANA2 # Get JANA -export JANA_HOME=~/jana_home # Set install dir -export PATH=$PATH:$JANA_HOME/bin # Put jana executable on path +export JANA_VERSION=v2.0.5 # Convenient to set this once for specific release +export JANA_HOME=${PWD}/JANA${JANA_VERSION} # Set full path to install dir -mkdir build # Set build dir +git clone https://github.com/JeffersonLab/JANA2 --branch ${JANA_VERSION} ${JANA_HOME} # Get JANA2 + +mkdir build # Set build dir cd build -cmake ../JANA2 -DCMAKE_INSTALL_PREFIX=$JANA_HOME # Generate makefiles -make -j8 install # Build (using 8 threads) and install -jana -Pplugins=JTest # Run JTest plugin to verify successful install +cmake3 ${JANA_HOME} # Generate makefiles # Generate makefiles +make -j8 install # Build (using 8 threads) and install +source ${JANA_HOME}/bin/jana-this.sh # Set PATH (and other envars) +jana -Pplugins=JTest # Run JTest plugin to verify successful install ~~~ Note: If you want to use a compiler other than the default one on your system, it is not enough to modify your From 9e8aa28f753c0515764df345503ca48c7088b9dc Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Wed, 22 Jun 2022 14:01:55 -0400 Subject: [PATCH 05/14] Fix issue where jana-this.csh fails if LD_LIBRARY_PATH is no set --- scripts/jana-this.csh.in | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/scripts/jana-this.csh.in b/scripts/jana-this.csh.in index 682626e49..3106c6136 100644 --- a/scripts/jana-this.csh.in +++ b/scripts/jana-this.csh.in @@ -10,6 +10,16 @@ # # +# tcsh gives errors if accessing LD_LIBRARY_PATH when not set. This saves a few lines +# by requiring a check every time we extend it below. +set MY_TMP_LD_LIBRARY_PATH="" +if ( $?LD_LIBRARY_PATH ) then + set MY_TMP_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" +endif + +#-------------------------------------------------------------------------------------- + + # BMS_OSNAME setenv BMS_OSNAME "@BMS_OSNAME@" @@ -28,14 +38,14 @@ endif if ( "@HAVE_XERCES@" == "1" ) then setenv XERCESCROOT "@XERCESCROOT@" # only add to LD_LIBRARY_PATH if XERCESCROOT does not appear to be a system directory - if ( ${XERCESCROOT} != /usr ) setenv LD_LIBRARY_PATH ${XERCESCROOT}/lib:${LD_LIBRARY_PATH} + if ( ${XERCESCROOT} != /usr ) set MY_TMP_LD_LIBRARY_PATH=${XERCESCROOT}/lib:${MY_TMP_LD_LIBRARY_PATH} endif # CCDB if ( "@HAVE_CCDB@" == "1" ) then setenv CCDB_HOME "@CCDB_HOME@" setenv PATH ${CCDB_HOME}/bin:${PATH} - setenv LD_LIBRARY_PATH ${CCDB_HOME}/lib:${LD_LIBRARY_PATH} + set MY_TMP_LD_LIBRARY_PATH=${CCDB_HOME}/lib:${MY_TMP_LD_LIBRARY_PATH} endif # MYSQL @@ -45,7 +55,7 @@ endif # that was actually used to get the compile/link options when JANA2 was built. if ( "@HAVE_MYSQL@" == "1" ) then setenv JANA2_MYSQL_CONFIG "@JANA2_MYSQL_CONFIG@" - setenv LD_LIBRARY_PATH @MYSQL_PKGLIBDIR@:${LD_LIBRARY_PATH} + set MY_TMP_LD_LIBRARY_PATH=@MYSQL_PKGLIBDIR@:${MY_TMP_LD_LIBRARY_PATH} endif # CURL @@ -54,7 +64,7 @@ if ( "@HAVE_CURL@" == "1" ) then # only add to PATH and LD_LIBRARY_PATH if CURL_ROOT does not appear to be a system directory if ( ${CURL_ROOT} != /usr ) then setenv PATH ${CURL_ROOT}/bin:${PATH} - setenv LD_LIBRARY_PATH ${CURL_ROOT}/lib:${LD_LIBRARY_PATH} + set MY_TMP_LD_LIBRARY_PATH=${CURL_ROOT}/lib:${MY_TMP_LD_LIBRARY_PATH} endif endif @@ -67,3 +77,8 @@ if ( -d @JANA_INSTALL_DIR@/python ) then setenv PYTHONPATH @JANA_INSTALL_DIR@/python endif endif + +#-------------------------------------------------------------------------------------- + +# Overwrite LD_LIBRARY_PATH with new values (assuming it is not empty) +if ( "$MY_TMP_LD_LIBRARY_PATH" !~ "" ) setenv LD_LIBRARY_PATH "$MY_TMP_LD_LIBRARY_PATH" From 0ff7b2d9c68d8a2ef1e1f84043779628ca3e277f Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Thu, 23 Jun 2022 13:52:22 -0400 Subject: [PATCH 06/14] Updating tutorial and corresponding changes to jana-generate.py. This includes up to JEventSource. --- docs/Tutorial.md | 106 ++++++++++++++++++--------------------- scripts/jana-generate.py | 19 ++++--- 2 files changed, 61 insertions(+), 64 deletions(-) diff --git a/docs/Tutorial.md b/docs/Tutorial.md index 0befa29d5..4d137c7d9 100644 --- a/docs/Tutorial.md +++ b/docs/Tutorial.md @@ -29,7 +29,7 @@ The installation process is described [here](Installation.html). We can quickly was successful by running a builtin benchmarking/scaling test: ``` -jana -Pplugins=JTest -b +jana -Pplugins=JTest -b # (cancel with Ctrl-C) ``` We can understand this command as follows: @@ -52,61 +52,44 @@ measuring the overall throughput. You can cancel processing at any time by press With JANA working, we can now create our own plugin. JANA provides a script which generates code skeletons to help us get started. We shall generate a skeleton for a plugin named "QuickTutorial" as follows: ``` -cd ~ -jana-generate.py StandalonePlugin QuickTutorial +jana-generate.py Plugin QuickTutorial ``` -This creates the following directory tree. Examine the files `QuickTutorial.cc`, which provides the plugin - entry point, and `QuickTutorialProcessor.cc`, which is where the majority of the work happens. The generated - files include lots of comments providing helpful hints on their use. +This creates the following directory tree. By default, a minimal skelton is created in a single file: +`QuickTutorial.cc`. This provides a JEventProcessor class as well as the the plugin entry point. The +generated files include lots of comments providing helpful hints on their use. ``` QuickTutorial/ ├── CMakeLists.txt -├── cmake -│   └── FindJANA.cmake -├── src -│   ├── CMakeLists.txt -│   ├── QuickTutorial.cc -│   ├── QuickTutorialProcessor.cc -│   └── QuickTutorialProcessor.h -└── tests - ├── catch.hpp - ├── CMakeLists.txt - ├── IntegrationTests.cc - └── TestsMain.cc +│├─ QuickTutorial.cc ``` -## Integrating into an existing project - -If we are working with an existing project such as eJANA or GlueX, we don't need the CMake -project definition, CMake helper files, or tests boilerplate. All we need is the inner `src` -directory, which we copy into its own leaf in the project tree: -``` -cp QuickTutorial/src $PATH_TO_PROJECT_SOURCE/src/plugins/QuickTutorial -``` +The `jana-generate.py Plugin ...` command provides some option flags as well that can be given at the +end of the command line. Run `jana-generate.py --help` to see what they are. -For convenience, `jana-generate.py` will generate the stripped-down plugin directly if we specify -`ProjectPlugin` instead. +## Integrating into an existing project +If you are working with an existing project such as eJANA or GlueX, then you don't need the CMake +project. All you need are the source files (e.g. `QuickTutorial.cc`): ``` -cd $PATH_TO_PROJECT_SOURCE/src/plugins -jana-generate.py ProjectPlugin QuickTutorial +cp QuickTutorial $PATH_TO_PROJECT_SOURCE/src/plugins/QuickTutorial ``` -Either way, we'll have to manually tell the parent CMakeLists.txt to +Be aware that you will have to manually tell the parent CMakeLists.txt to `add_subdirectory(QuickTutorial)`. -The rest of the tutorial assumes that we are using a standalone plugin instead. +The rest of the tutorial assumes that we are using a standalone plugin. ## Building the plugin We build and run the plugin with the following: ``` +cd QuickTutorial mkdir build cd build -cmake .. +cmake3 .. make install jana -Pplugins=QuickTutorial ``` @@ -121,37 +104,46 @@ assume that we don't have access to an event source, so we'll create one ourselv source will emit an infinite stream of random data, so we'll name it RandomSource. ``` -cd src +cd .. jana-generate.py JEventSource RandomSource ``` This creates two files, `RandomSource.cc` and `RandomSource.h`, in the current directory. We'll need to add them to `CMakeLists.txt` ourselves. Note that we retain complete control over our directory -structure. In this tutorial, for simplicity, we'll keep all .h and .cc files directly under `src`, except -for tests, which belong under `tests`. For larger projects, `jana-generate project MyProjectName` creates +structure. In this tutorial, for simplicity, we'll keep all .h and .cc files in the topmost directory. +For larger projects, `jana-generate project MyProjectName` creates a much more complex code skeleton. To use our new RandomSource as-is, we need to do three things: -* Add `RandomSource.cc` and `RandomSource.h` to the `QuickTutorial_PLUGIN_SOURCES` list at the top of `src/CMakeLists.txt` -* Register our `RandomSource` with JANA inside `QuickTutorial.cc` like this: +* Add `RandomSource.cc` and `RandomSource.h` to the `add_library(...)` line in `CMakeLists.txt`. +* Register our `RandomSource` with JANA inside `QuickTutorial.cc` +* Rebuild the cmake project, rebuild the plugin target, and install. +The modified line in the CMakeLists.txt line should look like: +``` +add_library(QuickTutorial_plugin SHARED QuickTutorial.cc RandomSource.cc RandomSource.h) ``` -#include -#include "QuickTutorialProcessor.h" -#include "RandomSource.h" // <- ADD THIS LINE +The modified `QuickTuorial.cc` file needs to have the new `RandomSource.h` header included so +it can instantiatie an object and pass it over to the JApplication in the `InitPlugin()` routine. +The bottom of the file should look like this: -extern "C" { -void InitPlugin(JApplication* app) { +``` +#include // <- ADD THIS LINE (probably better to put this at top of file) - InitJANAPlugin(app); +extern "C" { + void InitPlugin(JApplication *app) { + InitJANAPlugin(app); + app->Add(new QuickTutorialProcessor); + app->Add(new RandomSource("random", app)); // <- ADD THIS LINE + } +}``` - app->Add(new QuickTutorialProcessor); - app->Add(new RandomSource("random", app)); // <- ADD THIS LINE -} -} +And finally, rebuild ... +``` +cd build +make install ``` -* Rebuild the cmake project, rebuild the plugin target, and install. When we run the QuickTutorial plugin now, we observe that `QuickTutorialProcessor::Process` is being called on every event. Note that `Process` is 'seeing' events slightly out-of-order. This is @@ -162,7 +154,7 @@ we organize the work we do inside there. This will be discussed in depth later. Because neither the source nor the processor are doing any 'real work', the events are being processed very quickly. To throttle the rate events get emitted, to whatever frequency we like, we can add a delay -inside `GetEvent`. Perhaps we'd like to set the emit frequency at runtime. First, we declare a member variable on +inside `GetEvent`. Perhaps we'd even like to set the emit frequency at runtime. First, we declare a member variable on `RandomSource`, initializing it to our preferred default value: ``` @@ -188,10 +180,10 @@ plugin. This helps prevent namespace collisions. ``` void RandomSource::Open() { - JApplication* app = GetApplication(); - app->SetDefaultParameter("random_source:max_emit_freq_hz", // ADD ME - m_max_emit_freq_hz, // ADD ME - "Maximum event rate [Hz] for RandomSource"); // ADD ME + JApplication* app = GetApplication(); // <- ADD THIS LINE + app->SetDefaultParameter("random_source:max_emit_freq_hz", // <- ADD THIS LINE + m_max_emit_freq_hz, // <- ADD THIS LINE + "Maximum event rate [Hz] for RandomSource"); // <- ADD THIS LINE } ``` @@ -206,9 +198,9 @@ void RandomSource::GetEvent(std::shared_ptr event) { event->SetEventNumber(current_event_number++); event->SetRunNumber(22); - /// Slow down event source // ADD ME - auto delay_ms = std::chrono::milliseconds(1000/m_max_emit_freq_hz); // ADD ME - std::this_thread::sleep_for(delay_ms); // ADD ME + /// Slow down event source // <- ADD THIS LINE + auto delay_ms = std::chrono::milliseconds(1000/m_max_emit_freq_hz); // <- ADD THIS LINE + std::this_thread::sleep_for(delay_ms); // <- ADD THIS LINE } ``` diff --git a/scripts/jana-generate.py b/scripts/jana-generate.py index 712606972..49aff855c 100755 --- a/scripts/jana-generate.py +++ b/scripts/jana-generate.py @@ -370,7 +370,7 @@ class {name} : public JEventSource {{ add_library({name}_plugin SHARED ${{{name}_PLUGIN_SOURCES}}) -target_include_directories({name}_plugin PUBLIC ${{JANA_INCLUDE_DIR}} {extra_includes}) +target_include_directories({name}_plugin PUBLIC ${{CMAKE_SOURCE_DIR}} ${{JANA_INCLUDE_DIR}} {extra_includes}) target_link_libraries({name}_plugin ${{JANA_LIBRARY}} {extra_libraries}) set_target_properties({name}_plugin PROPERTIES PREFIX "" OUTPUT_NAME "{name}" SUFFIX ".so") @@ -391,7 +391,7 @@ class {name} : public JEventSource {{ add_library({name}_plugin SHARED {name}.cc) -target_include_directories({name}_plugin PUBLIC ${{JANA_INCLUDE_DIR}} {extra_includes}) +target_include_directories({name}_plugin PUBLIC ${{CMAKE_SOURCE_DIR}} ${{JANA_INCLUDE_DIR}} {extra_includes}) target_link_libraries({name}_plugin ${{JANA_LIB}} {extra_libraries}) set_target_properties({name}_plugin PROPERTIES PREFIX "" OUTPUT_NAME "{name}" SUFFIX ".so") @@ -684,8 +684,7 @@ class {processor_name}: public JEventProcessor {{ m_lock->acquire_write_lock(); if( dest_file == nullptr ){{ - /// TODO: Create dest_file or acquire it via either a JService or a JParameter - dest_file = gDirectory; // default to current directory which may be memory resident + dest_file = new TFile("{processor_name}.root", "recreate"); /// TODO: Acquire dest_file via either a JService or a JParameter }} dest_dir = dest_file->mkdir("{dir_name}"); // Create a subdir inside dest_file for these results h1d_pt_reco = new TH1D("pt_reco", "reco pt", 100,0,10); @@ -707,7 +706,10 @@ class {processor_name}: public JEventProcessor {{ }} void {processor_name}::Finish() {{ - // Close TFile (unless shared) + // TODO: If we did not create this file then we should not delete it + dest_file->Write(); + delete dest_file; + dest_file = nullptr; }}; """ @@ -791,7 +793,7 @@ class {name}Processor: public JEventProcessor {{ /// Set up histograms m_lock->acquire_write_lock(); - //dest_file = ... /// TODO: Acquire dest_file via either a JService or a JParameter + dest_file = new TFile("{name}.root", "recreate"); /// TODO: Acquire dest_file via either a JService or a JParameter dest_dir = dest_file->mkdir("{name}"); // Create a subdir inside dest_file for these results dest_file->cd(); h1d_pt_reco = new TH1D("pt_reco", "reco pt", 100,0,10); @@ -813,7 +815,10 @@ class {name}Processor: public JEventProcessor {{ }} void Finish() override {{ - // Close TFile (unless shared) + // TODO: If we did not create this file then we should not delete it + dest_file->Write(); + delete dest_file; + dest_file = nullptr; }} }}; From 2e983b033a2bdf3948f2bc1b5c9311712c659054 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 24 Jun 2022 07:59:27 -0400 Subject: [PATCH 07/14] Replace ZeroMQ_LIBRARY with ZeroMQ_LIBRARIES --- src/plugins/janacontrol/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/janacontrol/src/CMakeLists.txt b/src/plugins/janacontrol/src/CMakeLists.txt index 20b41d1c0..68da47396 100644 --- a/src/plugins/janacontrol/src/CMakeLists.txt +++ b/src/plugins/janacontrol/src/CMakeLists.txt @@ -15,7 +15,7 @@ if (${USE_ZEROMQ}) add_library(janacontrol_plugin SHARED ${janacontrol_PLUGIN_SOURCES}) target_include_directories(janacontrol_plugin PUBLIC ${JANA_INCLUDE_DIR} ${ZeroMQ_INCLUDE_DIRS}) - target_link_libraries(janacontrol_plugin jana2 Threads::Threads ${ZeroMQ_LIBRARY}) + target_link_libraries(janacontrol_plugin jana2 Threads::Threads ${ZeroMQ_LIBRARIES}) set_target_properties(janacontrol_plugin PROPERTIES PREFIX "" OUTPUT_NAME "janacontrol" SUFFIX ".so") install(TARGETS janacontrol_plugin DESTINATION plugins) From f20a559a145cb7bab2c424f0a62c1ade19b8b8d1 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 24 Jun 2022 08:01:01 -0400 Subject: [PATCH 08/14] Set the ZeroMQ_DIR variable which had been made a requirement, but somehow was not being set anywhere --- cmake/FindZeroMQ.cmake | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmake/FindZeroMQ.cmake b/cmake/FindZeroMQ.cmake index c1e85558e..7cc3ef87f 100644 --- a/cmake/FindZeroMQ.cmake +++ b/cmake/FindZeroMQ.cmake @@ -4,16 +4,31 @@ # ZeroMQ_INCLUDE_DIRS - The ZeroMQ include directories # ZeroMQ_LIBRARIES - The libraries needed to use ZeroMQ # ZeroMQ_DEFINITIONS - Compiler switches required for using ZeroMQ + find_path (ZeroMQ_INCLUDE_DIR zmq.h) find_library (ZeroMQ_LIBRARY NAMES zmq) set (ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY}) set (ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR}) -include (FindPackageHandleStandardArgs) + +# Use parent directory name of the include directory to +# indicate where we are getting this from. This is +# informational only for when the top-level file +# prints "USE_ZEROMQ On -->" +# n.b. it is possible the library and include directories +# don't point to the same version! +get_filename_component(ZeroMQ_DIR ${ZeroMQ_INCLUDE_DIR} DIRECTORY) + +# For debugging +#message(STATUS "ZeroMQ_INCLUDE_DIR=${ZeroMQ_INCLUDE_DIR}") +#message(STATUS "ZeroMQ_LIBRARY=${ZeroMQ_LIBRARY}") +#message(STATUS "ZeroMQ_DIR=${ZeroMQ_DIR}") + # handle the QUIETLY and REQUIRED arguments and set ZeroMQ_FOUND to TRUE # if all listed variables are TRUE +include (FindPackageHandleStandardArgs) find_package_handle_standard_args(ZeroMQ FOUND_VAR ZeroMQ_FOUND VERSION_VAR ZeroMQ_VERSION - REQUIRED_VARS ZeroMQ_DIR ZeroMQ_INCLUDE_DIR ZeroMQ_LIBRARY + REQUIRED_VARS ZeroMQ_DIR ZeroMQ_INCLUDE_DIRS ZeroMQ_LIBRARIES ) From 3a3923814240b72c860a43f2df3b5ce5a14d2610 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 24 Jun 2022 08:21:53 -0400 Subject: [PATCH 09/14] Disable timeout when entering debug mode --- src/plugins/janacontrol/src/JControlEventProcessor.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/janacontrol/src/JControlEventProcessor.cc b/src/plugins/janacontrol/src/JControlEventProcessor.cc index 98c516746..94e291586 100644 --- a/src/plugins/janacontrol/src/JControlEventProcessor.cc +++ b/src/plugins/janacontrol/src/JControlEventProcessor.cc @@ -64,6 +64,7 @@ void JControlEventProcessor::Finish() { //------------------------------------------------------------- void JControlEventProcessor::SetDebugMode(bool debug_mode){ _debug_mode = debug_mode; + GetApplication()->SetTimeoutEnabled( !_debug_mode ); // TODO: Add a GetTimeoutEnabled() to JApplication } //------------------------------------------------------------- @@ -126,4 +127,4 @@ uint32_t JControlEventProcessor::GetRunNumber(void){ uint64_t JControlEventProcessor::GetEventNumber(void){ if(_jevent.get() == nullptr ) return 0; return _jevent->GetEventNumber(); -} \ No newline at end of file +} From bd78eb80bcb5a5a69060612501e6a9394439e32a Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 24 Jun 2022 08:22:24 -0400 Subject: [PATCH 10/14] Update documentation on Monitor/Debugger GUI. --- docs/GUI_Monitor_Debug.md | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/GUI_Monitor_Debug.md b/docs/GUI_Monitor_Debug.md index 7abb369ab..02bff678e 100644 --- a/docs/GUI_Monitor_Debug.md +++ b/docs/GUI_Monitor_Debug.md @@ -31,14 +31,22 @@ running on either the local node or a remote node. For this to work, the followi This should generally be added to the *end* of the plugin list like this: - ```jana -Pplugins=JTest,janacontrol``` +``` +jana -Pplugins=JTest,janacontrol +``` + +To start the JANA control GUI, just run the `jana-control.py` program: + +``` +jana-control.py +``` By default, it will try to attach to port 11238 on the localhost. It does not matter whether the JANA process is already running or not. It will automatically connect when it starts and reconnect if the process is restarted. -The following command line options are available: +The following command line options are available for `jana-control.py`:
 -h, --help     Print this Usage statement and exit
@@ -48,10 +56,24 @@ The following command line options are available:
 
 n.b. To set the port used by the remote JANA process set the
 jana:zmq_port configuration parameter when that process is started.
+For example:
+
+```
+jana -Pplugins=JTest,janacontrol -Pjana:zmq_port=12345
+```
 
 Debugger
 --------------
 
+The `Debugger` GUI here is really just a browser. It does not allow 
+for true control flow debugging. For that, please look at the command line
+debugger features of JANA2. This is intended to give a way to step
+through events and examine the exposed data members of the objects
+created in the event.
+
+To open the Debugger window, just press the button in the lower
+right hand coner of the control window.
+
 ![](images/JANA_Debugger_GUI.png)
 
 The GUI can be used to step through events in the JANA process and
@@ -69,7 +91,9 @@ events can be examined and stepped through. To stall processing on the
 very first event, the JANA process should have the jana:debug_mode
 config. parameter set to a non-zero value when it is started. e.g.
 
-``jana -Pplugins=myplugin1,myplugin2,janacontrol -Pjana:debug_mode=1 file1.dat``
+```
+jana -Pplugins=JTest,janacontrol -Pjana:debug_mode=1
+```
 
 Once an event is loaded, click on a factory to display a list of 
 objects it created for this event (displayed as the object's hexadecimal

From 77567aac24e59f9759b739961bbba759fd6bcb0d Mon Sep 17 00:00:00 2001
From: David Lawrence 
Date: Fri, 24 Jun 2022 09:06:36 -0400
Subject: [PATCH 11/14] Search for a banner font using a list of preferred
 fonts and the available system fonts

---
 scripts/jana-control.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/scripts/jana-control.py b/scripts/jana-control.py
index e85ab5f12..d1abf4c42 100644
--- a/scripts/jana-control.py
+++ b/scripts/jana-control.py
@@ -27,7 +27,6 @@
 # import matplotlib.pyplot as plt
 # import numpy as np
 
-# TODO: Allow command line arguments to change host and port numbers
 # -- Globals
 DONE      = False
 PORT      = 11238
@@ -141,9 +140,20 @@ def __init__(self, master=None):
     #=========================
     # init_window
     def init_window(self):
-
+	 
+        # Find a font family for the banner
+        preferred_fonts = ['Comic Sans MS', 'URW Gothic', 'Courier']
+        available_fonts=list(tkFont.families())
+        self.bannerFont = None
+        for f in preferred_fonts:
+            for af in available_fonts:
+                if af.startswith( f ):
+                    self.bannerFont = tkFont.Font(family=af, size=36)
+                    break
+            if self.bannerFont : break
+        if self.bannerFont == None : self.bannerFont = tkFont.Font(family=preferred_fonts[-1], size=36)
+            
         self.labelsFont = tkFont.Font(family="Helvetica", size=16)
-        self.bannerFont = tkFont.Font(family="Comic Sans MS", size=36)
         self.labmap = {}
 
         self.master.title('JANA Status/Control GUI')

From 3a2ba31fdd5f02d9064c8d127b87ac4deeee1cf4 Mon Sep 17 00:00:00 2001
From: David Lawrence 
Date: Sat, 25 Jun 2022 09:53:11 -0400
Subject: [PATCH 12/14] Disable ticker and timeout when running
 JInspector::Loop. Needs more work to restore values these had upon entry.
 Also to prevent time accumulated while in Loop from counting towards the
 timeout.

---
 src/libraries/JANA/JEvent.h            | 2 +-
 src/libraries/JANA/Utils/JInspector.cc | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/libraries/JANA/JEvent.h b/src/libraries/JANA/JEvent.h
index ddedfe85d..825b503ef 100644
--- a/src/libraries/JANA/JEvent.h
+++ b/src/libraries/JANA/JEvent.h
@@ -90,7 +90,7 @@ class JEvent : public JResettable, public std::enable_shared_from_this
         JApplication* GetJApplication() const {return mApplication;}
         JEventSource* GetJEventSource() const {return mEventSource; }
         JCallGraphRecorder* GetJCallGraphRecorder() const {return &mCallGraph;}
-        void Inspect() const { mInspector.Loop(); }
+        void Inspect() const { mInspector.Loop();} // TODO: Force this not to be inlined AND used so it is defined in libJANA.a
         bool GetSequential() const {return mIsBarrierEvent;}
         friend class JEventPool;
 
diff --git a/src/libraries/JANA/Utils/JInspector.cc b/src/libraries/JANA/Utils/JInspector.cc
index 4abeb41c8..1dc43dc2c 100644
--- a/src/libraries/JANA/Utils/JInspector.cc
+++ b/src/libraries/JANA/Utils/JInspector.cc
@@ -615,6 +615,8 @@ void JInspector::PrintObjectAncestors(std::string factory_idx, int object_idx) {
 
 void JInspector::Loop() {
     bool stay_in_loop = true;
+    m_event->GetJApplication()->SetTicker( false ); // TODO: Get the current ticker state first (requires JApplication be modified)
+    m_event->GetJApplication()->SetTimeoutEnabled( false ); // TODO: Get current state and save
     m_out << std::endl;
     m_out << "--------------------------------------------------------------------------------------" << std::endl;
     m_out << "Welcome to JANA's interactive inspector! Type `Help` or `h` to see available commands." << std::endl;
@@ -622,7 +624,7 @@ void JInspector::Loop() {
     PrintEvent();
     while (stay_in_loop) {
         std::string user_input;
-        m_out << std::endl << "JANA: ";
+        m_out << std::endl << "JANA: "; m_out.flush();
         // Obtain a single line
         std::getline(m_in, user_input);
         // Split into tokens
@@ -686,4 +688,7 @@ void JInspector::Loop() {
             PrintHelp();
         }
     }
+
+    m_event->GetJApplication()->SetTicker( true ); // TODO: Reset to what it was upon entry
+    m_event->GetJApplication()->SetTimeoutEnabled( true ); // TODO: Reset to what it was upon entry
 }

From 8774d39dd6095de7ac69491d23ecf5a254cb2288 Mon Sep 17 00:00:00 2001
From: David Lawrence 
Date: Sat, 25 Jun 2022 10:10:53 -0400
Subject: [PATCH 13/14] Fix bug in jana-generate.py for creating event source.

---
 scripts/jana-generate.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/jana-generate.py b/scripts/jana-generate.py
index 49aff855c..7d4784c8b 100755
--- a/scripts/jana-generate.py
+++ b/scripts/jana-generate.py
@@ -204,7 +204,7 @@ class {name} : public JEventSource {{
 }};
 
 template <>
-double JEventSourceGeneratorT::CheckOpenable(std::string);
+double JEventSourceGeneratorT<{name}>::CheckOpenable(std::string);
 
 #endif // _{name}_h_
 

From 80b5c06d479a00a38f3b1154634f1ec76d608534 Mon Sep 17 00:00:00 2001
From: David Lawrence 
Date: Sat, 25 Jun 2022 15:00:04 -0400
Subject: [PATCH 14/14] Bring mini-plugin CMakeLists.txt config into alignment
 with the large one. Namely, default to compiling all source and automatically
 install headers and ROOT .pcm files on make install.

---
 scripts/jana-generate.py | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/scripts/jana-generate.py b/scripts/jana-generate.py
index 7d4784c8b..01f5e4451 100755
--- a/scripts/jana-generate.py
+++ b/scripts/jana-generate.py
@@ -389,7 +389,26 @@ class {name} : public JEventSource {{
 mini_plugin_cmakelists_txt = """
 {extra_find_packages}
 
-add_library({name}_plugin SHARED {name}.cc)
+# According to the internet, CMake authors discourage the use
+# of GLOB for identifying source files. IMHO, this is due to
+# the flawed use of cache files in CMake itself. Here, GLOB
+# is used as the default. What this means is you can add source
+# files and re-run cmake (after clearing the cache file) and
+# they will be found without needing to modify this file.
+# You also have the option of switching the following to "false"
+# and managing the source file list manually the way they recommend.
+if(true)
+  # Automatically determine source file list.
+  file(GLOB mysourcefiles *.cpp *.cc *.c  *.hpp *.hh *.h)
+  set( {name}_PLUGIN_SOURCES ${{mysourcefiles}} )    
+else()
+  # Manually manage source file list
+  set ({name}_PLUGIN_SOURCES
+        {name}.cc
+  )
+endif()
+
+add_library({name}_plugin SHARED ${{{name}_PLUGIN_SOURCES}})
 
 target_include_directories({name}_plugin PUBLIC ${{CMAKE_SOURCE_DIR}} ${{JANA_INCLUDE_DIR}} {extra_includes})
 target_link_libraries({name}_plugin ${{JANA_LIB}} {extra_libraries})
@@ -397,6 +416,13 @@ class {name} : public JEventSource {{
 
 install(TARGETS {name}_plugin DESTINATION plugins)
 
+file(GLOB my_headers "*.h*")
+install(FILES ${{my_headers}} DESTINATION include/{name})
+
+# For root dictionaries
+file(GLOB my_pcms "${{CMAKE_CURRENT_BINARY_DIR}}/*.pcm")
+install(FILES ${{my_pcms}} DESTINATION plugins)
+
 """