BxCppDev / Bayeux

Core Persistency, Geometry and Data Processing C++ Library for Particle and Nuclear Physics Experiments
GNU General Public License v3.0
4 stars 9 forks source link

Possible incorrect behaviour of `datatools::event_id::set` #9

Closed drbenmorgan closed 6 years ago

drbenmorgan commented 7 years ago

When setting run and event numbers in datatools::event_id, the "wildcard" datatools::event_id::ANY_RUN_NUMBER is ignored. Minimal working example is:

  datatools::event_id working {datatools::event_id::ANY_RUN_NUMBER, 42};
  std::cout << working << std::endl; //"-2_42"

  std::string stringEID {"-2_42"};
  std::istringstream streamedEID {stringEID};
  datatools::event_id notWorking;
  streamedEID >> notWorking;
  std::cout << notWorking << std::endl; //"-1_42"

  notWorking.set(datatools::event_id::ANY_RUN_NUMBER, 24);
  std::cout << notWorking << std::endl; //"-1_24"

which as noted in the comments prints:

-2_42
-1_42
-1_24

The bug appears to be in the set method where integers less than the INVALID_RUN_NUMBER marker are ignored.

fmauger commented 7 years ago

A fix attempt is available from the release-3.1.0 branch. It should be possible now to use an incomplete event ID object with ANY run_number and specific event number. The event_id::match method can be used to select a given event ID pattern. stream methods have been rewritten.