From dc42f00af50c7693fdf54a782f6521b9df8bcc59 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 2 Jan 2025 11:38:10 -0500 Subject: [PATCH 1/8] Deprecate jerror.h --- src/libraries/JANA/Compatibility/jerror.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libraries/JANA/Compatibility/jerror.h b/src/libraries/JANA/Compatibility/jerror.h index 12de67b20..f4da22957 100644 --- a/src/libraries/JANA/Compatibility/jerror.h +++ b/src/libraries/JANA/Compatibility/jerror.h @@ -8,6 +8,12 @@ #pragma once +namespace jana::compatibility::jerror { +[[deprecated("This will be completely removed from JANA with no replacement. If you still need jerror.h, copy it into your own project.")]] +constexpr static int header_is_deprecated = 0; +constexpr static int warn_about_header_deprecation = header_is_deprecated; +} + enum jerror_t{ NOERROR = 0, UNKNOWN_ERROR = -1000, From 1a3a515485614d58dd29ec24126bfcdc9a3971b1 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 2 Jan 2025 11:40:24 -0500 Subject: [PATCH 2/8] Deprecate JStreamLog --- src/libraries/JANA/Compatibility/JStreamLog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/JANA/Compatibility/JStreamLog.h b/src/libraries/JANA/Compatibility/JStreamLog.h index 249c4c807..e5671d5eb 100644 --- a/src/libraries/JANA/Compatibility/JStreamLog.h +++ b/src/libraries/JANA/Compatibility/JStreamLog.h @@ -40,7 +40,7 @@ /// jout<<"Hello World!"< Date: Thu, 2 Jan 2025 11:31:31 -0500 Subject: [PATCH 3/8] Move JLockService from Compatibility/ to Services/ --- .../JANA/Compatibility/JLockService.h | 271 +---------------- src/libraries/JANA/Services/JLockService.h | 275 ++++++++++++++++++ 2 files changed, 280 insertions(+), 266 deletions(-) create mode 100644 src/libraries/JANA/Services/JLockService.h diff --git a/src/libraries/JANA/Compatibility/JLockService.h b/src/libraries/JANA/Compatibility/JLockService.h index 4e5f4d1ba..0ccb91532 100644 --- a/src/libraries/JANA/Compatibility/JLockService.h +++ b/src/libraries/JANA/Compatibility/JLockService.h @@ -3,273 +3,12 @@ // Subject to the terms in the LICENSE file found in the top-level directory. #pragma once -#include +#include -class JEventProcessor; - -class JLockService : public JService { - -public: - - JLockService() { - pthread_rwlock_init(&m_rw_locks_lock, nullptr); - pthread_rwlock_init(&m_root_fill_locks_lock, nullptr); - m_app_rw_lock = CreateLock("app"); - m_root_rw_lock = CreateLock("root"); - } - - ~JLockService() override { - for (const auto& pair : m_rw_locks) { - delete pair.second; - } - for (const auto& pair : m_root_fill_rw_lock) { - delete pair.second; - } - } - - inline pthread_rwlock_t *CreateLock(const std::string &name, bool throw_exception_if_exists = true); - - inline pthread_rwlock_t *ReadLock(const std::string &name); - - inline pthread_rwlock_t *WriteLock(const std::string &name); - - inline pthread_rwlock_t *Unlock(const std::string &name = std::string("app")); - - inline pthread_rwlock_t *RootReadLock() { - pthread_rwlock_rdlock(m_root_rw_lock); - return m_root_rw_lock; - } - - inline pthread_rwlock_t *RootWriteLock() { - pthread_rwlock_wrlock(m_root_rw_lock); - return m_root_rw_lock; - } - - inline pthread_rwlock_t *RootUnLock() { - pthread_rwlock_unlock(m_root_rw_lock); - return m_root_rw_lock; - } - - inline pthread_rwlock_t *RootFillLock(JEventProcessor *proc); - - inline pthread_rwlock_t *RootFillUnLock(JEventProcessor *proc); - - pthread_rwlock_t* GetReadWriteLock(std::string &name) { - return m_rw_locks.count( name ) == 0 ? nullptr : m_rw_locks[name]; - } - pthread_rwlock_t* GetRootReadWriteLock() { - return m_root_rw_lock; - } - pthread_rwlock_t* GetRootFillLock( JEventProcessor *proc ) { - return m_root_fill_rw_lock.count( proc ) == 0 ? nullptr : m_root_fill_rw_lock[proc]; - } - - -private: - - std::map m_rw_locks; - pthread_rwlock_t *m_app_rw_lock = nullptr; - pthread_rwlock_t *m_root_rw_lock = nullptr; - pthread_rwlock_t m_rw_locks_lock {}; // control access to rw_locks - pthread_rwlock_t m_root_fill_locks_lock {}; // control access to m_root_fill_rw_lock - std::map m_root_fill_rw_lock; - -}; - -inline pthread_rwlock_t *JLockService::CreateLock(const std::string &name, bool throw_exception_if_exists) { - // Lock the rw locks lock - pthread_rwlock_wrlock(&m_rw_locks_lock); - - // Make sure a lock with this name does not already exist - std::map::iterator iter = m_rw_locks.find(name); - pthread_rwlock_t *lock = (iter != m_rw_locks.end() ? iter->second : NULL); - - if (lock != NULL) { - // Lock exists. Throw exception (if specified) - if (throw_exception_if_exists) { - pthread_rwlock_unlock(&m_rw_locks_lock); - std::string mess = "Trying to create JANA rw lock \"" + name + "\" when it already exists!"; - throw JException(mess); - } - } else { - // Lock does not exist. Create it. - lock = new pthread_rwlock_t; - pthread_rwlock_init(lock, NULL); - m_rw_locks[name] = lock; - } - - // Unlock the rw locks lock - pthread_rwlock_unlock(&m_rw_locks_lock); - - return lock; -} - -//--------------------------------- -// ReadLock -//--------------------------------- -inline pthread_rwlock_t *JLockService::ReadLock(const std::string &name) { - /// Lock a global, named, rw_lock for reading. If a lock with that - /// name does not exist, then create one and lock it for reading. - /// - /// This is a little tricky. Access to the map of rw locks must itself - /// be controlled by a rw lock. This means we incure the overhead of two - /// locks and one unlock for every call to this method. Furthermore, to - /// keep this efficient, we want to try only read locking the map at - /// first. If we fail to find the requested lock in the map, we must - /// release the map's read lock and try creating the new lock. - - // Ensure the rw_locks map is not changed while we're looking at it, - // lock the rw_locks_lock. - pthread_rwlock_rdlock(&m_rw_locks_lock); - - // Find the lock. If it doesn't exist, set pointer to NULL - std::map::iterator iter = m_rw_locks.find(name); - pthread_rwlock_t *lock = (iter != m_rw_locks.end() ? iter->second : NULL); - - // Unlock the locks lock - pthread_rwlock_unlock(&m_rw_locks_lock); - - // If the lock doesn't exist, we need to create it. Because multiple - // threads may be trying to do this at the same time, one may create - // it while another waits for the locks lock. We flag the CreateLock - // method to not throw an exception to accommodate this. - if (lock == NULL) lock = CreateLock(name, false); - - // Finally, lock the named lock or print error message if not found - if (lock != NULL) { - pthread_rwlock_rdlock(lock); - } else { - std::string mess = "Unable to find or create lock \"" + name + "\" for reading!"; - throw JException(mess); - } - - return lock; -} - -//--------------------------------- -// WriteLock -//--------------------------------- -inline pthread_rwlock_t *JLockService::WriteLock(const std::string &name) { - /// Lock a global, named, rw_lock for writing. If a lock with that - /// name does not exist, then create one and lock it for writing. - /// - /// This is a little tricky. Access to the map of rw locks must itself - /// be controlled by a rw lock. This means we incure the overhead of two - /// locks and one unlock for every call to this method. Furthermore, to - /// keep this efficient, we want to try only read locking the map at - /// first. If we fail to find the requested lock in the map, we must - /// release the map's read lock and try creating the new lock. - - // Ensure the rw_locks map is not changed while we're looking at it, - // lock the rw_locks_lock. - pthread_rwlock_rdlock(&m_rw_locks_lock); - - // Find the lock. If it doesn't exist, set pointer to NULL - std::map::iterator iter = m_rw_locks.find(name); - pthread_rwlock_t *lock = (iter != m_rw_locks.end() ? iter->second : NULL); - - // Unlock the locks lock - pthread_rwlock_unlock(&m_rw_locks_lock); - - // If the lock doesn't exist, we need to create it. Because multiple - // threads may be trying to do this at the same time, one may create - // it while another waits for the locks lock. We flag the CreateLock - // method to not throw an exception to accommodate this. - if (lock == NULL) lock = CreateLock(name, false); - - // Finally, lock the named lock or print error message if not found - if (lock != NULL) { - pthread_rwlock_wrlock(lock); - } else { - std::string mess = "Unable to find or create lock \"" + name + "\" for writing!"; - throw JException(mess); - } - - return lock; -} - -//--------------------------------- -// Unlock -//--------------------------------- -inline pthread_rwlock_t *JLockService::Unlock(const std::string &name) { - /// Unlock a global, named rw_lock - - // To ensure the rw_locks map is not changed while we're looking at it, - // lock the rw_locks_lock. - pthread_rwlock_rdlock(&m_rw_locks_lock); - - // Find the lock. If it doesn't exist, set pointer to NULL - std::map::iterator iter = m_rw_locks.find(name); - pthread_rwlock_t *lock = (iter != m_rw_locks.end() ? iter->second : NULL); - - // Unlock the locks lock - pthread_rwlock_unlock(&m_rw_locks_lock); - - // Finally, unlock the named lock or print error message if not found - if (lock != NULL) { - pthread_rwlock_unlock(lock); - } else { - std::string mess = "Unable to find lock \"" + name + "\" for unlocking!"; - throw JException(mess); - } - - return lock; -} - -//--------------------------------- -// RootFillLock -//--------------------------------- -inline pthread_rwlock_t *JLockService::RootFillLock(JEventProcessor *proc) { - /// Use this to lock a rwlock that is used exclusively by the given - /// JEventProcessor. This addresses the common case where many plugins - /// are in use and all contending for the same root lock. You should - /// only use this when filling a histogram and not for creating. Use - /// RootWriteLock and RootUnLock for that. - pthread_rwlock_t *lock; - - pthread_rwlock_rdlock(&m_root_fill_locks_lock); - auto iter = m_root_fill_rw_lock.find(proc); - if (iter == m_root_fill_rw_lock.end()) { - pthread_rwlock_unlock(&m_root_fill_locks_lock); - pthread_rwlock_wrlock(&m_root_fill_locks_lock); - auto iter_now = m_root_fill_rw_lock.find(proc); - if(iter_now == m_root_fill_rw_lock.end()){ - lock = new pthread_rwlock_t; - pthread_rwlock_init(lock, nullptr); - m_root_fill_rw_lock[proc] = lock; - } - else{ - lock = iter_now->second; - } - } - else { - lock = iter->second; - } - pthread_rwlock_unlock(&m_root_fill_locks_lock); - pthread_rwlock_wrlock(lock); - return lock; -} - -//--------------------------------- -// RootFillUnLock -//--------------------------------- -inline pthread_rwlock_t *JLockService::RootFillUnLock(JEventProcessor *proc) { - /// Use this to unlock a rwlock that is used exclusively by the given - /// JEventProcessor. This addresses the common case where many plugins - /// are in use and all contending for the same root lock. You should - /// only use this when filling a histogram and not for creating. Use - /// RootWriteLock and RootUnLock for that. - pthread_rwlock_rdlock(&m_root_fill_locks_lock); - std::map::iterator iter = m_root_fill_rw_lock.find(proc); - if (iter == m_root_fill_rw_lock.end()) { - pthread_rwlock_unlock(&m_root_fill_locks_lock); - throw JException( - "Tried calling JLockService::RootFillUnLock with something other than a registered JEventProcessor!"); - } - pthread_rwlock_t *lock = iter->second; - pthread_rwlock_unlock(&m_root_fill_locks_lock); - pthread_rwlock_unlock(lock); - return lock; +namespace jana::compatibility::jlockservice { +[[deprecated("Use JANA/Services/JLockService.h instead")]] +constexpr static int header_is_deprecated = 0; +constexpr static int warn_about_header_deprecation = header_is_deprecated; } diff --git a/src/libraries/JANA/Services/JLockService.h b/src/libraries/JANA/Services/JLockService.h new file mode 100644 index 000000000..4e5f4d1ba --- /dev/null +++ b/src/libraries/JANA/Services/JLockService.h @@ -0,0 +1,275 @@ + +// Copyright 2020, Jefferson Science Associates, LLC. +// Subject to the terms in the LICENSE file found in the top-level directory. + +#pragma once +#include + +class JEventProcessor; + +class JLockService : public JService { + +public: + + JLockService() { + pthread_rwlock_init(&m_rw_locks_lock, nullptr); + pthread_rwlock_init(&m_root_fill_locks_lock, nullptr); + m_app_rw_lock = CreateLock("app"); + m_root_rw_lock = CreateLock("root"); + } + + ~JLockService() override { + for (const auto& pair : m_rw_locks) { + delete pair.second; + } + for (const auto& pair : m_root_fill_rw_lock) { + delete pair.second; + } + } + + inline pthread_rwlock_t *CreateLock(const std::string &name, bool throw_exception_if_exists = true); + + inline pthread_rwlock_t *ReadLock(const std::string &name); + + inline pthread_rwlock_t *WriteLock(const std::string &name); + + inline pthread_rwlock_t *Unlock(const std::string &name = std::string("app")); + + inline pthread_rwlock_t *RootReadLock() { + pthread_rwlock_rdlock(m_root_rw_lock); + return m_root_rw_lock; + } + + inline pthread_rwlock_t *RootWriteLock() { + pthread_rwlock_wrlock(m_root_rw_lock); + return m_root_rw_lock; + } + + inline pthread_rwlock_t *RootUnLock() { + pthread_rwlock_unlock(m_root_rw_lock); + return m_root_rw_lock; + } + + inline pthread_rwlock_t *RootFillLock(JEventProcessor *proc); + + inline pthread_rwlock_t *RootFillUnLock(JEventProcessor *proc); + + pthread_rwlock_t* GetReadWriteLock(std::string &name) { + return m_rw_locks.count( name ) == 0 ? nullptr : m_rw_locks[name]; + } + pthread_rwlock_t* GetRootReadWriteLock() { + return m_root_rw_lock; + } + pthread_rwlock_t* GetRootFillLock( JEventProcessor *proc ) { + return m_root_fill_rw_lock.count( proc ) == 0 ? nullptr : m_root_fill_rw_lock[proc]; + } + + +private: + + std::map m_rw_locks; + pthread_rwlock_t *m_app_rw_lock = nullptr; + pthread_rwlock_t *m_root_rw_lock = nullptr; + pthread_rwlock_t m_rw_locks_lock {}; // control access to rw_locks + pthread_rwlock_t m_root_fill_locks_lock {}; // control access to m_root_fill_rw_lock + std::map m_root_fill_rw_lock; + +}; + +inline pthread_rwlock_t *JLockService::CreateLock(const std::string &name, bool throw_exception_if_exists) { + // Lock the rw locks lock + pthread_rwlock_wrlock(&m_rw_locks_lock); + + // Make sure a lock with this name does not already exist + std::map::iterator iter = m_rw_locks.find(name); + pthread_rwlock_t *lock = (iter != m_rw_locks.end() ? iter->second : NULL); + + if (lock != NULL) { + // Lock exists. Throw exception (if specified) + if (throw_exception_if_exists) { + pthread_rwlock_unlock(&m_rw_locks_lock); + std::string mess = "Trying to create JANA rw lock \"" + name + "\" when it already exists!"; + throw JException(mess); + } + } else { + // Lock does not exist. Create it. + lock = new pthread_rwlock_t; + pthread_rwlock_init(lock, NULL); + m_rw_locks[name] = lock; + } + + // Unlock the rw locks lock + pthread_rwlock_unlock(&m_rw_locks_lock); + + return lock; +} + +//--------------------------------- +// ReadLock +//--------------------------------- +inline pthread_rwlock_t *JLockService::ReadLock(const std::string &name) { + /// Lock a global, named, rw_lock for reading. If a lock with that + /// name does not exist, then create one and lock it for reading. + /// + /// This is a little tricky. Access to the map of rw locks must itself + /// be controlled by a rw lock. This means we incure the overhead of two + /// locks and one unlock for every call to this method. Furthermore, to + /// keep this efficient, we want to try only read locking the map at + /// first. If we fail to find the requested lock in the map, we must + /// release the map's read lock and try creating the new lock. + + // Ensure the rw_locks map is not changed while we're looking at it, + // lock the rw_locks_lock. + pthread_rwlock_rdlock(&m_rw_locks_lock); + + // Find the lock. If it doesn't exist, set pointer to NULL + std::map::iterator iter = m_rw_locks.find(name); + pthread_rwlock_t *lock = (iter != m_rw_locks.end() ? iter->second : NULL); + + // Unlock the locks lock + pthread_rwlock_unlock(&m_rw_locks_lock); + + // If the lock doesn't exist, we need to create it. Because multiple + // threads may be trying to do this at the same time, one may create + // it while another waits for the locks lock. We flag the CreateLock + // method to not throw an exception to accommodate this. + if (lock == NULL) lock = CreateLock(name, false); + + // Finally, lock the named lock or print error message if not found + if (lock != NULL) { + pthread_rwlock_rdlock(lock); + } else { + std::string mess = "Unable to find or create lock \"" + name + "\" for reading!"; + throw JException(mess); + } + + return lock; +} + +//--------------------------------- +// WriteLock +//--------------------------------- +inline pthread_rwlock_t *JLockService::WriteLock(const std::string &name) { + /// Lock a global, named, rw_lock for writing. If a lock with that + /// name does not exist, then create one and lock it for writing. + /// + /// This is a little tricky. Access to the map of rw locks must itself + /// be controlled by a rw lock. This means we incure the overhead of two + /// locks and one unlock for every call to this method. Furthermore, to + /// keep this efficient, we want to try only read locking the map at + /// first. If we fail to find the requested lock in the map, we must + /// release the map's read lock and try creating the new lock. + + // Ensure the rw_locks map is not changed while we're looking at it, + // lock the rw_locks_lock. + pthread_rwlock_rdlock(&m_rw_locks_lock); + + // Find the lock. If it doesn't exist, set pointer to NULL + std::map::iterator iter = m_rw_locks.find(name); + pthread_rwlock_t *lock = (iter != m_rw_locks.end() ? iter->second : NULL); + + // Unlock the locks lock + pthread_rwlock_unlock(&m_rw_locks_lock); + + // If the lock doesn't exist, we need to create it. Because multiple + // threads may be trying to do this at the same time, one may create + // it while another waits for the locks lock. We flag the CreateLock + // method to not throw an exception to accommodate this. + if (lock == NULL) lock = CreateLock(name, false); + + // Finally, lock the named lock or print error message if not found + if (lock != NULL) { + pthread_rwlock_wrlock(lock); + } else { + std::string mess = "Unable to find or create lock \"" + name + "\" for writing!"; + throw JException(mess); + } + + return lock; +} + +//--------------------------------- +// Unlock +//--------------------------------- +inline pthread_rwlock_t *JLockService::Unlock(const std::string &name) { + /// Unlock a global, named rw_lock + + // To ensure the rw_locks map is not changed while we're looking at it, + // lock the rw_locks_lock. + pthread_rwlock_rdlock(&m_rw_locks_lock); + + // Find the lock. If it doesn't exist, set pointer to NULL + std::map::iterator iter = m_rw_locks.find(name); + pthread_rwlock_t *lock = (iter != m_rw_locks.end() ? iter->second : NULL); + + // Unlock the locks lock + pthread_rwlock_unlock(&m_rw_locks_lock); + + // Finally, unlock the named lock or print error message if not found + if (lock != NULL) { + pthread_rwlock_unlock(lock); + } else { + std::string mess = "Unable to find lock \"" + name + "\" for unlocking!"; + throw JException(mess); + } + + return lock; +} + +//--------------------------------- +// RootFillLock +//--------------------------------- +inline pthread_rwlock_t *JLockService::RootFillLock(JEventProcessor *proc) { + /// Use this to lock a rwlock that is used exclusively by the given + /// JEventProcessor. This addresses the common case where many plugins + /// are in use and all contending for the same root lock. You should + /// only use this when filling a histogram and not for creating. Use + /// RootWriteLock and RootUnLock for that. + pthread_rwlock_t *lock; + + pthread_rwlock_rdlock(&m_root_fill_locks_lock); + auto iter = m_root_fill_rw_lock.find(proc); + if (iter == m_root_fill_rw_lock.end()) { + pthread_rwlock_unlock(&m_root_fill_locks_lock); + pthread_rwlock_wrlock(&m_root_fill_locks_lock); + auto iter_now = m_root_fill_rw_lock.find(proc); + if(iter_now == m_root_fill_rw_lock.end()){ + lock = new pthread_rwlock_t; + pthread_rwlock_init(lock, nullptr); + m_root_fill_rw_lock[proc] = lock; + } + else{ + lock = iter_now->second; + } + } + else { + lock = iter->second; + } + pthread_rwlock_unlock(&m_root_fill_locks_lock); + pthread_rwlock_wrlock(lock); + return lock; +} + +//--------------------------------- +// RootFillUnLock +//--------------------------------- +inline pthread_rwlock_t *JLockService::RootFillUnLock(JEventProcessor *proc) { + /// Use this to unlock a rwlock that is used exclusively by the given + /// JEventProcessor. This addresses the common case where many plugins + /// are in use and all contending for the same root lock. You should + /// only use this when filling a histogram and not for creating. Use + /// RootWriteLock and RootUnLock for that. + pthread_rwlock_rdlock(&m_root_fill_locks_lock); + std::map::iterator iter = m_root_fill_rw_lock.find(proc); + if (iter == m_root_fill_rw_lock.end()) { + pthread_rwlock_unlock(&m_root_fill_locks_lock); + throw JException( + "Tried calling JLockService::RootFillUnLock with something other than a registered JEventProcessor!"); + } + pthread_rwlock_t *lock = iter->second; + pthread_rwlock_unlock(&m_root_fill_locks_lock); + pthread_rwlock_unlock(lock); + return lock; +} + + From fb49471a6b97e951d120eb299961b4a0cbaa416a Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 2 Jan 2025 11:45:20 -0500 Subject: [PATCH 4/8] Move geometry from Compatibility/ to Geometry/ --- src/libraries/JANA/CMakeLists.txt | 7 +- src/libraries/JANA/Compatibility/JGeometry.h | 384 +----------------- .../JANA/Compatibility/JGeometryManager.h | 23 +- .../JANA/Compatibility/JGeometryXML.h | 163 +------- src/libraries/JANA/Geometry/JGeometry.h | 383 +++++++++++++++++ .../JGeometryManager.cc | 2 +- .../JANA/Geometry/JGeometryManager.h | 22 + .../JGeometryXML.cc | 2 +- src/libraries/JANA/Geometry/JGeometryXML.h | 163 ++++++++ 9 files changed, 591 insertions(+), 558 deletions(-) create mode 100644 src/libraries/JANA/Geometry/JGeometry.h rename src/libraries/JANA/{Compatibility => Geometry}/JGeometryManager.cc (98%) create mode 100644 src/libraries/JANA/Geometry/JGeometryManager.h rename src/libraries/JANA/{Compatibility => Geometry}/JGeometryXML.cc (99%) create mode 100644 src/libraries/JANA/Geometry/JGeometryXML.h diff --git a/src/libraries/JANA/CMakeLists.txt b/src/libraries/JANA/CMakeLists.txt index e5ab86d7e..4ce7034b0 100644 --- a/src/libraries/JANA/CMakeLists.txt +++ b/src/libraries/JANA/CMakeLists.txt @@ -44,14 +44,15 @@ set(JANA2_SOURCES Calibrations/JCalibrationFile.cc Calibrations/JLargeCalibration.cc + Geometry/JGeometryManager.cc + Geometry/JGeometryXML.cc + CLI/JBenchmarker.cc CLI/JSignalHandler.cc CLI/JMain.cc Compatibility/JStreamLog.cc Compatibility/JStreamLogBuffer.cc - Compatibility/JGeometryManager.cc - Compatibility/JGeometryXML.cc ) if (${USE_PODIO}) @@ -125,6 +126,7 @@ file(GLOB jana_services_headers "Services/*.h*") file(GLOB jana_streaming_headers "Streaming/*.h*") file(GLOB jana_utils_headers "Utils/*.h*") file(GLOB jana_calibs_headers "Calibrations/*.h*") +file(GLOB jana_geometry_headers "Geometry/*.h*") file(GLOB jana_cli_headers "CLI/*.h*") file(GLOB jana_compat_headers "Compatibility/*.h*") file(GLOB jana_podio_headers "Podio/*.h*") @@ -137,6 +139,7 @@ install(FILES ${jana_services_headers} DESTINATION include/JANA/Services) install(FILES ${jana_streaming_headers} DESTINATION include/JANA/Streaming) install(FILES ${jana_utils_headers} DESTINATION include/JANA/Utils) install(FILES ${jana_calibs_headers} DESTINATION include/JANA/Calibrations) +install(FILES ${jana_geometry_headers} DESTINATION include/JANA/Geometry) install(FILES ${jana_cli_headers} DESTINATION include/JANA/CLI) install(FILES ${jana_compat_headers} DESTINATION include/JANA/Compatibility) install(FILES ${jana_component_headers} DESTINATION include/JANA/Components) diff --git a/src/libraries/JANA/Compatibility/JGeometry.h b/src/libraries/JANA/Compatibility/JGeometry.h index 12e0c10d3..a57df919d 100644 --- a/src/libraries/JANA/Compatibility/JGeometry.h +++ b/src/libraries/JANA/Compatibility/JGeometry.h @@ -1,383 +1,9 @@ -// $Id$ -// -// File: JGeometry.h -// Created: Fri Jul 6 16:24:24 EDT 2007 -// Creator: davidl (on Darwin fwing-dhcp61.jlab.org 8.10.1 i386) -// #pragma once +#include -#include -#include -#include -#include -using std::map; -using std::string; -using std::stringstream; -using std::vector; - - -/// JGeometry is a virtual base class used to define the interface by -/// which geometry information can be obtained in JANA. -/// Implementing this base class allows the JANA end user to be -/// agnostic as to the details of how the geometry info is stored. -/// The geometry can be stored in a database or any number of file -/// formats. The files can be stored locally, or on the network -/// somewhere. -/// -/// The primary advantage here is that it allows one to work with -/// local files, but then easily switch to a remote source method -/// when appropriate without requiring modifications to the end -/// user code. -/// -/// On the user side they will call one of the Get(...) methods which all get -/// translated into a call of one of the two vitural methods: -/// -/// virtual bool Get(string namepath, string &sval, map &where)=0; -/// virtual bool Get(string namepath, map &svals, map &where)=0; -/// -/// These two virtual methods along with one to get a list of the available -/// namepaths are the only things that need to be implemented -/// in a concrete subclass of JGeometry. -/// -/// A geometry element is specified by its namepath and an optional -/// set of qualifiers (the where argument). The namepath -/// is a hierarchal list of elements separated by forward slashes(/) -/// analogous to a path on a unix filesystem. This path is always assumed -/// to be relative to the url specified in the constructor. So, -/// for instance, suppose one kept the geometry in a set XML files on the -/// local filesystem and wished to access information from the file -/// -/// /home/joe/calib/geom_Oct10_2017.xml -/// -/// One would specify the url as: -/// -/// file:///home/joe/calib/geom_Oct10_2017.xml -/// -/// and then the namepath could be specified as the string: -/// -/// "TOF/bar/X_Y_Z" -/// -/// which would indicate the attribute "X_Y_Z" of the -/// subtag "bar" of the tag "TOF" in the file -/// "/home/joe/calib/geom_Oct10_2017.xml" - -class JGeometry{ - public: - JGeometry(string url, int run, string context="default"){ - this->url = url; - this->run_requested = run; - this->context = context; - } - virtual ~JGeometry(){} - virtual const char* className(void){return static_className();} - static const char* static_className(void){return "JGeometry";} - - typedef enum{ - // Used to specify which (if any) attributes should be included in - // the values obtained through GetXPaths(). - attr_level_none = 0, // Don't include any attributes. Only node names. - attr_level_last = 1, // Include the attributes for the last node only. - attr_level_all = 2 // Include attributes for all nodes. - }ATTR_LEVEL_t; - - void SetVerbose(int newval){ verbose = newval; } - - // Virtual methods called through base class - virtual bool Get(string xpath, string &sval)=0; - virtual bool Get(string xpath, map &svals)=0; - virtual bool GetMultiple(string xpath, vector &vsval)=0; - virtual bool GetMultiple(string xpath, vector >&vsvals)=0; - virtual void GetXPaths(vector &xpaths, ATTR_LEVEL_t level=attr_level_last, const string &filter="")=0; - virtual string GetChecksum(void) const {return string("not supported");} - - // Templated methods that can return more useful forms - template bool Get(string xpath, T &val); - template bool Get(string xpath, vector &vals, string delimiter=" "); - template bool Get(string xpath, map &vals); - template bool GetMultiple(string xpath, vector &vval); - template bool GetMultiple(string xpath, vector > &vvals, string delimiter=" "); - template bool GetMultiple(string xpath, vector > &vvals); - - const int& GetRunRequested(void) const {return run_requested;} - const int& GetRunFound(void) const {return run_found;} - const int& GetRunMin(void) const {return run_min;} - const int& GetRunMax(void) const {return run_max;} - const string& GetContext(void) const {return context;} - const string& GetURL(void) const {return url;} - - protected: - int run_min; - int run_max; - int run_found; - - int verbose=1; - -private: - JGeometry(){} // Don't allow trivial constructor - - int run_requested; - string context; - string url; - map anywhere; // an empty map means no constraints - -}; - - -//------------- -// Get (single version) -//------------- -template -bool JGeometry::Get(string xpath, T &val) -{ - /// Templated method used to get a single geometry element. - /// - /// This method will get the specified geometry element in the form of - /// a string using the virtual (non-templated) Get(...) method. It will - /// then convert the string into the data type on which val is - /// based. It does this using the stringstream - /// class so T is restricted to the types stringstream understands (int, float, - /// double, string, ...). - /// - /// If no element of the specified name is found, a value - /// of boolean "false" is returned. A value of "true" is - /// returned upon success. - - // Get values in the form of a string - string sval; - bool res = Get(xpath, sval); - if(!res)return res; - - // Convert the string to type "T" and copy it into val. - // Use stringstream to convert from a string to type "T" - stringstream ss(sval); - ss >> val; - - return res; -} - -//------------- -// Get (vector version) -//------------- -template -bool JGeometry::Get(string xpath, vector &vals, string delimiter) -{ - /// Templated method used to get a set of values from a geometry attribute. - /// - /// This method can be used to get a list of values (possibly only one) - /// from a single geometry attribute specified by xpath. The attribute - /// is obtained as a string using the non-templated Get(...) method - /// and the string broken into tokens separated by the delimiter - /// (which defaults to a single white space). Each - /// token is then converted into type T using the stringstream class - /// so T is restricted to the types stringstream understands (int, float, - /// double, string, ...). - /// - /// If no element of the specified name is found, a value - /// of boolean "false" is returned. A value of "true" is - /// returned upon success. - - // Get values in the form of strings - vals.clear(); - string svals; - bool res = Get(xpath, svals); - if(!res)return res; - - string::size_type pos_start = svals.find_first_not_of(delimiter,0); - while(pos_start != string::npos){ - string::size_type pos_end = svals.find_first_of(delimiter, pos_start); - if(pos_end==string::npos)pos_end=svals.size(); - - T v; - string val = svals.substr(pos_start, pos_end-pos_start); - stringstream ss(val); - ss >> v; - vals.push_back(v); - - pos_start = svals.find_first_not_of(delimiter, pos_end); - } - - return res; -} - -//------------- -// Get (map version) -//------------- -template -bool JGeometry::Get(string xpath, map &vals) -{ - /// Templated method used to get a set of geometry attributes. - /// - /// This method can be used to get a list of all attributes for - /// a given xpath. The attributes are copied into the vals - /// map with the attribute name as the key and the attribute - /// value as the value. This relies on the non-templated, virtual - /// Get(string, map&) method to first get the values - /// in the form of strings. It converts them using the stringstream - /// class so T is restricted to the types it understands (int, float, - /// double, string, ...). - /// - /// If no element of the specified name is found, a value - /// of boolean "false" is returned. A value of "true" is - /// returned upon success. - - // Get values in the form of strings - map svals; - bool res = Get(xpath, svals); - - // Loop over values, converting the strings to type "T" and - // copying them into the vals map. - vals.clear(); - map::const_iterator iter; - for(iter=svals.begin(); iter!=svals.end(); ++iter){ - // Use stringstream to convert from a string to type "T" - T v; - stringstream ss(iter->second); - ss >> v; - vals[iter->first] = v; - } - - return res; -} - - -//------------- -// GetMultiple (single version) -//------------- -template -bool JGeometry::GetMultiple(string xpath, vector &vval) -{ - /// Templated method used to get multiple entries satisfying a single xpath. - /// - /// This method will get the specified geometry element in the form of - /// a string using the virtual (non-templated) Get(...) method. It will - /// then convert the string into the data type on which val is - /// based. It does this using the stringstream - /// class so T is restricted to the types stringstream understands (int, float, - /// double, string, ...). - /// - /// This differs from the similar Get() method in that the geometry tree - /// will be searched for all nodes satisfying the given xpath and all - /// all values will be copied into the container provided. In Get(), only - /// the first node encountered that satisfies the xpath will be copied. - /// - /// If no element of the specified name is found, a value - /// of boolean "false" is returned. A value of "true" is - /// returned upon success. - - // Get values in the form of a string - vector vsval; - bool res = GetMultiple(xpath, vsval); - if(!res)return res; - - // Convert the string to type "T" and copy it into val. - // Use stringstream to convert from a string to type "T" - for(unsigned int i=0; i> val; - vval.push_back(val); - } - - return res; +namespace jana::compatibility::jgeometry { +[[deprecated("Use JANA/Geometry/JGeometry.h instead")]] +constexpr static int header_is_deprecated = 0; +constexpr static int warn_about_header_deprecation = header_is_deprecated; } - -//------------- -// GetMultiple (vector version) -//------------- -template -bool JGeometry::GetMultiple(string xpath, vector > &vvals, string delimiter) -{ - /// Templated method used to get a set of values from a geometry attribute. - /// - /// This method can be used to get a list of values (possibly only one) - /// from a single geometry attribute specified by xpath. The attribute - /// is obtained as a string using the non-templated Get(...) method - /// and the string broken into tokens separated by the delimiter - /// (which defaults to a single white space). Each - /// token is then converted into type T using the stringstream class - /// so T is restricted to the types stringstream understands (int, float, - /// double, string, ...). - /// - /// If no element of the specified name is found, a value - /// of boolean "false" is returned. A value of "true" is - /// returned upon success. - - // Get values in the form of strings - vvals.clear(); - vector vsvals; - bool res = GetMultiple(xpath, vsvals); - if(!res)return res; - - for(unsigned int i=0; i vals; - while(pos_start != string::npos){ - string::size_type pos_end = svals.find_first_of(delimiter, pos_start); - if(pos_end==string::npos)pos_end=svals.size(); - - T v; - string val = svals.substr(pos_start, pos_end-pos_start); - stringstream ss(val); - ss >> v; - vals.push_back(v); - - pos_start = svals.find_first_not_of(delimiter, pos_end); - } - - vvals.push_back(vals); - } - - return res; -} - -//------------- -// GetMultiple (map version) -//------------- -template -bool JGeometry::GetMultiple(string xpath, vector > &vvals) -{ - /// Templated method used to get a set of geometry attributes. - /// - /// This method can be used to get a list of all attributes for - /// a given xpath. The attributes are copied into the vals - /// map with the attribute name as the key and the attribute - /// value as the value. This relies on the non-templated, virtual - /// Get(string, map&) method to first get the values - /// in the form of strings. It converts them using the stringstream - /// class so T is restricted to the types it understands (int, float, - /// double, string, ...). - /// - /// If no element of the specified name is found, a value - /// of boolean "false" is returned. A value of "true" is - /// returned upon success. - - // Get values in the form of strings - vector > vsvals; - bool res = GetMultiple(xpath, vsvals); - - // Loop over values, converting the strings to type "T" and - // copying them into the vals map. - vvals.clear(); - - for(unsigned int i=0; i &svals = vsvals[i]; - - map vals; - map::const_iterator iter; - for(iter=svals.begin(); iter!=svals.end(); ++iter){ - // Use stringstream to convert from a string to type "T" - T v; - stringstream ss(iter->second); - ss >> v; - vals[iter->first] = v; - } - - vvals.push_back(vals); - } - - return res; -} - diff --git a/src/libraries/JANA/Compatibility/JGeometryManager.h b/src/libraries/JANA/Compatibility/JGeometryManager.h index 79161a706..584e26b83 100644 --- a/src/libraries/JANA/Compatibility/JGeometryManager.h +++ b/src/libraries/JANA/Compatibility/JGeometryManager.h @@ -1,22 +1,11 @@ -// Copyright 2020, Jefferson Science Associates, LLC. -// Subject to the terms in the LICENSE file found in the top-level directory. - #pragma once -#include -#include - -#include -#include - -class JGeometryManager: public JService { - - std::mutex m_mutex; - std::vector geometries; - -public: - JGeometry* GetJGeometry(unsigned int run_number); +#include -}; +namespace jana::compatibility::jgeometrymanager { +[[deprecated("Use JANA/Geometry/JGeometryManager.h instead")]] +constexpr static int header_is_deprecated = 0; +constexpr static int warn_about_header_deprecation = header_is_deprecated; +} diff --git a/src/libraries/JANA/Compatibility/JGeometryXML.h b/src/libraries/JANA/Compatibility/JGeometryXML.h index ae6ef4548..6c3a23faf 100644 --- a/src/libraries/JANA/Compatibility/JGeometryXML.h +++ b/src/libraries/JANA/Compatibility/JGeometryXML.h @@ -1,163 +1,10 @@ -// $Id$ -// -// File: JGeometryXML.h -// Created: Tues Jan 15 2008 -// Creator: davidl -// #pragma once -#include +#include -#include -#include -#include -#include - - -#if JANA2_HAVE_XERCES -#if !defined(__CINT__) && !defined(__CLING__) -// XERCES3 -#include -#include -#include -#include -#include -#include - -#else // __CINT__ __CLING__ -namespace xercesc{ -class xercesc::DOMBuilder; -class xercesc::DOMDocument; -class xercesc::DOMNode; -class xercesc::DOMErrorHandler; -class xercesc::DOMError; +namespace jana::compatibility::jgeometryxml { +[[deprecated("Use JANA/Geometry/JGeometryXML.h instead")]] +constexpr static int header_is_deprecated = 0; +constexpr static int warn_about_header_deprecation = header_is_deprecated; } -#endif // __CINT__ __CLING__ -#endif // JANA2_HAVE_XERCES - - -class JGeometryXML:public JGeometry{ - public: - - typedef pair > node_t; - typedef vector::iterator node_iter_t; - - JGeometryXML(string url, int run, string context="default"); - void Init(string xmlfile, string xml); - - virtual ~JGeometryXML(); - virtual const char* className(void){return static_className();} - static const char* static_className(void){return "JGeometryXML";} - -#if JANA2_HAVE_XERCES - void MapNodeNames(xercesc::DOMNode *current_node); -#endif // JANA2_HAVE_XERCES - bool Get(string xpath, string &sval); - bool Get(string xpath, map &svals); - bool GetMultiple(string xpath, vector &vsval); - bool GetMultiple(string xpath, vector >&vsvals); - void GetXPaths(vector &xpaths, ATTR_LEVEL_t level, const string &filter=""); - string GetChecksum(void) const {return md5_checksum;} - - void ParseXPath(string xpath, vector &nodes, string &attribute, unsigned int &attr_depth) const; - bool NodeCompare(node_iter_t iter1, node_iter_t end1, node_iter_t iter2, node_iter_t end2); - - - private: - JGeometryXML(); - - protected: - string xmlfile; - bool valid_xmlfile; - JCalibration *jcalib; - string md5_checksum; - map found_xpaths; // used to store xpaths already found to speed up subsequent requests - pthread_mutex_t found_xpaths_mutex; -#if JANA2_HAVE_XERCES - map node_names; -#endif // JANA2_HAVE_XERCES - -#if JANA2_HAVE_XERCES - - class SearchParameters{ - public: - // Inputs - vector nodes; // parsed xpath (see ParseXPath() ) - string attribute_name; // Name of attribute of interest - unsigned int attr_depth; // index of nodes vector containing attribute of interest - unsigned int max_values; // return up to max_values attributes (0 means return all) - - // Outputs - std::multimap attributes; // DOMnode* is deepest level matched to xpath, string is value of specified attribute - - // Recursion variables (used to pass state through recursive calls) - unsigned int depth; // keeps track of depth in nodes tree - string attr_value; // value of attribute of interest in current branch - xercesc::DOMNode *current_node; // current DOMnode being searched - - void SearchTree(map &node_names); // Returns true if a matching node was found - }; - - - xercesc::XercesDOMParser *parser; - xercesc::DOMDocument *doc; - - void AddNodeToList(xercesc::DOMNode* start, string start_path, vector &xpaths, JGeometry::ATTR_LEVEL_t level); - //xercesc::DOMNode* FindNode(string xpath, string &attribute, xercesc::DOMNode *after_node=NULL); - //xercesc::DOMNode* SearchTree(xercesc::DOMNode* current_node, unsigned int depth, vector > > &nodes, unsigned int attr_depth, bool find_all=false, vector *dom_nodes=NULL); - - void FindAttributeValues(string &xpath, std::multimap &attributes, unsigned int max_values=0); - static void GetAttributes(xercesc::DOMNode* node, map &attributes); - - // Error handler callback class - class ErrorHandler : public xercesc::ErrorHandler - { - public: - // Constructors and Destructor - ErrorHandler(){} - ~ErrorHandler(){} - bool handleError(const xercesc::DOMError& /*domError*/){jerr<<"Got Error!!"< GetXMLFilenames(void); - std::string GetMD5_checksum(void); - - private: - std::vector xml_filenames; - std::vector xml_content; - std::string path; - JCalibration *jcalib; - bool PRINT_CHECKSUM_INPUT_FILES; - }; -#endif // JANA2_HAVE_XERCES - -}; - -// The following is here just so we can use ROOT's THtml class to generate documentation. -#ifdef G__DICTIONARY -typedef JGeometryXML::node_t node_t; -#endif - diff --git a/src/libraries/JANA/Geometry/JGeometry.h b/src/libraries/JANA/Geometry/JGeometry.h new file mode 100644 index 000000000..12e0c10d3 --- /dev/null +++ b/src/libraries/JANA/Geometry/JGeometry.h @@ -0,0 +1,383 @@ +// $Id$ +// +// File: JGeometry.h +// Created: Fri Jul 6 16:24:24 EDT 2007 +// Creator: davidl (on Darwin fwing-dhcp61.jlab.org 8.10.1 i386) +// + +#pragma once + +#include +#include +#include +#include +using std::map; +using std::string; +using std::stringstream; +using std::vector; + + +/// JGeometry is a virtual base class used to define the interface by +/// which geometry information can be obtained in JANA. +/// Implementing this base class allows the JANA end user to be +/// agnostic as to the details of how the geometry info is stored. +/// The geometry can be stored in a database or any number of file +/// formats. The files can be stored locally, or on the network +/// somewhere. +/// +/// The primary advantage here is that it allows one to work with +/// local files, but then easily switch to a remote source method +/// when appropriate without requiring modifications to the end +/// user code. +/// +/// On the user side they will call one of the Get(...) methods which all get +/// translated into a call of one of the two vitural methods: +/// +/// virtual bool Get(string namepath, string &sval, map &where)=0; +/// virtual bool Get(string namepath, map &svals, map &where)=0; +/// +/// These two virtual methods along with one to get a list of the available +/// namepaths are the only things that need to be implemented +/// in a concrete subclass of JGeometry. +/// +/// A geometry element is specified by its namepath and an optional +/// set of qualifiers (the where argument). The namepath +/// is a hierarchal list of elements separated by forward slashes(/) +/// analogous to a path on a unix filesystem. This path is always assumed +/// to be relative to the url specified in the constructor. So, +/// for instance, suppose one kept the geometry in a set XML files on the +/// local filesystem and wished to access information from the file +/// +/// /home/joe/calib/geom_Oct10_2017.xml +/// +/// One would specify the url as: +/// +/// file:///home/joe/calib/geom_Oct10_2017.xml +/// +/// and then the namepath could be specified as the string: +/// +/// "TOF/bar/X_Y_Z" +/// +/// which would indicate the attribute "X_Y_Z" of the +/// subtag "bar" of the tag "TOF" in the file +/// "/home/joe/calib/geom_Oct10_2017.xml" + +class JGeometry{ + public: + JGeometry(string url, int run, string context="default"){ + this->url = url; + this->run_requested = run; + this->context = context; + } + virtual ~JGeometry(){} + virtual const char* className(void){return static_className();} + static const char* static_className(void){return "JGeometry";} + + typedef enum{ + // Used to specify which (if any) attributes should be included in + // the values obtained through GetXPaths(). + attr_level_none = 0, // Don't include any attributes. Only node names. + attr_level_last = 1, // Include the attributes for the last node only. + attr_level_all = 2 // Include attributes for all nodes. + }ATTR_LEVEL_t; + + void SetVerbose(int newval){ verbose = newval; } + + // Virtual methods called through base class + virtual bool Get(string xpath, string &sval)=0; + virtual bool Get(string xpath, map &svals)=0; + virtual bool GetMultiple(string xpath, vector &vsval)=0; + virtual bool GetMultiple(string xpath, vector >&vsvals)=0; + virtual void GetXPaths(vector &xpaths, ATTR_LEVEL_t level=attr_level_last, const string &filter="")=0; + virtual string GetChecksum(void) const {return string("not supported");} + + // Templated methods that can return more useful forms + template bool Get(string xpath, T &val); + template bool Get(string xpath, vector &vals, string delimiter=" "); + template bool Get(string xpath, map &vals); + template bool GetMultiple(string xpath, vector &vval); + template bool GetMultiple(string xpath, vector > &vvals, string delimiter=" "); + template bool GetMultiple(string xpath, vector > &vvals); + + const int& GetRunRequested(void) const {return run_requested;} + const int& GetRunFound(void) const {return run_found;} + const int& GetRunMin(void) const {return run_min;} + const int& GetRunMax(void) const {return run_max;} + const string& GetContext(void) const {return context;} + const string& GetURL(void) const {return url;} + + protected: + int run_min; + int run_max; + int run_found; + + int verbose=1; + +private: + JGeometry(){} // Don't allow trivial constructor + + int run_requested; + string context; + string url; + map anywhere; // an empty map means no constraints + +}; + + +//------------- +// Get (single version) +//------------- +template +bool JGeometry::Get(string xpath, T &val) +{ + /// Templated method used to get a single geometry element. + /// + /// This method will get the specified geometry element in the form of + /// a string using the virtual (non-templated) Get(...) method. It will + /// then convert the string into the data type on which val is + /// based. It does this using the stringstream + /// class so T is restricted to the types stringstream understands (int, float, + /// double, string, ...). + /// + /// If no element of the specified name is found, a value + /// of boolean "false" is returned. A value of "true" is + /// returned upon success. + + // Get values in the form of a string + string sval; + bool res = Get(xpath, sval); + if(!res)return res; + + // Convert the string to type "T" and copy it into val. + // Use stringstream to convert from a string to type "T" + stringstream ss(sval); + ss >> val; + + return res; +} + +//------------- +// Get (vector version) +//------------- +template +bool JGeometry::Get(string xpath, vector &vals, string delimiter) +{ + /// Templated method used to get a set of values from a geometry attribute. + /// + /// This method can be used to get a list of values (possibly only one) + /// from a single geometry attribute specified by xpath. The attribute + /// is obtained as a string using the non-templated Get(...) method + /// and the string broken into tokens separated by the delimiter + /// (which defaults to a single white space). Each + /// token is then converted into type T using the stringstream class + /// so T is restricted to the types stringstream understands (int, float, + /// double, string, ...). + /// + /// If no element of the specified name is found, a value + /// of boolean "false" is returned. A value of "true" is + /// returned upon success. + + // Get values in the form of strings + vals.clear(); + string svals; + bool res = Get(xpath, svals); + if(!res)return res; + + string::size_type pos_start = svals.find_first_not_of(delimiter,0); + while(pos_start != string::npos){ + string::size_type pos_end = svals.find_first_of(delimiter, pos_start); + if(pos_end==string::npos)pos_end=svals.size(); + + T v; + string val = svals.substr(pos_start, pos_end-pos_start); + stringstream ss(val); + ss >> v; + vals.push_back(v); + + pos_start = svals.find_first_not_of(delimiter, pos_end); + } + + return res; +} + +//------------- +// Get (map version) +//------------- +template +bool JGeometry::Get(string xpath, map &vals) +{ + /// Templated method used to get a set of geometry attributes. + /// + /// This method can be used to get a list of all attributes for + /// a given xpath. The attributes are copied into the vals + /// map with the attribute name as the key and the attribute + /// value as the value. This relies on the non-templated, virtual + /// Get(string, map&) method to first get the values + /// in the form of strings. It converts them using the stringstream + /// class so T is restricted to the types it understands (int, float, + /// double, string, ...). + /// + /// If no element of the specified name is found, a value + /// of boolean "false" is returned. A value of "true" is + /// returned upon success. + + // Get values in the form of strings + map svals; + bool res = Get(xpath, svals); + + // Loop over values, converting the strings to type "T" and + // copying them into the vals map. + vals.clear(); + map::const_iterator iter; + for(iter=svals.begin(); iter!=svals.end(); ++iter){ + // Use stringstream to convert from a string to type "T" + T v; + stringstream ss(iter->second); + ss >> v; + vals[iter->first] = v; + } + + return res; +} + + +//------------- +// GetMultiple (single version) +//------------- +template +bool JGeometry::GetMultiple(string xpath, vector &vval) +{ + /// Templated method used to get multiple entries satisfying a single xpath. + /// + /// This method will get the specified geometry element in the form of + /// a string using the virtual (non-templated) Get(...) method. It will + /// then convert the string into the data type on which val is + /// based. It does this using the stringstream + /// class so T is restricted to the types stringstream understands (int, float, + /// double, string, ...). + /// + /// This differs from the similar Get() method in that the geometry tree + /// will be searched for all nodes satisfying the given xpath and all + /// all values will be copied into the container provided. In Get(), only + /// the first node encountered that satisfies the xpath will be copied. + /// + /// If no element of the specified name is found, a value + /// of boolean "false" is returned. A value of "true" is + /// returned upon success. + + // Get values in the form of a string + vector vsval; + bool res = GetMultiple(xpath, vsval); + if(!res)return res; + + // Convert the string to type "T" and copy it into val. + // Use stringstream to convert from a string to type "T" + for(unsigned int i=0; i> val; + vval.push_back(val); + } + + return res; +} + +//------------- +// GetMultiple (vector version) +//------------- +template +bool JGeometry::GetMultiple(string xpath, vector > &vvals, string delimiter) +{ + /// Templated method used to get a set of values from a geometry attribute. + /// + /// This method can be used to get a list of values (possibly only one) + /// from a single geometry attribute specified by xpath. The attribute + /// is obtained as a string using the non-templated Get(...) method + /// and the string broken into tokens separated by the delimiter + /// (which defaults to a single white space). Each + /// token is then converted into type T using the stringstream class + /// so T is restricted to the types stringstream understands (int, float, + /// double, string, ...). + /// + /// If no element of the specified name is found, a value + /// of boolean "false" is returned. A value of "true" is + /// returned upon success. + + // Get values in the form of strings + vvals.clear(); + vector vsvals; + bool res = GetMultiple(xpath, vsvals); + if(!res)return res; + + for(unsigned int i=0; i vals; + while(pos_start != string::npos){ + string::size_type pos_end = svals.find_first_of(delimiter, pos_start); + if(pos_end==string::npos)pos_end=svals.size(); + + T v; + string val = svals.substr(pos_start, pos_end-pos_start); + stringstream ss(val); + ss >> v; + vals.push_back(v); + + pos_start = svals.find_first_not_of(delimiter, pos_end); + } + + vvals.push_back(vals); + } + + return res; +} + +//------------- +// GetMultiple (map version) +//------------- +template +bool JGeometry::GetMultiple(string xpath, vector > &vvals) +{ + /// Templated method used to get a set of geometry attributes. + /// + /// This method can be used to get a list of all attributes for + /// a given xpath. The attributes are copied into the vals + /// map with the attribute name as the key and the attribute + /// value as the value. This relies on the non-templated, virtual + /// Get(string, map&) method to first get the values + /// in the form of strings. It converts them using the stringstream + /// class so T is restricted to the types it understands (int, float, + /// double, string, ...). + /// + /// If no element of the specified name is found, a value + /// of boolean "false" is returned. A value of "true" is + /// returned upon success. + + // Get values in the form of strings + vector > vsvals; + bool res = GetMultiple(xpath, vsvals); + + // Loop over values, converting the strings to type "T" and + // copying them into the vals map. + vvals.clear(); + + for(unsigned int i=0; i &svals = vsvals[i]; + + map vals; + map::const_iterator iter; + for(iter=svals.begin(); iter!=svals.end(); ++iter){ + // Use stringstream to convert from a string to type "T" + T v; + stringstream ss(iter->second); + ss >> v; + vals[iter->first] = v; + } + + vvals.push_back(vals); + } + + return res; +} + diff --git a/src/libraries/JANA/Compatibility/JGeometryManager.cc b/src/libraries/JANA/Geometry/JGeometryManager.cc similarity index 98% rename from src/libraries/JANA/Compatibility/JGeometryManager.cc rename to src/libraries/JANA/Geometry/JGeometryManager.cc index e8b2b2651..0fdafd32b 100644 --- a/src/libraries/JANA/Compatibility/JGeometryManager.cc +++ b/src/libraries/JANA/Geometry/JGeometryManager.cc @@ -6,7 +6,7 @@ #include "JGeometryManager.h" #include -#include +#include JGeometry *JGeometryManager::GetJGeometry(unsigned int run_number) { diff --git a/src/libraries/JANA/Geometry/JGeometryManager.h b/src/libraries/JANA/Geometry/JGeometryManager.h new file mode 100644 index 000000000..69ccb4d5d --- /dev/null +++ b/src/libraries/JANA/Geometry/JGeometryManager.h @@ -0,0 +1,22 @@ + +// Copyright 2020, Jefferson Science Associates, LLC. +// Subject to the terms in the LICENSE file found in the top-level directory. + +#pragma once +#include +#include + +#include +#include + +class JGeometryManager: public JService { + + std::mutex m_mutex; + std::vector geometries; + +public: + JGeometry* GetJGeometry(unsigned int run_number); + +}; + + diff --git a/src/libraries/JANA/Compatibility/JGeometryXML.cc b/src/libraries/JANA/Geometry/JGeometryXML.cc similarity index 99% rename from src/libraries/JANA/Compatibility/JGeometryXML.cc rename to src/libraries/JANA/Geometry/JGeometryXML.cc index 5a438103d..ca5600952 100644 --- a/src/libraries/JANA/Compatibility/JGeometryXML.cc +++ b/src/libraries/JANA/Geometry/JGeometryXML.cc @@ -15,9 +15,9 @@ using namespace std; #include #include +#include #include #include -#include "JGeometryXML.h" #if JANA2_HAVE_XERCES using namespace xercesc; diff --git a/src/libraries/JANA/Geometry/JGeometryXML.h b/src/libraries/JANA/Geometry/JGeometryXML.h new file mode 100644 index 000000000..54393e274 --- /dev/null +++ b/src/libraries/JANA/Geometry/JGeometryXML.h @@ -0,0 +1,163 @@ +// $Id$ +// +// File: JGeometryXML.h +// Created: Tues Jan 15 2008 +// Creator: davidl +// + +#pragma once +#include + +#include +#include +#include +#include + + +#if JANA2_HAVE_XERCES +#if !defined(__CINT__) && !defined(__CLING__) +// XERCES3 +#include +#include +#include +#include +#include +#include + +#else // __CINT__ __CLING__ +namespace xercesc{ +class xercesc::DOMBuilder; +class xercesc::DOMDocument; +class xercesc::DOMNode; +class xercesc::DOMErrorHandler; +class xercesc::DOMError; +} +#endif // __CINT__ __CLING__ +#endif // JANA2_HAVE_XERCES + + +class JGeometryXML:public JGeometry{ + public: + + typedef pair > node_t; + typedef vector::iterator node_iter_t; + + JGeometryXML(string url, int run, string context="default"); + void Init(string xmlfile, string xml); + + virtual ~JGeometryXML(); + virtual const char* className(void){return static_className();} + static const char* static_className(void){return "JGeometryXML";} + +#if JANA2_HAVE_XERCES + void MapNodeNames(xercesc::DOMNode *current_node); +#endif // JANA2_HAVE_XERCES + bool Get(string xpath, string &sval); + bool Get(string xpath, map &svals); + bool GetMultiple(string xpath, vector &vsval); + bool GetMultiple(string xpath, vector >&vsvals); + void GetXPaths(vector &xpaths, ATTR_LEVEL_t level, const string &filter=""); + string GetChecksum(void) const {return md5_checksum;} + + void ParseXPath(string xpath, vector &nodes, string &attribute, unsigned int &attr_depth) const; + bool NodeCompare(node_iter_t iter1, node_iter_t end1, node_iter_t iter2, node_iter_t end2); + + + private: + JGeometryXML(); + + protected: + string xmlfile; + bool valid_xmlfile; + JCalibration *jcalib; + string md5_checksum; + map found_xpaths; // used to store xpaths already found to speed up subsequent requests + pthread_mutex_t found_xpaths_mutex; +#if JANA2_HAVE_XERCES + map node_names; +#endif // JANA2_HAVE_XERCES + +#if JANA2_HAVE_XERCES + + class SearchParameters{ + public: + // Inputs + vector nodes; // parsed xpath (see ParseXPath() ) + string attribute_name; // Name of attribute of interest + unsigned int attr_depth; // index of nodes vector containing attribute of interest + unsigned int max_values; // return up to max_values attributes (0 means return all) + + // Outputs + std::multimap attributes; // DOMnode* is deepest level matched to xpath, string is value of specified attribute + + // Recursion variables (used to pass state through recursive calls) + unsigned int depth; // keeps track of depth in nodes tree + string attr_value; // value of attribute of interest in current branch + xercesc::DOMNode *current_node; // current DOMnode being searched + + void SearchTree(map &node_names); // Returns true if a matching node was found + }; + + + xercesc::XercesDOMParser *parser; + xercesc::DOMDocument *doc; + + void AddNodeToList(xercesc::DOMNode* start, string start_path, vector &xpaths, JGeometry::ATTR_LEVEL_t level); + //xercesc::DOMNode* FindNode(string xpath, string &attribute, xercesc::DOMNode *after_node=NULL); + //xercesc::DOMNode* SearchTree(xercesc::DOMNode* current_node, unsigned int depth, vector > > &nodes, unsigned int attr_depth, bool find_all=false, vector *dom_nodes=NULL); + + void FindAttributeValues(string &xpath, std::multimap &attributes, unsigned int max_values=0); + static void GetAttributes(xercesc::DOMNode* node, map &attributes); + + // Error handler callback class + class ErrorHandler : public xercesc::ErrorHandler + { + public: + // Constructors and Destructor + ErrorHandler(){} + ~ErrorHandler(){} + bool handleError(const xercesc::DOMError& /*domError*/){jerr<<"Got Error!!"< GetXMLFilenames(void); + std::string GetMD5_checksum(void); + + private: + std::vector xml_filenames; + std::vector xml_content; + std::string path; + JCalibration *jcalib; + bool PRINT_CHECKSUM_INPUT_FILES; + }; +#endif // JANA2_HAVE_XERCES + +}; + +// The following is here just so we can use ROOT's THtml class to generate documentation. +#ifdef G__DICTIONARY +typedef JGeometryXML::node_t node_t; +#endif + + From b3b418b21cbfa56c8ea1439b53f2275bd5fc75ed Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 2 Jan 2025 11:48:12 -0500 Subject: [PATCH 5/8] Move JStatusBits from Compatibility/ to Utils/ --- .../JANA/Compatibility/JStatusBits.h | 176 +----------------- src/libraries/JANA/Utils/JStatusBits.h | 174 +++++++++++++++++ .../unit_tests/Utils/JStatusBitsTests.cc | 2 +- 3 files changed, 181 insertions(+), 171 deletions(-) create mode 100644 src/libraries/JANA/Utils/JStatusBits.h diff --git a/src/libraries/JANA/Compatibility/JStatusBits.h b/src/libraries/JANA/Compatibility/JStatusBits.h index 3a30ba38d..dac2f26c5 100644 --- a/src/libraries/JANA/Compatibility/JStatusBits.h +++ b/src/libraries/JANA/Compatibility/JStatusBits.h @@ -1,174 +1,10 @@ -// -// Created by Nathan Brei on 6/18/20. -// #pragma once +#include -#include -#include -#include -#include - -template -class JStatusBits { - - uint64_t m_status = 0L; - static std::mutex m_mutex; - static std::map m_status_bit_descriptions; - -public: - - void SetStatus(uint64_t status) { m_status = status; } - - uint64_t GetStatus() const { return m_status; } - - bool GetStatusBit(T bit) const - { - /// Return the present value of the specified status bit. - /// The value of "bit" should be from 0-63. - - return (m_status>>int(bit)) & 0x01; - } - - bool SetStatusBit(T bit, bool val=true) - { - /// Set the value of the specified status bit. If the - /// second argument is passed, the bit will be set to - /// that value. Otherwise, the bit will be set to "true". - /// The value of "bit" should be from 0-63. - /// The value of the status bit prior to this call is - /// returned. - - bool old_val = (m_status>>int(bit)) & 0x01; - - uint64_t mask = ((uint64_t)0x01)<>int(bit)) & 0x01; - - uint64_t mask = ((uint64_t)0x01)< lock(m_mutex); - m_status_bit_descriptions[bit] = description; - } - - - static std::string GetStatusBitDescription(T bit) - { - /// Get the description of the specified status bit. - /// The value of "bit" should be from 0-63. - - std::string description("no description available"); - - std::lock_guard lock(m_mutex); - auto iter = m_status_bit_descriptions.find(bit); - if(iter != m_status_bit_descriptions.end()) description = iter->second; - - return description; - } - - - static void GetStatusBitDescriptions(std::map &status_bit_descriptions) - { - /// Get the full list of descriptions of status bits. - /// Note that the meaning of the bits is implementation - /// specific and so descriptions are optional. It may be - /// that some or none of the bits used have an associated description. - - std::lock_guard lock(m_mutex); - status_bit_descriptions = m_status_bit_descriptions; - } - - - std::string ToString() const - { - /// Generate a formatted string suitable for printing to the screen, including the - /// entire word in both hexadecimal and binary along with descriptions. - - // Lock mutex to prevent changes to status_bit_descriptions while we - // read from it. - std::lock_guard lock(m_mutex); - - std::stringstream ss; - - // Add status in hex first - ss << "status: 0x" << std::hex << std::setw(sizeof(uint64_t)*2) << std::setfill('0') << m_status << std::dec <=0; i--){ - ss << ((m_status>>i) & 0x1); - if((i%8)==0) ss << "|"; - } - ss << std::endl; - - // 1-byte hex under binary - ss << " hex "; - for(int i=sizeof(uint64_t) - 1; i>=0; i--){ - ss << std::hex << " 0x"<< std::setw(2) << ((m_status>>(i*8)) & 0xFF) << " "; - } - ss << std::endl; - - // Descriptions for each bit that has a description or is set - for(unsigned int i=0; i>i) & 0x1); - - auto iter = m_status_bit_descriptions.find(i); - - if(iter != m_status_bit_descriptions.end() || val != 0){ - ss << std::dec << std::setw(2) << std::setfill(' '); - ss << " " << val << " - [" << std::setw(2) << std::setfill(' ') << i << "] " << m_status_bit_descriptions[i] << std::endl; - } - } - ss << std::endl; - return ss.str(); - } - -}; - -template -std::mutex JStatusBits::m_mutex; - -template -std::map JStatusBits::m_status_bit_descriptions; - +namespace jana::compatibility::jstatusbits { +[[deprecated("Use JANA/Utils/JStatusBits.h instead")]] +constexpr static int header_is_deprecated = 0; +constexpr static int warn_about_header_deprecation = header_is_deprecated; +} diff --git a/src/libraries/JANA/Utils/JStatusBits.h b/src/libraries/JANA/Utils/JStatusBits.h new file mode 100644 index 000000000..3a30ba38d --- /dev/null +++ b/src/libraries/JANA/Utils/JStatusBits.h @@ -0,0 +1,174 @@ +// +// Created by Nathan Brei on 6/18/20. +// + +#pragma once + +#include +#include +#include +#include + +template +class JStatusBits { + + uint64_t m_status = 0L; + static std::mutex m_mutex; + static std::map m_status_bit_descriptions; + +public: + + void SetStatus(uint64_t status) { m_status = status; } + + uint64_t GetStatus() const { return m_status; } + + bool GetStatusBit(T bit) const + { + /// Return the present value of the specified status bit. + /// The value of "bit" should be from 0-63. + + return (m_status>>int(bit)) & 0x01; + } + + bool SetStatusBit(T bit, bool val=true) + { + /// Set the value of the specified status bit. If the + /// second argument is passed, the bit will be set to + /// that value. Otherwise, the bit will be set to "true". + /// The value of "bit" should be from 0-63. + /// The value of the status bit prior to this call is + /// returned. + + bool old_val = (m_status>>int(bit)) & 0x01; + + uint64_t mask = ((uint64_t)0x01)<>int(bit)) & 0x01; + + uint64_t mask = ((uint64_t)0x01)< lock(m_mutex); + m_status_bit_descriptions[bit] = description; + } + + + static std::string GetStatusBitDescription(T bit) + { + /// Get the description of the specified status bit. + /// The value of "bit" should be from 0-63. + + std::string description("no description available"); + + std::lock_guard lock(m_mutex); + auto iter = m_status_bit_descriptions.find(bit); + if(iter != m_status_bit_descriptions.end()) description = iter->second; + + return description; + } + + + static void GetStatusBitDescriptions(std::map &status_bit_descriptions) + { + /// Get the full list of descriptions of status bits. + /// Note that the meaning of the bits is implementation + /// specific and so descriptions are optional. It may be + /// that some or none of the bits used have an associated description. + + std::lock_guard lock(m_mutex); + status_bit_descriptions = m_status_bit_descriptions; + } + + + std::string ToString() const + { + /// Generate a formatted string suitable for printing to the screen, including the + /// entire word in both hexadecimal and binary along with descriptions. + + // Lock mutex to prevent changes to status_bit_descriptions while we + // read from it. + std::lock_guard lock(m_mutex); + + std::stringstream ss; + + // Add status in hex first + ss << "status: 0x" << std::hex << std::setw(sizeof(uint64_t)*2) << std::setfill('0') << m_status << std::dec <=0; i--){ + ss << ((m_status>>i) & 0x1); + if((i%8)==0) ss << "|"; + } + ss << std::endl; + + // 1-byte hex under binary + ss << " hex "; + for(int i=sizeof(uint64_t) - 1; i>=0; i--){ + ss << std::hex << " 0x"<< std::setw(2) << ((m_status>>(i*8)) & 0xFF) << " "; + } + ss << std::endl; + + // Descriptions for each bit that has a description or is set + for(unsigned int i=0; i>i) & 0x1); + + auto iter = m_status_bit_descriptions.find(i); + + if(iter != m_status_bit_descriptions.end() || val != 0){ + ss << std::dec << std::setw(2) << std::setfill(' '); + ss << " " << val << " - [" << std::setw(2) << std::setfill(' ') << i << "] " << m_status_bit_descriptions[i] << std::endl; + } + } + ss << std::endl; + return ss.str(); + } + +}; + +template +std::mutex JStatusBits::m_mutex; + +template +std::map JStatusBits::m_status_bit_descriptions; + + diff --git a/src/programs/unit_tests/Utils/JStatusBitsTests.cc b/src/programs/unit_tests/Utils/JStatusBitsTests.cc index ef160c337..3e371c441 100644 --- a/src/programs/unit_tests/Utils/JStatusBitsTests.cc +++ b/src/programs/unit_tests/Utils/JStatusBitsTests.cc @@ -1,7 +1,7 @@ #include "catch.hpp" -#include +#include TEST_CASE("JStatusBitsTest_Unscoped") { From b426ae742cb7b34ebf96cbf76732bea76b046432 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 2 Jan 2025 11:50:10 -0500 Subject: [PATCH 6/8] Deprecate CLI/JVersion.h header --- src/libraries/JANA/CLI/JVersion.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libraries/JANA/CLI/JVersion.h b/src/libraries/JANA/CLI/JVersion.h index 10a0d697a..15edadce7 100644 --- a/src/libraries/JANA/CLI/JVersion.h +++ b/src/libraries/JANA/CLI/JVersion.h @@ -5,4 +5,8 @@ #include - +namespace jana::cli::jversion { +[[deprecated("Use JANA/JVersion.h instead")]] +constexpr static int header_is_deprecated = 0; +constexpr static int warn_about_header_deprecation = header_is_deprecated; +} From 4e58163ffd3cd7850b02befd4cb19f27a3522623 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 2 Jan 2025 12:03:07 -0500 Subject: [PATCH 7/8] Rename JLargeCalibration to JResource --- src/libraries/JANA/CMakeLists.txt | 2 +- .../JANA/Calibrations/JCalibrationManager.h | 21 ++- .../JANA/Calibrations/JLargeCalibration.h | 174 +----------------- .../{JLargeCalibration.cc => JResource.cc} | 24 +-- src/libraries/JANA/Calibrations/JResource.h | 174 ++++++++++++++++++ 5 files changed, 205 insertions(+), 190 deletions(-) rename src/libraries/JANA/Calibrations/{JLargeCalibration.cc => JResource.cc} (96%) create mode 100644 src/libraries/JANA/Calibrations/JResource.h diff --git a/src/libraries/JANA/CMakeLists.txt b/src/libraries/JANA/CMakeLists.txt index 4ce7034b0..9224d14de 100644 --- a/src/libraries/JANA/CMakeLists.txt +++ b/src/libraries/JANA/CMakeLists.txt @@ -42,7 +42,7 @@ set(JANA2_SOURCES Calibrations/JCalibration.cc Calibrations/JCalibrationFile.cc - Calibrations/JLargeCalibration.cc + Calibrations/JResource.cc Geometry/JGeometryManager.cc Geometry/JGeometryXML.cc diff --git a/src/libraries/JANA/Calibrations/JCalibrationManager.h b/src/libraries/JANA/Calibrations/JCalibrationManager.h index 2002af403..cbf27cfc6 100644 --- a/src/libraries/JANA/Calibrations/JCalibrationManager.h +++ b/src/libraries/JANA/Calibrations/JCalibrationManager.h @@ -10,12 +10,12 @@ #include #include "JANA/Services/JParameterManager.h" -#include "JLargeCalibration.h" +#include "JResource.h" class JCalibrationManager : public JService { vector m_calibrations; - vector m_resource_managers; + vector m_resource_managers; vector m_calibration_generators; pthread_mutex_t m_calibration_mutex; @@ -177,10 +177,9 @@ class JCalibrationManager : public JService { return calib->Get(namepath, vals, event_number); } + JResource* GetResource(unsigned int run_number = 0) { - JLargeCalibration *GetLargeCalibration(unsigned int run_number = 0) { - - /// Return a pointer to the JLargeCalibration object for the specified run_number. If no run_number is given or a + /// Return a pointer to the JResource object for the specified run_number. If no run_number is given or a /// value of 0 is given, then the first element from the list of resource managers is returned. If no managers /// currently exist, one will be created using one of the following in order of precedence: /// 1. JCalibration corresponding to given run number @@ -196,9 +195,9 @@ class JCalibrationManager : public JService { pthread_mutex_lock(&m_resource_manager_mutex); if (m_resource_managers.empty()) { if (m_calibrations.empty()) { - m_resource_managers.push_back(new JLargeCalibration(m_params, nullptr)); + m_resource_managers.push_back(new JResource(m_params, nullptr)); } else { - m_resource_managers.push_back(new JLargeCalibration(m_params, m_calibrations[0])); + m_resource_managers.push_back(new JResource(m_params, m_calibrations[0])); } } pthread_mutex_unlock(&m_resource_manager_mutex); @@ -213,7 +212,7 @@ class JCalibrationManager : public JService { } // No resource manager exists for the JCalibration that corresponds to the given run_number. Create one. - JLargeCalibration *resource_manager = new JLargeCalibration(m_params, jcalib); + JResource *resource_manager = new JResource(m_params, jcalib); pthread_mutex_lock(&m_resource_manager_mutex); m_resource_managers.push_back(resource_manager); pthread_mutex_unlock(&m_resource_manager_mutex); @@ -221,6 +220,12 @@ class JCalibrationManager : public JService { return resource_manager; } + + [[deprecated("Replaced with GetResource()")]] + JResource *GetLargeCalibration(unsigned int run_number = 0) { + return GetResource(run_number); + } + }; diff --git a/src/libraries/JANA/Calibrations/JLargeCalibration.h b/src/libraries/JANA/Calibrations/JLargeCalibration.h index 3030b603c..f771bf3ca 100644 --- a/src/libraries/JANA/Calibrations/JLargeCalibration.h +++ b/src/libraries/JANA/Calibrations/JLargeCalibration.h @@ -1,173 +1,9 @@ -// $Id$ -// -// File: JLargeCalibration.h -// Created: Mon Oct 15 07:36:44 EDT 2012 -// Creator: davidl (on Darwin eleanor.jlab.org 12.2.0 i386) -// #pragma once -#include +#include -using std::string; - -#include -#include - - -/// The JLargeCalibration class is used to manage local resource files. -/// These would typically be larger files that are costly to download -/// every time the program is run. (i.e. if they come from the -/// JCalibration system.) Files are kept in a central location -/// on the local filesystem so only one copy needs to exist. -/// -/// The JLargeCalibration constructor takes two arguments. The first -/// is a pointer to a JCalibration object. If not NULL, this is used -/// to retrieve the URL of the file's location on the web. This allows -/// the JLargeCalibration to automatically download the file if needed. -/// -/// If no JCalibration object is supplied (i.e. it's NULL), then it will -/// simply look for a file with the specified namepath relative to the -/// root directory used to hold the resources. The root resource directory -/// can be specified multiple ways. These are, in order of precedence: -/// -/// 1. Passed as second argument to the constructor -/// 2. Specified in JANA:RESOURCE_DIR configuration parameter -/// 3. Specified in JANA_RESOURCE_DIR environment variable -/// 4. Specified in JANA:RESOURCE_DEFAULT_PATH configuration parameter -/// 5. Create a user directory in /tmp called "resources" -/// -/// Note that in nearly all instances, no second argument should -/// be passed to the constructor so that the value can be changed -/// via run time parameters. -/// -/// Resource files can be of any format but if they are in an ASCII -/// format compatible with JCalibrationFile then the file can be -/// parsed using the Get(...) methods of JLargeCalibration which map -/// directly to those of JCalibrationFile. -/// -/// To get the location of a resource on the local file system, -/// use the method: -/// -/// string GetResource(string namepath); -/// -/// This will return a string with the full path to the resource file on -/// the local file system. The call will automatically download -/// the resource and install it if it does not already exist locally. -/// The download location will be retrieved using the specified -/// namepath and the JCalibration object passed in to the constructor. -/// The calibration DB should have an entry for the namepath that is -/// a map of key-values with two options for how the URL is specified: -/// -/// Option 1.) The DB provides a "URL_base" string and a "path" -/// string. These are combined to make the full URL, and the -/// "path" is appended to the resource_dir to generate the local -/// path. Alternatively, "URL_base" may be provided via the -/// JANA:RESOURCE_URL configuration parameter in which case it need -/// not be present in the calib DB. If the config. parameter is -/// supplied, it will be used instead of any "URL_base" values found -/// in the calib DB. -/// -/// Option 2.) The DB provides a "URL" string only. This is used -/// as the full URL and as a key to the resources map to find -/// the local path. If none exists, this local path is taken -/// to be the namepath specified (appended to resource_dir). -/// -/// Option 1. takes precedent. If either the "URL_base" or "path" -/// strings are present, then the other must be as well or an -/// exception is thrown. If neither is present, then the URL -/// string is checked and used. If it also does not exist, an -/// exception is thrown. -/// -/// -/// A text file named "resources" is maintained at the top level of -/// the resources directory tree to record what URLs have been -/// downloaded and where the files are stored. This file is necessary -/// if option 2 above is used to store URLs in the calibration DB, -/// but is only informational if option 1 is used. It is ignored -/// completely if no calibration database is used. -/// -/// The templated Get(namepath, T vals [, event_number]) method will -/// first call the GetResource() method described above, but will -/// then use a JCalibrationFile object to parse the resource file, -/// filling the container passed in for "vals". See the documentation -/// for the JCalibration class for more info on the allowed types -/// for "vals". - - -class JLargeCalibration { -public: - JLargeCalibration(std::shared_ptr params, JCalibration *jcalib = NULL, string resource_dir = ""); - - virtual ~JLargeCalibration(); - - template - bool Get(string namepath, T &vals, int event_number = 0); - - string GetResource(string namepath); - - string GetLocalPathToResource(string namepath); - - map GetLocalResources(void) { return resources; } - - JCalibration *GetJCalibration(void) { return jcalib; } - - void GetResourceFromURL(const string &URL, const string &fullpath); - - string Get_MD5(string fullpath); - -protected: - - // Used to get URL of remote resource - JCalibration *jcalib; - - // Keep list of namepaths in JCalibration - vector calib_namepaths; - - // Used to convert files to values in STL containers - JCalibrationFile *jcalibfile; - - // Full path to top-most directory of resource files - string resource_dir; - - // Map of URLs to namepaths for existing resources - // key is URL and value is relative path (which should - // be the same as the namepath) - map resources; - - void ReadResourceInfoFile(void); - - void WriteResourceInfoFile(void); - - // Argument for the external curl program in case it is used - string curl_args; - -private: - - // Holds user specified URL_base that superceeds any found - // in calib DB - bool overide_URL_base; - string URL_base; - bool check_md5; - -}; - -//---------------------- -// Get -//---------------------- -template -bool JLargeCalibration::Get(string namepath, T &vals, int event_number) { - /// Get the specified resource and parse it, placing the values in the - /// specified "vals" container. This first calls GetResource(namepath) - /// to download the resource (if necessary) and then uses a - /// JCalibrationFile::Get() method to parse the file and fill the - /// "vals" container. - - // Call to GetResource to (optionally) download and install resource file - string fullpath = GetResource(namepath); - string path = fullpath.substr(resource_dir.size() + 1); // chop off resource_dir + "/" - - // Have JCalibrationFile parse the resource file - return jcalibfile->Get(path, vals, event_number); +namespace jana::calibrations::jlargecalibration { +[[deprecated("Use JANA/Calibrations/JResource.h instead")]] +constexpr static int header_is_deprecated = 0; +constexpr static int warn_about_header_deprecation = header_is_deprecated; } - - diff --git a/src/libraries/JANA/Calibrations/JLargeCalibration.cc b/src/libraries/JANA/Calibrations/JResource.cc similarity index 96% rename from src/libraries/JANA/Calibrations/JLargeCalibration.cc rename to src/libraries/JANA/Calibrations/JResource.cc index 5b0e292fb..a5b80707d 100644 --- a/src/libraries/JANA/Calibrations/JLargeCalibration.cc +++ b/src/libraries/JANA/Calibrations/JResource.cc @@ -1,13 +1,13 @@ // $Id$ // -// File: JLargeFile.cc +// File: JResource.cc // Created: Mon Oct 15 07:36:44 EDT 2012 // Creator: davidl (on Darwin eleanor.jlab.org 12.2.0 i386) // #include #include -#include +#include #include @@ -37,9 +37,9 @@ static int mycurl_printprogress(void *clientp, double dltotal, double dlnow, dou //--------------------------------- -// JLargeFile (Constructor) +// JResource (Constructor) //--------------------------------- -JLargeCalibration::JLargeCalibration(std::shared_ptr params, JCalibration *jcalib, string resource_dir) { +JResource::JResource(std::shared_ptr params, JCalibration *jcalib, string resource_dir) { /// Creates a new resource manager. See class description for details // Record JCalibration object used to get URLs of resources from calibration DB. @@ -141,9 +141,9 @@ JLargeCalibration::JLargeCalibration(std::shared_ptr params, } //--------------------------------- -// ~JLargeFile (Destructor) +// ~JResource (Destructor) //--------------------------------- -JLargeCalibration::~JLargeCalibration() { +JResource::~JResource() { if (jcalibfile) delete jcalibfile; #ifdef HAVE_CURL @@ -155,7 +155,7 @@ JLargeCalibration::~JLargeCalibration() { //--------------------------------- // GetResource //--------------------------------- -string JLargeCalibration::GetResource(string namepath) { +string JResource::GetResource(string namepath) { string fullpath = GetLocalPathToResource(namepath); // If a calibration object was specified, then use it to check @@ -377,7 +377,7 @@ string JLargeCalibration::GetResource(string namepath) { //--------------------------------- // GetLocalPathToResource //--------------------------------- -string JLargeCalibration::GetLocalPathToResource(string namepath) { +string JResource::GetLocalPathToResource(string namepath) { string fullpath = resource_dir + "/" + namepath; if (jcalib) { for (unsigned int i = 0; i < calib_namepaths.size(); i++) { @@ -399,7 +399,7 @@ string JLargeCalibration::GetLocalPathToResource(string namepath) { //--------------------------------- // ReadResourceInfoFile //--------------------------------- -void JLargeCalibration::ReadResourceInfoFile(void) { +void JResource::ReadResourceInfoFile(void) { pthread_mutex_lock(&resource_manager_mutex); // Clear the resources container so it is empty @@ -425,7 +425,7 @@ void JLargeCalibration::ReadResourceInfoFile(void) { //--------------------------------- // WriteResourceInfoFile //--------------------------------- -void JLargeCalibration::WriteResourceInfoFile(void) { +void JResource::WriteResourceInfoFile(void) { pthread_mutex_lock(&resource_manager_mutex); // Get full path to resources file @@ -458,7 +458,7 @@ void JLargeCalibration::WriteResourceInfoFile(void) { //--------------------------------- // GetResourceFromURL //--------------------------------- -void JLargeCalibration::GetResourceFromURL(const string &URL, const string &fullpath) { +void JResource::GetResourceFromURL(const string &URL, const string &fullpath) { /// Download the specified file and place it in the location specified /// by fullpath. If unsuccessful, a JException will be thrown with /// an appropriate error message. @@ -532,7 +532,7 @@ void JLargeCalibration::GetResourceFromURL(const string &URL, const string &full //----------- // Get_MD5 //----------- -string JLargeCalibration::Get_MD5(string fullpath) { +string JResource::Get_MD5(string fullpath) { ifstream ifs(fullpath.c_str()); if (!ifs.is_open()) return string(""); diff --git a/src/libraries/JANA/Calibrations/JResource.h b/src/libraries/JANA/Calibrations/JResource.h new file mode 100644 index 000000000..b1ff8b56a --- /dev/null +++ b/src/libraries/JANA/Calibrations/JResource.h @@ -0,0 +1,174 @@ +// $Id$ +// +// File: JResource.h +// Created: Mon Oct 15 07:36:44 EDT 2012 +// Creator: davidl (on Darwin eleanor.jlab.org 12.2.0 i386) +// + +#pragma once +#include + +using std::string; + +#include +#include + + +/// The JResource class is used to manage local resource files. +/// These would typically be larger files that are costly to download +/// every time the program is run. (i.e. if they come from the +/// JCalibration system.) Files are kept in a central location +/// on the local filesystem so only one copy needs to exist. +/// +/// The JResource constructor takes two arguments. The first +/// is a pointer to a JCalibration object. If not NULL, this is used +/// to retrieve the URL of the file's location on the web. This allows +/// the JResource to automatically download the file if needed. +/// +/// If no JCalibration object is supplied (i.e. it's NULL), then it will +/// simply look for a file with the specified namepath relative to the +/// root directory used to hold the resources. The root resource directory +/// can be specified multiple ways. These are, in order of precedence: +/// +/// 1. Passed as second argument to the constructor +/// 2. Specified in JANA:RESOURCE_DIR configuration parameter +/// 3. Specified in JANA_RESOURCE_DIR environment variable +/// 4. Specified in JANA:RESOURCE_DEFAULT_PATH configuration parameter +/// 5. Create a user directory in /tmp called "resources" +/// +/// Note that in nearly all instances, no second argument should +/// be passed to the constructor so that the value can be changed +/// via run time parameters. +/// +/// Resource files can be of any format but if they are in an ASCII +/// format compatible with JCalibrationFile then the file can be +/// parsed using the Get(...) methods of JResource which map +/// directly to those of JCalibrationFile. +/// +/// To get the location of a resource on the local file system, +/// use the method: +/// +/// string GetResource(string namepath); +/// +/// This will return a string with the full path to the resource file on +/// the local file system. The call will automatically download +/// the resource and install it if it does not already exist locally. +/// The download location will be retrieved using the specified +/// namepath and the JCalibration object passed in to the constructor. +/// The calibration DB should have an entry for the namepath that is +/// a map of key-values with two options for how the URL is specified: +/// +/// Option 1.) The DB provides a "URL_base" string and a "path" +/// string. These are combined to make the full URL, and the +/// "path" is appended to the resource_dir to generate the local +/// path. Alternatively, "URL_base" may be provided via the +/// JANA:RESOURCE_URL configuration parameter in which case it need +/// not be present in the calib DB. If the config. parameter is +/// supplied, it will be used instead of any "URL_base" values found +/// in the calib DB. +/// +/// Option 2.) The DB provides a "URL" string only. This is used +/// as the full URL and as a key to the resources map to find +/// the local path. If none exists, this local path is taken +/// to be the namepath specified (appended to resource_dir). +/// +/// Option 1. takes precedent. If either the "URL_base" or "path" +/// strings are present, then the other must be as well or an +/// exception is thrown. If neither is present, then the URL +/// string is checked and used. If it also does not exist, an +/// exception is thrown. +/// +/// +/// A text file named "resources" is maintained at the top level of +/// the resources directory tree to record what URLs have been +/// downloaded and where the files are stored. This file is necessary +/// if option 2 above is used to store URLs in the calibration DB, +/// but is only informational if option 1 is used. It is ignored +/// completely if no calibration database is used. +/// +/// The templated Get(namepath, T vals [, event_number]) method will +/// first call the GetResource() method described above, but will +/// then use a JCalibrationFile object to parse the resource file, +/// filling the container passed in for "vals". See the documentation +/// for the JCalibration class for more info on the allowed types +/// for "vals". + + +class JResource { +public: + JResource(std::shared_ptr params, JCalibration *jcalib = NULL, string resource_dir = ""); + + virtual ~JResource(); + + template + bool Get(string namepath, T &vals, int event_number = 0); + + string GetResource(string namepath); + + string GetLocalPathToResource(string namepath); + + map GetLocalResources(void) { return resources; } + + JCalibration *GetJCalibration(void) { return jcalib; } + + void GetResourceFromURL(const string &URL, const string &fullpath); + + string Get_MD5(string fullpath); + +protected: + + // Used to get URL of remote resource + JCalibration *jcalib; + + // Keep list of namepaths in JCalibration + vector calib_namepaths; + + // Used to convert files to values in STL containers + JCalibrationFile *jcalibfile; + + // Full path to top-most directory of resource files + string resource_dir; + + // Map of URLs to namepaths for existing resources + // key is URL and value is relative path (which should + // be the same as the namepath) + map resources; + + void ReadResourceInfoFile(void); + + void WriteResourceInfoFile(void); + + // Argument for the external curl program in case it is used + string curl_args; + +private: + + // Holds user specified URL_base that superceeds any found + // in calib DB + bool overide_URL_base; + string URL_base; + bool check_md5; + +}; + +//---------------------- +// Get +//---------------------- +template +bool JResource::Get(string namepath, T &vals, int event_number) { + /// Get the specified resource and parse it, placing the values in the + /// specified "vals" container. This first calls GetResource(namepath) + /// to download the resource (if necessary) and then uses a + /// JCalibrationFile::Get() method to parse the file and fill the + /// "vals" container. + + // Call to GetResource to (optionally) download and install resource file + string fullpath = GetResource(namepath); + string path = fullpath.substr(resource_dir.size() + 1); // chop off resource_dir + "/" + + // Have JCalibrationFile parse the resource file + return jcalibfile->Get(path, vals, event_number); +} + + +using JLargeCalibration [[deprecated("Renamed to JResource")]]= JResource; From 83c187fa20c21a6af1375e3d13a90c39bac19e1e Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 2 Jan 2025 12:35:31 -0500 Subject: [PATCH 8/8] Make license headers consistent in Calibrations/ and Geometry/ --- src/libraries/JANA/Calibrations/JCalibration.cc | 4 +++- src/libraries/JANA/Calibrations/JCalibration.h | 3 ++- src/libraries/JANA/Calibrations/JCalibrationCCDB.h | 3 ++- src/libraries/JANA/Calibrations/JCalibrationFile.cc | 3 ++- src/libraries/JANA/Calibrations/JCalibrationFile.h | 3 ++- .../JANA/Calibrations/JCalibrationGenerator.h | 3 ++- .../JANA/Calibrations/JCalibrationGeneratorCCDB.h | 3 ++- src/libraries/JANA/Calibrations/JCalibrationManager.h | 4 +++- src/libraries/JANA/Calibrations/JLargeCalibration.h | 4 ++++ src/libraries/JANA/Calibrations/JResource.cc | 10 ++++------ src/libraries/JANA/Calibrations/JResource.h | 10 ++++------ src/libraries/JANA/Geometry/JGeometry.h | 9 +++------ src/libraries/JANA/Geometry/JGeometryManager.cc | 4 ++-- src/libraries/JANA/Geometry/JGeometryManager.h | 3 ++- src/libraries/JANA/Geometry/JGeometryXML.cc | 10 ++++------ src/libraries/JANA/Geometry/JGeometryXML.h | 10 ++++------ 16 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/libraries/JANA/Calibrations/JCalibration.cc b/src/libraries/JANA/Calibrations/JCalibration.cc index df3cbdd52..e4fe6d481 100644 --- a/src/libraries/JANA/Calibrations/JCalibration.cc +++ b/src/libraries/JANA/Calibrations/JCalibration.cc @@ -1,6 +1,8 @@ -// Copyright 2020, Jefferson Science Associates, LLC. + +// Copyright 2007-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #include #include "JCalibration.h" diff --git a/src/libraries/JANA/Calibrations/JCalibration.h b/src/libraries/JANA/Calibrations/JCalibration.h index 6405aa3d8..89b248d11 100644 --- a/src/libraries/JANA/Calibrations/JCalibration.h +++ b/src/libraries/JANA/Calibrations/JCalibration.h @@ -1,6 +1,7 @@ -// Copyright 2020, Jefferson Science Associates, LLC. +// Copyright 2007-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #pragma once #include diff --git a/src/libraries/JANA/Calibrations/JCalibrationCCDB.h b/src/libraries/JANA/Calibrations/JCalibrationCCDB.h index d66b9f5a0..713d2a171 100644 --- a/src/libraries/JANA/Calibrations/JCalibrationCCDB.h +++ b/src/libraries/JANA/Calibrations/JCalibrationCCDB.h @@ -1,4 +1,5 @@ -// Copyright 2020, Jefferson Science Associates, LLC. + +// Copyright 2020-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. #pragma once diff --git a/src/libraries/JANA/Calibrations/JCalibrationFile.cc b/src/libraries/JANA/Calibrations/JCalibrationFile.cc index eb4494db7..53d14251d 100644 --- a/src/libraries/JANA/Calibrations/JCalibrationFile.cc +++ b/src/libraries/JANA/Calibrations/JCalibrationFile.cc @@ -1,6 +1,7 @@ -// Copyright 2020, Jefferson Science Associates, LLC. +// Copyright 2012-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #include "JCalibrationFile.h" #include diff --git a/src/libraries/JANA/Calibrations/JCalibrationFile.h b/src/libraries/JANA/Calibrations/JCalibrationFile.h index c18f1123a..bfabdc9eb 100644 --- a/src/libraries/JANA/Calibrations/JCalibrationFile.h +++ b/src/libraries/JANA/Calibrations/JCalibrationFile.h @@ -1,6 +1,7 @@ -// Copyright 2020, Jefferson Science Associates, LLC. +// Copyright 2012-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #pragma once #include "JCalibration.h" diff --git a/src/libraries/JANA/Calibrations/JCalibrationGenerator.h b/src/libraries/JANA/Calibrations/JCalibrationGenerator.h index df3f1dcf1..e2e845b2c 100644 --- a/src/libraries/JANA/Calibrations/JCalibrationGenerator.h +++ b/src/libraries/JANA/Calibrations/JCalibrationGenerator.h @@ -1,6 +1,7 @@ -// Copyright 2020, Jefferson Science Associates, LLC. +// Copyright 2007-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #pragma once #include diff --git a/src/libraries/JANA/Calibrations/JCalibrationGeneratorCCDB.h b/src/libraries/JANA/Calibrations/JCalibrationGeneratorCCDB.h index 1b482cab6..26568017c 100644 --- a/src/libraries/JANA/Calibrations/JCalibrationGeneratorCCDB.h +++ b/src/libraries/JANA/Calibrations/JCalibrationGeneratorCCDB.h @@ -1,4 +1,5 @@ -// Copyright 2020, Jefferson Science Associates, LLC. + +// Copyright 2020-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. #pragma once diff --git a/src/libraries/JANA/Calibrations/JCalibrationManager.h b/src/libraries/JANA/Calibrations/JCalibrationManager.h index cbf27cfc6..192528a99 100644 --- a/src/libraries/JANA/Calibrations/JCalibrationManager.h +++ b/src/libraries/JANA/Calibrations/JCalibrationManager.h @@ -1,5 +1,7 @@ -// Copyright 2020, Jefferson Science Associates, LLC. + +// Copyright 2007-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #pragma once #include diff --git a/src/libraries/JANA/Calibrations/JLargeCalibration.h b/src/libraries/JANA/Calibrations/JLargeCalibration.h index f771bf3ca..d030d73e4 100644 --- a/src/libraries/JANA/Calibrations/JLargeCalibration.h +++ b/src/libraries/JANA/Calibrations/JLargeCalibration.h @@ -1,4 +1,8 @@ +// Copyright 2020-2025, Jefferson Science Associates, LLC. +// Subject to the terms in the LICENSE file found in the top-level directory. +// Author: Nathan Brei + #pragma once #include diff --git a/src/libraries/JANA/Calibrations/JResource.cc b/src/libraries/JANA/Calibrations/JResource.cc index a5b80707d..e3eea16af 100644 --- a/src/libraries/JANA/Calibrations/JResource.cc +++ b/src/libraries/JANA/Calibrations/JResource.cc @@ -1,9 +1,7 @@ -// $Id$ -// -// File: JResource.cc -// Created: Mon Oct 15 07:36:44 EDT 2012 -// Creator: davidl (on Darwin eleanor.jlab.org 12.2.0 i386) -// + +// Copyright 2012-2025, Jefferson Science Associates, LLC. +// Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #include #include diff --git a/src/libraries/JANA/Calibrations/JResource.h b/src/libraries/JANA/Calibrations/JResource.h index b1ff8b56a..3704a0aac 100644 --- a/src/libraries/JANA/Calibrations/JResource.h +++ b/src/libraries/JANA/Calibrations/JResource.h @@ -1,9 +1,7 @@ -// $Id$ -// -// File: JResource.h -// Created: Mon Oct 15 07:36:44 EDT 2012 -// Creator: davidl (on Darwin eleanor.jlab.org 12.2.0 i386) -// + +// Copyright 2012-2025, Jefferson Science Associates, LLC. +// Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #pragma once #include diff --git a/src/libraries/JANA/Geometry/JGeometry.h b/src/libraries/JANA/Geometry/JGeometry.h index 12e0c10d3..8e1c72528 100644 --- a/src/libraries/JANA/Geometry/JGeometry.h +++ b/src/libraries/JANA/Geometry/JGeometry.h @@ -1,9 +1,6 @@ -// $Id$ -// -// File: JGeometry.h -// Created: Fri Jul 6 16:24:24 EDT 2007 -// Creator: davidl (on Darwin fwing-dhcp61.jlab.org 8.10.1 i386) -// + +// Copyright 2007-2025, Jefferson Science Associates, LLC. +// Subject to the terms in the LICENSE file found in the top-level directory. #pragma once diff --git a/src/libraries/JANA/Geometry/JGeometryManager.cc b/src/libraries/JANA/Geometry/JGeometryManager.cc index 0fdafd32b..d185d1d97 100644 --- a/src/libraries/JANA/Geometry/JGeometryManager.cc +++ b/src/libraries/JANA/Geometry/JGeometryManager.cc @@ -1,7 +1,7 @@ -// Copyright 2020, Jefferson Science Associates, LLC. +// Copyright 2007-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. - +// Author: David Lawrence #include "JGeometryManager.h" diff --git a/src/libraries/JANA/Geometry/JGeometryManager.h b/src/libraries/JANA/Geometry/JGeometryManager.h index 69ccb4d5d..0779c5218 100644 --- a/src/libraries/JANA/Geometry/JGeometryManager.h +++ b/src/libraries/JANA/Geometry/JGeometryManager.h @@ -1,6 +1,7 @@ -// Copyright 2020, Jefferson Science Associates, LLC. +// Copyright 2007-2025, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #pragma once #include diff --git a/src/libraries/JANA/Geometry/JGeometryXML.cc b/src/libraries/JANA/Geometry/JGeometryXML.cc index ca5600952..84d52be60 100644 --- a/src/libraries/JANA/Geometry/JGeometryXML.cc +++ b/src/libraries/JANA/Geometry/JGeometryXML.cc @@ -1,9 +1,7 @@ -// $Id$ -// -// File: JGeometryXML.cc -// Created: Tues Jan 15, 2008 -// Creator: davidl -// + +// Copyright 2008-2025, Jefferson Science Associates, LLC. +// Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #include diff --git a/src/libraries/JANA/Geometry/JGeometryXML.h b/src/libraries/JANA/Geometry/JGeometryXML.h index 54393e274..3af5e18ff 100644 --- a/src/libraries/JANA/Geometry/JGeometryXML.h +++ b/src/libraries/JANA/Geometry/JGeometryXML.h @@ -1,9 +1,7 @@ -// $Id$ -// -// File: JGeometryXML.h -// Created: Tues Jan 15 2008 -// Creator: davidl -// + +// Copyright 2008-2025, Jefferson Science Associates, LLC. +// Subject to the terms in the LICENSE file found in the top-level directory. +// Author: David Lawrence #pragma once #include