CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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);
57  void writeOne(EventForOutput const& e);
58  //void endFile();
60  void writeRun(RunForOutput const& r);
63  void writeFileIdentifier();
64  void writeIndexIntoFile();
73  void writeEventAuxiliary();
75 
76  void finishEndFile();
77  void beginInputFile(FileBlock const& fb, int remainingEvents);
78  void respondToCloseInputFile(FileBlock const& fb);
79  bool shouldWeCloseFile() const;
80 
81  std::string const& fileName() const { return file_; }
82 
83  private:
84  void setBranchAliases(TTree* tree, SelectedProducts const& branches, std::string const& processName) const;
85 
86  void fillBranches(BranchType const& branchType,
87  OccurrenceForOutput const& occurrence,
88  unsigned int ttreeIndex,
89  StoredProductProvenanceVector* productProvenanceVecPtr = nullptr,
90  ProductProvenanceRetriever const* provRetriever = nullptr);
91 
92  void insertAncestors(ProductProvenance const& iGetParents,
93  ProductProvenanceRetriever const* iMapper,
94  bool produced,
95  std::set<BranchID> const& producedBranches,
96  std::set<StoredProductProvenance>& oToFill);
97 
98  bool insertProductProvenance(const ProductProvenance&, std::set<StoredProductProvenance>& oToInsert);
99 
100  std::shared_ptr<TFile const> filePtr() const { return get_underlying_safe(filePtr_); }
101  std::shared_ptr<TFile>& filePtr() { return get_underlying_safe(filePtr_); }
104  }
106 
107  //-------------------------------
108  // Member data
109 
123  unsigned long nEventsInLumi_;
140  std::vector<edm::propagate_const<std::unique_ptr<RootOutputTree>>> processBlockTrees_;
141  std::vector<edm::propagate_const<RootOutputTree*>> treePointers_;
144  std::map<ParentageID, unsigned int> parentageIDs_;
145  std::set<BranchID> branchesWithStoredHistory_;
148  };
149 
150 } // namespace edm
151 
152 #endif
PoolOutputModule::OutputItemList OutputItemList
void beginInputFile(FileBlock const &fb, int remainingEvents)
LuminosityBlockAuxiliary lumiAux_
std::shared_ptr< TFile > & filePtr()
void writeProcessHistoryRegistry()
void insertAncestors(ProductProvenance const &iGetParents, ProductProvenanceRetriever const *iMapper, bool produced, std::set< BranchID > const &producedBranches, std::set< StoredProductProvenance > &oToFill)
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)
bool shouldWeCloseFile() const
BranchType
Definition: BranchType.h:11
std::set< BranchID > branchesWithStoredHistory_
std::vector< edm::propagate_const< RootOutputTree * > > treePointers_
std::vector< EventSelectionID > EventSelectionIDVector
RootOutputFile(PoolOutputModule *om, std::string const &fileName, std::string const &logicalFileName, std::vector< std::string > const &processesWithSelectedMergeableRunProducts)
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
std::string const & fileName() const
void writeThinnedAssociationsHelper()
std::shared_ptr< TFile const > filePtr() const
long long EntryNumber_t
RootOutputTree eventTree_
std::vector< BranchListIndex > BranchListIndexes
edm::propagate_const< PoolOutputModule * > om_
IndexIntoFile::EntryNumber_t eventEntryNumber_
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_
RunAuxiliary runAux_
void writeProductDescriptionRegistry()
StoredProductProvenanceVector const * pEventEntryInfoVector() const
void writeProcessBlock(ProcessBlockForOutput const &)
std::vector< OutputItem > OutputItemList
BranchListIndexes const * pBranchListIndexes_
std::vector< edm::propagate_const< std::unique_ptr< RootOutputTree > > > processBlockTrees_
IndexIntoFile::EntryNumber_t lumiEntryNumber_
RootOutputTree lumiTree_
void writeRun(RunForOutput const &r)
RunAuxiliary const * pRunAux_
void setBranchAliases(TTree *tree, SelectedProducts const &branches, std::string const &processName) const
JobReport::Token reportToken_
EventToProcessBlockIndexes const * pEventToProcessBlockIndexes_