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
00036 #define TRACE_NAME "InputUtilities"
00037 #define TLVL_READOBJANY 32
00038 #define TLVL_PROCESSHISTORYID 33
00039 #define TLVL_PROCESSMAP 34
00040
00041 #include "tracemf.h"
00042 #include <memory>
00043 #include <string>
00044 #include <iostream>
00045
00046
00047
00048 namespace art
00049 {
00058 template <typename T>
00059 T* ReadObjectAny(const std::unique_ptr<TBufferFile>& infile, const std::string& className, const std::string& callerName)
00060 {
00061 static TClass* tclassPtr = TClass::GetClass(className.c_str());
00062
00063 if (tclassPtr == nullptr)
00064 {
00065 throw art::Exception(art::errors::DictionaryNotFound) <<
00066 callerName << " call to ReadObjectAny: "
00067 "Could not get TClass for " << className << "!";
00068 }
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 T* ptr = reinterpret_cast<T*>(infile->ReadObjectAny(tclassPtr));
00080 TLOG(TLVL_READOBJANY) << "ReadObjectAny: Got object of class " << className <<
00081 ", located at " << static_cast<void*>(ptr) << " caller:" << callerName << TLOG_ENDL;
00082
00083 return ptr;
00084 }
00085
00092 template <typename T>
00093 void printProcessHistoryID(const std::string& label, const T& object)
00094 {
00095
00096 if (object->processHistoryID().isValid())
00097 {
00098
00099
00100 TLOG(TLVL_PROCESSHISTORYID) << label << ": " << "ProcessHistoryID: " << object->processHistoryID() << TLOG_ENDL;
00101 }
00102 else
00103 {
00104 TLOG(TLVL_PROCESSHISTORYID) << label << ": " << "ProcessHistoryID: 'INVALID'";
00105 }
00106 }
00107
00114 template <typename T>
00115 void printProcessMap(const T& mappable, const std::string description)
00116 {
00117 TLOG(TLVL_PROCESSMAP) << "Got " << description;
00118
00119 TLOG(TLVL_PROCESSMAP) << "Dumping " << description << "...";
00120 TLOG(TLVL_PROCESSMAP) << "Size: " << (unsigned long)mappable.size();
00121 for (auto I = mappable.begin(), E = mappable.end(); I != E; ++I)
00122 {
00123 std::ostringstream OS;
00124 I->first.print(OS);
00125 TLOG(TLVL_PROCESSMAP) << description << ": id: '" << OS.str() << "'";
00126 OS.str("");
00127 TLOG(TLVL_PROCESSMAP) << description << ": data.size(): " << I->second.data().size();
00128 I->second.data().back().id().print(OS);
00129
00130 TLOG(TLVL_PROCESSMAP) << description << ": data.back().id(): '" << OS.str() << "'";
00131 }
00132 }
00133 }
00134
00135
00136 #endif