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