CMS 3D CMS Logo

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

#include <RootFile.h>

Public Types

typedef std::array< RootTree *, NumBranchTypesRootTreePtrArray
 

Public Member Functions

std::shared_ptr< BranchIDListHelper const > branchIDListHelper () const
 
std::shared_ptr< BranchIDListHelper > & branchIDListHelper ()
 
bool branchListIndexesUnchanged () const
 
void close ()
 
bool containsItem (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
 
std::unique_ptr< FileBlockcreateFileBlock () const
 
EventAuxiliary const & eventAux () const
 
EventID const & eventID () const
 
RootTree const & eventTree () const
 
std::string const & file () const
 
FileFormatVersion fileFormatVersion () const
 
IndexIntoFile::EntryType getNextItemType (RunNumber_t &run, LuminosityBlockNumber_t &lumi, EventNumber_t &event)
 
bool goToEvent (EventID const &eventID)
 
std::array< bool, NumBranchTypes > const & hasNewlyDroppedBranch () const
 
IndexIntoFile::IndexIntoFileItr indexIntoFileIter () const
 
std::shared_ptr< IndexIntoFile const > indexIntoFileSharedPtr () const
 
std::shared_ptr< IndexIntoFile > & indexIntoFileSharedPtr ()
 
void initAssociationsFromSecondary (std::vector< BranchID > const &)
 
RootTree const & lumiTree () const
 
bool modifiedIDs () const
 
bool nextEventEntry ()
 
RootFileoperator= (RootFile const &)=delete
 
std::shared_ptr< ProductRegistry const > productRegistry () const
 
bool readCurrentEvent (EventPrincipal &cache)
 
void readEvent (EventPrincipal &cache)
 
void readFakeRun_ (RunPrincipal &runPrincipal)
 
std::shared_ptr< RunAuxiliaryreadFakeRunAuxiliary_ ()
 
void readLuminosityBlock_ (LuminosityBlockPrincipal &lumiPrincipal)
 
std::shared_ptr< LuminosityBlockAuxiliaryreadLuminosityBlockAuxiliary_ ()
 
void readRun_ (RunPrincipal &runPrincipal)
 
std::shared_ptr< RunAuxiliaryreadRunAuxiliary_ ()
 
void reportOpened (std::string const &inputType)
 
void rewind ()
 
 RootFile (std::string const &fileName, ProcessConfiguration const &processConfiguration, std::string const &logicalFileName, std::shared_ptr< InputFile > filePtr, std::shared_ptr< EventSkipperByID > eventSkipperByID, bool skipAnyEvents, int remainingEvents, int remainingLumis, unsigned int nStreams, unsigned int treeCacheSize, int treeMaxVirtualSize, InputSource::ProcessingMode processingMode, RunHelperBase *runHelper, bool noEventSort, ProductSelectorRules const &productSelectorRules, InputType inputType, std::shared_ptr< BranchIDListHelper > branchIDListHelper, std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper, std::vector< BranchID > const *associationsFromSecondary, std::shared_ptr< DuplicateChecker > duplicateChecker, bool dropDescendantsOfDroppedProducts, ProcessHistoryRegistry &processHistoryRegistry, std::vector< std::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< std::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile, std::vector< ProcessHistoryID > &orderedProcessHistoryIDs, bool bypassVersionCheck, bool labelRawDataLikeMC, bool usingGoToEvent, bool enablePrefetching, bool enforceGUIDInFileName)
 
 RootFile (std::string const &fileName, ProcessConfiguration const &processConfiguration, std::string const &logicalFileName, std::shared_ptr< InputFile > filePtr, unsigned int nStreams, int treeMaxVirtualSize, InputSource::ProcessingMode processingMode, RunHelperBase *runHelper, ProductSelectorRules const &productSelectorRules, InputType inputType, std::shared_ptr< BranchIDListHelper > branchIDListHelper, std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper, std::vector< BranchID > const *associationsFromSecondary, bool dropDescendantsOfDroppedProducts, ProcessHistoryRegistry &processHistoryRegistry, std::vector< std::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< std::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile, std::vector< ProcessHistoryID > &orderedProcessHistoryIDs, bool bypassVersionCheck, bool labelRawDataLikeMC, bool enablePrefetching, bool enforceGUIDInFileName)
 
 RootFile (std::string const &fileName, ProcessConfiguration const &processConfiguration, std::string const &logicalFileName, std::shared_ptr< InputFile > filePtr, unsigned int nStreams, unsigned int treeCacheSize, int treeMaxVirtualSize, RunHelperBase *runHelper, ProductSelectorRules const &productSelectorRules, InputType inputType, ProcessHistoryRegistry &processHistoryRegistry, std::vector< std::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< std::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile, std::vector< ProcessHistoryID > &orderedProcessHistoryIDs, bool bypassVersionCheck, bool enablePrefetching, bool enforceGUIDInFileName)
 
 RootFile (RootFile const &)=delete
 
RootTree const & runTree () const
 
void setAtEventEntry (IndexIntoFile::EntryNumber_t entry)
 
bool setEntryAtEvent (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
 
bool setEntryAtItem (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
 
bool setEntryAtLumi (RunNumber_t run, LuminosityBlockNumber_t lumi)
 
bool setEntryAtNextEventInLumi (RunNumber_t run, LuminosityBlockNumber_t lumi)
 
bool setEntryAtRun (RunNumber_t run)
 
void setPosition (IndexIntoFile::IndexIntoFileItr const &position)
 
void setSignals (signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *preEventReadSource, signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *postEventReadSource)
 
void setToLastEntry ()
 
bool skipEntries (unsigned int &offset)
 
bool skipEvents (int &offset)
 
bool wasFirstEventJustRead () const
 
bool wasLastEventJustRead () const
 
int whyNotFastClonable () const
 
 ~RootFile ()
 

Private Member Functions

std::shared_ptr< BranchChildren const > branchChildren () const
 
std::shared_ptr< BranchChildren > & branchChildren ()
 
void dropOnInput (ProductRegistry &reg, ProductSelectorRules const &rules, bool dropDescendants, InputType inputType)
 
std::shared_ptr< ProductProvenanceRetriever const > eventProductProvenanceRetriever (size_t index) const
 
std::shared_ptr< ProductProvenanceRetriever > & eventProductProvenanceRetriever (size_t index)
 
bool fillEventAuxiliary (IndexIntoFile::EntryNumber_t entry)
 
void fillEventHistory ()
 
void fillIndexIntoFile ()
 
std::shared_ptr< LuminosityBlockAuxiliaryfillLumiAuxiliary ()
 
std::shared_ptr< RunAuxiliaryfillRunAuxiliary ()
 
void fillThisEventAuxiliary ()
 
void initializeDuplicateChecker (std::vector< std::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< std::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile)
 
bool isDuplicateEvent ()
 
std::shared_ptr< ProductProvenanceRetrievermakeProductProvenanceRetriever (unsigned int iStreamIndex)
 
std::unique_ptr< MakeProvenanceReadermakeProvenanceReaderMaker (InputType inputType)
 
void markBranchToBeDropped (bool dropDescendants, BranchDescription const &branch, std::set< BranchID > &branchesToDrop, std::map< BranchID, BranchID > const &droppedToKeptAlias) const
 
std::string const & newBranchToOldBranch (std::string const &newBranch) const
 
void readEntryDescriptionTree (EntryDescriptionMap &entryDescriptionMap, InputType inputType)
 
void readEventHistoryTree ()
 
void readParentageTree (InputType inputType)
 
std::shared_ptr< RunAuxiliary const > savedRunAuxiliary () const
 
std::shared_ptr< RunAuxiliary > & savedRunAuxiliary ()
 
void setIfFastClonable (int remainingEvents, int remainingLumis)
 
bool skipThisEntry ()
 
RootTreePtrArraytreePointers ()
 
void validateFile (InputType inputType, bool usingGoToEvent)
 

Private Attributes

edm::propagate_const< std::shared_ptr< BranchChildren > > branchChildren_
 
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
 
std::shared_ptr< BranchIDLists const > branchIDLists_
 
BranchListIndexes branchListIndexes_
 
bool branchListIndexesUnchanged_
 
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
 
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
 
edm::propagate_const< TClass * > edProductClass_
 
bool enforceGUIDInFileName_
 
EventAuxiliary eventAux_
 
edm::propagate_const< TTree * > eventHistoryTree_
 
std::vector< EventProcessHistoryIDeventProcessHistoryIDs_
 
std::vector< EventProcessHistoryID >::const_iterator eventProcessHistoryIter_
 
std::vector< edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > > eventProductProvenanceRetrievers_
 
EventSelectionIDVector eventSelectionIDs_
 
edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
 
RootTree eventTree_
 
FileID fid_
 
std::string const file_
 
FileFormatVersion fileFormatVersion_
 
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
 
edm::propagate_const< std::unique_ptr< ThinnedAssociationsHelper > > fileThinnedAssociationsHelper_
 
std::array< bool, NumBranchTypeshasNewlyDroppedBranch_
 
edm::propagate_const< std::unique_ptr< History > > history_
 
IndexIntoFileindexIntoFile_
 
IndexIntoFile::IndexIntoFileItr indexIntoFileBegin_
 
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
 
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
 
edm::propagate_const< std::shared_ptr< IndexIntoFile > > indexIntoFileSharedPtr_
 
IndexIntoFile::EntryNumber_t lastEventEntryNumberRead_
 
std::string const logicalFile_
 
RootTree lumiTree_
 
std::map< std::string, std::string > newBranchToOldBranch_
 
bool noEventSort_
 
std::vector< ProcessHistoryID > & orderedProcessHistoryIDs_
 
std::vector< ParentageIDparentageIDLookup_
 
ProcessConfiguration const & processConfiguration_
 
edm::propagate_const< ProcessHistoryRegistry * > processHistoryRegistry_
 
InputSource::ProcessingMode processingMode_
 
std::shared_ptr< ProductRegistry const > productRegistry_
 
edm::propagate_const< std::unique_ptr< ProvenanceAdaptor > > provenanceAdaptor_
 
edm::propagate_const< std::unique_ptr< MakeProvenanceReader > > provenanceReaderMaker_
 
edm::propagate_const< RunHelperBase * > runHelper_
 
RootTree runTree_
 
edm::propagate_const< std::shared_ptr< RunAuxiliary > > savedRunAuxiliary_
 
bool skipAnyEvents_
 
edm::propagate_const< std::shared_ptr< ThinnedAssociationsHelper > > thinnedAssociationsHelper_
 
RootTreePtrArray treePointers_
 
int whyNotFastClonable_
 

Detailed Description

Definition at line 61 of file RootFile.h.

Member Typedef Documentation

Definition at line 63 of file RootFile.h.

Constructor & Destructor Documentation

edm::RootFile::RootFile ( std::string const &  fileName,
ProcessConfiguration const &  processConfiguration,
std::string const &  logicalFileName,
std::shared_ptr< InputFile filePtr,
std::shared_ptr< EventSkipperByID eventSkipperByID,
bool  skipAnyEvents,
int  remainingEvents,
int  remainingLumis,
unsigned int  nStreams,
unsigned int  treeCacheSize,
int  treeMaxVirtualSize,
InputSource::ProcessingMode  processingMode,
RunHelperBase runHelper,
bool  noEventSort,
ProductSelectorRules const &  productSelectorRules,
InputType  inputType,
std::shared_ptr< BranchIDListHelper branchIDListHelper,
std::shared_ptr< ThinnedAssociationsHelper thinnedAssociationsHelper,
std::vector< BranchID > const *  associationsFromSecondary,
std::shared_ptr< DuplicateChecker duplicateChecker,
bool  dropDescendantsOfDroppedProducts,
ProcessHistoryRegistry processHistoryRegistry,
std::vector< std::shared_ptr< IndexIntoFile > > const &  indexesIntoFiles,
std::vector< std::shared_ptr< IndexIntoFile > >::size_type  currentIndexIntoFile,
std::vector< ProcessHistoryID > &  orderedProcessHistoryIDs,
bool  bypassVersionCheck,
bool  labelRawDataLikeMC,
bool  usingGoToEvent,
bool  enablePrefetching,
bool  enforceGUIDInFileName 
)

Definition at line 130 of file RootFile.cc.

References edm::IndexIntoFile::begin(), branchChildren_, edm::poolNames::branchIDListBranchName(), branchIDListHelper_, branchIDLists_, branchListIndexesUnchanged_, edm::BranchDescription::branchName(), edm::BranchDescription::branchType(), edm::BranchTypeToAuxiliaryBranchName(), edm::BranchDescription::className(), edm::ProductRegistry::copyProduct(), daqProvenanceHelper_, edm::roottree::defaultNonEventCacheSize, edm::IndexIntoFile::doneFileInitialization(), dropOnInput(), edm::IndexIntoFile::end(), edm::errors::EventCorruption, edm::poolNames::eventHistoryBranchName(), eventProcessHistoryIDs_, eventProcessHistoryIter_, eventSkipperByID_, edm::FileBlock::EventsOrLumisSelectedByID, eventTree_, Exception, fid_, file(), fileFormatVersion(), fileFormatVersion_, edm::poolNames::fileFormatVersionBranchName(), edm::poolNames::fileIdentifierBranchName(), filePtr_, edm::errors::FileReadError, fileThinnedAssociationsHelper_, ghostTrackVertexReco_cff::finder, edm::IndexIntoFile::firstAppearanceOrder, edm::BranchDescription::friendlyClassName(), edm::friendlyname::friendlyName(), edm::roottree::getEntry(), hasNewlyDroppedBranch_, edm::FileFormatVersion::hasThinnedAssociations(), mps_fire::i, edm::poolNames::idToParameterSetBlobsBranchName(), indexIntoFile_, indexIntoFileBegin_, edm::poolNames::indexIntoFileBranchName(), indexIntoFileEnd_, indexIntoFileIter_, edm::InEvent, edm::BranchDescription::init(), initializeDuplicateChecker(), edm::InLumi, edm::InRun, edm::pset::Registry::insertMapped(), edm::pset::Registry::instance(), lumiTree_, makeProvenanceReaderMaker(), edm::poolNames::metaDataTreeName(), edm::poolNames::moduleDescriptionMapBranchName(), newBranchToOldBranch(), newBranchToOldBranch_, edm::IndexIntoFile::numericalOrder, edm::poolNames::parameterSetMapBranchName(), edm::poolNames::parameterSetsTreeName(), edm::Primary, edm::poolNames::processConfigurationBranchName(), edm::poolNames::processHistoryBranchName(), edm::poolNames::processHistoryMapBranchName(), parseEventContent::prod, edm::poolNames::productDependenciesBranchName(), edm::poolNames::productDescriptionBranchName(), edm::ProductRegistry::productList(), edm::ProductRegistry::productListUpdator(), productRegistry(), productRegistry_, provenanceAdaptor_, provenanceReaderMaker_, muonDTDigis_cfi::pset, readEventHistoryTree(), edm::ProcessHistoryRegistry::registerProcessHistory(), edm::RootTree::resetTraining(), edm::IndexIntoFile::IndexIntoFileItr::run(), runHelper_, runTree_, edm::SecondaryFile, edm::SecondarySource, setIfFastClonable(), edm::source(), AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, edm::poolNames::thinnedAssociationsHelperBranchName(), edm::RootTree::trainCache(), edm::roottree::trainCache(), treePointers_, edm::errors::UnimplementedFeature, edm::BranchDescription::updateFriendlyClassName(), validateFile(), and whyNotFastClonable_.

159  :
160  file_(fileName),
161  logicalFile_(logicalFileName),
162  processConfiguration_(processConfiguration),
163  processHistoryRegistry_(&processHistoryRegistry),
164  filePtr_(filePtr),
165  eventSkipperByID_(eventSkipperByID),
167  fid_(),
168  indexIntoFileSharedPtr_(new IndexIntoFile),
170  orderedProcessHistoryIDs_(orderedProcessHistoryIDs),
177  skipAnyEvents_(skipAnyEvents),
179  enforceGUIDInFileName_(enforceGUIDInFileName),
183  eventAux_(),
184  eventTree_(filePtr, InEvent, nStreams, treeMaxVirtualSize, treeCacheSize, roottree::defaultLearningEntries, enablePrefetching, inputType),
185  lumiTree_(filePtr, InLumi, 1, treeMaxVirtualSize, roottree::defaultNonEventCacheSize, roottree::defaultNonEventLearningEntries, enablePrefetching, inputType),
186  runTree_(filePtr, InRun, 1, treeMaxVirtualSize, roottree::defaultNonEventCacheSize, roottree::defaultNonEventLearningEntries, enablePrefetching, inputType),
187  treePointers_(),
190  branchIDLists_(),
193  thinnedAssociationsHelper_(thinnedAssociationsHelper),
194  processingMode_(processingMode),
195  runHelper_(runHelper),
197  eventHistoryTree_(nullptr),
200  history_(),
201  branchChildren_(new BranchChildren),
202  duplicateChecker_(duplicateChecker),
208  edProductClass_(TClass::GetClass("edm::WrapperBase")) {
209 
210  hasNewlyDroppedBranch_.fill(false);
211 
215 
216  // Read the metadata tree.
217  // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
218  std::unique_ptr<TTree> metaDataTree(dynamic_cast<TTree *>(filePtr_->Get(poolNames::metaDataTreeName().c_str())));
219  if(nullptr == metaDataTree.get()) {
220  throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::metaDataTreeName()
221  << " in the input file.\n";
222  }
223 
224  // To keep things simple, we just read in every possible branch that exists.
225  // We don't pay attention to which branches exist in which file format versions
226 
227  FileFormatVersion *fftPtr = &fileFormatVersion_;
228  if(metaDataTree->FindBranch(poolNames::fileFormatVersionBranchName().c_str()) != nullptr) {
229  TBranch *fft = metaDataTree->GetBranch(poolNames::fileFormatVersionBranchName().c_str());
230  fft->SetAddress(&fftPtr);
231  roottree::getEntry(fft, 0);
232  metaDataTree->SetBranchAddress(poolNames::fileFormatVersionBranchName().c_str(), &fftPtr);
233  }
234 
235  FileID *fidPtr = &fid_;
236  if(metaDataTree->FindBranch(poolNames::fileIdentifierBranchName().c_str()) != nullptr) {
237  metaDataTree->SetBranchAddress(poolNames::fileIdentifierBranchName().c_str(), &fidPtr);
238  }
239 
240  IndexIntoFile *iifPtr = &indexIntoFile_;
241  if(metaDataTree->FindBranch(poolNames::indexIntoFileBranchName().c_str()) != nullptr) {
242  metaDataTree->SetBranchAddress(poolNames::indexIntoFileBranchName().c_str(), &iifPtr);
243  }
244 
245  // Need to read to a temporary registry so we can do a translation of the BranchKeys.
246  // This preserves backward compatibility against friendly class name algorithm changes.
247  ProductRegistry inputProdDescReg;
248  ProductRegistry *ppReg = &inputProdDescReg;
249  metaDataTree->SetBranchAddress(poolNames::productDescriptionBranchName().c_str(), (&ppReg));
250 
251  typedef std::map<ParameterSetID, ParameterSetBlob> PsetMap;
252  PsetMap psetMap;
253  PsetMap *psetMapPtr = &psetMap;
254  if(metaDataTree->FindBranch(poolNames::parameterSetMapBranchName().c_str()) != nullptr) {
255  //backward compatibility
256  assert(!fileFormatVersion().parameterSetsTree());
257  metaDataTree->SetBranchAddress(poolNames::parameterSetMapBranchName().c_str(), &psetMapPtr);
258  } else {
259  assert(fileFormatVersion().parameterSetsTree());
260  // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
261  std::unique_ptr<TTree> psetTree(dynamic_cast<TTree *>(filePtr_->Get(poolNames::parameterSetsTreeName().c_str())));
262  if(nullptr == psetTree.get()) {
263  throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::parameterSetsTreeName()
264  << " in the input file.\n";
265  }
266 
267  typedef std::pair<ParameterSetID, ParameterSetBlob> IdToBlobs;
268  IdToBlobs idToBlob;
269  IdToBlobs* pIdToBlob = &idToBlob;
270  psetTree->SetBranchAddress(poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);
271 
272  std::unique_ptr<TTreeCache> psetTreeCache = roottree::trainCache(psetTree.get(), *filePtr_, roottree::defaultNonEventCacheSize, "*");
273  psetTreeCache->SetEnablePrefetching(false);
274  filePtr_->SetCacheRead(psetTreeCache.get());
275  for(Long64_t i = 0; i != psetTree->GetEntries(); ++i) {
276  psetTree->GetEntry(i);
277  psetMap.insert(idToBlob);
278  }
279  filePtr_->SetCacheRead(nullptr);
280  }
281 
282  // backward compatibility
284  ProcessHistoryRegistry::collection_type *pHistMapPtr = &pHistMap;
285  if(metaDataTree->FindBranch(poolNames::processHistoryMapBranchName().c_str()) != nullptr) {
286  metaDataTree->SetBranchAddress(poolNames::processHistoryMapBranchName().c_str(), &pHistMapPtr);
287  }
288 
290  ProcessHistoryRegistry::vector_type *pHistVectorPtr = &pHistVector;
291  if(metaDataTree->FindBranch(poolNames::processHistoryBranchName().c_str()) != nullptr) {
292  metaDataTree->SetBranchAddress(poolNames::processHistoryBranchName().c_str(), &pHistVectorPtr);
293  }
294 
295  // backward compatibility
296  ProcessConfigurationVector processConfigurations;
297  ProcessConfigurationVector* procConfigVectorPtr = &processConfigurations;
298  if(metaDataTree->FindBranch(poolNames::processConfigurationBranchName().c_str()) != nullptr) {
299  metaDataTree->SetBranchAddress(poolNames::processConfigurationBranchName().c_str(), &procConfigVectorPtr);
300  }
301 
302  auto branchIDListsAPtr = std::make_unique<BranchIDLists>();
303  BranchIDLists* branchIDListsPtr = branchIDListsAPtr.get();
304  if(metaDataTree->FindBranch(poolNames::branchIDListBranchName().c_str()) != nullptr) {
305  metaDataTree->SetBranchAddress(poolNames::branchIDListBranchName().c_str(), &branchIDListsPtr);
306  }
307 
308  if(inputType != InputType::SecondarySource) {
309  fileThinnedAssociationsHelper_ = std::make_unique<ThinnedAssociationsHelper>(); // propagate_const<T> has no reset() function
310  ThinnedAssociationsHelper* thinnedAssociationsHelperPtr = fileThinnedAssociationsHelper_.get();
311  if(metaDataTree->FindBranch(poolNames::thinnedAssociationsHelperBranchName().c_str()) != nullptr) {
312  metaDataTree->SetBranchAddress(poolNames::thinnedAssociationsHelperBranchName().c_str(), &thinnedAssociationsHelperPtr);
313  }
314  }
315 
316  BranchChildren* branchChildrenBuffer = branchChildren_.get();
317  if(metaDataTree->FindBranch(poolNames::productDependenciesBranchName().c_str()) != nullptr) {
318  metaDataTree->SetBranchAddress(poolNames::productDependenciesBranchName().c_str(), &branchChildrenBuffer);
319  }
320 
321  // backward compatibility
322  std::vector<EventProcessHistoryID> *eventHistoryIDsPtr = &eventProcessHistoryIDs_;
323  if(metaDataTree->FindBranch(poolNames::eventHistoryBranchName().c_str()) != nullptr) {
324  metaDataTree->SetBranchAddress(poolNames::eventHistoryBranchName().c_str(), &eventHistoryIDsPtr);
325  }
326 
327  if(metaDataTree->FindBranch(poolNames::moduleDescriptionMapBranchName().c_str()) != nullptr) {
328  if(metaDataTree->GetBranch(poolNames::moduleDescriptionMapBranchName().c_str())->GetSplitLevel() != 0) {
329  metaDataTree->SetBranchStatus((poolNames::moduleDescriptionMapBranchName() + ".*").c_str(), false);
330  } else {
331  metaDataTree->SetBranchStatus(poolNames::moduleDescriptionMapBranchName().c_str(), false);
332  }
333  }
334 
335  // Here we read the metadata tree
336  roottree::getEntry(metaDataTree.get(), 0);
337 
339 
340  // Here we read the event history tree, if we have one.
342 
344  if(!fileFormatVersion().triggerPathsTracked()) {
345  ParameterSetConverter converter(psetMap, psetIdConverter, fileFormatVersion().parameterSetsByReference());
346  } else {
347  // Merge into the parameter set registry.
348  pset::Registry& psetRegistry = *pset::Registry::instance();
349  for(auto const& psetEntry : psetMap) {
350  ParameterSet pset(psetEntry.second.pset());
351  pset.setID(psetEntry.first);
352  // For thread safety, don't update global registries when a secondary source opens a file.
353  if(inputType != InputType::SecondarySource) {
354  psetRegistry.insertMapped(pset);
355  }
356  }
357  }
358  if(!fileFormatVersion().splitProductIDs()) {
359  // Old provenance format input file. Create a provenance adaptor.
360  // propagate_const<T> has no reset() function
361  provenanceAdaptor_ = std::make_unique<ProvenanceAdaptor>(
362  inputProdDescReg, pHistMap, pHistVector, processConfigurations, psetIdConverter, true);
363  // Fill in the branchIDLists branch from the provenance adaptor
364  branchIDLists_ = provenanceAdaptor_->branchIDLists();
365  } else {
366  if(!fileFormatVersion().triggerPathsTracked()) {
367  // New provenance format, but change in ParameterSet Format. Create a provenance adaptor.
368  // propagate_const<T> has no reset() function
369  provenanceAdaptor_ = std::make_unique<ProvenanceAdaptor>(
370  inputProdDescReg, pHistMap, pHistVector, processConfigurations, psetIdConverter, false);
371  }
372  // New provenance format input file. The branchIDLists branch was read directly from the input file.
373  if(metaDataTree->FindBranch(poolNames::branchIDListBranchName().c_str()) == nullptr) {
375  << "Failed to find branchIDLists branch in metaData tree.\n";
376  }
377  branchIDLists_.reset(branchIDListsAPtr.release());
378  }
379 
381  if(metaDataTree->FindBranch(poolNames::thinnedAssociationsHelperBranchName().c_str()) == nullptr) {
383  << "Failed to find thinnedAssociationsHelper branch in metaData tree.\n";
384  }
385  }
386 
387  if(!bypassVersionCheck) {
388  checkReleaseVersion(pHistVector, file());
389  }
390 
391  if(labelRawDataLikeMC) {
392  std::string const rawData("FEDRawDataCollection");
393  std::string const source("source");
394  ProductRegistry::ProductList& pList = inputProdDescReg.productListUpdator();
395  BranchKey finder(rawData, source, "", "");
396  ProductRegistry::ProductList::iterator it = pList.lower_bound(finder);
397  if(it != pList.end() && it->first.friendlyClassName() == rawData && it->first.moduleLabel() == source) {
398  // We found raw data with a module label of source.
399  // We need to change the module label and process name.
400  // Create helper.
401  it->second.init();
402  // propagate_const<T> has no reset() function
403  daqProvenanceHelper_ = std::make_unique<DaqProvenanceHelper>(it->second.unwrappedTypeID());
404  // Create the new branch description
405  BranchDescription const& newBD = daqProvenanceHelper_->branchDescription();
406  // Save info from the old and new branch descriptions
407  daqProvenanceHelper_->saveInfo(it->second, newBD);
408  // Map the new branch name to the old branch name.
409  newBranchToOldBranch_.insert(std::make_pair(newBD.branchName(), it->second.branchName()));
410  // Remove the old branch description from the product Registry.
411  pList.erase(it);
412  // Check that there was only one.
413  it = pList.lower_bound(finder);
414  assert(!(it != pList.end() && it->first.friendlyClassName() == rawData && it->first.moduleLabel() == source));
415  // Insert the new branch description into the product registry.
416  inputProdDescReg.copyProduct(newBD);
417  // Fix up other per file metadata.
418  daqProvenanceHelper_->fixMetaData(processConfigurations, pHistVector);
419  daqProvenanceHelper_->fixMetaData(*branchIDLists_);
420  daqProvenanceHelper_->fixMetaData(*branchChildren_);
421  }
422  }
423 
424  for(auto const& history : pHistVector) {
425  processHistoryRegistry.registerProcessHistory(history);
426  }
427 
429 
430  // Update the branch id info. This has to be done before validateFile since
431  // depending on the file format, the branchIDListHelper_ may have its fixBranchListIndexes call made
432  if(inputType == InputType::Primary) {
433  branchListIndexesUnchanged_ = branchIDListHelper_->updateFromInput(*branchIDLists_);
434  }
435 
436  validateFile(inputType, usingGoToEvent);
437 
438  // Here, we make the class that will make the ProvenanceReader
439  // It reads whatever trees it needs.
440  // propagate_const<T> has no reset() function
441  provenanceReaderMaker_ = std::unique_ptr<MakeProvenanceReader>(makeProvenanceReaderMaker(inputType).release());
442 
443  // Merge into the hashed registries.
444  if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
446  }
447 
448  initializeDuplicateChecker(indexesIntoFiles, currentIndexIntoFile);
452  eventProcessHistoryIter_ = eventProcessHistoryIDs_.begin();
453 
454  // Set product presence information in the product registry.
455  ProductRegistry::ProductList& pList = inputProdDescReg.productListUpdator();
456  for(auto& product : pList) {
457  BranchDescription& prod = product.second;
458  prod.init();
459  treePointers_[prod.branchType()]->setPresence(prod, newBranchToOldBranch(prod.branchName()));
460  }
461 
462  auto newReg = std::make_unique<ProductRegistry>();
463 
464  // Do the translation from the old registry to the new one
465  {
466  ProductRegistry::ProductList const& prodList = inputProdDescReg.productList();
467  for(auto const& product : prodList) {
468  BranchDescription const& prod = product.second;
469  std::string newFriendlyName = friendlyname::friendlyName(prod.className());
470  if(newFriendlyName == prod.friendlyClassName()) {
471  newReg->copyProduct(prod);
472  } else {
473  if(fileFormatVersion().splitProductIDs()) {
475  << "Cannot change friendly class name algorithm without more development work\n"
476  << "to update BranchIDLists and ThinnedAssociationsHelper. Contact the framework group.\n";
477  }
478  BranchDescription newBD(prod);
479  newBD.updateFriendlyClassName();
480  newReg->copyProduct(newBD);
481  newBranchToOldBranch_.insert(std::make_pair(newBD.branchName(), prod.branchName()));
482  }
483  }
484  dropOnInput(*newReg, productSelectorRules, dropDescendants, inputType);
485  if(inputType == InputType::SecondaryFile) {
486  thinnedAssociationsHelper->updateFromSecondaryInput(*fileThinnedAssociationsHelper_,
487  *associationsFromSecondary);
488  } else if (inputType == InputType::Primary) {
489  thinnedAssociationsHelper->updateFromPrimaryInput(*fileThinnedAssociationsHelper_);
490  }
491  // freeze the product registry
492  newReg->setFrozen(inputType != InputType::Primary);
493  productRegistry_.reset(newReg.release());
494  }
495 
496  // Set up information from the product registry.
497  ProductRegistry::ProductList const& prodList = productRegistry()->productList();
498 
499  {
500  std::array<size_t,NumBranchTypes> nBranches;
501  nBranches.fill(0);
502  for(auto const& product : prodList) {
503  ++nBranches[product.second.branchType()];
504  }
505 
506  int i = 0;
507  for(auto t: treePointers_) {
508  t->numberOfBranchesToAdd(nBranches[i]);
509  ++i;
510  }
511  }
512  for(auto const& product : prodList) {
513  BranchDescription const& prod = product.second;
514  treePointers_[prod.branchType()]->addBranch(prod,
515  newBranchToOldBranch(prod.branchName()));
516  }
517 
518  // Determine if this file is fast clonable.
519  setIfFastClonable(remainingEvents, remainingLumis);
520 
521  // We are done with our initial reading of EventAuxiliary.
523 
524  // Tell the event tree to begin training at the next read.
526 
527  // Train the run and lumi trees.
528  runTree_.trainCache("*");
529  lumiTree_.trainCache("*");
530  }
void dropOnInput(ProductRegistry &reg, ProductSelectorRules const &rules, bool dropDescendants, InputType inputType)
Definition: RootFile.cc:1696
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:510
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:255
edm::propagate_const< std::unique_ptr< ThinnedAssociationsHelper > > fileThinnedAssociationsHelper_
Definition: RootFile.h:288
std::vector< ProcessConfiguration > ProcessConfigurationVector
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:115
unsigned int const defaultNonEventLearningEntries
Definition: RootTree.h:49
void doneFileInitialization() const
Clears the temporary vector of event numbers to reduce memory usage.
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
std::shared_ptr< BranchIDLists const > branchIDLists_
Definition: RootFile.h:286
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
Definition: RootFile.h:298
std::shared_ptr< BranchIDListHelper const > branchIDListHelper() const
Definition: RootFile.h:210
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
static std::string const source("source")
bool enforceGUIDInFileName_
Definition: RootFile.h:275
int whyNotFastClonable_
Definition: RootFile.h:276
edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
Definition: RootFile.h:261
edm::propagate_const< std::shared_ptr< ThinnedAssociationsHelper > > thinnedAssociationsHelper_
Definition: RootFile.h:289
std::map< std::string, std::string > newBranchToOldBranch_
Definition: RootFile.h:292
std::map< BranchKey, BranchDescription > ProductList
edm::propagate_const< std::shared_ptr< IndexIntoFile > > indexIntoFileSharedPtr_
Definition: RootFile.h:264
RootTree lumiTree_
Definition: RootFile.h:281
edm::propagate_const< ProcessHistoryRegistry * > processHistoryRegistry_
Definition: RootFile.h:259
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
edm::propagate_const< std::shared_ptr< RunAuxiliary > > savedRunAuxiliary_
Definition: RootFile.h:272
std::string const & fileFormatVersionBranchName()
Definition: BranchType.cc:218
IndexIntoFileItr begin(SortOrder sortOrder) const
InputSource::ProcessingMode processingMode_
Definition: RootFile.h:290
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
void trainCache(char const *branchNames)
Definition: RootTree.cc:471
std::shared_ptr< ProductRegistry const > productRegistry() const
Definition: RootFile.h:170
edm::propagate_const< TClass * > edProductClass_
Definition: RootFile.h:304
FileFormatVersion fileFormatVersion_
Definition: RootFile.h:262
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:251
std::vector< edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > > eventProductProvenanceRetrievers_
Definition: RootFile.h:301
std::vector< EventProcessHistoryID >::const_iterator eventProcessHistoryIter_
Definition: RootFile.h:271
FileID fid_
Definition: RootFile.h:263
std::string const logicalFile_
Definition: RootFile.h:257
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:193
bool noEventSort_
Definition: RootFile.h:274
std::string friendlyName(std::string const &iFullName)
IndexIntoFile::EntryNumber_t lastEventEntryNumberRead_
Definition: RootFile.h:284
std::string const & indexIntoFileBranchName()
Definition: BranchType.cc:233
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
std::string const & eventHistoryBranchName()
Definition: BranchType.cc:238
EventSelectionIDVector eventSelectionIDs_
Definition: RootFile.h:294
edm::propagate_const< std::unique_ptr< ProvenanceAdaptor > > provenanceAdaptor_
Definition: RootFile.h:299
bool skipAnyEvents_
Definition: RootFile.h:273
RootTree eventTree_
Definition: RootFile.h:280
std::map< ParameterSetID, ParameterSetID > ParameterSetIdConverter
BranchListIndexes branchListIndexes_
Definition: RootFile.h:295
std::string const & metaDataTreeName()
Definition: BranchType.cc:168
std::string const & parameterSetMapBranchName()
Definition: BranchType.cc:183
edm::propagate_const< std::unique_ptr< History > > history_
Definition: RootFile.h:296
std::string const & processHistoryBranchName()
Definition: BranchType.cc:198
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
RootTree runTree_
Definition: RootFile.h:282
edm::propagate_const< std::unique_ptr< MakeProvenanceReader > > provenanceReaderMaker_
Definition: RootFile.h:300
std::array< bool, NumBranchTypes > hasNewlyDroppedBranch_
Definition: RootFile.h:277
static constexpr EntryNumber_t invalidEntry
ProcessConfiguration const & processConfiguration_
Definition: RootFile.h:258
std::shared_ptr< ProductRegistry const > productRegistry_
Definition: RootFile.h:285
void setIfFastClonable(int remainingEvents, int remainingLumis)
Definition: RootFile.cc:618
edm::propagate_const< std::shared_ptr< BranchChildren > > branchChildren_
Definition: RootFile.h:297
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootFile.h:260
std::string const & file() const
Definition: RootFile.h:169
std::string const & productDescriptionBranchName()
Definition: BranchType.cc:173
std::string const & processConfigurationBranchName()
Definition: BranchType.cc:203
IndexIntoFile::IndexIntoFileItr indexIntoFileBegin_
Definition: RootFile.h:267
edm::propagate_const< RunHelperBase * > runHelper_
Definition: RootFile.h:291
bool branchListIndexesUnchanged_
Definition: RootFile.h:278
edm::propagate_const< TTree * > eventHistoryTree_
Definition: RootFile.h:293
unsigned int const defaultNonEventCacheSize
Definition: RootTree.h:47
RootTreePtrArray treePointers_
Definition: RootFile.h:283
void initializeDuplicateChecker(std::vector< std::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< std::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile)
Definition: RootFile.cc:1670
std::vector< ProcessHistoryID > & orderedProcessHistoryIDs_
Definition: RootFile.h:266
std::string const & productDependenciesBranchName()
Definition: BranchType.cc:178
std::string const & thinnedAssociationsHelperBranchName()
Definition: BranchType.cc:213
std::unique_ptr< MakeProvenanceReader > makeProvenanceReaderMaker(InputType inputType)
Definition: RootFile.cc:1827
std::string const & branchIDListBranchName()
Definition: BranchType.cc:208
std::vector< ParentageID > parentageIDLookup_
Definition: RootFile.h:302
EventAuxiliary eventAux_
Definition: RootFile.h:279
void resetTraining()
Definition: RootTree.h:190
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
Definition: RootFile.h:287
void validateFile(InputType inputType, bool usingGoToEvent)
Definition: RootFile.cc:1106
std::string const & newBranchToOldBranch(std::string const &newBranch) const
Definition: RootFile.cc:681
std::unique_ptr< TTreeCache > trainCache(TTree *tree, InputFile &file, unsigned int cacheSize, char const *branchNames)
Definition: RootTree.cc:534
unsigned int const defaultLearningEntries
Definition: RootTree.h:48
bool hasThinnedAssociations() const
std::string const & fileIdentifierBranchName()
Definition: BranchType.cc:223
std::string const & moduleDescriptionMapBranchName()
Definition: BranchType.cc:188
std::string const file_
Definition: RootFile.h:256
std::vector< EventProcessHistoryID > eventProcessHistoryIDs_
Definition: RootFile.h:270
static Registry * instance()
Definition: Registry.cc:13
void readEventHistoryTree()
Definition: RootFile.cc:1657
edm::RootFile::RootFile ( std::string const &  fileName,
ProcessConfiguration const &  processConfiguration,
std::string const &  logicalFileName,
std::shared_ptr< InputFile filePtr,
unsigned int  nStreams,
int  treeMaxVirtualSize,
InputSource::ProcessingMode  processingMode,
RunHelperBase runHelper,
ProductSelectorRules const &  productSelectorRules,
InputType  inputType,
std::shared_ptr< BranchIDListHelper branchIDListHelper,
std::shared_ptr< ThinnedAssociationsHelper thinnedAssociationsHelper,
std::vector< BranchID > const *  associationsFromSecondary,
bool  dropDescendantsOfDroppedProducts,
ProcessHistoryRegistry processHistoryRegistry,
std::vector< std::shared_ptr< IndexIntoFile > > const &  indexesIntoFiles,
std::vector< std::shared_ptr< IndexIntoFile > >::size_type  currentIndexIntoFile,
std::vector< ProcessHistoryID > &  orderedProcessHistoryIDs,
bool  bypassVersionCheck,
bool  labelRawDataLikeMC,
bool  enablePrefetching,
bool  enforceGUIDInFileName 
)
inline

Definition at line 95 of file RootFile.h.

116  : RootFile(
117  fileName, processConfiguration, logicalFileName, filePtr,
118  nullptr, false, -1, -1, nStreams, 0U, treeMaxVirtualSize,
119  processingMode, runHelper,
120  false, productSelectorRules, inputType, branchIDListHelper,
121  thinnedAssociationsHelper, associationsFromSecondary,
122  nullptr, dropDescendantsOfDroppedProducts, processHistoryRegistry,
123  indexesIntoFiles, currentIndexIntoFile, orderedProcessHistoryIDs,
124  bypassVersionCheck, labelRawDataLikeMC,
125  false, enablePrefetching, enforceGUIDInFileName) {}
std::shared_ptr< BranchIDListHelper const > branchIDListHelper() const
Definition: RootFile.h:210
RootFile(std::string const &fileName, ProcessConfiguration const &processConfiguration, std::string const &logicalFileName, std::shared_ptr< InputFile > filePtr, std::shared_ptr< EventSkipperByID > eventSkipperByID, bool skipAnyEvents, int remainingEvents, int remainingLumis, unsigned int nStreams, unsigned int treeCacheSize, int treeMaxVirtualSize, InputSource::ProcessingMode processingMode, RunHelperBase *runHelper, bool noEventSort, ProductSelectorRules const &productSelectorRules, InputType inputType, std::shared_ptr< BranchIDListHelper > branchIDListHelper, std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper, std::vector< BranchID > const *associationsFromSecondary, std::shared_ptr< DuplicateChecker > duplicateChecker, bool dropDescendantsOfDroppedProducts, ProcessHistoryRegistry &processHistoryRegistry, std::vector< std::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< std::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile, std::vector< ProcessHistoryID > &orderedProcessHistoryIDs, bool bypassVersionCheck, bool labelRawDataLikeMC, bool usingGoToEvent, bool enablePrefetching, bool enforceGUIDInFileName)
Definition: RootFile.cc:130
edm::RootFile::RootFile ( std::string const &  fileName,
ProcessConfiguration const &  processConfiguration,
std::string const &  logicalFileName,
std::shared_ptr< InputFile filePtr,
unsigned int  nStreams,
unsigned int  treeCacheSize,
int  treeMaxVirtualSize,
RunHelperBase runHelper,
ProductSelectorRules const &  productSelectorRules,
InputType  inputType,
ProcessHistoryRegistry processHistoryRegistry,
std::vector< std::shared_ptr< IndexIntoFile > > const &  indexesIntoFiles,
std::vector< std::shared_ptr< IndexIntoFile > >::size_type  currentIndexIntoFile,
std::vector< ProcessHistoryID > &  orderedProcessHistoryIDs,
bool  bypassVersionCheck,
bool  enablePrefetching,
bool  enforceGUIDInFileName 
)
inline

Definition at line 127 of file RootFile.h.

References helperFunctions::cache(), and AlCaHLTBitMon_QueryRunRegistry::string.

143  : RootFile(
144  fileName, processConfiguration, logicalFileName, filePtr,
145  nullptr, false, -1, -1, nStreams, treeCacheSize, treeMaxVirtualSize,
147  false, productSelectorRules, inputType, nullptr, nullptr,
148  nullptr, nullptr, false, processHistoryRegistry,
149  indexesIntoFiles, currentIndexIntoFile, orderedProcessHistoryIDs,
150  bypassVersionCheck, false,
151  false, enablePrefetching, enforceGUIDInFileName) {}
RootFile(std::string const &fileName, ProcessConfiguration const &processConfiguration, std::string const &logicalFileName, std::shared_ptr< InputFile > filePtr, std::shared_ptr< EventSkipperByID > eventSkipperByID, bool skipAnyEvents, int remainingEvents, int remainingLumis, unsigned int nStreams, unsigned int treeCacheSize, int treeMaxVirtualSize, InputSource::ProcessingMode processingMode, RunHelperBase *runHelper, bool noEventSort, ProductSelectorRules const &productSelectorRules, InputType inputType, std::shared_ptr< BranchIDListHelper > branchIDListHelper, std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper, std::vector< BranchID > const *associationsFromSecondary, std::shared_ptr< DuplicateChecker > duplicateChecker, bool dropDescendantsOfDroppedProducts, ProcessHistoryRegistry &processHistoryRegistry, std::vector< std::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< std::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile, std::vector< ProcessHistoryID > &orderedProcessHistoryIDs, bool bypassVersionCheck, bool labelRawDataLikeMC, bool usingGoToEvent, bool enablePrefetching, bool enforceGUIDInFileName)
Definition: RootFile.cc:130
edm::RootFile::~RootFile ( )

Definition at line 532 of file RootFile.cc.

532  {
533  }
edm::RootFile::RootFile ( RootFile const &  )
delete

Member Function Documentation

std::shared_ptr<BranchChildren const> edm::RootFile::branchChildren ( ) const
inlineprivate

Definition at line 250 of file RootFile.h.

References edm::get_underlying_safe().

Referenced by createFileBlock().

std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< BranchChildren > > branchChildren_
Definition: RootFile.h:297
std::shared_ptr<BranchChildren>& edm::RootFile::branchChildren ( )
inlineprivate

Definition at line 251 of file RootFile.h.

References edm::get_underlying_safe().

std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< BranchChildren > > branchChildren_
Definition: RootFile.h:297
std::shared_ptr<BranchIDListHelper const> edm::RootFile::branchIDListHelper ( ) const
inline

Definition at line 210 of file RootFile.h.

References edm::get_underlying_safe().

std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
Definition: RootFile.h:287
std::shared_ptr<BranchIDListHelper>& edm::RootFile::branchIDListHelper ( )
inline

Definition at line 211 of file RootFile.h.

References edm::get_underlying_safe().

std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
Definition: RootFile.h:287
bool edm::RootFile::branchListIndexesUnchanged ( ) const
inline

Definition at line 182 of file RootFile.h.

Referenced by createFileBlock().

bool branchListIndexesUnchanged_
Definition: RootFile.h:278
void edm::RootFile::close ( void  )

Definition at line 1175 of file RootFile.cc.

References eventHistoryTree_, filePtr_, and treePointers_.

Referenced by lumiQTWidget.ApplicationWindow::fileQuit(), esMonitoring.AsyncLineReaderMixin::handle_close(), esMonitoring.FDJsonServer::handle_close(), Vispa.Gui.BoxContentDialog.BoxContentDialog::keyPressEvent(), and Vispa.Gui.FindDialog.FindDialog::keyPressEvent().

1175  {
1176  // Just to play it safe, zero all pointers to objects in the InputFile to be closed.
1177  eventHistoryTree_ = nullptr;
1178  for(auto& treePointer : treePointers_) {
1179  treePointer->close();
1180  treePointer = nullptr;
1181  }
1182  filePtr_->Close();
1183  filePtr_ = nullptr; // propagate_const<T> has no reset() function
1184  }
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootFile.h:260
edm::propagate_const< TTree * > eventHistoryTree_
Definition: RootFile.h:293
RootTreePtrArray treePointers_
Definition: RootFile.h:283
bool edm::RootFile::containsItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 760 of file RootFile.cc.

References edm::IndexIntoFile::containsItem(), and indexIntoFile_.

760  {
762  }
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
bool containsItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: event.py:1
std::unique_ptr< FileBlock > edm::RootFile::createFileBlock ( ) const

Definition at line 664 of file RootFile.cc.

References branchChildren(), branchListIndexesUnchanged(), eventTree_, file_, fileFormatVersion(), hasNewlyDroppedBranch(), lumiTree_, edm::RootTree::metaTree(), modifiedIDs(), runTree_, AlCaHLTBitMon_QueryRunRegistry::string, edm::RootTree::tree(), and whyNotFastClonable().

664  {
665  return std::make_unique<FileBlock>(fileFormatVersion(),
666  eventTree_.tree(),
668  lumiTree_.tree(),
670  runTree_.tree(),
671  runTree_.metaTree(),
674  file_,
676  modifiedIDs(),
677  branchChildren());
678  }
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
bool branchListIndexesUnchanged() const
Definition: RootFile.h:182
RootTree lumiTree_
Definition: RootFile.h:281
TTree const * metaTree() const
Definition: RootTree.h:180
TTree const * tree() const
Definition: RootTree.h:178
bool modifiedIDs() const
Definition: RootFile.h:183
int whyNotFastClonable() const
Definition: RootFile.h:180
RootTree eventTree_
Definition: RootFile.h:280
std::array< bool, NumBranchTypes > const & hasNewlyDroppedBranch() const
Definition: RootFile.h:181
RootTree runTree_
Definition: RootFile.h:282
std::shared_ptr< BranchChildren const > branchChildren() const
Definition: RootFile.h:250
std::string const file_
Definition: RootFile.h:256
void edm::RootFile::dropOnInput ( ProductRegistry reg,
ProductSelectorRules const &  rules,
bool  dropDescendants,
InputType  inputType 
)
private

Definition at line 1696 of file RootFile.cc.

References edm::ProductRegistry::allBranchDescriptions(), TrackValidation_cff::association, edm::BranchDescription::branchID(), edm::BranchDescription::branchName(), edm::BranchDescription::branchType(), SimDataFormats::CaloAnalysis::cp, drop, edm::BranchDescription::dropped(), edProductClass_, file_, fileThinnedAssociationsHelper_, edm::getWrapperBasePtr(), hasNewlyDroppedBranch_, edm::InEvent, edm::ProductSelector::initialize(), markBranchToBeDropped(), newBranchToOldBranch(), PFRecoTauDiscriminationByIsolation_cfi::offset, edm::BranchDescription::originalBranchID(), AlCaHLTBitMon_ParallelJobs::p, edm::BranchDescription::present(), parseEventContent::prod, edm::ProductRegistry::productListUpdator(), edm::SecondaryFile, edm::SecondarySource, edm::ProductSelector::selected(), groupFilesInBlocks::temp, treePointers_, edm::BranchDescription::unwrappedType(), and edm::BranchDescription::wrappedName().

Referenced by RootFile().

1696  {
1697 
1698  // This is the selector for drop on input.
1699  ProductSelector productSelector;
1700  productSelector.initialize(rules, reg.allBranchDescriptions());
1701 
1702  std::vector<BranchDescription const*> associationDescriptions;
1703 
1704  ProductRegistry::ProductList& prodList = reg.productListUpdator();
1705  // Do drop on input. On the first pass, just fill in a set of branches to be dropped.
1706  std::set<BranchID> branchesToDrop;
1707  std::map<BranchID, BranchID> droppedToKeptAlias;
1708  for(auto const& product : prodList) {
1709  BranchDescription const& prod = product.second;
1710  if (prod.branchID() != prod.originalBranchID() && prod.present()) {
1711  droppedToKeptAlias[prod.originalBranchID()] = prod.branchID();
1712  }
1713  }
1714  for(auto const& product : prodList) {
1715  BranchDescription const& prod = product.second;
1716  // Special handling for ThinnedAssociations
1717  if(prod.unwrappedType() == typeid(ThinnedAssociation) && prod.present()) {
1718  if(inputType != InputType::SecondarySource) {
1719  associationDescriptions.push_back(&prod);
1720  } else {
1721  markBranchToBeDropped(dropDescendants, prod, branchesToDrop, droppedToKeptAlias);
1722  }
1723  } else if(!productSelector.selected(prod)) {
1724  markBranchToBeDropped(dropDescendants, prod, branchesToDrop, droppedToKeptAlias);
1725  }
1726  }
1727 
1728  if(inputType != InputType::SecondarySource) {
1729 
1730  // Decide whether to keep the thinned associations and corresponding
1731  // entries in the helper. For secondary source they are all dropped,
1732  // but in other cases we look for thinned collections the associations
1733  // redirect a Ref or Ptr to when dereferencing them.
1734 
1735  // Need a list of kept products in order to determine which thinned associations
1736  // are kept.
1737  std::set<BranchID> keptProductsInEvent;
1738  for(auto const& product : prodList) {
1739  BranchDescription const& prod = product.second;
1740  if( branchesToDrop.find(prod.branchID()) == branchesToDrop.end() &&
1741  prod.present() &&
1742  prod.branchType() == InEvent) {
1743  keptProductsInEvent.insert(prod.branchID());
1744  }
1745  }
1746 
1747  // Decide which ThinnedAssociations to keep and store the decision in keepAssociation
1748  std::map<BranchID, bool> keepAssociation;
1749  fileThinnedAssociationsHelper_->selectAssociationProducts(associationDescriptions,
1750  keptProductsInEvent,
1751  keepAssociation);
1752 
1753  for(auto association : associationDescriptions) {
1754  if(!keepAssociation[association->branchID()]) {
1755  markBranchToBeDropped(dropDescendants, *association, branchesToDrop, droppedToKeptAlias);
1756  }
1757  }
1758 
1759  // Also delete the dropped associations from the ThinnedAssociationsHelper
1760  auto temp = std::make_unique<ThinnedAssociationsHelper>();
1761  for(auto const& associationBranches : fileThinnedAssociationsHelper_->data()) {
1762  auto iter = keepAssociation.find(associationBranches.association());
1763  if(iter != keepAssociation.end() && iter->second) {
1764  temp->addAssociation(associationBranches);
1765  }
1766  }
1767  // propagate_const<T> has no reset() function
1768  fileThinnedAssociationsHelper_ = std::unique_ptr<ThinnedAssociationsHelper>(temp.release());
1769  }
1770 
1771  // On this pass, actually drop the branches.
1772  std::set<BranchID>::const_iterator branchesToDropEnd = branchesToDrop.end();
1773  for(ProductRegistry::ProductList::iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd;) {
1774  BranchDescription const& prod = it->second;
1775  bool drop = branchesToDrop.find(prod.branchID()) != branchesToDropEnd;
1776  if(drop) {
1777  if(!prod.dropped()) {
1778  if(productSelector.selected(prod) && prod.unwrappedType() != typeid(ThinnedAssociation)) {
1779  LogWarning("RootFile")
1780  << "Branch '" << prod.branchName() << "' is being dropped from the input\n"
1781  << "of file '" << file_ << "' because it is dependent on a branch\n"
1782  << "that was explicitly dropped.\n";
1783  }
1784  treePointers_[prod.branchType()]->dropBranch(newBranchToOldBranch(prod.branchName()));
1785  hasNewlyDroppedBranch_[prod.branchType()] = true;
1786  }
1787  ProductRegistry::ProductList::iterator icopy = it;
1788  ++it;
1789  prodList.erase(icopy);
1790  } else {
1791  ++it;
1792  }
1793  }
1794 
1795  // Drop on input mergeable run and lumi products, this needs to be invoked for secondary file input
1796  if(inputType == InputType::SecondaryFile) {
1797  TString tString;
1798  for(ProductRegistry::ProductList::iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd;) {
1799  BranchDescription const& prod = it->second;
1800  if(prod.branchType() != InEvent) {
1801  TClass* cp = TClass::GetClass(prod.wrappedName().c_str());
1802  void* p = cp->New();
1803  int offset = cp->GetBaseClassOffset(edProductClass_);
1804  std::unique_ptr<WrapperBase> edp = getWrapperBasePtr(p, offset);
1805  if(edp->isMergeable()) {
1806  treePointers_[prod.branchType()]->dropBranch(newBranchToOldBranch(prod.branchName()));
1807  ProductRegistry::ProductList::iterator icopy = it;
1808  ++it;
1809  prodList.erase(icopy);
1810  } else {
1811  ++it;
1812  }
1813  }
1814  else ++it;
1815  }
1816  }
1817  }
edm::propagate_const< std::unique_ptr< ThinnedAssociationsHelper > > fileThinnedAssociationsHelper_
Definition: RootFile.h:288
std::map< BranchKey, BranchDescription > ProductList
edm::propagate_const< TClass * > edProductClass_
Definition: RootFile.h:304
const int drop
std::array< bool, NumBranchTypes > hasNewlyDroppedBranch_
Definition: RootFile.h:277
RootTreePtrArray treePointers_
Definition: RootFile.h:283
std::unique_ptr< WrapperBase > getWrapperBasePtr(void *p, int offset)
std::string const & newBranchToOldBranch(std::string const &newBranch) const
Definition: RootFile.cc:681
void markBranchToBeDropped(bool dropDescendants, BranchDescription const &branch, std::set< BranchID > &branchesToDrop, std::map< BranchID, BranchID > const &droppedToKeptAlias) const
Definition: RootFile.cc:1686
std::string const file_
Definition: RootFile.h:256
EventAuxiliary const& edm::RootFile::eventAux ( ) const
inline
EventID const& edm::RootFile::eventID ( ) const
inline

Definition at line 175 of file RootFile.h.

175 {return eventAux().id();}
EventAuxiliary const & eventAux() const
Definition: RootFile.h:171
EventID const & id() const
std::shared_ptr<ProductProvenanceRetriever const> edm::RootFile::eventProductProvenanceRetriever ( size_t  index) const
inlineprivate

Definition at line 253 of file RootFile.h.

References edm::get_underlying_safe().

Referenced by makeProductProvenanceRetriever().

std::vector< edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > > eventProductProvenanceRetrievers_
Definition: RootFile.h:301
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::shared_ptr<ProductProvenanceRetriever>& edm::RootFile::eventProductProvenanceRetriever ( size_t  index)
inlineprivate

Definition at line 254 of file RootFile.h.

References edm::get_underlying_safe().

std::vector< edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > > eventProductProvenanceRetrievers_
Definition: RootFile.h:301
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
RootTree const& edm::RootFile::eventTree ( ) const
inline

Definition at line 176 of file RootFile.h.

176 {return eventTree_;}
RootTree eventTree_
Definition: RootFile.h:280
std::string const& edm::RootFile::file ( ) const
inline

Definition at line 169 of file RootFile.h.

Referenced by RootFile().

169 {return file_;}
std::string const file_
Definition: RootFile.h:256
FileFormatVersion edm::RootFile::fileFormatVersion ( ) const
inline
bool edm::RootFile::fillEventAuxiliary ( IndexIntoFile::EntryNumber_t  entry)
private

Definition at line 1206 of file RootFile.cc.

References edm::RootTree::current(), eventTree_, fillThisEventAuxiliary(), and edm::RootTree::setEntryNumber().

Referenced by getNextItemType(), isDuplicateEvent(), readEvent(), readLuminosityBlockAuxiliary_(), readRunAuxiliary_(), setEntryAtNextEventInLumi(), skipEvents(), and skipThisEntry().

1206  {
1207  if(!eventTree_.current(entry)) {
1208  return false;
1209  }
1212  return true;
1213  }
bool current() const
Definition: RootTree.h:126
RootTree eventTree_
Definition: RootFile.h:280
void fillThisEventAuxiliary()
Definition: RootFile.cc:1187
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
void edm::RootFile::fillEventHistory ( )
private

Definition at line 1216 of file RootFile.cc.

References branchIDListHelper_, branchListIndexes_, edm::poolNames::branchListIndexesBranchName(), daqProvenanceHelper_, edm::RootTree::entryNumber(), event(), eventAux(), eventAux_, edm::errors::EventCorruption, edm::poolNames::eventHistoryBranchName(), edm::FileFormatVersion::eventHistoryTree(), eventHistoryTree_, eventProcessHistoryIDs_, eventProcessHistoryIter_, eventSelectionIDs_, edm::poolNames::eventSelectionsBranchName(), eventTree_, Exception, fileFormatVersion(), edm::RootTree::fillBranchEntry(), edm::roottree::getEntry(), history_, triggerObjects_cff::id, edm::lower_bound_all(), edm::FileFormatVersion::noMetaDataTrees(), edm::EventAuxiliary::processHistoryID(), provenanceAdaptor_, findQualityFiles::run, edm::EventAuxiliary::setProcessHistoryID(), edm::FileFormatVersion::splitProductIDs(), edmPickEvents::target, and edm::RootTree::tree().

Referenced by fillIndexIntoFile(), readCurrentEvent(), and readRunAuxiliary_().

1216  {
1217  // We could consider doing delayed reading, but because we have to
1218  // store this History object in a different tree than the event
1219  // data tree, this is too hard to do in this first version.
1220 
1221  if(fileFormatVersion().eventHistoryBranch()) {
1222  // Lumi block number was not in EventID for the relevant releases.
1223  EventID id(eventAux().id().run(), 0, eventAux().id().event());
1224  if(eventProcessHistoryIter_->eventID() != id) {
1225  EventProcessHistoryID target(id, ProcessHistoryID());
1227  assert(eventProcessHistoryIter_->eventID() == id);
1228  }
1231  } else if(fileFormatVersion().eventHistoryTree()) {
1232  // for backward compatibility.
1233  History* pHistory = history_.get();
1234  TBranch* eventHistoryBranch = eventHistoryTree_->GetBranch(poolNames::eventHistoryBranchName().c_str());
1235  if(!eventHistoryBranch) {
1237  << "Failed to find history branch in event history tree.\n";
1238  }
1239  eventHistoryBranch->SetAddress(&pHistory);
1241  eventAux_.setProcessHistoryID(history_->processHistoryID());
1242  eventSelectionIDs_.swap(history_->eventSelectionIDs());
1243  branchListIndexes_.swap(history_->branchListIndexes());
1244  } else if(fileFormatVersion().noMetaDataTrees()) {
1245  // Current format
1247  TBranch* eventSelectionIDBranch = eventTree_.tree()->GetBranch(poolNames::eventSelectionsBranchName().c_str());
1248  assert(eventSelectionIDBranch != nullptr);
1249  eventTree_.fillBranchEntry(eventSelectionIDBranch, pESV);
1251  TBranch* branchListIndexesBranch = eventTree_.tree()->GetBranch(poolNames::branchListIndexesBranchName().c_str());
1252  assert(branchListIndexesBranch != nullptr);
1253  eventTree_.fillBranchEntry(branchListIndexesBranch, pBLI);
1254  }
1255  if(provenanceAdaptor_) {
1256  eventAux_.setProcessHistoryID(provenanceAdaptor_->convertID(eventAux().processHistoryID()));
1257  for(auto& esID : eventSelectionIDs_) {
1258  esID = provenanceAdaptor_->convertID(esID);
1259  }
1260  }
1261  if(daqProvenanceHelper_) {
1263  }
1265  // old format. branchListIndexes_ must be filled in from the ProvenanceAdaptor.
1266  provenanceAdaptor_->branchListIndexes(branchListIndexes_);
1267  }
1268  if(branchIDListHelper_) {
1269  branchIDListHelper_->fixBranchListIndexes(branchListIndexes_);
1270  }
1271  }
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:510
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
ForwardSequence::const_iterator lower_bound_all(ForwardSequence const &s, Datum const &d)
wrappers for std::lower_bound
Definition: Algorithms.h:91
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:243
std::vector< EventSelectionID > EventSelectionIDVector
std::vector< EventProcessHistoryID >::const_iterator eventProcessHistoryIter_
Definition: RootFile.h:271
TTree const * tree() const
Definition: RootTree.h:178
std::vector< BranchListIndex > BranchListIndexes
std::string const & eventHistoryBranchName()
Definition: BranchType.cc:238
EventAuxiliary const & eventAux() const
Definition: RootFile.h:171
EventSelectionIDVector eventSelectionIDs_
Definition: RootFile.h:294
bool eventHistoryTree() const
edm::propagate_const< std::unique_ptr< ProvenanceAdaptor > > provenanceAdaptor_
Definition: RootFile.h:299
RootTree eventTree_
Definition: RootFile.h:280
BranchListIndexes branchListIndexes_
Definition: RootFile.h:295
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
Hash< ProcessHistoryType > ProcessHistoryID
edm::propagate_const< std::unique_ptr< History > > history_
Definition: RootFile.h:296
EntryNumber const & entryNumber() const
Definition: RootTree.h:131
void fillBranchEntry(TBranch *branch, T *&pbuf)
Definition: RootTree.h:156
void setProcessHistoryID(ProcessHistoryID const &phid)
ProcessHistoryID const & processHistoryID() const
edm::propagate_const< TTree * > eventHistoryTree_
Definition: RootFile.h:293
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:247
EventAuxiliary eventAux_
Definition: RootFile.h:279
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
Definition: RootFile.h:287
std::vector< EventProcessHistoryID > eventProcessHistoryIDs_
Definition: RootFile.h:270
void edm::RootFile::fillIndexIntoFile ( )
private

Definition at line 880 of file RootFile.cc.

References edm::RootTree::entries(), edm::RootTree::entryNumber(), event(), eventAux(), eventAux_, eventTree_, fileFormatVersion(), fillEventHistory(), fillLumiAuxiliary(), fillRunAuxiliary(), fillThisEventAuxiliary(), edm::find_in_all(), indexIntoFile_, edm::IndexIntoFile::invalidEntry, edm::RootTree::isValid(), lastEventEntryNumberRead_, summaryLumi::lcount, edm::EventAuxiliary::luminosityBlock(), heppy_report::lumis, lumiTree_, eostools::move(), edm::RootTree::next(), processHistoryRegistry_, edm::EventAuxiliary::run(), findQualityFiles::run, gather_cfg::runs, runTree_, edm::second(), edm::RootTree::setEntryNumber(), edm::IndexIntoFile::setProcessHistoryIDs(), edm::IndexIntoFile::setRunOrLumiEntries(), edm::stable_sort_all(), mitigatedMETSequence_cff::U, and edm::IndexIntoFile::unsortedEventNumbers().

Referenced by validateFile().

880  {
881  // This function is for backward compatibility.
882  // If reading a current format file, indexIntoFile_ is read from the input
883  // file and should always be there. Note that the algorithm below will work
884  // sometimes but often fail with the new format introduced in release 3_8_0.
885  // If it ever becomes necessary to rebuild IndexIntoFile from the new format,
886  // probably a separate function should be written to deal with the task.
887  // This is possible just not implemented yet.
888  assert(!fileFormatVersion().hasIndexIntoFile());
889 
890  typedef std::list<LumiItem> LumiList;
891  LumiList lumis; // (declare 1)
892 
893  typedef std::set<LuminosityBlockID> RunLumiSet;
894  RunLumiSet runLumiSet; // (declare 2)
895 
896  typedef std::list<RunItem> RunList;
897  RunList runs; // (declare 5)
898 
899  typedef std::set<RunNumber_t> RunSet;
900  RunSet runSet; // (declare 4)
901 
902  typedef std::set<RunItem, RunItemSortByRunPhid> RunItemSet;
903  RunItemSet runItemSet; // (declare 3)
904 
905  typedef std::map<RunNumber_t, ProcessHistoryID> PHIDMap;
906  PHIDMap phidMap;
907 
908  RunNumber_t prevRun = 0;
909  LuminosityBlockNumber_t prevLumi = 0;
910  ProcessHistoryID prevPhid;
911  bool iFirst = true;
912 
913  indexIntoFile_.unsortedEventNumbers().clear(); // should already be empty, just being careful
915 
916  // First, loop through the event tree.
917  while(eventTree_.next()) {
918  bool newRun = false;
919  bool newLumi = false;
922 
923  // Save the event numbers as we loop through the event auxiliary to avoid
924  // having to read through the event auxiliary again later. These event numbers
925  // are not actually used in this function, but could be needed elsewhere.
927 
928  ProcessHistoryID reducedPHID = processHistoryRegistry_->reducedProcessHistoryID(eventAux().processHistoryID());
929 
930  if(iFirst || prevPhid != reducedPHID || prevRun != eventAux().run()) {
931  iFirst = false;
932  newRun = newLumi = true;
933  } else if(prevLumi != eventAux().luminosityBlock()) {
934  newLumi = true;
935  }
936  prevPhid = reducedPHID;
937  prevRun = eventAux().run();
938  prevLumi = eventAux().luminosityBlock();
939  if(newLumi) {
940  lumis.emplace_back(reducedPHID,
941  eventAux().run(), eventAux().luminosityBlock(), eventTree_.entryNumber()); // (insert 1)
942  runLumiSet.insert(LuminosityBlockID(eventAux().run(), eventAux().luminosityBlock())); // (insert 2)
943  } else {
944  LumiItem& currentLumi = lumis.back();
945  assert(currentLumi.lastEventEntry_ == eventTree_.entryNumber());
946  ++currentLumi.lastEventEntry_;
947  }
948  if(newRun) {
949  // Insert run in list if it is not already there.
950  RunItem item(reducedPHID, eventAux().run());
951  if(runItemSet.insert(item).second) { // (check 3, insert 3)
952  runs.push_back(std::move(item)); // (insert 5)
953  runSet.insert(eventAux().run()); // (insert 4)
954  phidMap.insert(std::make_pair(eventAux().run(), reducedPHID));
955  }
956  }
957  }
958  // now clean up.
960  eventAux_ = EventAuxiliary();
962 
963  // Loop over run entries and fill information.
964 
965  typedef std::map<RunNumber_t, IndexIntoFile::EntryNumber_t> RunMap;
966  RunMap runMap; // (declare 11)
967 
968  typedef std::vector<RunItem> RunVector;
969  RunVector emptyRuns; // (declare 12)
970 
971  if(runTree_.isValid()) {
972  while(runTree_.next()) {
973  // Note: adjacent duplicates will be skipped without an explicit check.
974 
975  std::shared_ptr<RunAuxiliary> runAux = fillRunAuxiliary();
976  ProcessHistoryID reducedPHID = processHistoryRegistry_->reducedProcessHistoryID(runAux->processHistoryID());
977 
978  if(runSet.insert(runAux->run()).second) { // (check 4, insert 4)
979  // This run was not associated with any events.
980  emptyRuns.emplace_back(reducedPHID, runAux->run()); // (insert 12)
981  }
982  runMap.insert(std::make_pair(runAux->run(), runTree_.entryNumber())); // (insert 11)
983  phidMap.insert(std::make_pair(runAux->run(), reducedPHID));
984  }
985  // now clean up.
987  }
988 
989  // Insert the ordered empty runs into the run list.
990  RunItemSortByRun runItemSortByRun;
991  stable_sort_all(emptyRuns, runItemSortByRun);
992 
993  RunList::iterator itRuns = runs.begin(), endRuns = runs.end();
994  for(auto const& emptyRun : emptyRuns) {
995  for(; itRuns != endRuns; ++itRuns) {
996  if(runItemSortByRun(emptyRun, *itRuns)) {
997  break;
998  }
999  }
1000  runs.insert(itRuns, emptyRun);
1001  }
1002 
1003  // Loop over luminosity block entries and fill information.
1004 
1005  typedef std::vector<LumiItem> LumiVector;
1006  LumiVector emptyLumis; // (declare 7)
1007 
1008  typedef std::map<LuminosityBlockID, IndexIntoFile::EntryNumber_t> RunLumiMap;
1009  RunLumiMap runLumiMap; // (declare 6)
1010 
1011  if(lumiTree_.isValid()) {
1012  while(lumiTree_.next()) {
1013  // Note: adjacent duplicates will be skipped without an explicit check.
1014  std::shared_ptr<LuminosityBlockAuxiliary> lumiAux = fillLumiAuxiliary();
1015  LuminosityBlockID lumiID = LuminosityBlockID(lumiAux->run(), lumiAux->luminosityBlock());
1016  if(runLumiSet.insert(lumiID).second) { // (check 2, insert 2)
1017  // This lumi was not associated with any events.
1018  // Use the process history ID from the corresponding run. In cases of practical
1019  // importance, this should be the correct process history ID, but it is possible
1020  // to construct files where this is not the correct process history ID ...
1021  PHIDMap::const_iterator iPhidMap = phidMap.find(lumiAux->run());
1022  assert(iPhidMap != phidMap.end());
1023  emptyLumis.emplace_back(iPhidMap->second, lumiAux->run(), lumiAux->luminosityBlock(), IndexIntoFile::invalidEntry); // (insert 7)
1024  }
1025  runLumiMap.insert(std::make_pair(lumiID, lumiTree_.entryNumber()));
1026  }
1027  // now clean up.
1029  }
1030 
1031  // Insert the ordered empty lumis into the lumi list.
1032  LumiItemSortByRunLumi lumiItemSortByRunLumi;
1033  stable_sort_all(emptyLumis, lumiItemSortByRunLumi);
1034 
1035  LumiList::iterator itLumis = lumis.begin(), endLumis = lumis.end();
1036  for(auto const& emptyLumi : emptyLumis) {
1037  for(; itLumis != endLumis; ++itLumis) {
1038  if(lumiItemSortByRunLumi(emptyLumi, *itLumis)) {
1039  break;
1040  }
1041  }
1042  lumis.insert(itLumis, emptyLumi);
1043  }
1044 
1045  // Create a map of RunItems that gives the order of first appearance in the list.
1046  // Also fill in the vector of process history IDs
1047  typedef std::map<RunItem, int, RunItemSortByRunPhid> RunCountMap;
1048  RunCountMap runCountMap; // Declare (17)
1049  std::vector<ProcessHistoryID>& phids = indexIntoFile_.setProcessHistoryIDs();
1050  assert(phids.empty());
1051  std::vector<IndexIntoFile::RunOrLumiEntry>& entries = indexIntoFile_.setRunOrLumiEntries();
1052  assert(entries.empty());
1053  int rcount = 0;
1054  for(auto& run : runs) {
1055  RunCountMap::const_iterator countMapItem = runCountMap.find(run);
1056  if(countMapItem == runCountMap.end()) {
1057  countMapItem = runCountMap.insert(std::make_pair(run, rcount)).first; // Insert (17)
1058  assert(countMapItem != runCountMap.end());
1059  ++rcount;
1060  }
1061  std::vector<ProcessHistoryID>::const_iterator phidItem = find_in_all(phids, run.phid_);
1062  if(phidItem == phids.end()) {
1063  phids.push_back(run.phid_);
1064  phidItem = phids.end() - 1;
1065  }
1066  entries.emplace_back(
1067  countMapItem->second, // use (17)
1069  runMap[run.run_], // use (11)
1070  phidItem - phids.begin(),
1071  run.run_,
1072  0U,
1075  }
1076 
1077  // Create a map of LumiItems that gives the order of first appearance in the list.
1078  typedef std::map<LumiItem, int, LumiItemSortByRunLumiPhid> LumiCountMap;
1079  LumiCountMap lumiCountMap; // Declare (19)
1080  int lcount = 0;
1081  for(auto& lumi : lumis) {
1082  RunCountMap::const_iterator runCountMapItem = runCountMap.find(RunItem(lumi.phid_, lumi.run_));
1083  assert(runCountMapItem != runCountMap.end());
1084  LumiCountMap::const_iterator countMapItem = lumiCountMap.find(lumi);
1085  if(countMapItem == lumiCountMap.end()) {
1086  countMapItem = lumiCountMap.insert(std::make_pair(lumi, lcount)).first; // Insert (17)
1087  assert(countMapItem != lumiCountMap.end());
1088  ++lcount;
1089  }
1090  std::vector<ProcessHistoryID>::const_iterator phidItem = find_in_all(phids, lumi.phid_);
1091  assert(phidItem != phids.end());
1092  entries.emplace_back(
1093  runCountMapItem->second,
1094  countMapItem->second,
1095  runLumiMap[LuminosityBlockID(lumi.run_, lumi.lumi_)],
1096  phidItem - phids.begin(),
1097  lumi.run_,
1098  lumi.lumi_,
1099  lumi.firstEventEntry_,
1100  lumi.lastEventEntry_);
1101  }
1102  stable_sort_all(entries);
1103  }
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
std::shared_ptr< LuminosityBlockAuxiliary > fillLumiAuxiliary()
Definition: RootFile.cc:1274
RootTree lumiTree_
Definition: RootFile.h:281
edm::propagate_const< ProcessHistoryRegistry * > processHistoryRegistry_
Definition: RootFile.h:259
EntryNumber const & entries() const
Definition: RootTree.h:133
RunNumber_t run() const
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:135
unsigned int LuminosityBlockNumber_t
LuminosityBlockNumber_t luminosityBlock() const
U second(std::pair< T, U > const &p)
std::vector< ProcessHistoryID > & setProcessHistoryIDs()
bool next()
Definition: RootTree.h:123
IndexIntoFile::EntryNumber_t lastEventEntryNumberRead_
Definition: RootFile.h:284
EventAuxiliary const & eventAux() const
Definition: RootFile.h:171
std::shared_ptr< RunAuxiliary > fillRunAuxiliary()
Definition: RootFile.cc:1298
RootTree eventTree_
Definition: RootFile.h:280
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
Hash< ProcessHistoryType > ProcessHistoryID
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
RootTree runTree_
Definition: RootFile.h:282
EntryNumber const & entryNumber() const
Definition: RootTree.h:131
std::vector< RunOrLumiEntry > & setRunOrLumiEntries()
std::vector< EventNumber_t > & unsortedEventNumbers() const
static constexpr EntryNumber_t invalidEntry
ForwardSequence::const_iterator find_in_all(ForwardSequence const &s, Datum const &d)
wrappers for std::find
Definition: Algorithms.h:32
void fillEventHistory()
Definition: RootFile.cc:1216
bool isValid() const
Definition: RootTree.cc:106
unsigned int RunNumber_t
EventAuxiliary eventAux_
Definition: RootFile.h:279
void fillThisEventAuxiliary()
Definition: RootFile.cc:1187
def move(src, dest)
Definition: eostools.py:510
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
std::shared_ptr< LuminosityBlockAuxiliary > edm::RootFile::fillLumiAuxiliary ( )
private

Definition at line 1274 of file RootFile.cc.

References edm::conversion(), daqProvenanceHelper_, fileFormatVersion(), edm::RootTree::fillAux(), lumiTree_, edm::FileFormatVersion::newAuxiliary(), provenanceAdaptor_, and edm::FileFormatVersion::runsAndLumis().

Referenced by fillIndexIntoFile(), and readLuminosityBlockAuxiliary_().

1274  {
1275  auto lumiAuxiliary = std::make_shared<LuminosityBlockAuxiliary>();
1277  LuminosityBlockAuxiliary *pLumiAux = lumiAuxiliary.get();
1278  lumiTree_.fillAux<LuminosityBlockAuxiliary>(pLumiAux);
1279  } else {
1280  LuminosityBlockAux lumiAux;
1281  LuminosityBlockAux *pLumiAux = &lumiAux;
1282  lumiTree_.fillAux<LuminosityBlockAux>(pLumiAux);
1283  conversion(lumiAux, *lumiAuxiliary);
1284  }
1285  if(provenanceAdaptor_) {
1286  lumiAuxiliary->setProcessHistoryID(provenanceAdaptor_->convertID(lumiAuxiliary->processHistoryID()));
1287  }
1288  if(daqProvenanceHelper_) {
1289  lumiAuxiliary->setProcessHistoryID(daqProvenanceHelper_->mapProcessHistoryID(lumiAuxiliary->processHistoryID()));
1290  }
1291  if(lumiAuxiliary->luminosityBlock() == 0 && !fileFormatVersion().runsAndLumis()) {
1292  lumiAuxiliary->id() = LuminosityBlockID(RunNumber_t(1), LuminosityBlockNumber_t(1));
1293  }
1294  return lumiAuxiliary;
1295  }
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
RootTree lumiTree_
Definition: RootFile.h:281
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
unsigned int LuminosityBlockNumber_t
edm::propagate_const< std::unique_ptr< ProvenanceAdaptor > > provenanceAdaptor_
Definition: RootFile.h:299
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
unsigned int RunNumber_t
void fillAux(T *&pAux)
Definition: RootTree.h:140
std::shared_ptr< RunAuxiliary > edm::RootFile::fillRunAuxiliary ( )
private

Definition at line 1298 of file RootFile.cc.

References edm::conversion(), daqProvenanceHelper_, fileFormatVersion(), edm::RootTree::fillAux(), edm::FileFormatVersion::newAuxiliary(), provenanceAdaptor_, and runTree_.

Referenced by fillIndexIntoFile(), and readRunAuxiliary_().

1298  {
1299  auto runAuxiliary = std::make_shared<RunAuxiliary>();
1301  RunAuxiliary *pRunAux = runAuxiliary.get();
1302  runTree_.fillAux<RunAuxiliary>(pRunAux);
1303  } else {
1304  RunAux runAux;
1305  RunAux *pRunAux = &runAux;
1306  runTree_.fillAux<RunAux>(pRunAux);
1307  conversion(runAux, *runAuxiliary);
1308  }
1309  if(provenanceAdaptor_) {
1310  runAuxiliary->setProcessHistoryID(provenanceAdaptor_->convertID(runAuxiliary->processHistoryID()));
1311  }
1312  if(daqProvenanceHelper_) {
1313  runAuxiliary->setProcessHistoryID(daqProvenanceHelper_->mapProcessHistoryID(runAuxiliary->processHistoryID()));
1314  }
1315  return runAuxiliary;
1316  }
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
edm::propagate_const< std::unique_ptr< ProvenanceAdaptor > > provenanceAdaptor_
Definition: RootFile.h:299
RootTree runTree_
Definition: RootFile.h:282
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
void fillAux(T *&pAux)
Definition: RootTree.h:140
void edm::RootFile::fillThisEventAuxiliary ( )
private

Definition at line 1187 of file RootFile.cc.

References edm::conversion(), edm::RootTree::entryNumber(), eventAux(), eventAux_, eventTree_, fileFormatVersion(), edm::RootTree::fillAux(), lastEventEntryNumberRead_, and edm::FileFormatVersion::newAuxiliary().

Referenced by fillEventAuxiliary(), fillIndexIntoFile(), initializeDuplicateChecker(), and readCurrentEvent().

1187  {
1189  // Already read.
1190  return;
1191  }
1193  EventAuxiliary *pEvAux = &eventAux_;
1194  eventTree_.fillAux<EventAuxiliary>(pEvAux);
1195  } else {
1196  // for backward compatibility.
1197  EventAux eventAux;
1198  EventAux *pEvAux = &eventAux;
1199  eventTree_.fillAux<EventAux>(pEvAux);
1200  conversion(eventAux, eventAux_);
1201  }
1203  }
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
IndexIntoFile::EntryNumber_t lastEventEntryNumberRead_
Definition: RootFile.h:284
EventAuxiliary const & eventAux() const
Definition: RootFile.h:171
RootTree eventTree_
Definition: RootFile.h:280
EntryNumber const & entryNumber() const
Definition: RootTree.h:131
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
EventAuxiliary eventAux_
Definition: RootFile.h:279
void fillAux(T *&pAux)
Definition: RootTree.h:140
IndexIntoFile::EntryType edm::RootFile::getNextItemType ( RunNumber_t run,
LuminosityBlockNumber_t lumi,
EventNumber_t event 
)

Definition at line 765 of file RootFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::advanceToNextLumiOrRun(), edm::IndexIntoFile::IndexIntoFileItr::advanceToNextRun(), edm::IndexIntoFile::IndexIntoFileItr::entry(), edm::EventAuxiliary::event(), eventAux_, fillEventAuxiliary(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), indexIntoFileIter_, isDuplicateEvent(), edm::IndexIntoFile::kEnd, edm::IndexIntoFile::kEvent, edm::IndexIntoFile::kLumi, edm::IndexIntoFile::kRun, edm::IndexIntoFile::IndexIntoFileItr::lumi(), processingMode_, edm::IndexIntoFile::IndexIntoFileItr::run(), runHelper_, edm::InputSource::Runs, edm::InputSource::RunsAndLumis, and skipThisEntry().

765  {
766  // First, account for consecutive skipped entries.
767  while(skipThisEntry()) {
770  }
773  }
774  else {
776  }
777  }
778  // OK, we have an entry that is not skipped.
780  if(entryType == IndexIntoFile::kEnd) {
781  return IndexIntoFile::kEnd;
782  }
783  if(entryType == IndexIntoFile::kRun) {
785  runHelper_->checkForNewRun(run);
786  return IndexIntoFile::kRun;
787  } else if(processingMode_ == InputSource::Runs) {
789  return getNextItemType(run, lumi, event);
790  }
791  if(entryType == IndexIntoFile::kLumi) {
794  return IndexIntoFile::kLumi;
797  return getNextItemType(run, lumi, event);
798  }
799  if(isDuplicateEvent()) {
801  return getNextItemType(run, lumi, event);
802  }
806  event = eventAux_.event();
807  return IndexIntoFile::kEvent;
808  }
InputSource::ProcessingMode processingMode_
Definition: RootFile.h:290
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
LuminosityBlockNumber_t lumi() const
bool fillEventAuxiliary(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1206
bool skipThisEntry()
Definition: RootFile.cc:705
IndexIntoFile::EntryType getNextItemType(RunNumber_t &run, LuminosityBlockNumber_t &lumi, EventNumber_t &event)
Definition: RootFile.cc:765
bool isDuplicateEvent()
Definition: RootFile.cc:749
edm::propagate_const< RunHelperBase * > runHelper_
Definition: RootFile.h:291
EventAuxiliary eventAux_
Definition: RootFile.h:279
EventNumber_t event() const
Definition: event.py:1
bool edm::RootFile::goToEvent ( EventID const &  eventID)

Definition at line 1387 of file RootFile.cc.

References duplicateChecker_, edm::IndexIntoFile::end(), edm::EventID::event(), edm::IndexIntoFile::fillEventNumbers(), edm::IndexIntoFile::findPosition(), edm::IndexIntoFile::firstAppearanceOrder, indexIntoFile_, indexIntoFileIter_, edm::EventID::luminosityBlock(), noEventSort_, edm::IndexIntoFile::numericalOrder, and edm::EventID::run().

1387  {
1388 
1390 
1391  if(duplicateChecker_) {
1392  duplicateChecker_->disable();
1393  }
1394 
1397 
1398  IndexIntoFile::IndexIntoFileItr iter =
1400 
1401  if(iter == indexIntoFile_.end(sortOrder)) {
1402  return false;
1403  }
1404  indexIntoFileIter_ = iter;
1405  return true;
1406  }
RunNumber_t run() const
Definition: EventID.h:39
EventID const & eventID() const
Definition: RootFile.h:175
EventNumber_t event() const
Definition: EventID.h:41
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
Definition: RootFile.h:298
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
bool noEventSort_
Definition: RootFile.h:274
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
void fillEventNumbers() const
std::array<bool, NumBranchTypes> const& edm::RootFile::hasNewlyDroppedBranch ( ) const
inline

Definition at line 181 of file RootFile.h.

Referenced by createFileBlock().

181 {return hasNewlyDroppedBranch_;}
std::array< bool, NumBranchTypes > hasNewlyDroppedBranch_
Definition: RootFile.h:277
IndexIntoFile::IndexIntoFileItr edm::RootFile::indexIntoFileIter ( ) const

Definition at line 690 of file RootFile.cc.

References indexIntoFileIter_.

690  {
691  return indexIntoFileIter_;
692  }
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
std::shared_ptr<IndexIntoFile const> edm::RootFile::indexIntoFileSharedPtr ( ) const
inline

Definition at line 212 of file RootFile.h.

References edm::get_underlying_safe().

edm::propagate_const< std::shared_ptr< IndexIntoFile > > indexIntoFileSharedPtr_
Definition: RootFile.h:264
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::shared_ptr<IndexIntoFile>& edm::RootFile::indexIntoFileSharedPtr ( )
inline

Definition at line 213 of file RootFile.h.

References edm::get_underlying_safe(), and position.

edm::propagate_const< std::shared_ptr< IndexIntoFile > > indexIntoFileSharedPtr_
Definition: RootFile.h:264
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void edm::RootFile::initAssociationsFromSecondary ( std::vector< BranchID > const &  associationsFromSecondary)

Definition at line 700 of file RootFile.cc.

References fileThinnedAssociationsHelper_, and thinnedAssociationsHelper_.

700  {
701  thinnedAssociationsHelper_->initAssociationsFromSecondary(associationsFromSecondary, *fileThinnedAssociationsHelper_);
702  }
edm::propagate_const< std::unique_ptr< ThinnedAssociationsHelper > > fileThinnedAssociationsHelper_
Definition: RootFile.h:288
edm::propagate_const< std::shared_ptr< ThinnedAssociationsHelper > > thinnedAssociationsHelper_
Definition: RootFile.h:289
void edm::RootFile::initializeDuplicateChecker ( std::vector< std::shared_ptr< IndexIntoFile > > const &  indexesIntoFiles,
std::vector< std::shared_ptr< IndexIntoFile > >::size_type  currentIndexIntoFile 
)
private

Definition at line 1670 of file RootFile.cc.

References duplicateChecker_, eventAux(), eventTree_, fillThisEventAuxiliary(), indexIntoFile_, edm::IndexIntoFile::invalidEntry, edm::RootTree::next(), and edm::RootTree::setEntryNumber().

Referenced by RootFile().

1672  {
1673  if(duplicateChecker_) {
1674  if(eventTree_.next()) {
1676  duplicateChecker_->inputFileOpened(eventAux().isRealData(),
1678  indexesIntoFiles,
1679  currentIndexIntoFile);
1680  }
1682  }
1683  }
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
Definition: RootFile.h:298
bool next()
Definition: RootTree.h:123
EventAuxiliary const & eventAux() const
Definition: RootFile.h:171
RootTree eventTree_
Definition: RootFile.h:280
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
static constexpr EntryNumber_t invalidEntry
void fillThisEventAuxiliary()
Definition: RootFile.cc:1187
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
bool edm::RootFile::isDuplicateEvent ( )
private

Definition at line 749 of file RootFile.cc.

References duplicateChecker_, edm::IndexIntoFile::IndexIntoFileItr::entry(), edm::EventID::event(), eventAux_, file_, fillEventAuxiliary(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), edm::EventAuxiliary::id(), indexIntoFileIter_, edm::IndexIntoFile::kEvent, edm::IndexIntoFile::IndexIntoFileItr::lumi(), edm::IndexIntoFile::IndexIntoFileItr::processHistoryIDIndex(), and edm::IndexIntoFile::IndexIntoFileItr::run().

Referenced by getNextItemType().

749  {
751  if(duplicateChecker_.get() == nullptr) {
752  return false;
753  }
755  return duplicateChecker_->isDuplicateAndCheckActive(indexIntoFileIter_.processHistoryIDIndex(),
757  }
EventNumber_t event() const
Definition: EventID.h:41
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
Definition: RootFile.h:298
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
LuminosityBlockNumber_t lumi() const
bool fillEventAuxiliary(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1206
EventID const & id() const
EventAuxiliary eventAux_
Definition: RootFile.h:279
std::string const file_
Definition: RootFile.h:256
RootTree const& edm::RootFile::lumiTree ( ) const
inline

Definition at line 177 of file RootFile.h.

177 {return lumiTree_;}
RootTree lumiTree_
Definition: RootFile.h:281
std::shared_ptr< ProductProvenanceRetriever > edm::RootFile::makeProductProvenanceRetriever ( unsigned int  iStreamIndex)
private

Definition at line 1844 of file RootFile.cc.

References daqProvenanceHelper_, eventProductProvenanceRetriever(), eventProductProvenanceRetrievers_, eventTree_, and provenanceReaderMaker_.

Referenced by readCurrentEvent().

1844  {
1845  if(eventProductProvenanceRetrievers_.size()<=iStreamID) {
1846  eventProductProvenanceRetrievers_.resize(iStreamID+1);
1847  }
1848  if(!eventProductProvenanceRetrievers_[iStreamID]) {
1849  // propagate_const<T> has no reset() function
1850  eventProductProvenanceRetrievers_[iStreamID] = std::make_shared<ProductProvenanceRetriever>(provenanceReaderMaker_->makeReader(eventTree_, daqProvenanceHelper_.get()));
1851  }
1852  eventProductProvenanceRetrievers_[iStreamID]->reset();
1853  return eventProductProvenanceRetriever(iStreamID);
1854  }
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
std::shared_ptr< ProductProvenanceRetriever const > eventProductProvenanceRetriever(size_t index) const
Definition: RootFile.h:253
std::vector< edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > > eventProductProvenanceRetrievers_
Definition: RootFile.h:301
RootTree eventTree_
Definition: RootFile.h:280
edm::propagate_const< std::unique_ptr< MakeProvenanceReader > > provenanceReaderMaker_
Definition: RootFile.h:300
std::unique_ptr< MakeProvenanceReader > edm::RootFile::makeProvenanceReaderMaker ( InputType  inputType)
private

Definition at line 1827 of file RootFile.cc.

References fileFormatVersion_, eostools::move(), parentageIDLookup_, edm::FileFormatVersion::perEventProductIDs(), readEntryDescriptionTree(), readParentageTree(), edm::FileFormatVersion::splitProductIDs(), and edm::FileFormatVersion::storedProductProvenanceUsed().

Referenced by RootFile().

1827  {
1829  readParentageTree(inputType);
1830  return std::make_unique<MakeReducedProvenanceReader>(parentageIDLookup_);
1831  } else if(fileFormatVersion_.splitProductIDs()) {
1832  readParentageTree(inputType);
1833  return std::make_unique<MakeFullProvenanceReader>();
1834  } else if(fileFormatVersion_.perEventProductIDs()) {
1835  auto entryDescriptionMap = std::make_unique<EntryDescriptionMap>();
1836  readEntryDescriptionTree(*entryDescriptionMap, inputType);
1837  return std::make_unique<MakeOldProvenanceReader>(std::move(entryDescriptionMap));
1838  } else {
1839  return std::make_unique<MakeDummyProvenanceReader>();
1840  }
1841  }
void readEntryDescriptionTree(EntryDescriptionMap &entryDescriptionMap, InputType inputType)
Definition: RootFile.cc:536
FileFormatVersion fileFormatVersion_
Definition: RootFile.h:262
void readParentageTree(InputType inputType)
Definition: RootFile.cc:582
bool storedProductProvenanceUsed() const
bool perEventProductIDs() const
std::vector< ParentageID > parentageIDLookup_
Definition: RootFile.h:302
def move(src, dest)
Definition: eostools.py:510
void edm::RootFile::markBranchToBeDropped ( bool  dropDescendants,
BranchDescription const &  branch,
std::set< BranchID > &  branchesToDrop,
std::map< BranchID, BranchID > const &  droppedToKeptAlias 
) const
private

Definition at line 1686 of file RootFile.cc.

References branchChildren_, and edm::BranchDescription::branchID().

Referenced by dropOnInput().

1687  {
1688  if(dropDescendants) {
1689  branchChildren_->appendToDescendants(branch, branchesToDrop, droppedToKeptAlias);
1690  } else {
1691  branchesToDrop.insert(branch.branchID());
1692  }
1693  }
edm::propagate_const< std::shared_ptr< BranchChildren > > branchChildren_
Definition: RootFile.h:297
bool edm::RootFile::modifiedIDs ( ) const
inline

Definition at line 183 of file RootFile.h.

Referenced by createFileBlock().

183 {return daqProvenanceHelper_.get() != nullptr;}
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
std::string const & edm::RootFile::newBranchToOldBranch ( std::string const &  newBranch) const
private

Definition at line 681 of file RootFile.cc.

References newBranchToOldBranch_.

Referenced by dropOnInput(), and RootFile().

681  {
682  std::map<std::string, std::string>::const_iterator it = newBranchToOldBranch_.find(newBranch);
683  if(it != newBranchToOldBranch_.end()) {
684  return it->second;
685  }
686  return newBranch;
687  }
std::map< std::string, std::string > newBranchToOldBranch_
Definition: RootFile.h:292
bool edm::RootFile::nextEventEntry ( )
inline

Definition at line 208 of file RootFile.h.

208 {return eventTree_.nextWithCache();}
RootTree eventTree_
Definition: RootFile.h:280
bool nextWithCache()
Definition: RootTree.cc:196
RootFile& edm::RootFile::operator= ( RootFile const &  )
delete
std::shared_ptr<ProductRegistry const> edm::RootFile::productRegistry ( ) const
inline

Definition at line 170 of file RootFile.h.

Referenced by RootFile().

170 {return productRegistry_;}
std::shared_ptr< ProductRegistry const > productRegistry_
Definition: RootFile.h:285
bool edm::RootFile::readCurrentEvent ( EventPrincipal cache)

Definition at line 1444 of file RootFile.cc.

References branchListIndexes_, edm::RootTree::current(), eventAux(), eventAux_, eventSelectionIDs_, eventTree_, fileFormatVersion(), filePtr_, fillEventHistory(), edm::EventPrincipal::fillEventPrincipal(), fillThisEventAuxiliary(), edm::EventAuxiliary::id(), edm::RootTree::insertEntryForIndex(), edm::EventAuxiliary::isRealData(), makeProductProvenanceRetriever(), eostools::move(), edm::EventAuxiliary::oldLuminosityBlock(), processHistoryRegistry_, edm::RootTree::resetAndGetRootDelayedReader(), edm::EventAuxiliary::resetObsoleteInfo(), runHelper_, edm::EventPrincipal::streamID(), edm::EDProductGetter::transitionIndex(), and edm::StreamID::value().

Referenced by readEvent().

1444  {
1445  if(!eventTree_.current()) {
1446  return false;
1447  }
1449  if(!fileFormatVersion().lumiInEventID()) {
1450  //ugly, but will disappear when the backward compatibility is done with schema evolution.
1451  const_cast<EventID&>(eventAux_.id()).setLuminosityBlockNumber(eventAux_.oldLuminosityBlock());
1453  }
1454  fillEventHistory();
1455  runHelper_->overrideRunNumber(eventAux_.id(), eventAux().isRealData());
1456 
1457  // We're not done ... so prepare the EventPrincipal
1458  eventTree_.insertEntryForIndex(principal.transitionIndex());
1459  principal.fillEventPrincipal(eventAux(),
1463  *(makeProductProvenanceRetriever(principal.streamID().value())),
1465 
1466  // report event read from file
1467  filePtr_->eventReadFromFile();
1468  return true;
1469  }
bool isRealData() const
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
edm::propagate_const< ProcessHistoryRegistry * > processHistoryRegistry_
Definition: RootFile.h:259
bool current() const
Definition: RootTree.h:126
def principal(options)
void insertEntryForIndex(unsigned int index)
Definition: RootTree.cc:100
DelayedReader * resetAndGetRootDelayedReader() const
Definition: RootTree.cc:118
EventAuxiliary const & eventAux() const
Definition: RootFile.h:171
EventSelectionIDVector eventSelectionIDs_
Definition: RootFile.h:294
RootTree eventTree_
Definition: RootFile.h:280
BranchListIndexes branchListIndexes_
Definition: RootFile.h:295
LuminosityBlockNumber_t oldLuminosityBlock() const
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootFile.h:260
void fillEventHistory()
Definition: RootFile.cc:1216
std::shared_ptr< ProductProvenanceRetriever > makeProductProvenanceRetriever(unsigned int iStreamIndex)
Definition: RootFile.cc:1844
EventID const & id() const
edm::propagate_const< RunHelperBase * > runHelper_
Definition: RootFile.h:291
EventAuxiliary eventAux_
Definition: RootFile.h:279
void fillThisEventAuxiliary()
Definition: RootFile.cc:1187
def move(src, dest)
Definition: eostools.py:510
void edm::RootFile::readEntryDescriptionTree ( EntryDescriptionMap entryDescriptionMap,
InputType  inputType 
)
private

Definition at line 536 of file RootFile.cc.

References daqProvenanceHelper_, edm::poolNames::entryDescriptionBranchName(), edm::poolNames::entryDescriptionIDBranchName(), edm::poolNames::entryDescriptionTreeName(), edm::errors::EventCorruption, Exception, filePtr_, edm::errors::FileReadError, edm::roottree::getEntry(), mps_fire::i, edm::EventEntryDescription::id(), edm::Parentage::id(), edm::ParentageRegistry::insertMapped(), edm::ParentageRegistry::instance(), edm::numEntries(), parents, edm::EventEntryDescription::parents(), edm::Parentage::parentsForUpdate(), PhysicsTools::registry, edm::SecondarySource, and edm::Parentage::setParents().

Referenced by makeProvenanceReaderMaker().

536  {
537  // Called only for old format files.
538  // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
539  std::unique_ptr<TTree> entryDescriptionTree(dynamic_cast<TTree*>(filePtr_->Get(poolNames::entryDescriptionTreeName().c_str())));
540  if(nullptr == entryDescriptionTree.get()) {
541  throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::entryDescriptionTreeName()
542  << " in the input file.\n";
543  }
544 
545  EntryDescriptionID idBuffer;
546  EntryDescriptionID* pidBuffer = &idBuffer;
547  entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionIDBranchName().c_str(), &pidBuffer);
548 
549  EventEntryDescription entryDescriptionBuffer;
550  EventEntryDescription *pEntryDescriptionBuffer = &entryDescriptionBuffer;
551  entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionBranchName().c_str(), &pEntryDescriptionBuffer);
552 
553  // Fill in the parentage registry.
554  ParentageRegistry& registry = *ParentageRegistry::instance();
555 
556  for(Long64_t i = 0, numEntries = entryDescriptionTree->GetEntries(); i < numEntries; ++i) {
557  roottree::getEntry(entryDescriptionTree.get(), i);
558  if(idBuffer != entryDescriptionBuffer.id()) {
559  throw Exception(errors::EventCorruption) << "Corruption of EntryDescription tree detected.\n";
560  }
561  entryDescriptionMap.insert(std::make_pair(entryDescriptionBuffer.id(),entryDescriptionBuffer));
562  Parentage parents;
563  parents.setParents(entryDescriptionBuffer.parents());
565  ParentageID const oldID = parents.id();
566  daqProvenanceHelper_->fixMetaData(parents.parentsForUpdate());
567  ParentageID newID = parents.id();
568  if(newID != oldID) {
569  daqProvenanceHelper_->setOldParentageIDToNew(oldID,newID);
570  }
571  }
572  // For thread safety, don't update global registries when a secondary source opens a file.
573  if(inputType != InputType::SecondarySource) {
574  registry.insertMapped(parents);
575  }
576  }
577  entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionIDBranchName().c_str(), nullptr);
578  entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionBranchName().c_str(), nullptr);
579  }
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:510
TPRegexp parents
Definition: eve_filter.cc:21
std::string const & entryDescriptionBranchName()
Definition: BranchType.cc:154
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
Hash< EntryDescriptionType > EntryDescriptionID
std::string const & entryDescriptionTreeName()
Definition: BranchType.cc:146
Long64_t numEntries(TFile *hdl, std::string const &trname)
Definition: CollUtil.cc:50
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootFile.h:260
std::string const & entryDescriptionIDBranchName()
Definition: BranchType.cc:150
static Interceptor::Registry registry("Interceptor")
static ParentageRegistry * instance()
Hash< ParentageType > ParentageID
Definition: ParentageID.h:9
void edm::RootFile::readEvent ( EventPrincipal cache)

Definition at line 1421 of file RootFile.cc.

References daqProvenanceHelper_, edm::IndexIntoFile::IndexIntoFileItr::entry(), eventAux(), fileFormatVersion(), fillEventAuxiliary(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), indexIntoFile_, indexIntoFileEnd_, indexIntoFileIter_, edm::IndexIntoFile::kEvent, edm::IndexIntoFile::IndexIntoFileItr::lumi(), edm::EventAuxiliary::processHistoryID(), edm::IndexIntoFile::processHistoryID(), edm::IndexIntoFile::IndexIntoFileItr::processHistoryIDIndex(), processHistoryRegistry_, readCurrentEvent(), findQualityFiles::run, edm::IndexIntoFile::IndexIntoFileItr::run(), runHelper_, and edm::FileFormatVersion::useReducedProcessHistoryID().

1421  {
1424  // read the event auxiliary if not alrady read.
1426 
1427  // read the event
1429 
1430  runHelper_->checkRunConsistency(eventAux().run(), indexIntoFileIter_.run());
1431  runHelper_->checkLumiConsistency(eventAux().luminosityBlock(), indexIntoFileIter_.lumi());
1432 
1433  // If this next assert shows up in performance profiling or significantly affects memory, then these three lines should be deleted.
1434  // The IndexIntoFile should guarantee that it never fails.
1436  ProcessHistoryID const& reducedPHID = processHistoryRegistry_->reducedProcessHistoryID(idToCheck);
1438 
1440  }
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
edm::propagate_const< ProcessHistoryRegistry * > processHistoryRegistry_
Definition: RootFile.h:259
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
LuminosityBlockNumber_t lumi() const
bool readCurrentEvent(EventPrincipal &cache)
Definition: RootFile.cc:1444
bool fillEventAuxiliary(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1206
def principal(options)
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
EventAuxiliary const & eventAux() const
Definition: RootFile.h:171
Hash< ProcessHistoryType > ProcessHistoryID
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
ProcessHistoryID const & processHistoryID(int i) const
ProcessHistoryID const & processHistoryID() const
edm::propagate_const< RunHelperBase * > runHelper_
Definition: RootFile.h:291
bool useReducedProcessHistoryID() const
void edm::RootFile::readEventHistoryTree ( )
private

Definition at line 1657 of file RootFile.cc.

References edm::errors::EventCorruption, eventHistoryTree_, edm::poolNames::eventHistoryTreeName(), Exception, fileFormatVersion(), filePtr_, and history_.

Referenced by RootFile().

1657  {
1658  // Read in the event history tree, if we have one...
1659  if(fileFormatVersion().eventHistoryTree()) {
1660  history_ = std::make_unique<History>(); // propagate_const<T> has no reset() function
1661  eventHistoryTree_ = dynamic_cast<TTree*>(filePtr_->Get(poolNames::eventHistoryTreeName().c_str()));
1662  if(!eventHistoryTree_) {
1664  << "Failed to find the event history tree.\n";
1665  }
1666  }
1667  }
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
edm::propagate_const< std::unique_ptr< History > > history_
Definition: RootFile.h:296
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootFile.h:260
edm::propagate_const< TTree * > eventHistoryTree_
Definition: RootFile.h:293
std::string const & eventHistoryTreeName()
Definition: BranchType.cc:268
void edm::RootFile::readFakeRun_ ( RunPrincipal runPrincipal)
std::shared_ptr<RunAuxiliary> edm::RootFile::readFakeRunAuxiliary_ ( )
void edm::RootFile::readLuminosityBlock_ ( LuminosityBlockPrincipal lumiPrincipal)

Definition at line 1601 of file RootFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::entry(), edm::LuminosityBlockPrincipal::fillLuminosityBlockPrincipal(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), indexIntoFileEnd_, indexIntoFileIter_, edm::RootTree::insertEntryForIndex(), edm::RootTree::isValid(), edm::IndexIntoFile::kLumi, lumiTree_, processHistoryRegistry_, edm::Principal::readAllFromSourceAndMergeImmediately(), edm::RootTree::resetAndGetRootDelayedReader(), and edm::RootTree::setEntryNumber().

1601  {
1604  // Begin code for backward compatibility before the existence of lumi trees.
1605  if(!lumiTree_.isValid()) {
1607  return;
1608  }
1609  // End code for backward compatibility before the existence of lumi trees.
1611  // NOTE: we use 0 for the index since do not do delayed reads for LuminosityBlockPrincipals
1613  lumiPrincipal.fillLuminosityBlockPrincipal(*processHistoryRegistry_, lumiTree_.resetAndGetRootDelayedReader());
1614  // Read in all the products now.
1615  lumiPrincipal.readAllFromSourceAndMergeImmediately();
1617  }
RootTree lumiTree_
Definition: RootFile.h:281
edm::propagate_const< ProcessHistoryRegistry * > processHistoryRegistry_
Definition: RootFile.h:259
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
void insertEntryForIndex(unsigned int index)
Definition: RootTree.cc:100
DelayedReader * resetAndGetRootDelayedReader() const
Definition: RootTree.cc:118
bool isValid() const
Definition: RootTree.cc:106
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
std::shared_ptr< LuminosityBlockAuxiliary > edm::RootFile::readLuminosityBlockAuxiliary_ ( )

Definition at line 1563 of file RootFile.cc.

References edm::RootTree::current(), edm::IndexIntoFile::IndexIntoFileItr::entry(), eventAux(), eventTree_, fileFormatVersion(), filePtr_, fillEventAuxiliary(), fillLumiAuxiliary(), edm::IndexIntoFile::IndexIntoFileItr::firstEventEntryThisLumi(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), indexIntoFileEnd_, indexIntoFileIter_, edm::IndexIntoFile::invalidEntry, edm::Timestamp::invalidTimestamp(), edm::RootTree::isValid(), edm::IndexIntoFile::kLumi, edm::IndexIntoFile::IndexIntoFileItr::lumi(), edm::LuminosityBlockID::luminosityBlock(), lumiTree_, edm::LuminosityBlockID::run(), edm::IndexIntoFile::IndexIntoFileItr::run(), runHelper_, savedRunAuxiliary_, edm::RootTree::setEntryNumber(), edm::EventAuxiliary::time(), and ntuplemaker::time.

1563  {
1566  // Begin code for backward compatibility before the existence of lumi trees.
1567  if(!lumiTree_.isValid()) {
1569  assert(eventEntry != IndexIntoFile::invalidEntry);
1570  assert(eventTree_.current(eventEntry));
1571  fillEventAuxiliary(eventEntry);
1572 
1573  LuminosityBlockID lumi = LuminosityBlockID(indexIntoFileIter_.run(), indexIntoFileIter_.lumi());
1574  runHelper_->overrideRunNumber(lumi);
1575  return std::make_shared<LuminosityBlockAuxiliary>(lumi.run(), lumi.luminosityBlock(), eventAux().time(), Timestamp::invalidTimestamp());
1576  }
1577  // End code for backward compatibility before the existence of lumi trees.
1579  std::shared_ptr<LuminosityBlockAuxiliary> lumiAuxiliary = fillLumiAuxiliary();
1580  assert(lumiAuxiliary->run() == indexIntoFileIter_.run());
1581  assert(lumiAuxiliary->luminosityBlock() == indexIntoFileIter_.lumi());
1582  runHelper_->overrideRunNumber(lumiAuxiliary->id());
1583  filePtr_->reportInputLumiSection(lumiAuxiliary->run(), lumiAuxiliary->luminosityBlock());
1584  if(lumiAuxiliary->beginTime() == Timestamp::invalidTimestamp()) {
1586  if(eventEntry != IndexIntoFile::invalidEntry) {
1587  assert(eventTree_.current(eventEntry));
1588  fillEventAuxiliary(eventEntry);
1589 
1590  lumiAuxiliary->setBeginTime(eventAux().time());
1591  }
1592  lumiAuxiliary->setEndTime(Timestamp::invalidTimestamp());
1593  }
1594  if(!fileFormatVersion().processHistorySameWithinRun() && savedRunAuxiliary_) {
1595  lumiAuxiliary->setProcessHistoryID(savedRunAuxiliary_->processHistoryID());
1596  }
1597  return lumiAuxiliary;
1598  }
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
std::shared_ptr< LuminosityBlockAuxiliary > fillLumiAuxiliary()
Definition: RootFile.cc:1274
static Timestamp invalidTimestamp()
Definition: Timestamp.h:101
RootTree lumiTree_
Definition: RootFile.h:281
Timestamp const & time() const
edm::propagate_const< std::shared_ptr< RunAuxiliary > > savedRunAuxiliary_
Definition: RootFile.h:272
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
bool current() const
Definition: RootTree.h:126
LuminosityBlockNumber_t lumi() const
bool fillEventAuxiliary(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1206
long long EntryNumber_t
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
EventAuxiliary const & eventAux() const
Definition: RootFile.h:171
RootTree eventTree_
Definition: RootFile.h:280
static constexpr EntryNumber_t invalidEntry
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootFile.h:260
bool isValid() const
Definition: RootTree.cc:106
edm::propagate_const< RunHelperBase * > runHelper_
Definition: RootFile.h:291
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
void edm::RootFile::readParentageTree ( InputType  inputType)
private

Definition at line 582 of file RootFile.cc.

References daqProvenanceHelper_, Exception, filePtr_, edm::errors::FileReadError, edm::roottree::getEntry(), mps_fire::i, edm::Parentage::id(), edm::ParentageRegistry::insertMapped(), edm::ParentageRegistry::instance(), edm::numEntries(), edm::poolNames::parentageBranchName(), parentageIDLookup_, edm::poolNames::parentageTreeName(), parents, edm::Parentage::parentsForUpdate(), PhysicsTools::registry, and edm::SecondarySource.

Referenced by makeProvenanceReaderMaker().

582  {
583  // New format file
584  // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
585  std::unique_ptr<TTree> parentageTree(dynamic_cast<TTree*>(filePtr_->Get(poolNames::parentageTreeName().c_str())));
586  if(nullptr == parentageTree.get()) {
587  throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::parentageTreeName()
588  << " in the input file.\n";
589  }
590 
591  Parentage parents;
592  Parentage *pParentageBuffer = &parents;
593  parentageTree->SetBranchAddress(poolNames::parentageBranchName().c_str(), &pParentageBuffer);
594 
595  ParentageRegistry& registry = *ParentageRegistry::instance();
596 
597  parentageIDLookup_.reserve(parentageTree->GetEntries());
598  for(Long64_t i = 0, numEntries = parentageTree->GetEntries(); i < numEntries; ++i) {
599  roottree::getEntry(parentageTree.get(), i);
601  ParentageID const oldID = parents.id();
602  daqProvenanceHelper_->fixMetaData(parents.parentsForUpdate());
603  ParentageID newID = parents.id();
604  if(newID != oldID) {
605  daqProvenanceHelper_->setOldParentageIDToNew(oldID,newID);
606  }
607  }
608  // For thread safety, don't update global registries when a secondary source opens a file.
609  if(inputType != InputType::SecondarySource) {
610  registry.insertMapped(parents);
611  }
612  parentageIDLookup_.push_back(parents.id());
613  }
614  parentageTree->SetBranchAddress(poolNames::parentageBranchName().c_str(), nullptr);
615  }
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:510
TPRegexp parents
Definition: eve_filter.cc:21
std::string const & parentageTreeName()
Definition: BranchType.cc:159
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
Long64_t numEntries(TFile *hdl, std::string const &trname)
Definition: CollUtil.cc:50
std::string const & parentageBranchName()
Definition: BranchType.cc:163
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootFile.h:260
std::vector< ParentageID > parentageIDLookup_
Definition: RootFile.h:302
static Interceptor::Registry registry("Interceptor")
static ParentageRegistry * instance()
Hash< ParentageType > ParentageID
Definition: ParentageID.h:9
void edm::RootFile::readRun_ ( RunPrincipal runPrincipal)

Definition at line 1543 of file RootFile.cc.

References edm::RunPrincipal::fillRunPrincipal(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), indexIntoFileEnd_, indexIntoFileIter_, edm::RootTree::insertEntryForIndex(), edm::RootTree::isValid(), edm::IndexIntoFile::kRun, processHistoryRegistry_, edm::Principal::readAllFromSourceAndMergeImmediately(), edm::RootTree::resetAndGetRootDelayedReader(), runHelper_, and runTree_.

1543  {
1544  if(!runHelper_->fakeNewRun()) {
1548  }
1549  // Begin code for backward compatibility before the existence of run trees.
1550  if(!runTree_.isValid()) {
1551  return;
1552  }
1553  // End code for backward compatibility before the existence of run trees.
1554  // NOTE: we use 0 for the index since do not do delayed reads for RunPrincipals
1556  runPrincipal.fillRunPrincipal(*processHistoryRegistry_, runTree_.resetAndGetRootDelayedReader());
1557  // Read in all the products now.
1558  runPrincipal.readAllFromSourceAndMergeImmediately();
1559  }
edm::propagate_const< ProcessHistoryRegistry * > processHistoryRegistry_
Definition: RootFile.h:259
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
void insertEntryForIndex(unsigned int index)
Definition: RootTree.cc:100
DelayedReader * resetAndGetRootDelayedReader() const
Definition: RootTree.cc:118
RootTree runTree_
Definition: RootFile.h:282
bool isValid() const
Definition: RootTree.cc:106
edm::propagate_const< RunHelperBase * > runHelper_
Definition: RootFile.h:291
std::shared_ptr< RunAuxiliary > edm::RootFile::readRunAuxiliary_ ( )

Definition at line 1477 of file RootFile.cc.

References edm::RootTree::current(), edm::IndexIntoFile::IndexIntoFileItr::entry(), eventAux(), eventTree_, fileFormatVersion(), filePtr_, fillEventAuxiliary(), fillEventHistory(), fillRunAuxiliary(), edm::IndexIntoFile::IndexIntoFileItr::firstEventEntryThisRun(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), indexIntoFileEnd_, indexIntoFileIter_, edm::IndexIntoFile::invalidEntry, edm::Timestamp::invalidTimestamp(), edm::RootTree::isValid(), edm::IndexIntoFile::kRun, edm::FileFormatVersion::processHistorySameWithinRun(), edm::RunID::run(), findQualityFiles::run, edm::IndexIntoFile::IndexIntoFileItr::run(), runHelper_, runTree_, savedRunAuxiliary(), savedRunAuxiliary_, edm::RootTree::setEntryNumber(), edm::EventAuxiliary::time(), and ntuplemaker::time.

1477  {
1478  if(runHelper_->fakeNewRun()) {
1479  runHelper_->overrideRunNumber(savedRunAuxiliary_->id());
1480  return savedRunAuxiliary();
1481  }
1484 
1485  // Begin code for backward compatibility before the existence of run trees.
1486  if(!runTree_.isValid()) {
1487 
1488  // prior to the support of run trees.
1489  // RunAuxiliary did not contain a valid timestamp. Take it from the next event.
1491  assert(eventEntry != IndexIntoFile::invalidEntry);
1492  assert(eventTree_.current(eventEntry));
1493  fillEventAuxiliary(eventEntry);
1494 
1495  RunID run = RunID(indexIntoFileIter_.run());
1496  runHelper_->overrideRunNumber(run);
1497  savedRunAuxiliary_ = std::make_shared<RunAuxiliary>(run.run(), eventAux().time(), Timestamp::invalidTimestamp());
1498  return savedRunAuxiliary();
1499  }
1500  // End code for backward compatibility before the existence of run trees.
1502  std::shared_ptr<RunAuxiliary> runAuxiliary = fillRunAuxiliary();
1503  assert(runAuxiliary->run() == indexIntoFileIter_.run());
1504  runHelper_->overrideRunNumber(runAuxiliary->id());
1505  filePtr_->reportInputRunNumber(runAuxiliary->run());
1506  // If RunAuxiliary did not contain a valid begin timestamp, invalidate any end timestamp.
1507  if(runAuxiliary->beginTime() == Timestamp::invalidTimestamp()) {
1508  runAuxiliary->setEndTime(Timestamp::invalidTimestamp());
1509  }
1510 
1511  // If RunAuxiliary did not contain a valid timestamp, or if this an old format file from
1512  // when the Run's ProcessHistory included only processes where products were added to the Run itself,
1513  // we attempt to read the first event in the run to get appropriate info.
1514  if(runAuxiliary->beginTime() == Timestamp::invalidTimestamp() ||
1516 
1518  // If we have a valid event, use its information.
1519  if(eventEntry != IndexIntoFile::invalidEntry) {
1520  assert(eventTree_.current(eventEntry));
1521  fillEventAuxiliary(eventEntry);
1522 
1523  // RunAuxiliary did not contain a valid timestamp. Take it from the next event in this run if there is one.
1524  if(runAuxiliary->beginTime() == Timestamp::invalidTimestamp()) {
1525  runAuxiliary->setBeginTime(eventAux().time());
1526  }
1527 
1528  // For backwards compatibility when the Run's ProcessHistory included only processes where products were added to the
1529  // Run, and then the Run and Event auxiliaries could be different. Use the event ProcessHistoryID if there is one. It should
1530  // almost always be correct by the current definition (processes included if any products are added. This makes the run, lumi,
1531  // and event ProcessHistory's always be the same if no file merging occurs).
1532  if(!fileFormatVersion().processHistorySameWithinRun()) {
1533  fillEventHistory();
1534  runAuxiliary->setProcessHistoryID(eventAux().processHistoryID());
1535  }
1536  }
1537  }
1538  savedRunAuxiliary_ = runAuxiliary;
1539  return runAuxiliary;
1540  }
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
static Timestamp invalidTimestamp()
Definition: Timestamp.h:101
Timestamp const & time() const
edm::propagate_const< std::shared_ptr< RunAuxiliary > > savedRunAuxiliary_
Definition: RootFile.h:272
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
bool current() const
Definition: RootTree.h:126
bool fillEventAuxiliary(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1206
long long EntryNumber_t
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
EventAuxiliary const & eventAux() const
Definition: RootFile.h:171
std::shared_ptr< RunAuxiliary > fillRunAuxiliary()
Definition: RootFile.cc:1298
RootTree eventTree_
Definition: RootFile.h:280
RootTree runTree_
Definition: RootFile.h:282
std::shared_ptr< RunAuxiliary const > savedRunAuxiliary() const
Definition: RootFile.h:247
static constexpr EntryNumber_t invalidEntry
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootFile.h:260
bool processHistorySameWithinRun() const
void fillEventHistory()
Definition: RootFile.cc:1216
bool isValid() const
Definition: RootTree.cc:106
edm::propagate_const< RunHelperBase * > runHelper_
Definition: RootFile.h:291
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
void edm::RootFile::reportOpened ( std::string const &  inputType)

Definition at line 1161 of file RootFile.cc.

References edm::RootTree::branchNames(), eventTree_, edm::FileID::fid(), fid_, filePtr_, diffTwoXMLs::label, logicalFile_, edm::moduleName(), and AlCaHLTBitMon_QueryRunRegistry::string.

1161  {
1162  // Report file opened.
1163  std::string const label = "source";
1164  std::string moduleName = "PoolSource";
1165  filePtr_->inputFileOpened(
1166  logicalFile_,
1167  inputType,
1168  moduleName,
1169  label,
1170  fid_.fid(),
1172  }
std::vector< std::string > const & branchNames() const
Definition: RootTree.h:136
FileID fid_
Definition: RootFile.h:263
std::string const logicalFile_
Definition: RootFile.h:257
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
std::string const & fid() const
Definition: FileID.h:19
RootTree eventTree_
Definition: RootFile.h:280
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootFile.h:260
void edm::RootFile::rewind ( )
inline

Definition at line 195 of file RootFile.h.

195  {
197  eventTree_.rewind();
198  lumiTree_.rewind();
199  runTree_.rewind();
200  }
RootTree lumiTree_
Definition: RootFile.h:281
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
RootTree eventTree_
Definition: RootFile.h:280
RootTree runTree_
Definition: RootFile.h:282
IndexIntoFile::IndexIntoFileItr indexIntoFileBegin_
Definition: RootFile.h:267
void rewind()
Definition: RootTree.h:128
RootTree const& edm::RootFile::runTree ( ) const
inline

Definition at line 178 of file RootFile.h.

Referenced by validateFile().

178 {return runTree_;}
RootTree runTree_
Definition: RootFile.h:282
std::shared_ptr<RunAuxiliary const> edm::RootFile::savedRunAuxiliary ( ) const
inlineprivate

Definition at line 247 of file RootFile.h.

References edm::get_underlying_safe().

Referenced by readRunAuxiliary_().

edm::propagate_const< std::shared_ptr< RunAuxiliary > > savedRunAuxiliary_
Definition: RootFile.h:272
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::shared_ptr<RunAuxiliary>& edm::RootFile::savedRunAuxiliary ( )
inlineprivate

Definition at line 248 of file RootFile.h.

References edm::get_underlying_safe().

edm::propagate_const< std::shared_ptr< RunAuxiliary > > savedRunAuxiliary_
Definition: RootFile.h:272
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void edm::RootFile::setAtEventEntry ( IndexIntoFile::EntryNumber_t  entry)

Definition at line 1472 of file RootFile.cc.

References eventTree_, and edm::RootTree::setEntryNumber().

1472  {
1474  }
RootTree eventTree_
Definition: RootFile.h:280
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
bool edm::RootFile::setEntryAtEvent ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
)

Definition at line 1620 of file RootFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::entry(), eventTree_, edm::IndexIntoFile::findEventPosition(), indexIntoFile_, indexIntoFileEnd_, indexIntoFileIter_, and edm::RootTree::setEntryNumber().

1620  {
1622  if(indexIntoFileIter_ == indexIntoFileEnd_) return false;
1624  return true;
1625  }
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
RootTree eventTree_
Definition: RootFile.h:280
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
IndexIntoFileItr findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: event.py:1
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
bool edm::RootFile::setEntryAtItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
)
inline

Definition at line 185 of file RootFile.h.

References mps_splice::entry, and findQualityFiles::run.

185  {
187  }
bool setEntryAtRun(RunNumber_t run)
Definition: RootFile.cc:1636
bool setEntryAtLumi(RunNumber_t run, LuminosityBlockNumber_t lumi)
Definition: RootFile.cc:1628
bool setEntryAtEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
Definition: RootFile.cc:1620
Definition: event.py:1
bool edm::RootFile::setEntryAtLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
)

Definition at line 1628 of file RootFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::entry(), edm::IndexIntoFile::findLumiPosition(), indexIntoFile_, indexIntoFileEnd_, indexIntoFileIter_, lumiTree_, and edm::RootTree::setEntryNumber().

1628  {
1630  if(indexIntoFileIter_ == indexIntoFileEnd_) return false;
1632  return true;
1633  }
RootTree lumiTree_
Definition: RootFile.h:281
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
IndexIntoFileItr findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
bool edm::RootFile::setEntryAtNextEventInLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
)

Definition at line 1644 of file RootFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::advanceToEvent(), edm::IndexIntoFile::IndexIntoFileItr::entry(), fillEventAuxiliary(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), indexIntoFileIter_, edm::IndexIntoFile::kEvent, edm::IndexIntoFile::IndexIntoFileItr::lumi(), and edm::IndexIntoFile::IndexIntoFileItr::run().

1644  {
1647  }
1650  if(run != indexIntoFileIter_.run()) return false;
1651  if(lumi != indexIntoFileIter_.lumi()) return false;
1653  return true;
1654  }
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
LuminosityBlockNumber_t lumi() const
bool fillEventAuxiliary(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1206
bool edm::RootFile::setEntryAtRun ( RunNumber_t  run)

Definition at line 1636 of file RootFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::entry(), edm::IndexIntoFile::findRunPosition(), indexIntoFile_, indexIntoFileEnd_, indexIntoFileIter_, runTree_, and edm::RootTree::setEntryNumber().

1636  {
1638  if(indexIntoFileIter_ == indexIntoFileEnd_) return false;
1640  return true;
1641  }
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
IndexIntoFileItr findRunPosition(RunNumber_t run) const
Same as findPosition.
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
RootTree runTree_
Definition: RootFile.h:282
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:205
void edm::RootFile::setIfFastClonable ( int  remainingEvents,
int  remainingLumis 
)
private

Definition at line 618 of file RootFile.cc.

References duplicateChecker_, edm::FileBlock::DuplicateEventsRemoved, edm::RootTree::entries(), edm::FileBlock::EventsToBeSorted, eventTree_, fileFormatVersion(), edm::FileBlock::FileTooOld, edm::IndexIntoFile::firstAppearanceOrder, edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), indexIntoFile_, indexIntoFileBegin_, indexIntoFileEnd_, edm::FileBlock::InitialEventsSkipped, edm::IndexIntoFile::iterationWillBeInEntryOrder(), edm::IndexIntoFile::kEvent, lumiTree_, edm::FileBlock::MaxEventsTooSmall, edm::FileBlock::MaxLumisTooSmall, edm::FileBlock::NoEventsInFile, noEventSort_, edm::FileBlock::NotProcessingEvents, edm::IndexIntoFile::numericalOrder, processingMode_, edm::FileBlock::RunOrLumiNotContiguous, edm::InputSource::RunsLumisAndEvents, skipAnyEvents_, and whyNotFastClonable_.

Referenced by RootFile().

618  {
619  if(fileFormatVersion().noMetaDataTrees() and !fileFormatVersion().storedProductProvenanceUsed()) {
620  //we must avoid copying the old branch which stored the per product per event provenance
622  return;
623  }
624  if(!fileFormatVersion().splitProductIDs()) {
626  return;
627  }
630  return;
631  }
632  // Find entry for first event in file
633  IndexIntoFile::IndexIntoFileItr it = indexIntoFileBegin_;
634  while(it != indexIntoFileEnd_ && it.getEntryType() != IndexIntoFile::kEvent) {
635  ++it;
636  }
637  if(it == indexIntoFileEnd_) {
639  return;
640  }
641 
642  // From here on, record all reasons we can't fast clone.
646  }
647  if(skipAnyEvents_) {
649  }
650  if(remainingEvents >= 0 && eventTree_.entries() > remainingEvents) {
652  }
653  if(remainingLumis >= 0 && lumiTree_.entries() > remainingLumis) {
655  }
656  if(duplicateChecker_ &&
657  !duplicateChecker_->checkDisabled() &&
658  !duplicateChecker_->noDuplicatesInFile()) {
660  }
661  }
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
Definition: RootFile.h:298
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
int whyNotFastClonable_
Definition: RootFile.h:276
RootTree lumiTree_
Definition: RootFile.h:281
EntryNumber const & entries() const
Definition: RootTree.h:133
InputSource::ProcessingMode processingMode_
Definition: RootFile.h:290
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
bool noEventSort_
Definition: RootFile.h:274
bool skipAnyEvents_
Definition: RootFile.h:273
RootTree eventTree_
Definition: RootFile.h:280
bool iterationWillBeInEntryOrder(SortOrder sortOrder) const
Used to determine whether or not to disable fast cloning.
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
IndexIntoFile::IndexIntoFileItr indexIntoFileBegin_
Definition: RootFile.h:267
void edm::RootFile::setPosition ( IndexIntoFile::IndexIntoFileItr const &  position)

Definition at line 695 of file RootFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::copyPosition(), and indexIntoFileIter_.

695  {
697  }
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
void copyPosition(IndexIntoFileItr const &position)
Copy the position without modifying the pointer to the IndexIntoFile or size.
static int position[264][3]
Definition: ReadPGInfo.cc:509
void edm::RootFile::setSignals ( signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *  preEventReadSource,
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *  postEventReadSource 
)

Definition at line 1820 of file RootFile.cc.

References eventTree_, and edm::RootTree::setSignals().

1821  {
1822  eventTree_.setSignals(preEventReadSource,postEventReadSource);
1823  }
void setSignals(signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *preEventReadSource, signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *postEventReadSource)
Definition: RootTree.cc:501
RootTree eventTree_
Definition: RootFile.h:280
void edm::RootFile::setToLastEntry ( )
inline

Definition at line 201 of file RootFile.h.

201  {
203  }
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
bool edm::RootFile::skipEntries ( unsigned int &  offset)
inline
bool edm::RootFile::skipEvents ( int &  offset)

Definition at line 1319 of file RootFile.cc.

References duplicateChecker_, edm::EventID::event(), eventAux_, eventSkipperByID_, file_, fillEventAuxiliary(), edm::EventAuxiliary::id(), indexIntoFileEnd_, indexIntoFileIter_, edm::IndexIntoFile::invalidEntry, edm::IndexIntoFile::invalidIndex, edm::IndexIntoFile::invalidLumi, edm::IndexIntoFile::invalidRun, PFRecoTauDiscriminationByIsolation_cfi::offset, edm::IndexIntoFile::IndexIntoFileItr::skipEventBackward(), and edm::IndexIntoFile::IndexIntoFileItr::skipEventForward().

1319  {
1320  while(offset > 0 && indexIntoFileIter_ != indexIntoFileEnd_) {
1321 
1322  int phIndexOfSkippedEvent = IndexIntoFile::invalidIndex;
1323  RunNumber_t runOfSkippedEvent = IndexIntoFile::invalidRun;
1326 
1327  indexIntoFileIter_.skipEventForward(phIndexOfSkippedEvent,
1328  runOfSkippedEvent,
1329  lumiOfSkippedEvent,
1330  skippedEventEntry);
1331 
1332  // At the end of the file and there were no more events to skip
1333  if(skippedEventEntry == IndexIntoFile::invalidEntry) break;
1334 
1335  if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
1336  fillEventAuxiliary(skippedEventEntry);
1337  if(eventSkipperByID_->skipIt(runOfSkippedEvent, lumiOfSkippedEvent, eventAux_.id().event())) {
1338  continue;
1339  }
1340  }
1341  if(duplicateChecker_ &&
1342  !duplicateChecker_->checkDisabled() &&
1343  !duplicateChecker_->noDuplicatesInFile()) {
1344 
1345  fillEventAuxiliary(skippedEventEntry);
1346  if(duplicateChecker_->isDuplicateAndCheckActive(phIndexOfSkippedEvent,
1347  runOfSkippedEvent,
1348  lumiOfSkippedEvent,
1349  eventAux_.id().event(),
1350  file_)) {
1351  continue;
1352  }
1353  }
1354  --offset;
1355  }
1356 
1357  while(offset < 0) {
1358 
1359  if(duplicateChecker_) {
1360  duplicateChecker_->disable();
1361  }
1362 
1363  int phIndexOfEvent = IndexIntoFile::invalidIndex;
1367 
1368  indexIntoFileIter_.skipEventBackward(phIndexOfEvent,
1369  runOfEvent,
1370  lumiOfEvent,
1371  eventEntry);
1372 
1373  if(eventEntry == IndexIntoFile::invalidEntry) break;
1374 
1375  if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
1376  fillEventAuxiliary(eventEntry);
1377  if(eventSkipperByID_->skipIt(runOfEvent, lumiOfEvent, eventAux_.id().event())) {
1378  continue;
1379  }
1380  }
1381  ++offset;
1382  }
1384  }
EventNumber_t event() const
Definition: EventID.h:41
static constexpr int invalidIndex
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
Definition: RootFile.h:298
edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
Definition: RootFile.h:261
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
unsigned int LuminosityBlockNumber_t
bool fillEventAuxiliary(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1206
long long EntryNumber_t
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
static constexpr RunNumber_t invalidRun
void skipEventBackward(int &phIndexOfEvent, RunNumber_t &runOfEvent, LuminosityBlockNumber_t &lumiOfEvent, EntryNumber_t &eventEntry)
static constexpr EntryNumber_t invalidEntry
static constexpr LuminosityBlockNumber_t invalidLumi
EventID const & id() const
unsigned int RunNumber_t
EventAuxiliary eventAux_
Definition: RootFile.h:279
std::string const file_
Definition: RootFile.h:256
void skipEventForward(int &phIndexOfSkippedEvent, RunNumber_t &runOfSkippedEvent, LuminosityBlockNumber_t &lumiOfSkippedEvent, EntryNumber_t &skippedEventEntry)
bool edm::RootFile::skipThisEntry ( )
private

Definition at line 705 of file RootFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::entry(), edm::EventID::event(), eventAux_, eventSkipperByID_, fillEventAuxiliary(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), edm::EventAuxiliary::id(), indexIntoFileEnd_, indexIntoFileIter_, edm::IndexIntoFile::invalidLumi, edm::IndexIntoFile::kEvent, edm::IndexIntoFile::kRun, edm::IndexIntoFile::IndexIntoFileItr::lumi(), edm::IndexIntoFile::IndexIntoFileItr::peekAheadAtLumi(), edm::IndexIntoFile::IndexIntoFileItr::run(), edm::IndexIntoFile::IndexIntoFileItr::skipLumiInRun(), and mitigatedMETSequence_cff::U.

Referenced by getNextItemType().

705  {
707  return false;
708  }
709  if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
710 
711  // See first if the entire lumi or run is skipped, so we won't have to read the event Auxiliary in that case.
713  return true;
714  }
715 
716  // The Lumi is not skipped. If this is an event, see if the event is skipped.
721  eventAux_.id().event())) {
722  return true;
723  }
724  }
725 
726  // Skip runs with no lumis if either lumisToSkip or lumisToProcess have been set to select lumis
728  eventSkipperByID_->skippingLumis()) {
729  IndexIntoFile::IndexIntoFileItr iterLumi = indexIntoFileIter_;
730 
731  // There are no lumis in this run, not even ones we will skip
732  if(iterLumi.peekAheadAtLumi() == IndexIntoFile::invalidLumi) {
733  return true;
734  }
735  // If we get here there are lumis in the run, check to see if we are skipping all of them
736  do {
737  if(!eventSkipperByID_->skipIt(iterLumi.run(), iterLumi.peekAheadAtLumi(), 0U)) {
738  return false;
739  }
740  }
741  while(iterLumi.skipLumiInRun());
742  return true;
743  }
744  }
745  return false;
746  }
EventNumber_t event() const
Definition: EventID.h:41
edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
Definition: RootFile.h:261
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
LuminosityBlockNumber_t lumi() const
bool fillEventAuxiliary(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1206
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:268
static constexpr LuminosityBlockNumber_t invalidLumi
EventID const & id() const
EventAuxiliary eventAux_
Definition: RootFile.h:279
RootTreePtrArray& edm::RootFile::treePointers ( )
inlineprivate

Definition at line 223 of file RootFile.h.

References MicroEventContent_cff::branch, cmsCodeRulesChecker::rules, and AlCaHLTBitMon_QueryRunRegistry::string.

223 {return treePointers_;}
RootTreePtrArray treePointers_
Definition: RootFile.h:283
void edm::RootFile::validateFile ( InputType  inputType,
bool  usingGoToEvent 
)
private

Definition at line 1106 of file RootFile.cc.

References edm::createGlobalIdentifier(), daqProvenanceHelper_, duplicateChecker_, edm::IndexIntoFile::empty(), enforceGUIDInFileName_, edm::RootTree::entries(), edm::errors::EventCorruption, eventTree_, Exception, edm::FileID::fid(), fid_, file_, fileFormatVersion(), edm::errors::FileNameInconsistentWithGUID, edm::IndexIntoFile::fillEventNumbersOrEntries(), fillIndexIntoFile(), edm::IndexIntoFile::fixIndexes(), indexIntoFile_, edm::FileID::isValid(), edm::RootTree::isValid(), noEventSort_, orderedProcessHistoryIDs_, edm::Primary, processHistoryRegistry_, edm::IndexIntoFile::reduceProcessHistoryIDs(), runTree(), edm::IndexIntoFile::setEventFinder(), edm::IndexIntoFile::setNumberOfEvents(), edm::IndexIntoFile::setProcessHistoryIDs(), edm::stemFromPath(), and edm::FileFormatVersion::useReducedProcessHistoryID().

Referenced by RootFile().

1106  {
1107  if(!fid_.isValid()) {
1108  fid_ = FileID(createGlobalIdentifier());
1109  }
1110  if(!eventTree_.isValid()) {
1112  "'Events' tree is corrupted or not present\n" << "in the input file.\n";
1113  }
1114  if (enforceGUIDInFileName_) {
1115  auto guidFromName = stemFromPath(file_);
1116  if (guidFromName != fid_.fid()) {
1118  << "GUID " << guidFromName << " extracted from file name " << file_
1119  << " is inconsistent with the GUID read from the file " << fid_.fid();
1120  }
1121  }
1122 
1123  if(fileFormatVersion().hasIndexIntoFile()) {
1124  if(runTree().entries() > 0) {
1125  assert(!indexIntoFile_.empty());
1126  }
1128  if(daqProvenanceHelper_) {
1129  std::vector<ProcessHistoryID>& phidVec = indexIntoFile_.setProcessHistoryIDs();
1130  for(auto& phid : phidVec) {
1131  phid = daqProvenanceHelper_->mapProcessHistoryID(phid);
1132  }
1133  }
1135  }
1136  }
1137  else {
1138  assert(indexIntoFile_.empty());
1140  }
1141 
1144  indexIntoFile_.setEventFinder(std::shared_ptr<IndexIntoFile::EventFinder>(std::make_shared<RootFileEventFinder>(eventTree_)));
1145  // We fill the event numbers explicitly if we need to find events in closed files,
1146  // such as for secondary files (or secondary sources) or if duplicate checking across files.
1147  bool needEventNumbers = false;
1148  bool needIndexesForDuplicateChecker = duplicateChecker_ && duplicateChecker_->checkingAllFiles() && !duplicateChecker_->checkDisabled();
1149  if(inputType != InputType::Primary || needIndexesForDuplicateChecker || usingGoToEvent) {
1150  needEventNumbers = true;
1151  }
1152  bool needEventEntries = false;
1153  if(inputType != InputType::Primary || !noEventSort_) {
1154  // We need event entries for sorting or for secondary files or sources.
1155  needEventEntries = true;
1156  }
1157  indexIntoFile_.fillEventNumbersOrEntries(needEventNumbers, needEventEntries);
1158  }
void fillEventNumbersOrEntries(bool needEventNumbers, bool needEventEntries) const
void setEventFinder(std::shared_ptr< EventFinder > ptr) const
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
Definition: RootFile.h:298
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:179
bool enforceGUIDInFileName_
Definition: RootFile.h:275
bool empty() const
True if no runs, lumis, or events are in the file.
std::string_view stemFromPath(std::string_view path)
Definition: stemFromPath.cc:4
edm::propagate_const< ProcessHistoryRegistry * > processHistoryRegistry_
Definition: RootFile.h:259
edm::propagate_const< std::unique_ptr< DaqProvenanceHelper > > daqProvenanceHelper_
Definition: RootFile.h:303
EntryNumber const & entries() const
Definition: RootTree.h:133
void reduceProcessHistoryIDs(ProcessHistoryRegistry const &processHistoryRegistry)
FileID fid_
Definition: RootFile.h:263
std::vector< ProcessHistoryID > & setProcessHistoryIDs()
bool noEventSort_
Definition: RootFile.h:274
std::string const & fid() const
Definition: FileID.h:19
RootTree const & runTree() const
Definition: RootFile.h:178
RootTree eventTree_
Definition: RootFile.h:280
bool isValid() const
Definition: FileID.h:18
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:265
void fixIndexes(std::vector< ProcessHistoryID > &processHistoryIDs)
bool isValid() const
Definition: RootTree.cc:106
void fillIndexIntoFile()
Definition: RootFile.cc:880
std::vector< ProcessHistoryID > & orderedProcessHistoryIDs_
Definition: RootFile.h:266
void setNumberOfEvents(EntryNumber_t nevents) const
bool useReducedProcessHistoryID() const
std::string const file_
Definition: RootFile.h:256
std::string createGlobalIdentifier()
bool edm::RootFile::wasFirstEventJustRead ( ) const

Definition at line 818 of file RootFile.cc.

References a, b, mps_splice::entry, indexIntoFileIter_, edm::IndexIntoFile::invalidEntry, csvLumiCalc::lumi, findQualityFiles::run, and edm::IndexIntoFile::IndexIntoFileItr::skipEventBackward().

818  {
819  IndexIntoFile::IndexIntoFileItr itr(indexIntoFileIter_);
820  int phIndex;
823  IndexIntoFile::EntryNumber_t eventEntry;
824  itr.skipEventBackward(phIndex,
825  run,
826  lumi,
827  eventEntry);
828  itr.skipEventBackward(phIndex,
829  run,
830  lumi,
831  eventEntry);
832  return eventEntry == IndexIntoFile::invalidEntry;
833  }
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
unsigned int LuminosityBlockNumber_t
long long EntryNumber_t
static constexpr EntryNumber_t invalidEntry
unsigned int RunNumber_t
bool edm::RootFile::wasLastEventJustRead ( ) const

Definition at line 811 of file RootFile.cc.

References edm::IndexIntoFile::IndexIntoFileItr::advanceToEvent(), edm::IndexIntoFile::IndexIntoFileItr::getEntryType(), indexIntoFileIter_, and edm::IndexIntoFile::kEnd.

811  {
812  IndexIntoFile::IndexIntoFileItr itr(indexIntoFileIter_);
813  itr.advanceToEvent();
814  return itr.getEntryType() == IndexIntoFile::kEnd;
815  }
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:269
int edm::RootFile::whyNotFastClonable ( ) const
inline

Definition at line 180 of file RootFile.h.

Referenced by createFileBlock().

180 {return whyNotFastClonable_;}
int whyNotFastClonable_
Definition: RootFile.h:276

Member Data Documentation

edm::propagate_const<std::shared_ptr<BranchChildren> > edm::RootFile::branchChildren_
private

Definition at line 297 of file RootFile.h.

Referenced by markBranchToBeDropped(), and RootFile().

edm::propagate_const<std::shared_ptr<BranchIDListHelper> > edm::RootFile::branchIDListHelper_
private

Definition at line 287 of file RootFile.h.

Referenced by fillEventHistory(), and RootFile().

std::shared_ptr<BranchIDLists const> edm::RootFile::branchIDLists_
private

Definition at line 286 of file RootFile.h.

Referenced by RootFile().

BranchListIndexes edm::RootFile::branchListIndexes_
private

Definition at line 295 of file RootFile.h.

Referenced by fillEventHistory(), and readCurrentEvent().

bool edm::RootFile::branchListIndexesUnchanged_
private

Definition at line 278 of file RootFile.h.

Referenced by RootFile().

edm::propagate_const<std::unique_ptr<DaqProvenanceHelper> > edm::RootFile::daqProvenanceHelper_
private
edm::propagate_const<std::shared_ptr<DuplicateChecker> > edm::RootFile::duplicateChecker_
private
edm::propagate_const<TClass*> edm::RootFile::edProductClass_
private

Definition at line 304 of file RootFile.h.

Referenced by dropOnInput().

bool edm::RootFile::enforceGUIDInFileName_
private

Definition at line 275 of file RootFile.h.

Referenced by validateFile().

EventAuxiliary edm::RootFile::eventAux_
private
edm::propagate_const<TTree*> edm::RootFile::eventHistoryTree_
private

Definition at line 293 of file RootFile.h.

Referenced by close(), fillEventHistory(), and readEventHistoryTree().

std::vector<EventProcessHistoryID> edm::RootFile::eventProcessHistoryIDs_
private

Definition at line 270 of file RootFile.h.

Referenced by fillEventHistory(), and RootFile().

std::vector<EventProcessHistoryID>::const_iterator edm::RootFile::eventProcessHistoryIter_
private

Definition at line 271 of file RootFile.h.

Referenced by fillEventHistory(), and RootFile().

std::vector<edm::propagate_const<std::shared_ptr<ProductProvenanceRetriever> > > edm::RootFile::eventProductProvenanceRetrievers_
private

Definition at line 301 of file RootFile.h.

Referenced by makeProductProvenanceRetriever().

EventSelectionIDVector edm::RootFile::eventSelectionIDs_
private

Definition at line 294 of file RootFile.h.

Referenced by fillEventHistory(), and readCurrentEvent().

edm::propagate_const<std::shared_ptr<EventSkipperByID> > edm::RootFile::eventSkipperByID_
private

Definition at line 261 of file RootFile.h.

Referenced by RootFile(), skipEvents(), and skipThisEntry().

RootTree edm::RootFile::eventTree_
private
FileID edm::RootFile::fid_
private

Definition at line 263 of file RootFile.h.

Referenced by reportOpened(), RootFile(), and validateFile().

std::string const edm::RootFile::file_
private

Definition at line 256 of file RootFile.h.

Referenced by createFileBlock(), dropOnInput(), isDuplicateEvent(), skipEvents(), and validateFile().

FileFormatVersion edm::RootFile::fileFormatVersion_
private

Definition at line 262 of file RootFile.h.

Referenced by makeProvenanceReaderMaker(), and RootFile().

edm::propagate_const<std::shared_ptr<InputFile> > edm::RootFile::filePtr_
private
edm::propagate_const<std::unique_ptr<ThinnedAssociationsHelper> > edm::RootFile::fileThinnedAssociationsHelper_
private

Definition at line 288 of file RootFile.h.

Referenced by dropOnInput(), initAssociationsFromSecondary(), and RootFile().

std::array<bool, NumBranchTypes> edm::RootFile::hasNewlyDroppedBranch_
private

Definition at line 277 of file RootFile.h.

Referenced by dropOnInput(), and RootFile().

edm::propagate_const<std::unique_ptr<History> > edm::RootFile::history_
private

Definition at line 296 of file RootFile.h.

Referenced by fillEventHistory(), and readEventHistoryTree().

IndexIntoFile& edm::RootFile::indexIntoFile_
private
IndexIntoFile::IndexIntoFileItr edm::RootFile::indexIntoFileBegin_
private

Definition at line 267 of file RootFile.h.

Referenced by RootFile(), and setIfFastClonable().

IndexIntoFile::IndexIntoFileItr edm::RootFile::indexIntoFileEnd_
private
IndexIntoFile::IndexIntoFileItr edm::RootFile::indexIntoFileIter_
private
edm::propagate_const<std::shared_ptr<IndexIntoFile> > edm::RootFile::indexIntoFileSharedPtr_
private

Definition at line 264 of file RootFile.h.

IndexIntoFile::EntryNumber_t edm::RootFile::lastEventEntryNumberRead_
private

Definition at line 284 of file RootFile.h.

Referenced by fillIndexIntoFile(), and fillThisEventAuxiliary().

std::string const edm::RootFile::logicalFile_
private

Definition at line 257 of file RootFile.h.

Referenced by reportOpened().

RootTree edm::RootFile::lumiTree_
private
std::map<std::string, std::string> edm::RootFile::newBranchToOldBranch_
private

Definition at line 292 of file RootFile.h.

Referenced by newBranchToOldBranch(), and RootFile().

bool edm::RootFile::noEventSort_
private

Definition at line 274 of file RootFile.h.

Referenced by goToEvent(), setIfFastClonable(), and validateFile().

std::vector<ProcessHistoryID>& edm::RootFile::orderedProcessHistoryIDs_
private

Definition at line 266 of file RootFile.h.

Referenced by validateFile().

std::vector<ParentageID> edm::RootFile::parentageIDLookup_
private

Definition at line 302 of file RootFile.h.

Referenced by makeProvenanceReaderMaker(), and readParentageTree().

ProcessConfiguration const& edm::RootFile::processConfiguration_
private

Definition at line 258 of file RootFile.h.

edm::propagate_const<ProcessHistoryRegistry*> edm::RootFile::processHistoryRegistry_
private
InputSource::ProcessingMode edm::RootFile::processingMode_
private

Definition at line 290 of file RootFile.h.

Referenced by getNextItemType(), and setIfFastClonable().

std::shared_ptr<ProductRegistry const> edm::RootFile::productRegistry_
private

Definition at line 285 of file RootFile.h.

Referenced by RootFile().

edm::propagate_const<std::unique_ptr<ProvenanceAdaptor> > edm::RootFile::provenanceAdaptor_
private

Definition at line 299 of file RootFile.h.

Referenced by fillEventHistory(), fillLumiAuxiliary(), fillRunAuxiliary(), and RootFile().

edm::propagate_const<std::unique_ptr<MakeProvenanceReader> > edm::RootFile::provenanceReaderMaker_
private

Definition at line 300 of file RootFile.h.

Referenced by makeProductProvenanceRetriever(), and RootFile().

edm::propagate_const<RunHelperBase*> edm::RootFile::runHelper_
private
RootTree edm::RootFile::runTree_
private
edm::propagate_const<std::shared_ptr<RunAuxiliary> > edm::RootFile::savedRunAuxiliary_
private

Definition at line 272 of file RootFile.h.

Referenced by readLuminosityBlockAuxiliary_(), and readRunAuxiliary_().

bool edm::RootFile::skipAnyEvents_
private

Definition at line 273 of file RootFile.h.

Referenced by setIfFastClonable().

edm::propagate_const<std::shared_ptr<ThinnedAssociationsHelper> > edm::RootFile::thinnedAssociationsHelper_
private

Definition at line 289 of file RootFile.h.

Referenced by initAssociationsFromSecondary().

RootTreePtrArray edm::RootFile::treePointers_
private

Definition at line 283 of file RootFile.h.

Referenced by close(), dropOnInput(), and RootFile().

int edm::RootFile::whyNotFastClonable_
private

Definition at line 276 of file RootFile.h.

Referenced by RootFile(), and setIfFastClonable().