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/ProcessHistoryRegistry.h"
13 #include "canvas/Persistency/Common/EDProduct.h"
14 #include "canvas/Persistency/Common/Wrapper.h"
15 #include "canvas/Persistency/Provenance/BranchDescription.h"
16 #include "canvas/Persistency/Provenance/BranchKey.h"
17 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
18 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
19 #include "canvas/Persistency/Provenance/ProcessHistory.h"
20 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
21 #include "canvas/Persistency/Provenance/ProductList.h"
22 #include "canvas/Persistency/Provenance/ProductProvenance.h"
23 #include "canvas/Utilities/DebugMacros.h"
25 #include <TBufferFile.h>
27 #define TLVL_READOBJANY 32
28 #define TLVL_PROCESSHISTORYID 33
29 #define TLVL_PROCESSMAP 34
47 T*
ReadObjectAny(
const std::unique_ptr<TBufferFile>& infile,
const std::string& className,
const std::string& callerName)
49 static TClass* tclassPtr = TClass::GetClass(className.c_str());
51 if (tclassPtr ==
nullptr)
53 throw art::Exception(art::errors::DictionaryNotFound) << callerName <<
" call to ReadObjectAny: "
54 "Could not get TClass for "
67 T* ptr =
reinterpret_cast<T*
>(infile->ReadObjectAny(tclassPtr));
68 TLOG(TLVL_READOBJANY,
"InputUtilities") <<
"ReadObjectAny: Got object of class " << className <<
", located at " <<
static_cast<void*
>(ptr) <<
" caller:" << callerName;
82 if (object->processHistoryID().isValid())
86 TLOG(TLVL_PROCESSHISTORYID,
"InputUtilities") << label <<
": "
87 <<
"ProcessHistoryID: " <<
object->processHistoryID();
91 TLOG(TLVL_PROCESSHISTORYID,
"InputUtilities") << label <<
": "
92 <<
"ProcessHistoryID: 'INVALID'";
105 TLOG(TLVL_PROCESSMAP,
"InputUtilities") <<
"Got " << description;
107 TLOG(TLVL_PROCESSMAP,
"InputUtilities") <<
"Dumping " << description <<
"...";
108 TLOG(TLVL_PROCESSMAP,
"InputUtilities") <<
"Size: " << mappable.size();
109 for (
auto I = mappable.begin(), E = mappable.end(); I != E; ++I)
111 std::ostringstream OS;
113 TLOG(TLVL_PROCESSMAP,
"InputUtilities") << description <<
": id: '" << OS.str() <<
"'";
115 TLOG(TLVL_PROCESSMAP,
"InputUtilities") << description <<
": data.size(): " << I->second.data().size();
116 I->second.data().back().id().print(OS);
118 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.