CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <memory>
15 #include <string>
16 
22 
23 class TTree;
24 namespace edm {
25 
26  class ModuleCallingContext;
27  class ParameterSet;
28  class RootOutputFile;
30 
31  class PoolOutputModule : public one::OutputModule<WatchInputFiles> {
32  public:
34  explicit PoolOutputModule(ParameterSet const& ps);
35  virtual ~PoolOutputModule();
36  PoolOutputModule(PoolOutputModule const&) = delete; // Disallow copying and moving
37  PoolOutputModule& operator=(PoolOutputModule const&) = delete; // Disallow copying and moving
38  std::string const& fileName() const {return fileName_;}
39  std::string const& logicalFileName() const {return logicalFileName_;}
40  int const& compressionLevel() const {return compressionLevel_;}
42  int const& basketSize() const {return basketSize_;}
44  int const& splitLevel() const {return splitLevel_;}
45  std::string const& basketOrder() const {return basketOrder_;}
46  int const& treeMaxVirtualSize() const {return treeMaxVirtualSize_;}
48  DropMetaData const& dropMetaData() const {return dropMetaData_;}
49  std::string const& catalog() const {return catalog_;}
50  std::string const& moduleLabel() const {return moduleLabel_;}
51  unsigned int const& maxFileSize() const {return maxFileSize_;}
52  int const& inputFileCount() const {return inputFileCount_;}
53  int const& whyNotFastClonable() const {return whyNotFastClonable_;}
54 
55  std::string const& currentFileName() const;
56 
57  static void fillDescription(ParameterSetDescription& desc);
58  static void fillDescriptions(ConfigurationDescriptions& descriptions);
59 
61 
62  struct AuxItem {
63  AuxItem();
64  ~AuxItem() {}
66  };
67  typedef std::array<AuxItem, NumBranchTypes> AuxItemArray;
68  AuxItemArray const& auxItems() const {return auxItems_;}
69 
70  struct OutputItem {
71  class Sorter {
72  public:
73  explicit Sorter(TTree* tree);
74  bool operator() (OutputItem const& lh, OutputItem const& rh) const;
75  private:
76  std::shared_ptr<std::map<std::string, int> > treeMap_;
77  };
78 
79  OutputItem();
80 
81  explicit OutputItem(BranchDescription const* bd, int splitLevel, int basketSize);
82 
84 
86  std::string const& branchName() const { return branchDescription_->branchName(); }
87 
88  bool operator <(OutputItem const& rh) const {
90  }
91 
93  mutable void const* product_;
96  };
97 
98  typedef std::vector<OutputItem> OutputItemList;
99 
100  typedef std::array<OutputItemList, NumBranchTypes> OutputItemListArray;
101 
103 
105 
106  protected:
108  virtual bool shouldWeCloseFile() const override;
109  virtual void write(EventPrincipal const& e, ModuleCallingContext const*) override;
110 
111  virtual std::pair<std::string, std::string> physicalAndLogicalNameForNewFile();
112  virtual void doExtrasAfterCloseFile();
113  private:
114  virtual void openFile(FileBlock const& fb) override;
115  virtual void respondToOpenInputFile(FileBlock const& fb) override;
116  virtual void respondToCloseInputFile(FileBlock const& fb) override;
117  virtual void writeLuminosityBlock(LuminosityBlockPrincipal const& lb, ModuleCallingContext const*) override;
118  virtual void writeRun(RunPrincipal const& r, ModuleCallingContext const*) override;
119  virtual void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override;
120  virtual bool isFileOpen() const override;
121  virtual void reallyOpenFile() override;
122  virtual void reallyCloseFile() override;
123  virtual void beginJob() override;
124 
125  typedef std::map<BranchID, std::set<ParentageID> > BranchParents;
126  void updateBranchParents(EventPrincipal const& ep);
127  void fillDependencyGraph();
128 
129  void startEndFile();
130  void writeFileFormatVersion();
131  void writeFileIdentifier();
132  void writeIndexIntoFile();
136  void writeParentageRegistry();
140  void finishEndFile();
141 
142  void fillSelectedItemList(BranchType branchtype, TTree* theInputTree);
143  void beginInputFile(FileBlock const& fb);
144 
151  unsigned int const maxFileSize_;
152  int const compressionLevel_;
154  int const basketSize_;
156  int const splitLevel_;
165  unsigned int childIndex_;
170  std::unique_ptr<RootOutputFile> rootOutputFile_;
172  };
173 }
174 
175 #endif
176 
virtual void openFile(FileBlock const &fb) override
virtual std::pair< std::string, std::string > physicalAndLogicalNameForNewFile()
std::string const & branchName() const
virtual void writeRun(RunPrincipal const &r, ModuleCallingContext const *) override
BranchDescription const * branchDescription_
int const & basketSize() const
std::string const compressionAlgorithm_
bool const & overrideInputFileSplitLevels() const
int eventAutoFlushSize() const
std::string const & catalog() const
std::string const catalog_
PoolOutputModule & operator=(PoolOutputModule const &)=delete
std::string const & moduleLabel() const
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)
bool operator()(OutputItem const &lh, OutputItem const &rh) const
std::string const & currentFileName() const
bool operator<(OutputItem const &rh) const
std::string const & compressionAlgorithm() const
OutputItemListArray selectedOutputItemList_
std::string const & basketOrder() const
std::string const & branchName() const
void updateBranchParents(EventPrincipal const &ep)
int const & splitLevel() const
BranchID const & branchID() const
virtual void reallyOpenFile() override
BranchParents branchParents_
std::unique_ptr< RootOutputFile > rootOutputFile_
int const & whyNotFastClonable() const
unsigned int numberOfDigitsInIndex_
std::array< AuxItem, NumBranchTypes > AuxItemArray
unsigned int const maxFileSize_
BranchChildren const & branchChildren() const
virtual bool shouldWeCloseFile() const override
allow inheriting classes to override but still be able to call this method in the overridden version ...
virtual void respondToCloseInputFile(FileBlock const &fb) override
virtual bool isFileOpen() const override
virtual void write(EventPrincipal const &e, ModuleCallingContext const *) override
virtual void beginJob() override
virtual void reallyCloseFile() override
AuxItemArray const & auxItems() const
std::string const fileName_
virtual void writeLuminosityBlock(LuminosityBlockPrincipal const &lb, ModuleCallingContext const *) override
int const & treeMaxVirtualSize() const
std::array< OutputItemList, NumBranchTypes > OutputItemListArray
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)
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:101