9#include <framework/database/DBStore.h>
10#include <framework/database/Database.h>
11#include <framework/logging/Logger.h>
13#include <boost/none.hpp>
35 const TClass* objClass,
bool array,
bool required)
43 if (!dbEntry.
checkType(type, objClass, array))
return nullptr;
45 B2DEBUG(39,
"DBEntry " << name <<
" was requested once more.");
48 B2DEBUG(34,
"DBEntry " << name <<
" is now required");
56 B2DEBUG(34,
"DBEntry " << name <<
" was created (" << (required ?
"required" :
"optional") <<
")");
115 std::vector<Database::DBQuery> entries;
118 bool expired = !entry.second.getIoV().contains(event);
120 B2DEBUG(34,
"DBEntry " << entry.first <<
" out of date, will need update");
122 if (!entry.second.keepUntilExpired() || expired)
123 entries.emplace_back(entry.first, entry.second.isRequired());
129 if (entries.empty())
return;
135 for (
auto& query : entries) {
136 auto& dbEntry =
m_dbEntries.find(query.name)->second;
137 dbEntry.updatePayload(query.revision, query.iov, query.filename, query.checksum, query.globaltag, event);
147 B2WARNING(
"DBStore is currently using manual event information. But you are asking for the DataStore's EventMetaData "
148 "to be used to update the Intra-run dependencies. Update could not proceed. "
149 "Did you forget to call DBStore::Instance().update() before calling this function?");
162 B2WARNING(
"DBStore is not currently using manual event information. But you are asking for the event number to be set "
163 " to a custom value. Update of the Intra-run dependencies could not proceed. "
164 "Did you forget to call DBStore::Instance().update(event), or accidentally call DBStore::Instance().update() "
165 "prior to to this?");
173 dbEntry->updateObject(event);
180 B2DEBUG(31,
"DBStore::reset(): Cleaning all database information");
186 entry.second.resetPayload();
198 std::set<std::string> s{};
228 B2WARNING(
"An override for DBEntry " << name <<
" was created.");
Class to hold one entry from the ConditionsDB in the DBStore.
EPayloadType
Possible Store entry types.
bool isIntraRunDependent() const
return whether or not the payload might change even during the run
void require()
Change status of this payload to required.
bool isRequired() const
check whether this payload is required for operation
Singleton class to cache database objects.
StoreObjPtr< EventMetaData > m_storeEvent
StoreObjPtr for the EventMetaData to get the current experiment and run from the DataStore.
std::set< DBStoreEntry * > m_intraRunDependencies
List of intra-run dependent conditions.
std::optional< EventMetaData > m_manualEvent
Optional EventMetaData variable.
std::unordered_map< std::string, DBStoreEntry > m_dbEntries
Map names to DBEntry objects.
@ c_InitGlobaltagList
Globaltag list has been finalized metadata providers not and globaltags are not checked for usability...
A class that describes the interval of experiments/runs for which an object in the database is valid.
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
Type-safe access to single objects in the data store.
void reset(bool keepEntries=false)
Invalidate all payloads.
void initialize(const EDatabaseState target=c_Ready)
Initialize the database connection settings on first use.
bool checkType(const TObject *object) const
Check if a given TObject instance is compatible with the type of this entry.
std::pair< TObject *, IntervalOfValidity > getData(const EventMetaData &event, const std::string &name)
Request an object from the database.
void performUpdateEvent(const EventMetaData &event)
The main code that does an updateEvent.
static Database & Instance()
Instance of a singleton Database.
static DBStore & Instance()
Instance of a singleton DBStore.
void performUpdate(const EventMetaData &event)
The main code that does an update, factored out so it can be used by both update and update(event).
void overrideObject(TObject *obj, const IntervalOfValidity &iov)
Set an override object in case we want to use a different object then actually provided by the databa...
DBStoreEntry * getEntry(DBStoreEntry::EPayloadType payloadType, const std::string &name, const TClass *objClass, bool array, bool required=true)
Returns the entry with the requested name in the DBStore.
void updateEvent()
Updates all intra-run dependent objects.
void update()
Updates all objects that are outside their interval of validity.
static DBStoreEntry fromObject(const std::string &name, const TObject *obj, bool isRequired)
Construct a new DBStoreEntry with a requested name and an object directly.
void addConstantOverride(const std::string &name, TObject *obj, bool oneRun=false)
Add constant override payload.
std::set< std::string > getAllEntryNames()
Return the names of all the payloads stored in the database at the time of this function is called.
void updatePayload(unsigned int revision, const IntervalOfValidity &iov, const std::string &filename, const std::string &checksum, const std::string &globaltag, const EventMetaData &event)
Update the payload information for this entry and if appropriate open the new file and extract the ob...
Abstract base class for different kinds of events.