Project
Loading...
Searching...
No Matches
test_GeneratorHepMCIndexed.cxx File Reference
#include <boost/test/unit_test.hpp>
#include <Generators/GeneratorService.h>
#include <CommonUtils/ConfigurableParam.h>
#include <SimulationDataFormat/MCEventHeader.h>
#include <SimulationDataFormat/MCTrack.h>
#include <HepMC3/GenEvent.h>
#include <HepMC3/GenParticle.h>
#include <HepMC3/GenRunInfo.h>
#include <HepMC3/ReaderAscii.h>
#include <HepMC3/ReaderAsciiHepMC2.h>
#include <HepMC3/WriterAsciiHepMC2.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <memory>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   Test GeneratorHepMC indexed access
 
#define BOOST_TEST_MAIN
 
#define BOOST_TEST_DYN_LINK
 

Functions

 BOOST_AUTO_TEST_CASE (hepmc3_reader_can_be_seeked)
 
 BOOST_AUTO_TEST_CASE (generator_serves_a_permutation)
 
 BOOST_AUTO_TEST_CASE (generator_honours_events_to_skip)
 
 BOOST_AUTO_TEST_CASE (generator_reads_hepmc2)
 

Macro Definition Documentation

◆ BOOST_TEST_DYN_LINK

#define BOOST_TEST_DYN_LINK

Definition at line 26 of file test_GeneratorHepMCIndexed.cxx.

◆ BOOST_TEST_MAIN

#define BOOST_TEST_MAIN

Definition at line 25 of file test_GeneratorHepMCIndexed.cxx.

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   Test GeneratorHepMC indexed access

Tests for the indexed (seekable) access GeneratorHepMC uses to serve the events of a HepMC3 ASCII file out of order.

The first test guards the assumption the whole scheme rests on: that a HepMC3 ASCII reader holds no state between events besides the stream, so that the stream can be repositioned underneath it. That is an implementation detail of HepMC3, not a documented contract, so it has to be re-checked against every version we build against - if it ever stops holding, the generator would silently serve the wrong events rather than fail.

Author
M. Giacalone - September 2026 co-written with Claude Opus 5

Definition at line 24 of file test_GeneratorHepMCIndexed.cxx.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/4]

BOOST_AUTO_TEST_CASE ( generator_honours_events_to_skip  )

eventsToSkip has to leave the skipped entries out of the game entirely. This also pins the index down to an absolute position in the file: an index off by any amount would serve an entry from outside the requested range.

Definition at line 276 of file test_GeneratorHepMCIndexed.cxx.

◆ BOOST_AUTO_TEST_CASE() [2/4]

BOOST_AUTO_TEST_CASE ( generator_reads_hepmc2  )

The same must hold when the input is in the HepMC2 IO_GenEvent format, which the generator indexes with ReaderAsciiHepMC2 instead of ReaderAscii.

Definition at line 313 of file test_GeneratorHepMCIndexed.cxx.

◆ BOOST_AUTO_TEST_CASE() [3/4]

BOOST_AUTO_TEST_CASE ( generator_serves_a_permutation  )

The generator must serve every event of the file exactly once per pass, start over in roundRobin mode, and - the part that a wrong index would break silently - hand out the event that actually sits at the entry it claims to be serving. Driving this through GeneratorService also exercises the configurable-parameter path the generator is configured by in a real job.

Definition at line 227 of file test_GeneratorHepMCIndexed.cxx.

◆ BOOST_AUTO_TEST_CASE() [4/4]

BOOST_AUTO_TEST_CASE ( hepmc3_reader_can_be_seeked  )

The ASCII readers must survive having their stream repositioned between events: reading the entries by seeking to a recorded offset has to give exactly what reading the file from start to end gives. Checked for both formats the generator indexes.

Definition at line 209 of file test_GeneratorHepMCIndexed.cxx.