Skip to content

Commit

Permalink
feat(CCDB): add getForRunMiddleTimeStamp method
Browse files Browse the repository at this point in the history
Adds a new method `getForRunMiddleTimeStamp` to the `CCDBManagerInstance`
class. This method retrieves an object of type `T` from the CCDB using the
path and the middle timestamp of the given run number. This is a useful
utility method for cases where the exact timestamp does not matter and the
run number is available.
  • Loading branch information
mpuccio committed Oct 1, 2024
1 parent b943e69 commit f00f658
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CCDB/include/CCDB/BasicCCDBManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class CCDBManagerInstance
template <typename T>
T* getForTimeStamp(std::string const& path, long timestamp);

/// retrieve an object of type T from CCDB as stored under path and using the timestamp in the middle of the run
template <typename T>
T* getForRunMiddleTimeStamp(std::string const& path, int runNumber);

/// retrieve an object of type T from CCDB as stored under path, timestamp and metaData
template <typename T>
T* getSpecific(std::string const& path, long timestamp = -1, MD metaData = MD())
Expand Down Expand Up @@ -311,6 +315,20 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
return ptr;
}

template <typename T>
T* CCDBManagerInstance::getForRunMiddleTimeStamp(std::string const& path, int runNumber)
{
auto [start, stop] = getRunDuration(runNumber);
if (start < 0 || stop < 0) {
if (mFatalWhenNull) {
reportFatal(std::string("Failed to get run duration for run ") + std::to_string(runNumber));
}
return nullptr;
}
return getForTimeStamp<T>(path, start / 2 + stop / 2);
}


class BasicCCDBManager : public CCDBManagerInstance
{
public:
Expand Down

0 comments on commit f00f658

Please sign in to comment.