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