File indexing completed on 2025-01-25 08:30:08
0001 #ifndef IOPool_Output_RootOutputFile_h
0002 #define IOPool_Output_RootOutputFile_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <array>
0013 #include <map>
0014 #include <string>
0015 #include <vector>
0016
0017 #include <memory>
0018
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/MessageLogger/interface/JobReport.h"
0021 #include "FWCore/Utilities/interface/BranchType.h"
0022 #include "FWCore/Utilities/interface/get_underlying_safe.h"
0023 #include "FWCore/Utilities/interface/propagate_const.h"
0024 #include "DataFormats/Provenance/interface/BranchListIndex.h"
0025 #include "DataFormats/Provenance/interface/EventSelectionID.h"
0026 #include "DataFormats/Provenance/interface/FileID.h"
0027 #include "DataFormats/Provenance/interface/IndexIntoFile.h"
0028 #include "DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h"
0029 #include "DataFormats/Provenance/interface/ParentageID.h"
0030 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
0031 #include "DataFormats/Provenance/interface/ProductProvenance.h"
0032 #include "DataFormats/Provenance/interface/StoredProductProvenance.h"
0033 #include "DataFormats/Provenance/interface/StoredMergeableRunProductMetadata.h"
0034 #include "DataFormats/Provenance/interface/RunAuxiliary.h"
0035 #include "DataFormats/Provenance/interface/SelectedProducts.h"
0036 #include "DataFormats/Provenance/interface/CompactEventAuxiliaryVector.h"
0037 #include "IOPool/Output/interface/PoolOutputModule.h"
0038 #include "IOPool/Output/src/RootOutputTree.h"
0039
0040 class TTree;
0041 class TFile;
0042 class TClass;
0043
0044 namespace edm {
0045 class OccurrenceForOutput;
0046 class PoolOutputModule;
0047
0048 class RootOutputFile {
0049 public:
0050 using OutputItem = PoolOutputModule::OutputItem;
0051 using OutputItemList = PoolOutputModule::OutputItemList;
0052 explicit RootOutputFile(PoolOutputModule* om,
0053 std::string const& fileName,
0054 std::string const& logicalFileName,
0055 std::vector<std::string> const& processesWithSelectedMergeableRunProducts,
0056 std::string const& overrideGUID);
0057 ~RootOutputFile() {}
0058 void writeOne(EventForOutput const& e);
0059
0060 void writeLuminosityBlock(LuminosityBlockForOutput const& lb);
0061 void writeRun(RunForOutput const& r);
0062 void writeProcessBlock(ProcessBlockForOutput const&);
0063 void writeFileFormatVersion();
0064 void writeFileIdentifier();
0065 void writeIndexIntoFile();
0066 void writeStoredMergeableRunProductMetadata();
0067 void writeProcessHistoryRegistry();
0068 void writeParameterSetRegistry();
0069 void writeProductDescriptionRegistry(ProductRegistry const&);
0070 void writeParentageRegistry();
0071 void writeBranchIDListRegistry();
0072 void writeThinnedAssociationsHelper();
0073 void writeProductDependencies();
0074 void writeEventAuxiliary();
0075 void writeProcessBlockHelper();
0076
0077 void finishEndFile();
0078 void beginInputFile(FileBlock const& fb, int remainingEvents);
0079 void respondToCloseInputFile(FileBlock const& fb);
0080 bool shouldWeCloseFile() const;
0081
0082 std::string const& fileName() const { return file_; }
0083
0084 private:
0085 void setBranchAliases(TTree* tree, SelectedProducts const& branches, std::string const& processName) const;
0086
0087 void fillBranches(BranchType const& branchType,
0088 OccurrenceForOutput const& occurrence,
0089 unsigned int ttreeIndex,
0090 StoredProductProvenanceVector* productProvenanceVecPtr = nullptr,
0091 ProductProvenanceRetriever const* provRetriever = nullptr);
0092
0093 void insertAncestors(ProductProvenance const& iGetParents,
0094 ProductProvenanceRetriever const* iMapper,
0095 bool produced,
0096 std::set<BranchID> const& producedBranches,
0097 std::set<StoredProductProvenance>& oToFill);
0098
0099 bool insertProductProvenance(const ProductProvenance&, std::set<StoredProductProvenance>& oToInsert);
0100
0101 std::shared_ptr<TFile const> filePtr() const { return get_underlying_safe(filePtr_); }
0102 std::shared_ptr<TFile>& filePtr() { return get_underlying_safe(filePtr_); }
0103 StoredProductProvenanceVector const* pEventEntryInfoVector() const {
0104 return get_underlying_safe(pEventEntryInfoVector_);
0105 }
0106 StoredProductProvenanceVector*& pEventEntryInfoVector() { return get_underlying_safe(pEventEntryInfoVector_); }
0107
0108
0109
0110
0111 std::string file_;
0112 std::string logicalFile_;
0113 JobReport::Token reportToken_;
0114 edm::propagate_const<PoolOutputModule*> om_;
0115 int whyNotFastClonable_;
0116 bool canFastCloneAux_;
0117 edm::propagate_const<std::shared_ptr<TFile>> filePtr_;
0118 FileID fid_;
0119 IndexIntoFile::EntryNumber_t eventEntryNumber_;
0120 IndexIntoFile::EntryNumber_t lumiEntryNumber_;
0121 IndexIntoFile::EntryNumber_t runEntryNumber_;
0122 IndexIntoFile indexIntoFile_;
0123 StoredMergeableRunProductMetadata storedMergeableRunProductMetadata_;
0124 unsigned long nEventsInLumi_;
0125 edm::propagate_const<TTree*> metaDataTree_;
0126 edm::propagate_const<TTree*> parameterSetsTree_;
0127 edm::propagate_const<TTree*> parentageTree_;
0128 LuminosityBlockAuxiliary lumiAux_;
0129 RunAuxiliary runAux_;
0130 EventAuxiliary const* pEventAux_;
0131 LuminosityBlockAuxiliary const* pLumiAux_;
0132 RunAuxiliary const* pRunAux_;
0133 StoredProductProvenanceVector eventEntryInfoVector_;
0134 edm::propagate_const<StoredProductProvenanceVector*> pEventEntryInfoVector_;
0135 BranchListIndexes const* pBranchListIndexes_;
0136 EventToProcessBlockIndexes const* pEventToProcessBlockIndexes_;
0137 EventSelectionIDVector const* pEventSelectionIDs_;
0138 RootOutputTree eventTree_;
0139 RootOutputTree lumiTree_;
0140 RootOutputTree runTree_;
0141 std::vector<edm::propagate_const<std::unique_ptr<RootOutputTree>>> processBlockTrees_;
0142 std::vector<edm::propagate_const<RootOutputTree*>> treePointers_;
0143 bool dataTypeReported_;
0144 ProcessHistoryRegistry processHistoryRegistry_;
0145 std::map<ParentageID, unsigned int> parentageIDs_;
0146 std::set<BranchID> branchesWithStoredHistory_;
0147 edm::propagate_const<TClass*> wrapperBaseTClass_;
0148 CompactEventAuxiliaryVector compactEventAuxiliary_;
0149 };
0150
0151 }
0152
0153 #endif