Skip to content

Commit

Permalink
CCDB: add getSpecificForRun (#13569)
Browse files Browse the repository at this point in the history
* CCDB: add getSpecificForRun

This PR adds a method `getSpecificForRun` to the base CCDB manager class. It is specifically tailored for analysis use in which the reconstruction pass is checked.
  • Loading branch information
ddobrigk authored Oct 9, 2024
1 parent eaba5c2 commit 39489be
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions CCDB/include/CCDB/BasicCCDBManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ class CCDBManagerInstance
return getForTimeStamp<T>(path, timestamp);
}

/// retrieve an object of type T from CCDB as stored under path and using the timestamp in the middle of the run + metadata. The run number is provided separately to conform to typical analysis use (in which case metadata does not include runNumber)
template <typename T>
T* getSpecificForRun(std::string const& path, int runNumber, MD metaData = MD());

/// detect online processing modes (i.e. CCDB objects may be updated in the lifetime of the manager)
bool isOnline() const { return mDeplMode == o2::framework::DeploymentMode::OnlineAUX || mDeplMode == o2::framework::DeploymentMode::OnlineDDS || mDeplMode == o2::framework::DeploymentMode::OnlineECS; }

Expand Down Expand Up @@ -317,6 +321,14 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)

template <typename T>
T* CCDBManagerInstance::getForRun(std::string const& path, int runNumber, bool setRunMetadata)
{
auto metaData = setRunMetadata ? MD{{"runNumber", std::to_string(runNumber)}} : MD{};
mMetaData = metaData;
return getSpecificForRun<T>(path, runNumber, metaData);
}

template <typename T>
T* CCDBManagerInstance::getSpecificForRun(std::string const& path, int runNumber, MD metaData)
{
auto [start, stop] = getRunDuration(runNumber);
if (start < 0 || stop < 0) {
Expand All @@ -325,8 +337,7 @@ T* CCDBManagerInstance::getForRun(std::string const& path, int runNumber, bool s
}
return nullptr;
}
mMetaData = setRunMetadata ? MD{{"runNumber", std::to_string(runNumber)}} : MD{};
return getForTimeStamp<T>(path, start / 2 + stop / 2);
return getSpecific<T>(path, start / 2 + stop / 2, metaData);
}

class BasicCCDBManager : public CCDBManagerInstance
Expand Down

0 comments on commit 39489be

Please sign in to comment.