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