CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/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 <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     int const& basketSize() const {return basketSize_;}
00036     int const eventAutoFlushSize() const {return eventAutoFlushSize_;}
00037     int const& splitLevel() const {return splitLevel_;}
00038     std::string const& basketOrder() const {return basketOrder_;}
00039     int const& treeMaxVirtualSize() const {return treeMaxVirtualSize_;}
00040     bool const& overrideInputFileSplitLevels() const {return overrideInputFileSplitLevels_;}
00041     DropMetaData const& dropMetaData() const {return dropMetaData_;}
00042     std::string const& catalog() const {return catalog_;}
00043     std::string const& moduleLabel() const {return moduleLabel_;}
00044     unsigned int const& maxFileSize() const {return maxFileSize_;}
00045     int const& inputFileCount() const {return inputFileCount_;}
00046     int const& whyNotFastClonable() const {return whyNotFastClonable_;}
00047 
00048     std::string const& currentFileName() const;
00049 
00050     static void fillDescriptions(ConfigurationDescriptions& descriptions);
00051 
00052     using OutputModule::selectorConfig;
00053 
00054     struct AuxItem {
00055       AuxItem();
00056       ~AuxItem() {}
00057       int basketSize_;
00058     };
00059     typedef boost::array<AuxItem, NumBranchTypes> AuxItemArray;
00060     AuxItemArray const& auxItems() const {return auxItems_;}
00061 
00062     struct OutputItem {
00063       class Sorter {
00064       public:
00065         explicit Sorter(TTree* tree);
00066         bool operator() (OutputItem const& lh, OutputItem const& rh) const;
00067       private:
00068         boost::shared_ptr<std::map<std::string, int> > treeMap_;
00069       };
00070 
00071       OutputItem();
00072 
00073       explicit OutputItem(BranchDescription const* bd, int splitLevel, int basketSize);
00074 
00075       ~OutputItem() {}
00076 
00077       BranchID branchID() const { return branchDescription_->branchID(); }
00078       std::string const& branchName() const { return branchDescription_->branchName(); }
00079 
00080       bool operator <(OutputItem const& rh) const {
00081         return *branchDescription_ < *rh.branchDescription_;
00082       }
00083 
00084       BranchDescription const* branchDescription_;
00085       mutable void const* product_;
00086       int splitLevel_;
00087       int basketSize_;
00088     };
00089 
00090     typedef std::vector<OutputItem> OutputItemList;
00091 
00092     typedef boost::array<OutputItemList, NumBranchTypes> OutputItemListArray;
00093 
00094     OutputItemListArray const& selectedOutputItemList() const {return selectedOutputItemList_;}
00095 
00096   protected:
00098     virtual bool shouldWeCloseFile() const;
00099     virtual void write(EventPrincipal const& e);
00100   private:
00101     virtual void openFile(FileBlock const& fb);
00102     virtual void respondToOpenInputFile(FileBlock const& fb);
00103     virtual void respondToCloseInputFile(FileBlock const& fb);
00104     virtual void writeLuminosityBlock(LuminosityBlockPrincipal const& lb);
00105     virtual void writeRun(RunPrincipal const& r);
00106     virtual void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
00107     virtual bool isFileOpen() const;
00108     virtual void doOpenFile();
00109 
00110 
00111     virtual void startEndFile();
00112     virtual void writeFileFormatVersion();
00113     virtual void writeFileIdentifier();
00114     virtual void writeIndexIntoFile();
00115     virtual void writeProcessConfigurationRegistry();
00116     virtual void writeProcessHistoryRegistry();
00117     virtual void writeParameterSetRegistry();
00118     virtual void writeProductDescriptionRegistry();
00119     virtual void writeParentageRegistry();
00120     virtual void writeBranchIDListRegistry();
00121     virtual void writeProductDependencies();
00122     virtual void finishEndFile();
00123 
00124     void fillSelectedItemList(BranchType branchtype, TTree* theInputTree);
00125     void beginInputFile(FileBlock const& fb);
00126 
00127     RootServiceChecker rootServiceChecker_;
00128     AuxItemArray auxItems_;
00129     OutputItemListArray selectedOutputItemList_;
00130     std::string const fileName_;
00131     std::string const logicalFileName_;
00132     std::string const catalog_;
00133     unsigned int const maxFileSize_;
00134     int const compressionLevel_;
00135     int const basketSize_;
00136     int const eventAutoFlushSize_;
00137     int const splitLevel_;
00138     std::string basketOrder_;
00139     int const treeMaxVirtualSize_;
00140     int whyNotFastClonable_;
00141     DropMetaData dropMetaData_;
00142     std::string const moduleLabel_;
00143     bool initializedFromInput_;
00144     int outputFileCount_;
00145     int inputFileCount_;
00146     unsigned int childIndex_;
00147     unsigned int numberOfDigitsInIndex_;
00148     bool overrideInputFileSplitLevels_;
00149     boost::scoped_ptr<RootOutputFile> rootOutputFile_;
00150     std::string statusFileName_;
00151   };
00152 }
00153 
00154 #endif