RootOutputFile.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Root_RootOutputFile_h
2 #define art_Framework_IO_Root_RootOutputFile_h
3 // vim: set sw=2 expandtab :
4 
14 #include "boost/filesystem.hpp"
23 #include "hep_concurrency/RecursiveMutex.h"
24 
25 #include <array>
26 #include <map>
27 #include <memory>
28 #include <set>
29 #include <string>
30 #include <vector>
31 
32 #include "TFile.h"
33 #include "TROOT.h"
34 
35 class TTree;
36 
37 namespace art {
38  class ResultsPrincipal;
39  class RootOutput;
40  class History;
41  class FileBlock;
42  class EventAuxiliary;
43  class SubRunAuxiliary;
44  class RunAuxiliary;
45  class ResultsAuxiliary;
46  class RootFileBlock;
48  public: // TYPES
49  enum class ClosureRequestMode { MaxEvents = 0, MaxSize = 1, Unset = 2 };
51  std::array<std::unique_ptr<RootOutputTree>, NumBranchTypes>;
52  struct OutputItem {
53  public: // MEMBER FUNCTIONS -- Special Member Functions
54  ~OutputItem();
55  explicit OutputItem(BranchDescription const& bd);
56 
57  public: // MEMBER FUNCTIONS
58  std::string const& branchName() const;
59  bool operator<(OutputItem const& rh) const;
60 
61  public: // MEMBER DATA
63  mutable void const* product_;
64  };
65 
66  public: // MEMBER FUNCTIONS -- Static API
67  static bool shouldFastClone(bool const fastCloningSet,
68  bool const fastCloning,
69  bool const wantAllEvents,
70  ClosingCriteria const& cc);
71 
72  public: // MEMBER FUNCTIONS -- Special Member Functions
74  explicit RootOutputFile(OutputModule*,
75  std::string const& fileName,
76  ClosingCriteria const& fileSwitchCriteria,
77  int const compressionLevel,
78  int64_t const saveMemoryObjectThreshold,
79  int64_t const treeMaxVirtualSize,
80  int const splitLevel,
81  int const basketSize,
82  DropMetaData dropMetaData,
83  bool dropMetaDataForDroppedData,
84  bool fastCloningRequested);
85  RootOutputFile(RootOutputFile const&) = delete;
86  RootOutputFile(RootOutputFile&&) = delete;
87  RootOutputFile& operator=(RootOutputFile const&) = delete;
89 
90  public: // MEMBER FUNCTIONS
91  void writeTTrees();
92  void writeOne(EventPrincipal const&);
93  void writeSubRun(SubRunPrincipal const&);
94  void writeRun(RunPrincipal const&);
96  void writeFileIndex();
97  void writeEventHistory();
102  void writeParentageRegistry();
107  void writeResults(ResultsPrincipal& resp);
108  void setRunAuxiliaryRangeSetID(RangeSet const&);
110  void beginInputFile(RootFileBlock const*, bool fastClone);
112  void respondToCloseInputFile(FileBlock const&);
113  bool requestsToCloseFile();
114  void setFileStatus(OutputFileStatus const ofs);
115  void selectProducts();
116  std::string const& currentFileName() const;
118  FileIndex::EntryNumber_t const maxEventsPerFile) const;
119  bool maxSizeReached(unsigned const maxFileSize) const;
120 
121  private: // MEMBER FUNCTIONS
122  template <BranchType>
123  void fillBranches(Principal const&, std::vector<ProductProvenance>*);
124  template <BranchType BT>
126  getProduct(OutputHandle const&,
127  RangeSet const& productRS,
128  std::string const& wrappedName);
129  template <BranchType BT>
131  getProduct(OutputHandle const&,
132  RangeSet const& productRS,
133  std::string const& wrappedName);
134 
135  private: // MEMBER DATA
136  mutable hep::concurrency::RecursiveMutex mutex_;
141  int const compressionLevel_;
144  int const splitLevel_;
145  int const basketSize_;
150  std::unique_ptr<TFile> filePtr_;
172  std::array<ProductDescriptionsByID, NumBranchTypes> descriptionsToPersist_;
173  std::unique_ptr<cet::sqlite::Connection> rootFileDB_;
174  std::array<std::set<OutputItem>, NumBranchTypes> selectedOutputItemList_;
176  unsigned subRunRSID_;
177  unsigned runRSID_;
178  std::chrono::steady_clock::time_point beginTime_;
179  };
180 
181 } // namespace art
182 
183 // Local Variables:
184 // mode: c++
185 // End:
186 #endif /* art_Framework_IO_Root_RootOutputFile_h */
SubRunAuxiliary const * pSubRunAux_
EventAuxiliary const * pEventAux_
std::vector< std::pair< std::string, std::string >> collection_type
void setFileStatus(OutputFileStatus const ofs)
int const compressionLevel_
bool fastCloningEnabledAtConstruction_
std::string const & currentFileName() const
RootOutputFile(OutputModule *, std::string const &fileName, ClosingCriteria const &fileSwitchCriteria, int const compressionLevel, int64_t const saveMemoryObjectThreshold, int64_t const treeMaxVirtualSize, int const splitLevel, int const basketSize, DropMetaData dropMetaData, bool dropMetaDataForDroppedData, bool fastCloningRequested)
ProductProvenances * pRunProductProvenanceVector_
int64_t const treeMaxVirtualSize_
std::string string
Definition: nybbler.cc:12
ProductProvenances resultsProductProvenanceVector_
std::chrono::steady_clock::time_point beginTime_
std::unique_ptr< TFile > filePtr_
void beginInputFile(RootFileBlock const *, bool fastClone)
std::array< std::set< OutputItem >, NumBranchTypes > selectedOutputItemList_
DropMetaData dropMetaData_
ProductProvenances runProductProvenanceVector_
BranchDescription const branchDescription_
void writeOne(EventPrincipal const &)
hep::concurrency::RecursiveMutex mutex_
long long EntryNumber_t
Definition: FileIndex.h:42
void setRunAuxiliaryRangeSetID(RangeSet const &)
ProductProvenances eventProductProvenanceVector_
ProductProvenances * pResultsProductProvenanceVector_
void writeFileCatalogMetadata(FileStatsCollector const &stats, FileCatalogMetadata::collection_type const &, FileCatalogMetadata::collection_type const &)
OutputFileStatus status_
void setSubRunAuxiliaryRangeSetID(RangeSet const &)
bool operator<(ProductInfo const &a, ProductInfo const &b)
Definition: ProductInfo.cc:49
ProductProvenances subRunProductProvenanceVector_
OutputFileStatus
FileProperties fp_
void writeSubRun(SubRunPrincipal const &)
static bool shouldFastClone(bool const fastCloningSet, bool const fastCloning, bool const wantAllEvents, ClosingCriteria const &cc)
detail::DummyProductCache dummyProductCache_
void writeResults(ResultsPrincipal &resp)
RootOutputTreePtrArray treePointers_
std::unique_ptr< cet::sqlite::Connection > rootFileDB_
void respondToCloseInputFile(FileBlock const &)
ProductProvenances * pEventProductProvenanceVector_
std::enable_if_t<!detail::RangeSetsSupported< BT >::value, EDProduct const * > getProduct(OutputHandle const &, RangeSet const &productRS, std::string const &wrappedName)
bool maxSizeReached(unsigned const maxFileSize) const
void writeProductDescriptionRegistry()
std::array< ProductDescriptionsByID, NumBranchTypes > descriptionsToPersist_
bool maxEventsPerFileReached(FileIndex::EntryNumber_t const maxEventsPerFile) const
void writeProcessConfigurationRegistry()
OutputModule const * om_
signed __int64 int64_t
Definition: stdint.h:131
int64_t const saveMemoryObjectThreshold_
void writeRun(RunPrincipal const &)
std::array< std::unique_ptr< RootOutputTree >, NumBranchTypes > RootOutputTreePtrArray
void writeProcessHistoryRegistry()
std::vector< ProductProvenance > ProductProvenances
ResultsAuxiliary const * pResultsAux_
ProductProvenances * pSubRunProductProvenanceVector_
RunAuxiliary const * pRunAux_
History const * pHistory_
RootOutputFile & operator=(RootOutputFile const &)=delete
ClosingCriteria fileSwitchCriteria_
void fillBranches(Principal const &, std::vector< ProductProvenance > *)