CMS 3D CMS Logo

InputSource.h
Go to the documentation of this file.
1 #ifndef DataFormats_FWLite_interface_InputSource_h
2 #define DataFormats_FWLite_interface_InputSource_h
3 
4 #include <vector>
5 #include <string>
8 
17 namespace fwlite {
18 
19  class InputSource {
20 
21  public:
24  throw cms::Exception("InvalidInput") << "Must specify a vstring fileNames" << std::endl;
25  }
28  maxEvents_(-1), reportAfter_(10),
29  files_( cfg.getParameterSet("fwliteInput").getParameter<std::vector<std::string> >("fileNames") )
30  {
31  // optional parameter
32  if( cfg.getParameterSet("fwliteInput").existsAs<int>("maxEvents")){
33  maxEvents_ = cfg.getParameterSet("fwliteInput").getParameter<int>("maxEvents");
34  }
35  // optional parameter
36  if( cfg.getParameterSet("fwliteInput").existsAs<unsigned int>("outputEvery")){
37  reportAfter_ = cfg.getParameterSet("fwliteInput").getParameter<unsigned int>("outputEvery");
38  }
39  }
41  const std::vector<std::string>& files() const { return files_; }
43  int maxEvents() const { return maxEvents_; }
45  unsigned int reportAfter() const { return reportAfter_;}
46 
47  protected:
51  unsigned int reportAfter_;
53  std::vector<std::string> files_;
54  };
55 }
56 
57 #endif
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
InputSource(const edm::ParameterSet &cfg)
default constructor from parameter set
Definition: InputSource.h:27
ParameterSet const & getParameterSet(ParameterSetID const &id)
std::vector< std::string > files_
vector of input files
Definition: InputSource.h:53
unsigned int reportAfter_
report after N events
Definition: InputSource.h:51
InputSource()
empty constructor
Definition: InputSource.h:23
int maxEvents_
maximal number of events to loop
Definition: InputSource.h:49
ParameterSet const & getParameterSet(std::string const &) const
int maxEvents() const
return maxEvetns_
Definition: InputSource.h:43
const std::vector< std::string > & files() const
return vector of files_
Definition: InputSource.h:41
unsigned int reportAfter() const
return reportAfter_
Definition: InputSource.h:45