13 #ifndef ICARUSCODE_UTILITIES_EVENTREGISTRY_H
14 #define ICARUSCODE_UTILITIES_EVENTREGISTRY_H
18 #include "canvas/Persistency/Provenance/EventID.h"
19 #include "cetlib_except/exception.h"
22 #include <unordered_map>
37 struct hash<art::EventID> {
39 std::size_t operator() (art::EventID
const& ID)
const noexcept
41 return std::hash<std::uint64_t>{}(
42 (std::uint64_t{ ID.run() } << 40U)
43 + (std::uint64_t{ ID.subRun() } << 22U)
44 + (std::uint64_t{ ID.event() })
54 namespace sbn {
class EventRegistry; }
131 (
FileID_t const& fileID, std::string
const& defName)
const;
142 std::vector<EventIDandRecord_t>
records()
const;
146 std::optional<EventRecord_t>
eventRecord(art::EventID
const& event)
const;
209 #endif // ICARUSCODE_UTILITIES_EVENTREGISTRY_H
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
std::vector< FileID_t > sourceFiles
List of ID of source files.
std::optional< EventRecord_t > eventRecord(art::EventID const &event) const
FileRegistry_t::iterator findSource(std::string const &fileName)
Returns an iterator pointing to the specified file registry entry.
static constexpr FileID_t NoFileID
Mnemonic for no file ID.
static std::size_t fileIDtoIndex(FileID_t fileID)
Converts a FileID_t into an internal index in file source registry.
std::vector< std::string > fSourceFiles
Registered source file, by file ID key.
std::unordered_map< EventID_t, EventRecord_t > fEventRegistry
Registry of all events.
std::lock_guard< std::mutex > lockEventRegistry() const
Returns a lock guard around fEventRegistry.
std::optional< std::string > sourceName(FileID_t const &fileID) const
EventRecord_t recordEvent(EventID_t const &event, FileID_t sourceFileID)
Registers an event and returns a copy of its record.
std::pair< EventID_t, EventRecord_t > EventIDandRecord_t
Type with event ID (first) and event record information (second).
std::vector< EventIDandRecord_t > records() const
Returns a copy of all event records.
std::mutex fEventRegistryLock
Lock for fEventRegistry.
std::size_t FileID_t
Type used to identify a source file.
services TFileService fileName
Keeps a record of all registered events and their source.
static FileID_t indexToFileID(std::size_t index)
Converts an internal index in file source registry into a FileID_t.
std::vector< std::string > FileRegistry_t
Type for source file registry.
bool hasSource(FileID_t const &fileID) const
Returns whether the specified file ID is registered as a source.
std::string sourceNameOr(FileID_t const &fileID, std::string const &defName) const
FileID_t recordSource(std::string const &fileName)
Registers a source file and returns its ID in the registry.
void copyEventRecordsInto(std::vector< EventIDandRecord_t > &recordCopy) const
Copies all event records into recordCopy.
art::EventID EventID_t
Type used to identify an event.
Element of the registry for an event.
std::optional< FileID_t > sourceID(std::string const &fileName) const