Go to the documentation of this file.00001 #ifndef IOPool_Output_PoolOutputModule_h
00002 #define IOPool_Output_PoolOutputModule_h
00003
00005
00006
00007
00008
00009
00010
00012
00013 #include <string>
00014 #include "boost/scoped_ptr.hpp"
00015 #include "boost/shared_ptr.hpp"
00016
00017 #include "IOPool/Common/interface/RootServiceChecker.h"
00018 #include "FWCore/Framework/interface/Frameworkfwd.h"
00019 #include "FWCore/Framework/interface/OutputModule.h"
00020
00021 class TTree;
00022 namespace edm {
00023 class ParameterSet;
00024 class RootOutputFile;
00025 class ConfigurationDescriptions;
00026
00027 class PoolOutputModule : public OutputModule {
00028 public:
00029 enum DropMetaData { DropNone, DropDroppedPrior, DropPrior, DropAll };
00030 explicit PoolOutputModule(ParameterSet const& ps);
00031 virtual ~PoolOutputModule();
00032 std::string const& fileName() const {return fileName_;}
00033 std::string const& logicalFileName() const {return logicalFileName_;}
00034 int const& compressionLevel() const {return compressionLevel_;}
00035 std::string const& compressionAlgorithm() const {return compressionAlgorithm_;}
00036 int const& basketSize() const {return basketSize_;}
00037 int const eventAutoFlushSize() const {return eventAutoFlushSize_;}
00038 int const& splitLevel() const {return splitLevel_;}
00039 std::string const& basketOrder() const {return basketOrder_;}
00040 int const& treeMaxVirtualSize() const {return treeMaxVirtualSize_;}
00041 bool const& overrideInputFileSplitLevels() const {return overrideInputFileSplitLevels_;}
00042 DropMetaData const& dropMetaData() const {return dropMetaData_;}
00043 std::string const& catalog() const {return catalog_;}
00044 std::string const& moduleLabel() const {return moduleLabel_;}
00045 unsigned int const& maxFileSize() const {return maxFileSize_;}
00046 int const& inputFileCount() const {return inputFileCount_;}
00047 int const& whyNotFastClonable() const {return whyNotFastClonable_;}
00048
00049 std::string const& currentFileName() const;
00050
00051 static void fillDescriptions(ConfigurationDescriptions& descriptions);
00052
00053 using OutputModule::selectorConfig;
00054
00055 struct AuxItem {
00056 AuxItem();
00057 ~AuxItem() {}
00058 int basketSize_;
00059 };
00060 typedef boost::array<AuxItem, NumBranchTypes> AuxItemArray;
00061 AuxItemArray const& auxItems() const {return auxItems_;}
00062
00063 struct OutputItem {
00064 class Sorter {
00065 public:
00066 explicit Sorter(TTree* tree);
00067 bool operator() (OutputItem const& lh, OutputItem const& rh) const;
00068 private:
00069 boost::shared_ptr<std::map<std::string, int> > treeMap_;
00070 };
00071
00072 OutputItem();
00073
00074 explicit OutputItem(BranchDescription const* bd, int splitLevel, int basketSize);
00075
00076 ~OutputItem() {}
00077
00078 BranchID branchID() const { return branchDescription_->branchID(); }
00079 std::string const& branchName() const { return branchDescription_->branchName(); }
00080
00081 bool operator <(OutputItem const& rh) const {
00082 return *branchDescription_ < *rh.branchDescription_;
00083 }
00084
00085 BranchDescription const* branchDescription_;
00086 mutable void const* product_;
00087 int splitLevel_;
00088 int basketSize_;
00089 };
00090
00091 typedef std::vector<OutputItem> OutputItemList;
00092
00093 typedef boost::array<OutputItemList, NumBranchTypes> OutputItemListArray;
00094
00095 OutputItemListArray const& selectedOutputItemList() const {return selectedOutputItemList_;}
00096
00097 protected:
00099 virtual bool shouldWeCloseFile() const;
00100 virtual void write(EventPrincipal const& e);
00101 private:
00102 virtual void openFile(FileBlock const& fb);
00103 virtual void respondToOpenInputFile(FileBlock const& fb);
00104 virtual void respondToCloseInputFile(FileBlock const& fb);
00105 virtual void writeLuminosityBlock(LuminosityBlockPrincipal const& lb);
00106 virtual void writeRun(RunPrincipal const& r);
00107 virtual void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
00108 virtual bool isFileOpen() const;
00109 virtual void doOpenFile();
00110 virtual void beginJob();
00111
00112 virtual void startEndFile();
00113 virtual void writeFileFormatVersion();
00114 virtual void writeFileIdentifier();
00115 virtual void writeIndexIntoFile();
00116 virtual void writeProcessConfigurationRegistry();
00117 virtual void writeProcessHistoryRegistry();
00118 virtual void writeParameterSetRegistry();
00119 virtual void writeProductDescriptionRegistry();
00120 virtual void writeParentageRegistry();
00121 virtual void writeBranchIDListRegistry();
00122 virtual void writeProductDependencies();
00123 virtual void finishEndFile();
00124
00125 void fillSelectedItemList(BranchType branchtype, TTree* theInputTree);
00126 void beginInputFile(FileBlock const& fb);
00127
00128 RootServiceChecker rootServiceChecker_;
00129 AuxItemArray auxItems_;
00130 OutputItemListArray selectedOutputItemList_;
00131 std::string const fileName_;
00132 std::string const logicalFileName_;
00133 std::string const catalog_;
00134 unsigned int const maxFileSize_;
00135 int const compressionLevel_;
00136 std::string const compressionAlgorithm_;
00137 int const basketSize_;
00138 int const eventAutoFlushSize_;
00139 int const splitLevel_;
00140 std::string basketOrder_;
00141 int const treeMaxVirtualSize_;
00142 int whyNotFastClonable_;
00143 DropMetaData dropMetaData_;
00144 std::string const moduleLabel_;
00145 bool initializedFromInput_;
00146 int outputFileCount_;
00147 int inputFileCount_;
00148 unsigned int childIndex_;
00149 unsigned int numberOfDigitsInIndex_;
00150 bool overrideInputFileSplitLevels_;
00151 boost::scoped_ptr<RootOutputFile> rootOutputFile_;
00152 std::string statusFileName_;
00153 };
00154 }
00155
00156 #endif