CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RootFile.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
3 
4 #include "RootFile.h"
5 #include "DuplicateChecker.h"
6 #include "InputFile.h"
7 #include "ProvenanceAdaptor.h"
8 
41 
42 //used for backward compatibility
47 
48 #include "TROOT.h"
49 #include "Rtypes.h"
50 #include "TClass.h"
51 #include "TString.h"
52 #include "TTree.h"
53 #include "TTreeCache.h"
54 
55 #include <algorithm>
56 #include <list>
57 
58 namespace edm {
59 
60  // Algorithm classes for making ProvenanceReader:
62  public:
63  virtual std::unique_ptr<ProvenanceReaderBase> makeReader(RootTree& eventTree, DaqProvenanceHelper const* daqProvenanceHelper) const override;
64  };
66  public:
67  MakeOldProvenanceReader(std::unique_ptr<EntryDescriptionMap>&& entryDescriptionMap) : MakeProvenanceReader(), entryDescriptionMap_(std::move(entryDescriptionMap)) {}
68  virtual std::unique_ptr<ProvenanceReaderBase> makeReader(RootTree& eventTree, DaqProvenanceHelper const* daqProvenanceHelper) const override;
69  private:
70  std::unique_ptr<EntryDescriptionMap> entryDescriptionMap_;
71  };
73  public:
74  virtual std::unique_ptr<ProvenanceReaderBase> makeReader(RootTree& eventTree, DaqProvenanceHelper const* daqProvenanceHelper) const override;
75  };
77  public:
78  MakeReducedProvenanceReader(std::vector<ParentageID> const& parentageIDLookup) : parentageIDLookup_(parentageIDLookup) {}
79  virtual std::unique_ptr<ProvenanceReaderBase> makeReader(RootTree& eventTree, DaqProvenanceHelper const* daqProvenanceHelper) const override;
80  private:
81  std::vector<ParentageID> const& parentageIDLookup_;
82  };
83 
84  namespace {
85  int
86  forcedRunOffset(RunNumber_t const& forcedRunNumber, IndexIntoFile::IndexIntoFileItr inxBegin, IndexIntoFile::IndexIntoFileItr inxEnd) {
87  if(inxBegin == inxEnd) return 0;
88  int defaultOffset = (inxBegin.run() != 0 ? 0 : 1);
89  int offset = (forcedRunNumber != 0U ? forcedRunNumber - inxBegin.run() : defaultOffset);
90  if(offset < 0) {
92  << "The value of the 'setRunNumber' parameter must not be\n"
93  << "less than the first run number in the first input file.\n"
94  << "'setRunNumber' was " << forcedRunNumber <<", while the first run was "
95  << forcedRunNumber - offset << ".\n";
96  }
97  return offset;
98  }
99 
100  void
101  checkReleaseVersion(std::vector<ProcessHistory> processHistoryVector, std::string const& fileName) {
102  std::string releaseVersion = getReleaseVersion();
103  releaseversion::DecomposedReleaseVersion currentRelease(releaseVersion);
104  for(auto const& ph : processHistoryVector) {
105  for(auto const& pc : ph) {
106  if(releaseversion::isEarlierRelease(currentRelease, pc.releaseVersion())) {
108  << "The release you are using, " << getReleaseVersion() << " , predates\n"
109  << "a release (" << pc.releaseVersion() << ") used in writing the input file, " << fileName <<".\n"
110  << "Forward compatibility cannot be supported.\n";
111  }
112  }
113  }
114  }
115  }
116 
117  // This is a helper class for IndexIntoFile.
119  public:
120  explicit RootFileEventFinder(RootTree& eventTree) : eventTree_(eventTree) {}
121  virtual ~RootFileEventFinder() {}
122  virtual
125  eventTree_.setEntryNumber(entry);
126  EventAuxiliary eventAux;
127  EventAuxiliary *pEvAux = &eventAux;
129  eventTree_.setEntryNumber(saveEntry);
130  return eventAux.event();
131  }
132 
133  private:
135  };
136 
137 //---------------------------------------------------------------------
140  std::string const& logicalFileName,
141  std::shared_ptr<InputFile> filePtr,
142  std::shared_ptr<EventSkipperByID> eventSkipperByID,
143  bool skipAnyEvents,
144  int remainingEvents,
145  int remainingLumis,
146  unsigned int nStreams,
147  unsigned int treeCacheSize,
148  int treeMaxVirtualSize,
150  RunNumber_t const& forcedRunNumber,
151  bool noEventSort,
152  ProductSelectorRules const& productSelectorRules,
153  InputType inputType,
154  std::shared_ptr<BranchIDListHelper> branchIDListHelper,
155  std::shared_ptr<DuplicateChecker> duplicateChecker,
156  bool dropDescendants,
157  ProcessHistoryRegistry& processHistoryRegistry,
158  std::vector<std::shared_ptr<IndexIntoFile> > const& indexesIntoFiles,
159  std::vector<std::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile,
160  std::vector<ProcessHistoryID>& orderedProcessHistoryIDs,
161  bool bypassVersionCheck,
162  bool labelRawDataLikeMC,
163  bool usingGoToEvent,
164  bool enablePrefetching) :
165  file_(fileName),
166  logicalFile_(logicalFileName),
167  processConfiguration_(processConfiguration),
168  processHistoryRegistry_(&processHistoryRegistry),
169  filePtr_(filePtr),
170  eventSkipperByID_(eventSkipperByID),
171  fileFormatVersion_(),
172  fid_(),
173  indexIntoFileSharedPtr_(new IndexIntoFile),
174  indexIntoFile_(*indexIntoFileSharedPtr_),
175  orderedProcessHistoryIDs_(orderedProcessHistoryIDs),
176  indexIntoFileBegin_(indexIntoFile_.begin(noEventSort ? IndexIntoFile::firstAppearanceOrder : IndexIntoFile::numericalOrder)),
177  indexIntoFileEnd_(indexIntoFileBegin_),
178  indexIntoFileIter_(indexIntoFileBegin_),
179  eventProcessHistoryIDs_(),
180  eventProcessHistoryIter_(eventProcessHistoryIDs_.begin()),
181  savedRunAuxiliary_(),
182  skipAnyEvents_(skipAnyEvents),
183  noEventSort_(noEventSort),
184  whyNotFastClonable_(0),
185  hasNewlyDroppedBranch_(),
186  branchListIndexesUnchanged_(false),
187  eventAux_(),
188  eventTree_(filePtr_, InEvent, nStreams, treeMaxVirtualSize, treeCacheSize, roottree::defaultLearningEntries, enablePrefetching, inputType),
189  lumiTree_(filePtr_, InLumi, 1, treeMaxVirtualSize, roottree::defaultNonEventCacheSize, roottree::defaultNonEventLearningEntries, enablePrefetching, inputType),
190  runTree_(filePtr_, InRun, 1, treeMaxVirtualSize, roottree::defaultNonEventCacheSize, roottree::defaultNonEventLearningEntries, enablePrefetching, inputType),
191  treePointers_(),
192  lastEventEntryNumberRead_(IndexIntoFile::invalidEntry),
193  productRegistry_(),
194  branchIDLists_(),
195  branchIDListHelper_(branchIDListHelper),
196  processingMode_(processingMode),
197  forcedRunOffset_(0),
198  newBranchToOldBranch_(),
199  eventHistoryTree_(nullptr),
200  eventSelectionIDs_(),
201  branchListIndexes_(),
202  history_(),
203  branchChildren_(new BranchChildren),
204  duplicateChecker_(duplicateChecker),
205  provenanceAdaptor_(),
206  provenanceReaderMaker_(),
207  eventProductProvenanceRetrievers_(),
208  parentageIDLookup_(),
209  daqProvenanceHelper_(),
210  edProductClass_(gROOT->GetClass("edm::WrapperBase")) {
211 
212  hasNewlyDroppedBranch_.fill(false);
213 
217 
218  // Read the metadata tree.
219  // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
220  std::unique_ptr<TTree> metaDataTree(dynamic_cast<TTree *>(filePtr_->Get(poolNames::metaDataTreeName().c_str())));
221  if(nullptr == metaDataTree.get()) {
222  throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::metaDataTreeName()
223  << " in the input file.\n";
224  }
225 
226  // To keep things simple, we just read in every possible branch that exists.
227  // We don't pay attention to which branches exist in which file format versions
228 
230  if(metaDataTree->FindBranch(poolNames::fileFormatVersionBranchName().c_str()) != nullptr) {
231  TBranch *fft = metaDataTree->GetBranch(poolNames::fileFormatVersionBranchName().c_str());
232  fft->SetAddress(&fftPtr);
233  roottree::getEntry(fft, 0);
234  metaDataTree->SetBranchAddress(poolNames::fileFormatVersionBranchName().c_str(), &fftPtr);
235  }
236 
237  FileID *fidPtr = &fid_;
238  if(metaDataTree->FindBranch(poolNames::fileIdentifierBranchName().c_str()) != nullptr) {
239  metaDataTree->SetBranchAddress(poolNames::fileIdentifierBranchName().c_str(), &fidPtr);
240  }
241 
242  IndexIntoFile *iifPtr = &indexIntoFile_;
243  if(metaDataTree->FindBranch(poolNames::indexIntoFileBranchName().c_str()) != nullptr) {
244  metaDataTree->SetBranchAddress(poolNames::indexIntoFileBranchName().c_str(), &iifPtr);
245  }
246 
247  // Need to read to a temporary registry so we can do a translation of the BranchKeys.
248  // This preserves backward compatibility against friendly class name algorithm changes.
249  ProductRegistry inputProdDescReg;
250  ProductRegistry *ppReg = &inputProdDescReg;
251  metaDataTree->SetBranchAddress(poolNames::productDescriptionBranchName().c_str(), (&ppReg));
252 
253  typedef std::map<ParameterSetID, ParameterSetBlob> PsetMap;
254  PsetMap psetMap;
255  PsetMap *psetMapPtr = &psetMap;
256  if(metaDataTree->FindBranch(poolNames::parameterSetMapBranchName().c_str()) != nullptr) {
257  //backward compatibility
258  assert(!fileFormatVersion().parameterSetsTree());
259  metaDataTree->SetBranchAddress(poolNames::parameterSetMapBranchName().c_str(), &psetMapPtr);
260  } else {
261  assert(fileFormatVersion().parameterSetsTree());
262  // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
263  std::unique_ptr<TTree> psetTree(dynamic_cast<TTree *>(filePtr_->Get(poolNames::parameterSetsTreeName().c_str())));
264  if(nullptr == psetTree.get()) {
265  throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::parameterSetsTreeName()
266  << " in the input file.\n";
267  }
268 
269  typedef std::pair<ParameterSetID, ParameterSetBlob> IdToBlobs;
270  IdToBlobs idToBlob;
271  IdToBlobs* pIdToBlob = &idToBlob;
272  psetTree->SetBranchAddress(poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);
273 
274  std::unique_ptr<TTreeCache> psetTreeCache = roottree::trainCache(psetTree.get(), *filePtr_, roottree::defaultNonEventCacheSize, "*");
275  psetTreeCache->SetEnablePrefetching(false);
276  filePtr_->SetCacheRead(psetTreeCache.get());
277  for(Long64_t i = 0; i != psetTree->GetEntries(); ++i) {
278  psetTree->GetEntry(i);
279  psetMap.insert(idToBlob);
280  }
281  filePtr_->SetCacheRead(0);
282  }
283 
284  // backward compatibility
286  ProcessHistoryRegistry::collection_type *pHistMapPtr = &pHistMap;
287  if(metaDataTree->FindBranch(poolNames::processHistoryMapBranchName().c_str()) != nullptr) {
288  metaDataTree->SetBranchAddress(poolNames::processHistoryMapBranchName().c_str(), &pHistMapPtr);
289  }
290 
292  ProcessHistoryRegistry::vector_type *pHistVectorPtr = &pHistVector;
293  if(metaDataTree->FindBranch(poolNames::processHistoryBranchName().c_str()) != nullptr) {
294  metaDataTree->SetBranchAddress(poolNames::processHistoryBranchName().c_str(), &pHistVectorPtr);
295  }
296 
297  // backward compatibility
298  ProcessConfigurationVector processConfigurations;
299  ProcessConfigurationVector* procConfigVectorPtr = &processConfigurations;
300  if(metaDataTree->FindBranch(poolNames::processConfigurationBranchName().c_str()) != nullptr) {
301  metaDataTree->SetBranchAddress(poolNames::processConfigurationBranchName().c_str(), &procConfigVectorPtr);
302  }
303 
304  std::unique_ptr<BranchIDLists> branchIDListsAPtr(new BranchIDLists);
305  BranchIDLists* branchIDListsPtr = branchIDListsAPtr.get();
306  if(metaDataTree->FindBranch(poolNames::branchIDListBranchName().c_str()) != nullptr) {
307  metaDataTree->SetBranchAddress(poolNames::branchIDListBranchName().c_str(), &branchIDListsPtr);
308  }
309 
310  BranchChildren* branchChildrenBuffer = branchChildren_.get();
311  if(metaDataTree->FindBranch(poolNames::productDependenciesBranchName().c_str()) != nullptr) {
312  metaDataTree->SetBranchAddress(poolNames::productDependenciesBranchName().c_str(), &branchChildrenBuffer);
313  }
314 
315  // backward compatibility
316  std::vector<EventProcessHistoryID> *eventHistoryIDsPtr = &eventProcessHistoryIDs_;
317  if(metaDataTree->FindBranch(poolNames::eventHistoryBranchName().c_str()) != nullptr) {
318  metaDataTree->SetBranchAddress(poolNames::eventHistoryBranchName().c_str(), &eventHistoryIDsPtr);
319  }
320 
321  if(metaDataTree->FindBranch(poolNames::moduleDescriptionMapBranchName().c_str()) != nullptr) {
322  if(metaDataTree->GetBranch(poolNames::moduleDescriptionMapBranchName().c_str())->GetSplitLevel() != 0) {
323  metaDataTree->SetBranchStatus((poolNames::moduleDescriptionMapBranchName() + ".*").c_str(), 0);
324  } else {
325  metaDataTree->SetBranchStatus(poolNames::moduleDescriptionMapBranchName().c_str(), 0);
326  }
327  }
328 
329  // Here we read the metadata tree
330  roottree::getEntry(metaDataTree.get(), 0);
331 
333 
334  // Here we read the event history tree, if we have one.
336 
338  if(!fileFormatVersion().triggerPathsTracked()) {
339  ParameterSetConverter converter(psetMap, psetIdConverter, fileFormatVersion().parameterSetsByReference());
340  } else {
341  // Merge into the parameter set registry.
342  pset::Registry& psetRegistry = *pset::Registry::instance();
343  for(auto const& psetEntry : psetMap) {
344  ParameterSet pset(psetEntry.second.pset());
345  pset.setID(psetEntry.first);
346  // For thread safety, don't update global registries when a secondary source opens a file.
347  if(inputType != InputType::SecondarySource) {
348  psetRegistry.insertMapped(pset);
349  }
350  }
351  }
352  if(!fileFormatVersion().splitProductIDs()) {
353  // Old provenance format input file. Create a provenance adaptor.
355  inputProdDescReg, pHistMap, pHistVector, processConfigurations, psetIdConverter, true));
356  // Fill in the branchIDLists branch from the provenance adaptor
357  branchIDLists_ = provenanceAdaptor_->branchIDLists();
358  } else {
359  if(!fileFormatVersion().triggerPathsTracked()) {
360  // New provenance format, but change in ParameterSet Format. Create a provenance adaptor.
362  inputProdDescReg, pHistMap, pHistVector, processConfigurations, psetIdConverter, false));
363  }
364  // New provenance format input file. The branchIDLists branch was read directly from the input file.
365  if(metaDataTree->FindBranch(poolNames::branchIDListBranchName().c_str()) == nullptr) {
367  << "Failed to find branchIDLists branch in metaData tree.\n";
368  }
369  branchIDLists_.reset(branchIDListsAPtr.release());
370  }
371 
372  if(!bypassVersionCheck) {
373  checkReleaseVersion(pHistVector, file());
374  }
375 
376  if(labelRawDataLikeMC) {
377  std::string const rawData("FEDRawDataCollection");
378  std::string const source("source");
379  ProductRegistry::ProductList& pList = inputProdDescReg.productListUpdator();
380  BranchKey finder(rawData, source, "", "");
381  ProductRegistry::ProductList::iterator it = pList.lower_bound(finder);
382  if(it != pList.end() && it->first.friendlyClassName() == rawData && it->first.moduleLabel() == source) {
383  // We found raw data with a module label of source.
384  // We need to change the module label and process name.
385  // Create helper.
386  it->second.init();
387  daqProvenanceHelper_.reset(new DaqProvenanceHelper(it->second.unwrappedTypeID()));
388  // Create the new branch description
389  BranchDescription const& newBD = daqProvenanceHelper_->branchDescription();
390  // Save info from the old and new branch descriptions
391  daqProvenanceHelper_->saveInfo(it->second, newBD);
392  // Map the new branch name to the old branch name.
393  newBranchToOldBranch_.insert(std::make_pair(newBD.branchName(), it->second.branchName()));
394  // Remove the old branch description from the product Registry.
395  pList.erase(it);
396  // Check that there was only one.
397  it = pList.lower_bound(finder);
398  assert(!(it != pList.end() && it->first.friendlyClassName() == rawData && it->first.moduleLabel() == source));
399  // Insert the new branch description into the product registry.
400  inputProdDescReg.copyProduct(newBD);
401  // Fix up other per file metadata.
402  daqProvenanceHelper_->fixMetaData(processConfigurations, pHistVector);
403  daqProvenanceHelper_->fixMetaData(*branchIDLists_);
404  daqProvenanceHelper_->fixMetaData(*branchChildren_);
405  }
406  }
407 
408  for(auto const& history : pHistVector) {
409  processHistoryRegistry.registerProcessHistory(history);
410  }
411 
413 
414  // Update the branch id info. This has to be done before validateFile since
415  // depending on the file format, the branchIDListHelper_ may have its fixBranchListIndexes call made
416  if(inputType == InputType::Primary || inputType == InputType::SecondarySource) {
418  }
419 
420  validateFile(inputType, usingGoToEvent);
421 
422  // Here, we make the class that will make the ProvenanceReader
423  // It reads whatever trees it needs.
425 
426  // Merge into the hashed registries.
427  if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
429  }
430 
431  initializeDuplicateChecker(indexesIntoFiles, currentIndexIntoFile);
433  indexIntoFileEnd_ = indexIntoFile_.end(noEventSort ? IndexIntoFile::firstAppearanceOrder : IndexIntoFile::numericalOrder);
434  forcedRunOffset_ = forcedRunOffset(forcedRunNumber, indexIntoFileBegin_, indexIntoFileEnd_);
435  eventProcessHistoryIter_ = eventProcessHistoryIDs_.begin();
436 
437  // Set product presence information in the product registry.
438  ProductRegistry::ProductList& pList = inputProdDescReg.productListUpdator();
439  for(auto& product : pList) {
440  BranchDescription& prod = product.second;
441  prod.init();
442  treePointers_[prod.branchType()]->setPresence(prod, newBranchToOldBranch(prod.branchName()));
443  }
444 
445  std::unique_ptr<ProductRegistry> newReg(new ProductRegistry);
446 
447  // Do the translation from the old registry to the new one
448  {
449  ProductRegistry::ProductList const& prodList = inputProdDescReg.productList();
450  for(auto const& product : prodList) {
451  BranchDescription const& prod = product.second;
452  std::string newFriendlyName = friendlyname::friendlyName(prod.className());
453  if(newFriendlyName == prod.friendlyClassName()) {
454  newReg->copyProduct(prod);
455  } else {
456  if(fileFormatVersion().splitProductIDs()) {
458  << "Cannot change friendly class name algorithm without more development work\n"
459  << "to update BranchIDLists. Contact the framework group.\n";
460  }
461  BranchDescription newBD(prod);
462  newBD.updateFriendlyClassName();
463  newReg->copyProduct(newBD);
464  newBranchToOldBranch_.insert(std::make_pair(newBD.branchName(), prod.branchName()));
465  }
466  }
467  dropOnInput(*newReg, productSelectorRules, dropDescendants, inputType);
468  // freeze the product registry
469  newReg->setFrozen(inputType != InputType::Primary);
470  productRegistry_.reset(newReg.release());
471  }
472 
473  // Set up information from the product registry.
474  ProductRegistry::ProductList const& prodList = productRegistry()->productList();
475  for(auto const& product : prodList) {
476  BranchDescription const& prod = product.second;
477  treePointers_[prod.branchType()]->addBranch(product.first, prod,
479  }
480 
481  // Determine if this file is fast clonable.
482  setIfFastClonable(remainingEvents, remainingLumis);
483 
484  setRefCoreStreamer(true); // backward compatibility
485 
486  // We are done with our initial reading of EventAuxiliary.
488 
489  // Tell the event tree to begin training at the next read.
491 
492  // Train the run and lumi trees.
493  runTree_.trainCache("*");
494  lumiTree_.trainCache("*");
495  }
496 
498  }
499 
500  void
502  // Called only for old format files.
503  // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
504  std::unique_ptr<TTree> entryDescriptionTree(dynamic_cast<TTree*>(filePtr_->Get(poolNames::entryDescriptionTreeName().c_str())));
505  if(nullptr == entryDescriptionTree.get()) {
506  throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::entryDescriptionTreeName()
507  << " in the input file.\n";
508  }
509 
510  EntryDescriptionID idBuffer;
511  EntryDescriptionID* pidBuffer = &idBuffer;
512  entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionIDBranchName().c_str(), &pidBuffer);
513 
514  EventEntryDescription entryDescriptionBuffer;
515  EventEntryDescription *pEntryDescriptionBuffer = &entryDescriptionBuffer;
516  entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionBranchName().c_str(), &pEntryDescriptionBuffer);
517 
518  // Fill in the parentage registry.
520 
521  for(Long64_t i = 0, numEntries = entryDescriptionTree->GetEntries(); i < numEntries; ++i) {
522  roottree::getEntry(entryDescriptionTree.get(), i);
523  if(idBuffer != entryDescriptionBuffer.id()) {
524  throw Exception(errors::EventCorruption) << "Corruption of EntryDescription tree detected.\n";
525  }
526  entryDescriptionMap.insert(std::make_pair(entryDescriptionBuffer.id(),entryDescriptionBuffer));
528  parents.setParents(entryDescriptionBuffer.parents());
530  ParentageID const oldID = parents.id();
531  daqProvenanceHelper_->fixMetaData(parents.parentsForUpdate());
532  ParentageID newID = parents.id();
533  if(newID != oldID) {
534  daqProvenanceHelper_->setOldParentageIDToNew(oldID,newID);
535  }
536  }
537  // For thread safety, don't update global registries when a secondary source opens a file.
538  if(inputType != InputType::SecondarySource) {
539  registry.insertMapped(parents);
540  }
541  }
542  entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionIDBranchName().c_str(), nullptr);
543  entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionBranchName().c_str(), nullptr);
544  }
545 
546  void
548  // New format file
549  // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
550  std::unique_ptr<TTree> parentageTree(dynamic_cast<TTree*>(filePtr_->Get(poolNames::parentageTreeName().c_str())));
551  if(nullptr == parentageTree.get()) {
552  throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::parentageTreeName()
553  << " in the input file.\n";
554  }
555 
557  Parentage *pParentageBuffer = &parents;
558  parentageTree->SetBranchAddress(poolNames::parentageBranchName().c_str(), &pParentageBuffer);
559 
561 
562  parentageIDLookup_.reserve(parentageTree->GetEntries());
563  for(Long64_t i = 0, numEntries = parentageTree->GetEntries(); i < numEntries; ++i) {
564  roottree::getEntry(parentageTree.get(), i);
566  ParentageID const oldID = parents.id();
567  daqProvenanceHelper_->fixMetaData(parents.parentsForUpdate());
568  ParentageID newID = parents.id();
569  if(newID != oldID) {
570  daqProvenanceHelper_->setOldParentageIDToNew(oldID,newID);
571  }
572  }
573  // For thread safety, don't update global registries when a secondary source opens a file.
574  if(inputType != InputType::SecondarySource) {
575  registry.insertMapped(parents);
576  }
577  parentageIDLookup_.push_back(parents.id());
578  }
579  parentageTree->SetBranchAddress(poolNames::parentageBranchName().c_str(), nullptr);
580  }
581 
582  void
583  RootFile::setIfFastClonable(int remainingEvents, int remainingLumis) {
584  if(fileFormatVersion().noMetaDataTrees() and !fileFormatVersion().storedProductProvenanceUsed()) {
585  //we must avoid copying the old branch which stored the per product per event provenance
587  return;
588  }
589  if(!fileFormatVersion().splitProductIDs()) {
591  return;
592  }
595  return;
596  }
597  // Find entry for first event in file
599  while(it != indexIntoFileEnd_ && it.getEntryType() != IndexIntoFile::kEvent) {
600  ++it;
601  }
602  if(it == indexIntoFileEnd_) {
604  return;
605  }
606 
607  // From here on, record all reasons we can't fast clone.
611  }
612  if(skipAnyEvents_) {
614  }
615  if(remainingEvents >= 0 && eventTree_.entries() > remainingEvents) {
617  }
618  if(remainingLumis >= 0 && lumiTree_.entries() > remainingLumis) {
620  }
621  // We no longer fast copy the EventAuxiliary branch, so there
622  // is no longer any need to disable fast copying because the run
623  // number is being modified. Also, this check did not work anyway
624  // because this function is called before forcedRunOffset_ is set.
625 
626  // if(forcedRunOffset_ != 0) {
627  // whyNotFastClonable_ += FileBlock::RunNumberModified;
628  // }
629  if(duplicateChecker_ &&
630  !duplicateChecker_->checkDisabled() &&
631  !duplicateChecker_->noDuplicatesInFile()) {
633  }
634  }
635 
636  std::unique_ptr<FileBlock>
638  return std::unique_ptr<FileBlock>(new FileBlock(fileFormatVersion(),
639  eventTree_.tree(),
641  lumiTree_.tree(),
643  runTree_.tree(),
644  runTree_.metaTree(),
647  file_,
649  modifiedIDs(),
650  branchChildren_));
651  }
652 
653  std::string const&
654  RootFile::newBranchToOldBranch(std::string const& newBranch) const {
655  std::map<std::string, std::string>::const_iterator it = newBranchToOldBranch_.find(newBranch);
656  if(it != newBranchToOldBranch_.end()) {
657  return it->second;
658  }
659  return newBranch;
660  }
661 
664  return indexIntoFileIter_;
665  }
666 
667  void
670  }
671 
672  bool
675  return false;
676  }
677  if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
678 
679  // See first if the entire lumi or run is skipped, so we won't have to read the event Auxiliary in that case.
681  return true;
682  }
683 
684  // The Lumi is not skipped. If this is an event, see if the event is skipped.
689  eventAux_.id().event())) {
690  return true;
691  }
692  }
693 
694  // Skip runs with no lumis if either lumisToSkip or lumisToProcess have been set to select lumis
696  eventSkipperByID_->skippingLumis()) {
698 
699  // There are no lumis in this run, not even ones we will skip
700  if(iterLumi.peekAheadAtLumi() == IndexIntoFile::invalidLumi) {
701  return true;
702  }
703  // If we get here there are lumis in the run, check to see if we are skipping all of them
704  do {
705  if(!eventSkipperByID_->skipIt(iterLumi.run(), iterLumi.peekAheadAtLumi(), 0U)) {
706  return false;
707  }
708  }
709  while(iterLumi.skipLumiInRun());
710  return true;
711  }
712  }
713  return false;
714  }
715 
716  bool
719  if(duplicateChecker_.get() == nullptr) {
720  return false;
721  }
723  return duplicateChecker_->isDuplicateAndCheckActive(indexIntoFileIter_.processHistoryIDIndex(),
725  }
726 
727  bool
729  return indexIntoFile_.containsItem(run, lumi, event);
730  }
731 
734  // First, account for consecutive skipped entries.
735  while(skipThisEntry()) {
738  }
741  }
742  else {
744  }
745  }
746  // OK, we have an entry that is not skipped.
748  if(entryType == IndexIntoFile::kEnd) {
749  return IndexIntoFile::kEnd;
750  }
751  if(entryType == IndexIntoFile::kRun) {
752  run = indexIntoFileIter_.run();
753  return IndexIntoFile::kRun;
754  } else if(processingMode_ == InputSource::Runs) {
756  return getNextItemType(run, lumi, event);
757  }
758  if(entryType == IndexIntoFile::kLumi) {
759  run = indexIntoFileIter_.run();
760  lumi = indexIntoFileIter_.lumi();
761  return IndexIntoFile::kLumi;
764  return getNextItemType(run, lumi, event);
765  }
766  if(isDuplicateEvent()) {
768  return getNextItemType(run, lumi, event);
769  }
770  run = indexIntoFileIter_.run();
771  lumi = indexIntoFileIter_.lumi();
773  event = eventAux_.event();
774  return IndexIntoFile::kEvent;
775  }
776 
777  bool
780  itr.advanceToEvent();
781  return itr.getEntryType() == IndexIntoFile::kEnd;
782  }
783 
784  bool
787  int phIndex;
790  IndexIntoFile::EntryNumber_t eventEntry;
791  itr.skipEventBackward(phIndex,
792  run,
793  lumi,
794  eventEntry);
795  itr.skipEventBackward(phIndex,
796  run,
797  lumi,
798  eventEntry);
799  return eventEntry == IndexIntoFile::invalidEntry;
800  }
801 
802  namespace {
803  struct RunItem {
804  RunItem(ProcessHistoryID const& phid, RunNumber_t const& run) :
805  phid_(phid), run_(run) {}
806  ProcessHistoryID phid_;
807  RunNumber_t run_;
808  };
809  struct RunItemSortByRun {
810  bool operator()(RunItem const& a, RunItem const& b) const {
811  return a.run_ < b.run_;
812  }
813  };
814  struct RunItemSortByRunPhid {
815  bool operator()(RunItem const& a, RunItem const& b) const {
816  return a.run_ < b.run_ || (!(b.run_ < a.run_) && a.phid_ < b.phid_);
817  }
818  };
819  struct LumiItem {
820  LumiItem(ProcessHistoryID const& phid, RunNumber_t const& run,
822  phid_(phid), run_(run), lumi_(lumi), firstEventEntry_(entry),
823  lastEventEntry_(entry == IndexIntoFile::invalidEntry ? IndexIntoFile::invalidEntry : entry + 1) {}
824  ProcessHistoryID phid_;
825  RunNumber_t run_;
827  IndexIntoFile::EntryNumber_t firstEventEntry_;
828  IndexIntoFile::EntryNumber_t lastEventEntry_;
829  };
830  struct LumiItemSortByRunLumi {
831  bool operator()(LumiItem const& a, LumiItem const& b) const {
832  return a.run_ < b.run_ || (!(b.run_ < a.run_) && a.lumi_ < b.lumi_);
833  }
834  };
835  struct LumiItemSortByRunLumiPhid {
836  bool operator()(LumiItem const& a, LumiItem const& b) const {
837  if(a.run_ < b.run_) return true;
838  if(b.run_ < a.run_) return false;
839  if(a.lumi_ < b.lumi_) return true;
840  if(b.lumi_ < a.lumi_) return false;
841  return a.phid_ < b.phid_;
842  }
843  };
844  }
845 
846  void
848  // This function is for backward compatibility.
849  // If reading a current format file, indexIntoFile_ is read from the input
850  // file and should always be there. Note that the algorithm below will work
851  // sometimes but often fail with the new format introduced in release 3_8_0.
852  // If it ever becomes necessary to rebuild IndexIntoFile from the new format,
853  // probably a separate function should be written to deal with the task.
854  // This is possible just not implemented yet.
855  assert(!fileFormatVersion().hasIndexIntoFile());
856 
857  typedef std::list<LumiItem> LumiList;
858  LumiList lumis; // (declare 1)
859 
860  typedef std::set<LuminosityBlockID> RunLumiSet;
861  RunLumiSet runLumiSet; // (declare 2)
862 
863  typedef std::list<RunItem> RunList;
864  RunList runs; // (declare 5)
865 
866  typedef std::set<RunNumber_t> RunSet;
867  RunSet runSet; // (declare 4)
868 
869  typedef std::set<RunItem, RunItemSortByRunPhid> RunItemSet;
870  RunItemSet runItemSet; // (declare 3)
871 
872  typedef std::map<RunNumber_t, ProcessHistoryID> PHIDMap;
873  PHIDMap phidMap;
874 
875  RunNumber_t prevRun = 0;
876  LuminosityBlockNumber_t prevLumi = 0;
877  ProcessHistoryID prevPhid;
878  bool iFirst = true;
879 
880  indexIntoFile_.unsortedEventNumbers().clear(); // should already be empty, just being careful
882 
883  // First, loop through the event tree.
884  while(eventTree_.next()) {
885  bool newRun = false;
886  bool newLumi = false;
889 
890  // Save the event numbers as we loop through the event auxiliary to avoid
891  // having to read through the event auxiliary again later. These event numbers
892  // are not actually used in this function, but could be needed elsewhere.
894 
895  ProcessHistoryID reducedPHID = processHistoryRegistry_->reducedProcessHistoryID(eventAux().processHistoryID());
896 
897  if(iFirst || prevPhid != reducedPHID || prevRun != eventAux().run()) {
898  iFirst = false;
899  newRun = newLumi = true;
900  } else if(prevLumi != eventAux().luminosityBlock()) {
901  newLumi = true;
902  }
903  prevPhid = reducedPHID;
904  prevRun = eventAux().run();
905  prevLumi = eventAux().luminosityBlock();
906  if(newLumi) {
907  lumis.emplace_back(reducedPHID,
908  eventAux().run(), eventAux().luminosityBlock(), eventTree_.entryNumber()); // (insert 1)
909  runLumiSet.insert(LuminosityBlockID(eventAux().run(), eventAux().luminosityBlock())); // (insert 2)
910  } else {
911  LumiItem& currentLumi = lumis.back();
912  assert(currentLumi.lastEventEntry_ == eventTree_.entryNumber());
913  ++currentLumi.lastEventEntry_;
914  }
915  if(newRun) {
916  // Insert run in list if it is not already there.
917  RunItem item(reducedPHID, eventAux().run());
918  if(runItemSet.insert(item).second) { // (check 3, insert 3)
919  runs.push_back(std::move(item)); // (insert 5)
920  runSet.insert(eventAux().run()); // (insert 4)
921  phidMap.insert(std::make_pair(eventAux().run(), reducedPHID));
922  }
923  }
924  }
925  // now clean up.
929 
930  // Loop over run entries and fill information.
931 
932  typedef std::map<RunNumber_t, IndexIntoFile::EntryNumber_t> RunMap;
933  RunMap runMap; // (declare 11)
934 
935  typedef std::vector<RunItem> RunVector;
936  RunVector emptyRuns; // (declare 12)
937 
938  if(runTree_.isValid()) {
939  while(runTree_.next()) {
940  // Note: adjacent duplicates will be skipped without an explicit check.
941 
942  std::shared_ptr<RunAuxiliary> runAux = fillRunAuxiliary();
943  ProcessHistoryID reducedPHID = processHistoryRegistry_->reducedProcessHistoryID(runAux->processHistoryID());
944 
945  if(runSet.insert(runAux->run()).second) { // (check 4, insert 4)
946  // This run was not associated with any events.
947  emptyRuns.emplace_back(reducedPHID, runAux->run()); // (insert 12)
948  }
949  runMap.insert(std::make_pair(runAux->run(), runTree_.entryNumber())); // (insert 11)
950  phidMap.insert(std::make_pair(runAux->run(), reducedPHID));
951  }
952  // now clean up.
954  }
955 
956  // Insert the ordered empty runs into the run list.
957  RunItemSortByRun runItemSortByRun;
958  stable_sort_all(emptyRuns, runItemSortByRun);
959 
960  RunList::iterator itRuns = runs.begin(), endRuns = runs.end();
961  for(auto const& emptyRun : emptyRuns) {
962  for(; itRuns != endRuns; ++itRuns) {
963  if(runItemSortByRun(emptyRun, *itRuns)) {
964  break;
965  }
966  }
967  runs.insert(itRuns, emptyRun);
968  }
969 
970  // Loop over luminosity block entries and fill information.
971 
972  typedef std::vector<LumiItem> LumiVector;
973  LumiVector emptyLumis; // (declare 7)
974 
975  typedef std::map<LuminosityBlockID, IndexIntoFile::EntryNumber_t> RunLumiMap;
976  RunLumiMap runLumiMap; // (declare 6)
977 
978  if(lumiTree_.isValid()) {
979  while(lumiTree_.next()) {
980  // Note: adjacent duplicates will be skipped without an explicit check.
981  std::shared_ptr<LuminosityBlockAuxiliary> lumiAux = fillLumiAuxiliary();
982  LuminosityBlockID lumiID = LuminosityBlockID(lumiAux->run(), lumiAux->luminosityBlock());
983  if(runLumiSet.insert(lumiID).second) { // (check 2, insert 2)
984  // This lumi was not associated with any events.
985  // Use the process history ID from the corresponding run. In cases of practical
986  // importance, this should be the correct process history ID, but it is possible
987  // to construct files where this is not the correct process history ID ...
988  PHIDMap::const_iterator iPhidMap = phidMap.find(lumiAux->run());
989  assert(iPhidMap != phidMap.end());
990  emptyLumis.emplace_back(iPhidMap->second, lumiAux->run(), lumiAux->luminosityBlock(), IndexIntoFile::invalidEntry); // (insert 7)
991  }
992  runLumiMap.insert(std::make_pair(lumiID, lumiTree_.entryNumber()));
993  }
994  // now clean up.
996  }
997 
998  // Insert the ordered empty lumis into the lumi list.
999  LumiItemSortByRunLumi lumiItemSortByRunLumi;
1000  stable_sort_all(emptyLumis, lumiItemSortByRunLumi);
1001 
1002  LumiList::iterator itLumis = lumis.begin(), endLumis = lumis.end();
1003  for(auto const& emptyLumi : emptyLumis) {
1004  for(; itLumis != endLumis; ++itLumis) {
1005  if(lumiItemSortByRunLumi(emptyLumi, *itLumis)) {
1006  break;
1007  }
1008  }
1009  lumis.insert(itLumis, emptyLumi);
1010  }
1011 
1012  // Create a map of RunItems that gives the order of first appearance in the list.
1013  // Also fill in the vector of process history IDs
1014  typedef std::map<RunItem, int, RunItemSortByRunPhid> RunCountMap;
1015  RunCountMap runCountMap; // Declare (17)
1016  std::vector<ProcessHistoryID>& phids = indexIntoFile_.setProcessHistoryIDs();
1017  assert(phids.empty());
1018  std::vector<IndexIntoFile::RunOrLumiEntry>& entries = indexIntoFile_.setRunOrLumiEntries();
1019  assert(entries.empty());
1020  int rcount = 0;
1021  for(auto& run : runs) {
1022  RunCountMap::const_iterator countMapItem = runCountMap.find(run);
1023  if(countMapItem == runCountMap.end()) {
1024  countMapItem = runCountMap.insert(std::make_pair(run, rcount)).first; // Insert (17)
1025  assert(countMapItem != runCountMap.end());
1026  ++rcount;
1027  }
1028  std::vector<ProcessHistoryID>::const_iterator phidItem = find_in_all(phids, run.phid_);
1029  if(phidItem == phids.end()) {
1030  phids.push_back(run.phid_);
1031  phidItem = phids.end() - 1;
1032  }
1033  entries.emplace_back(
1034  countMapItem->second, // use (17)
1036  runMap[run.run_], // use (11)
1037  phidItem - phids.begin(),
1038  run.run_,
1039  0U,
1042  }
1043 
1044  // Create a map of LumiItems that gives the order of first appearance in the list.
1045  typedef std::map<LumiItem, int, LumiItemSortByRunLumiPhid> LumiCountMap;
1046  LumiCountMap lumiCountMap; // Declare (19)
1047  int lcount = 0;
1048  for(auto& lumi : lumis) {
1049  RunCountMap::const_iterator runCountMapItem = runCountMap.find(RunItem(lumi.phid_, lumi.run_));
1050  assert(runCountMapItem != runCountMap.end());
1051  LumiCountMap::const_iterator countMapItem = lumiCountMap.find(lumi);
1052  if(countMapItem == lumiCountMap.end()) {
1053  countMapItem = lumiCountMap.insert(std::make_pair(lumi, lcount)).first; // Insert (17)
1054  assert(countMapItem != lumiCountMap.end());
1055  ++lcount;
1056  }
1057  std::vector<ProcessHistoryID>::const_iterator phidItem = find_in_all(phids, lumi.phid_);
1058  assert(phidItem != phids.end());
1059  entries.emplace_back(
1060  runCountMapItem->second,
1061  countMapItem->second,
1062  runLumiMap[LuminosityBlockID(lumi.run_, lumi.lumi_)],
1063  phidItem - phids.begin(),
1064  lumi.run_,
1065  lumi.lumi_,
1066  lumi.firstEventEntry_,
1067  lumi.lastEventEntry_);
1068  }
1069  stable_sort_all(entries);
1070  }
1071 
1072  void
1073  RootFile::validateFile(InputType inputType, bool usingGoToEvent) {
1074  if(!fid_.isValid()) {
1076  }
1077  if(!eventTree_.isValid()) {
1079  "'Events' tree is corrupted or not present\n" << "in the input file.\n";
1080  }
1081 
1082  if(fileFormatVersion().hasIndexIntoFile()) {
1083  if(runTree().entries() > 0) {
1084  assert(!indexIntoFile_.empty());
1085  }
1087  if(daqProvenanceHelper_) {
1088  std::vector<ProcessHistoryID>& phidVec = indexIntoFile_.setProcessHistoryIDs();
1089  for(auto& phid : phidVec) {
1090  phid = daqProvenanceHelper_->mapProcessHistoryID(phid);
1091  }
1092  }
1094  }
1095  }
1096  else {
1097  assert(indexIntoFile_.empty());
1099  }
1100 
1103  indexIntoFile_.setEventFinder(std::shared_ptr<IndexIntoFile::EventFinder>(std::make_shared<RootFileEventFinder>(eventTree_)));
1104  // We fill the event numbers explicitly if we need to find events in closed files,
1105  // such as for secondary files (or secondary sources) or if duplicate checking across files.
1106  bool needEventNumbers = false;
1107  bool needIndexesForDuplicateChecker = duplicateChecker_ && duplicateChecker_->checkingAllFiles() && !duplicateChecker_->checkDisabled();
1108  if(inputType != InputType::Primary || needIndexesForDuplicateChecker || usingGoToEvent) {
1109  needEventNumbers = true;
1110  }
1111  bool needEventEntries = false;
1112  if(inputType != InputType::Primary || !noEventSort_) {
1113  // We need event entries for sorting or for secondary files or sources.
1114  needEventEntries = true;
1115  }
1116  indexIntoFile_.fillEventNumbersOrEntries(needEventNumbers, needEventEntries);
1117  }
1118 
1119  void
1121  // Report file opened.
1122  std::string const label = "source";
1123  std::string moduleName = "PoolSource";
1124  filePtr_->inputFileOpened(
1125  logicalFile_,
1126  inputType,
1127  moduleName,
1128  label,
1129  fid_.fid(),
1131  }
1132 
1133  void
1135  // Just to play it safe, zero all pointers to objects in the InputFile to be closed.
1136  eventHistoryTree_ = nullptr;
1137  for(auto& treePointer : treePointers_) {
1138  treePointer->close();
1139  treePointer = nullptr;
1140  }
1141  filePtr_->Close();
1142  filePtr_.reset();
1143  }
1144 
1145  void
1148  // Already read.
1149  return;
1150  }
1152  EventAuxiliary *pEvAux = &eventAux_;
1154  } else {
1155  // for backward compatibility.
1157  EventAux *pEvAux = &eventAux;
1158  eventTree_.fillAux<EventAux>(pEvAux);
1159  conversion(eventAux, eventAux_);
1160  }
1162  }
1163 
1164  bool
1166  if(!eventTree_.current(entry)) {
1167  return false;
1168  }
1169  eventTree_.setEntryNumber(entry);
1171  return true;
1172  }
1173 
1174  void
1176  // We could consider doing delayed reading, but because we have to
1177  // store this History object in a different tree than the event
1178  // data tree, this is too hard to do in this first version.
1179 
1180  if(fileFormatVersion().eventHistoryBranch()) {
1181  // Lumi block number was not in EventID for the relevant releases.
1182  EventID id(eventAux().id().run(), 0, eventAux().id().event());
1183  if(eventProcessHistoryIter_->eventID() != id) {
1186  assert(eventProcessHistoryIter_->eventID() == id);
1187  }
1190  } else if(fileFormatVersion().eventHistoryTree()) {
1191  // for backward compatibility.
1192  History* pHistory = history_.get();
1193  TBranch* eventHistoryBranch = eventHistoryTree_->GetBranch(poolNames::eventHistoryBranchName().c_str());
1194  if(!eventHistoryBranch) {
1196  << "Failed to find history branch in event history tree.\n";
1197  }
1198  eventHistoryBranch->SetAddress(&pHistory);
1200  eventAux_.setProcessHistoryID(history_->processHistoryID());
1201  eventSelectionIDs_.swap(history_->eventSelectionIDs());
1202  branchListIndexes_.swap(history_->branchListIndexes());
1203  } else if(fileFormatVersion().noMetaDataTrees()) {
1204  // Current format
1206  TBranch* eventSelectionIDBranch = eventTree_.tree()->GetBranch(poolNames::eventSelectionsBranchName().c_str());
1207  assert(eventSelectionIDBranch != nullptr);
1208  eventTree_.fillBranchEntry(eventSelectionIDBranch, pESV);
1210  TBranch* branchListIndexesBranch = eventTree_.tree()->GetBranch(poolNames::branchListIndexesBranchName().c_str());
1211  assert(branchListIndexesBranch != nullptr);
1212  eventTree_.fillBranchEntry(branchListIndexesBranch, pBLI);
1213  }
1214  if(provenanceAdaptor_) {
1215  eventAux_.setProcessHistoryID(provenanceAdaptor_->convertID(eventAux().processHistoryID()));
1216  for(auto& esID : eventSelectionIDs_) {
1217  esID = provenanceAdaptor_->convertID(esID);
1218  }
1219  }
1220  if(daqProvenanceHelper_) {
1222  }
1224  // old format. branchListIndexes_ must be filled in from the ProvenanceAdaptor.
1225  provenanceAdaptor_->branchListIndexes(branchListIndexes_);
1226  }
1227  branchIDListHelper_->fixBranchListIndexes(branchListIndexes_);
1228  }
1229 
1230  std::shared_ptr<LuminosityBlockAuxiliary>
1232  auto lumiAuxiliary = std::make_shared<LuminosityBlockAuxiliary>();
1234  LuminosityBlockAuxiliary *pLumiAux = lumiAuxiliary.get();
1236  } else {
1237  LuminosityBlockAux lumiAux;
1238  LuminosityBlockAux *pLumiAux = &lumiAux;
1240  conversion(lumiAux, *lumiAuxiliary);
1241  }
1242  if(provenanceAdaptor_) {
1243  lumiAuxiliary->setProcessHistoryID(provenanceAdaptor_->convertID(lumiAuxiliary->processHistoryID()));
1244  }
1245  if(daqProvenanceHelper_) {
1246  lumiAuxiliary->setProcessHistoryID(daqProvenanceHelper_->mapProcessHistoryID(lumiAuxiliary->processHistoryID()));
1247  }
1248  if(lumiAuxiliary->luminosityBlock() == 0 && !fileFormatVersion().runsAndLumis()) {
1249  lumiAuxiliary->id() = LuminosityBlockID(RunNumber_t(1), LuminosityBlockNumber_t(1));
1250  }
1251  return lumiAuxiliary;
1252  }
1253 
1254  std::shared_ptr<RunAuxiliary>
1256  auto runAuxiliary = std::make_shared<RunAuxiliary>();
1258  RunAuxiliary *pRunAux = runAuxiliary.get();
1259  runTree_.fillAux<RunAuxiliary>(pRunAux);
1260  } else {
1261  RunAux runAux;
1262  RunAux *pRunAux = &runAux;
1263  runTree_.fillAux<RunAux>(pRunAux);
1264  conversion(runAux, *runAuxiliary);
1265  }
1266  if(provenanceAdaptor_) {
1267  runAuxiliary->setProcessHistoryID(provenanceAdaptor_->convertID(runAuxiliary->processHistoryID()));
1268  }
1269  if(daqProvenanceHelper_) {
1270  runAuxiliary->setProcessHistoryID(daqProvenanceHelper_->mapProcessHistoryID(runAuxiliary->processHistoryID()));
1271  }
1272  return runAuxiliary;
1273  }
1274 
1275  bool
1277  while(offset > 0 && indexIntoFileIter_ != indexIntoFileEnd_) {
1278 
1279  int phIndexOfSkippedEvent = IndexIntoFile::invalidIndex;
1280  RunNumber_t runOfSkippedEvent = IndexIntoFile::invalidRun;
1283 
1284  indexIntoFileIter_.skipEventForward(phIndexOfSkippedEvent,
1285  runOfSkippedEvent,
1286  lumiOfSkippedEvent,
1287  skippedEventEntry);
1288 
1289  // At the end of the file and there were no more events to skip
1290  if(skippedEventEntry == IndexIntoFile::invalidEntry) break;
1291 
1292  if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
1293  fillEventAuxiliary(skippedEventEntry);
1294  if(eventSkipperByID_->skipIt(runOfSkippedEvent, lumiOfSkippedEvent, eventAux_.id().event())) {
1295  continue;
1296  }
1297  }
1298  if(duplicateChecker_ &&
1299  !duplicateChecker_->checkDisabled() &&
1300  !duplicateChecker_->noDuplicatesInFile()) {
1301 
1302  fillEventAuxiliary(skippedEventEntry);
1303  if(duplicateChecker_->isDuplicateAndCheckActive(phIndexOfSkippedEvent,
1304  runOfSkippedEvent,
1305  lumiOfSkippedEvent,
1306  eventAux_.id().event(),
1307  file_)) {
1308  continue;
1309  }
1310  }
1311  --offset;
1312  }
1313 
1314  while(offset < 0) {
1315 
1316  if(duplicateChecker_) {
1317  duplicateChecker_->disable();
1318  }
1319 
1320  int phIndexOfEvent = IndexIntoFile::invalidIndex;
1324 
1325  indexIntoFileIter_.skipEventBackward(phIndexOfEvent,
1326  runOfEvent,
1327  lumiOfEvent,
1328  eventEntry);
1329 
1330  if(eventEntry == IndexIntoFile::invalidEntry) break;
1331 
1332  if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
1333  fillEventAuxiliary(eventEntry);
1334  if(eventSkipperByID_->skipIt(runOfEvent, lumiOfEvent, eventAux_.id().event())) {
1335  continue;
1336  }
1337  }
1338  ++offset;
1339  }
1341  }
1342 
1343  bool
1344  RootFile::goToEvent(EventID const& eventID) {
1345 
1347 
1348  if(duplicateChecker_) {
1349  duplicateChecker_->disable();
1350  }
1351 
1354 
1356  indexIntoFile_.findPosition(sortOrder, eventID.run(), eventID.luminosityBlock(), eventID.event());
1357 
1358  if(iter == indexIntoFile_.end(sortOrder)) {
1359  return false;
1360  }
1362  return true;
1363  }
1364 
1365  // readEvent() is responsible for creating, and setting up, the
1366  // EventPrincipal.
1367  //
1368  // 1. create an EventPrincipal with a unique EventID
1369  // 2. For each entry in the provenance, put in one ProductHolder,
1370  // holding the Provenance for the corresponding EDProduct.
1371  // 3. set up the the EventPrincipal to know about this ProductHolder.
1372  //
1373  // We do *not* create the EDProduct instance (the equivalent of reading
1374  // the branch containing this EDProduct. That will be done by the Delayed Reader,
1375  // when it is asked to do so.
1376  //
1377  void
1381  // read the event auxiliary if not alrady read.
1383 
1384  // read the event
1385  readCurrentEvent(principal);
1386 
1387  assert(eventAux().run() == indexIntoFileIter_.run() + forcedRunOffset_);
1388  assert(eventAux().luminosityBlock() == indexIntoFileIter_.lumi());
1389 
1390  // If this next assert shows up in performance profiling or significantly affects memory, then these three lines should be deleted.
1391  // The IndexIntoFile should guarantee that it never fails.
1393  ProcessHistoryID const& reducedPHID = processHistoryRegistry_->reducedProcessHistoryID(idToCheck);
1395 
1397  }
1398 
1399  // Reads event at the current entry in the event tree
1400  bool
1402  if(!eventTree_.current()) {
1403  return false;
1404  }
1406  if(!fileFormatVersion().lumiInEventID()) {
1407  //ugly, but will disappear when the backward compatibility is done with schema evolution.
1408  const_cast<EventID&>(eventAux_.id()).setLuminosityBlockNumber(eventAux_.oldLuminosityBlock());
1410  }
1411  fillEventHistory();
1413 
1414  // We're not done ... so prepare the EventPrincipal
1416  principal.fillEventPrincipal(eventAux(),
1418  std::move(eventSelectionIDs_),
1419  std::move(branchListIndexes_),
1420  *(makeProductProvenanceRetriever(principal.streamID().value())),
1422 
1423  // report event read from file
1424  filePtr_->eventReadFromFile();
1425  return true;
1426  }
1427 
1428  void
1430  eventTree_.setEntryNumber(entry);
1431  }
1432 
1433  std::shared_ptr<RunAuxiliary>
1437 
1438  // Begin code for backward compatibility before the existence of run trees.
1439  if(!runTree_.isValid()) {
1440 
1441  // prior to the support of run trees.
1442  // RunAuxiliary did not contain a valid timestamp. Take it from the next event.
1444  assert(eventEntry != IndexIntoFile::invalidEntry);
1445  assert(eventTree_.current(eventEntry));
1446  fillEventAuxiliary(eventEntry);
1447 
1449  overrideRunNumber(run);
1450  return std::make_shared<RunAuxiliary>(run.run(), eventAux().time(), Timestamp::invalidTimestamp());
1451  }
1452  // End code for backward compatibility before the existence of run trees.
1454  std::shared_ptr<RunAuxiliary> runAuxiliary = fillRunAuxiliary();
1455  assert(runAuxiliary->run() == indexIntoFileIter_.run());
1456  overrideRunNumber(runAuxiliary->id());
1457  filePtr_->reportInputRunNumber(runAuxiliary->run());
1458  // If RunAuxiliary did not contain a valid begin timestamp, invalidate any end timestamp.
1459  if(runAuxiliary->beginTime() == Timestamp::invalidTimestamp()) {
1460  runAuxiliary->setEndTime(Timestamp::invalidTimestamp());
1461  }
1462 
1463  // If RunAuxiliary did not contain a valid timestamp, or if this an old format file from
1464  // when the Run's ProcessHistory included only processes where products were added to the Run itself,
1465  // we attempt to read the first event in the run to get appropriate info.
1466  if(runAuxiliary->beginTime() == Timestamp::invalidTimestamp() ||
1468 
1470  // If we have a valid event, use its information.
1471  if(eventEntry != IndexIntoFile::invalidEntry) {
1472  assert(eventTree_.current(eventEntry));
1473  fillEventAuxiliary(eventEntry);
1474 
1475  // RunAuxiliary did not contain a valid timestamp. Take it from the next event in this run if there is one.
1476  if(runAuxiliary->beginTime() == Timestamp::invalidTimestamp()) {
1477  runAuxiliary->setBeginTime(eventAux().time());
1478  }
1479 
1480  // For backwards compatibility when the Run's ProcessHistory included only processes where products were added to the
1481  // Run, and then the Run and Event auxiliaries could be different. Use the event ProcessHistoryID if there is one. It should
1482  // almost always be correct by the current definition (processes included if any products are added. This makes the run, lumi,
1483  // and event ProcessHistory's always be the same if no file merging occurs).
1484  if(!fileFormatVersion().processHistorySameWithinRun()) {
1485  fillEventHistory();
1486  runAuxiliary->setProcessHistoryID(eventAux().processHistoryID());
1487  savedRunAuxiliary_ = runAuxiliary;
1488  }
1489  } else {
1490  // No valid event, just use what is there, because it is the best we can do.
1491  savedRunAuxiliary_ = runAuxiliary;
1492  }
1493  }
1494  return runAuxiliary;
1495  }
1496 
1497  void
1501  // Begin code for backward compatibility before the existence of run trees.
1502  if(!runTree_.isValid()) {
1504  return;
1505  }
1506  // End code for backward compatibility before the existence of run trees.
1509  // Read in all the products now.
1510  runPrincipal.readImmediate();
1512  }
1513 
1514  std::shared_ptr<LuminosityBlockAuxiliary>
1518  // Begin code for backward compatibility before the existence of lumi trees.
1519  if(!lumiTree_.isValid()) {
1521  assert(eventEntry != IndexIntoFile::invalidEntry);
1522  assert(eventTree_.current(eventEntry));
1523  fillEventAuxiliary(eventEntry);
1524 
1526  overrideRunNumber(lumi);
1527  return std::make_shared<LuminosityBlockAuxiliary>(lumi.run(), lumi.luminosityBlock(), eventAux().time(), Timestamp::invalidTimestamp());
1528  }
1529  // End code for backward compatibility before the existence of lumi trees.
1531  std::shared_ptr<LuminosityBlockAuxiliary> lumiAuxiliary = fillLumiAuxiliary();
1532  assert(lumiAuxiliary->run() == indexIntoFileIter_.run());
1533  assert(lumiAuxiliary->luminosityBlock() == indexIntoFileIter_.lumi());
1534  overrideRunNumber(lumiAuxiliary->id());
1535  filePtr_->reportInputLumiSection(lumiAuxiliary->run(), lumiAuxiliary->luminosityBlock());
1536  if(lumiAuxiliary->beginTime() == Timestamp::invalidTimestamp()) {
1538  if(eventEntry != IndexIntoFile::invalidEntry) {
1539  assert(eventTree_.current(eventEntry));
1540  fillEventAuxiliary(eventEntry);
1541 
1542  lumiAuxiliary->setBeginTime(eventAux().time());
1543  }
1544  lumiAuxiliary->setEndTime(Timestamp::invalidTimestamp());
1545  }
1546  if(!fileFormatVersion().processHistorySameWithinRun() && savedRunAuxiliary_) {
1547  lumiAuxiliary->setProcessHistoryID(savedRunAuxiliary_->processHistoryID());
1548  }
1549  return lumiAuxiliary;
1550  }
1551 
1552  void
1556  // Begin code for backward compatibility before the existence of lumi trees.
1557  if(!lumiTree_.isValid()) {
1559  return;
1560  }
1561  // End code for backward compatibility before the existence of lumi trees.
1565  // Read in all the products now.
1566  lumiPrincipal.readImmediate();
1568  }
1569 
1570  bool
1573  if(indexIntoFileIter_ == indexIntoFileEnd_) return false;
1575  return true;
1576  }
1577 
1578  bool
1581  if(indexIntoFileIter_ == indexIntoFileEnd_) return false;
1583  return true;
1584  }
1585 
1586  bool
1589  if(indexIntoFileIter_ == indexIntoFileEnd_) return false;
1591  return true;
1592  }
1593 
1594  bool
1598  }
1601  if(run != indexIntoFileIter_.run()) return false;
1602  if(lumi != indexIntoFileIter_.lumi()) return false;
1604  return true;
1605  }
1606 
1607  void
1609  if(forcedRunOffset_ != 0) {
1610  id = RunID(id.run() + forcedRunOffset_);
1611  }
1612  if(id < RunID::firstValidRun()) id = RunID::firstValidRun();
1613  }
1614 
1615  void
1617  if(forcedRunOffset_ != 0) {
1618  id = LuminosityBlockID(id.run() + forcedRunOffset_, id.luminosityBlock());
1619  }
1620  if(RunID(id.run()) < RunID::firstValidRun()) id = LuminosityBlockID(RunID::firstValidRun().run(), id.luminosityBlock());
1621  }
1622 
1623  void
1624  RootFile::overrideRunNumber(EventID& id, bool isRealData) {
1625  if(forcedRunOffset_ != 0) {
1626  if(isRealData) {
1627  throw Exception(errors::Configuration, "RootFile::RootFile()")
1628  << "The 'setRunNumber' parameter of PoolSource cannot be used with real data.\n";
1629  }
1630  id = EventID(id.run() + forcedRunOffset_, id.luminosityBlock(), id.event());
1631  }
1632  if(RunID(id.run()) < RunID::firstValidRun()) {
1634  }
1635  }
1636 
1637 
1638  void
1640  // Read in the event history tree, if we have one...
1641  if(fileFormatVersion().eventHistoryTree()) {
1642  history_.reset(new History);
1643  eventHistoryTree_ = dynamic_cast<TTree*>(filePtr_->Get(poolNames::eventHistoryTreeName().c_str()));
1644  if(!eventHistoryTree_) {
1646  << "Failed to find the event history tree.\n";
1647  }
1648  }
1649  }
1650 
1651  void
1653  std::vector<std::shared_ptr<IndexIntoFile> > const& indexesIntoFiles,
1654  std::vector<std::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile) {
1655  if(duplicateChecker_) {
1656  if(eventTree_.next()) {
1658  duplicateChecker_->inputFileOpened(eventAux().isRealData(),
1660  indexesIntoFiles,
1661  currentIndexIntoFile);
1662  }
1664  }
1665  }
1666 
1667  void
1668  RootFile::dropOnInput (ProductRegistry& reg, ProductSelectorRules const& rules, bool dropDescendants, InputType inputType) {
1669  // This is the selector for drop on input.
1670  ProductSelector productSelector;
1671  productSelector.initialize(rules, reg.allBranchDescriptions());
1672 
1674  // Do drop on input. On the first pass, just fill in a set of branches to be dropped.
1675  std::set<BranchID> branchesToDrop;
1676  for(auto const& product : prodList) {
1677  BranchDescription const& prod = product.second;
1678  if(!productSelector.selected(prod)) {
1679  if(dropDescendants) {
1680  branchChildren_->appendToDescendants(prod.branchID(), branchesToDrop);
1681  } else {
1682  branchesToDrop.insert(prod.branchID());
1683  }
1684  }
1685  }
1686 
1687  // On this pass, actually drop the branches.
1688  std::set<BranchID>::const_iterator branchesToDropEnd = branchesToDrop.end();
1689  for(ProductRegistry::ProductList::iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd;) {
1690  BranchDescription const& prod = it->second;
1691  bool drop = branchesToDrop.find(prod.branchID()) != branchesToDropEnd;
1692  if(drop) {
1693  if(productSelector.selected(prod)) {
1694  LogWarning("RootFile")
1695  << "Branch '" << prod.branchName() << "' is being dropped from the input\n"
1696  << "of file '" << file_ << "' because it is dependent on a branch\n"
1697  << "that was explicitly dropped.\n";
1698  }
1699  treePointers_[prod.branchType()]->dropBranch(newBranchToOldBranch(prod.branchName()));
1700  hasNewlyDroppedBranch_[prod.branchType()] = true;
1701  ProductRegistry::ProductList::iterator icopy = it;
1702  ++it;
1703  prodList.erase(icopy);
1704  } else {
1705  ++it;
1706  }
1707  }
1708 
1709  // Drop on input mergeable run and lumi products, this needs to be invoked for secondary file input
1710  if(inputType == InputType::SecondaryFile) {
1711  TString tString;
1712  for(ProductRegistry::ProductList::iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd;) {
1713  BranchDescription const& prod = it->second;
1714  if(prod.branchType() != InEvent) {
1715  TClass* cp = gROOT->GetClass(prod.wrappedName().c_str());
1716  void* p = cp->New();
1717  int offset = cp->GetBaseClassOffset(edProductClass_);
1718  std::unique_ptr<WrapperBase> edp = getWrapperBasePtr(p, offset);
1719  if(edp->isMergeable()) {
1720  treePointers_[prod.branchType()]->dropBranch(newBranchToOldBranch(prod.branchName()));
1721  ProductRegistry::ProductList::iterator icopy = it;
1722  ++it;
1723  prodList.erase(icopy);
1724  } else {
1725  ++it;
1726  }
1727  }
1728  else ++it;
1729  }
1730  }
1731  }
1732 
1733  std::unique_ptr<MakeProvenanceReader>
1736  readParentageTree(inputType);
1737  return std::unique_ptr<MakeProvenanceReader>(new MakeReducedProvenanceReader(parentageIDLookup_));
1738  } else if(fileFormatVersion_.splitProductIDs()) {
1739  readParentageTree(inputType);
1740  return std::unique_ptr<MakeProvenanceReader>(new MakeFullProvenanceReader);
1741  } else if(fileFormatVersion_.perEventProductIDs()) {
1742  std::unique_ptr<EntryDescriptionMap> entryDescriptionMap(new EntryDescriptionMap);
1743  readEntryDescriptionTree(*entryDescriptionMap, inputType);
1744  return std::unique_ptr<MakeProvenanceReader>(new MakeOldProvenanceReader(std::move(entryDescriptionMap)));
1745  } else {
1746  return std::unique_ptr<MakeProvenanceReader>(new MakeDummyProvenanceReader);
1747  }
1748  }
1749 
1750  std::shared_ptr<ProductProvenanceRetriever>
1752  if(eventProductProvenanceRetrievers_.size()<=iStreamID) {
1753  eventProductProvenanceRetrievers_.resize(iStreamID+1);
1754  }
1755  if(!eventProductProvenanceRetrievers_[iStreamID]) {
1757  }
1758  eventProductProvenanceRetrievers_[iStreamID]->reset();
1759  return eventProductProvenanceRetrievers_[iStreamID];
1760  }
1761 
1763  public:
1764  ReducedProvenanceReader(RootTree* iRootTree, std::vector<ParentageID> const& iParentageIDLookup, DaqProvenanceHelper const* daqProvenanceHelper);
1765  private:
1766  virtual void readProvenance(ProductProvenanceRetriever const& provRetriever, unsigned int) const override;
1768  TBranch* provBranch_;
1771  std::vector<ParentageID> const& parentageIDLookup_;
1774  };
1775 
1777  RootTree* iRootTree,
1778  std::vector<ParentageID> const& iParentageIDLookup,
1779  DaqProvenanceHelper const* daqProvenanceHelper) :
1781  rootTree_(iRootTree),
1782  pProvVector_(&provVector_),
1783  parentageIDLookup_(iParentageIDLookup),
1784  daqProvenanceHelper_(daqProvenanceHelper),
1785  resourceAcquirer_(SharedResourcesRegistry::instance()->createAcquirerForSourceDelayedReader())
1786  {
1788  }
1789 
1790  void
1791  ReducedProvenanceReader::readProvenance(ProductProvenanceRetriever const& provRetriever, unsigned int transitionIndex) const {
1792  {
1793  std::lock_guard<SharedResourcesAcquirer> guard(resourceAcquirer_);
1794  ReducedProvenanceReader* me = const_cast<ReducedProvenanceReader*>(this);
1795  me->rootTree_->fillBranchEntry(me->provBranch_, me->rootTree_->entryNumberForIndex(transitionIndex), me->pProvVector_);
1796  setRefCoreStreamer(true);
1797  }
1798  if(daqProvenanceHelper_) {
1799  for(auto const& prov : provVector_) {
1800  BranchID bid(prov.branchID_);
1802  daqProvenanceHelper_->mapParentageID(parentageIDLookup_[prov.parentageIDIndex_])));
1803  }
1804  } else {
1805  for(auto const& prov : provVector_) {
1806  if(prov.parentageIDIndex_ >= parentageIDLookup_.size()) {
1808  << "ReducedProvenanceReader::ReadProvenance\n"
1809  << "The parentage ID index value " << prov.parentageIDIndex_ << " is out of bounds. The maximum value is " << parentageIDLookup_.size()-1 << ".\n"
1810  << "This should never happen.\n"
1811  << "Please report this to the framework hypernews forum 'hn-cms-edmFramework@cern.ch'.\n";
1812  }
1813  provRetriever.insertIntoSet(ProductProvenance(BranchID(prov.branchID_), parentageIDLookup_[prov.parentageIDIndex_]));
1814  }
1815  }
1816  }
1817 
1819  public:
1820  explicit FullProvenanceReader(RootTree* rootTree, DaqProvenanceHelper const* daqProvenanceHelper);
1822  private:
1823  virtual void readProvenance(ProductProvenanceRetriever const& provRetriever, unsigned int transitionIndex) const override;
1829  };
1830 
1833  rootTree_(rootTree),
1834  infoVector_(),
1835  pInfoVector_(&infoVector_),
1836  daqProvenanceHelper_(daqProvenanceHelper),
1837  resourceAcquirer_(SharedResourcesRegistry::instance()->createAcquirerForSourceDelayedReader()) {
1838  }
1839 
1840  void
1841  FullProvenanceReader::readProvenance(ProductProvenanceRetriever const& provRetriever, unsigned int transitionIndex) const {
1842  {
1843  std::lock_guard<SharedResourcesAcquirer> guard(resourceAcquirer_);
1845  setRefCoreStreamer(true);
1846  }
1847  if(daqProvenanceHelper_) {
1848  for(auto const& info : infoVector_) {
1850  daqProvenanceHelper_->mapParentageID(info.parentageID())));
1851  }
1852  } else {
1853  for(auto const& info : infoVector_) {
1854  provRetriever.insertIntoSet(info);
1855  }
1856  }
1857  }
1858 
1860  public:
1861  explicit OldProvenanceReader(RootTree* rootTree, EntryDescriptionMap const& theMap, DaqProvenanceHelper const* daqProvenanceHelper);
1863  private:
1864  virtual void readProvenance(ProductProvenanceRetriever const& provRetriever, unsigned int transitionIndex) const override;
1866  std::vector<EventEntryInfo> infoVector_;
1867  mutable std::vector<EventEntryInfo> *pInfoVector_;
1871  };
1872 
1873  OldProvenanceReader::OldProvenanceReader(RootTree* rootTree, EntryDescriptionMap const& theMap, DaqProvenanceHelper const* daqProvenanceHelper) :
1875  rootTree_(rootTree),
1876  infoVector_(),
1877  pInfoVector_(&infoVector_),
1878  entryDescriptionMap_(theMap),
1879  daqProvenanceHelper_(daqProvenanceHelper),
1880  resourceAcquirer_(SharedResourcesRegistry::instance()->createAcquirerForSourceDelayedReader()) {
1881  }
1882 
1883  void
1884  OldProvenanceReader::readProvenance(ProductProvenanceRetriever const& provRetriever, unsigned int transitionIndex) const {
1885  {
1886  std::lock_guard<SharedResourcesAcquirer> guard(resourceAcquirer_);
1887  rootTree_->branchEntryInfoBranch()->SetAddress(&pInfoVector_);
1889  setRefCoreStreamer(true);
1890  }
1891  for(auto const& info : infoVector_) {
1892  EntryDescriptionMap::const_iterator iter = entryDescriptionMap_.find(info.entryDescriptionID());
1893  assert(iter != entryDescriptionMap_.end());
1894  Parentage parentage(iter->second.parents());
1895  if(daqProvenanceHelper_) {
1897  daqProvenanceHelper_->mapParentageID(parentage.id()));
1898  provRetriever.insertIntoSet(entry);
1899  } else {
1900  ProductProvenance entry(info.branchID(), parentage.id());
1901  provRetriever.insertIntoSet(entry);
1902  }
1903 
1904  }
1905  }
1906 
1908  public:
1911  private:
1912  virtual void readProvenance(ProductProvenanceRetriever const& provRetriever,unsigned int) const override;
1913  };
1914 
1917  }
1918 
1919  void
1921  // Not providing parentage!!!
1922  }
1923 
1924  std::unique_ptr<ProvenanceReaderBase>
1926  return std::unique_ptr<ProvenanceReaderBase>(new DummyProvenanceReader);
1927  }
1928 
1929  std::unique_ptr<ProvenanceReaderBase>
1930  MakeOldProvenanceReader::makeReader(RootTree& rootTree, DaqProvenanceHelper const* daqProvenanceHelper) const {
1931  return std::unique_ptr<ProvenanceReaderBase>(new OldProvenanceReader(&rootTree, *entryDescriptionMap_, daqProvenanceHelper));
1932  }
1933 
1934  std::unique_ptr<ProvenanceReaderBase>
1935  MakeFullProvenanceReader::makeReader(RootTree& rootTree, DaqProvenanceHelper const* daqProvenanceHelper) const {
1936  return std::unique_ptr<ProvenanceReaderBase>(new FullProvenanceReader(&rootTree, daqProvenanceHelper));
1937  }
1938 
1939  std::unique_ptr<ProvenanceReaderBase>
1940  MakeReducedProvenanceReader::makeReader(RootTree& rootTree, DaqProvenanceHelper const* daqProvenanceHelper) const {
1941  return std::unique_ptr<ProvenanceReaderBase>(new ReducedProvenanceReader(&rootTree, parentageIDLookup_, daqProvenanceHelper));
1942  }
1943 }
void dropOnInput(ProductRegistry &reg, ProductSelectorRules const &rules, bool dropDescendants, InputType inputType)
Definition: RootFile.cc:1668
RunNumber_t run() const
Definition: EventID.h:39
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:461
void fillEventNumbersOrEntries(bool needEventNumbers, bool needEventEntries) const
virtual void readProvenance(ProductProvenanceRetriever const &provRetriever, unsigned int) const override
Definition: RootFile.cc:1791
void setID(ParameterSetID const &id)
EventNumber_t event() const
Definition: EventID.h:41
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:249
std::unique_ptr< ProvenanceAdaptor > provenanceAdaptor_
Definition: RootFile.h:216
std::vector< ProcessConfiguration > ProcessConfigurationVector
void setEventFinder(std::shared_ptr< EventFinder > ptr) const
int i
Definition: DBlmapReader.cc:9
std::string const & branchName() const
StoredProductProvenanceVector provVector_
Definition: RootFile.cc:1769
bool isRealData() const
bool selected(BranchDescription const &desc) const
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, RunNumber_t const &forcedRunNumber, bool noEventSort, ProductSelectorRules const &productSelectorRules, InputType inputType, std::shared_ptr< BranchIDListHelper > branchIDListHelper, 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)
Definition: RootFile.cc:138
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:114
unsigned int const defaultNonEventLearningEntries
Definition: RootTree.h:40
std::unique_ptr< History > history_
Definition: RootFile.h:213
InputType
Definition: InputType.h:5
static const TGPicture * info(bool iBackgroundIsBlack)
void doneFileInitialization() const
Clears the temporary vector of event numbers to reduce memory usage.
static int const invalidIndex
TPRegexp parents
Definition: eve_filter.cc:24
BranchType const & branchType() const
std::string const & parentageTreeName()
Definition: BranchType.cc:158
static LuminosityBlockID firstValidLuminosityBlock()
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
std::shared_ptr< BranchIDLists const > branchIDLists_
Definition: RootFile.h:205
std::string const & entryDescriptionBranchName()
Definition: BranchType.cc:153
bool skipEvents(int &offset)
Definition: RootFile.cc:1276
FileFormatVersion fileFormatVersion() const
Definition: RootFile.h:111
std::shared_ptr< LuminosityBlockAuxiliary > fillLumiAuxiliary()
Definition: RootFile.cc:1231
ProductProvenanceVector infoVector_
Definition: RootFile.cc:1825
static std::string const source("source")
static Timestamp invalidTimestamp()
Definition: Timestamp.h:101
ForwardSequence::const_iterator lower_bound_all(ForwardSequence const &s, Datum const &d)
wrappers for std::lower_bound
Definition: Algorithms.h:91
void readEntryDescriptionTree(EntryDescriptionMap &entryDescriptionMap, InputType inputType)
Definition: RootFile.cc:501
bool branchListIndexesUnchanged() const
Definition: RootFile.h:114
RunNumber_t run() const
Definition: RunID.h:39
std::vector< std::string > const & branchNames() const
Definition: RootTree.h:98
bool setEntryAtNextEventInLumi(RunNumber_t run, LuminosityBlockNumber_t lumi)
Definition: RootFile.cc:1595
StoredProductProvenanceVector * pProvVector_
Definition: RootFile.cc:1770
unsigned int EventNumber_t
Definition: EventRange.h:30
static PFTauRenderPlugin instance
MakeOldProvenanceReader(std::unique_ptr< EntryDescriptionMap > &&entryDescriptionMap)
Definition: RootFile.cc:67
int whyNotFastClonable_
Definition: RootFile.h:195
std::vector< BranchID > & parentsForUpdate()
Definition: Parentage.h:38
ParentageID id() const
Definition: Parentage.cc:19
DaqProvenanceHelper const * daqProvenanceHelper_
Definition: RootFile.cc:1827
tuple lumi
Definition: fjr2json.py:35
std::map< std::string, std::string > newBranchToOldBranch_
Definition: RootFile.h:209
EntryNumber_t firstEventEntryThisRun() const
bool empty() const
True if no runs, lumis, or events are in the file.
std::map< BranchKey, BranchDescription > ProductList
BranchID const & mapBranchID(BranchID const &branchID) const
#define nullptr
bool registerProcessHistory(ProcessHistory const &processHistory)
bool setEntryAtRun(RunNumber_t run)
Definition: RootFile.cc:1587
void readRun_(RunPrincipal &runPrincipal)
Definition: RootFile.cc:1498
ProductProvenanceVector * pInfoVector_
Definition: RootFile.cc:1826
RootTree lumiTree_
Definition: RootFile.h:200
Timestamp const & time() const
virtual std::unique_ptr< ProvenanceReaderBase > makeReader(RootTree &eventTree, DaqProvenanceHelper const *daqProvenanceHelper) const override
Definition: RootFile.cc:1930
std::unique_ptr< MakeProvenanceReader > provenanceReaderMaker_
Definition: RootFile.h:217
EntryNumber const & entries() const
Definition: RootTree.h:95
RunNumber_t run() const
void setRefCoreStreamer(bool resetAll=false)
processConfiguration
Definition: Schedule.cc:368
std::string const & fileFormatVersionBranchName()
Definition: BranchType.cc:212
IndexIntoFileItr begin(SortOrder sortOrder) const
FullProvenanceReader(RootTree *rootTree, DaqProvenanceHelper const *daqProvenanceHelper)
Definition: RootFile.cc:1831
EntryDescriptionMap const & entryDescriptionMap_
Definition: RootFile.cc:1868
std::vector< BranchID > const & parents() const
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:237
InputSource::ProcessingMode processingMode_
Definition: RootFile.h:207
TClass * edProductClass_
Definition: RootFile.h:221
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
Definition: RootFile.h:189
bool current() const
Definition: RootTree.h:89
virtual std::unique_ptr< ProvenanceReaderBase > makeReader(RootTree &eventTree, DaqProvenanceHelper const *daqProvenanceHelper) const override
Definition: RootFile.cc:1925
void fillRunPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
Definition: RunPrincipal.cc:21
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:135
static RunID firstValidRun()
Definition: RunID.h:77
LuminosityBlockNumber_t lumi() const
void fillBranchEntryMeta(TBranch *branch, T *&pbuf)
Definition: RootTree.h:106
std::unique_ptr< FileBlock > createFileBlock() const
Definition: RootFile.cc:637
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
void trainCache(char const *branchNames)
Definition: RootTree.cc:430
bool readCurrentEvent(EventPrincipal &cache)
Definition: RootFile.cc:1401
virtual void readProvenance(ProductProvenanceRetriever const &provRetriever, unsigned int) const override
Definition: RootFile.cc:1920
virtual std::unique_ptr< ProvenanceReaderBase > makeReader(RootTree &eventTree, DaqProvenanceHelper const *daqProvenanceHelper) const override
Definition: RootFile.cc:1935
std::shared_ptr< ProductRegistry const > productRegistry() const
Definition: RootFile.h:100
uint16_t size_type
unsigned int LuminosityBlockNumber_t
virtual ~OldProvenanceReader()
Definition: RootFile.cc:1862
IndexIntoFileItr findRunPosition(RunNumber_t run) const
Same as findPosition.
TBranch * branchEntryInfoBranch() const
Definition: RootTree.h:145
long long EntryNumber_t
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
void readImmediate() const
Definition: RunPrincipal.cc:51
bool fillEventAuxiliary(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1165
MakeReducedProvenanceReader(std::vector< ParentageID > const &parentageIDLookup)
Definition: RootFile.cc:78
virtual ~DummyProvenanceReader()
Definition: RootFile.cc:1910
IndexIntoFileItr findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
std::vector< EventSelectionID > EventSelectionIDVector
LuminosityBlockNumber_t luminosityBlock() const
FileFormatVersion fileFormatVersion_
Definition: RootFile.h:182
TTree const * metaTree() const
Definition: RootTree.h:141
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:245
void setPosition(IndexIntoFile::IndexIntoFileItr const &position)
Definition: RootFile.cc:668
tuple runs
Definition: gather_cfg.py:87
ProductList const & productList() const
U second(std::pair< T, U > const &p)
std::vector< EventProcessHistoryID >::const_iterator eventProcessHistoryIter_
Definition: RootFile.h:191
virtual void readProvenance(ProductProvenanceRetriever const &provRetriever, unsigned int transitionIndex) const override
Definition: RootFile.cc:1841
void reduceProcessHistoryIDs(ProcessHistoryRegistry const &processHistoryRegistry)
bool skipThisEntry()
Definition: RootFile.cc:673
TTree const * tree() const
Definition: RootTree.h:139
FileID fid_
Definition: RootFile.h:183
bool containsItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: RootFile.cc:728
virtual void readProvenance(ProductProvenanceRetriever const &provRetriever, unsigned int transitionIndex) const override
Definition: RootFile.cc:1884
void setParents(std::vector< BranchID > const &parents)
Definition: Parentage.h:39
DaqProvenanceHelper const * daqProvenanceHelper_
Definition: RootFile.cc:1772
std::string const logicalFile_
Definition: RootFile.h:177
std::vector< BranchListIndex > BranchListIndexes
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
Definition: RootFile.h:188
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
void fillLuminosityBlockPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
void readParentageTree(InputType inputType)
Definition: RootFile.cc:547
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:192
std::vector< ProcessHistoryID > & setProcessHistoryIDs()
bool next()
Definition: RootTree.h:87
bool noEventSort_
Definition: RootFile.h:194
std::string const & className() const
std::unique_ptr< EntryDescriptionMap > entryDescriptionMap_
Definition: RootFile.cc:70
bool wasLastEventJustRead() const
Definition: RootFile.cc:778
void insertEntryForIndex(unsigned int index)
Definition: RootTree.cc:98
virtual std::unique_ptr< ProvenanceReaderBase > makeReader(RootTree &eventTree, DaqProvenanceHelper const *daqProvenanceHelper) const override
Definition: RootFile.cc:1940
bool setEntryAtLumi(RunNumber_t run, LuminosityBlockNumber_t lumi)
Definition: RootFile.cc:1579
std::string friendlyName(std::string const &iFullName)
static RunNumber_t const invalidRun
std::string const & entryDescriptionTreeName()
Definition: BranchType.cc:145
void close()
Definition: RootFile.cc:1134
std::string const & fid() const
Definition: FileID.h:19
RootTree const & runTree() const
Definition: RootFile.h:110
bool modifiedIDs() const
Definition: RootFile.h:115
IndexIntoFile::EntryNumber_t lastEventEntryNumberRead_
Definition: RootFile.h:203
std::shared_ptr< BranchIDListHelper > branchIDListHelper_
Definition: RootFile.h:206
void copyPosition(IndexIntoFileItr const &position)
Copy the position without modifying the pointer to the IndexIntoFile or size.
std::string const & indexIntoFileBranchName()
Definition: BranchType.cc:227
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:232
void skipEventBackward(int &phIndexOfEvent, RunNumber_t &runOfEvent, LuminosityBlockNumber_t &lumiOfEvent, EntryNumber_t &eventEntry)
Long64_t numEntries(TFile *hdl, std::string const &trname)
Definition: CollUtil.cc:50
std::shared_ptr< RunAuxiliary > readRunAuxiliary_()
Definition: RootFile.cc:1434
EventAuxiliary const & eventAux() const
Definition: RootFile.h:103
EventSelectionIDVector eventSelectionIDs_
Definition: RootFile.h:211
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_()
Definition: RootFile.cc:1515
bool eventHistoryTree() const
bool isEarlierRelease(std::string const &a, std::string const &b)
int whyNotFastClonable() const
Definition: RootFile.h:112
StreamID streamID() const
BranchType branchType() const
Definition: RootTree.h:153
RunNumber_t run() const
std::shared_ptr< RunAuxiliary > fillRunAuxiliary()
Definition: RootFile.cc:1255
bool skipAnyEvents_
Definition: RootFile.h:193
std::vector< std::shared_ptr< ProductProvenanceRetriever > > eventProductProvenanceRetrievers_
Definition: RootFile.h:218
RootTree eventTree_
Definition: RootFile.h:199
std::vector< BranchDescription const * > allBranchDescriptions() const
std::map< ParameterSetID, ParameterSetID > ParameterSetIdConverter
bool isValid() const
Definition: FileID.h:18
bool iterationWillBeInEntryOrder(SortOrder sortOrder) const
Used to determine whether or not to disable fast cloning.
std::string const & friendlyClassName() const
BranchID const & branchID() const
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
std::array< bool, NumBranchTypes > const & hasNewlyDroppedBranch() const
Definition: RootFile.h:113
IndexIntoFile::EntryType getNextItemType(RunNumber_t &run, LuminosityBlockNumber_t &lumi, EventNumber_t &event)
Definition: RootFile.cc:733
BranchListIndexes branchListIndexes_
Definition: RootFile.h:212
std::string const & metaDataTreeName()
Definition: BranchType.cc:167
bool isDuplicateEvent()
Definition: RootFile.cc:717
LuminosityBlockNumber_t oldLuminosityBlock() const
EntryDescriptionID id() const
unsigned int offset(bool)
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
IndexIntoFile::EntryNumber_t EntryNumber
Definition: RootTree.h:41
bool wasFirstEventJustRead() const
Definition: RootFile.cc:785
std::string const & parameterSetMapBranchName()
Definition: BranchType.cc:182
Hash< ProcessHistoryType > ProcessHistoryID
std::vector< ProductProvenance > ProductProvenanceVector
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=nullptr)
const int drop
std::string const & processHistoryBranchName()
Definition: BranchType.cc:197
IndexIntoFile & indexIntoFile_
Definition: RootFile.h:185
virtual ~FullProvenanceReader()
Definition: RootFile.cc:1821
std::shared_ptr< InputFile > filePtr_
Definition: RootFile.h:180
void readEvent(EventPrincipal &cache)
Definition: RootFile.cc:1378
RootTree runTree_
Definition: RootFile.h:201
EntryNumber const & entryNumber() const
Definition: RootTree.h:93
bool containsItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
bool goToEvent(EventID const &eventID)
Definition: RootFile.cc:1344
std::string getReleaseVersion()
std::shared_ptr< EventSkipperByID > eventSkipperByID_
Definition: RootFile.h:181
void setAtEventEntry(IndexIntoFile::EntryNumber_t entry)
Definition: RootFile.cc:1429
bool storedProductProvenanceUsed() const
void fixIndexes(std::vector< ProcessHistoryID > &processHistoryIDs)
DelayedReader * rootDelayedReader() const
Definition: RootTree.cc:116
std::vector< RunOrLumiEntry > & setRunOrLumiEntries()
EntryNumber const & entryNumberForIndex(unsigned int index) const
Definition: RootTree.cc:92
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
std::array< bool, NumBranchTypes > hasNewlyDroppedBranch_
Definition: RootFile.h:196
std::vector< EventNumber_t > & unsortedEventNumbers() const
unsigned int value() const
Definition: StreamID.h:46
static EntryNumber_t const invalidEntry
SharedResourcesAcquirer resourceAcquirer_
Definition: RootFile.cc:1870
ForwardSequence::const_iterator find_in_all(ForwardSequence const &s, Datum const &d)
wrappers for std::find
Definition: Algorithms.h:32
std::shared_ptr< ProductRegistry const > productRegistry_
Definition: RootFile.h:204
void setIfFastClonable(int remainingEvents, int remainingLumis)
Definition: RootFile.cc:583
void fillBranchEntry(TBranch *branch, T *&pbuf)
Definition: RootTree.h:117
static LuminosityBlockNumber_t const invalidLumi
IndexIntoFileItr findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
std::map< EntryDescriptionID, EventEntryDescription > EntryDescriptionMap
Definition: RootFile.h:47
virtual EventNumber_t getEventNumberOfEntry(roottree::EntryNumber entry) const override
Definition: RootFile.cc:123
std::string const & parentageBranchName()
Definition: BranchType.cc:162
std::shared_ptr< BranchChildren > branchChildren_
Definition: RootFile.h:214
double b
Definition: hdecay.h:120
LuminosityBlockNumber_t luminosityBlock() const
bool processHistorySameWithinRun() const
void fillEventHistory()
Definition: RootFile.cc:1175
ProcessHistoryID const & processHistoryID(int i) const
ProductList & productListUpdator()
void setProcessHistoryID(ProcessHistoryID const &phid)
unsigned int transitionIndex() const
std::vector< ParentageID > const & parentageIDLookup_
Definition: RootFile.cc:1771
bool isValid() const
Definition: RootTree.cc:104
std::shared_ptr< ProductProvenanceRetriever > makeProductProvenanceRetriever(unsigned int iStreamIndex)
Definition: RootFile.cc:1751
std::vector< StoredProductProvenance > StoredProductProvenanceVector
std::string const & file() const
Definition: RootFile.h:99
std::string const & productDescriptionBranchName()
Definition: BranchType.cc:172
std::string const & processConfigurationBranchName()
Definition: BranchType.cc:202
IndexIntoFile::IndexIntoFileItr indexIntoFileBegin_
Definition: RootFile.h:187
EntryNumber_t firstEventEntryThisLumi() const
ProcessHistoryID const & processHistoryID() const
EventID const & id() const
std::unique_ptr< DaqProvenanceHelper > daqProvenanceHelper_
Definition: RootFile.h:220
bool branchListIndexesUnchanged_
Definition: RootFile.h:197
void fillIndexIntoFile()
Definition: RootFile.cc:847
#define begin
Definition: vmac.h:30
SharedResourcesAcquirer resourceAcquirer_
Definition: RootFile.cc:1828
void readLuminosityBlock_(LuminosityBlockPrincipal &lumiPrincipal)
Definition: RootFile.cc:1553
std::vector< EventEntryInfo > * pInfoVector_
Definition: RootFile.cc:1867
unsigned int const defaultNonEventCacheSize
Definition: RootTree.h:38
RootTreePtrArray treePointers_
Definition: RootFile.h:202
void fillEventNumbers() const
double a
Definition: hdecay.h:121
void initialize(ProductSelectorRules const &rules, std::vector< BranchDescription const * > const &branchDescriptions)
void initializeDuplicateChecker(std::vector< std::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< std::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile)
Definition: RootFile.cc:1652
std::shared_ptr< DuplicateChecker > duplicateChecker_
Definition: RootFile.h:215
bool perEventProductIDs() const
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
Definition: BranchType.cc:130
std::vector< ProcessHistoryID > & orderedProcessHistoryIDs_
Definition: RootFile.h:186
std::string const & productDependenciesBranchName()
Definition: BranchType.cc:177
void setNumberOfEvents(EntryNumber_t nevents) const
void overrideRunNumber(RunID &id)
Definition: RootFile.cc:1608
std::string const & entryDescriptionIDBranchName()
Definition: BranchType.cc:149
bool useReducedProcessHistoryID() const
std::unique_ptr< MakeProvenanceReader > makeProvenanceReaderMaker(InputType inputType)
Definition: RootFile.cc:1734
std::unique_ptr< WrapperBase > getWrapperBasePtr(void *p, int offset)
std::string const & branchIDListBranchName()
Definition: BranchType.cc:207
unsigned int RunNumber_t
Definition: EventRange.h:32
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:241
std::vector< ParentageID > parentageIDLookup_
Definition: RootFile.h:219
EventAuxiliary eventAux_
Definition: RootFile.h:198
void fillThisEventAuxiliary()
Definition: RootFile.cc:1146
void resetTraining()
Definition: RootTree.h:151
bool setEntryAtEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
Definition: RootFile.cc:1571
ProcessHistoryRegistry * processHistoryRegistry_
Definition: RootFile.h:179
volatile std::atomic< bool > shutdown_flag false
std::vector< ParentageID > const & parentageIDLookup_
Definition: RootFile.cc:81
ReducedProvenanceReader(RootTree *iRootTree, std::vector< ParentageID > const &iParentageIDLookup, DaqProvenanceHelper const *daqProvenanceHelper)
Definition: RootFile.cc:1776
std::string const & eventHistoryTreeName()
Definition: BranchType.cc:262
static Interceptor::Registry registry("Interceptor")
RootFileEventFinder(RootTree &eventTree)
Definition: RootFile.cc:120
ParentageID const & mapParentageID(ParentageID const &phid) const
void validateFile(InputType inputType, bool usingGoToEvent)
Definition: RootFile.cc:1073
bool insertMapped(value_type const &v)
Definition: Registry.cc:37
IndexIntoFile::IndexIntoFileItr indexIntoFileIter() const
Definition: RootFile.cc:663
std::string const & newBranchToOldBranch(std::string const &newBranch) const
Definition: RootFile.cc:654
std::unique_ptr< TTreeCache > trainCache(TTree *tree, InputFile &file, unsigned int cacheSize, char const *branchNames)
Definition: RootTree.cc:485
static ParentageRegistry * instance()
OldProvenanceReader(RootTree *rootTree, EntryDescriptionMap const &theMap, DaqProvenanceHelper const *daqProvenanceHelper)
Definition: RootFile.cc:1873
IndexIntoFileItr findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
unsigned int const defaultLearningEntries
Definition: RootTree.h:39
std::vector< EventEntryInfo > infoVector_
Definition: RootFile.cc:1866
TTree * eventHistoryTree_
Definition: RootFile.h:210
LuminosityBlockNumber_t peekAheadAtLumi() const
std::string const & fileIdentifierBranchName()
Definition: BranchType.cc:217
SharedResourcesAcquirer resourceAcquirer_
Definition: RootFile.cc:1773
std::shared_ptr< RunAuxiliary > savedRunAuxiliary_
Definition: RootFile.h:192
std::string const & wrappedName() const
virtual ~RootFileEventFinder()
Definition: RootFile.cc:121
EventNumber_t event() const
std::string const & moduleDescriptionMapBranchName()
Definition: BranchType.cc:187
bool insertMapped(value_type const &v)
std::string const file_
Definition: RootFile.h:176
void skipEventForward(int &phIndexOfSkippedEvent, RunNumber_t &runOfSkippedEvent, LuminosityBlockNumber_t &lumiOfSkippedEvent, EntryNumber_t &skippedEventEntry)
std::vector< EventProcessHistoryID > eventProcessHistoryIDs_
Definition: RootFile.h:190
static Registry * instance()
Definition: Registry.cc:14
DaqProvenanceHelper const * daqProvenanceHelper_
Definition: RootFile.cc:1869
std::string createGlobalIdentifier()
void copyProduct(BranchDescription const &productdesc)
void readEventHistoryTree()
Definition: RootFile.cc:1639
int forcedRunOffset_
Definition: RootFile.h:208
void fillAux(T *&pAux)
Definition: RootTree.h:101
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:190
void reportOpened(std::string const &inputType)
Definition: RootFile.cc:1120
void insertIntoSet(ProductProvenance const &provenanceProduct) const