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