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),
80 parameterSetsTree_(0),
87 eventEntryInfoVector_(),
88 pEventEntryInfoVector_(&eventEntryInfoVector_),
89 pBranchListIndexes_(0),
90 pEventSelectionIDs_(0),
93 runTree_(filePtr_,
InRun, om_->
splitLevel(), om_->treeMaxVirtualSize()),
95 dataTypeReported_(
false),
97 branchesWithStoredHistory_() {
98 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
100 filePtr_->SetCompressionAlgorithm(ROOT::kZLIB);
102 filePtr_->SetCompressionAlgorithm(ROOT::kLZMA);
105 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
145 it->branchDescription_->produced());
162 std::vector<std::string> branchNames;
163 std::vector<BranchDescription const*> branches;
169 branchNames.push_back(it->branchDescription_->branchName());
170 branches.push_back(it->branchDescription_);
173 sort_all(branches, sorterForJobReportHash);
175 std::ostringstream oss;
176 char const underscore =
'_';
177 for(std::vector<BranchDescription const*>::const_iterator it = branches.begin(), itEnd = branches.end(); it != itEnd; ++it) {
184 std::string stringrep = oss.str();
189 std::string moduleName =
"PoolOutputModule";
204 maybeIssueWarning(
int whyNotFastClonable, std::string
const& ifileName, std::string
const& ofileName) {
207 if ((whyNotFastClonable &
215 bool isWarning =
true;
217 message <<
"Fast copying of file " << ifileName <<
" to file " << ofileName <<
" is disabled because:\n";
219 message <<
"a SecondaryFileSequence was specified.\n";
224 message <<
"the input file is in an old format.\n";
229 message <<
"events need to be sorted.\n";
233 message <<
"a run or a lumi is not contiguous in the input file.\n";
237 message <<
"events or lumis were selected or skipped by ID.\n";
242 message <<
"initial events, lumis or runs were skipped.\n";
247 message <<
"some events were skipped because of duplicate checking.\n";
251 message <<
"some events were not copied because of maxEvents limit.\n";
256 message <<
"some events were not copied because of maxLumis limit.\n";
261 message <<
"parallel processing was specified.\n";
266 message <<
"an EventSelector was specified.\n";
271 message <<
"some events were not copied because of maxEvents output limit.\n";
276 message <<
"the split level or basket size of a branch or branches was modified.\n";
280 message <<
"The format of a data product has changed.\n";
285 LogWarning(
"FastCloningDisabled") << message.str();
287 LogInfo(
"FastCloningDisabled") << message.str();
302 if(remainingEvents >= 0 && remainingEvents < fb.
tree()->GetEntries()) {
319 "Merge failure because input file " <<
file_ <<
" has different ROOT split levels or basket sizes\n" <<
320 "than previous files. To allow merging in splite of this, use the configuration parameter\n" <<
321 "overrideInputFileSplitLevels=cms.untracked.bool(True)\n" <<
322 "in every PoolOutputModule.\n";
345 !reg->anyProductProduced() &&
371 unsigned int const oneK = 1024;
454 <<
"Failed to create a branch for Parentages in the output file";
462 for(std::map<ParentageID,unsigned int>::const_iterator it =
parentageIDs_.begin(),
466 orderedIDs[it->second]=it->first;
469 for(std::vector<ParentageID>::const_iterator it = orderedIDs.begin(),
470 itEnd = orderedIDs.end();
500 ex <<
"The number of entries in at least one output TBranch whose entries\n"
501 "were copied from the input does not match the number of events\n"
502 "recorded in IndexIntoFile. This might (or might not) indicate a\n"
503 "problem related to fast copy.";
504 ex.
addContext(
"Calling RootOutputFile::writeIndexIntoFile");
518 for(Map::const_iterator
i = procConfigMap.begin(),
e = procConfigMap.end();
i !=
e; ++
i) {
519 procConfigVector.push_back(
i->second);
532 for(Map::const_iterator
i = procHistoryMap.begin(),
e = procHistoryMap.end();
i !=
e; ++
i) {
533 procHistoryVector.push_back(
i->second);
549 std::pair<ParameterSetID, ParameterSetBlob> idToBlob;
550 std::pair<ParameterSetID, ParameterSetBlob>* pIdToBlob = &idToBlob;
557 idToBlob.first = it->first;
558 idToBlob.second.pset() = it->second.toString();
569 ProductList& pList =
const_cast<ProductList &
>(pReg.productList());
571 for(ProductList::iterator it = pList.begin(); it != pList.end();) {
574 ProductList::iterator itCopy = it;
630 if(tree && tree->GetNbranches() != 0) {
631 for(Selections::const_iterator
i = branches.
begin(), iEnd = branches.
end();
636 std::string
const& alias =
638 tree->SetAlias(alias.c_str(), full.c_str());
641 for(; it != itEnd; ++it) {
642 tree->SetAlias((*it).c_str(), full.c_str());
653 std::set<StoredProductProvenance>& oToFill) {
659 for(std::vector<BranchID>::const_iterator it = parentIDs.begin(), itEnd = parentIDs.end();
680 typedef std::vector<std::pair<TClass*, void const*> > Dummies;
687 std::set<StoredProductProvenance> provenanceToKeep;
690 for(OutputItemList::const_iterator
i = items.begin(), iEnd = items.end();
i != iEnd; ++
i) {
692 BranchID const&
id =
i->branchDescription_->branchID();
695 bool produced =
i->branchDescription_->produced();
696 bool keepProvenance = productProvenanceVecPtr != 0 &&
700 bool getProd = (produced || !fastCloning ||
703 void const* product = 0;
709 assert(eventPrincipal.branchMapperPtr());
717 TClass*
cp = gROOT->GetClass(
i->branchDescription_->wrappedName().c_str());
719 dummies.emplace_back(cp, product);
721 i->product_ = product;
725 if(productProvenanceVecPtr != 0) productProvenanceVecPtr->assign(provenanceToKeep.begin(), provenanceToKeep.end());
727 if(productProvenanceVecPtr != 0) productProvenanceVecPtr->clear();
728 for(Dummies::iterator it = dummies.begin(), itEnd = dummies.end(); it != itEnd; ++it) {
729 it->first->Destructor(const_cast<void *>(it->second));
735 std::set<edm::StoredProductProvenance>& oToInsert) {
738 std::set<edm::StoredProductProvenance>::iterator itFound = oToInsert.find(toStore);
739 if(itFound == oToInsert.end()) {
743 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()
int eventAutoFlushSize() const
std::string const & catalog() const
void writeProcessHistoryRegistry()
void writeOne(EventPrincipal const &e)
std::string & branchName() const
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
FileFormatVersion const & fileFormatVersion() const
ProductProvenance const * productProvenance() const
int whyNotFastClonable() const
std::array< bool, NumBranchTypes > const & hasNewlyDroppedBranch() const
void insertAncestors(ProductProvenance const &iGetParents, EventPrincipal const &principal, bool produced, std::set< StoredProductProvenance > &oToFill)
LuminosityBlockAuxiliary const & aux() const
std::string const & fileFormatVersionBranchName()
static ThreadSafeRegistry * instance()
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)
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)
bool getMapped(key_type const &k, value_type &result) const
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()
static ThreadSafeIndexedRegistry * instance()
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
bool branchListIndexesUnchanged() const
boost::array< bool, NumBranchTypes > const & hasNewlyDroppedBranch() const
EventAuxiliary const * pEventAux_
author Stefano ARGIRO author Bill Tanenbaum
void writeParentageRegistry()
void writeProductDescriptionRegistry()
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
collection_type & data()
Provide access to the contained collection.
std::string const & productDependenciesBranchName()
const_iterator end() const
RootOutputFile(PoolOutputModule *om, std::string const &fileName, std::string const &logicalFileName)
std::vector< value_type > collection_type
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)
bool insertMapped(value_type const &v)
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