CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RootSecondaryFileSequence.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
3 #include "DuplicateChecker.h"
4 #include "PoolSource.h"
5 #include "InputFile.h"
6 #include "RootFile.h"
8 #include "RootTree.h"
9 
19 
20 namespace edm {
22  ParameterSet const& pset,
25  unsigned int nStreams) :
26  RootInputFileSequence(pset, catalog),
27  input_(input),
28  firstFile_(true),
29  orderedProcessHistoryIDs_(),
30  nStreams_(nStreams),
31  // The default value provided as the second argument to the getUntrackedParameter function call
32  // is not used when the ParameterSet has been validated and the parameters are not optional
33  // in the description. This is currently true when PoolSource is the primary input source.
34  // The modules that use PoolSource as a SecSource have not defined their fillDescriptions function
35  // yet, so the ParameterSet does not get validated yet. As soon as all the modules with a SecSource
36  // have defined descriptions, the defaults in the getUntrackedParameterSet function calls can
37  // and should be deleted from the code.
38  skipBadFiles_(pset.getUntrackedParameter<bool>("skipBadFiles", false)),
39  bypassVersionCheck_(pset.getUntrackedParameter<bool>("bypassVersionCheck", false)),
40  treeMaxVirtualSize_(pset.getUntrackedParameter<int>("treeMaxVirtualSize", -1)),
41  setRun_(pset.getUntrackedParameter<unsigned int>("setRunNumber", 0U)),
42  productSelectorRules_(pset, "inputCommands", "InputSource"),
43  dropDescendants_(pset.getUntrackedParameter<bool>("dropDescendantsOfDroppedBranches", true)),
44  labelRawDataLikeMC_(pset.getUntrackedParameter<bool>("labelRawDataLikeMC", true)),
45  enablePrefetching_(false) {
46 
47  // The SiteLocalConfig controls the TTreeCache size and the prefetching settings.
49  if(pSLC.isAvailable()) {
50  enablePrefetching_ = pSLC->enablePrefetching();
51  }
52 
53  // Prestage the files
54  //NOTE: we do not want to stage in all secondary files since we can be given a list of
55  // thousands of files and prestaging all those files can cause a site to fail.
56  // So, we stage in the first secondary file only.
59 
60  // Open the first file.
63  if(rootFile()) break;
64  }
65  if(rootFile()) {
66  input_.productRegistryUpdate().updateFromInput(rootFile()->productRegistry()->productList());
67  }
68  }
69 
71  }
72 
73  void
75  closeFile_();
76  }
77 
78  void
80  // close the currently open file, if any, and delete the RootFile object.
81  if(rootFile()) {
82  rootFile()->close();
83  rootFile().reset();
84  }
85  }
86 
88  initTheFile(skipBadFiles, false, nullptr, "secondaryFiles", InputType::SecondaryFile);
89  }
90 
92  RootSecondaryFileSequence::makeRootFile(std::shared_ptr<InputFile> filePtr) {
93  size_t currentIndexIntoFile = sequenceNumberOfFile();
94  return std::make_shared<RootFile>(
95  fileName(),
98  filePtr,
99  nullptr, // eventSkipperByID_
100  false, // initialNumberOfEventsToSkip_ != 0
101  -1, // remainingEvents()
102  -1, // remainingLuminosityBlocks()
103  nStreams_,
104  0U, // treeCacheSize_
107  setRun_,
108  false, // noEventSort_
114  nullptr, //duplicateChecker_
118  currentIndexIntoFile,
122  false, // usingGoToEvent_
124  }
125 
126  void
127  RootSecondaryFileSequence::initAssociationsFromSecondary(std::set<BranchID> const& associationsFromSecondary) {
128  for(auto const& branchID : associationsFromSecondary) {
129  associationsFromSecondary_.push_back(branchID);
130  }
131  rootFile()->initAssociationsFromSecondary(associationsFromSecondary_);
132  }
133 }
std::string const & logicalFileName() const
void initFile(bool skipBadFiles)
void initAssociationsFromSecondary(std::set< BranchID > const &)
std::string const & fileName() const
RootSecondaryFileSequence(ParameterSet const &pset, PoolSource &input, InputFileCatalog const &catalog, unsigned int nStreams)
std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper() const
Accessor for thinnedAssociationsHelper.
Definition: InputSource.h:178
std::vector< std::shared_ptr< IndexIntoFile > > const & indexesIntoFiles() const
ProcessingMode processingMode() const
RunsLumisAndEvents (default), RunsAndLumis, or Runs.
Definition: InputSource.h:251
std::vector< BranchID > associationsFromSecondary_
static std::string const input
Definition: EdmProvDump.cc:43
std::shared_ptr< RootFile > RootFileSharedPtr
virtual void initFile_(bool skipBadFiles) override
static const StorageFactory * get(void)
void stagein(const std::string &url) const
std::shared_ptr< BranchIDListHelper > branchIDListHelper() const
Accessor for branchIDListHelper.
Definition: InputSource.h:175
void initTheFile(bool skipBadFiles, bool deleteIndexIntoFile, InputSource *input, char const *inputTypeName, InputType inputType)
RootFileSharedPtr const & rootFile() const
bool isAvailable() const
Definition: Service.h:46
virtual RootFileSharedPtr makeRootFile(std::shared_ptr< InputFile > filePtr) override
ProductRegistry & productRegistryUpdate() const
Definition: InputSource.h:345
tuple skipBadFiles
Definition: example_cfg.py:64
ProcessHistoryRegistry & processHistoryRegistryForUpdate() const
Definition: InputSource.h:346
void updateFromInput(ProductList const &other)
volatile std::atomic< bool > shutdown_flag false
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
ProcessConfiguration const & processConfiguration() const
Accessor for Process Configuration.
Definition: InputSource.h:209