CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/FWCore/Framework/interface/FileBlock.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_FileBlock_h
00002 #define FWCore_Framework_FileBlock_h
00003 
00004 /*----------------------------------------------------------------------
00005 
00006 FileBlock: Properties of an input file.
00007 
00008 ----------------------------------------------------------------------*/
00009 
00010 #include "DataFormats/Provenance/interface/FileFormatVersion.h"
00011 #include "DataFormats/Provenance/interface/BranchChildren.h"
00012 class TTree;
00013 #include "boost/array.hpp"
00014 #include "boost/shared_ptr.hpp"
00015 #include <string>
00016 
00017 namespace edm {
00018   class BranchDescription;
00019   class FileBlock {
00020   public:
00021     // bit mask for reasons fast cloning can be disabled or not applicable
00022     enum
00023     WhyNotFastClonable {
00024       CanFastClone = 0x0,
00025 
00026       // For entire job
00027       NoRootInputSource = 0x1,
00028       ParallelProcesses = (NoRootInputSource << 1),
00029       NotProcessingEvents = (ParallelProcesses << 1),
00030       HasSecondaryFileSequence = (NotProcessingEvents << 1),
00031 
00032       // For a given input file
00033       FileTooOld = (HasSecondaryFileSequence << 1),
00034       NoEventsInFile = (FileTooOld << 1),
00035       EventsToBeSorted = (NoEventsInFile << 1),
00036       RunOrLumiNotContiguous = (EventsToBeSorted << 1),
00037       EventsOrLumisSelectedByID = (RunOrLumiNotContiguous << 1),
00038       InitialEventsSkipped = (EventsOrLumisSelectedByID << 1),
00039       MaxEventsTooSmall = (InitialEventsSkipped << 1),
00040       MaxLumisTooSmall = (MaxEventsTooSmall << 1),
00041       RunNumberModified = (MaxLumisTooSmall << 1),
00042       DuplicateEventsRemoved = (RunNumberModified << 1),
00043 
00044       // The remainder of these are defined here for convenience,
00045       // but never set in FileBlock, because they are output module specific.
00046 
00047       // For a given output module
00048       DisabledInConfigFile = (DuplicateEventsRemoved << 1),
00049       EventSelectionUsed = (DisabledInConfigFile << 1),
00050 
00051       // For given input and output files
00052       OutputMaxEventsTooSmall = (EventSelectionUsed << 1),
00053       SplitLevelMismatch = (OutputMaxEventsTooSmall << 1),
00054       BranchMismatch = (SplitLevelMismatch << 1)
00055     };
00056 
00057     FileBlock() :
00058       fileFormatVersion_(),
00059       tree_(0), metaTree_(0),
00060       lumiTree_(0), lumiMetaTree_(0),
00061       runTree_(0), runMetaTree_(0),
00062       whyNotFastClonable_(NoRootInputSource),
00063       hasNewlyDroppedBranch_(),
00064       fileName_(),
00065       branchListIndexesUnchanged_(false),
00066       branchChildren_(new BranchChildren) {}
00067 
00068     FileBlock(FileFormatVersion const& version,
00069               TTree const* ev, TTree const* meta,
00070               TTree const* lumi, TTree const* lumiMeta,
00071               TTree const* run, TTree const* runMeta,
00072               int whyNotFastClonable,
00073               boost::array<bool, NumBranchTypes> const& hasNewlyDroppedBranch,
00074               std::string const& fileName,
00075               bool branchListIndexesUnchanged,
00076               boost::shared_ptr<BranchChildren> branchChildren) :
00077       fileFormatVersion_(version),
00078       tree_(const_cast<TTree*>(ev)),
00079       metaTree_(const_cast<TTree*>(meta)),
00080       lumiTree_(const_cast<TTree*>(lumi)),
00081       lumiMetaTree_(const_cast<TTree*>(lumiMeta)),
00082       runTree_(const_cast<TTree*>(run)),
00083       runMetaTree_(const_cast<TTree*>(runMeta)),
00084       whyNotFastClonable_(whyNotFastClonable),
00085       hasNewlyDroppedBranch_(hasNewlyDroppedBranch),
00086       fileName_(fileName),
00087       branchListIndexesUnchanged_(branchListIndexesUnchanged),
00088       branchChildren_(branchChildren) {}
00089 
00090     ~FileBlock() {}
00091 
00092     FileFormatVersion const& fileFormatVersion() const {return fileFormatVersion_;}
00093     TTree* const tree() const {return tree_;}
00094     TTree* const metaTree() const {return metaTree_;}
00095     TTree* const lumiTree() const {return lumiTree_;}
00096     TTree* const lumiMetaTree() const {return lumiMetaTree_;}
00097     TTree* const runTree() const {return runTree_;}
00098     TTree* const runMetaTree() const {return runMetaTree_;}
00099 
00100     int whyNotFastClonable() const {return whyNotFastClonable_;}
00101     boost::array<bool, NumBranchTypes> const& hasNewlyDroppedBranch() const {return hasNewlyDroppedBranch_;}
00102     std::string const& fileName() const {return fileName_;}
00103     bool branchListIndexesUnchanged() const {return branchListIndexesUnchanged_;}
00104 
00105     void setNotFastClonable(WhyNotFastClonable const& why) {
00106       whyNotFastClonable_ |= why;
00107     }
00108     BranchChildren const& branchChildren() const { return *branchChildren_; }
00109     void close () {runMetaTree_ = lumiMetaTree_ = metaTree_ = runTree_ = lumiTree_ = tree_ = 0;}
00110 
00111   private:
00112     FileFormatVersion fileFormatVersion_;
00113     // We use bare pointers because ROOT owns these.
00114     TTree* tree_;
00115     TTree* metaTree_;
00116     TTree* lumiTree_;
00117     TTree* lumiMetaTree_;
00118     TTree* runTree_;
00119     TTree* runMetaTree_;
00120     int whyNotFastClonable_;
00121     boost::array<bool, NumBranchTypes> hasNewlyDroppedBranch_;
00122     std::string fileName_;
00123     bool branchListIndexesUnchanged_;
00124     boost::shared_ptr<BranchChildren> branchChildren_;
00125   };
00126 }
00127 #endif