Skip to content

Commit c92bff9

Browse files
authored
Merge pull request #37 from JeffersonLab/evio-6-dev-tmp
Evio 6 dev tmp
2 parents 8bc6cc0 + 04fe2ea commit c92bff9

13 files changed

Lines changed: 356 additions & 51 deletions

File tree

.github/workflows/c_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
run: cmake -S . -B build -DMAKE_EXAMPLES=1
1818

1919
- name: Build
20-
run: cmake --build build -- -j$(nproc)
20+
run: cmake --build build --target install --parallel
2121

2222
- name: Run tests
2323
working-directory: build

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ build/
2929
jbuild/
3030
lib/
3131
bin/
32+
tmp/
3233
doxyerrors.log
3334
target/
3435
doc/javadoc
@@ -37,3 +38,5 @@ doc/doxygen/C
3738
doc/source/
3839
config.log
3940

41+
# Ignore typical install directory type
42+
Linux-*/

CMakeLists.txt

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1+
# See instructions in README.md for building and installing
2+
3+
### VERSION DEFINITIONS ###
14
cmake_minimum_required(VERSION 3.22)
25
project(evio VERSION 6.1.0 LANGUAGES C CXX)
3-
4-
# C/C++ standard and build options
56
set(CMAKE_C_STANDARD 11)
6-
set(CMAKE_C_STANDARD_REQUIRED ON)
77
set(CMAKE_CXX_STANDARD 20)
8+
# C/C++ build options
9+
set(CMAKE_C_STANDARD_REQUIRED ON)
810
set(CMAKE_CXX_STANDARD_REQUIRED ON)
911
set(CMAKE_DEBUG_POSTFIX -dbg)
10-
add_compile_options(-Wall)
12+
add_compile_options(-Wall) # Enable all warnings
1113

12-
# Build options (and defaults)
14+
# Includes
15+
include(GNUInstallDirs)
16+
include(FindPackageHandleStandardArgs) # find_package_handle_standard_args()
17+
include(CTest)
18+
19+
# Build option parameters (and defaults)
1320
option(C_ONLY "SKIP building C++ library, build C only" OFF)
1421
option(MAKE_EXAMPLES "Build example/test programs" OFF)
1522
option(USE_FILESYSTEMLIB "Use C++ <filesystem> instead of Boost" OFF)
1623
option(DISRUPTOR_FETCH "Allow CMake to download Disruptor if not found" ON)
17-
include(GNUInstallDirs)
18-
include(FindPackageHandleStandardArgs) # find_package_handle_standard_args()
19-
include(CTest)
2024

2125
# Add custom find_package for Disruptor
2226
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -51,7 +55,10 @@ elseif (DEFINED ENV{CODA})
5155
else()
5256
# Use default CMAKE_INSTALL_PREFIX
5357
set(INSTALL_DIR_DEFINED 1)
58+
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/${ARCH})
59+
set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include)
5460
message(STATUS "Installing to default location: ${CMAKE_INSTALL_PREFIX}")
61+
message(STATUS "Installing includes to default location: ${CMAKE_INSTALL_INCLUDEDIR}")
5562
endif()
5663

5764
# Boost libs
@@ -98,12 +105,13 @@ file(GLOB C_LIB_FILES "src/libsrc/*.c")
98105
# C++ source files
99106
file(GLOB CPP_LIB_FILES "src/libsrc++/*.cpp")
100107
file(GLOB CPP_HEADER_FILES "src/libsrc++/*.h")
101-
# A few extras required
108+
# C++ utility files
109+
file(GLOB CPP_UTILS_FILES "src/utils/cpp/*.cpp")
110+
# A few extras required for examples
102111
if(MAKE_EXAMPLES)
112+
list(APPEND CPP_HEADER_FILES src/test/cpp/EvioTestHelper.h)
103113
file(GLOB TEST "src/test/cpp/*.cpp")
104114
file(GLOB TESTC "src/test/c/*.c")
105-
list(APPEND CPP_HEADER_FILES src/test/cpp/EvioTestHelper.h)
106-
# list(APPEND CPP_LIB_FILES src/test/cpp/EvioTestHelper.h)
107115
endif()
108116

109117
# BUILD C++ LIBRARY (unless otherwise specified)
@@ -142,6 +150,25 @@ if(NOT C_ONLY)
142150
${DISRUPTOR_INCLUDE_DIR}
143151
)
144152

153+
# Build utility programs
154+
foreach(fileName ${CPP_UTILS_FILES})
155+
# Get file name with no directory or extension as executable name
156+
get_filename_component(execName ${fileName} NAME_WE)
157+
# Create executable from file
158+
add_executable(${execName} ${fileName})
159+
# Put debug extension on if applicable
160+
set_target_properties(${execName} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
161+
# Needs these libs
162+
target_link_libraries(${execName} eviocc pthread ${Boost_LIBRARIES} ${LZ4_LIBRARY} expat dl z m)
163+
164+
# Only install if installation directory has been defined
165+
if(DEFINED INSTALL_DIR_DEFINED)
166+
message(STATUS "Installing utility executable: ${execName}")
167+
# Install into bin/utils dir
168+
install(TARGETS ${execName} RUNTIME DESTINATION bin/utils)
169+
endif()
170+
endforeach()
171+
145172
# Add the C++ tests/examples
146173
if(MAKE_EXAMPLES)
147174
foreach(fileName ${TEST})

README.md

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,50 @@
11
# **EVIO 6 SOFTWARE PACKAGE**
22

3-
EVIO stands for EVent Input/Output, a unique data format developed by Jefferson Lab.
4-
It was created by the Data Acquisition (DAQ) group and is maintained by the
5-
Experimental Physics Software and Computing Infrastructure (EPSCI) group at Thomas
6-
Jefferson National Accelerator Facility (JLab).
3+
EVIO stands for EVent Input/Output, a unique data format developed by Jefferson Lab used by typical detector readout systems at the lab. This software repository allows one to read & write `.evio` and `.ev` format data, within either a C/C++ or Java programming environment.
74

8-
This software repository allows one to read & write `.evio` and `.ev` format data,
9-
within either a C/C++ or Java programming environment.
5+
# **Useful Links**
6+
7+
Documentation on GitHub:
8+
9+
* [All Links](https://jeffersonlab.github.io/evio)
10+
* [User's Guide PDF](https://jeffersonlab.github.io/evio/doc-6.0/users_guide/evio_Users_Guide.pdf)
11+
* [EVIO Data Format Reference](https://jeffersonlab.github.io/evio/doc-6.0/format_guide/evio_Formats.pdf)
12+
13+
Software Library Documentation:
14+
15+
* [Javadoc for Java Library](https://jeffersonlab.github.io/evio/doc-6.0/javadoc/index.html)
16+
* [Doxygen for C Library](https://jeffersonlab.github.io/evio/doc-6.0/doxygen/C/html/index.html)
17+
* [Doxygen for C++ Libary](https://jeffersonlab.github.io/evio/doc-6.0/doxygen/CC/html/index.html)
1018

1119
# **Getting Started**
1220

1321
## **C/C++ Library**
1422

15-
To build C/C++ code from this repository:
23+
The C and C++ libraries are build using `cmake`. To build C/C++ code from this repository:
1624

1725
git clone https://github.com/JeffersonLab/evio/
1826
cd evio; mkdir build
1927
cmake -S . -B build
20-
cmake --build build --parallel
28+
cmake --build build --target install --parallel
2129

22-
Note that during the cmake configure step (first of two `cmake` commands above), one can
23-
toggle the following special flags:
30+
Note that during the cmake configure step (first of two `cmake` commands above), one can also include the following special flags:
2431

2532
* `C_ONLY` : build C lib only, skip C++ (default `-DC_ONLY=0`)
2633
* `MAKE_EXAMPLES`: build example/test programs (default `-DMAKE_EXAMPLES=0`)
2734
* `USE_FILESYSTEMLIB`: ue C++17 <filesystem> instead of Boost (default `-DUSE_FILESYSTEMLIB=0`)
2835
* `DISRUPTOR_FETCH`: allow CMake to download Disruptor if not found (default `-DDISRUPTOR_FETCH=1`)
36+
* `CODA_INSTALL`: installs in this base directory. If not used,
37+
then the env variable $CODA location is next checked. Otherwise defaults to \${CMAKE_HOST_SYSTEM_NAME}-\${CMAKE_HOST_SYSTEM_PROCESSOR}, typically something like `[evio_directory]/Linux-x86_64`.
2938

3039
One can still also use `scons` instead of cmake to build the evio C/C++ library, though this feature
3140
will not be supported in future releases.
3241

3342
### Prerequisites
3443

35-
C++ 17 or higher, `cmake`, `lz4`, `boost_system`, `boost_thread`, and `boost_chrono`. If LZ4 is not
36-
already configured, it can be installed from [LZ4 on github](https://github.com/lz4/lz4). The boost
37-
libraries are typically system-specific.
44+
C++ 17 or higher, `cmake`, `lz4`, `boost_system`, `boost_thread`, and `boost_chrono`. Compilation can
45+
be done using `clang` or `gcc` (gcc 11 or higher recommended). If LZ4 is not
46+
already configured, it can be installed from [LZ4 on github](https://github.com/lz4/lz4). Installation of boost
47+
libraries are typically system-specific (e.g. using a command like `yum`, `dbn`, `rpm`, `apt-get`, etc.).
3848

3949
## **Java Library**
4050

@@ -57,23 +67,12 @@ Requires Maven (`mvn`) and an installation of Java on your system.
5767
**Running on "ifarm" at JLab will not work unless you install java yourself**. Note that the default java versions on the farm will be too old to
5868
work. See downloads from [OpenJDK](https://openjdk.org/install/) or [Oracle](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html).
5969

60-
-----------------------------
6170

62-
# **Useful Links**
63-
64-
----------------------------
71+
# **Further Information**
6572

66-
Documentation on GitHub:
6773

68-
* [All Documentation](https://jeffersonlab.github.io/evio)
69-
* [User's Guide PDF](https://jeffersonlab.github.io/evio/doc-6.0/users_guide/evio_Users_Guide.pdf)
70-
* [EVIO Data Format Reference](https://jeffersonlab.github.io/evio/doc-6.0/format_guide/evio_Formats.pdf)
74+
The EVIO package was created by the Data Acquisition (DAQ) group and is maintained by the Experimental Physics Software and Computing Infrastructure (EPSCI) group at the Thomas Jefferson National Accelerator Facility (JLab). It has been developed by many authors over the years.
7175

72-
Software Library Documentation:
73-
74-
* [Javadoc for Java Library](https://jeffersonlab.github.io/evio/doc-6.0/javadoc/index.html)
75-
* [Doxygen for C Library](https://jeffersonlab.github.io/evio/doc-6.0/doxygen/C/html/index.html)
76-
* [Doxygen for C++ Libary](https://jeffersonlab.github.io/evio/doc-6.0/doxygen/CC/html/index.html)
7776

7877
Other Links:
7978
* [EVIO Event Viewer on GitHub](https://github.com/JeffersonLab/JEventViewer)
@@ -86,10 +85,8 @@ well as the software used to read and write to these respective `.evio` and `.hi
8685
More information on the HIPO data format can be found at https://github.com/gavalian/hipo,
8786
or from the CLAS12 Software Project Coordinator.
8887

89-
----------------------------
88+
Contact: Jon Zarling (jzarling@jlab.org)
9089

9190
# **Copyright**
9291

93-
----------------------------
94-
9592
For any issues regarding use and copyright, read the [license](LICENSE.txt) file.

java/jars/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# **Java JARs Folder**
22

3-
This folder contains any jar file dependencies required by the EVIO Java library that are not retrieved directly from the Maven repository. At present, only the disruptor library needs to be added from here.
3+
This folder contains jar files used for executing EVIO code using the Java API. The main jar file was made using Java 17.
44

5-
Note that the disruptor 4.0.0 jar file included comes from a [JeffersonLab fork](https://github.com/JeffersonLab/disruptor) of the original lmax Java library. This forked repository adds an additional function (SpinCountBackoffWaitStrategy) that is required in the evio Java Library.
5+
It also includes dependencies required by the EVIO Java library that are not retrieved directly from the Maven repository. At present, only the disruptor dependency needs to be added from here. Note that the disruptor 4.0.0 jar file included comes from a [JeffersonLab fork](https://github.com/JeffersonLab/disruptor) of the original lmax Java library. This forked repository adds an additional function (SpinCountBackoffWaitStrategy) that is required in the evio Java Library.

src/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
| [libsrc](libsrc) | EVIO C library |
66
| [libsrc++](libsrc++) | EVIO C++ library |
77
| [main/java](main/java) | EVIO Java Library |
8-
| [test](test) | For internal testing of Java, C, C++ libraries. |
8+
| [test](test) | For internal testing of Java, C, C++ libraries. |
9+
| [utils](utils) | Standalone programs, e.g. utilities to merge files, convert formats, attempt recovery, etc. |
910

src/libsrc++/EventParser.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ namespace evio {
227227
// --which will be interpreted by the various "get data" methods.
228228
auto & bytes = structure->getRawBytes();
229229
ByteOrder byteOrder = structure->getByteOrder();
230-
231230
if (bytes.empty()) {
232-
throw EvioException("Null data in structure");
231+
// throw EvioException("Null data in structure");
232+
// printf("WARNING: no data inside structure! Skipping... \n");
233+
// printf(" structure %s \n", structure->getHeader()->toString().c_str());
234+
return;
233235
}
234236

235237
size_t length = bytes.size();

src/libsrc++/EvioReaderV4.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ namespace evio {
10901090
uint32_t eventDataSizeBytes = 4*(length - 1);
10911091

10921092
try {
1093-
auto *bytes = new uint8_t[eventDataSizeBytes];
1093+
auto bytes = std::vector<uint8_t>(eventDataSizeBytes);
10941094

10951095
uint32_t bytesToGo = eventDataSizeBytes;
10961096
uint32_t offset = 0;
@@ -1106,7 +1106,7 @@ namespace evio {
11061106
blkBytesRemaining : bytesToGo;
11071107

11081108
// Read in bytes remaining in internal buffer
1109-
byteBuffer->getBytes(bytes + offset, bytesToReadNow);
1109+
byteBuffer->getBytes(bytes.data() + offset, bytesToReadNow);
11101110
offset += bytesToReadNow;
11111111
bytesToGo -= bytesToReadNow;
11121112
blkBytesRemaining -= bytesToReadNow;
@@ -1123,12 +1123,14 @@ namespace evio {
11231123
blkBytesRemaining = blockBytesRemaining();
11241124
}
11251125
}
1126+
1127+
11261128
}
11271129

11281130
// Last (perhaps only) read
1129-
byteBuffer->getBytes(bytes + offset, bytesToGo);
1131+
byteBuffer->getBytes(bytes.data() + offset, bytesToGo);
11301132
//std::cout << "nextEvent: eventDataSizeByte = " << eventDataSizeBytes << std::endl;
1131-
event->setRawBytes(bytes, eventDataSizeBytes);
1133+
event->setRawBytes(bytes.data(), eventDataSizeBytes);
11321134
event->setByteOrder(byteOrder); // add this to track endianness, timmer
11331135
// Don't worry about dictionaries here as version must be 1-3
11341136
event->setEventNumber(++eventNumber);

src/main/java/org/jlab/coda/jevio/EvioReader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public EvioReader(File file, boolean checkRecNumSeq, boolean sequential, boolean
215215

216216
// Parse file header to find the file's endianness & evio version #
217217
if (findEvioVersion() != ReadStatus.SUCCESS) {
218+
rFile.close();
218219
throw new EvioException("Failed reading first block header");
219220
}
220221

src/main/java/org/jlab/coda/jevio/EvioReaderUnsyncV4.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ else if (bytesInBuf % 32768 == 0) {
10461046
// Check block size, attempt to recover if flag set
10471047
// (otherwise return exception with a hint to set flag)
10481048
// System.out.println("blkSize BEFORE = " + blkSize);
1049-
if(doHeaderRecoveryCheck && fileSize - fileChannel.position() >= 10*4) {
1049+
if(doHeaderRecoveryCheck && (fileSize - fileChannel.position()) >= 10*4 && fileChannel.position() > 20*4) {
10501050

10511051
int expectedMagicPos = 27; // in words
10521052
int words_to_skip = 0; // words_to_skip = foundMagicPos - expectedMagicPos

0 commit comments

Comments
 (0)