41 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
42 #include "Compression.h"
53 sorterForJobReportHash(BranchDescription
const*
lh, BranchDescription
const* rh) {
55 lh->fullClassName() < rh->fullClassName() ?
true :
56 lh->fullClassName() > rh->fullClassName() ?
false :
57 lh->moduleLabel() < rh->moduleLabel() ?
true :
58 lh->moduleLabel() > rh->moduleLabel() ?
false :
59 lh->productInstanceName() < rh->productInstanceName() ?
true :
60 lh->productInstanceName() > rh->productInstanceName() ?
false :
61 lh->processName() < rh->processName() ?
true :
68 logicalFile_(logicalFileName),
71 whyNotFastClonable_(om_->whyNotFastClonable()),
72 canFastCloneAux_(
false),
73 filePtr_(TFile::Open(file_.c_str(),
"recreate",
"", om_->compressionLevel())),
75 eventEntryNumber_(0LL),
76 lumiEntryNumber_(0LL),
87 eventEntryInfoVector_(),
88 pEventEntryInfoVector_(&eventEntryInfoVector_),
93 runTree_(filePtr_,
InRun, om_->
splitLevel(), om_->treeMaxVirtualSize()),
95 dataTypeReported_(
false),
96 processHistoryRegistry_(),
98 branchesWithStoredHistory_() {
99 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
101 filePtr_->SetCompressionAlgorithm(ROOT::kZLIB);
103 filePtr_->SetCompressionAlgorithm(ROOT::kLZMA);
106 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
135 item.product_ =
nullptr;
143 item.branchDescription_->produced());
160 std::vector<std::string> branchNames;
161 std::vector<BranchDescription const*> branches;
165 branchNames.push_back(item.branchDescription_->branchName());
166 branches.push_back(item.branchDescription_);
169 sort_all(branches, sorterForJobReportHash);
171 std::ostringstream oss;
172 char const underscore =
'_';
173 for(
auto const& branch : branches) {
203 if ((whyNotFastClonable &
211 bool isWarning =
true;
213 message <<
"Fast copying of file " << ifileName <<
" to file " << ofileName <<
" is disabled because:\n";
215 message <<
"a SecondaryFileSequence was specified.\n";
220 message <<
"the input file is in an old format.\n";
225 message <<
"events need to be sorted.\n";
229 message <<
"a run or a lumi is not contiguous in the input file.\n";
233 message <<
"events or lumis were selected or skipped by ID.\n";
238 message <<
"initial events, lumis or runs were skipped.\n";
243 message <<
"some events were skipped because of duplicate checking.\n";
247 message <<
"some events were not copied because of maxEvents limit.\n";
252 message <<
"some events were not copied because of maxLumis limit.\n";
257 message <<
"parallel processing was specified.\n";
262 message <<
"an EventSelector was specified.\n";
267 message <<
"some events were not copied because of maxEvents output limit.\n";
272 message <<
"the split level or basket size of a branch or branches was modified.\n";
276 message <<
"The format of a data product has changed.\n";
281 LogWarning(
"FastCloningDisabled") << message.str();
283 LogInfo(
"FastCloningDisabled") << message.str();
294 if(fb.
tree() !=
nullptr) {
298 if(remainingEvents >= 0 && remainingEvents < fb.
tree()->GetEntries()) {
315 "Merge failure because input file " <<
file_ <<
" has different ROOT split levels or basket sizes\n" <<
316 "than previous files. To allow merging in splite of this, use the configuration parameter\n" <<
317 "overrideInputFileSplitLevels=cms.untracked.bool(True)\n" <<
318 "in every PoolOutputModule.\n";
376 unsigned int const oneK = 1024;
472 <<
"Failed to create a branch for Parentages in the output file";
478 orderedIDs[parentageID.second] = parentageID.first;
481 for(
auto const& orderedID : orderedIDs) {
508 ex <<
"The number of entries in at least one output TBranch whose entries\n"
509 "were copied from the input does not match the number of events\n"
510 "recorded in IndexIntoFile. This might (or might not) indicate a\n"
511 "problem related to fast copy.";
512 ex.
addContext(
"Calling RootOutputFile::writeIndexIntoFile");
525 procHistoryVector.push_back(ph.second);
541 std::pair<ParameterSetID, ParameterSetBlob> idToBlob;
542 std::pair<ParameterSetID, ParameterSetBlob>* pIdToBlob = &idToBlob;
546 idToBlob.first = pset.first;
547 idToBlob.second.pset() = pset.second.toString();
558 ProductList& pList =
const_cast<ProductList &
>(pReg.productList());
559 for(
auto const&
prod : pList) {
560 if(
prod.second.branchID() !=
prod.second.originalBranchID()) {
567 for(ProductList::iterator it = pList.begin(); it != pList.end();) {
570 ProductList::iterator itCopy = it;
612 treePointer->close();
613 treePointer =
nullptr;
626 if(tree && tree->GetNbranches() != 0) {
633 tree->SetAlias(alias.c_str(), full.c_str());
636 tree->SetAlias(alias.c_str(), full.c_str());
647 std::set<StoredProductProvenance>& oToFill,
654 for(
auto const& parentID : parentIDs) {
675 typedef std::vector<std::pair<TClass*, void const*> > Dummies;
682 std::set<StoredProductProvenance> provenanceToKeep;
685 for(
auto const& item : items) {
687 BranchID const&
id = item.branchDescription_->branchID();
690 bool produced = item.branchDescription_->produced();
691 bool keepProvenance = productProvenanceVecPtr !=
nullptr &&
695 bool getProd = (produced || !fastCloning ||
698 void const* product =
nullptr;
704 assert(eventPrincipal.productProvenanceRetrieverPtr());
709 if(product ==
nullptr) {
712 TClass*
cp = gROOT->GetClass(item.branchDescription_->wrappedName().c_str());
714 dummies.emplace_back(cp, product);
716 item.product_ = product;
720 if(productProvenanceVecPtr !=
nullptr) productProvenanceVecPtr->assign(provenanceToKeep.begin(), provenanceToKeep.end());
722 if(productProvenanceVecPtr !=
nullptr) productProvenanceVecPtr->clear();
723 for(
auto& dummy : dummies) {
724 dummy.first->Destructor(const_cast<void *>(dummy.second));
730 std::set<edm::StoredProductProvenance>& oToInsert) {
733 std::set<edm::StoredProductProvenance>::iterator itFound = oToInsert.find(toStore);
734 if(itFound == oToInsert.end()) {
740 <<
"RootOutputFile::insertProductProvenance\n"
741 <<
"The parentage ID index value " << toStore.
parentageIDIndex_ <<
" is out of bounds. The maximum value is currently " <<
parentageIDs_.size()-1 <<
".\n"
742 <<
"This should never happen.\n"
743 <<
"Please report this to the framework hypernews forum 'hn-cms-edmFramework@cern.ch'.\n";
746 oToInsert.insert(toStore);
BranchIDLists const * branchIDLists() const
std::vector< ProcessHistory > ProcessHistoryVector
EventNumber_t event() const
void fillBranches(BranchType const &branchType, Principal const &principal, StoredProductProvenanceVector *productProvenanceVecPtr, ModuleCallingContext const *)
std::string const & idToParameterSetBlobsBranchName()
std::string const & branchName() const
void beginInputFile(FileBlock const &fb, int remainingEvents)
BranchID const & branchID() const
LuminosityBlockAuxiliary lumiAux_
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
int const & basketSize() const
bool wantAllEvents() 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()
std::string const & moduleLabel() const
void writeRun(RunPrincipal const &r, ModuleCallingContext const *)
DropMetaData const & dropMetaData() const
std::map< BranchKey, BranchDescription > ProductList
bool checkSplitLevelsAndBasketSizes(TTree *inputTree) const
bool registerProcessHistory(ProcessHistory const &processHistory)
void writeOne(EventPrincipal const &e, ModuleCallingContext const *)
EventID const & id() const
Provenance getProvenance(ProductID const &pid, ModuleCallingContext const *mcc) const
ProductProvenance const * productProvenance() const
int whyNotFastClonable() const
LuminosityBlockAuxiliary const & aux() const
std::string const & fileFormatVersionBranchName()
OutputItemListArray const & selectedOutputItemList() const
ProcessHistoryRegistry processHistoryRegistry_
std::string const & processName() const
std::string const & eventSelectionsBranchName()
unsigned int const & maxFileSize() const
void setAutoFlush(Long64_t size)
ParameterSetID selectorConfig() const
BranchListIndexes const & branchListIndexes() const
bool shouldWeCloseFile() const
bool checkIfFastClonable(TTree *inputTree) const
ProcessHistory const & processHistory() 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()
std::vector< BranchID > const & parents() const
unsigned int parentageIDIndex_
std::map< ParentageID, unsigned int > parentageIDs_
RootOutputTree eventTree_
std::vector< BranchListIndex > BranchListIndexes
std::string moduleName(Provenance const &provenance)
bool getMapped(key_type const &k, value_type &result) const
PoolOutputModule const * om_
std::string const & compressionAlgorithm() const
std::string const & moduleLabel() const
IndexIntoFile::EntryNumber_t eventEntryNumber_
std::string const & productInstanceName() const
ProcessHistoryID const & processHistoryID() const
void insertAncestors(ProductProvenance const &iGetParents, EventPrincipal const &principal, bool produced, std::set< StoredProductProvenance > &oToFill, ModuleCallingContext const *)
LuminosityBlockAuxiliary const * pLumiAux_
std::string const & indexIntoFileBranchName()
std::string const & basketOrder() const
int getFileFormatVersion()
void const * wrapper() const
SelectedProductsForBranchType const & keptProducts() const
bool checkEntriesInReadBranches(Long64_t expectedNumberOfEntries) const
WrapperInterfaceBase const * getInterface() const
RunAuxiliary const & aux() const
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
void setProcessHistoryID(ProcessHistoryID const &phid)
std::string const & metaDataTreeName()
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_
OutputHandle getForOutput(BranchID const &bid, bool getProd, ModuleCallingContext const *mcc) const
void writeIndexIntoFile()
void writeFileIdentifier()
eventsetup::produce::Produce produced
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
BranchChildren const & branchChildren() const
void setBranchAliases(TTree *tree, SelectedProducts const &branches) const
boost::shared_ptr< ProductProvenanceRetriever > productProvenanceRetrieverPtr() const
std::string toString() const
std::string const & parentageBranchName()
LuminosityBlockNumber_t luminosityBlock() const
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_
TTree * parameterSetsTree_
ParentageID const & parentageID() const
static void writeTTree(TTree *tree)
ProcessHistoryID const & processHistoryID() const
EventAuxiliary const * pEventAux_
void writeParentageRegistry()
std::vector< BranchDescription const * > SelectedProducts
ProductProvenance const * branchIDToProvenance(BranchID const &bid) const
void writeProductDescriptionRegistry()
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
std::string const & productDependenciesBranchName()
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_
volatile std::atomic< bool > shutdown_flag false
BranchListIndexes const * pBranchListIndexes_
void writeLuminosityBlock(LuminosityBlockPrincipal const &lb, ModuleCallingContext const *)
void maybeFastCloneTree(bool canFastClone, bool canFastCloneAux, TTree *tree, std::string const &option)
static ParentageRegistry * instance()
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_
std::string const & wrappedName() const
tuple size
Write out results.
EventNumber_t event() const
int const & inputFileCount() const
static Registry * instance()
JobReport::Token reportToken_
std::string createGlobalIdentifier()
std::string const & fileName() const
LuminosityBlockID id() const
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)