1 #ifndef artdaq_ArtModules_InputUtilities_hh
2 #define artdaq_ArtModules_InputUtilities_hh
4 #include "art/Framework/Core/FileBlock.h"
5 #include "art/Framework/Core/InputSourceMacros.h"
6 #include "art/Framework/Core/ProductRegistryHelper.h"
7 #include "art/Framework/IO/Sources/Source.h"
8 #include "art/Framework/IO/Sources/SourceHelper.h"
9 #include "art/Framework/IO/Sources/SourceTraits.h"
10 #include "art/Framework/Services/Registry/ServiceHandle.h"
11 #include "art/Persistency/Provenance/BranchIDListHelper.h"
12 #include "art/Persistency/Provenance/BranchIDListRegistry.h"
13 #include "art/Persistency/Provenance/MasterProductRegistry.h"
14 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
15 #include "art/Persistency/Provenance/ProductMetaData.h"
17 #include "canvas/Persistency/Common/EDProduct.h"
18 #include "canvas/Persistency/Common/Wrapper.h"
19 #include "canvas/Persistency/Provenance/BranchDescription.h"
20 #include "canvas/Persistency/Provenance/BranchIDList.h"
21 #include "canvas/Persistency/Provenance/BranchKey.h"
22 #include "canvas/Persistency/Provenance/History.h"
23 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
24 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
25 #include "canvas/Persistency/Provenance/ProcessHistory.h"
26 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
27 #include "canvas/Persistency/Provenance/ProductList.h"
28 #include "canvas/Persistency/Provenance/ProductProvenance.h"
29 #include "canvas/Utilities/DebugMacros.h"
31 #include "TBufferFile.h"
56 T*
ReadObjectAny(
const std::unique_ptr<TBufferFile>& infile,
const std::string& className,
const std::string& callerName)
58 static TClass* tclassPtr = TClass::GetClass(className.c_str());
60 if (tclassPtr ==
nullptr)
62 throw art::Exception(art::errors::DictionaryNotFound) <<
63 callerName <<
" call to ReadObjectAny: "
64 "Could not get TClass for " << className <<
"!";
76 T* ptr =
reinterpret_cast<T*
>(infile->ReadObjectAny(tclassPtr));
78 TLOG_DEBUG(callerName) <<
"ReadObjectAny: Got object of class " << className <<
79 ", located at " <<
static_cast<void*
>(ptr);
96 if (art::debugit() >= 1)
98 if (object->processHistoryID().isValid())
100 std::ostringstream OS;
101 object->processHistoryID().print(OS);
103 TLOG_DEBUG(
"printProcessHistoryID") << label <<
": "
104 <<
"ProcessHistoryID: '"
105 << OS.str() <<
"'\n";
111 TLOG_DEBUG(
"printProcessHistoryID") << label <<
": "
112 <<
"ProcessHistoryID: 'INVALID'\n";
124 template <
typename T>
130 TLOG_DEBUG(
"printProcessMap") <<
"Got " << description <<
"\n";
133 if (art::debugit() >= 1)
136 TLOG_DEBUG(
"printProcessMap") <<
"Dumping " << description <<
"...\n";
137 TLOG_DEBUG(
"printProcessMap") <<
"Size: "
138 << (
unsigned long) mappable.size() <<
'\n';
140 for (
auto I = mappable.begin(), E = mappable.end(); I != E; ++I)
142 std::ostringstream OS;
145 TLOG_DEBUG(
"printProcessMap") << description <<
": id: '" << OS.str() <<
"'\n";
149 TLOG_DEBUG(
"printProcessMap") << description <<
": data.size(): "
150 << I->second.data().size() <<
'\n';
152 I->second.data().back().id().print(OS);
155 TLOG_DEBUG(
"printProcessMap") << description <<
": data.back().id(): '"
156 << OS.str() <<
"'\n";
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.