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  methodName_ = cfg.getParameter<std::string>("methodName");
59  gbrForestName_ = ( cfg.existsAs<std::string>("gbrForestName") ? cfg.getParameter<std::string>("gbrForestName") : methodName_ );
60  }
61  else
62  gbrForestName_ = cfg.getParameter<std::string>("gbrForestName");
63  }
66  enum { kXML, kGBRForest };
72  };
73  struct jobEntryType
74  {
76  {
77  if ( cfg.exists("categories") ) {
78  edm::VParameterSet cfgCategories = cfg.getParameter<edm::VParameterSet>("categories");
79  for ( edm::VParameterSet::const_iterator cfgCategory = cfgCategories.begin();
80  cfgCategory != cfgCategories.end(); ++cfgCategory ) {
81  categoryEntryType* category = new categoryEntryType(*cfgCategory);
82  categories_.push_back(category);
83  }
84  } else {
86  categories_.push_back(category);
87  }
88  std::string outputFileType_string = cfg.getParameter<std::string>("outputFileType");
89  if ( outputFileType_string == "GBRForest" ) outputFileType_ = kGBRForest;
90  else if ( outputFileType_string == "SQLLite" ) outputFileType_ = kSQLLite;
91  else throw cms::Exception("GBRForestWriter")
92  << " Invalid Configuration Parameter 'outputFileType' = " << outputFileType_string << " !!\n";
93  if ( outputFileType_ == kGBRForest ) {
94  outputFileName_ = cfg.getParameter<std::string>("outputFileName");
95  }
96  if ( outputFileType_ == kSQLLite ) {
97  outputRecord_ = cfg.getParameter<std::string>("outputRecord");
98  }
99  }
101  {
102  for ( std::vector<categoryEntryType*>::iterator it = categories_.begin();
103  it != categories_.end(); ++it ) {
104  delete (*it);
105  }
106  }
107  std::vector<categoryEntryType*> categories_;
108  enum { kGBRForest, kSQLLite };
112  };
113  std::vector<jobEntryType*> jobs_;
114 };
115 
116 #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