00001 #ifndef artdaq_ArtModules_InputUtilities_hh
00002 #define artdaq_ArtModules_InputUtilities_hh
00003
00004 #include "art/Framework/Core/FileBlock.h"
00005 #include "art/Framework/Core/InputSourceMacros.h"
00006 #include "art/Framework/Core/ProductRegistryHelper.h"
00007 #include "art/Framework/IO/Sources/Source.h"
00008 #include "art/Framework/IO/Sources/SourceHelper.h"
00009 #include "art/Framework/IO/Sources/SourceTraits.h"
00010 #include "art/Framework/Services/Registry/ServiceHandle.h"
00011 #if ART_HEX_VERSION < 0x20703
00012 #include "art/Persistency/Provenance/BranchIDListHelper.h"
00013 #endif
00014 #include "art/Persistency/Provenance/BranchIDListRegistry.h"
00015 #include "art/Persistency/Provenance/MasterProductRegistry.h"
00016 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
00017 #include "art/Persistency/Provenance/ProductMetaData.h"
00018
00019 #include "canvas/Persistency/Common/EDProduct.h"
00020 #include "canvas/Persistency/Common/Wrapper.h"
00021 #include "canvas/Persistency/Provenance/BranchDescription.h"
00022 #include "canvas/Persistency/Provenance/BranchIDList.h"
00023 #include "canvas/Persistency/Provenance/BranchKey.h"
00024 #include "canvas/Persistency/Provenance/History.h"
00025 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
00026 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
00027 #include "canvas/Persistency/Provenance/ProcessHistory.h"
00028 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
00029 #include "canvas/Persistency/Provenance/ProductList.h"
00030 #include "canvas/Persistency/Provenance/ProductProvenance.h"
00031 #include "canvas/Utilities/DebugMacros.h"
00032
00033 #include <TBufferFile.h>
00034
00035 #include "tracemf.h"
00036 #include <memory>
00037 #include <string>
00038 #include <iostream>
00039
00040
00041 namespace art
00042 {
00051 template <typename T>
00052 T* ReadObjectAny(const std::unique_ptr<TBufferFile>& infile, const std::string& className, const std::string& callerName)
00053 {
00054 static TClass* tclassPtr = TClass::GetClass(className.c_str());
00055
00056 if (tclassPtr == nullptr)
00057 {
00058 throw art::Exception(art::errors::DictionaryNotFound) <<
00059 callerName << " call to ReadObjectAny: "
00060 "Could not get TClass for " << className << "!";
00061 }
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 T* ptr = reinterpret_cast<T*>(infile->ReadObjectAny(tclassPtr));
00073 TLOG_ARB(5,"InputUtilities") << "ReadObjectAny: Got object of class " << className <<
00074 ", located at " << static_cast<void*>(ptr) << " caller:" << callerName << TLOG_ENDL;
00075
00076 return ptr;
00077 }
00078
00085 template <typename T>
00086 void printProcessHistoryID(const std::string& label, const T& object)
00087 {
00088 (void)label;
00089
00090 if (art::debugit() >= 1)
00091 {
00092 if (object->processHistoryID().isValid())
00093 {
00094
00095
00096 TLOG_ARB(5,"InputUtilities") << label << ": "
00097 << "ProcessHistoryID: "
00098 << object->processHistoryID() << TLOG_ENDL;
00099 }
00100 else
00101 {
00102 #ifdef LOGDEBUG
00103 TLOG_DEBUG("printProcessHistoryID") << label << ": "
00104 << "ProcessHistoryID: 'INVALID'\n";
00105 #endif
00106 }
00107 }
00108 }
00109
00116 template <typename T>
00117 void printProcessMap(const T& mappable, const std::string description)
00118 {
00119 (void) description;
00120
00121 #ifdef LOGDEBUG
00122 TLOG_DEBUG("printProcessMap") << "Got " << description << "\n";
00123 #endif
00124
00125 if (art::debugit() >= 1)
00126 {
00127 #ifdef LOGDEBUG
00128 TLOG_DEBUG("printProcessMap") << "Dumping " << description << "...\n";
00129 TLOG_DEBUG("printProcessMap") << "Size: "
00130 << (unsigned long) mappable.size() << '\n';
00131 #endif
00132 for (auto I = mappable.begin(), E = mappable.end(); I != E; ++I)
00133 {
00134 std::ostringstream OS;
00135 I->first.print(OS);
00136 #ifdef LOGDEBUG
00137 TLOG_DEBUG("printProcessMap") << description << ": id: '" << OS.str() << "'\n";
00138 #endif
00139 OS.str("");
00140 #ifdef LOGDEBUG
00141 TLOG_DEBUG("printProcessMap") << description << ": data.size(): "
00142 << I->second.data().size() << '\n';
00143 #endif
00144 I->second.data().back().id().print(OS);
00145
00146 #ifdef LOGDEBUG
00147 TLOG_DEBUG("printProcessMap") << description << ": data.back().id(): '"
00148 << OS.str() << "'\n";
00149 #endif
00150 }
00151 }
00152 }
00153 }
00154
00155
00156 #endif