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 
54 
55  // Prestage the files
56  //NOTE: we do not want to stage in all secondary files since we can be given a list of
57  // thousands of files and prestaging all those files can cause a site to fail.
58  // So, we stage in the first secondary file only.
60  factory->activateTimeout(fileName());
61  factory->stagein(fileName());
62 
63  // Open the first file.
66  if(rootFile()) break;
67  }
68  if(rootFile()) {
69  input_.productRegistryUpdate().updateFromInput(rootFile()->productRegistry()->productList());
70  }
71  }
72 
74  }
75 
76  void
78  closeFile_();
79  }
80 
81  void
83  // close the currently open file, if any, and delete the RootFile object.
84  if(rootFile()) {
85  rootFile()->close();
86  rootFile().reset();
87  }
88  }
89 
91  initTheFile(skipBadFiles, false, nullptr, "secondaryFiles", InputType::SecondaryFile);
92  }
93 
95  RootSecondaryFileSequence::makeRootFile(std::shared_ptr<InputFile> filePtr) {
96  size_t currentIndexIntoFile = sequenceNumberOfFile();
97  return std::make_shared<RootFile>(
98  fileName(),
100  logicalFileName(),
101  filePtr,
102  nullptr, // eventSkipperByID_
103  false, // initialNumberOfEventsToSkip_ != 0
104  -1, // remainingEvents()
105  -1, // remainingLuminosityBlocks()
106  nStreams_,
107  0U, // treeCacheSize_
110  setRun_,
111  false, // noEventSort_
117  nullptr, //duplicateChecker_
121  currentIndexIntoFile,
125  false, // usingGoToEvent_
127  }
128 
129  void
130  RootSecondaryFileSequence::initAssociationsFromSecondary(std::set<BranchID> const& associationsFromSecondary) {
131  for(auto const& branchID : associationsFromSecondary) {
132  associationsFromSecondary_.push_back(branchID);
133  }
134  rootFile()->initAssociationsFromSecondary(associationsFromSecondary_);
135  }
136 }
std::string const & logicalFileName() const
void stagein(const std::string &url)
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
static StorageFactory * get(void)
std::shared_ptr< RootFile > RootFileSharedPtr
virtual void initFile_(bool skipBadFiles) override
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)
void activateTimeout(const std::string &url)
volatile std::atomic< bool > shutdown_flag false
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
ProcessConfiguration const & processConfiguration() const
Accessor for Process Configuration.
Definition: InputSource.h:209