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 #include "art/Persistency/Provenance/BranchIDListHelper.h"
00012 #include "art/Persistency/Provenance/BranchIDListRegistry.h"
00013 #include "art/Persistency/Provenance/MasterProductRegistry.h"
00014 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
00015 #include "art/Persistency/Provenance/ProductMetaData.h"
00016
00017 #include "canvas/Persistency/Common/EDProduct.h"
00018 #include "canvas/Persistency/Common/Wrapper.h"
00019 #include "canvas/Persistency/Provenance/BranchDescription.h"
00020 #include "canvas/Persistency/Provenance/BranchIDList.h"
00021 #include "canvas/Persistency/Provenance/BranchKey.h"
00022 #include "canvas/Persistency/Provenance/History.h"
00023 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
00024 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
00025 #include "canvas/Persistency/Provenance/ProcessHistory.h"
00026 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
00027 #include "canvas/Persistency/Provenance/ProductList.h"
00028 #include "canvas/Persistency/Provenance/ProductProvenance.h"
00029 #include "canvas/Utilities/DebugMacros.h"
00030
00031 #include "TBufferFile.h"
00032
00033 #include <memory>
00034 #include <string>
00035 #include <iostream>
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 namespace art
00046 {
00055 template <typename T>
00056 T* ReadObjectAny(const std::unique_ptr<TBufferFile>& infile, const std::string& className, const std::string& callerName)
00057 {
00058 static TClass* tclassPtr = TClass::GetClass(className.c_str());
00059
00060 if (tclassPtr == nullptr)
00061 {
00062 throw art::Exception(art::errors::DictionaryNotFound) <<
00063 callerName << " call to ReadObjectAny: "
00064 "Could not get TClass for " << className << "!";
00065 }
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 T* ptr = reinterpret_cast<T*>(infile->ReadObjectAny(tclassPtr));
00077 #ifdef LOGDEBUG
00078 TLOG_DEBUG(callerName) << "ReadObjectAny: Got object of class " << className <<
00079 ", located at " << static_cast<void*>(ptr);
00080 #endif
00081
00082 return ptr;
00083 }
00084
00091 template <typename T>
00092 void printProcessHistoryID(const std::string& label, const T& object)
00093 {
00094 (void)label;
00095
00096 if (art::debugit() >= 1)
00097 {
00098 if (object->processHistoryID().isValid())
00099 {
00100 std::ostringstream OS;
00101 object->processHistoryID().print(OS);
00102 #ifdef LOGDEBUG
00103 TLOG_DEBUG("printProcessHistoryID") << label << ": "
00104 << "ProcessHistoryID: '"
00105 << OS.str() << "'\n";
00106 #endif
00107 }
00108 else
00109 {
00110 #ifdef LOGDEBUG
00111 TLOG_DEBUG("printProcessHistoryID") << label << ": "
00112 << "ProcessHistoryID: 'INVALID'\n";
00113 #endif
00114 }
00115 }
00116 }
00117
00124 template <typename T>
00125 void printProcessMap(const T& mappable, const std::string description)
00126 {
00127 (void) description;
00128
00129 #ifdef LOGDEBUG
00130 TLOG_DEBUG("printProcessMap") << "Got " << description << "\n";
00131 #endif
00132
00133 if (art::debugit() >= 1)
00134 {
00135 #ifdef LOGDEBUG
00136 TLOG_DEBUG("printProcessMap") << "Dumping " << description << "...\n";
00137 TLOG_DEBUG("printProcessMap") << "Size: "
00138 << (unsigned long) mappable.size() << '\n';
00139 #endif
00140 for (auto I = mappable.begin(), E = mappable.end(); I != E; ++I)
00141 {
00142 std::ostringstream OS;
00143 I->first.print(OS);
00144 #ifdef LOGDEBUG
00145 TLOG_DEBUG("printProcessMap") << description << ": id: '" << OS.str() << "'\n";
00146 #endif
00147 OS.str("");
00148 #ifdef LOGDEBUG
00149 TLOG_DEBUG("printProcessMap") << description << ": data.size(): "
00150 << I->second.data().size() << '\n';
00151 #endif
00152 I->second.data().back().id().print(OS);
00153
00154 #ifdef LOGDEBUG
00155 TLOG_DEBUG("printProcessMap") << description << ": data.back().id(): '"
00156 << OS.str() << "'\n";
00157 #endif
00158 }
00159 }
00160 }
00161 }
00162
00163
00164 #endif