25 auto const fileID = sourceID(
fileName);
26 if (fileID)
return fileID.value();
29 return indexToFileID(fSourceFiles.size() - 1U);
41 {
return findSource(fileName) != fSourceFiles.end(); }
46 -> std::optional<FileID_t>
48 auto const iSource = findSource(
fileName);
49 return (iSource != fSourceFiles.end())
50 ? std::optional{indexToFileID(
std::distance(fSourceFiles.begin(), iSource))}
60 return hasSource(fileID)
61 ? std::optional{ fSourceFiles[fileIDtoIndex(fileID)] }: std::nullopt;
67 (
FileID_t const& fileID, std::string
const& defName)
const
68 {
return sourceName(fileID).value_or(defName); }
74 std::vector<EventIDandRecord_t> recordCopy;
75 copyEventRecordsInto(recordCopy);
83 -> std::optional<EventRecord_t>
86 auto const lg = lockEventRegistry();
88 auto const iRecord = fEventRegistry.find(event);
89 return (iRecord != fEventRegistry.end())
90 ? std::optional{ iRecord->second }: std::nullopt;
100 auto const lg = lockEventRegistry();
102 auto& record = fEventRegistry[event];
103 record.sourceFiles.push_back(sourceFileID);
112 -> FileRegistry_t::iterator
113 {
return std::find(fSourceFiles.begin(), fSourceFiles.end(),
fileName); }
116 -> FileRegistry_t::const_iterator
117 {
return std::find(fSourceFiles.begin(), fSourceFiles.end(),
fileName); }
122 (std::vector<EventIDandRecord_t>& recordCopy)
const
124 recordCopy.reserve(fEventRegistry.size());
125 auto const lg = lockEventRegistry();
127 recordCopy.reserve(fEventRegistry.size());
128 std::copy(fEventRegistry.cbegin(), fEventRegistry.cend(),
129 std::back_inserter(recordCopy));
136 {
return std::lock_guard{ fEventRegistryLock }; }
141 {
return static_cast<FileID_t>(index); }
146 {
return static_cast<std::size_t
>(fileID); }
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
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 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::lock_guard< std::mutex > lockEventRegistry() const
Returns a lock guard around fEventRegistry.
std::optional< std::string > sourceName(FileID_t const &fileID) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Class keeping track of art event IDs.
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
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::size_t FileID_t
Type used to identify a source file.
services TFileService fileName
static FileID_t indexToFileID(std::size_t index)
Converts an internal index in file source registry into a FileID_t.
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