8 #ifndef ROOTPERSISTENCESERVICE_H_ 9 #define ROOTPERSISTENCESERVICE_H_ 21 #include <unordered_map> 32 bool BookEventObject(
const std::string &objName,
const std::string &objStore)
override;
33 bool BookPassObject(
const std::string &objName,
const std::string &objStore)
override;
34 bool BookGlobalObject(
const std::string &objName,
const std::string &objStore)
override;
70 std::unique_ptr<PersistenceService>
Copy(
const std::string &name,
const std::string &output)
override;
105 : dataStoreName(storeName), dataStore(nullptr), isGlob(false), isMatched(false), isAlias(false),
106 aliasToBeChecked(true), nameForEvBranch(nullptr) {}
123 :
ObjInfo(storeName), outputBranch(nullptr), flag(true), object(nullptr), defaultObject(nullptr),
124 objClass(nullptr), prevObject(nullptr), aliasedObjsBook(new
EvObjectsBook) {}
127 :
ObjInfo(otherObjInfo), outputBranch(otherObjInfo.outputBranch), flag(otherObjInfo.flag),
128 object(otherObjInfo.object), defaultObject(otherObjInfo.defaultObject), objClass(otherObjInfo.objClass),
129 prevObject(otherObjInfo.prevObject), aliasedObjsBook(new
EvObjectsBook(*(otherObjInfo.aliasedObjsBook))) {}
155 template <
typename T>
162 template <
typename T>
165 const std::string routineName(
"RootPersistenceService::_ResolveGlobAndBook");
166 typename std::remove_reference<decltype(objBook)>::type newBook;
167 for (
auto &objInfoElem : objBook) {
168 const std::string &objName = objInfoElem.first;
169 T &objInfo = objInfoElem.second;
170 if (!(objInfo.dataStore)) {
174 objInfo.dataStore = dsManager->GetGlobalDataStore(objInfo.dataStoreName);
176 objInfo.dataStore = dsManager->GetEventDataStore(objInfo.dataStoreName);
179 COUT(
ERROR) << objCategory <<
" object store " << objInfo.dataStoreName <<
" not found." <<
ENDL;
184 if (objInfo.isGlob) {
188 auto storeKnownObjs = objInfo.dataStore->GetKnownObjects();
189 for (
auto knownObj : storeKnownObjs) {
190 if (std::regex_match(knownObj.name, match, regEx)) {
191 objInfo.isMatched =
true;
192 auto insertionResult = newBook.insert(std::pair<std::string, T>(knownObj.name, objInfo));
193 if (!(insertionResult.second)) {
194 COUT(
ERROR) <<
"Can't insert the " << std::nouppercase << objCategory <<
" object name " << knownObj.name
195 <<
" matching the booked glob " << objName <<
" among the booked objects" <<
ENDL;
198 insertionResult.first->second.isGlob =
false;
199 insertionResult.first->second.isAlias =
false;
200 insertionResult.first->second.aliasToBeChecked =
false;
202 for (
auto &alias : knownObj.aliases) {
203 if (std::regex_match(alias, match, regEx)) {
204 objInfo.isMatched =
true;
205 auto insertionResult = newBook.insert(std::pair<std::string, T>(alias, objInfo));
206 if (!(insertionResult.second)) {
207 COUT(
ERROR) <<
"Can't insert the " << objCategory <<
" object alias " << alias
208 <<
" matching the booked glob " << objName <<
" among the booked objects" <<
ENDL;
211 insertionResult.first->second.isGlob =
false;
212 insertionResult.first->second.isAlias =
true;
213 insertionResult.first->second.aliasToBeChecked =
false;
221 auto insertionResult = newBook.insert(objInfoElem);
222 if (!(insertionResult.second)) {
223 COUT(
ERROR) <<
"Can't insert the " << objCategory <<
" object " << objInfoElem.first
224 <<
" among the booked objects" <<
ENDL;
229 objBook.swap(newBook);
bool BookEventObject(const std::string &objName, const std::string &objStore) override
Books an event object for persistence.
Definition: RootPersistenceService.cpp:55
bool BookEventObjectImpl(const std::string &objName, const std::string &objStore, EvObjectsBook &book)
Definition: RootPersistenceService.cpp:58
std::set< std::string > actualNames
Definition: RootPersistenceService.h:102
bool _EndOfEventForEventObject(const std::string &objName, EvObjInfo &objInfo)
Definition: RootPersistenceService.cpp:221
std::string dataStoreName
Definition: RootPersistenceService.h:94
bool isGlob
Definition: RootPersistenceService.h:96
bool _SaveGlobalObject(const std::string &objName, GlobObjInfo &objInfo)
Definition: RootPersistenceService.cpp:585
bool BookPassObject(const std::string &objName, const std::string &objStore) override
Definition: RootPersistenceService.cpp:75
Definition: RootPersistenceService.h:137
std::vector< BookedObject > GetBookedGlobalObjects() override
Gets the list of booked global objects.
Definition: RootPersistenceService.cpp:109
Definition: PersistenceService.h:20
void * prevObject
Definition: RootPersistenceService.h:118
bool isMatched
Definition: RootPersistenceService.h:97
A smart pointer not owning the wrapped object.
Definition: ObserverPtr.h:28
#define COUT(level)
Definition: SmartLog.h:88
observer_ptr< TTree > GetEventTree()
Getter method for the event tree.
Definition: RootPersistenceService.h:87
Base struct for Root output.
Definition: RootOutputStruct.h:24
bool EndOfProcessing() override
Definition: RootPersistenceService.cpp:500
bool Connect() override
Definition: RootPersistenceService.cpp:28
observer_ptr< TFile > GetOutputFile()
Getter method for the output file.
Definition: RootPersistenceService.h:79
Definition: RootPersistenceService.h:93
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
std::string nameForThisEv
Definition: RootPersistenceService.h:101
TBranch * outputBranch
Definition: RootPersistenceService.h:113
EvObjectsBook _eventBook
Definition: RootPersistenceService.h:132
Exception for unknown object.
Definition: RetrievalExceptions.h:39
EvObjInfo(const EvObjInfo &otherObjInfo)
Definition: RootPersistenceService.h:126
bool EndOfEvent() override
Save event objects on persistence medium.
Definition: RootPersistenceService.cpp:120
EvObjectsBook _newEventAliasesBook
Definition: RootPersistenceService.h:132
#define ENDL
Definition: SmartLog.h:117
bool BookGlobalObject(const std::string &objName, const std::string &objStore) override
Definition: RootPersistenceService.cpp:77
void * object
Definition: RootPersistenceService.h:115
bool _ResolveGlobAndBook(std::unordered_map< std::string, T > &objBook, ObjectCategory objCategory)
Definition: RootPersistenceService.h:163
ObjInfo(const std::string &storeName)
Definition: RootPersistenceService.h:104
Objects with values defined on a per-pass basis.
std::vector< BookedObject > GetBookedPassObjects() override
Gets the list of booked pass objects.
Definition: RootPersistenceService.cpp:107
ObjectCategory
Category of objects.
Definition: ObjectCategory.h:17
bool BeginOfProcessing() override
Definition: RootPersistenceService.cpp:487
std::string RegexFromGlob(const std::string &str)
Build a regex starting from a glob expression.
Definition: StringUtils.cpp:152
std::unique_ptr< PersistenceService > Copy(const std::string &name, const std::string &output) override
Copies the persistence service.
Definition: RootPersistenceService.cpp:643
observer_ptr< DataStoreManager > GetDataStoreManager()
Getter for the Data store manager.
Definition: DataStoreUser.h:42
StorePtr dataStore
Definition: RootPersistenceService.h:95
bool aliasToBeChecked
Definition: RootPersistenceService.h:99
bool BeginOfPass() override
Definition: RootPersistenceService.cpp:484
GlobObjectsBook _newGlobalAliasesBook
Definition: RootPersistenceService.h:143
void * defaultObject
Definition: RootPersistenceService.h:116
TTree * _eventTree
Definition: RootPersistenceService.h:153
GlobObjInfo(const std::string &storeName)
Definition: RootPersistenceService.h:140
bool flag
Definition: RootPersistenceService.h:114
TBranch * nameForEvBranch
Definition: RootPersistenceService.h:100
bool BookGlobalObjectImpl(const std::string &objName, const std::string &objStore, GlobObjectsBook &book)
Definition: RootPersistenceService.cpp:81
EvObjInfo(const std::string &storeName)
Definition: RootPersistenceService.h:122
bool saved
Definition: RootPersistenceService.h:138
GlobObjectsBook _globalBook
Definition: RootPersistenceService.h:143
bool EndOfPass() override
Definition: RootPersistenceService.cpp:485
Definition: RootPersistenceService.h:112
bool _EndOfEventForGlobalObject(const std::string &objName, GlobObjInfo &objInfo)
Definition: RootPersistenceService.cpp:420
TClass * objClass
Definition: RootPersistenceService.h:117
TFile * _outputFile
Definition: RootPersistenceService.h:152
bool isAlias
Definition: RootPersistenceService.h:98
std::vector< BookedObject > GetBookedEventObjects() override
Gets the list of booked event objects.
Definition: RootPersistenceService.cpp:98
bool BeginOfEvent() override
Definition: RootPersistenceService.cpp:118
RootPersistenceService(const std::string &name, const std::string &output)
Definition: RootPersistenceService.cpp:25
bool Disconnect() override
Definition: RootPersistenceService.cpp:48
std::unordered_map< std::string, GlobObjInfo > GlobObjectsBook
Definition: RootPersistenceService.h:142
Definition: RootPersistenceService.h:25
Aliased object is an alias.
std::unordered_map< std::string, EvObjInfo > EvObjectsBook
Definition: RootPersistenceService.h:111
std::unique_ptr< EvObjectsBook > aliasedObjsBook
Definition: RootPersistenceService.h:120