Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:49:50

0001 #ifndef DataFormats_FWLite_interface_InputSource_h
0002 #define DataFormats_FWLite_interface_InputSource_h
0003 
0004 #include <vector>
0005 #include <string>
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 
0009 /**
0010   \class    InputSource InputSource.h "DataFormats/FWLite/interface/InputSource.h"
0011   \brief    Helper class to handle FWLite file input sources
0012 
0013   This is a very simple class to handle the appropriate python configuration of 
0014   input files in FWLite. 
0015 */
0016 
0017 namespace fwlite {
0018 
0019   class InputSource {
0020   public:
0021     /// empty constructor
0022     InputSource() { throw cms::Exception("InvalidInput") << "Must specify a vstring fileNames" << std::endl; }
0023     /// default constructor from parameter set
0024     InputSource(const edm::ParameterSet& cfg)
0025         : maxEvents_(-1),
0026           reportAfter_(10),
0027           files_(cfg.getParameterSet("fwliteInput").getParameter<std::vector<std::string> >("fileNames")) {
0028       // optional parameter
0029       if (cfg.getParameterSet("fwliteInput").existsAs<int>("maxEvents")) {
0030         maxEvents_ = cfg.getParameterSet("fwliteInput").getParameter<int>("maxEvents");
0031       }
0032       // optional parameter
0033       if (cfg.getParameterSet("fwliteInput").existsAs<unsigned int>("outputEvery")) {
0034         reportAfter_ = cfg.getParameterSet("fwliteInput").getParameter<unsigned int>("outputEvery");
0035       }
0036     }
0037     /// return vector of files_
0038     const std::vector<std::string>& files() const { return files_; }
0039     /// return maxEvetns_
0040     int maxEvents() const { return maxEvents_; }
0041     /// return reportAfter_
0042     unsigned int reportAfter() const { return reportAfter_; }
0043 
0044   protected:
0045     /// maximal number of events to loop
0046     int maxEvents_;
0047     /// report after N events
0048     unsigned int reportAfter_;
0049     /// vector of input files
0050     std::vector<std::string> files_;
0051   };
0052 }  // namespace fwlite
0053 
0054 #endif