CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GBRForestWriter.h
Go to the documentation of this file.
1 #ifndef RecoMET_METPUSubtraction_GBRForestWriter_h
2 #define RecoMET_METPUSubtraction_GBRForestWriter_h
3 
17 
18 #include <vector>
19 #include <string>
20 
22 {
23  public:
26 
27  private:
28  virtual void analyze(const edm::Event&, const edm::EventSetup&);
29 
31 
32  bool hasRun_;
33 
34  typedef std::vector<std::string> vstring;
35 
37  {
39  {
40  if ( cfg.existsAs<edm::FileInPath>("inputFileName") ) {
41  edm::FileInPath inputFileName_fip = cfg.getParameter<edm::FileInPath>("inputFileName");
42  if ( inputFileName_fip.location()!=edm::FileInPath::Local)
43  throw cms::Exception("GBRForestWriter")
44  << " Failed to find File = " << inputFileName_fip << " !!\n";
45  inputFileName_ = inputFileName_fip.fullPath();
46  } else if ( cfg.existsAs<std::string>("inputFileName") ) {
47  inputFileName_ = cfg.getParameter<std::string>("inputFileName");
48  } else throw cms::Exception("GBRForestWriter")
49  << " Undefined Configuration Parameter 'inputFileName !!\n";
50  std::string inputFileType_string = cfg.getParameter<std::string>("inputFileType");
51  if ( inputFileType_string == "XML" ) inputFileType_ = kXML;
52  else if ( inputFileType_string == "GBRForest" ) inputFileType_ = kGBRForest;
53  else throw cms::Exception("GBRForestWriter")
54  << " Invalid Configuration Parameter 'inputFileType' = " << inputFileType_string << " !!\n";
55  if ( inputFileType_ == kXML ) {
56  inputVariables_ = cfg.getParameter<vstring>("inputVariables");
57  spectatorVariables_ = cfg.getParameter<vstring>("spectatorVariables");
58  }
59  gbrForestName_ = cfg.getParameter<std::string>("gbrForestName");
60  }
63  enum { kXML, kGBRForest };
68  };
69  struct jobEntryType
70  {
72  {
73  if ( cfg.exists("categories") ) {
74  edm::VParameterSet cfgCategories = cfg.getParameter<edm::VParameterSet>("categories");
75  for ( edm::VParameterSet::const_iterator cfgCategory = cfgCategories.begin();
76  cfgCategory != cfgCategories.end(); ++cfgCategory ) {
77  categoryEntryType* category = new categoryEntryType(*cfgCategory);
78  categories_.push_back(category);
79  }
80  } else {
82  categories_.push_back(category);
83  }
84  std::string outputFileType_string = cfg.getParameter<std::string>("outputFileType");
85  if ( outputFileType_string == "GBRForest" ) outputFileType_ = kGBRForest;
86  else if ( outputFileType_string == "SQLLite" ) outputFileType_ = kSQLLite;
87  else throw cms::Exception("GBRForestWriter")
88  << " Invalid Configuration Parameter 'outputFileType' = " << outputFileType_string << " !!\n";
89  if ( outputFileType_ == kGBRForest ) {
90  outputFileName_ = cfg.getParameter<std::string>("outputFileName");
91  }
92  if ( outputFileType_ == kSQLLite ) {
93  outputRecord_ = cfg.getParameter<std::string>("outputRecord");
94  }
95  }
97  {
98  for ( std::vector<categoryEntryType*>::iterator it = categories_.begin();
99  it != categories_.end(); ++it ) {
100  delete (*it);
101  }
102  }
103  std::vector<categoryEntryType*> categories_;
104  enum { kGBRForest, kSQLLite };
108  };
109  std::vector<jobEntryType*> jobs_;
110 };
111 
112 #endif
T getParameter(std::string const &) const
tuple cfg
Definition: looper.py:259
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:185
categoryEntryType(const edm::ParameterSet &cfg)
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string moduleLabel_
GBRForestWriter(const edm::ParameterSet &)
std::vector< categoryEntryType * > categories_
jobEntryType(const edm::ParameterSet &cfg)
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:159
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< jobEntryType * > jobs_
std::vector< std::string > vstring
std::string fullPath() const
Definition: FileInPath.cc:165