CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/IOPool/Output/src/RootOutputFile.h

Go to the documentation of this file.
00001 #ifndef IOPool_Output_RootOutputFile_h
00002 #define IOPool_Output_RootOutputFile_h
00003 
00005 //
00006 // Class RootOutputFile
00007 //
00008 // Current Author: Bill Tanenbaum
00009 //
00011 
00012 #include <array>
00013 #include <map>
00014 #include <string>
00015 #include <vector>
00016 
00017 #include "boost/shared_ptr.hpp"
00018 
00019 #include "FWCore/Framework/interface/Frameworkfwd.h"
00020 #include "FWCore/MessageLogger/interface/JobReport.h"
00021 #include "DataFormats/Provenance/interface/BranchListIndex.h"
00022 #include "DataFormats/Provenance/interface/EventSelectionID.h"
00023 #include "DataFormats/Provenance/interface/FileID.h"
00024 #include "DataFormats/Provenance/interface/IndexIntoFile.h"
00025 #include "DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h"
00026 #include "DataFormats/Provenance/interface/ParentageID.h"
00027 #include "DataFormats/Provenance/interface/ProductProvenance.h"
00028 #include "DataFormats/Provenance/interface/StoredProductProvenance.h"
00029 #include "DataFormats/Provenance/interface/RunAuxiliary.h"
00030 #include "DataFormats/Provenance/interface/Selections.h"
00031 #include "IOPool/Output/interface/PoolOutputModule.h"
00032 #include "IOPool/Output/src/RootOutputTree.h"
00033 
00034 class TTree;
00035 class TFile;
00036 
00037 namespace edm {
00038   class PoolOutputModule;
00039 
00040   class RootOutputFile {
00041   public:
00042     typedef PoolOutputModule::OutputItem OutputItem;
00043     typedef PoolOutputModule::OutputItemList OutputItemList;
00044     typedef std::array<RootOutputTree*, NumBranchTypes> RootOutputTreePtrArray;
00045     explicit RootOutputFile(PoolOutputModule* om, std::string const& fileName,
00046                             std::string const& logicalFileName);
00047     ~RootOutputFile() {}
00048     void writeOne(EventPrincipal const& e);
00049     //void endFile();
00050     void writeLuminosityBlock(LuminosityBlockPrincipal const& lb);
00051     void writeRun(RunPrincipal const& r);
00052     void writeFileFormatVersion();
00053     void writeFileIdentifier();
00054     void writeIndexIntoFile();
00055     void writeProcessConfigurationRegistry();
00056     void writeProcessHistoryRegistry();
00057     void writeParameterSetRegistry();
00058     void writeProductDescriptionRegistry();
00059     void writeParentageRegistry();
00060     void writeBranchIDListRegistry();
00061     void writeProductDependencies();
00062 
00063     void finishEndFile();
00064     void beginInputFile(FileBlock const& fb, int remainingEvents);
00065     void respondToCloseInputFile(FileBlock const& fb);
00066     bool shouldWeCloseFile() const;
00067 
00068     std::string const& fileName() const {return file_;}
00069 
00070   private:
00071 
00072     //-------------------------------
00073     // Local types
00074     //
00075 
00076     //-------------------------------
00077     // Private functions
00078 
00079     void setBranchAliases(TTree* tree, Selections const& branches) const;
00080 
00081     void fillBranches(BranchType const& branchType,
00082                       Principal const& principal,
00083                       StoredProductProvenanceVector* productProvenanceVecPtr);
00084 
00085      void insertAncestors(ProductProvenance const& iGetParents,
00086                           EventPrincipal const& principal,
00087                           bool produced,
00088                           std::set<StoredProductProvenance>& oToFill);
00089 
00090     bool insertProductProvenance(const ProductProvenance&,
00091                                  std::set<StoredProductProvenance>& oToInsert);
00092     //-------------------------------
00093     // Member data
00094 
00095     std::string file_;
00096     std::string logicalFile_;
00097     JobReport::Token reportToken_;
00098     PoolOutputModule const* om_;
00099     int whyNotFastClonable_;
00100     bool canFastCloneAux_;
00101     boost::shared_ptr<TFile> filePtr_;
00102     FileID fid_;
00103     IndexIntoFile::EntryNumber_t eventEntryNumber_;
00104     IndexIntoFile::EntryNumber_t lumiEntryNumber_;
00105     IndexIntoFile::EntryNumber_t runEntryNumber_;
00106     IndexIntoFile indexIntoFile_;
00107     TTree* metaDataTree_;
00108     TTree* parameterSetsTree_;
00109     TTree* parentageTree_;
00110     LuminosityBlockAuxiliary  lumiAux_;
00111     RunAuxiliary              runAux_;
00112     EventAuxiliary const*           pEventAux_;
00113     LuminosityBlockAuxiliary const* pLumiAux_;
00114     RunAuxiliary const*             pRunAux_;
00115     StoredProductProvenanceVector eventEntryInfoVector_;
00116     StoredProductProvenanceVector*        pEventEntryInfoVector_;
00117     BranchListIndexes const*        pBranchListIndexes_;
00118     EventSelectionIDVector const*   pEventSelectionIDs_;
00119     RootOutputTree eventTree_;
00120     RootOutputTree lumiTree_;
00121     RootOutputTree runTree_;
00122     RootOutputTreePtrArray treePointers_;
00123     bool dataTypeReported_;
00124     std::map<ParentageID,unsigned int> parentageIDs_;
00125     std::set<BranchID> branchesWithStoredHistory_;
00126   };
00127 
00128 }
00129 
00130 #endif