CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/IOPool/Output/interface/PoolOutputModule.h

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