1 #ifndef artdaq_ArtModules_InputUtilities_hh
2 #define artdaq_ArtModules_InputUtilities_hh
4 #include "TRACE/tracemf.h"
7 #include "canvas/Utilities/Exception.h"
9 #include <TBufferFile.h>
17 #define TLVL_READOBJANY 32
18 #define TLVL_PROCESSHISTORYID 33
19 #define TLVL_PROCESSMAP 34
31 T*
ReadObjectAny(
const std::unique_ptr<TBufferFile>& infile,
const std::string& className,
const std::string& callerName)
33 static TClass* tclassPtr = TClass::GetClass(className.c_str());
35 if (tclassPtr ==
nullptr)
37 throw art::Exception(art::errors::DictionaryNotFound) << callerName <<
" call to ReadObjectAny: "
38 "Could not get TClass for "
51 T* ptr =
reinterpret_cast<T*
>(infile->ReadObjectAny(tclassPtr));
52 TLOG(TLVL_READOBJANY,
"InputUtilities") <<
"ReadObjectAny: Got object of class " << className <<
", located at " <<
static_cast<void*
>(ptr) <<
" caller:" << callerName;
66 if (object->processHistoryID().isValid())
70 TLOG(TLVL_PROCESSHISTORYID,
"InputUtilities") << label <<
": "
71 <<
"ProcessHistoryID: " <<
object->processHistoryID();
75 TLOG(TLVL_PROCESSHISTORYID,
"InputUtilities") << label <<
": "
76 <<
"ProcessHistoryID: 'INVALID'";
89 TLOG(TLVL_PROCESSMAP,
"InputUtilities") <<
"Got " << description;
91 TLOG(TLVL_PROCESSMAP,
"InputUtilities") <<
"Dumping " << description <<
"...";
92 TLOG(TLVL_PROCESSMAP,
"InputUtilities") <<
"Size: " << mappable.size();
93 for (
auto I = mappable.begin(), E = mappable.end(); I != E; ++I)
95 std::ostringstream OS;
97 TLOG(TLVL_PROCESSMAP,
"InputUtilities") << description <<
": id: '" << OS.str() <<
"'";
99 TLOG(TLVL_PROCESSMAP,
"InputUtilities") << description <<
": data.size(): " << I->second.data().size();
100 I->second.data().back().id().print(OS);
102 TLOG(TLVL_PROCESSMAP,
"InputUtilities") << description <<
": data.back().id(): '" << OS.str() <<
"'";
void printProcessHistoryID(const std::string &label, const T &object)
Print the processHistoryID from the object.
void printProcessMap(const T &mappable, const std::string &description)
Print data from a map-like class.
T * ReadObjectAny(const std::unique_ptr< TBufferFile > &infile, const std::string &className, const std::string &callerName)
ReadObjectAny reads data from a TBufferFile and casts it to the given type.