40 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
41 #include "Compression.h"
52 sorterForJobReportHash(BranchDescription
const*
lh, BranchDescription
const* rh) {
54 lh->fullClassName() < rh->fullClassName() ?
true :
55 lh->fullClassName() > rh->fullClassName() ?
false :
56 lh->moduleLabel() < rh->moduleLabel() ?
true :
57 lh->moduleLabel() > rh->moduleLabel() ?
false :
58 lh->productInstanceName() < rh->productInstanceName() ?
true :
59 lh->productInstanceName() > rh->productInstanceName() ?
false :
60 lh->processName() < rh->processName() ?
true :
67 logicalFile_(logicalFileName),
70 whyNotFastClonable_(om_->whyNotFastClonable()),
71 canFastCloneAux_(
false),
72 filePtr_(TFile::Open(file_.c_str(),
"recreate",
"", om_->compressionLevel())),
74 eventEntryNumber_(0LL),
75 lumiEntryNumber_(0LL),
79 parameterSetsTree_(0),
86 eventEntryInfoVector_(),
87 pEventEntryInfoVector_(&eventEntryInfoVector_),
88 pBranchListIndexes_(0),
89 pEventSelectionIDs_(0),
92 runTree_(filePtr_,
InRun, om_->
splitLevel(), om_->treeMaxVirtualSize()),
94 dataTypeReported_(
false),
96 branchesWithStoredHistory_() {
97 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
99 filePtr_->SetCompressionAlgorithm(ROOT::kZLIB);
101 filePtr_->SetCompressionAlgorithm(ROOT::kLZMA);
104 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
144 it->branchDescription_->produced());
161 std::vector<std::string> branchNames;
162 std::vector<BranchDescription const*> branches;
168 branchNames.push_back(it->branchDescription_->branchName());
169 branches.push_back(it->branchDescription_);
172 sort_all(branches, sorterForJobReportHash);
174 std::ostringstream oss;
175 char const underscore =
'_';
176 for(std::vector<BranchDescription const*>::const_iterator it = branches.begin(), itEnd = branches.end(); it != itEnd; ++it) {
206 if ((whyNotFastClonable &
214 bool isWarning =
true;
216 message <<
"Fast copying of file " << ifileName <<
" to file " << ofileName <<
" is disabled because:\n";
218 message <<
"a SecondaryFileSequence was specified.\n";
223 message <<
"the input file is in an old format.\n";
228 message <<
"events need to be sorted.\n";
232 message <<
"a run or a lumi is not contiguous in the input file.\n";
236 message <<
"events or lumis were selected or skipped by ID.\n";
241 message <<
"initial events, lumis or runs were skipped.\n";
246 message <<
"some events were skipped because of duplicate checking.\n";
250 message <<
"some events were not copied because of maxEvents limit.\n";
255 message <<
"some events were not copied because of maxLumis limit.\n";
260 message <<
"parallel processing was specified.\n";
265 message <<
"an EventSelector was specified.\n";
270 message <<
"some events were not copied because of maxEvents output limit.\n";
275 message <<
"the split level or basket size of a branch or branches was modified.\n";
279 message <<
"The format of a data product has changed.\n";
284 LogWarning(
"FastCloningDisabled") << message.str();
286 LogInfo(
"FastCloningDisabled") << message.str();
301 if(remainingEvents >= 0 && remainingEvents < fb.
tree()->GetEntries()) {
318 "Merge failure because input file " <<
file_ <<
" has different ROOT split levels or basket sizes\n" <<
319 "than previous files. To allow merging in splite of this, use the configuration parameter\n" <<
320 "overrideInputFileSplitLevels=cms.untracked.bool(True)\n" <<
321 "in every PoolOutputModule.\n";
379 unsigned int const oneK = 1024;
462 <<
"Failed to create a branch for Parentages in the output file";
470 for(std::map<ParentageID,unsigned int>::const_iterator it =
parentageIDs_.begin(),
474 orderedIDs[it->second]=it->first;
477 for(std::vector<ParentageID>::const_iterator it = orderedIDs.begin(),
478 itEnd = orderedIDs.end();
507 ex <<
"The number of entries in at least one output TBranch whose entries\n"
508 "were copied from the input does not match the number of events\n"
509 "recorded in IndexIntoFile. This might (or might not) indicate a\n"
510 "problem related to fast copy.";
511 ex.
addContext(
"Calling RootOutputFile::writeIndexIntoFile");
525 for(Map::const_iterator
i = procConfigMap.begin(),
e = procConfigMap.end();
i !=
e; ++
i) {
526 procConfigVector.push_back(
i->second);
539 for(Map::const_iterator
i = procHistoryMap.begin(),
e = procHistoryMap.end();
i !=
e; ++
i) {
540 procHistoryVector.push_back(
i->second);
556 std::pair<ParameterSetID, ParameterSetBlob> idToBlob;
557 std::pair<ParameterSetID, ParameterSetBlob>* pIdToBlob = &idToBlob;
564 idToBlob.first = it->first;
565 idToBlob.second.pset() = it->second.toString();
576 ProductList& pList =
const_cast<ProductList &
>(pReg.productList());
577 for(
auto const&
prod : pList) {
578 if(
prod.second.branchID() !=
prod.second.originalBranchID()) {
585 for(ProductList::iterator it = pList.begin(); it != pList.end();) {
588 ProductList::iterator itCopy = it;
644 if(tree && tree->GetNbranches() != 0) {
645 for(Selections::const_iterator
i = branches.
begin(), iEnd = branches.
end();
652 tree->SetAlias(alias.c_str(), full.c_str());
655 for(; it != itEnd; ++it) {
656 tree->SetAlias((*it).c_str(), full.c_str());
667 std::set<StoredProductProvenance>& oToFill) {
673 for(std::vector<BranchID>::const_iterator it = parentIDs.begin(), itEnd = parentIDs.end();
694 typedef std::vector<std::pair<TClass*, void const*> > Dummies;
701 std::set<StoredProductProvenance> provenanceToKeep;
704 for(OutputItemList::const_iterator
i = items.begin(), iEnd = items.end();
i != iEnd; ++
i) {
706 BranchID const&
id =
i->branchDescription_->branchID();
709 bool produced =
i->branchDescription_->produced();
710 bool keepProvenance = productProvenanceVecPtr != 0 &&
714 bool getProd = (produced || !fastCloning ||
717 void const* product = 0;
723 assert(eventPrincipal.branchMapperPtr());
731 TClass*
cp = gROOT->GetClass(
i->branchDescription_->wrappedName().c_str());
733 dummies.emplace_back(cp, product);
735 i->product_ = product;
739 if(productProvenanceVecPtr != 0) productProvenanceVecPtr->assign(provenanceToKeep.begin(), provenanceToKeep.end());
741 if(productProvenanceVecPtr != 0) productProvenanceVecPtr->clear();
742 for(Dummies::iterator it = dummies.begin(), itEnd = dummies.end(); it != itEnd; ++it) {
743 it->first->Destructor(const_cast<void *>(it->second));
749 std::set<edm::StoredProductProvenance>& oToInsert) {
752 std::set<edm::StoredProductProvenance>::iterator itFound = oToInsert.find(toStore);
753 if(itFound == oToInsert.end()) {
759 <<
"RootOutputFile::insertProductProvenance\n"
760 <<
"The parentage ID index value " << toStore.
parentageIDIndex_ <<
" is out of bounds. The maximum value is currently " <<
parentageIDs_.size()-1 <<
".\n"
761 <<
"This should never happen.\n"
762 <<
"Please report this to the framework hypernews forum 'hn-cms-edmFramework@cern.ch'.\n";
765 oToInsert.insert(toStore);
ProductProvenance const * branchIDToProvenance(BranchID const &bid) const
EventNumber_t event() const
std::string const & idToParameterSetBlobsBranchName()
void beginInputFile(FileBlock const &fb, int remainingEvents)
BranchID const & branchID() const
LuminosityBlockAuxiliary lumiAux_
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
int const & basketSize() const
SelectionsArray const & keptProducts() const
EventSelectionIDVector const & eventSelectionIDs() const
bool const & overrideInputFileSplitLevels() const
std::string const & parentageTreeName()
std::vector< BranchIDList > BranchIDLists
int eventAutoFlushSize() const
std::string const & catalog() const
void writeProcessHistoryRegistry()
void writeOne(EventPrincipal const &e)
std::string & branchName() const
static ThreadSafeRegistry * instance()
std::string const & moduleLabel() const
DropMetaData const & dropMetaData() const
void writeProcessConfigurationRegistry()
std::map< BranchKey, BranchDescription > ProductList
bool checkSplitLevelsAndBasketSizes(TTree *inputTree) const
EventID const & id() const
ProductProvenance const * productProvenance() const
int whyNotFastClonable() const
bool getMapped(key_type const &k, value_type &result) const
void insertAncestors(ProductProvenance const &iGetParents, EventPrincipal const &principal, bool produced, std::set< StoredProductProvenance > &oToFill)
LuminosityBlockAuxiliary const & aux() const
std::string const & fileFormatVersionBranchName()
OutputItemListArray const & selectedOutputItemList() const
std::string const & processName() const
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName, BranchDescription::MatchMode m)
std::string const & eventSelectionsBranchName()
unsigned int const & maxFileSize() const
void setBranchAliases(TTree *tree, Selections const &branches) const
void setAutoFlush(Long64_t size)
bool insertMapped(value_type const &v)
BranchListIndexes const & branchListIndexes() const
bool shouldWeCloseFile() const
bool checkIfFastClonable(TTree *inputTree) const
void addBranch(std::string const &branchName, std::string const &className, WrapperInterfaceBase const *interface, void const *&pProd, int splitLevel, int basketSize, bool produced)
std::set< BranchID > branchesWithStoredHistory_
std::vector< EventSelectionID > EventSelectionIDVector
void sortVector_Run_Or_Lumi_Entries()
LuminosityBlockNumber_t luminosityBlock() const
std::string const & parameterSetsTreeName()
ProcessConfigurationRegistry::vector_type ProcessConfigurationVector
bool wantAllEvents() const
std::vector< BranchID > const & parents() const
unsigned int parentageIDIndex_
std::map< ParentageID, unsigned int > parentageIDs_
RootOutputTree eventTree_
std::map< key_type, value_type > collection_type
std::vector< BranchListIndex > BranchListIndexes
void writeRun(RunPrincipal const &r)
const_iterator begin() const
PoolOutputModule const * om_
std::string const & compressionAlgorithm() const
std::string const & moduleLabel() const
boost::shared_ptr< BranchMapper > branchMapperPtr() const
IndexIntoFile::EntryNumber_t eventEntryNumber_
std::string const & productInstanceName() const
ProcessHistoryID const & processHistoryID() const
LuminosityBlockAuxiliary const * pLumiAux_
std::string const & indexIntoFileBranchName()
collection_type::const_iterator const_iterator
std::string const & basketOrder() const
void fillBranches(BranchType const &branchType, Principal const &principal, StoredProductProvenanceVector *productProvenanceVecPtr)
int getFileFormatVersion()
void const * wrapper() const
bool checkEntriesInReadBranches(Long64_t expectedNumberOfEntries) const
OutputHandle getForOutput(BranchID const &bid, bool getProd) const
ProcessHistoryRegistry::vector_type ProcessHistoryVector
WrapperInterfaceBase const * getInterface() const
RunAuxiliary const & aux() const
void setProcessHistoryID(ProcessHistoryID const &phid)
std::string const & metaDataTreeName()
std::string & wrappedName() const
PoolOutputModule::OutputItemList OutputItemList
LuminosityBlockNumber_t luminosityBlock() const
void addEntry(ProcessHistoryID const &processHistoryID, RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
void writeProductDependencies()
void writeBranchIDListRegistry()
static TTree * makeTTree(TFile *filePtr, std::string const &name, int splitLevel)
int const & whyNotFastClonable() const
std::string const & fullClassName() const
std::string const & processHistoryBranchName()
EventSelectionIDVector const * pEventSelectionIDs_
StoredProductProvenanceVector * pEventEntryInfoVector_
void writeIndexIntoFile()
void writeFileIdentifier()
eventsetup::produce::Produce produced
BranchChildren const & branchChildren() const
Provenance getProvenance(ProductID const &pid) const
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
std::string toString() const
std::string const & parentageBranchName()
void addContext(std::string const &context)
AuxItemArray const & auxItems() const
std::set< std::string > const & branchAliases() const
bool insertProductProvenance(const ProductProvenance &, std::set< StoredProductProvenance > &oToInsert)
void addAuxiliary(std::string const &branchName, T const *&pAux, int bufSize, bool allowCloning=true)
std::vector< StoredProductProvenance > StoredProductProvenanceVector
void writeParameterSetRegistry()
void respondToCloseInputFile(FileBlock const &fb)
IndexIntoFile indexIntoFile_
std::string const & productDescriptionBranchName()
IndexIntoFile::EntryNumber_t runEntryNumber_
std::string const & processConfigurationBranchName()
void writeLuminosityBlock(LuminosityBlockPrincipal const &lb)
TTree * parameterSetsTree_
ParentageID const & parentageID() const
static void writeTTree(TTree *tree)
ProcessHistoryID const & processHistoryID() const
EventAuxiliary const * pEventAux_
BranchIDLists const * branchIDLists() const
void writeParentageRegistry()
void writeProductDescriptionRegistry()
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
std::string const & productDependenciesBranchName()
const_iterator end() const
RootOutputFile(PoolOutputModule *om, std::string const &fileName, std::string const &logicalFileName)
std::string const & branchIDListBranchName()
void setProcessHistoryID(ProcessHistoryID const &phid)
std::string const & branchListIndexesBranchName()
void writeFileFormatVersion()
Parentage const & parentage() const
RootOutputTreePtrArray treePointers_
BranchListIndexes const * pBranchListIndexes_
collection_type & data()
Provide access to the contained collection.
void maybeFastCloneTree(bool canFastClone, bool canFastCloneAux, TTree *tree, std::string const &option)
IndexIntoFile::EntryNumber_t lumiEntryNumber_
boost::shared_ptr< TFile > filePtr_
void optimizeBaskets(ULong64_t size)
EventAuxiliary const & aux() const
std::string const & fileIdentifierBranchName()
RunAuxiliary const * pRunAux_
tuple size
Write out results.
EventNumber_t event() const
int const & inputFileCount() const
JobReport::Token reportToken_
std::string createGlobalIdentifier()
std::string const & fileName() const
ParameterSetID selectorConfig() const