ATLAS Offline Software
Loading...
Searching...
No Matches
IOVDbMetaDataTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef IOVDBMETADATATOOLS_IOVDBMETADATATOOL_H
6#define IOVDBMETADATATOOLS_IOVDBMETADATATOOL_H
7
19
21#include "GaudiKernel/ServiceHandle.h"
22#include "GaudiKernel/IIncidentListener.h"
24
25#include <string>
26#include <shared_mutex>
27
28class StoreGateSvc;
30
38
39class IOVDbMetaDataTool : public extends<AthAlgTool,
40 IIncidentListener, IIOVDbMetaDataTool>
41{
42public:
43 // Constructor
44 IOVDbMetaDataTool(const std::string& type,
45 const std::string& name,
46 const IInterface* parent);
47 // Standard Destructor
48 virtual ~IOVDbMetaDataTool();
49
51 virtual StatusCode initialize() override;
52
54 virtual StatusCode finalize() override;
55
57 virtual StatusCode beginInputFile(const SG::SourceID&) override;
58
60 virtual StatusCode endInputFile(const SG::SourceID&) override;
61
63 virtual StatusCode metaDataStop() override;
64
66 virtual void handle(const Incident& incident) override;
67
69 virtual StatusCode registerFolder(const std::string& folderName,
70 const std::string& folderDescription) const override;
71
74 virtual StatusCode registerFolder(const std::string& folderName) const override;
75
78 virtual StatusCode addPayload(const std::string& folderName,
79 CondAttrListCollection* payload) const override;
80
87 virtual StatusCode processInputFileMetaData(const std::string& fileName) override;
88
89 virtual IOVMetaDataContainer* findMetaDataContainer(const std::string& folderName) const override final;
90
91 // ILockableTool API implementation
92 virtual void lock_shared() const override final { m_mutex.lock_shared(); }
93 virtual void unlock_shared() const override final { m_mutex.unlock_shared(); }
94
95private:
96
98 IOVMetaDataContainer* getMetaDataContainer(const std::string& folderName,
99 const std::string& folderDescription) const;
100
103
105 StatusCode overrideIOV (CondAttrListCollection*& coll) const;
106
109 StatusCode modifyPayload (const std::string& folderName,
110 CondAttrListCollection*& payload) const;
111
114
117
123
124 // Flag to check whether we need to override run number for MC
125 // events in incoming file meta data. This is needed for example
126 // for incoming simulation or digitization parameters.
129
130 // Values for changing run number
131 unsigned int m_newRunNumber;
132 unsigned int m_oldRunNumber;
133
134 unsigned int m_minRunNumber;
135 unsigned int m_maxRunNumber;
136
137 // Files already processed, maintain a set
138 std::set<std::string> m_filesProcessed;
139
140 UnsignedIntegerArrayProperty m_minMaxRunNumbers{this, "MinMaxRunNumbers", {}, "Min/max run numbers for overriding meta data IOV"};
141 StringArrayProperty m_foldersToBeModified{this, "FoldersToBeModified", {"/Simulation/Parameters"}};
142 StringArrayProperty m_attributesToBeRemoved{this, "AttributesToBeRemoved", {"RandomSeedOffset"}};
144
145 // Property for direct payload registration without intermediate files
146 // Format: flat map with "folder:key" -> "value"
147 // Special keys: "folder:beginRun" and "folder:endRun" specify IOV range
148 Gaudi::Property<std::map<std::string, std::string>> m_payloads{
149 this, "Payloads", {}, "Direct payload registration (format: {folder:key: value})"};
150
151 // Folders to serialize to ByteStream metadata
152 Gaudi::Property<std::vector<std::string>> m_foldersToSerializeToBSMetadata{
153 this, "FoldersToSerializeToBSMetadata", {},
154 "List of folder names to serialize to ByteStream metadata as JSON"};
155
156 // mutex for R/W locking of the entire tool (and supposedly all metadata objects it works with)
157 mutable std::shared_mutex m_mutex;
158};
159
160#endif // IOVDBMETADATATOOLS_IOVDBMETADATATOOL_H
161
162
This is an interface to a tool used to manage the IOV Meta Data for a given object in the MetaData St...
This class is a collection of AttributeLists where each one is associated with a channel number.
virtual StatusCode processInputFileMetaData(const std::string &fileName) override
Explicit call to process IOV meta data from the input meta data store, transferring it to the main me...
IOVDbMetaDataTool(const std::string &type, const std::string &name, const IInterface *parent)
StoreGateSvc_t m_inputStore
virtual StatusCode metaDataStop() override
Function called when the tool should write out its metadata.
virtual StatusCode endInputFile(const SG::SourceID &) override
Function called when the currently open input file got completely processed.
StringArrayProperty m_foldersToBeModified
unsigned int m_minRunNumber
std::string serializeContainerToJSON(const IOVMetaDataContainer *container) const
Serialize IOVMetaDataContainer to JSON format for ByteStream metadata.
virtual void handle(const Incident &incident) override
Incident service handle listening for BeginInputFile and EndInputFile.
StatusCode overrideIOV(CondAttrListCollection *&coll) const
override IOV with new run number
StatusCode serializeIOVMetadataToBSMetadata()
Serialize IOV metadata to ByteStream metadata (called from processInputFileMetaData)
std::set< std::string > m_filesProcessed
StoreGateSvc_t m_condStore
virtual StatusCode finalize() override
Finalize AlgTool.
virtual StatusCode addPayload(const std::string &folderName, CondAttrListCollection *payload) const override
Add an IOV and Payload for a particular folder - replaces payloads if there is an IOV overlap.
unsigned int m_maxRunNumber
ServiceHandle< StoreGateSvc > StoreGateSvc_t
Handles to the meta data stores.
IOVMetaDataContainer * getMetaDataContainer(const std::string &folderName, const std::string &folderDescription) const
return meta data container from the meta data store
UnsignedIntegerArrayProperty m_minMaxRunNumbers
unsigned int m_oldRunNumber
StoreGateSvc_t m_metaDataStore
virtual IOVMetaDataContainer * findMetaDataContainer(const std::string &folderName) const override final
virtual StatusCode beginInputFile(const SG::SourceID &) override
Function called when a new input file is opened.
virtual StatusCode initialize() override
Initialize AlgTool.
Gaudi::Property< std::map< std::string, std::string > > m_payloads
std::shared_mutex m_mutex
unsigned int m_newRunNumber
virtual StatusCode registerFolder(const std::string &folderName, const std::string &folderDescription) const override
Register folder in the IOV Db MetaData - done once at initialize.
virtual void unlock_shared() const override final
void checkOverrideRunNumber()
check if we should override the run number in the incoming meta data
Gaudi::Property< std::vector< std::string > > m_foldersToSerializeToBSMetadata
virtual void lock_shared() const override final
StatusCode modifyPayload(const std::string &folderName, CondAttrListCollection *&payload) const
Modify a Payload for a particular folder - replaces one of the internal attributes.
StringArrayProperty m_attributesToBeRemoved
This class is a container for conditions data.
The Athena Transient Store API.