Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-19 01:43:41

0001 #ifndef FWCore_Framework_FileBlock_h
0002 #define FWCore_Framework_FileBlock_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 FileBlock: Properties of an input file.
0007 
0008 ----------------------------------------------------------------------*/
0009 
0010 #include "DataFormats/Provenance/interface/FileFormatVersion.h"
0011 #include "DataFormats/Provenance/interface/BranchChildren.h"
0012 #include "FWCore/Utilities/interface/BranchType.h"
0013 class TTree;
0014 #include <memory>
0015 #include <array>
0016 #include <string>
0017 #include <utility>
0018 #include <vector>
0019 
0020 namespace edm {
0021   class BranchDescription;
0022   class FileBlock {
0023   public:
0024     // bit mask for reasons fast cloning can be disabled or not applicable
0025     enum WhyNotFastClonable {
0026       CanFastClone = 0x0,
0027 
0028       // For entire job
0029       NoRootInputSource = 0x1,
0030       ParallelProcesses = (NoRootInputSource << 1),
0031       NotProcessingEvents = (ParallelProcesses << 1),
0032       HasSecondaryFileSequence = (NotProcessingEvents << 1),
0033 
0034       // For a given input file
0035       FileTooOld = (HasSecondaryFileSequence << 1),
0036       NoEventsInFile = (FileTooOld << 1),
0037       EventsToBeSorted = (NoEventsInFile << 1),
0038       RunOrLumiNotContiguous = (EventsToBeSorted << 1),
0039       EventsOrLumisSelectedByID = (RunOrLumiNotContiguous << 1),
0040       InitialEventsSkipped = (EventsOrLumisSelectedByID << 1),
0041       MaxEventsTooSmall = (InitialEventsSkipped << 1),
0042       MaxLumisTooSmall = (MaxEventsTooSmall << 1),
0043       RunNumberModified = (MaxLumisTooSmall << 1),
0044       DuplicateEventsRemoved = (RunNumberModified << 1),
0045 
0046       // The remainder of these are defined here for convenience,
0047       // but never set in FileBlock, because they are output module specific.
0048 
0049       // For a given output module
0050       DisabledInConfigFile = (DuplicateEventsRemoved << 1),
0051       EventSelectionUsed = (DisabledInConfigFile << 1),
0052 
0053       // For given input and output files
0054       OutputMaxEventsTooSmall = (EventSelectionUsed << 1),
0055       SplitLevelMismatch = (OutputMaxEventsTooSmall << 1),
0056       BranchMismatch = (SplitLevelMismatch << 1)
0057     };
0058 
0059     FileBlock()
0060         : fileFormatVersion_(),
0061           tree_(nullptr),
0062           metaTree_(nullptr),
0063           lumiTree_(nullptr),
0064           lumiMetaTree_(nullptr),
0065           runTree_(nullptr),
0066           runMetaTree_(nullptr),
0067           whyNotFastClonable_(NoRootInputSource),
0068           hasNewlyDroppedBranch_(),
0069           fileName_(),
0070           branchListIndexesUnchanged_(false),
0071           modifiedIDs_(false),
0072           branchChildren_(new BranchChildren) {}
0073 
0074     FileBlock(FileFormatVersion const& version,
0075               TTree* ev,
0076               TTree* meta,
0077               TTree* lumi,
0078               TTree* lumiMeta,
0079               TTree* run,
0080               TTree* runMeta,
0081               std::vector<TTree*> processBlockTrees,
0082               std::vector<std::string> processesWithProcessBlockTrees,
0083               int whyNotFastClonable,
0084               std::array<bool, NumBranchTypes> const& hasNewlyDroppedBranch,
0085               std::string const& fileName,
0086               bool branchListIndexesUnchanged,
0087               bool modifiedIDs,
0088               std::shared_ptr<BranchChildren const> branchChildren)
0089         : fileFormatVersion_(version),
0090           tree_(ev),
0091           metaTree_(meta),
0092           lumiTree_(lumi),
0093           lumiMetaTree_(lumiMeta),
0094           runTree_(run),
0095           runMetaTree_(runMeta),
0096           processBlockTrees_(std::move(processBlockTrees)),
0097           processesWithProcessBlockTrees_(std::move(processesWithProcessBlockTrees)),
0098           whyNotFastClonable_(whyNotFastClonable),
0099           hasNewlyDroppedBranch_(hasNewlyDroppedBranch),
0100           fileName_(fileName),
0101           branchListIndexesUnchanged_(branchListIndexesUnchanged),
0102           modifiedIDs_(modifiedIDs),
0103           branchChildren_(branchChildren) {}
0104 
0105     ~FileBlock() {}
0106 
0107     void updateTTreePointers(TTree* ev,
0108                              TTree* meta,
0109                              TTree* lumi,
0110                              TTree* lumiMeta,
0111                              TTree* run,
0112                              TTree* runMeta,
0113                              std::vector<TTree*> processBlockTrees,
0114                              std::vector<std::string> processesWithProcessBlockTrees);
0115 
0116     FileFormatVersion const& fileFormatVersion() const { return fileFormatVersion_; }
0117     TTree* tree() const { return tree_; }
0118     TTree* metaTree() const { return metaTree_; }
0119     TTree* lumiTree() const { return lumiTree_; }
0120     TTree* lumiMetaTree() const { return lumiMetaTree_; }
0121     TTree* runTree() const { return runTree_; }
0122     TTree* runMetaTree() const { return runMetaTree_; }
0123     TTree* processBlockTree(std::string const& processName) const;
0124 
0125     std::vector<TTree*> const& processBlockTrees() const { return processBlockTrees_; }
0126     std::vector<std::string> const& processesWithProcessBlockTrees() const { return processesWithProcessBlockTrees_; }
0127 
0128     int whyNotFastClonable() const { return whyNotFastClonable_; }
0129     std::array<bool, NumBranchTypes> const& hasNewlyDroppedBranch() const { return hasNewlyDroppedBranch_; }
0130     std::string const& fileName() const { return fileName_; }
0131     bool branchListIndexesUnchanged() const { return branchListIndexesUnchanged_; }
0132     bool modifiedIDs() const { return modifiedIDs_; }
0133 
0134     void setNotFastClonable(WhyNotFastClonable const& why) { whyNotFastClonable_ |= why; }
0135     BranchChildren const& branchChildren() const { return *branchChildren_; }
0136     void close();
0137 
0138   private:
0139     FileFormatVersion fileFormatVersion_;
0140     // We use bare pointers because ROOT owns these.
0141     TTree* tree_;
0142     TTree* metaTree_;
0143     TTree* lumiTree_;
0144     TTree* lumiMetaTree_;
0145     TTree* runTree_;
0146     TTree* runMetaTree_;
0147     std::vector<TTree*> processBlockTrees_;
0148     std::vector<std::string> processesWithProcessBlockTrees_;
0149     int whyNotFastClonable_;
0150     std::array<bool, NumBranchTypes> hasNewlyDroppedBranch_;
0151     std::string fileName_;
0152     bool branchListIndexesUnchanged_;
0153     bool modifiedIDs_;
0154     std::shared_ptr<BranchChildren const> branchChildren_;
0155   };
0156 }  // namespace edm
0157 #endif