CMS 3D CMS Logo

PoolOutputModule.h
Go to the documentation of this file.
1 #ifndef IOPool_Output_PoolOutputModule_h
2 #define IOPool_Output_PoolOutputModule_h
3 
5 //
6 // Class PoolOutputModule. Output module to POOL file
7 //
8 // Oringinal Author: Luca Lista
9 // Current Author: Bill Tanenbaum
10 //
12 
13 #include <array>
14 #include <map>
15 #include <memory>
16 #include <set>
17 #include <string>
18 #include <vector>
19 
27 
28 class TTree;
29 namespace edm {
30 
31  class EDGetToken;
32  class ModuleCallingContext;
33  class ParameterSet;
34  class RootOutputFile;
36  class ProductProvenanceRetriever;
37 
38  class PoolOutputModule : public one::OutputModule<WatchInputFiles> {
39  public:
41  explicit PoolOutputModule(ParameterSet const& ps);
42  virtual ~PoolOutputModule();
43  PoolOutputModule(PoolOutputModule const&) = delete; // Disallow copying and moving
44  PoolOutputModule& operator=(PoolOutputModule const&) = delete; // Disallow copying and moving
45  std::string const& fileName() const {return fileName_;}
46  std::string const& logicalFileName() const {return logicalFileName_;}
47  int const& compressionLevel() const {return compressionLevel_;}
49  int const& basketSize() const {return basketSize_;}
51  int const& splitLevel() const {return splitLevel_;}
52  std::string const& basketOrder() const {return basketOrder_;}
53  int const& treeMaxVirtualSize() const {return treeMaxVirtualSize_;}
55  DropMetaData const& dropMetaData() const {return dropMetaData_;}
56  std::string const& catalog() const {return catalog_;}
57  std::string const& moduleLabel() const {return moduleLabel_;}
58  unsigned int const& maxFileSize() const {return maxFileSize_;}
59  int const& inputFileCount() const {return inputFileCount_;}
60  int const& whyNotFastClonable() const {return whyNotFastClonable_;}
61 
62  std::string const& currentFileName() const;
63 
64  static void fillDescription(ParameterSetDescription& desc);
65  static void fillDescriptions(ConfigurationDescriptions& descriptions);
66 
68 
69  struct AuxItem {
70  AuxItem();
71  ~AuxItem() {}
73  };
74  typedef std::array<AuxItem, NumBranchTypes> AuxItemArray;
75  AuxItemArray const& auxItems() const {return auxItems_;}
76 
77  struct OutputItem {
78  class Sorter {
79  public:
80  explicit Sorter(TTree* tree);
81  bool operator() (OutputItem const& lh, OutputItem const& rh) const;
82  private:
83  std::shared_ptr<std::map<std::string, int> > treeMap_;
84  };
85 
86  OutputItem();
87 
88  explicit OutputItem(BranchDescription const* bd, EDGetToken const& token, int splitLevel, int basketSize);
89 
91 
92  BranchID branchID() const { return branchDescription_->branchID(); }
93  std::string const& branchName() const { return branchDescription_->branchName(); }
94 
95  bool operator <(OutputItem const& rh) const {
96  return *branchDescription_ < *rh.branchDescription_;
97  }
98 
101  mutable void const* product_;
104  };
105 
106  typedef std::vector<OutputItem> OutputItemList;
107 
108  typedef std::array<OutputItemList, NumBranchTypes> OutputItemListArray;
109 
110  OutputItemListArray const& selectedOutputItemList() const {return selectedOutputItemList_;}
111 
113 
114  protected:
116  virtual bool shouldWeCloseFile() const override;
117  virtual void write(EventForOutput const& e) override;
118 
119  virtual std::pair<std::string, std::string> physicalAndLogicalNameForNewFile();
120  virtual void doExtrasAfterCloseFile();
121  private:
122  virtual void preActionBeforeRunEventAsync(WaitingTask* iTask, ModuleCallingContext const& iModuleCallingContext, Principal const& iPrincipal) const override;
123 
124  virtual void openFile(FileBlock const& fb) override;
125  virtual void respondToOpenInputFile(FileBlock const& fb) override;
126  virtual void respondToCloseInputFile(FileBlock const& fb) override;
127  virtual void writeLuminosityBlock(LuminosityBlockForOutput const& lb) override;
128  virtual void writeRun(RunForOutput const& r) override;
129  virtual void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override;
130  virtual bool isFileOpen() const override;
131  virtual void reallyOpenFile() override;
132  virtual void reallyCloseFile() override;
133  virtual void beginJob() override;
134 
135  typedef std::map<BranchID, std::set<ParentageID> > BranchParents;
137  BranchID const& branchID);
138  void updateBranchParents(EventForOutput const& e);
139  void fillDependencyGraph();
140 
141  void startEndFile();
142  void writeFileFormatVersion();
143  void writeFileIdentifier();
144  void writeIndexIntoFile();
148  void writeParentageRegistry();
152  void finishEndFile();
153 
154  void fillSelectedItemList(BranchType branchtype, TTree* theInputTree);
155  void beginInputFile(FileBlock const& fb);
156 
158  AuxItemArray auxItems_;
159  OutputItemListArray selectedOutputItemList_;
163  unsigned int const maxFileSize_;
164  int const compressionLevel_;
166  int const basketSize_;
168  int const splitLevel_;
177  unsigned int childIndex_;
179  BranchParents branchParents_;
181  std::vector<BranchID> producedBranches_;
185  };
186 }
187 
188 #endif
189 
bool operator<(DetSet< T > const &x, DetSet< T > const &y)
Definition: DetSet.h:90
virtual void openFile(FileBlock const &fb) override
virtual std::pair< std::string, std::string > physicalAndLogicalNameForNewFile()
virtual bool shouldWeCloseFile() const override
allow inheriting classes to override but still be able to call this method in the overridden version ...
BranchDescription const * branchDescription_
int const & basketSize() const
std::string const compressionAlgorithm_
bool const & overrideInputFileSplitLevels() const
int eventAutoFlushSize() const
std::string const & catalog() const
virtual void write(EventForOutput const &e) override
edm::propagate_const< std::unique_ptr< RootOutputFile > > rootOutputFile_
std::string const catalog_
PoolOutputModule & operator=(PoolOutputModule const &)=delete
std::string const & moduleLabel() const
void updateBranchParents(EventForOutput const &e)
DropMetaData const & dropMetaData() const
BranchChildren branchChildren_
std::vector< OutputItem > OutputItemList
std::string const & fileName() const
int const & compressionLevel() const
OutputItemListArray const & selectedOutputItemList() const
std::string const moduleLabel_
bool int lh
Definition: SIMDVec.h:21
unsigned int const & maxFileSize() const
virtual void doExtrasAfterCloseFile()
std::string const & logicalFileName() const
BranchType
Definition: BranchType.h:11
void fillSelectedItemList(BranchType branchtype, TTree *theInputTree)
PoolOutputModule(ParameterSet const &ps)
void updateBranchParentsForOneBranch(ProductProvenanceRetriever const *provRetriever, BranchID const &branchID)
std::string const & currentFileName() const
std::string const & compressionAlgorithm() const
OutputItemListArray selectedOutputItemList_
std::vector< BranchID > producedBranches_
virtual void preActionBeforeRunEventAsync(WaitingTask *iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
std::string const & basketOrder() const
std::string const & branchName() const
int const & splitLevel() const
virtual void reallyOpenFile() override
BranchParents branchParents_
int const & whyNotFastClonable() const
unsigned int numberOfDigitsInIndex_
std::array< AuxItem, NumBranchTypes > AuxItemArray
unsigned int const maxFileSize_
virtual void writeRun(RunForOutput const &r) override
virtual bool isFileOpen() const override
BranchChildren const & branchChildren() const
virtual void respondToCloseInputFile(FileBlock const &fb) override
virtual void beginJob() override
virtual void reallyCloseFile() override
AuxItemArray const & auxItems() const
std::string const fileName_
int const & treeMaxVirtualSize() const
std::array< OutputItemList, NumBranchTypes > OutputItemListArray
HLT enums.
virtual void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override
std::shared_ptr< std::map< std::string, int > > treeMap_
std::string const logicalFileName_
void beginInputFile(FileBlock const &fb)
Definition: tree.py:1
virtual void respondToOpenInputFile(FileBlock const &fb) override
static void fillDescriptions(ConfigurationDescriptions &descriptions)
static void fillDescription(ParameterSetDescription &desc)
std::map< BranchID, std::set< ParentageID > > BranchParents
RootServiceChecker rootServiceChecker_
int const & inputFileCount() const
ParameterSetID selectorConfig() const
Definition: OutputModule.h:102
virtual void writeLuminosityBlock(LuminosityBlockForOutput const &lb) override