9#include <framework/modules/core/PrintCollectionsModule.h>
11#include <framework/datastore/StoreObjPtr.h>
12#include <framework/dataobjects/EventMetaData.h>
15#include <TClonesArray.h>
17#include <boost/format.hpp>
33 setDescription(
"Prints the contents of the DataStore in an event, listing all objects and arrays (including size).");
36 "Print the collections only for a specific event number. If set to -1 (default) only the collections of the first event will be printed, if set to 0, the collections of all events will be printed, which might be a lot of output.",
62 B2INFO(
"============================================================================");
63 B2INFO(
"DataStore collections in event " << eventMetaDataPtr->getEvent());
64 B2INFO(
"============================================================================");
65 B2INFO(boost::format(
"Type %|20t| Name %|47t| #Entries <Event>"));
67 B2INFO(
"----------------------------------------------------------------------------");
68 B2INFO(boost::format(
"Type %|20t| Name %|47t| #Entries <Persistent>"));
70 B2INFO(
"============================================================================");
75std::string shorten(std::string className)
77 if (className.compare(0, 8,
"Belle2::") == 0) {
79 return className.substr(8);
95 for (
auto iter = map.begin(); iter != map.end(); ++iter) {
96 if (iter->second.isArray)
98 const TObject* currCol = iter->second.ptr;
100 if (currCol !=
nullptr) {
101 B2INFO(boost::format(
"%1% %|20t| %2%") % shorten(currCol->ClassName()) % iter->first);
109 for (
auto iter = map.begin(); iter != map.end(); ++iter) {
110 if (!iter->second.isArray)
112 const TClonesArray* currCol =
dynamic_cast<TClonesArray*
>(iter->second.ptr);
115 if (currCol !=
nullptr)
116 entries = currCol->GetEntriesFast();
118 std::string type = shorten(iter->second.objClass->GetName());
120 B2INFO(boost::format(
"%1%[] %|20t| %2% %|47t| %3%") % type % iter->first % entries);
StoreEntryMap & getStoreEntryMap(EDurability durability)
Get a reference to the object/array map.
EDurability
Durability types.
@ c_Persistent
Object is available during entire execution time.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
static DataStore & Instance()
Instance of singleton Store.
std::map< std::string, StoreEntry > StoreEntryMap
Map for StoreEntries.
void setDescription(const std::string &description)
Sets the description of the module.
bool m_firstEvent
boolean to check if the current event is the first encountered
virtual void initialize() override
initialization.
virtual void event() override
Prints information for each collection in the DataStore.
virtual ~PrintCollectionsModule()
Destructor of the module.
int m_printForEvent
Parameter to set the event number for which the collections should be printed.
void printCollections(DataStore::EDurability durability)
Prints information for each collection in the DataStore using the specified durability.
PrintCollectionsModule()
Constructor of the module.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Type-safe access to single objects in the data store.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.