CMS 3D CMS Logo

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