CMS 3D CMS Logo

GBRForestGetterFromDB.cc
Go to the documentation of this file.
1 #ifndef CalibratedElectronProducer_h
2 #define CalibratedElectronProducer_h
3 
4 #include <string>
14 #include <TFile.h>
15 
17 public:
18  explicit GBRForestGetterFromDB(const edm::ParameterSet &);
19  ~GBRForestGetterFromDB() override;
20  void analyze(const edm::Event &, const edm::EventSetup &) override;
21 
22 private:
27 };
28 
30  : theGBRForestName(conf.getParameter<std::string>("grbForestName")),
31  theOutputFileName(conf.getUntrackedParameter<std::string>("outputFileName")),
32  theOutputObjectName(conf.getUntrackedParameter<std::string>(
33  "outputObjectName", theGBRForestName.empty() ? "GBRForest" : theGBRForestName)),
34  theGBRForestToken_(esConsumes()) {}
35 
37 
39  auto theGBRForestHandle = iSetup.getHandle(theGBRForestToken_);
40  TFile *fOut = TFile::Open(theOutputFileName.c_str(), "RECREATE");
41  fOut->WriteObject(theGBRForestHandle.product(), theOutputObjectName.c_str());
42  fOut->Close();
43  edm::LogPrint("GBRForestGetterFromDB") << "Wrote output to " << theOutputFileName;
44 }
45 
48 
49 #endif
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int iEvent
Definition: GenABIO.cc:224
GBRForestGetterFromDB(const edm::ParameterSet &)
Log< level::Warning, true > LogPrint
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
edm::ESGetToken< GBRForest, GBRWrapperRcd > theGBRForestToken_
void analyze(const edm::Event &, const edm::EventSetup &) override