CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::RootOutputFile Class Reference

#include <RootOutputFile.h>

Public Types

typedef PoolOutputModule::OutputItem OutputItem
 
typedef PoolOutputModule::OutputItemList OutputItemList
 
typedef std::array< edm::propagate_const< RootOutputTree * >, NumBranchTypesRootOutputTreePtrArray
 

Public Member Functions

void beginInputFile (FileBlock const &fb, int remainingEvents)
 
std::string const & fileName () const
 
void finishEndFile ()
 
void respondToCloseInputFile (FileBlock const &fb)
 
 RootOutputFile (PoolOutputModule *om, std::string const &fileName, std::string const &logicalFileName)
 
bool shouldWeCloseFile () const
 
void writeBranchIDListRegistry ()
 
void writeFileFormatVersion ()
 
void writeFileIdentifier ()
 
void writeIndexIntoFile ()
 
void writeLuminosityBlock (LuminosityBlockForOutput const &lb)
 
void writeOne (EventForOutput const &e)
 
void writeParameterSetRegistry ()
 
void writeParentageRegistry ()
 
void writeProcessHistoryRegistry ()
 
void writeProductDependencies ()
 
void writeProductDescriptionRegistry ()
 
void writeRun (RunForOutput const &r)
 
void writeThinnedAssociationsHelper ()
 
 ~RootOutputFile ()
 

Private Member Functions

std::shared_ptr< TFile const > filePtr () const
 
std::shared_ptr< TFile > & filePtr ()
 
void fillBranches (BranchType const &branchType, OccurrenceForOutput const &occurrence, StoredProductProvenanceVector *productProvenanceVecPtr=0, ProductProvenanceRetriever const *provRetriever=0)
 
void insertAncestors (ProductProvenance const &iGetParents, ProductProvenanceRetriever const *iMapper, bool produced, std::set< BranchID > const &producedBranches, std::set< StoredProductProvenance > &oToFill)
 
bool insertProductProvenance (const ProductProvenance &, std::set< StoredProductProvenance > &oToInsert)
 
StoredProductProvenanceVector const * pEventEntryInfoVector () const
 
StoredProductProvenanceVector *& pEventEntryInfoVector ()
 
void setBranchAliases (TTree *tree, SelectedProducts const &branches) const
 

Private Attributes

std::set< BranchIDbranchesWithStoredHistory_
 
bool canFastCloneAux_
 
bool dataTypeReported_
 
StoredProductProvenanceVector eventEntryInfoVector_
 
IndexIntoFile::EntryNumber_t eventEntryNumber_
 
RootOutputTree eventTree_
 
FileID fid_
 
std::string file_
 
edm::propagate_const< std::shared_ptr< TFile > > filePtr_
 
IndexIntoFile indexIntoFile_
 
std::string logicalFile_
 
LuminosityBlockAuxiliary lumiAux_
 
IndexIntoFile::EntryNumber_t lumiEntryNumber_
 
RootOutputTree lumiTree_
 
edm::propagate_const< TTree * > metaDataTree_
 
unsigned long nEventsInLumi_
 
edm::propagate_const< PoolOutputModule * > om_
 
edm::propagate_const< TTree * > parameterSetsTree_
 
std::map< ParentageID, unsigned int > parentageIDs_
 
edm::propagate_const< TTree * > parentageTree_
 
BranchListIndexes const * pBranchListIndexes_
 
EventAuxiliary const * pEventAux_
 
edm::propagate_const< StoredProductProvenanceVector * > pEventEntryInfoVector_
 
EventSelectionIDVector const * pEventSelectionIDs_
 
LuminosityBlockAuxiliary const * pLumiAux_
 
ProcessHistoryRegistry processHistoryRegistry_
 
RunAuxiliary const * pRunAux_
 
JobReport::Token reportToken_
 
RunAuxiliary runAux_
 
IndexIntoFile::EntryNumber_t runEntryNumber_
 
RootOutputTree runTree_
 
RootOutputTreePtrArray treePointers_
 
int whyNotFastClonable_
 
edm::propagate_const< TClass * > wrapperBaseTClass_
 

Detailed Description

Definition at line 44 of file RootOutputFile.h.

Member Typedef Documentation

Definition at line 46 of file RootOutputFile.h.

Definition at line 47 of file RootOutputFile.h.

Definition at line 48 of file RootOutputFile.h.

Constructor & Destructor Documentation

edm::RootOutputFile::RootOutputFile ( PoolOutputModule om,
std::string const &  fileName,
std::string const &  logicalFileName 
)
explicit

Definition at line 78 of file RootOutputFile.cc.

References edm::RootOutputTree::addAuxiliary(), edm::RootOutputTree::addBranch(), MicroEventContent_cff::branch, branchesWithStoredHistory_, edm::poolNames::branchListIndexesBranchName(), edm::FileBlock::BranchMismatch, edm::BranchDescription::branchName(), revisionDML::branchType(), edm::BranchTypeToAuxiliaryBranchName(), edm::BranchTypeToProductProvenanceBranchName(), edm::FileBlock::CanFastClone, edm::errors::Configuration, edm::createGlobalIdentifier(), cms::Digest::digest(), edm::FileBlock::DisabledInConfigFile, edm::FileBlock::DuplicateEventsRemoved, edm::PoolOutputModule::eventAutoFlushSize(), edm::poolNames::eventSelectionsBranchName(), edm::FileBlock::EventSelectionUsed, edm::FileBlock::EventsOrLumisSelectedByID, edm::FileBlock::EventsToBeSorted, eventTree_, Exception, fid_, file_, filePtr_, edm::FileBlock::FileTooOld, edm::BranchDescription::fullClassName(), edm::propagate_const< T >::get(), edm::FileBlock::HasSecondaryFileSequence, mps_fire::i, edm::InEvent, edm::FileBlock::InitialEventsSkipped, edm::InLumi, edm::InRun, logicalFile_, lumiTree_, edm::RootOutputTree::makeTTree(), edm::FileBlock::MaxEventsTooSmall, edm::FileBlock::MaxLumisTooSmall, python.rootplot.argparse::message, metaDataTree_, edm::poolNames::metaDataTreeName(), edm::BranchDescription::moduleLabel(), edm::moduleName(), edm::FileBlock::NoEventsInFile, edm::FileBlock::NoRootInputSource, edm::FileBlock::NotProcessingEvents, edm::NumBranchTypes, om_, edm::FileBlock::OutputMaxEventsTooSmall, edm::FileBlock::ParallelProcesses, parameterSetsTree_, edm::poolNames::parameterSetsTreeName(), parentageTree_, edm::poolNames::parentageTreeName(), pBranchListIndexes_, pEventAux_, pEventEntryInfoVector(), pEventSelectionIDs_, pLumiAux_, edm::BranchDescription::processName(), edm::BranchDescription::productInstanceName(), pRunAux_, reportToken_, edm::FileBlock::RunOrLumiNotContiguous, runTree_, edm::PoolOutputModule::selectedOutputItemList(), edm::RootOutputTree::setAutoFlush(), edm::sort_all(), edm::FileBlock::SplitLevelMismatch, AlCaHLTBitMon_QueryRunRegistry::string, cms::MD5Result::toString(), treePointers_, and edm::BranchDescription::wrappedName().

78  :
79  file_(fileName),
80  logicalFile_(logicalFileName),
81  reportToken_(0),
82  om_(om),
83  whyNotFastClonable_(om_->whyNotFastClonable()),
84  canFastCloneAux_(false),
85  filePtr_(openTFile(file_.c_str(), om_->compressionLevel())),
86  fid_(),
87  eventEntryNumber_(0LL),
88  lumiEntryNumber_(0LL),
89  runEntryNumber_(0LL),
91  nEventsInLumi_(0),
92  metaDataTree_(nullptr),
93  parameterSetsTree_(nullptr),
94  parentageTree_(nullptr),
95  lumiAux_(),
96  runAux_(),
97  pEventAux_(nullptr),
99  pRunAux_(&runAux_),
102  pBranchListIndexes_(nullptr),
103  pEventSelectionIDs_(nullptr),
104  eventTree_(filePtr(), InEvent, om_->splitLevel(), om_->treeMaxVirtualSize()),
105  lumiTree_(filePtr(), InLumi, om_->splitLevel(), om_->treeMaxVirtualSize()),
106  runTree_(filePtr(), InRun, om_->splitLevel(), om_->treeMaxVirtualSize()),
107  treePointers_(),
108  dataTypeReported_(false),
110  parentageIDs_(),
112  wrapperBaseTClass_(TClass::GetClass("edm::WrapperBase")) {
113  if (om_->compressionAlgorithm() == std::string("ZLIB")) {
114  filePtr_->SetCompressionAlgorithm(ROOT::kZLIB);
115  } else if (om_->compressionAlgorithm() == std::string("LZMA")) {
116  filePtr_->SetCompressionAlgorithm(ROOT::kLZMA);
117  } else {
118  throw Exception(errors::Configuration) << "PoolOutputModule configured with unknown compression algorithm '" << om_->compressionAlgorithm() << "'\n"
119  << "Allowed compression algorithms are ZLIB and LZMA\n";
120  }
121  if (-1 != om->eventAutoFlushSize()) {
122  eventTree_.setAutoFlush(-1*om->eventAutoFlushSize());
123  }
125  pEventAux_, om_->auxItems()[InEvent].basketSize_);
127  pEventEntryInfoVector(), om_->auxItems()[InEvent].basketSize_);
129  pEventSelectionIDs_, om_->auxItems()[InEvent].basketSize_,false);
131  pBranchListIndexes_, om_->auxItems()[InEvent].basketSize_);
132 
134  pLumiAux_, om_->auxItems()[InLumi].basketSize_);
135 
137  pRunAux_, om_->auxItems()[InRun].basketSize_);
138 
140  treePointers_[InLumi] = &lumiTree_;
141  treePointers_[InRun] = &runTree_;
142 
143  for(int i = InEvent; i < NumBranchTypes; ++i) {
144  BranchType branchType = static_cast<BranchType>(i);
145  RootOutputTree *theTree = treePointers_[branchType];
146  for(auto const& item : om_->selectedOutputItemList()[branchType]) {
147  item.product_ = nullptr;
148  BranchDescription const& desc = *item.branchDescription_;
149  theTree->addBranch(desc.branchName(),
150  desc.wrappedName(),
151  item.product_,
152  item.splitLevel_,
153  item.basketSize_,
154  item.branchDescription_->produced());
155  //make sure we always store product registry info for all branches we create
156  branchesWithStoredHistory_.insert(item.branchID());
157  }
158  }
159  // Don't split metadata tree or event description tree
163 
164  fid_ = FileID(createGlobalIdentifier());
165 
166  // For the Job Report, get a vector of branch names in the "Events" tree.
167  // Also create a hash of all the branch names in the "Events" tree
168  // in a deterministic order, except use the full class name instead of the friendly class name.
169  // To avoid extra string copies, we create a vector of pointers into the product registry,
170  // and use a custom comparison operator for sorting.
171  std::vector<std::string> branchNames;
172  std::vector<BranchDescription const*> branches;
173  branchNames.reserve(om_->selectedOutputItemList()[InEvent].size());
174  branches.reserve(om->selectedOutputItemList()[InEvent].size());
175  for(auto const& item : om_->selectedOutputItemList()[InEvent]) {
176  branchNames.push_back(item.branchDescription_->branchName());
177  branches.push_back(item.branchDescription_);
178  }
179  // Now sort the branches for the hash.
180  sort_all(branches, sorterForJobReportHash);
181  // Now, make a concatenated string.
182  std::ostringstream oss;
183  char const underscore = '_';
184  for(auto const& branch : branches) {
185  BranchDescription const& bd = *branch;
186  oss << bd.fullClassName() << underscore
187  << bd.moduleLabel() << underscore
188  << bd.productInstanceName() << underscore
189  << bd.processName() << underscore;
190  }
191  std::string stringrep = oss.str();
192  cms::Digest md5alg(stringrep);
193 
194  // Register the output file with the JobReport service
195  // and get back the token for it.
196  std::string moduleName = "PoolOutputModule";
197  Service<JobReport> reportSvc;
198  reportToken_ = reportSvc->outputFileOpened(
199  file_, logicalFile_, // PFN and LFN
200  om_->catalog(), // catalog
201  moduleName, // module class name
202  om_->moduleLabel(), // module label
203  fid_.fid(), // file id (guid)
204  std::string(), // data type (not yet known, so string is empty).
205  md5alg.digest().toString(), // branch hash
206  branchNames); // branch names being written
207  }
LuminosityBlockAuxiliary lumiAux_
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:115
std::string const & parentageTreeName()
Definition: BranchType.cc:159
edm::propagate_const< TTree * > metaDataTree_
unsigned long nEventsInLumi_
ProcessHistoryRegistry processHistoryRegistry_
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:243
void setAutoFlush(Long64_t size)
BranchType
Definition: BranchType.h:11
std::set< BranchID > branchesWithStoredHistory_
std::vector< EventSelectionID > EventSelectionIDVector
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:251
std::string const & fileName() const
std::map< ParentageID, unsigned int > parentageIDs_
std::shared_ptr< TFile const > filePtr() const
RootOutputTree eventTree_
std::vector< BranchListIndex > BranchListIndexes
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
edm::propagate_const< PoolOutputModule * > om_
IndexIntoFile::EntryNumber_t eventEntryNumber_
LuminosityBlockAuxiliary const * pLumiAux_
edm::propagate_const< std::shared_ptr< TFile > > filePtr_
std::string logicalFile_
std::string const & metaDataTreeName()
Definition: BranchType.cc:168
edm::propagate_const< TClass * > wrapperBaseTClass_
static TTree * makeTTree(TFile *filePtr, std::string const &name, int splitLevel)
element_type const * get() const
EventSelectionIDVector const * pEventSelectionIDs_
edm::propagate_const< TTree * > parameterSetsTree_
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
edm::propagate_const< StoredProductProvenanceVector * > pEventEntryInfoVector_
RootOutputTree runTree_
StoredProductProvenanceVector eventEntryInfoVector_
edm::propagate_const< TTree * > parentageTree_
void addAuxiliary(std::string const &branchName, T const *&pAux, int bufSize, bool allowCloning=true)
std::vector< StoredProductProvenance > StoredProductProvenanceVector
IndexIntoFile indexIntoFile_
IndexIntoFile::EntryNumber_t runEntryNumber_
EventAuxiliary const * pEventAux_
RunAuxiliary runAux_
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
Definition: BranchType.cc:131
StoredProductProvenanceVector const * pEventEntryInfoVector() const
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:247
RootOutputTreePtrArray treePointers_
BranchListIndexes const * pBranchListIndexes_
IndexIntoFile::EntryNumber_t lumiEntryNumber_
RootOutputTree lumiTree_
RunAuxiliary const * pRunAux_
def branchType(schema, name)
Definition: revisionDML.py:112
JobReport::Token reportToken_
std::string createGlobalIdentifier()
edm::RootOutputFile::~RootOutputFile ( )
inline

Member Function Documentation

void edm::RootOutputFile::beginInputFile ( FileBlock const &  fb,
int  remainingEvents 
)

Definition at line 299 of file RootOutputFile.cc.

References edm::FileBlock::BranchMismatch, edm::FileBlock::CanFastClone, canFastCloneAux_, edm::RootOutputTree::checkIfFastClonable(), edm::RootOutputTree::checkSplitLevelsAndBasketSizes(), eventTree_, Exception, file_, edm::FileBlock::fileName(), edm::match(), edm::RootOutputTree::maybeFastCloneTree(), edm::errors::MismatchedInputFiles, edm::FileBlock::NoRootInputSource, om_, edm::FileBlock::OutputMaxEventsTooSmall, reportToken_, edm::FileBlock::SplitLevelMismatch, edm::FileBlock::tree(), edm::FileBlock::whyNotFastClonable(), and whyNotFastClonable_.

Referenced by ~RootOutputFile().

299  {
300 
301  // Reset per input file information
302  whyNotFastClonable_ = om_->whyNotFastClonable();
303  canFastCloneAux_ = false;
304 
305  if(fb.tree() != nullptr) {
306 
307  whyNotFastClonable_ |= fb.whyNotFastClonable();
308 
309  if(remainingEvents >= 0 && remainingEvents < fb.tree()->GetEntries()) {
311  }
312 
314  if(!match) {
315  if(om_->overrideInputFileSplitLevels()) {
316  // We may be fast copying. We must disable fast copying if the split levels
317  // or basket sizes do not match.
319  } else {
320  // We are using the input split levels and basket sizes from the first input file
321  // for copied output branches. In this case, we throw an exception if any branches
322  // have different split levels or basket sizes in a subsequent input file.
323  // If the mismatch is in the first file, there is a bug somewhere, so we assert.
324  assert(om_->inputFileCount() > 1);
325  throw Exception(errors::MismatchedInputFiles, "RootOutputFile::beginInputFile()") <<
326  "Merge failure because input file " << file_ << " has different ROOT split levels or basket sizes\n" <<
327  "than previous files. To allow merging in splite of this, use the configuration parameter\n" <<
328  "overrideInputFileSplitLevels=cms.untracked.bool(True)\n" <<
329  "in every PoolOutputModule.\n";
330  }
331  }
332 
333  // Since this check can be time consuming, we do it only if we would otherwise fast clone.
335  if(!eventTree_.checkIfFastClonable(fb.tree())) {
337  }
338  }
339  // We now check if we can fast copy the auxiliary branches.
340  // We can do so only if we can otherwise fast copy,
341  // the input file has the current format (these branches are in the Events Tree),
342  // there are no newly dropped or produced products,
343  // no metadata has been dropped,
344  // ID's have not been modified,
345  // and the branch list indexes do not need modification.
346 
347  // Note: Fast copy of the EventProductProvenance branch is unsafe
348  // unless we can enforce that the parentage information for a fully copied
349  // output file will be the same as for the input file, with nothing dropped.
350  // This has never been enforced, and, withthe EDAlias feature, it may no longer
351  // work by accident.
352  // So, for now, we do not enable fast cloning of the non-product branches.
353 /*
354  Service<ConstProductRegistry> reg;
355  canFastCloneAux_ = (whyNotFastClonable_ == FileBlock::CanFastClone) &&
356  fb.fileFormatVersion().noMetaDataTrees() &&
357  !om_->hasNewlyDroppedBranch()[InEvent] &&
358  !fb.hasNewlyDroppedBranch()[InEvent] &&
359  om_->dropMetaData() == PoolOutputModule::DropNone &&
360  !reg->anyProductProduced() &&
361  !fb.modifiedIDs() &&
362  fb.branchListIndexesUnchanged();
363 */
364 
365  // Report the fast copying status.
366  Service<JobReport> reportSvc;
367  reportSvc->reportFastCopyingStatus(reportToken_, fb.fileName(), whyNotFastClonable_ == FileBlock::CanFastClone);
368  } else {
370  }
371 
373 
374  // Possibly issue warning or informational message if we haven't fast cloned.
375  if(fb.tree() != nullptr && whyNotFastClonable_ != FileBlock::CanFastClone) {
376  maybeIssueWarning(whyNotFastClonable_, fb.fileName(), file_);
377  }
378  }
bool checkSplitLevelsAndBasketSizes(TTree *inputTree) const
bool checkIfFastClonable(TTree *inputTree) const
RootOutputTree eventTree_
edm::propagate_const< PoolOutputModule * > om_
void maybeFastCloneTree(bool canFastClone, bool canFastCloneAux, TTree *tree, std::string const &option)
JobReport::Token reportToken_
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
std::string const& edm::RootOutputFile::fileName ( ) const
inline
std::shared_ptr<TFile const> edm::RootOutputFile::filePtr ( ) const
inlineprivate

Definition at line 99 of file RootOutputFile.h.

References filePtr_, and edm::get_underlying_safe().

edm::propagate_const< std::shared_ptr< TFile > > filePtr_
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::shared_ptr<TFile>& edm::RootOutputFile::filePtr ( )
inlineprivate

Definition at line 100 of file RootOutputFile.h.

References filePtr_, and edm::get_underlying_safe().

100 {return get_underlying_safe(filePtr_);}
edm::propagate_const< std::shared_ptr< TFile > > filePtr_
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void edm::RootOutputFile::fillBranches ( BranchType const &  branchType,
OccurrenceForOutput const &  occurrence,
StoredProductProvenanceVector productProvenanceVecPtr = 0,
ProductProvenanceRetriever const *  provRetriever = 0 
)
private

Definition at line 688 of file RootOutputFile.cc.

References branchesWithStoredHistory_, edm::ProductProvenanceRetriever::branchIDToProvenance(), revisionDML::branchType(), edm::FileBlock::CanFastClone, SimDataFormats::CaloAnalysis::cp, edm::PoolOutputModule::DropAll, edm::PoolOutputModule::DropNone, edm::PoolOutputModule::DropPrior, read312RV_cfg::fastCloning, runEdmFileComparison::found, edm::OccurrenceForOutput::getByToken(), edm::getWrapperBasePtr(), edm::InEvent, insertAncestors(), insertProductProvenance(), mps_monitormerge::items, eostools::move(), PFRecoTauDiscriminationByIsolation_cfi::offset, om_, AlCaHLTBitMon_ParallelJobs::p, edm::es::produced, edm::Provenance::productProvenance(), edm::BasicHandle::provenance(), mps_fire::result, treePointers_, whyNotFastClonable_, edm::BasicHandle::wrapper(), and wrapperBaseTClass_.

Referenced by fileName(), writeLuminosityBlock(), writeOne(), and writeRun().

692  {
693 
694  std::vector<std::unique_ptr<WrapperBase> > dummies;
695 
696  OutputItemList const& items = om_->selectedOutputItemList()[branchType];
697 
698  bool const doProvenance = (productProvenanceVecPtr != nullptr) && (om_->dropMetaData() != PoolOutputModule::DropAll);
699  bool const keepProvenanceForPrior = doProvenance && om_->dropMetaData() != PoolOutputModule::DropPrior;
700 
702  std::set<StoredProductProvenance> provenanceToKeep;
703  //
704  //If we are dropping some of the meta data we need to know
705  // which BranchIDs were produced in this process because
706  // we may be storing meta data for only those products
707  // We do this only for event products.
708  std::set<BranchID> producedBranches;
709  if(doProvenance && branchType == InEvent && om_->dropMetaData() != PoolOutputModule::DropNone) {
711  for(auto bd : preg->allBranchDescriptions()) {
712  if(bd->produced() && bd->branchType() == InEvent) {
713  producedBranches.insert(bd->branchID());
714  }
715  }
716  }
717 
718  // Loop over EDProduct branches, possibly fill the provenance, and write the branch.
719  for(auto const& item : items) {
720 
721  BranchID const& id = item.branchDescription_->branchID();
722  branchesWithStoredHistory_.insert(id);
723 
724  bool produced = item.branchDescription_->produced();
725  bool getProd = (produced || !fastCloning || treePointers_[branchType]->uncloned(item.branchDescription_->branchName()));
726  bool keepProvenance = doProvenance && (produced || keepProvenanceForPrior);
727 
728  WrapperBase const* product = nullptr;
729  ProductProvenance const* productProvenance = nullptr;
730  BasicHandle result;
731  if(getProd) {
732  bool found = occurrence.getByToken(item.token_, item.branchDescription_->unwrappedTypeID(), result);
733  product = result.wrapper();
734  if(found && keepProvenance) {
735  productProvenance = result.provenance()->productProvenance();
736  }
737  if(product == nullptr) {
738  // No product with this ID is in the event.
739  // Add a null product.
740  TClass* cp = item.branchDescription_->wrappedType().getClass();
741  assert(cp != nullptr);
742  int offset = cp->GetBaseClassOffset(wrapperBaseTClass_);
743  void* p = cp->New();
744  std::unique_ptr<WrapperBase> dummy = getWrapperBasePtr(p, offset);
745  product = dummy.get();
746  dummies.emplace_back(std::move(dummy));
747  }
748  item.product_ = product;
749  }
750  if (keepProvenance && productProvenance == nullptr) {
751  productProvenance = provRetriever->branchIDToProvenance(item.branchDescription_->originalBranchID());
752  }
753  if(productProvenance) {
754  insertProductProvenance(*productProvenance,provenanceToKeep);
755  insertAncestors(*productProvenance, provRetriever, produced, producedBranches, provenanceToKeep);
756  }
757  }
758 
759  if(doProvenance) productProvenanceVecPtr->assign(provenanceToKeep.begin(), provenanceToKeep.end());
760  treePointers_[branchType]->fillTree();
761  if(doProvenance) productProvenanceVecPtr->clear();
762  }
void insertAncestors(ProductProvenance const &iGetParents, ProductProvenanceRetriever const *iMapper, bool produced, std::set< BranchID > const &producedBranches, std::set< StoredProductProvenance > &oToFill)
std::set< BranchID > branchesWithStoredHistory_
edm::propagate_const< PoolOutputModule * > om_
PoolOutputModule::OutputItemList OutputItemList
edm::propagate_const< TClass * > wrapperBaseTClass_
bool insertProductProvenance(const ProductProvenance &, std::set< StoredProductProvenance > &oToInsert)
std::unique_ptr< WrapperBase > getWrapperBasePtr(void *p, int offset)
RootOutputTreePtrArray treePointers_
const eventsetup::produce::Produce produced
Definition: ESProducts.cc:20
def move(src, dest)
Definition: eostools.py:510
def branchType(schema, name)
Definition: revisionDML.py:112
void edm::RootOutputFile::finishEndFile ( )

Definition at line 613 of file RootOutputFile.cc.

References revisionDML::branchType(), filePtr_, mps_fire::i, edm::InEvent, metaDataTree_, edm::NumBranchTypes, om_, parameterSetsTree_, parentageTree_, reportToken_, setBranchAliases(), compare::tree, treePointers_, and edm::RootOutputTree::writeTTree().

Referenced by ~RootOutputFile().

613  {
614  metaDataTree_->SetEntries(-1);
617 
619 
620  // Create branch aliases for all the branches in the
621  // events/lumis/runs trees. The loop is over all types of data
622  // products.
623  for(int i = InEvent; i < NumBranchTypes; ++i) {
624  BranchType branchType = static_cast<BranchType>(i);
625  setBranchAliases(treePointers_[branchType]->tree(), om_->keptProducts()[branchType]);
626  treePointers_[branchType]->writeTree();
627  }
628 
629  // close the file -- mfp
630  // Just to play it safe, zero all pointers to objects in the TFile to be closed.
631  metaDataTree_ = parentageTree_ = nullptr;
632  for(auto& treePointer : treePointers_) {
633  treePointer->close();
634  treePointer = nullptr;
635  }
636  filePtr_->Close();
637  filePtr_ = nullptr; // propagate_const<T> has no reset() function
638 
639  // report that file has been closed
640  Service<JobReport> reportSvc;
641  reportSvc->outputFileClosed(reportToken_);
642 
643  }
edm::propagate_const< TTree * > metaDataTree_
BranchType
Definition: BranchType.h:11
edm::propagate_const< PoolOutputModule * > om_
edm::propagate_const< std::shared_ptr< TFile > > filePtr_
edm::propagate_const< TTree * > parameterSetsTree_
void setBranchAliases(TTree *tree, SelectedProducts const &branches) const
edm::propagate_const< TTree * > parentageTree_
static void writeTTree(TTree *tree)
RootOutputTreePtrArray treePointers_
def branchType(schema, name)
Definition: revisionDML.py:112
JobReport::Token reportToken_
void edm::RootOutputFile::insertAncestors ( ProductProvenance const &  iGetParents,
ProductProvenanceRetriever const *  iMapper,
bool  produced,
std::set< BranchID > const &  producedBranches,
std::set< StoredProductProvenance > &  oToFill 
)
private

Definition at line 665 of file RootOutputFile.cc.

References branchesWithStoredHistory_, edm::ProductProvenance::branchID(), edm::ProductProvenanceRetriever::branchIDToProvenance(), edm::PoolOutputModule::DropAll, edm::PoolOutputModule::DropDroppedPrior, edm::PoolOutputModule::DropNone, edm::PoolOutputModule::DropPrior, info(), insertProductProvenance(), om_, edm::ProductProvenance::parentage(), edm::Parentage::parents(), and edm::es::produced.

Referenced by fileName(), and fillBranches().

669  {
670  assert(om_->dropMetaData() != PoolOutputModule::DropAll);
671  assert(produced || om_->dropMetaData() != PoolOutputModule::DropPrior);
672  if(om_->dropMetaData() == PoolOutputModule::DropDroppedPrior && !produced) return;
673  std::vector<BranchID> const& parentIDs = iGetParents.parentage().parents();
674  for(auto const& parentID : parentIDs) {
675  branchesWithStoredHistory_.insert(parentID);
676  ProductProvenance const* info = iMapper->branchIDToProvenance(parentID);
677  if(info) {
678  if(om_->dropMetaData() == PoolOutputModule::DropNone || (iProducedIDs.end() != iProducedIDs.find(info->branchID()) ) ) {
679  if(insertProductProvenance(*info,oToFill) ) {
680  //haven't seen this one yet
681  insertAncestors(*info, iMapper, produced, iProducedIDs, oToFill);
682  }
683  }
684  }
685  }
686  }
static const TGPicture * info(bool iBackgroundIsBlack)
void insertAncestors(ProductProvenance const &iGetParents, ProductProvenanceRetriever const *iMapper, bool produced, std::set< BranchID > const &producedBranches, std::set< StoredProductProvenance > &oToFill)
std::set< BranchID > branchesWithStoredHistory_
edm::propagate_const< PoolOutputModule * > om_
bool insertProductProvenance(const ProductProvenance &, std::set< StoredProductProvenance > &oToInsert)
const eventsetup::produce::Produce produced
Definition: ESProducts.cc:20
bool edm::RootOutputFile::insertProductProvenance ( const ProductProvenance ,
std::set< StoredProductProvenance > &  oToInsert 
)
private

Definition at line 765 of file RootOutputFile.cc.

References edm::ProductProvenance::branchID(), edm::StoredProductProvenance::branchID_, Exception, mps_fire::i, edm::BranchID::id(), edm::errors::LogicError, edm::ProductProvenance::parentageID(), edm::StoredProductProvenance::parentageIDIndex_, and parentageIDs_.

Referenced by fileName(), fillBranches(), and insertAncestors().

766  {
767  StoredProductProvenance toStore;
768  toStore.branchID_ = iProv.branchID().id();
769  std::set<edm::StoredProductProvenance>::iterator itFound = oToInsert.find(toStore);
770  if(itFound == oToInsert.end()) {
771  //get the index to the ParentageID or insert a new value if not already present
772  std::pair<std::map<edm::ParentageID,unsigned int>::iterator,bool> i = parentageIDs_.insert(std::make_pair(iProv.parentageID(),static_cast<unsigned int>(parentageIDs_.size())));
773  toStore.parentageIDIndex_ = i.first->second;
774  if(toStore.parentageIDIndex_ >= parentageIDs_.size()) {
776  << "RootOutputFile::insertProductProvenance\n"
777  << "The parentage ID index value " << toStore.parentageIDIndex_ << " is out of bounds. The maximum value is currently " << parentageIDs_.size()-1 << ".\n"
778  << "This should never happen.\n"
779  << "Please report this to the framework hypernews forum 'hn-cms-edmFramework@cern.ch'.\n";
780  }
781 
782  oToInsert.insert(toStore);
783  return true;
784  }
785  return false;
786  }
std::map< ParentageID, unsigned int > parentageIDs_
StoredProductProvenanceVector const* edm::RootOutputFile::pEventEntryInfoVector ( ) const
inlineprivate

Definition at line 101 of file RootOutputFile.h.

References edm::get_underlying_safe(), and pEventEntryInfoVector_.

Referenced by RootOutputFile().

std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< StoredProductProvenanceVector * > pEventEntryInfoVector_
StoredProductProvenanceVector*& edm::RootOutputFile::pEventEntryInfoVector ( )
inlineprivate

Definition at line 102 of file RootOutputFile.h.

References edm::get_underlying_safe(), and pEventEntryInfoVector_.

std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< StoredProductProvenanceVector * > pEventEntryInfoVector_
void edm::RootOutputFile::respondToCloseInputFile ( FileBlock const &  fb)

Definition at line 380 of file RootOutputFile.cc.

References eventTree_, lumiTree_, runTree_, and edm::RootOutputTree::setEntries().

Referenced by ~RootOutputFile().

380  {
384  }
RootOutputTree eventTree_
RootOutputTree runTree_
RootOutputTree lumiTree_
void edm::RootOutputFile::setBranchAliases ( TTree *  tree,
SelectedProducts const &  branches 
) const
private

Definition at line 646 of file RootOutputFile.cc.

References egammaCTFFinalFitWithMaterial_cff::alias, edm::BranchDescription::branchAliases(), edm::BranchDescription::branchName(), full, edm::BranchDescription::moduleLabel(), edm::BranchDescription::productInstanceName(), corrVsCorr::selection, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by fileName(), and finishEndFile().

646  {
647  if(tree && tree->GetNbranches() != 0) {
648  for(auto const& selection : branches) {
649  BranchDescription const& pd = *selection.first;
650  std::string const& full = pd.branchName() + "obj";
651  if(pd.branchAliases().empty()) {
652  std::string const& alias =
653  (pd.productInstanceName().empty() ? pd.moduleLabel() : pd.productInstanceName());
654  tree->SetAlias(alias.c_str(), full.c_str());
655  } else {
656  for(auto const& alias : pd.branchAliases()) {
657  tree->SetAlias(alias.c_str(), full.c_str());
658  }
659  }
660  }
661  }
662  }
selection
main part
Definition: corrVsCorr.py:98
Definition: GenABIO.cc:180
Definition: tree.py:1
bool edm::RootOutputFile::shouldWeCloseFile ( ) const

Definition at line 386 of file RootOutputFile.cc.

References filePtr_, om_, and findQualityFiles::size.

Referenced by ~RootOutputFile().

386  {
387  unsigned int const oneK = 1024;
388  Long64_t size = filePtr_->GetSize()/oneK;
389  return(size >= om_->maxFileSize());
390  }
size
Write out results.
edm::propagate_const< PoolOutputModule * > om_
edm::propagate_const< std::shared_ptr< TFile > > filePtr_
void edm::RootOutputFile::writeBranchIDListRegistry ( )

Definition at line 547 of file RootOutputFile.cc.

References b, edm::poolNames::branchIDListBranchName(), metaDataTree_, om_, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by ~RootOutputFile().

547  {
548  BranchIDLists const* p = om_->branchIDLists();
549  TBranch* b = metaDataTree_->Branch(poolNames::branchIDListBranchName().c_str(), &p, om_->basketSize(), 0);
550  assert(b);
551  b->Fill();
552  }
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
edm::propagate_const< TTree * > metaDataTree_
edm::propagate_const< PoolOutputModule * > om_
double b
Definition: hdecay.h:120
std::string const & branchIDListBranchName()
Definition: BranchType.cc:208
void edm::RootOutputFile::writeFileFormatVersion ( )

Definition at line 504 of file RootOutputFile.cc.

References b, edm::poolNames::fileFormatVersionBranchName(), edm::getFileFormatVersion(), metaDataTree_, and om_.

Referenced by ~RootOutputFile().

504  {
505  FileFormatVersion fileFormatVersion(getFileFormatVersion());
506  FileFormatVersion* pFileFmtVsn = &fileFormatVersion;
507  TBranch* b = metaDataTree_->Branch(poolNames::fileFormatVersionBranchName().c_str(), &pFileFmtVsn, om_->basketSize(), 0);
508  assert(b);
509  b->Fill();
510  }
std::string const & fileFormatVersionBranchName()
Definition: BranchType.cc:218
edm::propagate_const< TTree * > metaDataTree_
edm::propagate_const< PoolOutputModule * > om_
int getFileFormatVersion()
double b
Definition: hdecay.h:120
void edm::RootOutputFile::writeFileIdentifier ( )

Definition at line 512 of file RootOutputFile.cc.

References b, fid_, edm::poolNames::fileIdentifierBranchName(), metaDataTree_, and om_.

Referenced by ~RootOutputFile().

512  {
513  FileID* fidPtr = &fid_;
514  TBranch* b = metaDataTree_->Branch(poolNames::fileIdentifierBranchName().c_str(), &fidPtr, om_->basketSize(), 0);
515  assert(b);
516  b->Fill();
517  }
edm::propagate_const< TTree * > metaDataTree_
edm::propagate_const< PoolOutputModule * > om_
double b
Definition: hdecay.h:120
std::string const & fileIdentifierBranchName()
Definition: BranchType.cc:223
void edm::RootOutputFile::writeIndexIntoFile ( )

Definition at line 519 of file RootOutputFile.cc.

References cms::Exception::addContext(), b, edm::RootOutputTree::checkEntriesInReadBranches(), eventEntryNumber_, eventTree_, indexIntoFile_, edm::poolNames::indexIntoFileBranchName(), metaDataTree_, om_, edm::errors::OtherCMS, and edm::IndexIntoFile::sortVector_Run_Or_Lumi_Entries().

Referenced by ~RootOutputFile().

519  {
522  ex << "The number of entries in at least one output TBranch whose entries\n"
523  "were copied from the input does not match the number of events\n"
524  "recorded in IndexIntoFile. This might (or might not) indicate a\n"
525  "problem related to fast copy.";
526  ex.addContext("Calling RootOutputFile::writeIndexIntoFile");
527  throw ex;
528  }
530  IndexIntoFile* iifPtr = &indexIntoFile_;
531  TBranch* b = metaDataTree_->Branch(poolNames::indexIntoFileBranchName().c_str(), &iifPtr, om_->basketSize(), 0);
532  assert(b);
533  b->Fill();
534  }
edm::propagate_const< TTree * > metaDataTree_
void sortVector_Run_Or_Lumi_Entries()
RootOutputTree eventTree_
edm::propagate_const< PoolOutputModule * > om_
IndexIntoFile::EntryNumber_t eventEntryNumber_
std::string const & indexIntoFileBranchName()
Definition: BranchType.cc:233
bool checkEntriesInReadBranches(Long64_t expectedNumberOfEntries) const
double b
Definition: hdecay.h:120
IndexIntoFile indexIntoFile_
void edm::RootOutputFile::writeLuminosityBlock ( LuminosityBlockForOutput const &  lb)

Definition at line 439 of file RootOutputFile.cc.

References edm::IndexIntoFile::addEntry(), fillBranches(), edm::LuminosityBlockForOutput::id(), indexIntoFile_, edm::InLumi, lumiAux_, lumiEntryNumber_, edm::LuminosityBlockID::luminosityBlock(), edm::LuminosityBlockAuxiliary::luminosityBlock(), edm::LuminosityBlockForOutput::luminosityBlockAuxiliary(), lumiTree_, nEventsInLumi_, edm::RootOutputTree::optimizeBaskets(), edm::OccurrenceForOutput::processHistory(), edm::OccurrenceForOutput::processHistoryID(), processHistoryRegistry_, edm::ProcessHistoryRegistry::reducedProcessHistoryID(), edm::ProcessHistoryRegistry::registerProcessHistory(), reportToken_, edm::LuminosityBlockID::run(), edm::LuminosityBlockAuxiliary::run(), edm::LuminosityBlockAuxiliary::setProcessHistoryID(), and mitigatedMETSequence_cff::U.

Referenced by ~RootOutputFile().

439  {
440  // Auxiliary branch
441  // NOTE: lumiAux_ must be filled before calling fillBranches since it gets written out in that routine.
442  lumiAux_ = lb.luminosityBlockAuxiliary();
443  // Use the updated process historyID
444  lumiAux_.setProcessHistoryID(lb.processHistoryID());
445  // Store the process history.
446  processHistoryRegistry_.registerProcessHistory(lb.processHistory());
447  // Store the reduced ID in the IndexIntoFile
448  ProcessHistoryID reducedPHID = processHistoryRegistry_.reducedProcessHistoryID(lb.processHistoryID());
449  // Add lumi to index.
452  fillBranches(InLumi, lb);
453  lumiTree_.optimizeBaskets(10ULL*1024*1024);
454 
455  Service<JobReport> reportSvc;
456  reportSvc->reportLumiSection(reportToken_, lb.id().run(), lb.id().luminosityBlock(),nEventsInLumi_);
457  nEventsInLumi_ = 0;
458  }
LuminosityBlockAuxiliary lumiAux_
bool registerProcessHistory(ProcessHistory const &processHistory)
unsigned long nEventsInLumi_
ProcessHistoryRegistry processHistoryRegistry_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
void setProcessHistoryID(ProcessHistoryID const &phid)
LuminosityBlockNumber_t luminosityBlock() const
void addEntry(ProcessHistoryID const &processHistoryID, RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
Hash< ProcessHistoryType > ProcessHistoryID
IndexIntoFile indexIntoFile_
IndexIntoFile::EntryNumber_t lumiEntryNumber_
RootOutputTree lumiTree_
void optimizeBaskets(ULong64_t size)
JobReport::Token reportToken_
void fillBranches(BranchType const &branchType, OccurrenceForOutput const &occurrence, StoredProductProvenanceVector *productProvenanceVecPtr=0, ProductProvenanceRetriever const *provRetriever=0)
void edm::RootOutputFile::writeOne ( EventForOutput const &  e)

Definition at line 392 of file RootOutputFile.cc.

References edm::IndexIntoFile::addEntry(), edm::EventForOutput::branchListIndexes(), MergeFilesAndCalculateEfficiencies_cfg::dataType, dataTypeReported_, edm::EventID::event(), edm::EventAuxiliary::event(), edm::EventForOutput::eventAuxiliary(), eventEntryNumber_, edm::EventForOutput::eventSelectionIDs(), fillBranches(), edm::EventForOutput::id(), indexIntoFile_, edm::InEvent, edm::EventAuxiliary::isRealData(), edm::EventAuxiliary::luminosityBlock(), nEventsInLumi_, om_, pBranchListIndexes_, pEventAux_, pEventEntryInfoVector_, pEventSelectionIDs_, edm::OccurrenceForOutput::processHistory(), edm::OccurrenceForOutput::processHistoryID(), edm::EventAuxiliary::processHistoryID(), processHistoryRegistry_, edm::EventForOutput::productProvenanceRetrieverPtr(), edm::ProcessHistoryRegistry::reducedProcessHistoryID(), edm::ProcessHistoryRegistry::registerProcessHistory(), reportToken_, edm::EventID::run(), edm::EventAuxiliary::run(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~RootOutputFile().

392  {
393  // Auxiliary branch
394  pEventAux_ = &e.eventAuxiliary();
395 
396  // Because getting the data may cause an exception to be thrown we want to do that
397  // first before writing anything to the file about this event
398  // NOTE: pEventAux_, pBranchListIndexes_, pEventSelectionIDs_, and pEventEntryInfoVector_
399  // must be set before calling fillBranches since they get written out in that routine.
400  assert(pEventAux_->processHistoryID() == e.processHistoryID());
401  pBranchListIndexes_ = &e.branchListIndexes();
402 
403  // Note: The EventSelectionIDVector should have a one to one correspondence with the processes in the process history.
404  // Therefore, a new entry should be added if and only if the current process has been added to the process history,
405  // which is done if and only if there is a produced product.
407  EventSelectionIDVector esids = e.eventSelectionIDs();
408  if (reg->anyProductProduced() || !om_->wantAllEvents()) {
409  esids.push_back(om_->selectorConfig());
410  }
411  pEventSelectionIDs_ = &esids;
412  ProductProvenanceRetriever const* provRetriever = e.productProvenanceRetrieverPtr();
413  assert(provRetriever);
414  fillBranches(InEvent, e, pEventEntryInfoVector_, provRetriever);
415 
416  // Add the dataType to the job report if it hasn't already been done
417  if(!dataTypeReported_) {
418  Service<JobReport> reportSvc;
419  std::string dataType("MC");
420  if(pEventAux_->isRealData()) dataType = "Data";
421  reportSvc->reportDataType(reportToken_, dataType);
422  dataTypeReported_ = true;
423  }
424 
425  // Store the process history.
427  // Store the reduced ID in the IndexIntoFile
428  ProcessHistoryID reducedPHID = processHistoryRegistry_.reducedProcessHistoryID(e.processHistoryID());
429  // Add event to index
432 
433  // Report event written
434  Service<JobReport> reportSvc;
435  reportSvc->eventWrittenToFile(reportToken_, e.id().run(), e.id().event());
436  ++nEventsInLumi_;
437  }
bool isRealData() const
bool registerProcessHistory(ProcessHistory const &processHistory)
RunNumber_t run() const
unsigned long nEventsInLumi_
ProcessHistoryRegistry processHistoryRegistry_
std::vector< EventSelectionID > EventSelectionIDVector
LuminosityBlockNumber_t luminosityBlock() const
edm::propagate_const< PoolOutputModule * > om_
IndexIntoFile::EntryNumber_t eventEntryNumber_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
void addEntry(ProcessHistoryID const &processHistoryID, RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
Hash< ProcessHistoryType > ProcessHistoryID
EventSelectionIDVector const * pEventSelectionIDs_
edm::propagate_const< StoredProductProvenanceVector * > pEventEntryInfoVector_
IndexIntoFile indexIntoFile_
ProcessHistoryID const & processHistoryID() const
EventAuxiliary const * pEventAux_
BranchListIndexes const * pBranchListIndexes_
EventNumber_t event() const
JobReport::Token reportToken_
void fillBranches(BranchType const &branchType, OccurrenceForOutput const &occurrence, StoredProductProvenanceVector *productProvenanceVecPtr=0, ProductProvenanceRetriever const *provRetriever=0)
void edm::RootOutputFile::writeParameterSetRegistry ( )

Definition at line 561 of file RootOutputFile.cc.

References b, edm::poolNames::idToParameterSetBlobsBranchName(), edm::pset::Registry::instance(), om_, parameterSetsTree_, and muonDTDigis_cfi::pset.

Referenced by ~RootOutputFile().

561  {
562  std::pair<ParameterSetID, ParameterSetBlob> idToBlob;
563  std::pair<ParameterSetID, ParameterSetBlob>* pIdToBlob = &idToBlob;
564  TBranch* b = parameterSetsTree_->Branch(poolNames::idToParameterSetBlobsBranchName().c_str(),&pIdToBlob,om_->basketSize(), 0);
565 
566  for(auto const& pset : *pset::Registry::instance()) {
567  idToBlob.first = pset.first;
568  idToBlob.second.pset() = pset.second.toString();
569 
570  b->Fill();
571  }
572  }
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:255
edm::propagate_const< PoolOutputModule * > om_
edm::propagate_const< TTree * > parameterSetsTree_
double b
Definition: hdecay.h:120
static Registry * instance()
Definition: Registry.cc:12
void edm::RootOutputFile::writeParentageRegistry ( )

Definition at line 480 of file RootOutputFile.cc.

References Exception, edm::errors::FatalRootError, edm::ParentageRegistry::getMapped(), edm::ParentageRegistry::instance(), om_, edm::poolNames::parentageBranchName(), parentageIDs_, and parentageTree_.

Referenced by ~RootOutputFile().

480  {
481  Parentage const* desc(nullptr);
482 
483  if(!parentageTree_->Branch(poolNames::parentageBranchName().c_str(),
484  &desc, om_->basketSize(), 0))
486  << "Failed to create a branch for Parentages in the output file";
487 
488  ParentageRegistry& ptReg = *ParentageRegistry::instance();
489 
490  std::vector<ParentageID> orderedIDs(parentageIDs_.size());
491  for(auto const& parentageID : parentageIDs_) {
492  orderedIDs[parentageID.second] = parentageID.first;
493  }
494  //now put them into the TTree in the correct order
495  for(auto const& orderedID : orderedIDs) {
496  desc = ptReg.getMapped(orderedID);
497  //NOTE: some old format files have missing Parentage info
498  // so a null value of desc can't be fatal.
499  // Root will default construct an object in that case.
500  parentageTree_->Fill();
501  }
502  }
std::map< ParentageID, unsigned int > parentageIDs_
edm::propagate_const< PoolOutputModule * > om_
std::string const & parentageBranchName()
Definition: BranchType.cc:163
edm::propagate_const< TTree * > parentageTree_
static ParentageRegistry * instance()
void edm::RootOutputFile::writeProcessHistoryRegistry ( )

Definition at line 536 of file RootOutputFile.cc.

References b, metaDataTree_, om_, AlCaHLTBitMon_ParallelJobs::p, edm::poolNames::processHistoryBranchName(), and processHistoryRegistry_.

Referenced by ~RootOutputFile().

536  {
537  ProcessHistoryVector procHistoryVector;
538  for(auto const& ph : processHistoryRegistry_) {
539  procHistoryVector.push_back(ph.second);
540  }
541  ProcessHistoryVector* p = &procHistoryVector;
542  TBranch* b = metaDataTree_->Branch(poolNames::processHistoryBranchName().c_str(), &p, om_->basketSize(), 0);
543  assert(b);
544  b->Fill();
545  }
std::vector< ProcessHistory > ProcessHistoryVector
edm::propagate_const< TTree * > metaDataTree_
ProcessHistoryRegistry processHistoryRegistry_
edm::propagate_const< PoolOutputModule * > om_
std::string const & processHistoryBranchName()
Definition: BranchType.cc:198
double b
Definition: hdecay.h:120
void edm::RootOutputFile::writeProductDependencies ( )

Definition at line 605 of file RootOutputFile.cc.

References b, metaDataTree_, om_, and edm::poolNames::productDependenciesBranchName().

Referenced by ~RootOutputFile().

605  {
606  BranchChildren& pDeps = const_cast<BranchChildren&>(om_->branchChildren());
607  BranchChildren* ppDeps = &pDeps;
608  TBranch* b = metaDataTree_->Branch(poolNames::productDependenciesBranchName().c_str(), &ppDeps, om_->basketSize(), 0);
609  assert(b);
610  b->Fill();
611  }
edm::propagate_const< TTree * > metaDataTree_
edm::propagate_const< PoolOutputModule * > om_
double b
Definition: hdecay.h:120
std::string const & productDependenciesBranchName()
Definition: BranchType.cc:178
void edm::RootOutputFile::writeProductDescriptionRegistry ( )

Definition at line 574 of file RootOutputFile.cc.

References b, branchesWithStoredHistory_, end, metaDataTree_, om_, parseEventContent::prod, and edm::poolNames::productDescriptionBranchName().

Referenced by ~RootOutputFile().

574  {
575  // Make a local copy of the ProductRegistry, removing any transient or pruned products.
576  typedef ProductRegistry::ProductList ProductList;
578  ProductRegistry pReg(reg->productList());
579  ProductList& pList = const_cast<ProductList &>(pReg.productList());
580  for(auto const& prod : pList) {
581  if(prod.second.branchID() != prod.second.originalBranchID()) {
582  if(branchesWithStoredHistory_.find(prod.second.branchID()) != branchesWithStoredHistory_.end()) {
583  branchesWithStoredHistory_.insert(prod.second.originalBranchID());
584  }
585  }
586  }
587  std::set<BranchID>::iterator end = branchesWithStoredHistory_.end();
588  for(ProductList::iterator it = pList.begin(); it != pList.end();) {
589  if(branchesWithStoredHistory_.find(it->second.branchID()) == end) {
590  // avoid invalidating iterator on deletion
591  ProductList::iterator itCopy = it;
592  ++it;
593  pList.erase(itCopy);
594 
595  } else {
596  ++it;
597  }
598  }
599 
600  ProductRegistry* ppReg = &pReg;
601  TBranch* b = metaDataTree_->Branch(poolNames::productDescriptionBranchName().c_str(), &ppReg, om_->basketSize(), 0);
602  assert(b);
603  b->Fill();
604  }
std::map< BranchKey, BranchDescription > ProductList
edm::propagate_const< TTree * > metaDataTree_
std::set< BranchID > branchesWithStoredHistory_
edm::propagate_const< PoolOutputModule * > om_
#define end
Definition: vmac.h:37
double b
Definition: hdecay.h:120
std::string const & productDescriptionBranchName()
Definition: BranchType.cc:173
void edm::RootOutputFile::writeRun ( RunForOutput const &  r)

Definition at line 460 of file RootOutputFile.cc.

References edm::IndexIntoFile::addEntry(), fillBranches(), indexIntoFile_, edm::InRun, edm::RootOutputTree::optimizeBaskets(), edm::OccurrenceForOutput::processHistory(), edm::OccurrenceForOutput::processHistoryID(), processHistoryRegistry_, edm::ProcessHistoryRegistry::reducedProcessHistoryID(), edm::ProcessHistoryRegistry::registerProcessHistory(), reportToken_, edm::RunAuxiliary::run(), edm::RunForOutput::run(), runAux_, edm::RunForOutput::runAuxiliary(), runEntryNumber_, runTree_, edm::RunAuxiliary::setProcessHistoryID(), and mitigatedMETSequence_cff::U.

Referenced by ~RootOutputFile().

460  {
461  // Auxiliary branch
462  // NOTE: runAux_ must be filled before calling fillBranches since it gets written out in that routine.
463  runAux_ = r.runAuxiliary();
464  // Use the updated process historyID
465  runAux_.setProcessHistoryID(r.processHistoryID());
466  // Store the process history.
468  // Store the reduced ID in the IndexIntoFile
469  ProcessHistoryID reducedPHID = processHistoryRegistry_.reducedProcessHistoryID(r.processHistoryID());
470  // Add run to index.
471  indexIntoFile_.addEntry(reducedPHID, runAux_.run(), 0U, 0U, runEntryNumber_);
472  ++runEntryNumber_;
473  fillBranches(InRun, r);
474  runTree_.optimizeBaskets(10ULL*1024*1024);
475 
476  Service<JobReport> reportSvc;
477  reportSvc->reportRunNumber(reportToken_, r.run());
478  }
bool registerProcessHistory(ProcessHistory const &processHistory)
ProcessHistoryRegistry processHistoryRegistry_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
void addEntry(ProcessHistoryID const &processHistoryID, RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
Hash< ProcessHistoryType > ProcessHistoryID
RootOutputTree runTree_
IndexIntoFile indexIntoFile_
IndexIntoFile::EntryNumber_t runEntryNumber_
RunAuxiliary runAux_
void setProcessHistoryID(ProcessHistoryID const &phid)
Definition: RunAuxiliary.h:36
void optimizeBaskets(ULong64_t size)
RunNumber_t run() const
Definition: RunAuxiliary.h:41
JobReport::Token reportToken_
void fillBranches(BranchType const &branchType, OccurrenceForOutput const &occurrence, StoredProductProvenanceVector *productProvenanceVecPtr=0, ProductProvenanceRetriever const *provRetriever=0)
void edm::RootOutputFile::writeThinnedAssociationsHelper ( )

Definition at line 554 of file RootOutputFile.cc.

References b, metaDataTree_, om_, AlCaHLTBitMon_ParallelJobs::p, and edm::poolNames::thinnedAssociationsHelperBranchName().

Referenced by ~RootOutputFile().

554  {
555  ThinnedAssociationsHelper const* p = om_->thinnedAssociationsHelper();
556  TBranch* b = metaDataTree_->Branch(poolNames::thinnedAssociationsHelperBranchName().c_str(), &p, om_->basketSize(), 0);
557  assert(b);
558  b->Fill();
559  }
edm::propagate_const< TTree * > metaDataTree_
edm::propagate_const< PoolOutputModule * > om_
double b
Definition: hdecay.h:120
std::string const & thinnedAssociationsHelperBranchName()
Definition: BranchType.cc:213

Member Data Documentation

std::set<BranchID> edm::RootOutputFile::branchesWithStoredHistory_
private
bool edm::RootOutputFile::canFastCloneAux_
private

Definition at line 112 of file RootOutputFile.h.

Referenced by beginInputFile().

bool edm::RootOutputFile::dataTypeReported_
private

Definition at line 136 of file RootOutputFile.h.

Referenced by writeOne().

StoredProductProvenanceVector edm::RootOutputFile::eventEntryInfoVector_
private

Definition at line 128 of file RootOutputFile.h.

IndexIntoFile::EntryNumber_t edm::RootOutputFile::eventEntryNumber_
private

Definition at line 115 of file RootOutputFile.h.

Referenced by writeIndexIntoFile(), and writeOne().

RootOutputTree edm::RootOutputFile::eventTree_
private
FileID edm::RootOutputFile::fid_
private

Definition at line 114 of file RootOutputFile.h.

Referenced by RootOutputFile(), and writeFileIdentifier().

std::string edm::RootOutputFile::file_
private

Definition at line 107 of file RootOutputFile.h.

Referenced by beginInputFile(), fileName(), and RootOutputFile().

edm::propagate_const<std::shared_ptr<TFile> > edm::RootOutputFile::filePtr_
private

Definition at line 113 of file RootOutputFile.h.

Referenced by filePtr(), finishEndFile(), RootOutputFile(), and shouldWeCloseFile().

IndexIntoFile edm::RootOutputFile::indexIntoFile_
private

Definition at line 118 of file RootOutputFile.h.

Referenced by writeIndexIntoFile(), writeLuminosityBlock(), writeOne(), and writeRun().

std::string edm::RootOutputFile::logicalFile_
private

Definition at line 108 of file RootOutputFile.h.

Referenced by RootOutputFile().

LuminosityBlockAuxiliary edm::RootOutputFile::lumiAux_
private

Definition at line 123 of file RootOutputFile.h.

Referenced by writeLuminosityBlock().

IndexIntoFile::EntryNumber_t edm::RootOutputFile::lumiEntryNumber_
private

Definition at line 116 of file RootOutputFile.h.

Referenced by writeLuminosityBlock().

RootOutputTree edm::RootOutputFile::lumiTree_
private

Definition at line 133 of file RootOutputFile.h.

Referenced by respondToCloseInputFile(), RootOutputFile(), and writeLuminosityBlock().

edm::propagate_const<TTree*> edm::RootOutputFile::metaDataTree_
private
unsigned long edm::RootOutputFile::nEventsInLumi_
private

Definition at line 119 of file RootOutputFile.h.

Referenced by writeLuminosityBlock(), and writeOne().

edm::propagate_const<PoolOutputModule*> edm::RootOutputFile::om_
private
edm::propagate_const<TTree*> edm::RootOutputFile::parameterSetsTree_
private

Definition at line 121 of file RootOutputFile.h.

Referenced by finishEndFile(), RootOutputFile(), and writeParameterSetRegistry().

std::map<ParentageID,unsigned int> edm::RootOutputFile::parentageIDs_
private

Definition at line 138 of file RootOutputFile.h.

Referenced by insertProductProvenance(), and writeParentageRegistry().

edm::propagate_const<TTree*> edm::RootOutputFile::parentageTree_
private

Definition at line 122 of file RootOutputFile.h.

Referenced by finishEndFile(), RootOutputFile(), and writeParentageRegistry().

BranchListIndexes const* edm::RootOutputFile::pBranchListIndexes_
private

Definition at line 130 of file RootOutputFile.h.

Referenced by RootOutputFile(), and writeOne().

EventAuxiliary const* edm::RootOutputFile::pEventAux_
private

Definition at line 125 of file RootOutputFile.h.

Referenced by RootOutputFile(), and writeOne().

edm::propagate_const<StoredProductProvenanceVector*> edm::RootOutputFile::pEventEntryInfoVector_
private

Definition at line 129 of file RootOutputFile.h.

Referenced by pEventEntryInfoVector(), and writeOne().

EventSelectionIDVector const* edm::RootOutputFile::pEventSelectionIDs_
private

Definition at line 131 of file RootOutputFile.h.

Referenced by RootOutputFile(), and writeOne().

LuminosityBlockAuxiliary const* edm::RootOutputFile::pLumiAux_
private

Definition at line 126 of file RootOutputFile.h.

Referenced by RootOutputFile().

ProcessHistoryRegistry edm::RootOutputFile::processHistoryRegistry_
private
RunAuxiliary const* edm::RootOutputFile::pRunAux_
private

Definition at line 127 of file RootOutputFile.h.

Referenced by RootOutputFile().

JobReport::Token edm::RootOutputFile::reportToken_
private
RunAuxiliary edm::RootOutputFile::runAux_
private

Definition at line 124 of file RootOutputFile.h.

Referenced by writeRun().

IndexIntoFile::EntryNumber_t edm::RootOutputFile::runEntryNumber_
private

Definition at line 117 of file RootOutputFile.h.

Referenced by writeRun().

RootOutputTree edm::RootOutputFile::runTree_
private

Definition at line 134 of file RootOutputFile.h.

Referenced by respondToCloseInputFile(), RootOutputFile(), and writeRun().

RootOutputTreePtrArray edm::RootOutputFile::treePointers_
private

Definition at line 135 of file RootOutputFile.h.

Referenced by fillBranches(), finishEndFile(), and RootOutputFile().

int edm::RootOutputFile::whyNotFastClonable_
private

Definition at line 111 of file RootOutputFile.h.

Referenced by beginInputFile(), and fillBranches().

edm::propagate_const<TClass*> edm::RootOutputFile::wrapperBaseTClass_
private

Definition at line 140 of file RootOutputFile.h.

Referenced by fillBranches().