Belle II Software prerelease-11-00-00d
PruneDataStoreModule.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/core/Module.h>
12#include <framework/datastore/DataStore.h>
13#include <string>
14#include <vector>
15#include <regex>
16
17namespace Belle2 {
35
36 public:
37
40
42 virtual ~PruneDataStoreModule() = default;
43
45 void initialize() override;
46
48 void event() override;
49
50 protected:
51
55 std::regex compileAndCatch(std::string& regexString) const;
56
58 std::vector<std::string> m_matchEntries;
59
65 std::vector<std::string> m_keepEntriesImplicit = {{ "EventMetaData" }};
66
72
74 std::vector < std::regex > m_compiled_regex;
75
77 std::vector < std::regex > m_compiled_regex_implicit;
78
83
88 std::vector<DataStore::StoreEntry*> m_entriesToPrune;
89
91 std::vector<const std::string*> m_entriesToKeep;
92
94 bool m_cacheValid{false};
95
96 };
97
98} // end namespace Belle2
std::map< std::string, StoreEntry > StoreEntryMap
Map for StoreEntries.
Definition DataStore.h:87
Module()
Constructor.
Definition Module.cc:30
void initialize() override
Prepare regex checks.
bool m_cacheValid
Whether the caches above have already been filled for this run.
void event() override
Prune datastore.
std::vector< std::string > m_keepEntriesImplicit
Branches to always keep because the are required by the framework to properly work with the datastore...
std::vector< const std::string * > m_entriesToKeep
Names of the DataStore entries which are kept, only used for debug output.
std::vector< std::regex > m_compiled_regex_implicit
Caching the regex expression for the keep check.
bool m_keepMatchedEntries
If true, all entries matched by the RegEx expression are kept.
virtual ~PruneDataStoreModule()=default
Virtual Constructor to prevent memory leaks.
std::vector< std::regex > m_compiled_regex
Caching the regex expression for the keep check.
std::vector< std::string > m_matchEntries
Storing the option of branches to keep.
void updateCache(DataStore::StoreEntryMap &storemap)
Evaluate the regular expressions for all entries of the given DataStore map and fill the m_entriesToP...
std::regex compileAndCatch(std::string &regexString) const
Compile a regex expression and catch the exception if the regex string is not valid.
std::vector< DataStore::StoreEntry * > m_entriesToPrune
DataStore entries which have to be pruned.
Abstract base class for different kinds of events.