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