1 #ifndef art_Framework_IO_Root_RootDAQOutFile_h
2 #define art_Framework_IO_Root_RootDAQOutFile_h
5 #include "art/Framework/Core/Frameworkfwd.h"
6 #include "art/Framework/Core/OutputModule.h"
7 #include "art/Framework/IO/ClosingCriteria.h"
8 #include "art/Framework/IO/FileStatsCollector.h"
9 #include "art/Framework/IO/Root/DropMetaData.h"
10 #include "art/Framework/IO/Root/RootOutputTree.h"
11 #include "art/Framework/IO/Root/detail/DummyProductCache.h"
12 #include "art/Framework/Principal/RangeSetsSupported.h"
13 #include "art/Persistency/Provenance/Selections.h"
14 #include "boost/filesystem.hpp"
15 #include "canvas/Persistency/Provenance/BranchDescription.h"
16 #include "canvas/Persistency/Provenance/BranchType.h"
17 #include "canvas/Persistency/Provenance/FileIndex.h"
18 #include "canvas/Persistency/Provenance/ParameterSetBlob.h"
19 #include "canvas/Persistency/Provenance/ParameterSetMap.h"
20 #include "canvas/Persistency/Provenance/ProductID.h"
21 #include "canvas/Persistency/Provenance/ProductProvenance.h"
22 #include "cetlib/sqlite/Connection.h"
39 class ResultsPrincipal;
44 class SubRunAuxiliary;
46 class ResultsAuxiliary;
53 enum class ClosureRequestMode
59 using RootOutputTreePtrArray =
60 std::array<std::unique_ptr<RootOutputTree>, NumBranchTypes>;
64 BranchDescription
const* branchDescription_{
nullptr};
65 mutable void const* product_{
nullptr};
67 explicit OutputItem(BranchDescription
const* pd)
68 : branchDescription_{pd} {}
73 return branchDescription_->branchName();
79 return *branchDescription_ < *rh.branchDescription_;
83 using OutputItemList = std::set<OutputItem>;
84 using OutputItemListArray = std::array<OutputItemList, NumBranchTypes>;
88 std::string
const& fileName,
89 ClosingCriteria
const& fileSwitchCriteria,
90 int const compressionLevel,
93 int64_t
const saveMemoryObjectThreshold,
94 int64_t
const treeMaxVirtualSize,
97 DropMetaData dropMetaData,
98 bool dropMetaDataForDroppedData,
99 bool fastCloningRequested);
105 void writeOne(EventPrincipal
const&);
106 void writeSubRun(SubRunPrincipal
const&);
107 void writeRun(RunPrincipal
const&);
108 void writeFileFormatVersion();
109 void writeFileIndex();
110 void writeEventHistory();
111 void writeProcessConfigurationRegistry();
112 void writeProcessHistoryRegistry();
113 void writeParameterSetRegistry();
114 void writeProductDescriptionRegistry();
115 void writeParentageRegistry();
116 void writeProductDependencies();
117 void writeFileCatalogMetadata(FileStatsCollector
const& stats,
118 FileCatalogMetadata::collection_type
const&,
119 FileCatalogMetadata::collection_type
const&);
120 void writeResults(ResultsPrincipal& resp);
121 void setRunAuxiliaryRangeSetID(RangeSet
const&);
122 void setSubRunAuxiliaryRangeSetID(RangeSet
const&);
123 void beginInputFile(RootFileBlock
const*,
bool fastClone);
124 void incrementInputFileNumber();
125 void respondToCloseInputFile(FileBlock
const&);
126 bool requestsToCloseFile();
128 setFileStatus(OutputFileStatus
const ofs)
133 void selectProducts();
136 currentFileName()
const
141 bool maxEventsPerFileReached(
142 FileIndex::EntryNumber_t
const maxEventsPerFile)
const;
143 bool maxSizeReached(
unsigned const maxFileSize)
const;
146 void createDatabaseTables();
149 void fillBranches(Principal
const&,
150 std::vector<ProductProvenance>*);
152 template<BranchType BT>
153 std::enable_if_t<!detail::RangeSetsSupported<BT>::value,
154 art::EDProduct
const*>
155 getProduct(OutputHandle
const&,
156 RangeSet
const& productRS,
157 std::string
const& wrappedName);
159 template<BranchType BT>
160 std::enable_if_t<detail::RangeSetsSupported<BT>::value, art::EDProduct
const*>
161 getProduct(OutputHandle
const&,
162 RangeSet
const& productRS,
163 std::string
const& wrappedName);
166 OutputModule
const* om_;
168 ClosingCriteria fileSwitchCriteria_;
169 OutputFileStatus status_{OutputFileStatus::Closed};
170 int const compressionLevel_;
171 unsigned freePercent_;
173 int64_t
const saveMemoryObjectThreshold_;
174 int64_t
const treeMaxVirtualSize_;
175 int const splitLevel_;
176 int const basketSize_;
177 DropMetaData dropMetaData_;
178 bool dropMetaDataForDroppedData_;
179 bool fastCloningEnabledAtConstruction_;
180 bool wasFastCloned_{
false};
181 std::unique_ptr<TFile> filePtr_;
182 FileIndex fileIndex_{};
183 FileProperties fp_{};
184 TTree* metaDataTree_{
nullptr};
185 TTree* fileIndexTree_{
nullptr};
186 TTree* parentageTree_{
nullptr};
187 TTree* eventHistoryTree_{
nullptr};
188 EventAuxiliary
const* pEventAux_{
nullptr};
189 SubRunAuxiliary
const* pSubRunAux_{
nullptr};
190 RunAuxiliary
const* pRunAux_{
nullptr};
191 ResultsAuxiliary
const* pResultsAux_{
nullptr};
192 ProductProvenances eventProductProvenanceVector_{};
193 ProductProvenances subRunProductProvenanceVector_{};
194 ProductProvenances runProductProvenanceVector_{};
195 ProductProvenances resultsProductProvenanceVector_{};
196 ProductProvenances* pEventProductProvenanceVector_{
197 &eventProductProvenanceVector_};
198 ProductProvenances* pSubRunProductProvenanceVector_{
199 &subRunProductProvenanceVector_};
200 ProductProvenances* pRunProductProvenanceVector_{
201 &runProductProvenanceVector_};
202 ProductProvenances* pResultsProductProvenanceVector_{
203 &resultsProductProvenanceVector_};
204 History
const* pHistory_{
nullptr};
205 RootOutputTreePtrArray treePointers_;
206 bool dataTypeReported_{
false};
207 std::set<ProductID> branchesWithStoredHistory_{};
208 cet::sqlite::Connection rootFileDB_;
212 OutputItemListArray selectedOutputItemList_{{}};
213 detail::DummyProductCache dummyProductCache_{};
214 unsigned subRunRSID_{-1u};
215 unsigned runRSID_{-1u};
216 std::chrono::steady_clock::time_point beginTime_{
217 std::chrono::steady_clock::now()};