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