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>
31 PrintCollectionsModule::PrintCollectionsModule()
33 setDescription(
"Prints the contents of the DataStore in an event, listing all objects and arrays (including size).");
35 addParam(
"printForEvent", m_printForEvent,
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.",
40 PrintCollectionsModule::~PrintCollectionsModule() =
default;
42 void PrintCollectionsModule::initialize()
47 void PrintCollectionsModule::event()
52 if (m_printForEvent < 0) {
59 else if ((m_printForEvent > 0) && ((
unsigned int)m_printForEvent != eventMetaDataPtr->getEvent()))
62 B2INFO(
"============================================================================");
63 B2INFO(
"DataStore collections in event " << eventMetaDataPtr->getEvent());
64 B2INFO(
"============================================================================");
65 B2INFO(boost::format(
"Type %|20t| Name %|47t| #Entries <Event>"));
66 printCollections(DataStore::c_Event);
67 B2INFO(
"----------------------------------------------------------------------------");
68 B2INFO(boost::format(
"Type %|20t| Name %|47t| #Entries <Persistent>"));
69 printCollections(DataStore::c_Persistent);
70 B2INFO(
"============================================================================");
75 std::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);
EDurability
Durability types.
std::map< std::string, StoreEntry > StoreEntryMap
Map for StoreEntries.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Type-safe access to single objects in the data store.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.