CMS 3D CMS Logo

RootOutputFile.h
Go to the documentation of this file.
1 #ifndef IOPool_Output_RootOutputFile_h
2 #define IOPool_Output_RootOutputFile_h
3 
5 //
6 // Class RootOutputFile
7 //
8 // Current Author: Bill Tanenbaum
9 //
11 
12 #include <array>
13 #include <map>
14 #include <string>
15 #include <vector>
16 
17 #include <memory>
18 
39 
40 class TTree;
41 class TFile;
42 class TClass;
43 
44 namespace edm {
45  class OccurrenceForOutput;
46  class PoolOutputModule;
47 
49  public:
52  explicit RootOutputFile(PoolOutputModule* om,
53  std::string const& fileName,
54  std::string const& logicalFileName,
55  std::vector<std::string> const& processesWithSelectedMergeableRunProducts,
56  std::string const& overrideGUID);
58  void writeOne(EventForOutput const& e);
59  //void endFile();
61  void writeRun(RunForOutput const& r);
64  void writeFileIdentifier();
65  void writeIndexIntoFile();
74  void writeEventAuxiliary();
76 
77  void finishEndFile();
78  void beginInputFile(FileBlock const& fb, int remainingEvents);
79  void respondToCloseInputFile(FileBlock const& fb);
80  bool shouldWeCloseFile() const;
81 
82  std::string const& fileName() const { return file_; }
83 
84  private:
85  void setBranchAliases(TTree* tree, SelectedProducts const& branches, std::string const& processName) const;
86 
87  void fillBranches(BranchType const& branchType,
88  OccurrenceForOutput const& occurrence,
89  unsigned int ttreeIndex,
90  StoredProductProvenanceVector* productProvenanceVecPtr = nullptr,
91  ProductProvenanceRetriever const* provRetriever = nullptr);
92 
93  void insertAncestors(ProductProvenance const& iGetParents,
94  ProductProvenanceRetriever const* iMapper,
95  bool produced,
96  std::set<BranchID> const& producedBranches,
97  std::set<StoredProductProvenance>& oToFill);
98 
99  bool insertProductProvenance(const ProductProvenance&, std::set<StoredProductProvenance>& oToInsert);
100 
101  std::shared_ptr<TFile const> filePtr() const { return get_underlying_safe(filePtr_); }
102  std::shared_ptr<TFile>& filePtr() { return get_underlying_safe(filePtr_); }
105  }
107 
108  //-------------------------------
109  // Member data
110 
124  unsigned long nEventsInLumi_;
141  std::vector<edm::propagate_const<std::unique_ptr<RootOutputTree>>> processBlockTrees_;
142  std::vector<edm::propagate_const<RootOutputTree*>> treePointers_;
145  std::map<ParentageID, unsigned int> parentageIDs_;
146  std::set<BranchID> branchesWithStoredHistory_;
149  };
150 
151 } // namespace edm
152 
153 #endif
PoolOutputModule::OutputItemList OutputItemList
void beginInputFile(FileBlock const &fb, int remainingEvents)
LuminosityBlockAuxiliary lumiAux_
std::shared_ptr< TFile > & filePtr()
void writeProcessHistoryRegistry()
void setBranchAliases(TTree *tree, SelectedProducts const &branches, std::string const &processName) const
RootOutputFile(PoolOutputModule *om, std::string const &fileName, std::string const &logicalFileName, std::vector< std::string > const &processesWithSelectedMergeableRunProducts, std::string const &overrideGUID)
void insertAncestors(ProductProvenance const &iGetParents, ProductProvenanceRetriever const *iMapper, bool produced, std::set< BranchID > const &producedBranches, std::set< StoredProductProvenance > &oToFill)
std::shared_ptr< TFile const > filePtr() const
std::map< ParentageID, unsigned int > parentageIDs_
edm::propagate_const< TTree * > metaDataTree_
unsigned long nEventsInLumi_
ProcessHistoryRegistry processHistoryRegistry_
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
StoredProductProvenanceVector *& pEventEntryInfoVector()
void writeLuminosityBlock(LuminosityBlockForOutput const &lb)
BranchType
Definition: BranchType.h:11
std::set< BranchID > branchesWithStoredHistory_
std::vector< edm::propagate_const< RootOutputTree * > > treePointers_
std::vector< EventSelectionID > EventSelectionIDVector
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
void writeThinnedAssociationsHelper()
long long EntryNumber_t
RootOutputTree eventTree_
std::vector< BranchListIndex > BranchListIndexes
edm::propagate_const< PoolOutputModule * > om_
IndexIntoFile::EntryNumber_t eventEntryNumber_
std::string const & fileName() const
LuminosityBlockAuxiliary const * pLumiAux_
edm::propagate_const< std::shared_ptr< TFile > > filePtr_
void writeOne(EventForOutput const &e)
std::string logicalFile_
void fillBranches(BranchType const &branchType, OccurrenceForOutput const &occurrence, unsigned int ttreeIndex, StoredProductProvenanceVector *productProvenanceVecPtr=nullptr, ProductProvenanceRetriever const *provRetriever=nullptr)
CompactEventAuxiliaryVector compactEventAuxiliary_
edm::propagate_const< TClass * > wrapperBaseTClass_
std::size_t Token
Definition: JobReport.h:106
EventSelectionIDVector const * pEventSelectionIDs_
edm::propagate_const< TTree * > parameterSetsTree_
StoredMergeableRunProductMetadata storedMergeableRunProductMetadata_
void writeStoredMergeableRunProductMetadata()
edm::propagate_const< StoredProductProvenanceVector * > pEventEntryInfoVector_
RootOutputTree runTree_
StoredProductProvenanceVector eventEntryInfoVector_
edm::propagate_const< TTree * > parentageTree_
bool insertProductProvenance(const ProductProvenance &, std::set< StoredProductProvenance > &oToInsert)
std::vector< StoredProductProvenance > StoredProductProvenanceVector
void respondToCloseInputFile(FileBlock const &fb)
IndexIntoFile indexIntoFile_
IndexIntoFile::EntryNumber_t runEntryNumber_
EventAuxiliary const * pEventAux_
StoredProductProvenanceVector const * pEventEntryInfoVector() const
HLT enums.
RunAuxiliary runAux_
void writeProductDescriptionRegistry()
void writeProcessBlock(ProcessBlockForOutput const &)
Definition: tree.py:1
std::vector< OutputItem > OutputItemList
BranchListIndexes const * pBranchListIndexes_
std::vector< edm::propagate_const< std::unique_ptr< RootOutputTree > > > processBlockTrees_
bool shouldWeCloseFile() const
IndexIntoFile::EntryNumber_t lumiEntryNumber_
RootOutputTree lumiTree_
void writeRun(RunForOutput const &r)
RunAuxiliary const * pRunAux_
JobReport::Token reportToken_
EventToProcessBlockIndexes const * pEventToProcessBlockIndexes_